OSTicket 1.6 ST: Add Pending Status, and Autoclose tickets after 5 days.

Based on the Pending and Autoclose mod posted by GooseMoose on the OSTicket forums, here are my re-written directions on how to do it, as well as a bug fix.

What:

This MOD is for OSTicket 1.6 ST and will add in a new ticket status type of “pending”. If any ticket is left pending for 5 days it will close the ticket. It also adds a new section at the top [see image] that displays how many pending tickets there are and lets you click the link to look at them.

UPDATE: Please note that today Sept 14th, 2011 I noticed that I forgot to include part of step 1 in my directions. This step has been updated accordingly, sorry for any confusion it may have caused.

Directions:

Step 1 –

Copy the two files [preLogin.pgp and autoClose.php] in the attached zip to /include/staff

In /scp/login.php at circa line 54 after

require_once('index.php'); //Just incase header is messed up.

add the following code:

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

Step 2 –

update the database [please edit this to fit your installation] with the following MySQL Query

ALTER TABLE ost_ticket CHANGE status status ENUM('open','closed','pending') DEFAULT 'open';

Step 3 –

Make the following code changes

3A: In [document root]/scp/tickets.php

at circa line 56

Change

$statusKeys=array('open'=>'Open','Reopen'=>'Open','Close'=>'Closed');

to

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

at circa line 96 after

}

and before

//Finally upload attachment if any

Add the following

$wasPending=$ticket->isPending();
if(isset($_POST['pending_status']) && $_POST['pending_status']) {
   if($ticket->setStatus($_POST['pending_status']) && $ticket->reload()) {
	   $note=sprintf('%s %s the ticket on reply',$thisuser->getName(),($ticket->isPending()?'Pending': $ticket->isOpen() ? 'Open' : 'Closed'));
	   $ticket->logActivity('Ticket status changed to '.($ticket->isPending()?'Pending': $ticket->isOpen() ? 'Open' : 'Closed'),$note);
   }
}
if($wasPending && !isset($_POST['pending_status']))
{
	$ticket->setStatus('open');
	$note=sprintf('%s %s the ticket on reply',$thisuser->getName(),$ticket->isOpen()?'reopened':'closed');
	$ticket->logActivity('Ticket status changed to '.($ticket->isOpen()?'Open':'Closed'),$note);
}

at circa line 432 change

$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 '.
     ' 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.' 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());

to

$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());

at circa line 463 after

if($stats['overdue']) {
    $nav->addSubMenu(array('desc'=>'Overdue ('.$stats['overdue'].')','title'=>'Stale Tickets',
                    'href'=>'tickets.php?status=overdue','iconclass'=>'overdueTickets'));

    if(!$sysnotice && $stats['overdue']>10)
        $sysnotice=$stats['overdue'] .' overdue tickets!';
}

add the following

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

3B: In [document root]/include/staff/viewticket.inc.php

circa line 333 change

isOpen()){?>
<label><input type="checkbox" name="ticket_status" id="l_ticket_status" value="Close"  > Close on Reply

<label><input type="checkbox" name="ticket_status" id="l_ticket_status" value="Reopen"  > Reopen on Reply

to

isPending())
{
	?>
	
	isOpen()){?>
	<label><input type="checkbox" name="ticket_status" id="l_ticket_status" value="Close"  > Close on Reply
	
	<label><input type="checkbox" name="ticket_status" id="l_ticket_status" value="Reopen"  > Reopen on Reply
	isClosed())
{
	if($ticket->isPending()){
	?>
	<label><input type="checkbox" name="pending_status" id="l_pending_status" value="Pending" checked="checked" > Ticket is pending (Untick to mark not pending)
	
	<label><input type="checkbox" name="pending_status" id="l_pending_status" value="Pending"  > Mark As Pending
	

3C: In [document root]/include/class.ticket.php

circa line 107 add
note: I added this after the isOpen function and before the isClosed function.

    function isPending(){
        return (strcasecmp($this->getStatus(),'Pending')==0)?true:false;
    }

Locate function setStatus circa line 378 and add:

case 'pending':
            return $this->pending();
            break;

circa line 397 add

function pending(){
        
        $sql= 'UPDATE '.TICKET_TABLE.' SET status='.db_input('pending').',updated=NOW() '.
              ' WHERE ticket_id='.db_input($this->getId());
        return (db_query($sql) && db_affected_rows())?true:false;
    }

3D: In [document root]/include/staff/tickets.inc.php

circa line 32 add

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


*** Update 05 Mar 2013 ***
For some reason Drupal hosed some of my file attachments. Here is a link to the pending mod files that you need to complete this modification.

Pending Mod files: pending-mod-files.zip

Dell PowerEdge 840: fix for memory limited to 256

So generally when I run across something at work that I think “hey someone else might have this same problem” I generally try to remember to post about it here at tmib.net. Sadly I am pretty bad at remembering to do it on a time and regular basis. I have been playing with Google+ recently and although I have been posting updates about there on there, that means that I am neglecting this page more. So since I hit a snag yesterday on something I figured I would post about it on the off chance that someone else has this type of thing happen to them.

I work for a non-profit agency, and as such we regularly receive older technology donations. The average computer here at work is a single core Pentium4 1.8-2 Ghz machine with 256 to 512mb ram. So when we get something a little bigger then that I tend to try to fix it right up, install the OS and our standard software packages and get it right out to someone. This includes when we get something like the Dell PowerEdge 840 with a 2.8Ghz single core, 1Gb RAM, Raid Controller, and a 250GB hard drive we automatically think “this would make someone a good desktop”.

It just so happens that someones computer died yesterday so I went and started to setup the PowerEdge to replace her computer. I went into the bios changed a few settings. Threw my Windows 7 Enterprise installation disk in the drive and … huh. Odd the raid controller is reporting 0 disks. Okay, reboot go into the raid controller setup the hard drive [which means deleting the volume and re-initializing it since it was already setup]. Reboot the machine, it sees the drive now but still no windows installer. Go back into the Bios, double check that its set to let the CD-Rom be the boot drive… it is. But then thats the problem isn’t it? Cd-Rom… Win7 is on a DVD.

/facepalm.

Open the case, replace the drive with a DVD drive. Fire the machine back up, Windows Installer is Go! Houston we have lift off. I go back to my desk and work on something else while I wait for it to get to needing my input. I turn around and there is an error message on the screen basically saying “You’re computer has 256mb of ram, this version of windows requires 512mb.” (yes totally paraphrased). So standing there dumbfounded since there is 1Gb on the Motherboard, and another 256Mb on the Raid… oh you don’t think that its the raid controller do you? Well I did. So I rebooted went into setup the Bios see’s the 1Gb. There are no options to change for the memory. Went into the raid controller, nothing to change in there. Shut the machine down, re-seat the RAM and turn it back on. Thats when I notice the little error message during boot that says:

“Amount of available memory limited to 256MB”

Grr… Okay back into the Bios for a quick look then off to visit our overlords at Google. A quick search of “PowerEdge 840 limited to 256” leads me to the solution. And thus concludes my little tech story to you all by saying this:

Go back into the Bios and shut off “OS Install Mode”.

I can happily report that the machine is currently installing Windows 7 Enterprise as I write this. Hopefully if someone else has a similar problem, this post will help them find the answer that they are looking for.

See you in the funny pages.