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]['afternoon']) $cssonholiday.='onholidayafternoon ';
// Duration
print '<td align="center" class="duration'.($cssonholiday?' '.$cssonholiday:'').'">';
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 '<td class="center duration'.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">';
$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 ='<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)
{
$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';
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="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>';*/
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="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";
print '<td class="center">'.$langs->trans("HourStart").'</td>';
// 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 '<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)
{
//var_dump($tasksarray); // contains only selected tasks
@ -571,13 +590,24 @@ if (count($tasksarray) > 0)
if ($conf->use_javascript_ajax)
{
print '<tr class="liste_total">
<td class="liste_total" colspan="'.$colspan.'">';
print $langs->trans("Total");
//print ' - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong>';
print '</td>
<td class="liste_total hide0" align="center"><div id="totalDay[0]">&nbsp;</div></td>
<td class="liste_total"></td>
print '<tr class="liste_total">';
print '<td class="liste_total" colspan="'.$colspan.'">';
print $langs->trans("Total");
//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';
}
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>
</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>';
for($i=0;$i<7;$i++)
for($idw=0;$idw<7;$idw++)
{
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
$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 '<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 "</tr>\n";
@ -578,7 +595,13 @@ if (count($tasksarray) > 0)
print '</td>';
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');
$timeonothertasks=($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]);
if ($timeonothertasks)
@ -599,15 +622,19 @@ if (count($tasksarray) > 0)
<td class="liste_total" colspan="'.$colspan.'">';
print $langs->trans("Total");
print ' - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong>';
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>
<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>
<td class="liste_total hide4" align="center"><div id="totalDay[4]">&nbsp;</div></td>
<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>
<td class="liste_total"></td>
print '</td>';
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 '<td class="liste_total hide'.$idw.($cssweekend?' '.$cssweekend:'').'" align="center"><div id="totalDay['.$idw.']">&nbsp;</div></td>';
}
print '<td class="liste_total"></td>
</tr>';
}
}
@ -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 '</script>';

View File

@ -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;
}