diff --git a/app/controllers/documents_controller.php b/app/controllers/documents_controller.php index 039f0dcc..e6117c62 100755 --- a/app/controllers/documents_controller.php +++ b/app/controllers/documents_controller.php @@ -16,7 +16,6 @@ class DocumentsController extends AppController { function index() { $this->Document->recursive = 0; $this->set('documents', $this->paginate()); - $this->set('users', $this->Document->User->getUsersList()); } @@ -697,14 +696,27 @@ ENDINSTRUCTIONS; break; case "purchaseOrder": + $principle = $this->Document->LineItem->Product->Principle->find('first', array('conditions'=>array('Principle.id' => $document['PurchaseOrder']['principle_id']))); + $this->set('principle', $principle); + $purchase_order = $this->Document->PurchaseOrder->find('first', + array('conditions'=>array('PurchaseOrder.id' => $document['PurchaseOrder']['id']))); + $this->set('purchase_order', $purchase_order); + $totalsDescText = array( 'subtotal' => 'SUBTOTAL', - 'gst' => '', + 'gst' => 'GST', 'total' => 'ORDER TOTAL' ); //No GST for POs for now. - $totals = $this->calculateTotals($document, 0); + if($principle['Country']['id'] == 1) { + $totals = $this->calculateTotals($document, 1); + } + else { + $totalsDescText['gst'] = ''; + $totals = $this->calculateTotals($document, 0); + } + $this->set('totals',$totals); $this->set('totalsDescText',$totalsDescText); @@ -852,7 +864,16 @@ ENDINSTRUCTIONS; $this->set('invoice', $this->Document->Invoice->find('first', array('conditions'=>array('Invoice.id'=>$document['Invoice']['id'])))); break; case 'purchaseOrder': - $this->set('job', $this->Document->PurchaseOrder->Job->find('first', array('conditions'=>array('Job.id'=>$document['OrderAcknowledgement']['job_id'])))); + $primary_contact = $this->Document->User->find('first', array('conditions'=>array('User.principle_id' => $document['PurchaseOrder']['principle_id'],'User.primary_contact' => 1))); + if(empty($primary_contact)) { + + $this->Session->setFlash(__('Unable to sent. No primary Principle Contact', true)); + $this->redirect(array('action'=>'view/'.$id), null, false); + return; + } + + $this->Email->to = $primary_contact['User']['email']; + $this->set('job', $this->Document->PurchaseOrder->Job->find('first', array('conditions'=>array('Job.id'=>$document['OrderAcknowledgement']['job_id'])))); break; case 'orderAck': $this->set('job', $this->Document->OrderAcknowledgement->Job->find('first', array('conditions'=>array('Job.id'=>$document['OrderAcknowledgement']['job_id'])))); diff --git a/app/migrations/15_6_2013_add_extra_po_fields.sql b/app/migrations/15_6_2013_add_extra_po_fields.sql index 936fd112..ae915ba5 100644 --- a/app/migrations/15_6_2013_add_extra_po_fields.sql +++ b/app/migrations/15_6_2013_add_extra_po_fields.sql @@ -2,4 +2,4 @@ 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; - +ALTER TABLE `purchase_orders` ADD `jobs_text` VARCHAR( 512 ) NOT NULL diff --git a/app/vendors/pdfdoc.php b/app/vendors/pdfdoc.php index 6cdbadfc..e45541bf 100755 --- a/app/vendors/pdfdoc.php +++ b/app/vendors/pdfdoc.php @@ -15,11 +15,11 @@ class PDFDOC extends FPDI { function pageContent($content) { - $this->SetTextColor(0); - $this->SetFontSize(11); //Changed from 12 - $this->SetFont('times', ''); + $this->SetTextColor(0); + $this->SetFontSize(11); //Changed from 12 + $this->SetFont('times', ''); - $this->writeHTML($content, true, false, false, false, ''); + $this->writeHTML($content, true, false, false, false, ''); } diff --git a/app/views/documents/pdf_po.ctp b/app/views/documents/pdf_po.ctp index 04f9a71c..a977dd8a 100755 --- a/app/views/documents/pdf_po.ctp +++ b/app/views/documents/pdf_po.ctp @@ -6,6 +6,7 @@ $pdfdoc = new PDFDOC(); $pdfdoc->SetPrintHeader(false); $pdfdoc->SetPrintFooter(false); +$pdfdoc->SetPrintHeader(true); $pdfdoc->AddPage(); $pdfdoc->Page1Header(); @@ -19,9 +20,7 @@ $pageNo = $pdfdoc->PageNoFormatted(); $totalCount = $pdfdoc->getAliasNbPages(); $pdfdoc->AddPage(); - $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 25600124..e06988d4 100755 --- a/app/views/elements/document_purchase_order_view.ctp +++ b/app/views/elements/document_purchase_order_view.ctp @@ -4,28 +4,25 @@