Customer Industries working ok now - Can fix up GUI later
This commit is contained in:
parent
5b1f72489b
commit
1390e62240
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class Customer extends AppModel {
|
|||
'className' => 'Industry',
|
||||
'joinTable' => 'industries_customers',
|
||||
'foreignKey' => 'customer_id',
|
||||
'associationForeignKey' => 'industry_id'
|
||||
'associationForeignKey' => 'industry_id',
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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 '</div>';
|
||||
?>
|
||||
|
||||
|
||||
|
||||
echo $form->input('Industry.Industry', array('multiple'=>'checkbox', 'showParents'=>false, 'options' => $industries));
|
||||
|
||||
|
||||
?>
|
||||
|
||||
</fieldset>
|
||||
<?php echo $form->end('Submit');?>
|
||||
</div>
|
||||
|
|
@ -26,3 +33,4 @@
|
|||
<li><?php echo $html->link(__('New Enquiry', true), array('controller'=> 'enquiries', 'action'=>'add')); ?> </li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,23 @@
|
|||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="related">
|
||||
<h3><?php __('Industries that this Customer has been tagged in'); ?></h3>
|
||||
<?php if(!empty($customer['Industry'])): ?>
|
||||
<ul id="industrytaglist">
|
||||
<?php foreach ($customer['Industry'] as $industry) {
|
||||
echo "<li>".$html->link(__($industry['name'],true), array('action'=>'view', 'controller'=>'industries', $industry['id']))."</li>";
|
||||
|
||||
}
|
||||
echo "</ul>";
|
||||
endif;
|
||||
|
||||
?>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="related">
|
||||
<h3><?php __('Contacts');?><?php echo $html->image('system-users.png'); ?></h3>
|
||||
<div class="actions">
|
||||
|
|
@ -92,9 +109,6 @@
|
|||
<?php endforeach; ?>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -4,8 +4,8 @@
|
|||
<legend><?php __('Add Industry');?></legend>
|
||||
<?php
|
||||
echo $form->input('name');
|
||||
echo $form->input('parent_id');
|
||||
?>
|
||||
echo $form->input('parent_id', array('empty' => 'None'));
|
||||
?>
|
||||
</fieldset>
|
||||
<?php echo $form->end('Submit');?>
|
||||
</div>
|
||||
|
|
@ -18,3 +18,4 @@
|
|||
<li><?php echo $html->link(__('New Customer', true), array('controller'=> 'customers', 'action'=>'add')); ?> </li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue