From 3a2cfe1fab5ab4ca16829793e9a3bd4c1ae476fb Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 1 Aug 2022 10:42:30 +0200 Subject: [PATCH] NEW : add employment anniversary in birthday box --- htdocs/core/boxes/box_birthdays.php | 31 ++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index 9462c810393..6aec6f4064a 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -85,13 +85,19 @@ class box_birthdays extends ModeleBoxes if ($user->rights->user->user->lire) { $tmparray = dol_getdate(dol_now(), true); - $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth, u.email, u.statut as status"; + $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth as datea, 'birth' as typea, u.email, u.statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.entity IN (".getEntity('user').")"; $sql .= " AND u.statut = 1"; $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); - $sql .= " ORDER BY DAY(u.birth) ASC"; - $sql .= $this->db->plimit($max, 0); + $sql .= ' UNION '; + $sql .= "SELECT u.rowid, u.firstname, u.lastname, u.dateemployment as datea, 'employment' as typea, u.email, u.statut as status"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE u.entity IN (".getEntity('user').")"; + $sql .= " AND u.statut = 1"; + $sql .= dolSqlDateFilter('u.dateemployment', 0, $tmparray['mon'], 0); + + $sql .= " ORDER BY DAY(datea) ASC"; dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); $result = $this->db->query($sql); @@ -108,9 +114,13 @@ class box_birthdays extends ModeleBoxes $userstatic->email = $objp->email; $userstatic->statut = $objp->status; - $dateb = $this->db->jdate($objp->birth); + $dateb = $this->db->jdate($objp->datea); $age = date('Y', dol_now()) - date('Y', $dateb); + $picb = ''; + $pice = ''; + $typea = ($objp->typea == 'birth') ? $picb : $pice; + $this->info_box_contents[$line][] = array( 'td' => '', 'text' => $userstatic->getNomUrl(1), @@ -119,7 +129,18 @@ class box_birthdays extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="center nowraponall"', - 'text' => dol_print_date($dateb, "day", 'tzserver').' - '.$age.' '.$langs->trans('DurationYears') + 'text' => dol_print_date($dateb, "day", 'tzserver') + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => $age.' '.$langs->trans('DurationYears') + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="center nowraponall"', + 'text' => $typea, + 'asis' => 1 ); /*$this->info_box_contents[$line][] = array(