NEW Use a css style for weekend in time spent

This commit is contained in:
Laurent Destailleur 2018-02-09 20:11:32 +01:00
parent eb8664e649
commit 633dc507fe
4 changed files with 116 additions and 37 deletions

View File

@ -996,9 +996,19 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning ';
elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon ';
// Duration global $daytoparse;
print '<td align="center" class="duration'.($cssonholiday?' '.$cssonholiday:'').'">'; $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 '<td class="center duration'.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">';
$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]; $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
$totalforeachday[$preselectedday]+=$dayWorkLoad; $totalforeachday[$preselectedday]+=$dayWorkLoad;
@ -1280,7 +1290,14 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
$alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']); $alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']);
$tableCell ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').'">'; 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 ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">';
if ($alreadyspent) if ($alreadyspent)
{ {
$tableCell.='<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>'; $tableCell.='<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';

View File

@ -365,7 +365,6 @@ $nav.=' <input type="submit" name="submitdateselect" class="button valignmiddle"
$picto='calendarweek'; $picto='calendarweek';
print '<form name="addtime" method="POST" action="'.$_SERVER["PHP_SELF"].($project->id > 0 ? '?id='.$project->id : '').'">'; print '<form name="addtime" method="POST" action="'.$_SERVER["PHP_SELF"].($project->id > 0 ? '?id='.$project->id : '').'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addtime">'; print '<input type="hidden" name="action" value="addtime">';
@ -482,23 +481,43 @@ if ($usertoprocess->id == $user->id) print '<td align="right" class="maxwidth100
else print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpentByUser").'</td>';*/ else print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpentByUser").'</td>';*/
print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpent").'<br>('.$langs->trans("Everybody").')</td>'; print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpent").'<br>('.$langs->trans("Everybody").')</td>';
print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpent").($usertoprocess->firstname?'<br>('.$usertoprocess->firstname.')':'').'</td>'; print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpent").($usertoprocess->firstname?'<br>('.$usertoprocess->firstname.')':'').'</td>';
print '<td align="center">'.$langs->trans("HourStart").'</td>'; print '<td class="center">'.$langs->trans("HourStart").'</td>';
print '<td align="center">'.$langs->trans("Duration").'</td>';
print '<td align="center">'.$langs->trans("Note").'</td>';
print '<td align="center"></td>';
print "</tr>\n";
// By default, we can edit only tasks we are assigned to // By default, we can edit only tasks we are assigned to
$restrictviewformytask=(empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)?1:0); $restrictviewformytask=(empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)?1:0);
// Get if user is available or not for each day // Get if user is available or not for each day
$holiday = new Holiday($db); $holiday = new Holiday($db);
$isavailable=array(); $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 $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 $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 '<td class="center'.($cssweekend?' '.$cssweekend:'').'">'.$langs->trans("Duration").'</td>';
print '<td class="center">'.$langs->trans("Note").'</td>';
print '<td class="center"></td>';
print "</tr>\n";
if (count($tasksarray) > 0) if (count($tasksarray) > 0)
{ {
//var_dump($tasksarray); // contains only selected tasks //var_dump($tasksarray); // contains only selected tasks
@ -571,13 +590,24 @@ if (count($tasksarray) > 0)
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax)
{ {
print '<tr class="liste_total"> print '<tr class="liste_total">';
<td class="liste_total" colspan="'.$colspan.'">'; print '<td class="liste_total" colspan="'.$colspan.'">';
print $langs->trans("Total"); print $langs->trans("Total");
//print ' - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong>'; //print ' - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong>';
print '</td> print '</td>';
<td class="liste_total hide0" align="center"><div id="totalDay[0]">&nbsp;</div></td>
<td class="liste_total"></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';
}
print '<td class="liste_total hide0 center'.($cssweekend?' '.$cssweekend:'').'"><div id="totalDay[0]">&nbsp;</div></td>';
print '<td class="liste_total"></td>
<td class="liste_total"></td> <td class="liste_total"></td>
</tr>'; </tr>';
} }

View File

