! -> Note
$ -> Affected files
+26-May-2009 Joe Hunt
+# Again fixed nested subtypes in account types correctly in COA, Monthly Breakdown, Balance Sheet and P&L Statement
+$ /gl/includes/db/gl_db_accounts.inc
+ /gl/includes/db/gl_db_account_types.inc
+ /reporting/rep701.php
+ /reporting/rep705.php
+ /reporting/rep706.php
+ /reporting/rep707.php
+# fixed wider combobox for backup-files in company backup
+$ /admin/backups.php
+
25-May-2009 Joe Hunt
# Fixed Supplier Credit so Purchase Order Outstanding is decreased too.
$ /purchasing/includes/db/grn_db.inc
# Fixed so nested subtypes in account types are nested correctly in Balance Sheet and P&L Statement
$ /gl/includes/db/gl_db_accounts.inc
-$ /reporting/rep706.php
-$ /reporting/rep707.php
+ /reporting/rep706.php
+ /reporting/rep707.php
! Extra column in Stock Check Sheet, On Order and option for selecting Only Shortage.
$ /reporting/rep303.php
/reporting/reports_main.php
if (preg_match("/.sql(.zip|.gz)?$/", $file))
$opt_files .= "<option value='$file'>$file</option>";
- $selector = "<select name='cmb_backups' size=2 style='height:160px;width:230px'>$opt_files</select>";
+ $selector = "<select name='cmb_backups' size=2 style='height:160px;min-width:230px'>$opt_files</select>";
$Ajax->addUpdate('cmd_backups', "_cmd_backups_sel", $selector);
$selector = "<span id='_cmd_backups_sel'>".$selector."</span>\n";
}
+function get_account_types_all($balance=-1)
+{
+ $sql = "SELECT ".TB_PREF."chart_types.name AS AccountTypeName,".TB_PREF."chart_types.parent,".TB_PREF."chart_types.id AS AccountType,
+ ".TB_PREF."chart_class.class_name AS AccountClassName
+ FROM ".TB_PREF."chart_types, ".TB_PREF."chart_class
+ WHERE ".TB_PREF."chart_types.class_id=".TB_PREF."chart_class.cid";
+ if ($balance != -1)
+ $sql .= " AND ".TB_PREF."chart_class.balance_sheet=$balance";
+ $sql .= " ORDER BY ".TB_PREF."chart_class.cid, IF(parent > -1,parent,".TB_PREF."chart_types.id), parent";
+
+ return db_query($sql, "could not get gl types");
+}
+
function delete_account_type($id)
{
$sql = "DELETE FROM ".TB_PREF."chart_types WHERE id = $id";
return db_query($sql, "could not get gl accounts");
}
-function get_gl_accounts_all($balance=-1)
+function get_gl_accounts_in_type($type)
{
- $sql = "SELECT ".TB_PREF."chart_master.*,".TB_PREF."chart_types.name AS AccountTypeName,".TB_PREF."chart_types.parent,
- ".TB_PREF."chart_class.class_name AS AccountClassName
- FROM ".TB_PREF."chart_master,".TB_PREF."chart_types, ".TB_PREF."chart_class
- WHERE ".TB_PREF."chart_master.account_type=".TB_PREF."chart_types.id AND
- ".TB_PREF."chart_types.class_id=".TB_PREF."chart_class.cid";
- if ($balance != -1)
- $sql .= " AND ".TB_PREF."chart_class.balance_sheet=$balance";
- $sql .= " ORDER BY ".TB_PREF."chart_class.cid, ".TB_PREF."chart_types.id, ".TB_PREF."chart_master.account_code";
+ $sql = "SELECT * FROM ".TB_PREF."chart_master WHERE account_type=$type ORDER BY account_code";
return db_query($sql, "could not get gl accounts");
}
+function num_accounts_in_type($type, $parent)
+{
+ $sql = "SELECT COUNT(*) FROM ".TB_PREF."chart_master WHERE account_type=$type OR account_type=$parent";
+
+ $result = db_query($sql, "could not get gl accounts");
+ $row = db_fetch_row($result);
+ return $row[0];
+}
+
function get_gl_account($code)
{
$sql = "SELECT * FROM ".TB_PREF."chart_master WHERE account_code='$code'";
$classname = '';
$group = '';
- $accounts = get_gl_accounts_all();
+ $types = get_account_types_all();
- while ($account=db_fetch($accounts))
+ while ($type=db_fetch($types))
{
- if ($showbalance == 1)
- {
- $begin = begin_fiscalyear();
- if (is_account_balancesheet($account["account_code"]))
- $begin = "";
- $balance = get_gl_trans_from_to($begin, ToDay(), $account["account_code"], 0);
- }
- if ($account['AccountTypeName'] != $group)
+ if (!num_accounts_in_type($type['AccountType'], $type['parent']))
+ continue;
+ if ($type['AccountTypeName'] != $group)
{
if ($classname != '')
$rep->row -= 4;
- if ($account['AccountClassName'] != $classname)
+ if ($type['AccountClassName'] != $classname)
{
$rep->Font('bold');
- $rep->TextCol(0, 4, $account['AccountClassName']);
+ $rep->TextCol(0, 4, $type['AccountClassName']);
$rep->Font();
//$rep->row -= ($rep->lineHeight + 4);
$rep->NewLine();
}
- $group = $account['AccountTypeName'];
- $rep->TextCol(0, 4, $account['AccountTypeName']);
+ $group = $type['AccountTypeName'];
+ $rep->TextCol(0, 4, $type['AccountTypeName']);
//$rep->Line($rep->row - 4);
//$rep->row -= ($rep->lineHeight + 4);
$rep->NewLine();
}
- $classname = $account['AccountClassName'];
-
- $rep->TextCol(0, 1, $account['account_code']);
- $rep->TextCol(1, 2, $account['account_name']);
- $rep->TextCol(2, 3, $account['account_code2']);
- if ($showbalance == 1)
- $rep->AmountCol(3, 4, $balance, $dec);
-
- $rep->NewLine();
- if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight)
+ $classname = $type['AccountClassName'];
+
+ $accounts = get_gl_accounts_in_type($type['AccountType']);
+ while ($account=db_fetch($accounts))
{
- $rep->Line($rep->row - 2);
- $rep->Header();
- }
+ if ($showbalance == 1)
+ {
+ $begin = begin_fiscalyear();
+ if (is_account_balancesheet($account["account_code"]))
+ $begin = "";
+ $balance = get_gl_trans_from_to($begin, ToDay(), $account["account_code"], 0);
+ }
+ $rep->TextCol(0, 1, $account['account_code']);
+ $rep->TextCol(1, 2, $account['account_name']);
+ $rep->TextCol(2, 3, $account['account_code2']);
+ if ($showbalance == 1)
+ $rep->AmountCol(3, 4, $balance, $dec);
+
+ $rep->NewLine();
+ if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight)
+ {
+ $rep->Line($rep->row - 2);
+ $rep->Header();
+ }
+ }
}
$rep->Line($rep->row);
$rep->End();
$rep->Header();
$classname = '';
- $group = '';
- $total = Array(1 => 0,0,0,0,0,0,0,0,0,0,0,0);
+ $total = Array(
+ 0 => Array(1 => 0,0,0,0,0,0,0,0,0,0,0,0),
+ Array(1 => 0,0,0,0,0,0,0,0,0,0,0,0),
+ Array(1 => 0,0,0,0,0,0,0,0,0,0,0,0),
+ Array(1 => 0,0,0,0,0,0,0,0,0,0,0,0),
+ Array(1 => 0,0,0,0,0,0,0,0,0,0,0,0),
+ Array(1 => 0,0,0,0,0,0,0,0,0,0,0,0),
+ Array(1 => 0,0,0,0,0,0,0,0,0,0,0,0),
+ Array(1 => 0,0,0,0,0,0,0,0,0,0,0,0),
+ Array(1 => 0,0,0,0,0,0,0,0,0,0,0,0),
+ Array(1 => 0,0,0,0,0,0,0,0,0,0,0,0));
$total2 = Array(1 => 0,0,0,0,0,0,0,0,0,0,0,0);
$sales = Array(1 => 0,0,0,0,0,0,0,0,0,0,0,0);
$calc = Array(1 => 0,0,0,0,0,0,0,0,0,0,0,0);
- $accounts = get_gl_accounts_all(0);
+ $typename = array('','','','','','','','','','');
+ $closing = array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1);
+ $level = 0;
+ $last = -1;
- while ($account = db_fetch($accounts))
+ $types = get_account_types_all(0);
+
+ while ($type = db_fetch($types))
{
- $bal = getPeriods($year, $account["account_code"], $dimension, $dimension2);
- if (!$bal['per01'] && !$bal['per02'] && !$bal['per03'] && !$bal['per04'] &&
- !$bal['per05'] && !$bal['per06'] && !$bal['per07'] && !$bal['per08'] &&
- !$bal['per09'] && !$bal['per10'] && !$bal['per11'] && !$bal['per12'])
+ if (!num_accounts_in_type($type['AccountType'], $type['parent']))
continue;
- $balance = array(1 => $bal['per01'], $bal['per02'], $bal['per03'], $bal['per04'],
- $bal['per05'], $bal['per06'], $bal['per07'], $bal['per08'],
- $bal['per09'], $bal['per10'], $bal['per11'], $bal['per12']);
- if ($account['AccountClassName'] != $classname)
+ if ($type['AccountClassName'] != $classname)
{
if ($classname != '')
{
}
}
- if ($account['AccountTypeName'] != $group)
+ if ($type['AccountTypeName'] != $typename[$level])
{
- if ($group != '')
+ if ($typename[$level] != '')
{
- $rep->row += 6;
- $rep->Line($rep->row);
- $rep->NewLine();
- $rep->TextCol(0, 2, _('Total') . " " . $group);
- for ($i = 1; $i <= 12; $i++)
- $rep->AmountCol($i + 1, $i + 2, $total[$i], $dec);
- $total = Array(1 => 0,0,0,0,0,0,0,0,0,0,0,0);
- $rep->NewLine();
+ for ( ; $level >= 0, $typename[$level] != ''; $level--)
+ {
+ if ($type['parent'] == $closing[$level] || $type['parent'] == $last || $type['parent'] <= 0)
+ {
+ $rep->row += 6;
+ $rep->Line($rep->row);
+ $rep->NewLine();
+ $rep->TextCol(0, 2, _('Total') . " " . $typename[$level]);
+ for ($i = 1; $i <= 12; $i++)
+ {
+ $rep->AmountCol($i + 1, $i + 2, $total[$level][$i], $dec);
+ $total[$level][$i] = 0.0;
+ }
+ }
+ else
+ break;
+ $rep->NewLine();
+ }
if ($closeclass)
{
$rep->row += 6;
$closeclass = false;
}
}
- if ($account['AccountClassName'] != $classname)
+ if ($type['AccountClassName'] != $classname)
{
$rep->Font('bold');
- $rep->TextCol(0, 5, $account['AccountClassName']);
+ $rep->TextCol(0, 5, $type['AccountClassName']);
$rep->Font();
$rep->NewLine();
}
- $group = $account['AccountTypeName'];
+ $level++;
+ if ($type['parent'] != $last)
+ $last = $type['parent'];
+ $typename[$level] = $type['AccountTypeName'];
+ $closing[$level] = $type['parent'];
$rep->row -= 4;
- $rep->TextCol(0, 5, $account['AccountTypeName']);
+ $rep->TextCol(0, 5, $type['AccountTypeName']);
$rep->row -= 4;
$rep->Line($rep->row);
$rep->NewLine();
}
- $classname = $account['AccountClassName'];
- $rep->TextCol(0, 1, $account['account_code']);
- $rep->TextCol(1, 2, $account['account_name']);
- for ($i = 1; $i <= 12; $i++)
+ $classname = $type['AccountClassName'];
+
+ $accounts = get_gl_accounts_in_type($type['AccountType']);
+ while ($account=db_fetch($accounts))
{
- $rep->AmountCol($i + 1, $i + 2, $balance[$i], $dec);
- $total[$i] += $balance[$i];
- $total2[$i] += $balance[$i];
- }
+ $bal = getPeriods($year, $account["account_code"], $dimension, $dimension2);
+ if (!$bal['per01'] && !$bal['per02'] && !$bal['per03'] && !$bal['per04'] &&
+ !$bal['per05'] && !$bal['per06'] && !$bal['per07'] && !$bal['per08'] &&
+ !$bal['per09'] && !$bal['per10'] && !$bal['per11'] && !$bal['per12'])
+ continue;
+ $balance = array(1 => $bal['per01'], $bal['per02'], $bal['per03'], $bal['per04'],
+ $bal['per05'], $bal['per06'], $bal['per07'], $bal['per08'],
+ $bal['per09'], $bal['per10'], $bal['per11'], $bal['per12']);
+ $rep->TextCol(0, 1, $account['account_code']);
+ $rep->TextCol(1, 2, $account['account_name']);
- $rep->NewLine();
+ for ($i = 1; $i <= 12; $i++)
+ {
+ $rep->AmountCol($i + 1, $i + 2, $balance[$i], $dec);
+ $total2[$i] += $balance[$i];
+ }
+ for ($j = 0; $j <= $level; $j++)
+ {
+ for ($i = 1; $i <= 12; $i++)
+ $total[$j][$i] += $balance[$i];
+ }
+ $rep->NewLine();
- if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight)
- {
- $rep->Line($rep->row - 2);
- $rep->Header();
- }
+ if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight)
+ {
+ $rep->Line($rep->row - 2);
+ $rep->Header();
+ }
+ }
}
- if ($account['AccountClassName'] != $classname)
+ if ($type['AccountClassName'] != $classname)
{
if ($classname != '')
{
$closeclass = true;
}
}
- if ($account['AccountTypeName'] != $group)
+ if ($type['AccountTypeName'] != $typename[$level])
{
- if ($group != '')
+ if ($typename[$level] != '')
{
- $rep->row += 6;
- $rep->Line($rep->row);
- $rep->NewLine();
- $rep->TextCol(0, 2, _('Total') . " " . $group);
- for ($i = 1; $i <= 12; $i++)
- $rep->AmountCol($i + 1, $i + 2, $total[$i], $dec);
- $rep->NewLine();
+ for ( ; $level >= 0, $typename[$level] != ''; $level--)
+ {
+ if ($type['parent'] == $closing[$level] || $type['parent'] == $last || $type['parent'] <= 0)
+ {
+ $rep->row += 6;
+ $rep->Line($rep->row);
+ $rep->NewLine();
+ $rep->TextCol(0, 2, _('Total') . " " . $typename[$level]);
+ for ($i = 1; $i <= 12; $i++)
+ {
+ $rep->AmountCol($i + 1, $i + 2, $total[$level][$i], $dec);
+ $total[$level][$i] = 0.0;
+ }
+ }
+ else
+ break;
+ $rep->NewLine();
+ }
if ($closeclass)
{
$rep->row += 6;
$typeperiod = array(0,0,0,0,0,0,0,0,0,0);
$typeclose = array(0,0,0,0,0,0,0,0,0,0);
$typename = array('','','','','','','','','','');
- $parent = array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1);
+ $closing = array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1);
$level = 0;
+ $last = -1;
$closeclass = false;
$rep->NewLine();
- $accounts = get_gl_accounts_all(1);
+ $types = get_account_types_all(1);
- while ($account=db_fetch($accounts))
+ while ($type=db_fetch($types))
{
- $prev_balance = get_gl_balance_from_to("", $from, $account["account_code"], $dimension, $dimension2);
-
- $curr_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2);
-
- if (!$prev_balance && !$curr_balance)
+ if (!num_accounts_in_type($type['AccountType'], $type['parent']))
continue;
-
- if ($account['AccountClassName'] != $classname)
+ if ($type['AccountClassName'] != $classname)
{
if ($classname != '')
{
}
}
- if ($account['AccountTypeName'] != $typename[$level])
+ if ($type['AccountTypeName'] != $typename[$level])
{
- if ($typename[$level] != '' && $account['parent'] == -1)
+ //$rep->NewLine();
+ //$rep->TextCol(0, 5, "level = $level, closing[level] = ".$closing[$level].", type[parent] = ".$type['parent']." last = ".$last);
+ //$rep->NewLine();
+ if ($typename[$level] != '')
{
- for ( ; $level >= 0; $level--)
+ for ( ; $level >= 0, $typename[$level] != ''; $level--)
{
- $rep->row += 6;
- $rep->Line($rep->row);
- $rep->NewLine();
- $rep->TextCol(0, 2, _('Total') . " " . $typename[$level]);
- $rep->AmountCol(2, 3, $typeopen[$level], $dec);
- $rep->AmountCol(3, 4, $typeperiod[$level], $dec);
- $rep->AmountCol(4, 5, $typeclose[$level], $dec);
- $typeopen[$level] = $typeperiod[$level] = $typeclose[$level] = 0.0;
- if ($parent[$level] == -1)
+ if ($type['parent'] == $closing[$level] || $type['parent'] == $last || $type['parent'] <= 0)
+ {
+ $rep->row += 6;
+ $rep->Line($rep->row);
+ $rep->NewLine();
+ $rep->TextCol(0, 2, _('Total') . " " . $typename[$level]);
+ $rep->AmountCol(2, 3, $typeopen[$level], $dec);
+ $rep->AmountCol(3, 4, $typeperiod[$level], $dec);
+ $rep->AmountCol(4, 5, $typeclose[$level], $dec);
+ if ($graphics)
+ {
+ $pg->x[] = $$typename[$level];
+ $pg->y[] = abs($typeclose[$level]);
+ }
+ $typeopen[$level] = $typeperiod[$level] = $typeclose[$level] = 0.0;
+ }
+ else
break;
$rep->NewLine();
}
- if ($graphics)
- {
- $pg->x[] = $$typename[$level];
- $pg->y[] = abs($typeclose[$level]);
- }
- $rep->NewLine();
+ //$rep->NewLine();
if ($closeclass)
{
$rep->row += 6;
$closeclass = false;
}
}
- if ($account['AccountClassName'] != $classname)
+ if ($type['AccountClassName'] != $classname)
{
$rep->Font('bold');
- $rep->TextCol(0, 5, $account['AccountClassName']);
+ $rep->TextCol(0, 5, $type['AccountClassName']);
$rep->Font();
$rep->NewLine();
}
- if ($account['parent'] != -1 && $account['parent'] != $parent[$level])
- $level++;
- $typename[$level] = $account['AccountTypeName'];
+ $level++;
+ if ($type['parent'] != $last)
+ $last = $type['parent'];
+ $typename[$level] = $type['AccountTypeName'];
+ $closing[$level] = $type['parent'];
$rep->row -= 4;
- $rep->TextCol(0, 5, $account['AccountTypeName']);
+ $rep->TextCol(0, 5, $type['AccountTypeName']);
$rep->row -= 4;
$rep->Line($rep->row);
$rep->NewLine();
}
- $classname = $account['AccountClassName'];
- $parent[$level] = $account['parent'];
+ $classname = $type['AccountClassName'];
- for ($i = 0; $i <= $level; $i++)
+ $accounts = get_gl_accounts_in_type($type['AccountType']);
+ while ($account=db_fetch($accounts))
{
- $typeopen[$i] += $prev_balance;
- $typeperiod[$i] += $curr_balance;
- $typeclose[$i] = $typeopen[$i] + $typeperiod[$i];
- }
- $classopen += $prev_balance;
- $classperiod += $curr_balance;
- $classclose = $classopen + $classperiod;
- $rep->TextCol(0, 1, $account['account_code']);
- $rep->TextCol(1, 2, $account['account_name']);
+ $prev_balance = get_gl_balance_from_to("", $from, $account["account_code"], $dimension, $dimension2);
- $rep->AmountCol(2, 3, $prev_balance, $dec);
- $rep->AmountCol(3, 4, $curr_balance, $dec);
- $rep->AmountCol(4, 5, $curr_balance + $prev_balance, $dec);
+ $curr_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2);
- $rep->NewLine();
+ if (!$prev_balance && !$curr_balance)
+ continue;
- if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight)
- {
- $rep->Line($rep->row - 2);
- $rep->Header();
- }
+ for ($i = 0; $i <= $level; $i++)
+ {
+ $typeopen[$i] += $prev_balance;
+ $typeperiod[$i] += $curr_balance;
+ $typeclose[$i] = $typeopen[$i] + $typeperiod[$i];
+ }
+ $classopen += $prev_balance;
+ $classperiod += $curr_balance;
+ $classclose = $classopen + $classperiod;
+ $rep->TextCol(0, 1, $account['account_code']);
+ $rep->TextCol(1, 2, $account['account_name']);
+
+ $rep->AmountCol(2, 3, $prev_balance, $dec);
+ $rep->AmountCol(3, 4, $curr_balance, $dec);
+ $rep->AmountCol(4, 5, $curr_balance + $prev_balance, $dec);
+
+ $rep->NewLine();
+
+ if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight)
+ {
+ $rep->Line($rep->row - 2);
+ $rep->Header();
+ }
+ }
}
- if ($account['AccountClassName'] != $classname)
+ if ($type['AccountClassName'] != $classname)
{
if ($classname != '')
{
$closeclass = true;
}
}
- if ($account['AccountTypeName'] != $typename[$level])
+ if ($type['AccountTypeName'] != $typename[$level])
{
if ($typename[$level] != '')
{
- for ( ; $level >= 0; $level--)
+ for ( ; $level >= 0, $typename[$level] != ''; $level--)
{
- $rep->row += 6;
- $rep->Line($rep->row);
- $rep->NewLine();
- $rep->TextCol(0, 2, _('Total') . " " . $typename[$level]);
- $rep->AmountCol(2, 3, $typeopen[$level], $dec);
- $rep->AmountCol(3, 4, $typeperiod[$level], $dec);
- $rep->AmountCol(4, 5, $typeclose[$level], $dec);
- $typeopen[$level] = $typeperiod[$level] = $typeclose[$level] = 0.0;
- if ($parent[$level] == -1)
+ if ($type['parent'] == $closing[$level] || $type['parent'] == $last || $type['parent'] <= 0)
+ {
+ $rep->row += 6;
+ $rep->Line($rep->row);
+ $rep->NewLine();
+ $rep->TextCol(0, 2, _('Total') . " " . $typename[$level]);
+ $rep->AmountCol(2, 3, $typeopen[$level], $dec);
+ $rep->AmountCol(3, 4, $typeperiod[$level], $dec);
+ $rep->AmountCol(4, 5, $typeclose[$level], $dec);
+ if ($graphics)
+ {
+ $pg->x[] = $$typename[$level];
+ $pg->y[] = abs($typeclose[$level]);
+ }
+ $typeopen[$level] = $typeperiod[$level] = $typeclose[$level] = 0.0;
+ }
+ else
break;
$rep->NewLine();
}
- if ($graphics)
- {
- $pg->x[] = $$typename[$level];
- $pg->y[] = abs($typeclose[$level]);
- }
- $rep->NewLine();
+ //$rep->NewLine();
if ($closeclass)
{
$calculateopen = -$assetsopen - $classopen;
$typeper = array(0,0,0,0,0,0,0,0,0,0);
$typeacc = array(0,0,0,0,0,0,0,0,0,0);
$typename = array('','','','','','','','','','');
- $parent = array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1);
+ $closing = array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1);
$level = 0;
$classper = 0.0;
$classacc = 0.0;
$salesper = 0.0;
$salesacc = 0.0;
+ $last = -1;
- $accounts = get_gl_accounts_all(0);
+ $types = get_account_types_all(0);
- while ($account=db_fetch($accounts))
+ while ($type=db_fetch($types))
{
- $per_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2);
-
- if ($compare == 2)
- $acc_balance = get_budget_trans_from_to($begin, $end, $account["account_code"], $dimension, $dimension2);
- else
- $acc_balance = get_gl_trans_from_to($begin, $end, $account["account_code"], $dimension, $dimension2);
- if (!$per_balance && !$acc_balance)
+ if (!num_accounts_in_type($type['AccountType'], $type['parent']))
continue;
- if ($account['AccountClassName'] != $classname)
+ if ($type['AccountClassName'] != $classname)
{
if ($classname != '')
{
}
}
- if ($account['AccountTypeName'] != $typename[$level])
+ if ($type['AccountTypeName'] != $typename[$level])
{
- if ($typename[$level] != '' && $account['parent'] == -1)
+ if ($typename[$level] != '')
{
- for ( ; $level >= 0; $level--)
+ for ( ; $level >= 0, $typename[$level] != ''; $level--)
{
- $rep->row += 6;
- $rep->Line($rep->row);
- $rep->NewLine();
- $rep->TextCol(0, 2, _('Total') . " " . $typename[$level]);
- $rep->AmountCol(2, 3, $typeper[$level], $dec);
- $rep->AmountCol(3, 4, $typeacc[$level], $dec);
- $rep->AmountCol(4, 5, Achieve($typeper[$level], $typeacc[$level]), $pdec);
- $typeper[$level] = $typeacc[$level] = 0.0;
- if ($parent[$level] == -1)
+ if ($type['parent'] == $closing[$level] || $type['parent'] == $last || $type['parent'] <= 0)
+ {
+ $rep->row += 6;
+ $rep->Line($rep->row);
+ $rep->NewLine();
+ $rep->TextCol(0, 2, _('Total') . " " . $typename[$level]);
+ $rep->AmountCol(2, 3, $typeper[$level], $dec);
+ $rep->AmountCol(3, 4, $typeacc[$level], $dec);
+ $rep->AmountCol(4, 5, Achieve($typeper[$level], $typeacc[$level]), $pdec);
+ if ($graphics)
+ {
+ $pg->x[] = $typename[$level];
+ $pg->y[] = abs($typeper[$level]);
+ $pg->z[] = abs($typeacc[$level]);
+ }
+ $typeper[$level] = $typeacc[$level] = 0.0;
+ }
+ else
break;
$rep->NewLine();
}
- if ($graphics)
- {
- $pg->x[] = $typename[$level];
- $pg->y[] = abs($typeper[$level]);
- $pg->z[] = abs($typeacc[$level]);
- }
- $rep->NewLine();
+ //$rep->NewLine();
if ($closeclass)
{
$rep->row += 6;
$closeclass = false;
}
}
- if ($account['AccountClassName'] != $classname)
+ if ($type['AccountClassName'] != $classname)
{
$rep->Font('bold');
- $rep->TextCol(0, 5, $account['AccountClassName']);
+ $rep->TextCol(0, 5, $type['AccountClassName']);
$rep->Font();
$rep->NewLine();
}
- if ($account['parent'] != -1 && $account['parent'] != $parent[$level])
- $level++;
- $typename[$level] = $account['AccountTypeName'];
+ $level++;
+ if ($type['parent'] != $last)
+ $last = $type['parent'];
+ $typename[$level] = $type['AccountTypeName'];
+ $closing[$level] = $type['parent'];
$rep->row -= 4;
- $rep->TextCol(0, 5, $account['AccountTypeName']);
+ $rep->TextCol(0, 5, $type['AccountTypeName']);
$rep->row -= 4;
$rep->Line($rep->row);
$rep->NewLine();
}
- $classname = $account['AccountClassName'];
- $parent[$level] = $account['parent'];
+ $classname = $type['AccountClassName'];
- $per_balance *= -1;
- $acc_balance *= -1;
-
- for ($i = 0; $i <= $level; $i++)
+ $accounts = get_gl_accounts_in_type($type['AccountType']);
+ while ($account=db_fetch($accounts))
{
- $typeper[$i] += $per_balance;
- $typeacc[$i] += $acc_balance;
- }
- $classper += $per_balance;
- $classacc += $acc_balance;
- $rep->TextCol(0, 1, $account['account_code']);
- $rep->TextCol(1, 2, $account['account_name']);
+ $per_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2);
+
+ if ($compare == 2)
+ $acc_balance = get_budget_trans_from_to($begin, $end, $account["account_code"], $dimension, $dimension2);
+ else
+ $acc_balance = get_gl_trans_from_to($begin, $end, $account["account_code"], $dimension, $dimension2);
+ if (!$per_balance && !$acc_balance)
+ continue;
+ $per_balance *= -1;
+ $acc_balance *= -1;
+
+ for ($i = 0; $i <= $level; $i++)
+ {
+ $typeper[$i] += $per_balance;
+ $typeacc[$i] += $acc_balance;
+ }
+ $classper += $per_balance;
+ $classacc += $acc_balance;
+ $rep->TextCol(0, 1, $account['account_code']);
+ $rep->TextCol(1, 2, $account['account_name']);
- $rep->AmountCol(2, 3, $per_balance, $dec);
- $rep->AmountCol(3, 4, $acc_balance, $dec);
- $rep->AmountCol(4, 5, Achieve($per_balance, $acc_balance), $pdec);
+ $rep->AmountCol(2, 3, $per_balance, $dec);
+ $rep->AmountCol(3, 4, $acc_balance, $dec);
+ $rep->AmountCol(4, 5, Achieve($per_balance, $acc_balance), $pdec);
- $rep->NewLine();
+ $rep->NewLine();
- if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight)
- {
- $rep->Line($rep->row - 2);
- $rep->Header();
- }
+ if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight)
+ {
+ $rep->Line($rep->row - 2);
+ $rep->Header();
+ }
+ }
}
- if ($account['AccountClassName'] != $classname)
+ if ($type['AccountClassName'] != $classname)
{
if ($classname != '')
{
$closeclass = true;
}
}
- if ($account['AccountTypeName'] != $typename[$level])
+ if ($type['AccountTypeName'] != $typename[$level])
{
if ($typename[$level] != '')
{
- for ( ; $level >= 0; $level--)
+ for ( ; $level >= 0, $typename[$level] != ''; $level--)
{
- $rep->row += 6;
- $rep->Line($rep->row);
- $rep->NewLine();
- $rep->TextCol(0, 2, _('Total') . " " . $typename[$level]);
- $rep->AmountCol(2, 3, $typeper[$level], $dec);
- $rep->AmountCol(3, 4, $typeacc[$level], $dec);
- $rep->AmountCol(4, 5, Achieve($typeper[$level], $typeacc[$level]), $pdec);
- $typeper[$level] = $typeacc[$level] = 0.0;
- if ($parent[$level] == -1)
+ if ($type['parent'] == $closing[$level] || $type['parent'] == $last || $type['parent'] <= 0)
+ {
+ $rep->row += 6;
+ $rep->Line($rep->row);
+ $rep->NewLine();
+ $rep->TextCol(0, 2, _('Total') . " " . $typename[$level]);
+ $rep->AmountCol(2, 3, $typeper[$level], $dec);
+ $rep->AmountCol(3, 4, $typeacc[$level], $dec);
+ $rep->AmountCol(4, 5, Achieve($typeper[$level], $typeacc[$level]), $pdec);
+ if ($graphics)
+ {
+ $pg->x[] = $typename[$level];
+ $pg->y[] = abs($typeper[$level]);
+ $pg->z[] = abs($typeacc[$level]);
+ }
+ $typeper[$level] = $typeacc[$level] = 0.0;
+ }
+ else
break;
$rep->NewLine();
}
- if ($graphics)
- {
- $pg->x[] = $typename[$level];
- $pg->y[] = abs($typeper[$level]);
- $pg->z[] = abs($typeacc[$level]);
- }
- $rep->NewLine();
+ //$rep->NewLine();
if ($closeclass)
{
$rep->Line($rep->row + 6);