backoffice first commit
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PreventivoResource\Pages;
|
||||
|
||||
use App\Filament\Resources\PreventivoResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreatePreventivo extends CreateRecord
|
||||
{
|
||||
protected static string $resource = PreventivoResource::class;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PreventivoResource\Pages;
|
||||
|
||||
use App\Filament\Resources\PreventivoResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditPreventivo extends EditRecord
|
||||
{
|
||||
protected static string $resource = PreventivoResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PreventivoResource\Pages;
|
||||
|
||||
use App\Filament\Resources\PreventivoResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListPreventivos extends ListRecords
|
||||
{
|
||||
protected static string $resource = PreventivoResource::class;
|
||||
|
||||
// Nessuna azione di creazione: i preventivi nascono dal configuratore.
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PreventivoResource\Pages;
|
||||
|
||||
use App\Filament\Resources\PreventivoResource;
|
||||
use App\Support\PreventivoPdf;
|
||||
use Filament\Actions;
|
||||
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'
|
||||
);
|
||||
}),
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PreventivoResource\RelationManagers;
|
||||
|
||||
use App\Support\ConfigurazioneFormatter;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ItemsRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'items';
|
||||
|
||||
protected static ?string $title = 'Prodotti configurati';
|
||||
|
||||
protected static ?string $modelLabel = 'prodotto';
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->recordTitleAttribute('nome_modello')
|
||||
->columns([
|
||||
Tables\Columns\ImageColumn::make('immagine_path')
|
||||
->label('Anteprima')
|
||||
->disk('public')
|
||||
->height(60)
|
||||
->square(),
|
||||
Tables\Columns\TextColumn::make('nome_modello')
|
||||
->label('Modello')
|
||||
->description(fn (Model $record) => trim(($record->sistema ? ucfirst($record->sistema) : '').' '.($record->type ?? ''))),
|
||||
Tables\Columns\TextColumn::make('dimensioni')
|
||||
->label('Dimensioni')
|
||||
->state(fn (Model $record) => $record->larghezza && $record->altezza
|
||||
? "{$record->larghezza} × {$record->altezza} cm" : '—'),
|
||||
Tables\Columns\TextColumn::make('quantita')->label('Q.tà'),
|
||||
Tables\Columns\TextColumn::make('prezzo_unitario')->label('Prezzo un.')->money('EUR'),
|
||||
Tables\Columns\TextColumn::make('prezzo_totale')->label('Totale')->money('EUR'),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make()
|
||||
->infolist(fn ($infolist) => $infolist->schema([
|
||||
\Filament\Infolists\Components\ImageEntry::make('immagine_path')
|
||||
->label('Anteprima')
|
||||
->disk('public')
|
||||
->height(220),
|
||||
\Filament\Infolists\Components\KeyValueEntry::make('configurazione_display')
|
||||
->label('Configurazione selezionata')
|
||||
->state(fn (Model $record) => collect(ConfigurazioneFormatter::toRows($record->payload))
|
||||
->mapWithKeys(fn ($row) => [$row['label'] => $row['value']])
|
||||
->all())
|
||||
->columnSpanFull(),
|
||||
])),
|
||||
])
|
||||
->paginated(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user