Added Monthly Charges report. Also, added a new area to the menu specifically for reports.
git-svn-id: file:///svn-source/pmgr/branches/v0.3_work@958 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -39,7 +39,7 @@ class AppController extends Controller {
|
||||
var $helpers = array('Html', 'Form', 'Javascript', 'Format', 'Time', 'Grid');
|
||||
var $components = array('DebugKit.Toolbar');
|
||||
|
||||
var $sidemenu = array('areas' => array('SITE' => false, 'CONTROLLER' => false, 'ACTION' => false, 'SANDBOX' => false));
|
||||
var $sidemenu = array('areas' => array('SITE' => false, 'REPORT' => false, 'CONTROLLER' => false, 'ACTION' => false, 'SANDBOX' => false));
|
||||
var $std_area = 10;
|
||||
var $admin_area = 20;
|
||||
var $dev_area = 30;
|
||||
@@ -80,6 +80,8 @@ class AppController extends Controller {
|
||||
$name = Inflector::humanize($this->params['controller']);
|
||||
elseif ($area == 'ACTION')
|
||||
$name = Inflector::humanize(Inflector::singularize($this->params['controller']));
|
||||
elseif ($area == 'REPORT')
|
||||
$name = 'Reports';
|
||||
elseif ($area == 'SANDBOX')
|
||||
$name = 'Sandbox';
|
||||
|
||||
@@ -260,6 +262,21 @@ class AppController extends Controller {
|
||||
array('controller' => 'leases', 'action' => 'assess_all'), null,
|
||||
'SITE', $this->op_area);
|
||||
|
||||
if ($this->admin()) {
|
||||
$this->addSideMenuLink('Unit Summary',
|
||||
array('controller' => 'units', 'action' => 'overview'), null,
|
||||
'REPORT');
|
||||
$this->addSideMenuLink('Monthly Charges',
|
||||
array('controller' => 'statement_entries', 'action' => 'chargesbymonth'), null,
|
||||
'REPORT');
|
||||
}
|
||||
else {
|
||||
$this->sideMenuEnable('REPORT', null, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$url_components = array('plugin', 'controller', 'action', 'named');
|
||||
if (devbox()) {
|
||||
/* $sources = ConnectionManager::sourceList(); */
|
||||
@@ -398,6 +415,13 @@ class AppController extends Controller {
|
||||
$this->sideMenuAreaActivate($area_name);
|
||||
}
|
||||
|
||||
// If generating reports, don't display the controller menu.
|
||||
// Each report comes from a controller, but there is no need
|
||||
// to present the controller actions, so remove that section
|
||||
// from the menu.
|
||||
if ($this->sidemenu['active']['area'] == 'REPORT')
|
||||
$this->sideMenuEnable('CONTROLLER', null, false);
|
||||
|
||||
//pr($this->sidemenu);
|
||||
$this->set('sidemenu', $this->sidemenu);
|
||||
}
|
||||
|
||||
@@ -253,6 +253,53 @@ class StatementEntriesController extends AppController {
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* action: chargesbymonth
|
||||
* - Displays charges by month
|
||||
*/
|
||||
|
||||
function chargesbymonth() {
|
||||
$result = $this->StatementEntry->find
|
||||
('all',
|
||||
array('link' => array('Account' => array('fields' => 'name')),
|
||||
'fields' => array('MONTHNAME(effective_date) AS month',
|
||||
'YEAR(effective_date) AS year',
|
||||
'SUM(amount) AS amount',
|
||||
),
|
||||
'conditions' => array('StatementEntry.type' => 'CHARGE',
|
||||
'effective_date >=' => '2009-04-01',
|
||||
'effective_date <= NOW()',
|
||||
),
|
||||
'group' => array('YEAR(effective_date), MONTH(effective_date)', 'Account.id'),
|
||||
'order' => array('YEAR(effective_date), MONTH(effective_date)', 'Account.name'),
|
||||
));
|
||||
|
||||
$overview = array('months' => array(), 'charges' => 0);
|
||||
foreach ($result AS $row) {
|
||||
$mname = $row[0]['month'] .', '. $row[0]['year'];
|
||||
if (empty($overview['months'][$mname]))
|
||||
$overview['months'][$mname] = array('name' => $mname,
|
||||
'subs' => array(),
|
||||
'charges' => 0);
|
||||
$month = &$overview['months'][$mname];
|
||||
$month['subs'][] = array('name' => $row['Account']['name'],
|
||||
'charges' => $row[0]['amount']);
|
||||
|
||||
$month['charges'] += $row[0]['amount'];
|
||||
$overview['charges'] += $row[0]['amount'];
|
||||
}
|
||||
|
||||
// Enable the Reports menu section
|
||||
$this->sideMenuAreaActivate('REPORT');
|
||||
|
||||
// Prepare to render.
|
||||
$this->set('title', 'Monthly Charges');
|
||||
$this->set(compact('overview'));
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
|
||||
@@ -31,10 +31,6 @@ class UnitsController extends AppController {
|
||||
$this->addSideMenuLink('All',
|
||||
array('controller' => 'units', 'action' => 'all'), null,
|
||||
'CONTROLLER');
|
||||
if ($this->admin())
|
||||
$this->addSideMenuLink('Overview',
|
||||
array('controller' => 'units', 'action' => 'overview'), null,
|
||||
'CONTROLLER');
|
||||
}
|
||||
|
||||
|
||||
@@ -244,7 +240,6 @@ class UnitsController extends AppController {
|
||||
'group' => array('UnitType.id', 'Unit.status'),
|
||||
'order' => array('UnitType.name', 'Unit.status')
|
||||
));
|
||||
//pr($result);
|
||||
|
||||
$overview = array('types' => array(), 'count' => 0, 'rents' => 0);
|
||||
foreach ($result AS $row) {
|
||||
@@ -283,7 +278,9 @@ class UnitsController extends AppController {
|
||||
$type['phys_pct'] = $type['count'] / $overview['count'];
|
||||
$type['econ_pct'] = $type['rents'] / $overview['rents'];
|
||||
}
|
||||
//pr($overview);
|
||||
|
||||
// Enable the Reports menu section
|
||||
$this->sideMenuAreaActivate('REPORT');
|
||||
|
||||
// Prepare to render.
|
||||
$this->set('title', 'Unit Overview');
|
||||
|
||||
Reference in New Issue
Block a user