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 {
|
class DocumentsController extends AppController {
|
||||||
|
|
||||||
var $name = 'Documents';
|
var $name = 'Documents';
|
||||||
var $helpers = array('Html', 'Form');
|
var $helpers = array('Html', 'Form', 'Number');
|
||||||
|
|
||||||
function index() {
|
function index() {
|
||||||
$this->Document->recursive = 0;
|
$this->Document->recursive = 0;
|
||||||
|
|
@ -14,28 +14,14 @@ class DocumentsController extends AppController {
|
||||||
$this->Session->setFlash(__('Invalid Document.', true));
|
$this->Session->setFlash(__('Invalid Document.', true));
|
||||||
$this->redirect(array('action'=>'index'));
|
$this->redirect(array('action'=>'index'));
|
||||||
}
|
}
|
||||||
$document = $this->Document->read(null, $id);
|
$document = $this->Document->read(null,$id);
|
||||||
|
//$document = $this->Document->find('first',array('conditions'=>array('Document.id'=>$id), 'recursive'=>2));
|
||||||
$this->set('document', $document);
|
$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->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'));
|
// $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['Quote']['revision'] = $number_of_revisions;
|
||||||
|
|
||||||
$this->data['Document']['user_id']= $enquiry['Enquiry']['user_id'];
|
$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)) {
|
if ($this->Document->saveAll($this->data)) {
|
||||||
|
|
@ -113,7 +99,7 @@ class DocumentsController extends AppController {
|
||||||
$enquiryid = $id;
|
$enquiryid = $id;
|
||||||
$this->Document->create();
|
$this->Document->create();
|
||||||
|
|
||||||
$enquiry = $this->Document->Enquiry->findById($id);
|
$enquiry = $this->Document->Quote->Enquiry->findById($id);
|
||||||
|
|
||||||
$this->data['Document']['enquiry_id'] = $enquiryid;
|
$this->data['Document']['enquiry_id'] = $enquiryid;
|
||||||
|
|
||||||
|
|
@ -124,13 +110,8 @@ class DocumentsController extends AppController {
|
||||||
$newInvoiceNumber = $invoice_number_offset + $number_of_invoices;
|
$newInvoiceNumber = $invoice_number_offset + $number_of_invoices;
|
||||||
|
|
||||||
$this->data['Invoice']['title'] = "CMCIN".$newInvoiceNumber;
|
$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']['user_id']= $enquiry['Enquiry']['user_id'];
|
||||||
$this->data['Document']['contact_id']= $enquiry['Enquiry']['contact_id'];
|
$this->data['Document']['type'] = 'invoice';
|
||||||
$this->data['Page'][0]['page_number'] = 1;
|
|
||||||
$this->data['Page'][0]['contentPage'] = 0;
|
|
||||||
|
|
||||||
if ($this->Document->saveAll($this->data)) {
|
if ($this->Document->saveAll($this->data)) {
|
||||||
$newid = $this->Document->id;
|
$newid = $this->Document->id;
|
||||||
|
|
@ -172,7 +153,7 @@ class DocumentsController extends AppController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function ajax_edit($id=null) {
|
function ajax_edit($id = null) {
|
||||||
$this->layout = 'ajax';
|
$this->layout = 'ajax';
|
||||||
|
|
||||||
if (!$id && empty($this->data)) {
|
if (!$id && empty($this->data)) {
|
||||||
|
|
@ -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) {
|
/*function delete($id = null) {
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
$this->Session->setFlash(__('Invalid id for Document', true));
|
$this->Session->setFlash(__('Invalid id for Document', true));
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,6 @@ class EnquiriesController extends AppController {
|
||||||
$this->pageTitle = "Enquiry: ".$enquiry['Enquiry']['title'];
|
$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('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']));
|
$this->set('principle_emails', $this->Enquiry->Principle->PrincipleContact->findAllByPrincipleId($enquiry['Enquiry']['principle_id']));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
class LineItemsController extends AppController {
|
class LineItemsController extends AppController {
|
||||||
|
|
||||||
var $name = 'LineItems';
|
var $name = 'LineItems';
|
||||||
var $helpers = array('Html', 'Form', 'Javascript');
|
var $helpers = array('Html', 'Form', 'Javascript', 'Number');
|
||||||
|
|
||||||
var $components = array('RequestHandler');
|
var $components = array('RequestHandler');
|
||||||
|
|
||||||
|
|
@ -13,7 +13,27 @@ class LineItemsController extends AppController {
|
||||||
if(!empty($this->data)) {
|
if(!empty($this->data)) {
|
||||||
$this->LineItem->create($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";
|
echo "SUCCESS";
|
||||||
}
|
}
|
||||||
else {
|
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) {
|
function getTable($documentID = null) {
|
||||||
$this->layout = 'ajax';
|
$this->layout = 'ajax';
|
||||||
if($documentID == null) {
|
if($documentID == null) {
|
||||||
|
|
@ -36,19 +71,35 @@ class LineItemsController extends AppController {
|
||||||
$document = $this->LineItem->Document->find('first',array('conditions'=>array('Document.id'=>$documentID)));
|
$document = $this->LineItem->Document->find('first',array('conditions'=>array('Document.id'=>$documentID)));
|
||||||
$this->set('document',$document);
|
$this->set('document',$document);
|
||||||
|
|
||||||
$currencies = $this->LineItem->Document->Quote->Currency->find('list', array('fields'=>array('Currency.id','Currency.iso4217')));
|
$enquiry = $this->LineItem->Document->getEnquiry($document);
|
||||||
$this->set('currencies',$currencies);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$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) {
|
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) {
|
function add($documentID = null) {
|
||||||
|
$this->layout = 'ajax';
|
||||||
$document = $this->LineItem->Document->read(null, $documentID);
|
$document = $this->LineItem->Document->read(null, $documentID);
|
||||||
$this->set('document', $document);
|
$this->set('document', $document);
|
||||||
|
$this->set('yesNo', array(0=>'No', 1=>'Yes'));
|
||||||
$this->set('principles', $this->LineItem->Product->Principle->find('list'));
|
$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'));
|
$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() {
|
function add() {
|
||||||
|
|
||||||
if(isset($this->params['named']['enquiryid'])) {
|
if(isset($this->params['named']['enquiryid'])) {
|
||||||
|
|
@ -46,11 +65,8 @@ class QuotesController extends AppController {
|
||||||
$this->data['Quote']['currency_id'] = 2;
|
$this->data['Quote']['currency_id'] = 2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($this->Quote->save($this->data)) {
|
if ($this->Quote->save($this->data)) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$quoteid = $this->Quote->id;
|
$quoteid = $this->Quote->id;
|
||||||
//$this->data['Document']['']
|
//$this->data['Document']['']
|
||||||
|
|
||||||
|
|
@ -73,6 +89,8 @@ class QuotesController extends AppController {
|
||||||
|
|
||||||
|
|
||||||
function edit($id = null) {
|
function edit($id = null) {
|
||||||
|
$this->layout = 'ajax';
|
||||||
|
|
||||||
if (!$id && empty($this->data)) {
|
if (!$id && empty($this->data)) {
|
||||||
$this->Session->setFlash(__('Invalid Quote', true));
|
$this->Session->setFlash(__('Invalid Quote', true));
|
||||||
$this->redirect(array('action'=>'index'));
|
$this->redirect(array('action'=>'index'));
|
||||||
|
|
@ -101,6 +119,7 @@ class QuotesController extends AppController {
|
||||||
}
|
}
|
||||||
$enquiry = $this->Quote->Enquiry->findById($quote['Quote']['enquiry_id']);
|
$enquiry = $this->Quote->Enquiry->findById($quote['Quote']['enquiry_id']);
|
||||||
$currencies = $this->Quote->Currency->find('list');
|
$currencies = $this->Quote->Currency->find('list');
|
||||||
|
$this->set('yesNo', array(0=>'No', 1=>'Yes'));
|
||||||
$this->set(compact('enquiry', 'quote', 'currencies'));
|
$this->set(compact('enquiry', 'quote', 'currencies'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -320,11 +339,6 @@ class QuotesController extends AppController {
|
||||||
$this->data['LineItem'][] = $item;
|
$this->data['LineItem'][] = $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($quote['QuotePage'] as $page) {
|
|
||||||
$page['id'] = null;
|
|
||||||
$page['quote_id'] = null;
|
|
||||||
$this->data['QuotePage'][] = $page;
|
|
||||||
}
|
|
||||||
|
|
||||||
//debug($this->data);
|
//debug($this->data);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -199,6 +199,9 @@ class ShipmentsController extends AppController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function markJobsSent() {
|
function markJobsSent() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ class Document extends AppModel {
|
||||||
'fields' => '',
|
'fields' => '',
|
||||||
'order' => ''
|
'order' => ''
|
||||||
)
|
)
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
var $hasMany = array(
|
var $hasMany = array(
|
||||||
|
|
@ -47,5 +46,110 @@ class Document extends AppModel {
|
||||||
'foreignKey'=>'document_id'
|
'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(
|
'Job' => array(
|
||||||
'className' => 'Job',
|
'className' => 'Job',
|
||||||
'foreignKey' => 'job_id'
|
'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',
|
'foreignKey' => 'enquiry_id',
|
||||||
'conditions' => '',
|
'conditions' => '',
|
||||||
'fields' => '',
|
'fields' => '',
|
||||||
'order' => ''
|
'order' => '',
|
||||||
|
'counterCache'=>true
|
||||||
),
|
),
|
||||||
|
|
||||||
'Currency' => array('className' => 'Currency', 'foreignKey' => 'currency_id'),
|
'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
|
<?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");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with 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'))
|
if (!defined('ORD_tilde'))
|
||||||
define('ORD_tilde', ord('~'));
|
define('ORD_tilde', ord('~'));
|
||||||
|
|
||||||
$__tmp = version_compare(phpversion(), "5") == -1 ? array('FilterASCII85') : array('FilterASCII85', false);
|
if (!class_exists('FilterASCII85', false)) {
|
||||||
if (!call_user_func_array('class_exists', $__tmp)) {
|
|
||||||
|
|
||||||
class FilterASCII85 {
|
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
|
<?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");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with 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;
|
var $fpdi;
|
||||||
|
|
||||||
function FPDI_FilterASCII85(&$fpdi) {
|
function FilterASCII85_FPDI(&$fpdi) {
|
||||||
$this->fpdi =& $fpdi;
|
$this->fpdi =& $fpdi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
9
vendors/fpdi/filters/FilterLZW.php
vendored
9
vendors/fpdi/filters/FilterLZW.php
vendored
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?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");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
|
@ -17,8 +17,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
$__tmp = version_compare(phpversion(), "5") == -1 ? array('FilterLZW') : array('FilterLZW', false);
|
if (!class_exists('FilterLZW', false)) {
|
||||||
if (!call_user_func_array('class_exists', $__tmp)) {
|
|
||||||
|
|
||||||
class FilterLZW {
|
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
|
<?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");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
128
vendors/fpdi/fpdf_tpl.php
vendored
128
vendors/fpdi/fpdf_tpl.php
vendored
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
//
|
//
|
||||||
// FPDF_TPL - Version 1.1.4
|
// FPDF_TPL - Version 1.2
|
||||||
//
|
//
|
||||||
// Copyright 2004-2010 Setasign - Jan Slabon
|
// Copyright 2004-2010 Setasign - Jan Slabon
|
||||||
//
|
//
|
||||||
|
|
@ -73,7 +73,12 @@ class FPDF_TPL extends FPDF {
|
||||||
* @param int $h The height given in user-unit
|
* @param int $h The height given in user-unit
|
||||||
* @return int The ID of new created Template
|
* @return int The ID of new created Template
|
||||||
*/
|
*/
|
||||||
function beginTemplate($x=null, $y=null, $w=null, $h=null) {
|
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)
|
if ($this->page <= 0)
|
||||||
$this->error("You have to add a page to fpdf first!");
|
$this->error("You have to add a page to fpdf first!");
|
||||||
|
|
||||||
|
|
@ -113,8 +118,8 @@ class FPDF_TPL extends FPDF {
|
||||||
$this->w = $w;
|
$this->w = $w;
|
||||||
|
|
||||||
$this->_intpl = true;
|
$this->_intpl = true;
|
||||||
$this->SetXY($x+$this->lMargin, $y+$this->tMargin);
|
$this->SetXY($x + $this->lMargin, $y + $this->tMargin);
|
||||||
$this->SetRightMargin($this->w-$w+$this->rMargin);
|
$this->SetRightMargin($this->w - $w + $this->rMargin);
|
||||||
|
|
||||||
return $this->tpl;
|
return $this->tpl;
|
||||||
}
|
}
|
||||||
|
|
@ -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.
|
* @return mixed If a template is opened, the ID is returned. If not a false is returned.
|
||||||
*/
|
*/
|
||||||
function endTemplate() {
|
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) {
|
if ($this->_intpl) {
|
||||||
$this->_intpl = false;
|
$this->_intpl = false;
|
||||||
$tpl =& $this->tpls[$this->tpl];
|
$tpl =& $this->tpls[$this->tpl];
|
||||||
|
|
@ -161,12 +171,12 @@ class FPDF_TPL extends FPDF {
|
||||||
* @param int $_h The new height of the template
|
* @param int $_h The new height of the template
|
||||||
* @retrun array The height and width of the template
|
* @retrun array The height and width of the template
|
||||||
*/
|
*/
|
||||||
function useTemplate($tplidx, $_x=null, $_y=null, $_w=0, $_h=0) {
|
function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) {
|
||||||
if ($this->page <= 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]))
|
if (!isset($this->tpls[$tplidx]))
|
||||||
$this->error("Template does not exist!");
|
$this->error('Template does not exist!');
|
||||||
|
|
||||||
if ($this->_intpl) {
|
if ($this->_intpl) {
|
||||||
$this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx];
|
$this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx];
|
||||||
|
|
@ -193,19 +203,26 @@ class FPDF_TPL extends FPDF {
|
||||||
'y' => $this->y,
|
'y' => $this->y,
|
||||||
'w' => $_w,
|
'w' => $_w,
|
||||||
'h' => $_h,
|
'h' => $_h,
|
||||||
'scaleX' => ($_w/$w),
|
'scaleX' => ($_w / $w),
|
||||||
'scaleY' => ($_h/$h),
|
'scaleY' => ($_h / $h),
|
||||||
'tx' => $_x,
|
'tx' => $_x,
|
||||||
'ty' => ($this->h-$_y-$_h),
|
'ty' => ($this->h - $_y - $_h),
|
||||||
'lty' => ($this->h-$_y-$_h) - ($this->h-$h) * ($_h/$h)
|
'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));
|
$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;
|
$this->lastUsedTemplateData = $tData;
|
||||||
|
|
||||||
return array("w" => $_w, "h" => $_h);
|
return array('w' => $_w, 'h' => $_h);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -218,7 +235,7 @@ class FPDF_TPL extends FPDF {
|
||||||
* @param int $_h The height of the template
|
* @param int $_h The height of the template
|
||||||
* @return array The height and width of the template
|
* @return array The height and width of the template
|
||||||
*/
|
*/
|
||||||
function getTemplateSize($tplidx, $_w=0, $_h=0) {
|
function getTemplateSize($tplidx, $_w = 0, $_h = 0) {
|
||||||
if (!$this->tpls[$tplidx])
|
if (!$this->tpls[$tplidx])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -231,10 +248,10 @@ class FPDF_TPL extends FPDF {
|
||||||
$_h = $h;
|
$_h = $h;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_w==0)
|
if($_w == 0)
|
||||||
$_w = $_h*$w/$h;
|
$_w = $_h * $w / $h;
|
||||||
if($_h==0)
|
if($_h == 0)
|
||||||
$_h = $_w*$h/$w;
|
$_h = $_w * $h / $w;
|
||||||
|
|
||||||
return array("w" => $_w, "h" => $_h);
|
return array("w" => $_w, "h" => $_h);
|
||||||
}
|
}
|
||||||
|
|
@ -242,19 +259,21 @@ class FPDF_TPL extends FPDF {
|
||||||
/**
|
/**
|
||||||
* See FPDF/TCPDF-Documentation ;-)
|
* See FPDF/TCPDF-Documentation ;-)
|
||||||
*/
|
*/
|
||||||
function SetFont($family, $style='', $size=0, $fontfile='') {
|
public function SetFont($family, $style = '', $size = 0) {
|
||||||
if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 3) {
|
if (is_subclass_of($this, 'TCPDF')) {
|
||||||
$this->Error('More than 3 arguments for the SetFont method are only available in TCPDF.');
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($this, 'TCPDF::SetFont'), $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* force the resetting of font changes in a template
|
* force the resetting of font changes in a template
|
||||||
*/
|
*/
|
||||||
if ($this->_intpl)
|
if ($this->_intpl)
|
||||||
$this->FontFamily = '';
|
$this->FontFamily = '';
|
||||||
|
|
||||||
parent::SetFont($family, $style, $size, $fontfile);
|
parent::SetFont($family, $style, $size);
|
||||||
|
|
||||||
$fontkey = $this->FontFamily.$this->FontStyle;
|
$fontkey = $this->FontFamily . $this->FontStyle;
|
||||||
|
|
||||||
if ($this->_intpl) {
|
if ($this->_intpl) {
|
||||||
$this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
|
$this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
|
||||||
|
|
@ -266,17 +285,20 @@ class FPDF_TPL extends FPDF {
|
||||||
/**
|
/**
|
||||||
* See FPDF/TCPDF-Documentation ;-)
|
* 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) {
|
function Image($file, $x = null, $y = null, $w = 0, $h = 0, $type = '', $link = '') {
|
||||||
if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 7) {
|
if (is_subclass_of($this, 'TCPDF')) {
|
||||||
$this->Error('More than 7 arguments for the Image method are only available in 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) {
|
if ($this->_intpl) {
|
||||||
$this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file];
|
$this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file];
|
||||||
} else {
|
} else {
|
||||||
$this->_res['page'][$this->page]['images'][$file] =& $this->images[$file];
|
$this->_res['page'][$this->page]['images'][$file] =& $this->images[$file];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -284,32 +306,50 @@ class FPDF_TPL extends FPDF {
|
||||||
*
|
*
|
||||||
* AddPage is not available when you're "in" a template.
|
* AddPage is not available when you're "in" a template.
|
||||||
*/
|
*/
|
||||||
function AddPage($orientation='', $format='') {
|
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)
|
if ($this->_intpl)
|
||||||
$this->Error('Adding pages in templates isn\'t possible!');
|
$this->Error('Adding pages in templates isn\'t possible!');
|
||||||
|
|
||||||
parent::AddPage($orientation, $format);
|
parent::AddPage($orientation, $format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preserve adding Links in Templates ...won't work
|
* Preserve adding Links in Templates ...won't work
|
||||||
*/
|
*/
|
||||||
function Link($x, $y, $w, $h, $link, $spaces=0) {
|
function Link($x, $y, $w, $h, $link) {
|
||||||
if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 5) {
|
if (is_subclass_of($this, 'TCPDF')) {
|
||||||
$this->Error('More than 5 arguments for the Image method are only available in TCPDF.');
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($this, 'TCPDF::Link'), $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->_intpl)
|
if ($this->_intpl)
|
||||||
$this->Error('Using links in templates aren\'t possible!');
|
$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() {
|
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)
|
if ($this->_intpl)
|
||||||
$this->Error('Adding links in templates aren\'t possible!');
|
$this->Error('Adding links in templates aren\'t possible!');
|
||||||
return parent::AddLink();
|
return parent::AddLink();
|
||||||
}
|
}
|
||||||
|
|
||||||
function SetLink($link, $y=0, $page=-1) {
|
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)
|
if ($this->_intpl)
|
||||||
$this->Error('Setting links in templates aren\'t possible!');
|
$this->Error('Setting links in templates aren\'t possible!');
|
||||||
parent::SetLink($link, $y, $page);
|
parent::SetLink($link, $y, $page);
|
||||||
|
|
@ -331,18 +371,18 @@ class FPDF_TPL extends FPDF {
|
||||||
$this->_out('/FormType 1');
|
$this->_out('/FormType 1');
|
||||||
$this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]',
|
$this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]',
|
||||||
// llx
|
// llx
|
||||||
$tpl['x']*$this->k,
|
$tpl['x'] * $this->k,
|
||||||
// lly
|
// lly
|
||||||
-$tpl['y']*$this->k,
|
-$tpl['y'] * $this->k,
|
||||||
// urx
|
// urx
|
||||||
($tpl['w']+$tpl['x'])*$this->k,
|
($tpl['w'] + $tpl['x']) * $this->k,
|
||||||
// ury
|
// ury
|
||||||
($tpl['h']-$tpl['y'])*$this->k
|
($tpl['h'] - $tpl['y']) * $this->k
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($tpl['x'] != 0 || $tpl['y'] != 0) {
|
if ($tpl['x'] != 0 || $tpl['y'] != 0) {
|
||||||
$this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]',
|
$this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]',
|
||||||
-$tpl['x']*$this->k*2, $tpl['y']*$this->k*2
|
-$tpl['x'] * $this->k * 2, $tpl['y'] * $this->k * 2
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -352,7 +392,7 @@ class FPDF_TPL extends FPDF {
|
||||||
if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
|
if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
|
||||||
$this->_out('/Font <<');
|
$this->_out('/Font <<');
|
||||||
foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
|
foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
|
||||||
$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
|
$this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
}
|
}
|
||||||
if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) ||
|
if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) ||
|
||||||
|
|
@ -361,17 +401,17 @@ class FPDF_TPL extends FPDF {
|
||||||
$this->_out('/XObject <<');
|
$this->_out('/XObject <<');
|
||||||
if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
|
if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
|
||||||
foreach($this->_res['tpl'][$tplidx]['images'] as $image)
|
foreach($this->_res['tpl'][$tplidx]['images'] as $image)
|
||||||
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
|
$this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
|
||||||
}
|
}
|
||||||
if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
|
if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
|
||||||
foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl)
|
foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl)
|
||||||
$this->_out($this->tplprefix.$i.' '.$tpl['n'].' 0 R');
|
$this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R');
|
||||||
}
|
}
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
}
|
}
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
|
|
||||||
$this->_out('/Length '.strlen($p).' >>');
|
$this->_out('/Length ' . strlen($p) . ' >>');
|
||||||
$this->_putstream($p);
|
$this->_putstream($p);
|
||||||
$this->_out('endobj');
|
$this->_out('endobj');
|
||||||
}
|
}
|
||||||
|
|
@ -400,8 +440,8 @@ class FPDF_TPL extends FPDF {
|
||||||
* Private Method
|
* Private Method
|
||||||
*/
|
*/
|
||||||
function _out($s) {
|
function _out($s) {
|
||||||
if ($this->state==2 && $this->_intpl) {
|
if ($this->state == 2 && $this->_intpl) {
|
||||||
$this->tpls[$this->tpl]['buffer'] .= $s."\n";
|
$this->tpls[$this->tpl]['buffer'] .= $s . "\n";
|
||||||
} else {
|
} else {
|
||||||
parent::_out($s);
|
parent::_out($s);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
152
vendors/fpdi/fpdi.php
vendored
152
vendors/fpdi/fpdi.php
vendored
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?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");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
|
@ -17,14 +17,12 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
define('FPDI_VERSION','1.3.2');
|
define('FPDI_VERSION', '1.4.1');
|
||||||
|
|
||||||
// Check for TCPDF and remap TCPDF to FPDF
|
// Check for TCPDF and remap TCPDF to FPDF
|
||||||
$__tmp = version_compare(phpversion(), "5") == -1 ? array('TCPDF') : array('TCPDF', false);
|
if (class_exists('TCPDF', false)) {
|
||||||
if (call_user_func_array('class_exists', $__tmp)) {
|
|
||||||
require_once('fpdi2tcpdf_bridge.php');
|
require_once('fpdi2tcpdf_bridge.php');
|
||||||
}
|
}
|
||||||
unset($__tmp);
|
|
||||||
|
|
||||||
require_once('fpdf_tpl.php');
|
require_once('fpdf_tpl.php');
|
||||||
require_once('fpdi_pdf_parser.php');
|
require_once('fpdi_pdf_parser.php');
|
||||||
|
|
@ -73,9 +71,12 @@ class FPDI extends FPDF_TPL {
|
||||||
*/
|
*/
|
||||||
var $lastUsedPageBox;
|
var $lastUsedPageBox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache for imported pages/template ids
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
var $_importedPages = array();
|
var $_importedPages = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a source-file
|
* Set a source-file
|
||||||
*
|
*
|
||||||
|
|
@ -84,13 +85,40 @@ class FPDI extends FPDF_TPL {
|
||||||
*/
|
*/
|
||||||
function setSourceFile($filename) {
|
function setSourceFile($filename) {
|
||||||
$this->current_filename = $filename;
|
$this->current_filename = $filename;
|
||||||
$fn =& $this->current_filename;
|
|
||||||
|
|
||||||
if (!isset($this->parsers[$fn]))
|
if (!isset($this->parsers[$filename]))
|
||||||
$this->parsers[$fn] = new fpdi_pdf_parser($fn, $this);
|
$this->parsers[$filename] = $this->_getPdfParser($filename);
|
||||||
$this->current_parser =& $this->parsers[$fn];
|
$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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -99,15 +127,15 @@ class FPDI extends FPDF_TPL {
|
||||||
* @param int $pageno pagenumber
|
* @param int $pageno pagenumber
|
||||||
* @return int Index of imported page - to use with fpdf_tpl::useTemplate()
|
* @return int Index of imported page - to use with fpdf_tpl::useTemplate()
|
||||||
*/
|
*/
|
||||||
function importPage($pageno, $boxName='/CropBox') {
|
function importPage($pageno, $boxName = '/CropBox') {
|
||||||
if ($this->_intpl) {
|
if ($this->_intpl) {
|
||||||
return $this->error('Please import the desired pages before creating a new template.');
|
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
|
// check if page already imported
|
||||||
$pageKey = $fn.((int)$pageno).$boxName;
|
$pageKey = $fn . '-' . ((int)$pageno) . $boxName;
|
||||||
if (isset($this->_importedPages[$pageKey]))
|
if (isset($this->_importedPages[$pageKey]))
|
||||||
return $this->_importedPages[$pageKey];
|
return $this->_importedPages[$pageKey];
|
||||||
|
|
||||||
|
|
@ -116,7 +144,7 @@ class FPDI extends FPDF_TPL {
|
||||||
|
|
||||||
if (!in_array($boxName, $parser->availableBoxes))
|
if (!in_array($boxName, $parser->availableBoxes))
|
||||||
return $this->Error(sprintf('Unknown box: %s', $boxName));
|
return $this->Error(sprintf('Unknown box: %s', $boxName));
|
||||||
$pageboxes = $parser->getPageBoxes($pageno);
|
$pageboxes = $parser->getPageBoxes($pageno, $this->k);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MediaBox
|
* MediaBox
|
||||||
|
|
@ -162,7 +190,10 @@ class FPDI extends FPDF_TPL {
|
||||||
$tpl['w'] = $steps % 2 == 0 ? $_w : $_h;
|
$tpl['w'] = $steps % 2 == 0 ? $_w : $_h;
|
||||||
$tpl['h'] = $steps % 2 == 0 ? $_h : $_w;
|
$tpl['h'] = $steps % 2 == 0 ? $_h : $_w;
|
||||||
|
|
||||||
$tpl['_rotationAngle'] = $angle*-1;
|
if ($angle < 0)
|
||||||
|
$angle += 360;
|
||||||
|
|
||||||
|
$tpl['_rotationAngle'] = $angle * -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_importedPages[$pageKey] = $this->tpl;
|
$this->_importedPages[$pageKey] = $this->tpl;
|
||||||
|
|
@ -174,24 +205,29 @@ class FPDI extends FPDF_TPL {
|
||||||
return $this->lastUsedPageBox;
|
return $this->lastUsedPageBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
function useTemplate($tplidx, $_x=null, $_y=null, $_w=0, $_h=0, $adjustPageSize=false) {
|
function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0, $adjustPageSize = false) {
|
||||||
if ($adjustPageSize == true && is_null($_x) && is_null($_y)) {
|
if ($adjustPageSize == true && is_null($_x) && is_null($_y)) {
|
||||||
$size = $this->getTemplateSize($tplidx, $_w, $_h);
|
$size = $this->getTemplateSize($tplidx, $_w, $_h);
|
||||||
$format = array($size['w'], $size['h']);
|
$format = array($size['w'], $size['h']);
|
||||||
if ($format[0]!=$this->CurPageFormat[0] || $format[1]!=$this->CurPageFormat[1]) {
|
if (is_subclass_of($this, 'TCPDF')) {
|
||||||
$this->w=$format[0];
|
$this->setPageFormat($format, $format[0] > $format[1] ? 'L' : 'P');
|
||||||
$this->h=$format[1];
|
} else {
|
||||||
$this->wPt=$this->w*$this->k;
|
if ($format[0] != $this->CurPageFormat[0] || $format[1] != $this->CurPageFormat[1]) {
|
||||||
$this->hPt=$this->h*$this->k;
|
$this->w = $format[0];
|
||||||
$this->PageBreakTrigger=$this->h-$this->bMargin;
|
$this->h = $format[1];
|
||||||
$this->CurPageFormat=$format;
|
$this->wPt = $this->w * $this->k;
|
||||||
$this->PageSizes[$this->page]=array($this->wPt, $this->hPt);
|
$this->hPt = $this->h * $this->k;
|
||||||
|
$this->PageBreakTrigger = $this->h - $this->bMargin;
|
||||||
|
$this->CurPageFormat = $format;
|
||||||
|
$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
|
$this->_out('q 0 J 1 w 0 j 0 G 0 g'); // reset standard values
|
||||||
$s = parent::useTemplate($tplidx, $_x, $_y, $_w, $_h);
|
$s = parent::useTemplate($tplidx, $_x, $_y, $_w, $_h);
|
||||||
$this->_out('Q');
|
$this->_out('Q');
|
||||||
|
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -204,14 +240,14 @@ class FPDI extends FPDF_TPL {
|
||||||
$this->current_parser =& $this->parsers[$filename];
|
$this->current_parser =& $this->parsers[$filename];
|
||||||
if (isset($this->_obj_stack[$filename]) && is_array($this->_obj_stack[$filename])) {
|
if (isset($this->_obj_stack[$filename]) && is_array($this->_obj_stack[$filename])) {
|
||||||
while(($n = key($this->_obj_stack[$filename])) !== null) {
|
while(($n = key($this->_obj_stack[$filename])) !== null) {
|
||||||
$nObj = $this->current_parser->pdf_resolve_object($this->current_parser->c,$this->_obj_stack[$filename][$n][1]);
|
$nObj = $this->current_parser->pdf_resolve_object($this->current_parser->c, $this->_obj_stack[$filename][$n][1]);
|
||||||
|
|
||||||
$this->_newobj($this->_obj_stack[$filename][$n][0]);
|
$this->_newobj($this->_obj_stack[$filename][$n][0]);
|
||||||
|
|
||||||
if ($nObj[0] == PDF_TYPE_STREAM) {
|
if ($nObj[0] == PDF_TYPE_STREAM) {
|
||||||
$this->pdf_write_value ($nObj);
|
$this->pdf_write_value($nObj);
|
||||||
} else {
|
} else {
|
||||||
$this->pdf_write_value ($nObj[1]);
|
$this->pdf_write_value($nObj[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_out('endobj');
|
$this->_out('endobj');
|
||||||
|
|
@ -237,15 +273,15 @@ class FPDI extends FPDF_TPL {
|
||||||
$cN = $this->n; // TCPDF/Protection: rem current "n"
|
$cN = $this->n; // TCPDF/Protection: rem current "n"
|
||||||
|
|
||||||
$this->tpls[$tplidx]['n'] = $this->n;
|
$this->tpls[$tplidx]['n'] = $this->n;
|
||||||
$this->_out('<<'.$filter.'/Type /XObject');
|
$this->_out('<<' . $filter . '/Type /XObject');
|
||||||
$this->_out('/Subtype /Form');
|
$this->_out('/Subtype /Form');
|
||||||
$this->_out('/FormType 1');
|
$this->_out('/FormType 1');
|
||||||
|
|
||||||
$this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]',
|
$this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]',
|
||||||
(isset($tpl['box']['llx']) ? $tpl['box']['llx'] : $tpl['x'])*$this->k,
|
(isset($tpl['box']['llx']) ? $tpl['box']['llx'] : $tpl['x']) * $this->k,
|
||||||
(isset($tpl['box']['lly']) ? $tpl['box']['lly'] : -$tpl['y'])*$this->k,
|
(isset($tpl['box']['lly']) ? $tpl['box']['lly'] : -$tpl['y']) * $this->k,
|
||||||
(isset($tpl['box']['urx']) ? $tpl['box']['urx'] : $tpl['w'] + $tpl['x'])*$this->k,
|
(isset($tpl['box']['urx']) ? $tpl['box']['urx'] : $tpl['w'] + $tpl['x']) * $this->k,
|
||||||
(isset($tpl['box']['ury']) ? $tpl['box']['ury'] : $tpl['h']-$tpl['y'])*$this->k
|
(isset($tpl['box']['ury']) ? $tpl['box']['ury'] : $tpl['h'] - $tpl['y']) * $this->k
|
||||||
));
|
));
|
||||||
|
|
||||||
$c = 1;
|
$c = 1;
|
||||||
|
|
@ -301,7 +337,7 @@ class FPDI extends FPDF_TPL {
|
||||||
if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
|
if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
|
||||||
$this->_out('/Font <<');
|
$this->_out('/Font <<');
|
||||||
foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
|
foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
|
||||||
$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
|
$this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
}
|
}
|
||||||
if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) ||
|
if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) ||
|
||||||
|
|
@ -310,11 +346,11 @@ class FPDI extends FPDF_TPL {
|
||||||
$this->_out('/XObject <<');
|
$this->_out('/XObject <<');
|
||||||
if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
|
if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
|
||||||
foreach($this->_res['tpl'][$tplidx]['images'] as $image)
|
foreach($this->_res['tpl'][$tplidx]['images'] as $image)
|
||||||
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
|
$this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
|
||||||
}
|
}
|
||||||
if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
|
if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
|
||||||
foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl)
|
foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl)
|
||||||
$this->_out($this->tplprefix.$i.' '.$tpl['n'].' 0 R');
|
$this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R');
|
||||||
}
|
}
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
}
|
}
|
||||||
|
|
@ -323,7 +359,7 @@ class FPDI extends FPDF_TPL {
|
||||||
|
|
||||||
$nN = $this->n; // TCPDF: rem new "n"
|
$nN = $this->n; // TCPDF: rem new "n"
|
||||||
$this->n = $cN; // TCPDF: reset to current "n"
|
$this->n = $cN; // TCPDF: reset to current "n"
|
||||||
$this->_out('/Length '.strlen($p).' >>');
|
$this->_out('/Length ' . strlen($p) . ' >>');
|
||||||
$this->_putstream($p);
|
$this->_putstream($p);
|
||||||
$this->_out('endobj');
|
$this->_out('endobj');
|
||||||
$this->n = $nN; // TCPDF: reset to new "n"
|
$this->n = $nN; // TCPDF: reset to new "n"
|
||||||
|
|
@ -335,7 +371,7 @@ class FPDI extends FPDF_TPL {
|
||||||
/**
|
/**
|
||||||
* Rewritten to handle existing own defined objects
|
* Rewritten to handle existing own defined objects
|
||||||
*/
|
*/
|
||||||
function _newobj($obj_id=false,$onlynewobj=false) {
|
function _newobj($obj_id = false, $onlynewobj = false) {
|
||||||
if (!$obj_id) {
|
if (!$obj_id) {
|
||||||
$obj_id = ++$this->n;
|
$obj_id = ++$this->n;
|
||||||
}
|
}
|
||||||
|
|
@ -343,9 +379,10 @@ class FPDI extends FPDF_TPL {
|
||||||
//Begin a new object
|
//Begin a new object
|
||||||
if (!$onlynewobj) {
|
if (!$onlynewobj) {
|
||||||
$this->offsets[$obj_id] = is_subclass_of($this, 'TCPDF') ? $this->bufferlen : strlen($this->buffer);
|
$this->offsets[$obj_id] = is_subclass_of($this, 'TCPDF') ? $this->bufferlen : strlen($this->buffer);
|
||||||
$this->_out($obj_id.' 0 obj');
|
$this->_out($obj_id . ' 0 obj');
|
||||||
$this->_current_obj_id = $obj_id; // for later use with encryption
|
$this->_current_obj_id = $obj_id; // for later use with encryption
|
||||||
}
|
}
|
||||||
|
|
||||||
return $obj_id;
|
return $obj_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -363,19 +400,19 @@ class FPDI extends FPDF_TPL {
|
||||||
|
|
||||||
switch ($value[0]) {
|
switch ($value[0]) {
|
||||||
|
|
||||||
case PDF_TYPE_TOKEN :
|
case PDF_TYPE_TOKEN:
|
||||||
$this->_straightOut($value[1] . ' ');
|
$this->_straightOut($value[1] . ' ');
|
||||||
break;
|
break;
|
||||||
case PDF_TYPE_NUMERIC :
|
case PDF_TYPE_NUMERIC:
|
||||||
case PDF_TYPE_REAL :
|
case PDF_TYPE_REAL:
|
||||||
if (is_float($value[1]) && $value[1] != 0) {
|
if (is_float($value[1]) && $value[1] != 0) {
|
||||||
$this->_straightOut(rtrim(rtrim(sprintf('%F', $value[1]), '0'), '.') .' ');
|
$this->_straightOut(rtrim(rtrim(sprintf('%F', $value[1]), '0'), '.') . ' ');
|
||||||
} else {
|
} else {
|
||||||
$this->_straightOut($value[1] . ' ');
|
$this->_straightOut($value[1] . ' ');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PDF_TYPE_ARRAY :
|
case PDF_TYPE_ARRAY:
|
||||||
|
|
||||||
// An array. Output the proper
|
// An array. Output the proper
|
||||||
// structure and move on.
|
// structure and move on.
|
||||||
|
|
@ -388,7 +425,7 @@ class FPDI extends FPDF_TPL {
|
||||||
$this->_out(']');
|
$this->_out(']');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PDF_TYPE_DICTIONARY :
|
case PDF_TYPE_DICTIONARY:
|
||||||
|
|
||||||
// A dictionary.
|
// A dictionary.
|
||||||
$this->_straightOut('<<');
|
$this->_straightOut('<<');
|
||||||
|
|
@ -403,30 +440,30 @@ class FPDI extends FPDF_TPL {
|
||||||
$this->_straightOut('>>');
|
$this->_straightOut('>>');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PDF_TYPE_OBJREF :
|
case PDF_TYPE_OBJREF:
|
||||||
|
|
||||||
// An indirect object reference
|
// An indirect object reference
|
||||||
// Fill the object stack if needed
|
// Fill the object stack if needed
|
||||||
$cpfn =& $this->current_parser->filename;
|
$cpfn =& $this->current_parser->filename;
|
||||||
|
|
||||||
if (!isset($this->_don_obj_stack[$cpfn][$value[1]])) {
|
if (!isset($this->_don_obj_stack[$cpfn][$value[1]])) {
|
||||||
$this->_newobj(false,true);
|
$this->_newobj(false, true);
|
||||||
$this->_obj_stack[$cpfn][$value[1]] = array($this->n, $value);
|
$this->_obj_stack[$cpfn][$value[1]] = array($this->n, $value);
|
||||||
$this->_don_obj_stack[$cpfn][$value[1]] = array($this->n, $value); // Value is maybee obsolete!!!
|
$this->_don_obj_stack[$cpfn][$value[1]] = array($this->n, $value); // Value is maybee obsolete!!!
|
||||||
}
|
}
|
||||||
$objid = $this->_don_obj_stack[$cpfn][$value[1]][0];
|
$objid = $this->_don_obj_stack[$cpfn][$value[1]][0];
|
||||||
|
|
||||||
$this->_out($objid.' 0 R');
|
$this->_out($objid . ' 0 R');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PDF_TYPE_STRING :
|
case PDF_TYPE_STRING:
|
||||||
|
|
||||||
// A string.
|
// A string.
|
||||||
$this->_straightOut('('.$value[1].')');
|
$this->_straightOut('(' . $value[1] . ')');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PDF_TYPE_STREAM :
|
case PDF_TYPE_STREAM:
|
||||||
|
|
||||||
// A stream. First, output the
|
// A stream. First, output the
|
||||||
// stream dictionary, then the
|
// stream dictionary, then the
|
||||||
|
|
@ -436,15 +473,16 @@ class FPDI extends FPDF_TPL {
|
||||||
$this->_out($value[2][1]);
|
$this->_out($value[2][1]);
|
||||||
$this->_out('endstream');
|
$this->_out('endstream');
|
||||||
break;
|
break;
|
||||||
case PDF_TYPE_HEX :
|
|
||||||
$this->_straightOut('<'.$value[1].'>');
|
case PDF_TYPE_HEX:
|
||||||
|
$this->_straightOut('<' . $value[1] . '>');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PDF_TYPE_BOOLEAN :
|
case PDF_TYPE_BOOLEAN:
|
||||||
$this->_straightOut($value[1] ? 'true ' : 'false ');
|
$this->_straightOut($value[1] ? 'true ' : 'false ');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PDF_TYPE_NULL :
|
case PDF_TYPE_NULL:
|
||||||
// The null object.
|
// The null object.
|
||||||
|
|
||||||
$this->_straightOut('null ');
|
$this->_straightOut('null ');
|
||||||
|
|
@ -468,7 +506,7 @@ class FPDI extends FPDF_TPL {
|
||||||
// puts data before page footer
|
// puts data before page footer
|
||||||
$page = substr($this->getPageBuffer($this->page), 0, -$this->footerlen[$this->page]);
|
$page = substr($this->getPageBuffer($this->page), 0, -$this->footerlen[$this->page]);
|
||||||
$footer = substr($this->getPageBuffer($this->page), -$this->footerlen[$this->page]);
|
$footer = substr($this->getPageBuffer($this->page), -$this->footerlen[$this->page]);
|
||||||
$this->setPageBuffer($this->page, $page.' '.$s."\n".$footer);
|
$this->setPageBuffer($this->page, $page . ' ' . $s . "\n" . $footer);
|
||||||
} else {
|
} else {
|
||||||
$this->setPageBuffer($this->page, $s, true);
|
$this->setPageBuffer($this->page, $s, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
38
vendors/fpdi/fpdi2tcpdf_bridge.php
vendored
38
vendors/fpdi/fpdi2tcpdf_bridge.php
vendored
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?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");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
|
@ -28,27 +28,19 @@
|
||||||
*/
|
*/
|
||||||
class FPDF extends TCPDF {
|
class FPDF extends TCPDF {
|
||||||
|
|
||||||
function __get($name) {
|
function _putstream($s) {
|
||||||
switch ($name) {
|
$this->_out($this->_getstream($s));
|
||||||
case 'PDFVersion':
|
}
|
||||||
return $this->PDFVersion;
|
|
||||||
case 'k':
|
function _getxobjectdict() {
|
||||||
return $this->k;
|
$out = parent::_getxobjectdict();
|
||||||
default:
|
if (count($this->tpls)) {
|
||||||
// Error handling
|
foreach($this->tpls as $tplidx => $tpl) {
|
||||||
$this->Error('Cannot access protected property '.get_class($this).':$'.$name.' / Undefined property: '.get_class($this).'::$'.$name);
|
$out .= sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function __set($name, $value) {
|
return $out;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -58,7 +50,7 @@ class FPDF extends TCPDF {
|
||||||
*/
|
*/
|
||||||
function pdf_write_value(&$value) {
|
function pdf_write_value(&$value) {
|
||||||
switch ($value[0]) {
|
switch ($value[0]) {
|
||||||
case PDF_TYPE_STRING :
|
case PDF_TYPE_STRING:
|
||||||
if ($this->encrypted) {
|
if ($this->encrypted) {
|
||||||
$value[1] = $this->_unescape($value[1]);
|
$value[1] = $this->_unescape($value[1]);
|
||||||
$value[1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[1]);
|
$value[1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[1]);
|
||||||
|
|
@ -66,13 +58,13 @@ class FPDF extends TCPDF {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PDF_TYPE_STREAM :
|
case PDF_TYPE_STREAM:
|
||||||
if ($this->encrypted) {
|
if ($this->encrypted) {
|
||||||
$value[2][1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[2][1]);
|
$value[2][1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[2][1]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PDF_TYPE_HEX :
|
case PDF_TYPE_HEX:
|
||||||
if ($this->encrypted) {
|
if ($this->encrypted) {
|
||||||
$value[1] = $this->hex2str($value[1]);
|
$value[1] = $this->hex2str($value[1]);
|
||||||
$value[1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[1]);
|
$value[1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[1]);
|
||||||
|
|
|
||||||
70
vendors/fpdi/fpdi_pdf_parser.php
vendored
70
vendors/fpdi/fpdi_pdf_parser.php
vendored
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?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");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
|
@ -167,7 +167,7 @@ class fpdi_pdf_parser extends pdf_parser {
|
||||||
if (isset($this->pages[$this->pageno][1][1]['/Contents'])) {
|
if (isset($this->pages[$this->pageno][1][1]['/Contents'])) {
|
||||||
$contents = $this->_getPageContent($this->pages[$this->pageno][1][1]['/Contents']);
|
$contents = $this->_getPageContent($this->pages[$this->pageno][1][1]['/Contents']);
|
||||||
foreach($contents AS $tmp_content) {
|
foreach($contents AS $tmp_content) {
|
||||||
$buffer .= $this->_rebuildContentStream($tmp_content).' ';
|
$buffer .= $this->_rebuildContentStream($tmp_content) . ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -213,6 +213,11 @@ class fpdi_pdf_parser extends pdf_parser {
|
||||||
if (isset($obj[1][1]['/Filter'])) {
|
if (isset($obj[1][1]['/Filter'])) {
|
||||||
$_filter = $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) {
|
if ($_filter[0] == PDF_TYPE_TOKEN) {
|
||||||
$filters[] = $_filter;
|
$filters[] = $_filter;
|
||||||
} else if ($_filter[0] == PDF_TYPE_ARRAY) {
|
} else if ($_filter[0] == PDF_TYPE_ARRAY) {
|
||||||
|
|
@ -225,11 +230,16 @@ class fpdi_pdf_parser extends pdf_parser {
|
||||||
foreach ($filters AS $_filter) {
|
foreach ($filters AS $_filter) {
|
||||||
switch ($_filter[1]) {
|
switch ($_filter[1]) {
|
||||||
case '/FlateDecode':
|
case '/FlateDecode':
|
||||||
|
case '/Fl':
|
||||||
|
// $stream .= "\x0F\x0D"; // in an errorious stream this suffix could work
|
||||||
|
// $stream .= "\x0A";
|
||||||
|
// $stream .= "\x0D";
|
||||||
if (function_exists('gzuncompress')) {
|
if (function_exists('gzuncompress')) {
|
||||||
$stream = (strlen($stream) > 0) ? @gzuncompress($stream) : '';
|
$stream = (strlen($stream) > 0) ? @gzuncompress($stream) : '';
|
||||||
} else {
|
} else {
|
||||||
$this->error(sprintf('To handle %s filter, please compile php with zlib support.',$_filter[1]));
|
$this->error(sprintf('To handle %s filter, please compile php with zlib support.',$_filter[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($stream === false) {
|
if ($stream === false) {
|
||||||
$this->error('Error while decompressing stream.');
|
$this->error('Error while decompressing stream.');
|
||||||
}
|
}
|
||||||
|
|
@ -262,52 +272,60 @@ class fpdi_pdf_parser extends pdf_parser {
|
||||||
*
|
*
|
||||||
* @param array $page a /Page
|
* @param array $page a /Page
|
||||||
* @param string $box_index Type of Box @see $availableBoxes
|
* @param string $box_index Type of Box @see $availableBoxes
|
||||||
|
* @param float Scale factor from user space units to points
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getPageBox($page, $box_index) {
|
function getPageBox($page, $box_index, $k) {
|
||||||
$page = $this->pdf_resolve_object($this->c,$page);
|
$page = $this->pdf_resolve_object($this->c, $page);
|
||||||
$box = null;
|
$box = null;
|
||||||
if (isset($page[1][1][$box_index]))
|
if (isset($page[1][1][$box_index]))
|
||||||
$box =& $page[1][1][$box_index];
|
$box =& $page[1][1][$box_index];
|
||||||
|
|
||||||
if (!is_null($box) && $box[0] == PDF_TYPE_OBJREF) {
|
if (!is_null($box) && $box[0] == PDF_TYPE_OBJREF) {
|
||||||
$tmp_box = $this->pdf_resolve_object($this->c,$box);
|
$tmp_box = $this->pdf_resolve_object($this->c, $box);
|
||||||
$box = $tmp_box[1];
|
$box = $tmp_box[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($box) && $box[0] == PDF_TYPE_ARRAY) {
|
if (!is_null($box) && $box[0] == PDF_TYPE_ARRAY) {
|
||||||
$b =& $box[1];
|
$b =& $box[1];
|
||||||
return array('x' => $b[0][1]/$this->fpdi->k,
|
return array('x' => $b[0][1]/$k,
|
||||||
'y' => $b[1][1]/$this->fpdi->k,
|
'y' => $b[1][1]/$k,
|
||||||
'w' => abs($b[0][1]-$b[2][1])/$this->fpdi->k,
|
'w' => abs($b[0][1]-$b[2][1])/$k,
|
||||||
'h' => abs($b[1][1]-$b[3][1])/$this->fpdi->k,
|
'h' => abs($b[1][1]-$b[3][1])/$k,
|
||||||
'llx' => min($b[0][1], $b[2][1])/$this->fpdi->k,
|
'llx' => min($b[0][1], $b[2][1])/$k,
|
||||||
'lly' => min($b[1][1], $b[3][1])/$this->fpdi->k,
|
'lly' => min($b[1][1], $b[3][1])/$k,
|
||||||
'urx' => max($b[0][1], $b[2][1])/$this->fpdi->k,
|
'urx' => max($b[0][1], $b[2][1])/$k,
|
||||||
'ury' => max($b[1][1], $b[3][1])/$this->fpdi->k,
|
'ury' => max($b[1][1], $b[3][1])/$k,
|
||||||
);
|
);
|
||||||
} else if (!isset ($page[1][1]['/Parent'])) {
|
} else if (!isset ($page[1][1]['/Parent'])) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} 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
|
* @param array a /Page
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _getPageBoxes($page) {
|
function _getPageBoxes($page, $k) {
|
||||||
$boxes = array();
|
$boxes = array();
|
||||||
|
|
||||||
foreach($this->availableBoxes AS $box) {
|
foreach($this->availableBoxes AS $box) {
|
||||||
if ($_box = $this->getPageBox($page,$box)) {
|
if ($_box = $this->getPageBox($page, $box, $k)) {
|
||||||
$boxes[$box] = $_box;
|
$boxes[$box] = $_box;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -325,7 +343,7 @@ class fpdi_pdf_parser extends pdf_parser {
|
||||||
return $this->_getPageRotation($this->pages[$pageno-1]);
|
return $this->_getPageRotation($this->pages[$pageno-1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getPageRotation ($obj) { // $obj = /Page
|
function _getPageRotation($obj) { // $obj = /Page
|
||||||
$obj = $this->pdf_resolve_object($this->c, $obj);
|
$obj = $this->pdf_resolve_object($this->c, $obj);
|
||||||
if (isset ($obj[1][1]['/Rotate'])) {
|
if (isset ($obj[1][1]['/Rotate'])) {
|
||||||
$res = $this->pdf_resolve_object($this->c, $obj[1][1]['/Rotate']);
|
$res = $this->pdf_resolve_object($this->c, $obj[1][1]['/Rotate']);
|
||||||
|
|
@ -351,7 +369,7 @@ class fpdi_pdf_parser extends pdf_parser {
|
||||||
* @param array /Pages
|
* @param array /Pages
|
||||||
* @param array the result-array
|
* @param array the result-array
|
||||||
*/
|
*/
|
||||||
function read_pages (&$c, &$pages, &$result) {
|
function read_pages(&$c, &$pages, &$result) {
|
||||||
// Get the kids dictionary
|
// Get the kids dictionary
|
||||||
$_kids = $this->pdf_resolve_object ($c, $pages[1][1]['/Kids']);
|
$_kids = $this->pdf_resolve_object ($c, $pages[1][1]['/Kids']);
|
||||||
|
|
||||||
|
|
@ -369,7 +387,7 @@ class fpdi_pdf_parser extends pdf_parser {
|
||||||
if ($pg[1][1]['/Type'][1] === '/Pages') {
|
if ($pg[1][1]['/Type'][1] === '/Pages') {
|
||||||
// If one of the kids is an embedded
|
// If one of the kids is an embedded
|
||||||
// /Pages array, resolve it as well.
|
// /Pages array, resolve it as well.
|
||||||
$this->read_pages ($c, $pg, $result);
|
$this->read_pages($c, $pg, $result);
|
||||||
} else {
|
} else {
|
||||||
$result[] = $pg;
|
$result[] = $pg;
|
||||||
}
|
}
|
||||||
|
|
@ -385,7 +403,7 @@ class fpdi_pdf_parser extends pdf_parser {
|
||||||
*/
|
*/
|
||||||
function getPDFVersion() {
|
function getPDFVersion() {
|
||||||
parent::getPDFVersion();
|
parent::getPDFVersion();
|
||||||
$this->fpdi->PDFVersion = max($this->fpdi->PDFVersion, $this->pdfVersion);
|
$this->fpdi->setPDFVersion(max($this->fpdi->getPDFVersion(), $this->pdfVersion));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
17
vendors/fpdi/pdf_context.php
vendored
17
vendors/fpdi/pdf_context.php
vendored
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?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");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
|
@ -17,8 +17,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
$__tmp = version_compare(phpversion(), "5") == -1 ? array('pdf_context') : array('pdf_context', false);
|
if (!class_exists('pdf_context', false)) {
|
||||||
if (!call_user_func_array('class_exists', $__tmp)) {
|
|
||||||
|
|
||||||
class pdf_context {
|
class pdf_context {
|
||||||
|
|
||||||
|
|
@ -83,13 +82,17 @@ if (!call_user_func_array('class_exists', $__tmp)) {
|
||||||
|
|
||||||
// Forcefully read more data into the buffer
|
// Forcefully read more data into the buffer
|
||||||
|
|
||||||
function increase_length($l=100) {
|
function increase_length($l = 100) {
|
||||||
if ($this->_mode == 0 && feof($this->file)) {
|
if ($this->_mode == 0 && feof($this->file)) {
|
||||||
return false;
|
return false;
|
||||||
} else if ($this->_mode == 0) {
|
} else if ($this->_mode == 0) {
|
||||||
$totalLength = $this->length + $l;
|
$totalLength = $this->length + $l;
|
||||||
do {
|
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));
|
} while ((($this->length = strlen($this->buffer)) != $totalLength) && !feof($this->file));
|
||||||
|
|
||||||
return true;
|
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
|
<?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");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with 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');
|
require_once('pdf_context.php');
|
||||||
|
|
||||||
$__tmp = version_compare(phpversion(), "5") == -1 ? array('pdf_parser') : array('pdf_parser', false);
|
if (!class_exists('pdf_parser', false)) {
|
||||||
if (!call_user_func_array('class_exists', $__tmp)) {
|
|
||||||
|
|
||||||
class pdf_parser {
|
class pdf_parser {
|
||||||
|
|
||||||
|
|
@ -87,6 +86,13 @@ if (!call_user_func_array('class_exists', $__tmp)) {
|
||||||
*/
|
*/
|
||||||
var $pdfVersion;
|
var $pdfVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For reading encrypted documents and xref/objectstreams are in use
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
var $readPlain = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
|
@ -206,8 +212,8 @@ if (!call_user_func_array('class_exists', $__tmp)) {
|
||||||
* @param integer $offset of xref-table
|
* @param integer $offset of xref-table
|
||||||
*/
|
*/
|
||||||
function pdf_read_xref(&$result, $offset) {
|
function pdf_read_xref(&$result, $offset) {
|
||||||
|
$o_pos = $offset-min(20, $offset);
|
||||||
fseek($this->f, $o_pos = $offset-20); // set some bytes backwards to fetch errorious docs
|
fseek($this->f, $o_pos); // set some bytes backwards to fetch errorious docs
|
||||||
|
|
||||||
$data = fread($this->f, 100);
|
$data = fread($this->f, 100);
|
||||||
|
|
||||||
|
|
@ -542,8 +548,15 @@ if (!call_user_func_array('class_exists', $__tmp)) {
|
||||||
$header = $this->pdf_read_value($c);
|
$header = $this->pdf_read_value($c);
|
||||||
|
|
||||||
if ($header[0] != PDF_TYPE_OBJDEC || $header[1] != $obj_spec[1] || $header[2] != $obj_spec[2]) {
|
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");
|
$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
|
// If we're being asked to store all the information
|
||||||
// about the object, we add the object ID and generation
|
// 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)
|
5.9.078 (2011-05-12)
|
||||||
- Bug item #3300878 "wrong rendering for html bullet list in some case" was fixed.
|
- Bug item #3300878 "wrong rendering for html bullet list in some case" was fixed.
|
||||||
- Bug item #3301017 "Emphasized vs. font-weight" 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
|
Name: TCPDF
|
||||||
Version: 5.9.078
|
Version: 5.9.082
|
||||||
Release date: 2011-05-12
|
Release date: 2011-05-22
|
||||||
Author: Nicola Asuni
|
Author: Nicola Asuni
|
||||||
|
|
||||||
Copyright (c) 2002-2011:
|
Copyright (c) 2002-2011:
|
||||||
|
|
|
||||||
59
vendors/tcpdf/tcpdf.php
vendored
59
vendors/tcpdf/tcpdf.php
vendored
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
//============================================================+
|
//============================================================+
|
||||||
// File name : tcpdf.php
|
// File name : tcpdf.php
|
||||||
// Version : 5.9.078
|
// Version : 5.9.082
|
||||||
// Begin : 2002-08-03
|
// 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
|
// 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.
|
// 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>
|
* Tools to encode your unicode fonts are on fonts/utils directory.</p>
|
||||||
* @package com.tecnick.tcpdf
|
* @package com.tecnick.tcpdf
|
||||||
* @author Nicola Asuni
|
* @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.
|
// 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>
|
* 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
|
* @package com.tecnick.tcpdf
|
||||||
* @brief PHP class for generating PDF documents without requiring external extensions.
|
* @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
|
* @author Nicola Asuni - info@tecnick.com
|
||||||
*/
|
*/
|
||||||
class TCPDF {
|
class TCPDF {
|
||||||
|
|
@ -157,7 +157,7 @@ class TCPDF {
|
||||||
* Current TCPDF version.
|
* Current TCPDF version.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private $tcpdf_version = '5.9.078';
|
private $tcpdf_version = '5.9.082';
|
||||||
|
|
||||||
// Protected properties
|
// Protected properties
|
||||||
|
|
||||||
|
|
@ -572,6 +572,12 @@ class TCPDF {
|
||||||
*/
|
*/
|
||||||
protected $header_xobjid = -1;
|
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.
|
* Minimum distance between header and top page margin.
|
||||||
* @protected
|
* @protected
|
||||||
|
|
@ -1912,6 +1918,7 @@ class TCPDF {
|
||||||
$this->file_id = md5($this->getRandomSeed('TCPDF'.$orientation.$unit.$format.$encoding));
|
$this->file_id = md5($this->getRandomSeed('TCPDF'.$orientation.$unit.$format.$encoding));
|
||||||
// get default graphic vars
|
// get default graphic vars
|
||||||
$this->default_graphic_vars = $this->getGraphicVars();
|
$this->default_graphic_vars = $this->getGraphicVars();
|
||||||
|
$this->header_xobj_autoreset = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -4003,6 +4010,23 @@ class TCPDF {
|
||||||
return $this->img_rb_y;
|
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.
|
* This method is used to render the page header.
|
||||||
* It is automatically called by AddPage() and could be overwritten in your own inherited class.
|
* It is automatically called by AddPage() and could be overwritten in your own inherited class.
|
||||||
|
|
@ -4074,6 +4098,10 @@ class TCPDF {
|
||||||
$x = 0 + $dx;
|
$x = 0 + $dx;
|
||||||
}
|
}
|
||||||
$this->printTemplate($this->header_xobjid, $x, 0, 0, 0, '', '', false);
|
$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,
|
'bgcolor' => false,
|
||||||
'text' => 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)) {
|
if (empty($this->pagegroups)) {
|
||||||
$pagenumtxt = $this->l['w_page'].' '.$this->getAliasNumPage().' / '.$this->getAliasNbPages();
|
$pagenumtxt = $this->l['w_page'].' '.$this->getAliasNumPage().' / '.$this->getAliasNbPages();
|
||||||
|
|
@ -5694,7 +5722,7 @@ class TCPDF {
|
||||||
// increase/decrease font spacing
|
// increase/decrease font spacing
|
||||||
$rs .= sprintf('BT %.2F Tc ET ', ($this->font_spacing * $this->k));
|
$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.' ';
|
$s .= 'q '.$this->TextColor.' ';
|
||||||
}
|
}
|
||||||
// rendering mode
|
// rendering mode
|
||||||
|
|
@ -5801,7 +5829,7 @@ class TCPDF {
|
||||||
if ($this->overline) {
|
if ($this->overline) {
|
||||||
$s .= ' '.$this->_dooverlinew($xdx, $basefonty, $width);
|
$s .= ' '.$this->_dooverlinew($xdx, $basefonty, $width);
|
||||||
}
|
}
|
||||||
if ($this->ColorFlag) {
|
if ($this->ColorFlag AND ($this->textrendermode < 4)) {
|
||||||
$s .= ' Q';
|
$s .= ' Q';
|
||||||
}
|
}
|
||||||
if ($link) {
|
if ($link) {
|
||||||
|
|
@ -7261,8 +7289,12 @@ class TCPDF {
|
||||||
// encode spaces on filename (file is probably an URL)
|
// encode spaces on filename (file is probably an URL)
|
||||||
$file = str_replace(' ', '%20', $file);
|
$file = str_replace(' ', '%20', $file);
|
||||||
}
|
}
|
||||||
|
if (@file_exists($file)) {
|
||||||
// get image dimensions
|
// get image dimensions
|
||||||
$imsize = @getimagesize($file);
|
$imsize = @getimagesize($file);
|
||||||
|
} else {
|
||||||
|
$imsize = false;
|
||||||
|
}
|
||||||
if ($imsize === FALSE) {
|
if ($imsize === FALSE) {
|
||||||
if (function_exists('curl_init')) {
|
if (function_exists('curl_init')) {
|
||||||
// try to get remote file data using cURL
|
// 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'] != '/')) {
|
if (($tag['attribute']['src'][0] == '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
|
||||||
$findroot = strpos($tag['attribute']['src'], $_SERVER['DOCUMENT_ROOT']);
|
$findroot = strpos($tag['attribute']['src'], $_SERVER['DOCUMENT_ROOT']);
|
||||||
if (($findroot === false) OR ($findroot > 1)) {
|
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'] = $_SERVER['DOCUMENT_ROOT'].$tag['attribute']['src'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$tag['attribute']['src'] = urldecode($tag['attribute']['src']);
|
$tag['attribute']['src'] = urldecode($tag['attribute']['src']);
|
||||||
$type = $this->getImageFileType($tag['attribute']['src']);
|
$type = $this->getImageFileType($tag['attribute']['src']);
|
||||||
$testscrtype = @parse_url($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
|
// replace relative path with full server path
|
||||||
$img = $this->svgdir.'/'.$img;
|
$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']);
|
$findroot = strpos($img, $_SERVER['DOCUMENT_ROOT']);
|
||||||
if (($findroot === false) OR ($findroot > 1)) {
|
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 = $_SERVER['DOCUMENT_ROOT'].$img;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$img = urldecode($img);
|
$img = urldecode($img);
|
||||||
$testscrtype = @parse_url($img);
|
$testscrtype = @parse_url($img);
|
||||||
if (!isset($testscrtype['query']) OR empty($testscrtype['query'])) {
|
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');
|
App::import('Vendor', 'fpdi/fpdi');
|
||||||
|
|
||||||
class XFPDI extends 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() {
|
function Page1Footer() {
|
||||||
$this->SetY(-30);
|
$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, "<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->MultiCell(0, 2, "PROVIDING SOLUTIONS IN", 0, 'C', null, 1, null, null, true, 0, true, false);
|
||||||
//$this->ln();
|
//$this->ln();
|
||||||
//$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(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(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);
|
$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->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(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);
|
$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> $docType
|
||||||
* @param <type> $commercialDetails
|
* @param <type> $commercialDetails
|
||||||
*/
|
*/
|
||||||
function calculateProductPage($currency,$gst, $products ,$docType, $commercialDetails) {
|
function calculateProductPage($currency,$gst, $products, $commercialDetails) {
|
||||||
|
|
||||||
$itemColwidth = 12;
|
$itemColwidth = 12;
|
||||||
$qtyColwidth = 10;
|
$qtyColwidth = 10;
|
||||||
|
|
@ -191,8 +193,12 @@ class XTCPDF extends TCPDF {
|
||||||
|
|
||||||
$this->startTransaction();
|
$this->startTransaction();
|
||||||
|
|
||||||
$fullDesc = "<b>".$principlesList[$product[$docType]['principle_id']]."</b><br>"."<b>".$product[$docType]['title'].'</b><br>'.$product[$docType]['description'];
|
$fullDesc = "<b>".$product['title'].'</b><br>'.$product['description'];
|
||||||
$this->MultiCell($descColwidth, 0, $fullDesc, 1, "L", 0, 0, null, null, true, 0, true);
|
|
||||||
|
//$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();
|
$lasth = $this->getLastH();
|
||||||
$this->rollbackTransaction($this);
|
$this->rollbackTransaction($this);
|
||||||
|
|
@ -202,23 +208,22 @@ class XTCPDF extends TCPDF {
|
||||||
|
|
||||||
//echo $product[$docType]['id']." needs ".$lasth." has $heightLeft left<br>";
|
//echo $product[$docType]['id']." needs ".$lasth." has $heightLeft left<br>";
|
||||||
|
|
||||||
$itemno = $product[$docType]['item_number'];
|
$itemno = $product['item_number'];
|
||||||
|
|
||||||
if($heightLeft - $lasth <= 0) {
|
if($heightLeft - $lasth <= 0) {
|
||||||
// echo "<br>OUT OF SPACE ON PAGE $pagesRequired making a new one<br>";
|
// echo "<br>OUT OF SPACE ON PAGE $pagesRequired making a new one<br>";
|
||||||
$pagesRequired++;
|
$pagesRequired++;
|
||||||
$heightLeft = $availableHeight; //Start checking the next page;
|
$heightLeft = $availableHeight; //Start checking the next page;
|
||||||
// echo "<br>remaining height on new one = ".$heightLeft."<br>";
|
// echo "<br>remaining height on new one = ".$heightLeft."<br>";
|
||||||
$heightLeft -= $lasth;
|
$heightLeft -= $lasth;
|
||||||
$itemno = $product[$docType]['item_number'];
|
$itemno = $product['item_number'];
|
||||||
// echo "<br>Using $lasth for $itemno so now have $heightLeft left<br>";
|
// echo "<br>Using $lasth for $itemno so now have $heightLeft left<br>";
|
||||||
|
|
||||||
$pageProducts[$pagesRequired][] = $product[$docType]['id'];
|
$pageProducts[$pagesRequired][] = $product['id'];
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$heightLeft -= $lasth;
|
$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.
|
/* 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.
|
* 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();
|
$this->startTransaction();
|
||||||
$subtotal = 0;
|
$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);
|
$this->rollbackTransaction($this);
|
||||||
|
|
||||||
//echo "Currently have $heightLeft Comm details height is ".$commDetailsHeight." totals height is: ".$totalsHeight."<br>";
|
//echo "Currently have $heightLeft Comm details height is ".$commDetailsHeight." totals height is: ".$totalsHeight."<br>";
|
||||||
|
|
@ -263,6 +271,7 @@ class XTCPDF extends TCPDF {
|
||||||
|
|
||||||
|
|
||||||
debug($pageProducts);
|
debug($pageProducts);
|
||||||
|
print_r($pageProducts);
|
||||||
return $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.
|
$options = 0; //Toggled to 1 when we encounter an Optional product. Stops the totals being printed.
|
||||||
|
|
||||||
print_r($principlesList[0]);
|
|
||||||
foreach ($pageProducts as $page) {
|
foreach ($pageProducts as $page) {
|
||||||
|
|
||||||
$this->AddPage();
|
$this->AddPage();
|
||||||
|
|
@ -496,7 +504,7 @@ class XTCPDF extends TCPDF {
|
||||||
|
|
||||||
$totalHeight = 0;
|
$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();
|
$totalHeight += $this->getLastH();
|
||||||
|
|
||||||
$validUntilDate = strtotime($details["dateIssued"]. ' + '.$details["validFor"].' days');
|
$validUntilDate = strtotime($details["dateIssued"]. ' + '.$details["validFor"].' days');
|
||||||
|
|
@ -520,12 +528,12 @@ IS SUBJECT TO CHANGE IF QUANTITIES VARY.
|
||||||
ENDHTMLCONTENTS;
|
ENDHTMLCONTENTS;
|
||||||
//$commlines = $this->getNumLines($listHtmlContents);
|
//$commlines = $this->getNumLines($listHtmlContents);
|
||||||
//echo "lines required for commercial comments: ".$commlines;
|
//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();
|
$totalHeight += $this->getLastH();
|
||||||
|
|
||||||
$this->MultiCell(0, 0, "Signed: ____________________________", 0, 'L');
|
//$this->MultiCell(0, 0, "Signed: ____________________________", 0, 'L');
|
||||||
$totalHeight += $this->getLastH();
|
$totalHeight += $this->getLastH();
|
||||||
$this->MultiCell(0, 0, " ".$details["salesEngineer"], 0, 'L');
|
//$this->MultiCell(0, 0, " ".$details["salesEngineer"], 0, 'L');
|
||||||
$totalHeight += $this->getLastH();
|
$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;
|
break;
|
||||||
|
|
||||||
case 'invoice':
|
case 'invoice':
|
||||||
echo "INVOICE!!";
|
echo $this->element('document_invoice_view');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'purchaseOrder':
|
case 'purchaseOrder':
|
||||||
|
|
@ -34,7 +34,26 @@ switch($docType) {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div id="lineItemModal" title="Add Line Item">
|
<div id="addLineItemModal" title="Add Line Item">
|
||||||
</div>
|
</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">
|
<div id="lineItemDetails">
|
||||||
<?
|
<?
|
||||||
echo $form->create('LineItem', array('default'=>false));
|
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.document_id', array('type'=>'hidden', 'value'=>$document['Document']['id']));
|
||||||
echo $form->input('LineItem.item_number');
|
echo $form->input('LineItem.item_number', array('class'=>'number_input'));
|
||||||
echo $form->input('LineItem.option');
|
echo $form->input('LineItem.option', array('type'=>'select','options'=>$yesNo));
|
||||||
echo $form->input('LineItem.quantity');
|
echo $form->input('LineItem.quantity', array('class'=>'number_input quickpricing'));
|
||||||
echo $form->input('LineItem.title');
|
echo $form->input('LineItem.title');
|
||||||
echo $form->input('LineItem.description');
|
echo $form->input('LineItem.description');
|
||||||
echo $form->input('LineItem.product_id', array('type'=>'hidden'));
|
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();
|
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) {
|
if($document['Quote']['revision'] > 0) {
|
||||||
echo "Revision {$document['Quote']['revision']}";
|
echo "Revision {$document['Quote']['revision']}";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
for
|
||||||
|
<?=$html->link($enquiry['Customer']['name'], array('controller'=>'customers','action'=>'view',$enquiry['Customer']['id']));?>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
<?
|
<?
|
||||||
|
|
||||||
echo $form->create('Document',array('type'=>'post','action'=>'edit', 'default'=>false));
|
echo $form->create('Document',array('type'=>'post','action'=>'edit', 'default'=>false));
|
||||||
|
|
@ -13,6 +17,7 @@ echo $form->input('Document.id');
|
||||||
<div class="docButtons">
|
<div class="docButtons">
|
||||||
<button id="addPage">Add Content Page</button>
|
<button id="addPage">Add Content Page</button>
|
||||||
<button id="addLineItem">Add Line Item</button>
|
<button id="addLineItem">Add Line Item</button>
|
||||||
|
<button id="editQuoteDetails">View/Edit Quote Details</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="flashMessage" class="message">
|
<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>
|
<div class="input submit"><button id="savePages">Save Pages</button></div>
|
||||||
<?=$form->end();?>
|
<?=$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($this->data);?>
|
||||||
<? //debug($enquiry);?>
|
<? //debug($enquiry);?>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php echo $javascript->link('jquery.jeditable.mini'); ?>
|
<?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)); ?>
|
<?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><?php echo $time->nice($quote['Quote']['created']);?></td>
|
||||||
<td class="actions">
|
<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'])); ?>
|
<?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="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); ?>
|
<? echo $this->element('enquiry_table', $enquiries, $status_list); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,14 @@ $class = ' class="altrow"';?>
|
||||||
*/?>
|
*/?>
|
||||||
|
|
||||||
<div class="related">
|
<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); ?>
|
<?php echo $this->element('quote_table', $quotes); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -310,5 +317,5 @@ $class = ' class="altrow"';?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<?php // debug($enquiry);?>
|
||||||
<?php debug($emails); ?>
|
<?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
|
|
@ -1,8 +1,8 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
$('button').button();
|
$('button').button();
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -13,7 +13,7 @@ $(function() {
|
||||||
<th>ITEM<br>NO.</th>
|
<th>ITEM<br>NO.</th>
|
||||||
<th>QTY</th>
|
<th>QTY</th>
|
||||||
<th>DESCRIPTION</th>
|
<th>DESCRIPTION</th>
|
||||||
<th>UNIT<br.PRICE</th>
|
<th>UNIT<br>PRICE</th>
|
||||||
<th>TOTAL<br>PRICE</th>
|
<th>TOTAL<br>PRICE</th>
|
||||||
<th>ACTIONS</th>
|
<th>ACTIONS</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
@ -21,30 +21,76 @@ $(function() {
|
||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th><?=$currencies[$document['Quote']['currency_id']]?></th>
|
<th><?=$currencyCode?></th>
|
||||||
<th><?=$currencies[$document['Quote']['currency_id']]?></th>
|
<th><?=$currencyCode?></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?foreach($document['LineItem'] as $li):?>
|
<?foreach($document['LineItem'] as $li):?>
|
||||||
<tr>
|
<tr class="lineItem">
|
||||||
<td><?=$li['item_number'];?></td>
|
<td>
|
||||||
|
<? if($li['option'] == 1) {
|
||||||
|
echo 'Option<br>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<?=$li['item_number'];?></td>
|
||||||
<td><?=$li['quantity'];?></td>
|
<td><?=$li['quantity'];?></td>
|
||||||
<td class="description"><?=$li['title'];?>
|
<td class="description"><?=$li['title'];?>
|
||||||
<?=$li['description'];?>
|
<?=$li['description'];?>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class="price">
|
||||||
<?=$li['unit_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>
|
||||||
<td>
|
<td class="price">
|
||||||
<?=$li['gross_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>
|
<td id="<?=$li['id'];?>">
|
||||||
<button class="editLineItem">Edit</button><br>
|
<button class="editLineItem">Edit</button><br>
|
||||||
<button class="removeLineItem">Remove</button>
|
<button class="removeLineItem">Remove</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?endforeach;?>
|
<?endforeach;?>
|
||||||
</tbody>
|
</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>
|
</table>
|
||||||
|
|
@ -66,9 +66,10 @@
|
||||||
|
|
||||||
<div class="related">
|
<div class="related">
|
||||||
<h3><?php __('Related Enquiries');?></h3>
|
<h3><?php __('Related Enquiries');?></h3>
|
||||||
<?php if (!empty($principle['Enquiry'])):?>
|
|
||||||
|
<div id="enquiryTable">
|
||||||
<? echo $this->element('enquiry_table', $enquiries); ?>
|
<? echo $this->element('enquiry_table', $enquiries); ?>
|
||||||
<?php endif; ?>
|
</div>
|
||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -117,8 +118,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<? echo $javascript->link('add_user'); ?>
|
<? //echo $javascript->link('add_user'); ?>
|
||||||
<div id="addUserDiv">
|
<div id="addUserDiv" style="display: none;">
|
||||||
|
|
||||||
<?php echo $form->create('User');?>
|
<?php echo $form->create('User');?>
|
||||||
|
|
||||||
|
|
@ -141,4 +142,4 @@
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<?php debug($principleContacts); ?>
|
<?php debug($principle); ?>
|
||||||
0
views/quotes/ajax_edit.ctp
Normal file
0
views/quotes/ajax_edit.ctp
Normal file
|
|
@ -1,34 +1,26 @@
|
||||||
<div class="quotes form">
|
<script type="text/javascript">
|
||||||
<?php echo $form->create('Quote');?>
|
$(function() {
|
||||||
<fieldset>
|
$("button").button();
|
||||||
<legend><?php __('Edit Quote');?></legend>
|
});
|
||||||
<?php
|
|
||||||
echo $form->input('id');
|
</script>
|
||||||
echo $form->input('enquiry_id');
|
<?php
|
||||||
echo $form->input('currency_id');
|
echo $form->create('Quote',array('default'=>false));
|
||||||
echo $form->input('revision');
|
|
||||||
echo $form->input('delivery_time');
|
echo $form->input('id');
|
||||||
echo $form->input('payment_terms');
|
echo $form->input('enquiry_id', array('type'=>'hidden'));
|
||||||
echo $form->input('days_valid');
|
echo $form->input('currency_id');
|
||||||
echo $form->input('date_issued');
|
echo $form->input('revision', array('type'=>'hidden'));
|
||||||
echo $form->input('valid_until');
|
echo $form->input('delivery_time');
|
||||||
echo $form->input('delivery_point');
|
echo $form->input('payment_terms');
|
||||||
echo $form->input('exchange_rate');
|
echo $form->input('days_valid');
|
||||||
echo $form->input('customs_duty');
|
echo $form->input('date_issued');
|
||||||
echo $form->input('document_id');
|
echo $form->input('valid_until');
|
||||||
?>
|
echo $form->input('delivery_point');
|
||||||
</fieldset>
|
echo $form->input('exchange_rate');
|
||||||
<?php echo $form->end('Submit');?>
|
echo $form->input('customs_duty');
|
||||||
</div>
|
echo $form->input('document_id',array('type'=>'hidden'));
|
||||||
<div class="actions">
|
echo $form->input('commercial_comments', array('between'=>'<button class="generateCommercialComments">(re)Generate Commercial Comments</button>'));
|
||||||
<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>
|
echo $form->end();
|
||||||
<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['User']['first_name'].' '.$enquiry['User']['last_name'], $enquiry['User']['email'], $cmcRef,
|
||||||
$enquiry['Enquiry']['customer_reference'], $quote['Quote']['date_issued']);
|
$enquiry['Enquiry']['customer_reference'], $quote['Quote']['date_issued']);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -786,6 +786,10 @@ input#searchbox {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
input.number_input {
|
||||||
|
width: 80px;
|
||||||
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
clear: both;
|
clear: both;
|
||||||
font-size: 120%;
|
font-size: 120%;
|
||||||
|
|
@ -1534,3 +1538,14 @@ table.lineItems tr td.description {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
padding: 0.5em;
|
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() {
|
$(function() {
|
||||||
|
|
@ -11,18 +18,15 @@ $(function() {
|
||||||
|
|
||||||
$("#lineItemDetails").hide();
|
$("#lineItemDetails").hide();
|
||||||
|
|
||||||
$( "#lineItemModal" ).dialog({
|
$( "#addLineItemModal" ).dialog({
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
height: 900,
|
height: 900,
|
||||||
width: 600,
|
width: 600,
|
||||||
modal: true,
|
modal: true,
|
||||||
buttons: {
|
buttons: {
|
||||||
"Add Line Item": function() {
|
"Add Line Item": function() {
|
||||||
/*for ( instance in CKEDITOR.instances ) {
|
|
||||||
CKEDITOR.instances[instance].updateElement();
|
$('#QuoteCommercialComments').ckeditor(function() {
|
||||||
CKEDITOR.instances[instance].destroy();
|
|
||||||
}*/
|
|
||||||
$('#LineItemDescription').ckeditor(function() {
|
|
||||||
this.updateElement();
|
this.updateElement();
|
||||||
this.destroy();
|
this.destroy();
|
||||||
});
|
});
|
||||||
|
|
@ -31,14 +35,47 @@ $(function() {
|
||||||
var thisLineItemInputs = $('#LineItemAddForm').find('input,select,textarea');
|
var thisLineItemInputs = $('#LineItemAddForm').find('input,select,textarea');
|
||||||
|
|
||||||
$.post('/line_items/ajax_add', thisLineItemInputs, function(data) {
|
$.post('/line_items/ajax_add', thisLineItemInputs, function(data) {
|
||||||
$( "#lineItemModal" ).dialog('close');
|
$( "#addLineItemModal" ).dialog('close');
|
||||||
loadLineItems();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
Cancel: function() {
|
Cancel: function() {
|
||||||
$( this ).dialog( "close" );
|
$( this ).dialog( "close" );
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
close: function() {
|
||||||
loadLineItems();
|
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() {
|
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();
|
$("#pageContentFactory").hide();
|
||||||
|
|
@ -98,13 +166,29 @@ $(function() {
|
||||||
//Open the LineItem dialog
|
//Open the LineItem dialog
|
||||||
$("#addLineItem").button().click(function() {
|
$("#addLineItem").button().click(function() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var docID = $('#documentID').html();
|
var docID = $('#documentID').html();
|
||||||
|
|
||||||
|
$('#LineItemDescription').ckeditor(function() {
|
||||||
|
this.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#editLineItemModal").empty();
|
||||||
|
|
||||||
|
var nextItemNo = $(".lineItem").length;
|
||||||
|
nextItemNo++;
|
||||||
|
|
||||||
$.get('/line_items/add/'+docID, function(data) {
|
$.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();
|
$("#productDetails").hide();
|
||||||
$('#LineItemDescription').ckeditor(config);
|
$('#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() {
|
$("#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() {
|
function loadLineItems() {
|
||||||
var documentID = $("#documentID").html();
|
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'],
|
['Image','Table','HorizontalRule','SpecialChar'],
|
||||||
'/',
|
'/',
|
||||||
['Styles','Format'],
|
['Styles','Format'],
|
||||||
['Bold','Italic','Strike'],
|
['Bold','Italic','Strike','Underline'],
|
||||||
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
|
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
|
||||||
['Link','Unlink'],
|
['Link','Unlink'],
|
||||||
['Maximize','-','About']
|
['Maximize','-','About']
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue