From 3f1c37057d82ce42372419d465f8aeba36017c20 Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Sat, 15 Jun 2013 18:32:14 +1000 Subject: [PATCH 1/4] Implemented PO first page. Added extra PO field migration --- app/controllers/documents_controller.php | 40 +++++- .../15_6_2013_add_extra_po_fields.sql | 5 + app/views/documents/pdf_po.ctp | 13 +- .../elements/document_purchase_order_view.ctp | 20 ++- app/views/elements/line_items_table_po.ctp | 123 ++++++++++++++++++ app/views/elements/pdf_po_first_page.ctp | 74 +++++++++++ app/views/layouts/default.ctp | 3 +- app/views/purchase_orders/index.ctp | 31 ++--- app/webroot/js/document_add_edit.js | 64 +++++---- 9 files changed, 309 insertions(+), 64 deletions(-) create mode 100644 app/migrations/15_6_2013_add_extra_po_fields.sql create mode 100755 app/views/elements/line_items_table_po.ctp create mode 100644 app/views/elements/pdf_po_first_page.ctp diff --git a/app/controllers/documents_controller.php b/app/controllers/documents_controller.php index 0fc891fd..2096220f 100755 --- a/app/controllers/documents_controller.php +++ b/app/controllers/documents_controller.php @@ -269,16 +269,40 @@ class DocumentsController extends AppController { $enquiry = $this->Document->OrderAcknowledgement->Enquiry->read(null, $enquiryid); $count = $this->Document->PurchaseOrder->findCount(); $count++; - $offset = 2060; $count += $offset; $newPOnumber = "CMCPO".$count; $this->data['PurchaseOrder']['title'] = $newPOnumber; $this->data['PurchaseOrder']['issue_date'] = date('Y-m-d'); + + $this->data['PurchaseOrder']['deliver_to'] = << +Unit 19, 77 Bourke Road
+Alexandria NSW 2015 AUSTRALIA
+ENDDELIVER; + + //Fuck it all. + $this->data['PurchaseOrder']['shipping_instructions'] = <<PART SHIPMENT: Not Acceptable - please advise ASAP if production of an Item will Delay the Dispatch of the Complete Order by the Date Required stated above.
+INSURANCE: DO NOT INSURE - Insurance effected by CMC
+SECURITY: It is essential that the cargo is prepared & handled so as not to compromise its security standing.
+SHIPMENT MARKINGS:
+(Please put red fragile stickers on boxing)
+CMC TECHNOLOGIES PTY LTD
+UNIT 19, 77 BOURKE ROAD
+ALEXANDRIA NSW 2015 AUSTRALIA
+ENDINSTRUCTIONS; + + + + $this->data['Document']['user_id']= $enquiry['Enquiry']['user_id']; $this->data['Document']['revision'] = 0; //No revisions for POs. I have decreed it! $this->data['Document']['type'] = 'purchaseOrder'; break; + + case "orderAck": $enquiry = $this->Document->OrderAcknowledgement->Enquiry->read(null, $enquiryid); $this->data['OrderAcknowledgement']['job_id'] = $jobid; @@ -642,7 +666,21 @@ class DocumentsController extends AppController { break; case "purchaseOrder": + + $totalsDescText = array( + 'subtotal' => 'SUBTOTAL', + 'gst' => '', + 'total' => 'ORDER TOTAL' + ); + //No GST for POs for now. + $totals = $this->calculateTotals($document, 0); + $this->set('totals',$totals); + $this->set('totalsDescText',$totalsDescText); + $filename = $document['PurchaseOrder']['title']; + + $issue_date = date('l, j F Y', strtotime($document['PurchaseOrder']['issue_date'])); + $this->set('issue_date', $issue_date); $template_name = 'pdf_po'; break; diff --git a/app/migrations/15_6_2013_add_extra_po_fields.sql b/app/migrations/15_6_2013_add_extra_po_fields.sql new file mode 100644 index 00000000..936fd112 --- /dev/null +++ b/app/migrations/15_6_2013_add_extra_po_fields.sql @@ -0,0 +1,5 @@ +ALTER TABLE `purchase_orders` ADD `currency_id` INT NOT NULL; + +ALTER TABLE `purchase_orders` ADD `ordered_from` TEXT NOT NULL, ADD `description` TEXT NOT NULL, ADD `dispatch_by` VARCHAR(255) NOT NULL, ADD `deliver_to` TEXT NOT NULL, ADD `shipping_instructions` TEXT NOT NULL; + + diff --git a/app/views/documents/pdf_po.ctp b/app/views/documents/pdf_po.ctp index 13f14ce9..04f9a71c 100755 --- a/app/views/documents/pdf_po.ctp +++ b/app/views/documents/pdf_po.ctp @@ -10,20 +10,17 @@ $pdfdoc->SetPrintFooter(false); $pdfdoc->AddPage(); $pdfdoc->Page1Header(); -$pageTitle = "

PURCHASE ORDER

"; -$pdfdoc->writeHTML($pageTitle, true, false, false, false, 'C'); + +$first_page = $this->element('pdf_po_first_page'); +$pdfdoc->pageContent($first_page); $pdfdoc->SetTextColor(0); - $pageNo = $pdfdoc->PageNoFormatted(); $totalCount = $pdfdoc->getAliasNbPages(); +$pdfdoc->AddPage(); -$shippingBillingBox = $this->element('pdf_shipping_billing_box', array('pageNo'=>$pageNo, 'totalCount'=>$totalCount)); - -$pdfdoc->writeHTML($shippingBillingBox, false); - -$LineItemTable = $this->element('line_items_table_with_shipping'); +$LineItemTable = $this->element('line_items_table_po'); //Because fuck it. $pdfdoc->SetPrintHeader(true); $pdfdoc->pageContent($LineItemTable); diff --git a/app/views/elements/document_purchase_order_view.ctp b/app/views/elements/document_purchase_order_view.ctp index 9553f491..c90e8447 100755 --- a/app/views/elements/document_purchase_order_view.ctp +++ b/app/views/elements/document_purchase_order_view.ctp @@ -1,10 +1,9 @@

Purchase Order:

-

Job: link($invoice['Job']['title'], array('controller'=>'jobs', 'action'=>'view', $invoice['Job']['id']));?>

+

Job:

-
@@ -26,18 +25,15 @@ echo $form->input('PurchaseOrder.dispatch_date'); echo $form->input('PurchaseOrder.date_arrived'); //ARGH. Really Karl? - echo $form->input('billing_address_id', array('div' => 'addressradio', 'legend' => 'Select Billing Address', 'options' => $billing_addresses_list, 'type' => 'radio', 'class'=>'billing_address')); - echo $form->input('Document.bill_to'); - - - echo $form->input('shipping_address_id', array('div' => 'addressradio','legend' => 'Select Shipping Address', 'options' => $shipping_addresses_list, 'type' => 'radio', 'class' => 'shipping_address')); - echo $form->input('Document.ship_to'); + echo $form->input('PurchaseOrder.ordered_from'); + echo $form->input('PurchaseOrder.description'); + + echo $form->input('PurchaseOrder.dispatch_by'); + + echo $form->input('PurchaseOrder.deliver_to'); + echo $form->input('PurchaseOrder.shipping_instructions'); - - echo $form->input('PurchaseOrder.ship_via'); - echo $form->input('PurchaseOrder.fob'); - echo $form->input('Document.shipping_details', array('id'=>'shippingDetails')); echo $form->end(array('label'=>'Save PurchaseOrder Details', 'id'=>'savePurchaseOrderButton')); ?> diff --git a/app/views/elements/line_items_table_po.ctp b/app/views/elements/line_items_table_po.ctp new file mode 100755 index 00000000..1a81a6fe --- /dev/null +++ b/app/views/elements/line_items_table_po.ctp @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ITEM
NO.
QTYDESCRIPTIONUNIT
PRICE
TOTAL
PRICE
+ '; + $hasOptions = true; + } + ?> + + formatDecimal($li['quantity']);?>
+ +
+ + + currency($li['gross_unit_price'], $currencyCode);?> + +
less
%
+ discount
+ (-currency($li['discount_amount_unit'], $currencyCode);?>)
+ =
+ currency($li['net_unit_price'], $currencyCode);?> + + +
+ + + currency($li['gross_price'], $currencyCode);?> + +
less
%
+ discount*
+ (-currency($li['discount_amount_total'], $currencyCode);?>)
+ =
+ currency($li['net_price'], $currencyCode);?> + + +
+ currency($totals['subtotal'], $currencyCode); + } + else { + echo $currencySymbol.'TBA'; + } + ?>
+ +
+ currency($totals['total'], $currencyCode); + } + else { + echo $currencySymbol.'TBA'; + } + ?>
diff --git a/app/views/elements/pdf_po_first_page.ctp b/app/views/elements/pdf_po_first_page.ctp new file mode 100644 index 00000000..e35d7788 --- /dev/null +++ b/app/views/elements/pdf_po_first_page.ctp @@ -0,0 +1,74 @@ + + + + + + +
PURCHASE ORDER NO:Date:
+


