diff --git a/app/Exports/Pdf.php b/app/Exports/Pdf.php new file mode 100644 index 00000000..a73c507a --- /dev/null +++ b/app/Exports/Pdf.php @@ -0,0 +1,49 @@ +reportService->getVerticalSubHeader(); +// $horizontalSubHeader = $this->reportService->getHorizontalSubHeader(); +// $firstHeaderElementColSpan = $verticalSubHeader ? 2 : 1; +// $firstHeaderElementRowSpan = $horizontalSubHeader ? 2 : 1; + + return view('exports.export_pdf', [ +// 'reportData' => $this->reportService->getReportData(), +// 'header' => $this->reportService->getHorizontalHeader(), +// 'subHeader' => $horizontalSubHeader, +// 'subHeaderKey' => $this->reportService->getSubHeaderKey(), +// 'verticalHeader' => $this->reportService->getVerticalHeader(), +// 'verticalHeaderKey' => $this->reportService->getVerticalHeaderKey(), +// 'verticalSubHeader' => $verticalSubHeader, +// 'verticalSubHeaderKey' => $this->reportService->getVerticalSubHeaderKey(), +// 'firstHeaderElementColSpan' => $firstHeaderElementColSpan, +// 'firstHeaderElementRowSpan' => $firstHeaderElementRowSpan, + ]); + } +} diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Actions/ExportPdf.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Actions/ExportPdf.php new file mode 100644 index 00000000..e361df86 --- /dev/null +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Actions/ExportPdf.php @@ -0,0 +1,64 @@ +action(function () { + $infolist = Infolist::make() + ->record($this->getRecord()) + ->schema($this->schema); + + $html = view('exports.pdf-page', ['infolist' => $infolist])->render(); +// dd($html); + + return response()->streamDownload(function () use ($infolist) { + echo \Barryvdh\DomPDF\Facade\Pdf::loadHtml( + Blade::render('exports.pdf-page', ['infolist' => $infolist]) + ) +// ->setOptions(['defaultFont' => filament()->getFontFamily()], true) +// ->setOptions(['defaultFont' => 'identity'], true) + ->stream(); + }, 'test' . '.pdf'); + +// return \Barryvdh\DomPDF\Facade\Pdf::loadView('exports.pdf-page', ['infolist' => $infolist]) +// ->download('dasda.pdf') +// ->save(storage_path('app/public/exports.pdf')) +// ; +// ->download(); +// return Pdf::html($html)->download('close_file.pdf'); +// Pdf::view('exports.pdf-page', ['infolist' => $infolist]) +// ->name('close_file.pdf') +// ->download(); +// ->save(storage_path('app/public/exports.pdf')); +// return dd(); +// ->download(); + + }); + } + + public function schema(array|\Closure|null $schema): self + { + $this->schema = $schema; + + return $this; + } + + public function getName(): ?string + { + return 'export_pdf'; + } +} diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Actions/ExportPdf2.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Actions/ExportPdf2.php new file mode 100644 index 00000000..8bbf9f2e --- /dev/null +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Actions/ExportPdf2.php @@ -0,0 +1,45 @@ +exporter(\App\Exports\Pdf::class); + parent::setUp(); + +// $this->action(function () { +// $infolist = Infolist::make() +// ->record($this->getRecord()) +// ->schema($this->schema); +// +// dd(Pdf::view('exports.pdf-page', ['infolist' => $infolist])); +//// ->save(storage_path('app/public/exports.pdf')); +// return dd(); +//// ->download(); +// +// }); + } + + public function schema(array|\Closure|null $schema): self + { + $this->schema = $schema; + + return $this; + } + + public function getName(): ?string + { + return 'export_pdf_2'; + } +} diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/CloseFile/ViewCloseFile.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/CloseFile/ViewCloseFile.php index b4a63d30..9271a832 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/CloseFile/ViewCloseFile.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/CloseFile/ViewCloseFile.php @@ -33,9 +33,48 @@ public function getBreadcrumbs(): array ->getBreadcrumbs('view_close_file'); } + /** + * @return array + */ + public function getFileDetailsSchema(): array + { + return [ + TextEntry::make('date') + ->label(__('beneficiary.section.close_file.labels.date')), + + TextEntry::make('number') + ->label(__('beneficiary.section.close_file.labels.number')), + + TextEntry::make('admittance_date') + ->label(__('beneficiary.section.close_file.labels.admittance_date')), + + TextEntry::make('exit_date') + ->label(__('beneficiary.section.close_file.labels.exit_date')), + + TextEntry::make('caseManager.name_role') + ->label(__('beneficiary.section.close_file.labels.case_manager')), + + ]; + } + protected function getHeaderActions(): array { return [ + BeneficiaryResource\Actions\ExportPdf::make() + ->schema([ + TextEntry::make('status') + ->badge(), + + Section::make('asdasdasd') + ->columns() + ->relationship('closeFile') + ->schema($this->getFileDetailsSchema()), + ]), + + BeneficiaryResource\Actions\ExportPdf2::make() + ->exporter(\App\Exports\Pdf::class) + ->schema($this->getFileDetailsSchema()), + DeleteAction::make() ->label(__('beneficiary.section.close_file.actions.delete')) ->outlined() @@ -70,23 +109,7 @@ public function infolist(Infolist $infolist): Infolist Edit::make('edit_details') ->url(self::getResource()::getUrl('edit_close_file_details', ['record' => $this->getRecord()])), ]) - ->schema([ - TextEntry::make('date') - ->label(__('beneficiary.section.close_file.labels.date')), - - TextEntry::make('number') - ->label(__('beneficiary.section.close_file.labels.number')), - - TextEntry::make('admittance_date') - ->label(__('beneficiary.section.close_file.labels.admittance_date')), - - TextEntry::make('exit_date') - ->label(__('beneficiary.section.close_file.labels.exit_date')), - - TextEntry::make('caseManager.name_role') - ->label(__('beneficiary.section.close_file.labels.case_manager')), - - ]), + ->schema($this->getFileDetailsSchema()), ]), Tabs\Tab::make(__('beneficiary.section.identity.tab.beneficiary')) ->maxWidth('3xl') diff --git a/composer.json b/composer.json index dcbf5323..5c6a7aed 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,7 @@ "php": "^8.2", "alcea/cnp": "^3.0", "awcodes/filament-table-repeater": "^2.0", + "barryvdh/laravel-dompdf": "^3.0", "blade-ui-kit/blade-icons": "^1.6", "filament/filament": "^3.2", "filament/spatie-laravel-media-library-plugin": "^3.2", @@ -29,6 +30,7 @@ "pxlrbt/filament-excel": "^2.3", "sentry/sentry-laravel": "^4.7", "spatie/laravel-activitylog": "^4.8", + "spatie/laravel-pdf": "^1.5", "staudenmeir/belongs-to-through": "^2.5", "staudenmeir/eloquent-has-many-deep": "^1.7", "stevegrunwell/time-constants": "^1.2", diff --git a/composer.lock b/composer.lock index 5083bbfd..d936fa40 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "77a87cd0a837eb42445fb405700bae16", + "content-hash": "398f2eea021c24e527abcbc7d8b9c459", "packages": [ { "name": "alcea/cnp", @@ -409,6 +409,83 @@ }, "time": "2024-10-01T13:55:55+00:00" }, + { + "name": "barryvdh/laravel-dompdf", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-dompdf.git", + "reference": "2d814cd25e299be022a4fa0fb4509d7ccd353d8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-dompdf/zipball/2d814cd25e299be022a4fa0fb4509d7ccd353d8a", + "reference": "2d814cd25e299be022a4fa0fb4509d7ccd353d8a", + "shasum": "" + }, + "require": { + "dompdf/dompdf": "^3.0", + "illuminate/support": "^9|^10|^11", + "php": "^8.1" + }, + "require-dev": { + "larastan/larastan": "^2.7.0", + "orchestra/testbench": "^7|^8|^9", + "phpro/grumphp": "^2.5", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "PDF": "Barryvdh\\DomPDF\\Facade\\Pdf", + "Pdf": "Barryvdh\\DomPDF\\Facade\\Pdf" + }, + "providers": [ + "Barryvdh\\DomPDF\\ServiceProvider" + ] + }, + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Barryvdh\\DomPDF\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "A DOMPDF Wrapper for Laravel", + "keywords": [ + "dompdf", + "laravel", + "pdf" + ], + "support": { + "issues": "https://github.com/barryvdh/laravel-dompdf/issues", + "source": "https://github.com/barryvdh/laravel-dompdf/tree/v3.0.0" + }, + "funding": [ + { + "url": "https://fruitcake.nl", + "type": "custom" + }, + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], + "time": "2024-07-31T14:45:16+00:00" + }, { "name": "blade-ui-kit/blade-heroicons", "version": "2.4.0", @@ -1511,6 +1588,161 @@ ], "time": "2024-02-05T11:56:58+00:00" }, + { + "name": "dompdf/dompdf", + "version": "v3.0.1", + "source": { + "type": "git", + "url": "https://github.com/dompdf/dompdf.git", + "reference": "2d622faf9aa1f8f7f24dd094e49b5cf6c0c5d4e6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dompdf/dompdf/zipball/2d622faf9aa1f8f7f24dd094e49b5cf6c0c5d4e6", + "reference": "2d622faf9aa1f8f7f24dd094e49b5cf6c0c5d4e6", + "shasum": "" + }, + "require": { + "dompdf/php-font-lib": "^1.0.0", + "dompdf/php-svg-lib": "^1.0.0", + "ext-dom": "*", + "ext-mbstring": "*", + "masterminds/html5": "^2.0", + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "ext-gd": "*", + "ext-json": "*", + "ext-zip": "*", + "mockery/mockery": "^1.3", + "phpunit/phpunit": "^7.5 || ^8 || ^9 || ^10", + "squizlabs/php_codesniffer": "^3.5", + "symfony/process": "^4.4 || ^5.4 || ^6.2 || ^7.0" + }, + "suggest": { + "ext-gd": "Needed to process images", + "ext-gmagick": "Improves image processing performance", + "ext-imagick": "Improves image processing performance", + "ext-zlib": "Needed for pdf stream compression" + }, + "type": "library", + "autoload": { + "psr-4": { + "Dompdf\\": "src/" + }, + "classmap": [ + "lib/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1" + ], + "authors": [ + { + "name": "The Dompdf Community", + "homepage": "https://github.com/dompdf/dompdf/blob/master/AUTHORS.md" + } + ], + "description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter", + "homepage": "https://github.com/dompdf/dompdf", + "support": { + "issues": "https://github.com/dompdf/dompdf/issues", + "source": "https://github.com/dompdf/dompdf/tree/v3.0.1" + }, + "time": "2024-12-05T14:59:38+00:00" + }, + { + "name": "dompdf/php-font-lib", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/dompdf/php-font-lib.git", + "reference": "6137b7d4232b7f16c882c75e4ca3991dbcf6fe2d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dompdf/php-font-lib/zipball/6137b7d4232b7f16c882c75e4ca3991dbcf6fe2d", + "reference": "6137b7d4232b7f16c882c75e4ca3991dbcf6fe2d", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "^3 || ^4 || ^5 || ^6" + }, + "type": "library", + "autoload": { + "psr-4": { + "FontLib\\": "src/FontLib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1-or-later" + ], + "authors": [ + { + "name": "The FontLib Community", + "homepage": "https://github.com/dompdf/php-font-lib/blob/master/AUTHORS.md" + } + ], + "description": "A library to read, parse, export and make subsets of different types of font files.", + "homepage": "https://github.com/dompdf/php-font-lib", + "support": { + "issues": "https://github.com/dompdf/php-font-lib/issues", + "source": "https://github.com/dompdf/php-font-lib/tree/1.0.1" + }, + "time": "2024-12-02T14:37:59+00:00" + }, + { + "name": "dompdf/php-svg-lib", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/dompdf/php-svg-lib.git", + "reference": "eb045e518185298eb6ff8d80d0d0c6b17aecd9af" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dompdf/php-svg-lib/zipball/eb045e518185298eb6ff8d80d0d0c6b17aecd9af", + "reference": "eb045e518185298eb6ff8d80d0d0c6b17aecd9af", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^7.1 || ^8.0", + "sabberworm/php-css-parser": "^8.4" + }, + "require-dev": { + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Svg\\": "src/Svg" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "The SvgLib Community", + "homepage": "https://github.com/dompdf/php-svg-lib/blob/master/AUTHORS.md" + } + ], + "description": "A library to read, parse and export to PDF SVG files.", + "homepage": "https://github.com/dompdf/php-svg-lib", + "support": { + "issues": "https://github.com/dompdf/php-svg-lib/issues", + "source": "https://github.com/dompdf/php-svg-lib/tree/1.0.0" + }, + "time": "2024-04-29T13:26:35+00:00" + }, { "name": "dragonmantank/cron-expression", "version": "v3.4.0", @@ -6471,6 +6703,71 @@ ], "time": "2024-02-26T18:08:49+00:00" }, + { + "name": "sabberworm/php-css-parser", + "version": "v8.7.0", + "source": { + "type": "git", + "url": "https://github.com/MyIntervals/PHP-CSS-Parser.git", + "reference": "f414ff953002a9b18e3a116f5e462c56f21237cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MyIntervals/PHP-CSS-Parser/zipball/f414ff953002a9b18e3a116f5e462c56f21237cf", + "reference": "f414ff953002a9b18e3a116f5e462c56f21237cf", + "shasum": "" + }, + "require": { + "ext-iconv": "*", + "php": "^5.6.20 || ^7.0.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" + }, + "require-dev": { + "phpunit/phpunit": "5.7.27 || 6.5.14 || 7.5.20 || 8.5.40" + }, + "suggest": { + "ext-mbstring": "for parsing UTF-8 CSS" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "9.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Sabberworm\\CSS\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Raphael Schweikert" + }, + { + "name": "Oliver Klee", + "email": "github@oliverklee.de" + }, + { + "name": "Jake Hotson", + "email": "jake.github@qzdesign.co.uk" + } + ], + "description": "Parser for CSS Files written in PHP", + "homepage": "https://www.sabberworm.com/blog/2010/6/10/php-css-parser", + "keywords": [ + "css", + "parser", + "stylesheet" + ], + "support": { + "issues": "https://github.com/MyIntervals/PHP-CSS-Parser/issues", + "source": "https://github.com/MyIntervals/PHP-CSS-Parser/tree/v8.7.0" + }, + "time": "2024-10-27T17:38:32+00:00" + }, { "name": "sentry/sentry", "version": "4.9.0", @@ -6649,6 +6946,74 @@ ], "time": "2024-09-19T12:58:53+00:00" }, + { + "name": "spatie/browsershot", + "version": "4.4.0", + "source": { + "type": "git", + "url": "https://github.com/spatie/browsershot.git", + "reference": "3ff350cd0a36943759e2932a27d8cd18c11e5fdc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/browsershot/zipball/3ff350cd0a36943759e2932a27d8cd18c11e5fdc", + "reference": "3ff350cd0a36943759e2932a27d8cd18c11e5fdc", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "ext-json": "*", + "php": "^8.2", + "spatie/temporary-directory": "^2.0", + "symfony/process": "^6.0|^7.0" + }, + "require-dev": { + "pestphp/pest": "^1.20", + "spatie/image": "^3.6", + "spatie/pdf-to-text": "^1.52", + "spatie/phpunit-snapshot-assertions": "^4.2.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\Browsershot\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://github.com/freekmurze", + "role": "Developer" + } + ], + "description": "Convert a webpage to an image or pdf using headless Chrome", + "homepage": "https://github.com/spatie/browsershot", + "keywords": [ + "chrome", + "convert", + "headless", + "image", + "pdf", + "puppeteer", + "screenshot", + "webpage" + ], + "support": { + "source": "https://github.com/spatie/browsershot/tree/4.4.0" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2024-11-25T16:02:22+00:00" + }, { "name": "spatie/color", "version": "1.6.0", @@ -7155,6 +7520,91 @@ ], "time": "2024-08-27T18:56:10+00:00" }, + { + "name": "spatie/laravel-pdf", + "version": "1.5.2", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-pdf.git", + "reference": "fadf23c6249c491fd4924f8ec37166a283269966" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-pdf/zipball/fadf23c6249c491fd4924f8ec37166a283269966", + "reference": "fadf23c6249c491fd4924f8ec37166a283269966", + "shasum": "" + }, + "require": { + "illuminate/contracts": "^10.0|^11.0", + "php": "^8.2", + "spatie/browsershot": "^4.0", + "spatie/laravel-package-tools": "^1.16.1", + "spatie/temporary-directory": "^2.2.1" + }, + "require-dev": { + "ext-imagick": "*", + "larastan/larastan": "^2.7.0", + "laravel/pint": "^1.13.7", + "nunomaduro/collision": "^7.10", + "orchestra/testbench": "^8.18", + "pestphp/pest": "^2.30", + "pestphp/pest-plugin-arch": "^2.5", + "pestphp/pest-plugin-laravel": "^2.2", + "phpstan/extension-installer": "^1.3.1", + "phpstan/phpstan-deprecation-rules": "^1.1.4", + "phpstan/phpstan-phpunit": "^1.3.15", + "spatie/image": "^3.3.2", + "spatie/laravel-ray": "^1.33", + "spatie/pdf-to-image": "^2.2", + "spatie/pdf-to-text": "^1.52.1", + "spatie/pest-expectations": "^1.5", + "spatie/pest-plugin-snapshots": "^2.1", + "spatie/pixelmatch-php": "^1.0", + "wnx/sidecar-browsershot": "^2.0" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "LaravelPdf": "Pdf" + }, + "providers": [ + "Spatie\\LaravelPdf\\PdfServiceProvider" + ] + } + }, + "autoload": { + "files": [ + "src/Support/functions.php" + ], + "psr-4": { + "Spatie\\LaravelPdf\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "role": "Developer" + } + ], + "description": "Create PDFs in Laravel apps", + "homepage": "https://github.com/spatie/laravel-pdf", + "keywords": [ + "laravel", + "laravel-pdf", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/laravel-pdf/issues", + "source": "https://github.com/spatie/laravel-pdf/tree/1.5.2" + }, + "time": "2024-07-16T07:42:10+00:00" + }, { "name": "spatie/temporary-directory", "version": "2.2.1", @@ -15015,12 +15465,12 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": true, "prefer-lowest": false, "platform": { "php": "^8.2" }, - "platform-dev": {}, - "plugin-api-version": "2.6.0" + "platform-dev": [], + "plugin-api-version": "2.2.0" } diff --git a/resources/views/exports/pdf-page.blade.php b/resources/views/exports/pdf-page.blade.php new file mode 100644 index 00000000..0b6ea33a --- /dev/null +++ b/resources/views/exports/pdf-page.blade.php @@ -0,0 +1,96 @@ +{{----}} + + + + + + + + + @php + $title = trim(strip_tags(($livewire ?? null)?->getTitle() ?? '')); + $brandName = trim(strip_tags(filament()->getBrandName())); + @endphp + + + {{ filled($title) ? "{$title} - " : null }} {{ $brandName }} + + + + + + @filamentStyles + + {{ filament()->getTheme()->getHtml() }} +{{-- {{ filament()->getFontHtml() }}--}} + + + + @stack('styles') + + + @if (! filament()->hasDarkMode()) + + @elseif (filament()->hasDarkModeForced()) + + @else + + @endif + + + + + +{{-- --}} + + {{ $infolist }} + +{{-- --}} + +