X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Finquiry%2Fbank_inquiry.php;h=30380989c73ab95a6a557a55b34587a00e95dfa2;hb=50606312fee0bb0dbe984e2c08af53b7dab229bd;hp=eacf527b6681911a27c7f5b886e0f5bdbe715c67;hpb=95c8695a0b20185fd38d55aa13b4c6be0a6b7aa0;p=fa-stable.git diff --git a/gl/inquiry/bank_inquiry.php b/gl/inquiry/bank_inquiry.php index eacf527b..30380989 100644 --- a/gl/inquiry/bank_inquiry.php +++ b/gl/inquiry/bank_inquiry.php @@ -1,15 +1,15 @@ . + See the License here . ***********************************************************************/ -$page_security = 8; +$page_security = 'SA_BANKTRANSVIEW'; $path_to_root="../.."; include_once($path_to_root . "/includes/session.inc"); @@ -25,7 +25,7 @@ if ($use_popup_windows) $js .= get_js_open_window(800, 500); if ($use_date_picker) $js .= get_js_date_picker(); -page(_("Bank Statement"), false, false, "", $js); +page(_($help_context = "Bank Statement"), isset($_GET['bank_account']), false, "", $js); check_db_has_bank_accounts(_("There are no bank accounts defined in the system.")); @@ -38,58 +38,54 @@ if (get_post('Show')) } //------------------------------------------------------------------------------------------------ +if (isset($_GET['bank_account'])) + $_POST['bank_account'] = $_GET['bank_account']; + start_form(); -start_table("class='tablestyle_noborder'"); +start_table(TABLESTYLE_NOBORDER); start_row(); bank_accounts_list_cells(_("Account:"), 'bank_account', null); date_cells(_("From:"), 'TransAfterDate', '', null, -30); date_cells(_("To:"), 'TransToDate'); -submit_cells('Show',_("Show"),'','', true); +submit_cells('Show',_("Show"),'','', 'default'); end_row(); end_table(); end_form(); //------------------------------------------------------------------------------------------------ - -$date_after = date2sql($_POST['TransAfterDate']); -$date_to = date2sql($_POST['TransToDate']); if (!isset($_POST['bank_account'])) $_POST['bank_account'] = ""; -$sql = "SELECT ".TB_PREF."bank_trans.* FROM ".TB_PREF."bank_trans - WHERE ".TB_PREF."bank_trans.bank_act = '" . $_POST['bank_account'] . "' - AND trans_date >= '$date_after' - AND trans_date <= '$date_to' - ORDER BY trans_date,".TB_PREF."bank_trans.id"; -$result = db_query($sql,"The transactions for '" . $_POST['bank_account'] . "' could not be retrieved"); +$result = get_bank_trans_for_bank_account($_POST['bank_account'], $_POST['TransAfterDate'], $_POST['TransToDate']); div_start('trans_tbl'); $act = get_bank_account($_POST["bank_account"]); display_heading($act['bank_account_name']." - ".$act['bank_curr_code']); -start_table($table_style); +start_table(TABLESTYLE); $th = array(_("Type"), _("#"), _("Reference"), _("Date"), _("Debit"), _("Credit"), _("Balance"), _("Person/Item"), ""); table_header($th); -$sql = "SELECT SUM(amount) FROM ".TB_PREF."bank_trans WHERE bank_act='" . $_POST['bank_account'] . "' - AND trans_date < '$date_after'"; -$before_qty = db_query($sql, "The starting balance on hand could not be calculated"); +$bfw = get_balance_before_for_bank_account($_POST['bank_account'], $_POST['TransAfterDate']); -start_row("class='inquirybg'"); -label_cell(""._("Opening Balance")." - ".$_POST['TransAfterDate']."", "colspan=4"); -$bfw_row = db_fetch_row($before_qty); -$bfw = $bfw_row[0]; +$credit = $debit = 0; +start_row("class='inquirybg' style='font-weight:bold'"); +label_cell(_("Opening Balance")." - ".$_POST['TransAfterDate'], "colspan=4"); display_debit_or_credit_cells($bfw); label_cell(""); label_cell("", "colspan=2"); end_row(); $running_total = $bfw; +if ($bfw > 0 ) + $debit += $bfw; +else + $credit += $bfw; $j = 1; $k = 0; //row colour counter while ($myrow = db_fetch($result)) @@ -100,15 +96,19 @@ while ($myrow = db_fetch($result)) $running_total += $myrow["amount"]; $trandate = sql2date($myrow["trans_date"]); - label_cell(systypes::name($myrow["type"])); + label_cell($systypes_array[$myrow["type"]]); label_cell(get_trans_view_str($myrow["type"],$myrow["trans_no"])); label_cell(get_trans_view_str($myrow["type"],$myrow["trans_no"],$myrow['ref'])); label_cell($trandate); display_debit_or_credit_cells($myrow["amount"]); amount_cell($running_total); - label_cell(payment_person_types::person_name($myrow["person_type_id"],$myrow["person_id"])); + label_cell(get_counterparty_name($myrow["type"], $myrow["trans_no"])); label_cell(get_gl_view_str($myrow["type"], $myrow["trans_no"])); end_row(); + if ($myrow["amount"] > 0 ) + $debit += $myrow["amount"]; + else + $credit += $myrow["amount"]; if ($j == 12) { @@ -119,9 +119,12 @@ while ($myrow = db_fetch($result)) } //end of while loop -start_row("class='inquirybg'"); -label_cell("" . _("Ending Balance")." - ". $_POST['TransToDate']. "", "colspan=4"); -display_debit_or_credit_cells($running_total); +start_row("class='inquirybg' style='font-weight:bold'"); +label_cell(_("Ending Balance")." - ". $_POST['TransToDate'], "colspan=4"); +amount_cell($debit); +amount_cell(-$credit); +//display_debit_or_credit_cells($running_total); +amount_cell($debit+$credit); label_cell(""); label_cell("", "colspan=2"); end_row();