git-svn-id: file:///svn-source/pmgr/branches/initial_20090526/site@41 97e9348a-65ac-dc4b-aefc-98561f571b83
143 lines
5.3 KiB
PHP
143 lines
5.3 KiB
PHP
<?php
|
|
|
|
class UnitsController extends AppController {
|
|
var $helpers = array('Html');
|
|
|
|
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 = 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));
|
|
$this->redirect(array('action'=>''));
|
|
}
|
|
$this->Unit->recursive = 4;
|
|
$this->Unit->UnitSize->unbindModel(array('hasMany' => array('Unit')));
|
|
$this->Unit->UnitSize->UnitType->unbindModel(array('hasMany' => array('UnitSize')));
|
|
$this->Unit->Lease->unbindModel(array('belongsTo' => array('Unit')));
|
|
$this->Unit->Lease->LeaseType->unbindModel(array('hasMany' => array('Lease')));
|
|
$this->Unit->Lease->Charge->unbindModel(array('belongsTo' => array('Lease')));
|
|
$this->Unit->Lease->Charge->ChargeType->unbindModel(array('hasMany' => array('Charge')));
|
|
$this->Unit->Lease->Charge->Receipt->unbindModel(array('hasMany' => array('ChargesReceipt')));
|
|
|
|
$unit = $this->Unit->read(null, $id);
|
|
$title = 'Unit ' . $unit['Unit']['name'];
|
|
$this->set(compact('unit', 'title'));
|
|
|
|
/* $this->Unit->id = $id; */
|
|
/* if ($id !== null && $id !== false) { */
|
|
/* $this->Unit->data = $this->Unit->find('first', */
|
|
/* array('conditions' => array( */
|
|
/* $this->Unit->alias . '.' . $this->Unit->primaryKey => $id, */
|
|
/* 'ContactsLease.type = "TENANT"' */
|
|
/* ) */
|
|
/* )); */
|
|
/* $this->set('unit', $this->Unit->data); */
|
|
/* } */
|
|
}
|
|
}
|
|
|
|
?>
|