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));
75 $langs->load(
"boxes");
79 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
80 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
81 $userstatic =
new User($this->
db);
83 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleUserBirthdaysOfMonth"));
85 if ($user->rights->user->user->lire) {
88 $sql =
"SELECT u.rowid, u.firstname, u.lastname, u.birth as datea, 'birth' as typea, u.email, u.statut as status";
89 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
90 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
91 $sql .=
" AND u.statut = 1";
94 $sql .=
"SELECT u.rowid, u.firstname, u.lastname, u.dateemployment as datea, 'employment' as typea, u.email, u.statut as status";
95 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
96 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
97 $sql .=
" AND u.statut = 1";
100 $sql .=
" ORDER BY DAY(datea) ASC";
102 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
103 $result = $this->
db->query($sql);
105 $num = $this->
db->num_rows($result);
108 while ($line < $num) {
109 $objp = $this->
db->fetch_object($result);
111 $userstatic->id = $objp->rowid;
112 $userstatic->firstname = $objp->firstname;
113 $userstatic->lastname = $objp->lastname;
114 $userstatic->email = $objp->email;
115 $userstatic->statut = $objp->status;
117 $dateb = $this->
db->jdate($objp->datea);
118 $age = date(
'Y',
dol_now()) - date(
'Y', $dateb);
120 $picb =
'<i class="fas fa-birthday-cake inline-block"></i>';
121 $pice =
'<i class="fas fa-briefcase inline-block"></i>';
122 $typea = ($objp->typea ==
'birth') ? $picb : $pice;
124 $this->info_box_contents[$line][] = array(
126 'text' => $userstatic->getNomUrl(1),
130 $this->info_box_contents[$line][] = array(
131 'td' =>
'class="center nowraponall"',
135 $this->info_box_contents[$line][] = array(
136 'td' =>
'class="right nowraponall"',
137 'text' => $age.
' '.$langs->trans(
'DurationYears')
140 $this->info_box_contents[$line][] = array(
141 'td' =>
'class="center nowraponall"',
155 $this->info_box_contents[$line][0] = array(
'td' =>
'class="center"',
'text' =>
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>');
158 $this->
db->free($result);
160 $this->info_box_contents[0][0] = array(
163 'text' => ($this->
db->error().
' sql='.$sql)
167 $this->info_box_contents[0][0] = array(
168 'td' =>
'class="nohover left"',
169 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'
182 public function showBox($head =
null, $contents =
null, $nooutput = 0)
184 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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
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.
$conf db
API class for accounts.