From d359a4d7a54374007c50dba531c9f3f2f2fd355b Mon Sep 17 00:00:00 2001 From: Mohamed DAOUD Date: Tue, 20 May 2025 22:34:11 +0200 Subject: [PATCH] FIX #34046 No traceability when generating Intervention from Task Time (#34209) * fix generating Intervention from Task Time * remove comment * fix CI * FIX CI --- htdocs/fichinter/class/fichinter.class.php | 2 +- htdocs/projet/tasks/time.php | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index cf8fe9ddc78..a02f50e76ed 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1469,7 +1469,7 @@ class Fichinter extends CommonObject if ($result >= 0) { $this->db->commit(); - return 1; + return $line->id; } else { $this->error = $this->db->error(); $this->db->rollback(); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index da94e853c59..8551a8ce457 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -845,7 +845,7 @@ if ($action == 'confirm_generateinter') { $arrayoftasks[$object->timespent_id]['timespent'] = $object->timespent_duration; $arrayoftasks[$object->timespent_id]['totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm; $arrayoftasks[$object->timespent_id]['note'] = $object->timespent_note; - $arrayoftasks[$object->timespent_id]['date'] = date('Y-m-d H:i:s', $object->timespent_datehour); + $arrayoftasks[$object->timespent_id]['date'] = $object->timespent_datehour; } foreach ($arrayoftasks as $timespent_id => $value) { @@ -857,6 +857,19 @@ if ($action == 'confirm_generateinter') { // Add lines $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value['note']) ? ' - ' . $value['note'] : ''), (int) $value['date'], $value['timespent']); + + if ($lineid > 0) { + // Link timespent to intervention + $timespent = new TimeSpent($db); + $timespent->fetch($timespent_id); + $timespent->intervention_id = $tmpinter->id; + $timespent->intervention_line_id = $lineid; + $result = $timespent->update($user); + if ($result < 0) { + $error++; + setEventMessages($timespent->error, $timespent->errors, 'errors'); + } + } } }