Changed how sidemenu links work, so that order of execution doesn't have to control ordering of the list.

git-svn-id: file:///svn-source/pmgr/branches/pre_0.1_work_20090819@734 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-08-22 22:47:41 +00:00
parent 513182a6d5
commit f545502162
13 changed files with 416 additions and 321 deletions

View File

@@ -38,53 +38,158 @@ class AppController extends Controller {
var $helpers = array('Html', 'Form', 'Javascript', 'Format', 'Time', 'Grid'); var $helpers = array('Html', 'Form', 'Javascript', 'Format', 'Time', 'Grid');
var $components = array('DebugKit.Toolbar'); var $components = array('DebugKit.Toolbar');
var $sidemenu_areas = array('SITE' => false, 'CONTROLLER' => false, 'ACTION' => false);
var $admin_area = 2;
var $dev_area = 3;
function __construct() { function __construct() {
$this->params['dev'] = false; $this->params['dev'] = false;
$this->params['admin'] = false; $this->params['admin'] = false;
parent::__construct(); parent::__construct();
} }
function sideMenuLinks() { /**************************************************************************
// Stupid Cake... our constructor sets admin/dev, **************************************************************************
// but cake stomps it somewhere along the way **************************************************************************
// after constructing the CakeError controller. * function: sideMenuAreaVerify
if ($this->name === 'CakeError') { * - Verifies the validity of the sidemenu area/subarea/priority,
$this->params['dev'] = false; * and ensures the class member is set to appropriately handle it.
$this->params['admin'] = false; */
}
$menu = array(); function sideMenuAreaVerify(&$area, $subarea, $priority = null) {
$menu[] = array('name' => 'Common', 'header' => true); $area = strtoupper($area);
$menu[] = array('name' => 'Site Map', 'url' => array('controller' => 'maps', 'action' => 'view', 1)); if (!array_key_exists($area, $this->sidemenu_areas))
$menu[] = array('name' => 'Units', 'url' => array('controller' => 'units', 'action' => 'index')); $this->INTERNAL_ERROR("Sidemenu link '{$area}': Unknown");
$menu[] = array('name' => 'Leases', 'url' => array('controller' => 'leases', 'action' => 'index'));
$menu[] = array('name' => 'Customers', 'url' => array('controller' => 'customers', 'action' => 'index')); if ($area == 'SITE')
$menu[] = array('name' => 'Deposits', 'url' => array('controller' => 'transactions', 'action' => 'deposit')); $name = 'Common';
elseif ($area == 'CONTROLLER')
$name = Inflector::humanize($this->params['controller']);
elseif ($area == 'ACTION')
$name = Inflector::humanize(Inflector::singularize($this->params['controller']));
$subname = $name;
if ($subarea == $this->admin_area)
$subname .= '-Admin';
elseif ($subarea == $this->dev_area)
$subname .= '-Dev';
elseif ($subarea > 1)
$subname .= '-' . $subarea;
if (empty($this->sidemenu_areas[$area]))
$this->sidemenu_areas[$area] = array('name' => $name, 'subarea' => array());
if (empty($this->sidemenu_areas[$area]['subarea'][$subarea]))
$this->sidemenu_areas[$area]['subarea'][$subarea]
= array('name' => $subname, 'priorities' => array());
if (isset($priority) && empty($this->sidemenu_areas[$area]['subarea'][$subarea]['priorities'][$priority]))
$this->sidemenu_areas[$area]['subarea'][$subarea]['priorities'][$priority]
= array();
}
/**************************************************************************
**************************************************************************
**************************************************************************
* function: sideMenuAreaName
* - Sets the name of the sidemenu area/subarea
*/
function sideMenuAreaName($name, $area, $subarea = 1) {
$this->sideMenuAreaVerify($area, $subarea);
$this->sidemenu_areas[$area]['subarea'][$subarea]['name'] = $name;
}
/**************************************************************************
**************************************************************************
**************************************************************************
* function: addSideMenuLink
* - Adds another link to the sidemenu area/subarea/priority
*/
function addSideMenuLink($name, $url, $extra, $area, $subarea = 1, $priority = 10) {
$this->sideMenuAreaVerify($area, $subarea);
$this->sidemenu_areas[$area]['subarea'][$subarea]['priorities'][$priority][]
= array('name' => $name, 'url' => $url) + (empty($extra) ? array() : $extra);
}
/**************************************************************************
**************************************************************************
**************************************************************************
* function: addDefaultSideMenuLinks
* - Adds the standard links present on all generated pages
*/
function addDefaultSideMenuLinks() {
$this->addSideMenuLink('Site Map',
array('controller' => 'maps', 'action' => 'view', 1), null,
'SITE');
$this->addSideMenuLink('Units',
array('controller' => 'units', 'action' => 'index'), null,
'SITE');
$this->addSideMenuLink('Leases',
array('controller' => 'leases', 'action' => 'index'), null,
'SITE');
$this->addSideMenuLink('Customers',
array('controller' => 'customers', 'action' => 'index'), null,
'SITE');
$this->addSideMenuLink('Deposits',
array('controller' => 'transactions', 'action' => 'deposit'), null,
'SITE');
if ($this->params['admin']) { if ($this->params['admin']) {
$menu[] = array('name' => 'Admin', 'header' => true); $this->addSideMenuLink('Accounts',
$menu[] = array('name' => 'Accounts', 'url' => array('controller' => 'accounts', 'action' => 'index')); array('controller' => 'accounts', 'action' => 'index'), null,
$menu[] = array('name' => 'Contacts', 'url' => array('controller' => 'contacts', 'action' => 'index')); 'SITE', $this->admin_area);
$menu[] = array('name' => 'Ledgers', 'url' => array('controller' => 'ledgers', 'action' => 'index')); $this->addSideMenuLink('Contacts',
$menu[] = array('name' => 'Tenders', 'url' => array('controller' => 'tenders', 'action' => 'index')); array('controller' => 'contacts', 'action' => 'index'), null,
$menu[] = array('name' => 'Transactions', 'url' => array('controller' => 'transactions', 'action' => 'index')); 'SITE', $this->admin_area);
$menu[] = array('name' => 'Ldgr Entries', 'url' => array('controller' => 'ledger_entries', 'action' => 'index')); $this->addSideMenuLink('Ledgers',
$menu[] = array('name' => 'Stmt Entries', 'url' => array('controller' => 'statement_entries', 'action' => 'index')); array('controller' => 'ledgers', 'action' => 'index'), null,
$menu[] = array('name' => 'New Ledgers', 'url' => array('controller' => 'accounts', 'action' => 'newledger')); 'SITE', $this->admin_area);
$menu[] = array('name' => 'Assess Charges', 'url' => array('controller' => 'leases', 'action' => 'assess_all')); $this->addSideMenuLink('Tenders',
array('controller' => 'tenders', 'action' => 'index'), null,
'SITE', $this->admin_area);
$this->addSideMenuLink('Transactions',
array('controller' => 'transactions', 'action' => 'index'), null,
'SITE', $this->admin_area);
$this->addSideMenuLink('Ldgr Entries',
array('controller' => 'ledger_entries', 'action' => 'index'), null,
'SITE', $this->admin_area);
$this->addSideMenuLink('Stmt Entries',
array('controller' => 'statement_entries', 'action' => 'index'), null,
'SITE', $this->admin_area);
$this->addSideMenuLink('New Ledgers',
array('controller' => 'accounts', 'action' => 'newledger'), null,
'SITE', $this->admin_area);
$this->addSideMenuLink('Assess Charges',
array('controller' => 'leases', 'action' => 'assess_all'), null,
'SITE', $this->admin_area);
} }
if ($this->params['dev']) { if ($this->params['dev']) {
$menu[] = array('name' => 'Development', 'header' => true); $this->addSideMenuLink('Un-Nuke',
$menu[] = array('name' => 'Un-Nuke', 'url' => '#', 'htmlAttributes' => '#', array('htmlAttributes' =>
array('onclick' => '$(".pr-section").show(); return false;')); array('onclick' => '$(".pr-section").show(); return false;')),
$menu[] = array('name' => 'New Ledgers', 'url' => array('controller' => 'accounts', 'action' => 'newledger')); 'SITE', $this->dev_area);
//array('name' => 'RESET DATA', 'url' => array('controller' => 'accounts', 'action' => 'reset_data')); $this->addSideMenuLink('New Ledgers',
array('controller' => 'accounts', 'action' => 'newledger'), null,
'SITE', $this->dev_area);
//array('name' => 'RESET DATA', array('controller' => 'accounts', 'action' => 'reset_data'));
} }
return $menu;
} }
/**************************************************************************
**************************************************************************
**************************************************************************
* hook: beforeFilter
* - Called just before the action function
*/
function beforeFilter() { function beforeFilter() {
$this->params['dev'] = $this->params['dev'] =
(!empty($this->params['dev_route'])); (!empty($this->params['dev_route']));
@@ -93,12 +198,50 @@ class AppController extends Controller {
if (!$this->params['dev']) if (!$this->params['dev'])
Configure::write('debug', '0'); Configure::write('debug', '0');
$this->addDefaultSideMenuLinks();
} }
/**************************************************************************
**************************************************************************
**************************************************************************
* hook: beforeRender
* - Called just before rendering the page
*/
function beforeRender() { function beforeRender() {
$this->set('sidemenu', $this->sideMenuLinks()); // Stupid Cake... our constructor sets admin/dev,
// but cake stomps it somewhere along the way
// after constructing the CakeError controller.
if ($this->name === 'CakeError') {
$this->params['dev'] = false;
$this->params['admin'] = false;
}
foreach ($this->sidemenu_areas AS &$area) {
if (empty($area['subarea']))
continue;
ksort($area['subarea']);
foreach ($area['subarea'] AS &$subarea) {
if (empty($subarea['priorities']))
continue;
ksort($subarea['priorities']);
}
}
//pr($this->sidemenu_areas);
$this->set('sidemenu', $this->sidemenu_areas);
} }
/**************************************************************************
**************************************************************************
**************************************************************************
* override: redirect
*/
function redirect($url, $status = null, $exit = true) { function redirect($url, $status = null, $exit = true) {
// OK, since the controller will not be able to // OK, since the controller will not be able to
// utilize our overriden url function in AppHelper, // utilize our overriden url function in AppHelper,
@@ -127,6 +270,14 @@ class AppController extends Controller {
return parent::redirect($url, $status, $exit); return parent::redirect($url, $status, $exit);
} }
/**************************************************************************
**************************************************************************
**************************************************************************
* function: reset_data
* - Development function. TO BE DELETED
*/
function reset_data() { function reset_data() {
$this->layout = null; $this->layout = null;
$this->autoLayout = false; $this->autoLayout = false;

View File

@@ -4,25 +4,34 @@ class AccountsController extends AppController {
var $uses = array('Account', 'LedgerEntry'); var $uses = array('Account', 'LedgerEntry');
var $sidemenu_links =
array(array('name' => 'Accounts', 'header' => true),
array('name' => 'All', 'url' => array('controller' => 'accounts', 'action' => 'all')),
array('name' => 'Asset', 'url' => array('controller' => 'accounts', 'action' => 'asset')),
array('name' => 'Liability', 'url' => array('controller' => 'accounts', 'action' => 'liability')),
array('name' => 'Equity', 'url' => array('controller' => 'accounts', 'action' => 'equity')),
array('name' => 'Income', 'url' => array('controller' => 'accounts', 'action' => 'income')),
array('name' => 'Expense', 'url' => array('controller' => 'accounts', 'action' => 'expense')),
);
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
************************************************************************** **************************************************************************
* override: sideMenuLinks * override: addDefaultSideMenuLinks
* - Generates controller specific links for the side menu * - Adds controller specific default side menu links
*/ */
function sideMenuLinks() {
return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); function addDefaultSideMenuLinks() {
parent::addDefaultSideMenuLinks();
$this->addSideMenuLink('Asset',
array('controller' => 'accounts', 'action' => 'asset'), null,
'CONTROLLER');
$this->addSideMenuLink('Liability',
array('controller' => 'accounts', 'action' => 'liability'), null,
'CONTROLLER');
$this->addSideMenuLink('Equity',
array('controller' => 'accounts', 'action' => 'equity'), null,
'CONTROLLER');
$this->addSideMenuLink('Income',
array('controller' => 'accounts', 'action' => 'income'), null,
'CONTROLLER');
$this->addSideMenuLink('Expense',
array('controller' => 'accounts', 'action' => 'expense'), null,
'CONTROLLER');
$this->addSideMenuLink('All',
array('controller' => 'accounts', 'action' => 'all'), null,
'CONTROLLER');
} }
@@ -189,12 +198,12 @@ class AccountsController extends AppController {
$stats = $this->Account->stats($id, true); $stats = $this->Account->stats($id, true);
$stats = $stats['Ledger']; $stats = $stats['Ledger'];
$this->sidemenu_links[] = $this->addSideMenuLink('New Ledger',
array('name' => 'Operations', 'header' => true); array('action' => 'newledger', $id), null,
$this->sidemenu_links[] = 'ACTION');
array('name' => 'New Ledger', 'url' => array('action' => 'newledger', $id)); $this->addSideMenuLink('Collected',
$this->sidemenu_links[] = array('action' => 'collected', $id), null,
array('name' => 'Collected', 'url' => array('action' => 'collected', $id)); 'ACTION');
// Prepare to render // Prepare to render
$title = 'Account: ' . $account['Account']['name']; $title = 'Account: ' . $account['Account']['name'];

View File

@@ -2,18 +2,6 @@
class ContactsController extends AppController { class ContactsController extends AppController {
var $sidemenu_links = array();
/**************************************************************************
**************************************************************************
**************************************************************************
* override: sideMenuLinks
* - Generates controller specific links for the side menu
*/
function sideMenuLinks() {
return array_merge(parent::sideMenuLinks(), $this->sidemenu_links);
}
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
@@ -78,13 +66,9 @@ class ContactsController extends AppController {
)); ));
// Set up dynamic menu items // Set up dynamic menu items
$this->sidemenu_links[] = $this->addSideMenuLink('Edit',
array('name' => 'Operations', 'header' => true); array('action' => 'edit', $id), null,
'ACTION');
$this->sidemenu_links[] =
array('name' => 'Edit',
'url' => array('action' => 'edit',
$id));
// Prepare to render. // Prepare to render.
$title = 'Contact: ' . $contact['Contact']['display_name']; $title = 'Contact: ' . $contact['Contact']['display_name'];

View File

@@ -1,25 +1,30 @@
<?php <?php
class CustomersController extends AppController { class CustomersController extends AppController {
var $sidemenu_links =
array(array('name' => 'Customers', 'header' => true),
array('name' => 'Current', 'url' => array('controller' => 'customers', 'action' => 'current')),
array('name' => 'Past', 'url' => array('controller' => 'customers', 'action' => 'past')),
array('name' => 'All', 'url' => array('controller' => 'customers', 'action' => 'all')),
array('name' => 'Add Customer', 'url' => array('controller' => 'customers', 'action' => 'add')),
);
//var $components = array('RequestHandler');
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
************************************************************************** **************************************************************************
* override: sideMenuLinks * override: addDefaultSideMenuLinks
* - Generates controller specific links for the side menu * - Adds controller specific default side menu links
*/ */
function sideMenuLinks() {
return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); function addDefaultSideMenuLinks() {
parent::addDefaultSideMenuLinks();
$this->addSideMenuLink('Current',
array('controller' => 'customers', 'action' => 'current'), null,
'CONTROLLER');
$this->addSideMenuLink('Past',
array('controller' => 'customers', 'action' => 'past'), null,
'CONTROLLER');
$this->addSideMenuLink('All',
array('controller' => 'customers', 'action' => 'all'), null,
'CONTROLLER');
$this->addSideMenuLink('Add Customer',
array('controller' => 'customers', 'action' => 'add'), null,
'CONTROLLER');
} }
@@ -229,42 +234,35 @@ class CustomersController extends AppController {
} }
// Set up dynamic menu items // Set up dynamic menu items
$this->sidemenu_links[] =
array('name' => 'Operations', 'header' => true);
$this->sidemenu_links[] = $this->addSideMenuLink('Edit',
array('name' => 'Edit', array('action' => 'edit', $id), null,
'url' => array('action' => 'edit', 'ACTION');
$id));
$this->sidemenu_links[] = $this->addSideMenuLink('Move-In',
array('name' => 'Move-In', array('action' => 'move_in', $id), null,
'url' => array('action' => 'move_in', 'ACTION');
$id));
/* if ($show_moveout) { */ /* if ($show_moveout) { */
/* $this->sidemenu_links[] = */ /* $this->addSideMenuLink('Move-Out', */
/* array('name' => 'Move-Out', */ /* array('action' => 'move_out', $id), null, */
/* 'url' => array('action' => 'move_out', */ /* 'ACTION'); */
/* $id)); */
/* } */ /* } */
if ($show_payment || $outstanding_balance > 0) if ($show_payment || $outstanding_balance > 0)
$this->sidemenu_links[] = $this->addSideMenuLink('New Receipt',
array('name' => 'New Receipt', array('action' => 'receipt', $id), null,
'url' => array('action' => 'receipt', 'ACTION');
$id));
if (!$show_moveout && $outstanding_balance > 0) if (!$show_moveout && $outstanding_balance > 0)
$this->sidemenu_links[] = $this->addSideMenuLink('Write-Off',
array('name' => 'Write-Off', array('action' => 'bad_debt', $id), null,
'url' => array('action' => 'bad_debt', 'ACTION');
$id));
if ($outstanding_balance < 0) if ($outstanding_balance < 0)
$this->sidemenu_links[] = $this->addSideMenuLink('Issue Refund',
array('name' => 'Issue Refund', array('action' => 'refund', $id), null,
'url' => array('action' => 'refund', $id)); 'ACTION');
// Prepare to render. // Prepare to render.
$title = 'Customer: ' . $customer['Customer']['name']; $title = 'Customer: ' . $customer['Customer']['name'];

View File

@@ -2,19 +2,6 @@
class DoubleEntriesController extends AppController { class DoubleEntriesController extends AppController {
var $sidemenu_links = array();
/**************************************************************************
**************************************************************************
**************************************************************************
* override: sideMenuLinks
* - Generates controller specific links for the side menu
*/
function sideMenuLinks() {
return array_merge(parent::sideMenuLinks(), $this->sidemenu_links);
}
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************

View File

@@ -2,23 +2,28 @@
class LeasesController extends AppController { class LeasesController extends AppController {
var $sidemenu_links =
array(array('name' => 'Leases', 'header' => true),
array('name' => 'Active', 'url' => array('controller' => 'leases', 'action' => 'active')),
array('name' => 'Closed', 'url' => array('controller' => 'leases', 'action' => 'closed')),
array('name' => 'Delinquent', 'url' => array('controller' => 'leases', 'action' => 'delinquent')),
array('name' => 'All', 'url' => array('controller' => 'leases', 'action' => 'all')),
);
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
************************************************************************** **************************************************************************
* override: sideMenuLinks * override: addDefaultSideMenuLinks
* - Generates controller specific links for the side menu * - Adds controller specific default side menu links
*/ */
function sideMenuLinks() {
return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); function addDefaultSideMenuLinks() {
parent::addDefaultSideMenuLinks();
$this->addSideMenuLink('Active',
array('controller' => 'leases', 'action' => 'active'), null,
'CONTROLLER');
$this->addSideMenuLink('Closed',
array('controller' => 'leases', 'action' => 'closed'), null,
'CONTROLLER');
$this->addSideMenuLink('Delinquent',
array('controller' => 'leases', 'action' => 'delinquent'), null,
'CONTROLLER');
$this->addSideMenuLink('All',
array('controller' => 'leases', 'action' => 'all'), null,
'CONTROLLER');
} }
@@ -467,28 +472,21 @@ class LeasesController extends AppController {
// yet still have an outstanding balance. This can happen if someone // yet still have an outstanding balance. This can happen if someone
// were to reverse charges, or if a payment should come back NSF. // were to reverse charges, or if a payment should come back NSF.
if (!isset($lease['Lease']['close_date']) || $outstanding_balance > 0) { if (!isset($lease['Lease']['close_date']) || $outstanding_balance > 0) {
$this->sidemenu_links[] =
array('name' => 'Operations', 'header' => true);
if (!isset($lease['Lease']['moveout_date'])) if (!isset($lease['Lease']['moveout_date']))
$this->sidemenu_links[] = $this->addSideMenuLink('Move-Out',
array('name' => 'Move-Out', 'url' => array('action' => 'move_out', array('action' => 'move_out', $id), null,
$id)); 'ACTION');
if (!isset($lease['Lease']['close_date'])) if (!isset($lease['Lease']['close_date']))
$this->sidemenu_links[] = $this->addSideMenuLink('New Invoice',
array('name' => 'New Invoice', 'url' => array('action' => 'invoice', array('action' => 'invoice', $id), null,
$id)); 'ACTION');
$this->sidemenu_links[] = $this->addSideMenuLink('New Receipt',
array('name' => 'New Receipt', 'url' => array('controller' => 'customers', array('controller' => 'customers',
'action' => 'receipt', 'action' => 'receipt',
$lease['Customer']['id'])); $lease['Customer']['id']), null,
'ACTION');
/* if ($outstanding_balance < 0) */
/* $this->sidemenu_links[] = */
/* array('name' => 'Transfer Credit to Customer', */
/* 'url' => array('action' => 'promote_surplus', $id)); */
// REVISIT <AP>: // REVISIT <AP>:
// Not allowing refund to be issued from the lease, as // Not allowing refund to be issued from the lease, as
@@ -500,19 +498,19 @@ class LeasesController extends AppController {
$this->INTERNAL_ERROR("Should not have a customer lease credit."); $this->INTERNAL_ERROR("Should not have a customer lease credit.");
/* if ($outstanding_balance < 0) */ /* if ($outstanding_balance < 0) */
/* $this->sidemenu_links[] = */ /* $this->addSideMenuLink('Issue Refund', */
/* array('name' => 'Issue Refund', */ /* array('action' => 'refund', $id), null, */
/* 'url' => array('action' => 'refund', $id)); */ /* 'ACTION'); */
if (isset($lease['Lease']['moveout_date']) && $outstanding_balance > 0) if (isset($lease['Lease']['moveout_date']) && $outstanding_balance > 0)
$this->sidemenu_links[] = $this->addSideMenuLink('Write-Off',
array('name' => 'Write-Off', 'url' => array('action' => 'bad_debt', array('action' => 'bad_debt', $id), null,
$id)); 'ACTION');
if ($this->Lease->closeable($id)) if ($this->Lease->closeable($id))
$this->sidemenu_links[] = $this->addSideMenuLink('Close',
array('name' => 'Close', 'url' => array('action' => 'close', array('action' => 'close', $id), null,
$id)); 'ACTION');
} }
// Prepare to render // Prepare to render

View File

@@ -2,19 +2,6 @@
class LedgerEntriesController extends AppController { class LedgerEntriesController extends AppController {
var $sidemenu_links = array();
/**************************************************************************
**************************************************************************
**************************************************************************
* override: sideMenuLinks
* - Generates controller specific links for the side menu
*/
function sideMenuLinks() {
return array_merge(parent::sideMenuLinks(), $this->sidemenu_links);
}
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************

View File

@@ -2,22 +2,25 @@
class LedgersController extends AppController { class LedgersController extends AppController {
var $sidemenu_links =
array(array('name' => 'Ledgers', 'header' => true),
array('name' => 'Current', 'url' => array('controller' => 'ledgers', 'action' => 'current')),
array('name' => 'Closed', 'url' => array('controller' => 'ledgers', 'action' => 'closed')),
array('name' => 'All', 'url' => array('controller' => 'ledgers', 'action' => 'all')),
);
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
************************************************************************** **************************************************************************
* override: sideMenuLinks * override: addDefaultSideMenuLinks
* - Generates controller specific links for the side menu * - Adds controller specific default side menu links
*/ */
function sideMenuLinks() {
return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); function addDefaultSideMenuLinks() {
parent::addDefaultSideMenuLinks();
$this->addSideMenuLink('Current',
array('controller' => 'ledgers', 'action' => 'current'), null
'CONTROLLER');
$this->addSideMenuLink('Closed',
array('controller' => 'ledgers', 'action' => 'closed'), null,
'CONTROLLER');
$this->addSideMenuLink('All',
array('controller' => 'ledgers', 'action' => 'all'), null,
'CONTROLLER');
} }

View File

@@ -2,19 +2,6 @@
class StatementEntriesController extends AppController { class StatementEntriesController extends AppController {
var $sidemenu_links = array();
/**************************************************************************
**************************************************************************
**************************************************************************
* override: sideMenuLinks
* - Generates controller specific links for the side menu
*/
function sideMenuLinks() {
return array_merge(parent::sideMenuLinks(), $this->sidemenu_links);
}
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
@@ -293,24 +280,16 @@ class StatementEntriesController extends AppController {
if (strtoupper($entry['StatementEntry']['type']) === 'CHARGE') { if (strtoupper($entry['StatementEntry']['type']) === 'CHARGE') {
$reversable = $this->StatementEntry->reversable($id);
// Set up dynamic menu items // Set up dynamic menu items
if ($reversable || $stats['balance'] > 0) if ($this->StatementEntry->reversable($id))
$this->sidemenu_links[] = $this->addSideMenuLink('Reverse',
array('name' => 'Operations', 'header' => true); array('action' => 'reverse', $id), null,
'ACTION');
if ($reversable)
$this->sidemenu_links[] =
array('name' => 'Reverse',
'url' => array('action' => 'reverse',
$id));
if ($stats['balance'] > 0) if ($stats['balance'] > 0)
$this->sidemenu_links[] = $this->addSideMenuLink('Waive Balance',
array('name' => 'Waive Balance', array('action' => 'waive', $id), null,
'url' => array('action' => 'waive', 'ACTION');
$id));
} }
// Prepare to render. // Prepare to render.

View File

@@ -2,19 +2,6 @@
class TendersController extends AppController { class TendersController extends AppController {
var $sidemenu_links = array();
/**************************************************************************
**************************************************************************
**************************************************************************
* override: sideMenuLinks
* - Generates controller specific links for the side menu
*/
function sideMenuLinks() {
return array_merge(parent::sideMenuLinks(), $this->sidemenu_links);
}
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
@@ -163,16 +150,11 @@ class TendersController extends AppController {
)); ));
// Set up dynamic menu items
$this->sidemenu_links[] =
array('name' => 'Operations', 'header' => true);
// Watch out for the special "Closing" entries // Watch out for the special "Closing" entries
if (!empty($tender['TenderType']['id'])) if (!empty($tender['TenderType']['id']))
$this->sidemenu_links[] = $this->addSideMenuLink('Edit',
array('name' => 'Edit', array('action' => 'edit', $id), null,
'url' => array('action' => 'edit', 'ACTION');
$id));
if (!empty($tender['Tender']['deposit_transaction_id']) if (!empty($tender['Tender']['deposit_transaction_id'])
&& empty($tender['Tender']['nsf_transaction_id']) && empty($tender['Tender']['nsf_transaction_id'])
@@ -181,10 +163,9 @@ class TendersController extends AppController {
// (or if we're in development mode) // (or if we're in development mode)
&& (!empty($tender['TenderType']['data1_name']) || !empty($this->params['dev'])) && (!empty($tender['TenderType']['data1_name']) || !empty($this->params['dev']))
) { ) {
$this->sidemenu_links[] = $this->addSideMenuLink('NSF',
array('name' => 'NSF', array('action' => 'nsf', $id), null,
'url' => array('action' => 'nsf', 'ACTION');
$id));
} }
// Prepare to render. // Prepare to render.

View File

@@ -4,23 +4,28 @@ class TransactionsController extends AppController {
var $components = array('RequestHandler'); var $components = array('RequestHandler');
var $sidemenu_links =
array(array('name' => 'Transactions', 'header' => true),
array('name' => 'All', 'url' => array('controller' => 'transactions', 'action' => 'all')),
array('name' => 'Invoices', 'url' => array('controller' => 'transactions', 'action' => 'invoice')),
array('name' => 'Receipts', 'url' => array('controller' => 'transactions', 'action' => 'receipt')),
array('name' => 'Deposits', 'url' => array('controller' => 'transactions', 'action' => 'deposit')),
);
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
************************************************************************** **************************************************************************
* override: sideMenuLinks * override: addDefaultSideMenuLinks
* - Generates controller specific links for the side menu * - Adds controller specific default side menu links
*/ */
function sideMenuLinks() {
return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); function addDefaultSideMenuLinks() {
parent::addDefaultSideMenuLinks();
$this->addSideMenuLink('Invoices',
array('controller' => 'transactions', 'action' => 'invoice'), null,
'CONTROLLER');
$this->addSideMenuLink('Receipts',
array('controller' => 'transactions', 'action' => 'receipt'), null,
'CONTROLLER');
$this->addSideMenuLink('Deposits',
array('controller' => 'transactions', 'action' => 'deposit'), null,
'CONTROLLER');
$this->addSideMenuLink('All',
array('controller' => 'transactions', 'action' => 'all'), null,
'CONTROLLER');
} }
@@ -36,10 +41,9 @@ class TransactionsController extends AppController {
function invoice() { $this->gridView('Invoices'); } function invoice() { $this->gridView('Invoices'); }
function receipt() { $this->gridView('Receipts'); } function receipt() { $this->gridView('Receipts'); }
function deposit() { function deposit() {
$this->sidemenu_links = array $this->addSideMenuLink('New Deposit',
(array('name' => 'Operations', 'header' => true), array('controller' => 'tenders', 'action' => 'deposit'), null,
array('name' => 'New Deposit', 'url' => array('controller' => 'tenders', 'ACTION');
'action' => 'deposit')));
$this->gridView('Deposits'); $this->gridView('Deposits');
} }
@@ -410,20 +414,19 @@ class TransactionsController extends AppController {
$this->redirect(array('action'=>'index')); $this->redirect(array('action'=>'index'));
} }
if ($transaction['Transaction']['type'] === 'DEPOSIT' || $this->params['dev']) { if ($transaction['Transaction']['type'] === 'DEPOSIT')
$this->sidemenu_links[] = $this->addSideMenuLink('View Slip',
array('name' => 'Operations', 'header' => true); array('action' => 'deposit_slip', $id), null,
'ACTION');
if ($transaction['Transaction']['type'] === 'DEPOSIT') if ($this->params['dev'])
$this->sidemenu_links[] = $this->addSideMenuLink('Destroy',
array('name' => 'View Slip', 'url' => array('action' => 'deposit_slip', $id)); array('action' => 'destroy', $id),
if ($this->params['dev']) array('confirmMessage' =>
$this->sidemenu_links[] = "This may leave the database in an unstable state." .
array('name' => 'Destroy', 'url' => array('action' => 'destroy', $id), " Do NOT do this unless you know what you're doing." .
'confirmMessage' => ("This may leave the database in an unstable state." . " Proceed anyway?"),
" Do NOT do this unless you know what you're doing." . 'ACTION', $this->dev_area);
" Proceed anyway?"));
}
// OK, prepare to render. // OK, prepare to render.
$title = 'Transaction #' . $transaction['Transaction']['id']; $title = 'Transaction #' . $transaction['Transaction']['id'];
@@ -482,10 +485,9 @@ class TransactionsController extends AppController {
if ($deposit['Transaction']['amount'] != $deposit_total) if ($deposit['Transaction']['amount'] != $deposit_total)
$this->INTERNAL_ERROR("Deposit items do not add up to deposit slip total"); $this->INTERNAL_ERROR("Deposit items do not add up to deposit slip total");
$this->sidemenu_links[] = $this->addSideMenuLink('View',
array('name' => 'Operations', 'header' => true); array('action' => 'view', $id), null,
$this->sidemenu_links[] = 'ACTION');
array('name' => 'View Transaction', 'url' => array('action' => 'view', $id));
$title = 'Deposit Slip'; $title = 'Deposit Slip';
$this->set(compact('title', 'deposit')); $this->set(compact('title', 'deposit'));

View File

@@ -2,23 +2,28 @@
class UnitsController extends AppController { class UnitsController extends AppController {
var $sidemenu_links =
array(array('name' => 'Units', 'header' => true),
array('name' => 'Occupied', 'url' => array('controller' => 'units', 'action' => 'occupied')),
array('name' => 'Vacant', 'url' => array('controller' => 'units', 'action' => 'vacant')),
array('name' => 'Unavailable', 'url' => array('controller' => 'units', 'action' => 'unavailable')),
array('name' => 'All', 'url' => array('controller' => 'units', 'action' => 'all')),
);
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
************************************************************************** **************************************************************************
* override: sideMenuLinks * override: addDefaultSideMenuLinks
* - Generates controller specific links for the side menu * - Adds controller specific default side menu links
*/ */
function sideMenuLinks() {
return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); function addDefaultSideMenuLinks() {
parent::addDefaultSideMenuLinks();
$this->addSideMenuLink('Occupied',
array('controller' => 'units', 'action' => 'occupied'), null,
'CONTROLLER');
$this->addSideMenuLink('Vacant',
array('controller' => 'units', 'action' => 'vacant'), null,
'CONTROLLER');
$this->addSideMenuLink('Unavailable',
array('controller' => 'units', 'action' => 'unavailable'), null,
'CONTROLLER');
$this->addSideMenuLink('All',
array('controller' => 'units', 'action' => 'all'), null,
'CONTROLLER');
} }
@@ -233,36 +238,35 @@ class UnitsController extends AppController {
} }
// Set up dynamic menu items // Set up dynamic menu items
$this->sidemenu_links[] = $this->addSideMenuLink('Edit',
array('name' => 'Operations', 'header' => true); array('action' => 'edit', $id), null,
'ACTION');
$this->sidemenu_links[] =
array('name' => 'Edit', 'url' => array('action' => 'edit',
$id));
if (isset($unit['CurrentLease']['id']) && if (isset($unit['CurrentLease']['id']) &&
!isset($unit['CurrentLease']['moveout_date'])) { !isset($unit['CurrentLease']['moveout_date'])) {
$this->sidemenu_links[] = $this->addSideMenuLink('Move-Out',
array('name' => 'Move-Out', 'url' => array('action' => 'move_out', array('action' => 'move_out', $id), null,
$id)); 'ACTION');
} elseif ($this->Unit->available($unit['Unit']['status'])) { } elseif ($this->Unit->available($unit['Unit']['status'])) {
$this->sidemenu_links[] = $this->addSideMenuLink('Move-In',
array('name' => 'Move-In', 'url' => array('action' => 'move_in', array('action' => 'move_in', $id), null,
$id)); 'ACTION');
} else { } else {
// Unit is unavailable (dirty, damaged, reserved, business-use, etc) // Unit is unavailable (dirty, damaged, reserved, business-use, etc)
} }
if (isset($unit['CurrentLease']['id']) && if (isset($unit['CurrentLease']['id']) &&
!isset($unit['CurrentLease']['close_date'])) { !isset($unit['CurrentLease']['close_date'])) {
$this->sidemenu_links[] = $this->addSideMenuLink('New Invoice',
array('name' => 'New Invoice', 'url' => array('controller' => 'leases', array('controller' => 'leases',
'action' => 'invoice', 'action' => 'invoice',
$unit['CurrentLease']['id'])); $unit['CurrentLease']['id']), null,
$this->sidemenu_links[] = 'ACTION');
array('name' => 'New Receipt', 'url' => array('controller' => 'customers', $this->addSideMenuLink('New Receipt',
'action' => 'receipt', array('controller' => 'customers',
$unit['CurrentLease']['customer_id'])); 'action' => 'receipt',
$unit['CurrentLease']['customer_id']), null,
'ACTION');
} }
// Prepare to render. // Prepare to render.

View File

@@ -8,17 +8,29 @@
* @package pmgr * @package pmgr
*/ */
foreach ($menu AS $item) { foreach ($menu AS $area) {
if (isset($item['header'])) if (empty($area['subarea']))
echo('<DIV CLASS="header">' . $item['name'] . '</DIV>' . "\n"); continue;
elseif (isset($item['hr']))
echo('<HR>' . "\n");
elseif (isset($item['url']))
echo('<DIV CLASS="item">'
. $html->link($item['name'], $item['url'],
isset($item['htmlAttributes']) ? $item['htmlAttributes'] : null,
isset($item['confirmMessage']) ? $item['confirmMessage'] : null,
isset($item['escapeTitle']) ? $item['escapeTitle'] : null)
. '</DIV>' . "\n"); foreach ($area['subarea'] AS $subarea) {
if (empty($subarea['priorities']))
continue;
echo('<DIV CLASS="header">' . $subarea['name'] . '</DIV>' . "\n");
foreach ($subarea['priorities'] AS $priority) {
foreach ($priority AS $item) {
if (isset($item['header']))
echo('<DIV CLASS="header">' . $item['name'] . '</DIV>' . "\n");
elseif (isset($item['hr']))
echo('<HR>' . "\n");
elseif (isset($item['url']))
echo('<DIV CLASS="item">'
. $html->link($item['name'], $item['url'],
isset($item['htmlAttributes']) ? $item['htmlAttributes'] : null,
isset($item['confirmMessage']) ? $item['confirmMessage'] : null,
isset($item['escapeTitle']) ? $item['escapeTitle'] : null)
. '</DIV>' . "\n");
}
}
}
} }