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

[Mod Completed] Pending Status & Auto Close

2»

Comments

  • Will this still work with the new version, 1.7?
  • Not currently no.
  • Kindly follow the following steps to get this working in v1.7
    open scp\tickets.php
    search for
    $statusKeys=array('open'=>'Open','Reopen'=>'Open','Close'=>'Closed');

    replace it with
    $statusKeys=array('open'=>'Open','Reopen'=>'Open','Close'=>'Closed','pending'=>'Pending');

    search for
    if($stats['overdue']) {
    $nav->addSubMenu(array('desc'=>'Overdue ('.number_format($stats['overdue']).')',
    'title'=>'Stale Tickets',
    'href'=>'tickets.php?status=overdue',
    'iconclass'=>'overdueTickets'),
    ($_REQUEST['status']=='overdue'));
    if(!$sysnotice && $stats['overdue']>10)
    $sysnotice=$stats['overdue'] .' overdue tickets!';
    }

    below it add
            $nav->addSubMenu(array('desc'=>'Pending Tickets ('.number_format($stats['pending']).')',
    'title'=>'Pending Tickets',
    'href'=>'tickets.php?status=pending',
    'iconclass'=>'closedTickets'),
    (!$_REQUEST['status'] || $_REQUEST['status']=='Pending'));


    open include\class.ticket.php
    search for
        function isReopened() {
    return ($this->getReopenDate());
    }

    below it add
        function isPending(){
    return (strcasecmp($this->getStatus(),'Pending')==0);
    }

    search for
        function setStatus($status) {
    if(strcasecmp($this->getStatus(), $status)==0)
    return true; //No changes needed.
    switch(strtolower($status)) {
    case 'open':
    return $this->reopen();
    break;
    case 'closed':
    return $this->close();
    break;
    }
    return false;
    }

    replace with
        function setStatus($status) {
    if(strcasecmp($this->getStatus(), $status)==0)
    return true; //No changes needed.
    switch(strtolower($status)) {
    case 'open':
    return $this->reopen();
    break;
    case 'pending':
    return $this->pending();
    break;
    case 'closed':
    return $this->close();
    break;
    }
    return false;
    }

    search for
        function setState($state, $alerts=false) {
    switch(strtolower($state)) {
    case 'open':
    return $this->setStatus('open');
    break;
    case 'closed':
    return $this->setStatus('closed');
    break;
    case 'answered':
    return $this->setAnsweredState(1);
    break;
    case 'unanswered':
    return $this->setAnsweredState(0);
    break;
    case 'overdue':
    return $this->markOverdue();
    break;
    case 'notdue':
    return $this->clearOverdue();
    break;
    case 'unassined':
    return $this->unassign();
    }
    return false;
    }

    replace with
        function setState($state, $alerts=false) {
    switch(strtolower($state)) {
    case 'open':
    return $this->setStatus('open');
    break;
    case 'pending':
    return $this->setStatus('pending');
    break;
    case 'closed':
    return $this->setStatus('closed');
    break;
    case 'answered':
    return $this->setAnsweredState(1);
    break;
    case 'unanswered':
    return $this->setAnsweredState(0);
    break;
    case 'overdue':
    return $this->markOverdue();
    break;
    case 'notdue':
    return $this->clearOverdue();
    break;
    case 'unassined':
    return $this->unassign();
    }
    return false;
    }

    search for
        //Close the ticket
    function close() {
    global $thisstaff;
    $sql='UPDATE '.TICKET_TABLE.' SET closed=NOW(),isoverdue=0, duedate=NULL, updated=NOW(), status='.db_input('closed');
    if($thisstaff) //Give the closing staff credit.
    $sql.=', staff_id='.db_input($thisstaff->getId());
    $sql.=' WHERE ticket_id='.db_input($this->getId());
    if(!db_query($sql) || !db_affected_rows())
    return false;
    $this->reload();
    $this->logEvent('closed');
    return true;
    }

    above it add
        //Mark Ticket as Pending
    function pending() {
    global $thisstaff;
    $sql='UPDATE '.TICKET_TABLE.' SET isoverdue=0, duedate=NULL, updated=NOW(), status='.db_input('pending');
    if($thisstaff) //Give the closing staff credit.
    $sql.=', staff_id='.db_input($thisstaff->getId());
    $sql.=' WHERE ticket_id='.db_input($this->getId());
    if(!db_query($sql) || !db_affected_rows())
    return false;
    $this->reload();
    $this->logEvent('pending');
    return true;
    }

    search for
            $sql='SELECT count(open.ticket_id) as open, count(answered.ticket_id) as answered '
    .' ,count(overdue.ticket_id) as overdue, count(assigned.ticket_id) as assigned, count(closed.ticket_id) as closed '
    .' FROM '.TICKET_TABLE.' ticket '
    .' LEFT JOIN '.TICKET_TABLE.' open ON (open.ticket_id=ticket.ticket_id AND open.status=\'open\' AND open.isanswered=0 '.((!($cfg->showAssignedTickets() || $staff->showAssignedTickets()))? ' AND open.staff_id=0 ':'').') '
    .' LEFT JOIN '.TICKET_TABLE.' answered ON (answered.ticket_id=ticket.ticket_id AND answered.status=\'open\' AND answered.isanswered=1) '
    .' LEFT JOIN '.TICKET_TABLE.' overdue ON (overdue.ticket_id=ticket.ticket_id AND overdue.status=\'open\' AND overdue.isoverdue=1) '
    .' LEFT JOIN '.TICKET_TABLE.' assigned ON (assigned.ticket_id=ticket.ticket_id AND assigned.status=\'open\' AND assigned.staff_id='.db_input($staff->getId()).')'
    .' LEFT JOIN '.TICKET_TABLE.' closed ON (closed.ticket_id=ticket.ticket_id AND closed.status=\'closed\' )'
    .' WHERE (ticket.staff_id='.db_input($staff->getId());

    replace with
            $sql='SELECT count(open.ticket_id) as open, count(answered.ticket_id) as answered '
    .' ,count(overdue.ticket_id) as overdue, count(assigned.ticket_id) as assigned, count(pending.ticket_id) as pending, count(closed.ticket_id) as closed '
    .' FROM '.TICKET_TABLE.' ticket '
    .' LEFT JOIN '.TICKET_TABLE.' open ON (open.ticket_id=ticket.ticket_id AND open.status=\'open\' AND open.isanswered=0 '.((!($cfg->showAssignedTickets() || $staff->showAssignedTickets()))? ' AND open.staff_id=0 ':'').') '
    .' LEFT JOIN '.TICKET_TABLE.' answered ON (answered.ticket_id=ticket.ticket_id AND answered.status=\'open\' AND answered.isanswered=1) '
    .' LEFT JOIN '.TICKET_TABLE.' pending ON (pending.ticket_id=ticket.ticket_id AND pending.status=\'pending\' )'
    .' LEFT JOIN '.TICKET_TABLE.' overdue ON (overdue.ticket_id=ticket.ticket_id AND overdue.status=\'open\' AND overdue.isoverdue=1) '
    .' LEFT JOIN '.TICKET_TABLE.' assigned ON (assigned.ticket_id=ticket.ticket_id AND assigned.status=\'open\' AND assigned.staff_id='.db_input($staff->getId()).')'
    .' LEFT JOIN '.TICKET_TABLE.' closed ON (closed.ticket_id=ticket.ticket_id AND closed.status=\'closed\' )'
    .' WHERE (ticket.staff_id='.db_input($staff->getId());

    search for
            $sql='SELECT count(open.ticket_id) as open, count(closed.ticket_id) as closed '
    .' FROM '.TICKET_TABLE.' ticket '
    .' LEFT JOIN '.TICKET_TABLE.' open
    ON (open.ticket_id=ticket.ticket_id AND open.status=\'open\') '
    .' LEFT JOIN '.TICKET_TABLE.' closed
    ON (closed.ticket_id=ticket.ticket_id AND closed.status=\'closed\')'
    .' WHERE ticket.email='.db_input($email);

    replace with
            $sql='SELECT count(open.ticket_id) as open, count(pending.ticket_id) as pending, count(closed.ticket_id) as closed '
    .' FROM '.TICKET_TABLE.' ticket '
    .' LEFT JOIN '.TICKET_TABLE.' open
    ON (open.ticket_id=ticket.ticket_id AND open.status=\'open\') '
    .' LEFT JOIN '.TICKET_TABLE.' pending
    ON (pending.ticket_id=ticket.ticket_id AND pending.status=\'pending\') '
    .' LEFT JOIN '.TICKET_TABLE.' closed
    ON (closed.ticket_id=ticket.ticket_id AND closed.status=\'closed\')'
    .' WHERE ticket.email='.db_input($email);

    open include\staff\tickets.inc.php
    search for
        case 'open':
    $status='open';
    break;

    below add
        case 'pending':
    $status='pending';
    break;

    Continued to the next thread
  • Continued
    open include\staff\ticket-view.inc.php
    search for
                <?php
    if($ticket->isClosed() || $thisstaff->canCloseTickets()) { ?>
    <tr>
    <td width=\"160\">
    <label><strong>Ticket Status:</strong></label>
    </td>
    <td width=\"765\">
    <?php
    $statusChecked=isset($info['reply_ticket_status'])?'checked=\"checked\"':'';
    if($ticket->isClosed()) { ?>
    <label><input type=\"checkbox\" name=\"reply_ticket_status\" id=\"reply_ticket_status\" value=\"Open\"
    <?php echo $statusChecked; ?>> Reopen on Reply</label>
    <?php
    } elseif($thisstaff->canCloseTickets()) { ?>
    <label><input type=\"checkbox\" name=\"reply_ticket_status\" id=\"reply_ticket_status\" value=\"Closed\"
    <?php echo $statusChecked; ?>> Close on Reply</label>
    <?php
    } ?>
    </td>
    </tr>
    <?php
    } ?>

    replace with
                <tr>
    <td width=\"160\">
    <label><strong>Ticket Status:</strong></label>
    </td>
    <td width=\"765\">
    <?php
    $statusChecked=isset($info['reply_ticket_status'])?'checked=\"checked\"':'';
    if($ticket->isOpen()) { ?>
    <label><input type=\"checkbox\" name=\"reply_ticket_status\" id=\"reply_ticket_status\" value=\"Pending\"
    <?php echo $statusChecked; ?>> Mark as Pending</label>
    <?php
    } elseif($ticket->isPending()) { ?>
    <label><input type=\"checkbox\" name=\"reply_ticket_status\" id=\"reply_ticket_status\" value=\"Open\"
    <?php echo $statusChecked; ?>> Unmark as Pending</label>
    <?php
    } ?>
    <?php
    $statusChecked=isset($info['reply_ticket_status'])?'checked=\"checked\"':'';
    if($ticket->isClosed()) { ?>
    <label><input type=\"checkbox\" name=\"reply_ticket_status\" id=\"reply_ticket_status\" value=\"Open\"
    <?php echo $statusChecked; ?>> Reopen on Reply</label>
    <?php
    } elseif($thisstaff->canCloseTickets()) { ?>
    <label><input type=\"checkbox\" name=\"reply_ticket_status\" id=\"reply_ticket_status\" value=\"Closed\"
    <?php echo $statusChecked; ?>> Close on Reply</label>
    <?php
    } ?>
    </td>
    </tr>


    In /scp/login.php locate
    require_once('index.php'); //Just incase header is messed up.

    below add the following
    define(\"OMEGAPVTLTD\",TRUE); //Make includes happy        
    // do tasks prior to redirecting
    include_once(INCLUDE_DIR.'staff/preLogin.php');


    Copy the two files [preLogin.pgp and autoClose.php from 1st post in thread] to /include/staff

    Update the following db tables
    ALTER TABLE ost_ticket CHANGE status status ENUM('open','closed','pending') DEFAULT 'open';


    ALTER TABLE ost_ticket_event CHANGE state state ENUM('created','closed','reopened','assigned','transferred','overdue','pending')
  • Hello,

    I have gone through all the steps without issues till the last one :eek:!

    When running the MySql statement I get:

    mysql> ALTER TABLE ost_ticket_event CHANGE status state ENUMENUM('created','closed','reopened','assigned','transferred','overdue','pending');
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ENUMENUM('created','closed','reopened','assigned','transferred','overdue','pendi' at line 1
    mysql>

    Thinking ENUMENUM was a typo, I edited the command to one ENUM and got the following:

    mysql> ALTER TABLE ost_ticket_event CHANGE status state ENUM('created','closed','reopened','assigned','transferred','overdue','pending');
    ERROR 1054 (42S22): Unknown column 'status' in 'ost_ticket_event'
    mysql>

    Can you please assist?

    Thanks for the help and mod.
  • Jhendo6;40649 said:
    Hello,

    I have gone through all the steps without issues till the last one :eek:!

    When running the MySql statement I get:

    mysql> ALTER TABLE ost_ticket_event CHANGE status state ENUMENUM('created','closed','reopened','assigned','transferred','overdue','pending');
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ENUMENUM('created','closed','reopened','assigned','transferred','overdue','pendi' at line 1
    mysql>

    Thinking ENUMENUM was a typo, I edited the command to one ENUM and got the following:

    mysql> ALTER TABLE ost_ticket_event CHANGE status state ENUM('created','closed','reopened','assigned','transferred','overdue','pending');
    ERROR 1054 (42S22): Unknown column 'status' in 'ost_ticket_event'
    mysql>

    Can you please assist?

    Thanks for the help and mod.

    Ok that was a typing mistake use the code below
    ALTER TABLE ost_ticket CHANGE status status ENUM('open','closed','pending') DEFAULT 'open';


    and the other one
    ALTER TABLE ost_ticket_event CHANGE state state ENUM('created','closed','reopened','assigned','transferred','overdue','pending')
  • yup... that did it. Thanks for the edit and quick reply! :D

    Pending column looks good and functions perfectly except it won't show the number of pending tickets next to the heading. Any ideas?

    Thanks again for you support and working out this mod for the community.
  • Pending count not working...

    I can't seem to get the pending count number to augment. I have verified code and all else is working like a charm but the number remains (0) at all times.

    Any direction or advice is greatly appreciated!

    Thanks!
  • Can someone please point out where the zip file is. ?

    Thanks.
  • This was last updated for v1.7ST and no longer works.  I'm not aware of a zip file for this mod.
  • I'm running 1.6ST and would really like to get a hold of the attached files so that I can implement this mod. 

    Thanks.
  • The original post makes reference to files that don't exist in 1.6ST

    2). include\staff\preLogin.php
    This is the new file is been added and is in attached zip
    3). include\staff\autoClose.php
    This is the new file is been added and in attached zip

  • 1.6ST is no longer supported, but if you dont want to upgrade you can find what your looking for here:
    http://www.tmib.net/content/osticket-16-st-add-pending-status-and-autoclose-tickets-after-5-days
  • That's awesome.  Thanks very much for the link.

  • Very welcome. :)
Sign In or Register to comment.