Fix CSS for holiday. Fix #15266

This commit is contained in:
Laurent Destailleur 2020-11-05 19:09:58 +01:00
parent b2273eec6b
commit 4535d81964
4 changed files with 32 additions and 51 deletions

View File

@ -1319,11 +1319,11 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
global $daytoparse;
$tmparray = dol_getdate($daytoparse, true); // detail of current day
$idw = $tmparray['wday'];
$idw = ($tmparray['wday'] - (empty($conf->global->MAIN_START_WEEK)?0:1));
global $numstartworkingday, $numendworkingday;
$cssweekend = '';
if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css.
if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css.
{
$cssweekend = 'weekend';
}
@ -1702,12 +1702,13 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
global $numstartworkingday, $numendworkingday;
$cssweekend = '';
if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css.
if (($idw + 1 < $numstartworkingday) || ($idw + 1 > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css.
{
$cssweekend = 'weekend';
}
$tableCell = '<td class="center hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">';
//$tableCell .= 'idw='.$idw.' '.$conf->global->MAIN_START_WEEK.' '.$numstartworkingday.'-'.$numendworkingday;
$placeholder = '';
if ($alreadyspent)
{

View File

@ -1102,7 +1102,7 @@ class Holiday extends CommonObject
/**
* Check that a user is not on holiday for a particular timestamp
* Check that a user is not on holiday for a particular timestamp. Can check approved leave requests and not into public holidays of company.
*
* @param int $fk_user Id user
* @param integer $timestamp Time stamp date for a day (YYYY-MM-DD) without hours (= 12:00AM in english and not 12:00PM that is 12:00)
@ -1117,6 +1117,7 @@ class Holiday extends CommonObject
$isavailablemorning = true;
$isavailableafternoon = true;
// Check into leave requests
$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').")";
@ -1161,7 +1162,10 @@ class Holiday extends CommonObject
}
} else dol_print_error($this->db);
return array('morning'=>$isavailablemorning, 'afternoon'=>$isavailableafternoon);
$result = array('morning'=>$isavailablemorning, 'afternoon'=>$isavailableafternoon);
if (!$isavailablemorning) $result['morning_reason'] = 'leave_request';
if (!$isavailableafternoon) $result['afternoon_reason'] = 'leave_request';
return $result;
}

View File

@ -48,8 +48,7 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'per
$mine = 0;
if ($mode == 'mine') $mine = 1;
$projectid = '';
$projectid = isset($_GET["id"]) ? $_GET["id"] : $_POST["projectid"];
$projectid = isset($_GET["id"]) ? GETPOST("id", "int", 1) : GETPOST("projectid", "int");
$hookmanager->initHooks(array('timesheetperdaycard'));
@ -612,20 +611,24 @@ if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS))
}
}
$statusofholidaytocheck = '3';
$statusofholidaytocheck = Holiday::STATUS_APPROVED;
$isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse, $statusofholidaytocheck); // $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
$tmparray = dol_getdate($daytoparse, true); // detail of current day
$idw = $tmparray['wday'];
$test = num_public_holiday($daytoparse, $daytoparse + 86400, $mysoc->country_code);
if ($test) $isavailable[$daytoparse] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday');
$tmparray = dol_getdate($daytoparse, true); // detail of current day
// For monday, must be 0 for monday if MAIN_START_WEEK = 1, must be 1 for monday if MAIN_START_WEEK = 0
$idw = ($tmparray['wday'] - (empty($conf->global->MAIN_START_WEEK)?0:1));
// numstartworkingday and numendworkingday are default start and end date of working days (1 means sunday if MAIN_START_WEEK is 0, 1 means monday if MAIN_START_WEEK is 1)
$cssweekend = '';
if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css.
if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css.
{
$cssweekend = 'weekend';
}
$tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
$tmpday = dol_time_plus_duree($daytoparse, $idw, 'd');
$cssonholiday = '';
if (!$isavailable[$daytoparse]['morning'] && !$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayallday ';
@ -651,20 +654,6 @@ if ($conf->use_javascript_ajax)
//print ' - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong>';
print '</td>';
$tmparray = dol_getdate($daytoparse, true); // detail of current day
$idw = $tmparray['wday'];
$cssweekend = '';
if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css.
{
$cssweekend = 'weekend';
}
$cssonholiday = '';
if (!$isavailable[$daytoparse]['morning'] && !$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayallday ';
elseif (!$isavailable[$daytoparse]['morning']) $cssonholiday .= 'onholidaymorning ';
elseif (!$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayafternoon ';
print '<td class="liste_total center'.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'"><div class="totalDay0">&nbsp;</div></td>';
print '<td class="liste_total"></td>';
@ -752,20 +741,6 @@ if (count($tasksarray) > 0)
//print ' - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong>';
print '</td>';
$tmparray = dol_getdate($daytoparse, true); // detail of current day
$idw = $tmparray['wday'];
$cssweekend = '';
if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css.
{
$cssweekend = 'weekend';
}
$cssonholiday = '';
if (!$isavailable[$daytoparse]['morning'] && !$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayallday ';
elseif (!$isavailable[$daytoparse]['morning']) $cssonholiday .= 'onholidaymorning ';
elseif (!$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayafternoon ';
print '<td class="liste_total center'.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'"><div class="totalDay0">&nbsp;</div></td>';
print '<td class="liste_total"></td>

View File

@ -48,8 +48,7 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'per
$mine = 0;
if ($mode == 'mine') $mine = 1;
$projectid = '';
$projectid = isset($_GET["id"]) ? $_GET["id"] : $_POST["projectid"];
$projectid = isset($_GET["id"]) ? GETPOST("id", "int", 1) : GETPOST("projectid", "int");
$hookmanager->initHooks(array('timesheetperweekcard'));
@ -364,7 +363,6 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac
}
/*
* View
*/
@ -530,11 +528,16 @@ for ($idw = 0; $idw < 7; $idw++)
//print dol_print_date($dayinloopwithouthours, 'dayhour').' ';
//print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour').'<br>';
$statusofholidaytocheck = '3';
$statusofholidaytocheck = Holiday::STATUS_APPROVED;
$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
$test = num_public_holiday($dayinloopfromfirstdaytoshow, $dayinloopfromfirstdaytoshow + 86400, $mysoc->country_code);
if ($test) $isavailable[$dayinloopfromfirstdaytoshow] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday');
}
//var_dump($isavailable);
$moreforfilter = '';
@ -656,7 +659,7 @@ for ($idw = 0; $idw < 7; $idw++)
$dayinloop = dol_time_plus_duree($startday, $idw, 'd');
$cssweekend = '';
if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css.
if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css.
{
$cssweekend = 'weekend';
}
@ -689,7 +692,7 @@ if ($conf->use_javascript_ajax)
for ($idw = 0; $idw < 7; $idw++)
{
$cssweekend = '';
if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css.
if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css.
{
$cssweekend = 'weekend';
}
@ -700,7 +703,6 @@ if ($conf->use_javascript_ajax)
if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayallday ';
elseif (!$isavailable[$tmpday]['morning']) $cssonholiday .= 'onholidaymorning ';
elseif (!$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayafternoon ';
print '<td class="liste_total hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'" align="center"><div class="totalDay'.$idw.'">&nbsp;</div></td>';
}
print '<td class="liste_total center"><div class="totalDayAll">&nbsp;</div></td>';
@ -775,7 +777,7 @@ if (count($tasksarray) > 0)
for ($idw = 0; $idw < 7; $idw++)
{
$cssweekend = '';
if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css.
if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css.
{
$cssweekend = 'weekend';
}
@ -803,10 +805,9 @@ if (count($tasksarray) > 0)
print '<span class="opacitymediumbycolor"> - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong></span>';
print '</td>';
for ($idw = 0; $idw < 7; $idw++)
{
for ($idw = 0; $idw < 7; $idw++) {
$cssweekend = '';
if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css.
if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css.
{
$cssweekend = 'weekend';
}