Display bank balance in payment forms.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Sun, 3 Apr 2011 21:58:41 +0000 (23:58 +0200)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Sun, 3 Apr 2011 21:58:41 +0000 (23:58 +0200)
gl/bank_transfer.php
gl/includes/ui/gl_bank_ui.inc
gl/inquiry/bank_inquiry.php
includes/ui/ui_input.inc
purchasing/supplier_payment.php

index a9f99defde024ad686a20eccedb874177cf8c2e5..89ba5fc788be3df8749f5248a9fdb65d02b3f91e 100644 (file)
@@ -65,6 +65,8 @@ function gl_payment_controls()
 
        bank_accounts_list_row(_("From Account:"), 'FromBankAccount', null, true);
 
+       bank_balance_row($_POST['FromBankAccount']);
+
     bank_accounts_list_row(_("To Account:"), 'ToBankAccount', null, true);
 
     date_row(_("Transfer Date:"), 'DatePaid', '', null, 0, 0, 0, null, true);
index 6454edbda9bb9cfa4fe631ed07cb0b2044239ab3..b1031a96fab554cac9b68b8202616156ca137643 100644 (file)
@@ -21,7 +21,10 @@ function display_bank_header(&$order)
        table_section(1);
        
     bank_accounts_list_row( $payment ? _("From:") : _("To:"), 'bank_account', null, true);
-
+    
+    if ($payment)
+               bank_balance_row($_POST['bank_account']);
+       
     date_row(_("Date:"), 'date_', '', true, 0, 0, 0, null, true);
 
        table_section(2, "33%");
index 65a691fd84ad511b9ce880ab57d4729b1fbecaf8..b264fe7f673f539571e71d27d8f51bcaefbac00a 100644 (file)
@@ -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(_($help_context = "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,6 +38,9 @@ if (get_post('Show'))
 }
 //------------------------------------------------------------------------------------------------
 
+if (isset($_GET['bank_account']))
+       $_POST['bank_account'] = $_GET['bank_account'];
+
 start_form();
 start_table(TABLESTYLE_NOBORDER);
 start_row();
index 1889962d28b56e30ee65f724de901a523e3a73c0..1e966a1a72758135e2bd5a06d434e2c0a41b660d 100644 (file)
@@ -931,4 +931,18 @@ function supplier_credit_row($supplier, $credit, $parms='')
                ."</a>", $parms);
 }
 
+function bank_balance_row($bank_acc, $parms='')
+{
+       global $path_to_root;
+       
+       $to = add_days(Today(), 1);
+       $bal = get_balance_before_for_bank_account($bank_acc, $to);
+       label_row( _("Bank Balance:"),
+               "<a target='_blank' " . ($bal<0 ? 'class="redfg"' : '')
+               ."href='$path_to_root/gl/inquiry/bank_inquiry.php?bank_account=".$bank_acc."'"
+               ." onclick=\"javascript:openWindow(this.href,this.target); return false;\" >&nbsp;"
+               . price_format($bal)
+               ."</a>", $parms);
+}
+
 ?>
\ No newline at end of file
index 5421ee401d426db3ce60862252aa81999c6a94df..276a821c7734ec3de7b0e5bfedcc8627db20d9e1 100644 (file)
@@ -275,6 +275,8 @@ start_form();
        set_global_supplier($_POST['supplier_id']);
        
     bank_accounts_list_row(_("From Bank Account:"), 'bank_account', null, true);
+       
+       bank_balance_row($_POST['bank_account']);
 
        table_section(2);