First page generating working

This commit is contained in:
Karl Cordes 2011-06-15 18:26:22 +10:00
parent 8c0a907b76
commit 420630ce7b
7 changed files with 112 additions and 25 deletions

View file

@ -292,16 +292,21 @@ class DocumentsController extends AppController {
}
/*function delete($id = null) {
function generateFirstPage($id = null) {
$this->layout = 'ajax';
if(!$id) {
$this->Session->setFlash(__('Invalid id for Document', true));
$this->redirect(array('action'=>'index'));
return;
}
if ($this->Document->del($id)) {
$this->Session->setFlash(__('Document deleted', true));
$this->redirect(array('action'=>'index'));
$document = $this->Document->read(null, $id);
$this->set('document',$document);
$enquiry = $this->Document->Quote->Enquiry->read(null, $document['Quote']['enquiry_id']);
$this->set('enquiry', $enquiry);
}
}*/
}
?>

View file

@ -62,6 +62,10 @@ class LineItemsController extends AppController {
}
}
/**
* Get the products table with prices (for quotes, invoices etc)
* @param <type> $documentID
*/
function getTable($documentID = null) {
$this->layout = 'ajax';
if($documentID == null) {
@ -72,7 +76,7 @@ class LineItemsController extends AppController {
$this->set('document',$document);
$enquiry = $this->LineItem->Document->getEnquiry($document);
$this->set('enquiry', $enquiry);
$gst = $this->LineItem->Document->gstApplies($enquiry);
$this->set('gst',$gst);

View file

@ -0,0 +1,29 @@
<p>Dear <?=$enquiry['Contact']['first_name']?>,</p>
<p>Thank you for your enquiry. The following quotation is for:</p>
<table>
<tr>
<td width="10%"><u><b>Item</b></u></td>
<td width="80%"><u><b>Description</b></u></td>
<td width="10%"><u><b>Quantity</b></u></td>
</tr>
<? foreach($document['LineItem'] as $li):?>
<tr>
<td valign="top" width="10%"><? if($li['option'] == 1) {
echo 'Option<br>';
}
?><?=$li['item_number']?></td>
<td width="80%"><?=$li['title'];?></td>
<td valign="top" width="10%"><?=$li['quantity'];?></td>
</tr>
<? endforeach;?>
</table>
<p>If you have any further queries, please contact us at our office for assistance.</p>
<p>We look forward to your reply.</p>
<p>Regards,</p>
<?=$enquiry['User']['first_name'].' '.$enquiry['User']['last_name'];?><br />
<?=$enquiry['User']['job_title'];?><br />
<br />
<u><b>Attachments:</b></u><br />
CMC Technologies Terms & Conditions of Sale 1/7/06 (attached)<br />

View file

@ -16,6 +16,7 @@ echo $form->input('Document.id');
<div class="docButtons">
<button id="addPage">Add Content Page</button>
<button id="generateFirstPage">(re)Generate First Page</button>
<button id="addLineItem">Add Line Item</button>
<button id="editQuoteDetails">View/Edit Quote Details</button>
<?=$html->link('Generate PDF of this Quote', '/documents/pdf/'.$document['Document']['id']);?>
@ -25,11 +26,23 @@ echo $form->input('Document.id');
</div>
<div class="pages">
<?php foreach($document['DocPage'] as $key => $page):?>
<?php
$first = true;
foreach($document['DocPage'] as $key => $page):?>
<? if($first == true) {
$class = 'page firstPage';
$first = false;
}
else {
$class = 'page';
}
?>
<div class="docPage">
<?=$form->input("DocPage.{$key}.id");?>
<?=$form->input("DocPage.{$key}.content", array('class'=>'page', 'label'=>'Page '.$page['page_number'], 'between'=>'<button class="removePage">X</button>'));?>
<?=$form->input("DocPage.{$key}.content", array('class'=>$class, 'label'=>'Page '.$page['page_number'], 'between'=>'<button class="removePage">X</button>'));?>
<?=$form->input("DocPage.{$key}.document_id", array('type'=>'hidden'));?>
<?=$form->input("DocPage.{$key}.page_number", array('type'=>'hidden'));?>
</div>
@ -49,6 +62,10 @@ echo $form->input('Document.id');
<span style="font-size: small;">ANY VARIATIONS ON ITEMS 5. TO 7. WILL BE TO YOUR ACCOUNT. THIS QUOTATION IS BASED ON QUANTITIES STATED AND IS SUBJECT TO CHANGE IF QUANTITIES VARY.</span>
</div>
<? //For re-Generating the first page ?>
<div id="contactFirstName" style="display: none;"><?=$enquiry['Contact']['first_name'];?></div>
<? //debug($this->data);?>
<? //debug($enquiry);?>
<?php //debug($document);?>

View file

@ -220,6 +220,10 @@ $class = ' class="altrow"';?>
Redirecting you now to fill in the details.
</div>
<div id="jobConfirm" title="Are you sure you want to make a new Job">
This will create a new Job and a Job number. Are you sure you want to do this?
</div>
<div class="related">

View file

@ -1,9 +1,10 @@
$(function() {
$(".addJob").button('enable');
$(".addJob").click(function() {
$(".addJob").button('disable');
addJob();
$("#jobConfirm").dialog('open');
});
@ -22,6 +23,23 @@ $(function() {
});
$( "#jobConfirm" ).dialog({
autoOpen: false,
resizable: false,
height:140,
modal: true,
buttons: {
"Add new Job": function() {
addJob();
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
function addJob() {
var enquiryID = $(".addJob").attr("id");

View file

@ -12,6 +12,7 @@ $(function() {
// var config defined in global.js
loadLineItems();
var docID = $('#documentID').html();
$("#flashMessage").hide();
@ -168,7 +169,6 @@ $(function() {
var docID = $('#documentID').html();
$('#LineItemDescription').ckeditor(function() {
this.destroy();
@ -318,6 +318,16 @@ $(function() {
$("#QuoteDetails").dialog('open');
});
});
$("#generateFirstPage").click(function() {
$.get('/documents/generateFirstPage/'+docID, function(data) {
$(".firstPage").val(data);
});
});
});