- 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]>
145 lines
6.2 KiB
PHP
145 lines
6.2 KiB
PHP
<?php
|
|
|
|
use App\Modules\Inventory\Application\Contracts\InventoryCountQueries;
|
|
use App\Modules\Inventory\Application\Contracts\StockQueries;
|
|
use App\Modules\Inventory\Application\DTOs\InventoryCountSummary;
|
|
use App\Modules\Inventory\Application\UseCases\InventoryCounts;
|
|
use App\Modules\Inventory\Domain\Exceptions\InventoryCountAlreadyOpen;
|
|
use App\Modules\Inventory\Presentation\Livewire\Concerns\FormatsStock;
|
|
use Livewire\Attributes\Computed;
|
|
use Livewire\Component;
|
|
|
|
/**
|
|
* Stock counts (inventaario, spec 19.3): the list of counts, newest first,
|
|
* and for management the start of a new one for the whole stock or chosen
|
|
* item groups. Only one count is open at a time.
|
|
*/
|
|
new class extends Component
|
|
{
|
|
use FormatsStock;
|
|
|
|
/**
|
|
* @var list<string>
|
|
*/
|
|
public array $groupIds = [];
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->authorize('inventory.count');
|
|
}
|
|
|
|
/**
|
|
* @return list<InventoryCountSummary>
|
|
*/
|
|
#[Computed]
|
|
public function counts(): array
|
|
{
|
|
return app(InventoryCountQueries::class)->counts();
|
|
}
|
|
|
|
/**
|
|
* @return list<array{value: int, label: string}>
|
|
*/
|
|
#[Computed]
|
|
public function groupOptions(): array
|
|
{
|
|
return array_map(
|
|
fn ($group): array => ['value' => $group->id, 'label' => $group->name],
|
|
app(StockQueries::class)->groups(includeInactive: false),
|
|
);
|
|
}
|
|
|
|
public function start(InventoryCounts $counts): void
|
|
{
|
|
$this->authorize('inventory.manage-counts');
|
|
|
|
try {
|
|
$id = $counts->start(array_map('intval', $this->groupIds), (int) auth()->id());
|
|
} catch (InventoryCountAlreadyOpen) {
|
|
$this->addError('groupIds', __('inventory.counts.errors.already_open'));
|
|
|
|
return;
|
|
}
|
|
|
|
$this->redirectRoute('inventory.counts.show', $id, navigate: true);
|
|
}
|
|
|
|
public function render(): mixed
|
|
{
|
|
return $this->view()->title(__('inventory.counts.title'));
|
|
}
|
|
};
|
|
?>
|
|
|
|
<div class="mx-auto max-w-5xl space-y-6 p-4 sm:p-6">
|
|
<div class="space-y-2">
|
|
<x-page-title icon="clipboard-document-check">{{ __('inventory.counts.title') }}</x-page-title>
|
|
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('inventory.counts.intro') }}</p>
|
|
</div>
|
|
|
|
@can('inventory.manage-counts')
|
|
<section aria-labelledby="start-heading" class="card space-y-3">
|
|
<h2 id="start-heading" class="text-lg font-semibold">{{ __('inventory.counts.start_title') }}</h2>
|
|
<form wire:submit="start" class="space-y-4" novalidate>
|
|
@if ($this->groupOptions !== [])
|
|
<x-checkbox-group
|
|
:legend="__('inventory.counts.groups')"
|
|
model="groupIds"
|
|
:options="$this->groupOptions"
|
|
:hint="__('inventory.counts.groups_hint')"
|
|
/>
|
|
@endif
|
|
@error('groupIds')
|
|
<p role="alert" class="text-sm text-red-700 dark:text-red-400">{{ $message }}</p>
|
|
@enderror
|
|
<x-button submit icon="clipboard-document-check" :text="__('inventory.counts.start')" />
|
|
</form>
|
|
</section>
|
|
@endcan
|
|
|
|
<section aria-labelledby="counts-heading" class="card space-y-3">
|
|
<h2 id="counts-heading" class="text-lg font-semibold">{{ __('inventory.counts.list') }}</h2>
|
|
|
|
@if ($this->counts === [])
|
|
<x-empty-state icon="archive-box">{{ __('inventory.counts.none') }}</x-empty-state>
|
|
@else
|
|
<ul class="divide-y divide-zinc-200 rounded-lg border border-zinc-300 dark:divide-zinc-700 dark:border-zinc-600">
|
|
@foreach ($this->counts as $count)
|
|
<li wire:key="count-{{ $count->id }}" class="flex flex-wrap items-center justify-between gap-3 p-3">
|
|
<div class="min-w-0 space-y-1">
|
|
<p class="font-medium">
|
|
<x-link :href="route('inventory.counts.show', $count->id)" navigate>
|
|
{{ __('inventory.counts.name', ['date' => $this->dateLabel($count->countedOn)]) }}
|
|
</x-link>
|
|
</p>
|
|
<p class="text-sm">
|
|
{{ $count->groupNames === [] ? __('inventory.counts.whole_stock') : implode(', ', $count->groupNames) }}
|
|
· {{ trans_choice('inventory.counts.counted_items', $count->countedItems, ['count' => $count->countedItems]) }}
|
|
</p>
|
|
</div>
|
|
<div class="flex flex-wrap items-center gap-3 text-sm">
|
|
@if ($count->isConfirmed)
|
|
<span class="inline-flex items-center gap-1">
|
|
<x-icon name="lock-closed" class="size-4" aria-hidden="true" />
|
|
{{ __('inventory.counts.confirmed_by', ['name' => $count->confirmedByName, 'at' => $this->dateLabel((string) $count->confirmedAt)]) }}
|
|
</span>
|
|
@can('inventory.manage-counts')
|
|
<a href="{{ route('inventory.counts.csv', $count->id) }}" class="inline-flex items-center gap-1 font-medium underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 dark:focus-visible:outline-primary-300">
|
|
<x-icon name="arrow-down-tray" class="size-4" aria-hidden="true" />
|
|
{{ __('inventory.counts.csv_named', ['date' => $this->dateLabel($count->countedOn)]) }}
|
|
</a>
|
|
@endcan
|
|
@else
|
|
<span class="inline-flex items-center gap-1 font-medium">
|
|
<x-icon name="pencil-square" class="size-4" aria-hidden="true" />
|
|
{{ __('inventory.counts.open') }}
|
|
</span>
|
|
@endif
|
|
</div>
|
|
</li>
|
|
@endforeach
|
|
</ul>
|
|
@endif
|
|
</section>
|
|
</div>
|