Compare commits

..

1 Commits

Author SHA1 Message Date
abijah
82a010496d Releasing v0.3.0
git-svn-id: file:///svn-source/pmgr/tags/v0.3.0@999 97e9348a-65ac-dc4b-aefc-98561f571b83
2010-07-02 22:20:55 +00:00
6 changed files with 27 additions and 91 deletions

View File

@@ -278,14 +278,8 @@ class AppController extends Controller {
$this->addSideMenuLink('Unit Summary',
array('controller' => 'units', 'action' => 'overview'), null,
'REPORT');
$this->addSideMenuLink('Monthly Income',
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,
$this->addSideMenuLink('Monthly Charges',
array('controller' => 'statement_entries', 'action' => 'chargesbymonth'), null,
'REPORT');
}
else {
@@ -954,24 +948,13 @@ class AppController extends Controller {
'value' => $params['filtValue']);
}
// Translate a user specified date into the SQL date format
foreach ($searches AS &$search) {
if (preg_match('/(_date|stamp)$/', $search['field']) &&
preg_match('%(\d{1,2})[-/](\d{1,2})[-/](\d{2,4})%', $search['value'], $matches)) {
$search['value'] = sprintf('%04d%02d%02d',
$matches[3] + ($matches[3] < 50 ? 2000 : ($matches[3] < 100 ? 1900 : 0)),
$matches[2], $matches[1]);
}
}
unset($search);
$ops = array('eq' => array('op' => null, 'pre' => '', 'post' => ''),
'ne' => array('op' => '<>', 'pre' => '', 'post' => ''),
'lt' => array('op' => '<', 'pre' => '', 'post' => ''),
'le' => array('op' => '<=', 'pre' => '', 'post' => ''),
'gt' => array('op' => '>', 'pre' => '', 'post' => ''),
'ge' => array('op' => '>=', 'pre' => '', 'post' => ''),
'in' => array('op' => 'IN', 'pre' => '(', 'post' => ')'),
'in' => array('op' => 'IN', 'pre' => '(', 'post' => ')'),
'bw' => array('op' => 'LIKE', 'pre' => '', 'post' => '%'),
'ew' => array('op' => 'LIKE', 'pre' => '%', 'post' => ''),
'cn' => array('op' => 'LIKE', 'pre' => '%', 'post' => '%'),
@@ -1174,7 +1157,7 @@ class AppController extends Controller {
}
function gridDataOutputSummary(&$params, &$model, $pagination) {
if ($params['debug'])
if ($params['debug'])
echo " <params><![CDATA[\n" . print_r($params, true) . "\n]]></params>\n";
echo " <page>{$pagination['page']}</page>\n";
echo " <total>{$pagination['total']}</total>\n";

View File

@@ -260,65 +260,38 @@ class StatementEntriesController extends AppController {
/**************************************************************************
**************************************************************************
**************************************************************************
* action: incexpbymonth
* - Displays income and/or expenses by month
* action: chargesbymonth
* - Displays charges by month
*/
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"'; */
function chargesbymonth($months = 12) {
$result = $this->StatementEntry->find
('all',
array('link' => array('Account' => array('fields' => 'name')),
'fields' => array_merge(array('MONTHNAME(effective_date) AS month',
'YEAR(effective_date) AS year'),
$this->StatementEntry->chargeDisbursementFields(true)),
'conditions' => array('Account.type' => $accts,
"effective_date >= $datefrom",
"effective_date <= $dateto",
'conditions' => array('Account.type' => 'INCOME',
'effective_date >= DATE(NOW() - INTERVAL '.($months-1).' MONTH - INTERVAL DAY(NOW())-1 DAY)',
'effective_date <= NOW()',
),
'group' => array('YEAR(effective_date)', 'MONTH(effective_date)', 'Account.id'),
'order' => array('YEAR(effective_date) DESC', 'MONTH(effective_date) DESC', 'Account.type',
'IF(Account.id = '.$this->StatementEntry->Account->rentAccountID().', "---", Account.name)'),
'order' => array('YEAR(effective_date) DESC', 'MONTH(effective_date) DESC', 'Account.name'),
));
if ($security_deposits) {
$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) {
$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(),
'amount' => 0);
'charges' => 0);
$month = &$overview['months'][$mname];
$month['subs'][] = array('name' => $row['Account']['name'],
'amount' => $row[0]['balance']);
'charges' => $row[0]['balance']);
$month['amount'] += $row[0]['balance'];
$overview['amount'] += $row[0]['balance'];
$month['charges'] += $row[0]['balance'];
$overview['charges'] += $row[0]['balance'];
}
// Enable the Reports menu section
@@ -326,26 +299,8 @@ class StatementEntriesController extends AppController {
// Prepare to render.
$this->set('months', $months);
$this->set('title', 'Monthly Charges');
$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);
}

View File

@@ -330,15 +330,13 @@ class Customer extends AppModel {
}
// Remove any contacts which are already destination customer contacts
$new_contacts = array_diff($contacts, array_keys($dst_contacts));
$all_contacts = array_merge($new_contacts, array_keys($dst_contacts));
$this->pr(17, compact('new_contacts', 'all_contacts'));
$contacts = array_diff($contacts, array_keys($dst_contacts));
// For now, we'll assume the operation will succeed.
$ret = true;
// Add each desired source customer contact to the destination customer
foreach ($new_contacts AS $contact_id) {
foreach ($contacts AS $contact_id) {
$CM = new ContactsCustomer();
if (!$CM->save(array('customer_id' => $dst_id)
+ $src_contacts[$contact_id], false)) {
@@ -374,7 +372,7 @@ class Customer extends AppModel {
$this->delete($src_id);
// Delete all the orphaned customers
foreach (array_diff(array_keys($src_contacts), $all_contacts) AS $contact_id) {
foreach (array_diff(array_keys($src_contacts), $contacts) AS $contact_id) {
// Delete un-used or duplicate contacts
// REVISIT <AP> 20100702:
// Not sure if we really want to do this.

View File

@@ -544,7 +544,7 @@ class Lease extends AppModel {
function conditionDelinquent($table_name = 'Lease') {
if (empty($table_name)) $t = ''; else $t = $table_name . '.';
return ("({$t}close_date IS NULL AND" .
" NOW() > DATE_ADD({$t}paid_through_date, INTERVAL 1 DAY))");
" NOW() > DATE_ADD({$t}paid_through_date, INTERVAL 10 DAY))");
}
function delinquentDaysSQL($table_name = 'Lease') {

View File

@@ -66,7 +66,7 @@ function customerContactDiv($obj, $values = null, $primary = false) {
'</DIV>' . "\n" .
// BEGIN contact-div
'<div id="contact-%{id}-contact-div">' . "\n" .
'<div id="contact-%{id}-contact-div"' . "\n" .
$obj->element
('form_table',

View File

@@ -10,11 +10,11 @@ echo '<div class="statement_entry overview">' . "\n";
*/
$rows = array();
$rows[] = array("$months Month Total", FormatHelper::currency($overview['amount']));
$rows[] = array("$months Month Charges", FormatHelper::currency($overview['charges']));
echo $this->element('table',
array('class' => 'item statement_entry detail',
'caption' => $reptype,
'caption' => 'Monthly Charges',
'rows' => $rows,
'column_class' => array('field', 'value')));
@@ -38,11 +38,11 @@ foreach ($overview['months'] AS $month) {
$odd = 1;
foreach ($month['subs'] AS $sub) {
$row_class[] = array('subitem', $odd ? 'oddrow' : 'evenrow');
$rows[] = array($sub['name'], FormatHelper::currency($sub['amount']));
$rows[] = array($sub['name'], FormatHelper::currency($sub['charges']));
$odd = !$odd;
}
$row_class[] = 'grand';
$rows[] = array('Total for '.$month['name'], FormatHelper::currency($month['amount']));
$rows[] = array('Total for '.$month['name'], FormatHelper::currency($month['charges']));
}
echo $this->element('table',