Fix birthdays boxes and filter on month

This commit is contained in:
Maxime Kohlhaas 2020-04-18 20:01:18 +02:00
parent ea60d0be63
commit 817e16d652
3 changed files with 3 additions and 3 deletions

View File

@ -89,7 +89,7 @@ class box_birthdays extends ModeleBoxes
$sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE u.entity IN (".getEntity('user').")";
$sql.= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], $tmparray['year']);
$sql.= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0);
$sql.= " ORDER BY u.birth ASC";
$sql.= $this->db->plimit($max, 0);

View File

@ -90,7 +90,7 @@ class box_birthdays_members extends ModeleBoxes
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as u";
$sql.= " WHERE u.entity IN (".getEntity('adherent').")";
$sql.= " AND u.statut = 1";
$sql.= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], $tmparray['year']);
$sql.= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0);
$sql.= " ORDER BY u.birth ASC";
$sql.= $this->db->plimit($max, 0);

View File

@ -301,7 +301,7 @@ function dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $exclu
$sqldate.= ($excludefirstand ? "" : " AND ").$datefield." BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date, $day_date, $year_date));
$sqldate.= "' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date, $day_date, $year_date))."'";
} else
$sqldate.= ($excludefirstand ? "" : " AND ")." date_format( ".$datefield.", '%m') = '".$db->escape($month_date)."'";
$sqldate.= ($excludefirstand ? "" : " AND ")." date_format( ".$datefield.", '%c') = '".$db->escape($month_date)."'";
} elseif ($year_date > 0){
$sqldate.= ($excludefirstand ? "" : " AND ").$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, 1, false));
$sqldate.= "' AND '".$db->idate(dol_get_last_day($year_date, 12, false))."'";