From d6c6dbc866022e219927ae21278613c5e2bb409c Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Tue, 30 Mar 2010 10:36:29 +1100 Subject: [PATCH] Changed find customer to jquery dialog box instead of autocomplete --- controllers/principles_controller.php | 1 + views/customers/find.ctp | 9 ++++++-- views/principles/view.ctp | 32 +++++---------------------- webroot/js/autocomplete-customer.js | 2 +- webroot/js/findcustomer.js | 27 +++++++++++++++------- 5 files changed, 34 insertions(+), 37 deletions(-) diff --git a/controllers/principles_controller.php b/controllers/principles_controller.php index 5731e141..5aca7c28 100755 --- a/controllers/principles_controller.php +++ b/controllers/principles_controller.php @@ -30,6 +30,7 @@ class PrinciplesController extends AppController { $status_list[] = array($status['Status']['id'], $status['Status']['name']); } $this->set('status_list', $status_list); + $this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.principle_id' => $id))); } diff --git a/views/customers/find.ctp b/views/customers/find.ctp index c5829cfc..e43cb9bb 100755 --- a/views/customers/find.ctp +++ b/views/customers/find.ctp @@ -9,12 +9,17 @@ echo $form->input('Customer.name', array('Label'=>'Customer Name', 'id'=>'customerName', 'div'=>'ui-widget')); - echo $form->input('Customer.id', array('type'=>'hidden')); + //echo $form->input('Customer.id', array('type'=>'hidden')); - echo $form->end('Find'); + //echo $form->end('Find'); ?> +
+ +
\ No newline at end of file diff --git a/views/principles/view.ctp b/views/principles/view.ctp index 908aff1b..7378cdc9 100755 --- a/views/principles/view.ctp +++ b/views/principles/view.ctp @@ -85,20 +85,10 @@ - - + - - - - - - - - - - - + + > - - + - - - - - - - - - - - + +
link(__('View', true), array('controller'=> 'products', 'action'=>'view', $product['id'])); ?> link(__('Edit', true), array('controller'=> 'products', 'action'=>'edit', $product['id'])); ?> diff --git a/webroot/js/autocomplete-customer.js b/webroot/js/autocomplete-customer.js index 1e4fa6c5..6468c36f 100644 --- a/webroot/js/autocomplete-customer.js +++ b/webroot/js/autocomplete-customer.js @@ -3,7 +3,7 @@ * * used in customers/add.ctp * - * Not really an autocomplete, updates a dialog box with similar customer names to try and stop duplicate entries. + * Not an autocomplete anymore, updates a dialog box with similar customer names to try and stop duplicate entries. */ diff --git a/webroot/js/findcustomer.js b/webroot/js/findcustomer.js index 71d072b0..473d48fb 100644 --- a/webroot/js/findcustomer.js +++ b/webroot/js/findcustomer.js @@ -2,22 +2,33 @@ * filename: findcustomer.js * * used in: customers/find.ctp - * @todo: This doesn't update the ID for some reason. + * */ $(function() { + $("#dialog").hide(); - $("#customerName").autocomplete({ - source: "/customers/completeCustomer", - minLength: 3, - select: function(event, ui) { - $("#CustomerId").val(ui.item.id); - } + /*If the user has entered 3 or more characters. Check to see if its similar to existing customers. */ + $("#customerName").change(function () { - }); + if($("#customerName").val().length >= 3) { + $.post("/customers/similarCustomers", $("#customerName").serialize(), function(data) { + $("#similarCustList").html(data); + }); + + + $("#dialog").dialog({ + position: 'center', + width: 400 + }); + + } + + + })