Added shipments delete
This commit is contained in:
parent
24eaa4c0cd
commit
573971310d
|
|
@ -236,15 +236,14 @@ class ShipmentsController extends AppController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function delete($id = null) {
|
function delete($id = null) {
|
||||||
if (!$id) {
|
$this->layout = 'ajax';
|
||||||
$this->Session->setFlash(__('Invalid id for Shipment', true));
|
if ($this->Shipment->del($id)) {
|
||||||
$this->redirect(array('action'=>'index'));
|
return "Deleted"; // This should be returning status codes
|
||||||
}
|
}
|
||||||
if ($this->Shipment->del($id)) {
|
else {
|
||||||
$this->Session->setFlash(__('Shipment deleted', true));
|
return "Fail"; //All over the app.
|
||||||
$this->redirect(array('action'=>'index'));
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -470,4 +469,4 @@ class ShipmentsController extends AppController {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
<button id="<?=$shipment['Shipment']['id']?>" class="editButton">Edit</button>
|
<button id="<?=$shipment['Shipment']['id']?>" class="editButton">Edit</button>
|
||||||
|
|
||||||
|
<button class="deleteButton">Delete</button>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?php
|
<?php
|
||||||
|
|
@ -189,4 +191,4 @@
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<?php debug($currencies); ?>
|
<?php debug($currencies); ?>
|
||||||
|
|
|
||||||
0
app/views/shipments/delete.ctp
Normal file
0
app/views/shipments/delete.ctp
Normal file
|
|
@ -1677,3 +1677,8 @@ ul.document-buttons {
|
||||||
ul.document-buttons li {
|
ul.document-buttons li {
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.deleteButton {
|
||||||
|
display: block;
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,8 @@ $(function() {
|
||||||
|
|
||||||
|
|
||||||
$( ".newShipment" ).button().click(function() {
|
$( ".newShipment" ).button().click(function() {
|
||||||
$.get('/shipments/add/', false, function(data) {
|
|
||||||
|
$.get('/shipments/add/', false, function(data) {
|
||||||
|
|
||||||
$("#add-form").html(data);
|
$("#add-form").html(data);
|
||||||
$( "#add-form" ).dialog( "open" );
|
$( "#add-form" ).dialog( "open" );
|
||||||
|
|
@ -79,19 +80,26 @@ $(function() {
|
||||||
|
|
||||||
$(".editButton").button().click(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() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue