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->rights->user->user->lire && 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, 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";
93 $sql .=
" ORDER BY DAY(u.birth) ASC";
94 $sql .= $this->
db->plimit($max, 0);
96 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
97 $result = $this->
db->query($sql);
99 $num = $this->
db->num_rows($result);
102 while ($line < $num) {
103 $objp = $this->
db->fetch_object($result);
105 $userstatic->id = $objp->rowid;
106 $userstatic->firstname = $objp->firstname;
107 $userstatic->lastname = $objp->lastname;
108 $userstatic->email = $objp->email;
109 $userstatic->statut = $objp->status;
111 $dateb = $this->
db->jdate($objp->birth);
112 $age = date(
'Y',
dol_now()) - date(
'Y', $dateb);
114 $this->info_box_contents[$line][] = array(
116 'text' => $userstatic->getNomUrl(1),
120 $this->info_box_contents[$line][] = array(
121 'td' =>
'class="center nowraponall"',
122 'text' =>
dol_print_date($dateb,
"day",
'tzserver').
' - '.$age.
' '.$langs->trans(
'DurationYears')
134 $this->info_box_contents[$line][0] = array(
'td' =>
'class="center"',
'text' =>
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>');
137 $this->
db->free($result);
139 $this->info_box_contents[0][0] = array(
142 'text' => ($this->
db->error().
' sql='.$sql)
146 $this->info_box_contents[0][0] = array(
147 'td' =>
'class="nohover left"',
148 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'
161 public function showBox($head =
null, $contents =
null, $nooutput = 0)
163 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);