Faza 8: PDF generation pentru fișa lucru (DomPDF)

- barryvdh/laravel-dompdf instalat
- WorkOrderPdfService: încarcă WO cu toate relațiile (works/parts/payments),
  embed-ează logo ca data URI, foloseste theme_color din settings
- Blade template /resources/views/pdf/work-order.blade.php:
  - Header cu logo + date companie + nr fișă + data
  - Box-uri client + auto (kilometraj/VIN/plate)
  - Plângere + diagnostic
  - Tabel manopere (h, preț/h, total) cu maistru pe fiecare rând
  - Tabel piese (cod, brand, qty, preț, total)
  - Box total cu discount + plăți efectuate + rest de achitat
  - Block recomandări cu fundal galben (warning)
  - Linii semnătură client + maistru
  - Footer cu timestamp generare
- Action 'PDF' (icon descărcare) pe rând în lista de WO
- Action 'Descarcă PDF' în header-ul paginii Edit WO
This commit is contained in:
2026-05-07 13:01:42 +00:00
parent f1d196f018
commit 19a7afac27
6 changed files with 904 additions and 2 deletions
@@ -134,6 +134,19 @@ class WorkOrderResource extends Resource
->options(fn () => User::pluck('name', 'id')),
])
->actions([
Actions\Action::make('pdf')
->label('PDF')
->icon('heroicon-m-document-arrow-down')
->color('gray')
->action(function (WorkOrder $r) {
$svc = app(\App\Services\WorkOrderPdfService::class);
$pdf = $svc->generate($r);
$filename = $svc->filename($r);
return response()->streamDownload(
fn () => print($pdf->output()),
$filename
);
}),
Actions\EditAction::make(),
Actions\DeleteAction::make(),
])
@@ -3,6 +3,8 @@
namespace App\Filament\Tenant\Resources\WorkOrderResource\Pages;
use App\Filament\Tenant\Resources\WorkOrderResource;
use App\Models\Tenant\WorkOrder;
use App\Services\WorkOrderPdfService;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
@@ -12,6 +14,22 @@ class EditWorkOrder extends EditRecord
protected function getHeaderActions(): array
{
return [Actions\DeleteAction::make()];
return [
Actions\Action::make('pdf')
->label('Descarcă PDF')
->icon('heroicon-m-document-arrow-down')
->color('gray')
->action(function () {
/** @var WorkOrder $wo */
$wo = $this->record;
$svc = app(WorkOrderPdfService::class);
$pdf = $svc->generate($wo);
return response()->streamDownload(
fn () => print($pdf->output()),
$svc->filename($wo)
);
}),
Actions\DeleteAction::make(),
];
}
}