authorize('jobs.view'); abort_if($jobQueries->findDetails($job) === null, 404); $this->authorize('jobs.view-job', $job); $this->jobId = $job; } #[Computed] public function job(): CustomerJobDetails { return app(CustomerJobQueries::class)->findDetails($this->jobId) ?? abort(404); } /** * @return list */ #[Computed] public function tasks(): array { return app(TaskQueries::class)->tasksOf($this->jobId); } /** * A task's comments or images changed: the task cards show their number. */ #[On('task-comments-changed')] #[On('task-images-changed')] public function refreshTasks(): void { unset($this->tasks); } public function changeTaskStatus(int $taskId, string $status, ChangeTaskStatus $changeStatus): void { $this->authorize('jobs.update-task-status', $this->jobId); $newStatus = TaskStatus::tryFrom($status); $task = app(TaskQueries::class)->findTask($this->jobId, $taskId); if ($newStatus === null || $task === null) { $this->taskStatusMessage = __('jobs.tasks.not_found'); return; } try { $changeStatus->execute($this->jobId, $taskId, $newStatus); } catch (TaskNotFound) { $this->taskStatusMessage = __('jobs.tasks.not_found'); return; } unset($this->tasks); $this->taskStatusMessage = __('jobs.tasks.status_changed', ['title' => $task->title, 'status' => __('jobs.tasks.statuses.'.$newStatus->value)]); // The list is re-ordered (done tasks last): keep focus on the same select. $this->js("document.getElementById('task-status-{$taskId}')?.focus()"); } public function confirmTaskRemoval(int $taskId): void { $this->authorize('jobs.manage-tasks', $this->jobId); $task = app(TaskQueries::class)->findTask($this->jobId, $taskId); if ($task === null) { $this->taskStatusMessage = __('jobs.tasks.not_found'); return; } $this->removalTaskId = $task->id; $this->removalTaskTitle = $task->title; $this->js("document.getElementById('remove-task-dialog').showModal()"); } public function removeTask(RemoveTask $removeTask): void { $this->authorize('jobs.manage-tasks', $this->jobId); if ($this->removalTaskId === null) { return; } try { $removeTask->execute($this->jobId, $this->removalTaskId); $this->taskStatusMessage = __('jobs.tasks.removed', ['title' => $this->removalTaskTitle]); } catch (TaskNotFound) { $this->taskStatusMessage = __('jobs.tasks.not_found'); } catch (TaskHasTimeEntries) { $this->taskStatusMessage = __('jobs.tasks.has_time_entries', ['title' => $this->removalTaskTitle]); } unset($this->tasks); $this->reset('removalTaskId', 'removalTaskTitle'); $this->js("document.getElementById('remove-task-dialog').close(); document.getElementById('tasks-heading').focus()"); } public function render(): mixed { return $this->view()->title($this->job->number.' '.$this->job->name); } }; ?> @php($job = $this->job)

{{ $job->number }} {{ $job->name }}

@can('jobs.manage') @endcan
@if (session('status')) @endif
{{ __('jobs.fields.status') }}:
{{ __('jobs.fields.priority') }}:
{{ __('jobs.fields.due_on') }}:

{{ __('jobs.sections.basics') }}

{{ __('jobs.fields.customer') }}
@can('customers.use') {{ $job->customer->name }} @else {{ $job->customer->name }} @endcan
{{ __('jobs.fields.service_units') }}
{{ collect($job->serviceUnits)->pluck('name')->join(', ') }}
{{ __('jobs.fields.kind') }}
{{ __('jobs.kinds.'.$job->kind->value) }}
{{ __('jobs.fields.payment_basis') }}
{{ $job->paymentBasis === null ? __('jobs.not_set') : __('jobs.payment_bases.'.$job->paymentBasis->value) }} @if ($job->paymentBasis?->value === 'monthly_fee') @can('billing.manage') {{ __('jobs.monthly_billing_link') }} @endcan @endif
{{ __('jobs.fields.estimated_hours') }}
{{ $job->estimatedHours === null ? __('jobs.not_set') : str_replace('.', ',', $job->estimatedHours).' h' }}
@can('money.quotes')
{{ __('jobs.fields.quoted_amount') }}
{{ $job->quotedAmountCents === null ? __('jobs.not_set') : Money::fromCents($job->quotedAmountCents)->format().' '.__('jobs.vat_excluded') }}
@if ($job->paymentBasis?->value === 'monthly_fee' || $job->monthlyFeeCents !== null)
{{ __('jobs.fields.monthly_fee') }}
{{ $job->monthlyFeeCents === null ? __('jobs.not_set') : Money::fromCents($job->monthlyFeeCents)->format().' '.__('jobs.vat_excluded') }}
@endif @endcan
{{ __('jobs.fields.customer_reference') }}
{{ $job->customerReference ?? __('jobs.not_set') }}
{{ __('jobs.fields.tags') }}
{{ $job->tags === [] ? __('jobs.tags.none') : implode(', ', $job->tags) }}
@if ($job->completedAt !== null)
{{ __('jobs.fields.completed_at') }}
{{ CarbonImmutable::parse($job->completedAt)->format('j.n.Y H.i') }}
@endif
{{ __('jobs.fields.created_at') }}
{{ CarbonImmutable::parse($job->createdAt)->format('j.n.Y H.i') }}, {{ $job->createdByName }}
@if ($job->description !== null)

{{ __('jobs.fields.description') }}

{{ $job->description }}

@endif

{{ __('jobs.sections.schedule') }}

