Rah
This commit is contained in:
parent
1456d4ff04
commit
5b1f72489b
|
|
@ -27,10 +27,9 @@ class IndustriesController extends AppController {
|
|||
$this->Session->setFlash(__('The Industry could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$customers = $this->Industry->Customer->find('list');
|
||||
$parents = $this->Industry->find('list', array('conditions' => array(
|
||||
'Industry.parent_id' => null)));
|
||||
$this->set(compact('customers', 'parents'));
|
||||
$this->set(compact('parents'));
|
||||
}
|
||||
|
||||
function edit($id = null) {
|
||||
|
|
|
|||
36
models/industry.php
Normal file
36
models/industry.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?
|
||||
|
||||
class Industry extends AppModel {
|
||||
|
||||
var $name = 'Industry';
|
||||
|
||||
|
||||
var $hasAndBelongsToMany = array (
|
||||
'Customer' => array(
|
||||
'className' => 'Customer',
|
||||
'joinTable' => 'industries_customers'
|
||||
// 'foreignKey' => 'industry_id',
|
||||
// 'associationForeignKey' => 'customer_id'
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
var $belongsTo = array (
|
||||
'ParentIndustry' => array(
|
||||
'className' => 'Industries',
|
||||
'foreignKey' => 'parent_id'
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
var $hasMany = array (
|
||||
'subIndustry' => array(
|
||||
'className' => 'Industries',
|
||||
'foreignKey' => 'parent_id',
|
||||
'dependent' => true
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -5,7 +5,6 @@
|
|||
<?php
|
||||
echo $form->input('name');
|
||||
echo $form->input('parent_id');
|
||||
echo $form->input('Customer');
|
||||
?>
|
||||
</fieldset>
|
||||
<?php echo $form->end('Submit');?>
|
||||
|
|
|
|||
|
|
@ -11,19 +11,8 @@
|
|||
}
|
||||
|
||||
?></h2>
|
||||
<dl><?php $i = 0; $class = ' class="altrow"';?>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Name'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $industry['Industry']['name']; ?>
|
||||
|
||||
</dd>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Parent Industry'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $html->link($industry['ParentIndustry']['name'], array('controller'=> 'industries', 'action'=>'view', $industry['ParentIndustry']['id'])); ?>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<li><?php echo $html->link(__('Edit Industry', true), array('action'=>'edit', $industry['Industry']['id'])); ?> </li>
|
||||
|
|
@ -34,9 +23,9 @@
|
|||
</div>
|
||||
|
||||
|
||||
<?php if (!empty($industry['subIndustry'])):?>
|
||||
<div class="related">
|
||||
<h3><?php __('Sub-Industries');?></h3>
|
||||
<?php if (!empty($industry['subIndustry'])):?>
|
||||
<table cellpadding = "0" cellspacing = "0">
|
||||
<tr>
|
||||
<th><?php __('Name'); ?></th>
|
||||
|
|
@ -60,13 +49,16 @@
|
|||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<li><?php echo $html->link(__('New Sub Industry', true), array('controller'=> 'industries', 'action'=>'add'));?> </li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
|
@ -112,9 +104,4 @@
|
|||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<li><?php echo $html->link(__('New Customer', true), array('controller'=> 'customers', 'action'=>'add'));?> </li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue