- Added maximum discount settings configurable by the administrator. - Implemented discount calculations in the quote confirmation process. - Introduced transport options with associated costs, including handling for exceeding maximum piece limits. - Updated frontend to display discounts and transport information in the quote summary. - Created new database migrations for storing discount and transport settings. - Developed a new Filament page for managing global discount settings. - Enhanced email templates to include discount and transport details. - Added tests to ensure proper functionality of discounts and transport calculations.
61 lines
2.4 KiB
PHP
61 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\PreventivoResource\Pages;
|
|
|
|
use App\Filament\Resources\PreventivoResource;
|
|
use App\Support\PreventivoPdf;
|
|
use Filament\Actions;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Resources\Pages\ViewRecord;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class ViewPreventivo extends ViewRecord
|
|
{
|
|
protected static string $resource = PreventivoResource::class;
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Actions\Action::make('visualizzaPdf')
|
|
->label('Visualizza PDF')
|
|
->icon('heroicon-o-eye')
|
|
->color('gray')
|
|
->visible(fn () => $this->record->stato !== 'bozza')
|
|
->url(fn () => route('preventivi.pdf.show', $this->record))
|
|
->openUrlInNewTab(),
|
|
Actions\Action::make('scaricaPdf')
|
|
->label('Scarica PDF')
|
|
->icon('heroicon-o-arrow-down-tray')
|
|
->color('gray')
|
|
->visible(fn () => $this->record->stato !== 'bozza')
|
|
->action(function () {
|
|
if (! $this->record->pdf_path || ! Storage::disk('local')->exists($this->record->pdf_path)) {
|
|
$this->record->pdf_path = PreventivoPdf::genera($this->record);
|
|
$this->record->save();
|
|
}
|
|
|
|
return Storage::disk('local')->download(
|
|
$this->record->pdf_path,
|
|
'preventivo-'.$this->record->numero.'.pdf'
|
|
);
|
|
}),
|
|
// Il PDF è salvato alla conferma e poi riservito così com'è: dopo modifiche al
|
|
// template o ai dati va rigenerato.
|
|
Actions\Action::make('rigeneraPdf')
|
|
->label('Rigenera PDF')
|
|
->icon('heroicon-o-arrow-path')
|
|
->color('gray')
|
|
->visible(fn () => $this->record->stato !== 'bozza')
|
|
->requiresConfirmation()
|
|
->modalDescription('Il PDF verrà ricreato con il modello e i dati attuali, sostituendo quello salvato.')
|
|
->action(function () {
|
|
$this->record->pdf_path = PreventivoPdf::genera($this->record);
|
|
$this->record->save();
|
|
|
|
Notification::make()->title('PDF rigenerato')->success()->send();
|
|
}),
|
|
Actions\EditAction::make(),
|
|
];
|
|
}
|
|
}
|