diff --git a/controllers/contacts_controller.php b/controllers/contacts_controller.php index eaf90df..5e1ccdc 100644 --- a/controllers/contacts_controller.php +++ b/controllers/contacts_controller.php @@ -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')); } } diff --git a/controllers/units_controller.php b/controllers/units_controller.php index 6e0e931..63fe664 100644 --- a/controllers/units_controller.php +++ b/controllers/units_controller.php @@ -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', */ diff --git a/views/contacts/index.ctp b/views/contacts/index.ctp index 15d92e7..6fb4277 100644 --- a/views/contacts/index.ctp +++ b/views/contacts/index.ctp @@ -1,3 +1,3 @@
-element('contacts') ?> +element('contacts', array('heading' => '

'.$heading.'

')) ?>
diff --git a/views/contacts/view.ctp b/views/contacts/view.ctp index d2823c9..28aac21 100644 --- a/views/contacts/view.ctp +++ b/views/contacts/view.ctp @@ -33,14 +33,14 @@ function datefmt($date) { */ echo('' . "\n"); echo(' ' . "\n"); -echo $html->tableCells(array(array('Name', $tenant['Contact']['display_name']), - array('Company', $tenant['Contact']['company_name']), - array('SSN', $tenant['Contact']['id_federal']), - array('ID', $tenant['Contact']['id_num'] - . ($tenant['Contact']['id_state'] - ? " - ".$tenant['Contact']['id_state'] +echo $html->tableCells(array(array('Name', $contact['Contact']['display_name']), + array('Company', $contact['Contact']['company_name']), + array('SSN', $contact['Contact']['id_federal']), + array('ID', $contact['Contact']['id_num'] + . ($contact['Contact']['id_state'] + ? " - ".$contact['Contact']['id_state'] : "")), - array('Comment', $tenant['Contact']['comment'])), + array('Comment', $contact['Contact']['comment'])), null, array('class' => "altrow"), false, false); echo('
Tenant Info
' . "\n"); @@ -50,7 +50,7 @@ echo('' . "\n"); */ $headers = array('Location', 'Preference', 'Type', 'Phone', 'Extension', 'Comment'); $rows = array(); -foreach($tenant['ContactPhone'] AS $phone) { +foreach($contact['ContactPhone'] AS $phone) { $rows[] = array($phone['ContactsMethod']['type'], $phone['ContactsMethod']['preference'], $phone['type'], @@ -73,7 +73,7 @@ if (count($rows)) { */ $headers = array('Location', 'Preference', 'Email', 'Comment'); $rows = array(); -foreach($tenant['ContactEmail'] AS $email) { +foreach($contact['ContactEmail'] AS $email) { $rows[] = array($email['ContactsMethod']['type'], $email['ContactsMethod']['preference'], $email['email'], @@ -94,7 +94,7 @@ if (count($rows)) { */ $headers = array('Location', 'Preference', 'Address', 'City', 'State', 'Zip', 'Country', 'Comment'); $rows = array(); -foreach($tenant['ContactAddress'] AS $address) { +foreach($contact['ContactAddress'] AS $address) { $rows[] = array($address['ContactsMethod']['type'], $address['ContactsMethod']['preference'], $address['address'], @@ -119,7 +119,7 @@ if (count($rows)) { */ $headers = array('Lease', 'Unit', 'Signed', 'Move-In', 'Move-Out', 'Rent', 'Deposit', 'Comment'); $rows = array(); -foreach($tenant['Lease'] AS $lease) { +foreach($contact['Lease'] AS $lease) { $rows[] = array('#'.$lease['id'], $html->link($lease['Unit']['name'], array('controller' => 'units', @@ -145,7 +145,7 @@ echo('' . "\n"); */ $security_deposit = 0; $grand_total = 0; -foreach($tenant['Lease'] AS $lease) { +foreach($contact['Lease'] AS $lease) { $headers = array('Date', /*'Through',*/ /*'Charge/Receipt'*/'ID', 'Type', 'Comment', 'Amount', 'Total'); $rows = array(); diff --git a/views/units/index.ctp b/views/units/index.ctp index df3021c..d6ae893 100644 --- a/views/units/index.ctp +++ b/views/units/index.ctp @@ -1,3 +1,3 @@
-element('units') ?> +element('units', array('heading' => '

'.$heading.'

')) ?>