Added comment blocks and context specific side menu link items. Also tweaked the Page titles and headings for the table listings.

git-svn-id: file:///svn-source/pmgr/branches/initial_20090526/site@41 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-05-29 16:01:47 +00:00
parent 1145d293b2
commit 59398cb3f0
5 changed files with 198 additions and 71 deletions

View File

@@ -6,38 +6,109 @@ class UnitsController extends AppController {
var $paginate = array('limit' => 100,
'order' => array('Unit.sort_order' => 'ASC'));
/**************************************************************************
**************************************************************************
**************************************************************************
* override: sideMenuLinks
* - Generates controller specific links for the side menu
*/
function sideMenuLinks() {
$menu = parent::sideMenuLinks();
//$menu[] = array('hr' => true);
$menu[] = array('name' => 'Units', 'header' => true);
$menu[] = array('name' => 'Occupied', 'url' => array('controller' => 'units', 'action' => 'occupied'));
$menu[] = array('name' => 'Vacant', 'url' => array('controller' => 'units', 'action' => 'vacant'));
$menu[] = array('name' => 'Unavailable', 'url' => array('controller' => 'units', 'action' => 'unavailable'));
$menu[] = array('name' => 'All', 'url' => array('controller' => 'units', 'action' => 'all'));
return $menu;
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: index
* - Lists all units
*/
function index() {
$this->all();
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: unavailable
* - Lists unavailable units
*/
function unavailable() {
$this->Unit->recursive = 0;
$title = 'Unavailable Units';
$this->set('title', $title); $this->set('heading', $title);
$this->set('units', $this->paginate(array($this->Unit->conditionUnavailable())));
$this->render('index');
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: vacant
* - Lists vacant units
*/
function vacant() {
$this->Unit->recursive = 0;
$title = 'Vacant Units';
$this->set('title', $title); $this->set('heading', $title);
$this->set('units', $this->paginate(array($this->Unit->conditionVacant())));
$this->render('index');
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: occupied
* - Lists occupied units
*/
function occupied() {
$this->Unit->recursive = 0;
$title = 'Occupied Units';
$this->set('title', $title); $this->set('heading', $title);
$this->set('units', $this->paginate(array($this->Unit->conditionOccupied())));
$this->render('index');
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: all
* - Lists all units
*/
function all() {
$this->Unit->recursive = 2;
/* $this->Unit->UnitSize->unbindModel(array('hasMany' => array('Unit'))); */
/* $this->Unit->UnitSize->UnitType->unbindModel(array('hasMany' => array('UnitSize'))); */
//$this->Unit->bindModel(array('hasOne' => array('UnitType')));
//function paginate($conditions, $fields, $order, $limit, $page = 1, $recursive = null) {
$this->set('units', $this->paginate(null, null, null, null, null, 2));
$this->Unit->recursive = 0;
$title = 'All Units';
$this->set('title', $title); $this->set('heading', $title);
$this->set('units', $this->paginate());
$this->render('index');
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: view
* - Displays information about a specific unit
*/
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid Item.', true));
@@ -52,51 +123,10 @@ class UnitsController extends AppController {
$this->Unit->Lease->Charge->ChargeType->unbindModel(array('hasMany' => array('Charge')));
$this->Unit->Lease->Charge->Receipt->unbindModel(array('hasMany' => array('ChargesReceipt')));
/* //$this->Unit->Lease->unbindModel(array('hasMany' => array('Contact'))); */
/* $this->Unit->Lease->unbindModel(array('hasAndBelongsToMany' => array('Contact'))); */
/* //$this->Unit->Lease->unbindModel(array('hasOne' => array('Contact'))); */
/* //$this->Unit->Lease->unbindModel(array('belongsTo' => array('Contact'))); */
/* //$this->Unit->Lease->bindModel(array('hasOne' => array('ContactsLease'))); */
/* //$this->Unit->Lease->bindModel(array('hasOne' => array('Contact'))); */
/* /\* $this->Unit->Lease->bindModel(array('hasOne' => array('ContactsLease', *\/ */
/* /\* 'Contact' => array( *\/ */
/* /\* 'foreignKey' => false, *\/ */
/* /\* 'conditions' => *\/ */
/* /\* array('Contact.id = ContactsLease.contact_id', *\/ */
/* /\* //'ContactsLease.type = "TENANT"' *\/ */
/* /\* ))))); *\/ */
$unit = $this->Unit->read(null, $id);
$title = 'Unit ' . $unit['Unit']['name'];
$this->set(compact('unit', 'title'));
/* $this->Unit->bindModel(array('hasOne' => array('Lease' => array( */
/* 'foreignKey' => false, */
/* 'conditions' => array('Lease.unit_id = Unit.id') */
/* ), */
/* 'ContactsLease' => array( */
/* 'foreignKey' => false, */
/* 'conditions' => array('ContactsLease.lease_id = Lease.id') */
/* ), */
/* 'Contact' => array( */
/* 'foreignKey' => false, */
/* 'conditions' => array('Contact.id = ContactsLease.contact_id') */
/* ))), */
/* false); */
/* $this->Unit->Lease->bindModel(array('hasOne' => array('Contact' => array( */
/* 'className' => 'ContactsLease', */
/* 'foreignKey' => false, */
/* 'conditions' => */
/* array('ContactsLease.lease_id = Lease.id', */
/* 'ContactsLease.type = "TENANT"'))))); */
/* # 'hasOne' => array( */
/* # 'RecipesTag', */
/* # 'FilterTag' => array( */
/* # 'className' => 'Tag', */
/* # 'foreignKey' => false, */
/* # 'conditions' => array('FilterTag.id = RecipesTag.tag_id') */
/* # )))); */
$this->set('unit', $this->Unit->read(null, $id));
/* $this->Unit->id = $id; */
/* if ($id !== null && $id !== false) { */
/* $this->Unit->data = $this->Unit->find('first', */