X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Fmanage%2Fbank_accounts.php;h=e0173b22d036186d53485c9f62b343fd346f6f33;hb=3626626c1d1497affa0e1b1f7da41c656e78a385;hp=6f1d3cd073d1fb6a868d8edc508e19b4fa53e62a;hpb=da8311619dd73feae101d246a1957b972e00cbd2;p=fa-stable.git diff --git a/gl/manage/bank_accounts.php b/gl/manage/bank_accounts.php index 6f1d3cd0..e0173b22 100644 --- a/gl/manage/bank_accounts.php +++ b/gl/manage/bank_accounts.php @@ -7,18 +7,11 @@ include($path_to_root . "/includes/session.inc"); page(_("Bank Accounts")); include($path_to_root . "/includes/ui.inc"); -include($path_to_root . "/includes/data_checks.inc"); -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -elseif (isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} +simple_page_mode(); +//----------------------------------------------------------------------------------- -if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { //initialise no input errors assumed initially before we test @@ -29,16 +22,18 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) { $input_error = 1; display_error(_("The bank account name cannot be empty.")); + set_focus('bank_account_name'); } if ($input_error != 1) { - if (isset($selected_id)) + if ($selected_id != -1) { update_bank_account($selected_id, $_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'); } else { @@ -46,13 +41,12 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) 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'); } - - meta_forward($_SERVER['PHP_SELF']); + $Mode = 'RESET'; } - } -elseif (isset($_GET['delete'])) +elseif( $Mode == 'Delete') { //the link to delete a selected record was clicked instead of the submit button @@ -71,8 +65,16 @@ elseif (isset($_GET['delete'])) if (!$cancel_delete) { delete_bank_account($selected_id); - meta_forward($_SERVER['PHP_SELF']); + display_notification('Selected bank account has been deleted'); + $Mode = 'RESET'; } //end if Delete bank account +} + +if ($Mode == 'RESET') +{ + $selected_id = -1; + $_POST['bank_name'] = $_POST['bank_account_name'] = ''; + $_POST['bank_account_number'] = $_POST['bank_address'] = ''; } /* Always show the list of accounts */ @@ -83,10 +85,11 @@ $result = db_query($sql,"could not get bank accounts"); 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")); + _("Type"), _("Number"), _("Currency"), _("Bank Address"),'',''); table_header($th); $k = 0; @@ -95,33 +98,30 @@ while ($myrow = db_fetch($result)) alt_table_row_color($k); - label_cell($myrow["account_code"] . " " . $myrow["account_name"]); - label_cell($myrow["bank_name"]); - label_cell($myrow["bank_account_name"]); - label_cell(bank_account_types::name($myrow["account_type"])); - label_cell($myrow["bank_account_number"]); - label_cell($myrow["bank_curr_code"]); + 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["bank_address"]); - edit_link_cell("selected_id=" . $myrow["account_code"]); - delete_link_cell("selected_id=" . $myrow["account_code"]. "&delete=1"); + edit_button_cell("Edit".$myrow["account_code"], _("Edit")); + edit_button_cell("Delete".$myrow["account_code"], _("Delete")); end_row(); } -//END WHILE LIST LOOP - end_table(); - -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Bank Account")); - +end_form(); +echo '
'; start_form(); -$is_editing = (isset($selected_id) && !isset($_GET['delete'])); +$is_editing = $selected_id != -1; start_table($table_style2); if ($is_editing) { - + if ($Mode == 'Edit') { $myrow = get_bank_account($selected_id); $_POST['account_code'] = $myrow["account_code"]; @@ -131,15 +131,17 @@ if ($is_editing) $_POST['bank_account_number'] = $myrow["bank_account_number"]; $_POST['bank_address'] = $myrow["bank_address"]; $_POST['BankAccountCurrency'] = $myrow["bank_curr_code"]; - + } hidden('selected_id', $selected_id); - hidden('account_code', $_POST['account_code']); + hidden('account_code'); hidden('BankAccountCurrency', $_POST['BankAccountCurrency']); label_row(_("Bank Account GL Code:"), $_POST['account_code']); + set_focus('account_type'); } 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); @@ -157,11 +159,11 @@ else currencies_list_row(_("Bank Account Currency:"), 'BankAccountCurrency', null); } -text_row(_("Bank Address:"), 'bank_address', null, 70, 70); +textarea_row(_("Bank Address:"), 'bank_address', null, 40, 5); end_table(1); -submit_add_or_update_center(!isset($selected_id)); +submit_add_or_update_center($selected_id == -1, '', true); end_form();