Fix for some buggy curl versions.
[fa-stable.git] / gl / manage / exchange_rates.php
index 5381831a52025e5c70eeb655f21fc37decaee129..493509f9d7a339eb3da2c23638b11b05972984db 100644 (file)
@@ -1,5 +1,14 @@
 <?php
-
+/**********************************************************************
+    Copyright (C) FrontAccounting, LLC.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
 $page_security = 9;
 $path_to_root="../..";
 include($path_to_root . "/includes/db_pager.inc");
@@ -93,24 +102,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);
 }
 
 //---------------------------------------------------------------------------------------------
@@ -144,9 +135,6 @@ 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.'));
-               }
                $Ajax->activate('BuyRate');
        }
        small_amount_row(_("Exchange Rate:"), 'BuyRate', null, '',
@@ -201,6 +189,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 +212,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();
 }