Add restore button for soft-deleted WOs in admin diagnostic
Soft-deleted WOs (WO-26-0005..0008) are missing from admin view. A new restore action lets the admin recover them without CLI access. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -65,6 +65,29 @@ class ListWorkOrders extends ListRecords
|
|||||||
->modalSubmitAction(false)
|
->modalSubmitAction(false)
|
||||||
->modalCancelActionLabel('Închide');
|
->modalCancelActionLabel('Închide');
|
||||||
|
|
||||||
|
// Restore button — only if there are soft-deleted WOs in this tenant
|
||||||
|
if ($deletedTenant > 0) {
|
||||||
|
$actions[] = Actions\Action::make('restore_deleted_wos')
|
||||||
|
->label("Restaurează {$deletedTenant} fișe șterse")
|
||||||
|
->color('success')
|
||||||
|
->icon('heroicon-o-arrow-uturn-left')
|
||||||
|
->requiresConfirmation()
|
||||||
|
->modalHeading('Restaurează fișe șterse')
|
||||||
|
->modalDescription("Există {$deletedTenant} fișe soft-șterse în această companie. Vrei să le restaurezi?")
|
||||||
|
->modalSubmitActionLabel('Da, restaurează-le')
|
||||||
|
->action(function () use ($tenantId) {
|
||||||
|
$restored = DB::table('work_orders')
|
||||||
|
->where('company_id', $tenantId)
|
||||||
|
->whereNotNull('deleted_at')
|
||||||
|
->update(['deleted_at' => null]);
|
||||||
|
|
||||||
|
Notification::make()
|
||||||
|
->title("{$restored} fișe restaurate cu succes")
|
||||||
|
->success()
|
||||||
|
->send();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Recover button — only if there are orphaned active WOs
|
// Recover button — only if there are orphaned active WOs
|
||||||
if ($otherActive > 0) {
|
if ($otherActive > 0) {
|
||||||
$actions[] = Actions\Action::make('recover_wos')
|
$actions[] = Actions\Action::make('recover_wos')
|
||||||
|
|||||||
Reference in New Issue
Block a user