How can I notify a user that a ticket has been closed
Moderator: mkoch227
How can I notify a user that a ticket has been closed
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?
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?
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 to
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);
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);
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
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


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
Check 5th line of the code I posted (the second block), you will see the file referenced in the $efile variable.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
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


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
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?
-->
/* 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?
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);
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);
FIX For 2.2Beta:
MODIFY common.inc.php
TO
MODIFY admin_reply_ticket.php
TO
AND
TO
And offcource update your language file
And Email template (admin_reply_close_ticket.txt)
AND
And Email template (admin_reply_lock_ticket.txt)
The lock reply won't work
But the closed email is working!
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');
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
Code: Select all
/* Format e-mail message */
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'];
}
Code: Select all
@mail($ticket['email'],$hesklang['new_reply_staff'],$msg,$headers);
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!';
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 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!
