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.
140 lines
4.0 KiB
PHP
140 lines
4.0 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\ConfeccionResource\Pages;
|
|
use App\Filament\Resources\ConfeccionResource\RelationManagers;
|
|
use App\Models\Confeccion;
|
|
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\{
|
|
Select,
|
|
TextInput,
|
|
DatePicker,
|
|
Section
|
|
};
|
|
use Filament\Tables\Columns\{
|
|
TextColumn,
|
|
BadgeColumn
|
|
};
|
|
|
|
class ConfeccionResource extends Resource
|
|
{
|
|
protected static ?string $model = Confeccion::class;
|
|
|
|
protected static ?string $navigationGroup = 'Gestión';
|
|
protected static ?string $navigationIcon = 'heroicon-o-cog';
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form->schema([
|
|
Section::make('Datos de Confección')
|
|
->schema([
|
|
Select::make('proveedor_id')
|
|
->label('Tallerista')
|
|
->relationship(
|
|
'proveedor',
|
|
'nombre',
|
|
fn($query) => $query->where('categoria', 'talleres')
|
|
)
|
|
->searchable()
|
|
->preload()
|
|
->required(),
|
|
|
|
Select::make('orden_produccion_id')
|
|
->label('Orden de Producción')
|
|
->relationship('ordenProduccion', 'numero_orden')
|
|
->searchable()
|
|
->preload()
|
|
->required(),
|
|
|
|
DatePicker::make('fecha_envio')
|
|
->required(),
|
|
|
|
TextInput::make('cantidad_enviada')
|
|
->numeric()
|
|
->required(),
|
|
|
|
DatePicker::make('fecha_recepcion'),
|
|
|
|
TextInput::make('cantidad_recibida')
|
|
->numeric(),
|
|
|
|
TextInput::make('prendas_defectuosas')
|
|
->numeric()
|
|
->default(0),
|
|
|
|
TextInput::make('valor_por_prenda')
|
|
->numeric()
|
|
->prefix('$')
|
|
->required(),
|
|
|
|
TextInput::make('total_pagar')
|
|
->prefix('$'),
|
|
])
|
|
->columns(2),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('ordenProduccion.numero_orden')
|
|
->label('OP')
|
|
->searchable(),
|
|
|
|
TextColumn::make('proveedor.nombre')
|
|
->label('Tallerista')
|
|
->searchable(),
|
|
|
|
TextColumn::make('cantidad_enviada'),
|
|
|
|
TextColumn::make('cantidad_recibida'),
|
|
|
|
BadgeColumn::make('estado')
|
|
->colors([
|
|
'warning' => 'pendiente',
|
|
'info' => 'parcial',
|
|
'success' => 'completo',
|
|
])
|
|
->formatStateUsing(fn($state) => ucfirst($state)),
|
|
|
|
TextColumn::make('total_pagar')
|
|
->money('COP'),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->actions([
|
|
Tables\Actions\EditAction::make(),
|
|
])
|
|
->bulkActions([
|
|
Tables\Actions\BulkActionGroup::make([
|
|
Tables\Actions\DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListConfeccions::route('/'),
|
|
'create' => Pages\CreateConfeccion::route('/create'),
|
|
'edit' => Pages\EditConfeccion::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|