diff --git a/app/controllers/documents_controller.php b/app/controllers/documents_controller.php index 984ce376..8a837f21 100755 --- a/app/controllers/documents_controller.php +++ b/app/controllers/documents_controller.php @@ -292,20 +292,10 @@ class DocumentsController extends AppController { foreach($copy_doc_attributes as $attr) { $this->data['Document'][$attr] = $sourceDoc['Document'][$attr]; } - /*echo "
";
-			print_r($sourceDoc);
-			echo "--
"; - print_r($this->data); - echo "
"; - die();*/ - if(!empty($sourceDoc['LineItem'])) { - $this->data['LineItem'] = $sourceDoc['LineItem']; - foreach($this->data['LineItem'] as $index => $li) { - $this->data['LineItem'][$index]['id'] = null; - $this->data['LineItem'][$index]['document_id'] = null; - $this->data['LineItem'][$index]['costing_id'] = null; - } - } + + + $this->data['LineItem'] = $this->copy_related($sourceDoc, 'LineItem', array('id', 'document_id', 'costing_id')); + } if ($this->Document->saveAll($this->data)) { $newid = $this->Document->id; @@ -382,27 +372,14 @@ class DocumentsController extends AppController { /** Copy the LineItems from this Document. Applies to all of the Document Types */ - if(!empty($document['LineItem'])) { - $newDoc['LineItem'] = $document['LineItem']; - foreach($newDoc['LineItem'] as $index => $li) { - $newDoc['LineItem'][$index]['id'] = null; - $newDoc['LineItem'][$index]['document_id'] = null; - $newDoc['LineItem'][$index]['costing_id'] = null; - } - } + + $newDoc['LineItem'] = $this->copy_related($document, 'LineItem', array('id', 'document_id', 'costing_id')); - if(!empty($document['DocumentAttachment'])) { - $newDoc['DocumentAttachment'] = $document['DocumentAttachment']; - foreach($newDoc['DocumentAttachment'] as $index => $da) { - $newDoc['DocumentAttachment'][$index]['id'] = null; - $newDoc['DocumentAttachment'][$index]['document_id'] = null; - } - } + $newDoc['DocumentAttachment'] = $this->copy_related($document, 'DocumentAttachment', 'id', 'document_id'); $this->set('newDoc', $newDoc); - // - //print_r($newDoc); + if ($this->Document->saveAll($newDoc)) { $newid = $this->Document->id; $this->Session->setFlash(__("Revision {$number_of_revisions} created", true)); @@ -496,16 +473,11 @@ class DocumentsController extends AppController { } + $newDoc['LineItem'] = $this->copy_related($originalDoc, 'LineItem', array('id', 'document_id', 'costing_id')); + $newDoc['DocumentAttachment'] = $this->copy_related($originalDoc, 'DocumentAttachment', array('id', 'document_id')); /** Copy the LineItems from this Document. Applies to all of the Document Types */ - if(!empty($originalDoc['LineItem'])) { - $newDoc['LineItem'] = $originalDoc['LineItem']; - foreach($newDoc['LineItem'] as $index => $li) { - $newDoc['LineItem'][$index]['id'] = null; - $newDoc['LineItem'][$index]['document_id'] = null; - $newDoc['LineItem'][$index]['costing_id'] = null; - } - } + if ($this->Document->saveAll($newDoc)) { $newid = $this->Document->id; @@ -769,5 +741,29 @@ class DocumentsController extends AppController { } + /** Helper function to make copying related models more DRY + * + * @param array $document + * @param string $model - eg 'LineItem' + * @param array $keys_to_null - eg. array('id', 'document_id') + * + * */ + function copy_related($document, $model, $keys_to_null) { + if(empty($document[$model])) { + return null; + } + $newDoc[$model] = $document[$model]; + + foreach($newDoc[$model] as $index => $ele) { + foreach($keys_to_null as $key) { + $newDoc[$model][$index][$key] = null; + } + } + return $newDoc[$model]; + } + + + } + ?> diff --git a/app/vendors/pdfdoc.php b/app/vendors/pdfdoc.php index bd399319..6cdbadfc 100755 --- a/app/vendors/pdfdoc.php +++ b/app/vendors/pdfdoc.php @@ -40,7 +40,7 @@ class PDFDOC extends FPDI { $this->SetFontSize(10); $this->SetY(22); $this->Cell(30); - $this->Cell(0,0, "PTY LIMITED ACN: 47 085 991 224 ABN: 47 085 991 224", 0, 1, 'C', 1); + $this->Cell(0,0, "PTY LIMITED ACN: 085 991 224 ABN: 47 085 991 224", 0, 1, 'C', 1); //$this->Rect($x, $y, $w, $h, $style, $border_style); $this->Rect($this->GetX()+33, $this->GetY()+2, 157, 1, 'DF', array('width'=>0), array(0, 0, 0)); diff --git a/app/views/elements/line_items_table_with_shipping.ctp b/app/views/elements/line_items_table_with_shipping.ctp index 10eb8628..3981eb00 100755 --- a/app/views/elements/line_items_table_with_shipping.ctp +++ b/app/views/elements/line_items_table_with_shipping.ctp @@ -71,7 +71,7 @@ - SHIPPING DETAILS: + FREIGHT DETAILS: diff --git a/app/views/elements/pdf_shipping_billing_box.ctp b/app/views/elements/pdf_shipping_billing_box.ctp index 98db2fdd..60498d0a 100755 --- a/app/views/elements/pdf_shipping_billing_box.ctp +++ b/app/views/elements/pdf_shipping_billing_box.ctp @@ -6,14 +6,14 @@ $col3width = '30%'; ?> - - + + - - - + + - diff --git a/app/views/elements/pdf_shipping_billing_box_oa.ctp b/app/views/elements/pdf_shipping_billing_box_oa.ctp index 34e12fba..34201647 100755 --- a/app/views/elements/pdf_shipping_billing_box_oa.ctp +++ b/app/views/elements/pdf_shipping_billing_box_oa.ctp @@ -6,14 +6,14 @@ $col3width = '30%'; ?>
Billing Details:Delivery DetailsSold To / Invoice Address:Delivery Address: CMC #:
Date:
- Estimated Delivery:
+ Estimated Despatch Date:
Page: of

MAKE PAYMENT TO:
@@ -39,16 +39,14 @@ $col3width = '30%';
CUSTOMER ORDER NO CMC JOB #FOBSHIP VIATERMSINCOTERMS 2010PAYMENT TERMS CUSTOMER ABN
element('abn', array('abn'=>$job['Customer']['abn']));?>
- - + + - - + @@ -48,7 +47,6 @@ $col3width = '30%'; -
BILL TO:SHIP TO:Sold To / Invoice Address:Delivery Address: CMC #:
Date:
- Estimated Delivery:
+ Estimated Despatch Date:
Page: of

MAKE PAYMENT TO:
@@ -39,8 +39,7 @@ $col3width = '30%';
CUSTOMER ORDER NO CMC REF #EX WORKSSHIP VIAINCOTERMS 2010 PAYMENT TERMS CUST. ABN
element('abn', array('abn'=>$job['Customer']['abn']));?>