27 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
35 public $boxcode =
"birthdays_members";
36 public $boximg =
"object_user";
37 public $boxlabel =
"BoxTitleMemberNextBirthdays";
38 public $depends = array(
"adherent");
47 public $info_box_head = array();
48 public $info_box_contents = array();
63 $this->hidden = !($user->rights->adherent->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.
'/adherents/class/adherent.class.php';
83 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleMemberNextBirthdays"));
85 if ($user->rights->adherent->lire)
89 $sql =
"SELECT u.rowid, u.firstname, u.lastname, u.birth";
90 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as u";
91 $sql .=
" WHERE u.entity IN (".getEntity(
'adherent').
")";
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);
107 $memberstatic->id = $objp->rowid;
108 $memberstatic->firstname = $objp->firstname;
109 $memberstatic->lastname = $objp->lastname;
110 $memberstatic->email = $objp->email;
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' => $memberstatic->getNomUrl(1),
120 $this->info_box_contents[$line][] = array(
121 'td' =>
'class="right"',
122 'text' =>
dol_print_date($dateb,
"day").
' - '.$age.
' '.$langs->trans(
'DurationYears')
133 if ($num == 0) $this->info_box_contents[$line][0] = array(
'td' =>
'class="center opacitymedium"',
'text'=>$langs->trans(
"None"));
135 $this->
db->free($result);
137 $this->info_box_contents[0][0] = array(
140 'text' => ($this->
db->error().
' sql='.$sql)
144 $this->info_box_contents[0][0] = array(
145 'td' =>
'class="nohover opacitymedium left"',
146 'text' => $langs->trans(
"ReadPermissionNotAllowed")
159 public function showBox($head = null, $contents = null, $nooutput = 0)
161 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
dol_now($mode= 'auto')
Return date for now.
Class to manage the box to show user birthdays.
loadBox($max=20)
Load data for box to show them later.
$conf db
API class for accounts.
__construct($db, $param= '')
Constructor.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to manage members of a foundation.
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).