function print_Chart_of_Accounts() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $showbalance = $_REQUEST['PARAM_0']; $comments = $_REQUEST['PARAM_1']; $dec = 0; $cols = array(0, 50, 300, 425, 500); $headers = array(tr('Account'), tr('Account Name'), tr('Account Code'), tr('Balance')); $aligns = array('left', 'left', 'left', 'right'); $params = array(0 => $comments); $rep = new FrontReport(tr('Chart of Accounts'), "ChartOfAccounts.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $classname = ''; $group = ''; $accounts = get_gl_accounts_all(); while ($account = db_fetch($accounts)) { 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 ($classname != '') { $rep->row -= 4; } if ($account['AccountClassName'] != $classname) { $rep->Font('bold'); $rep->TextCol(0, 4, $account['AccountClassName']); $rep->Font(); $rep->row -= $rep->lineHeight + 4; } $group = $account['AccountTypeName']; $rep->TextCol(0, 4, $account['AccountTypeName']); //$rep->Line($rep->row - 4); $rep->row -= $rep->lineHeight + 4; } $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->TextCol(3, 4, number_format2($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(); }
function display_type($type, $typename, &$dec, &$rep, $showbalance, $level) { $printtitle = 0; //Flag for printing type name //Get Accounts directly under this group/type $result = get_gl_accounts(null, null, $type); while ($account = db_fetch($result)) { //Print Type Title if it has atleast one non-zero account if (!$printtitle) { $prefix = ''; for ($sp = 1; $sp <= $level; $sp++) { $prefix .= ' '; } $printtitle = 1; $rep->row -= 4; $rep->TextCol(0, 1, $type); $rep->TextCol(1, 4, $prefix . $typename); $rep->row -= 4; $rep->Line($rep->row); $rep->NewLine(); } 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, $prefix . $account['account_name']); $rep->TextCol(2, 3, $account['account_code2']); if ($showbalance == 1) { $rep->AmountCol(3, 4, $balance, $dec); } $rep->NewLine(); } //Get Account groups/types under this group/type $result = get_account_types(false, false, $type); while ($accounttype = db_fetch($result)) { //Print Type Title if has sub types and not previously printed if (!$printtitle) { $printtitle = 1; $rep->row -= 4; $rep->TextCol(0, 1, $type); $rep->TextCol(1, 4, $typename); $rep->row -= 4; $rep->Line($rep->row); $rep->NewLine(); } $nextlevel = $level + 1; display_type($accounttype["id"], $accounttype["name"] . ' (' . $typename . ')', $dec, $rep, $showbalance, $nextlevel); } }