up
This commit is contained in:
@@ -68,38 +68,6 @@ class EditConfeccion extends EditRecord
|
|||||||
// Refrescar la página para ver cambios (redirigir explicitando el record para evitar error de ruta)
|
// Refrescar la página para ver cambios (redirigir explicitando el record para evitar error de ruta)
|
||||||
$this->redirect(route('filament.admin.resources.confeccions.edit', ['record' => $record->id]));
|
$this->redirect(route('filament.admin.resources.confeccions.edit', ['record' => $record->id]));
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// Arreglos: restar cantidad del total recibido y crear traslado de reparaciones
|
|
||||||
Actions\Action::make('arreglos')
|
|
||||||
->label('Arreglos')
|
|
||||||
->modalHeading('Registrar Arreglo')
|
|
||||||
->form([
|
|
||||||
Forms\Components\TextInput::make('cantidad')
|
|
||||||
->label('Cantidad a arreglar')
|
|
||||||
->numeric()
|
|
||||||
->required()
|
|
||||||
->minValue(1)
|
|
||||||
->maxValue(fn () => $this->getRecord()->cantidad_recibida ?? 0)
|
|
||||||
->helperText(fn () => 'Máximo: ' . ($this->getRecord()->cantidad_recibida ?? 0)),
|
|
||||||
Forms\Components\Textarea::make('notas'),
|
|
||||||
])
|
|
||||||
->action(function (array $data): void {
|
|
||||||
$record = $this->getRecord();
|
|
||||||
|
|
||||||
$cantidad = (int) ($data['cantidad'] ?? 0);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$record->registerArreglo($cantidad, $data['notas'] ?? null, auth()->id() ?? null);
|
|
||||||
|
|
||||||
\Filament\Notifications\Notification::make()->success()->title('Arreglo registrado')->body('Se registró el arreglo correctamente.')->send();
|
|
||||||
} catch (\Illuminate\Validation\ValidationException $e) {
|
|
||||||
\Filament\Notifications\Notification::make()->danger()->title('Error')->body($e->validator->errors()->first() ?? 'Error al registrar arreglo.')->send();
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
\Filament\Notifications\Notification::make()->danger()->title('Error')->body($e->getMessage())->send();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->redirect(route('filament.admin.resources.confeccions.edit', ['record' => $record->id]));
|
|
||||||
}),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-12
@@ -11,6 +11,7 @@ class AjustesRelationManager extends RelationManager
|
|||||||
{
|
{
|
||||||
protected static string $relationship = 'ajustes';
|
protected static string $relationship = 'ajustes';
|
||||||
protected static ?string $recordTitleAttribute = 'id';
|
protected static ?string $recordTitleAttribute = 'id';
|
||||||
|
protected static ?string $title = 'Arreglos';
|
||||||
|
|
||||||
public function table(Tables\Table $table): Tables\Table
|
public function table(Tables\Table $table): Tables\Table
|
||||||
{
|
{
|
||||||
@@ -25,18 +26,29 @@ class AjustesRelationManager extends RelationManager
|
|||||||
])
|
])
|
||||||
->filters([])
|
->filters([])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
Tables\Actions\CreateAction::make()->form([
|
Tables\Actions\CreateAction::make()
|
||||||
\Filament\Forms\Components\TextInput::make('cantidad')->numeric()->required()->minValue(1),
|
->label('Registrar arreglo')
|
||||||
\Filament\Forms\Components\Textarea::make('notas'),
|
->modalHeading('Registrar Arreglo')
|
||||||
])->action(function (array $data) {
|
->form([
|
||||||
$owner = $this->getOwnerRecord();
|
\Filament\Forms\Components\TextInput::make('cantidad')
|
||||||
try {
|
->label('Cantidad')
|
||||||
$owner->registerArreglo((int)$data['cantidad'], $data['notas'] ?? null, auth()->id() ?? null);
|
->numeric()
|
||||||
\Filament\Notifications\Notification::make()->success()->title('Arreglo registrado')->send();
|
->required()
|
||||||
} catch (\Throwable $e) {
|
->minValue(1)
|
||||||
\Filament\Notifications\Notification::make()->danger()->title('Error')->body($e->getMessage())->send();
|
->helperText('Prendas que llegaron defectuosas y necesitan reparación'),
|
||||||
}
|
\Filament\Forms\Components\Textarea::make('notas'),
|
||||||
}),
|
])
|
||||||
|
->action(function (array $data) {
|
||||||
|
$owner = $this->getOwnerRecord();
|
||||||
|
try {
|
||||||
|
$owner->registerArreglo((int)$data['cantidad'], $data['notas'] ?? null, auth()->id() ?? null);
|
||||||
|
\Filament\Notifications\Notification::make()->success()->title('Arreglo registrado')->send();
|
||||||
|
} catch (\Illuminate\Validation\ValidationException $e) {
|
||||||
|
\Filament\Notifications\Notification::make()->danger()->title('Error')->body($e->validator->errors()->first())->send();
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
\Filament\Notifications\Notification::make()->danger()->title('Error')->body($e->getMessage())->send();
|
||||||
|
}
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
->actions([])
|
->actions([])
|
||||||
->bulkActions([]);
|
->bulkActions([]);
|
||||||
|
|||||||
Reference in New Issue
Block a user