Page 1 of 1
Customized Tag
Posted: Sun Feb 01, 2009 1:57 am
by Arno
Hello,
I know it's possible to have additional tags for emails, I already try and it worked well.
But I would like to put a tag for the name of a staff member in top of an email. I know that $myuser[name] is a tag (in manage_users.php) for it but it wont work in the email.
How can I get this to work?
Posted: Wed Feb 04, 2009 7:57 pm
by Klemen
Try using $_SESSION['name']
Posted: Fri Feb 06, 2009 6:07 pm
by Arno
Thanks for your respons.
$_SESSION['name'] does not work. This will give the name back of the staff member that's logged in.
So if i'm logged in and someone submits a ticket, the entire staff gets my name in top of the e-mail. If no one is logged is then there will be no name in top of the e-mail.
I hope you can find the right code.
Posted: Sat Feb 07, 2009 10:55 am
by Klemen
Well then you better give an actual example of what you want because I am not sure I understand what you're after here...
Posted: Sat Feb 07, 2009 12:16 pm
by Arno
Well this is what I want:
If an customer submits a ticket, all staff members (employee) in that category gets a notification email.
De first 3 lines in the email are:
Code: Select all
Hello,
A new support ticket has been submitted. Ticket details:
Ticket subject: %%SUBJECT%%
Now I want a tag after the word Hello
Like: Hello George,
George is as example one of the staff members.
Because there is more than 1 staff member, every staff member must see there own name after the word Hello.
I hope you understand
Posted: Sun Feb 08, 2009 1:35 pm
by Klemen
Didn't tet anything, but you can try changing this in submit_ticket.php
Code: Select all
/* Need to notify any admins? */
$admins=array();
$sql = "SELECT `email`,`isadmin`,`categories` FROM `".$hesk_settings['db_pfix']."users` WHERE `notify`='1'";
$result = hesk_dbQuery($sql);
while ($myuser=hesk_dbFetchAssoc($result))
{
/* Is this an administrator? */
if ($myuser['isadmin']) {$admins[]=$myuser['email']; continue;}
/* Not admin, is he allowed this category? */
$cat=substr($myuser['categories'], 0, -1);
$myuser['categories']=explode(',',$cat);
if (in_array($category,$myuser['categories']))
{
$admins[]=$myuser['email']; continue;
}
}
if (count($admins)>0)
{
$trackingURL_admin=$hesk_settings['hesk_url'].'/admin/admin_ticket.php?track='.$trackingID;
$message=file_get_contents(HESK_PATH.'emails/new_ticket_staff.txt');
$message=str_replace('%%NAME%%',$name,$message);
$message=str_replace('%%SUBJECT%%',$subject,$message);
$message=str_replace('%%TRACK_ID%%',$trackingID,$message);
$message=str_replace('%%TRACK_URL%%',$trackingURL_admin,$message);
$message=str_replace('%%SITE_TITLE%%',$hesk_settings['site_title'] ,$message);
$message=str_replace('%%SITE_URL%%',$hesk_settings['site_url'] ,$message);
/* Send e-mail to staff */
$email=implode(',',$admins);
$headers="From: $hesk_settings[noreply_mail]\n";
$headers.="Reply-to: $hesk_settings[noreply_mail]\n";
$headers.="Return-Path: $hesk_settings[webmaster_mail]\n";
@mail($email,$hesklang['new_ticket_submitted'],$message,$headers);
} // End if
to something like
Code: Select all
/* Need to notify any admins? */
$admins=array();
$sql = "SELECT `name`,`email`,`isadmin`,`categories` FROM `".$hesk_settings['db_pfix']."users` WHERE `notify`='1'";
$result = hesk_dbQuery($sql);
while ($myuser=hesk_dbFetchAssoc($result))
{
/* Is this an administrator? */
if ($myuser['isadmin']) {$admins[]=array($myuser['email'],$myuser['name']); continue;}
/* Not admin, is he allowed this category? */
$cat=substr($myuser['categories'], 0, -1);
$myuser['categories']=explode(',',$cat);
if (in_array($category,$myuser['categories']))
{
$admins[]=array($myuser['email'],$myuser['name']); continue;
}
}
if (count($admins)>0)
{
$trackingURL_admin=$hesk_settings['hesk_url'].'/admin/admin_ticket.php?track='.$trackingID;
$message=file_get_contents(HESK_PATH.'emails/new_ticket_staff.txt');
$message=str_replace('%%NAME%%',$name,$message);
$message=str_replace('%%SUBJECT%%',$subject,$message);
$message=str_replace('%%TRACK_ID%%',$trackingID,$message);
$message=str_replace('%%TRACK_URL%%',$trackingURL_admin,$message);
$message=str_replace('%%SITE_TITLE%%',$hesk_settings['site_title'] ,$message);
$message=str_replace('%%SITE_URL%%',$hesk_settings['site_url'] ,$message);
foreach ($admins as $me)
{
$tmp = str_replace('%%STAFF_NAME%%',$me[1] ,$message);
$email=implode(',',$admins);
$headers="From: $hesk_settings[noreply_mail]\n";
$headers.="Reply-to: $hesk_settings[noreply_mail]\n";
$headers.="Return-Path: $hesk_settings[webmaster_mail]\n";
@mail($me[0],$hesklang['new_ticket_submitted'],$tmp,$headers);
}
} // End if
And then you would use %%STAFF_NAME%% in the email template. Haven't tested anything though... Also something similar should be done in the reply_ticket.php file
Posted: Sun Feb 08, 2009 5:35 pm
by Arno
Klemen,
Thanks for your quick respons.
I try'ed the code you gived, the customer gets the normal email but there will be no emails send to the admins.
Somehow the code is not right.
Posted: Sun Feb 08, 2009 6:23 pm
by Klemen
Try again with the above code, "foreach ($admin as $me)" should be "foreach ($admins as $me)", I changed it now.
Posted: Sun Feb 08, 2009 10:06 pm
by Arno
Klemen,
Thank you very much, it works fine!
This is exactly what I wanted.