diff --git a/app/controllers/documents_controller.php b/app/controllers/documents_controller.php index 0b88fc58..9db4d5a5 100755 --- a/app/controllers/documents_controller.php +++ b/app/controllers/documents_controller.php @@ -808,165 +808,6 @@ ENDINSTRUCTIONS; $this->set('enquiry', $enquiry); } - - - - - function pdf($id = null) { - //Configure::write('debug',0); - if(!$id) { - $this->Session->setFlash(__('Invalid Document', true)); - $this->redirect(array('controller'=>'documents', 'action'=>'index')); - } - - $document = $this->Document->read(null,$id); - - $this->set('document', $document); - - $this->data = $document; - - $docType = $this->Document->getDocType($document); - $docTypeFullName = $this->Document->getDocFullName($docType); - - - - $currency = $this->Document->getCurrency($document); - $enquiry = $this->Document->getEnquiry($document); - - $this->set('docType', $docType); - $this->set('docTypeFullName',strtoupper($docTypeFullName)); - $this->set('currency',$currency); - $this->set('currencyCode', $currency['Currency']['iso4217']); - $this->set('currencySymbol', $currency['Currency']['symbol']); - - $gst = $enquiry['Enquiry']['gst']; - - $this->set('gst', $gst); - - if($gst == 1) { - $totalsDescText = array( - 'subtotal' => 'SUBTOTAL', - 'gst' => 'GST (10%)', - 'total' => 'TOTAL DUE' - ); - } - else { - $totalsDescText = array( - 'subtotal' => 'SUBTOTAL', - 'gst' => 'GST (10%)', - 'total' => 'TOTAL PAYABLE' - ); - } - - - $totals = $this->calculateTotals($document, $gst); - $this->set('totals',$totals); - $this->set('totalsDescText',$totalsDescText); - - $this->set('currency', $currency); - $this->set('enquiry', $enquiry); - - $this->set('principlesList', $this->Document->LineItem->Product->Principle->find('list')); - - $this->set('products', $document['LineItem']); - $this->set('states', $this->Document->Invoice->Enquiry->State->find('list')); - - - //Set filename for the document. - // - switch($docType) { - case "quote": - $filename = $enquiry['Enquiry']['title']; - $template_name = 'pdf_quote'; - break; - - case "invoice": - $filename = $document['Invoice']['title']; - $this->set('docTitle', $document['Invoice']['title']); - $this->set('job', $this->Document->Invoice->Job->find('first', array('conditions'=>array('Job.id'=>$document['Invoice']['job_id'])))); - $this->set('issue_date_string', date('d F Y', strtotime($document['Invoice']['issue_date']))); - - $this->set('ship_via', $document['Invoice']['ship_via']); - $this->set('fob', $document['Invoice']['fob']); - - - $template_name = 'pdf_invoice'; - break; - - case "purchaseOrder": - $filename = $document['PurchaseOrder']['title']; - break; - - case "orderAck": - - $job = $this->Document->OrderAcknowledgement->Job->find('first', array('conditions'=>array('Job.id'=>$document['OrderAcknowledgement']['job_id']))); - - $filename = $job['Job']['title'].'_OrderAcknowledgement'; - $this->set('docTitle', $job['Job']['title']); - - $this->set('docTypeFullName', 'JOB'); //So it doesnt say CMC order Ack # in the pdf_shipping_billing_box. This string is too long - $this->set('job', $job); - $this->set('issue_date_string', date('d F Y', strtotime($document['OrderAcknowledgement']['issue_date']))); - - $this->set('ship_via', $document['OrderAcknowledgement']['ship_via']); - $this->set('fob', $document['OrderAcknowledgement']['fob']); - $this->set('estimated_delivery', $document['OrderAcknowledgement']['estimated_delivery']); - - $template_name = 'pdf_orderack'; - break; - - } - - if($document['Document']['revision'] > 0) { - $filename = $filename.'_'.$document['Document']['revision'].'.pdf'; - } - else { - $filename = $filename.'.pdf'; - } - - $this->set('filename', $filename); - $document['Document']['pdf_filename'] = $filename; - $document['Document']['pdf_created_at'] = date('Y-m-d H:i:s'); - $document['Document']['pdf_created_by_user_id'] = $this->getCurrentUserID(); - if($this->Document->save($document)) { - //echo "Set pdf_filename attritbute to: ".$filename; - } - else { - //echo 'Failed to set pdf_filename to: '.$filename; - } - - - $colWidths = array( - 'item' => '7%', - 'qty' => '7%', - 'desc' => '56%', - 'unit' => '15%', - 'total' => '15%' - - ); - - $this->set('colWidths',$colWidths); - - $this->render($template_name); - } - - - //Called via AJAX to generate Quotation First Pages. - function generateFirstPage($id = null) { - $this->layout = 'ajax'; - - if(!$id) { - return; - } - - $document = $this->Document->read(null, $id); - $this->set('document',$document); - $enquiry = $this->Document->Quote->Enquiry->read(null, $document['Quote']['enquiry_id']); - $this->set('enquiry', $enquiry); - } - - - /** * Email the PDF(document + attachments) for this Document to a Recipient (Customer or Principle). @@ -1056,8 +897,6 @@ ENDINSTRUCTIONS; } -======= - $this->Session->setFlash(__('Error. Please generate the PDF before attempting to email it', true)); return; }