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->hasRight(
"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) {
88 $sql =
"SELECT u.rowid, u.firstname, u.lastname, u.birth";
89 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as u";
90 $sql .=
" WHERE u.entity IN (".getEntity(
'adherent').
")";
91 $sql .=
" AND u.statut = ".Adherent::STATUS_VALIDATED;
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);
104 $memberstatic->id = $objp->rowid;
105 $memberstatic->firstname = $objp->firstname;
106 $memberstatic->lastname = $objp->lastname;
107 $dateb = $this->
db->jdate($objp->birth);
108 $age = date(
'Y',
dol_now()) - date(
'Y', $dateb);
110 $this->info_box_contents[$line][] = array(
112 'text' => $memberstatic->getNomUrl(1),
116 $this->info_box_contents[$line][] = array(
117 'td' =>
'class="center nowraponall"',
118 'text' =>
dol_print_date($dateb,
"day",
'tzserver').
' - '.$age.
' '.$langs->trans(
'DurationYears')
130 $this->info_box_contents[$line][0] = array(
'td' =>
'class="center"',
'text' =>
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>');
133 $this->
db->free($result);
135 $this->info_box_contents[0][0] = array(
138 'text' => ($this->
db->error().
' sql='.
$sql)
142 $this->info_box_contents[0][0] = array(
143 'td' =>
'class="nohover left"',
144 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'
157 public function showBox($head =
null, $contents =
null, $nooutput = 0)
159 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);