NOT FINISHED, NEED TO BE CHECKED ONE MORE TIME
1). scp\login.php
Added below code from line 54
define("OMEGAPVTLTD",TRUE); //Make includes happy
// do tasks prior to redirecting
include_once(INCLUDE_DIR.'staff/preLogin.php');
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
4). scp\tickets.php
On line 57, Add pending option in array $statusKeys
Look for this:
//Finally upload attachment if any
And paste above it, this:
if(isset($_POST) && $_POST) {
if($ticket->setStatus($_POST) && $ticket->reload()) {
$note=sprintf('%s %s the ticket on ',$thisuser->getName(),($_POST=='pending'?'stopped': 'reopened'));
$ticket->logActivity('Ticket status changed to '.($_POST=='pending'?'Stopped': 'Opened'),$note);
}
}
Look for this:
/*quick stats...*/
$sql='SELECT count(open.ticket_id) as open
And modify the whole $sql var with this:
$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 '.
' FROM '.TICKET_TABLE.' ticket '.
'LEFT JOIN '.TICKET_TABLE.' open ON open.ticket_id=ticket.ticket_id AND open.status=\'open\' AND open.isanswered=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.staff_id='.db_input($thisuser->getId());
Look for this:
$nav->addSubMenu(array('desc'=>'Closed'
And paste above it, this:
if($stats) {
$nav->addSubMenu(array('desc'=>'Pending Tickets ('.$stats.')','title'=>'Pending Tickets', 'href'=>'tickets.php?status=pending', 'iconclass'=>'pendingTickets'));
}
5). include\staff\viewticket.inc.php
Writing it...
6). include\class.ticket.php
Look for "load" function:
function load($id) {
Modify its first var ($sql) by this one:
$sql =" SELECT CASE ticket.status".
" WHEN 'closed' THEN TIMEDIFF(ticket.closed, ticket.created)".
" ELSE TIMEDIFF(NOW(), ticket.created)".
" END as total_time,".
" CASE ticket.status".
" WHEN 'closed' THEN TIMEDIFF(TIMEDIFF(NOW(), ticket.closed),-ticket.pend_time)".
" END as pend_plus_time_closed,".
" CASE ticket.status".
" WHEN 'closed' THEN TIMEDIFF(TIMEDIFF(ticket.closed, ticket.created),ticket.pend_time)".
" WHEN 'pending' THEN TIMEDIFF(TIMEDIFF(ticket.pending, ticket.created), ticket.pend_time)".
" WHEN 'open' THEN TIMEDIFF(TIMEDIFF(NOW(), ticket.created), ticket.pend_time)".
" END as total_imp_time,".
" CASE ticket.status".
" WHEN 'pending' THEN TIMEDIFF(TIMEDIFF(NOW(), ticket.pending),-ticket.pend_time)".
" WHEN 'closed' THEN ticket.pend_time".
" WHEN 'open' THEN ticket.pend_time".
" END as total_pend_time,".
" ticket.*,topic.topic_id as topicId,lock_id,dept_name,priority_desc FROM ".TICKET_TABLE." ticket ".
" LEFT JOIN ".DEPT_TABLE." dept ON ticket.dept_id=dept.dept_id ".
" LEFT JOIN ".TICKET_PRIORITY_TABLE." pri ON ticket.priority_id=pri.priority_id ".
" LEFT JOIN ".TOPIC_TABLE." topic ON ticket.topic_id=topic.topic_id ".
" LEFT JOIN ".TICKET_LOCK_TABLE." tlock ON ticket.ticket_id=tlock.ticket_id AND tlock.expire>NOW() ".
" WHERE ticket.ticket_id=".db_input($id);
Look for this line:
$this->closed =$row;
And paste below it the following:
$this->pending =$row;
$this->pend_time =$row;
$this->total_pend_time =$row;
$this->total_imp_time =$row;
$this->total_time =$row;
$this->pend_plus_time_closed =$row;
Look for this function:
function isOpen(){
return (strcasecmp($this->getStatus(),'Open')==0)?true;
}
And paste below that, this:
function isPending(){
return (strcasecmp($this->getStatus(),'Pending')==0)?true;
}
Look for this function:
function getDueDate(){
return $this->duedate;
}
And paste below that, this:
function getPendingDate(){
return $this->pending;
}
function getPendTime(){
return $this->pend_time;
}
function getTotalPendTime(){
return $this->total_pend_time;
}
function getTotalTime(){
return $this->total_time;
}
function getTotalImpTime(){
if ($this->total_imp_time) {
return $this->total_imp_time;
} else {
return $this->total_time;
}
}
Look for this:
function setStatus($status){
And modify the complete function by these lines:
function setStatus($status){
if(strcasecmp($this->getStatus(),$status)==0)
return true; //No changes needed.
switch(strtolower($status)):
case 'reopen':
case 'open':
return $this->reopen();
break;
case 'pending':
return $this->pending();
break;
case 'no_pending':
return $this->no_pending();
break;
case 'close':
return $this->close();
break;
endswitch;
return false;
}
Look for this:
//set status to open on a closed ticket.
function reopen($isanswered=0){
global $thisuser;
$sql= 'UPDATE '.TICKET_TABLE.' SET status='.db_input('open').',isanswered=0,updated=NOW(),reopened=NOW() WHERE ticket_id='.db_input($this->getId());
return (db_query($sql) && db_affected_rows())?true;
}
And modify that with this:
//set status to open on a closed ticket.
function reopen($isanswered=0){
global $thisuser;
$sql= "UPDATE ".TICKET_TABLE." SET status=".db_input('open').",isanswered=0,updated=NOW(),reopened=NOW(),pend_time='".$this->pend_plus_time_closed."' WHERE ticket_id=".db_input($this->getId());
return (db_query($sql) && db_affected_rows())?true;
}
function pending(){
$sql= 'UPDATE '.TICKET_TABLE.' SET status='.db_input('pending').',updated=NOW(),pending=NOW() '.
' WHERE ticket_id='.db_input($this->getId());
return (db_query($sql) && db_affected_rows())?true;
}
function no_pending(){
$sql= "UPDATE ".TICKET_TABLE." SET status=".db_input('open').",updated=NOW(),pending=NULL,pend_time='".$this->total_pend_time."' WHERE ticket_id=".db_input($this->getId());
return (db_query($sql) && db_affected_rows())?true;
}
7). include\staff\tickets.inc.php
Look for this:
case 'open':
$status='open';
break;
And paste below that, this:
case 'pending':
$status='pending';
break;
8). Changes in ost_ticket table in MySQL:
Added new enum `pending` in the table ost_ticket in the field status
New field (after `updated`): `pending` datetime DEFAULT NULL
New field (after `pending`): `pend_time` time NOT NULL
[pending-mod-files.zip](https://forum.osticket.com/assets/files/migrated/f/3f26a572cebd3aa11f126a2a9b8d553.zip)