Page 1 of 1

[mod] add different emails on ticket merge

Posted: Wed Aug 14, 2024 9:50 am
by alxik
Hi,

One more small mod from my side, helpful for situation, when merging tickets and they have different customer emails (so no email will be lost due to merge).

File needed to modify is> /inc/admin_functions.inc.php.
Working on HESK: 3.4.6.

1) Find "/* Set some variables for later */" (~line 156) and add>

Code: Select all

	$merged_mail = $ticket['email'];
2) Few lines later find:

Code: Select all

        /* Get required ticket information */
        $res = hesk_dbQuery("SELECT `id`,`trackid`,`category`,`name`,`message`,`message_html`,`dt`,`time_worked`,`attachments` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` WHERE `id`='".intval($this_id)."' LIMIT 1");
And replace with:

Code: Select all

        /* Get required ticket information */
        $res = hesk_dbQuery("SELECT `id`,`trackid`,`category`,`name`,`message`,`message_html`,`dt`,`time_worked`,`attachments`,`email` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` WHERE `id`='".intval($this_id)."' LIMIT 1");
3) Few lines later after:

Code: Select all

        /* Has this user access to the ticket category? */
        if ( ! hesk_okCategory($row['category'], 0) )
        {
        	continue;
        }
add:

Code: Select all

		// Mod: Add email and customer name
		$customer_name = $row['name'];
		$customer_email = $row['email'];
		
		if ($merged_mail != $customer_email)
		{
			hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` SET `email`='".hesk_dbEscape($ticket['email']).",".hesk_dbEscape($customer_email)."' WHERE `id`='".intval($merge_into)."'");
		}
		// end mod
4) Then find :

Code: Select all

		/* Log that ticket has been merged */
		$history .= sprintf($hesklang['thist13'],hesk_date(),$row['trackid'],addslashes($_SESSION['name']).' ('.$_SESSION['user'].')');
		
And after that add:

Code: Select all

		// Mod: add history note with old name/mail also for all merged tickets.
		$history .= '<li class="smaller"> | '. $hesklang['customer']. ': ' . addslashes($customer_name) . ' ' . addslashes($customer_email) .'</li>';
		

Re: [mod] add different emails on ticket merge

Posted: Wed Aug 14, 2024 4:15 pm
by Klemen
Thanks for sharing!