up
This commit is contained in:
@@ -99,25 +99,18 @@ class ConfeccionResource extends Resource
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
Section::make('Recepción y Calidad')
|
||||
->description('Campos que se diligencian al recibir la confección en el taller o bodega')
|
||||
Section::make('Recepciones')
|
||||
->description('Resumen de recepciones. Para registrar recepciones múltiples use el botón "Agregar recepción" en la cabecera o la relación "Recepciones" abajo.')
|
||||
->schema([
|
||||
DatePicker::make('fecha_recepcion'),
|
||||
Forms\Components\Placeholder::make('recepcion_summary')
|
||||
->label('Resumen')
|
||||
->content(fn ($get) => "Total recibido: " . ($get('cantidad_recibida') ?? 0) . " — Faltan: " . ($get('faltantes') ?? 0)),
|
||||
|
||||
TextInput::make('cantidad_recibida')
|
||||
->numeric()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, $set, $get) {
|
||||
$valor = $get('valor_por_prenda') ?? 0;
|
||||
$cantidad = $state ?? $get('cantidad_enviada');
|
||||
$set('total_pagar', $cantidad && $valor ? $cantidad * $valor : 0);
|
||||
}),
|
||||
|
||||
TextInput::make('prendas_defectuosas')
|
||||
->numeric()
|
||||
->default(0),
|
||||
Forms\Components\Placeholder::make('instrucciones')
|
||||
->label('Acciones')
|
||||
->content('Use el botón "Agregar recepción" en la cabecera para registrar una recepción rápida. También puede gestionar todas las recepciones en la sección relacionada al final de la página.'),
|
||||
])
|
||||
->columns(2)
|
||||
->columns(1)
|
||||
->collapsed(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,35 @@ class EditConfeccion extends EditRecord
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
|
||||
Actions\Action::make('agregarRecepcion')
|
||||
->label('Agregar recepción')
|
||||
->modalHeading('Agregar Recepción')
|
||||
->form([
|
||||
Forms\Components\DatePicker::make('fecha_recepcion')->default(now())->required(),
|
||||
Forms\Components\TextInput::make('cantidad')->numeric()->required()->minValue(1),
|
||||
Forms\Components\Textarea::make('notas'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$record = $this->getRecord();
|
||||
|
||||
\App\Models\Recepcion::create([
|
||||
'referencia_type' => \App\Models\Confeccion::class,
|
||||
'referencia_id' => $record->id,
|
||||
'cantidad' => (int) $data['cantidad'],
|
||||
'fecha_recepcion' => $data['fecha_recepcion'],
|
||||
'notas' => $data['notas'] ?? null,
|
||||
]);
|
||||
|
||||
\Filament\Notifications\Notification::make()
|
||||
->success()
|
||||
->title('Recepción registrada')
|
||||
->body('La recepción se creó correctamente.')
|
||||
->send();
|
||||
|
||||
// Refrescar la página para ver cambios
|
||||
$this->redirect($this->getUrl());
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user