Significant changes to work with the new account/ledger structure. Removed much of the auto-generated model association code. Added helper functions into the models to perform model related work, such as model 'stats' (a bad name for a function to return a summary of pertinent financial information from a given model instance). There is a ton of cleanup to do, but first I want to get it all captured.
git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@81 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -78,6 +78,39 @@ class AppModel extends Model {
|
||||
} //end getEnumValues
|
||||
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* function: statMerge
|
||||
* - Merges summary data from $b into $a
|
||||
*/
|
||||
|
||||
function statsMerge (&$a, $b) {
|
||||
if (!isset($b))
|
||||
return;
|
||||
|
||||
if (!isset($a)) {
|
||||
$a = $b;
|
||||
}
|
||||
elseif (!is_array($a) && !is_array($b)) {
|
||||
$a += $b;
|
||||
}
|
||||
elseif (is_array($a) && is_array($b)) {
|
||||
foreach (array_intersect_key($a, $b) AS $k => $v)
|
||||
{
|
||||
if (preg_match("/^sp\./", $k))
|
||||
$a[$k] .= '; ' . $b[$k];
|
||||
else
|
||||
$this->statsMerge($a[$k], $b[$k]);
|
||||
}
|
||||
$a = array_merge($a, array_diff_key($b, $a));
|
||||
}
|
||||
else {
|
||||
die ("Can't yet merge array and non-array stats");
|
||||
}
|
||||
}
|
||||
|
||||
// Overriding pagination, since the stupid count mechanism blows.
|
||||
// This is also a crappy solution, especially if the query returns
|
||||
// a really large number of rows. However, trying to untagle this
|
||||
|
||||
Reference in New Issue
Block a user