diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index 408a1a35f2d..b82ae88f094 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -149,8 +149,8 @@ if ($action == 'add_currency') { // Manual insertion of a rate setEventMessages($langs->trans("SetupSaved"), null); } else { - // Run the update - $result = $multicurrency->syncRates(); + // Run the update o currency rate (this may updates database) + $result = $multicurrency->syncRates(0, 0, ''); if ($result > 0) { setEventMessages($langs->trans("CurrencyRateSyncSucceed"), null, "mesgs"); } else { diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index 728e9f0b5d0..e7d2ded797a 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -145,19 +145,19 @@ class modMultiCurrency extends DolibarrModules $this->cronjobs = array( 0 => array( - 'priority'=>61, - 'label'=>$langs->trans('MutltiCurrencyAutoUpdateCurrencies'), - 'jobtype'=>'method', - 'class'=>'multicurrency/class/multicurrency.class.php', - 'objectname'=>'MultiCurrency', - 'method'=>'syncRates', - 'parameters'=>'0,0,cron', - 'comment'=>'Update all the currencies using the currencylayer API. An API key needs to be given in the multi-currency module config page to have this job working.
First param is not used, Second parameter is 0 to update only already existing currency defined into the Multicurrency module or 1 to add any currency. Third parameter must be "cron".', - 'frequency'=>1, - 'unitfrequency'=>2678400, - 'status'=>$statusatinstall, - 'test'=>'isModEnabled("cron")', - 'datestart'=>$datestart + 'priority' => 61, + 'label' => $langs->trans('MutltiCurrencyAutoUpdateCurrencies'), + 'jobtype' => 'method', + 'class' => 'multicurrency/class/multicurrency.class.php', + 'objectname' => 'MultiCurrency', + 'method' => 'syncRates', + 'parameters' => '0,0,cron', + 'comment' => 'Update all the currencies using the currencylayer API. An API key needs to be given in the multi-currency module config page to have this job working.
First param is not used, Second parameter is 0 to update only already existing currency defined into the Multicurrency module or 1 to add any currency. Third parameter must be "cron".', + 'frequency' => 1, + 'unitfrequency' => 2678400, + 'status' => $statusatinstall, + 'test' => 'isModEnabled("cron")', + 'datestart' => $datestart ), ); diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index 69aa41f8cb2..fa280d81071 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -627,10 +627,10 @@ class MultiCurrency extends CommonObject } /** - * With free account we can't set source then recalcul all rates to force another source. + * With free account we can't set source to something else than US, to we recalculate all rates to force another source. * This modify the array &$TRate. * - * @param stdClass $TRate Object containing all currencies rates + * @param stdClass $TRate Object containing all currencies rates to recalculate * @return int -1 if KO, 0 if nothing, 1 if OK */ public function recalculRates(&$TRate) @@ -657,12 +657,12 @@ class MultiCurrency extends CommonObject /** * Sync rates from API * - * @param int|string $key No more used + * @param int $nu No more used * @param int $addifnotfound Add if not found * @param string $mode "" for standard use, "cron" to use it in a cronjob * @return int Return integer <0 if KO, >0 if OK, if mode = "cron" OK is 0 */ - public function syncRates($key = '', $addifnotfound = 0, $mode = "") + public function syncRates($nu = 0, $addifnotfound = 0, $mode = "") { global $db, $langs; @@ -698,6 +698,7 @@ class MultiCurrency extends CommonObject $TRate = $response->quotes; //$timestamp = $response->timestamp; + // Recalculate rate and update it (or add it) into database if ($this->recalculRates($TRate) >= 0) { foreach ($TRate as $currency_code => $rate) { $code = substr($currency_code, 3, 3);