From 234ecbbac96f52f02b76f39390eac2adc1757d47 Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Tue, 30 Aug 2011 09:28:03 +1000 Subject: [PATCH] docpdf class now extends FPDFI. Page counts now include merged T&Cs --- vendors/pdfdoc.php | 23 ++++++++++-- views/documents/pdf_invoice.ctp | 35 +------------------ views/documents/pdf_orderack.ctp | 35 +------------------ views/documents/pdf_quote.ctp | 34 +----------------- .../line_items_table_with_shipping.ctp | 17 +++++---- views/elements/pdf_output.ctp | 20 +++++++++++ 6 files changed, 55 insertions(+), 109 deletions(-) create mode 100644 views/elements/pdf_output.ctp diff --git a/vendors/pdfdoc.php b/vendors/pdfdoc.php index f29b9b83..76af0f48 100644 --- a/vendors/pdfdoc.php +++ b/vendors/pdfdoc.php @@ -1,9 +1,9 @@ files = $files; + } + + function concat() { + foreach($this->files AS $file) { + $pagecount = $this->setSourceFile($file); + for ($i = 1; $i <= $pagecount; $i++) { + $tplidx = $this->ImportPage($i); + + $this->AddPage(); + $this->useTemplate($tplidx); + } + } + } + } ?> \ No newline at end of file diff --git a/views/documents/pdf_invoice.ctp b/views/documents/pdf_invoice.ctp index 0c536569..180f8564 100644 --- a/views/documents/pdf_invoice.ctp +++ b/views/documents/pdf_invoice.ctp @@ -28,40 +28,7 @@ $pdfdoc->SetPrintHeader(true); $pdfdoc->pageContent($LineItemTable); - -$pdfdoc->lastPage(); - - -$output_dir = '/Users/karlcordes/Sites/quotenik/app/webroot/pdf/'; - -$debuglevel = Configure::read('debug'); - -if($debuglevel == 0) { - $output_dir = '/var/www/cakephp/app/webroot/pdf/'; -} - - -$pdfdoc->Output($output_dir.$filename, 'F'); - -echo "
Wrote: ".$output_dir.$filename; - -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"); -//$pdfdoc->Output($output_dir = '/Users/karlcordes/Sites/quotenik/app/webroot/pdf/'.'example_060.pdf', 'F'); - -//echo $html->link($filename, '/pdf/'.$filename); +$this->element('pdf_output', array('pdfdoc'=>$pdfdoc)); ?> diff --git a/views/documents/pdf_orderack.ctp b/views/documents/pdf_orderack.ctp index e02b496b..bebd5d6b 100644 --- a/views/documents/pdf_orderack.ctp +++ b/views/documents/pdf_orderack.ctp @@ -29,40 +29,7 @@ $pdfdoc->SetPrintHeader(true); $pdfdoc->pageContent($LineItemTable); - -$pdfdoc->lastPage(); - - -$output_dir = '/Users/karlcordes/Sites/quotenik/app/webroot/pdf/'; - -$debuglevel = Configure::read('debug'); - -if($debuglevel == 0) { - $output_dir = '/var/www/cakephp/app/webroot/pdf/'; -} - - -$pdfdoc->Output($output_dir.$filename, 'F'); - -echo "
Wrote: ".$output_dir.$filename; - -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"); -//$pdfdoc->Output($output_dir = '/Users/karlcordes/Sites/quotenik/app/webroot/pdf/'.'example_060.pdf', 'F'); - -//echo $html->link($filename, '/pdf/'.$filename); +$this->element('pdf_output', array('pdfdoc'=>$pdfdoc)); ?> diff --git a/views/documents/pdf_quote.ctp b/views/documents/pdf_quote.ctp index 73a4db2f..d7c2c24b 100755 --- a/views/documents/pdf_quote.ctp +++ b/views/documents/pdf_quote.ctp @@ -76,40 +76,8 @@ if($docType == 'quote') { } -$output_dir = '/Users/karlcordes/Sites/quotenik/app/webroot/pdf/'; +$this->element('pdf_output', array('pdfdoc'=>$pdfdoc)); -$debuglevel = Configure::read('debug'); - -if($debuglevel == 0) { - $output_dir = '/var/www/cakephp/app/webroot/pdf/'; -} - - -$pdfdoc->Output($output_dir.$filename, 'F'); - -//echo "
Wrote: ".$output_dir.$filename; -//echo "Wrote:" - - -//$tcpdf->Output('cmcquote.pdf', 'D'); - -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"); -//$pdfdoc->Output($output_dir = '/Users/karlcordes/Sites/quotenik/app/webroot/pdf/'.'example_060.pdf', 'F'); - -//echo $html->link($filename, '/pdf/'.$filename); ?> diff --git a/views/elements/line_items_table_with_shipping.ctp b/views/elements/line_items_table_with_shipping.ctp index 23a2234a..31f5e5e1 100644 --- a/views/elements/line_items_table_with_shipping.ctp +++ b/views/elements/line_items_table_with_shipping.ctp @@ -46,7 +46,7 @@
less
%
discount*
- (currency($li['discount_amount_total'], $currencyCode);?>)
+ (-currency($li['discount_amount_total'], $currencyCode);?>)
=
currency($li['net_price'], $currencyCode);?> @@ -58,7 +58,7 @@ SHIPPING DETAILS: - + - - + + -
+ + + + ?> +
+ + diff --git a/views/elements/pdf_output.ctp b/views/elements/pdf_output.ctp new file mode 100644 index 00000000..56ed1a88 --- /dev/null +++ b/views/elements/pdf_output.ctp @@ -0,0 +1,20 @@ +setSourceFile($output_dir.'CMC_terms_and_conditions2006_A4.pdf'); +for ($i = 1; $i <= $pagecount; $i++) { //Not really necessary for a 1 page T&C PDF, but handles future longer ones. + $tplidx = $pdfdoc->ImportPage($i); + $pdfdoc->AddPage(); + $pdfdoc->useTemplate($tplidx); +} + +$pdfdoc->lastPage(); +$pdfdoc->Output($output_dir.$filename, "F"); +?> \ No newline at end of file