This mod adds a box to the close ticket form to allow a user to enter the decimal time spent completing the ticket.
I looked at the Staff Time Sheet / Tracking mod by drunkenski, but found that as we may have upto 6 people working on a ticket over a period of several months the time sheet would end up being huge and waits a lot of time and paper if we ever had to print off the ticket. My method offers only the total time spent on the ticket. Future additions to this mod will allow each post to add time to the total and those totals to be graphed out in the admin panel
This is part of a growing audit system we are being 'asked' to put in place. I will be adding admin functions to display the times on a per department and per user basis in the next few days along with functions to add time to a ticket even when not closed.. enjoy
NOTE: THIS MOD HAS BEEN WRITTEN FOR OST 1.6 RC5 ONCE I UPGRADE I WILL NOTE ANY CHANGES HERE
Remember to back up you code and database before adding this mod!
NOTE: this mod involves adding a new column to the tickets table. before you begin add a column called time_spent of data type FLOAT(4,2) with a default value of 0.00 to your ost_tickets table. Below is the sql statement I used to do this. Yours may vary.
ALTER TABLE `ost_ticket` ADD COLUMN `time_spent` FLOAT(4,2) NOT NULL DEFAULT '0.00' AFTER `time_spent`;
ok lets begin
1) in include\staff\viewticket.inc.php, below
<?if($appendDeptSig) {?>
<input type="radio" name="signature" value="dept" <?=$info=='dept'?'checked':''?> > Dept Signature
<?}?>
</div>
<?}?>
<div style="margin-top: 3px;">
insert
<?php
if($ticket->isOpen())
{
?>
<br />
<label for="time_spent"><b>Time Spent:</b></label>
<input type="text" name="time_spent" size="5"
value="<?php if(isset($_POST)) echo $_POST;?>" />
(0.75 = 45 minutes)
<br />
<?php
}
?>
2) in includes\class.ticket.php below
var $ticket_notes;
var $ticketResponses;
insert
var $timeSpent;
3) below
$this->closed = $row ;
insert
$this->timeSpent = $row;
4) below
function getStatus() {
return $this->status;
}
insert
function getTimeSpent()
{
return $this->formatTime($this->timeSpent);
}
5) below
function getLock() {
if (! $this->tlock && $this->lock_id)
$this->tlock = new TicketLock ( $this->lock_id );
return $this->tlock;
}
insert
function formatTime($time){
if($time < 1){
$formatted = $time*60;
$formatted .= ' Minutes';
}else if ($time == 1){
$formatted = $time.' Hour';
}else{
$formatted = $time.' Hours';
}
return $formatted;
}
function timeSpent($time){
if(empty($time)){
$time = 0.00;
}else{
if(!is_numeric($time)){
$time = 0.25;
}else{
$time = round($time,2);
}
}
$sql = 'UPDATE ' . TICKET_TABLE . ' SET time_spent=' . db_input ( $time ) . ' WHERE ticket_id=' . db_input ( $this->getId () );
return (db_query($sql) && db_affected_rows())?true;
}}
6) in include\scp\tickets.php replace
if(isset($_POST) && $_POST)
$ticket->setStatus($_POST);
with
if(isset($_POST) && $_POST)
{
$ticket->timeSpent($_POST);
$ticket->setStatus($_POST);
}