diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index 1037c104758..a385f030a90 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2024-2025 Frédéric France * Copyright (C) 2025 MDW * Copyright (C) 2025 Jessica Kowal + * Copyright (C) 2025 Charlene Benke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -623,7 +624,7 @@ class Tasks extends DolibarrApi * @phan-return array{success:array{code:int,message:string}} * @phpstan-return array{success:array{code:int,message:string}} */ - public function addTimeSpent($id, $date, $duration, $product_id = null, $user_id = 0, $note = '', $progress = null) + public function addTimeSpent($id, $date, $duration, $product_id = null, $user_id = 0, $note = '', $progress = -1) { if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); @@ -651,8 +652,9 @@ class Tasks extends DolibarrApi $this->task->timespent_fk_product = $product_id; $this->task->timespent_fk_user = $uid; $this->task->timespent_note = $note; - if (!empty($this->task->progress)) + if (!empty($progress) && $progress >= 0 && $progress <= 100) { $this->task->progress = $progress; + } $result = $this->task->addTimeSpent(DolibarrApiAccess::$user, 0); if ($result == 0) {