Adding a New Field to tickets – osTicket Forums.
Adding a New Field to tickets
We added the field successfully and this thread explains the process. As a favor, can someone help us with adding that new field to the “tickets.inc.php” page?!?! It would be greatly appreciated. We’d like to be able to see Company in that table as a column where you see the ticket id, date, department, priority etc.
To add a new field there are 6 places you have to go to accomplish your goal.
- MySQL Database: manually add a field to ost_Ticket
- support/include/class.ticket.php
- support/include/client/open.inc.php
- support/include/client/viewticket.inc.php
- include/staff/viewticket.inc.php
- include/staff/newticket.inc.php
2.) class.ticket.php
Add your variable here:
class Ticket{
var
$id;
var $extid;
var $email;
var $status;
var $created;
var $updated;
var $priority;
and here: like so ($this->newvar=$row[‘newvar’]
if(($res=db_query($sql)) && db_num_rows($res)):
$row=db_fetch_array($res);
$this->id =$row['ticket_id'];
$this->extid =$row['ticketID'];
$this->email =$row['email'];
$this->fullname =$row['name'];
and here:
//GET
function getId(){
return $this->id;
}
function
getExtId(){
return $this->extid;
}
function
getEmail(){
return $this->email;
}
function
getNewvar(){
return $this->newvar;
}
and here:
function create($var,&$errors,$origin,$autorespond=true,$alertstaff=true) {
global $cfg,$thisclient,$_FILES;
$id=0;
$fields=array();
$fields['newvar'] = array('type'=>'string', 'required'=>1, 'error'=>'newvar required');
and finally:
$extId=Ticket::genExtRandID();
$sql= 'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.
',ticketID='.db_input($extId).
',dept_id='.db_input($deptId).
',priority_id='.db_input($priorityId).
',email='.db_input($var['email']).
',name='.db_input(Format::striptags($var['name'])).
',newvar='.db_input(Format::striptags($var['newvar'])).
4.) viewticket.inc.php Repeat Step 3
5.) staff/viewticket.inc.php Repeat Step 4
4.) staff/newticket.inc.php Repeat Step 5
/* Add New Fields Modification
* Author: James Williams
* osTicket v1.6 RC4
* Date: 07-22-08
* Ref: http://www.osticket.com/forums/showthread.php?t=873
*/
DB Table: ost_ticket
Field Type Collation Attributes Null
location text latin1_general_ci No
+ADD include\client\open.inc.php between subject and intersection
<tr> <th valign="top">Location, Address, or Intersection:</th> <td> <? if($errors['location']) {?> <font class="error"><b> <?=$errors['location']?></b></font><br/><?}?> <textarea name="location" cols="35" rows="3" wrap="soft" style="width:85%"><?=$info['location']?></textarea></td> </tr>
+ADD include\class.ticket.php
var $location; // mod080722_new_ticket_field
+ADD include\class.ticket.php
$this->location =$row['location']; // Mod080722_new_ticket_field
+ADD include\class.ticket.php
// mod080722_new_ticket_field
function getLocation() {
return $this->row['location'];
}
+ADD include\class.ticket.php
$fields['location'] = array('type'=>'text', 'required'=>0, 'error'=>'Provide a location, address, or directions'); //mod080722_new_ticket_field
+ADD include\class.ticket.php
//We are ready son...hold on to the rails.
$extId=Ticket::genExtRandID();
$sql= 'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.
',ticketID='.db_input($extId).
',dept_id='.db_input($deptId).
',priority_id='.db_input($priorityId).
',email='.db_input($var['email']).
',name='.db_input(Format::striptags($var['name'])).
',subject='.db_input(Format::striptags($var['subject'])).
',location='.db_input(Format::striptags($var['location'])). // mod080722_new_ticket_field
',phone='.db_input($var['phone']).
',ip_address='.db_input($ipaddress).
',source='.db_input($source);