From c5985c124d48252de8cb369387a747f498a0734f Mon Sep 17 00:00:00 2001 From: lizandrogd <77708265+lizandrogd@users.noreply.github.com> Date: Mon, 19 Jan 2026 18:55:06 -0500 Subject: [PATCH] up --- app/Filament/Resources/ConfeccionResource.php | 25 ++++++---------- .../Pages/EditConfeccion.php | 29 +++++++++++++++++++ 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/app/Filament/Resources/ConfeccionResource.php b/app/Filament/Resources/ConfeccionResource.php index 47b29eb..958c517 100644 --- a/app/Filament/Resources/ConfeccionResource.php +++ b/app/Filament/Resources/ConfeccionResource.php @@ -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(), ]); } diff --git a/app/Filament/Resources/ConfeccionResource/Pages/EditConfeccion.php b/app/Filament/Resources/ConfeccionResource/Pages/EditConfeccion.php index 64a7347..0fb2329 100644 --- a/app/Filament/Resources/ConfeccionResource/Pages/EditConfeccion.php +++ b/app/Filament/Resources/ConfeccionResource/Pages/EditConfeccion.php @@ -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()); + }), ]; } }