From: Janusz Dobrowolski Date: Fri, 4 Jul 2008 21:37:43 +0000 (+0000) Subject: Ajax additions X-Git-Tag: v2.4.2~19^2~1938 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=3626626c1d1497affa0e1b1f7da41c656e78a385;p=fa-stable.git Ajax additions --- diff --git a/gl/inquiry/bank_inquiry.php b/gl/inquiry/bank_inquiry.php index 9407a07e..d45570c9 100644 --- a/gl/inquiry/bank_inquiry.php +++ b/gl/inquiry/bank_inquiry.php @@ -20,10 +20,16 @@ page(_("Bank Statement"), false, false, "", $js); check_db_has_bank_accounts(_("There are no bank accounts defined in the system.")); +//----------------------------------------------------------------------------------- +// Ajax updates +// +if (get_post('Show')) +{ + $Ajax->activate('trans_tbl'); +} //------------------------------------------------------------------------------------------------ start_form(); - start_table("class='tablestyle_noborder'"); start_row(); bank_accounts_list_cells(_("Account:"), 'bank_account', null); @@ -31,7 +37,7 @@ bank_accounts_list_cells(_("Account:"), 'bank_account', null); date_cells(_("From:"), 'TransAfterDate', '', null, -30); date_cells(_("To:"), 'TransToDate'); -submit_cells('Show',_("Show")); +submit_cells('Show',_("Show"),'','', true); end_row(); end_table(); end_form(); @@ -55,6 +61,7 @@ $result = db_query($sql,"The transactions for '" . $_POST['bank_account'] . "' c $act = get_bank_account($_POST["bank_account"]); display_heading($act['bank_account_name']." - ".$act['bank_curr_code']); +div_start('trans_tbl'); start_table($table_style); $th = array(_("Type"), _("#"), _("Reference"), _("Type"), _("Date"), @@ -110,7 +117,7 @@ display_debit_or_credit_cells($running_total); label_cell(""); end_row(); end_table(2); - +div_end(); //------------------------------------------------------------------------------------------------ end_page(); diff --git a/gl/inquiry/gl_account_inquiry.php b/gl/inquiry/gl_account_inquiry.php index 0b0c2709..668a61de 100644 --- a/gl/inquiry/gl_account_inquiry.php +++ b/gl/inquiry/gl_account_inquiry.php @@ -21,6 +21,12 @@ if ($use_date_picker) page(_("General Ledger Account Inquiry"), false, false, '', $js); //---------------------------------------------------------------------------------------------------- +// Ajax updates +// +if (get_post('Show')) +{ + $Ajax->activate('trans_tbl'); +} if (isset($_GET["account"])) $_POST["account"] = $_GET["account"]; @@ -50,7 +56,7 @@ function gl_inquiry_controls() date_cells(_("from:"), 'TransFromDate', '', null, -30); date_cells(_("to:"), 'TransToDate'); - submit_cells('Show',_("Show")); + submit_cells('Show',_("Show"),'','', true); end_row(); @@ -83,6 +89,7 @@ function show_results() $_POST["account"], $_POST['Dimension'], $_POST['Dimension2']); $colspan = ($dim == 2 ? "6" : ($dim == 1 ? "5" : "4")); + div_start('trans_tbl'); //echo "\nDimension =". $_POST['Dimension']; display_heading($_POST["account"]. "   ".$act_name); @@ -159,6 +166,7 @@ function show_results() end_table(2); if (db_num_rows($result) == 0) display_note(_("No general ledger transactions have been created for this account on the selected dates."), 0, 1); + div_end(); } //---------------------------------------------------------------------------------------------------- diff --git a/gl/inquiry/gl_trial_balance.php b/gl/inquiry/gl_trial_balance.php index d5b7bc76..b3dee997 100644 --- a/gl/inquiry/gl_trial_balance.php +++ b/gl/inquiry/gl_trial_balance.php @@ -18,6 +18,12 @@ if ($use_date_picker) page(_("Trial Balance"), false, false, "", $js); //---------------------------------------------------------------------------------------------------- +// Ajax updates +// +if (get_post('Show')) +{ + $Ajax->activate('balance_tbl'); +} function gl_inquiry_controls() @@ -30,7 +36,7 @@ function gl_inquiry_controls() date_cells(_("To:"), 'TransToDate'); check_cells(_("No zero values"), 'NoZero', null); - submit_cells('Show',_("Show")); + submit_cells('Show',_("Show"),'','', true); end_table(); end_form(); } @@ -72,6 +78,7 @@ function display_trial_balance() { global $table_style, $path_to_root; + div_start('balance_tbl'); start_table($table_style); $tableheader = " " . _("Account") . " @@ -124,7 +131,7 @@ function display_trial_balance() } end_table(1); - + div_end(); } //---------------------------------------------------------------------------------------------------- diff --git a/gl/manage/bank_accounts.php b/gl/manage/bank_accounts.php index c7d665c3..e0173b22 100644 --- a/gl/manage/bank_accounts.php +++ b/gl/manage/bank_accounts.php @@ -8,16 +8,10 @@ page(_("Bank Accounts")); include($path_to_root . "/includes/ui.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 @@ -33,12 +27,13 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) 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; @@ -102,26 +105,23 @@ while ($myrow = db_fetch($result)) 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); @@ -158,11 +160,10 @@ else } textarea_row(_("Bank Address:"), 'bank_address', null, 40, 5); -//text_row(_("Bank Address:"), 'bank_address', null, 70, 70); end_table(1); -submit_add_or_update_center(!isset($selected_id)); +submit_add_or_update_center($selected_id == -1, '', true); end_form(); diff --git a/gl/manage/bank_trans_types.php b/gl/manage/bank_trans_types.php index 5f5267f3..37c6bf32 100644 --- a/gl/manage/bank_trans_types.php +++ b/gl/manage/bank_trans_types.php @@ -11,19 +11,10 @@ include($path_to_root . "/gl/includes/gl_db.inc"); include($path_to_root . "/includes/ui.inc"); -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -elseif(isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} -else - $selected_id = -1; +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 @@ -41,17 +32,15 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) if ($selected_id != -1) { - update_bank_trans_type($selected_id, $_POST['name']); - + display_notification('Selected bank account settings has been updated'); } else { - - add_bank_trans_type($_POST['name']); + add_bank_trans_type($_POST['name']); + display_notification('New bank account has been added'); } - - meta_forward($_SERVER['PHP_SELF']); + $Mode = 'RESET'; } } @@ -76,25 +65,30 @@ function can_delete($selected_id) //----------------------------------------------------------------------------------- -if (isset($_GET['delete'])) +if( $Mode == 'Delete') { - if (can_delete($selected_id)) { delete_bank_trans_type($selected_id); - meta_forward($_SERVER['PHP_SELF']); + display_notification('Selected bank account has been deleted'); } + $Mode = 'RESET'; } +if ($Mode == 'RESET') +{ + $selected_id = -1; + $_POST['name'] = ''; +} //----------------------------------------------------------------------------------- $result = get_all_bank_trans_type(); +start_form(); start_table($table_style); $th = array(_("Description"), "", ""); table_header($th); - $k = 0; while ($myrow = db_fetch($result)) { @@ -102,17 +96,16 @@ while ($myrow = db_fetch($result)) alt_table_row_color($k); label_cell($myrow["name"]); - edit_link_cell("selected_id=" . $myrow["id"]); - delete_link_cell("selected_id=" . $myrow["id"]. "&delete=1"); + + edit_button_cell("Edit".$myrow["id"], _("Edit")); + edit_button_cell("Delete".$myrow["id"], _("Delete")); end_row(); } - end_table(); - +end_form(); +echo '
'; //----------------------------------------------------------------------------------- -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Bank Transaction Type")); - start_form(); start_table($table_style2); @@ -120,19 +113,19 @@ start_table($table_style2); if ($selected_id != -1) { //editing an existing status code - - $myrow = get_bank_trans_type($selected_id); - - $_POST['name'] = $myrow["name"]; - + if ($Mode == 'Edit') { + $myrow = get_bank_trans_type($selected_id); + $_POST['name'] = $myrow["name"]; + } hidden('selected_id', $selected_id); } +set_focus('name'); text_row_ex(_("Description:"), 'name', 40); end_table(1); -submit_add_or_update_center($selected_id == -1); +submit_add_or_update_center($selected_id == -1, '', true); end_form(); diff --git a/gl/manage/currencies.php b/gl/manage/currencies.php index 48866256..0721dfaf 100644 --- a/gl/manage/currencies.php +++ b/gl/manage/currencies.php @@ -9,18 +9,8 @@ page(_("Currencies")); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/banking.inc"); -//--------------------------------------------------------------------------------------------- +simple_page_mode(false); -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -elseif (isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} -else - $selected_id = ""; //--------------------------------------------------------------------------------------------- function check_data() @@ -57,7 +47,7 @@ function check_data() function handle_submit() { - global $selected_id; + global $selected_id, $Mode; if (!check_data()) return false; @@ -67,15 +57,16 @@ function handle_submit() update_currency($_POST['Abbreviation'], $_POST['Symbol'], $_POST['CurrencyName'], $_POST['country'], $_POST['hundreds_name']); + display_notification('Selected currency settings has been updated'); } else { add_currency($_POST['Abbreviation'], $_POST['Symbol'], $_POST['CurrencyName'], $_POST['country'], $_POST['hundreds_name']); - } - - return true; + display_notification('New currency has been added'); + } + $Mode = 'RESET'; } //--------------------------------------------------------------------------------------------- @@ -131,14 +122,14 @@ function check_can_delete() function handle_delete() { - global $selected_id; + global $selected_id, $Mode; if (!check_can_delete()) return; //only delete if used in neither customer or supplier, comp prefs, bank trans accounts delete_currency($selected_id); - - meta_forward($_SERVER['PHP_SELF']); + display_notification('Selected currency has been deleted'); + $Mode = 'RESET'; } //--------------------------------------------------------------------------------------------- @@ -150,7 +141,7 @@ function display_currencies() $company_currency = get_company_currency(); $result = get_currencies(); - + start_form(); start_table($table_style); $th = array(_("Abbreviation"), _("Symbol"), _("Currency Name"), _("Hundredths name"), _("Country"), "", ""); @@ -173,9 +164,9 @@ function display_currencies() label_cell($myrow["currency"]); label_cell($myrow["hundreds_name"]); label_cell($myrow["country"]); - edit_link_cell("selected_id=" . $myrow["curr_abrev"]); + edit_button_cell("Edit".$myrow["curr_abrev"], _("Edit")); if ($myrow["curr_abrev"] != $company_currency) - delete_link_cell("selected_id=" . $myrow["curr_abrev"]. "&delete=1"); + edit_button_cell("Delete".$myrow["curr_abrev"], _("Delete")); else label_cell(''); end_row(); @@ -183,7 +174,7 @@ function display_currencies() } //END WHILE LIST LOOP end_table(); - + end_form(); display_note(_("The marked currency is the home currency which cannot be deleted."), 0, 0, "class='currentfg'"); } @@ -191,25 +182,26 @@ function display_currencies() function display_currency_edit($selected_id) { - global $table_style2; + global $table_style2, $Mode; start_form(); start_table($table_style2); - if ($selected_id != "") + if ($selected_id != '') { - //editing an existing currency - $myrow = get_currency($selected_id); - - $_POST['Abbreviation'] = $myrow["curr_abrev"]; - $_POST['Symbol'] = $myrow["curr_symbol"]; - $_POST['CurrencyName'] = $myrow["currency"]; - $_POST['country'] = $myrow["country"]; - $_POST['hundreds_name'] = $myrow["hundreds_name"]; - + if ($Mode == 'Edit') { + //editing an existing currency + $myrow = get_currency($selected_id); + + $_POST['Abbreviation'] = $myrow["curr_abrev"]; + $_POST['Symbol'] = $myrow["curr_symbol"]; + $_POST['CurrencyName'] = $myrow["currency"]; + $_POST['country'] = $myrow["country"]; + $_POST['hundreds_name'] = $myrow["hundreds_name"]; + } + hidden('Abbreviation'); hidden('selected_id', $selected_id); - hidden('Abbreviation', $_POST['Abbreviation']); - label_row(_("Currency Abbreviation:"), $_POST['Abbreviation']); + label_row(_("Currency Abbreviation:"), $_POST['Abbreviation']); } else { @@ -223,36 +215,32 @@ function display_currency_edit($selected_id) end_table(1); - submit_add_or_update_center($selected_id == ""); + submit_add_or_update_center($selected_id == '', '', true); end_form(); } //--------------------------------------------------------------------------------------------- -if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) -{ - - if (handle_submit()) - { - meta_forward($_SERVER['PHP_SELF']); - } -} +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') + handle_submit(); //--------------------------------------------------------------------------------------------- -if (isset($_GET['delete'])) -{ - +if ($Mode == 'Delete') handle_delete(); -} //--------------------------------------------------------------------------------------------- +if ($Mode == 'RESET') +{ + $selected_id = ''; + $_POST['Abbreviation'] = $_POST['Symbol'] = ''; + $_POST['CurrencyName'] = $_POST['country'] = ''; + $_POST['hundreds_name'] = ''; +} display_currencies(); -hyperlink_no_params($_SERVER['PHP_SELF'], _("Enter a New Currency")); - display_currency_edit($selected_id); //--------------------------------------------------------------------------------------------- diff --git a/gl/manage/exchange_rates.php b/gl/manage/exchange_rates.php index 6dfe221d..669895b1 100644 --- a/gl/manage/exchange_rates.php +++ b/gl/manage/exchange_rates.php @@ -13,18 +13,8 @@ if ($use_date_picker) $js .= get_js_date_picker(); page(_("Exchange Rates"), false, false, "", $js); -//--------------------------------------------------------------------------------------------- +simple_page_mode(false); -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -elseif (isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} -else - $selected_id = ""; //--------------------------------------------------------------------------------------------- function check_data() { @@ -63,7 +53,7 @@ function handle_submit() { update_exchange_rate($_POST['curr_abrev'], $_POST['date_'], - input_num('BuyRate'), input_num('BuyRate')); + input_num('BuyRate'), input_num('BuyRate')); } else { @@ -72,7 +62,7 @@ function handle_submit() input_num('BuyRate'), input_num('BuyRate')); } - return true; + $selected_id = ''; } //--------------------------------------------------------------------------------------------- @@ -84,8 +74,7 @@ function handle_delete() if ($selected_id == "") return; delete_exchange_rate($selected_id); - - meta_forward($_SERVER['PHP_SELF']); + $selected_id = ''; } //--------------------------------------------------------------------------------------------- @@ -110,12 +99,12 @@ function display_rates($curr_code) label_cell(sql2date($myrow["date_"])); label_cell(number_format2($myrow["rate_buy"], user_exrate_dec()), "nowrap align=right"); - edit_link_cell("selected_id=" . $myrow["id"]); - delete_link_cell("selected_id=" . $myrow["id"]. "&delete=1"); + edit_button_cell("Edit".$myrow["id"], _("Edit")); + edit_button_cell("Delete".$myrow["id"], _("Delete")); end_row(); - } //END WHILE LIST LOOP + } end_table(); } @@ -124,14 +113,10 @@ function display_rates($curr_code) function display_rate_edit() { - global $selected_id, $table_style2; + global $selected_id, $table_style2, $Ajax; start_table($table_style2); - if (isset($_POST['get_rate'])) - { - $_POST['BuyRate'] = exrate_format(get_ecb_rate($_POST['curr_abrev'])); - } if ($selected_id != "") { //editing an existing exchange rate @@ -143,20 +128,27 @@ function display_rate_edit() hidden('selected_id', $selected_id); hidden('date_', $_POST['date_']); - hidden('curr_abrev', $_POST['curr_abrev']); label_row(_("Date to Use From:"), $_POST['date_']); } else { + $_POST['date_'] = Today(); + $_POST['BuyRate'] = ''; date_row(_("Date to Use From:"), 'date_'); } + if (isset($_POST['get_rate'])) + { + $_POST['BuyRate'] = exrate_format(get_ecb_rate($_POST['curr_abrev'])); + $Ajax->activate('BuyRate'); + } small_amount_row(_("Exchange Rate:"), 'BuyRate', null, '', - submit('get_rate',_("Get"), false), user_exrate_dec()); + submit('get_rate',_("Get"), false, _('Get current ECB rate') , true), + user_exrate_dec()); end_table(1); - submit_add_or_update_center($selected_id == ""); + submit_add_or_update_center($selected_id == '', '', true); display_note(_("Exchange rates are entered against the company currency."), 1); } @@ -172,22 +164,14 @@ function clear_data() //--------------------------------------------------------------------------------------------- -if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) -{ - - if (handle_submit()) - { - meta_forward($_SERVER['PHP_SELF']); - } -} +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') + handle_submit(); //--------------------------------------------------------------------------------------------- -if (isset($_GET['delete'])) -{ - +if ($Mode == 'Delete') handle_delete(); -} + //--------------------------------------------------------------------------------------------- @@ -198,7 +182,7 @@ if (!isset($_POST['curr_abrev'])) echo "
"; echo _("Select a currency :") . " "; -currencies_list('curr_abrev', $_POST['curr_abrev'], true); +currencies_list('curr_abrev', null, true); echo "
"; // if currency sel has changed, clear the form @@ -220,10 +204,7 @@ else { display_rates($_POST['curr_abrev']); - - hyperlink_no_params($_SERVER['PHP_SELF'], _("Enter a New Exchange Rate")); br(1); - display_rate_edit(); } diff --git a/gl/manage/gl_account_classes.php b/gl/manage/gl_account_classes.php index f0fd7edb..5cd8c5b8 100644 --- a/gl/manage/gl_account_classes.php +++ b/gl/manage/gl_account_classes.php @@ -10,16 +10,7 @@ include($path_to_root . "/gl/includes/gl_db.inc"); include($path_to_root . "/includes/ui.inc"); -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -elseif(isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} -else - $selected_id = -1; +simple_page_mode(true); //----------------------------------------------------------------------------------- function can_process() @@ -37,7 +28,7 @@ function can_process() //----------------------------------------------------------------------------------- -if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { if (can_process()) @@ -45,16 +36,15 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) if ($selected_id != -1) { - update_account_class($selected_id, $_POST['name'], $_POST['Balance']); - + display_notification('Selected account class settings has been updated'); } else { - add_account_class($_POST['id'], $_POST['name'], $_POST['Balance']); + display_notification('New account class has been added'); } - meta_forward($_SERVER['PHP_SELF']); + $Mode = 'RESET'; } } @@ -80,20 +70,27 @@ function can_delete($selected_id) //----------------------------------------------------------------------------------- -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { if (can_delete($selected_id)) { delete_account_class($selected_id); - meta_forward($_SERVER['PHP_SELF']); + display_notification('Selected account class has been deleted'); + $Mode = 'RESET'; } } +//----------------------------------------------------------------------------------- +if ($Mode == 'RESET') +{ + $selected_id = -1; + $_POST['id'] = $_POST['name'] = $_POST['Balance'] = ''; +} //----------------------------------------------------------------------------------- $result = get_account_classes(); - +start_form(); start_table($table_style); $th = array(_("Class ID"), _("Class Name"), _("Balance Sheet"), "", ""); table_header($th); @@ -115,31 +112,32 @@ while ($myrow = db_fetch($result)) label_cell($myrow["cid"]); label_cell($myrow['class_name']); label_cell($bs_text); - edit_link_cell("selected_id=" . $myrow["cid"]); - delete_link_cell("selected_id=" . $myrow["cid"]. "&delete=1"); + edit_button_cell("Edit".$myrow["cid"], _("Edit")); + edit_button_cell("Delete".$myrow["cid"], _("Delete")); end_row(); } end_table(); - +end_form(); +echo '
'; //----------------------------------------------------------------------------------- -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Account Class")); - start_form(); start_table($table_style2); if ($selected_id != -1) { + if ($Mode == 'Edit') { //editing an existing status code - $myrow = get_account_class($selected_id); $_POST['id'] = $myrow["cid"]; $_POST['name'] = $myrow["class_name"]; $_POST['Balance'] = $myrow["balance_sheet"]; hidden('selected_id', $selected_id); + } + hidden('id'); label_row(_("Class ID:"), $_POST['id']); } diff --git a/gl/manage/gl_account_types.php b/gl/manage/gl_account_types.php index 6426408f..b570dd43 100644 --- a/gl/manage/gl_account_types.php +++ b/gl/manage/gl_account_types.php @@ -10,16 +10,7 @@ include($path_to_root . "/gl/includes/gl_db.inc"); include($path_to_root . "/includes/ui.inc"); -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -elseif(isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} -else - $selected_id = ""; +simple_page_mode(false); //----------------------------------------------------------------------------------- function can_process() @@ -44,7 +35,7 @@ function can_process() //----------------------------------------------------------------------------------- -if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { if (can_process()) @@ -52,16 +43,15 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) if ($selected_id != "") { - update_account_type($selected_id, $_POST['name'], $_POST['class_id'], $_POST['parent']); - + display_notification('Selected account type has been updated'); } else { - add_account_type($_POST['name'], $_POST['class_id'], $_POST['parent']); + display_notification('New account type has been added'); } - meta_forward($_SERVER['PHP_SELF']); + $Mode = 'RESET'; } } @@ -97,20 +87,27 @@ function can_delete($selected_id) //----------------------------------------------------------------------------------- -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { if (can_delete($selected_id)) { delete_account_type($selected_id); - meta_forward($_SERVER['PHP_SELF']); + display_notification('Selected currency has been deleted'); + $Mode = 'RESET'; } } - +if ($Mode == 'RESET') +{ + $selected_id = ''; + $_POST['name'] = ''; + unset($_POST['parent']); + unset($_POST['class_id']); +} //----------------------------------------------------------------------------------- $result = get_account_types(); - +start_form(); start_table($table_style); $th = array(_("Name"), _("Subgroup Of"), _("Class Type"), "", ""); table_header($th); @@ -135,33 +132,30 @@ while ($myrow = db_fetch($result)) label_cell($myrow["name"]); label_cell($parent_text); label_cell($bs_text); - edit_link_cell("selected_id=" . $myrow["id"]); - delete_link_cell("selected_id=" . $myrow["id"]. "&delete=1"); + edit_button_cell("Edit".$myrow["id"], _("Edit")); + edit_button_cell("Delete".$myrow["id"], _("Delete")); end_row(); } end_table(); - +end_form(); +echo '
'; //----------------------------------------------------------------------------------- -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Account Group")); - start_form(); start_table($table_style2); -if ($selected_id != "") +if ($Mode == 'Edit') { //editing an existing status code - $myrow = get_account_type($selected_id); $_POST['name'] = $myrow["name"]; $_POST['parent'] = $myrow["parent"]; $_POST['class_id'] = $myrow["class_id"]; - + } hidden('selected_id', $selected_id); -} text_row_ex(_("Name:"), 'name', 50); @@ -171,7 +165,7 @@ class_list_row(_("Class Type:"), 'class_id', null); end_table(1); -submit_add_or_update_center($selected_id == ""); +submit_add_or_update_center($selected_id == '', '', true); end_form();