Debug v17
This commit is contained in:
parent
26ef1cb270
commit
f8451ffc56
@ -134,7 +134,8 @@ if ($action == 'add_currency') {
|
||||
dolibarr_set_const($db, 'MULTICURRENCY_APP_SOURCE', GETPOST('MULTICURRENCY_APP_SOURCE', 'alpha'));
|
||||
//dolibarr_set_const($db, 'MULTICURRENCY_ALTERNATE_SOURCE', GETPOST('MULTICURRENCY_ALTERNATE_SOURCE', 'alpha'));
|
||||
} else {
|
||||
$result = MultiCurrency::syncRates($conf->global->MULTICURRENCY_APP_ID);
|
||||
$multiurrency = new MultiCurrency($db);
|
||||
$result = $multiurrency->syncRates(getDolGlobalString('MULTICURRENCY_APP_ID'));
|
||||
if ($result > 0) {
|
||||
setEventMessages($langs->trans("CurrencyRateSyncSucceed"), null, "mesgs");
|
||||
}
|
||||
|
||||
@ -600,30 +600,27 @@ class Job extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Get last job for user
|
||||
* Get the last occupied position for a user
|
||||
*
|
||||
* @param int $fk_user id of user we need to get last job
|
||||
* @return mixed|string|null
|
||||
* @param int $fk_user Id of user we need to get last job
|
||||
* @return Position|string Last occupied position
|
||||
*/
|
||||
public function getLastJobForUser($fk_user)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$j = new Job($db);
|
||||
$Tab = $j->getForUser($fk_user);
|
||||
$Tab = $this->getForUser($fk_user);
|
||||
|
||||
if (empty($Tab)) return '';
|
||||
|
||||
$job = array_shift($Tab);
|
||||
$lastpos = array_shift($Tab);
|
||||
|
||||
return $job;
|
||||
return $lastpos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get jobs for user
|
||||
* Get array of occupied positions for a user
|
||||
*
|
||||
* @param int $userid id of user we need to get job list
|
||||
* @return array of jobs
|
||||
* @param int $userid Id of user we need to get job list
|
||||
* @return Position[] Array of occupied positions
|
||||
*/
|
||||
public function getForUser($userid)
|
||||
{
|
||||
|
||||
@ -1036,6 +1036,8 @@ class Position extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* getForUser
|
||||
*
|
||||
* @param int $userid id of user we need to get position list
|
||||
* @return array|int of positions of user with for each of them the job fetched into that array
|
||||
*/
|
||||
@ -1049,7 +1051,7 @@ class Position extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a document onto disk according to template module.
|
||||
* Create a document onto disk according to template module.
|
||||
*
|
||||
* @param string $modele Force template to use ('' to not force)
|
||||
* @param Translate $outputlangs objet lang a utiliser pour traduction
|
||||
|
||||
@ -428,7 +428,7 @@ class MultiCurrency extends CommonObject
|
||||
*
|
||||
* @param string $code currency code
|
||||
* @param double $rate new rate
|
||||
* @return int -1 if KO, 1 if OK, 2 if label found and OK
|
||||
* @return int -1 if KO, 1 if OK, 2 if label found and OK
|
||||
*/
|
||||
public function addRateFromDolibarr($code, $rate)
|
||||
{
|
||||
@ -609,14 +609,14 @@ class MultiCurrency extends CommonObject
|
||||
* @param stdClass $TRate Object containing all currencies rates
|
||||
* @return int -1 if KO, 0 if nothing, 1 if OK
|
||||
*/
|
||||
public static function recalculRates(&$TRate)
|
||||
public function recalculRates(&$TRate)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if ($conf->currency != $conf->global->MULTICURRENCY_APP_SOURCE) {
|
||||
if ($conf->currency != getDolGlobalString('MULTICURRENCY_APP_SOURCE')) {
|
||||
$alternate_source = 'USD'.$conf->currency;
|
||||
if (!empty($TRate->{$alternate_source})) {
|
||||
$coef = $TRate->USDUSD / $TRate->{$alternate_source};
|
||||
if (!empty($TRate->$alternate_source)) {
|
||||
$coef = $TRate->USDUSD / $TRate->$alternate_source;
|
||||
foreach ($TRate as $attr => &$rate) {
|
||||
$rate *= $coef;
|
||||
}
|
||||
@ -637,7 +637,7 @@ class MultiCurrency extends CommonObject
|
||||
* @param int $addifnotfound Add if not found
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public static function syncRates($key, $addifnotfound = 0)
|
||||
public function syncRates($key, $addifnotfound = 0)
|
||||
{
|
||||
global $conf, $db, $langs;
|
||||
|
||||
@ -656,16 +656,16 @@ class MultiCurrency extends CommonObject
|
||||
|
||||
if ($response->success) {
|
||||
$TRate = $response->quotes;
|
||||
$timestamp = $response->timestamp;
|
||||
//$timestamp = $response->timestamp;
|
||||
|
||||
if (self::recalculRates($TRate) >= 0) {
|
||||
if ($this->recalculRates($TRate) >= 0) {
|
||||
foreach ($TRate as $currency_code => $rate) {
|
||||
$code = substr($currency_code, 3, 3);
|
||||
$obj = new MultiCurrency($db);
|
||||
if ($obj->fetch(null, $code) > 0) {
|
||||
$obj->updateRate($rate);
|
||||
} elseif ($addifnotfound) {
|
||||
self::addRateFromDolibarr($code, $rate);
|
||||
$this->addRateFromDolibarr($code, $rate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -271,7 +271,7 @@ if (!in_array($action, array("updateRate", "deleteRate"))) {
|
||||
|
||||
print ' <td>'.$langs->trans('Date').'</td>';
|
||||
print ' <td>';
|
||||
print $form->selectDate($dateinput, 'dateinput', 0, 0, 1);
|
||||
print $form->selectDate($dateinput, 'dateinput', 0, 0, 1, '', 1, 1);
|
||||
print '</td>';
|
||||
|
||||
print '<td> '.$langs->trans('Currency').'</td>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user