Compare commits
3 Commits
v0.3_php5.
...
v0.3.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6556b7c9af | ||
|
|
4dffa540a0 | ||
|
|
3d1c4d2492 |
@@ -278,8 +278,14 @@ class AppController extends Controller {
|
|||||||
$this->addSideMenuLink('Unit Summary',
|
$this->addSideMenuLink('Unit Summary',
|
||||||
array('controller' => 'units', 'action' => 'overview'), null,
|
array('controller' => 'units', 'action' => 'overview'), null,
|
||||||
'REPORT');
|
'REPORT');
|
||||||
$this->addSideMenuLink('Monthly Charges',
|
$this->addSideMenuLink('Monthly Income',
|
||||||
array('controller' => 'statement_entries', 'action' => 'chargesbymonth'), null,
|
array('controller' => 'statement_entries', 'action' => 'incomebymonth'), null,
|
||||||
|
'REPORT');
|
||||||
|
$this->addSideMenuLink('Monthly Expenses',
|
||||||
|
array('controller' => 'statement_entries', 'action' => 'expensebymonth'), null,
|
||||||
|
'REPORT');
|
||||||
|
$this->addSideMenuLink('Monthly Net',
|
||||||
|
array('controller' => 'statement_entries', 'action' => 'netbymonth'), null,
|
||||||
'REPORT');
|
'REPORT');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -349,8 +355,8 @@ class AppController extends Controller {
|
|||||||
if ($this->dev() && !$this->Option->enabled('dev'))
|
if ($this->dev() && !$this->Option->enabled('dev'))
|
||||||
$this->redirect("/");
|
$this->redirect("/");
|
||||||
|
|
||||||
if ($this->dev())
|
if (!$this->dev())
|
||||||
Configure::write('debug', 2);
|
Configure::write('debug', '0');
|
||||||
|
|
||||||
$this->addDefaultSideMenuLinks();
|
$this->addDefaultSideMenuLinks();
|
||||||
//$this->sideMenuEnable('SITE', $this->op_area, false);
|
//$this->sideMenuEnable('SITE', $this->op_area, false);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
* In production mode, flash messages redirect after a time interval.
|
* In production mode, flash messages redirect after a time interval.
|
||||||
* In development mode, you need to click the flash message to continue.
|
* In development mode, you need to click the flash message to continue.
|
||||||
*/
|
*/
|
||||||
Configure::write('debug', 0);
|
Configure::write('debug', 2);
|
||||||
/**
|
/**
|
||||||
* Application wide charset encoding
|
* Application wide charset encoding
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -260,38 +260,65 @@ class StatementEntriesController extends AppController {
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* action: chargesbymonth
|
* action: incexpbymonth
|
||||||
* - Displays charges by month
|
* - Displays income and/or expenses by month
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function chargesbymonth($months = 12) {
|
function incexpbymonth($accts, $security_deposits, $months) {
|
||||||
|
$datefrom = 'DATE(NOW() - INTERVAL '.($months-1).' MONTH - INTERVAL DAY(NOW())-1 DAY)';
|
||||||
|
$dateto = 'NOW()';
|
||||||
|
/* $datefrom = '"2009-01-01"'; */
|
||||||
|
/* $dateto = '"2011-12-31"'; */
|
||||||
|
|
||||||
$result = $this->StatementEntry->find
|
$result = $this->StatementEntry->find
|
||||||
('all',
|
('all',
|
||||||
array('link' => array('Account' => array('fields' => 'name')),
|
array('link' => array('Account' => array('fields' => 'name')),
|
||||||
'fields' => array_merge(array('MONTHNAME(effective_date) AS month',
|
'fields' => array_merge(array('MONTHNAME(effective_date) AS month',
|
||||||
'YEAR(effective_date) AS year'),
|
'YEAR(effective_date) AS year'),
|
||||||
$this->StatementEntry->chargeDisbursementFields(true)),
|
$this->StatementEntry->chargeDisbursementFields(true)),
|
||||||
'conditions' => array('Account.type' => 'INCOME',
|
'conditions' => array('Account.type' => $accts,
|
||||||
'effective_date >= DATE(NOW() - INTERVAL '.($months-1).' MONTH - INTERVAL DAY(NOW())-1 DAY)',
|
"effective_date >= $datefrom",
|
||||||
'effective_date <= NOW()',
|
"effective_date <= $dateto",
|
||||||
),
|
),
|
||||||
'group' => array('YEAR(effective_date)', 'MONTH(effective_date)', 'Account.id'),
|
'group' => array('YEAR(effective_date)', 'MONTH(effective_date)', 'Account.id'),
|
||||||
'order' => array('YEAR(effective_date) DESC', 'MONTH(effective_date) DESC', 'Account.name'),
|
'order' => array('YEAR(effective_date) DESC', 'MONTH(effective_date) DESC', 'Account.type',
|
||||||
|
'IF(Account.id = '.$this->StatementEntry->Account->rentAccountID().', "---", Account.name)'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$overview = array('months' => array(), 'charges' => 0);
|
if ($security_deposits) {
|
||||||
foreach ($result AS $row) {
|
$sdresult = $this->StatementEntry->Transaction->LedgerEntry->find
|
||||||
|
('all',
|
||||||
|
array('link' => array('Transaction' => array('StatementEntry' => array('fields' => 'effective_date'),
|
||||||
|
'fields' => array()),
|
||||||
|
'Account' => array('fields' => 'name')),
|
||||||
|
'fields' => array_merge(array('MONTHNAME(effective_date) AS month',
|
||||||
|
'YEAR(effective_date) AS year'),
|
||||||
|
$this->StatementEntry->Transaction->LedgerEntry->debitCreditFields(true)),
|
||||||
|
'conditions' => array('LedgerEntry.account_id' => $this->StatementEntry->Account->securityDepositAccountID(),
|
||||||
|
"effective_date >= $datefrom",
|
||||||
|
"effective_date <= $dateto",
|
||||||
|
'StatementEntry.id = (SELECT MIN(id) FROM pmgr_statement_entries WHERE transaction_id = `Transaction`.id)'
|
||||||
|
),
|
||||||
|
'group' => array('YEAR(effective_date)', 'MONTH(effective_date)', 'Account.id'),
|
||||||
|
'order' => array('YEAR(effective_date) DESC', 'MONTH(effective_date) DESC', 'Account.type', 'Account.name'),
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
$sdresult = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$overview = array('months' => array(), 'amount' => 0);
|
||||||
|
foreach (array_merge($result, $sdresult) AS $row) {
|
||||||
$mname = $row[0]['month'] .', '. $row[0]['year'];
|
$mname = $row[0]['month'] .', '. $row[0]['year'];
|
||||||
if (empty($overview['months'][$mname]))
|
if (empty($overview['months'][$mname]))
|
||||||
$overview['months'][$mname] = array('name' => $mname,
|
$overview['months'][$mname] = array('name' => $mname,
|
||||||
'subs' => array(),
|
'subs' => array(),
|
||||||
'charges' => 0);
|
'amount' => 0);
|
||||||
$month = &$overview['months'][$mname];
|
$month = &$overview['months'][$mname];
|
||||||
$month['subs'][] = array('name' => $row['Account']['name'],
|
$month['subs'][] = array('name' => $row['Account']['name'],
|
||||||
'charges' => $row[0]['balance']);
|
'amount' => $row[0]['balance']);
|
||||||
|
|
||||||
$month['charges'] += $row[0]['balance'];
|
$month['amount'] += $row[0]['balance'];
|
||||||
$overview['charges'] += $row[0]['balance'];
|
$overview['amount'] += $row[0]['balance'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable the Reports menu section
|
// Enable the Reports menu section
|
||||||
@@ -299,8 +326,26 @@ class StatementEntriesController extends AppController {
|
|||||||
|
|
||||||
// Prepare to render.
|
// Prepare to render.
|
||||||
$this->set('months', $months);
|
$this->set('months', $months);
|
||||||
$this->set('title', 'Monthly Charges');
|
|
||||||
$this->set(compact('overview'));
|
$this->set(compact('overview'));
|
||||||
|
$this->render('chargesbymonth');
|
||||||
|
}
|
||||||
|
|
||||||
|
function incomebymonth($months = 12) {
|
||||||
|
$this->set('title', 'Monthly Gross Income');
|
||||||
|
$this->set('reptype', 'Gross Income');
|
||||||
|
$this->incexpbymonth(array('INCOME'), true, $months);
|
||||||
|
}
|
||||||
|
|
||||||
|
function expensebymonth($months = 12) {
|
||||||
|
$this->set('title', 'Gross Monthly Expenses');
|
||||||
|
$this->set('reptype', 'Gross Expenses');
|
||||||
|
$this->incexpbymonth(array('EXPENSE'), false, $months);
|
||||||
|
}
|
||||||
|
|
||||||
|
function netbymonth($months = 12) {
|
||||||
|
$this->set('title', 'Net Monthly Income');
|
||||||
|
$this->set('reptype', 'Net Income');
|
||||||
|
$this->incexpbymonth(array('INCOME', 'EXPENSE'), true, $months);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ class ToolbarComponent extends Object {
|
|||||||
trigger_error(sprintf(__('Could not load DebugToolbar panel %s', true), $panel), E_USER_WARNING);
|
trigger_error(sprintf(__('Could not load DebugToolbar panel %s', true), $panel), E_USER_WARNING);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$panelObj = new $className();
|
$panelObj =& new $className();
|
||||||
if (is_subclass_of($panelObj, 'DebugPanel') || is_subclass_of($panelObj, 'debugpanel')) {
|
if (is_subclass_of($panelObj, 'DebugPanel') || is_subclass_of($panelObj, 'debugpanel')) {
|
||||||
$this->panels[$panel] =& $panelObj;
|
$this->panels[$panel] =& $panelObj;
|
||||||
}
|
}
|
||||||
@@ -456,7 +456,7 @@ class LogPanel extends DebugPanel {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _parseFile($filename) {
|
function _parseFile($filename) {
|
||||||
$file = new File($filename);
|
$file =& new File($filename);
|
||||||
$contents = $file->read();
|
$contents = $file->read();
|
||||||
$timePattern = '/(\d{4}-\d{2}\-\d{2}\s\d{1,2}\:\d{1,2}\:\d{1,2})/';
|
$timePattern = '/(\d{4}-\d{2}\-\d{2}\s\d{1,2}\:\d{1,2}\:\d{1,2})/';
|
||||||
$chunks = preg_split($timePattern, $contents, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
|
$chunks = preg_split($timePattern, $contents, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class DebugViewTestCase extends CakeTestCase {
|
|||||||
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
|
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
|
||||||
Router::parse('/');
|
Router::parse('/');
|
||||||
$this->Controller =& ClassRegistry::init('Controller');
|
$this->Controller =& ClassRegistry::init('Controller');
|
||||||
$this->View = new DebugView($this->Controller, false);
|
$this->View =& new DebugView($this->Controller, false);
|
||||||
$this->_debug = Configure::read('debug');
|
$this->_debug = Configure::read('debug');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ class DebugViewTestCase extends CakeTestCase {
|
|||||||
'here' => '/posts/index',
|
'here' => '/posts/index',
|
||||||
);
|
);
|
||||||
$this->Controller->layout = 'default';
|
$this->Controller->layout = 'default';
|
||||||
$View = new DebugView($this->Controller, false);
|
$View =& new DebugView($this->Controller, false);
|
||||||
$View->render('index');
|
$View->render('index');
|
||||||
|
|
||||||
$result = DebugKitDebugger::getTimers();
|
$result = DebugKitDebugger::getTimers();
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ class FirePhpToolbarHelperTestCase extends CakeTestCase {
|
|||||||
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
|
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
|
||||||
Router::parse('/');
|
Router::parse('/');
|
||||||
|
|
||||||
$this->Toolbar = new ToolbarHelper(array('output' => 'DebugKit.FirePhpToolbar'));
|
$this->Toolbar =& new ToolbarHelper(array('output' => 'DebugKit.FirePhpToolbar'));
|
||||||
$this->Toolbar->FirePhpToolbar = new FirePhpToolbarHelper();
|
$this->Toolbar->FirePhpToolbar =& new FirePhpToolbarHelper();
|
||||||
|
|
||||||
$this->Controller =& ClassRegistry::init('Controller');
|
$this->Controller =& ClassRegistry::init('Controller');
|
||||||
if (isset($this->_debug)) {
|
if (isset($this->_debug)) {
|
||||||
|
|||||||
@@ -38,10 +38,10 @@ class HtmlToolbarHelperTestCase extends CakeTestCase {
|
|||||||
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
|
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
|
||||||
Router::parse('/');
|
Router::parse('/');
|
||||||
|
|
||||||
$this->Toolbar = new ToolbarHelper(array('output' => 'DebugKit.HtmlToolbar'));
|
$this->Toolbar =& new ToolbarHelper(array('output' => 'DebugKit.HtmlToolbar'));
|
||||||
$this->Toolbar->HtmlToolbar = new HtmlToolbarHelper();
|
$this->Toolbar->HtmlToolbar =& new HtmlToolbarHelper();
|
||||||
$this->Toolbar->HtmlToolbar->Html = new HtmlHelper();
|
$this->Toolbar->HtmlToolbar->Html =& new HtmlHelper();
|
||||||
$this->Toolbar->HtmlToolbar->Javascript = new JavascriptHelper();
|
$this->Toolbar->HtmlToolbar->Javascript =& new JavascriptHelper();
|
||||||
|
|
||||||
$this->Controller =& ClassRegistry::init('Controller');
|
$this->Controller =& ClassRegistry::init('Controller');
|
||||||
if (isset($this->_debug)) {
|
if (isset($this->_debug)) {
|
||||||
|
|||||||
@@ -30,14 +30,14 @@ $timers = DebugKitDebugger::getTimers();
|
|||||||
?>
|
?>
|
||||||
<h2><?php __('Timers'); ?></h2>
|
<h2><?php __('Timers'); ?></h2>
|
||||||
<p class="request-time">
|
<p class="request-time">
|
||||||
<?php $totalTime = sprintf(__('%s (seconds)', true), DebugKitDebugger::requestTime()); ?>
|
<?php $totalTime = sprintf(__('%s (seconds)', true), $number->precision(DebugKitDebugger::requestTime(), 6)); ?>
|
||||||
<?php echo $toolbar->message(__('Total Request Time:', true), $totalTime)?>
|
<?php echo $toolbar->message(__('Total Request Time:', true), $totalTime)?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<?php foreach ($timers as $timerName => $timeInfo):
|
<?php foreach ($timers as $timerName => $timeInfo):
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
$timeInfo['message'],
|
$timeInfo['message'],
|
||||||
$timeInfo['time']
|
$number->precision($timeInfo['time'], 6)
|
||||||
);
|
);
|
||||||
$headers = array(__('Message', true), __('time in seconds', true));
|
$headers = array(__('Message', true), __('time in seconds', true));
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ function customerContactDiv($obj, $values = null, $primary = false) {
|
|||||||
'</DIV>' . "\n" .
|
'</DIV>' . "\n" .
|
||||||
|
|
||||||
// BEGIN contact-div
|
// BEGIN contact-div
|
||||||
'<div id="contact-%{id}-contact-div"' . "\n" .
|
'<div id="contact-%{id}-contact-div">' . "\n" .
|
||||||
|
|
||||||
$obj->element
|
$obj->element
|
||||||
('form_table',
|
('form_table',
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ echo '<div class="statement_entry overview">' . "\n";
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
$rows[] = array("$months Month Charges", FormatHelper::currency($overview['charges']));
|
$rows[] = array("$months Month Total", FormatHelper::currency($overview['amount']));
|
||||||
|
|
||||||
echo $this->element('table',
|
echo $this->element('table',
|
||||||
array('class' => 'item statement_entry detail',
|
array('class' => 'item statement_entry detail',
|
||||||
'caption' => 'Monthly Charges',
|
'caption' => $reptype,
|
||||||
'rows' => $rows,
|
'rows' => $rows,
|
||||||
'column_class' => array('field', 'value')));
|
'column_class' => array('field', 'value')));
|
||||||
|
|
||||||
@@ -38,11 +38,11 @@ foreach ($overview['months'] AS $month) {
|
|||||||
$odd = 1;
|
$odd = 1;
|
||||||
foreach ($month['subs'] AS $sub) {
|
foreach ($month['subs'] AS $sub) {
|
||||||
$row_class[] = array('subitem', $odd ? 'oddrow' : 'evenrow');
|
$row_class[] = array('subitem', $odd ? 'oddrow' : 'evenrow');
|
||||||
$rows[] = array($sub['name'], FormatHelper::currency($sub['charges']));
|
$rows[] = array($sub['name'], FormatHelper::currency($sub['amount']));
|
||||||
$odd = !$odd;
|
$odd = !$odd;
|
||||||
}
|
}
|
||||||
$row_class[] = 'grand';
|
$row_class[] = 'grand';
|
||||||
$rows[] = array('Total for '.$month['name'], FormatHelper::currency($month['charges']));
|
$rows[] = array('Total for '.$month['name'], FormatHelper::currency($month['amount']));
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $this->element('table',
|
echo $this->element('table',
|
||||||
|
|||||||
Reference in New Issue
Block a user