Files
LarsandClaude Opus 5.5 51d58ac55c
CI Feature / test (push) Successful in 1m0s
Deploy Test / test (push) Successful in 55s
Deploy Test / deploy (push) Successful in 23s
Ordne Paket, Rechteprofil, Säulen, Kombinationen und Benutzer in die gemeinsamen Muster ein.
- Gemeinsame Katalog-Objektseite (catalog/objekt): Kopf, Hauptabschnitte,
  Begleitinformation. Angebot, Paket und Rechteprofil nutzen sie; lesbare
  Bezeichnungen zentral in CatalogLabels.
- Paket: eine Maske für erste und geänderte Fassung, bei einer Änderung mit der
  neuesten veröffentlichten Fassung vorbelegt; Wirkung unverändert
  BundleService::publish (frühere Fassungen bleiben veröffentlicht).
- Rechteprofil: erlaubte Handlungen lesbar, Verwendung in Angeboten,
  Fassungen; der doppelte Titel „… ansehen ansehen“ entfällt.
- Fachliche Säulen, Fachliche Kombinationen und Benutzer in der gemeinsamen
  Bestandsliste; Säulen mit Website-Zustand und Medienzahl, Konten mit Status
  und Rollen.
- Gefüllte Filament-Hauptknöpfe überall im Verwaltungsgrün (auch Formularfuß,
  etwa „Speichern“ der Säule).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 08:53:25 +01:00

112 lines
4.3 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Filament\Resources\Offers\Pages;
use App\Domain\Catalog\Offer;
use App\Domain\Catalog\OfferService;
use App\Domain\Catalog\OfferStatus;
use App\Domain\Catalog\StatusValue;
use App\Filament\Resources\Offers\OfferResource;
use App\Filament\Support\CatalogLabels;
use App\Filament\Support\ListsCatalog;
use App\Filament\Support\ReportsDomainRules;
use Filament\Actions\Action;
use Filament\Forms\Components\TextInput;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Contracts\Support\Htmlable;
class ListOffers extends ListRecords
{
use ListsCatalog;
use ReportsDomainRules;
protected static string $resource = OfferResource::class;
public function getSubheading(): string|Htmlable|null
{
return 'Ein Angebot verbindet Artikel oder eine Paketfassung mit einem Rechteprofil. Die aufgelösten Berechtigungen stehen auf der Angebotsseite.';
}
protected function getHeaderActions(): array
{
return [
Action::make('create')->label('Angebot anlegen')
->modalHeading('Neues Angebot')
->modalDescription('Der Name genügt. Positionen, Vergabe und Preis legst du danach am Angebot fest.')
->modalSubmitActionLabel('Angebot anlegen')
->schema([
TextInput::make('name')->label('Name')->required(),
])->action(function (array $data): void {
$offer = null;
$this->report(function () use ($data, &$offer): void {
$offer = app(OfferService::class)->create($data['name']);
}, 'Das Angebot ist angelegt.');
if ($offer instanceof Offer) {
$this->redirect(OfferResource::getUrl('view', ['record' => $offer]));
}
}),
];
}
protected function catalogRows(): array
{
$rows = [];
foreach (Offer::query()->with(['versions.lines.article', 'versions.lines.bundleVersion.bundle', 'versions.lines.rights.profile'])->orderBy('name')->get() as $offer) {
$versions = $offer->versions->sortByDesc('number');
$active = $versions->first(fn ($version): bool => StatusValue::of($version->status) === OfferStatus::Aktiv->value);
$ended = $versions->filter(fn ($version): bool => StatusValue::of($version->status) === OfferStatus::Beendet->value)->count();
$chips = [];
$zustand = [];
$text = '';
if ($active !== null) {
$chips[] = ['label' => 'Fassung '.$active->number.' aktiv', 'ton' => 'gut'];
$chips[] = ['label' => CatalogLabels::vergabe($active), 'ton' => 'neutral'];
$zustand[] = 'aktiv';
$text = $active->lines->map(fn ($line): string => ($line->article !== null
? 'Lizenzartikel '.$line->article->code
: 'Paket '.($line->bundleVersion?->bundle?->name ?? '–')).' · '.($line->rights?->profile?->name ?? ''))->implode('; ');
} else {
$chips[] = ['label' => 'Keine aktive Fassung', 'ton' => 'offen'];
$zustand[] = 'ohne';
}
if ($ended > 0) {
$chips[] = ['label' => $ended === 1 ? '1 beendete Fassung' : $ended.' beendete Fassungen', 'ton' => 'leise'];
}
$url = OfferResource::getUrl('view', ['record' => $offer]);
$rows[] = [
'schluessel' => 'o'.$offer->id,
'titel' => $offer->name,
'meta' => 'Angebot',
'text' => $text,
'symbol' => 'etikett',
'url' => $url,
'chips' => $chips,
'zustand' => $zustand,
'aktionen' => [['label' => 'Öffnen', 'href' => $url]],
];
}
return $rows;
}
protected function zustandOptionen(): array
{
return ['alle' => 'Jeder Zustand', 'aktiv' => 'Mit aktiver Fassung', 'ohne' => 'Ohne aktive Fassung'];
}
protected function einheit(): array
{
return ['Angebot', 'Angebote'];
}
protected function leer(): array
{
return ['titel' => 'Noch keine Angebote', 'text' => 'Mit „Angebot anlegen“ oben entsteht das erste Angebot.'];
}
}