From f56de9f177aee6b8e1304ac1f797f8eac71e7343 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Mar 2020 22:04:40 +0100 Subject: [PATCH] Fix autocalculation of timespent in monthy mode --- htdocs/core/js/timesheet.js | 38 ++++++++++++++++++++++------- htdocs/core/lib/project.lib.php | 4 +-- htdocs/projet/activity/permonth.php | 14 +++++------ 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/htdocs/core/js/timesheet.js b/htdocs/core/js/timesheet.js index 5c9ba74e379..aea8f9a1318 100644 --- a/htdocs/core/js/timesheet.js +++ b/htdocs/core/js/timesheet.js @@ -120,7 +120,11 @@ function updateTotal(days,mode) total.setHours(0); total.setMinutes(0); var nbline = document.getElementById('numberOfLines').value; - for (var i=-1; i= 1 && startline <= 9 && stringdays < 10) { + stringdays = '0'+stringdays; + } + + if (total.getHours() || total.getMinutes()) jQuery('.totalDay'+stringdays).addClass("bold"); + else jQuery('.totalDay'+stringdays).removeClass("bold"); + jQuery('.totalDay'+stringdays).text(pad(total.getHours())+':'+pad(total.getMinutes())); var totalhour = 0; var totalmin = 0; for (var i=0; i<7; i++) { + stringdays = (i + startline); + if (startline >= 1 && startline <= 9 && stringdays < 10) { + stringdays = '0'+stringdays; + } + var taskTime= new Date(0); - result=parseTime(jQuery('.totalDay'+i).text(),taskTime); + result=parseTime(jQuery('.totalDay'+stringdays).text(),taskTime); if (result >= 0) { totalhour = totalhour + taskTime.getHours(); @@ -273,8 +287,14 @@ function updateTotal(days,mode) } } - if (total) jQuery('.totalDay'+days).addClass("bold"); - else jQuery('.totalDay'+days).removeClass("bold"); - jQuery('.totalDay'+days).text(total); + var stringdays = days; + if (startline >= 1 && startline <= 9 && stringdays < 10) { + stringdays = '0'+stringdays; + console.log(stringdays); + } + + if (total) jQuery('.totalDay'+stringdays).addClass("bold"); + else jQuery('.totalDay'+stringdays).removeClass("bold"); + jQuery('.totalDay'+stringdays).text(total); } } diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 71c1c277483..ef9ee7f2cd7 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1910,12 +1910,12 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & $placeholder = ''; if ($alreadyspent) { - $tableCell .= ''; + $tableCell .= ''; //$placeholder=' placeholder="00:00"'; //$tableCell.='+'; } - $tableCell .= ''; diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index d121b39b683..b5d4bcc633d 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -21,7 +21,7 @@ /** * \file htdocs/projet/activity/permonth.php * \ingroup projet - * \brief List activities of tasks (per week entry) + * \brief List activities of tasks (per month entry) */ require "../../main.inc.php"; @@ -480,8 +480,7 @@ print ''; print ''; print ''; print ''; -$countWeek = count($TWeek); -for ($idw=0;$idw<$countWeek;$idw++) +foreach ($TWeek as $week_number) { print ''; } @@ -516,6 +515,8 @@ $colspan=5; // By default, we can edit only tasks we are assigned to $restrictviewformytask=(empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)?1:0); +$isavailable = array(); + if (count($tasksarray) > 0) { //var_dump($tasksarray); // contains only selected tasks @@ -616,6 +617,7 @@ print ""; print ''; print ''."\n"; +print ''."\n"; print '
'; print ''; @@ -639,11 +641,9 @@ if ($conf->use_javascript_ajax) } });'."\n"; - $idw=0; - while ($idw < 7) + foreach ($TWeek as $week_number) { - print ' updateTotal('.$idw.',\''.$modeinput.'\');'; - $idw++; + print ' updateTotal('.$week_number.',\''.$modeinput.'\');'; } print "\n});\n"; print '';