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_DIMENSIONREP';
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 id >= ".db_escape($from)."
36 AND id <= ".db_escape($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 $orientation = $_POST['PARAM_4'];
78 $destination = $_POST['PARAM_5'];
80 include_once($path_to_root . "/reporting/includes/excel_report.inc");
82 include_once($path_to_root . "/reporting/includes/pdf_report.inc");
84 $orientation = ($orientation ? 'L' : 'P');
85 $cols = array(0, 50, 210, 250, 320, 395, 465, 515);
87 $headers = array(_('Reference'), _('Name'), _('Type'), _('Date'), _('Due Date'), _('Closed'), _('YTD'));
89 $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'right');
91 $params = array( 0 => $comments,
92 1 => array('text' => _('Dimension'), 'from' => get_dimension_string($fromdim), 'to' => get_dimension_string($todim)));
94 $rep = new FrontReport(_('Dimension Summary'), "DimensionSummary", user_pagesize(), 9, $orientation);
95 if ($orientation == 'L')
96 recalculate_cols($cols);
99 $rep->Info($params, $cols, $headers, $aligns);
102 $res = getTransactions($fromdim, $todim);
103 while ($trans=db_fetch($res))
105 $rep->TextCol(0, 1, $trans['reference']);
106 $rep->TextCol(1, 2, $trans['name']);
107 $rep->TextCol(2, 3, $trans['type_']);
108 $rep->DateCol(3, 4, $trans['date_'], true);
109 $rep->DateCol(4, 5, $trans['due_date'], true);
110 if ($trans['closed'])
114 $rep->TextCol(5, 6, $str);
117 $balance = getYTD($trans['id']);
118 $rep->AmountCol(6, 7, $balance, 0);
122 $rep->Line($rep->row);