Introduces a new Gestión dashboard page with a stats overview widget for Tela and OrdenProduccion. Updates navigation icons for several Filament resources for better distinction. Adds a relationship between Tela and OrdenProduccion models. Refactors the telas table migration to use integer types for numeric fields instead of strings.
146 lines
4.6 KiB
PHP
146 lines
4.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\OrdenProduccionResource\Pages;
|
|
use App\Filament\Resources\OrdenProduccionResource\RelationManagers;
|
|
use App\Models\OrdenProduccion;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Form;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
use Filament\Forms\Components\{
|
|
TextInput,
|
|
Select,
|
|
DatePicker,
|
|
Section
|
|
};
|
|
use Filament\Tables\Columns\{
|
|
TextColumn,
|
|
BadgeColumn
|
|
};
|
|
|
|
class OrdenProduccionResource extends Resource
|
|
{
|
|
protected static ?string $model = OrdenProduccion::class;
|
|
|
|
protected static ?string $navigationGroup = 'Gestión';
|
|
protected static ?string $navigationIcon = 'heroicon-o-clipboard-document-list';
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Section::make('Datos de la Orden')
|
|
->schema([
|
|
TextInput::make('prenda_modelo')
|
|
->label('Prenda / Modelo')
|
|
->required()
|
|
->maxLength(255),
|
|
|
|
TextInput::make('referencia')
|
|
->required()
|
|
->maxLength(255),
|
|
|
|
TextInput::make('cantidad_total')
|
|
->numeric()
|
|
->required()
|
|
->minValue(1),
|
|
|
|
Select::make('tela_id')
|
|
->label('Tela asociada')
|
|
->relationship('tela', 'codigo')
|
|
->searchable()
|
|
->preload()
|
|
->nullable(),
|
|
|
|
DatePicker::make('fecha_inicio')
|
|
->required(),
|
|
|
|
DatePicker::make('fecha_entrega_estimada')
|
|
->required(),
|
|
])
|
|
->columns(2),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('numero_orden')
|
|
->label('OP')
|
|
->sortable(),
|
|
|
|
TextColumn::make('prenda_modelo')
|
|
->searchable(),
|
|
|
|
TextColumn::make('referencia')
|
|
->searchable(),
|
|
|
|
TextColumn::make('cantidad_total')
|
|
->label('Cantidad'),
|
|
|
|
TextColumn::make('tela.codigo')
|
|
->label('Tela')
|
|
->toggleable(),
|
|
|
|
BadgeColumn::make('estado')
|
|
->colors([
|
|
'warning' => 'en_corte',
|
|
'info' => 'en_confeccion',
|
|
'primary' => 'en_tintoreria',
|
|
'secondary' => 'en_acabados',
|
|
'success' => 'finalizada',
|
|
])
|
|
->formatStateUsing(fn($state) => match ($state) {
|
|
'en_corte' => 'En corte',
|
|
'en_confeccion' => 'En confección',
|
|
'en_tintoreria' => 'En tintorería',
|
|
'en_acabados' => 'En acabados',
|
|
'finalizada' => 'Finalizada',
|
|
}),
|
|
|
|
TextColumn::make('fecha_entrega_estimada')
|
|
->date(),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->actions([
|
|
Tables\Actions\EditAction::make(),
|
|
])
|
|
->bulkActions([
|
|
Tables\Actions\BulkActionGroup::make([
|
|
Tables\Actions\DeleteBulkAction::make(),
|
|
// Tables\Actions\Action::make('avanzar')
|
|
// ->label('Avanzar estado')
|
|
// ->icon('heroicon-o-arrow-right')
|
|
// ->requiresConfirmation()
|
|
// ->visible(fn($record) => $record->estado !== 'finalizada')
|
|
// ->action(fn($record) => $record->avanzarEstado()),
|
|
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListOrdenProduccions::route('/'),
|
|
'create' => Pages\CreateOrdenProduccion::route('/create'),
|
|
'edit' => Pages\EditOrdenProduccion::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|