2009-10-08 01:42:23 -07:00
< ? php
2010-03-03 14:23:28 -08:00
2009-10-08 01:42:23 -07:00
App :: import ( 'Vendor' , 'tcpdf/tcpdf' );
2010-03-03 14:23:28 -08:00
class XTCPDF extends TCPDF {
2009-10-08 01:42:23 -07:00
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 ;
2011-05-24 02:11:07 -07:00
2009-11-18 15:23:21 -08:00
function Page1Header () {
2009-10-08 01:42:23 -07:00
2009-10-08 22:07:50 -07:00
2011-05-24 02:11:07 -07:00
list ( $r , $b , $g ) = $this -> xheadercolor ;
2009-10-08 22:07:50 -07:00
2011-05-24 02:11:07 -07:00
//$this->setY(10); // shouldn't be needed due to page margin, but helas, otherwise it's at the page top
2009-11-18 15:23:21 -08:00
2011-05-24 02:11:07 -07:00
$this -> SetFillColor ( 255 , 255 , 255 );
$this -> SetTextColor ( 0 , 0 , 152 ); //Set the Text Color to Blue
2009-11-18 15:23:21 -08:00
2011-05-24 02:11:07 -07:00
// $this->Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $ismask, $imgmask, $border, $fitbox, $hidden)
2009-10-11 01:59:21 -07:00
2011-05-24 02:11:07 -07:00
$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 );
2009-11-18 15:23:21 -08:00
2011-05-24 02:11:07 -07:00
$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: \n Fax: \n Email: \n Web Site: \n " , 0 , 'L' , 0 , 0 , 45 , 32 );
2009-10-08 22:07:50 -07:00
2011-05-24 02:11:07 -07:00
$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>
2009-10-08 22:07:50 -07:00
< br >< a href = \ " http://www.cmctechnologies.com.au \" >www.cmctechnologies.com.au</a><br> " , 0 , 'L' , 0 , 0 , 65 , null , true , 0 , true );
2011-05-24 02:11:07 -07:00
$this -> MultiCell ( 50 , 0 , " Unit 19, 77 Bourke Rd \n Alexandria \n NSW 2015 \n AUSTRALIA \n " , 0 , 'L' , 0 , 0 , 150 , null );
2009-10-08 22:07:50 -07:00
2011-05-24 02:11:07 -07:00
$this -> SetTextColor ( 0 , 0 , 152 ); //Set the Text Color to Blue
$this -> SetFont ( 'times' , 'B' );
$this -> MultiCell ( 30 , 20 , " Engineering & \n Industrial \n Instrumentation " , 0 , 'L' , 0 , 1 , 10 , 37 );
2009-11-18 15:23:21 -08:00
2009-10-08 22:07:50 -07:00
2009-10-08 01:42:23 -07:00
}
/**
2009-11-18 15:23:21 -08:00
* Overwrites the default footer
* set the text in the view using
* $fpdf -> xfootertext = 'Copyright © %d YOUR ORGANIZATION. All rights reserved.' ;
*/
function Page1Footer () {
2011-05-24 02:11:07 -07:00
$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 );
*/
2010-02-18 21:38:43 -08:00
2009-10-08 22:07:50 -07:00
}
/**
* For Quotes and ( hopefully ) Invoices . Identifies who the document is for , date , reference number , etc .
*/
2010-02-22 19:49:19 -08:00
function DetailsBox ( $companyName , $emailTo , $attention , $fromName , $fromEmail , $enquiryNumber , $your_reference , $issuedate ) {
2009-10-08 22:07:50 -07:00
2011-05-24 02:11:07 -07:00
$this -> SetTextColor ( 0 ); //Black Text
2009-10-09 00:10:41 -07:00
2011-05-24 02:11:07 -07:00
$boxYstart = 45 ;
$boxXstart = 10 ;
$firstColWidth = 40 ;
$secondColWidth = 70 ;
$thirdColWidth = 30 ;
$fourthColWidth = - 10 ;
2009-11-18 15:23:21 -08:00
2011-05-24 02:11:07 -07:00
$pageNo = $this -> PageNoFormatted ();
2010-01-16 15:41:46 -08:00
2011-05-24 02:11:07 -07:00
$this -> SetXY ( $boxXstart , 55 );
2009-10-08 22:07:50 -07:00
2011-05-24 02:11:07 -07:00
$heightNeeded = $this -> getNumLines ( $companyName , $secondColWidth );
2010-01-16 15:41:46 -08:00
2009-10-09 00:10:41 -07:00
2011-05-24 02:11:07 -07:00
$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.
2009-10-14 23:58:09 -07:00
2010-01-16 15:41:46 -08:00
2009-10-09 00:10:41 -07:00
2009-10-14 23:58:09 -07:00
2011-05-24 02:11:07 -07:00
$this -> MultiCell ( $firstColWidth , $lineHeight * $heightNeeded , " QUOTATION TO: " , 'LTR' , 'L' , 0 , 0 );
$this -> MultiCell ( $secondColWidth , $lineHeight * $heightNeeded , $companyName , 'LTR' , 'L' , 0 , 0 );
2009-10-11 01:59:21 -07:00
2011-05-24 02:11:07 -07:00
$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.
2010-01-16 15:41:46 -08:00
2009-10-11 01:59:21 -07:00
2011-05-24 02:11:07 -07:00
$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
2009-10-09 00:10:41 -07:00
2011-05-24 02:11:07 -07:00
$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 );
2009-10-09 00:10:41 -07:00
2011-05-24 02:11:07 -07:00
$todayPHPdate = strtotime ( $issuedate );
2009-10-09 00:10:41 -07:00
2011-05-24 02:11:07 -07:00
$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 );
2009-10-15 23:43:17 -07:00
2011-05-24 02:11:07 -07:00
$this -> MultiCell ( $fourthColWidth , 0 , $your_reference , 'BR' , 'L' , 0 , 1 );
$this -> SetFontSize ( 6 );
2009-11-18 15:23:21 -08:00
2011-05-24 02:11:07 -07:00
//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'
);
2009-11-18 15:23:21 -08:00
2009-10-08 01:42:23 -07:00
}
2009-10-15 23:43:17 -07:00
2009-10-29 23:29:20 -07:00
function continuedHeader ( $cmcRef ) {
2011-05-24 02:11:07 -07:00
$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 ();
2010-01-16 15:41:46 -08:00
2011-05-24 02:11:07 -07:00
$currentX = $this -> GetX ();
2010-01-16 15:41:46 -08:00
2011-05-24 02:11:07 -07:00
$this -> SetX ( $currentX + 40 );
2010-01-16 15:41:46 -08:00
2011-05-24 02:11:07 -07:00
$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)
2009-10-29 23:29:20 -07:00
2009-10-15 23:43:17 -07:00
}
2010-02-25 04:48:49 -08:00
2010-02-25 15:42:21 -08:00
/**
* 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
*/
2011-05-24 02:11:07 -07:00
function calculateProductPage ( $currency , $gst , $products , $commercialDetails ) {
2010-02-25 04:48:49 -08:00
2011-05-24 02:11:07 -07:00
$itemColwidth = 12 ;
$qtyColwidth = 10 ;
$descColwidth = 120 ;
$unitpriceColwidth = 25 ;
$totalPricColwidth = - 10 ;
2009-11-18 15:23:21 -08:00
2009-11-18 17:09:56 -08:00
2011-05-24 02:11:07 -07:00
//$availableHeight = 253;
$availableHeight = 230 ;
2009-11-18 17:09:56 -08:00
2011-05-24 02:11:07 -07:00
$heightLeft = $availableHeight ; //height left on this particular page.
2009-11-18 15:23:21 -08:00
2011-05-24 02:11:07 -07:00
$pagesRequired = 1 ;
2009-11-18 15:23:21 -08:00
2011-05-24 02:11:07 -07:00
foreach ( $products as $product ) {
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
$this -> startTransaction ();
2009-11-18 15:23:21 -08:00
2011-05-24 02:11:07 -07:00
$fullDesc = " <b> " . $product [ 'title' ] . '</b><br>' . $product [ 'description' ];
2009-11-18 15:23:21 -08:00
2011-05-24 02:11:07 -07:00
//$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);
2009-11-18 15:23:21 -08:00
2011-05-24 02:11:07 -07:00
$lasth = $this -> getLastH ();
$this -> rollbackTransaction ( $this );
//echo "Last height needed for item: ".$product[$docType]['item_number']." was: ".$lasth."<br>";
2010-02-18 21:38:43 -08:00
2011-05-24 02:11:07 -07:00
2009-11-18 15:23:21 -08:00
2011-05-24 02:11:07 -07:00
//echo $product[$docType]['id']." needs ".$lasth." has $heightLeft left<br>";
2009-11-18 15:23:21 -08:00
2011-05-24 02:11:07 -07:00
$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>";
2010-02-24 22:12:27 -08:00
2011-05-24 02:11:07 -07:00
$pageProducts [ $pagesRequired ][] = $product [ 'id' ];
2009-11-18 15:23:21 -08:00
2011-05-24 02:11:07 -07:00
}
else {
$heightLeft -= $lasth ;
$pageProducts [ $pagesRequired ][] = $product [ 'id' ];
2009-11-18 15:23:21 -08:00
2011-05-24 02:11:07 -07:00
}
2009-11-18 17:09:56 -08:00
2011-05-24 02:11:07 -07:00
}
2009-11-18 15:23:21 -08:00
2009-11-19 20:04:30 -08:00
2011-05-24 02:11:07 -07:00
2010-02-25 04:48:49 -08:00
2011-05-24 02:11:07 -07:00
/* 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 .
*/
2009-11-19 20:04:30 -08:00
2010-01-16 15:41:46 -08:00
2011-05-24 02:11:07 -07:00
$this -> startTransaction ();
$subtotal = 0 ;
//$totalsHeight = $this->totals($currency, $subtotal, 1);
$commDetailsHeight = $this -> commercialComments ( $commercialDetails );
echo " WOTOTOTO1111T " ;
$this -> rollbackTransaction ( $this );
2009-11-19 20:04:30 -08:00
2011-05-24 02:11:07 -07:00
//echo "Currently have $heightLeft Comm details height is ".$commDetailsHeight." totals height is: ".$totalsHeight."<br>";
2009-11-19 20:04:30 -08:00
2011-05-24 02:11:07 -07:00
$heightLeft -= $totalsHeight ;
2010-03-03 14:23:28 -08:00
2011-05-24 02:11:07 -07:00
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'];
}
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
echo " Height left before commDetails is: " . $heightLeft ;
echo " Comm Details Height is: " . $commDetailsHeight ;
2010-06-22 21:16:46 -07:00
2011-05-24 02:11:07 -07:00
$heightLeft -= $commDetailsHeight ;
echo " Heigh Left is now: " . $heightLeft ;
2010-06-22 21:16:46 -07:00
2011-05-24 02:11:07 -07:00
if ( $heightLeft <= 0 ) {
$pagesRequired ++ ;
}
2010-03-03 14:23:28 -08:00
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
debug ( $pageProducts );
print_r ( $pageProducts );
return $pageProducts ;
2010-02-25 15:42:21 -08:00
}
2009-11-18 19:57:55 -08:00
2010-02-25 15:42:21 -08:00
/**
*
2010-03-30 21:09:27 -07:00
* @ param Map $principles - list of principles . A hack so we can show a products principle name on it , without rewriting
2011-05-24 02:11:07 -07:00
* lots of code .
2010-02-25 15:42:21 -08:00
* @ 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 ()
*/
2010-03-30 21:48:55 -07:00
function productPage ( $currency , $gst , $products , $docType , $commercialDetails , $pageProducts ) {
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
$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
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
$itemColwidth = 12 ;
$qtyColwidth = 10 ;
$descColwidth = 120 ;
$unitpriceColwidth = 25 ;
$totalPricColwidth = - 10 ;
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
$this -> SetFillColor ( 240 );
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
$subTotal = 0 ;
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
$options = 0 ; //Toggled to 1 when we encounter an Optional product. Stops the totals being printed.
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
foreach ( $pageProducts as $page ) {
2010-03-10 15:32:00 -08:00
2011-05-24 02:11:07 -07:00
$this -> AddPage ();
2010-03-10 15:32:00 -08:00
2011-05-24 02:11:07 -07:00
//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 );
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
$heightNeeded = $this -> getLastH ();
/**
* @ todo this seems like a cleaner way of doing it than I did in the detailsBox () . Revise at some point
*/
2010-02-16 19:34:17 -08:00
2011-05-24 02:11:07 -07:00
$this -> MultiCell ( $qtyColwidth , $heightNeeded , " QTY " , 1 , " C " , 1 , 0 );
$this -> MultiCell ( $descColwidth , $heightNeeded , " DESCRIPTION " , 1 , " C " , 1 , 0 );
$this -> MultiCell ( $unitpriceColwidth , $heightNeeded , " UNIT \n PRICE " , 1 , " C " , 1 , 0 );
$this -> MultiCell ( $totalPricColwidth , $heightNeeded , " TOTAL \n PRICE " , 1 , " C " , 1 , 1 );
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
//Header Line 2
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
$this -> MultiCell ( $itemColwidth , 0 , " " , 1 , " C " , 1 , 0 );
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
$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 );
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
// echo "<h2>$pageNo</h2>";
// print_r($page);
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
//Start Printing Product cells, until we run out of room. Then continue on the next page
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
foreach ( $page as $productID ) {
$product = array_shift ( $products );
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
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' ];
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
}
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
if ( $product [ $docType ][ 'option' ] == 1 ) {
$options = 1 ;
}
2010-02-25 04:48:49 -08:00
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
$currentX = $this -> GetX ();
$currentY = $this -> GetY ();
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
$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 );
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
$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 );
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
$this -> SetX ( $endOfDesc );
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
if ( $product [ $docType ][ 'discount_percent' ] != 0 ) {
2010-02-25 04:48:49 -08:00
2010-03-30 21:09:27 -07:00
2011-05-24 02:11:07 -07:00
$percentage = number_format ( $product [ $docType ][ 'discount_percent' ], 2 );
2010-03-30 21:09:27 -07:00
2011-05-24 02:11:07 -07:00
$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' ]);
2010-03-30 21:09:27 -07:00
2011-05-24 02:11:07 -07:00
$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' ]);
2010-03-30 21:09:27 -07:00
2011-05-24 02:11:07 -07:00
}
else {
$unitPriceString = $this -> formatCurrency ( $currency [ 'symbol' ], $product [ $docType ][ 'unit_price' ]);
$totalPriceString = $this -> formatCurrency ( $currency [ 'symbol' ], $product [ $docType ][ 'net_price' ]);
2010-03-30 21:09:27 -07:00
2011-05-24 02:11:07 -07:00
}
2010-03-30 21:09:27 -07:00
2011-05-24 02:11:07 -07:00
//Unit Price Column
$this -> MultiCell ( $unitpriceColwidth , $heightNeeded , $unitPriceString , 1 , " C " , 0 , 0 , null , null , true , 0 , true );
2010-03-30 21:09:27 -07:00
2010-02-25 04:48:49 -08:00
2011-05-24 02:11:07 -07:00
//Net Price Column
$this -> MultiCell ( $totalPricColwidth , $heightNeeded , $totalPriceString , 1 , " C " , 0 , 1 , null , null , true , 0 , true );
2010-02-25 04:48:49 -08:00
2011-05-24 02:11:07 -07:00
$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>";
2009-11-18 17:09:56 -08:00
2011-05-24 02:11:07 -07:00
}
2009-11-18 17:09:56 -08:00
2009-11-18 15:23:21 -08:00
2011-05-24 02:11:07 -07:00
//debug($products);
2009-11-18 15:23:21 -08:00
2010-02-25 04:48:49 -08:00
2009-11-18 19:57:55 -08:00
2011-05-24 02:11:07 -07:00
//End Page For
}
2010-02-18 21:38:43 -08:00
2011-05-24 02:11:07 -07:00
/**
* 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
* );
*
*
*/
2010-03-03 14:23:28 -08:00
2010-02-25 15:42:21 -08:00
2011-05-24 02:11:07 -07:00
$this -> totals ( $currency , $subTotal , $gst , $options );
$this -> commercialComments ( $commercialDetails );
2010-02-25 15:42:21 -08:00
2011-05-24 02:11:07 -07:00
$this -> AliasNbPages ();
$this -> lastPage ();
2010-02-25 15:42:21 -08:00
2010-02-18 21:38:43 -08:00
2010-02-25 15:42:21 -08:00
}
2010-01-16 15:41:46 -08:00
2010-02-25 15:42:21 -08:00
/**
* 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 ) {
2011-05-24 02:11:07 -07:00
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 , '.' , ',' );
}
2010-02-25 15:42:21 -08:00
}
2010-01-16 15:41:46 -08:00
2010-02-25 15:42:21 -08:00
/**
*
* 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 ) {
2011-05-24 02:11:07 -07:00
$totalHeight = 0 ;
2010-02-25 15:42:21 -08:00
2011-05-24 02:11:07 -07:00
//$this->MultiCell(0, 0, "<b><u>Commercial Comments:</u></b>", 0, 'L', 0, 1, null, null, 1, null, true);
$totalHeight += $this -> getLastH ();
2010-02-25 15:42:21 -08:00
2011-05-24 02:11:07 -07:00
$validUntilDate = strtotime ( $details [ " dateIssued " ] . ' + ' . $details [ " validFor " ] . ' days' );
2010-02-25 15:42:21 -08:00
2011-05-24 02:11:07 -07:00
$niceValidUntilDate = strtoupper ( date ( 'l j F Y' , $validUntilDate ));
2010-02-25 15:42:21 -08:00
2011-05-24 02:11:07 -07:00
$listHtmlContents = <<< ENDHTMLCONTENTS
2010-01-16 15:41:46 -08:00
< 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 ;
2011-05-24 02:11:07 -07:00
//$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 ;
2010-02-25 15:42:21 -08:00
}
2010-01-10 10:05:04 -08:00
2010-02-25 15:42:21 -08:00
2009-10-15 23:43:17 -07:00
2010-03-10 15:32:00 -08:00
function totals ( $currency , $subTotal , $gst , $options ) {
2010-02-25 15:42:21 -08:00
2011-05-24 02:11:07 -07:00
$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 ;
2010-02-25 04:48:49 -08:00
}
2010-02-25 15:42:21 -08:00
}
2009-10-10 00:06:46 -07:00
?>