Merge pull request #8904 from Mavyre/develop
FIX Errors on synchronize rates when accessing Dolibarr from HTTPS
This commit is contained in:
commit
40ab046bd1
@ -142,17 +142,7 @@ elseif ($action == 'update_currency')
|
|||||||
}
|
}
|
||||||
elseif ($action == 'synchronize')
|
elseif ($action == 'synchronize')
|
||||||
{
|
{
|
||||||
$response = GETPOST('response');
|
MultiCurrency::syncRates($conf->global->MULTICURRENCY_APP_ID);
|
||||||
$response = json_decode($response);
|
|
||||||
|
|
||||||
if ($response->success)
|
|
||||||
{
|
|
||||||
MultiCurrency::syncRates($response);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setEventMessages($langs->trans('multicurrency_syncronize_error', $response->error->info), null, 'errors');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -841,9 +841,13 @@ if (! empty($conf->accounting->enabled) && ($modecompta == 'BOOKKEEPING'))
|
|||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
|
|
||||||
if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0;
|
if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0;
|
||||||
$encaiss[$obj->dm] += $obj->debit;
|
if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0;
|
||||||
|
$encaiss[$obj->dm] += $obj->credit;
|
||||||
|
$decaiss[$obj->dm] += $obj->debit;
|
||||||
if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0;
|
if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0;
|
||||||
|
if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0;
|
||||||
$encaiss_ttc[$obj->dm] += 0;
|
$encaiss_ttc[$obj->dm] += 0;
|
||||||
|
$decaiss_ttc[$obj->dm] += 0;
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -626,24 +626,38 @@ class MultiCurrency extends CommonObject
|
|||||||
{
|
{
|
||||||
global $db,$conf;
|
global $db,$conf;
|
||||||
|
|
||||||
$TRate = $response->quotes;
|
$ch = curl_init('http://apilayer.net/api/live?access_key='.$key.'');
|
||||||
$timestamp = $response->timestamp;
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
$response = curl_exec($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
$response = json_decode($response);
|
||||||
|
|
||||||
|
if ($response->success)
|
||||||
|
{
|
||||||
|
|
||||||
if (self::recalculRates($TRate) >= 0)
|
$TRate = $response->quotes;
|
||||||
{
|
$timestamp = $response->timestamp;
|
||||||
foreach ($TRate as $currency_code => $rate)
|
|
||||||
|
if (self::recalculRates($TRate) >= 0)
|
||||||
{
|
{
|
||||||
$code = substr($currency_code, 3, 3);
|
foreach ($TRate as $currency_code => $rate)
|
||||||
$obj = new MultiCurrency($db);
|
|
||||||
if ($obj->fetch(null, $code) > 0)
|
|
||||||
{
|
{
|
||||||
$obj->updateRate($rate);
|
$code = substr($currency_code, 3, 3);
|
||||||
}
|
$obj = new MultiCurrency($db);
|
||||||
else
|
if ($obj->fetch(null, $code) > 0)
|
||||||
{
|
{
|
||||||
self::addRateFromDolibarr($code, $rate);
|
$obj->updateRate($rate);
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
self::addRateFromDolibarr($code, $rate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans('multicurrency_syncronize_error', $response->error->info), null, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user