@ -461,7 +461,7 @@ print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
for($i=0;$i<7;$i++) for($idw=0;$idw<7;$idw++)
{ {
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
} }
@ -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 // Get if user is available or not for each day
$holiday = new Holiday($db); $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 $tmparray=explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS);
$dayinloop = dol_time_plus_duree($startday, $i, 'd'); 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 // Useless because $dayinloopwithouthours should be same than $dayinloopfromfirstdaytoshow
//$tmparray = dol_getdate($dayinloop); //$tmparray = dol_getdate($dayinloop);
@ -505,7 +515,14 @@ for ($i=0;$i<7;$i++)
$isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow); $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 $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>';
$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 '<td width="6%" align="center" class="hide'.$idw.($cssweekend?' '.$cssweekend:'').'">'.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'<br>'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'</td>';
} }
print '<td></td>'; print '<td></td>';
print "</tr>\n"; print "</tr>\n";
@ -578,7 +595,13 @@ if (count($tasksarray) > 0)
print '</td>'; print '</td>';
for ($idw = 0; $idw < 7; $idw++) for ($idw = 0; $idw < 7; $idw++)
{ {
print '<td align="center">'; $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 '<td align="center'.($cssweekend?' '.$cssweekend:'').'">';
$tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd');
$timeonothertasks=($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); $timeonothertasks=($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]);
if ($timeonothertasks) if ($timeonothertasks)
@ -599,15 +622,19 @@ if (count($tasksarray) > 0)
<td class="liste_total" colspan="'.$colspan.'">'; <td class="liste_total" colspan="'.$colspan.'">';
print $langs->trans("Total"); print $langs->trans("Total");
print ' - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong>'; print ' - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong>';
print '</td> print '</td>';
<td class="liste_total hide0" align="center"><div id="totalDay[0]">&nbsp;</div></td>
<td class="liste_total hide1" align="center"><div id="totalDay[1]">&nbsp;</div></td> for ($idw = 0; $idw < 7; $idw++)
<td class="liste_total hide2" align="center"><div id="totalDay[2]">&nbsp;</div></td> {
<td class="liste_total hide3" align="center"><div id="totalDay[3]">&nbsp;</div></td> $cssweekend='';
<td class="liste_total hide4" align="center"><div id="totalDay[4]">&nbsp;</div></td> 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.
<td class="liste_total hide5" align="center"><div id="totalDay[5]">&nbsp;</div></td> {
<td class="liste_total hide6" align="center"><div id="totalDay[6]">&nbsp;</div></td> $cssweekend='weekend';
<td class="liste_total"></td> }
print '<td class="liste_total hide'.$idw.($cssweekend?' '.$cssweekend:'').'" align="center"><div id="totalDay['.$idw.']">&nbsp;</div></td>';
}
print '<td class="liste_total"></td>
</tr>'; </tr>';
} }
} }
@ -642,11 +669,11 @@ if ($conf->use_javascript_ajax)
} }
});'."\n"; });'."\n";
$i=0; $idw=0;
while ($i < 7) while ($idw < 7)
{ {
print ' updateTotal('.$i.',\''.$modeinput.'\');'; print ' updateTotal('.$idw.',\''.$modeinput.'\');';
$i++; $idw++;
} }
print "\n});\n"; print "\n});\n";
print '</script>'; print '</script>';

View File

@ -388,18 +388,23 @@ input.buttonpaymentstripe {
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: 8px 11px; background-position: 8px 11px;
} }
/* Used by timesheets */ /* Used by timesheets */
span.timesheetalreadyrecorded input { span.timesheetalreadyrecorded input {
border: none; border: none;
border-bottom: solid 1px rgba(0,0,0,0.4); border-bottom: solid 1px rgba(0,0,0,0.4);
margin-right: 1px !important; margin-right: 1px !important;
} }
td.weekend {
background-color: #eee;
}
td.onholidaymorning, td.onholidayafternoon { td.onholidaymorning, td.onholidayafternoon {
background-color: #fdf6f2; background-color: #fdf6f2;
} }
td.onholidayallday { td.onholidayallday {
background-color: #f4eede; background-color: #f4eede;
} }
td.actionbuttons a { td.actionbuttons a {
padding-left: 6px; padding-left: 6px;
} }