66 global $conf, $user, $langs;
68 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
69 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
70 $userstatic =
new User($this->db);
73 $langs->load(
"boxes");
77 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleUserBirthdaysOfMonth"));
79 if ($user->hasRight(
'user',
'user',
'lire')) {
84 $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";
85 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
86 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
87 $sql .=
" AND u.statut = ".User::STATUS_ENABLED;
89 $sql .=
" AND u.birth < '".$this->db->idate(
dol_get_first_day($tmparray[
'year'])).
"'";
91 $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";
92 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
93 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
94 $sql .=
" AND u.statut = ".User::STATUS_ENABLED;
96 $sql .=
" AND u.dateemployment < '".$this->db->idate(
dol_get_first_day($tmparray[
'year'])).
"'";
97 $sql .=
" ORDER BY daya ASC";
98 $sql .= $this->db->plimit($max, 0);
100 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
101 $resql = $this->db->query($sql);
103 $num = $this->db->num_rows($resql);
106 while ($line < $num) {
107 $data[$line] = $this->db->fetch_object($resql);
112 $this->db->free($resql);
117 while ($j < count($data)) {
118 $userstatic->id = $data[$j]->rowid;
119 $userstatic->firstname = $data[$j]->firstname;
120 $userstatic->lastname = $data[$j]->lastname;
121 $userstatic->email = $data[$j]->email;
122 $userstatic->status = $data[$j]->status;
124 $dateb = $this->db->jdate($data[$j]->datea);
125 $age = idate(
'Y',
dol_now()) - idate(
'Y', $dateb);
127 $picb =
'<i class="fas fa-birthday-cake inline-block"></i>';
128 $pice =
'<i class="fas fa-briefcase inline-block"></i>';
129 $typea = ($data[$j]->typea ==
'birth') ? $picb : $pice;
131 $this->info_box_contents[$j][0] = array(
133 'text' => $userstatic->getNomUrl(1),
137 $this->info_box_contents[$j][1] = array(
138 'td' =>
'class="center nowraponall"',
142 $this->info_box_contents[$j][2] = array(
143 'td' =>
'class="right nowraponall"',
144 'text' => $age.
' '.$langs->trans(
'DurationYears')
147 $this->info_box_contents[$j][3] = array(
148 'td' =>
'class="right nowraponall"',
156 if (is_array($data) && count($data) == 0) {
157 $this->info_box_contents[0][0] = array(
158 'td' =>
'class="center"',
159 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>',
163 $this->info_box_contents[0][0] = array(
164 'td' =>
'class="nohover left"',
165 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'