4 // ----------------------------------------------------------------
8 // Title: GL Accounts Transactions
9 // ----------------------------------------------------------------
12 include_once($path_to_root . "includes/session.inc");
13 include_once($path_to_root . "includes/date_functions.inc");
14 include_once($path_to_root . "includes/data_checks.inc");
15 include_once($path_to_root . "gl/includes/gl_db.inc");
17 //----------------------------------------------------------------------------------------------------
19 // trial_inquiry_controls();
20 print_GL_transactions();
22 //----------------------------------------------------------------------------------------------------
24 function print_GL_transactions()
28 include_once($path_to_root . "reporting/includes/pdf_report.inc");
30 $rep = new FrontReport(_('GL Account Transactions'), "GLAccountTransactions.pdf", user_pagesize());
31 $dim = get_company_pref('use_dimension');
32 $dimension = $dimension2 = 0;
34 $from = $_POST['PARAM_0'];
35 $to = $_POST['PARAM_1'];
36 $fromacc = $_POST['PARAM_2'];
37 $toacc = $_POST['PARAM_3'];
40 $dimension = $_POST['PARAM_4'];
41 $dimension2 = $_POST['PARAM_5'];
42 $comments = $_POST['PARAM_6'];
46 $dimension = $_POST['PARAM_4'];
47 $comments = $_POST['PARAM_5'];
51 $comments = $_POST['PARAM_4'];
53 $dec = user_price_dec();
55 $cols = array(0, 70, 90, 140, 210, 280, 340, 400, 450, 510, 570);
56 //------------0--1---2---3----4----5----6----7----8----9----10-------
57 //-----------------------dim1-dim2-----------------------------------
58 //-----------------------dim1----------------------------------------
59 //-------------------------------------------------------------------
60 $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'right', 'right', 'right');
63 $headers = array(_('Type'), _('#'), _('Date'), _('Dimension')." 1", _('Dimension')." 2",
64 _('Person/Item'), _('Debit'), _('Credit'), _('Balance'));
66 $headers = array(_('Type'), _('#'), _('Date'), _('Dimension'), "", _('Person/Item'),
67 _('Debit'), _('Credit'), _('Balance'));
69 $headers = array(_('Type'), _('#'), _('Date'), "", "", _('Person/Item'),
70 _('Debit'), _('Credit'), _('Balance'));
74 $params = array( 0 => $comments,
75 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to),
76 2 => array('text' => _('Accounts'),'from' => $fromacc,'to' => $toacc),
77 3 => array('text' => _('Dimension')." 1", 'from' => get_dimension_string($dimension),
79 4 => array('text' => _('Dimension')." 2", 'from' => get_dimension_string($dimension2),
84 $params = array( 0 => $comments,
85 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to),
86 2 => array('text' => _('Accounts'),'from' => $fromacc,'to' => $toacc),
87 3 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension),
92 $params = array( 0 => $comments,
93 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to),
94 2 => array('text' => _('Accounts'),'from' => $fromacc,'to' => $toacc));
98 $rep->Info($params, $cols, $headers, $aligns);
101 $accounts = get_gl_accounts($fromacc, $toacc);
103 while ($account=db_fetch($accounts))
105 if (is_account_balancesheet($account["account_code"]))
109 $begin = begin_fiscalyear();
110 if (date1_greater_date2($begin, $from))
112 $begin = add_days($begin, -1);
114 $prev_balance = get_gl_balance_from_to($begin, $from, $account["account_code"], $dimension, $dimension2);
116 $trans = get_gl_transactions($from, $to, -1, $account['account_code'], $dimension, $dimension2);
117 $rows = db_num_rows($trans);
118 if ($prev_balance == 0.0 && $rows == 0)
121 $rep->TextCol(0, 3, $account['account_code'] . " " . $account['account_name']);
122 $rep->TextCol(3, 5, _('Opening Balance'));
123 if ($prev_balance > 0.0)
124 $rep->TextCol(6, 7, number_format2(abs($prev_balance), $dec));
126 $rep->TextCol(7, 8, number_format2(abs($prev_balance), $dec));
128 $total = $prev_balance;
132 while ($myrow=db_fetch($trans))
134 $total += $myrow['amount'];
136 $rep->TextCol(0, 1, systypes::name($myrow["type"]));
137 $rep->TextCol(1, 2, $myrow['type_no']);
138 $rep->TextCol(2, 3, sql2date($myrow["tran_date"]));
140 $rep->TextCol(3, 4, get_dimension_string($myrow['dimension_id']));
142 $rep->TextCol(4, 5, get_dimension_string($myrow['dimension2_id']));
143 $rep->TextCol(5, 6, payment_person_types::person_name($myrow["person_type_id"],$myrow["person_id"], false));
144 if ($myrow['amount'] > 0.0)
145 $rep->TextCol(6, 7, number_format2(abs($myrow['amount']), $dec));
147 $rep->TextCol(7, 8, number_format2(abs($myrow['amount']), $dec));
148 $rep->TextCol(8, 9, number_format2($total, $dec));
150 if ($rep->row < $rep->bottomMargin + $rep->lineHeight)
152 $rep->Line($rep->row - 2);
159 $rep->TextCol(3, 5, _("Ending Balance"));
161 $rep->TextCol(6, 7, number_format2(abs($total), $dec));
163 $rep->TextCol(7, 8, number_format2(abs($total), $dec));
165 $rep->Line($rep->row - $rep->lineHeight + 4);