diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index b75da799cb2..4ce8d347730 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -274,6 +274,7 @@ TicketsDelayForFirstResponseTooLong=Too much time elapsed since ticket opening w TicketsDelayFromLastResponseTooLong=Too much time elapsed since last answer on this ticket. TicketNoContractFoundToLink=No contract was found to be automatically linked to this ticket. Please link a contract manually. TicketManyContractsLinked=Many contracts have been automatically linked to this ticket. Make sure to verify which should be chosen. +TicketRefAlreadyUsed=The reference [%s] is already used, your new reference is [%s] # # Logs diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 76d266eb760..1b8e15adc98 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -207,7 +207,16 @@ if (empty($reshook)) { if (!$error) { $db->begin(); - $object->ref = GETPOST("ref", 'alphanohtml'); + $getRef = GETPOST("ref", 'alphanohtml'); + if ($object->fetch('', $getRef) > 0) { + $object->ref = $object->getDefaultRef(); + $object->track_id = null; + setEventMessage($langs->trans('TicketRefAlreadyUsed', $getRef, $object->ref)); + } + else { + $object->ref = $getRef; + } + $object->fk_soc = GETPOST("socid", 'int') > 0 ? GETPOST("socid", 'int') : 0; $object->subject = GETPOST("subject", 'alphanohtml'); $object->message = GETPOST("message", 'restricthtml');