NEW Add the total in the perday view of the time spent form.

This commit is contained in:
Laurent Destailleur 2017-09-18 14:18:34 +02:00
parent 85d59b32b3
commit da6b1e92b2
5 changed files with 79 additions and 6 deletions

View File

@ -5041,7 +5041,7 @@ class Form
}
elseif ($typehour=='text' || $typehour=='textselect')
{
$retstring.='<input placeholder="'.$langs->trans('HourShort').'" type="number" min="0" size="1" name="'.$prefix.'hour"'.($disabled?' disabled':'').' class="flat maxwidth50" value="'.(($hourSelected != '')?((int) $hourSelected):'').'">';
$retstring.='<input placeholder="'.$langs->trans('HourShort').'" type="number" min="0" size="1" name="'.$prefix.'hour"'.($disabled?' disabled':'').' class="flat maxwidth50 inputhour" value="'.(($hourSelected != '')?((int) $hourSelected):'').'">';
}
else return 'BadValueForParameterTypeHour';
@ -5065,7 +5065,7 @@ class Form
}
elseif ($typehour=='text' )
{
$retstring.='<input placeholder="'.$langs->trans('MinuteShort').'" type="number" min="0" size="1" name="'.$prefix.'min"'.($disabled?' disabled':'').' class="flat maxwidth50" value="'.(($minSelected != '')?((int) $minSelected):'').'">';
$retstring.='<input placeholder="'.$langs->trans('MinuteShort').'" type="number" min="0" size="1" name="'.$prefix.'min"'.($disabled?' disabled':'').' class="flat maxwidth50 inputminute" value="'.(($minSelected != '')?((int) $minSelected):'').'">';
}
if ($typehour!='text') $retstring.=' '.$langs->trans('MinuteShort');

View File

@ -163,6 +163,56 @@ function updateTotal(days,mode)
}
}
}
// Add data on the perday view
jQuery('.inputhour').each(function( index ) {
if (this.value)
{
var taskTime= new Date(0);
/*console.log(total.getHours())
console.log(this.value)
alert(element.value);*/
if (this.value)
{
console.log(this.value+':00')
result=parseTime(this.value+':00',taskTime);
}
else
{
result=parseTime(this.innerHTML+':00',taskTime);
}
if (result >= 0)
{
total.setHours(total.getHours()+taskTime.getHours());
}
console.log(total.getHours())
}
});
// Add data on the perday view
jQuery('.inputminute').each(function( index ) {
if (this.value)
{
var taskTime= new Date(0);
/* console.log(total.getHours())
console.log(this.value)
alert(element.value);*/
if (this.value)
{
console.log('00:'+this.value)
result=parseTime('00:'+"00".substring(0, 2 - this.value.length) + this.value,taskTime);
}
else
{
result=parseTime('00:'+"00".substring(0, 2 - this.innerHTML) + this.innerHTML,taskTime);
}
if (result >= 0)
{
total.setMinutes(total.getMinutes()+taskTime.getMinutes());
}
console.log(total.getMinutes())
}
});
if (document.getElementById('totalDay['+days+']')) // May be null if no task records to output (nbline is also 0 in this case)
{
document.getElementById('totalDay['+days+']').innerHTML = pad(total.getHours())+':'+pad(total.getMinutes());

View File

@ -739,6 +739,8 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
$alreadyspent='';
if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
$idw = 0;
$tableCell='';
$tableCell.='<span class="timesheetalreadyrecorded"><input type="text" class="center" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
$tableCell.=' + ';
@ -746,6 +748,15 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
$tableCell.=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1);
//$tableCell.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled':'').' value="'.$langs->trans("Add").'">';
print $tableCell;
$modeinput='hours';
print '<script type="text/javascript">';
print "jQuery(document).ready(function () {\n";
print " jQuery('.inputhour, .inputminute').bind('keyup', function(e) { updateTotal(0, '".$modeinput."') });";
print "})\n";
print '</script>';
print '</td>';
print '<td align="right">';

View File

@ -332,8 +332,7 @@ $tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($proj
//var_dump($projectsrole);
//var_dump($taskrole);
llxHeader("",$title,"");
llxHeader("",$title,"",'','','',array('/core/js/timesheet.js'));
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project');
@ -489,6 +488,16 @@ if (count($tasksarray) > 0)
{
$j=0;
projectLinesPerDay($j, 0, $usertoprocess, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $daytoparse);
$colspan = 8;
if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY)) $colspan++;
print '<tr class="liste_total">
<td class="liste_total" colspan="'.$colspan.'">'.$langs->trans("Total").'</td>
<td class="liste_total hide0" align="center"><div id="totalDay[0]">&nbsp;</div></td>
<td class="liste_total"></td>
<td class="liste_total"></td>
</tr>';
}
else
{
@ -497,16 +506,20 @@ else
print "</table>";
print '</div>';
print '<input type="hidden" id="numberOfLines" name="numberOfLines" value="'.count($tasksarray).'"/>'."\n";
print '<div class="center">';
print '<input type="submit" class="button"'.($disabledtask?' disabled':'').' value="'.$langs->trans("Save").'">';
print '</div>';
print '</form>';
$modeinput='hours';
print '<script type="text/javascript">';
print "jQuery(document).ready(function () {\n";
print ' jQuery(".timesheetalreadyrecorded").tipTip({ maxWidth: "600px", edgeOffset: 10, delay: 50, fadeIn: 50, fadeOut: 50, content: \''.dol_escape_js($langs->trans("TimeAlreadyRecorded", $user->getFullName($langs))).'\'});';
print ' jQuery(".timesheetalreadyrecorded").tipTip({ maxWidth: "600px", edgeOffset: 10, delay: 50, fadeIn: 50, fadeOut: 50, content: \''.dol_escape_js($langs->trans("TimeAlreadyRecorded", $user->getFullName($langs))).'\'});';
print ' updateTotal(0,\''.$modeinput.'\');';
print "});";
print '</script>';

View File

@ -515,7 +515,6 @@ else
print "</table>";
print '</div>';
print '<input type="hidden" name="timestamp" value="1425423513"/>'."\n";
print '<input type="hidden" id="numberOfLines" name="numberOfLines" value="'.count($tasksarray).'"/>'."\n";
print '<div class="center">';