diff --git a/app/controllers/shipments_controller.php b/app/controllers/shipments_controller.php index 93d4ba84..70a08082 100755 --- a/app/controllers/shipments_controller.php +++ b/app/controllers/shipments_controller.php @@ -236,15 +236,14 @@ class ShipmentsController extends AppController { - function delete($id = null) { - if (!$id) { - $this->Session->setFlash(__('Invalid id for Shipment', true)); - $this->redirect(array('action'=>'index')); - } - if ($this->Shipment->del($id)) { - $this->Session->setFlash(__('Shipment deleted', true)); - $this->redirect(array('action'=>'index')); - } + function delete($id = null) { + $this->layout = 'ajax'; + if ($this->Shipment->del($id)) { + return "Deleted"; // This should be returning status codes + } + else { + return "Fail"; //All over the app. + } } @@ -470,4 +469,4 @@ class ShipmentsController extends AppController { } } -?> \ No newline at end of file +?> diff --git a/app/views/elements/shipment_index_all.ctp b/app/views/elements/shipment_index_all.ctp index e4befc5a..9b6134f3 100755 --- a/app/views/elements/shipment_index_all.ctp +++ b/app/views/elements/shipment_index_all.ctp @@ -34,6 +34,8 @@ + + - \ No newline at end of file + diff --git a/app/views/shipments/delete.ctp b/app/views/shipments/delete.ctp new file mode 100644 index 00000000..e69de29b diff --git a/app/webroot/css/quotenik.css b/app/webroot/css/quotenik.css index f27ea5e0..3bdf5b5c 100755 --- a/app/webroot/css/quotenik.css +++ b/app/webroot/css/quotenik.css @@ -1677,3 +1677,8 @@ ul.document-buttons { ul.document-buttons li { padding: 0.5em; } + +.deleteButton { + display: block; + clear: both; +} diff --git a/app/webroot/js/shipment_index.js b/app/webroot/js/shipment_index.js index 0f9e6af5..2597ed8c 100755 --- a/app/webroot/js/shipment_index.js +++ b/app/webroot/js/shipment_index.js @@ -66,7 +66,8 @@ $(function() { $( ".newShipment" ).button().click(function() { - $.get('/shipments/add/', false, function(data) { + + $.get('/shipments/add/', false, function(data) { $("#add-form").html(data); $( "#add-form" ).dialog( "open" ); @@ -79,19 +80,26 @@ $(function() { $(".editButton").button().click(function() { - var id = $(this).attr('id'); + var id = $(this).attr('id'); + $.get('/shipments/edit/'+id, false, function(data) { - $.get('/shipments/edit/'+id, false, function(data) { - - $("#edit-form").html(data); - $( "#edit-form" ).dialog( "open" ); - } ); - - + $("#edit-form").html(data); + $( "#edit-form" ).dialog( "open" ); + } ); }); - + $(".deleteButton").click(function() { + var id = $(this).prev().attr('id'); + var confirmed = confirm("Permanently delete this shipment?"); + + if(confirmed) { + $.get('/shipments/delete/'+id, false, function() { + window.location.reload(); + }); + } + + }); @@ -101,4 +109,4 @@ $(function() { -}); \ No newline at end of file +});