diff --git a/controllers/customers_controller.php b/controllers/customers_controller.php index e136dfbd..ec8b1add 100755 --- a/controllers/customers_controller.php +++ b/controllers/customers_controller.php @@ -39,6 +39,7 @@ class CustomersController extends AppController { $status_list[] = array($status['Status']['id'], $status['Status']['name']); } $this->set('status_list', $status_list); + $this->set('parent_industry_list', $this->Customer->Industry->find('list', array('conditions' => array('parent_id' => null)))); } function add() { diff --git a/controllers/enquiries_controller.php b/controllers/enquiries_controller.php index fb8237a1..5d828e11 100755 --- a/controllers/enquiries_controller.php +++ b/controllers/enquiries_controller.php @@ -46,6 +46,7 @@ class EnquiriesController extends AppController { if($enquiry['Enquiry']['shipping_address_id'] != 0) { $this->set('shippingaddress', $this->Enquiry->ShippingAddress->findById($enquiry['Enquiry']['shipping_address_id'])); } + } diff --git a/controllers/industries_controller.php b/controllers/industries_controller.php index 86cf321f..c03319ff 100644 --- a/controllers/industries_controller.php +++ b/controllers/industries_controller.php @@ -32,21 +32,36 @@ class IndustriesController extends AppController { $this->redirect(array('action'=>'index')); } $this->set('industry', $this->Industry->read(null, $id)); + $subCustomers = $this->Industry->findAllByParentId($id); + $this->set('sub_customers', $subCustomers); + + $catCust = ""; + foreach ($subCustomers as $indust) { + foreach ($indust['Customer'] as $subcust) { + $myid = $subcust['id']; + $catCust[$myid] = $subcust; + } + + } + $this->set('category_customers', $catCust); + + } function add() { if (!empty($this->data)) { if ($this->Industry->save($this->data)) { - + $newid = $this->Industry->id; $new_industry = $this->Industry->findById($newid); if($new_industry['Industry']['parent_id'] == 0) { - + + $newsub = $this->data['Industry']['sub_category']; $this->Industry->create(); $this->data['Industry']['parent_id'] = $newid; - $this->data['Industry']['name'] = $new_industry['Industry']['name']." - General"; + $this->data['Industry']['name'] = $newsub; $this->Industry->save($this->data); } $this->Session->setFlash(__('The Industry has been saved', true)); diff --git a/models/industry.php b/models/industry.php index 8a9a44de..0838e991 100644 --- a/models/industry.php +++ b/models/industry.php @@ -8,9 +8,10 @@ class Industry extends AppModel { var $hasAndBelongsToMany = array ( 'Customer' => array( 'className' => 'Customer', - 'joinTable' => 'industries_customers', - 'unique' => false - ) + 'joinTable' => 'industries_customers' + // 'foreignKey' => 'industry_id', + // 'associationForeignKey' => 'customer_id' + ) ); @@ -30,6 +31,9 @@ class Industry extends AppModel { ) ); + + + } ?> diff --git a/views/contacts/add.ctp b/views/contacts/add.ctp index 1994dc5b..4c5e8161 100755 --- a/views/contacts/add.ctp +++ b/views/contacts/add.ctp @@ -13,6 +13,7 @@ echo $form->input('mobile'); echo $form->input('fax'); echo $form->input('contact_category_id'); + echo $form->input('job_title'); echo $form->input('notes'); ?> diff --git a/views/contacts/add_one.ctp b/views/contacts/add_one.ctp index 0a295a35..e1b368a7 100644 --- a/views/contacts/add_one.ctp +++ b/views/contacts/add_one.ctp @@ -15,6 +15,7 @@ echo $form->input("Contact.mobile"); echo $form->input("Contact.fax"); echo $form->input("Contact.contact_category_id", array('options' => $contact_categories, 'label' => 'Contact Department')); + echo $form->input("Contact.job_title"); echo $form->input("Contact.notes"); echo $form->input("Contact.customer_id", array('type'=>'hidden', 'value' => $customerid)); ?> diff --git a/views/contacts/add_to_customer.ctp b/views/contacts/add_to_customer.ctp index 65ed1635..79716bdc 100755 --- a/views/contacts/add_to_customer.ctp +++ b/views/contacts/add_to_customer.ctp @@ -13,8 +13,10 @@ echo $form->input('mobile'); echo $form->input('fax'); echo $form->input('contact_category_id', array('label'=>'Contact Department', 'empty' => 'Please Choose a Department')); + echo $form->input('job_title'); echo $form->input('notes'); - ?> + +?> end('Submit');?> diff --git a/views/contacts/edit.ctp b/views/contacts/edit.ctp index e70a29f1..ce396ca2 100755 --- a/views/contacts/edit.ctp +++ b/views/contacts/edit.ctp @@ -14,6 +14,7 @@ echo $form->input('mobile'); echo $form->input('fax'); echo $form->input('contact_category_id', array('label' => 'Department', 'empty' => 'Please Choose a Department')); + echo $form->input('job_title'); echo $form->input('notes'); ?> diff --git a/views/contacts/view.ctp b/views/contacts/view.ctp index 5de16f18..eb2e187a 100755 --- a/views/contacts/view.ctp +++ b/views/contacts/view.ctp @@ -42,11 +42,19 @@ +