invoice PDF generation working. More work still needed
This commit is contained in:
parent
a92eb939a4
commit
e400230c41
|
|
@ -4,6 +4,6 @@
|
|||
RewriteRule (.*) webroot/$1 [L]
|
||||
</IfModule>
|
||||
|
||||
<FilesMatch ".(js|css|txt)$">
|
||||
<FilesMatch ".(js|css|txt|pf)$">
|
||||
Header unset Cache-Control
|
||||
</FilesMatch>
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ class DocumentsController extends AppController {
|
|||
break;
|
||||
case 'invoice':
|
||||
$docTypeElement = 'document_invoice_view';
|
||||
$this->set('invoice', $this->Document->Invoice->find('first', array('conditions'=>array('Invoice.id'=>$document['Invoice']['id']))));
|
||||
break;
|
||||
|
||||
case 'purchaseOrder':
|
||||
|
|
@ -152,15 +153,17 @@ class DocumentsController extends AppController {
|
|||
$this->data['Document']['type'] = 'invoice';
|
||||
|
||||
$this->data['Invoice']['issue_date'] = date('Y-m-d'); //Argh. Quote model uses 'date_issed'.
|
||||
|
||||
$this->data['Document']['currency_id'] = 2; //All new Invoices default to AUD.
|
||||
|
||||
|
||||
$this->data['Invoice']['due_date'] = date("Y-m-d", strtotime("+30 days"));
|
||||
|
||||
|
||||
$this->data['Invoice']['currency_id'] = 2; //All new Invoices default to AUD.
|
||||
|
||||
break;
|
||||
case "purchaseOrder":
|
||||
|
||||
|
||||
|
||||
|
||||
break;
|
||||
case "orderAck":
|
||||
|
||||
|
|
@ -435,15 +438,32 @@ class DocumentsController extends AppController {
|
|||
$this->set('products', $document['LineItem']);
|
||||
|
||||
|
||||
//If this is a quote, set the filename
|
||||
//@TODO FIX THIS FOR OTHER DOCTYPES
|
||||
if($document['Document']['revision'] > 0) {
|
||||
$filename = $enquiry['Enquiry']['title'].'_'.$document['Document']['revision'].'.pdf';
|
||||
}
|
||||
else {
|
||||
$filename = $enquiry['Enquiry']['title'].'.pdf';
|
||||
//Set filename for the document.
|
||||
//
|
||||
switch($docType) {
|
||||
case "quote":
|
||||
$filename = $enquiry['Enquiry']['title'];
|
||||
break;
|
||||
|
||||
case "invoice":
|
||||
$filename = $document['Invoice']['title'];
|
||||
break;
|
||||
|
||||
case "purchaseOrder":
|
||||
$filename = $document['PurchaseOrder']['title'];
|
||||
break;
|
||||
|
||||
case "orderAck":
|
||||
$filename = $document['Job']['title'];
|
||||
break;
|
||||
}
|
||||
|
||||
if($document['Document']['revision'] > 0) {
|
||||
$filename = $filename.'_'.$document['Document']['revision'].'.pdf';
|
||||
}
|
||||
else {
|
||||
$filename = $filename.'.pdf';
|
||||
}
|
||||
|
||||
$this->set('filename', $filename);
|
||||
$document['Document']['pdf_filename'] = $filename;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@ class InvoicesController extends AppController {
|
|||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* function edit($id = null) {
|
||||
|
|
|
|||
|
|
@ -114,17 +114,12 @@ class Document extends AppModel {
|
|||
function getCMCReferenceNumber($document, $type) {
|
||||
switch($type) {
|
||||
case 'quote':
|
||||
|
||||
|
||||
break;
|
||||
case 'invoice':
|
||||
|
||||
break;
|
||||
case 'purchaseOrder':
|
||||
|
||||
break;
|
||||
case 'orderAck':
|
||||
|
||||
break;
|
||||
}
|
||||
return $fullName;
|
||||
|
|
|
|||
|
|
@ -5,17 +5,6 @@ echo $javascript->link('ckeditor/adapters/jquery');
|
|||
echo $javascript->link('document_add_edit');
|
||||
|
||||
?>
|
||||
|
||||
<h2><?=$docTypeFullName?>: <?=$html->link($enquiry['Enquiry']['title'], array('controller'=>'enquiries','action'=>'view',$enquiry['Enquiry']['id']));?>
|
||||
<?
|
||||
if($document['Document']['revision'] > 0) {
|
||||
echo "Revision {$document['Document']['revision']} ";
|
||||
}
|
||||
?>
|
||||
for
|
||||
<?=$html->link($enquiry['Customer']['name'], array('controller'=>'customers','action'=>'view',$enquiry['Customer']['id']));?>
|
||||
</h2>
|
||||
|
||||
<?=$this->element('pdf_created_message'); ?>
|
||||
|
||||
<?
|
||||
|
|
@ -57,4 +46,4 @@ echo $this->element($docTypeElement);
|
|||
|
||||
<?php //debug($enquiry);?>
|
||||
|
||||
<?php debug($document);?>
|
||||
<?php // debug($document);?>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<h2>Invoice: <?=$document['Invoice']['title']?></h2>
|
||||
|
||||
<h2>Invoice: <?=$document['Invoice']['title']?> for <?=$html->link($enquiry['Customer']['name'], '/customers/view/'.$enquiry['Customer']['id']);?></h2>
|
||||
<h2>Job: <?=$html->link($invoice['Job']['title'], array('controller'=>'jobs', 'action'=>'view', $invoice['Job']['id']));?></h2>
|
||||
<?
|
||||
|
||||
echo $form->create('Document',array('type'=>'post','action'=>'edit', 'default'=>false));
|
||||
|
|
@ -7,7 +7,10 @@ echo $form->input('Document.id');
|
|||
?>
|
||||
|
||||
<div class="docButtons">
|
||||
|
||||
<button id="generateFirstPage">(re)Generate First Page</button>
|
||||
<button id="addPage">Add Content Page</button>
|
||||
<button id="editQuoteDetails">View/Edit Quote Details</button>
|
||||
<?=$html->link('Generate PDF of this Quote', '/documents/pdf/'.$document['Document']['id']);?>
|
||||
</div>
|
||||
|
||||
<div id="flashMessage" class="message">
|
||||
|
|
@ -19,3 +22,5 @@ echo $form->input('Document.id');
|
|||
<? //debug($enquiry);?>
|
||||
<?php //debug($document);?>
|
||||
<?php //debug($docType);?>
|
||||
|
||||
<? //debug($invoice); ?>
|
||||
|
|
@ -1,4 +1,14 @@
|
|||
|
||||
<h2><?=$docTypeFullName?>: <?=$html->link($enquiry['Enquiry']['title'], array('controller'=>'enquiries','action'=>'view',$enquiry['Enquiry']['id']));?>
|
||||
<?
|
||||
if($document['Document']['revision'] > 0) {
|
||||
echo "Revision {$document['Document']['revision']} ";
|
||||
}
|
||||
?>
|
||||
for
|
||||
<?=$html->link($enquiry['Customer']['name'], array('controller'=>'customers','action'=>'view',$enquiry['Customer']['id']));?>
|
||||
</h2>
|
||||
|
||||
<?
|
||||
|
||||
echo $form->create('Document',array('type'=>'post','action'=>'edit', 'default'=>false));
|
||||
|
|
|
|||
|
|
@ -239,6 +239,11 @@
|
|||
</div>
|
||||
|
||||
|
||||
<ul id="jobsList" style="display: none;">
|
||||
<? foreach($jobs as $job):?>
|
||||
<li id="<?=$job['Job']['id'];?>"><?=$html->link($job['Job']['title'], "/documents/newDocument/invoice/{$job['Job']['enquiry_id']}/{$job['Job']['id']}");?></li>
|
||||
<? endforeach;?>
|
||||
</ul>
|
||||
|
||||
<div class="related">
|
||||
<h3><?php __($enquiry['Enquiry']['invoice_count'].' Invoices for this Enquiry');?></h3>
|
||||
|
|
@ -304,8 +309,6 @@
|
|||
|
||||
<td class="actions">
|
||||
<?php echo $html->link(__('View', true), array('controller'=>'documents', 'action' => 'view', $invoice['Invoice']['document_id'])); ?>
|
||||
<?php echo $html->link(__('Edit', true), array('controller'=>'invoices','action' => 'edit', $invoice['Invoice']['id'])); ?>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
|
@ -318,6 +321,7 @@
|
|||
<li><?php //echo $html->link(__('New Invoice', true), array('controller'=>'invoices', 'action' => 'add/enquiryid:'.$enquiry['Enquiry']['id'])); ?>
|
||||
</li>
|
||||
<li><?php echo $html->link(__('New Invoice', true), array('controller'=>'documents', 'action' => 'newDocument/invoice/'.$enquiry['Enquiry']['id'])); ?></li>
|
||||
<li><button class="addInvoice" id="<?=$enquiry['Enquiry']['id'];?>">New Invoice</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1615,6 +1615,6 @@ div.pdfGeneratedMessage {
|
|||
margin-bottom: 1em;
|
||||
padding: 0.5em;
|
||||
border: 2px dashed;
|
||||
width: 50%;
|
||||
width: 45em;
|
||||
font-size: 120%;
|
||||
}
|
||||
|
|
@ -58,6 +58,14 @@ $(function() {
|
|||
window.location = '/documents/newDocument/quote/'+$( this ).attr('id');
|
||||
});
|
||||
|
||||
|
||||
$(".addInvoice").click(function() {
|
||||
if($("#jobsList > li").length == 0) {
|
||||
alert("Cant add an invoice! Add Invoice must be for a job. No jobs exist");
|
||||
}
|
||||
else {
|
||||
$("#jobsList").show();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue