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 $path_to_root="../..";
15 include_once($path_to_root . "/includes/session.inc");
17 include_once($path_to_root . "/includes/date_functions.inc");
18 include_once($path_to_root . "/includes/ui.inc");
19 include_once($path_to_root . "/includes/data_checks.inc");
21 include_once($path_to_root . "/gl/includes/gl_db.inc");
25 $js = get_js_date_picker();
27 page(_("Trial Balance"), false, false, "", $js);
29 //----------------------------------------------------------------------------------------------------
34 $Ajax->activate('balance_tbl');
38 function gl_inquiry_controls()
42 start_table("class='tablestyle_noborder'");
44 date_cells(_("From:"), 'TransFromDate', '', null, -30);
45 date_cells(_("To:"), 'TransToDate');
46 check_cells(_("No zero values"), 'NoZero', null);
47 check_cells(_("Only balances"), 'Balance', null);
49 submit_cells('Show',_("Show"),'','', 'default');
54 //----------------------------------------------------------------------------------------------------
56 function display_trial_balance()
58 global $table_style, $path_to_root;
60 div_start('balance_tbl');
61 start_table($table_style);
63 <td rowspan=2 class='tableheader'>" . _("Account") . "</td>
64 <td rowspan=2 class='tableheader'>" . _("Account Name") . "</td>
65 <td colspan=2 class='tableheader'>" . _("Brought Forward") . "</td>
66 <td colspan=2 class='tableheader'>" . _("This Period") . "</td>
67 <td colspan=2 class='tableheader'>" . _("Balance") . "</td>
69 <td class='tableheader'>" . _("Debit") . "</td>
70 <td class='tableheader'>" . _("Credit") . "</td>
71 <td class='tableheader'>" . _("Debit") . "</td>
72 <td class='tableheader'>" . _("Credit") . "</td>
73 <td class='tableheader'>" . _("Debit") . "</td>
74 <td class='tableheader'>" . _("Credit") . "</td>
81 $accounts = get_gl_accounts();
82 $pdeb = $pcre = $cdeb = $ccre = $tdeb = $tcre = $pbal = $cbal = $tbal = 0;
83 $begin = begin_fiscalyear();
84 if (date1_greater_date2($begin, $_POST['TransFromDate']))
85 $begin = $_POST['TransFromDate'];
86 $begin = add_days($begin, -1);
88 while ($account = db_fetch($accounts))
90 $prev = get_balance($account["account_code"], 0, 0, $begin, $_POST['TransFromDate'], false, false);
91 $curr = get_balance($account["account_code"], 0, 0, $_POST['TransFromDate'], $_POST['TransToDate'], true, true);
92 $tot = get_balance($account["account_code"], 0, 0, $begin, $_POST['TransToDate'], false, true);
93 if (check_value("NoZero") && !$prev['balance'] && !$curr['balance'] && !$tot['balance'])
95 alt_table_row_color($k);
97 $url = "<a href='$path_to_root/gl/inquiry/gl_account_inquiry.php?TransFromDate=" . $_POST["TransFromDate"] . "&TransToDate=" . $_POST["TransToDate"] . "&account=" . $account["account_code"] . "'>" . $account["account_code"] . "</a>";
100 label_cell($account["account_name"]);
101 if (check_value('Balance'))
103 display_debit_or_credit_cells($prev['balance']);
104 display_debit_or_credit_cells($curr['balance']);
105 display_debit_or_credit_cells($tot['balance']);
110 amount_cell($prev['debit']);
111 amount_cell($prev['credit']);
112 amount_cell($curr['debit']);
113 amount_cell($curr['credit']);
114 amount_cell($tot['debit']);
115 amount_cell($tot['credit']);
116 $pdeb += $prev['debit'];
117 $pcre += $prev['credit'];
118 $cdeb += $curr['debit'];
119 $ccre += $curr['credit'];
120 $tdeb += $tot['debit'];
121 $tcre += $tot['credit'];
123 $pbal += $prev['balance'];
124 $cbal += $curr['balance'];
125 $tbal += $tot['balance'];
129 //$prev = get_balance(null, $begin, $_POST['TransFromDate'], false, false);
130 //$curr = get_balance(null, $_POST['TransFromDate'], $_POST['TransToDate'], true, true);
131 //$tot = get_balance(null, $begin, $_POST['TransToDate'], false, true);
132 if (!check_value('Balance'))
134 start_row("class='inquirybg' style='font-weight:bold'");
135 label_cell(_("Total") ." - ".$_POST['TransToDate'], "colspan=2");
144 start_row("class='inquirybg' style='font-weight:bold'");
145 label_cell(_("Ending Balance") ." - ".$_POST['TransToDate'], "colspan=2");
146 display_debit_or_credit_cells($pbal);
147 display_debit_or_credit_cells($cbal);
148 display_debit_or_credit_cells($tbal);
155 //----------------------------------------------------------------------------------------------------
157 gl_inquiry_controls();
159 display_trial_balance();
161 //----------------------------------------------------------------------------------------------------