From 761d2b3667dc6bddb8c0ecf6ca950532be548f85 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Apr 2018 17:44:36 +0200 Subject: [PATCH] FIX Not approved holidays must not be visible into timesheet --- htdocs/holiday/class/holiday.class.php | 10 ++++++---- htdocs/projet/activity/perday.php | 3 ++- htdocs/projet/activity/perweek.php | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 950c297fb3b..c8f73111021 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -779,25 +779,27 @@ class Holiday extends CommonObject /** - * Check a user is not on holiday for a particular timestamp + * Check that a user is not on holiday for a particular timestamp * * @param int $fk_user Id user * @param timestamp $timestamp Time stamp date for a day (YYYY-MM-DD) without hours (= 12:00AM in english and not 12:00PM that is 12:00) + * @param string $status Filter on holiday status. '-1' = no filter. * @return array array('morning'=> ,'afternoon'=> ), Boolean is true if user is available for day timestamp. * @see verifDateHolidayCP */ - function verifDateHolidayForTimestamp($fk_user, $timestamp) + function verifDateHolidayForTimestamp($fk_user, $timestamp, $status='-1') { global $langs, $conf; $isavailablemorning=true; $isavailableafternoon=true; - $sql = "SELECT cp.rowid, cp.date_debut as date_start, cp.date_fin as date_end, cp.halfday"; + $sql = "SELECT cp.rowid, cp.date_debut as date_start, cp.date_fin as date_end, cp.halfday, cp.statut"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp"; $sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; $sql.= " AND cp.fk_user = ".(int) $fk_user; - $sql.= " AND date_debut <= '".$this->db->idate($timestamp)."' AND date_fin >= '".$this->db->idate($timestamp)."'"; + $sql.= " AND cp.date_debut <= '".$this->db->idate($timestamp)."' AND cp.date_fin >= '".$this->db->idate($timestamp)."'"; + if ($status != '-1') $sql.=" AND cp.statut IN (".$this->db->escape($status).")"; $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index f30b0ac4757..7615ee75c20 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -496,7 +496,8 @@ $restrictviewformytask=(empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED $holiday = new Holiday($db); $isavailable=array(); -$isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse); // $daytoparse is a date with hours = 0 +$statusofholidaytocheck = '3'; +$isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse, $statusofholiday); // $daytoparse is a date with hours = 0 $isavailable[$daytoparse]=$isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day if (count($tasksarray) > 0) diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index a3c8c9ebe54..f60eaf89375 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -503,7 +503,8 @@ for ($i=0;$i<7;$i++) //print dol_print_date($dayinloopwithouthours, 'dayhour').' '; //print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour').'
'; - $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow); + $statusofholidaytocheck = '3'; + $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow, $statusofholidaytocheck); $isavailable[$dayinloopfromfirstdaytoshow]=$isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day print ''.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'
'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').''; }