Added shipments delete

This commit is contained in:
Karl Cordes 2013-04-29 23:00:24 +10:00
parent 24eaa4c0cd
commit 573971310d
5 changed files with 36 additions and 22 deletions

View file

@ -237,13 +237,12 @@ class ShipmentsController extends AppController {
function delete($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for Shipment', true));
$this->redirect(array('action'=>'index'));
}
$this->layout = 'ajax';
if ($this->Shipment->del($id)) {
$this->Session->setFlash(__('Shipment deleted', true));
$this->redirect(array('action'=>'index'));
return "Deleted"; // This should be returning status codes
}
else {
return "Fail"; //All over the app.
}
}

View file

@ -34,6 +34,8 @@
<tr>
<td class="actions">
<button id="<?=$shipment['Shipment']['id']?>" class="editButton">Edit</button>
<button class="deleteButton">Delete</button>
</td>
<td>
<?php

View file

View file

@ -1677,3 +1677,8 @@ ul.document-buttons {
ul.document-buttons li {
padding: 0.5em;
}
.deleteButton {
display: block;
clear: both;
}

View file

@ -66,6 +66,7 @@ $(function() {
$( ".newShipment" ).button().click(function() {
$.get('/shipments/add/', false, function(data) {
$("#add-form").html(data);
@ -80,14 +81,24 @@ $(function() {
$(".editButton").button().click(function() {
var id = $(this).attr('id');
$.get('/shipments/edit/'+id, false, function(data) {
$("#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();
});
}
});
@ -98,7 +109,4 @@ $(function() {
});