diff --git a/app/config/core.php b/app/config/core.php index d3eb62bd..cd9d2ab4 100644 --- a/app/config/core.php +++ b/app/config/core.php @@ -42,7 +42,7 @@ */ Configure::write('debug', 0); -Configure::write('version', '0.9.8'); +Configure::write('version', '0.9.9'); $host = $_SERVER['HTTP_HOST']; diff --git a/app/controllers/costings_controller.php b/app/controllers/costings_controller.php index fe2cd478..531e8932 100755 --- a/app/controllers/costings_controller.php +++ b/app/controllers/costings_controller.php @@ -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)); } diff --git a/app/controllers/documents_controller.php b/app/controllers/documents_controller.php index 8a837f21..0fc891fd 100755 --- a/app/controllers/documents_controller.php +++ b/app/controllers/documents_controller.php @@ -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) { diff --git a/app/controllers/products_controller.php b/app/controllers/products_controller.php index 6a85856f..2f592973 100755 --- a/app/controllers/products_controller.php +++ b/app/controllers/products_controller.php @@ -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')); diff --git a/app/migrations/10_6_2013_add_packing_list.sql b/app/migrations/10_6_2013_add_packing_list.sql new file mode 100644 index 00000000..a6449866 --- /dev/null +++ b/app/migrations/10_6_2013_add_packing_list.sql @@ -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; diff --git a/app/14_11_2011_add_myob_fields_to_products.sql b/app/migrations/14_11_2011_add_myob_fields_to_products.sql similarity index 100% rename from app/14_11_2011_add_myob_fields_to_products.sql rename to app/migrations/14_11_2011_add_myob_fields_to_products.sql diff --git a/app/27_9_2011_shipment_invoices.sql b/app/migrations/27_9_2011_shipment_invoices.sql similarity index 100% rename from app/27_9_2011_shipment_invoices.sql rename to app/migrations/27_9_2011_shipment_invoices.sql diff --git a/app/models/document.php b/app/models/document.php index 29fa542e..ee477c80 100755 --- a/app/models/document.php +++ b/app/models/document.php @@ -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; diff --git a/app/models/packing_list.php b/app/models/packing_list.php new file mode 100755 index 00000000..d40c7d5c --- /dev/null +++ b/app/models/packing_list.php @@ -0,0 +1,41 @@ + 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' + ) + ); + +} +?> diff --git a/app/views/documents/pdf_packinglist.ctp b/app/views/documents/pdf_packinglist.ctp new file mode 100755 index 00000000..6f5a8841 --- /dev/null +++ b/app/views/documents/pdf_packinglist.ctp @@ -0,0 +1,38 @@ +SetPrintHeader(false); +$pdfdoc->SetPrintFooter(false); + + +$pdfdoc->AddPage(); +$pdfdoc->Page1Header(); + +$pageTitle = "

PACKING LIST

"; +$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)); + +?> + + + diff --git a/app/views/elements/document_invoice_view.ctp b/app/views/elements/document_invoice_view.ctp index e5f477e7..9a830f01 100755 --- a/app/views/elements/document_invoice_view.ctp +++ b/app/views/elements/document_invoice_view.ctp @@ -9,6 +9,17 @@ +
+

Create new Documents based on this

+ +
+
diff --git a/app/views/elements/document_orderack_view.ctp b/app/views/elements/document_orderack_view.ctp index fc6cae67..58895a0d 100755 --- a/app/views/elements/document_orderack_view.ctp +++ b/app/views/elements/document_orderack_view.ctp @@ -12,7 +12,14 @@

Create new Documents based on this

diff --git a/app/views/elements/document_packinglist_view.ctp b/app/views/elements/document_packinglist_view.ctp new file mode 100755 index 00000000..68d3faec --- /dev/null +++ b/app/views/elements/document_packinglist_view.ctp @@ -0,0 +1,45 @@ +

Packing List: for link($enquiry['Customer']['name'], '/customers/view/'.$enquiry['Customer']['id']);?>

+

Job: link($packing_list['Job']['title'], array('controller'=>'jobs', 'action'=>'view', $invoice['Job']['id']));?>

+ +
+
+
+ + +
+ +
+
+ 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')); + ?> +
+
+ + + + +data);?> + + + + + diff --git a/app/views/elements/line_items_table_with_shipping_packinglist.ctp b/app/views/elements/line_items_table_with_shipping_packinglist.ctp new file mode 100755 index 00000000..ecef7ed6 --- /dev/null +++ b/app/views/elements/line_items_table_with_shipping_packinglist.ctp @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ITEM
NO.
QTYDESCRIPTION
+ '; + $hasOptions = true; + } + ?> + + formatDecimal($li['quantity']);?>
+ + +
FREIGHT DETAILS: + +
+
+ +
diff --git a/app/views/products/clone_product.ctp b/app/views/products/clone_product.ctp index 24748d84..b5d87867 100755 --- a/app/views/products/clone_product.ctp +++ b/app/views/products/clone_product.ctp @@ -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'); diff --git a/app/webroot/js/document_add_edit.js b/app/webroot/js/document_add_edit.js index b4486fe0..f4f25629 100755 --- a/app/webroot/js/document_add_edit.js +++ b/app/webroot/js/document_add_edit.js @@ -398,7 +398,7 @@ $(function() { $("#addJobConfirmation").dialog('open'); }); - $("#createInvoice").click(function() { + $(".button-link").click(function() { location.href = $(this).data('href'); });