editing shipments will now delete all boxes and ShipmentInvoices before saving new ones
This commit is contained in:
parent
95fcfb5373
commit
796371fc36
|
|
@ -166,6 +166,17 @@ class JobsController extends AppController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getFinancialYears() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function getFirstFYday($year) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build an array of Years/Months with Jobs.
|
* Build an array of Years/Months with Jobs.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -122,9 +122,18 @@ class ShipmentsController extends AppController {
|
||||||
if(!empty($this->data)) {
|
if(!empty($this->data)) {
|
||||||
//$this->Shipment->create($this->data);
|
//$this->Shipment->create($this->data);
|
||||||
|
|
||||||
|
$shipment_id = $this->data['Shipment']['id'];
|
||||||
|
|
||||||
|
$this->Shipment->Box->deleteAll(array('shipment_id'=>$shipment_id));
|
||||||
|
$this->Shipment->ShipmentInvoice->deleteAll(array('shipment_id'=>$shipment_id));
|
||||||
|
|
||||||
|
|
||||||
if ($this->Shipment->saveAll($this->data)) {
|
if ($this->Shipment->saveAll($this->data)) {
|
||||||
|
|
||||||
$boxIDs = array();
|
$this->Shipment->Box->updateCounterCache(array('shipment_id'=>$shipment_id));
|
||||||
|
$this->Shipment->ShipmentInvoice->updateCounterCache(array('shipment_id'=>$shipment_id));
|
||||||
|
|
||||||
|
/*$boxIDs = array();
|
||||||
foreach($this->data['Box'] as $box) {
|
foreach($this->data['Box'] as $box) {
|
||||||
$boxIDs[] = $box['id'];
|
$boxIDs[] = $box['id'];
|
||||||
|
|
||||||
|
|
@ -134,8 +143,15 @@ class ShipmentsController extends AppController {
|
||||||
foreach($this->data['ShipmentInvoice'] as $si) {
|
foreach($this->data['ShipmentInvoice'] as $si) {
|
||||||
$invoiceIDs[] = $si['id'];
|
$invoiceIDs[] = $si['id'];
|
||||||
}
|
}
|
||||||
print_r($boxIDs);
|
print_r($boxIDs);*/
|
||||||
|
|
||||||
|
/*foreach($this->data['Job'] as $job) {
|
||||||
|
foreach($job as $index => $id) {
|
||||||
|
echo $id."\n";
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
print_r($this->data);
|
||||||
|
|
||||||
|
|
||||||
echo "SUCCESS";
|
echo "SUCCESS";
|
||||||
|
|
@ -160,6 +176,7 @@ class ShipmentsController extends AppController {
|
||||||
|
|
||||||
if ($this->Shipment->saveAll($this->data)) {
|
if ($this->Shipment->saveAll($this->data)) {
|
||||||
echo "SUCCESS";
|
echo "SUCCESS";
|
||||||
|
print_r($this->data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo "FAILURE";
|
echo "FAILURE";
|
||||||
|
|
@ -174,6 +191,11 @@ class ShipmentsController extends AppController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function markJobsSent() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Moved the Views for Adding/Editing to elements. Called from the Index.
|
/* Moved the Views for Adding/Editing to elements. Called from the Index.
|
||||||
*
|
*
|
||||||
* function add($action = 'add') {
|
* function add($action = 'add') {
|
||||||
|
|
|
||||||
|
|
@ -55,9 +55,9 @@ echo $form->input('id', array('type'=>'hidden'));
|
||||||
|
|
||||||
<div id="job" class="hiddenDefault">
|
<div id="job" class="hiddenDefault">
|
||||||
<?
|
<?
|
||||||
echo $form->input('job', array('id'=>'job_autocomplete'));
|
echo $form->input('job', array('id'=>'job_autocomplete', array('label'=>'Job (start typing and select from the list)')));
|
||||||
?>
|
?>
|
||||||
|
<span class="moreInfo">Jobs in this Shipment will be updated as "sent"</span>
|
||||||
|
|
||||||
<ul id="jobsList" class="habtmList">
|
<ul id="jobsList" class="habtmList">
|
||||||
<?php foreach($this->data['Job'] as $job):?>
|
<?php foreach($this->data['Job'] as $job):?>
|
||||||
|
|
@ -72,7 +72,7 @@ echo $form->input('id', array('type'=>'hidden'));
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="customer" class="hiddenDefault">
|
<div id="customer" class="hiddenDefault">
|
||||||
<?=$form->input('customer', array('id'=>'customer_autocomplete', 'label'=>'Customer', 'value'=>$this->data['Customer']['name']));?>
|
<?=$form->input('customer', array('id'=>'customer_autocomplete', 'label'=>'Customer (start typing and select from the list)', 'value'=>$this->data['Customer']['name']));?>
|
||||||
<?=$form->input('customer_id', array('type'=>'hidden', 'id'=>'customer_id', 'value'=>$this->data['Shipment']['customer_id']));?>
|
<?=$form->input('customer_id', array('type'=>'hidden', 'id'=>'customer_id', 'value'=>$this->data['Shipment']['customer_id']));?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,8 @@
|
||||||
<td>
|
<td>
|
||||||
<?=$shipment['Shipment']['shipment_invoice_count'];?>
|
<?=$shipment['Shipment']['shipment_invoice_count'];?>
|
||||||
</td>
|
</td>
|
||||||
<td><?foreach($shipment['ShipmentInvoice'] as $si) {
|
<td><?
|
||||||
|
foreach($shipment['ShipmentInvoice'] as $si) {
|
||||||
if(!empty($si['principle_id'])) {
|
if(!empty($si['principle_id'])) {
|
||||||
echo $principles[$si['principle_id']];
|
echo $principles[$si['principle_id']];
|
||||||
}
|
}
|
||||||
|
|
@ -144,18 +145,31 @@
|
||||||
}?>
|
}?>
|
||||||
</td>
|
</td>
|
||||||
<td><?
|
<td><?
|
||||||
if($si['deferred_gst'] == 1) {
|
|
||||||
foreach($shipment['ShipmentInvoice'] as $si) {
|
foreach($shipment['ShipmentInvoice'] as $si) {
|
||||||
|
|
||||||
|
if($si['deferred_gst'] == 1) {
|
||||||
echo $currencies[$si['currency_id']]." ".$si['deferred_gst_amount']."<br />";
|
echo $currencies[$si['currency_id']]." ".$si['deferred_gst_amount']."<br />";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td><?=$this->element('booleanTick', array('bool'=>$si['approved'])); ?></td>
|
<td><?
|
||||||
<td><?=$this->element('booleanTick', array('bool'=>$si['paid'])); ?></td>
|
|
||||||
<td><?=$this->element('isEmptyDate', array('date'=>$si['date_paid']));?></td>
|
|
||||||
|
|
||||||
|
foreach($shipment['ShipmentInvoice'] as $si) {
|
||||||
|
echo $this->element('booleanTick', array('bool'=>$si['approved'])); }
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
<td><? foreach($shipment['ShipmentInvoice'] as $si) {
|
||||||
|
echo $this->element('booleanTick', array('bool'=>$si['paid']));
|
||||||
|
}?>
|
||||||
|
</td>
|
||||||
|
<td><? foreach($shipment['ShipmentInvoice'] as $si) {
|
||||||
|
echo $this->element('isEmptyDate', array('date'=>$si['date_paid']));
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?php echo $shipment['Shipment']['comments']; ?>
|
<?php echo $shipment['Shipment']['comments']; ?>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ $(function() {
|
||||||
|
|
||||||
$.post('/shipments/ajax_edit', thisShipmentInputs, function(data) {
|
$.post('/shipments/ajax_edit', thisShipmentInputs, function(data) {
|
||||||
$( "#edit-form" ).dialog('close');
|
$( "#edit-form" ).dialog('close');
|
||||||
window.location.reload(); //Change this to fetch a new copy of the table and update a <div>.
|
// window.location.reload(); //Change this to fetch a new copy of the table and update a <div>.
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
@ -69,9 +69,10 @@ $(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" );
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -83,9 +84,10 @@ $(function() {
|
||||||
$.get('/shipments/edit/'+id, false, function(data) {
|
$.get('/shipments/edit/'+id, false, function(data) {
|
||||||
|
|
||||||
$("#edit-form").html(data);
|
$("#edit-form").html(data);
|
||||||
|
$( "#edit-form" ).dialog( "open" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
$( "#edit-form" ).dialog( "open" );
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue