Page 1 of 3

Time spent on a ticket

Posted: Thu Jan 07, 2010 1:28 pm
by Brice
Hello,

I am looking for an add-on for the staff that indicates time spent on a ticket. Then we could add up all the time spent on the tickets of a person.

Thanks !

Posted: Fri Jan 08, 2010 4:04 pm
by Klemen
I'm not aware of any such mods at the moment, but this should be added in the future.

Posted: Sun Jan 10, 2010 3:03 am
by conepr09
I'm working on a mod to the admin_ticket.php page to add a field (Total Hours) so the technician can input the time spent on the ticket. Once I get this working and if you are interested I will post the code here.

Posted: Wed Jan 13, 2010 2:03 am
by Raven
Cool, yes please :)

Posted: Wed Apr 28, 2010 3:55 pm
by masterzonk
Anything?

Posted: Fri Jun 11, 2010 4:12 pm
by morsedesign
Has anyone gotten far enough to post something? I am looking to do a mod like this soon!

Posted: Thu Jun 17, 2010 9:38 am
by dr.sah
any news about this? It would be great to see time spend.

Posted: Sun Jun 20, 2010 5:43 pm
by Klemen
Not yet, maybe in 2.3...

I need one too

Posted: Thu Jul 15, 2010 4:46 pm
by cebicit
Has anyone here perhaps made their own mod that doesn't come native w/ hesk. Or, maybe someone can help me w/ mine. I am to the point now where I have a field in the response section for minutes spent. It is saved into the MySQL database. Now all I need is some code to retrieve those entries from the database, add them up, and display them. Your help would be greatly appreciated!

All I did to add the time field to the database and modded the submission form and the processor page to add it upon submission.

Re: Time spent on a ticket

Posted: Thu Mar 03, 2011 1:35 pm
by rmiddleton
As a work around, until someone writes this, I just setup a Checkbox field with these parameters.
Less than 15 minutes
15 minutes
30 minutes
45 minutes
1 hour
1.5 hours
2 hours
2.5 hours
3 hours
over 3 hours

Re: Time spent on a ticket

Posted: Fri Jul 22, 2011 9:13 pm
by seanieboy02
I've done a little mod that should give you time spent on each ticket, also allowing for the creation of custom reports on time per category, customer, member of staff, company etc.

Depending on your setup the code position might need to be altered but I've put in the line numbers from a blank hesk.

Add a new field into the DB, notes table called 'timeSpent'. int(3) default value of 0.
Add another field into the tickets table called 'totalTimeSpent'. int(3) default value of 0.

Add the following into admin_ticket.php

Inside the add notes block for the following 2 code blocks.
Line 188

Code: Select all

$msgTS = hesk_input($_POST['timeSpent']);
Replace 196 with the following

Code: Select all

'".hesk_dbEscape($msg)."',
'".hesk_dbEscape($msgTS)."')";
Add the following to just after the 'Add Note Action' (around line 204).

Code: Select all

//Time Spent Calculation and Diplay 
	$sqltime = 'SELECT sum(timeSpent) FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'notes` AS t1 WHERE `ticket`='.hesk_dbEscape($ticket['id']).' ORDER BY t1.`id` ASC';
	$restime = hesk_dbQuery($sqltime);
	$note = hesk_dbFetchAssoc($restime);
	$timeTotal = $note['sum(timeSpent)'];	
	?>
    <tr>
    	<td>Total time spent on ticket: </td>
        <td><?php echo $timeTotal;?> minutes</td>
     </tr>
Add the following to the three statuses in the case blocks around line 301. Just after the s=3 $GET variables

Code: Select all

tS='.$timeTotal.'
Replace the DIV block for the notesform around line 465 with

Code: Select all

<div id="notesform" style="display:none">
	    <form method="post" action="admin_ticket.php" style="margin:0px; padding:0px;">
        <p>
            <span>Action / Detail</span><br />
            <textarea name="notemsg" rows="6" cols="60"></textarea>
        </p>
        <p>
            <span>Time Spent (in minutes)</span><br />
            <input type="text" name="timeSpent" size="5" maxlength="3" value="0" />
        </p>
	    <input type="submit" value="<?php echo $hesklang['s']; ?>" class="orangebutton" onmouseover="hesk_btn(this,'orangebuttonover');" onmouseout="hesk_btn(this,'orangebutton');" /><input type="hidden" name="track" value="<?php echo $trackingID; ?>" />
        <i><?php echo $hesklang['nhid']; ?></i>
        <input type="hidden" name="token" value="<?php hesk_token_echo(); ?>" />
        </form>
	    </div>
Replace the Table Row which displays the notes (in the while loop) 493

Code: Select all

<tr>
	    <td class="notes"><i><?php echo $hesklang['noteby']; ?> <b><?php echo ($note['name'] ? $note['name'] : $hesklang['e_udel']); ?></b></i> - <?php echo hesk_date($note['dt']); ?> - <b>Time Spent: </b><?php echo $note['timeSpent']; ?> minutes<br /><img src="../img/blank.gif" border="0" width="5" height="5" alt="" /><br />
	    <?php echo $note['message']; ?></td>
</tr>
Finally, in the change_status.php file:

Add the following to around line 56 (with the rest of the $GET variables)

Code: Select all

$totalTime = hesk_isNumber($_GET['tS'],"$hesklang[int_error]: $hesklang[status_not_valid].");
Add this to the SQL block around line 79

Code: Select all

`totalTimeSpent`='".hesk_dbEscape($totalTime)."',

Re: Time spent on a ticket

Posted: Tue Aug 30, 2011 5:59 pm
by scheckc
Now I wish I hadn't upgraded to beta.. :(

Seems that the strucuture of the php files has changed too drastically, I can't follow your directions because the lines are not accurate at all.

really sucks too cuz this was a feature that I was waiting on. :(

Do you have a version of the instructions that are 2.3 compatible yet? Or possibly link the two modified files for download? Just a thought. Aside from time tracking HESK IS IT!!!

Thanks for the support all.

Re: Time spent on a ticket

Posted: Mon Nov 28, 2011 11:59 pm
by seanieboy02
I've just upgraded to 2.3 - about to re-create the add-on again.
If anyone has any advice on how to package it properly I'm open to suggestions!

:D

Re: Time spent on a ticket

Posted: Tue Jan 03, 2012 9:55 pm
by scheckc
Anyword on the 2.3 repack of this feature? I would really like to utilize it.

Thanks so much for any update, in advance.

Re: Time spent on a ticket

Posted: Fri Jan 06, 2012 4:25 pm
by bert blaas
Today I combined the code made by seanieboy02 ยป Fri Jul 22, 2011 10:13 pm into the 2.3 version and have it working as wanted.

Please advice me how to share this code now here, as I cannot seem to be able to upload files.
Do I need to copy & paste code like seanieboy02 did?