diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php
index 235b16ba100..e09347099de 100644
--- a/htdocs/admin/multicurrency.php
+++ b/htdocs/admin/multicurrency.php
@@ -119,6 +119,21 @@ elseif ($action == 'update_currency')
}
}
}
+elseif ($action == 'synchronize')
+{
+ $response = GETPOST('response');
+ $response = json_decode($response);
+
+ if ($response->success)
+ {
+ MultiCurrency::syncRates($response);
+ }
+ else
+ {
+ setEventMessages($langs->trans('multicurrency_syncronize_error', $reponse->error->info), null, 'errors');
+ }
+}
+
$TCurrency = array();
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE entity = '.$conf->entity;
@@ -139,9 +154,7 @@ if ($resql)
*/
$page_name = "MultiCurrency";
-$morejs = array('/multicurrency/js/currencylayer.js.php');
-
-llxHeader('', $langs->trans($page_name), '', '', '', '', $morejs);
+llxHeader('', $langs->trans($page_name));
// Subheader
$linkback = ''
@@ -228,7 +241,14 @@ print '
';
+
+
+print '
+
+';
+
llxFooter();
$db->close();
\ No newline at end of file
diff --git a/htdocs/multicurrency/ajax/updaterates.php b/htdocs/multicurrency/ajax/updaterates.php
deleted file mode 100644
index 663e68a647c..00000000000
--- a/htdocs/multicurrency/ajax/updaterates.php
+++ /dev/null
@@ -1,35 +0,0 @@
-
- * Copyright (C) 2016 Pierre-Henry Favre
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License 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
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
-if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
-if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
-if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
-if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
-if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1');
-
-require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
-
-$sync_response = GETPOST('sync_response');
-
-if (!empty($sync_response))
-{
- $sync_response = json_decode($sync_response);
- MultiCurrency::syncRates($sync_response);
-}
\ No newline at end of file
diff --git a/htdocs/multicurrency/js/currencylayer.js.php b/htdocs/multicurrency/js/currencylayer.js.php
deleted file mode 100644
index 0b563aae266..00000000000
--- a/htdocs/multicurrency/js/currencylayer.js.php
+++ /dev/null
@@ -1,98 +0,0 @@
-
- * Copyright (C) 2016 Pierre-Henry Favre
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License 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
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-include '../../main.inc.php';
-$langs->load('errors');
-
-?>
-
-function getXMLHttpRequest()
-{
- var xhr = null;
- if (window.XMLHttpRequest || window.ActiveXObject)
- {
- if (window.ActiveXObject)
- {
- try
- {
- xhr = new ActiveXObject("Msxml2.XMLHTTP");
- }
- catch(e)
- {
- xhr = new ActiveXObject("Microsoft.XMLHTTP");
- }
- }
- else
- {
- xhr = new XMLHttpRequest();
- }
- }
- else
- {
- if (typeof $ !== "undefined") $.jnotify("transnoentitiesnoconv('multicurrency_error_browser_incompatible'); ?>", "error");
- else alert("transnoentitiesnoconv('multicurrency_error_browser_incompatible'); ?>");
-
- return null;
- }
-
- return xhr;
-}
-
-function request(url, callback)
-{
- var xhr = getXMLHttpRequest();
- xhr.onreadystatechange = function()
- {
- if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0))
- {
- callback(xhr.responseText);
- }
-
- };
-
- xhr.open("GET", url, true);
- xhr.send(null);
-}
-
-function syncronize_rates()
-{
- document.getElementById("bt_sync").disabled = true;
- var url_sync = "http://apilayer.net/api/live?access_key=global->MULTICURRENCY_APP_ID; ?>&format=1global->MULTICURRENCY_APP_SOURCE)) echo '&source='.$conf->global->MULTICURRENCY_APP_SOURCE; ?>";
- request(url_sync, update_rates);
-}
-
-function update_rates(responseText)
-{
- var response = JSON.parse(responseText);
- if (response.success)
- {
- var url = "/multicurrency/ajax/updaterates.php?sync_response="+JSON.stringify(response);
- request(url, reloadpage);
- }
- else
- {
- if (typeof $ !== "undefined") $.jnotify("transnoentitiesnoconv('multicurrency_syncronize_error'); ?>: "+response.error.info, "error");
- else alert("transnoentitiesnoconv('multicurrency_syncronize_error'); ?>: "+response.error.info);
- }
-}
-
-function reloadpage(responseText)
-{
- document.getElementById("bt_sync").disabled = false;
- window.location.href = window.location.pathname;
-}