Added a lease up report
git-svn-id: file:///svn-source/pmgr/branches/v0.3_work/site@960 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -440,6 +440,64 @@ class LeasesController extends AppController {
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* action: overview
|
||||
* - Displays lease up information
|
||||
*/
|
||||
function overview() {
|
||||
|
||||
$overview = array('months' => array());
|
||||
|
||||
for ($month = 0; $month < 12; ++$month) {
|
||||
//for ($month = 12; $month >= 0; --$month) {
|
||||
$this_month = "(DATE(NOW() - INTERVAL $month MONTH - INTERVAL DAY(NOW())-1 DAY))";
|
||||
$next_month = "($this_month + INTERVAL 1 MONTH)";
|
||||
|
||||
$row = $this->Lease->find
|
||||
('first', array('link' => array(),
|
||||
'fields' => array("MONTHNAME($this_month) AS month",
|
||||
"YEAR($this_month) AS year"),
|
||||
));
|
||||
|
||||
$mname = $row[0]['month'] .', '. $row[0]['year'];
|
||||
$overview['months'][$mname] = array('name' => $mname);
|
||||
|
||||
foreach(array('start' => array('before' => $this_month, 'after' => $this_month),
|
||||
'finish' => array('before' => $next_month, 'after' => $next_month),
|
||||
'peak' => array('before' => $next_month, 'after' => $this_month))
|
||||
AS $type => $parm) {
|
||||
$count = $this->Lease->find
|
||||
('count',
|
||||
array('link' => array(),
|
||||
'conditions' => array("movein_date < {$parm['before']}",
|
||||
"(moveout_date IS NULL OR moveout_date >= {$parm['after']})",
|
||||
),
|
||||
));
|
||||
$overview['months'][$mname][$type] = $count;
|
||||
}
|
||||
|
||||
foreach(array('movein', 'moveout') AS $mvinout) {
|
||||
$count = $this->Lease->find
|
||||
('count',
|
||||
array('link' => array(),
|
||||
'conditions' => array("{$mvinout}_date < $next_month",
|
||||
"{$mvinout}_date >= $this_month")
|
||||
));
|
||||
$overview['months'][$mname][$mvinout] = $count;
|
||||
}
|
||||
}
|
||||
|
||||
// Enable the Reports menu section
|
||||
$this->sideMenuAreaActivate('REPORT');
|
||||
|
||||
// Prepare to render.
|
||||
$this->set('title', 'Lease Up Report');
|
||||
$this->set(compact('overview'));
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user