CluPilotCloud/resources/views/livewire/admin/invoices.blade.php

75 lines
4.7 KiB
PHP

<div class="space-y-5">
<div class="flex flex-wrap items-start gap-4 animate-rise">
<div>
<h1 class="text-2xl font-bold tracking-tight text-ink">{{ __('invoices_admin.title') }}</h1>
<p class="mt-1 text-sm text-muted">{{ __('invoices_admin.subtitle') }}</p>
</div>
{{-- The one thing that can be created here. The list itself stays
read-only: an issued invoice is corrected by a cancellation and a
new document, never by an edit button. --}}
<x-ui.button :href="route('admin.invoices.new')" variant="primary" class="ml-auto" wire:navigate>
<x-ui.icon name="plus" class="size-4" />{{ __('invoices_admin.new') }}
</x-ui.button>
</div>
@if (session('status'))
<x-ui.alert variant="success">{{ session('status') }}</x-ui.alert>
@endif
<div class="overflow-hidden rounded-lg border border-line bg-surface shadow-xs animate-rise [animation-delay:60ms]">
<div class="flex flex-wrap items-end gap-3 border-b border-line p-4">
<div class="min-w-56 flex-1">
<x-ui.input name="search" wire:model.live.debounce.300ms="search"
:label="__('invoices_admin.search')" :placeholder="__('invoices_admin.search_hint')" />
</div>
<div>
<label class="text-sm font-medium text-body" for="year">{{ __('invoices_admin.year') }}</label>
<select id="year" wire:model.live="year"
class="mt-1.5 rounded-md border border-line-strong bg-surface px-3 py-2 text-sm text-body">
<option value="">{{ __('invoices_admin.all_years') }}</option>
@foreach ($years as $y)<option value="{{ $y }}">{{ $y }}</option>@endforeach
</select>
</div>
</div>
@if ($invoices->isEmpty())
<p class="p-8 text-center text-sm text-muted">{{ __('invoices_admin.empty') }}</p>
@else
<table class="w-full text-sm">
<thead>
<tr class="border-b border-line bg-surface-2 text-left text-xs font-semibold text-muted">
<th class="px-4 py-3 font-semibold">{{ __('invoices_admin.col_number') }}</th>
<th class="px-4 py-3 font-semibold">{{ __('invoices_admin.col_customer') }}</th>
<th class="px-4 py-3 font-semibold">{{ __('invoices_admin.col_date') }}</th>
<th class="px-4 py-3 text-right font-semibold">{{ __('invoices_admin.col_net') }}</th>
<th class="px-4 py-3 text-right font-semibold">{{ __('invoices_admin.col_gross') }}</th>
<th class="px-4 py-3 text-right font-semibold">{{ __('invoices_admin.col_actions') }}</th>
</tr>
</thead>
<tbody>
@foreach ($invoices as $invoice)
<tr wire:key="inv-{{ $invoice->uuid }}" class="border-b border-line last:border-0">
<td class="px-4 py-3 font-mono font-semibold text-ink">{{ $invoice->number }}</td>
<td class="px-4 py-3 text-body">{{ $invoice->customer?->name ?? '—' }}</td>
<td class="px-4 py-3 text-muted">{{ $invoice->issued_on?->local()->format('d.m.Y') }}</td>
<td class="px-4 py-3 text-right font-mono text-muted">{{ \App\Services\Billing\InvoiceMath::money($invoice->net_cents) }}</td>
<td class="px-4 py-3 text-right font-mono font-semibold text-ink">{{ \App\Services\Billing\InvoiceMath::money($invoice->gross_cents) }} {{ $invoice->currency }}</td>
<td class="px-4 py-3 text-right">
{{-- A link, not a Livewire action: a PDF is a file
download, and routing one through a component
round-trip only adds a way for it to fail. --}}
<a href="{{ route('admin.invoices.pdf', $invoice->uuid) }}"
class="inline-flex items-center gap-1.5 rounded-md border border-line px-2.5 py-1.5 text-xs font-medium text-body hover:border-accent-border hover:text-accent-text">
<x-ui.icon name="download" class="size-4" />{{ __('invoices_admin.download') }}
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
<div class="border-t border-line p-4">{{ $invoices->links() }}</div>
@endif
</div>
</div>