I'm finishing work right now, so I'll post the rest of this MOD Monday morning (8/11/2010)
I was having some issues getting new fields to work on the latest release of OsTicket but I now have it working so I shall share the code.
Now I had to customize this code so we could use the system to book in computers in our computer shop, so I have added the following fields:
Password - Text Field
Type - Drop Down Selection
Sides - Drop Down Selection
Other - Textarea
Lets get started:
Adding the tables to the database:
1. Go to PHPMyAdmin - Open your OsTicket Database then click on ost_ticket on the left hand menu pane.
2. On the right hand side click on the "Structure" tab link then scroll to bottom.
3. Add 4 Fields 'after' the Name field (use the drop down box) then click go:
Field: (this is the field name, you will need to name the first one password, second one type. etc etc.
Type: VARCHAR
Length: 100
Collation: utf8_general_ci
Leave everything else as is, click save. and repeat until you have the following fields: password, type, sides, other.
Do note, these fields are for examples so you can name then whatever you wish, just remember to rename all instances of that name throughout all the code
Next we need to edit /includes/class.ticket.php
Find:
class Ticket{
var $id;
var $extid;
Add:
var $pass; // Added Variable
var $type; // Added Variable
var $sides; // Added Variable
var $other; // Added Variable
Find:
if(($res=db_query($sql)) && db_num_rows($res)):
$row=db_fetch_array($res);
$this->id =$row;
$this->extid =$row;
$this->email =$row;
Add:
$this->pass =$row; // Added Variable
$this->type =$row; // Added Variable
$this->sides =$row; // Added Variable
$this->other =$row; // Added Variable
Find:
//GET
function getId(){
return $this->id;
}
Add:
function getPass(){ // Added Variable
return $this->pass;
}
function getType(){ // Added Variable
return $this->type;
}
function getSides(){ // Added Variable
return $this->sides;
}
function getOther(){ // Added Variable
return $this->other;
}
Find:
$id=0;
$fields=array();
$fields = array('type'=>'string', 'required'=>1, 'error'=>'Name required');
$fields = array('type'=>'email', 'required'=>1, 'error'=>'Valid email required');
Add:
$fields = array('type'=>'string', 'required'=>0, 'error'=>'Password required'); // Added Variable
$fields = array('type'=>'string', 'required'=>1, 'error'=>'Type required'); // Added Variable
$fields = array('type'=>'string', 'required'=>1, 'error'=>'Sides required'); // Added Variable
$fields = array('type'=>'string', 'required'=>0, 'error'=>'Other Items required'); // Added Variable
Find: (This is the DB part)
//We are ready son...hold on to the rails.
$extId=Ticket:();
$sql= 'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.
',ticketID='.db_input($extId).
And Add:
',pass='.db_input(Format:($var)). // Var Added
',type='.db_input(Format:($var)). // Var Added
',sides='.db_input(Format:($var)). // Var Added
',other='.db_input(Format:($var)). // Var Added