Order Acknowledments PDF generation implemented. closes #6 #7

This commit is contained in:
Karl Cordes 2011-08-29 20:07:32 +10:00
parent 35c9534407
commit 5637c08958
23 changed files with 540 additions and 250 deletions

View file

@ -47,12 +47,19 @@ class DocumentsController extends AppController {
break; break;
case 'invoice': case 'invoice':
$docTypeElement = 'document_invoice_view'; $docTypeElement = 'document_invoice_view';
$this->set('currencies', $this->Document->Invoice->Currency->find('list'));
$this->set('invoice', $this->Document->Invoice->find('first', array('conditions'=>array('Invoice.id'=>$document['Invoice']['id'])))); $this->set('invoice', $this->Document->Invoice->find('first', array('conditions'=>array('Invoice.id'=>$document['Invoice']['id']))));
break; break;
case 'purchaseOrder': case 'purchaseOrder':
$docTypeElement = 'document_purchase_order_view'; $docTypeElement = 'document_purchase_order_view';
break; break;
case 'orderAck':
$this->set('currencies', $this->Document->OrderAcknowledgement->Currency->find('list'));
$this->set('job', $this->Document->OrderAcknowledgement->Job->find('first', array('conditions'=>array('Job.id'=>$document['OrderAcknowledgement']['job_id']))));
$docTypeElement = 'document_orderack_view';
} }
$this->set('docTypeElement', $docTypeElement); $this->set('docTypeElement', $docTypeElement);
@ -161,13 +168,16 @@ class DocumentsController extends AppController {
break; break;
case "purchaseOrder": case "purchaseOrder":
break; break;
case "orderAck": case "orderAck":
$enquiry = $this->Document->OrderAcknowledgement->Enquiry->read(null, $enquiryid);
$this->data['OrderAcknowledgement']['job_id'] = $jobid;
$this->data['OrderAcknowledgement']['enquiry_id'] = $enquiryid;
$this->data['OrderAcknowledgement']['currency_id'] = 2; //Default to AUD.
$this->data['Document']['user_id']= $enquiry['Enquiry']['user_id'];
$this->data['Document']['revision'] = 0; //No revisions for Order Acks. I have decreed it!
$this->data['Document']['type'] = 'orderAck';
break; break;
@ -179,7 +189,7 @@ class DocumentsController extends AppController {
$this->Session->setFlash(__('The Document has been saved', true)); $this->Session->setFlash(__('The Document has been saved', true));
$this->redirect(array('action'=>'view',$newid)); $this->redirect(array('action'=>'view',$newid));
} else { } else {
$this->Session->setFlash(__('The Document could not be saved. Please, try again.', true)); $this->Session->setFlash(__('The Document could not be saved. Something went wrong! Ensure all fields are entered correctly.', true));
} }
@ -276,41 +286,6 @@ class DocumentsController extends AppController {
} }
/**
* Create a new Quote, along with its associated Document and the first two pages.
* @param int $id - the Enquiry ID that this quote belongs to.
*/
function newInvoice($id = null) {
$enquiryid = $id;
$this->Document->create();
$enquiry = $this->Document->Quote->Enquiry->findById($id);
$this->data['Document']['enquiry_id'] = $enquiryid;
$this->data['Invoice']['enquiry_id'] = $enquiryid;
$invoice_number_offset = 4436; //What Invoice number we were up to before the new system.
$number_of_invoices = $this->Document->Invoice->findCount();
$newInvoiceNumber = $invoice_number_offset + $number_of_invoices;
$this->data['Invoice']['title'] = "CMCIN".$newInvoiceNumber;
$this->data['Document']['user_id']= $enquiry['Enquiry']['user_id'];
$this->data['Document']['type'] = 'invoice';
if ($this->Document->saveAll($this->data)) {
$newid = $this->Document->id;
$this->Session->setFlash(__('The Document has been saved', true));
$this->redirect(array('action'=>'view',$newid));
} else {
$this->Session->setFlash(__('The Document could not be saved. Please, try again.', true));
}
}
function ajax_edit($id = null) { function ajax_edit($id = null) {
$this->layout = 'ajax'; $this->layout = 'ajax';
@ -369,14 +344,14 @@ class DocumentsController extends AppController {
if($gst == 1) { if($gst == 1) {
$totalsDescText = array( $totalsDescText = array(
'subtotal' => 'SUB-TOTAL (EXCLUDING GST)', 'subtotal' => 'SUBTOTAL',
'gst' => 'GST (10%)', 'gst' => 'GST (10%)',
'total' => 'TOTAL PAYABLE (INCLUDING GST)' 'total' => 'TOTAL DUE'
); );
} }
else { else {
$totalsDescText = array( $totalsDescText = array(
'subtotal' => 'SUB-TOTAL', 'subtotal' => 'SUBTOTAL',
'gst' => 'GST (10%)', 'gst' => 'GST (10%)',
'total' => 'TOTAL PAYABLE' 'total' => 'TOTAL PAYABLE'
); );
@ -386,49 +361,6 @@ class DocumentsController extends AppController {
$totals = $this->calculateTotals($document, $gst); $totals = $this->calculateTotals($document, $gst);
$this->set('totals',$totals); $this->set('totals',$totals);
$this->set('totalsDescText',$totalsDescText); $this->set('totalsDescText',$totalsDescText);
/**
* Call the commercial Comments. Need to have already figured out what page to do this on..
*
* * Passing a data structure in the following format.
*
* $details = array(
* 'deliveryTime' => (String) eg. 2-3
* 'paymentTerms => (String) eg. 100% PAYMENT WITH ORDER || NET 30 DAYS FOR APPROVED ACCOUNTS
* 'dateIssued' => (String) eg. 2009-05-20
* 'daysValid' => (Int) eg. 30
* 'deliveryPoint' => (String) eg. EX-CMC Technologies, NSW. || EX-SUPPLIER NAME
* 'exchangeRate' => (String) eg. FIXED
* 'customsDuty' => (String) eg. NIL || 5%
* 'gst' => (String) eg. 10% EXTRA || Not Applicable for Export
* 'salesEngineer' => (String) eg. Karl Cordes || Con Carpis || Kenan Fernandes etc
* );
*
*
*/
if($enquiry['Enquiry']['gst'] == 1) {
$gstPhrase = "10% EXTRA";
}
else {
$gstPhrase = "Not Applicable for Export";
}
$commercialDetails = array (
'deliveryTime' => strtoupper($document['Quote']['delivery_time']),
'paymentTerms' => strtoupper($document['Quote']['payment_terms']),
'dateIssued' => $document['Quote']['date_issued'],
'validFor' => $document['Quote']['days_valid'],
'deliveryPoint' => strtoupper($document['Quote']['delivery_point']),
'exchangeRate' => strtoupper($document['Quote']['exchange_rate']),
'customsDuty' => strtoupper($document['Quote']['customs_duty']),
'gst' => strtoupper($gstPhrase),
'salesEngineer' => strtoupper($document['User']['first_name'].' '.$document['User']['last_name'])
);
$this->set('commercialDetails', $commercialDetails);
//debug($quote);
//debug($commercialDetails);
$this->set('currency', $currency); $this->set('currency', $currency);
$this->set('enquiry', $enquiry); $this->set('enquiry', $enquiry);
@ -449,7 +381,14 @@ class DocumentsController extends AppController {
case "invoice": case "invoice":
$filename = $document['Invoice']['title']; $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('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'; $template_name = 'pdf_invoice';
break; break;
@ -458,7 +397,21 @@ class DocumentsController extends AppController {
break; break;
case "orderAck": case "orderAck":
$filename = $document['Job']['title'];
$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; break;
} }
@ -482,11 +435,11 @@ class DocumentsController extends AppController {
$colWidths = array( $colWidths = array(
'item' => '8%', 'item' => '7%',
'qty' => '8%', 'qty' => '7%',
'desc' => '60%', 'desc' => '56%',
'unit' => '12%', 'unit' => '15%',
'total' => '12%' 'total' => '15%'
); );

View file

@ -44,47 +44,9 @@ class InvoicesController extends AppController {
function add() { //No longer creating invoices directly. Done through the Documents Controller
if (!empty($this->data)) { /*function edit($id = null) {
$this->Invoice->create();
$invoice_number_offset = 4436; //What Invoice number we are up to. Starting at 4500 due to the data loss.
$number_of_invoices = $this->Invoice->findCount();
$newInvoiceNumber = $invoice_number_offset + $number_of_invoices;
$this->data['Invoice']['title'] = "CMCIN".$newInvoiceNumber;
$enqid = $this->data['Invoice']['enquiry_id'];
if ($this->Invoice->save($this->data)) {
$this->Session->setFlash(__('The Invoice has been saved', true));
$this->redirect(array('controller'=>'enquiries', 'action'=>'view/'.$enqid));
} else {
$this->Session->setFlash(__('The Invoice could not be saved. Please, try again.', true));
}
}
else {
if(isset($this->params['named']['enquiryid'])) {
$enquiryid = $this->params['named']['enquiryid'];
$enquiry = $this->Invoice->Enquiry->findById($enquiryid);
$jobs = $this->Invoice->Job->find('list', array('conditions'=>array('Job.enquiry_id'=>$enquiryid)));
$user = $this->Auth->user();
$this->set(compact('enquiry', 'user','jobs'));
}
else {
$this->Session->setFlash(__('Invalid Enquiry ID', true));
$this->redirect(array('action'=>'index'));
}
}
}
/* function edit($id = null) {
if (!$id && empty($this->data)) { if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid Invoice', true)); $this->Session->setFlash(__('Invalid Invoice', true));
$this->redirect(array('action'=>'index')); $this->redirect(array('action'=>'index'));

View file

@ -1,73 +1,73 @@
<?php <?php
class Address extends AppModel { class Address extends AppModel {
var $name = 'Address'; var $name = 'Address';
var $validate = array( var $validate = array(
'address' => array( 'address' => array(
'rule' => array('notEmpty'), 'rule' => array('notEmpty'),
'message' => 'Please Enter the Addess', 'message' => 'Please Enter the Addess',
'required' => true, 'required' => true,
'allowEmpty' => false 'allowEmpty' => false
), ),
'city' => array(
'rule' => array('notEmpty'),
'message' => 'Please Enter the City',
'required' => true,
'allowEmpty' => false
),
'state_id' => array(
'rule' => array('notEmpty'),
'message' => 'Please select the State',
'required' => true,
'allowEmpty' => false
),
'postcode' => array(
'rule' => array('notEmpty'),
'message' => 'Please enter the Post Code',
'required' => true,
'allowEmpty' => false
),
'country_id' => array(
'rule' => array('notEmpty'),
'message' => 'Please select the Country',
'required' => true,
'allowEmpty' => false
),
'type' => array(
'rule' => array('notEmpty'),
'message' => 'Please select the Type of Address',
'required' => true,
'allowEmpty' => false
),
);
//The Associations below have been created with all possible keys, those that are not needed can be removed 'city' => array(
var $belongsTo = array( 'rule' => array('notEmpty'),
'Customer' => array('className' => 'Customer', 'message' => 'Please Enter the City',
'foreignKey' => 'customer_id', 'required' => true,
'conditions' => '', 'allowEmpty' => false
'fields' => '', ),
'order' => '' 'state_id' => array(
), 'rule' => array('notEmpty'),
'message' => 'Please select the State',
'State' => array('className' => 'State', 'required' => true,
'foreignKey' => 'state_id', 'allowEmpty' => false
'conditions' => '', ),
'fields' => '', 'postcode' => array(
'order' => ''), 'rule' => array('notEmpty'),
'message' => 'Please enter the Post Code',
'Country' => array('className' => 'Country', 'required' => true,
'foreignKey' => 'country_id', 'allowEmpty' => false
'conditions' => '', ),
'fields' => '', 'country_id' => array(
'order' => '' 'rule' => array('notEmpty'),
'message' => 'Please select the Country',
'required' => true,
)); 'allowEmpty' => false
),
'type' => array(
'rule' => array('notEmpty'),
'message' => 'Please select the Type of Address',
'required' => true,
'allowEmpty' => false
),
);
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $belongsTo = array(
'Customer' => array('className' => 'Customer',
'foreignKey' => 'customer_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'State' => array('className' => 'State',
'foreignKey' => 'state_id',
'conditions' => '',
'fields' => '',
'order' => ''),
'Country' => array('className' => 'Country',
'foreignKey' => 'country_id',
'conditions' => '',
'fields' => '',
'order' => ''
));
} }
?> ?>

View file

@ -53,6 +53,8 @@ class Document extends AppModel {
) )
); );
//So much refactoring possible on this.
function getCurrency($document) { function getCurrency($document) {
if(!empty($document['Invoice']['id'])) { if(!empty($document['Invoice']['id'])) {
@ -73,6 +75,11 @@ class Document extends AppModel {
$conditions = $this->__getCurrencyConditions($currencyID); $conditions = $this->__getCurrencyConditions($currencyID);
return $this->PurchaseOrder->Currency->find('first',$conditions); return $this->PurchaseOrder->Currency->find('first',$conditions);
} }
elseif(!empty($document['OrderAcknowledgement']['id'])) {
$currencyID = $document['OrderAcknowledgement']['currency_id'];
$conditions = $this->__getCurrencyConditions($currencyID);
return $this->OrderAcknowledgement->Currency->find('first',$conditions);
}
} }
@ -136,6 +143,10 @@ class Document extends AppModel {
elseif(!empty($document['PurchaseOrder']['id'])) { elseif(!empty($document['PurchaseOrder']['id'])) {
return $this->PurchaseOrder->Enquiry->find('first',array('conditions'=>array('Enquiry.id'=>$document['Invoice']['enquiry_id']))); return $this->PurchaseOrder->Enquiry->find('first',array('conditions'=>array('Enquiry.id'=>$document['Invoice']['enquiry_id'])));
} }
elseif(!empty($document['OrderAcknowledgement']['id'])) {
return $this->OrderAcknowledgement->Enquiry->find('first',array('conditions'=>array('Enquiry.id'=>$document['OrderAcknowledgement']['enquiry_id'])));
}
} }
/** /**
* Does GST apply on this document. Based on the Enquiry GST TinyInt. * Does GST apply on this document. Based on the Enquiry GST TinyInt.

View file

@ -177,6 +177,10 @@ class Enquiry extends AppModel {
'Job' => array('className' => 'Job', 'Job' => array('className' => 'Job',
'foreignKey' =>'enquiry_id'), 'foreignKey' =>'enquiry_id'),
'OrderAcknowledgement' => array('className'=>'OrderAcknowledgement', 'foreignKey'=>'enquiry_id')
); );

View file

@ -0,0 +1,33 @@
<?php
class OrderAcknowledgement extends AppModel {
var $name = 'OrderAcknowledgement';
/*var $validate = array(
'enquiry_id' => array('numeric'),
'revision' => array('alphanumeric'),
'deliverytime' => array('alphanumeric'),
'paymentterms' => array('alphanumeric'),
'daysvalid' => array('numeric')
);*/
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $belongsTo = array(
'Enquiry' => array('className' => 'Enquiry',
'foreignKey' => 'enquiry_id',
'conditions' => '',
'fields' => '',
'order' => '',
'counterCache'=>true
),
'Currency' => array('className' => 'Currency', 'foreignKey' => 'currency_id'),
'Document' => array('className'=>'Document', 'foreignKey'=>'document_id'),
'Job' => array('className'=>'Job', 'foreignKey'=>'job_id')
);
}
?>

View file

@ -14,22 +14,23 @@ $pageTitle = "<h1>TAX INVOICE</h1>";
$pdfdoc->writeHTML($pageTitle, true, false, false, false, 'C'); $pdfdoc->writeHTML($pageTitle, true, false, false, false, 'C');
$pdfdoc->SetTextColor(0); $pdfdoc->SetTextColor(0);
$shippingBillingBox = $this->element('pdf_shipping_billing_box');
$pageNo = $pdfdoc->PageNoFormatted();
$totalCount = $pdfdoc->getAliasNbPages();
$shippingBillingBox = $this->element('pdf_shipping_billing_box', array('pageNo'=>$pageNo, 'totalCount'=>$totalCount));
$pdfdoc->writeHTML($shippingBillingBox, false); $pdfdoc->writeHTML($shippingBillingBox, false);
$LineItemTable = $this->element('line_items_table'); $LineItemTable = $this->element('line_items_table_with_shipping');
$pdfdoc->SetPrintHeader(true); $pdfdoc->SetPrintHeader(true);
$pdfdoc->pageContent($LineItemTable); $pdfdoc->pageContent($LineItemTable);
$pdfdoc->lastPage(); $pdfdoc->lastPage();
if($docType == 'quote') {
$commercialComments = '<div nobr="true">'.$document['Quote']['commercial_comments'].'</div>';
$pdfdoc->pageContent($commercialComments);
}
$output_dir = '/Users/karlcordes/Sites/quotenik/app/webroot/pdf/'; $output_dir = '/Users/karlcordes/Sites/quotenik/app/webroot/pdf/';
@ -69,5 +70,5 @@ $newpdf->Output($output_dir.$filename, "F");
</script> </script>
<? debug($job); ?> <? debug($document); ?>
<? //debug($enquiry); ?> <? //debug($enquiry); ?>

View file

@ -0,0 +1,75 @@
<?php
App::import('Vendor','pdfdoc');
$pdfdoc = new PDFDOC();
$pdfdoc->SetPrintHeader(false);
$pdfdoc->SetPrintFooter(false);
$pdfdoc->AddPage();
$pdfdoc->Page1Header();
$pageTitle = "<h1>ORDER ACKNOWLEDGEMENT</h1>";
$pdfdoc->writeHTML($pageTitle, true, false, false, false, 'C');
$pdfdoc->SetTextColor(0);
$pageNo = $pdfdoc->PageNoFormatted();
$totalCount = $pdfdoc->getAliasNbPages();
$shippingBillingBox = $this->element('pdf_shipping_billing_box', array('pageNo'=>$pageNo, 'totalCount'=>$totalCount));
$pdfdoc->writeHTML($shippingBillingBox, false);
$LineItemTable = $this->element('line_items_table_with_shipping');
$pdfdoc->SetPrintHeader(true);
$pdfdoc->pageContent($LineItemTable);
$pdfdoc->lastPage();
$output_dir = '/Users/karlcordes/Sites/quotenik/app/webroot/pdf/';
$debuglevel = Configure::read('debug');
if($debuglevel == 0) {
$output_dir = '/var/www/cakephp/app/webroot/pdf/';
}
$pdfdoc->Output($output_dir.$filename, 'F');
echo "<br> Wrote: ".$output_dir.$filename;
App::import('Vendor', 'xfpdi');
//$newpdf = new concat_pdf();
$newpdf = new XFPDI();
$newpdf->SetMargins(2, 2);
$newpdf->setPrintHeader(false);
$newpdf->setPrintFooter(false);
$newpdf->setFiles(array($output_dir.$filename, $output_dir.'CMC_terms_and_conditions2006_A4.pdf'));
$newpdf->concat();
$newpdf->Output($output_dir.$filename, "F");
//$pdfdoc->Output($output_dir = '/Users/karlcordes/Sites/quotenik/app/webroot/pdf/'.'example_060.pdf', 'F');
//echo $html->link($filename, '/pdf/'.$filename);
?>
<script type="text/javascript">
//window.location.replace("/documents/view/<?=$document['Document']['id']?>");
</script>
<? debug($document); ?>
<? //debug($enquiry); ?>

View file

@ -0,0 +1,3 @@
<? debug($newDoc); ?>
<hr>
<? debug($document);?>

View file

@ -1,20 +1,28 @@
<h2>Invoice: <?=$document['Invoice']['title']?> for <?=$html->link($enquiry['Customer']['name'], '/customers/view/'.$enquiry['Customer']['id']);?></h2> <h2>Invoice: <?=$document['Invoice']['title']?> for <?=$html->link($enquiry['Customer']['name'], '/customers/view/'.$enquiry['Customer']['id']);?></h2>
<h2>Job: <?=$html->link($invoice['Job']['title'], array('controller'=>'jobs', 'action'=>'view', $invoice['Job']['id']));?></h2> <h2>Job: <?=$html->link($invoice['Job']['title'], array('controller'=>'jobs', 'action'=>'view', $invoice['Job']['id']));?></h2>
<?
echo $form->create('Document',array('type'=>'post','action'=>'edit', 'default'=>false));
echo $form->input('Document.id');
?>
<div class="docButtons">
<button id="generateFirstPage">(re)Generate First Page</button>
<button id="editInvoiceDetails">View/Edit Invoice Details</button>
<?=$html->link('Generate PDF of this Invoice', '/documents/pdf/'.$document['Document']['id']);?>
</div>
<div id="flashMessage" class="message"> <div id="flashMessage" class="message">
</div> </div>
<div class="docButtons">
<button id="paymentReceived">Enter Payment Received</button>
<?=$html->link('Generate PDF of this Invoice', '/documents/pdf/'.$document['Document']['id']);?>
</div>
<div id="invoiceDetails" class="documentDetails">
<fieldset>
<? echo $form->create('Document',array('type'=>'post','action'=>'edit', 'default'=>false));
echo $form->input('Document.id');
echo $form->input('Invoice.id');
echo $form->input('Invoice.currency_id');
echo $form->input('Invoice.issue_date');
echo $form->input('Invoice.due_date');
echo $form->input('Invoice.ship_via');
echo $form->input('Invoice.fob');
echo $form->input('Document.shipping_details', array('id'=>'shippingDetails'));
echo $form->end(array('label'=>'Save Invoice Details', 'id'=>'saveInvoiceButton'));
?>
</fieldset>
</div>
<span id="invoiceID" style="display: none;"><?=$document['Invoice']['id']?></span> <span id="invoiceID" style="display: none;"><?=$document['Invoice']['id']?></span>

View file

@ -0,0 +1,35 @@
<h2>Order Acknowledgement: <?=$html->link($job['Job']['title'], array('controller'=>'jobs', 'action'=>'view', $job['Job']['id']));?> for <?=$html->link($enquiry['Customer']['name'], '/customers/view/'.$enquiry['Customer']['id']);?></h2>
<div id="flashMessage" class="message">
</div>
<div class="docButtons">
<?=$html->link('Generate PDF of this Order Acknowledgement', '/documents/pdf/'.$document['Document']['id']);?>
</div>
<div id="invoiceDetails" class="documentDetails">
<fieldset>
<? echo $form->create('Document',array('type'=>'post','action'=>'edit', 'default'=>false));
echo $form->input('Document.id');
echo $form->input('OrderAcknowledgement.id');
echo $form->input('OrderAcknowledgement.currency_id');
echo $form->input('OrderAcknowledgement.issue_date');
echo $form->input('OrderAcknowledgement.ship_via');
echo $form->input('OrderAcknowledgement.fob');
echo $form->input('OrderAcknowledgement.estimated_delivery');
echo $form->input('Document.shipping_details', array('id'=>'shippingDetails'));
echo $form->end(array('label'=>'Save OA Details', 'id'=>'saveOAButton'));
?>
</fieldset>
</div>
<span id="invoiceID" style="display: none;"><?=$document['Invoice']['id']?></span>
<? //debug($this->data);?>
<? debug($enquiry);?>
<?php debug($document);?>
<?php //debug($docType);?>
<? //debug($invoice); ?>
<hr>
<?php // debug($job);?>

View file

@ -0,0 +1,14 @@
<span style="font-weight: bold;"><?=$customerName;?></span><br>
<?=$address['address'];?><br>
<?=$address['city'];?><br>
<?=$address['postcode'];?>
<? if($address['state_id'] == 9): //Overseas Enquiry. Print the country name
?>
<? ?>
<? else: //Australian Enquiry. Only print the state ?>
<?=strtoupper($states[$enquiry['BillingAddress']['state_id']]);?>
<?endif; ?>
<br>
<? //INCOMPLETE ?>

View file

@ -1,6 +1,6 @@
<table border="1" cellpadding="2" cellspacing="0" > <table border="1" cellpadding="2" cellspacing="0" >
<thead> <thead>
<tr bgcolor="#f2f2f2"> <tr bgcolor="#f2f2f2" nobr="true">
<th width="<?=$colWidths['item'];?>" align="center">ITEM<br />NO.</th> <th width="<?=$colWidths['item'];?>" align="center">ITEM<br />NO.</th>
<th width="<?=$colWidths['qty'];?>" align="center">QTY</th> <th width="<?=$colWidths['qty'];?>" align="center">QTY</th>
<th width="<?=$colWidths['desc'];?>" align="center">DESCRIPTION</th> <th width="<?=$colWidths['desc'];?>" align="center">DESCRIPTION</th>

View file

@ -0,0 +1,101 @@
<table border="1" cellpadding="2" cellspacing="0" >
<thead>
<tr bgcolor="#f2f2f2">
<th width="<?=$colWidths['item'];?>" align="center">ITEM<br />NO.</th>
<th width="<?=$colWidths['qty'];?>" align="center">QTY</th>
<th width="<?=$colWidths['desc'];?>" align="center">DESCRIPTION</th>
<th width="<?=$colWidths['unit'];?>" align="center">UNIT<br>PRICE</th>
<th width="<?=$colWidths['total'];?>" align="center">TOTAL<br>PRICE</th>
</tr>
<tr>
<th></th>
<th></th>
<th></th>
<th align="center"><?=$currencyCode?></th>
<th align="center"><?=$currencyCode?></th>
</tr>
</thead>
<tbody>
<?
$hasOptions = false;
foreach($document['LineItem'] as $li):?>
<tr nobr="true">
<td width="<?=$colWidths['item'];?>" align="center" valign="top">
<? if($li['option'] == 1) {
echo 'Option<br>';
$hasOptions = true;
}
?>
<?=$li['item_number'];?>
</td>
<td width="<?=$colWidths['qty'];?>" align="center" valign="top"><?=$decimal->formatDecimal($li['quantity']);?></td>
<td width="<?=$colWidths['desc'];?>"><?=$li['title'];?><br><?=$li['description'];?></td>
<td width="<?=$colWidths['unit'];?>" align="center" valign="top">
<?=$number->currency($li['gross_unit_price'], $currencyCode);?>
<? if($li['discount_percent']):?>
<br>less<br><?=$li['discount_percent']?>%<br>
discount*<br>
(-<?=$number->currency($li['discount_amount_unit'], $currencyCode);?>)<br>
=<br>
<?=$number->currency($li['net_unit_price'], $currencyCode);?>
<?endif;?>
</td>
<td width="<?=$colWidths['total'];?>" align="center" valign="top">
<?=$number->currency($li['gross_price'], $currencyCode);?>
<? if($li['discount_percent']):?>
<br>less<br><?=$li['discount_percent']?>%<br>
discount*<br>
(<?=$number->currency($li['discount_amount_total'], $currencyCode);?>)<br>
=<br>
<?=$number->currency($li['net_price'], $currencyCode);?>
<?endif;?>
</td>
</tr>
<?endforeach;?>
</tbody>
<tfoot>
<tr nobr="true">
<td colspan="3" bgcolor="#f2f2f2" nobr="true">SHIPPING DETAILS:
</td>
<td width="<?=$colWidths['unit'];?>" bgcolor="#f2f2f2"><?=$totalsDescText['subtotal']?></td>
<td width="<?=$colWidths['total'];?>" align="center">
<?
if(!$hasOptions) {
echo $number->currency($totals['subtotal'], $currencyCode);
}
else {
echo $currencySymbol.'TBA';
}
?></td>
</tr>
<tr nobr="true">
<td colspan="3" rowspan="2" nobr="true"><?=$document['Document']['shipping_details'];?></td>
<td width="<?=$colWidths['unit'];?>" bgcolor="#f2f2f2"><?=$totalsDescText['gst'];?></td>
<td width="<?=$colWidths['total'];?>" align="center">
<?
if(!$hasOptions) {
echo $number->currency($totals['gst'], $currencyCode);
}
else {
echo $currencySymbol.'TBA';
}
?>
</td>
</tr>
<tr nobr="true">
<td width="<?=$colWidths['unit'];?>" align="center" bgcolor="#f2f2f2"><?=$totalsDescText['total'];?><br><?=$currencyCode?></td>
<td width="<?=$colWidths['total'];?>" align="center">
<?
if(!$hasOptions) {
echo $number->currency($totals['total'], $currencyCode);
}
else {
echo $currencySymbol.'TBA';
}
?></td>
</tr>
</tfoot>
</table>

View file

@ -10,10 +10,14 @@ $col3width = '30%';
<td style="width: <?=$col1width?>; border-top: 1px solid black; border-left: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black; background-color: #f2f2f2">SHIP TO:</td> <td style="width: <?=$col1width?>; border-top: 1px solid black; border-left: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black; background-color: #f2f2f2">SHIP TO:</td>
<td style="width: 3%;"></td> <td style="width: 3%;"></td>
<td style="font-size: 9pt; width: 37%;" colspan="4" rowspan="2"> <td style="font-size: 9pt; width: 37%;" colspan="4" rowspan="2">
<span style="text-decoration: underline; font-size: 11pt">CMC INVOICE#: CMCIN4745</span><br> <span style="text-decoration: underline; font-size: 11pt">CMC <?=$docTypeFullName?>#:</span> <span style="font-size: 11pt"><?=$docTitle?></span><br>
<span style="text-decoration: none">Date: <?=$document['Invoice']['issue_date'];?></span><br><br> <span style="text-decoration: none;">Date: <?=$issue_date_string?></span><br>
<span style="text-decoration: underline">MAKE PAYMENT TO:</span><br> <? if($docType == 'orderAck'): ?>
<span style="text-decoration: none">Account Name: CMC Technologies Pty Ltd<br> <span style="text-decoration: none;">Estimated Delivery:</span> <span style="text-align: right;"><?=$estimated_delivery?></span><br>
<? endif; ?>
<span style="text-decoration: none;">Page: <?=$pageNo?> of <?=$totalCount?></span><br><br>
<span style="text-decoration: underline;">MAKE PAYMENT TO:</span><br>
<span style="text-decoration: none;">Account Name: CMC Technologies Pty Ltd<br>
Bank Number BSB#: 062-458<br> Bank Number BSB#: 062-458<br>
Account Number: 10067982<br> Account Number: 10067982<br>
SWIFT Code: CTBAAU2S SWIFT Code: CTBAAU2S
@ -22,16 +26,22 @@ $col3width = '30%';
</tr> </tr>
<tr> <tr>
<td style="width: <?=$col1width?>; border-top: 1px solid black; border-left: 1px solid black; border-bottom: 1px solid black"> <td style="width: <?=$col1width?>; border-top: 1px solid black; border-left: 1px solid black; border-bottom: 1px solid black">
<?=$enquiry['BillingAddress']['address'];?><br> <span style="font-weight: bold;"><?=$enquiry['Customer']['name'];?></span><br>
<?=$enquiry['BillingAddress']['city'];?><br> <? if(!empty($enquiry['BillingAddress']['id'])):?>
<?=$enquiry['BillingAddress']['postcode'];?> <?=$enquiry['BillingAddress']['address'];?><br>
<?=strtoupper($states[$enquiry['BillingAddress']['state_id']]);?><br> <?=$enquiry['BillingAddress']['city'];?><br>
<?=$enquiry['BillingAddress']['postcode'];?>
<?=strtoupper($states[$enquiry['BillingAddress']['state_id']]);?><br>
<? endif;?>
</td> </td>
<td style="width: <?=$col1width?>; border-top: 1px solid black; border-left: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black"> <td style="width: <?=$col1width?>; border-top: 1px solid black; border-left: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black">
<?=$enquiry['ShippingAddress']['address'];?><br> <span style="font-weight: bold;"><?=$enquiry['Customer']['name'];?></span><br>
<?=$enquiry['ShippingAddress']['city'];?><br> <? if(!empty($enquiry['ShippingAddress']['id'])):?>
<?=$enquiry['ShippingAddress']['postcode'];?> <?=$enquiry['ShippingAddress']['address'];?><br>
<?=strtoupper($states[$enquiry['ShippingAddress']['state_id']]);?><br> <?=$enquiry['ShippingAddress']['city'];?><br>
<?=$enquiry['ShippingAddress']['postcode'];?>
<?=strtoupper($states[$enquiry['ShippingAddress']['state_id']]);?><br>
<? endif; ?>
</td> </td>
</tr> </tr>
</table> </table>
@ -39,7 +49,7 @@ $col3width = '30%';
<table border="1" cellpadding="2" cellspacing="0"> <table border="1" cellpadding="2" cellspacing="0">
<tr bgcolor="#f2f2f2" align="center"> <tr bgcolor="#f2f2f2" align="center">
<? $moreDetailsFont = '9pt'; ?> <? $moreDetailsFont = '9pt'; ?>
<td style="font-size: <?=$moreDetailsFont?>">CUSTOMER ORDER NO</td> <td style="font-size: <?=$moreDetailsFont?>;">CUSTOMER ORDER NO</td>
<td style="font-size: <?=$moreDetailsFont?>">CMC JOB #</td> <td style="font-size: <?=$moreDetailsFont?>">CMC JOB #</td>
<td style="font-size: <?=$moreDetailsFont?>">FOB</td> <td style="font-size: <?=$moreDetailsFont?>">FOB</td>
<td style="font-size: <?=$moreDetailsFont?>">SHIP VIA</td> <td style="font-size: <?=$moreDetailsFont?>">SHIP VIA</td>
@ -49,9 +59,10 @@ $col3width = '30%';
<tr align="center"> <tr align="center">
<td style="font-size: <?=$moreDetailsFont?>"><?=$job['Job']['customer_order_number'];?></td> <td style="font-size: <?=$moreDetailsFont?>"><?=$job['Job']['customer_order_number'];?></td>
<td style="font-size: <?=$moreDetailsFont?>"><?=$job['Job']['title'];?></td> <td style="font-size: <?=$moreDetailsFont?>"><?=$job['Job']['title'];?></td>
<td style="font-size: <?=$moreDetailsFont?>">??</td> <td style="font-size: <?=$moreDetailsFont?>"><?=$fob;?></td>
<td style="font-size: <?=$moreDetailsFont?>">??</td> <td style="font-size: <?=$moreDetailsFont?>"><?=$ship_via;?></td>
<td style="font-size: <?=$moreDetailsFont?>"><?=$job['Customer']['payment_terms'];?></td> <td style="font-size: <?=$moreDetailsFont?>"><?=$job['Customer']['payment_terms'];?></td>
<td style="font-size: <?=$moreDetailsFont?>"><?=$this->element('abn', array('abn'=>$job['Customer']['abn']));?></td> <td style="font-size: <?=$moreDetailsFont?>"><?=$this->element('abn', array('abn'=>$job['Customer']['abn']));?></td>
</tr> </tr>
</table> </table>
<br>

View file

@ -0,0 +1,12 @@
<table border="1" cellpadding="2" cellspacing="0" width="50%">
<tr bgcolor="#f2f2f2" align="center">
<? $moreDetailsFont = '10pt'; ?>
<td style="font-size: <?=$moreDetailsFont?>;">Shipping Details</td>
</tr>
<tr align="center">
<td style="font-size: <?=$moreDetailsFont?>"><?=$document['Document']['shipping_details'];?></td>
</tr>
<tr>
<td></td>
</tr>
</table>

View file

@ -153,7 +153,6 @@
</div> </div>
<div class="related"> <div class="related">
<h3>Jobs from this Enquiry</h3> <h3>Jobs from this Enquiry</h3>
@ -238,13 +237,14 @@
This will create a new Job and a Job number. Are you sure you want to do this? This will create a new Job and a Job number. Are you sure you want to do this?
</div> </div>
<div id="jobsListDialog" style="display: none;">
<ul id="jobsList" style="display: none;"> Select the Job this Invoice is for.
<ul id="jobsListUL">
<? foreach($jobs as $job):?> <? foreach($jobs as $job):?>
<li id="<?=$job['Job']['id'];?>"><?=$html->link($job['Job']['title'], "/documents/newDocument/invoice/{$job['Job']['enquiry_id']}/{$job['Job']['id']}");?></li> <li id="<?=$job['Job']['id'];?>"><?=$html->link($job['Job']['title'], "/documents/newDocument/invoice/{$job['Job']['enquiry_id']}/{$job['Job']['id']}");?></li>
<? endforeach;?> <? endforeach;?>
</ul> </ul>
</div>
<div class="related"> <div class="related">
<h3><?php __($enquiry['Enquiry']['invoice_count'].' Invoices for this Enquiry');?></h3> <h3><?php __($enquiry['Enquiry']['invoice_count'].' Invoices for this Enquiry');?></h3>
<table class="quotetable"> <table class="quotetable">
@ -301,9 +301,6 @@
echo date('j M Y',$time->toUnix($invoice['Invoice']['payment_received_date'])); echo date('j M Y',$time->toUnix($invoice['Invoice']['payment_received_date']));
echo "</td>"; echo "</td>";
} }
?> ?>
@ -318,10 +315,7 @@
<div class="actions"> <div class="actions">
<ul> <ul>
<li><?php //echo $html->link(__('New Invoice', true), array('controller'=>'invoices', 'action' => 'add/enquiryid:'.$enquiry['Enquiry']['id'])); ?> <li><button class="addInvoice" id="<?=$enquiry['Enquiry']['id'];?>">New Invoice</button></li>
</li>
<li><?php echo $html->link(__('New Invoice', true), array('controller'=>'documents', 'action' => 'newDocument/invoice/'.$enquiry['Enquiry']['id'])); ?></li>
<li><button class="addInvoice" id="<?=$enquiry['Enquiry']['id'];?>">New Invoice</button></li>
</ul> </ul>
</div> </div>

View file

@ -1617,4 +1617,8 @@ div.pdfGeneratedMessage {
border: 2px dashed; border: 2px dashed;
width: 45em; width: 45em;
font-size: 120%; font-size: 120%;
}
div.documentDetails {
width: 45em
} }

View file

@ -8,4 +8,6 @@ CKEDITOR.editorConfig = function( config )
// Define changes to default configuration here. For example: // Define changes to default configuration here. For example:
// config.language = 'fr'; // config.language = 'fr';
// config.uiColor = '#AADC6E'; // config.uiColor = '#AADC6E';
config.enterMode = CKEDITOR.ENTER_BR;
}; };

View file

@ -295,6 +295,65 @@ $(function() {
}); });
//Invoice View
$('#shippingDetails').ckeditor(config);
$("#saveInvoiceButton").click(function() {
$('#shippingDetails').ckeditor(function() {
this.updateElement();
});
var invoiceDetails = $('#DocumentEditForm').find('input,select,textarea');
$.post('/documents/ajax_edit', invoiceDetails, function(data) {
if(data =='SUCCESS') {
$("#flashMessage").html("Invoice Saved Successfully");
}
else {
$("#flashMessage").html("Unable to Save Invoice");
}
$("#flashMessage").show();
loadLineItems();
});
});
//OA View.
$("#saveOAButton").click(function() {
$('#shippingDetails').ckeditor(function() {
this.updateElement();
});
var invoiceDetails = $('#DocumentEditForm').find('input,select,textarea');
$.post('/documents/ajax_edit', invoiceDetails, function(data) {
if(data =='SUCCESS') {
$("#flashMessage").html("Order Acknowledgement Saved Successfully");
}
else {
$("#flashMessage").html("Unable to Save Order Acknowledgement");
}
$("#flashMessage").show();
loadLineItems();
});
});
}); });

View file

@ -54,7 +54,7 @@ function getSelectedText(elementID) {
var config = { var config = {
toolbar:[ toolbar:[
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Scayt'], ['Source','Cut','Copy','Paste','PasteText','PasteFromWord','-','Scayt'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'], ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Image','Table','HorizontalRule','SpecialChar'], ['Image','Table','HorizontalRule','SpecialChar'],
'/', '/',

View file

@ -40,6 +40,14 @@ $(function() {
}); });
$( "#jobsListDialog" ).dialog({
autoOpen: false,
resizable: false,
height:140,
modal: true
});
function addJob() { function addJob() {
var enquiryID = $(".addJob").attr("id"); var enquiryID = $(".addJob").attr("id");
@ -59,11 +67,11 @@ $(function() {
}); });
$(".addInvoice").click(function() { $(".addInvoice").click(function() {
if($("#jobsList > li").length == 0) { if($("#jobsListUL > li").length == 0) {
alert("Cant add an invoice! Add Invoice must be for a job. No jobs exist"); alert("Cant add an invoice yet! Add Invoice must be for a job. No Jobs exist for this Enquiry");
} }
else { else {
$("#jobsList").show(); $("#jobsListDialog").dialog('open');
} }
}); });