635 lines
21 KiB
PHP
Executable file
635 lines
21 KiB
PHP
Executable file
<?php
|
|
|
|
App::import('Vendor','tcpdf/tcpdf');
|
|
|
|
|
|
class XTCPDF extends TCPDF {
|
|
|
|
var $xheadertext = 'PDF created using CakePHP and TCPDF';
|
|
var $xheadercolor = array(0,0,200);
|
|
var $xfootertext = 'Copyright © %d XXXXXXXXXXX. All rights reserved.';
|
|
var $xfooterfont = PDF_FONT_NAME_MAIN ;
|
|
var $xfooterfontsize = 8 ;
|
|
|
|
|
|
function Page1Header() {
|
|
|
|
|
|
list($r, $b, $g) = $this->xheadercolor;
|
|
|
|
|
|
//$this->setY(10); // shouldn't be needed due to page margin, but helas, otherwise it's at the page top
|
|
|
|
$this->SetFillColor(255, 255, 255);
|
|
$this->SetTextColor(0 , 0, 152); //Set the Text Color to Blue
|
|
|
|
// $this->Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $ismask, $imgmask, $border, $fitbox, $hidden)
|
|
|
|
$this->Image(K_PATH_IMAGES.'cmclogosmall.jpg', 10, 10, 30, 0, null, 'http://www.cmctechnologies.com.au', null, false, null, 'L');
|
|
$this->Cell(30);
|
|
$this->SetFont('times', 'B');
|
|
$this->SetFontSize(30);
|
|
$this->Cell(0,0, $this->xheadertext, 0,1,'C', 1);
|
|
$this->SetFontSize(10);
|
|
$this->SetY(22);
|
|
$this->Cell(30);
|
|
$this->Cell(0,0, "PTY LIMITED ACN: 47 085 991 224 ABN: 47 085 991 224", 0, 1, 'C', 1);
|
|
|
|
|
|
$this->Rect($this->GetX()+33, $this->GetY()+2, 157, 2, 'DF', array('width'=>0), array(0, 0, 0));
|
|
/* Start the contact details */
|
|
$this->SetTextColor(0); //Set the Text Color to Black
|
|
$this->MultiCell(18, 0, "Phone:\nFax:\nEmail:\nWeb Site:\n", 0, 'L', 0, 0, 45, 32);
|
|
|
|
|
|
|
|
$this->MultiCell(50, 0, "+61 2 9669 4000<br>+61 2 9669 4111<br><a href=\"mailto:sales@cmctechnologies.com.au\">sales@cmctechnologies.com.au</a>
|
|
<br><a href=\"http://www.cmctechnologies.com.au\">www.cmctechnologies.com.au</a><br>", 0, 'L', 0, 0, 65, null, true, 0, true);
|
|
|
|
$this->MultiCell(50, 0, "Unit 19, 77 Bourke Rd\nAlexandria\nNSW 2015\nAUSTRALIA\n", 0, 'L', 0, 0, 150, null);
|
|
|
|
$this->SetTextColor(0 , 0, 152); //Set the Text Color to Blue
|
|
$this->SetFont('times', 'B');
|
|
$this->MultiCell(30, 20, "Engineering &\nIndustrial\nInstrumentation", 0, 'L', 0, 1, 10,37);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
* Overwrites the default footer
|
|
* set the text in the view using
|
|
* $fpdf->xfootertext = 'Copyright © %d YOUR ORGANIZATION. All rights reserved.';
|
|
*/
|
|
function Page1Footer() {
|
|
$this->SetY(-30);
|
|
/*//$this->Image(K_PATH_IMAGES.'cmcfooter.jpg', null, 255, 200, 0, null, 'http://www.cmctechnologies.com.au', null, false, null, 'C');
|
|
$this->MultiCell(0, 2, "<hr>", 0, 'C', null, 1, null, null, true, 0, true, false);
|
|
// $this->MultiCell(0, 2, "PROVIDING SOLUTIONS IN", 0, 'C', null, 1, null, null, true, 0, true, false);
|
|
//$this->ln();
|
|
//$this->ln();
|
|
$this->SetFontSize(10);
|
|
$this->MultiCell(120, 2, "<span style=\"color: #DF0101; font-weight: bold\">EXPLOSION PREVENTION</span>", 0, 'L', null, 0, null, null, true, 0, true, false);
|
|
$this->MultiCell(0, 2, "<span style=\"color: #DF0101; font-weight: bold\">PRESSURE RELIEF</span>", 0, 'R', null, 1, null, null, true, 0, true, false);
|
|
$this->MultiCell(120, 2, "<span style=\"color: #088A4B; font-weight: bold\">EXPLOSION PROTECTION</span>", 0, 'L', null, 0, null, null, true, 0, true, false);
|
|
$this->MultiCell(0, 2, "<span style=\"color: #088A4B; font-weight: bold\">VISION IN THE PROCESS</span>", 0, 'R', null, 1, null, null, true, 0, true, false);
|
|
// $this->ln();
|
|
$this->MultiCell(80, 2, "<span style=\"color: #0000FF; font-weight: bold\">FLOW MEASUREMENT</span>", 0, 'L', null, 0, null, null, true, 0, true, false);
|
|
$this->MultiCell(0, 2, "<span style=\"color: #0000FF; font-weight: bold\">PROCESS INSTRUMENTATION</span>", 0, 'R', null, 1, null, null, true, 0, true, false);
|
|
*/
|
|
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
* For Quotes and (hopefully) Invoices. Identifies who the document is for, date, reference number, etc.
|
|
*/
|
|
function DetailsBox($companyName, $emailTo, $attention, $fromName, $fromEmail, $enquiryNumber, $your_reference, $issuedate) {
|
|
|
|
$this->SetTextColor(0); //Black Text
|
|
|
|
$boxYstart = 45;
|
|
$boxXstart = 10;
|
|
$firstColWidth = 40;
|
|
$secondColWidth = 70;
|
|
$thirdColWidth = 30;
|
|
$fourthColWidth = -10;
|
|
|
|
$pageNo = $this->PageNoFormatted();
|
|
|
|
$this->SetXY($boxXstart, 55);
|
|
|
|
$heightNeeded = $this->getNumLines($companyName, $secondColWidth);
|
|
|
|
|
|
$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.
|
|
|
|
|
|
|
|
|
|
$this->MultiCell($firstColWidth, $lineHeight*$heightNeeded, "QUOTATION TO:", 'LTR', 'L', 0, 0);
|
|
$this->MultiCell($secondColWidth, $lineHeight*$heightNeeded, $companyName, 'LTR', 'L', 0, 0);
|
|
|
|
$this->MultiCell($thirdColWidth, $lineHeight*$heightNeeded, "FROM:", 'LT', 'L', 0, 0);
|
|
$this->MultiCell($fourthColWidth, $lineHeight*$heightNeeded, "<a href=\"mailto:$fromEmail\">$fromName</a>", 'TR', 'L', 0, 1, null,null, true,0,true); //Start a new line after this.
|
|
|
|
|
|
$this->MultiCell($firstColWidth, 0, "EMAIL TO:", 'LR', 'L', 0, 0);
|
|
$this->MultiCell($secondColWidth, 0, "<a href=\"mailto:$emailTo\">$emailTo</a>", 'LR','L', 0, 0, null, null, true, 0, true);
|
|
$this->MultiCell($thirdColWidth, 0, "CMC REF#:", 'L', 'L', 0, 0);
|
|
$this->MultiCell($fourthColWidth, 0, $enquiryNumber, 'R', 'L', 0, 1); //Start a new line after thi
|
|
|
|
$this->MultiCell($firstColWidth, 0, "ATTENTION:", 'LRB', 'L', 0, 0);
|
|
$this->MultiCell($secondColWidth, 0, $attention, 'LRB', 'L', 0, 0);
|
|
$this->MultiCell($thirdColWidth, 0, "PAGE: ", 'LB', 'L', 0, 0);
|
|
$this->MultiCell($fourthColWidth, 0, "$pageNo of {nb}", 'BR', 'L', 0, 1);
|
|
|
|
$todayPHPdate = strtotime($issuedate);
|
|
|
|
$todaysDateString = date('l, j F Y', $todayPHPdate);
|
|
$this->MultiCell($firstColWidth + $secondColWidth, 0, "DATE: $todaysDateString", 'LRB', 'L', 0, 0);
|
|
$this->MultiCell($thirdColWidth, 0, "YOUR REF: ", 'LB', 'L', 0, 0);
|
|
|
|
|
|
$this->MultiCell($fourthColWidth, 0, $your_reference, 'BR', 'L', 0, 1);
|
|
$this->SetFontSize(6);
|
|
|
|
//Kinda lame that I cant seem to wrap this text nicer. But Whatever.
|
|
$this->MultiCell(0, 0, 'The information in this document is confidential and may be privileged. If you are not the indended recipient then access, disclosure, copying or other dissemination of the contents of t his message is unauthorised and may be unlawful. Please inform the sender immediately if you are not the intended addressee.',
|
|
'', 'L'
|
|
);
|
|
|
|
}
|
|
|
|
|
|
function continuedHeader($cmcRef) {
|
|
$this->Image(K_PATH_IMAGES.'cmclogosmall.jpg', 10, 10, 15, 13.6, null, 'http://www.cmctechnologies.com.au', null, false, null, 'L');
|
|
$this->SetFontSize(10);
|
|
$pageNo = $this->PageNoFormatted();
|
|
|
|
|
|
$currentX = $this->GetX();
|
|
|
|
$this->SetX($currentX + 40);
|
|
|
|
$this->MultiCell(100, 13.6, $cmcRef." CONTINUES", '','C', 0, 0);
|
|
$this->MultiCell(0,13.6, "PAGE $pageNo OF {nb}", '', 'R');
|
|
//$this->MultiCell($w, $h, $txt, $border, $align, $fill, $ln, $x, $y, $reseth, $stretch, $ishtml)
|
|
//$this->Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
* Start a TCPDF transaction and do the calculations for the product table.
|
|
* @param <type> $principleName
|
|
* @param <type> $currency
|
|
* @param <type> $gst
|
|
* @param <type> $products
|
|
* @param <type> $docType
|
|
* @param <type> $commercialDetails
|
|
*/
|
|
function calculateProductPage($currency,$gst, $products, $commercialDetails) {
|
|
|
|
$itemColwidth = 12;
|
|
$qtyColwidth = 10;
|
|
$descColwidth = 120;
|
|
$unitpriceColwidth = 25;
|
|
$totalPricColwidth = -10;
|
|
|
|
|
|
//$availableHeight = 253;
|
|
$availableHeight = 230;
|
|
|
|
$heightLeft = $availableHeight; //height left on this particular page.
|
|
|
|
$pagesRequired = 1;
|
|
|
|
foreach ($products as $product) {
|
|
|
|
$this->startTransaction();
|
|
|
|
$fullDesc = "<b>".$product['title'].'</b><br>'.$product['description'];
|
|
|
|
//$this->MultiCell($descColwidth, 0, $fullDesc, 1, "L", 0, 0, null, null, true, 0, true, true, 0, 'T', false);
|
|
// die($fullDesc);
|
|
|
|
//$this->MultiCell($descColwidth, 0, $fullDesc, 1, 'L', false, 1, 0, 0, true, 0, true, true);
|
|
|
|
$lasth = $this->getLastH();
|
|
$this->rollbackTransaction($this);
|
|
//echo "Last height needed for item: ".$product[$docType]['item_number']." was: ".$lasth."<br>";
|
|
|
|
|
|
|
|
//echo $product[$docType]['id']." needs ".$lasth." has $heightLeft left<br>";
|
|
|
|
$itemno = $product['item_number'];
|
|
if($heightLeft - $lasth <= 0) {
|
|
// echo "<br>OUT OF SPACE ON PAGE $pagesRequired making a new one<br>";
|
|
$pagesRequired++;
|
|
$heightLeft = $availableHeight; //Start checking the next page;
|
|
// echo "<br>remaining height on new one = ".$heightLeft."<br>";
|
|
$heightLeft -= $lasth;
|
|
$itemno = $product['item_number'];
|
|
// echo "<br>Using $lasth for $itemno so now have $heightLeft left<br>";
|
|
|
|
$pageProducts[$pagesRequired][] = $product['id'];
|
|
|
|
}
|
|
else {
|
|
$heightLeft -= $lasth;
|
|
$pageProducts[$pagesRequired][] = $product['id'];
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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.
|
|
*/
|
|
|
|
|
|
$this->startTransaction();
|
|
$subtotal = 0;
|
|
|
|
//$totalsHeight = $this->totals($currency, $subtotal, 1);
|
|
$commDetailsHeight = $this->commercialComments($commercialDetails);
|
|
echo "WOTOTOTO1111T";
|
|
$this->rollbackTransaction($this);
|
|
|
|
//echo "Currently have $heightLeft Comm details height is ".$commDetailsHeight." totals height is: ".$totalsHeight."<br>";
|
|
|
|
$heightLeft -= $totalsHeight;
|
|
|
|
if($heightLeft <= 0) {
|
|
// echo "<br>Need a new page for last item and totals";
|
|
//array_pop($pageProducts[$pagesRequired]);
|
|
$pagesRequired++;
|
|
$heightLeft = $availableHeight;
|
|
$heightLeft -= $totalsHeight;
|
|
//$pageProducts[$pagesRequired][] = $product[$docType]['id'];
|
|
}
|
|
|
|
echo "Height left before commDetails is:".$heightLeft;
|
|
echo "Comm Details Height is:".$commDetailsHeight;
|
|
|
|
$heightLeft -= $commDetailsHeight;
|
|
echo "Heigh Left is now:".$heightLeft;
|
|
|
|
if($heightLeft <= 0) {
|
|
$pagesRequired++;
|
|
}
|
|
|
|
|
|
debug($pageProducts);
|
|
print_r($pageProducts);
|
|
return $pageProducts;
|
|
}
|
|
|
|
|
|
/**
|
|
*
|
|
* @param Map $principles - list of principles. A hack so we can show a products principle name on it, without rewriting
|
|
* lots of code.
|
|
* @param <type> $currency
|
|
* @param int $gst - 0 or 1 if GST is applicable.
|
|
* @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 Map $commercialDetails - the details array/map - passed to commercialComments()
|
|
*/
|
|
function productPage($currency,$gst, $products ,$docType, $commercialDetails, $pageProducts) {
|
|
|
|
|
|
$this->SetFontSize(10);
|
|
|
|
$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 = 12;
|
|
$qtyColwidth = 10;
|
|
$descColwidth = 120;
|
|
$unitpriceColwidth = 25;
|
|
$totalPricColwidth = -10;
|
|
|
|
$this->SetFillColor(240);
|
|
|
|
|
|
$subTotal = 0;
|
|
|
|
$options = 0; //Toggled to 1 when we encounter an Optional product. Stops the totals being printed.
|
|
|
|
foreach ($pageProducts as $page) {
|
|
|
|
$this->AddPage();
|
|
|
|
//Draw Header Rows
|
|
$this->setFontSize(12);
|
|
$pageNo = $this->PageNoFormatted();
|
|
$this->MultiCell(0, 0, "PAGE $pageNo OF {nb}", 0, "R", 0, 1);
|
|
$this->MultiCell(0, 0, "PRICING & SPECIFICATIONS", 0, "C", 0, 1);
|
|
$this->setFontSize(10);
|
|
$this->MultiCell($itemColwidth, 0, "ITEM NO.", 1, "C", 1, 0);
|
|
|
|
$heightNeeded = $this->getLastH();
|
|
/**
|
|
* @todo this seems like a cleaner way of doing it than I did in the detailsBox(). Revise at some point
|
|
*/
|
|
|
|
|
|
$this->MultiCell($qtyColwidth, $heightNeeded, "QTY", 1, "C", 1, 0);
|
|
$this->MultiCell($descColwidth, $heightNeeded, "DESCRIPTION", 1, "C", 1, 0);
|
|
$this->MultiCell($unitpriceColwidth, $heightNeeded, "UNIT\nPRICE", 1, "C", 1, 0);
|
|
$this->MultiCell($totalPricColwidth, $heightNeeded, "TOTAL\nPRICE", 1, "C", 1, 1);
|
|
|
|
//Header Line 2
|
|
|
|
$this->MultiCell($itemColwidth, 0, "", 1, "C", 1, 0);
|
|
|
|
$heightNeeded = $this->getLastH();
|
|
$this->MultiCell($qtyColwidth, $heightNeeded, "", 1, "C", 1, 0);
|
|
$this->MultiCell($descColwidth, $heightNeeded, "", 1, "C", 1, 0); //Principle Name used to go here.
|
|
$this->MultiCell($unitpriceColwidth, $heightNeeded, $currency['iso4217'], 1, "C", 1, 0);
|
|
$this->MultiCell($totalPricColwidth, $heightNeeded, $currency['iso4217'], 1, "C", 1, 1);
|
|
|
|
|
|
// echo "<h2>$pageNo</h2>";
|
|
// print_r($page);
|
|
|
|
//Start Printing Product cells, until we run out of room. Then continue on the next page
|
|
|
|
foreach($page as $productID) {
|
|
$product = array_shift($products);
|
|
|
|
if($product['Principle']['id'] != null) {
|
|
$fullDesc = "<b>".$product['Principle']['name']."</b><br>"."<b>".$product[$docType]['title'].'</b><br>'.$product[$docType]['description'];
|
|
}
|
|
else {
|
|
$fullDesc = "<b>".$product[$docType]['title'].'</b><br>'.$product[$docType]['description'];
|
|
|
|
}
|
|
|
|
if($product[$docType]['option'] == 1) {
|
|
$options = 1;
|
|
}
|
|
|
|
|
|
$currentX = $this->GetX();
|
|
$currentY = $this->GetY();
|
|
|
|
$this->SetX($currentX + $itemColwidth + $qtyColwidth);
|
|
$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);
|
|
|
|
if($product[$docType]['discount_percent'] != 0) {
|
|
|
|
|
|
$percentage = number_format($product[$docType]['discount_percent'], 2);
|
|
|
|
$unitPriceString = $this->formatCurrency($currency['symbol'], $product[$docType]['unit_price']);
|
|
$unitPriceString .= "<br>less ".$percentage."% discount<br>(-"
|
|
.$this->formatCurrency($currency['symbol'], $product[$docType]['discount_amount_each']).")<br>=<br>";
|
|
$unitPriceString .= $this->formatCurrency($currency['symbol'], $product[$docType]['net_price_each']);
|
|
|
|
$totalPriceString = $this->formatCurrency($currency['symbol'], $product[$docType]['gross_price']);
|
|
$totalPriceString .= "<br>less ".$percentage."% discount<br>(-"
|
|
.$this->formatCurrency($currency['symbol'], $product[$docType]['total_discount_amount']).")<br>=<br>";
|
|
$totalPriceString .= $this->formatCurrency($currency['symbol'], $product[$docType]['net_price']);
|
|
|
|
}
|
|
else {
|
|
$unitPriceString = $this->formatCurrency($currency['symbol'], $product[$docType]['unit_price']);
|
|
$totalPriceString = $this->formatCurrency($currency['symbol'], $product[$docType]['net_price']);
|
|
|
|
}
|
|
|
|
//Unit Price Column
|
|
$this->MultiCell($unitpriceColwidth, $heightNeeded, $unitPriceString , 1, "C", 0, 0, null, null, true, 0, true);
|
|
|
|
|
|
|
|
|
|
//Net Price Column
|
|
$this->MultiCell($totalPricColwidth, $heightNeeded, $totalPriceString, 1, "C", 0, 1, null, null, true, 0, true);
|
|
|
|
|
|
|
|
$subTotal += $product[$docType]['net_price'];
|
|
$lastY = $this->GetY();
|
|
$lastX = $this->GetX();
|
|
//echo $product[$docType]['item_number']." Last X is $lastX, Last Y is $lastY <br>";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//debug($products);
|
|
|
|
|
|
|
|
|
|
//End Page For
|
|
}
|
|
|
|
/**
|
|
* 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
|
|
* 'timeScale' => (String) eg. WORKING DAYS || WEEKS || MONTHS
|
|
* 'paymentTerms => (String) eg. 100% PAYMENT WITH ORDER || NET 30 DAYS FOR APPROVED ACCOUNTS
|
|
* 'validFor' => (String) eg. 30 Days
|
|
* '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
|
|
* );
|
|
*
|
|
*
|
|
*/
|
|
|
|
|
|
|
|
$this->totals($currency, $subTotal, $gst, $options);
|
|
$this->commercialComments($commercialDetails);
|
|
|
|
|
|
$this->AliasNbPages();
|
|
$this->lastPage();
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* 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, '.', ',');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
*
|
|
* Print out the commercial comments in a CMC Quotation.
|
|
*
|
|
*
|
|
* Receives 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-10
|
|
* 'validFor' => (String) eg. 30 Days
|
|
* '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
|
|
* );
|
|
*/
|
|
function commercialComments($details) {
|
|
|
|
$totalHeight = 0;
|
|
|
|
//$this->MultiCell(0, 0, "<b><u>Commercial Comments:</u></b>", 0, 'L', 0, 1, null, null, 1, null, true);
|
|
$totalHeight += $this->getLastH();
|
|
|
|
$validUntilDate = strtotime($details["dateIssued"]. ' + '.$details["validFor"].' days');
|
|
|
|
$niceValidUntilDate = strtoupper(date('l j F Y',$validUntilDate));
|
|
|
|
$listHtmlContents = <<<ENDHTMLCONTENTS
|
|
<ol>
|
|
<li><b>DELIVERY</b> IS ESTIMATED AT {$details["deliveryTime"]} ({$details["deliveryPoint"]}) FROM RECEIPT OF YOUR TECHNICALLY AND COMMERCIALLY CLEAR ORDER.</li>
|
|
<li><b>PAYMENT TERMS:</b> {$details["paymentTerms"]}.</li>
|
|
<li><b>QUOTATION IS VALID</b> FOR: <u>{$details["validFor"]} DAYS</u> (UNTIL {$niceValidUntilDate}).</li>
|
|
<li>ALL PRICES ARE <u>{$details["deliveryPoint"]}</u>.</li>
|
|
<li>EXCHANGE RATE: {$details["exchangeRate"]}.</li>
|
|
<li>CUSTOMS DUTY INCLUDED AT: {$details["customsDuty"]}%.</li>
|
|
<li>GST: {$details["gst"]}.</li>
|
|
<li>WHEN PAYMENTS ARE MADE INTO OUR BANK ACCOUNT, BANK CHARGES ARE YOUR RESPONSIBILITY.<li>
|
|
</ol>
|
|
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.
|
|
<br>
|
|
ENDHTMLCONTENTS;
|
|
//$commlines = $this->getNumLines($listHtmlContents);
|
|
//echo "lines required for commercial comments: ".$commlines;
|
|
//$this->MultiCell(0, 0, $listHtmlContents, 0, 'L', 0, 1, null, null, 1, null, true);
|
|
$totalHeight += $this->getLastH();
|
|
|
|
//$this->MultiCell(0, 0, "Signed: ____________________________", 0, 'L');
|
|
$totalHeight += $this->getLastH();
|
|
//$this->MultiCell(0, 0, " ".$details["salesEngineer"], 0, 'L');
|
|
$totalHeight += $this->getLastH();
|
|
|
|
|
|
return $totalHeight;
|
|
}
|
|
|
|
|
|
|
|
|
|
function totals($currency, $subTotal, $gst, $options) {
|
|
|
|
$itemColwidth = 12;
|
|
$qtyColwidth = 10;
|
|
$descColwidth = 120;
|
|
$unitpriceColwidth = 25;
|
|
$totalPricColwidth = -10;
|
|
$totalHeight = 0;
|
|
|
|
// echo "desc col wdith : ".$descColwidth;
|
|
$this->MultiCell($itemColwidth, 6, "", 1, 'C', 0, 0);
|
|
$totalHeight += $this->getLastH();
|
|
$this->MultiCell($qtyColwidth, 6, "", 1, 'C', 0, 0);
|
|
$totalHeight += $this->getLastH();
|
|
$this->MultiCell($descColwidth, 6, "SUB-TOTAL (EXCLUDING GST)", 1, 'L', 0, 0);
|
|
$totalHeight += $this->getLastH();
|
|
$this->MultiCell($unitpriceColwidth, 6, "", 1, 'C', 0, 0);
|
|
$totalHeight += $this->getLastH();
|
|
if($options == 1) {
|
|
$this->MultiCell($totalPricColwidth, 6, $currency['symbol']. "TBA", 1, 'C', 0, 1);
|
|
}
|
|
else {
|
|
$this->MultiCell($totalPricColwidth, 6, $this->formatCurrency($currency['symbol'], $subTotal), 1, 'C', 0, 1);
|
|
}
|
|
|
|
|
|
$totalHeight += $this->getLastH();
|
|
|
|
$this->MultiCell($itemColwidth, 6, "", 1, 'C', 0, 0);
|
|
$totalHeight += $this->getLastH();
|
|
$this->MultiCell($qtyColwidth, 6, "", 1, 'C', 0, 0);
|
|
$totalHeight += $this->getLastH();
|
|
$this->MultiCell($descColwidth, 6, "GST (10%)", 1, 'L', 0, 0);
|
|
$totalHeight += $this->getLastH();
|
|
$this->MultiCell($unitpriceColwidth, 6, "", 1, 'C', 0, 0);
|
|
$totalHeight += $this->getLastH();
|
|
|
|
if($options == 1) {
|
|
$this->MultiCell($totalPricColwidth, 6, $currency['symbol']. "TBA", 1, 'C', 0, 1);
|
|
}
|
|
else {
|
|
if($gst == 1) {
|
|
$gstAmount = 0.1*$subTotal;
|
|
$this->MultiCell($totalPricColwidth, 6, $this->formatCurrency($currency['symbol'], $gstAmount), 1 , 'C', 0, 1);
|
|
$totalHeight += $this->getLastH();
|
|
|
|
}
|
|
else {
|
|
$this->MultiCell($totalPricColwidth, 6, "N/A", 1 , 'C', 0, 1);
|
|
$totalHeight += $this->getLastH();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$this->MultiCell($itemColwidth, 6, "", 1, 'C', 0, 0);
|
|
$totalHeight += $this->getLastH();
|
|
$this->MultiCell($qtyColwidth, 6, "", 1, 'C', 0, 0);
|
|
$totalHeight += $this->getLastH();
|
|
$this->MultiCell($descColwidth, 6, "TOTAL PAYABLE", 1, 'L', 0, 0);
|
|
$totalHeight += $this->getLastH();
|
|
$this->MultiCell($unitpriceColwidth, 6, "", 1, 'C', 0, 0);
|
|
$totalHeight += $this->getLastH();
|
|
|
|
if($options == 1) {
|
|
$this->MultiCell($totalPricColwidth, 6, $currency['symbol']. "TBA", 1, 'C', 0, 1);
|
|
}
|
|
else {
|
|
if($gst == 1) {
|
|
$totalPrice = $subTotal * 1.1;
|
|
}
|
|
else {
|
|
$totalPrice = $subTotal;
|
|
}
|
|
$this->MultiCell($totalPricColwidth, 6, $this->formatCurrency($currency['symbol'], $totalPrice), 1, 'C', 0, 1);
|
|
}
|
|
|
|
|
|
|
|
$totalHeight += $this->getLastH();
|
|
|
|
return $totalHeight;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
?>
|