diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index f46a9ecc61d..efa2eba0999 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -1055,7 +1055,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); diff --git a/htdocs/ticket/contact.php b/htdocs/ticket/contact.php index 89822df2676..ee76045ffec 100644 --- a/htdocs/ticket/contact.php +++ b/htdocs/ticket/contact.php @@ -137,6 +137,16 @@ if ($action == 'swapstatut' && $user->rights->ticket->write) { // Efface un contact if ($action == 'deletecontact' && $user->rights->ticket->write) { if ($object->fetch($id, '', $track_id)) { + $internal_contacts = $object->listeContact(-1, 'internal', 0, 'SUPPORTTEC'); + foreach ($internal_contacts as $key => $contact) { + if ($contact['rowid'] == $lineid && $object->fk_user_assign==$contact['id']) { + $ret = $object->assignUser($user, null); + if ($ret < 0) { + $error ++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } $result = $object->delete_contact($lineid); if ($result >= 0) {