X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Fmanage%2Fexchange_rates.php;h=55259ff8fa4a16ef43956c0022264f5b958f58c6;hb=508b54ee5cef13ac64f1532dfedfb7b242aa9077;hp=493509f9d7a339eb3da2c23638b11b05972984db;hpb=d567a10b7925c8bb97c734e213d6651a979af29d;p=fa-stable.git diff --git a/gl/manage/exchange_rates.php b/gl/manage/exchange_rates.php index 493509f9..55259ff8 100644 --- a/gl/manage/exchange_rates.php +++ b/gl/manage/exchange_rates.php @@ -9,8 +9,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ -$page_security = 9; -$path_to_root="../.."; +$page_security = 'SA_EXCHANGERATE'; +$path_to_root = "../.."; include($path_to_root . "/includes/db_pager.inc"); include_once($path_to_root . "/includes/session.inc"); @@ -21,7 +21,7 @@ include_once($path_to_root . "/includes/banking.inc"); $js = ""; if ($use_date_picker) $js .= get_js_date_picker(); -page(_("Exchange Rates"), false, false, "", $js); +page(_($help_context = "Exchange Rates"), false, false, "", $js); simple_page_mode(false); @@ -34,19 +34,18 @@ function check_data() set_focus('date_'); return false; } - if (!check_num('BuyRate', 0)) + if (input_num('BuyRate') <= 0) { - display_error( _("The exchange rate must be numeric and greater than zero.")); + display_error( _("The exchange rate cannot be zero or a negative number.")); set_focus('BuyRate'); return false; } - if ($_POST['BuyRate'] <= 0) + if (get_date_exchange_rate($_POST['curr_abrev'], $_POST['date_'])) { - display_error( _("The exchange rate cannot be zero or a negative number.")); - set_focus('BuyRate'); + display_error( _("The exchange rate for the date is already there.")); + set_focus('date_'); return false; } - return true; } @@ -73,6 +72,7 @@ function handle_submit() } $selected_id = ''; + clear_data(); } //--------------------------------------------------------------------------------------------- @@ -85,6 +85,7 @@ function handle_delete() return; delete_exchange_rate($selected_id); $selected_id = ''; + clear_data(); } //--------------------------------------------------------------------------------------------- @@ -134,7 +135,8 @@ function display_rate_edit() } if (isset($_POST['get_rate'])) { - $_POST['BuyRate'] = exrate_format(get_ecb_rate($_POST['curr_abrev'])); + $_POST['BuyRate'] = + exrate_format(retrieve_exrate($_POST['curr_abrev'], $_POST['date_'])); $Ajax->activate('BuyRate'); } small_amount_row(_("Exchange Rate:"), 'BuyRate', null, '', @@ -143,7 +145,7 @@ function display_rate_edit() end_table(1); - submit_add_or_update_center($selected_id == '', '', true); + submit_add_or_update_center($selected_id == '', '', 'both'); display_note(_("Exchange rates are entered against the company currency."), 1); } @@ -170,14 +172,14 @@ if ($Mode == 'Delete') //--------------------------------------------------------------------------------------------- -start_form(false, true); +start_form(); if (!isset($_POST['curr_abrev'])) $_POST['curr_abrev'] = get_global_curr_code(); echo "
"; echo _("Select a currency :") . " "; -currencies_list('curr_abrev', null, true); +echo currencies_list('curr_abrev', null, true); echo "
"; // if currency sel has changed, clear the form @@ -191,7 +193,7 @@ set_global_curr_code($_POST['curr_abrev']); $sql = "SELECT date_, rate_buy, id FROM " .TB_PREF."exchange_rates " - ."WHERE curr_code='".$_POST['curr_abrev']."' + ."WHERE curr_code=".db_escape($_POST['curr_abrev'])." ORDER BY date_ DESC"; $cols = array( @@ -212,11 +214,9 @@ else { br(1); - if (list_updated('curr_abrev')) { - $table->set_sql($sql); - $table->set_columns($cols); - } $table->width = "40%"; + if ($table->rec_count == 0) + $table->ready = false; display_db_pager($table); br(1); display_rate_edit();