Fix list of leave not complete for a manager

This commit is contained in:
Laurent Destailleur 2018-03-21 19:17:42 +01:00
parent a2b9dbfbe3
commit b3bb6d88e6
2 changed files with 120 additions and 119 deletions

View File

@ -50,7 +50,7 @@ class Holiday extends CommonObject
var $date_fin=''; // Date end in PHP server TZ var $date_fin=''; // Date end in PHP server TZ
var $date_debut_gmt=''; // Date start in GMT var $date_debut_gmt=''; // Date start in GMT
var $date_fin_gmt=''; // Date end in GMT var $date_fin_gmt=''; // Date end in GMT
var $halfday=''; var $halfday=''; // 0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning
var $statut=''; // 1=draft, 2=validated, 3=approved var $statut=''; // 1=draft, 2=validated, 3=approved
var $fk_validator; var $fk_validator;
var $date_valid=''; var $date_valid='';
@ -276,9 +276,9 @@ class Holiday extends CommonObject
} }
/** /**
* List holidays for a particular user * List holidays for a particular user or list of users
* *
* @param int $user_id ID of user to list * @param int|string $user_id ID of user to list, or comma separated list of IDs of users to list
* @param string $order Sort order * @param string $order Sort order
* @param string $filter SQL Filter * @param string $filter SQL Filter
* @return int -1 if KO, 1 if OK, 2 if no result * @return int -1 if KO, 1 if OK, 2 if no result
@ -321,8 +321,8 @@ class Holiday extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua";
$sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; $sql.= " WHERE cp.entity IN (".getEntity('holiday').")";
$sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau $sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid"; // Hack pour la recherche sur le tableau
$sql.= " AND cp.fk_user = ".$user_id; $sql.= " AND cp.fk_user IN (".$user_id.")";
// Filtre de séléction // Filtre de séléction
if(!empty($filter)) { if(!empty($filter)) {

View File

@ -48,7 +48,7 @@ $contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectl
$backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page $backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print') $optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print')
$childis = $user->getAllChildIds(1); $childids = $user->getAllChildIds(1);
// Security check // Security check
$socid=0; $socid=0;
@ -107,7 +107,6 @@ $fieldstosearchall = array(
'uu.firstname'=>'EmployeeFirstname' 'uu.firstname'=>'EmployeeFirstname'
); );
$childids = $user->getAllChildIds(1);
/* /*
@ -275,14 +274,16 @@ if ($id > 0)
$search_employee = $user_id; $search_employee = $user_id;
} }
// Récupération des congés payés de l'utilisateur ou de tous les users // Récupération des congés payés de l'utilisateur ou de tous les users de sa hierarchy
// Load array $holiday->holiday
if (empty($user->rights->holiday->read_all) || $id > 0) if (empty($user->rights->holiday->read_all) || $id > 0)
{ {
$result = $holiday->fetchByUser($user_id,$order,$filter); // Load array $holiday->holiday if ($id > 0) $result = $holiday->fetchByUser($id, $order, $filter);
else $result = $holiday->fetchByUser(join(',',$childids), $order, $filter);
} }
else else
{ {
$result = $holiday->fetchAll($order,$filter); // Load array $holiday->holiday $result = $holiday->fetchAll($order, $filter);
} }
// Si erreur SQL // Si erreur SQL
if ($result == '-1') if ($result == '-1')