From e43438cc7b82239e1438282437bb6c4c397950fc Mon Sep 17 00:00:00 2001 From: Vincent Penel Date: Tue, 10 Feb 2026 15:40:05 +0100 Subject: [PATCH] Fix/ticket status (#37129) * set oldCopy and Status * Update ticket.class.php * Question Eldy * Fix event status change --------- Co-authored-by: Laurent Destailleur --- htdocs/core/class/commonobject.class.php | 4 ++++ htdocs/ticket/card.php | 4 ++-- htdocs/ticket/class/ticket.class.php | 2 +- htdocs/ticket/list.php | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1561867c858..385b493b2d7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4478,7 +4478,11 @@ abstract class CommonObject } } + $this->context = array_merge($this->context, array('newstatus' => $status)); + if ($trigkey) { + $this->oldcopy = dol_clone($this); + // Call trigger $result = $this->call_trigger($trigkey, $user); if ($result < 0) { diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index e207479cacc..9832970bdfa 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -568,7 +568,7 @@ if (empty($reshook)) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { // prevent browser refresh from reopening ticket several times if ($object->status == Ticket::STATUS_CLOSED || $object->status == Ticket::STATUS_CANCELED) { - $res = $object->setStatut(Ticket::STATUS_ASSIGNED); + $res = $object->setStatut(Ticket::STATUS_ASSIGNED, null, '', 'TICKET_MODIFY'); if ($res) { // Log action in ticket logs table //$log_action = $langs->trans('TicketLogReopen'); @@ -626,7 +626,7 @@ if (empty($reshook)) { if ($object->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { $new_status = GETPOST('new_status', 'int'); $old_status = $object->status; - $res = $object->setStatut($new_status); + $res = $object->setStatut($new_status, null, '', 'TICKET_MODIFY'); if ($res) { // Log action in ticket logs table $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status])); diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index e821b4e80d4..fadcb371358 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -2714,7 +2714,7 @@ class Ticket extends CommonObject if (($object->status < self::STATUS_IN_PROGRESS && !$user->socid && !$private) || ($object->status > self::STATUS_IN_PROGRESS && $public_area) ) { - $object->setStatut(3); + $object->setStatut(3, null, '', 'TICKET_MODIFY'); } return 1; } else { diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 4c4dce5a428..1fddd77010c 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -284,7 +284,7 @@ if (empty($reshook)) { $result = $objecttmp->fetch($toselectid); if ($result > 0) { if ($objecttmp->status == Ticket::STATUS_CLOSED || $objecttmp->status == Ticket::STATUS_CANCELED) { - $result = $objecttmp->setStatut(Ticket::STATUS_ASSIGNED); + $result = $objecttmp->setStatut(Ticket::STATUS_ASSIGNED, null, '', 'TICKET_MODIFY'); if ($result < 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++;