Finished packinglists
Merge branch 'feature/PackingLists' into develop
This commit is contained in:
commit
2a54d15b99
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
Configure::write('debug', 0);
|
||||
|
||||
Configure::write('version', '0.9.8');
|
||||
Configure::write('version', '0.9.9');
|
||||
|
||||
$host = $_SERVER['HTTP_HOST'];
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class CostingsController extends AppController {
|
|||
|
||||
$this->set('type', 'line_item');
|
||||
$this->set('line_item', $line_item);
|
||||
die(print_r($line_item));
|
||||
//die(print_r($line_item));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -82,6 +82,13 @@ class DocumentsController extends AppController {
|
|||
$this->set('currencies', $this->Document->OrderAcknowledgement->Currency->find('list'));
|
||||
$this->set('job', $this->Document->OrderAcknowledgement->Job->find('first', array('conditions'=>array('Job.id'=>$document['OrderAcknowledgement']['job_id']))));
|
||||
$docTypeElement = 'document_orderack_view';
|
||||
break;
|
||||
|
||||
case 'packingList':
|
||||
$docTypeElement = 'document_packinglist_view';
|
||||
$this->set('currencies', $this->Document->Invoice->Currency->find('list'));
|
||||
$this->set('packing_list', $this->Document->PackingList->find('first', array('conditions'=>array('PackingList.id'=>$document['PackingList']['id']))));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->set('docTypeElement', $docTypeElement);
|
||||
|
|
@ -282,6 +289,65 @@ class DocumentsController extends AppController {
|
|||
$this->data['Document']['type'] = 'orderAck';
|
||||
break;
|
||||
|
||||
|
||||
case "packingList";
|
||||
$this->data['Document']['type'] = 'packingList';
|
||||
|
||||
|
||||
$packing_number_offset = 6500; //What PL number we are up to. Starting at 6500 to avoid conflicts
|
||||
|
||||
$number_of_packinglists = $this->Document->PackingList->findCount();
|
||||
|
||||
$enquiry = $this->Document->PackingList->Enquiry->read(null, $enquiryid);
|
||||
if(!$enquiry) {
|
||||
$this->Session->setFlash('Invalid Enquiry ID');
|
||||
$this->redirect(array('action'=>'index'));
|
||||
return;
|
||||
}
|
||||
|
||||
$newPackingNumber = $packing_number_offset + $number_of_packinglists;
|
||||
$this->data['PackingList']['enquiry_id'] = $enquiryid;
|
||||
$this->data['PackingList']['title'] = "CMCPL".$newPackingNumber;
|
||||
$this->data['PackingList']['job_id'] = $jobid;
|
||||
$this->data['PackingList']['customer_id'] = $enquiry['Enquiry']['customer_id'];
|
||||
|
||||
$this->data['Document']['user_id']= $enquiry['Enquiry']['user_id'];
|
||||
//$number_of_revisions = $this->Document->Invoice->findCount('Invoice.enquiry_id ='. $enquiryid);
|
||||
$this->data['Document']['revision'] = 0; //No revisions for Invoices. I have decreed it!
|
||||
$this->data['Document']['type'] = 'packingList';
|
||||
|
||||
$this->data['PackingList']['issue_date'] = date('Y-m-d'); //Argh. Quote model uses 'date_issed'.
|
||||
|
||||
|
||||
|
||||
|
||||
if(isset($source_document_id)) {
|
||||
//This is not ideal. But nothing else is either.
|
||||
$sourceDoc = $this->Document->find('first', array('conditions' => array('Document.id' => $source_document_id)));
|
||||
|
||||
$source_attribues = array(
|
||||
'ship_via',
|
||||
'fob',
|
||||
'estimated_delivery'
|
||||
);
|
||||
|
||||
if($sourceDoc['Document']['type'] == 'orderAck') {
|
||||
foreach($oa_attribues as $attr) {
|
||||
$this->data['PackingList'][$attr] = $sourceDoc['OrderAcknowledgement'][$attr];
|
||||
}
|
||||
}
|
||||
if($sourceDoc['Document']['type'] == 'invoice') {
|
||||
foreach($oa_attribues as $attr) {
|
||||
$this->data['PackingList'][$attr] = $sourceDoc['Invoice'][$attr];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(isset($source_document_id)) {
|
||||
|
|
@ -572,8 +638,6 @@ class DocumentsController extends AppController {
|
|||
|
||||
$this->set('ship_via', $document['Invoice']['ship_via']);
|
||||
$this->set('fob', $document['Invoice']['fob']);
|
||||
|
||||
|
||||
$template_name = 'pdf_invoice';
|
||||
break;
|
||||
|
||||
|
|
@ -600,6 +664,18 @@ class DocumentsController extends AppController {
|
|||
$template_name = 'pdf_orderack';
|
||||
break;
|
||||
|
||||
case "packingList":
|
||||
$filename = $document['PackingList']['title'];
|
||||
$this->set('docTitle', $document['PackingList']['title']);
|
||||
$this->set('job', $this->Document->PackingList->Job->find('first', array('conditions'=>array('Job.id'=>$document['PackingList']['job_id']))));
|
||||
$this->set('issue_date_string', date('d F Y', strtotime($document['PackingList']['issue_date'])));
|
||||
|
||||
$this->set('ship_via', $document['PackingList']['ship_via']);
|
||||
$this->set('fob', $document['PackingList']['fob']);
|
||||
$template_name = 'pdf_packinglist';
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if($document['Document']['revision'] > 0) {
|
||||
|
|
|
|||
|
|
@ -82,6 +82,10 @@ class ProductsController extends AppController {
|
|||
$this->data['Product']['principle_id'] = $product['Product']['principle_id'];
|
||||
$this->data['Product']['title'] = $product['Product']['title'];
|
||||
$this->data['Product']['description'] = $product['Product']['description'];
|
||||
$this->data['Product']['item_code'] = $product['Product']['item_code'];
|
||||
$this->data['Product']['notes'] = $product['Product']['notes'];
|
||||
$this->data['Product']['item_description'] = $product['Product']['item_description'];
|
||||
|
||||
|
||||
$principles = $this->Product->Principle->find('list');
|
||||
$this->set(compact('principles', 'product_categories'));
|
||||
|
|
|
|||
17
app/migrations/10_6_2013_add_packing_list.sql
Normal file
17
app/migrations/10_6_2013_add_packing_list.sql
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
CREATE TABLE `quotenik`.`packing_lists` ( `id` int( 11 ) NOT NULL AUTO_INCREMENT ,
|
||||
`currency_id` int( 11 ) DEFAULT NULL ,
|
||||
`created` datetime NOT NULL ,
|
||||
`issue_date` date NOT NULL ,
|
||||
`due_date` date NOT NULL ,
|
||||
`title` varchar( 255 ) NOT NULL COMMENT 'CMC Invoice Number String',
|
||||
`paid` tinyint( 1 ) NOT NULL DEFAULT '0' COMMENT 'PAID or UNPAID',
|
||||
`payment_received_date` date NOT NULL ,
|
||||
`ship_via` varchar( 255 ) NOT NULL ,
|
||||
`fob` varchar( 255 ) NOT NULL ,
|
||||
`enquiry_id` int( 11 ) NOT NULL ,
|
||||
`job_id` int( 11 ) NOT NULL ,
|
||||
`user_id` int( 11 ) NOT NULL ,
|
||||
`document_id` int( 11 ) DEFAULT NULL ,
|
||||
`customer_id` int( 11 ) NOT NULL ,
|
||||
UNIQUE KEY `id` ( `id` ) ) ENGINE = MyISAM DEFAULT CHARSET = latin1;
|
||||
|
|
@ -57,6 +57,10 @@ class Document extends AppModel {
|
|||
'OrderAcknowledgement' => array(
|
||||
'className' => 'OrderAcknowledgement',
|
||||
'foreignKey' => 'document_id'
|
||||
),
|
||||
'PackingList' => array(
|
||||
'className' => 'PackingList',
|
||||
'foreignKey' => 'document_id'
|
||||
)
|
||||
);
|
||||
|
||||
|
|
@ -113,6 +117,9 @@ class Document extends AppModel {
|
|||
case 'orderAck':
|
||||
$fullName = 'Order Acknowledgement';
|
||||
break;
|
||||
case 'packingList':
|
||||
$fullName = 'Packing List';
|
||||
break;
|
||||
}
|
||||
return $fullName;
|
||||
}
|
||||
|
|
@ -146,6 +153,9 @@ class Document extends AppModel {
|
|||
elseif(!empty($document['Quote']['id'])) {
|
||||
return $this->Quote->Enquiry->find('first',array('conditions'=>array('Enquiry.id'=>$document['Quote']['enquiry_id'])));
|
||||
}
|
||||
elseif(!empty($document['PackingList']['id'])) {
|
||||
return $this->PackingList->Enquiry->find('first',array('conditions'=>array('Enquiry.id'=>$document['PackingList']['enquiry_id'])));
|
||||
}
|
||||
elseif(!empty($document['PurchaseOrder']['id'])) {
|
||||
//No enquiries for POs. We want the Jobs.
|
||||
return;
|
||||
|
|
|
|||
41
app/models/packing_list.php
Executable file
41
app/models/packing_list.php
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
class PackingList extends AppModel {
|
||||
|
||||
var $name = 'PackingList';
|
||||
|
||||
// var $recursive = 2;
|
||||
|
||||
var $validate = array(
|
||||
'issue_date' => array('date'),
|
||||
'title' => array('notempty'),
|
||||
'enquiry_id' => array('numeric'),
|
||||
'user_id' => array('numeric')
|
||||
);
|
||||
|
||||
//The Associations below have been created with all possible keys, those that are not needed can be removed
|
||||
var $belongsTo = array(
|
||||
'Enquiry' => array(
|
||||
'className' => 'Enquiry',
|
||||
'foreignKey' => 'enquiry_id',
|
||||
'counterCache'=> true
|
||||
),
|
||||
'Customer' => array(
|
||||
'className' => 'Customer',
|
||||
'foreignKey' => 'customer_id'
|
||||
),
|
||||
'Job' => array(
|
||||
'className' => 'Job',
|
||||
'foreignKey' => 'job_id'
|
||||
),
|
||||
'Currency' => array(
|
||||
'className' => 'Currency',
|
||||
'foreignKey' => 'currency_id'
|
||||
),
|
||||
'Document' => array(
|
||||
'className' => 'Document',
|
||||
'foreignKey' => 'document_id'
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
?>
|
||||
38
app/views/documents/pdf_packinglist.ctp
Executable file
38
app/views/documents/pdf_packinglist.ctp
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
App::import('Vendor','pdfdoc');
|
||||
|
||||
$pdfdoc = new PDFDOC();
|
||||
|
||||
$pdfdoc->SetPrintHeader(false);
|
||||
$pdfdoc->SetPrintFooter(false);
|
||||
|
||||
|
||||
$pdfdoc->AddPage();
|
||||
$pdfdoc->Page1Header();
|
||||
|
||||
$pageTitle = "<h1>PACKING LIST</h1>";
|
||||
$pdfdoc->writeHTML($pageTitle, true, false, false, false, 'C');
|
||||
|
||||
$pdfdoc->SetTextColor(0);
|
||||
|
||||
$pageNo = $pdfdoc->PageNoFormatted();
|
||||
$totalCount = $pdfdoc->getAliasNbPages();
|
||||
|
||||
|
||||
$shippingBillingBox = $this->element('pdf_shipping_billing_box', array('pageNo'=>$pageNo, 'totalCount'=>$totalCount));
|
||||
|
||||
$pdfdoc->writeHTML($shippingBillingBox, false);
|
||||
|
||||
$LineItemTable = $this->element('line_items_table_with_shipping_packinglist');
|
||||
$pdfdoc->SetPrintHeader(true);
|
||||
|
||||
$pdfdoc->pageContent($LineItemTable);
|
||||
|
||||
$this->element('pdf_output', array('pdfdoc'=>$pdfdoc));
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
window.location.replace("/documents/view/<?=$document['Document']['id']?>");
|
||||
</script>
|
||||
|
||||
|
|
@ -9,6 +9,17 @@
|
|||
<button id="emailDocButton" data-url="/documents/email_pdf/<?= $document['Document']['id']; ?>">Email Invoice to customer</button>
|
||||
</div>
|
||||
|
||||
<div class="docOperations">
|
||||
<h3>Create new Documents based on this</h3>
|
||||
<ul class="document-buttons">
|
||||
|
||||
<li>
|
||||
<button id="createPackingList" class="button-link" data-href="/documents/newDocument/packingList/<?=$enquiry['Enquiry']['id']?>/<?=$invoice['Job']['id']?>/<?=$document['Document']['id']?>">Create Packing List</button>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div id="invoiceDetails" class="documentDetails">
|
||||
|
|
|
|||
|
|
@ -12,7 +12,14 @@
|
|||
<h3>Create new Documents based on this</h3>
|
||||
<ul class="document-buttons">
|
||||
<li>
|
||||
<button id="createInvoice" data-href="/documents/newDocument/invoice/<?=$enquiry['Enquiry']['id']?>/<?=$job['Job']['id']?>/<?=$document['Document']['id']?>">Create Invoice</button>
|
||||
<button id="createInvoice" class="button-link" data-href="/documents/newDocument/invoice/<?=$enquiry['Enquiry']['id']?>/<?=$job['Job']['id']?>/<?=$document['Document']['id']?>">Create Invoice</button>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<button id="createPackingList" class="button-link" data-href="/documents/newDocument/packingList/<?=$enquiry['Enquiry']['id']?>/<?=$job['Job']['id']?>/<?=$document['Document']['id']?>">Create Packing List</button>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
45
app/views/elements/document_packinglist_view.ctp
Executable file
45
app/views/elements/document_packinglist_view.ctp
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
<h2>Packing List: <?=$document['PackingList']['title']?> for <?=$html->link($enquiry['Customer']['name'], '/customers/view/'.$enquiry['Customer']['id']);?></h2>
|
||||
<h2>Job: <?=$html->link($packing_list['Job']['title'], array('controller'=>'jobs', 'action'=>'view', $invoice['Job']['id']));?></h2>
|
||||
|
||||
<div id="flashMessage" class="message">
|
||||
</div>
|
||||
<div class="docButtons">
|
||||
<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 PackingList to customer</button>
|
||||
</div>
|
||||
|
||||
<div id="invoiceDetails" class="documentDetails">
|
||||
<fieldset>
|
||||
<? echo $form->create('Document',array('type'=>'post','action'=>'edit', 'default'=>false));
|
||||
echo $form->input('Document.id');
|
||||
echo $form->input('PackingList.id');
|
||||
echo $form->input('PackingList.job_id');
|
||||
echo $form->input('PackingList.currency_id');
|
||||
echo $form->input('PackingList.issue_date');
|
||||
echo $form->input('PackingList.due_date');
|
||||
|
||||
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('Document.bill_to');
|
||||
|
||||
|
||||
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('PackingList.fob');
|
||||
echo $form->input('Document.shipping_details', array('id'=>'shippingDetails'));
|
||||
echo $form->end(array('label'=>'Save PackingList Details', 'id'=>'savePackingListButton'));
|
||||
?>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
|
||||
<span id="packingListID" style="display: none;"><?=$document['PackingList']['id']?></span>
|
||||
|
||||
<? //debug($this->data);?>
|
||||
<? //debug($enquiry);?>
|
||||
<?php //debug($document);?>
|
||||
<?php //debug($docType);?>
|
||||
|
||||
<? //debug($invoice); ?>
|
||||
63
app/views/elements/line_items_table_with_shipping_packinglist.ctp
Executable file
63
app/views/elements/line_items_table_with_shipping_packinglist.ctp
Executable file
|
|
@ -0,0 +1,63 @@
|
|||
<table border="1" cellpadding="2" cellspacing="0" >
|
||||
<thead>
|
||||
<tr bgcolor="#f2f2f2">
|
||||
<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"></th>
|
||||
<th width="<?=$colWidths['total'];?>" align="center"></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">
|
||||
|
||||
</td>
|
||||
<td width="<?=$colWidths['total'];?>" align="center" valign="top">
|
||||
</td>
|
||||
</tr>
|
||||
<?endforeach;?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr nobr="true">
|
||||
<td colspan="3" bgcolor="#f2f2f2" nobr="true">FREIGHT DETAILS:
|
||||
</td>
|
||||
<td width="<?=$colWidths['unit'];?>" bgcolor="#f2f2f2" align="left"></td>
|
||||
<td width="<?=$colWidths['total'];?>" align="center">
|
||||
</td>
|
||||
</tr>
|
||||
<tr nobr="true">
|
||||
<td colspan="3" rowspan="2" nobr="true" align="left"><?=$document['Document']['shipping_details'];?></td>
|
||||
<td width="<?=$colWidths['unit'];?>" bgcolor="#f2f2f2" align="left"></td>
|
||||
<td width="<?=$colWidths['total'];?>" align="center">
|
||||
</td>
|
||||
</tr>
|
||||
<tr nobr="true">
|
||||
|
||||
<td width="<?=$colWidths['unit'];?>" align="left" bgcolor="#f2f2f2">
|
||||
</td>
|
||||
<td width="<?=$colWidths['total'];?>" align="center">
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
|
@ -18,6 +18,8 @@ $('.ckeditor').ckeditor(config);
|
|||
echo $form->input('description', array('id' => 'description', 'class'=>'ckeditor'));
|
||||
|
||||
echo $form->input('notes');
|
||||
echo $form->input('item_code');
|
||||
echo $form->input('item_description');
|
||||
|
||||
|
||||
echo $html->image('calculator.png');
|
||||
|
|
|
|||
|
|
@ -398,7 +398,7 @@ $(function() {
|
|||
$("#addJobConfirmation").dialog('open');
|
||||
});
|
||||
|
||||
$("#createInvoice").click(function() {
|
||||
$(".button-link").click(function() {
|
||||
location.href = $(this).data('href');
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue