Implemented PDF page counter using FPDI. Wont work on all types of PDF attachments. Error message will need to be manually removed, and such PDFs will need to be re-encoded by acrobat
This commit is contained in:
parent
296336e431
commit
da23179673
|
|
@ -621,6 +621,7 @@ class DocumentsController extends AppController {
|
||||||
|
|
||||||
$document = $this->Document->read(null, $id);
|
$document = $this->Document->read(null, $id);
|
||||||
$this->set('document',$document);
|
$this->set('document',$document);
|
||||||
|
$this->set('attachments', $this->Document->DocumentAttachment->find('all', array('conditions'=>array('document_id'=> $id))));
|
||||||
$enquiry = $this->Document->Quote->Enquiry->read(null, $document['Quote']['enquiry_id']);
|
$enquiry = $this->Document->Quote->Enquiry->read(null, $document['Quote']['enquiry_id']);
|
||||||
$this->set('enquiry', $enquiry);
|
$this->set('enquiry', $enquiry);
|
||||||
}
|
}
|
||||||
|
|
@ -643,7 +644,9 @@ class DocumentsController extends AppController {
|
||||||
$document = $this->Document->read(null,$id);
|
$document = $this->Document->read(null,$id);
|
||||||
|
|
||||||
if(empty($document['Document']['pdf_filename'])) {
|
if(empty($document['Document']['pdf_filename'])) {
|
||||||
$this->Session->setFlash(__('Error. Please generate the PDF before attempting to email it', true));
|
|
||||||
|
|
||||||
|
$this->Session->setFlash(__('Error. Please generate the PDF before attempting to email it', true));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
24
app/vendors/pagecounter.php
vendored
Executable file
24
app/vendors/pagecounter.php
vendored
Executable file
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
App::import('Vendor','tcpdf/tcpdf');
|
||||||
|
App::import('Vendor', 'fpdi/fpdi');
|
||||||
|
/* Count pages of the PDF attachments using FPDI */
|
||||||
|
|
||||||
|
|
||||||
|
class PageCounter extends FPDI {
|
||||||
|
|
||||||
|
function count($file) {
|
||||||
|
$pdf = new FPDI();
|
||||||
|
|
||||||
|
$count = $pdf->setSourceFile($file);
|
||||||
|
if(is_numeric($count)) {
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
<?
|
||||||
|
|
||||||
|
App::import('Vendor','pagecounter');
|
||||||
|
$pagecounter = new PageCounter();
|
||||||
|
?>
|
||||||
|
|
||||||
<p>Dear <?=$enquiry['Contact']['first_name']?>,</p>
|
<p>Dear <?=$enquiry['Contact']['first_name']?>,</p>
|
||||||
|
|
||||||
<p>Thank you for your enquiry. The following quotation is for:</p>
|
<p>Thank you for your enquiry. The following quotation is for:</p>
|
||||||
|
|
@ -27,4 +33,7 @@
|
||||||
<?=$enquiry['User']['job_title'];?><br />
|
<?=$enquiry['User']['job_title'];?><br />
|
||||||
<br />
|
<br />
|
||||||
<u><b>Attachments:</b></u><br />
|
<u><b>Attachments:</b></u><br />
|
||||||
CMC Technologies Terms & Conditions of Sale 1/7/06 (attached)<br />
|
CMC Technologies Terms & Conditions of Sale 1/7/06 (attached)<br>
|
||||||
|
<?php foreach($attachments as $attachment) {; ?>
|
||||||
|
<?php echo $attachment['Attachment']['name']; ?> (<?=$pagecounter->count($attachment['Attachment']['file']); ?> pages)<br>
|
||||||
|
<?php } ?>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue