Page 1 of 1

[SOLVED] Notify Users of Reply

Posted: Wed Mar 27, 2013 1:23 pm
by mqcarpenter
I figured this out and wanted to share as I am sure it may help others.

This is for Version: 2.4.2 from 30th December 2012.

ISSUE: I wanted to have an option to notify all my support staff when a ticket was responded to. All my users work the same ticket pool, but once a ticket was assigned, they did not receive replies on tickets just to keep an eye out, unless they reviewed the ticket list and opened it. Also, the assigned users wanted a copy of the ticket reply.

SOLUTION: I added a check box to the ticket reply window to give them the option to copy the support team as a whole. When they reply, it sends an email to a distribution list.

Steps:
Open admin_ticket.php
Around line 1448 ( I added my option below the priority change option) AFTER

Code: Select all

	<label><input type="checkbox" name="set_priority" value="1" /> <?php echo $hesklang['change_priority']; ?> </label>
	<select name="priority">
	<?php echo implode('',$options); ?>
	</select><br />
ADD

Code: Select all

	<label><input type="checkbox" name="notify" value="1" checked="checked" /> <?php echo $hesklang['notify_all']; ?></label>
	</select><br />

Open and edit admin_reply_ticket.php

Around line 258 AFTER

Code: Select all

/* Update number of replies in the users table */
$sql = "UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` SET `replies`=`replies`+1 WHERE `id`=".hesk_dbEscape($_SESSION['id'])." LIMIT 1";
hesk_dbQuery($sql);

/* --> Prepare reply message */
$ticket['subject'] = hesk_msgToPlain($ticket['subject'], 1, 0);
$ticket['message'] = hesk_msgToPlain($message, 1);

/* Notify the customer */
hesk_notifyCustomer('new_reply_by_staff');
ADD

Code: Select all

if ( ! empty($_POST['notify']) )
{
    
	/* --> Prepare reply message */
	$ticket['subject'] = hesk_msgToPlain($ticket['subject'], 1, 0);
	$ticket['message'] = hesk_msgToPlain($message, 1);

	$notify2='support@yourdomain.com';
	$msg = hesk_getEmailMessage('new_reply_by_otherstaff',$ticket,1);
	hesk_mail($notify2,$hesklang['new_reply_by_otherstaff'],$msg);

}
else
{
    $notify = "";
}
Create a new email template. Mine as you see is called new_reply_by_otherstaff.txt:

Code: Select all

Ticket Topic: %%SUBJECT%%
----------------------------------------
Someone has updated Ticket %%TRACK_ID%% as follows:

%%MESSAGE%%



----------------------------------------
Access this ticket: 
%%TRACK_URL%%
You also need a new hesklang subject in text.php. Mine is called new_reply_by_otherstaff and the label on the form is notify_all. I did not need the ticket data in the subject. It would be confusing to them since these are not tickets assigned to them, so it is generic. If you wanted this, you would need to change the code above and grab that data to include it in the notification email.

Code: Select all

$hesklang['new_reply_by_otherstaff']     = 'Support Staff Updated a Ticket';
$hesklang['notify_all']='Notify ISD of reply';
That is it! It is set to send the email by default as you see on the checkbox value. You can turn that off if you like. I hope this helps others. There is no guarantee on this, it is just an idea. Cheers

Re: [SOLVED] Notify Users of Reply

Posted: Mon Aug 05, 2013 4:08 pm
by bastiaan.c
Hello all,
Thanks so much for this modification!!! :) It is exactly what I need! :P

I am using 2.5.0 and I have implemented all the code in the files. When I use option "Notify ISD of reply "
I will become following error.

Error:

Invalid email file



WARNING
Debug mode is enabled. Make sure you disable debug mode in settings once HESK is installed and working properly.


Please help. I checked if I did all correct twice.
Is it because I use 2.5.0 ??

Thanks for any help

Re: [SOLVED] Notify Users of Reply

Posted: Fri Sep 20, 2013 11:33 am
by bastiaan.c
Anyone???
:?

Re: [SOLVED] Notify Users of Reply

Posted: Fri Sep 20, 2013 12:06 pm
by peppe
Hi,
I have the same problem with HESK 2.5.0.
Can someone help me?

thanks

james

Re: [SOLVED] Notify Users of Reply

Posted: Mon Feb 23, 2015 10:24 pm
by mqcarpenter
This has major changes in 2.6. Can someone please review to update? It is an extremely useful mod

Re: [SOLVED] Notify Users of Reply

Posted: Tue Feb 24, 2015 10:49 pm
by mqcarpenter
This does not function exactly as before but at least my team is getting notifications again in 2.6. Unfortunately I have not found a way to implement a custom template like before. This basically just CCs another email when a ticket is updated and a customer is notified.

Open email_functions.php in inc
At or around 50 look for:

Code: Select all

function hesk_notifyCustomer($email_template = 'new_ticket')
{
	global $hesk_settings, $hesklang, $ticket;

	// Demo mode
	if ( defined('HESK_DEMO') )
	{
		return true;
	}

	// Format email subject and message
	$subject = hesk_getEmailSubject($email_template,$ticket);
	$message = hesk_getEmailMessage($email_template,$ticket);

	// Send e-mail
	hesk_mail($ticket['email'], $subject, $message);

    return true;

} // END hesk_notifyCustomer()

And change to:

Code: Select all

function hesk_notifyCustomer($email_template = 'new_ticket')
{
	global $hesk_settings, $hesklang, $ticket;

	// Demo mode
	if ( defined('HESK_DEMO') )
	{
		return true;
	}

	// Format email subject and message
	$subject = hesk_getEmailSubject($email_template,$ticket);
	$message = hesk_getEmailMessage($email_template,$ticket);
	$notify2='support@yourdomain.com';

	// Send e-mail
	hesk_mail($ticket['email'], $subject, $message);
	hesk_mail($notify2, $subject, $message);
    return true;

} // END hesk_notifyCustomer()




Re: [SOLVED] Notify Users of Reply

Posted: Sun Jul 31, 2016 6:10 pm
by xyzzy
Profile notifications needs settings added:
Someone replies a ticket assigned to me
Someone replies a ticket unassigned to me

So that a staff can get notify mail when a customer or a staff replies a ticket both way covered.