Contact alternate email (DB 4.4.1): one more address per contact in the contact window under Email, shown on their page, quick look and the Reach column, searched by the contacts, clients, tickets and global searches, exported and imported as Alternate Email and in the API as contact_email_alt, and recognized on incoming email as theirs - a new ticket as them at their client even with unknown senders off, and their reply by ticket number, conversation or subject - with the ticket's from line showing the address it came from while everything ITFlow sends still goes to their Email and neither address is copied in; the duplicate warning, Try an Email, Unprocessed Email and the ignored sender and routing rule warnings count it too, and the same-as-Email warning shows while typing (contactEmailSql(), contactHasEmail(), contactEmailMatchSql()); 26.12.4 changelog

This commit is contained in:
johnnyq
2026-12-02 13:36:49 -05:00
parent 8dae372d57
commit 2ad57e2865
31 changed files with 276 additions and 80 deletions

View File

@@ -108,9 +108,12 @@ function ticketMailTryOutcome(array $decision, $from_email, $auto_reply = false)
$contact_text . 'The subject is its subject and the email its details. ' . $route_text . ($decision['quiet'] ? '' : ' ' . ticketMailTryNoReply($from_email)) . $linked];
}
if ($contact) {
// From their alternate email - answered at their Email, where everything ITFlow sends goes
$alternate = strtolower(trim((string) $contact['contact_email'])) !== $from_email;
return ['fa-plus-circle', 'success', 'A new ticket for ' . ($decision['client_name'] ?? 'no client'),
'From ' . $contact['contact_name'] . ', with the subject as its subject and the email as its details. ' . (!empty($decision['picked']['others']) ? 'A note on it names the other clients they are a contact at. ' : '')
. ($route_text !== '' ? $route_text . ' ' : '') . ticketMailTryNoReply($from_email) . $linked];
'From ' . $contact['contact_name'] . ($alternate ? ', at their alternate email' : '') . ', with the subject as its subject and the email as its details. ' . (!empty($decision['picked']['others']) ? 'A note on it names the other clients they are a contact at. ' : '')
. ($route_text !== '' ? $route_text . ' ' : '') . ticketMailTryNoReply((string) $contact['contact_email'])
. ($alternate ? ' That goes to their Email, ' . $contact['contact_email'] . ', as all their ticket email does.' : '') . $linked];
}
if ($decision['new_contact']) {
return ['fa-plus-circle', 'success', 'A new contact and ticket for ' . $decision['client_name'],
@@ -150,7 +153,7 @@ function ticketMailTryRoute(array $route, $quiet) {
function ticketMailTryReply($from_email, $ticket_id) {
global $mysqli;
$from_sql = escapeSql($from_email);
$ticket = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT ticket_id, ticket_prefix, ticket_number, ticket_subject, ticket_status, ticket_client_id, contact_email, contact_name, client_name
$ticket = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT ticket_id, ticket_prefix, ticket_number, ticket_subject, ticket_status, ticket_client_id, ticket_contact_id, contact_email, " . contactEmailAltColumn() . ", contact_name, client_name
FROM tickets LEFT JOIN contacts ON contact_id = ticket_contact_id LEFT JOIN clients ON client_id = ticket_client_id
WHERE ticket_id = " . intval($ticket_id) . " LIMIT 1"));
if (!$ticket) {
@@ -159,8 +162,9 @@ function ticketMailTryReply($from_email, $ticket_id) {
$reference = ticketReference($ticket);
$on = $reference . ' - ' . $ticket['ticket_subject'] . ($ticket['client_name'] !== null ? ' (' . $ticket['client_name'] . ')' : '');
$client_id = intval($ticket['ticket_client_id']);
$known = (strtolower((string) $ticket['contact_email']) === $from_email && $from_email !== '')
|| ($client_id && mysqli_num_rows(mysqli_query($mysqli, "SELECT 1 FROM contacts WHERE contact_email = '$from_sql' AND contact_client_id = $client_id AND contact_archived_at IS NULL LIMIT 1")))
$is_contact = intval($ticket['ticket_contact_id']) && contactHasEmail($ticket, $from_email);
$known = $is_contact
|| ($client_id && mysqli_num_rows(mysqli_query($mysqli, "SELECT 1 FROM contacts WHERE " . contactEmailSql($from_email) . " AND contact_client_id = $client_id AND contact_archived_at IS NULL LIMIT 1")))
|| mysqli_num_rows(mysqli_query($mysqli, "SELECT 1 FROM ticket_ccs WHERE ticket_cc_ticket_id = " . intval($ticket['ticket_id']) . " AND ticket_cc_email = '$from_sql' LIMIT 1"));
if (intval($ticket['ticket_status']) === TICKET_STATUS_CLOSED) {
return ['fa-ban', 'warning', "A note on $reference - it is closed",
@@ -168,10 +172,10 @@ function ticketMailTryReply($from_email, $ticket_id) {
. ($known ? '. The sender is told it is closed, and how to raise a new ticket.' : '. The sender isn\'t a contact or CC, so nobody is told - a guessed number would tell them its subject.')];
}
$reopens = ticketMailTryReopens($ticket['ticket_status']);
if (strtolower((string) $ticket['contact_email']) === $from_email && $from_email !== '') {
return ['fa-reply', 'success', "A reply on $on", 'From its contact, ' . $ticket['contact_name'] . ', as the client\'s reply. ' . $reopens];
if ($is_contact) {
return ['fa-reply', 'success', "A reply on $on", 'From its contact, ' . $ticket['contact_name'] . (strtolower(trim((string) $ticket['contact_email'])) !== $from_email ? ' - their alternate email' : '') . ', as the client\'s reply. ' . $reopens];
}
$other = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT contact_name FROM contacts WHERE contact_email = '$from_sql' AND contact_client_id = $client_id LIMIT 1"));
$other = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT contact_name FROM contacts WHERE " . contactEmailSql($from_email) . " AND contact_client_id = $client_id LIMIT 1"));
if ($other) {
return ['fa-reply', 'success', "A reply on $on", 'From ' . $other['contact_name'] . ', another of the client\'s contacts, as the client\'s reply. ' . $reopens];
}