Implemented PO first page. Added extra PO field migration

This commit is contained in:
Karl Cordes 2013-06-15 18:32:14 +10:00
parent e2b1af84d8
commit 3f1c37057d
9 changed files with 309 additions and 64 deletions

View file

@ -269,16 +269,40 @@ class DocumentsController extends AppController {
$enquiry = $this->Document->OrderAcknowledgement->Enquiry->read(null, $enquiryid); $enquiry = $this->Document->OrderAcknowledgement->Enquiry->read(null, $enquiryid);
$count = $this->Document->PurchaseOrder->findCount(); $count = $this->Document->PurchaseOrder->findCount();
$count++; $count++;
$offset = 2060; $offset = 2060;
$count += $offset; $count += $offset;
$newPOnumber = "CMCPO".$count; $newPOnumber = "CMCPO".$count;
$this->data['PurchaseOrder']['title'] = $newPOnumber; $this->data['PurchaseOrder']['title'] = $newPOnumber;
$this->data['PurchaseOrder']['issue_date'] = date('Y-m-d'); $this->data['PurchaseOrder']['issue_date'] = date('Y-m-d');
$this->data['PurchaseOrder']['deliver_to'] = <<<ENDDELIVER
CMC TECHNOLOGIES PTY LTD<br>
Unit 19, 77 Bourke Road<br>
Alexandria NSW 2015 AUSTRALIA<br>
ENDDELIVER;
//Fuck it all.
$this->data['PurchaseOrder']['shipping_instructions'] = <<<ENDINSTRUCTIONS
<b>PART SHIPMENT:</b> Not Acceptable - please advise ASAP if production of an Item will Delay the Dispatch of the Complete Order by the Date Required stated above.<br>
<b>INSURANCE:</b> DO NOT INSURE - Insurance effected by CMC<br>
<b>SECURITY:</b> It is essential that the cargo is prepared & handled so as not to compromise its security standing.<br>
<b>SHIPMENT MARKINGS:</b><br>
(Please put red fragile stickers on boxing)<br>
CMC TECHNOLOGIES PTY LTD<br>
UNIT 19, 77 BOURKE ROAD<br>
ALEXANDRIA NSW 2015 AUSTRALIA<br>
ENDINSTRUCTIONS;
$this->data['Document']['user_id']= $enquiry['Enquiry']['user_id']; $this->data['Document']['user_id']= $enquiry['Enquiry']['user_id'];
$this->data['Document']['revision'] = 0; //No revisions for POs. I have decreed it! $this->data['Document']['revision'] = 0; //No revisions for POs. I have decreed it!
$this->data['Document']['type'] = 'purchaseOrder'; $this->data['Document']['type'] = 'purchaseOrder';
break; break;
case "orderAck": case "orderAck":
$enquiry = $this->Document->OrderAcknowledgement->Enquiry->read(null, $enquiryid); $enquiry = $this->Document->OrderAcknowledgement->Enquiry->read(null, $enquiryid);
$this->data['OrderAcknowledgement']['job_id'] = $jobid; $this->data['OrderAcknowledgement']['job_id'] = $jobid;
@ -642,7 +666,21 @@ class DocumentsController extends AppController {
break; break;
case "purchaseOrder": case "purchaseOrder":
$totalsDescText = array(
'subtotal' => 'SUBTOTAL',
'gst' => '',
'total' => 'ORDER TOTAL'
);
//No GST for POs for now.
$totals = $this->calculateTotals($document, 0);
$this->set('totals',$totals);
$this->set('totalsDescText',$totalsDescText);
$filename = $document['PurchaseOrder']['title']; $filename = $document['PurchaseOrder']['title'];
$issue_date = date('l, j F Y', strtotime($document['PurchaseOrder']['issue_date']));
$this->set('issue_date', $issue_date);
$template_name = 'pdf_po'; $template_name = 'pdf_po';
break; break;

View file

@ -0,0 +1,5 @@
ALTER TABLE `purchase_orders` ADD `currency_id` INT NOT NULL;
ALTER TABLE `purchase_orders` ADD `ordered_from` TEXT NOT NULL, ADD `description` TEXT NOT NULL, ADD `dispatch_by` VARCHAR(255) NOT NULL, ADD `deliver_to` TEXT NOT NULL, ADD `shipping_instructions` TEXT NOT NULL;

View file

@ -10,20 +10,17 @@ $pdfdoc->SetPrintFooter(false);
$pdfdoc->AddPage(); $pdfdoc->AddPage();
$pdfdoc->Page1Header(); $pdfdoc->Page1Header();
$pageTitle = "<h1>PURCHASE ORDER</h1>";
$pdfdoc->writeHTML($pageTitle, true, false, false, false, 'C'); $first_page = $this->element('pdf_po_first_page');
$pdfdoc->pageContent($first_page);
$pdfdoc->SetTextColor(0); $pdfdoc->SetTextColor(0);
$pageNo = $pdfdoc->PageNoFormatted(); $pageNo = $pdfdoc->PageNoFormatted();
$totalCount = $pdfdoc->getAliasNbPages(); $totalCount = $pdfdoc->getAliasNbPages();
$pdfdoc->AddPage();
$shippingBillingBox = $this->element('pdf_shipping_billing_box', array('pageNo'=>$pageNo, 'totalCount'=>$totalCount)); $LineItemTable = $this->element('line_items_table_po'); //Because fuck it.
$pdfdoc->writeHTML($shippingBillingBox, false);
$LineItemTable = $this->element('line_items_table_with_shipping');
$pdfdoc->SetPrintHeader(true); $pdfdoc->SetPrintHeader(true);
$pdfdoc->pageContent($LineItemTable); $pdfdoc->pageContent($LineItemTable);

View file

@ -1,10 +1,9 @@
<h2>Purchase Order: <?=$document['PurchaseOrder']['title']?></h2> <h2>Purchase Order: <?=$document['PurchaseOrder']['title']?></h2>
<h2>Job: <?=$html->link($invoice['Job']['title'], array('controller'=>'jobs', 'action'=>'view', $invoice['Job']['id']));?></h2> <h2>Job: </h2>
<div id="flashMessage" class="message"> <div id="flashMessage" class="message">
</div> </div>
<div class="docButtons"> <div class="docButtons">
<button id="paymentReceived">Enter Payment Received</button>
<button id="pdfDocButton" data-url="/documents/pdf/<?= $document['Document']['id']; ?>">Generate PDF</button> <button id="pdfDocButton" data-url="/documents/pdf/<?= $document['Document']['id']; ?>">Generate PDF</button>
<button id="emailDocButton" data-url="/documents/email_pdf/<?= $document['Document']['id']; ?>">Email PurchaseOrder to customer</button> <button id="emailDocButton" data-url="/documents/email_pdf/<?= $document['Document']['id']; ?>">Email PurchaseOrder to customer</button>
</div> </div>
@ -26,18 +25,15 @@
echo $form->input('PurchaseOrder.dispatch_date'); echo $form->input('PurchaseOrder.dispatch_date');
echo $form->input('PurchaseOrder.date_arrived'); //ARGH. Really Karl? echo $form->input('PurchaseOrder.date_arrived'); //ARGH. Really Karl?
echo $form->input('billing_address_id', array('div' => 'addressradio', 'legend' => 'Select Billing Address', 'options' => $billing_addresses_list, 'type' => 'radio', 'class'=>'billing_address')); echo $form->input('PurchaseOrder.ordered_from');
echo $form->input('Document.bill_to'); echo $form->input('PurchaseOrder.description');
echo $form->input('PurchaseOrder.dispatch_by');
echo $form->input('shipping_address_id', array('div' => 'addressradio','legend' => 'Select Shipping Address', 'options' => $shipping_addresses_list, 'type' => 'radio', 'class' => 'shipping_address'));
echo $form->input('Document.ship_to'); echo $form->input('PurchaseOrder.deliver_to');
echo $form->input('PurchaseOrder.shipping_instructions');
echo $form->input('PurchaseOrder.ship_via');
echo $form->input('PurchaseOrder.fob');
echo $form->input('Document.shipping_details', array('id'=>'shippingDetails'));
echo $form->end(array('label'=>'Save PurchaseOrder Details', 'id'=>'savePurchaseOrderButton')); echo $form->end(array('label'=>'Save PurchaseOrder Details', 'id'=>'savePurchaseOrderButton'));
?> ?>
</fieldset> </fieldset>

View file

@ -0,0 +1,123 @@
<table border="1" cellpadding="2" cellspacing="0" >
<thead>
<tr bgcolor="#f2f2f2" nobr="true">
<th width="<?=$colWidths['item'];?>" align="center">ITEM<br />NO.</th>
<th width="<?=$colWidths['qty'];?>" align="center">QTY</th>
<th width="<?=$colWidths['desc'];?>" align="center">DESCRIPTION</th>
<th width="<?=$colWidths['unit'];?>" align="center">UNIT<br>PRICE</th>
<th width="<?=$colWidths['total'];?>" align="center">TOTAL<br>PRICE</th>
</tr>
<tr>
<th></th>
<th></th>
<th></th>
<th align="center"><?=$currencyCode?></th>
<th align="center"><?=$currencyCode?></th>
</tr>
</thead>
<tbody>
<?
$hasOptions = false;
foreach($document['LineItem'] as $li):?>
<tr>
<td width="<?=$colWidths['item'];?>" align="center" valign="top">
<? if($li['option'] == 1) {
echo 'Option<br>';
$hasOptions = true;
}
?>
<?=$li['item_number'];?>
</td>
<td width="<?=$colWidths['qty'];?>" align="center" valign="top"><?=$decimal->formatDecimal($li['quantity']);?></td>
<td width="<?=$colWidths['desc'];?>"><?=$li['title'];?><br>
<?=$li['description'];?>
</td>
<td width="<?=$colWidths['unit'];?>" align="center" valign="top">
<?
if($li['has_text_prices']):
echo $li['unit_price_string'];
?>
<?
else:
?>
<?=$number->currency($li['gross_unit_price'], $currencyCode);?>
<? if($li['discount_percent']):?>
<br>less<br><?=$li['discount_percent']?>%<br>
discount<br>
(-<?=$number->currency($li['discount_amount_unit'], $currencyCode);?>)<br>
=<br>
<?=$number->currency($li['net_unit_price'], $currencyCode);?>
<?endif;?>
<?endif;?>
</td>
<td width="<?=$colWidths['total'];?>" align="center" valign="top">
<?
if($li['has_text_prices']):
echo $li['gross_price_string'];
?>
<?
else:
?>
<?=$number->currency($li['gross_price'], $currencyCode);?>
<? if($li['discount_percent']):?>
<br>less<br><?=$li['discount_percent']?>%<br>
discount*<br>
(-<?=$number->currency($li['discount_amount_total'], $currencyCode);?>)<br>
=<br>
<?=$number->currency($li['net_price'], $currencyCode);?>
<?endif;?>
<?endif;?>
</td>
</tr>
<?endforeach;?>
</tbody>
<tfoot nobr="true">
<tr nobr="true">
<td width="<?=$colWidths['item'];?>"></td>
<td width="<?=$colWidths['qty'];?>"></td>
<td width="<?=$colWidths['desc'];?>"><?=$totalsDescText['subtotal']?></td>
<td width="<?=$colWidths['unit'];?>"></td>
<td width="<?=$colWidths['total'];?>" align="center">
<?
if(!$hasOptions) {
echo $number->currency($totals['subtotal'], $currencyCode);
}
else {
echo $currencySymbol.'TBA';
}
?></td>
</tr>
<tr nobr="true">
<td width="<?=$colWidths['item'];?>"></td>
<td width="<?=$colWidths['qty'];?>"></td>
<td width="<?=$colWidths['desc'];?>"><?=$totalsDescText['gst'];?></td>
<td width="<?=$colWidths['unit'];?>"></td>
<td width="<?=$colWidths['total'];?>" align="center">
<?
if(!$hasOptions) {
}
else {
echo $currencySymbol.'TBA';
}
?>
</td>
</tr>
<tr nobr="true">
<td width="<?=$colWidths['item'];?>"></td>
<td width="<?=$colWidths['qty'];?>"></td>
<td width="<?=$colWidths['desc'];?>"><?=$totalsDescText['total'];?></td>
<td width="<?=$colWidths['unit'];?>" align="center"><?=$currencyCode?></td>
<td width="<?=$colWidths['total'];?>" align="center">
<?
if(!$hasOptions) {
echo $number->currency($totals['total'], $currencyCode);
}
else {
echo $currencySymbol.'TBA';
}
?></td>
</tr>
</tfoot>
</table>

View file

@ -0,0 +1,74 @@
<table style="font-size: 14px; font-weight: bold;">
<tr>
<td>PURCHASE ORDER NO:</td>
<td><?= $document['PurchaseOrder']['title']; ?></td>
<td style="font-size: 12px;">Date: <?= $issue_date ?></td>
</tr>
</table>
<br><br><br>
<table style="font-size: 12px; font-weight: bold;">
<tr>
<td style="width: 30%;">ORDERED FROM:</td>
<td style="font-size: 12px; width: 70%"><?=$document['PurchaseOrder']['ordered_from']; ?></td>
</tr>
</table>
<br><br><br>
<table style="font-size: 12px; font-weight: bold; border: 1px solid #000; text-align: center;">
<tr>
<td style="border: 1px solid black;">Reference</td>
<td style="border: 1px solid black;">Description</td>
<td style="border: 1px solid black;">Order Total <?= $currency['Currency']['iso4217']; ?></td>
</tr>
<tr>
<td style="border: 1px solid black;"><?= $document['PurchaseOrder']['principle_reference']; ?></td>
<td style="border: 1px solid black;"><?= $document['PurchaseOrder']['description']; ?></td>
<td style="border: 1px solid black;">
<?= $number->currency($totals['total'], $currencyCode); ?>
</td>
</tr>
</table>
<br><br>
<?php $col1 = '30%'; $col2 = '70%'; ?>
<table style="font-size: 11px; font-weight: bold;">
<tr>
<td style="width: <?=$col1;?>;">DISPATCH EX-WORKS BY:</td>
<td style="width: <?=$col2;?>"><?= $document['PurchaseOrder']['dispatch_by'];?></td>
</tr>
</table><br><br>
<table style="font-size: 11px; font-weight: bold;">
<tr>
<td style="width: <?=$col1;?>;">DELIVER TO:</td>
<td style="width: <?=$col2;?>"><?= $document['PurchaseOrder']['deliver_to'];?></td>
</tr>
</table><br><br>
<table style="font-size: 11px;">
<tr>
<td style="width: <?=$col1;?>;"><u>SHIPPING INSTRUCTIONS:</u></td>
</tr>
<tr>
<td style="width: <?=$col2;?>">
<br>
<?= $document['PurchaseOrder']['shipping_instructions'];?></td>
</tr>
</table>
<br><br>
<table style="font-size: 11px; font-weight: bold;">
<tr>
<td></td>
<td>I HEREBY CERTIFY THAT CMC TECHNOLOGIES IS REGISTERED FOR GST AND OUR REGISTRATION # IS 47 085 991 224. <br><br>
CON CARPIS</td>
</tr>
</table>

View file

@ -106,8 +106,7 @@ if ($currentuser['User']['access_level'] == 'manager' || $currentuser['User']['a
<li><?php echo $html->link('POs', '/purchase_orders/index'); ?> <li><?php echo $html->link('POs', '/purchase_orders/index'); ?>
<ul> <ul>
<li><?php echo $html->link('PO Index', '/purchase_orders/index'); ?></li> <li class="last"><?php echo $html->link('PO Index', '/purchase_orders/index'); ?></li>
<li class="last"><?php echo $html->link('New PO', '/purchase_orders/add'); ?></li>
</ul> </ul>
</li> </li>

View file

@ -1,5 +1,9 @@
<div class="purchaseOrders index"> <div class="purchaseOrders index">
<h2><?php __('PurchaseOrders');?></h2> <h2><?php __('PurchaseOrders');?></h2>
<div class="actions">
<a href="/documents/newDocument/purchaseOrder/0/0/0">New blank Purchase Order</a>
</div>
<p> <p>
<?php <?php
echo $paginator->counter(array( echo $paginator->counter(array(
@ -17,7 +21,7 @@ echo $paginator->counter(array(
<th><?php echo $paginator->sort('principle_id');?></th> <th><?php echo $paginator->sort('principle_id');?></th>
<th><?php echo $paginator->sort('principle_reference');?></th> <th><?php echo $paginator->sort('principle_reference');?></th>
<? /*<th><?php echo $paginator->sort('document_id');?></th> */?> <? /*<th><?php echo $paginator->sort('document_id');?></th> */?>
<th class="actions"><?php __('Actions');?></th> <th>Document</th>
</tr> </tr>
<?php <?php
$i = 0; $i = 0;
@ -58,11 +62,13 @@ foreach ($purchaseOrders as $purchaseOrder):
<? /*<td> <? /*<td>
<?php echo $html->link($purchaseOrder['Document']['id'], array('controller' => 'documents', 'action' => 'view', $purchaseOrder['Document']['id'])); ?> <?php echo $html->link($purchaseOrder['Document']['id'], array('controller' => 'documents', 'action' => 'view', $purchaseOrder['Document']['id'])); ?>
</td>*/ ?> </td>*/ ?>
<td class="actions"> <td>
<?php echo $html->link(__('View', true), array('action' => 'view', $purchaseOrder['PurchaseOrder']['id'])); ?> <?php if($purchaseOrder['PurchaseOrder']['document_id'] > 0) { ?>
<?php echo $html->link(__('Edit', true), array('action' => 'edit', $purchaseOrder['PurchaseOrder']['id'])); ?> <a href="/documents/view/<?=$purchaseOrder['PurchaseOrder']['document_id']; ?>">View</a>
</td> <?php } ?>
</tr> </td>
</tr>
<?php endforeach; ?> <?php endforeach; ?>
</table> </table>
</div> </div>
@ -71,18 +77,6 @@ foreach ($purchaseOrders as $purchaseOrder):
| <?php echo $paginator->numbers();?> | <?php echo $paginator->numbers();?>
<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?> <?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
</div> </div>
<div class="actions">
<ul>
<li><?php echo $html->link(__('New PurchaseOrder', true), array('action' => 'add')); ?></li>
<li><?php echo $html->link(__('List Principles', true), array('controller' => 'principles', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Principle', true), array('controller' => 'principles', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Documents', true), array('controller' => 'documents', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Document', true), array('controller' => 'documents', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Jobs', true), array('controller' => 'jobs', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Job', true), array('controller' => 'jobs', 'action' => 'add')); ?> </li>
</ul>
</div>
<?php <?php
@ -96,4 +90,3 @@ function isEmptyDate($date) {
} }
?> ?>
<?php debug($purchaseOrders);?>

View file

@ -40,7 +40,7 @@ $(function() {
} }
else { else {
alert("Line Item could not be saved") alert("Line Item could not be saved")
$('#LineItemDescription').ckeditor(config); $('#LineItemDescription').ckeditor(config);
} }
}); });
@ -75,7 +75,7 @@ $(function() {
} }
else { else {
alert("Line Item could not be saved") alert("Line Item could not be saved")
$('#LineItemDescription').ckeditor(config); $('#LineItemDescription').ckeditor(config);
} }
}); });
@ -353,12 +353,12 @@ $(function() {
var confirmed = confirm("This will overwrite any changes you have made to the first page"); var confirmed = confirm("This will overwrite any changes you have made to the first page");
} }
if(confirmed) { if(confirmed) {
$.get('/documents/generateFirstPage/'+docID, function(data) { $.get('/documents/generateFirstPage/'+docID, function(data) {
$(".firstPage").val(data); $(".firstPage").val(data);
savePages(); savePages();
}); });
} }
}); });
@ -386,21 +386,34 @@ $(function() {
//OA View. //OA View.
$("#saveOAButton").click(function() { $("#saveOAButton").click(function() {
saveDocument('Order Acknowledgement'); saveDocument('Order Acknowledgement');
//if the job has changed, the create invoice button wont work properly. //if the job has changed, the create invoice button wont work properly.
window.location.reload(true); window.location.reload(true);
$('.job-title').html($("#OrderAcknowledgementJobId :selected").text()); $('.job-title').html($("#OrderAcknowledgementJobId :selected").text());
}); });
//This is fucked beyond all words.
$("#PurchaseOrderDeliverTo").ckeditor(config);
$("#PurchaseOrderOrderedFrom").ckeditor(config);
$("#PurchaseOrderShippingInstructions").ckeditor(config);
$("#PurchaseOrderDescription").ckeditor(config);
//PackingList View. Damn you past Karl. //PackingList View. Damn you past Karl.
$("#savePackingListButton").click(function() { $("#savePackingListButton").click(function() {
saveDocument('Packing List'); saveDocument('Packing List');
//if the job has changed, the create invoice button wont work properly. //if the job has changed, the create invoice button wont work properly.
window.location.reload(true); window.location.reload(true);
$('.job-title').html($("#PackingListJobId :selected").text()); $('.job-title').html($("#PackingListJobId :selected").text());
}); });
//PurchaseOrder View. Damn you past Karl.
$("#savePurchaseOrderButton").click(function() {
saveDocument('Purchase Order');
});
$("#createOA").click(function() { $("#createOA").click(function() {
$("#addJobConfirmation").dialog('open'); $("#addJobConfirmation").dialog('open');
@ -472,8 +485,8 @@ function saveDocument(documentName) {
else { else {
$("#flashMessage").html("Unable to save "+documentName); $("#flashMessage").html("Unable to save "+documentName);
} }
$("#flashMessage").show(); $("#flashMessage").show();
loadLineItems(); loadLineItems();
}); });
} }
@ -505,17 +518,24 @@ function showHideTextPrices() {
} }
//I am a much better programmer now.
//FUCK YEAH!!
function updateTextFields() { function updateTextFields() {
$('#shippingDetails').ckeditor(function() { var fields = [
this.updateElement(); '#shippingDetails',
}); "#DocumentBillTo",
"#DocumentShipTo",
"#PurchaseOrderDeliverTo",
"#PurchaseOrderOrderedFrom",
"#PurchaseOrderShippingInstructions",
"#PurchaseOrderDescription"
];
$("#DocumentBillTo").ckeditor(function() { for (i in fields) {
this.updateElement(); $(fields[i]).ckeditor(function() {
}); this.updateElement();
$("#DocumentShipTo").ckeditor(function() { });
this.updateElement(); }
});
} }