28include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
36 public $boxcode =
"birthdays";
37 public $boximg =
"object_user";
38 public $boxlabel =
"BoxTitleUserBirthdaysOfMonth";
39 public $depends = array(
"user");
55 $this->hidden = !($user->hasRight(
'user',
'user',
'read') && empty($user->socid));
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>'
180 public function showBox($head =
null, $contents =
null, $nooutput = 0)
182 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
Class to manage Dolibarr users.
Class to manage the box to show user birthdays.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
loadBox($max=20)
Load data for box to show them later.
__construct($db, $param='')
Constructor.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...