Add customer jobs with numbering, members, tags, links and history

Phase 1, item 4. New Jobs module:
- Customer jobs with the spec's fields except money (phase 2): yearly
  running numbers (2026-0001) from a locked counter row, service units,
  schedule, kind, status, priority, payment basis, estimated hours,
  PO reference, instructions, members (responsible, contact person,
  customer contact, biller, billing unit, other members), tags shared
  across jobs, and links.
- Every change is recorded field by field and shown on the job page with
  names and Finnish dates.
- References to other modules are checked through their query
  contracts: contact and billing unit must be the customer's own;
  service units and users must be in use unless already on the job.
- Job list with search, filters and "my jobs" on by default; job form
  with an accessible customer search and quick add; job page.
- Access: subcontractors see only jobs they are members of, read only;
  billing statuses for management and the job's biller; archiving for
  management.

Related changes:
- Customers: one internal customer (created by a migration) for internal
  work; contacts and billing units used by a job cannot be removed.
- Users and Catalog: batch name lookups and active user options with
  roles for other modules.
- <x-checkbox-group> component; spec and CLAUDE.md updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-23 18:57:18 +02:00
co-authored by Claude Opus 5.5
parent 51b2d4a252
commit 70e107f6e2
95 changed files with 4631 additions and 26 deletions
@@ -0,0 +1,53 @@
{{--
A group of checkboxes for one array property, in a fieldset whose
legend names the group. Native inputs with wrapping labels, so every
box has a name; the validation error is announced with the group.
$options: list of ['value' => ..., 'label' => ..., 'note' => ?string].
--}}
@props([
'legend',
'model',
'options',
'hint' => null,
'columns' => true,
])
@php
$errorKey = $model;
$id = 'group-'.str_replace('.', '-', $model);
@endphp
<fieldset
{{ $attributes->class('space-y-2') }}
@if ($hint !== null || $errors->has($errorKey)) aria-describedby="{{ trim(($hint !== null ? $id.'-hint ' : '').($errors->has($errorKey) ? $id.'-error' : '')) }}" @endif
>
<legend class="text-sm font-semibold text-gray-700 dark:text-dark-300">{{ $legend }}</legend>
@if ($hint !== null)
<p id="{{ $id }}-hint" class="text-sm text-zinc-600 dark:text-zinc-300">{{ $hint }}</p>
@endif
<div @class(['grid gap-2', 'sm:grid-cols-2 lg:grid-cols-3' => $columns])>
@foreach ($options as $option)
<label wire:key="{{ $id }}-{{ $option['value'] }}" class="flex min-h-6 cursor-pointer items-start gap-2 text-sm">
<input
type="checkbox"
wire:model="{{ $model }}"
value="{{ $option['value'] }}"
class="mt-0.5 size-4 shrink-0 rounded border-zinc-400 text-primary-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-700 dark:border-zinc-500 dark:bg-zinc-800"
/>
<span>
{{ $option['label'] }}
@if (($option['note'] ?? null) !== null)
<span class="text-zinc-600 dark:text-zinc-300">({{ $option['note'] }})</span>
@endif
</span>
</label>
@endforeach
</div>
@error($errorKey)
<p id="{{ $id }}-error" class="text-sm text-red-700 dark:text-red-400">{{ $message }}</p>
@enderror
</fieldset>
@@ -0,0 +1,24 @@
{{--
A job's due date (Y-m-d) in Finnish format. A past due date of an open
job is marked with an icon and the word "Myöhässä", not colour alone.
--}}
@props(['date', 'status'])
@if ($date === null)
{{ __('jobs.not_set') }}
@else
@php
$isLate = \Carbon\CarbonImmutable::parse($date)->endOfDay()->isPast()
&& ! in_array($status->value, ['done', 'invoiced', 'billed', 'archived'], true);
@endphp
<span {{ $attributes->class('inline-flex flex-wrap items-center gap-1') }}>
{{ \Carbon\CarbonImmutable::parse($date)->format('j.n.Y') }}
@if ($isLate)
<span class="inline-flex items-center gap-1 font-medium text-red-700 dark:text-red-400">
<x-icon name="exclamation-triangle" class="size-4" aria-hidden="true" />
{{ __('jobs.late') }}
</span>
@endif
</span>
@endif
@@ -0,0 +1,20 @@
{{--
A job's priority: the colour dot is decoration, the text carries the
meaning (never colour alone). "Heti" gets a striped dot.
--}}
@props(['priority'])
@php
$dot = match ($priority->value) {
'waiting' => 'bg-blue-600',
'normal' => 'bg-green-600',
'first' => 'bg-yellow-400',
'urgent' => 'bg-red-600',
'immediate' => 'bg-[repeating-linear-gradient(45deg,var(--color-orange-500)_0_3px,var(--color-red-700)_3px_6px)]',
};
@endphp
<span {{ $attributes->class('inline-flex items-center gap-2') }}>
<span class="inline-block size-3 shrink-0 rounded-full ring-1 ring-black/20 dark:ring-white/30 {{ $dot }}" aria-hidden="true"></span>
{{ __('jobs.priorities.'.$priority->value) }}
</span>