diff --git a/controllers/customers_controller.php b/controllers/customers_controller.php index 99b4b671..491dc102 100755 --- a/controllers/customers_controller.php +++ b/controllers/customers_controller.php @@ -64,7 +64,7 @@ class CustomersController extends AppController { $this->redirect(array('action'=>'index')); } if (!empty($this->data)) { - if ($this->Customer->save($this->data)) { + if ($this->Customer->saveAll($this->data)) { $this->Session->setFlash(__('The Customer has been saved', true)); $id = $this->Customer->id; $this->redirect(array('action'=>'view/'.$id)); @@ -75,7 +75,10 @@ class CustomersController extends AppController { if (empty($this->data)) { $this->data = $this->Customer->read(null, $id); $this->set('customer_categories', $this->Customer->CustomerCategory->find('list')); + $this->set('industries', $this->Customer->Industry->find('list', array('fields'=>array('Industry.id', 'Industry.name', 'ParentIndustry.name'),'recursive' => 0, + 'order'=>'ParentIndustry.name ASC, Industry.name ASC'))); } + } /* Autocomplete the customer name - Used in: add.ctp */ diff --git a/controllers/industries_controller.php b/controllers/industries_controller.php index 98b8430b..b94df0a5 100644 --- a/controllers/industries_controller.php +++ b/controllers/industries_controller.php @@ -4,6 +4,11 @@ class IndustriesController extends AppController { var $name = 'Industries'; var $helpers = array('Html', 'Form'); + var $paginate = array( + 'Industry' => array('order' => array('ParentIndustry.name' => 'asc', 'Industry.name' => 'asc'), + 'limit' => 200 + )); + function index() { $this->Industry->recursive = 0; $this->set('industries', $this->paginate()); @@ -27,6 +32,8 @@ class IndustriesController extends AppController { $this->Session->setFlash(__('The Industry could not be saved. Please, try again.', true)); } } + + /* Parent Industries have NULL for their parent_id */ $parents = $this->Industry->find('list', array('conditions' => array( 'Industry.parent_id' => null))); $this->set(compact('parents')); diff --git a/models/customer.php b/models/customer.php index b19d62f8..c8e6bbee 100755 --- a/models/customer.php +++ b/models/customer.php @@ -76,7 +76,7 @@ class Customer extends AppModel { 'className' => 'Industry', 'joinTable' => 'industries_customers', 'foreignKey' => 'customer_id', - 'associationForeignKey' => 'industry_id' + 'associationForeignKey' => 'industry_id', ) ); diff --git a/models/industry.php b/models/industry.php index fed8c8ab..8a9a44de 100644 --- a/models/industry.php +++ b/models/industry.php @@ -8,10 +8,9 @@ class Industry extends AppModel { var $hasAndBelongsToMany = array ( 'Customer' => array( 'className' => 'Customer', - 'joinTable' => 'industries_customers' - // 'foreignKey' => 'industry_id', - // 'associationForeignKey' => 'customer_id' - ) + 'joinTable' => 'industries_customers', + 'unique' => false + ) ); diff --git a/views/customers/edit.ctp b/views/customers/edit.ctp index 4672c53a..e528efde 100755 --- a/views/customers/edit.ctp +++ b/views/customers/edit.ctp @@ -13,7 +13,14 @@ echo $form->label('Customer.customer_category_id', 'Customer Category'); echo $form->select('customer_category_id', $customer_categories, $this->data['Customer']['customer_category_id'], array('label'=>'Customer Category'), false); echo ''; - ?> + + + + echo $form->input('Industry.Industry', array('multiple'=>'checkbox', 'showParents'=>false, 'options' => $industries)); + + +?> + end('Submit');?> @@ -26,3 +33,4 @@
  • link(__('New Enquiry', true), array('controller'=> 'enquiries', 'action'=>'add')); ?>
  • + diff --git a/views/customers/view.ctp b/views/customers/view.ctp index bb7e3061..526e2ae9 100755 --- a/views/customers/view.ctp +++ b/views/customers/view.ctp @@ -46,6 +46,23 @@ + + + @@ -18,3 +18,4 @@
  • link(__('New Customer', true), array('controller'=> 'customers', 'action'=>'add')); ?>
  • + diff --git a/webroot/css/quotenik.css b/webroot/css/quotenik.css index 42209d06..ec21fe0b 100755 --- a/webroot/css/quotenik.css +++ b/webroot/css/quotenik.css @@ -106,6 +106,12 @@ ul.principle-emails { } +#industrytaglist li { + display: inline; + list-style-type: none; + font-size: 120%; +} + /* Layout */ #container { text-align: left; @@ -667,6 +673,9 @@ input[type=checkbox] { margin: 0px 6px 7px 2px; width: auto; } + + + input[type=radio] { clear: left; float: left;