X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Fmanage%2Fexchange_rates.php;h=e50fc5f308ae6995876c35213866cffca5005969;hb=fea32048f1b2874f75b7f15af5f2d9667163a4d8;hp=5cd3ed217fff4a9c8348c679e7ce177be36f8b9e;hpb=f12dbe7523bb1abc6cd69b009ef8f0be838f5348;p=fa-stable.git diff --git a/gl/manage/exchange_rates.php b/gl/manage/exchange_rates.php index 5cd3ed21..e50fc5f3 100644 --- a/gl/manage/exchange_rates.php +++ b/gl/manage/exchange_rates.php @@ -1,7 +1,17 @@ . +***********************************************************************/ +$page_security = 'SA_EXCHANGERATE'; +$path_to_root = "../.."; +include($path_to_root . "/includes/db_pager.inc"); include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/includes/date_functions.inc"); @@ -11,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); @@ -24,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'); @@ -63,6 +67,7 @@ function handle_submit() } $selected_id = ''; + clear_data(); } //--------------------------------------------------------------------------------------------- @@ -75,38 +80,24 @@ function handle_delete() return; delete_exchange_rate($selected_id); $selected_id = ''; + clear_data(); } //--------------------------------------------------------------------------------------------- +function edit_link($row) +{ + return button('Edit'.$row["id"], _("Edit"), true, ICON_EDIT); +} + +function del_link($row) +{ + return button('Delete'.$row["id"], _("Delete"), true, ICON_DELETE); +} function display_rates($curr_code) { global $table_style; - $result = get_exchange_rates($curr_code); - - br(2); - start_table($table_style); - $th = array(_("Date to Use From"), _("Exchange Rate"), "", ""); - table_header($th); - - $k = 0; //row colour counter - - while ($myrow = db_fetch($result)) - { - - alt_table_row_color($k); - - label_cell(sql2date($myrow["date_"])); - label_cell(number_format2($myrow["rate_buy"], user_exrate_dec()), "nowrap align=right"); - edit_button_cell("Edit".$myrow["id"], _("Edit")); - edit_button_cell("Delete".$myrow["id"], _("Delete")); - - end_row(); - - } - - end_table(); } //--------------------------------------------------------------------------------------------- @@ -139,10 +130,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, '', @@ -151,7 +140,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); } @@ -178,14 +167,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 @@ -197,6 +186,16 @@ if ($_POST['curr_abrev'] != get_global_curr_code()) set_global_curr_code($_POST['curr_abrev']); +$sql = get_sql_for_exchange_rates(); + +$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'])) { @@ -206,7 +205,9 @@ if (is_company_currency($_POST['curr_abrev'])) else { - display_rates($_POST['curr_abrev']); + br(1); + $table->width = "40%"; + display_db_pager($table); br(1); display_rate_edit(); }