From cc9baaea4b7258273f04165cfcfee25ce86b69c6 Mon Sep 17 00:00:00 2001 From: Andrew Wallo Date: Sun, 8 Dec 2024 21:41:24 -0500 Subject: [PATCH 1/8] wip --- .../InvoiceResource/Pages/ViewInvoice.php | 84 +++++---- .../PaymentsRelationManager.php | 2 + composer.lock | 76 ++++---- .../company/invoice/container.blade.php | 12 +- .../company/invoice/footer.blade.php | 2 +- .../invoice-layouts/classic.blade.php | 2 +- .../invoice-layouts/default.blade.php | 2 +- .../invoice-layouts/modern.blade.php | 2 +- .../components/invoice-view.blade.php | 169 ++++++++++++++++++ .../invoices/pages/view-invoice.blade.php | 47 +++++ 10 files changed, 321 insertions(+), 77 deletions(-) create mode 100644 resources/views/filament/company/resources/sales/invoices/components/invoice-view.blade.php create mode 100644 resources/views/filament/company/resources/sales/invoices/pages/view-invoice.blade.php diff --git a/app/Filament/Company/Resources/Sales/InvoiceResource/Pages/ViewInvoice.php b/app/Filament/Company/Resources/Sales/InvoiceResource/Pages/ViewInvoice.php index 7ceb1dc5..4d93c73d 100644 --- a/app/Filament/Company/Resources/Sales/InvoiceResource/Pages/ViewInvoice.php +++ b/app/Filament/Company/Resources/Sales/InvoiceResource/Pages/ViewInvoice.php @@ -6,22 +6,32 @@ use App\Filament\Company\Resources\Sales\InvoiceResource; use App\Models\Accounting\Invoice; use Filament\Actions; +use Filament\Infolists\Components\Grid; use Filament\Infolists\Components\Section; use Filament\Infolists\Components\TextEntry; +use Filament\Infolists\Components\ViewEntry; use Filament\Infolists\Infolist; use Filament\Resources\Pages\ViewRecord; use Filament\Support\Enums\FontWeight; use Filament\Support\Enums\IconPosition; use Filament\Support\Enums\IconSize; +use Filament\Support\Enums\MaxWidth; class ViewInvoice extends ViewRecord { + protected static string $view = 'filament.company.resources.sales.invoices.pages.view-invoice'; + protected static string $resource = InvoiceResource::class; protected $listeners = [ 'refresh' => '$refresh', ]; + public function getMaxContentWidth(): MaxWidth | string | null + { + return MaxWidth::SixExtraLarge; + } + protected function getHeaderActions(): array { return [ @@ -49,39 +59,47 @@ public function infolist(Infolist $infolist): Infolist Section::make('Invoice Details') ->columns(4) ->schema([ - TextEntry::make('invoice_number') - ->label('Invoice #'), - TextEntry::make('status') - ->badge(), - TextEntry::make('client.name') - ->label('Client') - ->color('primary') - ->weight(FontWeight::SemiBold) - ->url(static fn (Invoice $record) => ClientResource::getUrl('edit', ['record' => $record->client_id])), - TextEntry::make('total') - ->label('Total') - ->money(), - TextEntry::make('amount_due') - ->label('Amount Due') - ->money(), - TextEntry::make('date') - ->label('Date') - ->date(), - TextEntry::make('due_date') - ->label('Due') - ->asRelativeDay(), - TextEntry::make('approved_at') - ->label('Approved At') - ->placeholder('Not Approved') - ->date(), - TextEntry::make('last_sent') - ->label('Last Sent') - ->placeholder('Never') - ->date(), - TextEntry::make('paid_at') - ->label('Paid At') - ->placeholder('Not Paid') - ->date(), + Grid::make(1) + ->schema([ + TextEntry::make('invoice_number') + ->label('Invoice #'), + TextEntry::make('status') + ->badge(), + TextEntry::make('client.name') + ->label('Client') + ->color('primary') + ->weight(FontWeight::SemiBold) + ->url(static fn (Invoice $record) => ClientResource::getUrl('edit', ['record' => $record->client_id])), + TextEntry::make('amount_due') + ->label('Amount Due') + ->money(), + TextEntry::make('due_date') + ->label('Due') + ->asRelativeDay(), + TextEntry::make('approved_at') + ->label('Approved At') + ->placeholder('Not Approved') + ->date(), + TextEntry::make('last_sent') + ->label('Last Sent') + ->placeholder('Never') + ->date(), + TextEntry::make('paid_at') + ->label('Paid At') + ->placeholder('Not Paid') + ->date(), + ])->columnSpan(1), + Grid::make() + ->schema([ + ViewEntry::make('invoice-view') + ->label('View Invoice') + ->columnSpan(3) + ->view('filament.company.resources.sales.invoices.components.invoice-view') + ->viewData([ + 'invoice' => $this->record, + ]), + ]) + ->columnSpan(3), ]), ]); } diff --git a/app/Filament/Company/Resources/Sales/InvoiceResource/RelationManagers/PaymentsRelationManager.php b/app/Filament/Company/Resources/Sales/InvoiceResource/RelationManagers/PaymentsRelationManager.php index 54cef717..f077bf6d 100644 --- a/app/Filament/Company/Resources/Sales/InvoiceResource/RelationManagers/PaymentsRelationManager.php +++ b/app/Filament/Company/Resources/Sales/InvoiceResource/RelationManagers/PaymentsRelationManager.php @@ -28,6 +28,8 @@ class PaymentsRelationManager extends RelationManager protected static ?string $modelLabel = 'Payment'; + protected static bool $isLazy = false; + protected $listeners = [ 'refresh' => '$refresh', ]; diff --git a/composer.lock b/composer.lock index c5f32d05..26485829 100644 --- a/composer.lock +++ b/composer.lock @@ -256,12 +256,12 @@ "type": "library", "extra": { "laravel": { - "providers": [ - "Wallo\\Transmatic\\TransmaticServiceProvider" - ], "aliases": { "Transmatic": "Wallo\\Transmatic\\Facades\\Transmatic" - } + }, + "providers": [ + "Wallo\\Transmatic\\TransmaticServiceProvider" + ] } }, "autoload": { @@ -1317,29 +1317,27 @@ }, { "name": "doctrine/deprecations", - "version": "1.1.3", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab" + "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", - "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/31610dbb31faa98e6b5447b62340826f54fbc4e9", + "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^9", - "phpstan/phpstan": "1.4.10 || 1.10.15", - "phpstan/phpstan-phpunit": "^1.0", + "doctrine/coding-standard": "^9 || ^12", + "phpstan/phpstan": "1.4.10 || 2.0.3", + "phpstan/phpstan-phpunit": "^1.0 || ^2", "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "psalm/plugin-phpunit": "0.18.4", - "psr/log": "^1 || ^2 || ^3", - "vimeo/psalm": "4.30.0 || 5.12.0" + "psr/log": "^1 || ^2 || ^3" }, "suggest": { "psr/log": "Allows logging deprecations via PSR-3 logger implementation" @@ -1347,7 +1345,7 @@ "type": "library", "autoload": { "psr-4": { - "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" + "Doctrine\\Deprecations\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -1358,9 +1356,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.3" + "source": "https://github.com/doctrine/deprecations/tree/1.1.4" }, - "time": "2024-01-30T19:34:25+00:00" + "time": "2024-12-07T21:18:45+00:00" }, { "name": "doctrine/inflector", @@ -3706,16 +3704,16 @@ }, { "name": "league/csv", - "version": "9.18.0", + "version": "9.19.0", "source": { "type": "git", "url": "https://github.com/thephpleague/csv.git", - "reference": "b02d010e4055ae992247f6ffd1e7b103ef2a0790" + "reference": "f81df48a012a9e86d077e74eaff666fd15bfab88" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/csv/zipball/b02d010e4055ae992247f6ffd1e7b103ef2a0790", - "reference": "b02d010e4055ae992247f6ffd1e7b103ef2a0790", + "url": "https://api.github.com/repos/thephpleague/csv/zipball/f81df48a012a9e86d077e74eaff666fd15bfab88", + "reference": "f81df48a012a9e86d077e74eaff666fd15bfab88", "shasum": "" }, "require": { @@ -3727,12 +3725,12 @@ "ext-xdebug": "*", "friendsofphp/php-cs-fixer": "^3.64.0", "phpbench/phpbench": "^1.3.1", - "phpstan/phpstan": "^1.12.6", + "phpstan/phpstan": "^1.12.11", "phpstan/phpstan-deprecation-rules": "^1.2.1", - "phpstan/phpstan-phpunit": "^1.4.0", + "phpstan/phpstan-phpunit": "^1.4.1", "phpstan/phpstan-strict-rules": "^1.6.1", - "phpunit/phpunit": "^10.5.16 || ^11.4.1", - "symfony/var-dumper": "^6.4.8 || ^7.1.5" + "phpunit/phpunit": "^10.5.16 || ^11.4.3", + "symfony/var-dumper": "^6.4.8 || ^7.1.8" }, "suggest": { "ext-dom": "Required to use the XMLConverter and the HTMLConverter classes", @@ -3789,7 +3787,7 @@ "type": "github" } ], - "time": "2024-10-18T08:14:48+00:00" + "time": "2024-12-08T08:09:35+00:00" }, { "name": "league/flysystem", @@ -4057,20 +4055,20 @@ }, { "name": "league/uri", - "version": "7.4.1", + "version": "7.5.1", "source": { "type": "git", "url": "https://github.com/thephpleague/uri.git", - "reference": "bedb6e55eff0c933668addaa7efa1e1f2c417cc4" + "reference": "81fb5145d2644324614cc532b28efd0215bda430" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri/zipball/bedb6e55eff0c933668addaa7efa1e1f2c417cc4", - "reference": "bedb6e55eff0c933668addaa7efa1e1f2c417cc4", + "url": "https://api.github.com/repos/thephpleague/uri/zipball/81fb5145d2644324614cc532b28efd0215bda430", + "reference": "81fb5145d2644324614cc532b28efd0215bda430", "shasum": "" }, "require": { - "league/uri-interfaces": "^7.3", + "league/uri-interfaces": "^7.5", "php": "^8.1" }, "conflict": { @@ -4135,7 +4133,7 @@ "docs": "https://uri.thephpleague.com", "forum": "https://thephpleague.slack.com", "issues": "https://github.com/thephpleague/uri-src/issues", - "source": "https://github.com/thephpleague/uri/tree/7.4.1" + "source": "https://github.com/thephpleague/uri/tree/7.5.1" }, "funding": [ { @@ -4143,20 +4141,20 @@ "type": "github" } ], - "time": "2024-03-23T07:42:40+00:00" + "time": "2024-12-08T08:40:02+00:00" }, { "name": "league/uri-interfaces", - "version": "7.4.1", + "version": "7.5.0", "source": { "type": "git", "url": "https://github.com/thephpleague/uri-interfaces.git", - "reference": "8d43ef5c841032c87e2de015972c06f3865ef718" + "reference": "08cfc6c4f3d811584fb09c37e2849e6a7f9b0742" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/8d43ef5c841032c87e2de015972c06f3865ef718", - "reference": "8d43ef5c841032c87e2de015972c06f3865ef718", + "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/08cfc6c4f3d811584fb09c37e2849e6a7f9b0742", + "reference": "08cfc6c4f3d811584fb09c37e2849e6a7f9b0742", "shasum": "" }, "require": { @@ -4219,7 +4217,7 @@ "docs": "https://uri.thephpleague.com", "forum": "https://thephpleague.slack.com", "issues": "https://github.com/thephpleague/uri-src/issues", - "source": "https://github.com/thephpleague/uri-interfaces/tree/7.4.1" + "source": "https://github.com/thephpleague/uri-interfaces/tree/7.5.0" }, "funding": [ { @@ -4227,7 +4225,7 @@ "type": "github" } ], - "time": "2024-03-23T07:42:40+00:00" + "time": "2024-12-08T08:18:47+00:00" }, { "name": "livewire/livewire", diff --git a/resources/views/components/company/invoice/container.blade.php b/resources/views/components/company/invoice/container.blade.php index d42df72d..f18d432d 100644 --- a/resources/views/components/company/invoice/container.blade.php +++ b/resources/views/components/company/invoice/container.blade.php @@ -1,5 +1,15 @@ +@props([ + 'preview' => false, +]) +
-
+
$preview === false, + 'w-[38.25rem] h-[49.5rem] overflow-hidden' => $preview === true, + ]) + > {{ $slot }}
diff --git a/resources/views/components/company/invoice/footer.blade.php b/resources/views/components/company/invoice/footer.blade.php index 61d07797..983c9f44 100644 --- a/resources/views/components/company/invoice/footer.blade.php +++ b/resources/views/components/company/invoice/footer.blade.php @@ -1,3 +1,3 @@ -