PDF output working almost perfectly. Need to add commercial comments and discounts
This commit is contained in:
parent
5c75f512d7
commit
cb1d165155
|
|
@ -1,127 +1,126 @@
|
||||||
<?php
|
<?php
|
||||||
class QuotesController extends AppController {
|
class QuotesController extends AppController {
|
||||||
|
|
||||||
var $name = 'Quotes';
|
var $name = 'Quotes';
|
||||||
var $helpers = array('Html', 'Form','Ajax');
|
var $helpers = array('Html', 'Form','Ajax', 'Time');
|
||||||
|
|
||||||
var $components = array('RequestHandler');
|
var $components = array('RequestHandler');
|
||||||
|
|
||||||
function index() {
|
function index() {
|
||||||
$this->Quote->recursive = 0;
|
$this->Quote->recursive = 0;
|
||||||
$this->set('quotes', $this->paginate());
|
$this->set('quotes', $this->paginate());
|
||||||
}
|
}
|
||||||
|
|
||||||
function view($id = null) {
|
function view($id = null) {
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
$this->Session->setFlash(__('Invalid Quote.', true));
|
$this->Session->setFlash(__('Invalid Quote.', true));
|
||||||
$this->redirect(array('action'=>'index'));
|
$this->redirect(array('action'=>'index'));
|
||||||
}
|
}
|
||||||
$quote = $this->Quote->read(null, $id);
|
$quote = $this->Quote->read(null, $id);
|
||||||
$this->set('quote', $quote);
|
$this->set('quote', $quote);
|
||||||
|
|
||||||
$quoteProducts = $this->Quote->QuoteProduct->find('all', array('recursive' => 0, 'conditions' => array('QuoteProduct.quote_id' => $id),
|
$quoteProducts = $this->Quote->QuoteProduct->find('all', array('recursive' => 0, 'conditions' => array('QuoteProduct.quote_id' => $id),
|
||||||
'order' => array('QuoteProduct.item_number ASC'))
|
'order' => array('QuoteProduct.item_number ASC'))
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->set('customer', $this->Quote->Enquiry->Customer->read(null, $quote['Enquiry']['customer_id']));
|
$this->set('customer', $this->Quote->Enquiry->Customer->read(null, $quote['Enquiry']['customer_id']));
|
||||||
$this->set('quoteProducts', $quoteProducts);
|
$this->set('quoteProducts', $quoteProducts);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function add() {
|
function add() {
|
||||||
|
|
||||||
if(isset($this->params['named']['enquiryid'])) {
|
|
||||||
$enquiryid = $this->params['named']['enquiryid'];
|
|
||||||
$this->Quote->create();
|
|
||||||
$number_of_revisions = $this->Quote->findCount('Quote.enquiry_id ='. $enquiryid);
|
|
||||||
$this->data['Quote']['revision'] = $number_of_revisions;
|
|
||||||
$this->data['Quote']['enquiry_id'] = $enquiryid;
|
|
||||||
$this->data['Quote']['date_issued'] = date('Y-m-d');
|
|
||||||
|
|
||||||
$this->data['Quote']['currency_id'] = 2;
|
if(isset($this->params['named']['enquiryid'])) {
|
||||||
|
$enquiryid = $this->params['named']['enquiryid'];
|
||||||
|
$this->Quote->create();
|
||||||
|
$number_of_revisions = $this->Quote->findCount('Quote.enquiry_id ='. $enquiryid);
|
||||||
|
$this->data['Quote']['revision'] = $number_of_revisions;
|
||||||
|
$this->data['Quote']['enquiry_id'] = $enquiryid;
|
||||||
|
$this->data['Quote']['date_issued'] = date('Y-m-d');
|
||||||
|
|
||||||
/**
|
$this->data['Quote']['currency_id'] = 2;
|
||||||
* @todo Fix this hard coded default currency. Currently set to '2' for AUD.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
/**
|
||||||
if ($this->Quote->save($this->data)) {
|
* @todo Fix this hard coded default currency. Currently set to '2' for AUD.
|
||||||
$quoteid = $this->Quote->id;
|
*/
|
||||||
|
|
||||||
$this->Quote->QuotePage->create();
|
|
||||||
$this->data['QuotePage']['quote_id'] = $quoteid;
|
|
||||||
$this->data['QuotePage']['page_number'] = '1';
|
|
||||||
|
|
||||||
$this->Quote->QuotePage->save($this->data);
|
|
||||||
|
|
||||||
$this->Session->setFlash(__('The Quote has been saved', true));
|
|
||||||
$this->redirect(array('action'=>'view/'.$quoteid));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$this->Session->setFlash(__('The Quote was not saved. Something has gone wrong.', true));
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$this->Session->setFlash(__('Invalid Enquiry ID', true));
|
|
||||||
$this->redirect(array('controller'=>'enquiries','action'=>'index'));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function edit($id = null) {
|
|
||||||
if (!$id && empty($this->data)) {
|
|
||||||
$this->Session->setFlash(__('Invalid Quote', true));
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
}
|
|
||||||
if (!empty($this->data)) {
|
|
||||||
if ($this->Quote->save($this->data)) {
|
|
||||||
$this->Session->setFlash(__('The Quote has been saved', true));
|
|
||||||
$thisquote = $this->Quote->id;
|
|
||||||
$this->redirect(array('action' =>'view/'.$id), null, false);
|
|
||||||
} else {
|
|
||||||
$this->Session->setFlash(__('The Quote could not be saved. Please, try again.', true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (empty($this->data)) {
|
|
||||||
$quote = $this->Quote->read(null, $id);
|
|
||||||
$this->data = $quote;
|
|
||||||
}
|
|
||||||
$enquiry = $this->Quote->Enquiry->findById($quote['Quote']['enquiry_id']);
|
|
||||||
$currencies = $this->Quote->Currency->find('list');
|
|
||||||
$this->set(compact('enquiry', 'quote', 'currencies'));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function pdf($id = null) {
|
if ($this->Quote->save($this->data)) {
|
||||||
Configure::write('debug',0);
|
$quoteid = $this->Quote->id;
|
||||||
if(!$id) {
|
|
||||||
$this->Session->setFlash(__('Invalid Quote', true));
|
|
||||||
$this->redirect(array('controller'=>'enquiries', 'action'=>'index'));
|
|
||||||
}
|
|
||||||
$quote = $this->Quote->findById($id);
|
|
||||||
//$customer = $this->Quote->Enquiry->Customer->read(null, $quote['Enquiry']['customer_id']);
|
|
||||||
$enquiry = $this->Quote->Enquiry->find('first', array('conditions' => array('Enquiry.id' => $quote['Quote']['enquiry_id'])));
|
|
||||||
|
|
||||||
|
|
||||||
$quoteProducts = $this->Quote->QuoteProduct->find('all', array('recursive' => 0, 'conditions' => array('QuoteProduct.quote_id' => $id),
|
$this->Quote->QuotePage->create();
|
||||||
'order' => array('QuoteProduct.item_number ASC'))
|
$this->data['QuotePage']['quote_id'] = $quoteid;
|
||||||
);
|
$this->data['QuotePage']['page_number'] = '1';
|
||||||
|
|
||||||
|
$this->Quote->QuotePage->save($this->data);
|
||||||
|
|
||||||
|
$this->Session->setFlash(__('The Quote has been saved', true));
|
||||||
|
$this->redirect(array('action'=>'view/'.$quoteid));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->Session->setFlash(__('The Quote was not saved. Something has gone wrong.', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->Session->setFlash(__('Invalid Enquiry ID', true));
|
||||||
|
$this->redirect(array('controller'=>'enquiries','action'=>'index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->set('quote', $quote);
|
|
||||||
$this->set('enquiry', $enquiry);
|
|
||||||
|
|
||||||
$this->set('products', $quoteProducts);
|
function edit($id = null) {
|
||||||
|
if (!$id && empty($this->data)) {
|
||||||
|
$this->Session->setFlash(__('Invalid Quote', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
if (!empty($this->data)) {
|
||||||
|
if ($this->Quote->save($this->data)) {
|
||||||
|
$this->Session->setFlash(__('The Quote has been saved', true));
|
||||||
|
$thisquote = $this->Quote->id;
|
||||||
|
$this->redirect(array('action' =>'view/'.$id), null, false);
|
||||||
|
} else {
|
||||||
|
$this->Session->setFlash(__('The Quote could not be saved. Please, try again.', true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($this->data)) {
|
||||||
|
$quote = $this->Quote->read(null, $id);
|
||||||
|
$this->data = $quote;
|
||||||
|
}
|
||||||
|
$enquiry = $this->Quote->Enquiry->findById($quote['Quote']['enquiry_id']);
|
||||||
|
$currencies = $this->Quote->Currency->find('list');
|
||||||
|
$this->set(compact('enquiry', 'quote', 'currencies'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function pdf($id = null) {
|
||||||
|
Configure::write('debug',0);
|
||||||
|
if(!$id) {
|
||||||
|
$this->Session->setFlash(__('Invalid Quote', true));
|
||||||
|
$this->redirect(array('controller'=>'enquiries', 'action'=>'index'));
|
||||||
|
}
|
||||||
|
$quote = $this->Quote->findById($id);
|
||||||
|
//$customer = $this->Quote->Enquiry->Customer->read(null, $quote['Enquiry']['customer_id']);
|
||||||
|
$enquiry = $this->Quote->Enquiry->find('first', array('conditions' => array('Enquiry.id' => $quote['Quote']['enquiry_id'])));
|
||||||
|
|
||||||
|
|
||||||
|
$quoteProducts = $this->Quote->QuoteProduct->find('all', array('recursive' => 0, 'conditions' => array('QuoteProduct.quote_id' => $id),
|
||||||
|
'order' => array('QuoteProduct.item_number ASC'))
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$this->set('quote', $quote);
|
||||||
|
$this->set('enquiry', $enquiry);
|
||||||
|
|
||||||
|
$this->set('products', $quoteProducts);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// $this->set('customer', $customer);
|
|
||||||
//$this->layout = 'pdf';
|
|
||||||
//$this->render();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
191
vendors/xtcpdf.php
vendored
191
vendors/xtcpdf.php
vendored
|
|
@ -98,7 +98,7 @@ class XTCPDF extends TCPDF {
|
||||||
$this->SetXY($boxXstart, 55);
|
$this->SetXY($boxXstart, 55);
|
||||||
|
|
||||||
$heightNeeded = $this->getNumLines($companyName, $secondColWidth);
|
$heightNeeded = $this->getNumLines($companyName, $secondColWidth);
|
||||||
echo "Height needed: $heightNeeded";
|
//echo "Height needed: $heightNeeded";
|
||||||
|
|
||||||
$lineHeight = 6.40997; //Size of a single line of text. If the company name is more, multiply this by the number of lines it needs.
|
$lineHeight = 6.40997; //Size of a single line of text. If the company name is more, multiply this by the number of lines it needs.
|
||||||
|
|
||||||
|
|
@ -156,22 +156,23 @@ class XTCPDF extends TCPDF {
|
||||||
*
|
*
|
||||||
* @param <type> $principleName
|
* @param <type> $principleName
|
||||||
* @param <type> $currency
|
* @param <type> $currency
|
||||||
|
* @param int $gst - 0 or 1 if GST is applicable.
|
||||||
* @param <type> $products
|
* @param <type> $products
|
||||||
* @param String $docType - the model name of the Products we want to put in the table. ie. QuoteProduct, or InvoiceProduct, etc
|
* @param String $docType - the model name of the Products we want to put in the table. ie. QuoteProduct, or InvoiceProduct, etc
|
||||||
*/
|
*/
|
||||||
function productPage($principleName, $currency, $products ,$docType) {
|
function productPage($principleName, $currency,$gst, $products ,$docType) {
|
||||||
|
|
||||||
|
|
||||||
$this->SetFontSize(10);
|
$this->SetFontSize(10);
|
||||||
|
|
||||||
$lineHeight = 5.8; //Size of a single line of text. If the company name is more, multiply this by the number of lines it needs
|
$lineHeight = 5; //Size of a single line of text. If the company name is more, multiply this by the number of lines it needs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$itemColwidth = 15;
|
$itemColwidth = 12;
|
||||||
$qtyColwidth = 15;
|
$qtyColwidth = 10;
|
||||||
$descColwidth = 130;
|
$descColwidth = 120;
|
||||||
$unitpriceColwidth = 15;
|
$unitpriceColwidth = 25;
|
||||||
$totalPricColwidth = -10;
|
$totalPricColwidth = -10;
|
||||||
|
|
||||||
$this->SetFillColor(240);
|
$this->SetFillColor(240);
|
||||||
|
|
@ -181,12 +182,12 @@ class XTCPDF extends TCPDF {
|
||||||
|
|
||||||
/* Need to work out how many Pages the Product Table will need to be split over */
|
/* Need to work out how many Pages the Product Table will need to be split over */
|
||||||
|
|
||||||
echo "Product Page height is: ".$this->getPageHeight();
|
//echo "Product Page height is: ".$this->getPageHeight();
|
||||||
|
|
||||||
|
|
||||||
$availableHeight = 253; //Figured out experimentally. Approx 253mm of space left for the actual table data after the header rows.
|
$availableHeight = 253; //Figured out experimentally. Approx 253mm of space left for the actual table data after the header rows.
|
||||||
|
|
||||||
echo "Remaining space on the page is: $availableHeight <br>";
|
// echo "Remaining space on the page is: $availableHeight <br>";
|
||||||
|
|
||||||
$pagesRequired = 1;
|
$pagesRequired = 1;
|
||||||
|
|
||||||
|
|
@ -210,20 +211,34 @@ class XTCPDF extends TCPDF {
|
||||||
|
|
||||||
$remainingHeight -= $mmNeeded;
|
$remainingHeight -= $mmNeeded;
|
||||||
|
|
||||||
$pageProducts[$pagesRequired][] = $product;
|
$pageProducts[$pagesRequired][] = $product;
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$remainingHeight -= $mmNeeded;
|
$remainingHeight -= $mmNeeded;
|
||||||
$pageProducts[$pagesRequired][] = $product;
|
$pageProducts[$pagesRequired][] = $product;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* 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.
|
||||||
|
*/
|
||||||
|
if(end($products) == $product) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print_r($pageProducts[1]);
|
//print_r($pageProducts[1]);
|
||||||
|
|
||||||
echo "We need to make $pagesRequired product pages<br>";
|
//echo "We need to make $pagesRequired product pages<br>";
|
||||||
|
|
||||||
|
|
||||||
|
$subTotal = 0;
|
||||||
|
|
||||||
for($i=1; $i<=$pagesRequired; $i++) {
|
for($i=1; $i<=$pagesRequired; $i++) {
|
||||||
$this->AddPage();
|
$this->AddPage();
|
||||||
|
|
@ -232,7 +247,9 @@ class XTCPDF extends TCPDF {
|
||||||
|
|
||||||
//Draw Header Rows
|
//Draw Header Rows
|
||||||
$pageNo = $this->PageNoFormatted();
|
$pageNo = $this->PageNoFormatted();
|
||||||
$this->MultiCell(0, 0, "PRICING & SPECIFICATIONS (PAGE $pageNo OF {nb})", 0, "C", 0, 1);
|
$this->MultiCell(0, 0, "PAGE $pageNo OF {nb}", 0, "R", 0, 1);
|
||||||
|
$this->MultiCell(0, 0, "PRICING & SPECIFICATIONS", 0, "C", 0, 1);
|
||||||
|
$this->Ln();
|
||||||
|
|
||||||
$this->MultiCell($itemColwidth, 0, "ITEM\nNO.", 1, "C", 1, 0);
|
$this->MultiCell($itemColwidth, 0, "ITEM\nNO.", 1, "C", 1, 0);
|
||||||
|
|
||||||
|
|
@ -254,92 +271,126 @@ class XTCPDF extends TCPDF {
|
||||||
$heightNeeded = $this->getLastH();
|
$heightNeeded = $this->getLastH();
|
||||||
$this->MultiCell($qtyColwidth, $heightNeeded, "", 1, "C", 1, 0);
|
$this->MultiCell($qtyColwidth, $heightNeeded, "", 1, "C", 1, 0);
|
||||||
$this->MultiCell($descColwidth, $heightNeeded, $principleName, 1, "C", 1, 0);
|
$this->MultiCell($descColwidth, $heightNeeded, $principleName, 1, "C", 1, 0);
|
||||||
$this->MultiCell($unitpriceColwidth, $heightNeeded, $currency, 1, "C", 1, 0);
|
$this->MultiCell($unitpriceColwidth, $heightNeeded, $currency['iso4217'], 1, "C", 1, 0);
|
||||||
$this->MultiCell($totalPricColwidth, $heightNeeded, $currency, 1, "C", 1, 1);
|
$this->MultiCell($totalPricColwidth, $heightNeeded, $currency['iso4217'], 1, "C", 1, 1);
|
||||||
|
|
||||||
|
|
||||||
echo "POOOO";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Start Printing Product cells, until we run out of room. Then continue on the next page
|
//Start Printing Product cells, until we run out of room. Then continue on the next page
|
||||||
|
|
||||||
foreach($pageProducts[$i] as $product) {
|
foreach($pageProducts[$i] as $product) {
|
||||||
$fullDesc = "<b>".$product[$docType]['title'].'</b><br>'.$product[$docType]['description'];
|
$fullDesc = "<b>".$product[$docType]['title'].'</b><br>'.$product[$docType]['description'];
|
||||||
|
|
||||||
$linesNeeded = $this->getNumLines($fullDesc, $descColwidth);
|
|
||||||
// echo "<br>";
|
|
||||||
//echo $product[$docType]['title']." needs $linesNeeded so approx ".$linesNeeded*$lineHeight." mm <br>";
|
|
||||||
|
|
||||||
|
|
||||||
$mmNeeded = $linesNeeded*$lineHeight;
|
$currentX = $this->GetX();
|
||||||
|
$currentY = $this->GetY();
|
||||||
|
|
||||||
$this->MultiCell($itemColwidth, $mmNeeded, number_format($product[$docType]['item_number'], 1, '.', ''), 1, "C", 0, 0);
|
$this->SetX($currentX + $itemColwidth + $qtyColwidth);
|
||||||
$this->MultiCell($qtyColwidth, $mmNeeded, $product[$docType]['quantity'], 1, "C", 0, 0);
|
$this->MultiCell($descColwidth, 0, $fullDesc, 1, "L", 0, 0, null, null, true, 0, true);
|
||||||
|
$endOfDesc = $this->GetX();
|
||||||
|
$heightNeeded = $this->getLastH();
|
||||||
|
$this->SetX($currentX);
|
||||||
|
|
||||||
|
$this->MultiCell($itemColwidth, $heightNeeded, number_format($product[$docType]['item_number'], 1, '.', ''), 1, "C", 0, 0);
|
||||||
|
$this->MultiCell($qtyColwidth, $heightNeeded, $product[$docType]['quantity'], 1, "C", 0, 0);
|
||||||
|
|
||||||
|
$this->SetX($endOfDesc);
|
||||||
|
|
||||||
|
$this->MultiCell($unitpriceColwidth, $heightNeeded, $this->formatCurrency($currency['symbol'], $product[$docType]['unit_price']), 1, "C", 0, 0);
|
||||||
|
$thisTotalPrice = $product[$docType]['quantity']*$product[$docType]['unit_price'];
|
||||||
|
$this->MultiCell($totalPricColwidth, $heightNeeded, $this->formatCurrency($currency['symbol'],$thisTotalPrice), 1, "C", 0, 1);
|
||||||
|
|
||||||
|
$subTotal += $thisTotalPrice;
|
||||||
|
$lastY = $this->GetY();
|
||||||
|
$lastX = $this->GetX();
|
||||||
|
//echo $product[$docType]['item_number']." Last X is $lastX, Last Y is $lastY <br>";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(end($pageProducts[$pagesRequired]) == $product) {
|
||||||
|
|
||||||
|
|
||||||
|
//$this->MultiCell($w, $h, $txt, $border, $align, $fill, $ln, $x, $y, $reseth, $stretch, $ishtml, $autopadding);
|
||||||
|
$this->MultiCell($itemColwidth, 6, "", 1, 'C', 0, 0);
|
||||||
|
$this->MultiCell($qtyColwidth, 6, "", 1, 'C', 0, 0);
|
||||||
|
$this->MultiCell($descColwidth, 6, "SUB-TOTAL (EXCLUDING GST)", 1, 'L', 0, 0);
|
||||||
|
$this->MultiCell($unitpriceColwidth, 6, "", 1, 'C', 0, 0);
|
||||||
|
$this->MultiCell($totalPricColwidth, 6, $this->formatCurrency($currency['symbol'], $subTotal), 1, 'C', 0, 1);
|
||||||
|
|
||||||
|
$this->MultiCell($itemColwidth, 6, "", 1, 'C', 0, 0);
|
||||||
|
$this->MultiCell($qtyColwidth, 6, "", 1, 'C', 0, 0);
|
||||||
|
$this->MultiCell($descColwidth, 6, "GST (10%)", 1, 'L', 0, 0);
|
||||||
|
$this->MultiCell($unitpriceColwidth, 6, "", 1, 'C', 0, 0);
|
||||||
|
|
||||||
|
if($gst == 1) {
|
||||||
|
$gstAmount = 0.1*$subTotal;
|
||||||
|
$this->MultiCell($totalPricColwidth, 6, $this->formatCurrency($currency['symbol'], $gstAmount), 1 , 'C', 0, 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->MultiCell($totalPricColwidth, 6, "N/A", 1 , 'C', 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->MultiCell($itemColwidth, 6, "", 1, 'C', 0, 0);
|
||||||
|
$this->MultiCell($qtyColwidth, 6, "", 1, 'C', 0, 0);
|
||||||
|
$this->MultiCell($descColwidth, 6, "TOTAL PAYABLE", 1, 'L', 0, 0);
|
||||||
|
$this->MultiCell($unitpriceColwidth, 6, "", 1, 'C', 0, 0);
|
||||||
|
|
||||||
|
if($gst == 1) {
|
||||||
|
$totalPrice = $subTotal * 1.1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$totalPrice = $subTotal;
|
||||||
|
}
|
||||||
|
$this->MultiCell($totalPricColwidth, 6, $this->formatCurrency($currency['symbol'], $totalPrice), 1, 'C', 0, 1);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$this->MultiCell($descColwidth, $mmNeeded, $fullDesc, 1, "L", 0, 0, null, null, true, 0, true);
|
|
||||||
|
|
||||||
$this->MultiCell($unitpriceColwidth, $mmNeeded, "$1000", 1, "C", 0, 0);
|
|
||||||
$this->MultiCell($totalPricColwidth, $mmNeeded, "$2000", 1, "C", 0, 1);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->AliasNbPages();
|
|
||||||
$this->lastPage();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//End Page For
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// echo "Y is currently ".$this->GetY();
|
|
||||||
|
|
||||||
// $availableHeight = $this->getPageHeight() - $this->GetY() - 10;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* foreach ($products as $product) {
|
|
||||||
//Need to use the getNumLines method to figure out how big to make the cells before the description cell
|
|
||||||
$fullDesc = "<b>".$product[$docType]['title'].'</b><br>'.$product[$docType]['description'];
|
|
||||||
|
|
||||||
$linesNeeded = $this->getNumLines($fullDesc, $descColwidth);
|
|
||||||
echo "<br>";
|
|
||||||
echo $product[$docType]['title']." needs $linesNeeded so approx ".$linesNeeded*$lineHeight." mm <br>";
|
|
||||||
|
|
||||||
|
|
||||||
$mmNeeded = $linesNeeded*$lineHeight;
|
|
||||||
|
|
||||||
$this->MultiCell($itemColwidth, $mmNeeded, number_format($product[$docType]['item_number'], 1, '.', ''), 1, "C", 0, 0);
|
|
||||||
$this->MultiCell($qtyColwidth, $mmNeeded, $product[$docType]['quantity'], 1, "C", 0, 0);
|
|
||||||
|
|
||||||
$this->MultiCell($descColwidth, $mmNeeded, $fullDesc, 1, "L", 0, 0, null, null, true, 0, true);
|
|
||||||
|
|
||||||
$this->MultiCell($unitpriceColwidth, $mmNeeded, "$1000", 1, "C", 0, 0);
|
|
||||||
$this->MultiCell($totalPricColwidth, $mmNeeded, "$2000", 1, "C", 0, 1);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
* */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$this->AliasNbPages();
|
||||||
|
$this->lastPage();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// function productPageHTML() {
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to format currency in an attractive human-viewable way. Australian style. Returns the formatted string.
|
||||||
|
* @param String $symbol
|
||||||
|
*
|
||||||
|
* @param $number
|
||||||
|
*/
|
||||||
|
function formatCurrency($symbol, $number) {
|
||||||
|
list($int, $dec) = explode('.', $number); //Creates an Undefined Offset notice. Fix eventually.
|
||||||
|
|
||||||
|
if($dec > 0) {
|
||||||
|
return $symbol.number_format($number, 2, '.', ',');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return $symbol.number_format($number, 0, '.', ',');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ foreach ($quote['QuotePage'] as $page) {
|
||||||
if($page1done == false) {
|
if($page1done == false) {
|
||||||
$tcpdf->Page1Header();
|
$tcpdf->Page1Header();
|
||||||
|
|
||||||
if( (!$enqury['Enquiry']['customer_reference']) || ($enquiry['Enquiry']['customer_refernece'] == '') ) {
|
if( (!$enquiry['Enquiry']['customer_reference']) || ($enquiry['Enquiry']['customer_refernece'] == '') ) {
|
||||||
|
|
||||||
$enquiry_date = date('d/m/Y',$time->toUnix($enquiry['Enquiry']['created']));
|
$enquiry_date = date('d/m/Y',$time->toUnix($enquiry['Enquiry']['created']));
|
||||||
|
|
||||||
|
|
@ -91,7 +91,7 @@ foreach ($quote['QuotePage'] as $page) {
|
||||||
|
|
||||||
$principle_name = strtoupper($enquiry['Principle']['name']);
|
$principle_name = strtoupper($enquiry['Principle']['name']);
|
||||||
|
|
||||||
$tcpdf->productPage($principle_name, $quote['Currency']['iso4217'], $products, 'QuoteProduct');
|
$tcpdf->productPage($principle_name, $quote['Currency'], $enquiry['Enquiry']['gst'], $products, 'QuoteProduct');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -172,10 +172,13 @@ foreach ($quote['QuotePage'] as $quotePage):
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<ul>
|
<ul>
|
||||||
<li><?php echo $html->link(__('Add Product to this Quote', true), array('controller'=> 'quote_products', 'action'=>'add', $quote['Quote']['id']));?> </li>
|
<li><?php echo $html->link(__('Add Product to this Quote', true), array('controller'=> 'quote_products', 'action'=>'add', $quote['Quote']['id']));?> </li>
|
||||||
|
<li><?php echo $html->link(__('Generate PDF from this Quote', true), array('controller'=>'quotes', 'action'=>'pdf', $quote['Quote']['id'])); ?></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php debug($quote); ?>
|
<?php // debug($quote);
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
|
||||||
BIN
webroot/img/pdf.png
Executable file
BIN
webroot/img/pdf.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 6.2 KiB |
Loading…
Reference in a new issue