6 include_once($path_to_root . "/includes/session.inc");
8 page(_("Trial Balance"));
10 include_once($path_to_root . "/includes/date_functions.inc");
11 include_once($path_to_root . "/includes/ui.inc");
12 include_once($path_to_root . "/includes/data_checks.inc");
14 include_once($path_to_root . "/gl/includes/gl_db.inc");
16 //----------------------------------------------------------------------------------------------------
19 function gl_inquiry_controls()
23 start_table("class='tablestyle_noborder'");
25 date_cells(_("From:"), 'TransFromDate', null, -30);
26 date_cells(_("To:"), 'TransToDate');
27 check_cells(_("No zero values"), 'NoZero', null);
29 submit_cells('Show',_("Show"));
34 //----------------------------------------------------------------------------------------------------
36 function get_balance($account, $from, $to, $from_incl=true, $to_incl=true) {
38 $sql = "SELECT SUM(amount) As TransactionSum FROM ".TB_PREF."gl_trans
39 WHERE account=$account";
43 $from_date = date2sql($from);
45 $sql .= " AND tran_date >= '$from_date'";
47 $sql .= " AND tran_date > '$from_date'";
52 $to_date = date2sql($to);
54 $sql .= " AND tran_date <= '$to_date' ";
56 $sql .= " AND tran_date < '$to_date' ";
59 $result = db_query($sql,"No general ledger accounts were returned");
61 $row = db_fetch_row($result);
65 //----------------------------------------------------------------------------------------------------
67 function display_trial_balance()
69 global $table_style, $path_to_root;
71 start_table($table_style);
73 <td rowspan=2 class='tableheader'>" . _("Account") . "</td>
74 <td rowspan=2 class='tableheader'>" . _("Account Name") . "</td>
75 <td colspan=2 class='tableheader'>" . _("Brought Forward") . "</td>
76 <td colspan=2 class='tableheader'>" . _("This Period") . "</td>
77 <td colspan=2 class='tableheader'>" . _("Balance") . "</td>
79 <td class='tableheader'>" . _("Debit") . "</td>
80 <td class='tableheader'>" . _("Credit") . "</td>
81 <td class='tableheader'>" . _("Debit") . "</td>
82 <td class='tableheader'>" . _("Credit") . "</td>
83 <td class='tableheader'>" . _("Debit") . "</td>
84 <td class='tableheader'>" . _("Credit") . "</td>
91 $accounts = get_gl_accounts();
93 while ($account = db_fetch($accounts))
96 $prev_balance = get_balance($account["account_code"], null, $_POST['TransFromDate'], false, false);
98 $curr_balance = get_balance($account["account_code"], $_POST['TransFromDate'], $_POST['TransToDate']);
99 if (check_value("NoZero") && !$prev_balance && !$curr_balance)
101 alt_table_row_color($k);
103 $url = "<a href='$path_to_root/gl/inquiry/gl_account_inquiry.php?" . SID . "TransFromDate=" . $_POST["TransFromDate"] . "&TransToDate=" . $_POST["TransToDate"] . "&account=" . $account["account_code"] . "'>" . $account["account_code"] . "</a>";
106 label_cell($account["account_name"]);
108 display_debit_or_credit_cells($prev_balance);
109 display_debit_or_credit_cells($curr_balance);
110 display_debit_or_credit_cells($prev_balance + $curr_balance);
118 //----------------------------------------------------------------------------------------------------
120 gl_inquiry_controls();
122 display_trial_balance();
124 //----------------------------------------------------------------------------------------------------