Can we assign ticket to whoever created it from admin panel?

Everything related to Hesk - helpdesk software

Moderator: mkoch227

SS113
Posts: 27
Joined: Mon Aug 15, 2011 1:27 pm

Can we assign ticket to whoever created it from admin panel?

Post by SS113 »

As the subject reads, I am trying to find a way to automatically assign a ticket to whoever (admin/staff) creates it. The auto-assign feature doesn't really help me since I do not want one staff member to create it and get it assigned to another one.

Any thoughts?

Thank you!
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Re: Can we assign ticket to whoever created it from admin pa

Post by Klemen »

Simply select your name from the "Assign ticket to" list.

Or leave "Unassigned" and click the "Assign to me" link when the ticket is created.
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
SS113
Posts: 27
Joined: Mon Aug 15, 2011 1:27 pm

Re: Can we assign ticket to whoever created it from admin pa

Post by SS113 »

Thank you but that only works if you are an admin. If it's staff they don't have that option when creating the ticket. I'm looking for a way to automatically do this when the user submits the form without asking them

Thank you
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Re: Can we assign ticket to whoever created it from admin pa

Post by Klemen »

It does work for non-admins too, just make sure they have "Can assign tickets to self" feature selected.
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
SS113
Posts: 27
Joined: Mon Aug 15, 2011 1:27 pm

Re: Can we assign ticket to whoever created it from admin pa

Post by SS113 »

Got you, thank you!
dr_patso
Posts: 192
Joined: Tue May 15, 2012 3:23 am

Re: Can we assign ticket to whoever created it from admin pa

Post by dr_patso »

hey, here's a way to make it so you never have an unassigned ticket or assigned to the wrong user...

to your /admin/new_ticket.php add

Code: Select all

<option value="">-- Please select --</option>
right below

Code: Select all

<?php echo $hesklang['asst2']; ?> <select name="owner" <?php if (in_array('owner',$_SESSION['iserror'])) {echo ' class="isError" ';} ?>>
to /language/en/text.php add

Code: Select all

$hesklang['selectowner']='Please select owner of the ticket';
around line 50-60 under /* ERROR MESSAGES */

to /admin/admin_submit_ticket.php add

Code: Select all

$tmpvar['owner'] = hesk_input($_POST['owner']) or $hesk_error_buffer['owner']=$hesklang['selectowner'];
around like 50-56
dr_patso
Posts: 192
Joined: Tue May 15, 2012 3:23 am

Re: Can we assign ticket to whoever created it from admin pa

Post by dr_patso »

would be nice to get some help, but i'm going to start researching a way to atleast have the box already selecting the logged in user i'm sure this can be done with php

if user id ="" or username select option for their username in the owner drop down .. maybe i'd have to do this for every user id or something.... but i wouldn't care...
steve
Posts: 147
Joined: Tue Mar 27, 2012 9:32 pm

Re: Can we assign ticket to whoever created it from admin pa

Post by steve »

I don't use ticket assignment at all. So I just set EVERY ticket to Ower = 1, here is how I did it.

open /inc/admin_submit_ticket.php

find

Code: Select all

/* Owner */
$owner = 0;
if (hesk_checkPermission('can_assign_others',0))
{
	$owner = intval($_REQUEST['owner']);

	/* If ID is -1 the ticket will be unassigned */
	if ($owner == -1)
	{
		$owner = 0;
	}
    /* Automatically assign owner? */
    elseif ($owner == -2 && $hesk_settings['autoassign'] == 1)
    {
		$autoassign_owner = hesk_autoAssignTicket($tmpvar['category']);
		if ($autoassign_owner)
		{
			$owner = $autoassign_owner['id'];
			$history .= sprintf($hesklang['thist10'],hesk_date(),$autoassign_owner['name'].' ('.$autoassign_owner['user'].')');
		}
        else
        {
        	$owner = 0;
        }
    }
    /* Check for invalid owner values */
	elseif ($owner < 1)
	{
	    $owner = 0;
	}
    else
    {
	    /* Has the new owner access to the selected category? */
		$sql = "SELECT `name`,`isadmin`,`categories` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE `id`=".hesk_dbEscape($owner)." LIMIT 1";
		$res = hesk_dbQuery($sql);
	    if (hesk_dbNumRows($res) == 1)
	    {
	    	$row = hesk_dbFetchAssoc($res);
	        if (!$row['isadmin'])
	        {
				$row['categories']=explode(',',$row['categories']);
				if (!in_array($tmpvar['category'],$row['categories']))
				{
                	$_SESSION['isnotice'][] = 'category';
					$hesk_error_buffer['owner']=$hesklang['onasc'];
				}
	        }
	    }
	    else
	    {
        	$_SESSION['isnotice'][] = 'category';
	    	$hesk_error_buffer['owner']=$hesklang['onasc'];
	    }
    }
}
elseif (hesk_checkPermission('can_assign_self',0) && hesk_okCategory($tmpvar['category'],0) && !empty($_POST['assing_to_self']))
{
	$owner = intval($_SESSION['id']);
}
Replace with

