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: Dimension Summary
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_dimension_summary();
30 function getTransactions($from, $to)
35 WHERE reference >= '$from'
36 AND reference <= '$to'
40 return db_query($sql,"No transactions were returned");
46 $date = begin_fiscalyear($date);
49 $sql = "SELECT SUM(amount) AS Balance
52 WHERE (dimension_id = '$dim' OR dimension2_id = '$dim')
53 AND tran_date >= '$date'";
55 $TransResult = db_query($sql,"No transactions were returned");
56 if (db_num_rows($TransResult) == 1)
58 $DemandRow = db_fetch_row($TransResult);
59 $balance = $DemandRow[0];
67 //----------------------------------------------------------------------------------------------------
69 function print_dimension_summary()
73 $fromdim = $_POST['PARAM_0'];
74 $todim = $_POST['PARAM_1'];
75 $showbal = $_POST['PARAM_2'];
76 $comments = $_POST['PARAM_3'];
77 $destination = $_POST['PARAM_4'];
79 include_once($path_to_root . "/reporting/includes/excel_report.inc");
81 include_once($path_to_root . "/reporting/includes/pdf_report.inc");
83 $cols = array(0, 50, 210, 250, 320, 395, 465, 515);
85 $headers = array(_('Reference'), _('Name'), _('Type'), _('Date'), _('Due Date'), _('Closed'), _('YTD'));
87 $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'right');
89 $params = array( 0 => $comments,
90 1 => array('text' => _('Dimension'), 'from' => $fromdim, 'to' => $todim));
92 $rep = new FrontReport(_('Dimension Summary'), "DimensionSummary", user_pagesize());
95 $rep->Info($params, $cols, $headers, $aligns);
98 $res = getTransactions($fromdim, $todim);
99 while ($trans=db_fetch($res))
101 $rep->TextCol(0, 1, $trans['reference']);
102 $rep->TextCol(1, 2, $trans['name']);
103 $rep->TextCol(2, 3, $trans['type_']);
104 $rep->DateCol(3, 4, $trans['date_'], true);
105 $rep->DateCol(4, 5, $trans['due_date'], true);
106 if ($trans['closed'])
110 $rep->TextCol(5, 6, $str);
113 $balance = getYTD($trans['id']);
114 $rep->AmountCol(6, 7, $balance, 0);
118 $rep->Line($rep->row);