127 lines
4.5 KiB
PHP
127 lines
4.5 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\TrasladoPrendaResource\Pages;
|
|
use App\Filament\Resources\TrasladoPrendaResource\RelationManagers;
|
|
use App\Models\TrasladoPrenda;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Form;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
use Filament\Tables\Filters\SelectFilter;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Forms\Components\DateTimePicker;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
|
|
class TrasladoPrendaResource extends Resource
|
|
{
|
|
protected static ?string $model = TrasladoPrenda::class;
|
|
|
|
protected static ?string $navigationGroup = 'Gestión';
|
|
protected static ?int $navigationSort = 7;
|
|
protected static ?string $navigationIcon = 'heroicon-o-map';
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Select::make('origen')->options([
|
|
'confeccion' => 'Confección',
|
|
'tintoreria' => 'Tintorería',
|
|
'acabados' => 'Acabados',
|
|
'bodega' => 'Bodega',
|
|
])->required(),
|
|
|
|
Select::make('destino')->options([
|
|
'confeccion' => 'Confección',
|
|
'tintoreria' => 'Tintorería',
|
|
'acabados' => 'Acabados',
|
|
'bodega' => 'Bodega',
|
|
])->required(),
|
|
|
|
TextInput::make('cantidad_enviada')->numeric()->required(),
|
|
TextInput::make('cantidad_recibida')->numeric()->nullable(),
|
|
TextInput::make('prendas_defectuosas')->numeric()->nullable(),
|
|
TextInput::make('reparaciones')->numeric()->nullable(),
|
|
TextInput::make('saldos')->numeric()->nullable(),
|
|
TextInput::make('residual')->numeric()->disabled()->dehydrated(false),
|
|
DateTimePicker::make('fecha_envio')->nullable(),
|
|
DateTimePicker::make('fecha_recepcion')->nullable(),
|
|
Select::make('estado')->options([
|
|
'pendiente' => 'Pendiente',
|
|
'realizado' => 'Realizado',
|
|
'recibido' => 'Recibido',
|
|
])->default('pendiente'),
|
|
Textarea::make('notas')->columnSpanFull(),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('id')->sortable(),
|
|
TextColumn::make('origen'),
|
|
TextColumn::make('destino'),
|
|
TextColumn::make('cantidad_enviada'),
|
|
TextColumn::make('cantidad_recibida'),
|
|
TextColumn::make('prendas_defectuosas'),
|
|
TextColumn::make('reparaciones'),
|
|
TextColumn::make('saldos'),
|
|
TextColumn::make('residual'),
|
|
TextColumn::make('estado'),
|
|
TextColumn::make('fecha_envio')->dateTime(),
|
|
TextColumn::make('fecha_recepcion')->dateTime(),
|
|
TextColumn::make('referencia_type')->label('Referencia'),
|
|
])
|
|
->filters([
|
|
SelectFilter::make('orden_produccion_id')
|
|
->label('Orden de Producción')
|
|
->options(function () {
|
|
return \App\Models\OrdenProduccion::orderBy('id', 'desc')->pluck('numero_orden', 'id')->toArray();
|
|
})
|
|
->searchable(),
|
|
])
|
|
->actions([
|
|
Tables\Actions\EditAction::make(),
|
|
Tables\Actions\DeleteAction::make(),
|
|
])
|
|
->bulkActions([
|
|
Tables\Actions\DeleteBulkAction::make(),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListTrasladoPrendas::route('/'),
|
|
'create' => Pages\CreateTrasladoPrenda::route('/create'),
|
|
'edit' => Pages\EditTrasladoPrenda::route('/{record}/edit'),
|
|
];
|
|
}
|
|
|
|
public static function getNavigationBadge(): ?string
|
|
{
|
|
try {
|
|
if (! \Illuminate\Support\Facades\Schema::hasTable('traslados_prenda')) {
|
|
return null;
|
|
}
|
|
|
|
return (string) \App\Models\TrasladoPrenda::count();
|
|
} catch (\Exception $e) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|