FIX #34046 No traceability when generating Intervention from Task Time (#34209)

* fix generating Intervention from Task Time

* remove comment

* fix CI

* FIX CI
This commit is contained in:
Mohamed DAOUD 2025-05-20 22:34:11 +02:00 committed by GitHub
parent c724800a05
commit d359a4d7a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 2 deletions

View file

@ -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();

View file

@ -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');
}
}
}
}