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 ***********************************************************************/
12 $page_security = 'SA_GLANALYTIC';
13 // ----------------------------------------------------------------
17 // Title: List of Journal Entries
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");
25 include_once($path_to_root . "/includes/ui/ui_view.inc");
27 //----------------------------------------------------------------------------------------------------
29 print_list_of_journal_entries();
31 //----------------------------------------------------------------------------------------------------
33 function print_list_of_journal_entries()
35 global $path_to_root, $systypes_array;
37 $from = $_POST['PARAM_0'];
38 $to = $_POST['PARAM_1'];
39 $systype = $_POST['PARAM_2'];
40 $comments = $_POST['PARAM_3'];
41 $orientation = $_POST['PARAM_4'];
42 $destination = $_POST['PARAM_5'];
44 include_once($path_to_root . "/reporting/includes/excel_report.inc");
46 include_once($path_to_root . "/reporting/includes/pdf_report.inc");
48 $orientation = ($orientation ? 'L' : 'P');
49 $dec = user_price_dec();
51 $cols = array(0, 100, 240, 300, 400, 460, 520, 580);
53 $headers = array(_('Type/Account'), _('Reference').'/'._('Account Name'), _('Date/Dim.'),
54 _('Person/Item/Memo'), _('Debit'), _('Credit'));
56 $aligns = array('left', 'left', 'left', 'left', 'right', 'right');
58 $params = array( 0 => $comments,
59 1 => array('text' => _('Period'), 'from' => $from,'to' => $to),
60 2 => array('text' => _('Type'), 'from' =>
61 $systype == -1 ? _('All') : $systypes_array[$systype],
64 $rep = new FrontReport(_('List of Journal Entries'), "JournalEntries", user_pagesize(), 9, $orientation);
65 if ($orientation == 'L')
66 recalculate_cols($cols);
69 $rep->Info($params, $cols, $headers, $aligns);
75 $trans = get_gl_transactions($from, $to, -1, null, 0, 0, $systype);
78 $debit = $credit = 0.0;
79 $totdeb = $totcre = 0.0;
80 while ($myrow=db_fetch($trans))
82 if ($type != $myrow['type'] || $typeno != $myrow['type_no'])
86 $rep->Line($rep->row += 6);
88 $rep->AmountCol(4, 5, $debit, $dec);
89 $rep->AmountCol(5, 6, abs($credit), $dec);
92 $debit = $credit = 0.0;
93 $rep->Line($rep->row -= 4);
96 $typeno = $myrow['type_no'];
97 $type = $myrow['type'];
98 $TransName = $systypes_array[$myrow['type']];
99 $rep->TextCol(0, 1, $TransName . " # " . $myrow['type_no']);
100 $rep->TextCol(1, 2, get_reference($myrow['type'], $myrow['type_no']));
101 $rep->DateCol(2, 3, $myrow['tran_date'], true);
102 $coms = get_subaccount_name($myrow["account"], $myrow["person_id"]);
103 $memo = get_comments_string($myrow['type'], $myrow['type_no']);
109 $coms .= " / ".$memo;
111 $rep->TextColLines(3, 6, $coms);
114 $rep->TextCol(0, 1, $myrow['account']);
115 $rep->TextCol(1, 2, $myrow['account_name']);
116 $dim_str = get_dimension_string($myrow['dimension_id']);
117 $dim_str2 = get_dimension_string($myrow['dimension2_id']);
119 $dim_str .= "/".$dim_str2;
120 $rep->TextCol(2, 3, $dim_str);
121 $rep->TextCol(3, 4, $myrow['memo_']);
122 if ($myrow['amount'] > 0.0) {
123 $debit += $myrow['amount'];
124 $rep->AmountCol(4, 5, abs($myrow['amount']), $dec);
127 $credit += $myrow['amount'];
128 $rep->AmountCol(5, 6, abs($myrow['amount']), $dec);
134 $rep->Line($rep->row += 6);
136 $rep->AmountCol(4, 5, $debit, $dec);
137 $rep->AmountCol(5, 6, abs($credit), $dec);
140 $rep->Line($rep->row -= 4);
142 $rep->TextCol(0, 4, _("Total"));
143 $rep->AmountCol(4, 5, $totdeb, $dec);
144 $rep->AmountCol(5, 6, abs($totcre), $dec);
145 $rep->Line($rep->row -= 4);