From cd61a550e6fc270d329d07ac576940db4857d97c Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Tue, 10 May 2011 17:01:17 +1000 Subject: [PATCH] Addresses working on Shipments register --- controllers/shipments_controller.php | 6 +++++- views/elements/add_edit_shipment.ctp | 14 +++++++++++--- views/shipments/edit.ctp | 2 +- webroot/js/add_edit_shipment.js | 15 ++++++--------- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/controllers/shipments_controller.php b/controllers/shipments_controller.php index f25c2230..696043ce 100644 --- a/controllers/shipments_controller.php +++ b/controllers/shipments_controller.php @@ -98,6 +98,10 @@ class ShipmentsController extends AppController { if(isset($id)) { if (empty($this->data)) { $this->data = $this->Shipment->read(null, $id); + + $address = $this->Shipment->Address->find('first', array('conditions'=>array('Address.id'=>$this->data['Shipment']['address_id']),'recursive'=>0)); + + $principles = $this->Shipment->Principle->find('list'); $freightForwarders = $this->Shipment->FreightForwarder->find('list'); $shipmentType = $this->typeOptions(false); @@ -107,7 +111,7 @@ class ShipmentsController extends AppController { $invoiceType = $this->invoiceTypeOptions(); $this->set('yesNo', array(0=>'No', 1=>'Yes')); - $this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort', 'currencies','invoiceType', 'yesNo')); + $this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort', 'currencies','invoiceType', 'yesNo', 'address')); diff --git a/views/elements/add_edit_shipment.ctp b/views/elements/add_edit_shipment.ctp index 261f1953..8c08a7b9 100644 --- a/views/elements/add_edit_shipment.ctp +++ b/views/elements/add_edit_shipment.ctp @@ -80,11 +80,19 @@ echo $form->input('id', array('type'=>'hidden')); Shipping Address:
- input('address_id', array('type'=>'hidden', 'id'=>'address_id', 'value'=>$this->data['Shipment']['address_id']));?> - + +
+ + + + + +
+
- +input('address_id', array('type'=>'hidden', 'id'=>'address_id', 'value'=>$this->data['Shipment']['address_id']));?>
input('freight_forwarder_id');?> diff --git a/views/shipments/edit.ctp b/views/shipments/edit.ctp index 7c72a94d..6224363f 100644 --- a/views/shipments/edit.ctp +++ b/views/shipments/edit.ctp @@ -2,4 +2,4 @@ element('add_edit_shipment');?> -data); ?> \ No newline at end of file + \ No newline at end of file diff --git a/webroot/js/add_edit_shipment.js b/webroot/js/add_edit_shipment.js index 3fcce710..41eddcf2 100644 --- a/webroot/js/add_edit_shipment.js +++ b/webroot/js/add_edit_shipment.js @@ -165,7 +165,7 @@ $(function() { $(".selectAddress").parent('div').fadeOut(); $(this).button({ - label: 'Select a different address' + label: 'Select a different Address' }); $(this).button('enable'); @@ -173,15 +173,12 @@ $(function() { $(".changeAddress").live('click', function() { $("#address_id").val(''); - $(this).removeClass('changeAddress'); - $(this).button({ - label: 'Ship to this Address' + + $.get('/addresses/customerAddresses/'+$("#customer_id").val(), function(data) { + $("#address").html(data); + $(".selectAddress", data).button(); }); - $(this).addClass('selectAddress'); - - $(".selectAddress").parent('div').fadeIn(); - - $('.selectAddress').button('enable'); + });