diff --git a/controllers/customers_controller.php b/controllers/customers_controller.php index 71e60c33..1d0278d5 100755 --- a/controllers/customers_controller.php +++ b/controllers/customers_controller.php @@ -169,17 +169,30 @@ class CustomersController extends AppController { $this->layout = 'ajax'; } - function find() { - if(!empty($this->data)) { - $customer = $this->Customer->findByName($this->data['Customer']['name']); - if(!$customer) { - $this->Session->setFlash(__('Could not find the Requested Customer. Please select one from the drop down box as you type.', true)); - } - else { - $this->redirect(array('action'=>'view/'.$customer['Customer']['id'])); - } + + function customerContacts($id = null) { + $this->layout = 'ajax'; + + if(!$id) { + return; } - } + else { + $contacts = $this->Customer->Contact->find('all', array('conditions'=>array('Contact.customer_id'=>$id))); + + $contactList = array(); + + foreach($contacts as $contact) { + $contactList[$contact['Contact']['id']] = $contact['Contact']['first_name'].' '.$contact['Contact']['last_name']; + } + + $this->set('contacts',$contactList); + } + + + } + + + function tagindustries($id = null) { if (!$id && empty($this->data)) { @@ -208,6 +221,10 @@ class CustomersController extends AppController { $this->set('customers', $this->Customer->find('all', array('recursive'=>0))); $this->layout = 'csv'; } + + + + diff --git a/controllers/enquiries_controller.php b/controllers/enquiries_controller.php index 37bc219d..f9039cba 100755 --- a/controllers/enquiries_controller.php +++ b/controllers/enquiries_controller.php @@ -77,44 +77,18 @@ class EnquiriesController extends AppController { } - function add_enquiry() { - - Configure::write('debug', 0); - $this->layout = 'ajax'; - if (!empty($this->data)) { - $this->Enquiry->create(); - $this->Enquiry->set($this->data['Enquiry']); - if($this->User->validates()) { - if ($this->User->save($this->data)) { - $message = __('The User has been saved.', true); - $data = $this->data; - $this->set('success', compact('message', 'data')); - } - } - else { - $message = __('The User could not be saved. Please, try again.', true); - $User = $this->User->invalidFields(); - $data = compact('User'); - $this->set('errors', compact('message', 'data')); - } - - - } - else { - $this->redirect('/'); - } - - - + function add() { + $this->set('users',$this->Enquiry->User->find('list', array('conditions'=>array('User.type'=>'user', 'User.enabled'=>true)))); } - + /* function add() { if(empty($this->data)) { if(isset($this->params['named']['customerid'])) { - $customer = $this->Enquiry->Customer->findById($this->params['named']['customerid']); + $customer = $this->Enquiry->Cu + * stomer->findById($this->params['named']['customerid']); } else { $this->Session->setFlash(__('The customer must already exist in the database. Please add Enquiries to an existing Customer', true)); @@ -122,9 +96,9 @@ class EnquiriesController extends AppController { } } - if(isset($customer)) { + if(isset($customer)) {*/ /* Check if the customer exists in the database - otherwise send the user back to step 1*/ - if(!$customer) { + /*if(!$customer) { $this->Session->setFlash(__('The customer must already exist in the database. Please try again', true)); $this->redirect(array('action'=>'add')); } @@ -176,15 +150,15 @@ class EnquiriesController extends AppController { } } - } + }*/ /* Internal function to display page 2 of the Add Enquiry Form Wizard * to help make the flow-control logic of the add function clearer. * */ - function __showPage2($customer) { + /* function __showPage2($customer) { */ /* Combine the first_name and last_name for the Contact Drop Down Box */ - $contacts = $this->Enquiry->Contact->find('all', array('conditions' => array('Contact.customer_id' => $customer['Customer']['id']))); +/* $contacts = $this->Enquiry->Contact->find('all', array('conditions' => array('Contact.customer_id' => $customer['Customer']['id']))); $contacts = Set::Combine($contacts, '{n}.Contact.id', array('{0} {1}', '{n}.Contact.first_name', '{n}.Contact.last_name')); $states = $this->Enquiry->State->find('list'); $countries = $this->Enquiry->Country->find('list', array('order'=> 'Country.name asc')); @@ -195,9 +169,9 @@ class EnquiriesController extends AppController { $customerAddresses = $this->Enquiry->BillingAddress->find('all', array('conditions'=>array('BillingAddress.customer_id' => $customer['Customer']['id']))); $this->set('billing_addresses', $customerAddresses); $this->set('shipping_addresses', $customerAddresses); - $this->set('errors', $this->Enquiry->invalidFields()); + $this->set('errors', $this->Enquiry->invalidFields()); */ /* Feels like an ugly hack. But it gets the desired effect and it will do for now */ - +/* if(isset($customerAddresses[0]['BillingAddress'])) { $billing_address_list[0] = "No Address Selected"; foreach ($customerAddresses as $address) { @@ -211,7 +185,7 @@ class EnquiriesController extends AppController { $this->set('billing_addresses_list', 'No Addresses exist for this Customer. Please add one'); $this->set('shipping_addresses_list', 'No Addresses exist for this Customer. Please add one'); } - } + }*/ diff --git a/controllers/users_controller.php b/controllers/users_controller.php index c2ee6324..a22cbd0b 100755 --- a/controllers/users_controller.php +++ b/controllers/users_controller.php @@ -244,7 +244,5 @@ class UsersController extends AppController { - - } ?> diff --git a/views/customers/add.ctp b/views/customers/add.ctp index 75c92c23..2597a7ab 100755 --- a/views/customers/add.ctp +++ b/views/customers/add.ctp @@ -1,4 +1,4 @@ -link('autocomplete-customer'); ?> +link('similar-customer.js'); ?>