118 lines
2.9 KiB
PHP
Executable file
118 lines
2.9 KiB
PHP
Executable file
<?php
|
|
App::import('Vendor','xtcpdf');
|
|
|
|
|
|
//print_r($quote);
|
|
|
|
//print_r($enquiry);
|
|
|
|
$tcpdf = new XTCPDF('P', 'mm', 'A4', true, false, 'UTF-8');
|
|
|
|
|
|
$textfont = 'times'; // looks better, finer, and more condensed than 'dejavusans'
|
|
|
|
//$tcpdf->SetTopMargin();
|
|
//$tcpdf->SetLeftMargin(29);
|
|
//$tcpdf->SetMargins(1, 1);
|
|
|
|
|
|
$tcpdf->SetAuthor("CMC Technologies");
|
|
$tcpdf->SetTitle("CMC Technologies Quote: ".$quote['Enquiry']['title']);
|
|
$tcpdf->SetAutoPageBreak( false );
|
|
$tcpdf->setHeaderFont(array($textfont,'',40));
|
|
$tcpdf->xheadercolor = array(150,0,0);
|
|
$tcpdf->xheadertext = 'CMC TECHNOLOGIES';
|
|
$tcpdf->xfootertext = 'Copyright © %d CMC Technologies. All rights reserved.';
|
|
|
|
$tcpdf->setPrintHeader(false);
|
|
$tcpdf->setPrintFooter(false);
|
|
|
|
|
|
|
|
$page1done = false; //Have we already made the first page? If so, don't show the CMC header/footer
|
|
|
|
foreach ($quote['QuotePage'] as $page) {
|
|
|
|
$tcpdf->AddPage();
|
|
|
|
if($page1done == false) {
|
|
$tcpdf->Page1Header();
|
|
|
|
if( (!$enqury['Enquiry']['customer_reference']) || ($enquiry['Enquiry']['customer_refernece'] == '') ) {
|
|
|
|
$enquiry_date = date('d/m/Y',$time->toUnix($enquiry['Enquiry']['created']));
|
|
|
|
|
|
$enquiry['Enquiry']['customer_reference'] = "Enquiry on $enquiry_date";
|
|
}
|
|
|
|
if ($quote['Quote']['revision'] > 0) {
|
|
$cmcRef = $enquiry['Enquiry']['title'].' rev '.$quote['Quote']['revision'];
|
|
}
|
|
else {
|
|
$cmcRef = $enquiry['Enquiry']['title'];
|
|
}
|
|
|
|
|
|
$tcpdf->DetailsBox($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['Enquiry']['customer_reference']);
|
|
|
|
}
|
|
else {
|
|
$tcpdf->continuedHeader($enquiry['Enquiry']['title']);
|
|
}
|
|
|
|
|
|
|
|
$currentX = $tcpdf->GetX();
|
|
$currentY = $tcpdf->GetY();
|
|
|
|
$tcpdf->SetTextColor(0);
|
|
$tcpdf->SetFont('times', '', 12);
|
|
|
|
|
|
$tcpdf->writeHTMLCell(0, 0, $currentX, $currentY+5, $page['content'], '', 1, 0, true, 'L', true);
|
|
|
|
|
|
/* Only show the footer if it's the first page */
|
|
if($page1done == false) {
|
|
$tcpdf->Page1Footer();
|
|
$page1done = true;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//print_r($products);
|
|
|
|
$principle_name = strtoupper($enquiry['Principle']['name']);
|
|
|
|
$tcpdf->productPage($principle_name, $quote['Currency']['iso4217'], $products, 'QuoteProduct');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$output_dir = '/Users/karlcordes/Sites/quotenik/app/webroot/pdf/';
|
|
|
|
if($quote['Quote']['revision'] > 0) {
|
|
$filename = $enquiry['Enquiry']['title'].'rev'.$quote['Quote']['revision'].'.pdf';
|
|
}
|
|
else {
|
|
$filename = $enquiry['Enquiry']['title'].'.pdf';
|
|
}
|
|
|
|
|
|
$tcpdf->Output($output_dir.$filename, 'F');
|
|
|
|
echo "<br> Wrote: ".$output_dir.$filename;
|
|
|
|
//$tcpdf->Output('cmcquote.pdf', 'D');
|
|
|
|
|
|
?>
|