27 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
35 public $boxcode =
"birthdays";
36 public $boximg =
"object_user";
37 public $boxlabel =
"BoxTitleUserBirthdaysOfMonth";
38 public $depends = array(
"user");
47 public $info_box_head = array();
48 public $info_box_contents = array();
63 $this->hidden = !($user->hasRight(
'user',
'user',
'read') && empty($user->socid));
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;
98 $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";
99 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
100 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
101 $sql .=
" AND u.statut = ".User::STATUS_ENABLED;
103 $sql .=
" ORDER BY daya ASC";
104 $sql .= $this->db->plimit($max, 0);
106 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
107 $resql = $this->db->query(
$sql);
109 $num = $this->db->num_rows($resql);
112 while ($line < $num) {
113 $data[$line] = $this->db->fetch_object($resql);
118 $this->db->free($resql);
123 while ($j < count($data)) {
124 $userstatic->id = $data[$j]->rowid;
125 $userstatic->firstname = $data[$j]->firstname;
126 $userstatic->lastname = $data[$j]->lastname;
127 $userstatic->email = $data[$j]->email;
128 $userstatic->statut = $data[$j]->status;
130 $dateb = $this->db->jdate($data[$j]->datea);
131 $age = date(
'Y',
dol_now()) - date(
'Y', $dateb);
133 $picb =
'<i class="fas fa-birthday-cake inline-block"></i>';
134 $pice =
'<i class="fas fa-briefcase inline-block"></i>';
135 $typea = ($data[$j]->typea ==
'birth') ? $picb : $pice;
137 $this->info_box_contents[$j][0] = array(
139 'text' => $userstatic->getNomUrl(1),
143 $this->info_box_contents[$j][1] = array(
144 'td' =>
'class="center nowraponall"',
148 $this->info_box_contents[$j][2] = array(
149 'td' =>
'class="right nowraponall"',
150 'text' => $age.
' '.$langs->trans(
'DurationYears')
153 $this->info_box_contents[$j][3] = array(
154 'td' =>
'class="right nowraponall"',
162 if (is_array($data) && count($data) == 0) {
163 $this->info_box_contents[0][0] = array(
164 'td' =>
'class="center"',
165 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>',
169 $this->info_box_contents[0][0] = array(
170 'td' =>
'class="nohover left"',
171 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'
184 public function showBox($head =
null, $contents =
null, $nooutput = 0)
186 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);