Minor bug
[fa-stable.git] / gl / manage / bank_accounts.php
index 9cb5618055bf12d5c51c68f7f199ce0b544f1759..26fe90d5437ba2da3bea056095c0d654c009732a 100644 (file)
@@ -1,5 +1,14 @@
 <?php
-
+/**********************************************************************
+    Copyright (C) FrontAccounting, LLC.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
 $page_security = 10;
 $path_to_root="../..";
 include($path_to_root . "/includes/session.inc");
@@ -64,6 +73,14 @@ elseif( $Mode == 'Delete')
                $cancel_delete = 1;
                display_error(_("Cannot delete this bank account because transactions have been created using this account."));
        }
+       $sql= "SELECT COUNT(*) FROM ".TB_PREF."sales_pos WHERE pos_account='$selected_id'";
+       $result = db_query($sql,"check failed");
+       $myrow = db_fetch_row($result);
+       if ($myrow[0] > 0) 
+       {
+               $cancel_delete = 1;
+               display_error(_("Cannot delete this bank account because POS definitions have been created using this account."));
+       }
        if (!$cancel_delete) 
        {
                delete_bank_account($selected_id);
@@ -83,8 +100,9 @@ if ($Mode == 'RESET')
 
 $sql = "SELECT account.*, gl_account.account_name 
        FROM ".TB_PREF."bank_accounts account, ".TB_PREF."chart_master gl_account 
-       WHERE account.account_code = gl_account.account_code"
-       ." ORDER BY account_code, bank_curr_code";
+       WHERE account.account_code = gl_account.account_code";
+if (!check_value('show_inactive')) $sql .= " AND !account.inactive";
+$sql .= " ORDER BY account_code, bank_curr_code";
 
 $result = db_query($sql,"could not get bank accounts");
 
@@ -95,6 +113,7 @@ start_table("$table_style width='80%'");
 
 $th = array(_("Account Name"), _("Type"), _("Currency"), _("GL Account"), 
        _("Bank"), _("Number"), _("Bank Address"),'','');
+inactive_control_column($th);
 table_header($th);     
 
 $k = 0; 
@@ -110,15 +129,14 @@ while ($myrow = db_fetch($result))
     label_cell($myrow["bank_name"], "nowrap");
     label_cell($myrow["bank_account_number"], "nowrap");
     label_cell($myrow["bank_address"]);
+       inactive_control_cell($myrow["id"], $myrow["inactive"], 'bank_accounts', 'id');
        edit_button_cell("Edit".$myrow["id"], _("Edit"));
-       edit_button_cell("Delete".$myrow["id"], _("Delete"));
+       delete_button_cell("Delete".$myrow["id"], _("Delete"));
     end_row(); 
 }
 
-end_table();
-end_form();
-echo '<br>';
-start_form();
+inactive_control_row($th);
+end_table(1);
 
 $is_editing = $selected_id != -1; 
 
@@ -159,7 +177,7 @@ else
 if($is_editing)
        label_row(_("Bank Account GL Code:"), $_POST['account_code']);
 else 
-       gl_all_accounts_list_row(_("Bank Account GL Code:"), 'account_code', null, false);
+       gl_all_accounts_list_row(_("Bank Account GL Code:"), 'account_code', null);
 
 text_row(_("Bank Name:"), 'bank_name', null, 50, 60);
 text_row(_("Bank Account Number:"), 'bank_account_number', null, 30, 60);
@@ -167,7 +185,7 @@ textarea_row(_("Bank Address:"), 'bank_address', null, 40, 5);
 
 end_table(1);
 
-submit_add_or_update_center($selected_id == -1, '', true);
+submit_add_or_update_center($selected_id == -1, '', 'both');
 
 end_form();