Page 1 of 1
How can I notify a user that a ticket has been closed
Posted: Fri Apr 11, 2008 9:09 pm
by sc123
Script URL:
Version of script: 0.94.1
Hosting company:
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution: closed notify
Write your message below:
When a ticket is closed a generic "New reply to your support ticket" is E-Mailed, but this E-Mail doesn't tell the user that the ticket is closed. My customers never look and see that the task is "Resolved" and just continue to post things, usually unrelated. I don't want to prevent the customer from re-opening the task, but I would like to be able to send them a custom E-Mail for tickets that have been closed. Is this possible, and if so, what do I need to do to accomplish it?
Posted: Sat Apr 12, 2008 9:53 am
by Klemen
You can try this (haven't tested it though, make sure you have a backup!):
1. create a new text file inside "emails" folder with the message, for example named "admin_reply_close_ticket.txt"
2. open admin_reply.php in Notepad or Wordpad and change this code
Code: Select all
/* Update the original ticket */
if (!empty($_POST['close']))
{
$sql = "UPDATE `hesk_tickets` SET `status`='3',`lastreplier`='1',`lastchange`=NOW() $priority_sql WHERE `id`=$replyto LIMIT 1";
}
else
{
$sql = "UPDATE `hesk_tickets` SET `status`='2',`lastreplier`='1',`lastchange`=NOW() $priority_sql WHERE `id`=$replyto LIMIT 1";
}
$result = hesk_dbQuery($sql) or hesk_error("$hesklang[cant_sql]: $sql</p><p>$hesklang[mysql_said]:<br>".mysql_error()."</p><p>$hesklang[contact_webmsater] $hesk_settings[webmaster_mail]");
/*** Send "New reply added" e-mail ***/
/* Get e-mail message */
$fp=fopen('emails/new_reply_by_staff.txt','r');
$message=fread($fp,filesize('emails/new_reply_by_staff.txt'));
fclose($fp);
to
Code: Select all
/* Update the original ticket */
if (!empty($_POST['close']))
{
$sql = "UPDATE `hesk_tickets` SET `status`='3',`lastreplier`='1',`lastchange`=NOW() $priority_sql WHERE `id`=$replyto LIMIT 1";
$efile = 'admin_reply_close_ticket.txt';
}
else
{
$sql = "UPDATE `hesk_tickets` SET `status`='2',`lastreplier`='1',`lastchange`=NOW() $priority_sql WHERE `id`=$replyto LIMIT 1";
$efile = 'new_reply_by_staff.txt';
}
$result = hesk_dbQuery($sql) or hesk_error("$hesklang[cant_sql]: $sql</p><p>$hesklang[mysql_said]:<br>".mysql_error()."</p><p>$hesklang[contact_webmsater] $hesk_settings[webmaster_mail]");
/*** Send "New reply added" e-mail ***/
/* Get e-mail message */
$fp=fopen('emails/'.$efile,'r');
$message=fread($fp,filesize('emails/'.$efile));
fclose($fp);
Posted: Sat Apr 12, 2008 10:28 pm
by sc123
Thanks Klemen, that worked! I also noticed when testing that if you close a ticket using the "Close Ticket" link by the Ticket Status, no E-mail is sent to the customer. Is it possible to add another else to the statement to add this functionality?
Posted: Fri May 22, 2009 7:57 pm
by newtech
I am looking at the edited code and I don't see it referencing to the new e-mail:
admin_reply_close_ticket.txt
So, how can it be working?
Am I missing something?
Posted: Sat May 23, 2009 11:01 am
by Klemen
Check 5th line of the code I posted (the second block), you will see the file referenced in the $efile variable.
Posted: Tue Jun 23, 2009 9:27 am
by lupolo
What about the new version?
-->
/* Update the original ticket */
if (!empty($_POST['close']))
{
$sql = "UPDATE `".$hesk_settings['db_pfix']."tickets` SET `status`='3',`lastreplier`='1',`lastchange`=NOW() $priority_sql WHERE `id`=$replyto LIMIT 1";
}
else
{
$sql = "UPDATE `".$hesk_settings['db_pfix']."tickets` SET `status`='2',`lastreplier`='1',`lastchange`=NOW() $priority_sql WHERE `id`=$replyto LIMIT 1";
}
hesk_dbQuery($sql);
/* Update number of replies in the users table */
$sql = "UPDATE `".$hesk_settings['db_pfix']."users` SET `replies`=`replies`+1 WHERE `id`=$_SESSION[id] LIMIT 1";
hesk_dbQuery($sql);
/*** Send "New reply added" e-mail ***/
/* Get e-mail message */
$message=file_get_contents(HESK_PATH.'emails/new_reply_by_staff.txt');
$message=str_replace('%%NAME%%',$orig_name,$message);
$message=str_replace('%%SUBJECT%%',$orig_subject,$message);
$message=str_replace('%%TRACK_ID%%',$trackingID,$message);
$message=str_replace('%%TRACK_URL%%',$trackingURL,$message);
$message=str_replace('%%SITE_TITLE%%',$hesk_settings['site_title'] ,$message);
$message=str_replace('%%SITE_URL%%',$hesk_settings['site_url'] ,$message);
<--
Can not get it to work, and does it reply by both close buttons?
Posted: Mon Jun 29, 2009 10:13 am
by phpsierra
I got this working in the brilliant version 2 of Hesk.
Obviously I'm not the author and I can't promise this will work for you - make sure you have a backup!
I also made an adjustment so the e-mail subject is different when a ticket is closed.
1) Edit the language file to add the new subject - the section below shows the middle item which is new - the top and bottom one already exist.
$hesklang['new_reply_staff']='New reply to your support ticket';
$hesklang['ticket_closed_staff']='Your support ticket has been closed';
$hesklang['reply_added']='Reply added';
2) Here's the relevent new code in admin_reply_ticket.php
The changes are:
- the addition of the two new variables, $efile and $esubject
- the adjustment of
$message=file_get_contents - so it reads $efile
- the alteration of the @mail command to use $esubject rather than a direct call to the language file.
/* Update the original ticket */
if (!empty($_POST['close']))
{
$sql = "UPDATE `".$hesk_settings['db_pfix']."tickets` SET `status`='3',`lastreplier`='1',`lastchange`=NOW() $priority_sql WHERE `id`=$replyto LIMIT 1";
$efile = 'admin_reply_close_ticket.txt';
$esubject = $hesklang['ticket_closed_staff'];
}
else
{
$sql = "UPDATE `".$hesk_settings['db_pfix']."tickets` SET `status`='2',`lastreplier`='1',`lastchange`=NOW() $priority_sql WHERE `id`=$replyto LIMIT 1";
$efile = 'new_reply_by_staff.txt';
$esubject = $hesklang['new_reply_staff'];
}
hesk_dbQuery($sql);
/* Update number of replies in the users table */
$sql = "UPDATE `".$hesk_settings['db_pfix']."users` SET `replies`=`replies`+1 WHERE `id`=$_SESSION[id] LIMIT 1";
hesk_dbQuery($sql);
/*** Send "New reply added" e-mail ***/
/* Get e-mail message */
$message=file_get_contents(HESK_PATH.('emails/'.$efile)) ;
$message=str_replace('%%NAME%%',$orig_name,$message);
$message=str_replace('%%SUBJECT%%',$orig_subject,$message);
$message=str_replace('%%TRACK_ID%%',$trackingID,$message);
$message=str_replace('%%TRACK_URL%%',$trackingURL,$message);
$message=str_replace('%%SITE_TITLE%%',$hesk_settings['site_title'] ,$message);
$message=str_replace('%%SITE_URL%%',$hesk_settings['site_url'] ,$message);
$message=str_replace('%%MESSAGE%%',$messagetomail,$message);
/* Send the e-mail */
$headers="From: $hesk_settings[noreply_mail]\n";
$headers.="Reply-to: $hesk_settings[noreply_mail]\n";
$headers.="Return-Path: $hesk_settings[webmaster_mail]\n";
@mail($orig_email,$esubject,$message,$headers);
Posted: Tue Jun 30, 2009 7:24 am
by lupolo
Hi,
I have copy paste the code into mine, but still no closed reply email, al the others works oke!
Posted: Tue Jun 30, 2009 7:44 am
by phpsierra
If the others work OK - did you remember the extra part of the language file?
$hesklang['ticket_closed_staff']='Your support ticket has been closed';
Posted: Tue Jun 30, 2009 7:51 am
by lupolo
That's a fast reply
The language was indeed the problem, had changed it, but forgot to place it back

