Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

My Assigned Tickets counter

Hi all,

I modified the code to keep assigned to staff the closed tickets in order to avoid unassignment when closing the ticket.


//Close the ticket
function close(){

$sql= 'UPDATE '.TICKET_TABLE.' SET status='.db_input('closed').',staff_id=0,isoverdue =0,updated=NOW(),closed=NOW() '.
' WHERE ticket_id='.db_input($this->getId());
return (db_query($sql) && db_affected_rows())?true:false;

//Close the ticket
function close(){
global $thisuser;
$sql= 'UPDATE '.TICKET_TABLE.' SET status='.db_input('closed').',staff_id='.db_input( $thisuser->getId()).
',isoverdue=0,updated=NOW(),closed=NOW() '.
' WHERE ticket_id='.db_input($this->getId());
return (db_query($sql) && db_affected_rows())?true:false;

It works like a charm but my problem is that closed and assigned ticket still appearing in My Assigned Tickets counter and i´m going crazy trying to find the f***ing query that counts these tickets.

I just want to add a single "...WHERE status="open" " :(


  • File: /scp/tickets.php

    Find "/*quick stats...*/".

    Change the last line to:
    'LEFT JOIN '.TICKET_TABLE.' assigned ON assigned.ticket_id=ticket.ticket_id AND open.status=\'Open\' AND assigned.staff_id='.db_input($thisuser->getId());
  • Thanks a lot Corey! it works perfectly!

    I´m going to comment the SQL with a more specific label than "/*quick stats...*/" :D
  • @equisde  & @Corey : I also want the same function. But the code equisde mentioned is not present in class.ticket file. (function close () is not available). My ticket version is 1.9.2 Could you pls help
  • In 1.9.12 its located at line 825

        function setStatus($status, $comments='', $set_closing_agent=true) {
            global $thisstaff;

            if ($status && is_numeric($status))
                $status = TicketStatus::lookup($status);

            if (!$status || !$status instanceof TicketStatus)
                return false;

            // XXX: intercept deleted status and do hard delete
            if (!strcasecmp($status->getState(), 'deleted'))
                return $this->delete($comments);

            if ($this->getStatusId() == $status->getId())
                return true;

            $sql = 'UPDATE '.TICKET_TABLE.' SET updated=NOW() '.
                   ' ,status_id='.db_input($status->getId());

            $ecb = null;
            switch($status->getState()) {
                case 'closed':
                    $sql.=', closed=NOW(), duedate=NULL ';
                    if ($thisstaff && $set_closing_agent)
                        $sql.=', staff_id='.db_input($thisstaff->getId());

                    $ecb = function($t) {
Sign In or Register to comment.