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 include_once($path_to_root . "/includes/ui.inc");
14 //--------------------------------------------------------------------------------------
16 function display_dimension_balance($id, $from, $to)
18 global $path_to_root, $table_style;
20 $from = date2sql($from);
22 $sql = "SELECT account, ".TB_PREF."chart_master.account_name, sum(amount) AS amt FROM
23 ".TB_PREF."gl_trans,".TB_PREF."chart_master WHERE
24 ".TB_PREF."gl_trans.account = ".TB_PREF."chart_master.account_code AND
25 (dimension_id = $id OR dimension2_id = $id) AND
26 tran_date >= '$from' AND tran_date <= '$to' GROUP BY account";
27 $result = db_query($sql, "Transactions could not be calculated");
29 if (db_num_rows($result) == 0)
31 display_note(_("There are no transactions for this dimension for the selected period."));
35 display_heading2(_("Balance for this Dimension"));
37 start_table($table_style);
38 $th = array(_("Account"), _("Debit"), _("Credit"));
42 while ($myrow = db_fetch($result))
44 alt_table_row_color($k);
46 label_cell($myrow["account"]." ".$myrow['account_name']);
47 display_debit_or_credit_cells($myrow["amt"]);
48 $total += $myrow["amt"];
52 label_cell("<b>"._("Balance")."</b>");
55 amount_cell($total, true);
61 amount_cell(abs($total), true);
69 //--------------------------------------------------------------------------------------