Generate shipping instructions on PO views #73
This commit is contained in:
parent
8b74fe4d86
commit
26257567d3
|
|
@ -526,8 +526,7 @@ ENDINSTRUCTIONS;
|
|||
//Delete all the existing JobPurchaseOrder relationships for this PO.
|
||||
//Fuck it. @TODO SQL injection potential here.
|
||||
$query = "DELETE FROM jobs_purchase_orders WHERE purchase_order_id =".$this->data['PurchaseOrder']['id'];
|
||||
$result = $this->Document->query($query);
|
||||
|
||||
$this->Document->query($query);
|
||||
}
|
||||
|
||||
if(isset($this->data['PurchaseOrder']['Job'])) {
|
||||
|
|
@ -1060,6 +1059,65 @@ EOT;
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// generateShippingReference builds the Shipping Instructions: with the PO number and job titles.
|
||||
function generateShippingInstructions($document_id) {
|
||||
$this->layout = 'ajax';
|
||||
|
||||
$po = $this->Document->PurchaseOrder->find('first',
|
||||
array('conditions'=>
|
||||
array('Document.id' => $document_id)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// TODO SQL injection risk. Need to rewrite this whole rickety thing..
|
||||
$query = 'select j.title as job_title, po.title as po_title from jobs_purchase_orders jpo JOIN jobs j on j.id = jpo.job_id JOIN purchase_orders po ON po.id= jpo.purchase_order_id WHERE jpo.purchase_order_id = '.$po['PurchaseOrder']['id'].';';
|
||||
|
||||
|
||||
|
||||
$results = $this->Document->query($query);
|
||||
//echo "<pre>";
|
||||
//print_r($results);
|
||||
//echo "</pre>";
|
||||
|
||||
$label = "";
|
||||
|
||||
if (count($results) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (count($results) > 0) {
|
||||
$label = $results[0]["po"]["po_title"];
|
||||
}
|
||||
|
||||
foreach ($results as $result) {
|
||||
$label .= " / ". $result["j"]["job_title"];
|
||||
}
|
||||
|
||||
echo <<<ENDINSTRUCTIONS
|
||||
|
||||
<b>PART SHIPMENT:</b> Not Acceptable - please advise ASAP if production of an Item will Delay the Dispatch of the Complete Order by the Date Required stated above.<br>
|
||||
<b>INSURANCE:</b> DO NOT INSURE - Insurance effected by CMC<br>
|
||||
<b>SECURITY:</b> It is essential that the cargo is prepared & handled so as not to compromise its security standing.<br>
|
||||
<b>SHIPMENT MARKINGS:</b><br>
|
||||
(Please put red fragile stickers on boxing)<br>
|
||||
CMC TECHNOLOGIES PTY LTD<br>
|
||||
UNIT 19, 77 BOURKE ROAD<br>
|
||||
ALEXANDRIA NSW 2015 AUSTRALIA<br>
|
||||
REF: $label
|
||||
ENDINSTRUCTIONS;
|
||||
|
||||
/*if($this->Document->PurchaseOrder->save($po["PurchaseOrder"])) {
|
||||
echo "SUCCESS"; //THIS IS SO STUPID.
|
||||
}
|
||||
else {
|
||||
echo "FAILURE";
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function add_job_items_to_po($job_id, $document_id) {
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@
|
|||
|
||||
echo $form->input('PurchaseOrder.deliver_to');
|
||||
echo $form->input('PurchaseOrder.shipping_instructions');
|
||||
?>
|
||||
<button id="generateShippingInstructions">Regenerate shipping instructions</button>
|
||||
<?php
|
||||
|
||||
|
||||
echo $form->end(array('label'=>'Save PurchaseOrder Details', 'id'=>'savePurchaseOrderButton'));
|
||||
|
|
|
|||
|
|
@ -555,6 +555,7 @@ $(function() {
|
|||
var jobs_val = $("#PurchaseOrderJobsText").val();
|
||||
|
||||
$("#PurchaseOrderJobsText").val(jobs_val +', '+ ui.item.value)
|
||||
|
||||
console.log(ui.item.id);
|
||||
console.log(ui.item.value);
|
||||
//POST the job ID to a method on the documents controller to add the LineItems
|
||||
|
|
@ -562,8 +563,6 @@ $(function() {
|
|||
|
||||
loadLineItems();
|
||||
saveDocument('Purchase Order');
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -575,6 +574,15 @@ $(function() {
|
|||
|
||||
});
|
||||
|
||||
$('#generateShippingInstructions').live('click', function(event) {
|
||||
event.preventDefault();
|
||||
$.post('/documents/generateShippingInstructions/'+$("#DocumentId").val(), function(data) {
|
||||
$('#PurchaseOrderShippingInstructions').val(data);
|
||||
updateTextFields(); //Update the CKEditor instances.
|
||||
//$("#PurchaseOrderShippingInstructions").ckeditor(config);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$('.generateCommercialComments').live('click', function(event) {
|
||||
event.preventDefault();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@ ID=$(docker ps -qf ancestor='cmc:latest')
|
|||
docker kill $ID
|
||||
sleep 1
|
||||
docker run -d -p 127.0.0.1:8888:80 \
|
||||
--mount type=bind,source=/home/k/projects/cmc-sales/app/webroot/pdf,target=/var/www/cmc-sales/app/webroot/pdf \
|
||||
--mount type=bind,source=/home/k/projects/cmc-sales/app/webroot/attachments_files,target=/var/www/cmc-sales/app/webroot/attachments_files \
|
||||
--mount type=bind,source=/home/k/src/cmc-sales/app/webroot/pdf,target=/var/www/cmc-sales/app/webroot/pdf \
|
||||
--mount type=bind,source=/home/k/src/cmc-sales/app/webroot/attachments_files,target=/var/www/cmc-sales/app/webroot/attachments_files \
|
||||
cmc:latest
|
||||
|
|
|
|||
Loading…
Reference in a new issue