From c556a4910bfd5fa65165bc7983b5ef6e8cee9f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Bra=C3=B1a?= Date: Mon, 25 May 2026 17:21:25 +0200 Subject: [PATCH] feat: Add Excel export functionality for reports (projects, phases, inspections) using maatwebsite/excel --- app/Exports/InspectionsExport.php | 38 ++ app/Exports/PhasesExport.php | 38 ++ app/Exports/ProjectsExport.php | 38 ++ .../Controllers/Reports/ExportController.php | 31 + composer.json | 1 + composer.lock | 593 +++++++++++++++++- .../reports/reports-dashboard.blade.php | 1 + routes/web.php | 7 +- 8 files changed, 745 insertions(+), 2 deletions(-) create mode 100644 app/Exports/InspectionsExport.php create mode 100644 app/Exports/PhasesExport.php create mode 100644 app/Exports/ProjectsExport.php create mode 100644 app/Http/Controllers/Reports/ExportController.php diff --git a/app/Exports/InspectionsExport.php b/app/Exports/InspectionsExport.php new file mode 100644 index 0000000..06d156a --- /dev/null +++ b/app/Exports/InspectionsExport.php @@ -0,0 +1,38 @@ +get(); + } + + public function headings(): array + { + return [ + 'ID', + 'ID Proyecto', + 'ID Característica', + 'ID Plantilla', + 'Estado', + 'Notas', + 'Creado el', + 'Actualizado el' + ]; + } +} diff --git a/app/Exports/PhasesExport.php b/app/Exports/PhasesExport.php new file mode 100644 index 0000000..3df9db4 --- /dev/null +++ b/app/Exports/PhasesExport.php @@ -0,0 +1,38 @@ +get(); + } + + public function headings(): array + { + return [ + 'ID', + 'ID Proyecto', + 'Nombre', + 'Progreso (%)', + 'Fecha de inicio', + 'Fecha de fin', + 'Creado el', + 'Actualizado el' + ]; + } +} diff --git a/app/Exports/ProjectsExport.php b/app/Exports/ProjectsExport.php new file mode 100644 index 0000000..3ad7ad6 --- /dev/null +++ b/app/Exports/ProjectsExport.php @@ -0,0 +1,38 @@ +get(); + } + + public function headings(): array + { + return [ + 'ID', + 'Nombre', + 'Descripción', + 'Fecha de inicio', + 'Fecha de fin', + 'Estado', + 'Creado el', + 'Actualizado el' + ]; + } +} diff --git a/app/Http/Controllers/Reports/ExportController.php b/app/Http/Controllers/Reports/ExportController.php new file mode 100644 index 0000000..8f66457 --- /dev/null +++ b/app/Http/Controllers/Reports/ExportController.php @@ -0,0 +1,31 @@ +=7.4.0 <8.5.0", + "psr/simple-cache": "^1.0 || ^2.0 || ^3.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-main", + "doctrine/instantiator": "^1.5", + "dompdf/dompdf": "^1.0 || ^2.0 || ^3.0", + "friendsofphp/php-cs-fixer": "^3.2", + "mitoteam/jpgraph": "^10.3", + "mpdf/mpdf": "^8.1.1", + "phpcompatibility/php-compatibility": "^9.3", + "phpstan/phpstan": "^1.1", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^8.5 || ^9.0", + "squizlabs/php_codesniffer": "^3.7", + "tecnickcom/tcpdf": "^6.5" + }, + "suggest": { + "dompdf/dompdf": "Option for rendering PDF with PDF Writer", + "ext-intl": "PHP Internationalization Functions", + "mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers", + "mpdf/mpdf": "Option for rendering PDF with PDF Writer", + "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer" + }, + "type": "library", + "autoload": { + "psr-4": { + "PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maarten Balliauw", + "homepage": "https://blog.maartenballiauw.be" + }, + { + "name": "Mark Baker", + "homepage": "https://markbakeruk.net" + }, + { + "name": "Franck Lefevre", + "homepage": "https://rootslabs.net" + }, + { + "name": "Erik Tilt" + }, + { + "name": "Adrien Crivelli" + }, + { + "name": "Owen Leibman" + } + ], + "description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", + "homepage": "https://github.com/PHPOffice/PhpSpreadsheet", + "keywords": [ + "OpenXML", + "excel", + "gnumeric", + "ods", + "php", + "spreadsheet", + "xls", + "xlsx" + ], + "support": { + "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues", + "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.30.4" + }, + "time": "2026-04-19T06:00:39+00:00" + }, { "name": "phpoption/phpoption", "version": "1.9.5", diff --git a/resources/views/livewire/reports/reports-dashboard.blade.php b/resources/views/livewire/reports/reports-dashboard.blade.php index 33553c4..570e574 100644 --- a/resources/views/livewire/reports/reports-dashboard.blade.php +++ b/resources/views/livewire/reports/reports-dashboard.blade.php @@ -1,6 +1,7 @@

Reportes y Analítica

+
diff --git a/routes/web.php b/routes/web.php index 26d54d3..a3fc439 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,7 +1,7 @@ group(function () { ]); })->name('dashboard'); Route::get('/reports/dashboard', ReportsDashboard::class)->name('reports.dashboard'); + Route::prefix('reports')->name('reports.')->group(function () { + Route::get('export/projects', [App\Http\Controllers\Reports\ExportController::class, 'exportProjects'])->name('export.projects'); + Route::get('export/phases', [App\Http\Controllers\Reports\ExportController::class, 'exportPhases'])->name('export.phases'); + Route::get('export/inspections', [App\Http\Controllers\Reports\ExportController::class, 'exportInspections'])->name('export.inspections'); + }); // ------------------------------------------------------------ // Gestión de proyectos (CRUD completo)