Update create_ticket.php

This commit is contained in:
Laurent Destailleur 2022-11-02 01:07:31 +01:00 committed by GitHub
parent 634348d048
commit 414b183ead
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -146,7 +146,7 @@ if (empty($reshook) && $action == 'create_ticket' && GETPOST('save', 'alpha')) {
$contacts = $object->searchContactByEmail($origin_email);
// Ensure that contact is active and select first active contact
$cid = 0;
$cid = -1;
foreach ($contacts as $key => $contact) {
if ((int) $contact->statut == 1) {
$cid = $key;
@ -156,7 +156,7 @@ if (empty($reshook) && $action == 'create_ticket' && GETPOST('save', 'alpha')) {
// Option to require email exists to create ticket
if (!empty($conf->global->TICKET_EMAIL_MUST_EXISTS) && !$contacts[$cid]->socid) {
if (!empty($conf->global->TICKET_EMAIL_MUST_EXISTS) && ($cid <= 0 || empty($contacts[$cid]->socid))) {
$error++;
array_push($object->errors, $langs->trans("ErrorEmailMustExistToCreateTicket"));
$action = '';