FIX: do not update holiday for closed users

This commit is contained in:
Laurent Destailleur 2021-12-03 01:50:17 +01:00
parent d9aa471370
commit 1db52532ff

View File

@ -1470,11 +1470,11 @@ class Holiday extends CommonObject
$monthLastUpdate = $lastUpdate[4].$lastUpdate[5]; $monthLastUpdate = $lastUpdate[4].$lastUpdate[5];
//print 'month: '.$month.' lastUpdate:'.$lastUpdate.' monthLastUpdate:'.$monthLastUpdate;exit; //print 'month: '.$month.' lastUpdate:'.$lastUpdate.' monthLastUpdate:'.$monthLastUpdate;exit;
// Si la date du mois n'est pas la même que celle sauvegardée, on met à jour le timestamp // If month date is not same than the one of last update (the one we saved in database), then we update the timestamp and balance of each open user.
if ($month != $monthLastUpdate) { if ($month != $monthLastUpdate) {
$this->db->begin(); $this->db->begin();
$users = $this->fetchUsers(false, false); $users = $this->fetchUsers(false, false, ' AND u.statut > 0');
$nbUser = count($users); $nbUser = count($users);
$sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET";
@ -1675,7 +1675,7 @@ class Holiday extends CommonObject
* *
* @param boolean $stringlist If true return a string list of id. If false, return an array with detail. * @param boolean $stringlist If true return a string list of id. If false, return an array with detail.
* @param boolean $type If true, read Dolibarr user list, if false, return vacation balance list. * @param boolean $type If true, read Dolibarr user list, if false, return vacation balance list.
* @param string $filters Filters * @param string $filters Filters. Warning: This must not contains data from user input.
* @return array|string|int Return an array * @return array|string|int Return an array
*/ */
public function fetchUsers($stringlist = true, $type = true, $filters = '') public function fetchUsers($stringlist = true, $type = true, $filters = '')
@ -1776,7 +1776,7 @@ class Holiday extends CommonObject
// Si faux donc return array // Si faux donc return array
// List for Dolibarr users // List for Dolibarr users
if ($type) { if ($type) {
// If user of Dolibarr // If we need users of Dolibarr
$sql = "SELECT"; $sql = "SELECT";
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
$sql .= " DISTINCT"; $sql .= " DISTINCT";