From f8451ffc568a7b7666658eb0e06e63c2c46b3857 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Dec 2022 15:52:03 +0100 Subject: [PATCH 1/4] Debug v17 --- htdocs/admin/multicurrency.php | 3 ++- htdocs/hrm/class/job.class.php | 21 ++++++++----------- htdocs/hrm/class/position.class.php | 4 +++- .../class/multicurrency.class.php | 18 ++++++++-------- htdocs/multicurrency/multicurrency_rate.php | 2 +- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index 1cf838c08cb..5945ebfb5d5 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -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"); } diff --git a/htdocs/hrm/class/job.class.php b/htdocs/hrm/class/job.class.php index a08e8c713ae..93950979a1a 100644 --- a/htdocs/hrm/class/job.class.php +++ b/htdocs/hrm/class/job.class.php @@ -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) { diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index b72c11b36f6..98b5fd89be9 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -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 diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index 8b42f7cb25b..da1b9f653b3 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -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); } } } diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 03e5e09334a..8b9bbf4eef6 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -271,7 +271,7 @@ if (!in_array($action, array("updateRate", "deleteRate"))) { print ' '.$langs->trans('Date').''; print ' '; - print $form->selectDate($dateinput, 'dateinput', 0, 0, 1); + print $form->selectDate($dateinput, 'dateinput', 0, 0, 1, '', 1, 1); print ''; print ' '.$langs->trans('Currency').''; From 2970f039dd966b2c7d5e5105fd3ec3b38a1edec8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Dec 2022 16:52:23 +0100 Subject: [PATCH 2/4] Fix warning --- htdocs/core/lib/functions.lib.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5b791594fea..4724bf85d50 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -340,13 +340,13 @@ function getBrowserInfo($user_agent) $reg = array(); if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'firefox'; - $version = $reg[2]; + $version = empty($reg[2]) ? '' : $reg[2]; } elseif (preg_match('/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'edge'; - $version = $reg[2]; + $version = empty($reg[2]) ? '' : $reg[2]; } elseif (preg_match('/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) { $name = 'chrome'; - $version = $reg[2]; + $version = empty($reg[2]) ? '' : $reg[2]; } elseif (preg_match('/chrome/i', $user_agent, $reg)) { // we can have 'chrome (Mozilla...) chrome x.y' in one string $name = 'chrome'; @@ -356,11 +356,11 @@ function getBrowserInfo($user_agent) $name = 'epiphany'; } elseif (preg_match('/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'safari'; - $version = $reg[2]; + $version = empty($reg[2]) ? '' : $reg[2]; } elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { // Safari is often present in string for mobile but its not. $name = 'opera'; - $version = $reg[2]; + $version = empty($reg[2]) ? '' : $reg[2]; } elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name = 'ie'; $version = end($reg); @@ -368,10 +368,10 @@ function getBrowserInfo($user_agent) // MS products at end $name = 'ie'; $version = end($reg); - } elseif (preg_match('/l(i|y)n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) { + } elseif (preg_match('/l[iy]n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) { // MS products at end $name = 'lynxlinks'; - $version = $reg[4]; + $version = empty($reg[3]) ? '' : $reg[3]; } if ($tablet) { From 97222603c10c97396c450a6cb933c081d5c8dc3e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Dec 2022 17:14:58 +0100 Subject: [PATCH 3/4] Debug v17 --- htdocs/modulebuilder/index.php | 6 +++--- htdocs/stripe/admin/stripe.php | 4 ++-- htdocs/takepos/admin/terminal.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 8b87d84c10e..a6f3431bd2e 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1731,9 +1731,9 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) { ); $resultko = 0; - foreach ($filetodelete as $filetodelete) { - $resulttmp = dol_delete_file($dir.'/'.$filetodelete, 0, 0, 1); - $resulttmp = dol_delete_file($dir.'/'.$filetodelete.'.back', 0, 0, 1); + foreach ($filetodelete as $tmpfiletodelete) { + $resulttmp = dol_delete_file($dir.'/'.$tmpfiletodelete, 0, 0, 1); + $resulttmp = dol_delete_file($dir.'/'.$tmpfiletodelete.'.back', 0, 0, 1); if (!$resulttmp) { $resultko++; } diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 6cbefc14185..1c5a507b619 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -420,8 +420,8 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code $location = array(); $location[""] = $langs->trans("NotDefined"); - foreach ($locations as $locations) { - $location[$locations->id] = $locations->display_name; + foreach ($locations as $tmplocation) { + $location[$tmplocation->id] = $tmplocation->display_name; } print $form->selectarray("STRIPE_LOCATION", $location, getDolGlobalString('STRIPE_LOCATION')); print ''; diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index fe03139c8a3..7fc2d60544a 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -219,8 +219,8 @@ if (isModEnabled("banque")) { $reader = array(); $reader[""] = $langs->trans("NoReader"); - foreach ($readers as $readers) { - $reader[$reader->id] = $readers->label.' ('.$readers->status.')'; + foreach ($readers as $tmpreader) { + $reader[$tmpreader->id] = $tmpreader->label.' ('.$tmpreader->status.')'; } print $form->selectarray('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse, $reader, $conf->global->{'CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse}); print ''; From d1934bfded6f1ef8ff7c75487746c72f19e86dc6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Dec 2022 17:29:57 +0100 Subject: [PATCH 4/4] Debug v17 --- htdocs/compta/localtax/index.php | 12 ++---------- htdocs/compta/tva/index.php | 10 ---------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index ad0b86a161d..fb96e766945 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -18,11 +18,13 @@ * along with this program. If not, see . */ + /** * \file htdocs/compta/localtax/index.php * \ingroup tax * \brief Index page of IRPF reports */ + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; @@ -441,16 +443,6 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ $hookmanager->initHooks(array('externalbalance')); $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!is_array($x_coll) && $coll_listbuy == -1) { - $langs->load("errors"); - print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; - break; - } - if (!is_array($x_paye) && $coll_listbuy == -2) { - print ''.$langs->trans("FeatureNotYetAvailable").''; - break; - } - print ''; print ''.dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y").''; diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index f0efe305d8c..5c0d6930475 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -389,16 +389,6 @@ if ($refresh === true) { $hookmanager->initHooks(array('externalbalance')); $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!is_array($x_coll) && $coll_listbuy == -1) { - $langs->load("errors"); - print '' . $langs->trans("ErrorNoAccountancyModuleLoaded") . ''; - break; - } - if (!is_array($x_paye) && $coll_listbuy == -2) { - print '' . $langs->trans("FeatureNotYetAvailable") . ''; - break; - } - print ''; print '' . dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y") . '';