PDF Quote generation pretty much done. Disabled AJAX pagination of enquiries to fix principle view
This commit is contained in:
parent
d75eeb28de
commit
8aeac9cc9e
|
|
@ -78,6 +78,31 @@ class AppController extends Controller {
|
|||
|
||||
|
||||
|
||||
function calculateTotals($document, $gst) {
|
||||
$totals = array('subtotal'=>0, 'gst'=>0, 'total'=>0);
|
||||
|
||||
|
||||
foreach($document['LineItem'] as $lineitem) {
|
||||
if($lineitem['option'] == 1) {
|
||||
$totals['subtotal'] = 'TBA';
|
||||
$totals['total'] = 'TBA';
|
||||
$totals['gst'] = 'TBA';
|
||||
return $totals;
|
||||
}
|
||||
else {
|
||||
$totals['subtotal'] += $lineitem['net_price'];
|
||||
}
|
||||
}
|
||||
|
||||
if($gst == 1) {
|
||||
$totals['gst'] = 0.1*$totals['subtotal'];
|
||||
}
|
||||
$totals['total'] = $totals['gst'] + $totals['subtotal'];
|
||||
return $totals;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
class DocumentsController extends AppController {
|
||||
|
||||
var $name = 'Documents';
|
||||
var $helpers = array('Html', 'Form');
|
||||
var $helpers = array('Html', 'Form', 'Number');
|
||||
|
||||
function index() {
|
||||
$this->Document->recursive = 0;
|
||||
|
|
@ -15,27 +15,13 @@ class DocumentsController extends AppController {
|
|||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$document = $this->Document->read(null,$id);
|
||||
//$document = $this->Document->find('first',array('conditions'=>array('Document.id'=>$id), 'recursive'=>2));
|
||||
$this->set('document', $document);
|
||||
|
||||
|
||||
|
||||
$docType = "";
|
||||
|
||||
if(!empty($document['Invoice']['id'])) {
|
||||
$docType = "invoice";
|
||||
}
|
||||
elseif(!empty($document['Quote']['id'])) {
|
||||
$docType = "quote";
|
||||
$enquiry = $this->Document->Quote->Enquiry->read(null, $document['Quote']['enquiry_id']);
|
||||
$this->set('enquiry',$enquiry);
|
||||
|
||||
}
|
||||
elseif(!empty($document['PurchaseOrder']['id'])) {
|
||||
$docType = "purchaseOrder";
|
||||
}
|
||||
|
||||
$this->data = $document;
|
||||
$this->set('docType',$docType);
|
||||
$this->set('docType',$this->Document->getDocType($document));
|
||||
$this->set('currency', $this->Document->getCurrency($document));
|
||||
$this->set('enquiry', $this->Document->getEnquiry($document));
|
||||
// $this->set('principles', $this->Document->LineItem->Product->Principle->find('list'));
|
||||
}
|
||||
|
||||
|
|
@ -87,8 +73,8 @@ class DocumentsController extends AppController {
|
|||
$this->data['Quote']['revision'] = $number_of_revisions;
|
||||
|
||||
$this->data['Document']['user_id']= $enquiry['Enquiry']['user_id'];
|
||||
|
||||
|
||||
$this->data['Document']['enquiry_id'] = $enquiryid;
|
||||
$this->data['Document']['type'] = 'quote';
|
||||
|
||||
|
||||
if ($this->Document->saveAll($this->data)) {
|
||||
|
|
@ -113,7 +99,7 @@ class DocumentsController extends AppController {
|
|||
$enquiryid = $id;
|
||||
$this->Document->create();
|
||||
|
||||
$enquiry = $this->Document->Enquiry->findById($id);
|
||||
$enquiry = $this->Document->Quote->Enquiry->findById($id);
|
||||
|
||||
$this->data['Document']['enquiry_id'] = $enquiryid;
|
||||
|
||||
|
|
@ -124,13 +110,8 @@ class DocumentsController extends AppController {
|
|||
$newInvoiceNumber = $invoice_number_offset + $number_of_invoices;
|
||||
|
||||
$this->data['Invoice']['title'] = "CMCIN".$newInvoiceNumber;
|
||||
|
||||
|
||||
$this->data['Document']['customer_id'] = $enquiry['Enquiry']['customer_id'];
|
||||
$this->data['Document']['user_id']= $enquiry['Enquiry']['user_id'];
|
||||
$this->data['Document']['contact_id']= $enquiry['Enquiry']['contact_id'];
|
||||
$this->data['Page'][0]['page_number'] = 1;
|
||||
$this->data['Page'][0]['contentPage'] = 0;
|
||||
$this->data['Document']['type'] = 'invoice';
|
||||
|
||||
if ($this->Document->saveAll($this->data)) {
|
||||
$newid = $this->Document->id;
|
||||
|
|
@ -195,6 +176,122 @@ class DocumentsController extends AppController {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
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']);
|
||||
|
||||
|
||||
$gst = $enquiry['Enquiry']['gst'];
|
||||
|
||||
$this->set('gst', $gst);
|
||||
|
||||
if($gst == 1) {
|
||||
$totalsDescText = array(
|
||||
'subtotal' => 'SUB-TOTAL (EXCLUDING GST)',
|
||||
'gst' => 'GST (10%)',
|
||||
'total' => 'TOTAL PAYABLE (INCLUDING GST)'
|
||||
);
|
||||
}
|
||||
else {
|
||||
$totalsDescText = array(
|
||||
'subtotal' => 'SUB-TOTAL',
|
||||
'gst' => 'GST (10%)',
|
||||
'total' => 'TOTAL PAYABLE'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$totals = $this->calculateTotals($document, $gst);
|
||||
$this->set('totals',$totals);
|
||||
$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('enquiry', $enquiry);
|
||||
|
||||
$this->set('principlesList', $this->Document->LineItem->Product->Principle->find('list'));
|
||||
|
||||
$this->set('products', $document['LineItem']);
|
||||
|
||||
|
||||
$colWidths = array(
|
||||
'item' => '8%',
|
||||
'qty' => '8%',
|
||||
'desc' => '60%',
|
||||
'unit' => '12%',
|
||||
'total' => '12%'
|
||||
|
||||
);
|
||||
|
||||
$this->set('colWidths',$colWidths);
|
||||
|
||||
}
|
||||
|
||||
/*function delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for Document', true));
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ class EnquiriesController extends AppController {
|
|||
$this->pageTitle = "Enquiry: ".$enquiry['Enquiry']['title'];
|
||||
|
||||
|
||||
$this->set('number_of_quotes', $this->Enquiry->Quote->find('count', array('conditions'=>array('Quote.enquiry_id'=>$id))));
|
||||
//$this->set('number_of_files', $this->Enquiry->EnquiryFile->find('count', array('conditions' => array('EnquiryFile.enquiry_id'=>$id))));
|
||||
$this->set('principle_emails', $this->Enquiry->Principle->PrincipleContact->findAllByPrincipleId($enquiry['Enquiry']['principle_id']));
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
class LineItemsController extends AppController {
|
||||
|
||||
var $name = 'LineItems';
|
||||
var $helpers = array('Html', 'Form', 'Javascript');
|
||||
var $helpers = array('Html', 'Form', 'Javascript', 'Number');
|
||||
|
||||
var $components = array('RequestHandler');
|
||||
|
||||
|
|
@ -13,7 +13,27 @@ class LineItemsController extends AppController {
|
|||
if(!empty($this->data)) {
|
||||
$this->LineItem->create($this->data);
|
||||
|
||||
if ($this->LineItem->saveAll($this->data)) {
|
||||
if ($this->LineItem->save($this->data)) {
|
||||
echo "SUCCESS";
|
||||
}
|
||||
else {
|
||||
echo "FAILURE";
|
||||
|
||||
//print_r($this->data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "NO-DATA";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function ajax_edit() {
|
||||
$this->layout = 'ajax';
|
||||
if(!empty($this->data)) {
|
||||
|
||||
if ($this->LineItem->save($this->data)) {
|
||||
echo "SUCCESS";
|
||||
}
|
||||
else {
|
||||
|
|
@ -27,6 +47,21 @@ class LineItemsController extends AppController {
|
|||
}
|
||||
|
||||
|
||||
function ajax_delete($id = null) {
|
||||
$this->layout = 'ajax';
|
||||
if($id == null) {
|
||||
echo "FAILURE";
|
||||
}
|
||||
else {
|
||||
if ($this->LineItem->del($id)) {
|
||||
echo "SUCCESS";
|
||||
}
|
||||
else {
|
||||
echo "FAILURE";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getTable($documentID = null) {
|
||||
$this->layout = 'ajax';
|
||||
if($documentID == null) {
|
||||
|
|
@ -36,19 +71,35 @@ class LineItemsController extends AppController {
|
|||
$document = $this->LineItem->Document->find('first',array('conditions'=>array('Document.id'=>$documentID)));
|
||||
$this->set('document',$document);
|
||||
|
||||
$currencies = $this->LineItem->Document->Quote->Currency->find('list', array('fields'=>array('Currency.id','Currency.iso4217')));
|
||||
$this->set('currencies',$currencies);
|
||||
}
|
||||
}
|
||||
$enquiry = $this->LineItem->Document->getEnquiry($document);
|
||||
|
||||
$gst = $this->LineItem->Document->gstApplies($enquiry);
|
||||
$this->set('gst',$gst);
|
||||
|
||||
$this->set('totals', $this->calculateTotals($document, $gst));
|
||||
|
||||
$currency = $this->LineItem->Document->getCurrency($document);
|
||||
$this->set('currencyCode', $currency['Currency']['iso4217']);
|
||||
$this->set('currencySymbol', $currency['Currency']['symbol']);
|
||||
}
|
||||
}
|
||||
|
||||
function edit($id = null) {
|
||||
$this->layout = 'ajax';
|
||||
|
||||
$this->data = $this->LineItem->read(null,$id);
|
||||
$this->set('yesNo', array(0=>'No', 1=>'Yes'));
|
||||
$this->set('principles', $this->LineItem->Product->Principle->find('list'));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function add($documentID = null) {
|
||||
$this->layout = 'ajax';
|
||||
$document = $this->LineItem->Document->read(null, $documentID);
|
||||
$this->set('document', $document);
|
||||
$this->set('yesNo', array(0=>'No', 1=>'Yes'));
|
||||
$this->set('principles', $this->LineItem->Product->Principle->find('list'));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,214 +0,0 @@
|
|||
<?php
|
||||
class QuotePagesController extends AppController {
|
||||
|
||||
var $name = 'QuotePages';
|
||||
var $helpers = array('Html', 'Form', 'Ajax', 'Number', 'Fck');
|
||||
|
||||
var $components = array('RequestHandler');
|
||||
|
||||
function index() {
|
||||
$this->QuotePage->recursive = 0;
|
||||
$this->set('quotePages', $this->paginate());
|
||||
}
|
||||
|
||||
function view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid QuotePage.', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$this->set('quotePage', $this->QuotePage->read(null, $id));
|
||||
}
|
||||
|
||||
function add($id = null) {
|
||||
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid Quote ID', true));
|
||||
$this->redirect(array('controller' => 'quotes', 'action'=>'index'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!empty($this->data)) {
|
||||
$this->QuotePage->create();
|
||||
if ($this->QuotePage->save($this->data)) {
|
||||
$this->Session->setFlash(__('The Quote Page has been saved', true));
|
||||
$this->redirect(array('controller'=>'quotes', 'action'=>'view/'.$this->data['QuotePage']['quote_id']));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The Quote Page could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$quotes = $this->QuotePage->Quote->find('list');
|
||||
$this->set(compact('quotes'));
|
||||
$this->set('quoteid', $id);
|
||||
$number_of_pages = $this->QuotePage->find('count', array('conditions' => array('QuotePage.quote_id'=>$id)));
|
||||
$number_of_pages++;
|
||||
$this->set('pagenumber', $number_of_pages);
|
||||
}
|
||||
|
||||
function edit($id = null) {
|
||||
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid QuotePage', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
|
||||
if (!empty($this->data)) {
|
||||
if ($this->QuotePage->save($this->data)) {
|
||||
$this->Session->setFlash(__('The QuotePage has been saved', true));
|
||||
$id = $this->data['QuotePage']['quote_id'];
|
||||
$this->redirect(array('controller' => 'quotes', 'action'=>'view/'.$id));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The QuotePage could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
if (empty($this->data)) {
|
||||
$this->data = $this->QuotePage->read(null, $id);
|
||||
$this->set('content', $this->data['QuotePage']['content']);
|
||||
}
|
||||
$quotes = $this->QuotePage->Quote->find('list');
|
||||
$this->set(compact('quotes'));
|
||||
}
|
||||
|
||||
function delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for QuotePage', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
|
||||
$quotepage = $this->QuotePage->findById($id);
|
||||
$quoteid = $quotepage['QuotePage']['quote_id'];
|
||||
|
||||
if ($this->QuotePage->del($id)) {
|
||||
|
||||
|
||||
$this->Session->setFlash(__('Quote Page deleted', true));
|
||||
$this->redirect(array('controller' => 'quotes' , 'action'=>'view', $quoteid));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function show($id = null) {
|
||||
$this->layout = 'ajax';
|
||||
$this->set('quotePage', $this->QuotePage->read(null, $id));
|
||||
|
||||
}
|
||||
|
||||
function frame($id = null) {
|
||||
$this->layout = 'ajax';
|
||||
$this->set('id', $id);
|
||||
}
|
||||
|
||||
|
||||
function regeneratePage($id = null) {
|
||||
if(!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for QuotePage', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
else {
|
||||
$quotePage = $this->QuotePage->read(null, $id);
|
||||
|
||||
//$enquiry = $this->QuotePage->Quote->Enquiry->find('all', array('conditions' => array('Enquiry.id' => $quotePage['Quote']['enquiry_id'])));
|
||||
|
||||
$enquiry = $this->QuotePage->Quote->Enquiry->read(null, $quotePage['Quote']['enquiry_id']);
|
||||
|
||||
// $quote = $this->QuotePage->Quote->find('all', array('conditions' => array('Quote.id' => $quotePage['Quote']['id'])));
|
||||
|
||||
$quoteProducts = $this->QuotePage->Quote->LineItem->find('all', array('recursive' => 0, 'conditions' =>
|
||||
array('LineItem.quote_id' => $quotePage['Quote']['id']),
|
||||
'order' => array('LineItem.item_number ASC'))
|
||||
);
|
||||
|
||||
$contactFirstName = $enquiry['Contact']['first_name'];
|
||||
|
||||
$salesEngineerName = $enquiry['User']['first_name'].' '.$enquiry['User']['last_name'];
|
||||
|
||||
$productRows = "";
|
||||
|
||||
|
||||
foreach($quoteProducts as $quoteproduct) {
|
||||
|
||||
$itemNumber = $quoteproduct['LineItem']['item_number'];
|
||||
$title = $quoteproduct['LineItem']['title'];
|
||||
|
||||
if($quoteproduct['LineItem']['option'] == 1) {
|
||||
$optionText = "Option ";
|
||||
}
|
||||
else {
|
||||
$optionText = "";
|
||||
}
|
||||
|
||||
$productRows .= <<<ENDROW
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
$optionText
|
||||
$itemNumber
|
||||
</td>
|
||||
<td>
|
||||
$title
|
||||
</td>
|
||||
</tr>
|
||||
ENDROW;
|
||||
|
||||
}
|
||||
|
||||
|
||||
$this->data['QuotePage']['content'] = <<<ENDCONTENT
|
||||
|
||||
<p>Dear $contactFirstName, </p>
|
||||
<p> </p>
|
||||
|
||||
<p> Thank for your recent enquiry. Please see the following quotation for: </p>
|
||||
|
||||
<table border="0" cellpadding="1" cellspacing="1" style="width: 100%; ">
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<th><b>Item</b></th>
|
||||
<th><b>Product</b></th>
|
||||
</tr>
|
||||
|
||||
|
||||
$productRows
|
||||
|
||||
</tbody>
|
||||
</table
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p>Regards, </p>
|
||||
|
||||
<p>$salesEngineerName</p>
|
||||
|
||||
ENDCONTENT;
|
||||
|
||||
|
||||
|
||||
if (!empty($this->data)) {
|
||||
if ($this->QuotePage->save($this->data)) {
|
||||
$this->Session->setFlash(__('The QuotePage has been saved', true));
|
||||
$id = $quotePage['Quote']['id'];
|
||||
$this->redirect(array('controller' => 'quotes', 'action'=>'view/'.$id));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The QuotePage could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
debug($quotePage);
|
||||
|
||||
echo "<hr>";
|
||||
debug ($quoteProducts);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
@ -33,6 +33,25 @@ class QuotesController extends AppController {
|
|||
$this->set('principles', $this->Quote->Enquiry->Principle->find('list'));
|
||||
}
|
||||
|
||||
|
||||
function ajax_edit() {
|
||||
$this->layout = 'ajax';
|
||||
if(!empty($this->data)) {
|
||||
|
||||
if ($this->Quote->save($this->data)) {
|
||||
echo "SUCCESS";
|
||||
}
|
||||
else {
|
||||
echo "FAILURE";
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "NO-DATA";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function add() {
|
||||
|
||||
if(isset($this->params['named']['enquiryid'])) {
|
||||
|
|
@ -46,11 +65,8 @@ class QuotesController extends AppController {
|
|||
$this->data['Quote']['currency_id'] = 2;
|
||||
|
||||
|
||||
|
||||
if ($this->Quote->save($this->data)) {
|
||||
|
||||
|
||||
|
||||
$quoteid = $this->Quote->id;
|
||||
//$this->data['Document']['']
|
||||
|
||||
|
|
@ -73,6 +89,8 @@ class QuotesController extends AppController {
|
|||
|
||||
|
||||
function edit($id = null) {
|
||||
$this->layout = 'ajax';
|
||||
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid Quote', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
|
|
@ -101,6 +119,7 @@ class QuotesController extends AppController {
|
|||
}
|
||||
$enquiry = $this->Quote->Enquiry->findById($quote['Quote']['enquiry_id']);
|
||||
$currencies = $this->Quote->Currency->find('list');
|
||||
$this->set('yesNo', array(0=>'No', 1=>'Yes'));
|
||||
$this->set(compact('enquiry', 'quote', 'currencies'));
|
||||
}
|
||||
|
||||
|
|
@ -320,11 +339,6 @@ class QuotesController extends AppController {
|
|||
$this->data['LineItem'][] = $item;
|
||||
}
|
||||
|
||||
foreach($quote['QuotePage'] as $page) {
|
||||
$page['id'] = null;
|
||||
$page['quote_id'] = null;
|
||||
$this->data['QuotePage'][] = $page;
|
||||
}
|
||||
|
||||
//debug($this->data);
|
||||
|
||||
|
|
|
|||
|
|
@ -199,6 +199,9 @@ class ShipmentsController extends AppController {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function markJobsSent() {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ class Document extends AppModel {
|
|||
'fields' => '',
|
||||
'order' => ''
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
var $hasMany = array(
|
||||
|
|
@ -47,5 +46,110 @@ class Document extends AppModel {
|
|||
'foreignKey'=>'document_id'
|
||||
)
|
||||
);
|
||||
|
||||
function getCurrency($document) {
|
||||
|
||||
if(!empty($document['Invoice']['id'])) {
|
||||
$currencyID = $document['Invoice']['currency_id'];
|
||||
$conditions = $this->__getCurrencyConditions($currencyID);
|
||||
|
||||
return $this->Invoice->Currency->find('first',$conditions);
|
||||
|
||||
}
|
||||
elseif(!empty($document['Quote']['id'])) {
|
||||
$currencyID = $document['Quote']['currency_id'];
|
||||
$conditions = $this->__getCurrencyConditions($currencyID);
|
||||
return $this->Quote->Currency->find('first',$conditions);
|
||||
|
||||
}
|
||||
elseif(!empty($document['PurchaseOrder']['id'])) {
|
||||
$currencyID = $document['PurchaseOrder']['currency_id'];
|
||||
$conditions = $this->__getCurrencyConditions($currencyID);
|
||||
return $this->PurchaseOrder->Currency->find('first',$conditions);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function __getCurrencyConditions($currencyID) {
|
||||
return array('recursive'=>0, 'conditions'=>array('Currency.id'=>$currencyID));
|
||||
}
|
||||
|
||||
function getDocType($document) {
|
||||
return $document['Document']['type'];
|
||||
}
|
||||
|
||||
|
||||
function getDocFullName($type) {
|
||||
|
||||
switch($type) {
|
||||
case 'quote':
|
||||
$fullName = 'Quotation';
|
||||
break;
|
||||
case 'invoice':
|
||||
$fullName = 'Invoice';
|
||||
break;
|
||||
case 'purchaseOrder':
|
||||
$fullName = 'Purchase Order';
|
||||
break;
|
||||
case 'orderAck':
|
||||
$fullName = 'Order Acknowledgement';
|
||||
break;
|
||||
}
|
||||
return $fullName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Depending on the type of document. Return the CMC reference
|
||||
* ie. Enquiry Number (Quote)
|
||||
* Invoice Number (Invoice)
|
||||
* @param <type> $document
|
||||
* @param <type> $type
|
||||
*/
|
||||
function getCMCReferenceNumber($document, $type) {
|
||||
switch($type) {
|
||||
case 'quote':
|
||||
|
||||
|
||||
break;
|
||||
case 'invoice':
|
||||
|
||||
break;
|
||||
case 'purchaseOrder':
|
||||
|
||||
break;
|
||||
case 'orderAck':
|
||||
|
||||
break;
|
||||
}
|
||||
return $fullName;
|
||||
}
|
||||
|
||||
|
||||
function getEnquiry($document) {
|
||||
if(!empty($document['Invoice']['id'])) {
|
||||
return $this->Invoice->Enquiry->find('first',array('conditions'=>array('Enquiry.id'=>$document['Invoice']['enquiry_id'])));
|
||||
}
|
||||
elseif(!empty($document['Quote']['id'])) {
|
||||
return $this->Quote->Enquiry->find('first',array('conditions'=>array('Enquiry.id'=>$document['Quote']['enquiry_id'])));
|
||||
}
|
||||
elseif(!empty($document['PurchaseOrder']['id'])) {
|
||||
return $this->PurchaseOrder->Enquiry->find('first',array('conditions'=>array('Enquiry.id'=>$document['Invoice']['enquiry_id'])));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Does GST apply on this document. Based on the Enquiry GST TinyInt.
|
||||
* @param <type> $enquiry
|
||||
* @return Bool
|
||||
*/
|
||||
function gstApplies($enquiry) {
|
||||
if ($enquiry['Enquiry']['gst'] == 0) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
@ -38,6 +38,14 @@ class Invoice extends AppModel {
|
|||
'Job' => array(
|
||||
'className' => 'Job',
|
||||
'foreignKey' => 'job_id'
|
||||
),
|
||||
'Currency' => array(
|
||||
'className' => 'Currency',
|
||||
'foreignKey' => 'currency_id'
|
||||
),
|
||||
'Document' => array(
|
||||
'className' => 'Document',
|
||||
'foreignKey' => 'document_id'
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ class Quote extends AppModel {
|
|||
'foreignKey' => 'enquiry_id',
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => ''
|
||||
'order' => '',
|
||||
'counterCache'=>true
|
||||
),
|
||||
|
||||
'Currency' => array('className' => 'Currency', 'foreignKey' => 'currency_id'),
|
||||
|
|
|
|||
9
vendors/fpdi/filters/FilterASCII85.php
vendored
9
vendors/fpdi/filters/FilterASCII85.php
vendored
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
//
|
||||
// FPDI - Version 1.3.2
|
||||
// FPDI - Version 1.4.1
|
||||
//
|
||||
// Copyright 2004-2010 Setasign - Jan Slabon
|
||||
// Copyright 2004-2011 Setasign - Jan Slabon
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
@ -26,8 +26,7 @@ if (!defined('ORD_u'))
|
|||
if (!defined('ORD_tilde'))
|
||||
define('ORD_tilde', ord('~'));
|
||||
|
||||
$__tmp = version_compare(phpversion(), "5") == -1 ? array('FilterASCII85') : array('FilterASCII85', false);
|
||||
if (!call_user_func_array('class_exists', $__tmp)) {
|
||||
if (!class_exists('FilterASCII85', false)) {
|
||||
|
||||
class FilterASCII85 {
|
||||
|
||||
|
|
@ -100,5 +99,3 @@ if (!call_user_func_array('class_exists', $__tmp)) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($__tmp);
|
||||
6
vendors/fpdi/filters/FilterASCII85_FPDI.php
vendored
6
vendors/fpdi/filters/FilterASCII85_FPDI.php
vendored
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
//
|
||||
// FPDI - Version 1.3.2
|
||||
// FPDI - Version 1.4.1
|
||||
//
|
||||
// Copyright 2004-2010 Setasign - Jan Slabon
|
||||
// Copyright 2004-2011 Setasign - Jan Slabon
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
@ -23,7 +23,7 @@ class FilterASCII85_FPDI extends FilterASCII85 {
|
|||
|
||||
var $fpdi;
|
||||
|
||||
function FPDI_FilterASCII85(&$fpdi) {
|
||||
function FilterASCII85_FPDI(&$fpdi) {
|
||||
$this->fpdi =& $fpdi;
|
||||
}
|
||||
|
||||
|
|
|
|||
9
vendors/fpdi/filters/FilterLZW.php
vendored
9
vendors/fpdi/filters/FilterLZW.php
vendored
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
//
|
||||
// FPDI - Version 1.3.2
|
||||
// FPDI - Version 1.4.1
|
||||
//
|
||||
// Copyright 2004-2010 Setasign - Jan Slabon
|
||||
// Copyright 2004-2011 Setasign - Jan Slabon
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
@ -17,8 +17,7 @@
|
|||
// limitations under the License.
|
||||
//
|
||||
|
||||
$__tmp = version_compare(phpversion(), "5") == -1 ? array('FilterLZW') : array('FilterLZW', false);
|
||||
if (!call_user_func_array('class_exists', $__tmp)) {
|
||||
if (!class_exists('FilterLZW', false)) {
|
||||
|
||||
class FilterLZW {
|
||||
|
||||
|
|
@ -156,5 +155,3 @@ if (!call_user_func_array('class_exists', $__tmp)) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($__tmp);
|
||||
4
vendors/fpdi/filters/FilterLZW_FPDI.php
vendored
4
vendors/fpdi/filters/FilterLZW_FPDI.php
vendored
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
//
|
||||
// FPDI - Version 1.3.2
|
||||
// FPDI - Version 1.4.1
|
||||
//
|
||||
// Copyright 2004-2010 Setasign - Jan Slabon
|
||||
// Copyright 2004-2011 Setasign - Jan Slabon
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
|||
74
vendors/fpdi/fpdf_tpl.php
vendored
74
vendors/fpdi/fpdf_tpl.php
vendored
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
//
|
||||
// FPDF_TPL - Version 1.1.4
|
||||
// FPDF_TPL - Version 1.2
|
||||
//
|
||||
// Copyright 2004-2010 Setasign - Jan Slabon
|
||||
//
|
||||
|
|
@ -74,6 +74,11 @@ class FPDF_TPL extends FPDF {
|
|||
* @return int The ID of new created Template
|
||||
*/
|
||||
function beginTemplate($x = null, $y = null, $w = null, $h = null) {
|
||||
if (is_subclass_of($this, 'TCPDF')) {
|
||||
$this->Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->page <= 0)
|
||||
$this->error("You have to add a page to fpdf first!");
|
||||
|
||||
|
|
@ -127,6 +132,11 @@ class FPDF_TPL extends FPDF {
|
|||
* @return mixed If a template is opened, the ID is returned. If not a false is returned.
|
||||
*/
|
||||
function endTemplate() {
|
||||
if (is_subclass_of($this, 'TCPDF')) {
|
||||
$args = func_get_args();
|
||||
return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args);
|
||||
}
|
||||
|
||||
if ($this->_intpl) {
|
||||
$this->_intpl = false;
|
||||
$tpl =& $this->tpls[$this->tpl];
|
||||
|
|
@ -163,10 +173,10 @@ class FPDF_TPL extends FPDF {
|
|||
*/
|
||||
function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) {
|
||||
if ($this->page <= 0)
|
||||
$this->error("You have to add a page to fpdf first!");
|
||||
$this->error('You have to add a page first!');
|
||||
|
||||
if (!isset($this->tpls[$tplidx]))
|
||||
$this->error("Template does not exist!");
|
||||
$this->error('Template does not exist!');
|
||||
|
||||
if ($this->_intpl) {
|
||||
$this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx];
|
||||
|
|
@ -200,12 +210,19 @@ class FPDF_TPL extends FPDF {
|
|||
'lty' => ($this->h - $_y - $_h) - ($this->h - $h) * ($_h / $h)
|
||||
);
|
||||
|
||||
$this->_out(sprintf("q %.4F 0 0 %.4F %.4F %.4F cm", $tData['scaleX'], $tData['scaleY'], $tData['tx']*$this->k, $tData['ty']*$this->k)); // Translate
|
||||
$this->_out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm', $tData['scaleX'], $tData['scaleY'], $tData['tx'] * $this->k, $tData['ty'] * $this->k)); // Translate
|
||||
$this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx));
|
||||
|
||||
// reset font in the outer graphic state
|
||||
if ($this->FontFamily) {
|
||||
$family = $this->FontFamily;
|
||||
$this->FontFamily = '';
|
||||
$this->SetFont($family);
|
||||
}
|
||||
|
||||
$this->lastUsedTemplateData = $tData;
|
||||
|
||||
return array("w" => $_w, "h" => $_h);
|
||||
return array('w' => $_w, 'h' => $_h);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -242,17 +259,19 @@ class FPDF_TPL extends FPDF {
|
|||
/**
|
||||
* See FPDF/TCPDF-Documentation ;-)
|
||||
*/
|
||||
function SetFont($family, $style='', $size=0, $fontfile='') {
|
||||
if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 3) {
|
||||
$this->Error('More than 3 arguments for the SetFont method are only available in TCPDF.');
|
||||
public function SetFont($family, $style = '', $size = 0) {
|
||||
if (is_subclass_of($this, 'TCPDF')) {
|
||||
$args = func_get_args();
|
||||
return call_user_func_array(array($this, 'TCPDF::SetFont'), $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* force the resetting of font changes in a template
|
||||
*/
|
||||
if ($this->_intpl)
|
||||
$this->FontFamily = '';
|
||||
|
||||
parent::SetFont($family, $style, $size, $fontfile);
|
||||
parent::SetFont($family, $style, $size);
|
||||
|
||||
$fontkey = $this->FontFamily . $this->FontStyle;
|
||||
|
||||
|
|
@ -266,17 +285,20 @@ class FPDF_TPL extends FPDF {
|
|||
/**
|
||||
* See FPDF/TCPDF-Documentation ;-)
|
||||
*/
|
||||
function Image($file, $x, $y, $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0, $fitbox = false, $hidden = false) {
|
||||
if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 7) {
|
||||
$this->Error('More than 7 arguments for the Image method are only available in TCPDF.');
|
||||
function Image($file, $x = null, $y = null, $w = 0, $h = 0, $type = '', $link = '') {
|
||||
if (is_subclass_of($this, 'TCPDF')) {
|
||||
$args = func_get_args();
|
||||
return call_user_func_array(array($this, 'TCPDF::Image'), $args);
|
||||
}
|
||||
|
||||
parent::Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $ismask, $imgmask, $border, $fitbox, $hidden);
|
||||
$ret = parent::Image($file, $x, $y, $w, $h, $type, $link);
|
||||
if ($this->_intpl) {
|
||||
$this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file];
|
||||
} else {
|
||||
$this->_res['page'][$this->page]['images'][$file] =& $this->images[$file];
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -285,31 +307,49 @@ class FPDF_TPL extends FPDF {
|
|||
* AddPage is not available when you're "in" a template.
|
||||
*/
|
||||
function AddPage($orientation = '', $format = '') {
|
||||
if (is_subclass_of($this, 'TCPDF')) {
|
||||
$args = func_get_args();
|
||||
return call_user_func_array(array($this, 'TCPDF::AddPage'), $args);
|
||||
}
|
||||
|
||||
if ($this->_intpl)
|
||||
$this->Error('Adding pages in templates isn\'t possible!');
|
||||
|
||||
parent::AddPage($orientation, $format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preserve adding Links in Templates ...won't work
|
||||
*/
|
||||
function Link($x, $y, $w, $h, $link, $spaces=0) {
|
||||
if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 5) {
|
||||
$this->Error('More than 5 arguments for the Image method are only available in TCPDF.');
|
||||
function Link($x, $y, $w, $h, $link) {
|
||||
if (is_subclass_of($this, 'TCPDF')) {
|
||||
$args = func_get_args();
|
||||
return call_user_func_array(array($this, 'TCPDF::Link'), $args);
|
||||
}
|
||||
|
||||
if ($this->_intpl)
|
||||
$this->Error('Using links in templates aren\'t possible!');
|
||||
parent::Link($x, $y, $w, $h, $link, $spaces);
|
||||
|
||||
parent::Link($x, $y, $w, $h, $link);
|
||||
}
|
||||
|
||||
function AddLink() {
|
||||
if (is_subclass_of($this, 'TCPDF')) {
|
||||
$args = func_get_args();
|
||||
return call_user_func_array(array($this, 'TCPDF::AddLink'), $args);
|
||||
}
|
||||
|
||||
if ($this->_intpl)
|
||||
$this->Error('Adding links in templates aren\'t possible!');
|
||||
return parent::AddLink();
|
||||
}
|
||||
|
||||
function SetLink($link, $y = 0, $page = -1) {
|
||||
if (is_subclass_of($this, 'TCPDF')) {
|
||||
$args = func_get_args();
|
||||
return call_user_func_array(array($this, 'TCPDF::SetLink'), $args);
|
||||
}
|
||||
|
||||
if ($this->_intpl)
|
||||
$this->Error('Setting links in templates aren\'t possible!');
|
||||
parent::SetLink($link, $y, $page);
|
||||
|
|
|
|||
68
vendors/fpdi/fpdi.php
vendored
68
vendors/fpdi/fpdi.php
vendored
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
//
|
||||
// FPDI - Version 1.3.2
|
||||
// FPDI - Version 1.4.1
|
||||
//
|
||||
// Copyright 2004-2010 Setasign - Jan Slabon
|
||||
// Copyright 2004-2011 Setasign - Jan Slabon
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
@ -17,14 +17,12 @@
|
|||
// limitations under the License.
|
||||
//
|
||||
|
||||
define('FPDI_VERSION','1.3.2');
|
||||
define('FPDI_VERSION', '1.4.1');
|
||||
|
||||
// Check for TCPDF and remap TCPDF to FPDF
|
||||
$__tmp = version_compare(phpversion(), "5") == -1 ? array('TCPDF') : array('TCPDF', false);
|
||||
if (call_user_func_array('class_exists', $__tmp)) {
|
||||
if (class_exists('TCPDF', false)) {
|
||||
require_once('fpdi2tcpdf_bridge.php');
|
||||
}
|
||||
unset($__tmp);
|
||||
|
||||
require_once('fpdf_tpl.php');
|
||||
require_once('fpdi_pdf_parser.php');
|
||||
|
|
@ -73,9 +71,12 @@ class FPDI extends FPDF_TPL {
|
|||
*/
|
||||
var $lastUsedPageBox;
|
||||
|
||||
/**
|
||||
* Cache for imported pages/template ids
|
||||
* @var array
|
||||
*/
|
||||
var $_importedPages = array();
|
||||
|
||||
|
||||
/**
|
||||
* Set a source-file
|
||||
*
|
||||
|
|
@ -84,13 +85,40 @@ class FPDI extends FPDF_TPL {
|
|||
*/
|
||||
function setSourceFile($filename) {
|
||||
$this->current_filename = $filename;
|
||||
$fn =& $this->current_filename;
|
||||
|
||||
if (!isset($this->parsers[$fn]))
|
||||
$this->parsers[$fn] = new fpdi_pdf_parser($fn, $this);
|
||||
$this->current_parser =& $this->parsers[$fn];
|
||||
if (!isset($this->parsers[$filename]))
|
||||
$this->parsers[$filename] = $this->_getPdfParser($filename);
|
||||
$this->current_parser =& $this->parsers[$filename];
|
||||
|
||||
return $this->parsers[$fn]->getPageCount();
|
||||
return $this->parsers[$filename]->getPageCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a PDF parser object
|
||||
*
|
||||
* @param string $filename
|
||||
* @return fpdi_pdf_parser
|
||||
*/
|
||||
function _getPdfParser($filename) {
|
||||
return new fpdi_pdf_parser($filename, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current PDF version
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getPDFVersion() {
|
||||
return $this->PDFVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the PDF version
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function setPDFVersion($version = '1.3') {
|
||||
$this->PDFVersion = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -104,10 +132,10 @@ class FPDI extends FPDF_TPL {
|
|||
return $this->error('Please import the desired pages before creating a new template.');
|
||||
}
|
||||
|
||||
$fn =& $this->current_filename;
|
||||
$fn = $this->current_filename;
|
||||
|
||||
// check if page already imported
|
||||
$pageKey = $fn.((int)$pageno).$boxName;
|
||||
$pageKey = $fn . '-' . ((int)$pageno) . $boxName;
|
||||
if (isset($this->_importedPages[$pageKey]))
|
||||
return $this->_importedPages[$pageKey];
|
||||
|
||||
|
|
@ -116,7 +144,7 @@ class FPDI extends FPDF_TPL {
|
|||
|
||||
if (!in_array($boxName, $parser->availableBoxes))
|
||||
return $this->Error(sprintf('Unknown box: %s', $boxName));
|
||||
$pageboxes = $parser->getPageBoxes($pageno);
|
||||
$pageboxes = $parser->getPageBoxes($pageno, $this->k);
|
||||
|
||||
/**
|
||||
* MediaBox
|
||||
|
|
@ -162,6 +190,9 @@ class FPDI extends FPDF_TPL {
|
|||
$tpl['w'] = $steps % 2 == 0 ? $_w : $_h;
|
||||
$tpl['h'] = $steps % 2 == 0 ? $_h : $_w;
|
||||
|
||||
if ($angle < 0)
|
||||
$angle += 360;
|
||||
|
||||
$tpl['_rotationAngle'] = $angle * -1;
|
||||
}
|
||||
|
||||
|
|
@ -178,6 +209,9 @@ class FPDI extends FPDF_TPL {
|
|||
if ($adjustPageSize == true && is_null($_x) && is_null($_y)) {
|
||||
$size = $this->getTemplateSize($tplidx, $_w, $_h);
|
||||
$format = array($size['w'], $size['h']);
|
||||
if (is_subclass_of($this, 'TCPDF')) {
|
||||
$this->setPageFormat($format, $format[0] > $format[1] ? 'L' : 'P');
|
||||
} else {
|
||||
if ($format[0] != $this->CurPageFormat[0] || $format[1] != $this->CurPageFormat[1]) {
|
||||
$this->w = $format[0];
|
||||
$this->h = $format[1];
|
||||
|
|
@ -188,10 +222,12 @@ class FPDI extends FPDF_TPL {
|
|||
$this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->_out('q 0 J 1 w 0 j 0 G 0 g'); // reset standard values
|
||||
$s = parent::useTemplate($tplidx, $_x, $_y, $_w, $_h);
|
||||
$this->_out('Q');
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
|
@ -346,6 +382,7 @@ class FPDI extends FPDF_TPL {
|
|||
$this->_out($obj_id . ' 0 obj');
|
||||
$this->_current_obj_id = $obj_id; // for later use with encryption
|
||||
}
|
||||
|
||||
return $obj_id;
|
||||
}
|
||||
|
||||
|
|
@ -436,6 +473,7 @@ class FPDI extends FPDF_TPL {
|
|||
$this->_out($value[2][1]);
|
||||
$this->_out('endstream');
|
||||
break;
|
||||
|
||||
case PDF_TYPE_HEX:
|
||||
$this->_straightOut('<' . $value[1] . '>');
|
||||
break;
|
||||
|
|
|
|||
32
vendors/fpdi/fpdi2tcpdf_bridge.php
vendored
32
vendors/fpdi/fpdi2tcpdf_bridge.php
vendored
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
//
|
||||
// FPDI - Version 1.3.2
|
||||
// FPDI - Version 1.4.1
|
||||
//
|
||||
// Copyright 2004-2010 Setasign - Jan Slabon
|
||||
// Copyright 2004-2011 Setasign - Jan Slabon
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
@ -28,27 +28,19 @@
|
|||
*/
|
||||
class FPDF extends TCPDF {
|
||||
|
||||
function __get($name) {
|
||||
switch ($name) {
|
||||
case 'PDFVersion':
|
||||
return $this->PDFVersion;
|
||||
case 'k':
|
||||
return $this->k;
|
||||
default:
|
||||
// Error handling
|
||||
$this->Error('Cannot access protected property '.get_class($this).':$'.$name.' / Undefined property: '.get_class($this).'::$'.$name);
|
||||
function _putstream($s) {
|
||||
$this->_out($this->_getstream($s));
|
||||
}
|
||||
|
||||
function _getxobjectdict() {
|
||||
$out = parent::_getxobjectdict();
|
||||
if (count($this->tpls)) {
|
||||
foreach($this->tpls as $tplidx => $tpl) {
|
||||
$out .= sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n']);
|
||||
}
|
||||
}
|
||||
|
||||
function __set($name, $value) {
|
||||
switch ($name) {
|
||||
case 'PDFVersion':
|
||||
$this->PDFVersion = $value;
|
||||
break;
|
||||
default:
|
||||
// Error handling
|
||||
$this->Error('Cannot access protected property '.get_class($this).':$'.$name.' / Undefined property: '.get_class($this).'::$'.$name);
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
58
vendors/fpdi/fpdi_pdf_parser.php
vendored
58
vendors/fpdi/fpdi_pdf_parser.php
vendored
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
//
|
||||
// FPDI - Version 1.3.2
|
||||
// FPDI - Version 1.4.1
|
||||
//
|
||||
// Copyright 2004-2010 Setasign - Jan Slabon
|
||||
// Copyright 2004-2011 Setasign - Jan Slabon
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
@ -213,6 +213,11 @@ class fpdi_pdf_parser extends pdf_parser {
|
|||
if (isset($obj[1][1]['/Filter'])) {
|
||||
$_filter = $obj[1][1]['/Filter'];
|
||||
|
||||
if ($_filter[0] == PDF_TYPE_OBJREF) {
|
||||
$tmpFilter = $this->pdf_resolve_object($this->c, $_filter);
|
||||
$_filter = $tmpFilter[1];
|
||||
}
|
||||
|
||||
if ($_filter[0] == PDF_TYPE_TOKEN) {
|
||||
$filters[] = $_filter;
|
||||
} else if ($_filter[0] == PDF_TYPE_ARRAY) {
|
||||
|
|
@ -225,11 +230,16 @@ class fpdi_pdf_parser extends pdf_parser {
|
|||
foreach ($filters AS $_filter) {
|
||||
switch ($_filter[1]) {
|
||||
case '/FlateDecode':
|
||||
case '/Fl':
|
||||
// $stream .= "\x0F\x0D"; // in an errorious stream this suffix could work
|
||||
// $stream .= "\x0A";
|
||||
// $stream .= "\x0D";
|
||||
if (function_exists('gzuncompress')) {
|
||||
$stream = (strlen($stream) > 0) ? @gzuncompress($stream) : '';
|
||||
} else {
|
||||
$this->error(sprintf('To handle %s filter, please compile php with zlib support.',$_filter[1]));
|
||||
}
|
||||
|
||||
if ($stream === false) {
|
||||
$this->error('Error while decompressing stream.');
|
||||
}
|
||||
|
|
@ -262,9 +272,10 @@ class fpdi_pdf_parser extends pdf_parser {
|
|||
*
|
||||
* @param array $page a /Page
|
||||
* @param string $box_index Type of Box @see $availableBoxes
|
||||
* @param float Scale factor from user space units to points
|
||||
* @return array
|
||||
*/
|
||||
function getPageBox($page, $box_index) {
|
||||
function getPageBox($page, $box_index, $k) {
|
||||
$page = $this->pdf_resolve_object($this->c, $page);
|
||||
$box = null;
|
||||
if (isset($page[1][1][$box_index]))
|
||||
|
|
@ -277,37 +288,44 @@ class fpdi_pdf_parser extends pdf_parser {
|
|||
|
||||
if (!is_null($box) && $box[0] == PDF_TYPE_ARRAY) {
|
||||
$b =& $box[1];
|
||||
return array('x' => $b[0][1]/$this->fpdi->k,
|
||||
'y' => $b[1][1]/$this->fpdi->k,
|
||||
'w' => abs($b[0][1]-$b[2][1])/$this->fpdi->k,
|
||||
'h' => abs($b[1][1]-$b[3][1])/$this->fpdi->k,
|
||||
'llx' => min($b[0][1], $b[2][1])/$this->fpdi->k,
|
||||
'lly' => min($b[1][1], $b[3][1])/$this->fpdi->k,
|
||||
'urx' => max($b[0][1], $b[2][1])/$this->fpdi->k,
|
||||
'ury' => max($b[1][1], $b[3][1])/$this->fpdi->k,
|
||||
return array('x' => $b[0][1]/$k,
|
||||
'y' => $b[1][1]/$k,
|
||||
'w' => abs($b[0][1]-$b[2][1])/$k,
|
||||
'h' => abs($b[1][1]-$b[3][1])/$k,
|
||||
'llx' => min($b[0][1], $b[2][1])/$k,
|
||||
'lly' => min($b[1][1], $b[3][1])/$k,
|
||||
'urx' => max($b[0][1], $b[2][1])/$k,
|
||||
'ury' => max($b[1][1], $b[3][1])/$k,
|
||||
);
|
||||
} else if (!isset ($page[1][1]['/Parent'])) {
|
||||
return false;
|
||||
} else {
|
||||
return $this->getPageBox($this->pdf_resolve_object($this->c, $page[1][1]['/Parent']), $box_index);
|
||||
return $this->getPageBox($this->pdf_resolve_object($this->c, $page[1][1]['/Parent']), $box_index, $k);
|
||||
}
|
||||
}
|
||||
|
||||
function getPageBoxes($pageno) {
|
||||
return $this->_getPageBoxes($this->pages[$pageno-1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Boxes from /Page
|
||||
* Get all page boxes by page no
|
||||
*
|
||||
* @param int The page number
|
||||
* @param float Scale factor from user space units to points
|
||||
* @return array
|
||||
*/
|
||||
function getPageBoxes($pageno, $k) {
|
||||
return $this->_getPageBoxes($this->pages[$pageno-1], $k);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all boxes from /Page
|
||||
*
|
||||
* @param array a /Page
|
||||
* @return array
|
||||
*/
|
||||
function _getPageBoxes($page) {
|
||||
function _getPageBoxes($page, $k) {
|
||||
$boxes = array();
|
||||
|
||||
foreach($this->availableBoxes AS $box) {
|
||||
if ($_box = $this->getPageBox($page,$box)) {
|
||||
if ($_box = $this->getPageBox($page, $box, $k)) {
|
||||
$boxes[$box] = $_box;
|
||||
}
|
||||
}
|
||||
|
|
@ -385,7 +403,7 @@ class fpdi_pdf_parser extends pdf_parser {
|
|||
*/
|
||||
function getPDFVersion() {
|
||||
parent::getPDFVersion();
|
||||
$this->fpdi->PDFVersion = max($this->fpdi->PDFVersion, $this->pdfVersion);
|
||||
$this->fpdi->setPDFVersion(max($this->fpdi->getPDFVersion(), $this->pdfVersion));
|
||||
}
|
||||
|
||||
}
|
||||
15
vendors/fpdi/pdf_context.php
vendored
15
vendors/fpdi/pdf_context.php
vendored
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
//
|
||||
// FPDI - Version 1.3.2
|
||||
// FPDI - Version 1.4.1
|
||||
//
|
||||
// Copyright 2004-2010 Setasign - Jan Slabon
|
||||
// Copyright 2004-2011 Setasign - Jan Slabon
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
@ -17,8 +17,7 @@
|
|||
// limitations under the License.
|
||||
//
|
||||
|
||||
$__tmp = version_compare(phpversion(), "5") == -1 ? array('pdf_context') : array('pdf_context', false);
|
||||
if (!call_user_func_array('class_exists', $__tmp)) {
|
||||
if (!class_exists('pdf_context', false)) {
|
||||
|
||||
class pdf_context {
|
||||
|
||||
|
|
@ -89,7 +88,11 @@ if (!call_user_func_array('class_exists', $__tmp)) {
|
|||
} else if ($this->_mode == 0) {
|
||||
$totalLength = $this->length + $l;
|
||||
do {
|
||||
$this->buffer .= fread($this->file, $totalLength-$this->length);
|
||||
$toRead = $totalLength - $this->length;
|
||||
if ($toRead < 1)
|
||||
break;
|
||||
|
||||
$this->buffer .= fread($this->file, $toRead);
|
||||
} while ((($this->length = strlen($this->buffer)) != $totalLength) && !feof($this->file));
|
||||
|
||||
return true;
|
||||
|
|
@ -99,5 +102,3 @@ if (!call_user_func_array('class_exists', $__tmp)) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($__tmp);
|
||||
27
vendors/fpdi/pdf_parser.php
vendored
27
vendors/fpdi/pdf_parser.php
vendored
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
//
|
||||
// FPDI - Version 1.3.2
|
||||
// FPDI - Version 1.4.1
|
||||
//
|
||||
// Copyright 2004-2010 Setasign - Jan Slabon
|
||||
// Copyright 2004-2011 Setasign - Jan Slabon
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
@ -46,8 +46,7 @@ if (!defined ('PDF_TYPE_REAL'))
|
|||
|
||||
require_once('pdf_context.php');
|
||||
|
||||
$__tmp = version_compare(phpversion(), "5") == -1 ? array('pdf_parser') : array('pdf_parser', false);
|
||||
if (!call_user_func_array('class_exists', $__tmp)) {
|
||||
if (!class_exists('pdf_parser', false)) {
|
||||
|
||||
class pdf_parser {
|
||||
|
||||
|
|
@ -87,6 +86,13 @@ if (!call_user_func_array('class_exists', $__tmp)) {
|
|||
*/
|
||||
var $pdfVersion;
|
||||
|
||||
/**
|
||||
* For reading encrypted documents and xref/objectstreams are in use
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
var $readPlain = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
|
@ -206,8 +212,8 @@ if (!call_user_func_array('class_exists', $__tmp)) {
|
|||
* @param integer $offset of xref-table
|
||||
*/
|
||||
function pdf_read_xref(&$result, $offset) {
|
||||
|
||||
fseek($this->f, $o_pos = $offset-20); // set some bytes backwards to fetch errorious docs
|
||||
$o_pos = $offset-min(20, $offset);
|
||||
fseek($this->f, $o_pos); // set some bytes backwards to fetch errorious docs
|
||||
|
||||
$data = fread($this->f, 100);
|
||||
|
||||
|
|
@ -542,8 +548,15 @@ if (!call_user_func_array('class_exists', $__tmp)) {
|
|||
$header = $this->pdf_read_value($c);
|
||||
|
||||
if ($header[0] != PDF_TYPE_OBJDEC || $header[1] != $obj_spec[1] || $header[2] != $obj_spec[2]) {
|
||||
$toSearchFor = $obj_spec[1].' '.$obj_spec[2].' obj';
|
||||
if (preg_match('/'.$toSearchFor.'/', $c->buffer)) {
|
||||
$c->offset = strpos($c->buffer, $toSearchFor) + strlen($toSearchFor);
|
||||
// reset stack
|
||||
$c->stack = array();
|
||||
} else {
|
||||
$this->error("Unable to find object ({$obj_spec[1]}, {$obj_spec[2]}) at expected location");
|
||||
}
|
||||
}
|
||||
|
||||
// If we're being asked to store all the information
|
||||
// about the object, we add the object ID and generation
|
||||
|
|
@ -704,5 +717,3 @@ if (!call_user_func_array('class_exists', $__tmp)) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($__tmp);
|
||||
14
vendors/tcpdf/CHANGELOG.TXT
vendored
14
vendors/tcpdf/CHANGELOG.TXT
vendored
|
|
@ -1,3 +1,17 @@
|
|||
5.9.082 (2011-05-22)
|
||||
- Bug item #3305592 "Setting fill color <> text color breaks text clipping" was fixed.
|
||||
|
||||
5.9.081 (2011-05-18)
|
||||
- Method resetHeaderTemplate() was added to reset the xobject template used by Header() method.
|
||||
- Method setHeaderTemplateAutoreset() was added to automatically reset the xobject template used by Header() method at each page.
|
||||
|
||||
5.9.080 (2011-05-17)
|
||||
- A problem related to file path calculation for images was fixed.
|
||||
- A problem related to unsupressed getimagesize() error was fixed.
|
||||
|
||||
5.9.079 (2011-05-16)
|
||||
- Footer() method was changed to use C128 barcode as default (instead of the previous C128B).
|
||||
|
||||
5.9.078 (2011-05-12)
|
||||
- Bug item #3300878 "wrong rendering for html bullet list in some case" was fixed.
|
||||
- Bug item #3301017 "Emphasized vs. font-weight" was fixed.
|
||||
|
|
|
|||
4
vendors/tcpdf/README.TXT
vendored
4
vendors/tcpdf/README.TXT
vendored
|
|
@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
|
|||
------------------------------------------------------------
|
||||
|
||||
Name: TCPDF
|
||||
Version: 5.9.078
|
||||
Release date: 2011-05-12
|
||||
Version: 5.9.082
|
||||
Release date: 2011-05-22
|
||||
Author: Nicola Asuni
|
||||
|
||||
Copyright (c) 2002-2011:
|
||||
|
|
|
|||
59
vendors/tcpdf/tcpdf.php
vendored
59
vendors/tcpdf/tcpdf.php
vendored
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf.php
|
||||
// Version : 5.9.078
|
||||
// Version : 5.9.082
|
||||
// Begin : 2002-08-03
|
||||
// Last Update : 2011-05-12
|
||||
// Last Update : 2011-05-22
|
||||
// Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
|
||||
// License : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3 + YOU CAN'T REMOVE ANY TCPDF COPYRIGHT NOTICE OR LINK FROM THE GENERATED PDF DOCUMENTS.
|
||||
// -------------------------------------------------------------------
|
||||
|
|
@ -134,7 +134,7 @@
|
|||
* Tools to encode your unicode fonts are on fonts/utils directory.</p>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @author Nicola Asuni
|
||||
* @version 5.9.078
|
||||
* @version 5.9.082
|
||||
*/
|
||||
|
||||
// Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file.
|
||||
|
|
@ -146,7 +146,7 @@ require_once(dirname(__FILE__).'/config/tcpdf_config.php');
|
|||
* TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @brief PHP class for generating PDF documents without requiring external extensions.
|
||||
* @version 5.9.078
|
||||
* @version 5.9.082
|
||||
* @author Nicola Asuni - info@tecnick.com
|
||||
*/
|
||||
class TCPDF {
|
||||
|
|
@ -157,7 +157,7 @@ class TCPDF {
|
|||
* Current TCPDF version.
|
||||
* @private
|
||||
*/
|
||||
private $tcpdf_version = '5.9.078';
|
||||
private $tcpdf_version = '5.9.082';
|
||||
|
||||
// Protected properties
|
||||
|
||||
|
|
@ -572,6 +572,12 @@ class TCPDF {
|
|||
*/
|
||||
protected $header_xobjid = -1;
|
||||
|
||||
/**
|
||||
* If true reset the Header Xobject template at each page
|
||||
* @protected
|
||||
*/
|
||||
protected $header_xobj_autoreset = false;
|
||||
|
||||
/**
|
||||
* Minimum distance between header and top page margin.
|
||||
* @protected
|
||||
|
|
@ -1912,6 +1918,7 @@ class TCPDF {
|
|||
$this->file_id = md5($this->getRandomSeed('TCPDF'.$orientation.$unit.$format.$encoding));
|
||||
// get default graphic vars
|
||||
$this->default_graphic_vars = $this->getGraphicVars();
|
||||
$this->header_xobj_autoreset = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -4003,6 +4010,23 @@ class TCPDF {
|
|||
return $this->img_rb_y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the xobject template used by Header() method.
|
||||
* @public
|
||||
*/
|
||||
public function resetHeaderTemplate() {
|
||||
$this->header_xobjid = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a flag to automatically reset the xobject template used by Header() method at each page.
|
||||
* @param $val (boolean) set to true to reset Header xobject template at each page, false otherwise.
|
||||
* @public
|
||||
*/
|
||||
public function setHeaderTemplateAutoreset($val=true) {
|
||||
$this->header_xobj_autoreset = $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to render the page header.
|
||||
* It is automatically called by AddPage() and could be overwritten in your own inherited class.
|
||||
|
|
@ -4074,6 +4098,10 @@ class TCPDF {
|
|||
$x = 0 + $dx;
|
||||
}
|
||||
$this->printTemplate($this->header_xobjid, $x, 0, 0, 0, '', '', false);
|
||||
if ($this->header_xobj_autoreset) {
|
||||
// reset header xobject template at each page
|
||||
$this->header_xobjid = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -4104,7 +4132,7 @@ class TCPDF {
|
|||
'bgcolor' => false,
|
||||
'text' => false
|
||||
);
|
||||
$this->write1DBarcode($barcode, 'C128B', '', $cur_y + $line_width, '', (($this->footer_margin / 3) - $line_width), 0.3, $style, '');
|
||||
$this->write1DBarcode($barcode, 'C128', '', $cur_y + $line_width, '', (($this->footer_margin / 3) - $line_width), 0.3, $style, '');
|
||||
}
|
||||
if (empty($this->pagegroups)) {
|
||||
$pagenumtxt = $this->l['w_page'].' '.$this->getAliasNumPage().' / '.$this->getAliasNbPages();
|
||||
|
|
@ -5694,7 +5722,7 @@ class TCPDF {
|
|||
// increase/decrease font spacing
|
||||
$rs .= sprintf('BT %.2F Tc ET ', ($this->font_spacing * $this->k));
|
||||
}
|
||||
if ($this->ColorFlag) {
|
||||
if ($this->ColorFlag AND ($this->textrendermode < 4)) {
|
||||
$s .= 'q '.$this->TextColor.' ';
|
||||
}
|
||||
// rendering mode
|
||||
|
|
@ -5801,7 +5829,7 @@ class TCPDF {
|
|||
if ($this->overline) {
|
||||
$s .= ' '.$this->_dooverlinew($xdx, $basefonty, $width);
|
||||
}
|
||||
if ($this->ColorFlag) {
|
||||
if ($this->ColorFlag AND ($this->textrendermode < 4)) {
|
||||
$s .= ' Q';
|
||||
}
|
||||
if ($link) {
|
||||
|
|
@ -7261,8 +7289,12 @@ class TCPDF {
|
|||
// encode spaces on filename (file is probably an URL)
|
||||
$file = str_replace(' ', '%20', $file);
|
||||
}
|
||||
if (@file_exists($file)) {
|
||||
// get image dimensions
|
||||
$imsize = @getimagesize($file);
|
||||
} else {
|
||||
$imsize = false;
|
||||
}
|
||||
if ($imsize === FALSE) {
|
||||
if (function_exists('curl_init')) {
|
||||
// try to get remote file data using cURL
|
||||
|
|
@ -20967,9 +20999,13 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
|
|||
if (($tag['attribute']['src'][0] == '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
|
||||
$findroot = strpos($tag['attribute']['src'], $_SERVER['DOCUMENT_ROOT']);
|
||||
if (($findroot === false) OR ($findroot > 1)) {
|
||||
if (substr($_SERVER['DOCUMENT_ROOT'], -1) == '/') {
|
||||
$tag['attribute']['src'] = substr($_SERVER['DOCUMENT_ROOT'], 0, -1).$tag['attribute']['src'];
|
||||
} else {
|
||||
$tag['attribute']['src'] = $_SERVER['DOCUMENT_ROOT'].$tag['attribute']['src'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$tag['attribute']['src'] = urldecode($tag['attribute']['src']);
|
||||
$type = $this->getImageFileType($tag['attribute']['src']);
|
||||
$testscrtype = @parse_url($tag['attribute']['src']);
|
||||
|
|
@ -26371,13 +26407,16 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
|
|||
// replace relative path with full server path
|
||||
$img = $this->svgdir.'/'.$img;
|
||||
}
|
||||
if (($img{0} == '/') AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
|
||||
if (($img[0] == '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
|
||||
$findroot = strpos($img, $_SERVER['DOCUMENT_ROOT']);
|
||||
if (($findroot === false) OR ($findroot > 1)) {
|
||||
// replace relative path with full server path
|
||||
if (substr($_SERVER['DOCUMENT_ROOT'], -1) == '/') {
|
||||
$img = substr($_SERVER['DOCUMENT_ROOT'], 0, -1).$img;
|
||||
} else {
|
||||
$img = $_SERVER['DOCUMENT_ROOT'].$img;
|
||||
}
|
||||
}
|
||||
}
|
||||
$img = urldecode($img);
|
||||
$testscrtype = @parse_url($img);
|
||||
if (!isset($testscrtype['query']) OR empty($testscrtype['query'])) {
|
||||
|
|
|
|||
3
vendors/xfpdi.php
vendored
3
vendors/xfpdi.php
vendored
|
|
@ -1,5 +1,6 @@
|
|||
<?
|
||||
//App::import('Vendor', 'tcpdf/tcpdf');
|
||||
App::import('Vendor', 'tcpdf/tcpdf');
|
||||
|
||||
App::import('Vendor', 'fpdi/fpdi');
|
||||
|
||||
class XFPDI extends FPDI {
|
||||
|
|
|
|||
42
vendors/xtcpdf.php
vendored
42
vendors/xtcpdf.php
vendored
|
|
@ -64,12 +64,12 @@ class XTCPDF extends TCPDF {
|
|||
*/
|
||||
function Page1Footer() {
|
||||
$this->SetY(-30);
|
||||
//$this->Image(K_PATH_IMAGES.'cmcfooter.jpg', null, 255, 200, 0, null, 'http://www.cmctechnologies.com.au', null, false, null, 'C');
|
||||
/*//$this->Image(K_PATH_IMAGES.'cmcfooter.jpg', null, 255, 200, 0, null, 'http://www.cmctechnologies.com.au', null, false, null, 'C');
|
||||
$this->MultiCell(0, 2, "<hr>", 0, 'C', null, 1, null, null, true, 0, true, false);
|
||||
// $this->MultiCell(0, 2, "PROVIDING SOLUTIONS IN", 0, 'C', null, 1, null, null, true, 0, true, false);
|
||||
//$this->ln();
|
||||
//$this->ln();
|
||||
$this->SetFontSize(12);
|
||||
$this->SetFontSize(10);
|
||||
$this->MultiCell(120, 2, "<span style=\"color: #DF0101; font-weight: bold\">EXPLOSION PREVENTION</span>", 0, 'L', null, 0, null, null, true, 0, true, false);
|
||||
$this->MultiCell(0, 2, "<span style=\"color: #DF0101; font-weight: bold\">PRESSURE RELIEF</span>", 0, 'R', null, 1, null, null, true, 0, true, false);
|
||||
$this->MultiCell(120, 2, "<span style=\"color: #088A4B; font-weight: bold\">EXPLOSION PROTECTION</span>", 0, 'L', null, 0, null, null, true, 0, true, false);
|
||||
|
|
@ -77,6 +77,8 @@ class XTCPDF extends TCPDF {
|
|||
// $this->ln();
|
||||
$this->MultiCell(80, 2, "<span style=\"color: #0000FF; font-weight: bold\">FLOW MEASUREMENT</span>", 0, 'L', null, 0, null, null, true, 0, true, false);
|
||||
$this->MultiCell(0, 2, "<span style=\"color: #0000FF; font-weight: bold\">PROCESS INSTRUMENTATION</span>", 0, 'R', null, 1, null, null, true, 0, true, false);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -171,7 +173,7 @@ class XTCPDF extends TCPDF {
|
|||
* @param <type> $docType
|
||||
* @param <type> $commercialDetails
|
||||
*/
|
||||
function calculateProductPage($currency,$gst, $products ,$docType, $commercialDetails) {
|
||||
function calculateProductPage($currency,$gst, $products, $commercialDetails) {
|
||||
|
||||
$itemColwidth = 12;
|
||||
$qtyColwidth = 10;
|
||||
|
|
@ -191,8 +193,12 @@ class XTCPDF extends TCPDF {
|
|||
|
||||
$this->startTransaction();
|
||||
|
||||
$fullDesc = "<b>".$principlesList[$product[$docType]['principle_id']]."</b><br>"."<b>".$product[$docType]['title'].'</b><br>'.$product[$docType]['description'];
|
||||
$this->MultiCell($descColwidth, 0, $fullDesc, 1, "L", 0, 0, null, null, true, 0, true);
|
||||
$fullDesc = "<b>".$product['title'].'</b><br>'.$product['description'];
|
||||
|
||||
//$this->MultiCell($descColwidth, 0, $fullDesc, 1, "L", 0, 0, null, null, true, 0, true, true, 0, 'T', false);
|
||||
// die($fullDesc);
|
||||
|
||||
//$this->MultiCell($descColwidth, 0, $fullDesc, 1, 'L', false, 1, 0, 0, true, 0, true, true);
|
||||
|
||||
$lasth = $this->getLastH();
|
||||
$this->rollbackTransaction($this);
|
||||
|
|
@ -202,23 +208,22 @@ class XTCPDF extends TCPDF {
|
|||
|
||||
//echo $product[$docType]['id']." needs ".$lasth." has $heightLeft left<br>";
|
||||
|
||||
$itemno = $product[$docType]['item_number'];
|
||||
|
||||
$itemno = $product['item_number'];
|
||||
if($heightLeft - $lasth <= 0) {
|
||||
// echo "<br>OUT OF SPACE ON PAGE $pagesRequired making a new one<br>";
|
||||
$pagesRequired++;
|
||||
$heightLeft = $availableHeight; //Start checking the next page;
|
||||
// echo "<br>remaining height on new one = ".$heightLeft."<br>";
|
||||
$heightLeft -= $lasth;
|
||||
$itemno = $product[$docType]['item_number'];
|
||||
$itemno = $product['item_number'];
|
||||
// echo "<br>Using $lasth for $itemno so now have $heightLeft left<br>";
|
||||
|
||||
$pageProducts[$pagesRequired][] = $product[$docType]['id'];
|
||||
$pageProducts[$pagesRequired][] = $product['id'];
|
||||
|
||||
}
|
||||
else {
|
||||
$heightLeft -= $lasth;
|
||||
$pageProducts[$pagesRequired][] = $product[$docType]['id'];
|
||||
$pageProducts[$pagesRequired][] = $product['id'];
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -226,6 +231,8 @@ class XTCPDF extends TCPDF {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Reached the last product in this Product Table.
|
||||
* Need to see if we still have enough room to print the totals, if not will need to put the last item on a new page.
|
||||
*/
|
||||
|
|
@ -233,9 +240,10 @@ class XTCPDF extends TCPDF {
|
|||
|
||||
$this->startTransaction();
|
||||
$subtotal = 0;
|
||||
$totalsHeight = $this->totals($currency, $subtotal, 1);
|
||||
$commDetailsHeight = $this->commercialComments($commercialDetails);
|
||||
|
||||
//$totalsHeight = $this->totals($currency, $subtotal, 1);
|
||||
$commDetailsHeight = $this->commercialComments($commercialDetails);
|
||||
echo "WOTOTOTO1111T";
|
||||
$this->rollbackTransaction($this);
|
||||
|
||||
//echo "Currently have $heightLeft Comm details height is ".$commDetailsHeight." totals height is: ".$totalsHeight."<br>";
|
||||
|
|
@ -263,6 +271,7 @@ class XTCPDF extends TCPDF {
|
|||
|
||||
|
||||
debug($pageProducts);
|
||||
print_r($pageProducts);
|
||||
return $pageProducts;
|
||||
}
|
||||
|
||||
|
|
@ -300,7 +309,6 @@ class XTCPDF extends TCPDF {
|
|||
|
||||
$options = 0; //Toggled to 1 when we encounter an Optional product. Stops the totals being printed.
|
||||
|
||||
print_r($principlesList[0]);
|
||||
foreach ($pageProducts as $page) {
|
||||
|
||||
$this->AddPage();
|
||||
|
|
@ -496,7 +504,7 @@ class XTCPDF extends TCPDF {
|
|||
|
||||
$totalHeight = 0;
|
||||
|
||||
$this->MultiCell(0, 0, "<b><u>Commercial Comments:</u></b>", 0, 'L', 0, 1, null, null, 1, null, true);
|
||||
//$this->MultiCell(0, 0, "<b><u>Commercial Comments:</u></b>", 0, 'L', 0, 1, null, null, 1, null, true);
|
||||
$totalHeight += $this->getLastH();
|
||||
|
||||
$validUntilDate = strtotime($details["dateIssued"]. ' + '.$details["validFor"].' days');
|
||||
|
|
@ -520,12 +528,12 @@ IS SUBJECT TO CHANGE IF QUANTITIES VARY.
|
|||
ENDHTMLCONTENTS;
|
||||
//$commlines = $this->getNumLines($listHtmlContents);
|
||||
//echo "lines required for commercial comments: ".$commlines;
|
||||
$this->MultiCell(0, 0, $listHtmlContents, 0, 'L', 0, 1, null, null, 1, null, true);
|
||||
//$this->MultiCell(0, 0, $listHtmlContents, 0, 'L', 0, 1, null, null, 1, null, true);
|
||||
$totalHeight += $this->getLastH();
|
||||
|
||||
$this->MultiCell(0, 0, "Signed: ____________________________", 0, 'L');
|
||||
//$this->MultiCell(0, 0, "Signed: ____________________________", 0, 'L');
|
||||
$totalHeight += $this->getLastH();
|
||||
$this->MultiCell(0, 0, " ".$details["salesEngineer"], 0, 'L');
|
||||
//$this->MultiCell(0, 0, " ".$details["salesEngineer"], 0, 'L');
|
||||
$totalHeight += $this->getLastH();
|
||||
|
||||
|
||||
|
|
|
|||
109
views/documents/pdf.ctp
Executable file
109
views/documents/pdf.ctp
Executable file
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
App::import('Vendor','pdfdoc');
|
||||
|
||||
$pdfdoc = new PDFDOC();
|
||||
|
||||
$pdfdoc->SetPrintHeader(false);
|
||||
$pdfdoc->SetPrintFooter(false);
|
||||
|
||||
|
||||
$firstPageDone = false;
|
||||
|
||||
|
||||
$companyName = $enquiry['Customer']['name'];
|
||||
$emailTo = $enquiry['Contact']['email'];
|
||||
$attention = $enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'];
|
||||
|
||||
$fromName = $enquiry['User']['first_name'].' '.$enquiry['User']['last_name'];
|
||||
$fromEmail = $enquiry['User']['email'];
|
||||
|
||||
$enquiryNumber = $enquiry['Enquiry']['title'];
|
||||
$your_reference = 'Enquiry '.$enquiry['Enquiry']['created'];
|
||||
|
||||
$issue_date = $document['Quote']['date_issued'];
|
||||
|
||||
$pdfdoc->docRef = $enquiryNumber;
|
||||
|
||||
foreach($document['DocPage'] as $page) {
|
||||
|
||||
$pdfdoc->AddPage();
|
||||
$pdfdoc->Page1Header();
|
||||
if($firstPageDone == false) {
|
||||
|
||||
$pdfdoc->DetailsBox($docTypeFullName, $companyName, $emailTo, $attention, $fromName,
|
||||
$fromEmail, $enquiryNumber, $your_reference, $issue_date);
|
||||
|
||||
|
||||
$firstPageDone = true;
|
||||
|
||||
}
|
||||
|
||||
$pdfdoc->pageContent($page['content']);
|
||||
|
||||
$pdfdoc->Page1Footer();
|
||||
|
||||
}
|
||||
|
||||
|
||||
$LineItemTable = $this->element('line_items_table');
|
||||
echo $LineItemTable;
|
||||
$pdfdoc->SetHeaderMargin(30);
|
||||
$pdfdoc->SetFooterMargin(30);
|
||||
$pdfdoc->SetPrintHeader(true);
|
||||
$pdfdoc->AddPage();
|
||||
//$pdfdoc->MultiCell($w, $h, $txt, $border, $align, $fill, $ln, $x, $y, $reseth, $stretch, $ishtml)
|
||||
|
||||
$pdfdoc->MultiCell(0, 0, 'PRICING & SPECIFICATIONS', 0, 'C', false, 1, null, null, true, false, false);
|
||||
|
||||
|
||||
|
||||
$pdfdoc->pageContent($LineItemTable);
|
||||
$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/';
|
||||
|
||||
$debuglevel = Configure::read('debug');
|
||||
|
||||
if($debuglevel == 0) {
|
||||
$output_dir = '/var/www/cakephp/app/webroot/pdf/';
|
||||
}
|
||||
|
||||
|
||||
if($document['Quote']['revision'] > 0) {
|
||||
$filename = $enquiry['Enquiry']['title'].'rev'.$document['Quote']['revision'].'.pdf';
|
||||
}
|
||||
else {
|
||||
$filename = $enquiry['Enquiry']['title'].'.pdf';
|
||||
}
|
||||
|
||||
|
||||
$pdfdoc->Output($output_dir.$filename, 'F');
|
||||
|
||||
echo "<br> Wrote: ".$output_dir.$filename;
|
||||
|
||||
//$tcpdf->Output('cmcquote.pdf', 'D');
|
||||
|
||||
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');
|
||||
|
||||
?>
|
||||
|
|
@ -11,7 +11,7 @@ switch($docType) {
|
|||
break;
|
||||
|
||||
case 'invoice':
|
||||
echo "INVOICE!!";
|
||||
echo $this->element('document_invoice_view');
|
||||
break;
|
||||
|
||||
case 'purchaseOrder':
|
||||
|
|
@ -34,7 +34,26 @@ switch($docType) {
|
|||
</div>
|
||||
|
||||
|
||||
<div id="lineItemModal" title="Add Line Item">
|
||||
<div id="addLineItemModal" title="Add Line Item">
|
||||
</div>
|
||||
|
||||
<span id="documentID"><?=$document['Document']['id']?></span>
|
||||
<div id="editLineItemModal" title="Edit Line Item">
|
||||
</div>
|
||||
|
||||
<div id="QuoteDetails">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="InvoiceDetails">
|
||||
|
||||
</div>
|
||||
|
||||
<span id="documentID" style="display:none;"><?=$document['Document']['id']?></span>
|
||||
|
||||
<?php // debug($currency);?>
|
||||
<?php //debug($docType);?>
|
||||
|
||||
<?php //debug($enquiry);?>
|
||||
|
||||
<?php debug($document);?>
|
||||
|
|
@ -5,13 +5,28 @@
|
|||
<div id="lineItemDetails">
|
||||
<?
|
||||
echo $form->create('LineItem', array('default'=>false));
|
||||
echo $form->input('LineItem.id');
|
||||
echo $form->input('LineItem.document_id', array('type'=>'hidden', 'value'=>$document['Document']['id']));
|
||||
echo $form->input('LineItem.item_number');
|
||||
echo $form->input('LineItem.option');
|
||||
echo $form->input('LineItem.quantity');
|
||||
echo $form->input('LineItem.item_number', array('class'=>'number_input'));
|
||||
echo $form->input('LineItem.option', array('type'=>'select','options'=>$yesNo));
|
||||
echo $form->input('LineItem.quantity', array('class'=>'number_input quickpricing'));
|
||||
echo $form->input('LineItem.title');
|
||||
echo $form->input('LineItem.description');
|
||||
echo $form->input('LineItem.product_id', array('type'=>'hidden'));
|
||||
|
||||
?>
|
||||
<div id="noCosting">
|
||||
<?
|
||||
echo $form->input('gross_unit_price', array('class'=>'number_input quickpricing'));
|
||||
echo $form->input('discount_percent', array('class'=>'number_input quickpricing'));
|
||||
echo $form->input('discount_amount_unit', array('class'=>'number_input quickpricing'));
|
||||
echo $form->input('net_unit_price', array('class'=>'number_input quickpricing'));
|
||||
echo $form->input('gross_price', array('class'=>'number_input quickpricing'));
|
||||
echo $form->input('discount_amount_total', array('class'=>'number_input quickpricing'));
|
||||
echo $form->input('net_price', array('class'=>'number_input quickpricing'));
|
||||
?>
|
||||
</div>
|
||||
<?
|
||||
echo $form->end();
|
||||
?>
|
||||
|
||||
|
|
|
|||
21
views/elements/document_invoice_view.ctp
Normal file
21
views/elements/document_invoice_view.ctp
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<h2>Invoice: <?=$document['Invoice']['title']?></h2>
|
||||
|
||||
<?
|
||||
|
||||
echo $form->create('Document',array('type'=>'post','action'=>'edit', 'default'=>false));
|
||||
echo $form->input('Document.id');
|
||||
?>
|
||||
|
||||
<div class="docButtons">
|
||||
<button id="addLineItem">Add Line Item</button>
|
||||
</div>
|
||||
|
||||
<div id="flashMessage" class="message">
|
||||
</div>
|
||||
|
||||
<span id="invoiceID" style="display: none;"><?=$document['Invoice']['id']?></span>
|
||||
|
||||
<? //debug($this->data);?>
|
||||
<? //debug($enquiry);?>
|
||||
<?php //debug($document);?>
|
||||
<?php //debug($docType);?>
|
||||
|
|
@ -1,9 +1,13 @@
|
|||
<h2>Quote: <?=$enquiry['Enquiry']['title']?> <?
|
||||
<h2>Quote: <?=$html->link($enquiry['Enquiry']['title'], array('controller'=>'enquiries','action'=>'view',$enquiry['Enquiry']['id']));?> <?
|
||||
if($document['Quote']['revision'] > 0) {
|
||||
echo "Revision {$document['Quote']['revision']}";
|
||||
}
|
||||
?>
|
||||
for
|
||||
<?=$html->link($enquiry['Customer']['name'], array('controller'=>'customers','action'=>'view',$enquiry['Customer']['id']));?>
|
||||
</h2>
|
||||
|
||||
|
||||
<?
|
||||
|
||||
echo $form->create('Document',array('type'=>'post','action'=>'edit', 'default'=>false));
|
||||
|
|
@ -13,6 +17,7 @@ echo $form->input('Document.id');
|
|||
<div class="docButtons">
|
||||
<button id="addPage">Add Content Page</button>
|
||||
<button id="addLineItem">Add Line Item</button>
|
||||
<button id="editQuoteDetails">View/Edit Quote Details</button>
|
||||
</div>
|
||||
|
||||
<div id="flashMessage" class="message">
|
||||
|
|
@ -33,6 +38,15 @@ echo $form->input('Document.id');
|
|||
<div class="input submit"><button id="savePages">Save Pages</button></div>
|
||||
<?=$form->end();?>
|
||||
|
||||
<span id="quoteID" style="display: none;"><?=$document['Quote']['id']?></span>
|
||||
|
||||
<div id="commCommentsInitialString" style="display:none;">
|
||||
<u>Commercial Comments:</u><br />
|
||||
<span style="font-size: small;">The prices quoted are subject to our Standard Terms and Conditions of Sale dated 1/7/06 that is attached and remain firm unless specifically varied in writing. The prices above are based on the following:</span>
|
||||
<ol class="commList">
|
||||
</ol>
|
||||
<span style="font-size: small;">ANY VARIATIONS ON ITEMS 5. TO 7. WILL BE TO YOUR ACCOUNT. THIS QUOTATION IS BASED ON QUANTITIES STATED AND IS SUBJECT TO CHANGE IF QUANTITIES VARY.</span>
|
||||
</div>
|
||||
|
||||
<? //debug($this->data);?>
|
||||
<? //debug($enquiry);?>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php echo $javascript->link('jquery.jeditable.mini'); ?>
|
||||
|
||||
<?=$javascript->link('ajax_pagination_enquiry'); ?>
|
||||
<? //$javascript->link('ajax_pagination_enquiry'); ?>
|
||||
|
||||
|
||||
<?php echo $paginator->options(array('url'=>$this->passedArgs)); ?>
|
||||
|
|
|
|||
85
views/elements/line_items_table.ctp
Normal file
85
views/elements/line_items_table.ctp
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
<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>
|
||||
<?foreach($document['LineItem'] as $li):?>
|
||||
<tr nobr="true">
|
||||
<td width="<?=$colWidths['item'];?>" align="center">
|
||||
<? if($li['option'] == 1) {
|
||||
echo 'Option<br>';
|
||||
}
|
||||
?>
|
||||
<?=$li['item_number'];?></td>
|
||||
<td width="<?=$colWidths['qty'];?>" align="center"><?=$li['quantity'];?></td>
|
||||
<td width="<?=$colWidths['desc'];?>"><?=$li['title'];?>
|
||||
<?=$li['description'];?>
|
||||
</td>
|
||||
<td width="<?=$colWidths['unit'];?>" align="center">
|
||||
|
||||
<?=$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">
|
||||
<?=$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;?>
|
||||
|
||||
|
||||
<tr>
|
||||
<td width="<?=$colWidths['item'];?>"></td>
|
||||
<td width="<?=$colWidths['qty'];?>"></td>
|
||||
<td width="<?=$colWidths['desc'];?>"><?=$totalsDescText['subtotal']?></td>
|
||||
<td width="<?=$colWidths['unit'];?>"></td>
|
||||
<td width="<?=$colWidths['total'];?>" align="center"><?=$number->currency($totals['subtotal'], $currencyCode);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="<?=$colWidths['item'];?>"></td>
|
||||
<td width="<?=$colWidths['qty'];?>"></td>
|
||||
<td width="<?=$colWidths['desc'];?>"><?=$totalsDescText['gst'];?></td>
|
||||
<td width="<?=$colWidths['unit'];?>"></td>
|
||||
<td width="<?=$colWidths['total'];?>" align="center"><?
|
||||
if($gst ==1) {
|
||||
echo $number->currency($totals['gst'], $currencyCode);
|
||||
}
|
||||
else {
|
||||
echo 'N/A';
|
||||
}?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="<?=$colWidths['item'];?>"></td>
|
||||
<td width="<?=$colWidths['qty'];?>"></td>
|
||||
<td width="<?=$colWidths['desc'];?>"><?=$totalsDescText['total'];?></td>
|
||||
<td width="<?=$colWidths['unit'];?>" align="center"><?=$currencyCode?></td>
|
||||
<td width="<?=$colWidths['total'];?>" align="center"><?=$number->currency($totals['total'], $currencyCode);?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
<td><?php echo $time->nice($quote['Quote']['created']);?></td>
|
||||
<td class="actions">
|
||||
|
||||
<?php echo $html->link(__('View', true), array('controller'=> 'quotes', 'action'=>'view', $quote['Quote']['id'])); ?>
|
||||
<?php echo $html->link(__('View', true), array('controller'=> 'documents', 'action'=>'view', $quote['Quote']['document_id'])); ?>
|
||||
<?php echo $html->link(__('Revise', true), array('controller'=>'quotes', 'action'=>'revise', $quote['Quote']['id'])); ?>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<div id="ajaxLoad" style="display:none;"><?php echo $html->image('ajax-loader.gif'); ?></div>
|
||||
<div id="enquiryTable">
|
||||
<div class="enquiriesindex">
|
||||
<h2><?php __('Master Enquiry Register');?></h2>
|
||||
|
||||
<div id="enquiryTable">
|
||||
<h2><?php __('Master Enquiry Register');?></h2>
|
||||
<div class="enquiriesindex">
|
||||
<? echo $this->element('enquiry_table', $enquiries, $status_list); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -123,7 +123,14 @@ $class = ' class="altrow"';?>
|
|||
*/?>
|
||||
|
||||
<div class="related">
|
||||
<h3><?php __($number_of_quotes.' Quotes in this Enquiry');?></h3>
|
||||
<h3><?php if($enquiry['Enquiry']['quote_count'] > 1) {
|
||||
echo $enquiry['Enquiry']['quote_count'].' Quotes for this Enquiry';
|
||||
}
|
||||
else {
|
||||
echo $enquiry['Enquiry']['quote_count'].' Quote for this Enquiry';
|
||||
|
||||
}?>
|
||||
</h3>
|
||||
<?php echo $this->element('quote_table', $quotes); ?>
|
||||
</div>
|
||||
|
||||
|
|
@ -310,5 +317,5 @@ $class = ' class="altrow"';?>
|
|||
</div>
|
||||
|
||||
|
||||
|
||||
<?php debug($emails); ?>
|
||||
<?php // debug($enquiry);?>
|
||||
<?php //debug($emails); ?>
|
||||
0
views/line_items/ajax_delete.ctp
Normal file
0
views/line_items/ajax_delete.ctp
Normal file
0
views/line_items/ajax_edit.ctp
Normal file
0
views/line_items/ajax_edit.ctp
Normal file
|
|
@ -13,7 +13,7 @@ $(function() {
|
|||
<th>ITEM<br>NO.</th>
|
||||
<th>QTY</th>
|
||||
<th>DESCRIPTION</th>
|
||||
<th>UNIT<br.PRICE</th>
|
||||
<th>UNIT<br>PRICE</th>
|
||||
<th>TOTAL<br>PRICE</th>
|
||||
<th>ACTIONS</th>
|
||||
</tr>
|
||||
|
|
@ -21,30 +21,76 @@ $(function() {
|
|||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th><?=$currencies[$document['Quote']['currency_id']]?></th>
|
||||
<th><?=$currencies[$document['Quote']['currency_id']]?></th>
|
||||
<th><?=$currencyCode?></th>
|
||||
<th><?=$currencyCode?></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?foreach($document['LineItem'] as $li):?>
|
||||
<tr>
|
||||
<td><?=$li['item_number'];?></td>
|
||||
<tr class="lineItem">
|
||||
<td>
|
||||
<? if($li['option'] == 1) {
|
||||
echo 'Option<br>';
|
||||
}
|
||||
?>
|
||||
<?=$li['item_number'];?></td>
|
||||
<td><?=$li['quantity'];?></td>
|
||||
<td class="description"><?=$li['title'];?>
|
||||
<?=$li['description'];?>
|
||||
</td>
|
||||
<td>
|
||||
<?=$li['unit_price'];?>
|
||||
<td class="price">
|
||||
|
||||
<?=$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>
|
||||
<?=$li['gross_price'];?>
|
||||
<td class="price">
|
||||
<?=$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>
|
||||
<td>
|
||||
<td id="<?=$li['id'];?>">
|
||||
<button class="editLineItem">Edit</button><br>
|
||||
<button class="removeLineItem">Remove</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?endforeach;?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="leftAlign">SUB-TOTAL (Excluding GST)</td>
|
||||
<td></td>
|
||||
<td><?=$number->currency($totals['subtotal'], $currencyCode);?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="leftAlign">GST (10%)</td>
|
||||
<td></td>
|
||||
<td><?=$number->currency($totals['gst'], $currencyCode);?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="leftAlign">TOTAL PAYABLE (INCLUDING GST)</td>
|
||||
<td></td>
|
||||
<td><?=$number->currency($totals['total'], $currencyCode);?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
|
@ -66,9 +66,10 @@
|
|||
|
||||
<div class="related">
|
||||
<h3><?php __('Related Enquiries');?></h3>
|
||||
<?php if (!empty($principle['Enquiry'])):?>
|
||||
|
||||
<div id="enquiryTable">
|
||||
<? echo $this->element('enquiry_table', $enquiries); ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<ul>
|
||||
|
|
@ -117,8 +118,8 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<? echo $javascript->link('add_user'); ?>
|
||||
<div id="addUserDiv">
|
||||
<? //echo $javascript->link('add_user'); ?>
|
||||
<div id="addUserDiv" style="display: none;">
|
||||
|
||||
<?php echo $form->create('User');?>
|
||||
|
||||
|
|
@ -141,4 +142,4 @@
|
|||
|
||||
|
||||
</div>
|
||||
<?php debug($principleContacts); ?>
|
||||
<?php debug($principle); ?>
|
||||
0
views/quotes/ajax_edit.ctp
Normal file
0
views/quotes/ajax_edit.ctp
Normal file
|
|
@ -1,12 +1,16 @@
|
|||
<div class="quotes form">
|
||||
<?php echo $form->create('Quote');?>
|
||||
<fieldset>
|
||||
<legend><?php __('Edit Quote');?></legend>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$("button").button();
|
||||
});
|
||||
|
||||
</script>
|
||||
<?php
|
||||
echo $form->create('Quote',array('default'=>false));
|
||||
|
||||
echo $form->input('id');
|
||||
echo $form->input('enquiry_id');
|
||||
echo $form->input('enquiry_id', array('type'=>'hidden'));
|
||||
echo $form->input('currency_id');
|
||||
echo $form->input('revision');
|
||||
echo $form->input('revision', array('type'=>'hidden'));
|
||||
echo $form->input('delivery_time');
|
||||
echo $form->input('payment_terms');
|
||||
echo $form->input('days_valid');
|
||||
|
|
@ -15,20 +19,8 @@
|
|||
echo $form->input('delivery_point');
|
||||
echo $form->input('exchange_rate');
|
||||
echo $form->input('customs_duty');
|
||||
echo $form->input('document_id');
|
||||
echo $form->input('document_id',array('type'=>'hidden'));
|
||||
echo $form->input('commercial_comments', array('between'=>'<button class="generateCommercialComments">(re)Generate Commercial Comments</button>'));
|
||||
|
||||
echo $form->end();
|
||||
?>
|
||||
</fieldset>
|
||||
<?php echo $form->end('Submit');?>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<li><?php echo $html->link(__('Delete', true), array('action' => 'delete', $form->value('Quote.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('Quote.id'))); ?></li>
|
||||
<li><?php echo $html->link(__('List Quotes', true), array('action' => 'index'));?></li>
|
||||
<li><?php echo $html->link(__('List Enquiries', true), array('controller' => 'enquiries', 'action' => 'index')); ?> </li>
|
||||
<li><?php echo $html->link(__('New Enquiry', true), array('controller' => 'enquiries', 'action' => 'add')); ?> </li>
|
||||
<li><?php echo $html->link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?> </li>
|
||||
<li><?php echo $html->link(__('New Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?> </li>
|
||||
<li><?php echo $html->link(__('List Documents', true), array('controller' => 'documents', 'action' => 'index')); ?> </li>
|
||||
<li><?php echo $html->link(__('New Document', true), array('controller' => 'documents', 'action' => 'add')); ?> </li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ foreach ($quote['QuotePage'] as $page) {
|
|||
}
|
||||
|
||||
|
||||
$tcpdf->DetailsBox($enquiry['Customer']['name'], $enquiry['Contact']['email'], $enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'],
|
||||
$tcpdf->DetailsBox($docTypeFullName, $enquiry['Customer']['name'], $enquiry['Contact']['email'], $enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'],
|
||||
$enquiry['User']['first_name'].' '.$enquiry['User']['last_name'], $enquiry['User']['email'], $cmcRef,
|
||||
$enquiry['Enquiry']['customer_reference'], $quote['Quote']['date_issued']);
|
||||
|
||||
|
|
|
|||
|
|
@ -786,6 +786,10 @@ input#searchbox {
|
|||
}
|
||||
|
||||
|
||||
input.number_input {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
select {
|
||||
clear: both;
|
||||
font-size: 120%;
|
||||
|
|
@ -1534,3 +1538,14 @@ table.lineItems tr td.description {
|
|||
text-align: left;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
table.lineItems tr td.leftAlign {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
|
||||
table.lineItems tr td.price {
|
||||
padding-left: 0.5em;
|
||||
padding-right: 0.5em;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
|
@ -1,4 +1,11 @@
|
|||
|
||||
/**
|
||||
* Could (should) tidy this up to move the Quote/Invoice etc Specific
|
||||
* functionality into seperate files.
|
||||
*
|
||||
* Will do this at some point. Today I just need to hammer this out.
|
||||
*
|
||||
* Karl - 20/5/2011
|
||||
*/
|
||||
|
||||
|
||||
$(function() {
|
||||
|
|
@ -11,18 +18,15 @@ $(function() {
|
|||
|
||||
$("#lineItemDetails").hide();
|
||||
|
||||
$( "#lineItemModal" ).dialog({
|
||||
$( "#addLineItemModal" ).dialog({
|
||||
autoOpen: false,
|
||||
height: 900,
|
||||
width: 600,
|
||||
modal: true,
|
||||
buttons: {
|
||||
"Add Line Item": function() {
|
||||
/*for ( instance in CKEDITOR.instances ) {
|
||||
CKEDITOR.instances[instance].updateElement();
|
||||
CKEDITOR.instances[instance].destroy();
|
||||
}*/
|
||||
$('#LineItemDescription').ckeditor(function() {
|
||||
|
||||
$('#QuoteCommercialComments').ckeditor(function() {
|
||||
this.updateElement();
|
||||
this.destroy();
|
||||
});
|
||||
|
|
@ -31,14 +35,47 @@ $(function() {
|
|||
var thisLineItemInputs = $('#LineItemAddForm').find('input,select,textarea');
|
||||
|
||||
$.post('/line_items/ajax_add', thisLineItemInputs, function(data) {
|
||||
$( "#lineItemModal" ).dialog('close');
|
||||
loadLineItems();
|
||||
$( "#addLineItemModal" ).dialog('close');
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
Cancel: function() {
|
||||
$( this ).dialog( "close" );
|
||||
|
||||
}
|
||||
},
|
||||
close: function() {
|
||||
loadLineItems();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$( "#editLineItemModal" ).dialog({
|
||||
autoOpen: false,
|
||||
height: 900,
|
||||
width: 600,
|
||||
modal: true,
|
||||
buttons: {
|
||||
"Edit Line Item": function() {
|
||||
|
||||
$('#LineItemDescription').ckeditor(function() {
|
||||
this.updateElement();
|
||||
this.destroy();
|
||||
});
|
||||
|
||||
|
||||
var thisLineItemInputs = $('#LineItemEditForm').find('input,select,textarea');
|
||||
|
||||
$.post('/line_items/ajax_edit', thisLineItemInputs, function(data) {
|
||||
$( "#editLineItemModal" ).dialog('close');
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
Cancel: function() {
|
||||
$( "#editLineItemModal" ).dialog('close');
|
||||
|
||||
}
|
||||
},
|
||||
close: function() {
|
||||
|
|
@ -48,6 +85,37 @@ $(function() {
|
|||
});
|
||||
|
||||
|
||||
$( "#QuoteDetails" ).dialog({
|
||||
autoOpen: false,
|
||||
height: 900,
|
||||
width: 600,
|
||||
modal: true,
|
||||
buttons: {
|
||||
"Edit Quote Details": function() {
|
||||
|
||||
|
||||
$('#QuoteCommercialComments').ckeditor(function() {
|
||||
this.updateElement();
|
||||
this.destroy();
|
||||
});
|
||||
|
||||
|
||||
var quoteInputs = $('#QuoteEditForm').find('input,select,textarea');
|
||||
|
||||
$.post('/quotes/ajax_edit', quoteInputs, function(data) {
|
||||
$( "#QuoteDetails" ).dialog('close');
|
||||
});
|
||||
|
||||
},
|
||||
Cancel: function() {
|
||||
$( this ).dialog( "close" );
|
||||
|
||||
}
|
||||
},
|
||||
close: function() {
|
||||
loadLineItems();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$("#pageContentFactory").hide();
|
||||
|
|
@ -98,13 +166,29 @@ $(function() {
|
|||
//Open the LineItem dialog
|
||||
$("#addLineItem").button().click(function() {
|
||||
|
||||
|
||||
|
||||
var docID = $('#documentID').html();
|
||||
|
||||
$('#LineItemDescription').ckeditor(function() {
|
||||
this.destroy();
|
||||
});
|
||||
|
||||
$("#editLineItemModal").empty();
|
||||
|
||||
var nextItemNo = $(".lineItem").length;
|
||||
nextItemNo++;
|
||||
|
||||
$.get('/line_items/add/'+docID, function(data) {
|
||||
$("#lineItemModal").html(data);
|
||||
$("#addLineItemModal").html(data);
|
||||
|
||||
|
||||
$("#LineItemItemNumber").val(nextItemNo); //Auto fill in the next Item No
|
||||
|
||||
|
||||
$("#productDetails").hide();
|
||||
$('#LineItemDescription').ckeditor(config);
|
||||
$( "#lineItemModal" ).dialog('open');
|
||||
$( "#addLineItemModal" ).dialog('open');
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -112,6 +196,25 @@ $(function() {
|
|||
});
|
||||
|
||||
|
||||
$(".editLineItem").live('click', function() {
|
||||
|
||||
|
||||
$('#LineItemDescription').ckeditor(function() {
|
||||
this.destroy();
|
||||
});
|
||||
|
||||
$("#addLineItemModal").empty();
|
||||
|
||||
var thisLineItemID = $(this).parent('td').attr('id');
|
||||
$.get('/line_items/edit/'+thisLineItemID, function(data) {
|
||||
$("#editLineItemModal").html(data);
|
||||
$("#productDetails").hide();
|
||||
$('#LineItemDescription').ckeditor(config);
|
||||
$( "#editLineItemModal" ).dialog('open');
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$("#principleSelect").live('change',function() {
|
||||
|
||||
|
|
@ -183,9 +286,75 @@ $(function() {
|
|||
|
||||
});
|
||||
|
||||
|
||||
$(".quickpricing").live('change', function() {
|
||||
calculateQuickPrices();
|
||||
});
|
||||
|
||||
|
||||
$('.removeLineItem').live('click', function() {
|
||||
var thisLineItemID = $(this).parent('td').attr('id');
|
||||
$.post('/line_items/ajax_delete/'+thisLineItemID, function(data) {
|
||||
loadLineItems();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$("#editQuoteDetails").click(function() {
|
||||
var quoteID = $("#quoteID").html();
|
||||
|
||||
$('#QuoteCommercialComments').ckeditor(function() {
|
||||
this.destroy();
|
||||
});
|
||||
|
||||
$.get('/quotes/edit/'+quoteID, function(data) {
|
||||
|
||||
|
||||
|
||||
$("#QuoteDetails").html(data);
|
||||
|
||||
$('#QuoteCommercialComments').ckeditor(config);
|
||||
|
||||
$("#QuoteDetails").dialog('open');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('.generateCommercialComments').live('click', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
|
||||
|
||||
var deliveryTime = $("#QuoteDeliveryTime").val();
|
||||
var paymentTerms = $("#QuotePaymentTerms").val();
|
||||
var daysValid = $("#QuoteDaysValid").val();
|
||||
var deliveryPoint = $("#QuoteDeliveryPoint").val();
|
||||
var exchangeRate = $("#QuoteExchangeRate").val();
|
||||
var customsDuty = $("#QuoteCustomsDuty").val();
|
||||
|
||||
|
||||
deliveryTime = deliveryTime.toUpperCase();
|
||||
paymentTerms = paymentTerms.toUpperCase();
|
||||
deliveryPoint = deliveryPoint.toUpperCase();
|
||||
|
||||
var commComments = $("#commCommentsInitialString").clone();
|
||||
|
||||
var commList = commComments.find('ol');
|
||||
|
||||
commList.append('<li>DELIVERY IS ESTIMATED AT '+deliveryTime+ 'FROM RECEIPT OF YOUR TECHNICALLY AND COMMERCIALLY CLEAR ORDER');
|
||||
commList.append('<li>PAYMENT TERMS:'+paymentTerms+'</li>');
|
||||
commList.append('<li>QUOTATION IS VALID <u>FOR '+daysValid+' DAYS</li>');
|
||||
commList.append('<li>ALL PRICES ARE <u>'+deliveryPoint+'</u></li>');
|
||||
commList.append('<li>EXCHANGE RATE:'+exchangeRate+'</u></li>');
|
||||
commList.append('<li>CUSTOMS DUTY INCLUDED AT: '+customsDuty+'</li>');
|
||||
commList.append('<li>GST 10% EXTRA</li>');
|
||||
commList.append('<li>WHEN PAYMENTS ARE MADE INTO OUR BANK ACCOUNT, BANK CHARGES ARE YOUR RESPONSIBILITY</li>');
|
||||
$('#QuoteCommercialComments').val(commComments.html());
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
function loadLineItems() {
|
||||
var documentID = $("#documentID").html();
|
||||
|
|
@ -195,3 +364,76 @@ function loadLineItems() {
|
|||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
function calculateQuickPrices() {
|
||||
|
||||
var quantity = $('#LineItemQuantity').val();
|
||||
|
||||
var gross_unit_price = $("#LineItemGrossUnitPrice").val();
|
||||
var net_unit_price = $("#LineItemNetUnitPrice").val();
|
||||
var discount_percent = $("#LineItemDiscountPercent").val();
|
||||
var discount_amount_unit = $("#LineItemDiscountAmountUnit").val();
|
||||
var discount_amount_total = $("#LineItemDiscountAmountTotal").val();
|
||||
var gross_price = $("#LineItemGrossPrice").val();
|
||||
var net_price = $("#LineItemNetPrice").val();
|
||||
|
||||
gross_price = quantity * gross_unit_price;
|
||||
$("#LineItemGrossPrice").val(gross_price);
|
||||
|
||||
discount_amount_unit = (discount_percent/100) * gross_unit_price;
|
||||
discount_amount_unit = discount_amount_unit.toFixed(2);
|
||||
|
||||
discount_amount_total = (discount_percent/100) * gross_price;
|
||||
discount_amount_total = discount_amount_total.toFixed(2);
|
||||
$("#LineItemDiscountAmountTotal").val(discount_amount_total);
|
||||
|
||||
net_price = gross_price - discount_amount_total;
|
||||
$("#LineItemNetPrice").val(net_price);
|
||||
|
||||
|
||||
$("#LineItemDiscountAmountUnit").val(discount_amount_unit);
|
||||
net_unit_price = gross_unit_price - discount_amount_unit;
|
||||
$("#LineItemNetUnitPrice").val(net_unit_price);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function calcNetPrice() {
|
||||
var discountPercent = $("#discountPercent").val();
|
||||
var unitPrice = $('#unitPrice').val();
|
||||
|
||||
|
||||
var quantity = $('#LineItemQuantity').val();
|
||||
|
||||
|
||||
var grossSellPrice = quantity * unitPrice;
|
||||
|
||||
//Calculate the Sale Discount amount.
|
||||
var UnitDiscountAmount = (discountPercent/100) * unitPrice;
|
||||
|
||||
var TotalDiscountAmount = (discountPercent/100) * grossSellPrice;
|
||||
UnitDiscountAmount = UnitDiscountAmount.toFixed(2);
|
||||
TotalDiscountAmount = TotalDiscountAmount.toFixed(2);
|
||||
|
||||
$('#total_discountAmount').val(TotalDiscountAmount);
|
||||
$('#discountAmountEach').val(UnitDiscountAmount);
|
||||
$('#net_price_each').val(unitPrice - UnitDiscountAmount);
|
||||
|
||||
$('#grossPrice').val(grossSellPrice);
|
||||
|
||||
var netPrice = grossSellPrice - TotalDiscountAmount;
|
||||
$('#netPrice').val(netPrice);
|
||||
|
||||
}
|
||||
|
||||
function checkNaN(value) {
|
||||
if( isNaN(value) == true) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ var config = {
|
|||
['Image','Table','HorizontalRule','SpecialChar'],
|
||||
'/',
|
||||
['Styles','Format'],
|
||||
['Bold','Italic','Strike'],
|
||||
['Bold','Italic','Strike','Underline'],
|
||||
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
|
||||
['Link','Unlink'],
|
||||
['Maximize','-','About']
|
||||
|
|
|
|||
Loading…
Reference in a new issue