diff --git a/controllers/freight_forwarders_controller.php b/controllers/freight_forwarders_controller.php index 4ca40330..656638d5 100644 --- a/controllers/freight_forwarders_controller.php +++ b/controllers/freight_forwarders_controller.php @@ -47,15 +47,24 @@ class FreightForwardersController extends AppController { } } - function delete($id = null) { - if (!$id) { - $this->Session->setFlash(__('Invalid id for FreightForwarder', true)); - $this->redirect(array('action'=>'index')); + + function ajax_add() { + $this->layout = 'ajax'; + if(!empty($this->data['Shipment']['newFreightForwarderName'])) { + $this->FreightForwarder->create(); + $this->data['FreightForwarder']['name'] = trim($this->data['Shipment']['newFreightForwarderName']); + if($this->FreightForwarder->save($this->data['FreightForwarder'])) { + echo "SUCCESS"; } - if ($this->FreightForwarder->del($id)) { - $this->Session->setFlash(__('FreightForwarder deleted', true)); - $this->redirect(array('action'=>'index')); + else { + echo "FAIL"; } + } + } + + function build_options() { + $this->layout = 'ajax'; + $this->set('freight_forwarders',$this->FreightForwarder->find('list')); } } diff --git a/controllers/shipment_invoices_controller.php b/controllers/shipment_invoices_controller.php index 359575c4..740c1da1 100644 --- a/controllers/shipment_invoices_controller.php +++ b/controllers/shipment_invoices_controller.php @@ -28,10 +28,10 @@ class ShipmentInvoicesController extends AppController { } } $shipments = $this->ShipmentInvoice->Shipment->find('list'); - $freight_forwarders = $this->ShipmentInvoice->FreightForwarder->find('list'); $principles = $this->ShipmentInvoice->Principle->find('list'); $currencies = $this->ShipmentInvoice->Currency->find('list'); - $this->set(compact('shipments', 'principles', 'currencies', 'freight_forwarders')); + $freightForwarders = $this->ShipmentInvoice->FreightForwarder->find('list'); + $this->set(compact('shipments', 'principles', 'currencies', 'freightForwarders')); } function edit($id = null) { @@ -53,7 +53,8 @@ class ShipmentInvoicesController extends AppController { $shipments = $this->ShipmentInvoice->Shipment->find('list'); $principles = $this->ShipmentInvoice->Principle->find('list'); $currencies = $this->ShipmentInvoice->Currency->find('list'); - $this->set(compact('shipments','principles','currencies')); + $freightForwarders = $this->ShipmentInvoice->FreightForwarder->find('list'); + $this->set(compact('shipments','principles','currencies','freightForwarders')); } function delete($id = null) { diff --git a/controllers/shipments_controller.php b/controllers/shipments_controller.php index d22b1ad3..928f1998 100644 --- a/controllers/shipments_controller.php +++ b/controllers/shipments_controller.php @@ -66,7 +66,9 @@ class ShipmentsController extends AppController { $freightForwarders = $this->Shipment->FreightForwarder->find('list'); $shipmentType = $this->typeOptions(false); $shipmentTypeShort = $this->typeOptions(true); - $this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort')); + $currencies = $this->Shipment->ShipmentInvoice->Currency->find('list'); + + $this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort', 'currencies')); } @@ -84,7 +86,10 @@ class ShipmentsController extends AppController { $freightForwarders = $this->Shipment->FreightForwarder->find('list'); $shipmentType = $this->typeOptions(false); $shipmentTypeShort = $this->typeOptions(true); - $this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort')); + $currencies = $this->Shipment->ShipmentInvoice->Currency->find('list'); + $invoiceType = $this->invoiceTypeOptions(); + $this->set('yesNo', array(0=>'No', 1=>'Yes')); + $this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort', 'currencies','invoiceType', 'yesNo')); } @@ -97,7 +102,8 @@ class ShipmentsController extends AppController { $freightForwarders = $this->Shipment->FreightForwarder->find('list'); $shipmentType = $this->typeOptions(false); $shipmentTypeShort = $this->typeOptions(true); - $this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort')); + $currencies = $this->Shipment->ShipmentInvoice->Currency->find('list'); + $this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort', 'currencies')); } @@ -116,13 +122,14 @@ class ShipmentsController extends AppController { $boxIDs = array(); foreach($this->data['Box'] as $box) { $boxIDs[] = $box['id']; + } $invoiceIDs = array(); foreach($this->data['ShipmentInvoice'] as $si) { $invoiceIDs[] = $si['id']; } - + print_r($boxIDs); @@ -173,6 +180,12 @@ class ShipmentsController extends AppController { }*/ + + function invoiceTypeOptions() { + $options = array('', 'Freight','Customs','Principle'); + return $options; + } + function typeOptions($short = false) { if($short == false) { $options = array('','Import: Principle to CMC','Direct: Principle to Customer','Export','Local'); diff --git a/models/job.php b/models/job.php index fb67692e..0bb050ef 100755 --- a/models/job.php +++ b/models/job.php @@ -51,6 +51,11 @@ class Job extends AppModel { 'Email' => array( 'className' => 'Email', 'joinTable' => 'emails_jobs', + ), + + 'Shipment' => array( + 'className' => 'Shipment', + 'joinTable' => 'shipments_jobs', ) ); diff --git a/models/shipment_invoice.php b/models/shipment_invoice.php index 522e47f1..747224f5 100644 --- a/models/shipment_invoice.php +++ b/models/shipment_invoice.php @@ -2,13 +2,6 @@ class ShipmentInvoice extends AppModel { var $name = 'ShipmentInvoice'; - /*var $validate = array( - 'shipment_id' => array('numeric'), - 'principle_id' => array('numeric'), - 'currency_id' => array('numeric'), - 'invoice_number' => array('notempty'), - 'approved' => array('numeric') - );*/ //The Associations below have been created with all possible keys, those that are not needed can be removed var $belongsTo = array( @@ -18,7 +11,7 @@ class ShipmentInvoice extends AppModel { 'conditions' => '', 'fields' => '', 'order' => '', - 'counterCache'=>true + 'counterCache' => 'shipment_invoice_count', ), 'Principle' => array( 'className' => 'Principle', @@ -27,17 +20,19 @@ class ShipmentInvoice extends AppModel { 'fields' => '', 'order' => '' ), - - 'FreightForwarder' => array( - 'className' => 'FreightForwarder', - 'foreignKey' => 'freight_forwarder_id' - ), 'Currency' => array( 'className' => 'Currency', 'foreignKey' => 'currency_id', 'conditions' => '', 'fields' => '', 'order' => '' + ), + 'FreightForwarder' => array( + 'className' => 'FreightForwarder', + 'foreignKey' => 'freight_forwarder_id', + 'conditions' => '', + 'fields' => '', + 'order' => '' ) ); diff --git a/views/elements/add_edit_shipment.ctp b/views/elements/add_edit_shipment.ctp new file mode 100644 index 00000000..7b823e91 --- /dev/null +++ b/views/elements/add_edit_shipment.ctp @@ -0,0 +1,186 @@ +create('Shipment', array('default'=>false));?> +input('user_id', array('type'=>'hidden', 'value'=>$currentuser['User']['id'])); +echo $form->input('type', array('options'=>$shipmentType, 'id'=>'shipmentType')); +echo $form->input('id', array('type'=>'hidden')); +?> +
+ input('date_arrived_display', array('label'=>'Date Arrived', 'id'=>'date_arrived_display', 'value'=>$this->element('isEmptyDate', array('date'=>$this->data['Shipment']['date_arrived'])))); + echo $form->input('date_arrived', array('type'=>'hidden', 'id'=>'date_arrived')); + ?> + + + +
+ +
+ input('date_dispatched_display', array('label'=>'Date Dispatched', 'id'=>'date_dispatched_display', 'value'=>$this->element('isEmptyDate', array('date'=>$this->data['Shipment']['date_dispatched'])))); + + echo $form->input('date_dispatched', array('type'=>'hidden', 'id'=>'date_dispatched')); + ?> +
+ + +
+ input('Principle', array('name'=>'PrincipleSelect', 'type'=>'select', 'multiple'=>false)); ?> + + + +
+ +
+ input('purchase_order', array('id'=>'purchase_order_autocomplete' ,'label'=>'Purchase Order (start typing and select from the list)'));?> + + +
+ +
+ input('job', array('id'=>'job_autocomplete')); + ?> + + + + +
+ +
+ input('customer', array('id'=>'customer_autocomplete', 'label'=>'Customer', 'value'=>$this->data['Customer']['name']));?> + input('customer_id', array('type'=>'hidden', 'id'=>'customer_id', 'value'=>$this->data['Shipment']['customer_id']));?> +
+ +
+ Shipping Address: +
+
+ input('address_id', array('type'=>'hidden', 'id'=>'address_id', 'value'=>$this->data['Shipment']['address_id']));?> + + +
+ + +
+ input('freight_forwarder_id');?> + + +
+ input('newFreightForwarderName');?> + + +
+ +
+ +
+ input('airway_bill');?> +
+ +
+ + + + data['Box'] as $box):?> +
+ + input("Box.{$boxNo}.id", array('type'=>'hidden'));?> + input("Box.{$boxNo}.shipment_id", array('type'=>'hidden', 'value'=>$this->data['Shipment']['id']));?> + input("Box.{$boxNo}.length", array('label'=>'Length (cm)', 'div'=>'length'));?> + input("Box.{$boxNo}.width", array('label'=>'Width (cm)', 'div'=>'width'));?> + input("Box.{$boxNo}.height", array('label'=>'Height (cm)', 'div'=>'height'));?> + input("Box.{$boxNo}.weight", array('label'=>'Weight (kg)', 'div'=>'weight'));?> +
+ +
+ + +
+ + + + + + data['ShipmentInvoice'] as $invoice):?> +
+ + input("ShipmentInvoice.{$invNo}.id", array('type'=>'hidden')); + echo $form->input("ShipmentInvoice.{$invNo}.shipment_id", array('type'=>'hidden', 'value'=>$this->data['Shipment']['id'])); + echo $form->input("ShipmentInvoice.{$invNo}.currency_id"); + echo $form->input("ShipmentInvoice.{$invNo}.freight_forwarder_id"); + echo $form->input("ShipmentInvoice.{$invNo}.invoice_number"); + echo $form->input("ShipmentInvoice.{$invNo}.invoice_amount"); + echo $form->input("ShipmentInvoice.{$invNo}.gst_amount"); + echo $form->input("ShipmentInvoice.{$invNo}.deferred_gst"); + echo $form->input("ShipmentInvoice.{$invNo}.approved"); + echo $form->input("ShipmentInvoice.{$invNo}.paid"); + echo $form->input("ShipmentInvoice.{$invNo}.date_paid"); + echo $form->input("ShipmentInvoice.{$invNo}.invoice_type"); + ?> +
+ +
+ + +
+ input('comments');?> + +
+ + +end();?> +
+ input('length', array('label'=>'Length (cm)', 'div'=>'length'));?> + input('width', array('label'=>'Width (cm)', 'div'=>'width'));?> + input('height', array('label'=>'Height (cm)', 'div'=>'height'));?> + input('weight', array('label'=>'Weight (kg)', 'div'=>'weight'));?> +
+ +
+ input("invoice_type", array('type'=>'select','label'=>'Invoice Type', 'div'=>'inv_invoice_type', 'options'=>$invoiceType)); + echo $form->input("currency_id",array('label'=>'Currency', 'div'=>'inv_currency_id', 'options'=>$currencies)); + echo $form->input("freight_forwarder_id", array('label'=>'Freight Forwarder', 'div'=>'inv_freight_forwarder_id', 'options'=>$freightForwarders)); + echo $form->input("invoice_number", array('label'=>'Invoice Number', 'div'=>'inv_invoice_number')); + echo $form->input("invoice_amount", array('label'=>'Invoice Amount', 'div'=>'inv_invoice_amount')); + echo $form->input("gst_amount", array('label'=>'GST Amount', 'div'=>'inv_gst_amount')); + echo $form->input("deferred_gst", array('label'=>'Deferred GST?', 'div'=>'inv_deferred_gst', 'options'=>$yesNo)); + echo $form->input("deferred_gst_amount", array('label'=>'Deferred GST Amount', 'div'=>'inv_deferred_gst_amount')); + echo $form->input("approved", array('label'=>'Approved', 'div'=>'inv_approved')); + echo $form->input("paid", array('label'=>'Paid', 'div'=>'inv_paid')); + echo $form->input("date_paid", array('label'=>'Date Paid', 'div'=>'inv_date_paid')); + ?> +
\ No newline at end of file diff --git a/views/elements/add_shipment.ctp b/views/elements/add_shipment.ctp deleted file mode 100644 index 8119a9d4..00000000 --- a/views/elements/add_shipment.ctp +++ /dev/null @@ -1,92 +0,0 @@ - - -create('Shipment', array('default'=>false));?> -input('user_id', array('type'=>'hidden', 'value'=>$currentuser['User']['id'])); -echo $form->input('type', array('options'=>$shipmentType, 'id'=>'shipmentType')); -echo $form->input('id', array('type'=>'hidden')); -?> -
- input('date_arrived_display', array('label'=>'Date Arrived', 'id'=>'date_arrived_display')); - echo $form->input('date_arrived', array('type'=>'hidden', 'id'=>'date_arrived')); - - ?> -
- -
-input('date_dispatched_display', array('label'=>'Date dispatched', 'id'=>'date_dispatched_display')); - echo $form->input('date_dispatched', array('type'=>'hidden', 'id'=>'date_dispatched')); -?> -
- - -
- input('Principle', array('name'=>'PrincipleSelect', 'type'=>'select', 'multiple'=>false)); ?> - - - -
- -
- input('purchase_order', array('id'=>'purchase_order_autocomplete'));?> - - -
- -
- input('job', array('id'=>'job_autocomplete')); - ?> - - - - -
- -
- input('customer', array('id'=>'customer_autocomplete', 'label'=>'Customer'));?> - input('customer_id', array('type'=>'hidden', 'id'=>'customer_id'));?> -
- -
- Shipping Address: -
-
- -
- - -
- input('freight_forwarder_id');?> -
- -
- input('airway_bill');?> -
- -
- -
- -
- input('comments');?> - -
- - -end();?> - -
- input('Box.0.length', array('label'=>'Length (cm)', 'div'=>'length'));?> - input('Box.0.width', array('label'=>'Width (cm)', 'div'=>'width'));?> - input('Box.0.height', array('label'=>'Height (cm)', 'div'=>'height'));?> - input('Box.0.weight', array('label'=>'Weight (kg)', 'div'=>'weight'));?> -
\ No newline at end of file diff --git a/views/elements/isEmptyDate.ctp b/views/elements/isEmptyDate.ctp index f9e2c502..45a7a6ce 100755 --- a/views/elements/isEmptyDate.ctp +++ b/views/elements/isEmptyDate.ctp @@ -1,9 +1,13 @@ diff --git a/views/elements/shipment_index_all.ctp b/views/elements/shipment_index_all.ctp index 6b1069ae..c49d17aa 100644 --- a/views/elements/shipment_index_all.ctp +++ b/views/elements/shipment_index_all.ctp @@ -13,9 +13,16 @@ Weight (kg) sort('freight_forwarder_id');?> - - sort('airway_bill');?> + # Invoices + Issued By + Invoice Amount + Deferred GST + Approved? + Paid? + Date Paid + + sort('comments');?> @@ -110,6 +117,20 @@ + + + + + Issued By Principle/FF name + + + Invoice amount + Deferred GST amount + + Approved? + Paid + Date Paid + diff --git a/views/elements/shipment_index_direct.ctp b/views/elements/shipment_index_direct.ctp index 6b1069ae..8361c1c6 100644 --- a/views/elements/shipment_index_direct.ctp +++ b/views/elements/shipment_index_direct.ctp @@ -1,7 +1,6 @@ - @@ -28,11 +27,6 @@ -
sort('date_arrived');?> sort('date_dispatched');?> sort('type');?> Principle(s) - element('isEmptyDate', array('date'=>$shipment['Shipment']['date_arrived'])); - ?> - element('isEmptyDate', array('date'=>$shipment['Shipment']['date_dispatched'])); diff --git a/views/elements/shipment_index_export.ctp b/views/elements/shipment_index_export.ctp index 6b1069ae..ba77b235 100644 --- a/views/elements/shipment_index_export.ctp +++ b/views/elements/shipment_index_export.ctp @@ -1,12 +1,9 @@ - - - - + - - - - - - -
sort('date_arrived');?> sort('date_dispatched');?> sort('type');?>Principle(s)PO(s)JobsJob(s) sort('# Boxes','box_count');?> Box Details
LxWxH (cm) @@ -28,11 +25,6 @@ -
- element('isEmptyDate', array('date'=>$shipment['Shipment']['date_arrived'])); - ?> - element('isEmptyDate', array('date'=>$shipment['Shipment']['date_dispatched'])); @@ -43,27 +35,6 @@ - - link($principle['short_name'], array('controller'=>'principles','action'=>'view',$principle['id'])); - } - else { - echo $html->link($principle['name'], array('controller'=>'principles','action'=>'view',$principle['id'])); - } - ?> - -
- -
- - link($po['title'], array('controller'=>'purchase_orders', 'action'=>'view', $po['id']));?> -
- -
link($job['title'], array('controller'=>'jobs', 'action'=>'view', $job['id']));?> diff --git a/views/elements/shipment_index_import.ctp b/views/elements/shipment_index_import.ctp index 6b1069ae..aef9e8ef 100644 --- a/views/elements/shipment_index_import.ctp +++ b/views/elements/shipment_index_import.ctp @@ -2,11 +2,9 @@
sort('date_arrived');?>sort('date_dispatched');?> sort('type');?> Principle(s) PO(s)Jobs sort('# Boxes','box_count');?> Box Details
LxWxH (cm) @@ -33,11 +31,6 @@ echo $this->element('isEmptyDate', array('date'=>$shipment['Shipment']['date_arrived'])); ?> -
- element('isEmptyDate', array('date'=>$shipment['Shipment']['date_dispatched'])); - ?> - @@ -64,12 +57,6 @@ - - link($job['title'], array('controller'=>'jobs', 'action'=>'view', $job['id']));?> -
- -
diff --git a/views/elements/shipment_index_local.ctp b/views/elements/shipment_index_local.ctp index 6b1069ae..e32ebe9f 100644 --- a/views/elements/shipment_index_local.ctp +++ b/views/elements/shipment_index_local.ctp @@ -1,11 +1,8 @@ - - - - - - - + diff --git a/views/shipment_invoices/add.ctp b/views/shipment_invoices/add.ctp index 15a0d24c..41bd9182 100644 --- a/views/shipment_invoices/add.ctp +++ b/views/shipment_invoices/add.ctp @@ -11,6 +11,8 @@ echo $form->input('invoice_amount'); echo $form->input('deferred_gst'); echo $form->input('approved'); + echo $form->input('paid'); + echo $form->input('date_paid'); echo $form->input('invoice_type'); ?> @@ -19,13 +21,5 @@
  • link(__('List ShipmentInvoices', true), array('action' => 'index'));?>
  • -
  • link(__('List Shipments', true), array('controller' => 'shipments', 'action' => 'index')); ?>
  • -
  • link(__('New Shipment', true), array('controller' => 'shipments', 'action' => 'add')); ?>
  • -
  • link(__('List Principles', true), array('controller' => 'principles', 'action' => 'index')); ?>
  • -
  • link(__('New Principle', true), array('controller' => 'principles', 'action' => 'add')); ?>
  • -
  • link(__('List Freight Forwarders', true), array('controller' => 'freight_forwarders', 'action' => 'index')); ?>
  • -
  • link(__('New Freight Forwarder', true), array('controller' => 'freight_forwarders', 'action' => 'add')); ?>
  • -
  • link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?>
  • -
  • link(__('New Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?>
diff --git a/views/shipment_invoices/edit.ctp b/views/shipment_invoices/edit.ctp index 59cccc65..be1d444e 100644 --- a/views/shipment_invoices/edit.ctp +++ b/views/shipment_invoices/edit.ctp @@ -12,6 +12,8 @@ echo $form->input('invoice_amount'); echo $form->input('deferred_gst'); echo $form->input('approved'); + echo $form->input('paid'); + echo $form->input('date_paid'); echo $form->input('invoice_type'); ?> @@ -21,13 +23,5 @@
  • link(__('Delete', true), array('action' => 'delete', $form->value('ShipmentInvoice.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('ShipmentInvoice.id'))); ?>
  • link(__('List ShipmentInvoices', true), array('action' => 'index'));?>
  • -
  • link(__('List Shipments', true), array('controller' => 'shipments', 'action' => 'index')); ?>
  • -
  • link(__('New Shipment', true), array('controller' => 'shipments', 'action' => 'add')); ?>
  • -
  • link(__('List Principles', true), array('controller' => 'principles', 'action' => 'index')); ?>
  • -
  • link(__('New Principle', true), array('controller' => 'principles', 'action' => 'add')); ?>
  • -
  • link(__('List Freight Forwarders', true), array('controller' => 'freight_forwarders', 'action' => 'index')); ?>
  • -
  • link(__('New Freight Forwarder', true), array('controller' => 'freight_forwarders', 'action' => 'add')); ?>
  • -
  • link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?>
  • -
  • link(__('New Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?>
diff --git a/views/shipment_invoices/index.ctp b/views/shipment_invoices/index.ctp index 4ac39132..2bdeb62d 100644 --- a/views/shipment_invoices/index.ctp +++ b/views/shipment_invoices/index.ctp @@ -17,6 +17,8 @@ echo $paginator->counter(array( + + @@ -33,16 +35,16 @@ foreach ($shipmentInvoices as $shipmentInvoice): + + @@ -76,13 +84,5 @@ foreach ($shipmentInvoices as $shipmentInvoice):
  • link(__('New ShipmentInvoice', true), array('action' => 'add')); ?>
  • -
  • link(__('List Shipments', true), array('controller' => 'shipments', 'action' => 'index')); ?>
  • -
  • link(__('New Shipment', true), array('controller' => 'shipments', 'action' => 'add')); ?>
  • -
  • link(__('List Principles', true), array('controller' => 'principles', 'action' => 'index')); ?>
  • -
  • link(__('New Principle', true), array('controller' => 'principles', 'action' => 'add')); ?>
  • -
  • link(__('List Freight Forwarders', true), array('controller' => 'freight_forwarders', 'action' => 'index')); ?>
  • -
  • link(__('New Freight Forwarder', true), array('controller' => 'freight_forwarders', 'action' => 'add')); ?>
  • -
  • link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?>
  • -
  • link(__('New Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?>
diff --git a/views/shipment_invoices/view.ctp b/views/shipment_invoices/view.ctp index b47ba402..c48a0958 100644 --- a/views/shipment_invoices/view.ctp +++ b/views/shipment_invoices/view.ctp @@ -6,24 +6,24 @@   - > + > > - link($shipmentInvoice['Shipment']['id'], array('controller' => 'shipments', 'action' => 'view', $shipmentInvoice['Shipment']['id'])); ?> +   - > + > > - link($shipmentInvoice['Principle']['name'], array('controller' => 'principles', 'action' => 'view', $shipmentInvoice['Principle']['id'])); ?> +   - > + > > - link($shipmentInvoice['Currency']['name'], array('controller' => 'currencies', 'action' => 'view', $shipmentInvoice['Currency']['id'])); ?> +   - > + > > - link($shipmentInvoice['FreightForwarder']['name'], array('controller' => 'freight_forwarders', 'action' => 'view', $shipmentInvoice['FreightForwarder']['id'])); ?> +   > @@ -46,6 +46,16 @@   + > + > + +   + + > + > + +   + > > @@ -59,13 +69,5 @@
  • link(__('Delete ShipmentInvoice', true), array('action' => 'delete', $shipmentInvoice['ShipmentInvoice']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $shipmentInvoice['ShipmentInvoice']['id'])); ?>
  • link(__('List ShipmentInvoices', true), array('action' => 'index')); ?>
  • link(__('New ShipmentInvoice', true), array('action' => 'add')); ?>
  • -
  • link(__('List Shipments', true), array('controller' => 'shipments', 'action' => 'index')); ?>
  • -
  • link(__('New Shipment', true), array('controller' => 'shipments', 'action' => 'add')); ?>
  • -
  • link(__('List Principles', true), array('controller' => 'principles', 'action' => 'index')); ?>
  • -
  • link(__('New Principle', true), array('controller' => 'principles', 'action' => 'add')); ?>
  • -
  • link(__('List Freight Forwarders', true), array('controller' => 'freight_forwarders', 'action' => 'index')); ?>
  • -
  • link(__('New Freight Forwarder', true), array('controller' => 'freight_forwarders', 'action' => 'add')); ?>
  • -
  • link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?>
  • -
  • link(__('New Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?>
  • diff --git a/views/shipments/add.ctp b/views/shipments/add.ctp index bc083c54..750e30eb 100644 --- a/views/shipments/add.ctp +++ b/views/shipments/add.ctp @@ -1,2 +1,2 @@ link('add_edit_shipment');?> - element('add_shipment');?> \ No newline at end of file + element('add_edit_shipment', array('invoiceType'=>$invoiceType));?> \ No newline at end of file diff --git a/views/shipments/edit.ctp b/views/shipments/edit.ctp index 20712d42..ea6e53ed 100644 --- a/views/shipments/edit.ctp +++ b/views/shipments/edit.ctp @@ -1,133 +1,5 @@ link('add_edit_shipment');?> -create('Shipment', array('default'=>false));?> -input('user_id', array('type'=>'hidden', 'value'=>$currentuser['User']['id'])); -echo $form->input('type', array('options'=>$shipmentType, 'id'=>'shipmentType')); -echo $form->input('id', array('type'=>'hidden')); -?> -
    - input('date_arrived_display', array('label'=>'Date Arrived', 'id'=>'date_arrived_display', 'value'=>$this->element('isEmptyDate', array('date'=>$this->data['Shipment']['date_arrived'])))); - echo $form->input('date_arrived', array('type'=>'hidden', 'id'=>'date_arrived')); - ?> - - - -
    - -
    - input('date_dispatched_display', array('label'=>'Date Dispatched', 'id'=>'date_dispatched_display', 'value'=>$this->element('isEmptyDate', array('date'=>$this->data['Shipment']['date_dispatched'])))); - - echo $form->input('date_dispatched', array('type'=>'hidden', 'id'=>'date_dispatched')); - ?> -
    - - -
    - input('Principle', array('name'=>'PrincipleSelect', 'type'=>'select', 'multiple'=>false)); ?> - -
      - data['Principle'] as $principle):?> -
    • - - - -
    • - -
    - -
    - -
    - input('purchase_order', array('id'=>'purchase_order_autocomplete'));?> - -
      - data['PurchaseOrder'] as $po):?> -
    • - - - -
    • - -
    -
    - -
    - input('job', array('id'=>'job_autocomplete')); - ?> - - -
      - data['Job'] as $job):?> -
    • - - - -
    • - -
    - -
    - -
    - input('customer', array('id'=>'customer_autocomplete', 'label'=>'Customer', 'value'=>$this->data['Customer']['name']));?> - input('customer_id', array('type'=>'hidden', 'id'=>'customer_id', 'value'=>$this->data['Shipment']['customer_id']));?> -
    - -
    - Shipping Address: -
    -
    - input('address_id', array('type'=>'hidden', 'id'=>'address_id', 'value'=>$this->data['Shipment']['address_id']));?> - - -
    - - -
    - input('freight_forwarder_id');?> -
    - -
    - input('airway_bill');?> -
    - -
    - - - - data['Box'] as $box):?> -
    - - input("Box.{$boxNo}.id", array('type'=>'hidden'));?> - input("Box.{$boxNo}.shipment_id", array('type'=>'hidden', 'value'=>$this->data['Shipment']['id']));?> - input("Box.{$boxNo}.length", array('label'=>'Length (cm)', 'div'=>'length'));?> - input("Box.{$boxNo}.width", array('label'=>'Width (cm)', 'div'=>'width'));?> - input("Box.{$boxNo}.height", array('label'=>'Height (cm)', 'div'=>'height'));?> - input("Box.{$boxNo}.weight", array('label'=>'Weight (kg)', 'div'=>'weight'));?> -
    - -
    - -
    - input('comments');?> - -
    - - -end();?> - -
    - input('length', array('label'=>'Length (cm)', 'div'=>'length'));?> - input('width', array('label'=>'Width (cm)', 'div'=>'width'));?> - input('height', array('label'=>'Height (cm)', 'div'=>'height'));?> - input('weight', array('label'=>'Weight (kg)', 'div'=>'weight'));?> -
    + element('add_edit_shipment', array('invoiceType'=>$invoiceType));?> data); ?> \ No newline at end of file diff --git a/views/shipments/index.ctp b/views/shipments/index.ctp index aaae22d9..3e57b4fb 100644 --- a/views/shipments/index.ctp +++ b/views/shipments/index.ctp @@ -15,7 +15,8 @@
    - element('shipment_index_'.$type);?> + element('shipment_index_'.$type);?> + element('shipment_index_all');?>
    diff --git a/webroot/css/quotenik.css b/webroot/css/quotenik.css index 28f13bff..4153e4e5 100755 --- a/webroot/css/quotenik.css +++ b/webroot/css/quotenik.css @@ -1183,45 +1183,6 @@ label span#exchangeConversion { } -form.cmxform { - width: 80%; -} - -form.cmxform input { - width: auto; - display: inline; -} - -form.cmxform fieldset ol { - margin: 0; - padding: 0; -} -form.cmxform fieldset li { - list-style: none; - padding: 5px; - margin: 0; -} -form.cmxform fieldset fieldset { - border: none; - margin: 3px 0 0; -} -form.cmxform fieldset fieldset legend { - padding: 0 0 5px; - font-weight: normal; -} -form.cmxform fieldset fieldset label { - display: block; - -} -form.cmxform em { - font-weight: bold; - font-style: normal; - color: #f00; -} - -form.cmxform fieldset fieldset label { - margin-left: 123px; /* Width plus 3 (html space) */ -} #sortable { list-style-type: none; margin: 0; padding: 0; } @@ -1377,7 +1338,7 @@ select.job_status { .scrollHorizontal { - height: 800px; + height: 500px; overflow:scroll; } @@ -1477,18 +1438,19 @@ table.shipments { width: 50px; } -.boxForm label { - float: left; - margin-right: 1em; - text-align: right; - width: 8em; -} .boxForm div { } +.invForm { + border: 1px solid; + width: 15em; + margin-top: 1em; +} + + span.totalWeight { - + font-weight: bolder; } diff --git a/webroot/js/add_edit_shipment.js b/webroot/js/add_edit_shipment.js index 53259169..df4faadc 100644 --- a/webroot/js/add_edit_shipment.js +++ b/webroot/js/add_edit_shipment.js @@ -1,6 +1,9 @@ $(function() { var addedBoxes = $(".boxForm").length; + var addedInvoices = $('.invForm').length; + + $('button').button(); displayReleventFields(); @@ -32,8 +35,33 @@ $(function() { $(this).parent().remove(); }); + //Add a new Freight Forwarder. + $('.addFreightForwarder').live('click', function() { + $('#newFreightForwarderDiv').show(); + $(this).hide(); + }); + //Cancel adding a new Freight Forwarder. + $('.cancelNewFF').live('click', function() { + $('#newFreightForwarderDiv').hide(); + $('.addFreightForwarder').show(); + }); + //Save the new Freight Forwarder. **TODO : Handle errors **. + $('.saveNewFF').live('click', function() { + + $.post('/freight_forwarders/ajax_add', $('#newFreightForwarder'), function(data) { + if(data == 'SUCCESS') { + $.get('/freight_forwarders/build_options', function(newOptions) { + $('#ShipmentFreightForwarderId').html(newOptions); + $('#newFreightForwarderDiv').hide(); + $('.addFreightForwarder').show(); + }); + } + }); + }); + + //Add a(nother) Principle to this Shipment $('#addPrinciple').button().click(function() { var principleID = getSelectedID('#PrinciplePrinciple'); @@ -106,6 +134,17 @@ $(function() { }); + $("#addInvoice").button().click(function() { + addInvoice(addedInvoices); + addedInvoices++; + }); + + $(".removeInvoice").live('click',function() { + $(this).parent().remove(); + }); + + + $(".selectAddress").live('click', function() { var ID = $(this).attr('id'); $("#address_id").val(ID); @@ -147,25 +186,29 @@ $(function() { switch(shipmentTypeID) { case 1: //Import - $("#importFields, #principle, #purchaseOrder, #freight_forwarder, #airway_bill, #boxes").show(); + $("#importFields, #principle, #purchaseOrder").show(); + showCommonFields(); break; case 2: //Direct - $("#purchaseOrder, #job,#principle, #dateDispatched, #customer, #address, #addressSpan, #freight_forwarder, #airway_bill, #boxes").show(); + $("#purchaseOrder, #job,#principle, #dateDispatched, #customer, #address, #addressSpan").show(); + showCommonFields(); break; case 3: //Export - $("#job, #dateDispatched, #customer, #address, #addressSpan, #freight_forwarder, #airway_bill, #boxes").show(); + $("#job, #dateDispatched, #customer, #address, #addressSpan").show(); + showCommonFields(); break; case 4: //Local - $("#job, #dateDispatched, #customer, #address, #addressSpan, #freight_forwarder, #airway_bill, #boxes").show(); - - break; - - default: - - + $("#job, #dateDispatched, #customer, #address, #addressSpan").show(); + showCommonFields(); break; } + + } + //Show the fields in the shipment form that are available + //for all 4 cases + function showCommonFields() { + $("#airway_bill, #boxes, #invoices, #freight_forwarder, #comments").show(); } function addBox(addedBoxes) { @@ -176,39 +219,24 @@ $(function() { var boxNo = addedBoxes; - newBoxForm.attr('id',''); + newBoxForm.removeAttr('id'); newBoxForm.addClass('boxForm'); newBoxForm.show(); - //Set the appropriate naming for the fields so cake can work its magic. - //Should refactor into a function. - var div = newBoxForm.find('.length'); - var ID = getCakeID(model,boxNo,'length'); - var name = getCakeName(model, boxNo, 'length'); - div.children('label').attr('for', ID); - div.children('input').attr('id', ID).attr('name', name); - - div = newBoxForm.find('.width'); - ID = getCakeID(model,boxNo,'width'); - name = getCakeName(model, boxNo, 'width'); - div.children('label').attr('for', ID); - div.children('input').attr('id', ID).attr('name', name); - - div = newBoxForm.find('.height'); - ID = getCakeID(model,boxNo,'height'); - name = getCakeName(model, boxNo, 'height'); - div.children('label').attr('for', ID); - div.children('input').attr('id', ID).attr('name', name); - - div = newBoxForm.find('.weight'); - ID = getCakeID(model,boxNo,'weight'); - name = getCakeName(model, boxNo, 'weight'); - div.children('label').attr('for', ID); - div.children('input').attr('id', ID).attr('name', name); - - + var boxFields = ['length', 'width', 'height', 'weight']; + var div; + var ID; + var name; + + $.each(boxFields, function(index, field) { + div = newBoxForm.find('.'+field); + ID = getCakeID(model,boxNo,field); + name = getCakeName(model, boxNo, field); + div.children('label').attr('for', ID); + div.children('input').attr('id', ID).attr('name', name); + }); var closeButton = $(''); closeButton.addClass('removeBox'); @@ -220,6 +248,41 @@ $(function() { } + function addInvoice(addedInvoices) { + var model = 'ShipmentInvoice'; + var invoiceNo = addedInvoices; + + var newInvoiceForm = $('#invoiceFactory').clone(); + newInvoiceForm.removeAttr('id'); + newInvoiceForm.addClass('invForm'); + newInvoiceForm.show(); + + var invFields = ['currency_id', 'freight_forwarder_id', 'invoice_number', + 'invoice_amount','gst_amount','deferred_gst', 'deferred_gst_amount','approved', 'paid', 'date_paid','invoice_type']; + + var div; + var ID; + + $.each(invFields, function(index,field) { + div = newInvoiceForm.find('.inv_'+field); + ID = getCakeID(model,invoiceNo, field); + name = getCakeName(model, invoiceNo, field); + div.children('label').attr('for', ID); + div.children('input').attr('id', ID).attr('name', name); + + }); + + var closeButton = $(''); + closeButton.addClass('removeBox'); + closeButton.button(); + + newInvoiceForm.prepend(closeButton); + $("#invoices").append(newInvoiceForm); + + + + } + function getCakeID(model, count, field) { return model+count+capitalizeFirstLetter(field); }
    sort('date_arrived');?> sort('date_dispatched');?> sort('type');?>Principle(s)PO(s) Jobs sort('# Boxes','box_count');?> Box Details
    @@ -28,11 +25,6 @@ -
    - element('isEmptyDate', array('date'=>$shipment['Shipment']['date_arrived'])); - ?> - element('isEmptyDate', array('date'=>$shipment['Shipment']['date_dispatched'])); @@ -43,27 +35,6 @@ - - link($principle['short_name'], array('controller'=>'principles','action'=>'view',$principle['id'])); - } - else { - echo $html->link($principle['name'], array('controller'=>'principles','action'=>'view',$principle['id'])); - } - ?> - -
    - -
    - - link($po['title'], array('controller'=>'purchase_orders', 'action'=>'view', $po['id']));?> -
    - -
    link($job['title'], array('controller'=>'jobs', 'action'=>'view', $job['id']));?> diff --git a/views/jobs/view.ctp b/views/jobs/view.ctp index 7252c92e..7bb3d752 100755 --- a/views/jobs/view.ctp +++ b/views/jobs/view.ctp @@ -56,11 +56,6 @@
    • link(__('Edit Job', true), array('action' => 'edit', $job['Job']['id'])); ?>
    • -
    • link(__('Delete Job', true), array('action' => 'delete', $job['Job']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $job['Job']['id'])); ?>
    • -
    • link(__('List Jobs', true), array('action' => 'index')); ?>
    • -
    • link(__('New Job', true), array('action' => 'add')); ?>
    • -
    • link(__('List Enquiries', true), array('controller' => 'enquiries', 'action' => 'index')); ?>
    • -
    • link(__('New Enquiry', true), array('controller' => 'enquiries', 'action' => 'add')); ?>
    diff --git a/views/jobs/view_report.ctp b/views/jobs/view_report.ctp index 75123c4c..86fc2256 100644 --- a/views/jobs/view_report.ctp +++ b/views/jobs/view_report.ctp @@ -18,6 +18,7 @@
    Net Sales AUD Gross Profit AUD Net Export Sales Converted to Or Invoiced in AUDGross Profit Value Export in AUD GP% Excl Commissions ATO Exchange Rate sort('invoice_amount');?> sort('deferred_gst');?> sort('approved');?>sort('paid');?>sort('date_paid');?> sort('invoice_type');?>
    - link($shipmentInvoice['Shipment']['id'], array('controller' => 'shipments', 'action' => 'view', $shipmentInvoice['Shipment']['id'])); ?> + - link($shipmentInvoice['Principle']['name'], array('controller' => 'principles', 'action' => 'view', $shipmentInvoice['Principle']['id'])); ?> + - link($shipmentInvoice['Currency']['name'], array('controller' => 'currencies', 'action' => 'view', $shipmentInvoice['Currency']['id'])); ?> + - link($shipmentInvoice['FreightForwarder']['name'], array('controller' => 'freight_forwarders', 'action' => 'view', $shipmentInvoice['FreightForwarder']['id'])); ?> + @@ -56,6 +58,12 @@ foreach ($shipmentInvoices as $shipmentInvoice): + + + +