2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU Affero General Public License,
5 AGPL, as published by the Free Software Foundation, either version
6 3 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/agpl-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 // trial_inquiry_controls();
29 print_dimension_summary();
31 function getTransactions($from, $to)
36 WHERE reference >= '$from'
37 AND reference <= '$to'
41 return db_query($sql,"No transactions were returned");
47 $date = begin_fiscalyear($date);
50 $sql = "SELECT SUM(amount) AS Balance
53 WHERE (dimension_id = '$dim' OR dimension2_id = '$dim')
54 AND tran_date >= '$date'";
56 $TransResult = db_query($sql,"No transactions were returned");
57 if (db_num_rows($TransResult) == 1)
59 $DemandRow = db_fetch_row($TransResult);
60 $balance = $DemandRow[0];
68 //----------------------------------------------------------------------------------------------------
70 function print_dimension_summary()
74 include_once($path_to_root . "/reporting/includes/pdf_report.inc");
76 $fromdim = $_POST['PARAM_0'];
77 $todim = $_POST['PARAM_1'];
78 $showbal = $_POST['PARAM_2'];
79 $comments = $_POST['PARAM_3'];
82 $cols = array(0, 50, 210, 250, 320, 395, 465, 515);
84 $headers = array(_('Reference'), _('Name'), _('Type'), _('Date'), _('Due Date'), _('Closed'), _('YTD'));
86 $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'right');
88 $params = array( 0 => $comments,
89 1 => array('text' => _('Dimension'), 'from' => $fromdim, 'to' => $todim));
91 $rep = new FrontReport(_('Dimension Summary'), "DimensionSummary.pdf", user_pagesize());
94 $rep->Info($params, $cols, $headers, $aligns);
97 $res = getTransactions($fromdim, $todim);
98 while ($trans=db_fetch($res))
100 $rep->TextCol(0, 1, $trans['reference']);
101 $rep->TextCol(1, 2, $trans['name']);
102 $rep->TextCol(2, 3, $trans['type_']);
103 $rep->TextCol(3, 4, $trans['date_']);
104 $rep->TextCol(4, 5, $trans['due_date']);
105 if ($trans['closed'])
109 $rep->TextCol(5, 6, $str);
112 $balance = getYTD($trans['id']);
113 $rep->TextCol(6, 7, number_format2($balance, 0));
117 $rep->Line($rep->row);