Code: Select all

/* Owner */
$owner = 1;
You would have to do something similar for submit_ticket.php also.
-Steve
steve
Posts: 147
Joined: Tue Mar 27, 2012 9:32 pm

Re: Can we assign ticket to whoever created it from admin pa

Post by steve »

dr_patso wrote:would be nice to get some help, but i'm going to start researching a way to atleast have the box already selecting the logged in user i'm sure this can be done with php

if user id ="" or username select option for their username in the owner drop down .. maybe i'd have to do this for every user id or something.... but i wouldn't care...
You want the owner drop down box in admin/new_ticket.php to show the name of the currently logged in user?
-Steve
dr_patso
Posts: 192
Joined: Tue May 15, 2012 3:23 am

Re: Can we assign ticket to whoever created it from admin pa

Post by dr_patso »

it's not a huge deal really.

But i'd like to modify it so it automatically selects the logged in user in the drop down, that way the user doesn't have to mess with it unless they want to assign it to somebody else.
dr_patso
Posts: 192
Joined: Tue May 15, 2012 3:23 am

Re: Can we assign ticket to whoever created it from admin pa

Post by dr_patso »

i turned auto assign.. it can't be hard to change the logic in the auto assign function in admin_submit_ticket to just choose to sessions user ID as the value if auto assigned is selected
dr_patso
Posts: 192
Joined: Tue May 15, 2012 3:23 am

Re: Can we assign ticket to whoever created it from admin pa

Post by dr_patso »

ah here we go.. I think I nailed it, can someone confirm? enable auto assign tickets then

in admin_submit_ticket.php I changed...

Code: Select all


