|
@@ -1654,21 +1654,24 @@ class Holiday extends CommonObject
|
|
|
{
|
|
|
if ($type)
|
|
|
{
|
|
|
- // Si utilisateur de Dolibarr
|
|
|
-
|
|
|
- $sql = "SELECT u.rowid";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
|
|
|
+ // 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))
|
|
|
{
|
|
|
$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 .= " WHERE ((ug.fk_user = u.rowid";
|
|
|
+ $sql .= " AND ug.entity IN (".getEntity('usergroup')."))";
|
|
|
+ $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;
|
|
@@ -1709,7 +1712,7 @@ class Holiday extends CommonObject
|
|
|
// We want only list of vacation balance for user ids
|
|
|
$sql = "SELECT DISTINCT cpu.fk_user";
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u";
|
|
|
- $sql .= " WHERE cpu.fk_user = u.user";
|
|
|
+ $sql .= " WHERE cpu.fk_user = u.rowid";
|
|
|
if ($filters) $sql .= $filters;
|
|
|
|
|
|
$resql = $this->db->query($sql);
|
|
@@ -1750,17 +1753,24 @@ 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";
|
|
|
+ // 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))
|
|
|
{
|
|
|
- $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";
|
|
|
- } else {
|
|
|
- $sql.= " WHERE u.entity IN (0,".$conf->entity.")";
|
|
|
+ $sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
|
|
|
+ $sql .= " WHERE ((ug.fk_user = u.rowid";
|
|
|
+ $sql .= " AND ug.entity IN (".getEntity('usergroup')."))";
|
|
|
+ $sql .= " OR u.entity = 0)"; // Show always superadmin
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $sql .= " WHERE u.entity IN (".getEntity('user').")";
|
|
|
}
|
|
|
|
|
|
$sql.= " AND u.statut > 0";
|