From bc3a210d12add514e6f96f1ec61bef5f6bd2a995 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 3 Feb 2020 11:46:18 +0100 Subject: [PATCH 1/4] FIX compatibility with multicompany (avoid duplicate data) --- htdocs/holiday/class/holiday.class.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 66a118c744b..1e3567549a9 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1658,19 +1658,19 @@ class Holiday extends CommonObject { // Si utilisateur de Dolibarr - $sql = "SELECT u.rowid"; + $sql = "SELECT DISTINCT u.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql.= " WHERE (ug.fk_user = u.rowid"; - $sql.= " AND ug.entity = ".$conf->entity.")"; - $sql.= " OR u.admin = 1"; + $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql.= " WHERE ((ug.fk_user = u.rowid"; + $sql.= " AND ug.entity IN (".getEntity('user')."))"; + $sql.= " OR u.entity = 0)"; // Show always superadmin } else { - $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; + $sql.= " WHERE u.entity IN (".getEntity('user').")"; } $sql.= " AND u.statut > 0"; if ($filters) $sql.=$filters; @@ -1754,18 +1754,20 @@ class Holiday extends CommonObject // List for Dolibarr users if ($type) { - $sql = "SELECT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; + $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql.= " WHERE (ug.fk_user = u.rowid"; - $sql.= " AND ug.entity = ".$conf->entity.")"; - $sql.= " OR u.admin = 1"; + $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql.= " WHERE ((ug.fk_user = u.rowid"; + $sql.= " AND ug.entity IN (".getEntity('user')."))"; + $sql.= " OR u.entity = 0)"; // Show always superadmin } else - $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; + { + $sql.= " WHERE u.entity IN (".getEntity('user').")"; + } $sql.= " AND u.statut > 0"; if ($filters) $sql.=$filters; From e74e63941d6914241a60d5855a891cda1d9a14e8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 3 Feb 2020 11:55:55 +0100 Subject: [PATCH 2/4] FIX use "usergroup" instead "user" --- htdocs/holiday/class/holiday.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 1e3567549a9..31723379314 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1665,7 +1665,7 @@ class Holiday extends CommonObject { $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; $sql.= " WHERE ((ug.fk_user = u.rowid"; - $sql.= " AND ug.entity IN (".getEntity('user')."))"; + $sql.= " AND ug.entity IN (".getEntity('usergroup')."))"; $sql.= " OR u.entity = 0)"; // Show always superadmin } else @@ -1761,7 +1761,7 @@ class Holiday extends CommonObject { $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; $sql.= " WHERE ((ug.fk_user = u.rowid"; - $sql.= " AND ug.entity IN (".getEntity('user')."))"; + $sql.= " AND ug.entity IN (".getEntity('usergroup')."))"; $sql.= " OR u.entity = 0)"; // Show always superadmin } else From d35994e5db1a79ddea4babe94f466589f8b8a69a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Feb 2020 13:25:51 +0100 Subject: [PATCH 3/4] Update holiday.class.php --- htdocs/holiday/class/holiday.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 31723379314..78210d08bc9 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1656,9 +1656,12 @@ class Holiday extends CommonObject { if ($type) { - // Si utilisateur de Dolibarr - - $sql = "SELECT DISTINCT u.rowid"; + // If user of Dolibarr + $sql = "SELECT"; + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + $sql .= " DISTINCT"; + } + $sql.= " u.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) From c101c3dd55ec96f86e23c29618f6a1c4e0ef05ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Feb 2020 13:27:22 +0100 Subject: [PATCH 4/4] Update holiday.class.php --- htdocs/holiday/class/holiday.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 78210d08bc9..04ccf239766 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1757,7 +1757,12 @@ class Holiday extends CommonObject // List for Dolibarr users if ($type) { - $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; + // If user of Dolibarr + $sql = "SELECT"; + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + $sql .= " DISTINCT"; + } + $sql = " u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))