X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=inline;f=gl%2Fmanage%2Fbank_accounts.php;h=26fe90d5437ba2da3bea056095c0d654c009732a;hb=f4737ea725de62440c8bf58a7b4d7b187268fe93;hp=e0173b22d036186d53485c9f62b343fd346f6f33;hpb=3626626c1d1497affa0e1b1f7da41c656e78a385;p=fa-stable.git diff --git a/gl/manage/bank_accounts.php b/gl/manage/bank_accounts.php index e0173b22..26fe90d5 100644 --- a/gl/manage/bank_accounts.php +++ b/gl/manage/bank_accounts.php @@ -1,5 +1,14 @@ . +***********************************************************************/ $page_security = 10; $path_to_root="../.."; include($path_to_root . "/includes/session.inc"); @@ -30,18 +39,20 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') if ($selected_id != -1) { - update_bank_account($selected_id, $_POST['account_type'], $_POST['bank_account_name'], $_POST['bank_name'], - $_POST['bank_account_number'], + update_bank_account($selected_id, $_POST['account_code'], + $_POST['account_type'], $_POST['bank_account_name'], + $_POST['bank_name'], $_POST['bank_account_number'], $_POST['bank_address'], $_POST['BankAccountCurrency']); - display_notification('Bank account has been updated'); + display_notification(_('Bank account has been updated')); } else { - add_bank_account($_POST['account_code'], $_POST['account_type'], $_POST['bank_account_name'], $_POST['bank_name'], - $_POST['bank_account_number'], - $_POST['bank_address'], $_POST['BankAccountCurrency']); - display_notification('New bank account has been added'); + add_bank_account($_POST['account_code'], $_POST['account_type'], + $_POST['bank_account_name'], $_POST['bank_name'], + $_POST['bank_account_number'], $_POST['bank_address'], + $_POST['BankAccountCurrency']); + display_notification(_('New bank account has been added')); } $Mode = 'RESET'; } @@ -62,12 +73,20 @@ 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); - display_notification('Selected bank account has been deleted'); - $Mode = 'RESET'; + display_notification(_('Selected bank account has been deleted')); } //end if Delete bank account + $Mode = 'RESET'; } if ($Mode == 'RESET') @@ -79,8 +98,12 @@ if ($Mode == 'RESET') /* Always show the list of accounts */ -$sql = "SELECT ".TB_PREF."bank_accounts.*, ".TB_PREF."chart_master.account_name FROM ".TB_PREF."bank_accounts, ".TB_PREF."chart_master - WHERE ".TB_PREF."bank_accounts.account_code = ".TB_PREF."chart_master.account_code"; +$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"; +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"); check_db_error("The bank accounts set up could not be retreived", $sql); @@ -88,8 +111,9 @@ check_db_error("The bank accounts set up could not be retreived", $sql); start_form(); start_table("$table_style width='80%'"); -$th = array(_("GL Account"), _("Bank"), _("Account Name"), - _("Type"), _("Number"), _("Currency"), _("Bank Address"),'',''); +$th = array(_("Account Name"), _("Type"), _("Currency"), _("GL Account"), + _("Bank"), _("Number"), _("Bank Address"),'',''); +inactive_control_column($th); table_header($th); $k = 0; @@ -98,22 +122,21 @@ while ($myrow = db_fetch($result)) alt_table_row_color($k); - label_cell($myrow["account_code"] . " " . $myrow["account_name"], "nowrap"); - label_cell($myrow["bank_name"], "nowrap"); label_cell($myrow["bank_account_name"], "nowrap"); label_cell(bank_account_types::name($myrow["account_type"]), "nowrap"); - label_cell($myrow["bank_account_number"], "nowrap"); label_cell($myrow["bank_curr_code"], "nowrap"); + label_cell($myrow["account_code"] . " " . $myrow["account_name"], "nowrap"); + label_cell($myrow["bank_name"], "nowrap"); + label_cell($myrow["bank_account_number"], "nowrap"); label_cell($myrow["bank_address"]); - edit_button_cell("Edit".$myrow["account_code"], _("Edit")); - edit_button_cell("Delete".$myrow["account_code"], _("Delete")); + inactive_control_cell($myrow["id"], $myrow["inactive"], 'bank_accounts', 'id'); + edit_button_cell("Edit".$myrow["id"], _("Edit")); + delete_button_cell("Delete".$myrow["id"], _("Delete")); end_row(); } -end_table(); -end_form(); -echo '
'; -start_form(); +inactive_control_row($th); +end_table(1); $is_editing = $selected_id != -1; @@ -135,20 +158,12 @@ if ($is_editing) hidden('selected_id', $selected_id); hidden('account_code'); hidden('BankAccountCurrency', $_POST['BankAccountCurrency']); - label_row(_("Bank Account GL Code:"), $_POST['account_code']); - set_focus('account_type'); + set_focus('bank_account_name'); } -else -{ - gl_all_accounts_list_row(_("Bank Account GL Code:"), 'account_code', null, true); - set_focus('account_code'); -} -bank_account_types_list_row(_("Account Type:"), 'account_type', null); +text_row(_("Bank Account Name:"), 'bank_account_name', null, 50, 100); -text_row(_("Bank Name:"), 'bank_name', null, 50, 50); -text_row(_("Bank Account Name:"), 'bank_account_name', null, 50, 50); -text_row(_("Bank Account Number:"), 'bank_account_number', null, 30, 30); +bank_account_types_list_row(_("Account Type:"), 'account_type', null); if ($is_editing) { @@ -159,11 +174,18 @@ else currencies_list_row(_("Bank Account Currency:"), 'BankAccountCurrency', null); } +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); + +text_row(_("Bank Name:"), 'bank_name', null, 50, 60); +text_row(_("Bank Account Number:"), 'bank_account_number', null, 30, 60); 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();