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@41 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-05-29 16:01:47 +00:00
parent 79bcf99fc5
commit 2a4b8079fb
5 changed files with 198 additions and 71 deletions

View File

@@ -7,10 +7,64 @@ class ContactsController extends AppController {
'order' => array('Contact.last_name' => 'ASC',
'Contact.first_name' => 'ASC'));
function index() {
$this->all();
/**************************************************************************
**************************************************************************
**************************************************************************
* override: sideMenuLinks
* - Generates controller specific links for the side menu
*/
function sideMenuLinks() {
$menu = parent::sideMenuLinks();
//$menu[] = array('hr' => true);
$menu[] = array('name' => 'Tenants', 'header' => true);
$menu[] = array('name' => 'Current', 'url' => array('controller' => 'contacts', 'action' => 'current'));
$menu[] = array('name' => 'Past', 'url' => array('controller' => 'contacts', 'action' => 'past'));
$menu[] = array('name' => 'All Tenants', 'url' => array('controller' => 'contacts', 'action' => 'tenants'));
$menu[] = array('name' => 'All Contacts', 'url' => array('controller' => 'contacts', 'action' => 'all'));
return $menu;
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: index
* - Lists all current tenants
*/
function index() {
$this->current();
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: past
* - Lists all tenants, past and present
*/
function tenants() {
$this->Contact->recursive = 0;
$this->Contact->bindModel(array('hasOne' => array('ContactsLease')),
false);
$title = 'All Tenants';
$this->set('title', $title); $this->set('heading', $title);
$this->set('contacts', $this->paginate(array('ContactsLease.type != "ALTERNATE"')));
$this->render('index');
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: current
* - Lists all current tenants
*/
function current() {
$this->Contact->recursive = 0;
$this->Contact->bindModel(array('hasOne' => array('ContactsLease',
@@ -19,21 +73,62 @@ class ContactsController extends AppController {
'conditions' => array('Lease.id = ContactsLease.lease_id')
))),
false);
$title = 'Current Tenants';
$this->set('title', $title); $this->set('heading', $title);
$this->set('contacts', $this->paginate(array('Lease.close_date IS NULL',
'ContactsLease.type != "ALTERNATE"')));
$this->render('index');
}
function all() {
/**************************************************************************
**************************************************************************
**************************************************************************
* action: past
* - Lists all past tenants
*/
function past() {
$this->Contact->recursive = 0;
$this->Contact->bindModel(array('hasOne' => array('ContactsLease')),
$this->Contact->bindModel(array('hasOne' => array('ContactsLease',
'Lease' => array(
'foreignKey' => false,
'conditions' => array('Lease.id = ContactsLease.lease_id')
))),
false);
$this->set('contacts', $this->paginate(array('ContactsLease.type != "ALTERNATE"')));
$title = 'Past Tenants';
$this->set('title', $title); $this->set('heading', $title);
$this->set('contacts', $this->paginate(array('Lease.close_date IS NOT NULL',
'ContactsLease.type != "ALTERNATE"')));
$this->render('index');
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: all
* - Lists all contacts, including non-tenants
*/
function all() {
$this->Contact->recursive = 0;
$title = 'All Contacts';
$this->set('title', $title); $this->set('heading', $title);
$this->set('contacts', $this->paginate());
$this->render('index');
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: view
* - Displays information about a specific contact
*/
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid Item.', true));
@@ -45,7 +140,9 @@ class ContactsController extends AppController {
$this->Contact->Lease->Charge->ChargeType->unbindModel(array('hasMany' => array('Charge')));
$this->Contact->Lease->Charge->Receipt->unbindModel(array('hasMany' => array('ChargesReceipt')));
$this->set('tenant', $this->Contact->read(null, $id));
$contact = $this->Contact->read(null, $id);
$title = $contact['Contact']['display_name'];
$this->set(compact('contact', 'title'));
}
}

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', */