- Edited
Hello,
I have posted a few times about a MOD which has been put together. Ticket Linking & Ticket Categorization. The way that the MOD was implemented it was too time consuming for me to share it with the community and separate them. So here they are together.
There is a bunch of additional PHP files which you will need to add into several folders as well as make several changes to the back-end database.
Please make these changes in a test environment first before implementing them in your live environment.
Without further delay....
The Mod:
1. Edit include\class.ticket.php
A)
Search for the following code:
var $overdue;
Below it Add:
var $category_Id;
B)
Search for the following code:
function Ticket($id,$exid=false){
$this->load($id);
}
Replace it with:
function Ticket($id,$exid=false){
$this->load($id);
// $this->getParentTickets();
// $this->getChildTickets();
}
C)
Search for the Following code:
function load($id) {
$sql =' SELECT ticket.*,topic.topic_id as topicId,lock_id,dept_name,priority_desc FROM '.TICKET_TABLE.' ticket '.
Replace it with:
function getParentTickets($lticketId)
{ $sql= "SELECT links.id as LinkId,child_ticket_id,parent_ticket_id,subject,status,ticket_id FROM ".LINK_TABLE." links
INNER JOIN ".TICKET_TABLE. " tickets ON links.parent_ticket_id=tickets.ticketId
WHERE child_ticket_id=".$lticketId;
$res=db_query($sql);
$result=array();
if($res && db_num_rows($res))
{
list($LinkId,$child_ticket_id,$parent_ticket_id,$subject,$status,$ticket_id)= db_fetch_row($res);
$result=$LinkId;
$result=$child_ticket_id;
$result=$parent_ticket_id;
$result=$subject;
$result=$status;
$result=$ticket_id;
}
return $result;
}function getChildTickets($lticketId){
$sql= "SELECT links.id as LinkId,child_ticket_id,parent_ticket_id,subject,status,ticket_id FROM ".LINK_TABLE." links
INNER JOIN ".TICKET_TABLE. " tickets ON links.child_ticket_id=tickets.ticketId
WHERE parent_ticket_id=".$lticketId;
$res=db_query($sql);
$result=array();
if($res && db_num_rows($res))
{
$i=0;
while($row= db_fetch_row($res)){
$result=$row;
$result=$row;
$result=$row;
$result=$row;
$result=$row;
$result=$row;
$i++;
}
}
return $result;
}
function insertlinkTicket($var,&$errors) {
global $cfg,$thisuser;
$params = new Validator($fields);
if(!$params->validate($var)){
$errors=array_merge($errors,$params->errors());
}
$child_ticket_id=$var;
$parent_ticket_id=$var;
$sql="INSERT INTO ost_ticket_link(child_ticket_id,parent_ticket_id) values($child_ticket_id,$parent_ticket_id)";
if(db_query($sql)){
$this->getParentTickets($parent_ticket_id);
$this->getChildTickets($parent_ticket_id);
return true;
}
return false;
}
function updatecatid($var,&$errors) {
global $cfg,$thisuser;
$fields=array();
$fields = array('type'=>'int', 'required'=>1, 'error'=>'Ticket type required');
$fields = array('type'=>'int', 'required'=>1, 'error'=>'Main category required');
$fields = array('type'=>'int', 'required'=>1, 'error'=>'Sub category required');
$params = new Validator($fields);
if(!$params->validate($var)){
$errors=array_merge($errors,$params->errors());
}
$sql='UPDATE '.TICKET_TABLE.' SET category_Id='.db_input($var).',updated=NOW() WHERE ticket_id='.db_input($this->getId());
if(db_query($sql)){
$this->reload();
return true;
}
return false;
}
function load($id) {
$sql =' SELECT ticket.*,topic.topic_id as topicId,lock_id,dept_name,priority_desc,category_Id FROM '.TICKET_TABLE.' ticket '.
D)
Find the following code:
$this->overdue =$row;
Below Add the following code:
$this->category_Id=$row;
E)
Find the following code:
function isLocked() {
return $this->lock_id?true;
}
//GET
Below Add the following code:
function getCategory_Id(){
return $this->category_Id;
}
F)
Find the following code:
db_query('DELETE FROM '.TICKET_NOTE_TABLE.' WHERE ticket_id='.db_input($this->getId()));
Below Add the following code:
db_query('DELETE FROM '.LINK_TABLE.' WHERE child_ticket_id='.db_input($this->getExtId()));
G)
Search for the following code:
$fields = array('type'=>'int', 'required'=>0, 'error'=>'Invalid Selection');
ABOVE add the following code:
$fields = array('type'=>'text', 'required'=>1, 'error'=>'Categorization required');
H)
Search for the following code:
if(!$errors){
$sql='UPDATE '.TICKET_TABLE.' SET updated=NOW() '.
',email='.db_input($var).
Add the following code below:
',category_Id='.db_input( $var).
I)
Search for the following code:
if(strcasecmp($origin,'web')==0) { //Help topic only applicable on web tickets.
Above Add the following code:
$fields = array('type'=>'text', 'required'=>1, 'error'=>'Categorization required');
J)
Search for the following code:
//We are ready son...hold on to the rails.
$extId=Ticket:();
$sql= 'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.
',ticketID='.db_input($extId).
Below Add the following code:
',category_Id='.db_input( $var).
2. Edit scp\tickets.php
A)
Search for the following code:
if(!$errors && ($id=$_REQUEST?$_REQUEST:$_POST) && is_numeric($id)) {
$deptID=0;
$ticket= new Ticket($id);
replace with:
if(!$errors && ($id=$_REQUEST?$_REQUEST:$_POST) && is_numeric($id)) {
$deptID=0;
$ticket= new Ticket($id);
$parentArray= $ticket->getParentTickets($ticket->getExtId());
$childArray = $ticket->getChildTickets($ticket->getExtId());
B)
Search for the following Code:
}elseif($_REQUEST=='open') {
//TODO: Check perm here..
$page='newticket.inc.php';
}
Below Add the following:
if(isset($_GET) && !empty($_GET))
{ $deletequery="DELETE FROM ".LINK_TABLE." WHERE id=".$_GET;
db_query($deletequery);
$msg3='Ticket Linkage deleted successfully';
}
****NOTE***** Another Post with attached files, Screencaps and the rest of the MOD will Follow