Skip to content

Commit

Permalink
modale informativo sulla cancellazione di un ordine con prenotazioni …
Browse files Browse the repository at this point in the history
…aperte. closes #280
  • Loading branch information
madbob committed May 24, 2024
1 parent 54f2e39 commit 0253f1f
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
6 changes: 6 additions & 0 deletions code/app/Http/Controllers/OrdersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ private function oldOrders($user)
return easyFilterOrders($supplier_id, '1970-01-01', date('Y-m-d', strtotime('-1 years')), ['open', 'closed']);
}

public function noDestroyNotice(Request $request, $id)
{
$order = $this->service->show($id, true);
return view('order.partials.nodestroy', ['order' => $order]);
}

/*
Questa funzione è usata per aggiornare manualmente le quantità
di un certo prodotto all'interno di un ordine
Expand Down
34 changes: 31 additions & 3 deletions code/resources/views/order/edit.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
<?php $summary = $master_summary->orders[$order->id] ?>

<x-larastrap::mform :obj="$order" classes="order-editor" method="PUT" :action="route('orders.update', $order->id)" :nodelete="$order->bookings()->count() > 0" :other_buttons="[['label' => _i('Esporta'), 'classes' => ['float-start', 'link-button', 'me-2'], 'attributes' => ['data-link' => $order->exportableURL()]]]">
<?php
$summary = $master_summary->orders[$order->id];
$custom_buttons = [
[
'label' => _i('Esporta'),
'classes' => ['float-start', 'link-button', 'me-2'],
'attributes' => ['data-link' => $order->exportableURL()]
]
];
if ($order->bookings()->count() > 0) {
$nodelete = true;
$custom_buttons[] = [
'color' => 'danger',
'classes' => ['async-modal'],
'label' => _i('Elimina'),
'attributes' => [
'data-modal-url' => route('orders.nodestroy', $order->id),
]
];
}
else {
$nodelete = false;
}
?>

<x-larastrap::mform :obj="$order" classes="order-editor" method="PUT" :action="route('orders.update', $order->id)" :nodelete="$nodelete" :other_buttons="$custom_buttons">
<input type="hidden" name="order_id" value="{{ $order->id }}" />
<input type="hidden" name="post-saved-function" value="afterAggregateChange" class="skip-on-submit">

Expand Down
11 changes: 11 additions & 0 deletions code/resources/views/order/partials/nodestroy.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<x-larastrap::modal :title="_i('Operazione non permessa')">
<p>
{{ _i("L'ordine %s ha attualmente delle prenotazioni attive, e non può essere pertanto rimosso.", [$order->printableName()]) }}
</p>
<p>
{!! _i('Si raccomanda di accedere al <a href="%s">pannello delle prenotazioni per questo ordine</a> e, con lo strumento "Prenotazioni per Altri Utenti", invalidare le prenotazioni esistenti.', [$order->getBookingURL()]) !!}
</p>
<p>
{{ _i("Questo meccanismo è deliberatemente non automatico e volutamente complesso, per evitare la perdita involontaria di dati.") }}
</p>
</x-larastrap::modal>
1 change: 1 addition & 0 deletions code/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@

Route::get('orders/{id}/header', 'OrdersController@objhead')->name('orders.objhead');
Route::get('orders/search', 'OrdersController@search');
Route::get('orders/nodestroy/{id}', 'OrdersController@noDestroyNotice')->name('orders.nodestroy');
Route::get('orders/fixes/{id}/{product_id}', 'OrdersController@getFixes');
Route::post('orders/fixes/{id}', 'OrdersController@postFixes');
Route::get('orders/fixmods/{id}', 'OrdersController@getFixModifiers')->name('orders.fixmodifiers');
Expand Down

0 comments on commit 0253f1f

Please sign in to comment.