From 6549c00b49b1345d8cb2f1573700f3af88d87669 Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Sun, 23 Jun 2013 12:05:59 +1000 Subject: [PATCH] Implemented POs --- .../elements/document_purchase_order_view.ctp | 21 ++++++++ app/views/products/edit.ctp | 1 - app/webroot/js/document_add_edit.js | 50 +++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/app/views/elements/document_purchase_order_view.ctp b/app/views/elements/document_purchase_order_view.ctp index c90e8447..2bba11f1 100755 --- a/app/views/elements/document_purchase_order_view.ctp +++ b/app/views/elements/document_purchase_order_view.ctp @@ -21,6 +21,27 @@ echo $form->input('PurchaseOrder.id'); echo $form->input('PurchaseOrder.principle_id'); echo $form->input('PurchaseOrder.principle_reference'); +?> +
+ input('job', array('id'=>'job_autocomplete', array('label'=>'Job (start typing and select from the list)'))); + ?> + Jobs in this Shipment will be updated as "sent" + + + +
+ +input('PurchaseOrder.currency_id'); echo $form->input('PurchaseOrder.dispatch_date'); echo $form->input('PurchaseOrder.date_arrived'); //ARGH. Really Karl? diff --git a/app/views/products/edit.ctp b/app/views/products/edit.ctp index 57a6ea92..6bab0f39 100755 --- a/app/views/products/edit.ctp +++ b/app/views/products/edit.ctp @@ -15,7 +15,6 @@ echo $javascript->link('edit_product'); echo $form->input('description'); echo $form->input('notes'); - echo $form->input('item_code'); echo $form->input('item_description'); diff --git a/app/webroot/js/document_add_edit.js b/app/webroot/js/document_add_edit.js index dd45a138..8e58718c 100755 --- a/app/webroot/js/document_add_edit.js +++ b/app/webroot/js/document_add_edit.js @@ -9,6 +9,36 @@ $(function() { + + /** + * A more generic way of handling the HABTM + * Copypasta'd from add_edit_shipment.js. + */ + function addToList(modelName, id, value, ULelement) { + var thisLI = $('
  • '); + var thisButton = $(''); + thisButton.addClass('removeFromList'); + thisButton.button(); + + var thisHiddenInput = $(''); + + var modelString = '['+modelName+']'; + + thisHiddenInput.attr('name', 'data[PurchaseOrder]'+modelString+'[]'); + + thisHiddenInput.attr('value', id); + + thisLI.attr('id', modelName+'ID_'+id); + thisLI.html(value); + thisLI.prepend(thisButton); + thisLI.append(thisHiddenInput); + ULelement.append(thisLI); + +} + + + + // var config defined in global.js loadLineItems(); var docID = $('#documentID').html(); @@ -433,6 +463,25 @@ $(function() { setAddress(address, '#DocumentShipTo', 'Ship To'); }); + + + //Fuck it. Copypaste. Autocompletion of jobs on PO document view + $( "#job_autocomplete" ).autocomplete({ + source: "/jobs/autocomplete", + minLength: 2, + select: function( event, ui ) { + + if($('#JobID_'+ui.item.id).length == 0) { //This Job is already in the List. Don't do anything.' + addToList('Job', ui.item.id, ui.item.value, $('#jobsList')); + + + + } + } + }); + + + }); @@ -690,4 +739,5 @@ function checkNaN(value) { + }