From da6b1e92b2bb59110a3da802fbb85666d6700098 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2017 14:18:34 +0200 Subject: [PATCH] NEW Add the total in the perday view of the time spent form. --- htdocs/core/class/html.form.class.php | 4 +-- htdocs/core/js/timesheet.js | 50 +++++++++++++++++++++++++++ htdocs/core/lib/project.lib.php | 11 ++++++ htdocs/projet/activity/perday.php | 19 ++++++++-- htdocs/projet/activity/perweek.php | 1 - 5 files changed, 79 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0260effebc6..bca87c7a65f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5041,7 +5041,7 @@ class Form } elseif ($typehour=='text' || $typehour=='textselect') { - $retstring.=''; + $retstring.=''; } else return 'BadValueForParameterTypeHour'; @@ -5065,7 +5065,7 @@ class Form } elseif ($typehour=='text' ) { - $retstring.=''; + $retstring.=''; } if ($typehour!='text') $retstring.=' '.$langs->trans('MinuteShort'); diff --git a/htdocs/core/js/timesheet.js b/htdocs/core/js/timesheet.js index 5541f348c9f..a55424f8e8c 100644 --- a/htdocs/core/js/timesheet.js +++ b/htdocs/core/js/timesheet.js @@ -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()); diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index f220c2f6542..8233251d815 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -739,6 +739,8 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr $alreadyspent=''; if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); + $idw = 0; + $tableCell=''; $tableCell.=''; $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.=' '; print $tableCell; + + $modeinput='hours'; + + print ''; + print ''; print ''; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 4dff34ad30b..da789675cb8 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -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 ' + '.$langs->trans("Total").' +
 
+ + + '; } else { @@ -497,16 +506,20 @@ else print ""; print ''; +print ''."\n"; + print '
'; print ''; print '
'; print ''; +$modeinput='hours'; print ''; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 6ea60f3d76f..c0482967c9e 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -515,7 +515,6 @@ else print ""; print ''; -print ''."\n"; print ''."\n"; print '
';