Customized Tag

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
Arno
Posts: 12
Joined: Mon Jan 26, 2009 11:25 pm

Customized Tag

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

Post by Klemen »

Try using $_SESSION['name']
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
Arno
Posts: 12
Joined: Mon Jan 26, 2009 11:25 pm

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

Post 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...
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
Arno
Posts: 12
Joined: Mon Jan 26, 2009 11:25 pm

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

Post 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
Last edited by Klemen on Sun Feb 08, 2009 6:23 pm, edited 1 time in total.
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
Arno
Posts: 12
Joined: Mon Jan 26, 2009 11:25 pm

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

Post by Klemen »

Try again with the above code, "foreach ($admin as $me)" should be "foreach ($admins as $me)", I changed it now.
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
Arno
Posts: 12
Joined: Mon Jan 26, 2009 11:25 pm

Post by Arno »

Klemen,

Thank you very much, it works fine!
This is exactly what I wanted.
Post Reply