cmc-sales/php/app/views/quotes/pdf.ctp

148 lines
3.7 KiB
Plaintext
Raw Permalink Normal View History

<?php
2009-10-10 00:06:46 -07:00
App::import('Vendor','xtcpdf');
2010-03-03 14:23:28 -08:00
2009-10-15 23:43:17 -07:00
$tcpdf = new XTCPDF('P', 'mm', 'A4', true, false, 'UTF-8');
2009-10-10 00:06:46 -07:00
$textfont = 'times'; // looks better, finer, and more condensed than 'dejavusans'
$tcpdf->setHeaderFont(array('times','',10));
//$tcpdf->SetLeftMargin(29);
//$tcpdf->SetMargins(2, 2);
$tcpdf->SetAuthor("CMC Technologies");
2009-10-15 23:43:17 -07:00
$tcpdf->SetTitle("CMC Technologies Quote: ".$quote['Enquiry']['title']);
$tcpdf->SetAutoPageBreak( false );
$tcpdf->xheadercolor = array(150,0,0);
$tcpdf->xheadertext = 'CMC TECHNOLOGIES';
$tcpdf->xfootertext = 'Copyright © %d CMC Technologies. All rights reserved.';
$tcpdf->SetHeaderMargin(2);
$tcpdf->setPrintHeader(false);
$tcpdf->setPrintFooter(false);
$pageProducts = $tcpdf->calculateProductPage($principlesList, $quote['Currency'], $enquiry['Enquiry']['gst'], $products, 'LineItem', $commercialDetails);
2009-10-15 23:43:17 -07:00
$page1done = false; //Have we already made the first page? If so, don't show the CMC header/footer
foreach ($quote['QuotePage'] as $page) {
2009-10-29 23:29:20 -07:00
$tcpdf->AddPage();
2009-10-15 23:43:17 -07:00
2009-10-29 23:29:20 -07:00
if($page1done == false) {
$tcpdf->Page1Header();
2009-10-15 23:43:17 -07:00
if( (!$enquiry['Enquiry']['customer_reference']) || ($enquiry['Enquiry']['customer_refernece'] == '') ) {
2009-10-15 23:43:17 -07:00
2009-10-29 23:29:20 -07:00
$enquiry_date = date('d/m/Y',$time->toUnix($enquiry['Enquiry']['created']));
2009-10-15 23:43:17 -07:00
2009-10-29 23:29:20 -07:00
$enquiry['Enquiry']['customer_reference'] = "Enquiry on $enquiry_date";
}
2009-10-15 23:43:17 -07:00
2009-10-29 23:29:20 -07:00
if ($quote['Quote']['revision'] > 0) {
$cmcRef = $enquiry['Enquiry']['title'].' rev '.$quote['Quote']['revision'];
}
else {
$cmcRef = $enquiry['Enquiry']['title'];
}
2009-10-15 23:43:17 -07:00
$tcpdf->DetailsBox($docTypeFullName, $enquiry['Customer']['name'], $enquiry['Contact']['email'], $enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'],
2009-10-29 23:29:20 -07:00
$enquiry['User']['first_name'].' '.$enquiry['User']['last_name'], $enquiry['User']['email'], $cmcRef,
$enquiry['Enquiry']['customer_reference'], $quote['Quote']['date_issued']);
2009-10-15 23:43:17 -07:00
2009-10-29 23:29:20 -07:00
}
else {
$tcpdf->continuedHeader($enquiry['Enquiry']['title']);
}
2009-10-15 23:43:17 -07:00
2009-10-08 22:07:50 -07:00
2009-10-29 23:29:20 -07:00
$currentX = $tcpdf->GetX();
$currentY = $tcpdf->GetY();
2009-10-08 22:07:50 -07:00
2009-10-29 23:29:20 -07:00
$tcpdf->SetTextColor(0);
$tcpdf->SetFont('times', '', 12);
$tcpdf->writeHTMLCell(0, 0, $currentX, $currentY+5, $page['content'], '', 1, 0, true, 'L', true);
2009-10-08 22:07:50 -07:00
2009-10-29 23:29:20 -07:00
/* Only show the footer if it's the first page */
if($page1done == false) {
$tcpdf->Page1Footer();
$page1done = true;
}
2009-10-15 23:43:17 -07:00
}
//print_r($products);
print_r($principlesList);
//debug($commercialDetails);
//$tcpdf->productPageHTML($principle_name, $quote['Currency'], $enquiry['Enquiry']['gst'], $products, 'LineItem', $commercialDetails);
2009-10-15 23:43:17 -07:00
$tcpdf->productPage($principlesList, $quote['Currency'], $enquiry['Enquiry']['gst'], $products, 'LineItem', $commercialDetails,
$pageProducts);
2009-10-10 00:06:46 -07:00
//print_r($products);
2009-10-15 23:43:17 -07:00
$output_dir = '/Users/karlcordes/Sites/quotenik/app/webroot/pdf/';
2009-10-15 23:43:17 -07:00
2010-03-03 16:50:34 -08:00
$debuglevel = Configure::read('debug');
if($debuglevel == 0) {
$output_dir = '/var/www/cakephp/app/webroot/pdf/';
}
2009-10-15 23:43:17 -07:00
if($quote['Quote']['revision'] > 0) {
2009-10-29 23:29:20 -07:00
$filename = $enquiry['Enquiry']['title'].'rev'.$quote['Quote']['revision'].'.pdf';
2009-10-15 23:43:17 -07:00
}
else {
$filename = $enquiry['Enquiry']['title'].'.pdf';
}
$tcpdf->Output($output_dir.$filename, 'F');
echo "<br> Wrote: ".$output_dir.$filename;
2009-10-10 00:06:46 -07:00
//$tcpdf->Output('cmcquote.pdf', 'D');
2010-03-03 14:23:28 -08:00
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");
?>