74 global $conf, $user, $langs;
76 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
77 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
78 $userstatic =
new User($this->db);
81 $langs->load(
"boxes");
85 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleUserBirthdaysOfMonth"));
87 if ($user->hasRight(
'user',
'user',
'lire')) {
92 $sql =
"SELECT u.rowid, u.firstname, u.lastname, u.birth as datea, date_format(u.birth, '%d') as daya, 'birth' as typea, u.email, u.statut as status";
93 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
94 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
95 $sql .=
" AND u.statut = ".User::STATUS_ENABLED;
97 $sql .=
" AND u.birth < '".$this->db->idate(
dol_get_first_day($tmparray[
'year'])).
"'";
99 $sql .=
"SELECT u.rowid, u.firstname, u.lastname, u.dateemployment as datea, date_format(u.dateemployment, '%d') as daya, 'employment' as typea, u.email, u.statut as status";
100 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
101 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
102 $sql .=
" AND u.statut = ".User::STATUS_ENABLED;
104 $sql .=
" AND u.dateemployment < '".$this->db->idate(
dol_get_first_day($tmparray[
'year'])).
"'";
105 $sql .=
" ORDER BY daya ASC";
106 $sql .= $this->db->plimit($max, 0);
108 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
109 $resql = $this->db->query($sql);
111 $num = $this->db->num_rows($resql);
114 while ($line < $num) {
115 $data[$line] = $this->db->fetch_object($resql);
120 $this->db->free($resql);
125 while ($j < count($data)) {
126 $userstatic->id = $data[$j]->rowid;
127 $userstatic->firstname = $data[$j]->firstname;
128 $userstatic->lastname = $data[$j]->lastname;
129 $userstatic->email = $data[$j]->email;
130 $userstatic->statut = $data[$j]->status;
132 $dateb = $this->db->jdate($data[$j]->datea);
133 $age = date(
'Y',
dol_now()) - date(
'Y', $dateb);
135 $picb =
'<i class="fas fa-birthday-cake inline-block"></i>';
136 $pice =
'<i class="fas fa-briefcase inline-block"></i>';
137 $typea = ($data[$j]->typea ==
'birth') ? $picb : $pice;
139 $this->info_box_contents[$j][0] = array(
141 'text' => $userstatic->getNomUrl(1),
145 $this->info_box_contents[$j][1] = array(
146 'td' =>
'class="center nowraponall"',
150 $this->info_box_contents[$j][2] = array(
151 'td' =>
'class="right nowraponall"',
152 'text' => $age.
' '.$langs->trans(
'DurationYears')
155 $this->info_box_contents[$j][3] = array(
156 'td' =>
'class="right nowraponall"',
164 if (is_array($data) && count($data) == 0) {
165 $this->info_box_contents[0][0] = array(
166 'td' =>
'class="center"',
167 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>',
171 $this->info_box_contents[0][0] = array(
172 'td' =>
'class="nohover left"',
173 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'