From 03dbf6e747fe52a9edf8df82e029029ff828e92e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Jul 2016 14:28:33 +0200 Subject: [PATCH] Fix edit of progess only --- htdocs/projet/activity/perday.php | 6 +++--- htdocs/projet/activity/perweek.php | 28 ++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 07918c4bfbf..0c509240684 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -234,9 +234,9 @@ if ($action == 'addtime' && $user->rights->projet->lire) exit; } } - else - { - setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors'); + else + { + setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors'); } } diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 5bf60d426d8..53b9ba151b4 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -100,7 +100,7 @@ if (GETPOST('submitdateselect')) $action = ''; } -if ($action == 'addtime' && GETPOST('assigntask')) +if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')) { $action = 'assigntask'; @@ -185,9 +185,10 @@ if ($action == 'addtime' && $user->rights->projet->lire) } else { - foreach($timetoadd as $taskid => $value) + foreach($timetoadd as $taskid => $value) // Loop on each task { - foreach($value as $key => $val) + $updateoftaskdone=0; + foreach($value as $key => $val) // Loop on each day { $amountoadd=$timetoadd[$taskid][$key]; if (! empty($amountoadd)) @@ -201,7 +202,7 @@ if ($action == 'addtime' && $user->rights->projet->lire) if ($newduration > 0) { $object->fetch($taskid); - $object->progress = GETPOST($taskid . 'progress', 'int'); + $object->progress = GETPOST($taskid . 'progress', 'int'); $object->timespent_duration = $newduration; $object->timespent_fk_user = $usertoprocess->id; $object->timespent_date = dol_time_plus_duree($firstdaytoshow, $key, 'd'); @@ -213,9 +214,28 @@ if ($action == 'addtime' && $user->rights->projet->lire) $error++; break; } + + $updateoftaskdone++; } } } + + if (! $updateoftaskdone) // Check to update progress if no update were done on task. + { + $object->fetch($taskid); + //var_dump($object->progress);var_dump(GETPOST($taskid . 'progress', 'int')); exit; + if ($object->progress != GETPOST($taskid . 'progress', 'int')) + { + $object->progress = GETPOST($taskid . 'progress', 'int'); + $result=$object->update($user); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + break; + } + } + } } if (! $error)