- Dark theme page background is #5a5e60; text on it is lifted to zinc-200 / primary-100 and TallStackUI's dark labels, hints and checkbox labels are lightened so everything stays at 4.5:1. - Shared HexColor picks white or black text by the higher WCAG contrast; a native-dialog colour picker and a large work dialog component. - Customers get a header colour (customers.header_color), set on the customer page. - New job status Jatkuvat / Kausi (ongoing): open, never late, billed monthly like running jobs. - Kanban model: board columns and views, urgent threshold, per-user board preferences (density, column colours and sort), card positions, tasks of continuing jobs pinned to the board, MoveBoardCard and board queries with logged hours from TimeTracking. Co-Authored-By: Claude Opus 5.5 <[email protected]>
586 lines
27 KiB
PHP
586 lines
27 KiB
PHP
<?php
|
||
|
||
use App\Modules\Jobs\Application\Contracts\TaskQueries;
|
||
use App\Modules\Jobs\Application\DTOs\BookableTask;
|
||
use App\Modules\Shared\Domain\Exceptions\DomainException;
|
||
use App\Modules\TimeTracking\Application\Contracts\TimeEntryQueries;
|
||
use App\Modules\TimeTracking\Application\DTOs\WeekSheet;
|
||
use App\Modules\TimeTracking\Application\UseCases\ApproveWeek;
|
||
use App\Modules\TimeTracking\Application\UseCases\CancelWeekApproval;
|
||
use App\Modules\TimeTracking\Application\UseCases\SetDayHours;
|
||
use App\Modules\TimeTracking\Domain\Exceptions\DailyHoursExceeded;
|
||
use App\Modules\TimeTracking\Domain\Exceptions\InvalidWorkedHours;
|
||
use App\Modules\TimeTracking\Domain\Exceptions\TimeApproved;
|
||
use App\Modules\TimeTracking\Domain\Exceptions\TimeLocked;
|
||
use App\Modules\TimeTracking\Domain\ValueObjects\WorkedHours;
|
||
use App\Modules\Users\Application\Contracts\Clock;
|
||
use App\Modules\Users\Application\Contracts\UserAccountQueries;
|
||
use App\Modules\Users\Domain\Enums\Role;
|
||
use Carbon\CarbonImmutable;
|
||
use Illuminate\Support\Facades\Gate;
|
||
use Livewire\Attributes\Computed;
|
||
use Livewire\Attributes\Locked;
|
||
use Livewire\Attributes\Url;
|
||
use Livewire\Component;
|
||
|
||
/**
|
||
* The weekly time sheet: tasks as rows, days as columns. A cell saves when
|
||
* focus leaves it; an empty cell removes the day's entry. On a phone one
|
||
* day is shown at a time. Approved hours are locked. Management may open
|
||
* another user's week (?kayttaja=ID) to read, approve or cancel approval.
|
||
*/
|
||
new class extends Component
|
||
{
|
||
/**
|
||
* The Monday of the week shown (Y-m-d). Read from the URL on mount and
|
||
* then changed only by showWeek(), so the browser cannot set it.
|
||
*/
|
||
#[Locked]
|
||
#[Url(as: 'viikko', except: '')]
|
||
public string $week = '';
|
||
|
||
/**
|
||
* Another user's id from the URL, for management; '' is the signed-in user.
|
||
*/
|
||
#[Locked]
|
||
#[Url(as: 'kayttaja', except: '')]
|
||
public string $user = '';
|
||
|
||
#[Locked]
|
||
public int $viewedUserId = 0;
|
||
|
||
#[Locked]
|
||
public string $viewedUserName = '';
|
||
|
||
/**
|
||
* Stored hours as shown, by task id and day: [taskId => [Y-m-d => "2,5"]].
|
||
* The cells send their value with wire:change; the desktop grid and the
|
||
* phone list both have an input for the same cell.
|
||
*
|
||
* @var array<int|string, array<string, string>>
|
||
*/
|
||
#[Locked]
|
||
public array $cells = [];
|
||
|
||
/**
|
||
* Tasks added to this week by search, besides the user's own.
|
||
*
|
||
* @var list<int>
|
||
*/
|
||
#[Locked]
|
||
public array $extraTaskIds = [];
|
||
|
||
/**
|
||
* Values that were not saved, shown back in their cell with the error.
|
||
*
|
||
* @var array<string, string>
|
||
*/
|
||
#[Locked]
|
||
public array $rejected = [];
|
||
|
||
/**
|
||
* The day shown on phones; changed only by selectDay(), because it is
|
||
* written into element ids and wire:change calls.
|
||
*/
|
||
#[Locked]
|
||
public string $selectedDay = '';
|
||
|
||
public string $taskSearch = '';
|
||
|
||
public string $statusMessage = '';
|
||
|
||
public string $errorMessage = '';
|
||
|
||
public function mount(Clock $clock): void
|
||
{
|
||
$this->authorize('time.use');
|
||
|
||
$this->viewedUserId = (int) auth()->id();
|
||
|
||
if ($this->user !== '' && (int) $this->user !== $this->viewedUserId) {
|
||
$this->authorize('time.approve-others');
|
||
$summary = ctype_digit($this->user) ? app(UserAccountQueries::class)->findSummary((int) $this->user) : null;
|
||
|
||
abort_if($summary === null, 404);
|
||
|
||
$this->viewedUserId = $summary->id;
|
||
$this->viewedUserName = $summary->name;
|
||
} else {
|
||
$this->user = '';
|
||
}
|
||
|
||
$this->week = $this->mondayOf($this->week !== '' ? $this->week : $clock->today()->format('Y-m-d'));
|
||
$today = $clock->today()->format('Y-m-d');
|
||
$this->selectedDay = in_array($today, $this->sheet->days, true) ? $today : $this->week;
|
||
$this->loadCells();
|
||
}
|
||
|
||
#[Computed]
|
||
public function sheet(): WeekSheet
|
||
{
|
||
return app(TimeEntryQueries::class)->week($this->viewedUserId, $this->week, $this->extraTaskIds);
|
||
}
|
||
|
||
/**
|
||
* Whether management is looking at someone else's week: nothing can be typed then.
|
||
*/
|
||
public function isReadOnly(): bool
|
||
{
|
||
return $this->viewedUserId !== (int) auth()->id();
|
||
}
|
||
|
||
public function canApprove(): bool
|
||
{
|
||
return Gate::allows('time.approve', $this->viewedUserId);
|
||
}
|
||
|
||
public function approveWeek(ApproveWeek $approveWeek): void
|
||
{
|
||
$this->authorize('time.approve', $this->viewedUserId);
|
||
|
||
$count = $approveWeek->execute($this->viewedUserId, $this->week, (int) auth()->id());
|
||
|
||
unset($this->sheet);
|
||
$this->loadCells();
|
||
$this->rejected = [];
|
||
$this->resetErrorBag();
|
||
$this->errorMessage = '';
|
||
$this->statusMessage = $count === 0
|
||
? __('time.approval.nothing_to_approve')
|
||
: __('time.approval.approved', ['week' => $this->weekHeading()]);
|
||
}
|
||
|
||
public function confirmCancelApproval(): void
|
||
{
|
||
$this->authorize('time.cancel-approval');
|
||
|
||
$this->js("document.getElementById('cancel-approval-dialog').showModal()");
|
||
}
|
||
|
||
public function cancelApproval(CancelWeekApproval $cancelApproval): void
|
||
{
|
||
$this->authorize('time.cancel-approval');
|
||
|
||
$cancelApproval->execute($this->viewedUserId, $this->week);
|
||
|
||
unset($this->sheet);
|
||
$this->loadCells();
|
||
$this->statusMessage = __('time.approval.cancelled', ['week' => $this->weekHeading()]);
|
||
|
||
$this->js("document.getElementById('cancel-approval-dialog').close(); document.getElementById('approval-heading').focus()");
|
||
}
|
||
|
||
/**
|
||
* @return list<BookableTask>
|
||
*/
|
||
#[Computed]
|
||
public function searchResults(): array
|
||
{
|
||
$term = trim($this->taskSearch);
|
||
|
||
if (mb_strlen($term) < 2) {
|
||
return [];
|
||
}
|
||
|
||
$shown = array_map(fn ($row): int => $row->task->taskId, $this->sheet->rows);
|
||
|
||
return array_values(array_filter(
|
||
app(TaskQueries::class)->searchBookableTasks($term, $this->isSubcontractor() ? (int) auth()->id() : null),
|
||
fn (BookableTask $task): bool => ! in_array($task->taskId, $shown, true),
|
||
));
|
||
}
|
||
|
||
public function saveCell(int $taskId, string $day, string $value): void
|
||
{
|
||
$this->authorize('time.use');
|
||
|
||
$row = collect($this->sheet->rows)->first(fn ($row): bool => $row->task->taskId === $taskId);
|
||
|
||
if ($this->isReadOnly() || $row === null || ! in_array($day, $this->sheet->days, true)) {
|
||
return;
|
||
}
|
||
|
||
$this->authorize('time.book', $row->task->jobId);
|
||
$this->resetErrorBag("cells.{$taskId}.{$day}");
|
||
unset($this->rejected["{$taskId}.{$day}"]);
|
||
$this->errorMessage = '';
|
||
|
||
try {
|
||
app(SetDayHours::class)->execute((int) auth()->id(), $taskId, $day, $value);
|
||
} catch (DomainException $exception) {
|
||
$message = __(match (true) {
|
||
$exception instanceof InvalidWorkedHours => 'time.errors.invalid_hours',
|
||
$exception instanceof DailyHoursExceeded => 'time.errors.day_full',
|
||
$exception instanceof TimeLocked => 'time.errors.locked',
|
||
$exception instanceof TimeApproved => 'time.errors.approved',
|
||
default => 'time.errors.not_found',
|
||
});
|
||
$this->addError("cells.{$taskId}.{$day}", $message);
|
||
$this->errorMessage = $row->task->taskTitle.', '.$this->dayLabel($day).': '.$message;
|
||
$this->rejected["{$taskId}.{$day}"] = $value;
|
||
|
||
return;
|
||
}
|
||
|
||
unset($this->sheet);
|
||
$this->loadCells();
|
||
|
||
$hours = $this->cells[$taskId][$day] ?? '';
|
||
$this->statusMessage = $hours === ''
|
||
? __('time.removed', ['task' => $row->task->taskTitle, 'day' => $this->dayLabel($day)])
|
||
: __('time.saved', ['task' => $row->task->taskTitle, 'day' => $this->dayLabel($day), 'hours' => $hours]);
|
||
}
|
||
|
||
public function addTask(int $taskId): void
|
||
{
|
||
$this->authorize('time.use');
|
||
|
||
$task = app(TaskQueries::class)->bookableTask($taskId);
|
||
|
||
if ($this->isReadOnly() || $task === null || $task->isLocked() || Gate::denies('time.book', $task->jobId)) {
|
||
return;
|
||
}
|
||
|
||
if (! in_array($taskId, $this->extraTaskIds, true)) {
|
||
$this->extraTaskIds[] = $taskId;
|
||
}
|
||
|
||
$this->taskSearch = '';
|
||
unset($this->sheet);
|
||
$this->loadCells();
|
||
$this->statusMessage = __('time.add.added', ['task' => $task->label()]);
|
||
|
||
$this->js("(document.getElementById('cell-{$taskId}-{$this->selectedDay}')?.offsetParent ? document.getElementById('cell-{$taskId}-{$this->selectedDay}') : document.getElementById('mcell-{$taskId}-{$this->selectedDay}'))?.focus()");
|
||
}
|
||
|
||
public function selectDay(string $day): void
|
||
{
|
||
if (in_array($day, $this->sheet->days, true)) {
|
||
$this->selectedDay = $day;
|
||
}
|
||
}
|
||
|
||
public function showWeek(string $which, Clock $clock): void
|
||
{
|
||
$this->week = match ($which) {
|
||
'previous' => CarbonImmutable::parse($this->week)->subWeek()->toDateString(),
|
||
'next' => CarbonImmutable::parse($this->week)->addWeek()->toDateString(),
|
||
default => $this->mondayOf($clock->today()->format('Y-m-d')),
|
||
};
|
||
|
||
unset($this->sheet);
|
||
$this->selectedDay = $this->week;
|
||
$this->statusMessage = $this->weekHeading();
|
||
$this->errorMessage = '';
|
||
$this->resetErrorBag();
|
||
$this->rejected = [];
|
||
$this->loadCells();
|
||
}
|
||
|
||
public function weekHeading(): string
|
||
{
|
||
$monday = CarbonImmutable::parse($this->week);
|
||
|
||
return __('time.week_heading', [
|
||
'number' => $monday->isoWeek(),
|
||
'from' => $monday->format('j.n.'),
|
||
'to' => $monday->addDays(6)->format('j.n.Y'),
|
||
]);
|
||
}
|
||
|
||
public function dayLabel(string $day): string
|
||
{
|
||
$date = CarbonImmutable::parse($day);
|
||
|
||
return __('time.days')[$date->dayOfWeekIso - 1].' '.$date->format('j.n.');
|
||
}
|
||
|
||
public function hours(int $quarters): string
|
||
{
|
||
return WorkedHours::formatQuarters($quarters);
|
||
}
|
||
|
||
public function isSubcontractor(): bool
|
||
{
|
||
return auth()->user()?->role === Role::Subcontractor;
|
||
}
|
||
|
||
public function heading(): string
|
||
{
|
||
return $this->isReadOnly() ? __('time.other_title', ['name' => $this->viewedUserName]) : __('time.title');
|
||
}
|
||
|
||
public function render(): mixed
|
||
{
|
||
return $this->view()->title($this->heading());
|
||
}
|
||
|
||
private function loadCells(): void
|
||
{
|
||
$cells = [];
|
||
|
||
foreach ($this->sheet->rows as $row) {
|
||
foreach ($this->sheet->days as $day) {
|
||
$quarters = $row->quartersByDay[$day] ?? 0;
|
||
$cells[$row->task->taskId][$day] = $quarters === 0 ? '' : WorkedHours::formatQuarters($quarters);
|
||
}
|
||
}
|
||
|
||
$this->cells = $cells;
|
||
}
|
||
|
||
private function mondayOf(string $date): string
|
||
{
|
||
try {
|
||
return CarbonImmutable::parse($date)->startOfWeek()->toDateString();
|
||
} catch (\Throwable) {
|
||
return CarbonImmutable::now()->startOfWeek()->toDateString();
|
||
}
|
||
}
|
||
};
|
||
?>
|
||
|
||
@php($sheet = $this->sheet)
|
||
|
||
<div class="mx-auto max-w-7xl space-y-6 p-4 sm:p-6">
|
||
<div class="space-y-2">
|
||
<x-page-title icon="clock">{{ $this->heading() }}</x-page-title>
|
||
@if ($this->isReadOnly())
|
||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('time.other_intro') }}</p>
|
||
<x-link :href="route('time.approvals')" navigate class="text-sm">{{ __('time.approval.back_to_list') }}</x-link>
|
||
@else
|
||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('time.intro') }}</p>
|
||
@endif
|
||
</div>
|
||
|
||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||
<h2 class="text-xl font-semibold">{{ $this->weekHeading() }}</h2>
|
||
<div class="flex flex-wrap gap-2">
|
||
<x-button wire:click="showWeek('previous')" subtle color="black" sm icon="chevron-left" :text="__('time.previous_week')" />
|
||
<x-button wire:click="showWeek('this')" subtle color="black" sm :text="__('time.this_week')" />
|
||
<x-button wire:click="showWeek('next')" subtle color="black" sm icon="chevron-right" position="right" :text="__('time.next_week')" />
|
||
</div>
|
||
</div>
|
||
|
||
<p role="status" aria-live="polite" class="min-h-5 text-sm">{{ $statusMessage }}</p>
|
||
<p role="alert" class="text-sm font-medium text-red-700 dark:text-red-400">{{ $errorMessage }}</p>
|
||
|
||
@if ($sheet->rows === [])
|
||
<x-empty-state icon="clock">{{ __('time.no_rows') }}</x-empty-state>
|
||
@else
|
||
{{-- Desktop: the whole week as an input grid (a form, so a native table rather than <x-table>). --}}
|
||
<div class="card hidden lg:block">
|
||
<table class="w-full border-collapse text-sm">
|
||
<caption class="sr-only">{{ __('time.table_caption') }}</caption>
|
||
<thead>
|
||
<tr class="border-b-2 border-primary-200 text-primary-900 dark:border-primary-800 dark:text-primary-100">
|
||
<th scope="col" class="py-2 pr-3 text-left font-semibold">{{ __('time.task') }}</th>
|
||
@foreach ($sheet->days as $day)
|
||
<th scope="col" class="w-20 px-1 py-2 text-center font-semibold">{{ $this->dayLabel($day) }}</th>
|
||
@endforeach
|
||
<th scope="col" class="w-20 py-2 pl-3 text-right font-semibold">{{ __('time.total') }}</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
@foreach ($sheet->rows as $row)
|
||
<tr wire:key="row-{{ $row->task->taskId }}" class="border-b border-zinc-200 align-top dark:border-zinc-700">
|
||
<th scope="row" class="py-2 pr-3 text-left font-normal">
|
||
<x-link :href="route('time.task', $row->task->taskId)" navigate class="font-medium">{{ $row->task->label() }}</x-link>
|
||
<span class="block text-zinc-600 dark:text-zinc-200">{{ $row->task->workTypeName }}</span>
|
||
@if ($row->task->isLocked())
|
||
<span class="mt-1 inline-flex items-center gap-1 text-zinc-700 dark:text-zinc-200">
|
||
<x-icon name="lock-closed" class="size-4" aria-hidden="true" /> {{ __('time.locked') }}
|
||
</span>
|
||
@endif
|
||
</th>
|
||
@foreach ($sheet->days as $day)
|
||
<td class="px-1 py-2 text-center">
|
||
@if ($row->isApprovedOn($day))
|
||
<span class="inline-flex items-center gap-1">
|
||
{{ $this->hours($row->quartersByDay[$day] ?? 0) }}
|
||
<x-icon name="check-circle" class="size-4" aria-hidden="true" />
|
||
<span class="sr-only">{{ __('time.approval.cell_approved') }}</span>
|
||
</span>
|
||
@elseif ($row->task->isLocked() || $this->isReadOnly())
|
||
{{ isset($row->quartersByDay[$day]) ? $this->hours($row->quartersByDay[$day]) : '' }}
|
||
@else
|
||
<input
|
||
id="cell-{{ $row->task->taskId }}-{{ $day }}"
|
||
type="text"
|
||
inputmode="decimal"
|
||
autocomplete="off"
|
||
value="{{ $rejected[$row->task->taskId.'.'.$day] ?? $cells[$row->task->taskId][$day] ?? '' }}"
|
||
wire:change="saveCell({{ $row->task->taskId }}, '{{ $day }}', $event.target.value)"
|
||
aria-label="{{ __('time.cell_label', ['task' => $row->task->taskTitle, 'day' => $this->dayLabel($day)]) }}"
|
||
@error('cells.'.$row->task->taskId.'.'.$day) aria-invalid="true" aria-describedby="cell-{{ $row->task->taskId }}-{{ $day }}-error" @enderror
|
||
class="w-16 rounded-md border border-zinc-400 bg-white px-2 py-1.5 text-center text-zinc-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 dark:focus-visible:outline-primary-300 aria-invalid:border-red-700 dark:border-zinc-500 dark:bg-zinc-900 dark:text-zinc-100 dark:aria-invalid:border-red-400"
|
||
/>
|
||
@error('cells.'.$row->task->taskId.'.'.$day)
|
||
<p id="cell-{{ $row->task->taskId }}-{{ $day }}-error" class="mt-1 text-xs text-red-700 dark:text-red-400">{{ $message }}</p>
|
||
@enderror
|
||
@endif
|
||
</td>
|
||
@endforeach
|
||
<td class="py-2 pl-3 text-right font-medium">{{ $this->hours($row->totalQuarters) }}</td>
|
||
</tr>
|
||
@endforeach
|
||
</tbody>
|
||
<tfoot>
|
||
<tr>
|
||
<th scope="row" class="py-2 pr-3 text-left font-semibold">{{ __('time.day_total') }}</th>
|
||
@foreach ($sheet->days as $day)
|
||
<td class="px-1 py-2 text-center font-semibold">{{ $this->hours($sheet->dayTotals[$day]) }}</td>
|
||
@endforeach
|
||
<td class="py-2 pl-3 text-right font-semibold">{{ $this->hours($sheet->totalQuarters) }}</td>
|
||
</tr>
|
||
</tfoot>
|
||
</table>
|
||
</div>
|
||
|
||
{{-- Phone: one day at a time. --}}
|
||
<div class="space-y-4 lg:hidden">
|
||
<div role="group" aria-label="{{ __('time.choose_day') }}" class="grid grid-cols-4 gap-2 sm:grid-cols-7">
|
||
@foreach ($sheet->days as $day)
|
||
<button
|
||
type="button"
|
||
wire:click="selectDay('{{ $day }}')"
|
||
aria-pressed="{{ $day === $selectedDay ? 'true' : 'false' }}"
|
||
aria-label="{{ __('time.day_button', ['day' => $this->dayLabel($day), 'hours' => $this->hours($sheet->dayTotals[$day])]) }}"
|
||
@class([
|
||
'rounded-md border px-2 py-2 text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 dark:focus-visible:outline-primary-300',
|
||
'border-primary-700 bg-primary-700 font-semibold text-white' => $day === $selectedDay,
|
||
'border-zinc-300 bg-white text-zinc-900 dark:border-zinc-600 dark:bg-zinc-900 dark:text-zinc-100' => $day !== $selectedDay,
|
||
])
|
||
>
|
||
<span class="block">{{ $this->dayLabel($day) }}</span>
|
||
<span class="block text-xs">{{ __('time.hours_suffix', ['hours' => $this->hours($sheet->dayTotals[$day])]) }}</span>
|
||
</button>
|
||
@endforeach
|
||
</div>
|
||
|
||
<ul class="space-y-3">
|
||
@foreach ($sheet->rows as $row)
|
||
<li wire:key="mrow-{{ $row->task->taskId }}" class="rounded-xl border border-zinc-200 bg-white p-3 text-sm shadow-sm dark:border-zinc-700 dark:bg-zinc-900">
|
||
<x-link :href="route('time.task', $row->task->taskId)" navigate class="font-medium break-words">{{ $row->task->label() }}</x-link>
|
||
<span class="block text-zinc-600 dark:text-zinc-200">{{ $row->task->workTypeName }}</span>
|
||
|
||
@if ($row->isApprovedOn($selectedDay))
|
||
<p class="mt-2 inline-flex items-center gap-1">
|
||
<x-icon name="check-circle" class="size-4" aria-hidden="true" /> {{ __('time.approval.cell_approved') }}
|
||
– {{ __('time.hours_suffix', ['hours' => $this->hours($row->quartersByDay[$selectedDay] ?? 0)]) }}
|
||
</p>
|
||
@elseif ($row->task->isLocked() || $this->isReadOnly())
|
||
<p class="mt-2 inline-flex items-center gap-1">
|
||
@if ($row->task->isLocked())
|
||
<x-icon name="lock-closed" class="size-4" aria-hidden="true" /> {{ __('time.locked') }}
|
||
@else
|
||
{{ $this->dayLabel($selectedDay) }}
|
||
@endif
|
||
– {{ __('time.hours_suffix', ['hours' => $this->hours($row->quartersByDay[$selectedDay] ?? 0)]) }}
|
||
</p>
|
||
@else
|
||
<label for="mcell-{{ $row->task->taskId }}-{{ $selectedDay }}" class="mt-2 block font-medium">
|
||
{{ __('time.cell_label', ['task' => $row->task->taskTitle, 'day' => $this->dayLabel($selectedDay)]) }}
|
||
</label>
|
||
<input
|
||
id="mcell-{{ $row->task->taskId }}-{{ $selectedDay }}"
|
||
type="text"
|
||
inputmode="decimal"
|
||
autocomplete="off"
|
||
value="{{ $rejected[$row->task->taskId.'.'.$selectedDay] ?? $cells[$row->task->taskId][$selectedDay] ?? '' }}"
|
||
wire:change="saveCell({{ $row->task->taskId }}, '{{ $selectedDay }}', $event.target.value)"
|
||
@error('cells.'.$row->task->taskId.'.'.$selectedDay) aria-invalid="true" aria-describedby="mcell-{{ $row->task->taskId }}-{{ $selectedDay }}-error" @enderror
|
||
class="mt-1 w-24 rounded-md border border-zinc-400 bg-white px-2 py-2 text-zinc-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 dark:focus-visible:outline-primary-300 aria-invalid:border-red-700 dark:border-zinc-500 dark:bg-zinc-900 dark:text-zinc-100 dark:aria-invalid:border-red-400"
|
||
/>
|
||
@error('cells.'.$row->task->taskId.'.'.$selectedDay)
|
||
<p id="mcell-{{ $row->task->taskId }}-{{ $selectedDay }}-error" class="mt-1 text-xs text-red-700 dark:text-red-400">{{ $message }}</p>
|
||
@enderror
|
||
@endif
|
||
</li>
|
||
@endforeach
|
||
</ul>
|
||
</div>
|
||
|
||
<p class="inline-flex items-center gap-2 rounded-lg bg-primary-50 px-3 py-2 text-sm font-semibold text-primary-900 dark:bg-primary-950 dark:text-primary-100"><x-icon name="clock" class="size-4" aria-hidden="true" />{{ __('time.week_total', ['hours' => $this->hours($sheet->totalQuarters)]) }}</p>
|
||
@endif
|
||
|
||
<section aria-labelledby="approval-heading" class="card space-y-3">
|
||
<h2 id="approval-heading" tabindex="-1" class="text-lg font-semibold focus:outline-none">{{ __('time.approval.title') }}</h2>
|
||
|
||
@if ($sheet->hasUnapprovedHours())
|
||
<p class="text-sm">{{ __('time.approval.unapproved', ['hours' => $this->hours($sheet->unapprovedQuarters)]) }}</p>
|
||
@elseif ($sheet->totalQuarters === 0)
|
||
<p class="text-sm">{{ __('time.approval.no_hours') }}</p>
|
||
@endif
|
||
|
||
@if ($sheet->lastApproval !== null)
|
||
<p class="inline-flex items-center gap-1 text-sm">
|
||
<x-icon name="check-circle" class="size-4" aria-hidden="true" />
|
||
{{ __('time.approval.approved_by', ['date' => \Carbon\CarbonImmutable::parse($sheet->lastApproval->approvedAt)->format('j.n.Y H:i'), 'name' => $sheet->lastApproval->approverName]) }}
|
||
</p>
|
||
@endif
|
||
|
||
<div class="flex flex-wrap gap-2">
|
||
@if ($sheet->hasUnapprovedHours())
|
||
@if ($this->canApprove())
|
||
<x-button wire:click="approveWeek" icon="check" :text="__('time.approval.approve_week')" />
|
||
@else
|
||
<p class="text-sm">{{ __('time.approval.management_approves') }}</p>
|
||
@endif
|
||
@endif
|
||
|
||
@if ($sheet->hasApprovedHours())
|
||
@can('time.cancel-approval')
|
||
<x-button wire:click="confirmCancelApproval" subtle color="black" icon="arrow-uturn-left" :text="__('time.approval.cancel')" />
|
||
@endcan
|
||
@endif
|
||
</div>
|
||
</section>
|
||
|
||
@can('time.cancel-approval')
|
||
<x-confirm-dialog id="cancel-approval-dialog" :title="__('time.approval.cancel_title')">
|
||
<p>{{ __('time.approval.cancel_question', ['week' => $this->weekHeading()]) }}</p>
|
||
|
||
<x-slot:actions>
|
||
<x-button wire:click="cancelApproval" color="red" icon="arrow-uturn-left" :text="__('time.approval.cancel')" />
|
||
</x-slot:actions>
|
||
</x-confirm-dialog>
|
||
@endcan
|
||
|
||
@unless ($this->isReadOnly())
|
||
<section aria-labelledby="add-task-heading" class="card space-y-2">
|
||
<h2 id="add-task-heading" class="sr-only">{{ __('time.add.search') }}</h2>
|
||
<x-input
|
||
id="task-search"
|
||
wire:model.live.debounce.300ms="taskSearch"
|
||
type="search"
|
||
icon="magnifying-glass"
|
||
:label="__('time.add.search')"
|
||
:hint="__('time.add.search_description')"
|
||
autocomplete="off"
|
||
/>
|
||
|
||
@if (mb_strlen(trim($taskSearch)) >= 2)
|
||
<p role="status" aria-live="polite" class="text-sm text-zinc-600 dark:text-zinc-200">
|
||
{{ trans_choice('time.add.results', count($this->searchResults), ['count' => count($this->searchResults)]) }}
|
||
</p>
|
||
<ul class="space-y-1">
|
||
@foreach ($this->searchResults as $task)
|
||
<li wire:key="result-{{ $task->taskId }}">
|
||
<button
|
||
type="button"
|
||
wire:click="addTask({{ $task->taskId }})"
|
||
aria-label="{{ __('time.add.choose', ['task' => $task->label()]) }}"
|
||
class="w-full rounded-md px-3 py-2 text-left text-sm hover:bg-zinc-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 dark:focus-visible:outline-primary-300 dark:hover:bg-zinc-700"
|
||
>
|
||
<span class="font-medium">{{ $task->label() }}</span>
|
||
<span class="text-zinc-600 dark:text-zinc-200">{{ $task->workTypeName }}</span>
|
||
</button>
|
||
</li>
|
||
@endforeach
|
||
</ul>
|
||
@endif
|
||
</section>
|
||
@endunless
|
||
</div>
|