Improvements to PDF generation for Documents
This commit is contained in:
parent
9f813f5023
commit
c53cfebe6b
|
|
@ -30,7 +30,12 @@ class DocumentsController extends AppController {
|
|||
$this->set('document', $document);
|
||||
|
||||
$this->data = $document;
|
||||
$this->set('docType',$this->Document->getDocType($document));
|
||||
$docType = $this->Document->getDocType($document);
|
||||
$this->set('docType', $docType);
|
||||
|
||||
$this->set('docTypeFullName', $this->Document->getDocFullName($docType));
|
||||
$this->set('users', $this->Document->User->getUsersList());
|
||||
|
||||
$this->set('currency', $this->Document->getCurrency($document));
|
||||
$this->set('enquiry', $this->Document->getEnquiry($document));
|
||||
// $this->set('principles', $this->Document->LineItem->Product->Principle->find('list'));
|
||||
|
|
@ -307,10 +312,10 @@ class DocumentsController extends AppController {
|
|||
$document['Document']['pdf_created_at'] = date('Y-m-d H:i:s');
|
||||
$document['Document']['pdf_created_by_user_id'] = $this->getCurrentUserID();
|
||||
if($this->Document->save($document)) {
|
||||
echo "Set pdf_filename attritbute to: ".$filename;
|
||||
//echo "Set pdf_filename attritbute to: ".$filename;
|
||||
}
|
||||
else {
|
||||
echo 'Failed to set pdf_filename to: '.$filename;
|
||||
//echo 'Failed to set pdf_filename to: '.$filename;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -324,7 +329,6 @@ class DocumentsController extends AppController {
|
|||
);
|
||||
|
||||
$this->set('colWidths',$colWidths);
|
||||
|
||||
}
|
||||
|
||||
function generateFirstPage($id = null) {
|
||||
|
|
|
|||
|
|
@ -86,14 +86,6 @@ if($debuglevel == 0) {
|
|||
}
|
||||
|
||||
|
||||
if($document['Quote']['revision'] > 0) {
|
||||
$filename = $enquiry['Enquiry']['title'].'rev'.$document['Quote']['revision'].'.pdf';
|
||||
}
|
||||
else {
|
||||
$filename = $enquiry['Enquiry']['title'].'.pdf';
|
||||
}
|
||||
|
||||
|
||||
$pdfdoc->Output($output_dir.$filename, 'F');
|
||||
|
||||
//echo "<br> Wrote: ".$output_dir.$filename;
|
||||
|
|
@ -118,6 +110,10 @@ $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);
|
||||
//echo $html->link($filename, '/pdf/'.$filename);
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
window.location.replace("/documents/view/<?=$document['Document']['id']?>");
|
||||
</script>
|
||||
|
|
@ -4,12 +4,10 @@ echo $javascript->link('ckeditor/adapters/jquery');
|
|||
|
||||
echo $javascript->link('document_add_edit');
|
||||
|
||||
|
||||
switch($docType) {
|
||||
case 'quote':
|
||||
echo $this->element('document_quote_view');
|
||||
break;
|
||||
|
||||
case 'invoice':
|
||||
echo $this->element('document_invoice_view');
|
||||
break;
|
||||
|
|
@ -54,6 +52,6 @@ switch($docType) {
|
|||
<?php // debug($currency);?>
|
||||
<?php //debug($docType);?>
|
||||
|
||||
<?php debug($enquiry);?>
|
||||
<?php //debug($enquiry);?>
|
||||
|
||||
<?php debug($document);?>
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
<?=$html->link($enquiry['Customer']['name'], array('controller'=>'customers','action'=>'view',$enquiry['Customer']['id']));?>
|
||||
</h2>
|
||||
|
||||
|
||||
<?=$this->element('pdf_created_message'); ?>
|
||||
<?
|
||||
|
||||
echo $form->create('Document',array('type'=>'post','action'=>'edit', 'default'=>false));
|
||||
|
|
|
|||
7
views/elements/pdf_created_message.ctp
Normal file
7
views/elements/pdf_created_message.ctp
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<? if(!empty($document['Document']['pdf_filename'])):
|
||||
?>
|
||||
<div class="pdfGeneratedMessage">
|
||||
A <?=$html->link('PDF copy of this '.$docTypeFullName, '/pdf/'.$document['Document']['pdf_filename']);?> was created <?=$time->niceShort($document['Document']['pdf_created_at']);?> by
|
||||
<?=$html->link($users[$document['Document']['pdf_created_by_user_id']], '/users/view/'.$document['Document']['pdf_created_by_user_id']);?>
|
||||
</div>
|
||||
<? endif;?>
|
||||
|
|
@ -1610,3 +1610,11 @@ table.lineItems tr td.price {
|
|||
}
|
||||
|
||||
|
||||
div.pdfGeneratedMessage {
|
||||
margin-top: 2em;
|
||||
margin-bottom: 2em;
|
||||
padding: 1em;
|
||||
border: 2px dashed;
|
||||
width: 50%;
|
||||
font-size: 140%;
|
||||
}
|
||||
Loading…
Reference in a new issue