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)
89 $sql =
"SELECT u.rowid, u.firstname, u.lastname, u.birth, u.email, u.statut as status";
90 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
91 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
92 $sql .=
" AND u.statut = 1";
94 $sql .=
" ORDER BY DAY(u.birth) ASC";
95 $sql .= $this->
db->plimit($max, 0);
97 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
98 $result = $this->
db->query($sql);
101 $num = $this->
db->num_rows($result);
106 $objp = $this->
db->fetch_object($result);
108 $userstatic->id = $objp->rowid;
109 $userstatic->firstname = $objp->firstname;
110 $userstatic->lastname = $objp->lastname;
111 $userstatic->email = $objp->email;
112 $userstatic->statut = $objp->status;
114 $dateb = $this->
db->jdate($objp->birth);
115 $age = date(
'Y',
dol_now()) - date(
'Y', $dateb);
117 $this->info_box_contents[$line][] = array(
119 'text' => $userstatic->getNomUrl(1),
123 $this->info_box_contents[$line][] = array(
124 'td' =>
'class="right"',
125 'text' =>
dol_print_date($dateb,
"day").
' - '.$age.
' '.$langs->trans(
'DurationYears')
136 if ($num == 0) $this->info_box_contents[$line][0] = array(
'td' =>
'class="center opacitymedium"',
'text'=>$langs->trans(
"None"));
138 $this->
db->free($result);
140 $this->info_box_contents[0][0] = array(
143 'text' => ($this->
db->error().
' sql='.$sql)
147 $this->info_box_contents[0][0] = array(
148 'td' =>
'class="nohover opacitymedium left"',
149 'text' => $langs->trans(
"ReadPermissionNotAllowed")
162 public function showBox($head = null, $contents = null, $nooutput = 0)
164 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
$conf db
API class for accounts.
loadBox($max=20)
Load data for box to show them later.
__construct($db, $param= '')
Constructor.
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.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0)
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).
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
Class to manage the box to show user birthdays.