haha terrible mistake !
Works great now
Guy
Posted: Wed Jul 01, 2009 9:30 am
by phpsierra
Great, glad it worked for you.
Posted: Thu May 27, 2010 7:01 am
by lupolo
FIX For 2.2Beta:
MODIFY common.inc.php
Code: Select all
$valid_emails = array('category_moved','forgot_ticket_id','new_reply_by_customer','new_reply_by_staff','new_ticket','new_ticket_staff','ticket_assigned_to_you','new_pm');
TO
Code: Select all
$valid_emails = array('category_moved','forgot_ticket_id','new_reply_by_customer','new_reply_by_staff','new_ticket','new_ticket_staff','ticket_assigned_to_you','new_pm','admin_reply_close_ticket','admin_reply_lock_ticket')
MODIFY admin_reply_ticket.php
TO
Code: Select all
/* Format e-mail message */
if ($new_status == 1)
{
$msg = hesk_getEmailMessage('admin_reply_lock_ticket',$ticket);
$esubject = $hesklang['ticket_lock_staff'];
}
if ($new_status == 3)
{
$msg = hesk_getEmailMessage('admin_reply_close_ticket',$ticket);
$esubject = $hesklang['ticket_closed_staff'];
}
else
{
$msg = hesk_getEmailMessage('new_reply_by_staff',$ticket);
$esubject = $hesklang['new_reply_staff'];
}
AND
Code: Select all
@mail($ticket['email'],$hesklang['new_reply_staff'],$msg,$headers);
TO
Code: Select all
@mail($ticket['email'],$esubject,$msg,$headers);
And offcource update your language file
Code: Select all
$hesklang['ticket_closed_staff']='Your support ticket has been closed';
$hesklang['ticket_lock_staff']='Uw support ticket is gelocked!';
And Email template (admin_reply_close_ticket.txt)
Code: Select all
Dear %%NAME%%,
Here we inform you that your support ticket is closed.
To view the history of your ticket click on the link:
%%TRACK_URL%%
Yours sincerely,
Software Support Team
---
This is an automated e-mail message sent from our support system. Do not reply to this e-mail!
AND
And Email template (admin_reply_lock_ticket.txt)
Code: Select all
Dear %%NAME%%,
Here we inform you that your support ticket is locked.
To view the history of your ticket click on the link:
%%TRACK_URL%%
Yours sincerely,
Software Support Team
---
This is an automated e-mail message sent from our support system. Do not reply to this e-mail!
The lock reply won't work
But the closed email is working!