From aacf53b21b7d5f6393951d1511562feceafbdecf Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Mon, 26 Sep 2011 21:18:40 +1000 Subject: [PATCH] Added in Shipments auto complete --- controllers/purchase_orders_controller.php | 16 +++++----------- views/purchase_orders/getdata.ctp | 1 + webroot/js/add_edit_shipment.js | 13 ++++++++++++- 3 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 views/purchase_orders/getdata.ctp diff --git a/controllers/purchase_orders_controller.php b/controllers/purchase_orders_controller.php index 07e428c1..e8973300 100755 --- a/controllers/purchase_orders_controller.php +++ b/controllers/purchase_orders_controller.php @@ -117,18 +117,12 @@ class PurchaseOrdersController extends AppController { } + function getdata($id) { + $po = $this->PurchaseOrder->read(null, $id); + $this->set('po_json', json_encode($po)); + } - /*function delete($id = null) { - if (!$id) { - $this->Session->setFlash(__('Invalid id for PurchaseOrder', true)); - $this->redirect(array('action'=>'index')); - } - if ($this->PurchaseOrder->del($id)) { - $this->Session->setFlash(__('PurchaseOrder deleted', true)); - $this->redirect(array('action'=>'index')); - } - }*/ - + } ?> \ No newline at end of file diff --git a/views/purchase_orders/getdata.ctp b/views/purchase_orders/getdata.ctp new file mode 100644 index 00000000..4aa58e8b --- /dev/null +++ b/views/purchase_orders/getdata.ctp @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/webroot/js/add_edit_shipment.js b/webroot/js/add_edit_shipment.js index 0fc14bd7..0c5b656b 100644 --- a/webroot/js/add_edit_shipment.js +++ b/webroot/js/add_edit_shipment.js @@ -96,7 +96,18 @@ $(function() { if($('#PurchaseOrderID_'+ui.item.id).length == 0) { //This PO is already in the List. Don't do anything.' addToList('PurchaseOrder', ui.item.id, ui.item.value, $('#purchaseOrdersList')); - } + + $.getJSON('/purchase_orders/getdata/'+ui.item.id, function(data) { + console.log(data); + //alert(data.Principle.id+' '+data.Principle.name); + addToList('Principle', data.Principle.id, data.Principle.name, $('#principlesList')); + + $.each(data.Job, function(key, job) { + addToList('Job',job.id, job.title, $('#jobsList')); + }); + + }); + } }