From da17e6e676de53dd5dafcc2c2746aa7b136e1f36 Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 10 Mar 2016 23:52:06 +0100 Subject: [PATCH] New add sync with api to create/update all rates --- htdocs/admin/multicurrency.php | 103 ++++++++++++++++-- .../class/multicurrency.class.php | 11 ++ 2 files changed, 106 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index b1ad347d8b7..afb396a0217 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/multicurrency.lib.php'; require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; + // Translations $langs->load("multicurrency"); @@ -41,10 +42,17 @@ if (! $user->admin) { // Parameters $action = GETPOST('action', 'alpha'); - +$sync_response = GETPOST('sync_response'); /* * Actions */ +if (!empty($sync_response)) +{ + $sync_response = json_decode($sync_response); + MultiCurrency::syncRates($sync_response); + exit; +} + if (preg_match('/set_(.*)/',$action,$reg)) { $code=$reg[1]; @@ -64,7 +72,7 @@ if (preg_match('/del_(.*)/',$action,$reg)) $code=$reg[1]; if (dolibarr_del_const($db, $code, 0) > 0) { - Header("Location: ".$_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"]); exit; } else @@ -224,8 +232,8 @@ print ' '; print ''; print '
'; print ''; -print ''; -print ' '; +print ''; +print ' '; print ''; print '
'; print ''; @@ -244,16 +252,95 @@ print ''; print ''; print ''; - -print ''; - print '
'; + +print ''; + + print ''; print ''; print ''."\n"; print ''; -print ''."\n"; +print ''."\n"; $var=!$var; print ''; diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index fd6da3816ea..c78e7784ad1 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -520,6 +520,17 @@ class MultiCurrency extends CommonObject return false; } + + /** + * Sync rates from api + * + * @param array $response array of reponse from api to sync dolibarr rates + */ + public static function syncRates($response) + { + $TRate = $response['quotes']; + $timestamp = $response['timestamp']; + } } /**
'.$langs->trans("Currencies").' '.$langs->trans("Rate").''.$langs->trans("Rate").'