More work on tidying up the menu items for usability.
git-svn-id: file:///svn-source/pmgr/branches/pre_0.1_work_20090819@735 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -39,8 +39,11 @@ class AppController extends Controller {
|
||||
var $components = array('DebugKit.Toolbar');
|
||||
|
||||
var $sidemenu_areas = array('SITE' => false, 'CONTROLLER' => false, 'ACTION' => false);
|
||||
var $admin_area = 2;
|
||||
var $dev_area = 3;
|
||||
var $std_area = 10;
|
||||
var $new_area = 20;
|
||||
var $op_area = 30;
|
||||
var $admin_area = 40;
|
||||
var $dev_area = 50;
|
||||
|
||||
function __construct() {
|
||||
$this->params['dev'] = false;
|
||||
@@ -62,27 +65,43 @@ class AppController extends Controller {
|
||||
$this->INTERNAL_ERROR("Sidemenu link '{$area}': Unknown");
|
||||
|
||||
if ($area == 'SITE')
|
||||
$name = 'Common';
|
||||
$name = 'Navigation';
|
||||
elseif ($area == 'CONTROLLER')
|
||||
$name = Inflector::humanize($this->params['controller']);
|
||||
elseif ($area == 'ACTION')
|
||||
$name = Inflector::humanize(Inflector::singularize($this->params['controller']));
|
||||
|
||||
if (empty($this->sidemenu_areas[$area]))
|
||||
$this->sidemenu_areas[$area]
|
||||
= array('enable' => true, 'name' => $name, 'subarea' => array());
|
||||
|
||||
if (empty($subarea))
|
||||
return;
|
||||
|
||||
$subname = $name;
|
||||
if ($subarea == $this->admin_area)
|
||||
if ($subarea == $this->std_area)
|
||||
$subname .= '';
|
||||
elseif ($subarea == $this->op_area)
|
||||
//$subname .= '-Ops';
|
||||
$subname = 'Operations';
|
||||
elseif ($subarea == $this->new_area)
|
||||
//$subname .= '-New';
|
||||
$subname = 'Creation';
|
||||
elseif ($subarea == $this->admin_area)
|
||||
$subname .= '-Admin';
|
||||
elseif ($subarea == $this->dev_area)
|
||||
$subname .= '-Dev';
|
||||
elseif ($subarea > 1)
|
||||
else
|
||||
$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());
|
||||
$this->sidemenu_areas[$area]['subarea'][$subarea]
|
||||
= array('enable' => true, 'name' => $subname, 'priorities' => array());
|
||||
|
||||
if (isset($priority) && empty($this->sidemenu_areas[$area]['subarea'][$subarea]['priorities'][$priority]))
|
||||
if (empty($priority))
|
||||
return;
|
||||
|
||||
if (empty($this->sidemenu_areas[$area]['subarea'][$subarea]['priorities'][$priority]))
|
||||
$this->sidemenu_areas[$area]['subarea'][$subarea]['priorities'][$priority]
|
||||
= array();
|
||||
}
|
||||
@@ -95,9 +114,28 @@ class AppController extends Controller {
|
||||
* - Sets the name of the sidemenu area/subarea
|
||||
*/
|
||||
|
||||
function sideMenuAreaName($name, $area, $subarea = 1) {
|
||||
function sideMenuAreaName($name, $area, $subarea = null) {
|
||||
$this->sideMenuAreaVerify($area, $subarea);
|
||||
$this->sidemenu_areas[$area]['subarea'][$subarea]['name'] = $name;
|
||||
if (empty($subarea))
|
||||
$this->sidemenu_areas[$area]['name'] = $name;
|
||||
else
|
||||
$this->sidemenu_areas[$area]['subarea'][$subarea]['name'] = $name;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* function: sideMenuEnable
|
||||
* - Enables/Disables an area or subarea of the sidemenu
|
||||
*/
|
||||
|
||||
function sideMenuEnable($area, $subarea = null, $enable = true) {
|
||||
$this->sideMenuAreaVerify($area, $subarea);
|
||||
if (isset($subarea))
|
||||
$this->sidemenu_areas[$area]['subarea'][$subarea]['enable'] = $enable;
|
||||
else
|
||||
$this->sidemenu_areas[$area]['enable'] = $enable;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +146,9 @@ class AppController extends Controller {
|
||||
* - Adds another link to the sidemenu area/subarea/priority
|
||||
*/
|
||||
|
||||
function addSideMenuLink($name, $url, $extra, $area, $subarea = 1, $priority = 10) {
|
||||
function addSideMenuLink($name, $url, $extra, $area, $subarea = null, $priority = 10) {
|
||||
if (empty($subarea))
|
||||
$subarea = $this->std_area;
|
||||
$this->sideMenuAreaVerify($area, $subarea);
|
||||
$this->sidemenu_areas[$area]['subarea'][$subarea]['priorities'][$priority][]
|
||||
= array('name' => $name, 'url' => $url) + (empty($extra) ? array() : $extra);
|
||||
@@ -140,6 +180,26 @@ class AppController extends Controller {
|
||||
array('controller' => 'transactions', 'action' => 'deposit'), null,
|
||||
'SITE');
|
||||
|
||||
/* $this->addSideMenuLink('Move-In', */
|
||||
/* array('controller' => 'customers', 'action' => 'move_in'), null, */
|
||||
/* 'SITE', $this->op_area); */
|
||||
|
||||
/* $this->addSideMenuLink('Move-Out', */
|
||||
/* array('controller' => 'customers', 'action' => 'move_out'), null, */
|
||||
/* 'SITE', $this->op_area); */
|
||||
|
||||
/* $this->addSideMenuLink('New Receipt', */
|
||||
/* array('controller' => 'customers', 'action' => 'receipt'), null, */
|
||||
/* 'SITE', $this->op_area); */
|
||||
|
||||
/* $this->addSideMenuLink('New Customer', */
|
||||
/* array('controller' => 'customers', 'action' => 'add'), null, */
|
||||
/* 'SITE', $this->op_area); */
|
||||
|
||||
/* $this->addSideMenuLink('New Deposit', */
|
||||
/* array('controller' => 'tenders', 'action' => 'deposit'), null, */
|
||||
/* 'SITE', $this->op_area); */
|
||||
|
||||
if ($this->params['admin']) {
|
||||
$this->addSideMenuLink('Accounts',
|
||||
array('controller' => 'accounts', 'action' => 'index'), null,
|
||||
@@ -162,9 +222,6 @@ class AppController extends Controller {
|
||||
$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);
|
||||
@@ -180,6 +237,9 @@ class AppController extends Controller {
|
||||
'SITE', $this->dev_area);
|
||||
//array('name' => 'RESET DATA', array('controller' => 'accounts', 'action' => 'reset_data'));
|
||||
}
|
||||
|
||||
|
||||
$this->sideMenuAreaName('Operations', 'SITE', $this->op_area);
|
||||
}
|
||||
|
||||
|
||||
@@ -200,6 +260,7 @@ class AppController extends Controller {
|
||||
Configure::write('debug', '0');
|
||||
|
||||
$this->addDefaultSideMenuLinks();
|
||||
$this->sideMenuEnable('SITE', $this->op_area, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -220,11 +281,15 @@ class AppController extends Controller {
|
||||
}
|
||||
|
||||
foreach ($this->sidemenu_areas AS &$area) {
|
||||
if (empty($area['enable']))
|
||||
$area = array();
|
||||
if (empty($area['subarea']))
|
||||
continue;
|
||||
|
||||
ksort($area['subarea']);
|
||||
|
||||
foreach ($area['subarea'] AS &$subarea) {
|
||||
if (empty($subarea['enable']))
|
||||
$subarea = array();
|
||||
if (empty($subarea['priorities']))
|
||||
continue;
|
||||
ksort($subarea['priorities']);
|
||||
@@ -309,6 +374,7 @@ class AppController extends Controller {
|
||||
*/
|
||||
|
||||
function gridView($title, $action = null, $element = null) {
|
||||
$this->sideMenuEnable('SITE', $this->op_area);
|
||||
$this->set('title', $title);
|
||||
// The resulting page will contain a grid, which will
|
||||
// use ajax to obtain the actual data for this action
|
||||
|
||||
@@ -14,6 +14,25 @@ class AccountsController extends AppController {
|
||||
|
||||
function addDefaultSideMenuLinks() {
|
||||
parent::addDefaultSideMenuLinks();
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* action: index / asset / liability / equity / income / expense / all
|
||||
* - Generate a chart of accounts
|
||||
*/
|
||||
|
||||
function index() { $this->all(); }
|
||||
function asset() { $this->gridView('Asset Accounts'); }
|
||||
function liability() { $this->gridView('Liability Accounts'); }
|
||||
function equity() { $this->gridView('Equity Accounts'); }
|
||||
function income() { $this->gridView('Income Accounts'); }
|
||||
function expense() { $this->gridView('Expense Accounts'); }
|
||||
function all() { $this->gridView('All Accounts', 'all'); }
|
||||
|
||||
function gridView($title, $action = null, $element = null) {
|
||||
$this->addSideMenuLink('Asset',
|
||||
array('controller' => 'accounts', 'action' => 'asset'), null,
|
||||
'CONTROLLER');
|
||||
@@ -32,25 +51,10 @@ class AccountsController extends AppController {
|
||||
$this->addSideMenuLink('All',
|
||||
array('controller' => 'accounts', 'action' => 'all'), null,
|
||||
'CONTROLLER');
|
||||
parent::gridView($title, $action, $element);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* action: index / asset / liability / equity / income / expense / all
|
||||
* - Generate a chart of accounts
|
||||
*/
|
||||
|
||||
function index() { $this->all(); }
|
||||
function asset() { $this->gridView('Asset Accounts'); }
|
||||
function liability() { $this->gridView('Liability Accounts'); }
|
||||
function equity() { $this->gridView('Equity Accounts'); }
|
||||
function income() { $this->gridView('Income Accounts'); }
|
||||
function expense() { $this->gridView('Expense Accounts'); }
|
||||
function all() { $this->gridView('All Accounts', 'all'); }
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
|
||||
@@ -12,19 +12,6 @@ class CustomersController extends AppController {
|
||||
|
||||
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');
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +27,25 @@ class CustomersController extends AppController {
|
||||
function past() { $this->gridView('Past Tenants'); }
|
||||
function all() { $this->gridView('All Customers'); }
|
||||
|
||||
function gridView($title, $action = null, $element = null) {
|
||||
$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->sideMenuAreaName('Creation', 'ACTION', $this->new_area);
|
||||
$this->addSideMenuLink('New Customer',
|
||||
array('controller' => 'customers', 'action' => 'add'), null,
|
||||
'ACTION', $this->new_area);
|
||||
|
||||
parent::gridView($title, $action, $element);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
|
||||
@@ -12,18 +12,6 @@ class LeasesController extends AppController {
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +28,22 @@ class LeasesController extends AppController {
|
||||
function closed() { $this->gridView('Closed Leases'); }
|
||||
function all() { $this->gridView('All Leases', 'all'); }
|
||||
|
||||
function gridView($title, $action = null, $element = null) {
|
||||
$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');
|
||||
parent::gridView($title, $action, $element);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
|
||||
@@ -12,15 +12,6 @@ class LedgersController extends AppController {
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +27,19 @@ class LedgersController extends AppController {
|
||||
function closed() { $this->gridView('Closed Ledgers'); }
|
||||
function all() { $this->gridView('All Ledgers', 'all'); }
|
||||
|
||||
function gridView($title, $action = null, $element = null) {
|
||||
$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');
|
||||
parent::gridView($title, $action, $element);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
|
||||
@@ -14,18 +14,6 @@ class TransactionsController extends AppController {
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
|
||||
@@ -41,12 +29,29 @@ class TransactionsController extends AppController {
|
||||
function invoice() { $this->gridView('Invoices'); }
|
||||
function receipt() { $this->gridView('Receipts'); }
|
||||
function deposit() {
|
||||
if (empty($this->params['admin']))
|
||||
$this->sideMenuEnable('CONTROLLER', $this->std_area, false);
|
||||
$this->addSideMenuLink('New Deposit',
|
||||
array('controller' => 'tenders', 'action' => 'deposit'), null,
|
||||
'ACTION');
|
||||
$this->gridView('Deposits');
|
||||
}
|
||||
|
||||
function gridView($title, $action = null, $element = null) {
|
||||
$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');
|
||||
parent::gridView($title, $action, $element);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
|
||||
@@ -12,18 +12,6 @@ class UnitsController extends AppController {
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +28,21 @@ class UnitsController extends AppController {
|
||||
function occupied() { $this->gridView('Occupied Units'); }
|
||||
function all() { $this->gridView('All Units', 'all'); }
|
||||
|
||||
function gridView($title, $action = null, $element = null) {
|
||||
$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');
|
||||
parent::gridView($title, $action, $element);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user