/* Automatically assign owner? */
    elseif ($owner == -2 && $hesk_settings['autoassign'] == 1)
    {
		$autoassign_owner = hesk_autoAssignTicket($tmpvar['category']);
		if ($autoassign_owner)
		{
			$owner = $autoassign_owner['id'];
to

Code: Select all

    /* Automatically assign owner? */
    elseif ($owner == -2 && $hesk_settings['autoassign'] == 1)
    {
		$autoassign_owner = hesk_autoAssignTicket($tmpvar['category']);
		if ($autoassign_owner)
		{
			$owner = $_SESSION['id'];
change the line 115 for me

Code: Select all

$owner = $autoassign_owner['id'];
to

Code: Select all

$owner = $autoassign_owner['id'];
dr_patso
Posts: 192
Joined: Tue May 15, 2012 3:23 am

Re: Can we assign ticket to whoever created it from admin pa

Post by dr_patso »

this has been working for me for about 10 tickets on 3 different users.... I'm scared some other conditional logic will cause it not to work in the future... Klemen if you have time could you approve this as a way for auto assign to always assign to the logged in user??

i don't use the customer interface, if i did i would modify it to not use the auto assign function.
steve
Posts: 147
Joined: Tue Mar 27, 2012 9:32 pm

Re: Can we assign ticket to whoever created it from admin pa

Post by steve »

Here is how I would do it.

Change

Code: Select all

/* Owner */
$owner = 0;
if (hesk_checkPermission('can_assign_others',0))
{
	$owner = intval($_REQUEST['owner']);

	/* If ID is -1 the ticket will be unassigned */
	if ($owner == -1)
	{
		$owner = 0;
	}
    /* Automatically assign owner? */
    elseif ($owner == -2 && $hesk_settings['autoassign'] == 1)
    {
		$autoassign_owner = hesk_autoAssignTicket($tmpvar['category']);
		if ($autoassign_owner)
		{
			$owner = $autoassign_owner['id'];
			$history .= sprintf($hesklang['thist10'],hesk_date(),$autoassign_owner['name'].' ('.$autoassign_owner['user'].')');
		}
        else
        {
        	$owner = 0;
        }
    }
    /* Check for invalid owner values */
	elseif ($owner < 1)
	{
	    $owner = 0;
	}
    else
    {
	    /* Has the new owner access to the selected category? */
		$sql = "SELECT `name`,`isadmin`,`categories` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE `id`=".hesk_dbEscape($owner)." LIMIT 1";
		$res = hesk_dbQuery($sql);
	    if (hesk_dbNumRows($res) == 1)
	    {
	    	$row = hesk_dbFetchAssoc($res);
	        if (!$row['isadmin'])
	        {
				$row['categories']=explode(',',$row['categories']);
				if (!in_array($tmpvar['category'],$row['categories']))
				{
                	$_SESSION['isnotice'][] = 'category';
					$hesk_error_buffer['owner']=$hesklang['onasc'];
				}
	        }
	    }
	    else
	    {
        	$_SESSION['isnotice'][] = 'category';
	    	$hesk_error_buffer['owner']=$hesklang['onasc'];
	    }
    }
}
elseif (hesk_checkPermission('can_assign_self',0) && hesk_okCategory($tmpvar['category'],0) && !empty($_POST['assing_to_self']))
{
	$owner = intval($_SESSION['id']);
}
To

Code: Select all

$owner = $_SESSION['id'];
That way I don't have to worry about any other variables.
-Steve
dr_patso
Posts: 192
Joined: Tue May 15, 2012 3:23 am

Re: Can we assign ticket to whoever created it from admin pa

Post by dr_patso »

hm that breaks the ability to assign to others if needed...

what about this ? The /* Automatically assign owner? */ is the only section that addresses the -2 (auto assign) value... so it should be okay no??

Code: Select all

/* Owner */
$owner = 0;
if (hesk_checkPermission('can_assign_others',0))
{
	$owner = intval($_REQUEST['owner']);

	/* If ID is -1 the ticket will be unassigned */
	if ($owner == -1)
	{
		$owner = 0;
	}
    /* Automatically assign owner? */
    elseif ($owner == -2 && $hesk_settings['autoassign'] == 1)
    {
		$autoassign_owner = hesk_autoAssignTicket($tmpvar['category']);
		if ($autoassign_owner)
		{
			$owner = $_SESSION['id'];
		}
        else
        {
        	$owner = 0;
        }
    }
    /* Check for invalid owner values */
	elseif ($owner < 1)
	{
	    $owner = 0;
	}
    else
    {
	    /* Has the new owner access to the selected category? */
		$sql = "SELECT `name`,`isadmin`,`categories` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE `id`=".hesk_dbEscape($owner)." LIMIT 1";
		$res = hesk_dbQuery($sql);
	    if (hesk_dbNumRows($res) == 1)
	    {
	    	$row = hesk_dbFetchAssoc($res);
	        if (!$row['isadmin'])
	        {
				$row['categories']=explode(',',$row['categories']);
				if (!in_array($tmpvar['category'],$row['categories']))
				{
                	$_SESSION['isnotice'][] = 'category';
					$hesk_error_buffer['owner']=$hesklang['onasc'];
				}
	        }
	    }
	    else
	    {
        	$_SESSION['isnotice'][] = 'category';
	    	$hesk_error_buffer['owner']=$hesklang['onasc'];
	    }
    }
}
elseif (hesk_checkPermission('can_assign_self',0) && hesk_okCategory($tmpvar['category'],0) && !empty($_POST['assing_to_self']))
{
	$owner = intval($_SESSION['id']);
}
Post Reply