12-05-2026 Frontend dev
This commit is contained in:
parent
405df0a122
commit
5b8bdf4182
779 changed files with 480564 additions and 6241 deletions
314
resources/views/livewire/admin/invoices/index.blade.php
Normal file
314
resources/views/livewire/admin/invoices/index.blade.php
Normal file
|
|
@ -0,0 +1,314 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\Portal;
|
||||
use App\Models\LegacyInvoice;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Livewire\Attributes\Layout;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Volt\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
new #[Layout('components.layouts.app'), Title('Legacy Rechnungen')] class extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public string $search = '';
|
||||
|
||||
public string $portalFilter = 'all';
|
||||
|
||||
public string $statusFilter = 'all';
|
||||
|
||||
public string $mappingFilter = 'all';
|
||||
|
||||
public string $pdfFilter = 'all';
|
||||
|
||||
public function updatedSearch(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function updatedPortalFilter(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function updatedStatusFilter(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function updatedMappingFilter(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function updatedPdfFilter(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function resetFilters(): void
|
||||
{
|
||||
$this->reset(['search', 'portalFilter', 'statusFilter', 'mappingFilter', 'pdfFilter']);
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function with(): array
|
||||
{
|
||||
$baseQuery = LegacyInvoice::query();
|
||||
$filteredQuery = $this->filteredQuery();
|
||||
$supportsPdfGeneratedAt = $this->supportsPdfGeneratedAt();
|
||||
|
||||
return [
|
||||
'invoices' => $filteredQuery
|
||||
->with('user:id,name,email')
|
||||
->latest('invoice_date')
|
||||
->latest('id')
|
||||
->paginate(50),
|
||||
'statusOptions' => (clone $baseQuery)
|
||||
->whereNotNull('status')
|
||||
->distinct()
|
||||
->orderBy('status')
|
||||
->pluck('status')
|
||||
->filter()
|
||||
->values(),
|
||||
'portalOptions' => collect([Portal::Presseecho, Portal::Businessportal24]),
|
||||
'stats' => [
|
||||
'count' => (clone $baseQuery)->count(),
|
||||
'total_cents' => (int) (clone $baseQuery)->sum('total_cents'),
|
||||
'paid_count' => (clone $baseQuery)->whereNotNull('paid_at')->count(),
|
||||
'unmapped_count' => (clone $baseQuery)->whereNull('user_id')->count(),
|
||||
'generated_pdf_count' => $supportsPdfGeneratedAt
|
||||
? (clone $baseQuery)->whereNotNull('pdf_generated_at')->count()
|
||||
: 0,
|
||||
'filtered_count' => (clone $filteredQuery)->count(),
|
||||
],
|
||||
'supportsPdfGeneratedAt' => $supportsPdfGeneratedAt,
|
||||
];
|
||||
}
|
||||
|
||||
private function filteredQuery(): Builder
|
||||
{
|
||||
return LegacyInvoice::query()
|
||||
->when(filled($this->search), function (Builder $query): void {
|
||||
$search = trim($this->search);
|
||||
|
||||
$query->where(function (Builder $query) use ($search): void {
|
||||
$query
|
||||
->where('number', 'like', '%'.$search.'%')
|
||||
->orWhere('legacy_id', $search)
|
||||
->orWhere('legacy_user_id', $search)
|
||||
->orWhereHas('user', function (Builder $query) use ($search): void {
|
||||
$query
|
||||
->where('name', 'like', '%'.$search.'%')
|
||||
->orWhere('email', 'like', '%'.$search.'%');
|
||||
});
|
||||
});
|
||||
})
|
||||
->when($this->portalFilter !== 'all', fn (Builder $query) => $query->where('legacy_portal', $this->portalFilter))
|
||||
->when($this->statusFilter !== 'all', fn (Builder $query) => $query->where('status', $this->statusFilter))
|
||||
->when($this->mappingFilter === 'mapped', fn (Builder $query) => $query->whereNotNull('user_id'))
|
||||
->when($this->mappingFilter === 'unmapped', fn (Builder $query) => $query->whereNull('user_id'))
|
||||
->when($this->supportsPdfGeneratedAt() && $this->pdfFilter === 'generated', fn (Builder $query) => $query->whereNotNull('pdf_generated_at'))
|
||||
->when($this->supportsPdfGeneratedAt() && $this->pdfFilter === 'pending', fn (Builder $query) => $query->whereNull('pdf_generated_at'));
|
||||
}
|
||||
|
||||
private function supportsPdfGeneratedAt(): bool
|
||||
{
|
||||
return Schema::hasColumn('legacy_invoices', 'pdf_generated_at');
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<div class="space-y-6">
|
||||
<flux:card>
|
||||
<div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div class="space-y-2">
|
||||
<flux:heading size="lg">{{ __('Legacy Rechnungen') }}</flux:heading>
|
||||
<flux:subheading>
|
||||
{{ __('Legacy-Rechnungsarchiv mit read-only Übersicht, Filtern und PDF-Download. Der neue Stripe-Rechnungslauf folgt separat in Phase 8.') }}
|
||||
</flux:subheading>
|
||||
</div>
|
||||
<flux:badge color="zinc" icon="archive-box" size="lg">
|
||||
{{ __('Legacy-Archiv') }}
|
||||
</flux:badge>
|
||||
</div>
|
||||
</flux:card>
|
||||
|
||||
@if($stats['unmapped_count'] > 0)
|
||||
<flux:callout color="yellow" icon="exclamation-triangle">
|
||||
{{ __(':count Legacy-Rechnungen konnten keinem neuen User zugeordnet werden. Sie bleiben im Archiv sichtbar und sollten im Rehearsal-Report fachlich geprüft werden.', ['count' => number_format($stats['unmapped_count'], 0, ',', '.')]) }}
|
||||
</flux:callout>
|
||||
@endif
|
||||
|
||||
<div class="grid grid-cols-2 gap-4 lg:grid-cols-5">
|
||||
<flux:card>
|
||||
<flux:text class="text-xs text-zinc-500">{{ __('Rechnungen') }}</flux:text>
|
||||
<flux:text size="xl" weight="bold">{{ number_format($stats['count'], 0, ',', '.') }}</flux:text>
|
||||
</flux:card>
|
||||
<flux:card>
|
||||
<flux:text class="text-xs text-zinc-500">{{ __('Archivsumme') }}</flux:text>
|
||||
<flux:text size="xl" weight="bold">{{ number_format($stats['total_cents'] / 100, 2, ',', '.') }} €</flux:text>
|
||||
</flux:card>
|
||||
<flux:card>
|
||||
<flux:text class="text-xs text-zinc-500">{{ __('Bezahlt') }}</flux:text>
|
||||
<flux:text size="xl" weight="bold">{{ number_format($stats['paid_count'], 0, ',', '.') }}</flux:text>
|
||||
</flux:card>
|
||||
<flux:card>
|
||||
<flux:text class="text-xs text-zinc-500">{{ __('Ohne User') }}</flux:text>
|
||||
<flux:text size="xl" weight="bold">{{ number_format($stats['unmapped_count'], 0, ',', '.') }}</flux:text>
|
||||
</flux:card>
|
||||
@if($supportsPdfGeneratedAt)
|
||||
<flux:card>
|
||||
<flux:text class="text-xs text-zinc-500">{{ __('PDF erzeugt') }}</flux:text>
|
||||
<flux:text size="xl" weight="bold">{{ number_format($stats['generated_pdf_count'], 0, ',', '.') }}</flux:text>
|
||||
</flux:card>
|
||||
@else
|
||||
<flux:card>
|
||||
<flux:text class="text-xs text-zinc-500">{{ __('PDF-Status') }}</flux:text>
|
||||
<flux:text size="xl" weight="bold">{{ __('Migration offen') }}</flux:text>
|
||||
</flux:card>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<flux:card>
|
||||
<div class="grid gap-3 lg:grid-cols-6">
|
||||
<flux:input
|
||||
wire:model.live.debounce.300ms="search"
|
||||
placeholder="{{ __('Rechnungsnr., Legacy-ID, User oder E-Mail suchen...') }}"
|
||||
icon="magnifying-glass"
|
||||
class="lg:col-span-2"
|
||||
/>
|
||||
|
||||
<flux:select wire:model.live="portalFilter">
|
||||
<option value="all">{{ __('Alle Portale') }}</option>
|
||||
@foreach($portalOptions as $portal)
|
||||
<option value="{{ $portal->value }}">{{ $portal->label() }}</option>
|
||||
@endforeach
|
||||
</flux:select>
|
||||
|
||||
<flux:select wire:model.live="statusFilter">
|
||||
<option value="all">{{ __('Alle Status') }}</option>
|
||||
@foreach($statusOptions as $status)
|
||||
<option value="{{ $status }}">{{ $status }}</option>
|
||||
@endforeach
|
||||
</flux:select>
|
||||
|
||||
<flux:select wire:model.live="mappingFilter">
|
||||
<option value="all">{{ __('Alle Zuordnungen') }}</option>
|
||||
<option value="mapped">{{ __('Mit User') }}</option>
|
||||
<option value="unmapped">{{ __('Ohne User') }}</option>
|
||||
</flux:select>
|
||||
|
||||
<flux:select wire:model.live="pdfFilter">
|
||||
<option value="all">{{ __('Alle PDFs') }}</option>
|
||||
@if($supportsPdfGeneratedAt)
|
||||
<option value="generated">{{ __('PDF erzeugt') }}</option>
|
||||
<option value="pending">{{ __('Noch nicht erzeugt') }}</option>
|
||||
@endif
|
||||
</flux:select>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
||||
<flux:text class="text-sm text-zinc-500">
|
||||
{{ __(':count Treffer für die aktuelle Filterung. PDF-Dateien werden bei Bedarf aus den archivierten Legacy-Daten erzeugt.', ['count' => number_format($stats['filtered_count'], 0, ',', '.')]) }}
|
||||
</flux:text>
|
||||
<flux:button size="sm" variant="ghost" icon="arrow-path" wire:click="resetFilters">
|
||||
{{ __('Filter zurücksetzen') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</flux:card>
|
||||
|
||||
<flux:card class="p-0">
|
||||
<div class="p-4">
|
||||
<flux:table>
|
||||
<flux:table.columns>
|
||||
<flux:table.column>{{ __('Rechnungsnr.') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Portal') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('User') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Betrag') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Status') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Rechnungsdatum') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('PDF') }}</flux:table.column>
|
||||
</flux:table.columns>
|
||||
|
||||
@forelse($invoices as $invoice)
|
||||
<flux:table.row wire:key="admin-legacy-invoice-{{ $invoice->id }}">
|
||||
<flux:table.cell>
|
||||
<div class="space-y-1">
|
||||
<flux:text weight="semibold">{{ $invoice->number ?? ('#'.$invoice->legacy_id) }}</flux:text>
|
||||
<flux:text class="text-xs text-zinc-500">Legacy-ID: {{ $invoice->legacy_id }}</flux:text>
|
||||
</div>
|
||||
</flux:table.cell>
|
||||
<flux:table.cell>
|
||||
<flux:badge size="sm" color="zinc">{{ $invoice->legacy_portal?->label() }}</flux:badge>
|
||||
</flux:table.cell>
|
||||
<flux:table.cell>
|
||||
@if($invoice->user)
|
||||
<div class="space-y-1">
|
||||
<flux:button
|
||||
size="xs"
|
||||
variant="ghost"
|
||||
:href="route('admin.users.show', $invoice->user)"
|
||||
wire:navigate
|
||||
>
|
||||
{{ $invoice->user->name }}
|
||||
</flux:button>
|
||||
<flux:text class="text-xs text-zinc-500">{{ $invoice->user->email }}</flux:text>
|
||||
</div>
|
||||
@else
|
||||
<div class="space-y-1">
|
||||
<flux:badge size="sm" color="yellow">{{ __('Ohne Zuordnung') }}</flux:badge>
|
||||
<flux:text class="text-xs text-zinc-500">Legacy-User: {{ $invoice->legacy_user_id ?? 'n/a' }}</flux:text>
|
||||
</div>
|
||||
@endif
|
||||
</flux:table.cell>
|
||||
<flux:table.cell>
|
||||
<flux:text weight="semibold">{{ number_format($invoice->total_cents / 100, 2, ',', '.') }} €</flux:text>
|
||||
</flux:table.cell>
|
||||
<flux:table.cell>
|
||||
<flux:badge size="sm" color="{{ $invoice->paid_at ? 'green' : 'yellow' }}">
|
||||
{{ $invoice->status ?? ($invoice->paid_at ? __('Bezahlt') : __('Offen')) }}
|
||||
</flux:badge>
|
||||
</flux:table.cell>
|
||||
<flux:table.cell>
|
||||
<div class="space-y-1">
|
||||
<flux:text class="text-sm text-zinc-500">{{ $invoice->invoice_date?->format('d.m.Y') ?? '–' }}</flux:text>
|
||||
@if($invoice->paid_at)
|
||||
<flux:text class="text-xs text-zinc-500">{{ __('bezahlt: :date', ['date' => $invoice->paid_at->format('d.m.Y')]) }}</flux:text>
|
||||
@endif
|
||||
</div>
|
||||
</flux:table.cell>
|
||||
<flux:table.cell>
|
||||
<div class="flex items-center gap-2">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="arrow-top-right-on-square"
|
||||
:href="route('admin.legacy-invoices.pdf', $invoice)"
|
||||
target="_blank"
|
||||
>
|
||||
{{ __('Öffnen') }}
|
||||
</flux:button>
|
||||
@if($supportsPdfGeneratedAt && $invoice->pdf_generated_at)
|
||||
<flux:badge size="sm" color="green">{{ __('erzeugt') }}</flux:badge>
|
||||
@endif
|
||||
</div>
|
||||
</flux:table.cell>
|
||||
</flux:table.row>
|
||||
@empty
|
||||
<flux:table.row>
|
||||
<flux:table.cell colspan="7">
|
||||
<div class="flex flex-col items-center justify-center py-10">
|
||||
<flux:icon.document-text class="size-10 text-zinc-300" />
|
||||
<flux:text class="mt-3 text-zinc-500">{{ __('Keine Legacy-Rechnungen für diese Filter gefunden.') }}</flux:text>
|
||||
</div>
|
||||
</flux:table.cell>
|
||||
</flux:table.row>
|
||||
@endforelse
|
||||
</flux:table>
|
||||
</div>
|
||||
</flux:card>
|
||||
|
||||
{{ $invoices->links() }}
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue