From d4bbc72b1bee0f3291341d1481c4be306a2c25e1 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 7 Jun 2022 14:31:22 +0200 Subject: [PATCH] fix: 21139 --- htdocs/ticket/card.php | 3 ++- htdocs/ticket/class/ticket.class.php | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index f46a9ecc61d..b5759d194d4 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -387,6 +387,7 @@ if (empty($reshook)) { // Si déjà un user assigné on le supprime des contacts if ($useroriginassign > 0) { $internal_contacts = $object->listeContact(-1, 'internal', 0, 'SUPPORTTEC'); + foreach ($internal_contacts as $key => $contact) { if ($contact['id'] !== $usertoassign) { $result = $object->delete_contact($contact['rowid']); @@ -1055,7 +1056,7 @@ if ($action == 'create' || $action == 'presend') { print ''; print ''; //print ' '; - print $form->select_dolusers($user->id, 'fk_user_assign', 1); + print $form->select_dolusers(empty($object->fk_user_assign)?$user->id:$object->fk_user_assign, 'fk_user_assign', 1); print ' '; print ''; } diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index e267ffce6c1..3ac3727af13 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -496,6 +496,13 @@ class Ticket extends CommonObject } } + if (!$error && $this->fk_user_assign > 0) { + if ($this->add_contact($this->fk_user_assign, 'SUPPORTTEC', 'internal') < 0) { + $error++; + } + } + + //Update extrafield if (!$error) { $result = $this->insertExtraFields(); @@ -2194,6 +2201,10 @@ class Ticket extends CommonObject $sql .= " AND tc.source = 'external'"; } + if (!empty($code)) { + $sql .= " AND tc.code = '".$this->db->escape($code)."'"; + } + $sql .= " AND tc.active=1"; if ($status >= 0) { $sql .= " AND ec.statut = ".((int) $status);