59 $langs->loadLangs(array(
"boxes",
"holiday"));
63 include_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
64 $holidaystatic =
new Holiday($this->db);
65 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
66 $userstatic =
new User($this->db);
68 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleHolidaysToApprove", $max));
70 if ($user->hasRight(
'holiday',
'read') && $user->hasRight(
'holiday',
'approve')) {
71 $childids = $user->getAllChildIds(1);
73 $sql =
"SELECT d.rowid, d.ref, d.date_debut, d.date_fin, d.halfday, d.statut as status";
74 $sql .=
", u.rowid as user_id, u.lastname, u.firstname, u.login, u.photo, u.statut as user_status, u.entity as user_entity";
75 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as d";
76 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON d.fk_user = u.rowid";
77 $sql .=
" WHERE d.statut = ".Holiday::STATUS_VALIDATED;
78 $sql .=
" AND d.entity IN (".getEntity(
'holiday').
")";
79 if (!$user->hasRight(
'holiday',
'readall')) {
80 $sql .=
" AND (d.fk_user IN (".$this->db->sanitize(implode(
',', $childids)).
")";
81 $sql .=
" OR d.fk_validator = ".((int) $user->id).
")";
83 $sql .=
" ORDER BY d.date_debut ASC";
84 $sql .= $this->db->plimit($max, 0);
86 $result = $this->db->query($sql);
88 $num = $this->db->num_rows($result);
91 while ($line < $num) {
92 $objp = $this->db->fetch_object($result);
94 $holidaystatic->id = $objp->rowid;
95 $holidaystatic->ref = $objp->ref;
96 $holidaystatic->statut = $objp->status;
97 $holidaystatic->status = $objp->status;
99 $userstatic->id = $objp->user_id;
100 $userstatic->lastname = $objp->lastname;
101 $userstatic->firstname = $objp->firstname;
102 $userstatic->login = $objp->login;
103 $userstatic->photo = $objp->photo;
104 $userstatic->statut = $objp->user_status;
105 $userstatic->status = $objp->user_status;
106 $userstatic->entity = $objp->user_entity;
108 $this->info_box_contents[$line][] = array(
109 'td' =>
'class="nowraponall"',
110 'text' => $holidaystatic->getNomUrl(1),
114 $this->info_box_contents[$line][] = array(
115 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
116 'text' => $userstatic->getNomUrl(-1),
120 $this->info_box_contents[$line][] = array(
121 'td' =>
'class="nowraponall right"',
129 $this->info_box_contents[$line][] = array(
130 'td' =>
'class="center"',
131 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"NoHolidayToApprove").
'</span>',
135 $this->db->free($result);
137 $this->info_box_contents[0][] = array(
140 'text' => ($this->db->error().
' sql='.$sql),
144 $this->info_box_contents[0][] = array(
145 'td' =>
'class="nohover left"',
146 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'