X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Fmanage%2Fexchange_rates.php;h=528b42030d6a74fde6a1c196f37c6e13a6cb22f9;hb=310a0d3ae5aeacbdaa0069546cc2652ac7518e6b;hp=5381831a52025e5c70eeb655f21fc37decaee129;hpb=fddc446ee6f00e8924d0777ca21ff8562f511464;p=fa-stable.git diff --git a/gl/manage/exchange_rates.php b/gl/manage/exchange_rates.php index 5381831a..528b4203 100644 --- a/gl/manage/exchange_rates.php +++ b/gl/manage/exchange_rates.php @@ -1,5 +1,14 @@ . +***********************************************************************/ $page_security = 9; $path_to_root="../.."; include($path_to_root . "/includes/db_pager.inc"); @@ -25,13 +34,7 @@ function check_data() set_focus('date_'); return false; } - if (!check_num('BuyRate', 0)) - { - display_error( _("The exchange rate must be numeric and greater than zero.")); - set_focus('BuyRate'); - return false; - } - if ($_POST['BuyRate'] <= 0) + if (input_num('BuyRate') <= 0) { display_error( _("The exchange rate cannot be zero or a negative number.")); set_focus('BuyRate'); @@ -93,24 +96,6 @@ function display_rates($curr_code) { global $table_style; - $sql = "SELECT date_, rate_buy, id FROM " - .TB_PREF."exchange_rates " - ."WHERE curr_code='$curr_code' - ORDER BY date_ DESC"; - - $cols = array( - _("Date to Use From") => 'date', - _("Exchange Rate") => 'rate', - array('insert'=>true, 'fun'=>'edit_link'), - array('insert'=>true, 'fun'=>'del_link'), - ); - $table =& new_db_pager('orders_tbl', $sql, $cols); - if (list_updated('curr_abrev')) { - $table->set_sql($sql); - $table->set_columns($cols); - } - $table->width = "40%"; - display_db_pager($table); } //--------------------------------------------------------------------------------------------- @@ -143,10 +128,8 @@ function display_rate_edit() } if (isset($_POST['get_rate'])) { - $_POST['BuyRate'] = exrate_format(get_ecb_rate($_POST['curr_abrev'])); - if ($_POST['BuyRate'] == 0) { - display_error(_('This currency is not listed by ECB. Enter exchange rate manually.')); - } + $_POST['BuyRate'] = + exrate_format(retrieve_exrate($_POST['curr_abrev'], $_POST['date_'])); $Ajax->activate('BuyRate'); } small_amount_row(_("Exchange Rate:"), 'BuyRate', null, '', @@ -155,7 +138,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); } @@ -182,7 +165,7 @@ if ($Mode == 'Delete') //--------------------------------------------------------------------------------------------- -start_form(false, true); +start_form(); if (!isset($_POST['curr_abrev'])) $_POST['curr_abrev'] = get_global_curr_code(); @@ -201,6 +184,19 @@ if ($_POST['curr_abrev'] != get_global_curr_code()) set_global_curr_code($_POST['curr_abrev']); +$sql = "SELECT date_, rate_buy, id FROM " + .TB_PREF."exchange_rates " + ."WHERE curr_code='".$_POST['curr_abrev']."' + ORDER BY date_ DESC"; + +$cols = array( + _("Date to Use From") => 'date', + _("Exchange Rate") => 'rate', + array('insert'=>true, 'fun'=>'edit_link'), + array('insert'=>true, 'fun'=>'del_link'), +); +$table =& new_db_pager('orders_tbl', $sql, $cols); + if (is_company_currency($_POST['curr_abrev'])) { @@ -211,7 +207,12 @@ else { br(1); - display_rates($_POST['curr_abrev']); + if (list_updated('curr_abrev')) { + $table->set_sql($sql); + $table->set_columns($cols); + } + $table->width = "40%"; + display_db_pager($table); br(1); display_rate_edit(); }