2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
13 // ----------------------------------------------------------------
17 // Title: Chart of GL Accounts
18 // ----------------------------------------------------------------
21 include_once($path_to_root . "/includes/session.inc");
22 include_once($path_to_root . "/includes/date_functions.inc");
23 include_once($path_to_root . "/includes/data_checks.inc");
24 include_once($path_to_root . "/gl/includes/gl_db.inc");
26 //----------------------------------------------------------------------------------------------------
28 print_Chart_of_Accounts();
30 //----------------------------------------------------------------------------------------------------
32 function print_Chart_of_Accounts()
36 $showbalance = $_POST['PARAM_0'];
37 $comments = $_POST['PARAM_1'];
38 $destination = $_POST['PARAM_2'];
40 include_once($path_to_root . "/reporting/includes/excel_report.inc");
42 include_once($path_to_root . "/reporting/includes/pdf_report.inc");
46 $cols = array(0, 50, 300, 425, 500);
48 $headers = array(_('Account'), _('Account Name'), _('Account Code'), _('Balance'));
50 $aligns = array('left', 'left', 'left', 'right');
52 $params = array(0 => $comments);
54 $rep = new FrontReport(_('Chart of Accounts'), "ChartOfAccounts", user_pagesize());
57 $rep->Info($params, $cols, $headers, $aligns);
63 $accounts = get_gl_accounts_all();
65 while ($account=db_fetch($accounts))
67 if ($showbalance == 1)
69 $begin = begin_fiscalyear();
70 if (is_account_balancesheet($account["account_code"]))
72 $balance = get_gl_trans_from_to($begin, ToDay(), $account["account_code"], 0);
74 if ($account['AccountTypeName'] != $group)
78 if ($account['AccountClassName'] != $classname)
81 $rep->TextCol(0, 4, $account['AccountClassName']);
83 //$rep->row -= ($rep->lineHeight + 4);
86 $group = $account['AccountTypeName'];
87 $rep->TextCol(0, 4, $account['AccountTypeName']);
88 //$rep->Line($rep->row - 4);
89 //$rep->row -= ($rep->lineHeight + 4);
92 $classname = $account['AccountClassName'];
94 $rep->TextCol(0, 1, $account['account_code']);
95 $rep->TextCol(1, 2, $account['account_name']);
96 $rep->TextCol(2, 3, $account['account_code2']);
97 if ($showbalance == 1)
98 $rep->AmountCol(3, 4, $balance, $dec);
101 if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight)
103 $rep->Line($rep->row - 2);
107 $rep->Line($rep->row);