From 633dc507fe5150c25765b3ba60e6b0277bc6c0b4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Feb 2018 20:11:32 +0100 Subject: [PATCH] NEW Use a css style for weekend in time spent --- htdocs/core/lib/project.lib.php | 23 ++++++++-- htdocs/projet/activity/perday.php | 58 +++++++++++++++++++------- htdocs/projet/activity/perweek.php | 67 +++++++++++++++++++++--------- htdocs/theme/eldy/style.css.php | 5 +++ 4 files changed, 116 insertions(+), 37 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 7106657d417..67600a7ba3e 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -996,9 +996,19 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; - // Duration - print ''; + global $daytoparse; + $tmparray = dol_getdate($daytoparse,true); // detail of current day + $idw = $tmparray['wday']; + 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. + { + $cssweekend='weekend'; + } + + // Duration + print ''; $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]; $totalforeachday[$preselectedday]+=$dayWorkLoad; @@ -1280,7 +1290,14 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); $alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']); - $tableCell =''; + 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. + { + $cssweekend='weekend'; + } + + $tableCell =''; if ($alreadyspent) { $tableCell.=''; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index f30b0ac4757..dd3aa856817 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -365,7 +365,6 @@ $nav.=' id > 0 ? '?id='.$project->id : '').'">'; print ''; print ''; @@ -482,23 +481,43 @@ if ($usertoprocess->id == $user->id) print ''.$langs->trans("TimeSpentByUser").'';*/ print ''.$langs->trans("TimeSpent").'
('.$langs->trans("Everybody").')'; print ''.$langs->trans("TimeSpent").($usertoprocess->firstname?'
('.$usertoprocess->firstname.')':'').''; -print ''.$langs->trans("HourStart").''; -print ''.$langs->trans("Duration").''; -print ''.$langs->trans("Note").''; -print ''; -print "\n"; - +print ''.$langs->trans("HourStart").''; // By default, we can edit only tasks we are assigned to $restrictviewformytask=(empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)?1:0); // Get if user is available or not for each day $holiday = new Holiday($db); + $isavailable=array(); +if (! empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) +{ + $tmparray=explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); + if (count($tmparray) >= 2) + { + $numstartworkingday = $tmparray[0]; + $numendworkingday = $tmparray[1]; + } +} $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse); // $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']; + +$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'; +} + +print ''.$langs->trans("Duration").''; +print ''.$langs->trans("Note").''; +print ''; +print "\n"; + + if (count($tasksarray) > 0) { //var_dump($tasksarray); // contains only selected tasks @@ -571,13 +590,24 @@ if (count($tasksarray) > 0) if ($conf->use_javascript_ajax) { - print ' - '; - print $langs->trans("Total"); - //print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; - print ' -
 
- + print ''; + print ''; + print $langs->trans("Total"); + //print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; + print ''; + + $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'; + } + + print '
 
'; + + print ' '; } diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index a3c8c9ebe54..ba0e773d114 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -461,7 +461,7 @@ print ''; print ''; print ''; print ''; -for($i=0;$i<7;$i++) +for($idw=0;$idw<7;$idw++) { print ''; } @@ -489,12 +489,22 @@ $startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['fi // Get if user is available or not for each day $holiday = new Holiday($db); -$isavailable=array(); -for ($i=0;$i<7;$i++) +$isavailable=array(); +if (! empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { - $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $i, 'd'); // $firstdaytoshow is a date with hours = 0 - $dayinloop = dol_time_plus_duree($startday, $i, 'd'); + $tmparray=explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); + if (count($tmparray) >= 2) + { + $numstartworkingday = $tmparray[0]; + $numendworkingday = $tmparray[1]; + } +} + +for ($idw=0; $idw<7; $idw++) +{ + $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 + $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); // Useless because $dayinloopwithouthours should be same than $dayinloopfromfirstdaytoshow //$tmparray = dol_getdate($dayinloop); @@ -505,7 +515,14 @@ for ($i=0;$i<7;$i++) $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow); $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').''; + + $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'; + } + + print ''.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'
'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').''; } print ''; print "\n"; @@ -578,7 +595,13 @@ if (count($tasksarray) > 0) print ''; for ($idw = 0; $idw < 7; $idw++) { - print ''; + $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'; + } + + print ''; $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); $timeonothertasks=($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); if ($timeonothertasks) @@ -599,15 +622,19 @@ if (count($tasksarray) > 0) '; print $langs->trans("Total"); print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; - print ' -
 
-
 
-
 
-
 
-
 
-
 
-
 
- + print ''; + + 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. + { + $cssweekend='weekend'; + } + + print '
 
'; + } + print ' '; } } @@ -642,11 +669,11 @@ if ($conf->use_javascript_ajax) } });'."\n"; - $i=0; - while ($i < 7) + $idw=0; + while ($idw < 7) { - print ' updateTotal('.$i.',\''.$modeinput.'\');'; - $i++; + print ' updateTotal('.$idw.',\''.$modeinput.'\');'; + $idw++; } print "\n});\n"; print ''; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 03d1ccdd8a7..eea9a06f16f 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -388,18 +388,23 @@ input.buttonpaymentstripe { background-repeat: no-repeat; background-position: 8px 11px; } + /* Used by timesheets */ span.timesheetalreadyrecorded input { border: none; border-bottom: solid 1px rgba(0,0,0,0.4); margin-right: 1px !important; } +td.weekend { + background-color: #eee; +} td.onholidaymorning, td.onholidayafternoon { background-color: #fdf6f2; } td.onholidayallday { background-color: #f4eede; } + td.actionbuttons a { padding-left: 6px; }