This commit is contained in:
Karl Cordes 2009-07-06 11:25:53 +10:00
parent 1456d4ff04
commit 5b1f72489b
6 changed files with 44 additions and 23 deletions

View file

@ -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
View 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.

View file

@ -5,7 +5,6 @@
<?php
echo $form->input('name');
echo $form->input('parent_id');
echo $form->input('Customer');
?>
</fieldset>
<?php echo $form->end('Submit');?>

View file

@ -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']; ?>
&nbsp;
</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'])); ?>
&nbsp;
</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>