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:
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user