+ + + + + +
ORDERED FROM:
+ +


+ + + + + + + + + + + + + + + +
ReferenceDescriptionOrder Total
+ currency($totals['total'], $currencyCode); ?> +
+ +

+ + + + + + + + +
DISPATCH EX-WORKS BY:


+ + + + + +
DELIVER TO:


+ + + + + + + + + + +
SHIPPING INSTRUCTIONS:
+
+
+

+ + + + + +
I HEREBY CERTIFY THAT CMC TECHNOLOGIES IS REGISTERED FOR GST AND OUR REGISTRATION # IS 47 085 991 224.

+CON CARPIS
+ + diff --git a/app/views/layouts/default.ctp b/app/views/layouts/default.ctp index ad390ca1..e5d09f9a 100755 --- a/app/views/layouts/default.ctp +++ b/app/views/layouts/default.ctp @@ -106,8 +106,7 @@ if ($currentuser['User']['access_level'] == 'manager' || $currentuser['User']['a
  • link('POs', '/purchase_orders/index'); ?>
      -
    • link('PO Index', '/purchase_orders/index'); ?>
    • -
    • link('New PO', '/purchase_orders/add'); ?>
    • +
    • link('PO Index', '/purchase_orders/index'); ?>
  • diff --git a/app/views/purchase_orders/index.ctp b/app/views/purchase_orders/index.ctp index f707bfc4..abf811ca 100755 --- a/app/views/purchase_orders/index.ctp +++ b/app/views/purchase_orders/index.ctp @@ -1,5 +1,9 @@

    + +

    counter(array( @@ -17,7 +21,7 @@ echo $paginator->counter(array( sort('principle_id');?> sort('principle_reference');?> sort('document_id');?> */?> - + Document link($purchaseOrder['Document']['id'], array('controller' => 'documents', 'action' => 'view', $purchaseOrder['Document']['id'])); ?> */ ?> - - link(__('View', true), array('action' => 'view', $purchaseOrder['PurchaseOrder']['id'])); ?> - link(__('Edit', true), array('action' => 'edit', $purchaseOrder['PurchaseOrder']['id'])); ?> - - + + 0) { ?> + View + + + +

    @@ -71,18 +77,6 @@ foreach ($purchaseOrders as $purchaseOrder): | numbers();?> next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?> -
    -
      -
    • link(__('New PurchaseOrder', true), array('action' => 'add')); ?>
    • -
    • link(__('List Principles', true), array('controller' => 'principles', 'action' => 'index')); ?>
    • -
    • link(__('New Principle', true), array('controller' => 'principles', 'action' => 'add')); ?>
    • -
    • link(__('List Documents', true), array('controller' => 'documents', 'action' => 'index')); ?>
    • -
    • link(__('New Document', true), array('controller' => 'documents', 'action' => 'add')); ?>
    • -
    • link(__('List Jobs', true), array('controller' => 'jobs', 'action' => 'index')); ?>
    • -
    • link(__('New Job', true), array('controller' => 'jobs', 'action' => 'add')); ?>
    • -
    -
    - - \ No newline at end of file diff --git a/app/webroot/js/document_add_edit.js b/app/webroot/js/document_add_edit.js index 56aef3d4..dd45a138 100755 --- a/app/webroot/js/document_add_edit.js +++ b/app/webroot/js/document_add_edit.js @@ -40,7 +40,7 @@ $(function() { } else { alert("Line Item could not be saved") - $('#LineItemDescription').ckeditor(config); + $('#LineItemDescription').ckeditor(config); } }); @@ -75,7 +75,7 @@ $(function() { } else { alert("Line Item could not be saved") - $('#LineItemDescription').ckeditor(config); + $('#LineItemDescription').ckeditor(config); } }); @@ -353,12 +353,12 @@ $(function() { var confirmed = confirm("This will overwrite any changes you have made to the first page"); } - if(confirmed) { - $.get('/documents/generateFirstPage/'+docID, function(data) { - $(".firstPage").val(data); - savePages(); - }); - } + if(confirmed) { + $.get('/documents/generateFirstPage/'+docID, function(data) { + $(".firstPage").val(data); + savePages(); + }); + } }); @@ -386,21 +386,34 @@ $(function() { //OA View. $("#saveOAButton").click(function() { saveDocument('Order Acknowledgement'); - //if the job has changed, the create invoice button wont work properly. + //if the job has changed, the create invoice button wont work properly. window.location.reload(true); $('.job-title').html($("#OrderAcknowledgementJobId :selected").text()); }); - + + //This is fucked beyond all words. + $("#PurchaseOrderDeliverTo").ckeditor(config); + $("#PurchaseOrderOrderedFrom").ckeditor(config); + $("#PurchaseOrderShippingInstructions").ckeditor(config); + $("#PurchaseOrderDescription").ckeditor(config); + //PackingList View. Damn you past Karl. $("#savePackingListButton").click(function() { saveDocument('Packing List'); - //if the job has changed, the create invoice button wont work properly. + //if the job has changed, the create invoice button wont work properly. window.location.reload(true); $('.job-title').html($("#PackingListJobId :selected").text()); }); + //PurchaseOrder View. Damn you past Karl. + $("#savePurchaseOrderButton").click(function() { + saveDocument('Purchase Order'); + }); + + + $("#createOA").click(function() { $("#addJobConfirmation").dialog('open'); @@ -472,8 +485,8 @@ function saveDocument(documentName) { else { $("#flashMessage").html("Unable to save "+documentName); } - $("#flashMessage").show(); - loadLineItems(); + $("#flashMessage").show(); + loadLineItems(); }); } @@ -505,17 +518,24 @@ function showHideTextPrices() { } +//I am a much better programmer now. +//FUCK YEAH!! function updateTextFields() { - $('#shippingDetails').ckeditor(function() { - this.updateElement(); - }); + var fields = [ + '#shippingDetails', + "#DocumentBillTo", + "#DocumentShipTo", + "#PurchaseOrderDeliverTo", + "#PurchaseOrderOrderedFrom", + "#PurchaseOrderShippingInstructions", + "#PurchaseOrderDescription" + ]; - $("#DocumentBillTo").ckeditor(function() { - this.updateElement(); - }); - $("#DocumentShipTo").ckeditor(function() { - this.updateElement(); - }); + for (i in fields) { + $(fields[i]).ckeditor(function() { + this.updateElement(); + }); + } } From 58da2bd2732c1fc86df13a03086bc795fdd464a0 Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Sun, 16 Jun 2013 11:29:39 +1000 Subject: [PATCH 2/4] border change --- app/views/elements/pdf_po_first_page.ctp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/views/elements/pdf_po_first_page.ctp b/app/views/elements/pdf_po_first_page.ctp index e35d7788..cc47d635 100644 --- a/app/views/elements/pdf_po_first_page.ctp +++ b/app/views/elements/pdf_po_first_page.ctp @@ -15,7 +15,7 @@


    - +
    @@ -29,8 +29,6 @@ currency($totals['total'], $currencyCode); ?> - -
    Reference Description


    From 6549c00b49b1345d8cb2f1573700f3af88d87669 Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Sun, 23 Jun 2013 12:05:59 +1000 Subject: [PATCH 3/4] 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" + +
      + data['Job'] as $job):?> +
    • + + + +
    • + +
    + +
    + +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
    • [REMOVE BUTTON] NAME [HIDDEN INPUT]
    + * 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) { + } From c1f73845507af880fd6e520d0e6bfe875a9d2956 Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Sun, 23 Jun 2013 18:31:21 +1000 Subject: [PATCH 4/4] Got this damn thing working --- app/controllers/documents_controller.php | 86 +++++++++++++++++-- app/views/documents/add_job_items_to_po.ctp | 0 .../elements/document_purchase_order_view.ctp | 6 +- app/views/purchase_orders/index.ctp | 2 +- app/webroot/js/document_add_edit.js | 20 ++++- 5 files changed, 102 insertions(+), 12 deletions(-) create mode 100644 app/views/documents/add_job_items_to_po.ctp diff --git a/app/controllers/documents_controller.php b/app/controllers/documents_controller.php index 2096220f..039f0dcc 100755 --- a/app/controllers/documents_controller.php +++ b/app/controllers/documents_controller.php @@ -25,7 +25,8 @@ class DocumentsController extends AppController { $this->Session->setFlash(__('Invalid Document.', true)); $this->redirect(array('action'=>'index')); } - $document = $this->Document->read(null,$id); + //$document = $this->Document->read(null,$id); + $document = $this->Document->find('first', array('conditions' => array('Document.id' => $id), 'recursive'=>1)); $this->set('document', $document); @@ -77,6 +78,12 @@ class DocumentsController extends AppController { case 'purchaseOrder': $docTypeElement = 'document_purchase_order_view'; $this->set('currencies', $this->Document->PurchaseOrder->Currency->find('list')); + $this->set('purchaseOrder', $this->Document->PurchaseOrder->find('first', + array('conditions'=> + array('PurchaseOrder.id' => $document['PurchaseOrder']['id']) + ) + )); + break; case 'orderAck': $this->set('currencies', $this->Document->OrderAcknowledgement->Currency->find('list')); @@ -266,7 +273,7 @@ class DocumentsController extends AppController { break; case "purchaseOrder": - $enquiry = $this->Document->OrderAcknowledgement->Enquiry->read(null, $enquiryid); + //$enquiry = $this->Document->OrderAcknowledgement->Enquiry->read(null, $enquiryid); $count = $this->Document->PurchaseOrder->findCount(); $count++; $offset = 2060; @@ -295,9 +302,8 @@ ALEXANDRIA NSW 2015 AUSTRALIA
    ENDINSTRUCTIONS; - - - $this->data['Document']['user_id']= $enquiry['Enquiry']['user_id']; + $currentuser = $this->Session->read('Auth.User'); + $this->data['Document']['user_id'] = $currentuser['id']; $this->data['Document']['revision'] = 0; //No revisions for POs. I have decreed it! $this->data['Document']['type'] = 'purchaseOrder'; break; @@ -492,6 +498,31 @@ ENDINSTRUCTIONS; $this->Document->DocPage->deleteAll(array('document_id'=>$docID)); $this->Document->DocPage->updateCounterCache(array('document_id'=>$docID)); + if(isset($this->data['PurchaseOrder'])) { + //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); + + } + + if(isset($this->data['PurchaseOrder']['Job'])) { + //Loop over the submitted Jobs and add them. Fuck CakePHP is a piece of shit. + //This is easier than using the fucking built in crap that doesnt work. + //Fuck everything about this. + $po_id = $this->data['PurchaseOrder']['id']; + foreach($this->data['PurchaseOrder']['Job'] as $job_id) { + $query = "INSERT INTO `quotenik`.`jobs_purchase_orders` (`id`, `job_id`, `purchase_order_id`) VALUES (NULL, '{$job_id}', '{$po_id}');"; + $this->Document->query($query); + } + + $result = $this->Document->PurchaseOrder->saveAll($this->data['PurchaseOrder']); + + + //die(print_r($this->data['PurchaseOrder'])); + //die(print_r($result)); + //die(print_r($this->data)); + } if ($this->Document->saveAll($this->data)) { echo 'SUCCESS'; @@ -851,6 +882,51 @@ ENDINSTRUCTIONS; } + function add_job_items_to_po($job_id, $document_id) { + $this->layout = 'ajax'; + $job = $this->Document->PurchaseOrder->Job->find('first', array('conditions'=>array('Job.id' => $job_id))); + + $orderack = $this->Document->OrderAcknowledgement->find('first', array('conditions'=>array('OrderAcknowledgement.enquiry_id' => $job['Job']['enquiry_id']), 'recursive' => 1)); + + $oa_document = $this->Document->find('first', + array('conditions'=> + array('Document.id' => $orderack['Document']['id'] + ) + ) + ); + + + $destination_document = $this->Document->find('first', array('conditions'=>array('Document.id' => $document_id))); + + $new_items = $this->copy_related($oa_document, 'LineItem', array('id', 'document_id', 'costing_id')); + + $last_item_number = 1.0; + foreach($destination_document['LineItem'] as $item) { + $last_item_number = $item['item_number']; + } + if($last_item_number != 1.0) { //Fuck knows + $last_item_number++; + } + + foreach($new_items as $i => $item) { + $item['item_number'] = $last_item_number++; + $item['document_id'] = $document_id; + $destination_document['LineItem'][] = $item; + } + + + + if ($this->Document->LineItem->saveAll($destination_document['LineItem'])) { + echo 'SUCCESS'; + } + else { + echo 'FAILURE'; + + } + + } + + function costing() { } diff --git a/app/views/documents/add_job_items_to_po.ctp b/app/views/documents/add_job_items_to_po.ctp new file mode 100644 index 00000000..e69de29b diff --git a/app/views/elements/document_purchase_order_view.ctp b/app/views/elements/document_purchase_order_view.ctp index 2bba11f1..25600124 100755 --- a/app/views/elements/document_purchase_order_view.ctp +++ b/app/views/elements/document_purchase_order_view.ctp @@ -1,5 +1,4 @@

    Purchase Order:

    -

    Job:

    @@ -26,10 +25,10 @@ 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" + Items from the OA for this Job will be added automatically to the PO.
      - data['Job'] as $job):?> +
    • @@ -37,7 +36,6 @@
    -