FIX Not approved holidays must not be visible into timesheet

This commit is contained in:
Laurent Destailleur 2018-04-26 17:44:36 +02:00
parent 83b762b681
commit 761d2b3667
3 changed files with 10 additions and 6 deletions

View File

@ -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 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 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. * @return array array('morning'=> ,'afternoon'=> ), Boolean is true if user is available for day timestamp.
* @see verifDateHolidayCP * @see verifDateHolidayCP
*/ */
function verifDateHolidayForTimestamp($fk_user, $timestamp) function verifDateHolidayForTimestamp($fk_user, $timestamp, $status='-1')
{ {
global $langs, $conf; global $langs, $conf;
$isavailablemorning=true; $isavailablemorning=true;
$isavailableafternoon=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.= " FROM ".MAIN_DB_PREFIX."holiday as cp";
$sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; $sql.= " WHERE cp.entity IN (".getEntity('holiday').")";
$sql.= " AND cp.fk_user = ".(int) $fk_user; $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); $resql = $this->db->query($sql);
if ($resql) if ($resql)

View File

@ -496,7 +496,8 @@ $restrictviewformytask=(empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED
$holiday = new Holiday($db); $holiday = new Holiday($db);
$isavailable=array(); $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 $isavailable[$daytoparse]=$isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day
if (count($tasksarray) > 0) if (count($tasksarray) > 0)

View File

@ -503,7 +503,8 @@ for ($i=0;$i<7;$i++)
//print dol_print_date($dayinloopwithouthours, 'dayhour').' '; //print dol_print_date($dayinloopwithouthours, 'dayhour').' ';
//print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour').'<br>'; //print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour').'<br>';
$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 $isavailable[$dayinloopfromfirstdaytoshow]=$isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day
print '<td width="6%" align="center" class="hide'.$i.'">'.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'<br>'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'</td>'; print '<td width="6%" align="center" class="hide'.$i.'">'.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'<br>'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'</td>';
} }