{{ __('jobs.fields.starts_on') }}
{{ $this->formatDate($job->startsOn) }}
{{ __('jobs.fields.due_on') }}
{{ __('jobs.fields.planned_from') }}
{{ $this->formatDate($job->plannedFrom) }}
{{ __('jobs.fields.planned_to') }}
{{ $this->formatDate($job->plannedTo) }}

{{ __('jobs.sections.members') }}

{{ __('jobs.fields.responsible_user') }}
{{ $job->responsible->name }}
{{ __('jobs.fields.contact_user') }}
{{ $job->contactUser->name ?? __('jobs.not_set') }}
{{ __('jobs.fields.customer_contact') }}
{{ $job->customerContact->name ?? __('jobs.not_set') }}
{{ __('jobs.fields.biller_user') }}
{{ $job->biller->name ?? __('jobs.not_set') }}
{{ __('jobs.fields.billing_unit') }}
{{ $job->billingUnit->name ?? __('jobs.not_set') }}
{{ __('jobs.fields.members') }}
{{ $job->members === [] ? __('jobs.not_set') : collect($job->members)->pluck('name')->join(', ') }}

{{ __('jobs.tasks.title') }}

@can('jobs.manage-tasks', $job->id) @if ($job->status->allowsTasks())
@endif @endcan
@can('jobs.manage-tasks', $job->id) @unless ($job->status->allowsTasks())

{{ __('jobs.tasks.not_allowed_yet') }}

@endunless @endcan

{{ $taskStatusMessage }}

@if ($this->tasks === []) {{ __('jobs.tasks.empty') }} @else @php($canChangeStatus = Gate::allows('jobs.update-task-status', $job->id)) @php($canManageTasks = Gate::allows('jobs.manage-tasks', $job->id)) {{-- Task cards are disclosures: collapsed by default, each opened on its own, so several can be open at once. "Expand all" and "Collapse all" send a tasks-expand window event that every card follows. A card also opens when focus moves into it (e.g. the status select keeps focus after a re-render). --}}

    @foreach ($this->tasks as $task) {{-- A notification links to #task-: that card opens and comes into view. --}}
  • status->value) { 'in_progress' => 'border-l-primary-500', 'in_review' => 'border-l-amber-500', 'done' => 'border-l-emerald-500', default => 'border-l-zinc-400' }])>

    {{ __('jobs.tasks.fields.assignee') }}:
    {{ $task->assignee?->name ?? __('jobs.calendar.no_assignee') }}
    {{ __('jobs.tasks.fields.due_on') }}:
    {{ __('jobs.tasks.fields.status') }}:
    @if ($task->commentCount > 0)
    {{ __('jobs.tasks.comments.title') }}:
    {{ $task->commentCount }}
    @endif @if ($task->imageCount > 0)
    {{ __('jobs.tasks.images.title') }}:
    {{ $task->imageCount }}
    @endif
    {{ __('jobs.tasks.fields.work_type') }}
    {{ $task->workType->name }}
    @if ($task->members !== [])
    {{ __('jobs.tasks.fields.members') }}
    {{ collect($task->members)->pluck('name')->join(', ') }}
    @endif
    {{ __('jobs.tasks.schedule') }}
    @if ($task->plannedFrom === null) {{ __('jobs.not_set') }} @else {{ __('jobs.tasks.schedule_range', ['from' => $this->formatDate($task->plannedFrom), 'to' => $this->formatDate($task->plannedTo)]) }} @endif
    {{ __('jobs.tasks.fields.estimated_hours') }}
    {{ $task->estimatedHours === null ? __('jobs.not_set') : str_replace('.', ',', $task->estimatedHours).' h' }}
    @if ($task->description !== null)

    {{ $task->description }}

    @endif
    @if ($canChangeStatus)
    {{-- TallStackUI's native select does not tie its label to the control, so aria-label names it. --}} @foreach (TaskStatus::cases() as $status) @endforeach
    @endif @if (! $job->status->locksTime() && Gate::allows('time.book', $job->id)) @endif @if ($canManageTasks) @endif
    {{-- The sections mark themselves data-task-section when they have something to show. --}}

    {{ __('jobs.tasks.tabs.no_materials') }}

  • @endforeach
@endif

@if ($removalTaskId !== null) {{ __('jobs.tasks.remove_question', ['title' => $removalTaskTitle]) }} @endif

@can('expenses.record')

{{ __('jobs.sections.expenses') }}

{{ __('expenses.job_page.link') }}
@endcan
@if ($job->links === [])

{{ __('jobs.links.none') }}

@else
    @foreach ($job->links as $link)
  • {{ $link['title'] }} ({{ __('jobs.opens_in_new_tab') }})
  • @endforeach
@endif

{{ __('jobs.sections.instructions') }}

{{ $job->instructions ?? __('jobs.not_set') }}

@if ($this->changes === [])

{{ __('jobs.history.empty') }}

@else
    @foreach ($this->changes as $change)
  1. @if ($change->field === 'created') {{ __('jobs.history.created', ['user' => $change->userName, 'number' => $change->newValue]) }} @else {{ __('jobs.history.changed', [ 'field' => __('jobs.fields.'.$change->field), 'old' => $this->historyValue($change->field, $change->oldValue), 'new' => $this->historyValue($change->field, $change->newValue), ]) }} @if ($change->field === 'status' && \App\Modules\Jobs\Domain\Enums\JobStatus::tryFrom((string) $change->oldValue)?->unlocksTo(\App\Modules\Jobs\Domain\Enums\JobStatus::from((string) $change->newValue))) {{ __('jobs.history.unlocked') }} @endif @endif {{ __('jobs.history.by', ['user' => $change->userName, 'time' => CarbonImmutable::parse($change->changedAt)->format('j.n.Y H.i')]) }}
  2. @endforeach
@endif