From a6bffff40e500c9935e26b61f0df3db05895e10f Mon Sep 17 00:00:00 2001
From: Karl Cordes
Date: Fri, 29 Apr 2011 17:18:44 +1000
Subject: [PATCH] Shipment thing mostly functional. ShipmentInvoices and
export,local to be done tomorrow
---
controllers/addresses_controller.php | 9 +++-
views/addresses/customer_addresses.ctp | 19 ++++++++
views/shipments/index.ctp | 29 ++++++++----
webroot/css/quotenik.css | 22 +++++++++
webroot/js/shipment_index.js | 64 ++++++++++++++++++++++++--
5 files changed, 130 insertions(+), 13 deletions(-)
create mode 100644 views/addresses/customer_addresses.ctp
diff --git a/controllers/addresses_controller.php b/controllers/addresses_controller.php
index faf03861..442971b9 100755
--- a/controllers/addresses_controller.php
+++ b/controllers/addresses_controller.php
@@ -2,7 +2,7 @@
class AddressesController extends AppController {
var $name = 'Addresses';
- var $helpers = array('Html', 'Form', 'Ajax');
+ var $helpers = array('Html', 'Form');
var $components = array('RequestHandler');
function index() {
$this->Address->recursive = 0;
@@ -81,5 +81,12 @@ class AddressesController extends AppController {
}
+
+ function customerAddresses($customerID) {
+ $this->layout = 'ajax';
+
+ $this->set('addresses', $this->Address->find('all', array('conditions'=>array('Customer.id'=>$customerID))));
+ }
+
}
?>
diff --git a/views/addresses/customer_addresses.ctp b/views/addresses/customer_addresses.ctp
new file mode 100644
index 00000000..997242ee
--- /dev/null
+++ b/views/addresses/customer_addresses.ctp
@@ -0,0 +1,19 @@
+
+
+
+
+
+ =$address['Address']['address']?>
+ =$address['Address']['city'];?>
+ =$address['State']['name'];?>
+ =$address['Country']['name'];?>
+ Ship to this Address
+
+
\ No newline at end of file
diff --git a/views/shipments/index.ctp b/views/shipments/index.ctp
index 53a17ff3..f7fd97ef 100644
--- a/views/shipments/index.ctp
+++ b/views/shipments/index.ctp
@@ -9,6 +9,7 @@
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?>
+ New Shipment
sort('user_id');?>
@@ -20,8 +21,9 @@
Jobs
sort('# Boxes','box_count');?>
Box Details
- L x W x H (kg)
+ LxWxH (cm)
+ Weight (kg)
sort('freight_forwarder_id');?>
@@ -88,29 +90,38 @@
-
+
- =$box['length']?> x =$box['width']?> x =$box['height']?> (=$box['weight']?> kg)
- $totalWeight += $box['weight']; ?>
-
+ =$box['length']?>x=$box['width']?>x=$box['height']?>
+
+ $weightString .= $box['weight'].' kg ';
+ $totalWeight += $box['weight']; ?>
- =$totalWeight?> kg
+
+ $boxCount = $shipment['Shipment']['box_count'];
+ if($boxCount > 1) {
+ echo $weightString;
+ echo ' ';
+
+ }?>
+ if($boxCount != 0): ?>
+ =$totalWeight;?> kg
+ endif;?>
link($shipment['FreightForwarder']['name'], array('controller' => 'freight_forwarders', 'action' => 'view', $shipment['FreightForwarder']['id'])); ?>
@@ -136,7 +147,7 @@
- New Shipment
+ New Shipment
diff --git a/webroot/css/quotenik.css b/webroot/css/quotenik.css
index 8cfe109c..61e9f058 100755
--- a/webroot/css/quotenik.css
+++ b/webroot/css/quotenik.css
@@ -1440,11 +1440,18 @@ table.shipments tr td {
border: 1px solid;
}
+table.shipments tr td.boxDimensions {
+ text-align: left;
+}
+
+
table.shipments {
border: 1px solid;
}
+
+
.habtmList {
list-style: none;
margin: 0;
@@ -1476,4 +1483,19 @@ table.shipments {
}
.boxForm div {
+}
+
+span.totalWeight {
+
+ font-weight: bolder;
+}
+
+div.address {
+ border: 1px solid;
+ margin-top: 1em;
+ width: 15em;
+}
+
+div.address span {
+ display: block;
}
\ No newline at end of file
diff --git a/webroot/js/shipment_index.js b/webroot/js/shipment_index.js
index 4a63598f..b97ec7c3 100644
--- a/webroot/js/shipment_index.js
+++ b/webroot/js/shipment_index.js
@@ -34,7 +34,7 @@ $(function() {
}
});
- $( "#newShipment" ).button().click(function() {
+ $( ".newShipment" ).button().click(function() {
$( "#dialog-form" ).dialog( "open" );
@@ -50,6 +50,13 @@ $(function() {
});
+ $('#date_dispatched_display').datepicker({
+ showButtonPanel: true,
+ dateFormat: 'd M yy',
+ altFormat: 'yy-mm-dd',
+ altField: '#date_dispatched'
+ });
+
/**
* Display the relevent elements depending on this Shipment Type */
$("#shipmentType").change(function() {
@@ -58,9 +65,12 @@ $(function() {
$(".hiddenDefault").hide();
switch(shipmentTypeID) {
- case 1:
+ case 1: //Import
$("#importFields, #principle, #purchaseOrder, #freight_forwarder, #airway_bill, #boxes").show();
break;
+
+ case 2: //Direct
+ $("#purchaseOrder, #job,#principle, #dateDispatched, #customer, #address, #addressSpan, #freight_forwarder, #airway_bill, #boxes").show();
default:
break;
}
@@ -121,6 +131,20 @@ $(function() {
});
+ $("#customer_autocomplete").autocomplete({
+ source: "/customers/completeCustomer",
+ minLength: 2,
+ select: function( event, ui ) {
+ $("#customer_id").val(ui.item.id);
+
+ $.get('/addresses/customerAddresses/'+ui.item.id, function(data) {
+ $("#address").html(data);
+ $(".selectAddress", data).button();
+ });
+
+ }
+ })
+
$("#addBox").button().click(function() {
addBox(addedBoxes);
@@ -131,6 +155,40 @@ $(function() {
$(this).parent().remove();
});
+
+ $(".selectAddress").live('click', function() {
+ var ID = $(this).attr('id');
+ $("#address_id").val(ID);
+
+
+
+
+ $(this).removeClass('selectAddress');
+ $(this).addClass('changeAddress');
+
+ $(".selectAddress").button('disable');
+ $(".selectAddress").parent('div').fadeOut();
+
+ $(this).button({
+ label: 'Select a different address'
+ });
+ $(this).button('enable');
+
+ });
+
+ $(".changeAddress").live('click', function() {
+ $("#address_id").val('');
+ $(this).removeClass('changeAddress');
+ $(this).button({
+ label: 'Ship to this Address'
+ });
+ $(this).addClass('selectAddress');
+
+ $(".selectAddress").parent('div').fadeIn();
+
+ $('.selectAddress').button('enable');
+ });
+
/**
* Resets the Form to its default site
*/
@@ -203,7 +261,7 @@ $(function() {
}
function capitalizeFirstLetter(string) {
- return string.charAt(0).toUpperCase() + string.slice(1);
+ return string.charAt(0).toUpperCase() + string.slice(1);
}