update ticket ref when the ref is already used at the creation

This commit is contained in:
Maximilien Rozniecki 2023-05-10 09:27:49 +02:00
parent a900a6c968
commit 396abfe882
2 changed files with 11 additions and 1 deletions

View file

@ -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

View file

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