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: GL Accounts Transactions
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_GL_transactions();
30 //----------------------------------------------------------------------------------------------------
32 function print_GL_transactions()
36 $dim = get_company_pref('use_dimension');
37 $dimension = $dimension2 = 0;
39 $from = $_POST['PARAM_0'];
40 $to = $_POST['PARAM_1'];
41 $fromacc = $_POST['PARAM_2'];
42 $toacc = $_POST['PARAM_3'];
45 $dimension = $_POST['PARAM_4'];
46 $dimension2 = $_POST['PARAM_5'];
47 $comments = $_POST['PARAM_6'];
48 $destination = $_POST['PARAM_7'];
52 $dimension = $_POST['PARAM_4'];
53 $comments = $_POST['PARAM_5'];
54 $destination = $_POST['PARAM_6'];
58 $comments = $_POST['PARAM_4'];
59 $destination = $_POST['PARAM_5'];
62 include_once($path_to_root . "/reporting/includes/excel_report.inc");
64 include_once($path_to_root . "/reporting/includes/pdf_report.inc");
66 $rep = new FrontReport(_('GL Account Transactions'), "GLAccountTransactions", user_pagesize());
67 $dec = user_price_dec();
69 $cols = array(0, 70, 90, 140, 210, 280, 340, 400, 450, 510, 570);
70 //------------0--1---2---3----4----5----6----7----8----9----10-------
71 //-----------------------dim1-dim2-----------------------------------
72 //-----------------------dim1----------------------------------------
73 //-------------------------------------------------------------------
74 $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'right', 'right', 'right');
77 $headers = array(_('Type'), _('#'), _('Date'), _('Dimension')." 1", _('Dimension')." 2",
78 _('Person/Item'), _('Debit'), _('Credit'), _('Balance'));
80 $headers = array(_('Type'), _('#'), _('Date'), _('Dimension'), "", _('Person/Item'),
81 _('Debit'), _('Credit'), _('Balance'));
83 $headers = array(_('Type'), _('#'), _('Date'), "", "", _('Person/Item'),
84 _('Debit'), _('Credit'), _('Balance'));
88 $params = array( 0 => $comments,
89 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to),
90 2 => array('text' => _('Accounts'),'from' => $fromacc,'to' => $toacc),
91 3 => array('text' => _('Dimension')." 1", 'from' => get_dimension_string($dimension),
93 4 => array('text' => _('Dimension')." 2", 'from' => get_dimension_string($dimension2),
98 $params = array( 0 => $comments,
99 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to),
100 2 => array('text' => _('Accounts'),'from' => $fromacc,'to' => $toacc),
101 3 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension),
106 $params = array( 0 => $comments,
107 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to),
108 2 => array('text' => _('Accounts'),'from' => $fromacc,'to' => $toacc));
112 $rep->Info($params, $cols, $headers, $aligns);
115 $accounts = get_gl_accounts($fromacc, $toacc);
117 while ($account=db_fetch($accounts))
119 if (is_account_balancesheet($account["account_code"]))
123 $begin = begin_fiscalyear();
124 if (date1_greater_date2($begin, $from))
126 $begin = add_days($begin, -1);
128 $prev_balance = get_gl_balance_from_to($begin, $from, $account["account_code"], $dimension, $dimension2);
130 $trans = get_gl_transactions($from, $to, -1, $account['account_code'], $dimension, $dimension2);
131 $rows = db_num_rows($trans);
132 if ($prev_balance == 0.0 && $rows == 0)
135 $rep->TextCol(0, 3, $account['account_code'] . " " . $account['account_name']);
136 $rep->TextCol(3, 5, _('Opening Balance'));
137 if ($prev_balance > 0.0)
138 $rep->AmountCol(6, 7, abs($prev_balance), $dec);
140 $rep->AmountCol(7, 8, abs($prev_balance), $dec);
142 $total = $prev_balance;
146 while ($myrow=db_fetch($trans))
148 $total += $myrow['amount'];
150 $rep->TextCol(0, 1, systypes::name($myrow["type"]));
151 $rep->TextCol(1, 2, $myrow['type_no']);
152 $rep->DateCol(2, 3, $myrow["tran_date"], true);
154 $rep->TextCol(3, 4, get_dimension_string($myrow['dimension_id']));
156 $rep->TextCol(4, 5, get_dimension_string($myrow['dimension2_id']));
157 $rep->TextCol(5, 6, payment_person_types::person_name($myrow["person_type_id"],$myrow["person_id"], false));
158 if ($myrow['amount'] > 0.0)
159 $rep->AmountCol(6, 7, abs($myrow['amount']), $dec);
161 $rep->AmountCol(7, 8, abs($myrow['amount']), $dec);
162 $rep->TextCol(8, 9, number_format2($total, $dec));
164 if ($rep->row < $rep->bottomMargin + $rep->lineHeight)
166 $rep->Line($rep->row - 2);
173 $rep->TextCol(3, 5, _("Ending Balance"));
175 $rep->AmountCol(6, 7, abs($total), $dec);
177 $rep->AmountCol(7, 8, abs($total), $dec);
179 $rep->Line($rep->row - $rep->lineHeight + 4);