[mod] add different emails on ticket merge

Everything related to Hesk - helpdesk software

Moderator: mkoch227

Post Reply
alxik
Posts: 6
Joined: Mon Mar 11, 2024 2:57 pm

[mod] add different emails on ticket merge

Post 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>';
		
Klemen
Site Admin
Posts: 10135
Joined: Fri Feb 11, 2005 4:04 pm

Re: [mod] add different emails on ticket merge

Post by Klemen »

Thanks for sharing!
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Post Reply