5 include_once($path_to_root . "/includes/session.inc");
7 include_once($path_to_root . "/includes/date_functions.inc");
8 include_once($path_to_root . "/includes/ui.inc");
9 include_once($path_to_root . "/includes/data_checks.inc");
11 include_once($path_to_root . "/gl/includes/gl_db.inc");
12 include_once($path_to_root . "/includes/banking.inc");
15 if ($use_popup_windows)
16 $js .= get_js_open_window(800, 500);
18 $js .= get_js_date_picker();
19 page(_("Bank Statement"), false, false, "", $js);
21 check_db_has_bank_accounts(_("There are no bank accounts defined in the system."));
23 //-----------------------------------------------------------------------------------
28 $Ajax->activate('trans_tbl');
30 //------------------------------------------------------------------------------------------------
33 start_table("class='tablestyle_noborder'");
35 bank_accounts_list_cells(_("Account:"), 'bank_account', null);
37 date_cells(_("From:"), 'TransAfterDate', '', null, -30);
38 date_cells(_("To:"), 'TransToDate');
40 submit_cells('Show',_("Show"),'','', true);
45 //------------------------------------------------------------------------------------------------
48 $date_after = date2sql($_POST['TransAfterDate']);
49 $date_to = date2sql($_POST['TransToDate']);
50 if (!isset($_POST['bank_account']))
51 $_POST['bank_account'] = "";
52 $sql = "SELECT ".TB_PREF."bank_trans.* FROM ".TB_PREF."bank_trans
53 WHERE ".TB_PREF."bank_trans.bank_act = '" . $_POST['bank_account'] . "'
54 AND trans_date >= '$date_after'
55 AND trans_date <= '$date_to'
56 ORDER BY trans_date,".TB_PREF."bank_trans.id";
58 $result = db_query($sql,"The transactions for '" . $_POST['bank_account'] . "' could not be retrieved");
60 div_start('trans_tbl');
61 $act = get_bank_account($_POST["bank_account"]);
62 display_heading($act['bank_account_name']." - ".$act['bank_curr_code']);
64 start_table($table_style);
66 $th = array(_("Type"), _("#"), _("Reference"), _("Date"),
67 _("Debit"), _("Credit"), _("Balance"), _("Person/Item"), "");
70 $sql = "SELECT SUM(amount) FROM ".TB_PREF."bank_trans WHERE bank_act='" . $_POST['bank_account'] . "'
71 AND trans_date < '$date_after'";
72 $before_qty = db_query($sql, "The starting balance on hand could not be calculated");
74 start_row("class='inquirybg'");
75 label_cell("<b>"._("Opening Balance")." - ".$_POST['TransAfterDate']."</b>", "colspan=5");
76 $bfw_row = db_fetch_row($before_qty);
78 display_debit_or_credit_cells($bfw);
82 $running_total = $bfw;
84 $k = 0; //row colour counter
85 while ($myrow = db_fetch($result))
88 alt_table_row_color($k);
90 $running_total += $myrow["amount"];
92 $trandate = sql2date($myrow["trans_date"]);
93 label_cell(systypes::name($myrow["type"]));
94 label_cell(get_trans_view_str($myrow["type"],$myrow["trans_no"]));
95 label_cell(get_trans_view_str($myrow["type"],$myrow["trans_no"],$myrow['ref']));
96 label_cell($trandate);
97 display_debit_or_credit_cells($myrow["amount"]);
98 amount_cell($running_total);
99 label_cell(payment_person_types::person_name($myrow["person_type_id"],$myrow["person_id"]));
100 label_cell(get_gl_view_str($myrow["type"], $myrow["trans_no"]));
112 start_row("class='inquirybg'");
113 label_cell("<b>" . _("Ending Balance")." - ". $_POST['TransToDate']. "</b>", "colspan=5");
114 display_debit_or_credit_cells($running_total);
119 //------------------------------------------------------------------------------------------------