Hi,
I've ever read one of some topics in this forum that asking for Help-Topic should be implemented as good as its functionality. As we know, in this current version (v1.6 RC4), this help-topic has not been implemented 100%, yet. Or at least this help-topic information that client select on Open New Ticket form has not been saved in database. In addition, if Staff add new ticket from Staff Panel, there is no "help-topic" selection that Staff can select.
I made some modification for this, and I have tested it, it works good now! Please note that I have been implementing the multi-language in my osticket system. So in some part of my modification below, you will find some language constants. You can change them to the string based on the original system. Please be kind of this. ;)
Let's getting started, shall we? Ouw, before forgot, please please please, BACKUP YOUR FILES BEFORE DOING THIS!!!
Alter ticket table with adding a new field named: "topic_id" int 11 default = 1
Then:
Open \include\client\open.inc.php, and FIND:
<option value="0" >General Inquiry</option>
REPLACE WITH:
// MOD Help Topic by Masino Sinaga, April 19, 2009
<option value="0" >General Inquiry</option>
Open \scp\tickets.php, and FIND:
$_POST=$_POST=0; //clean crap.
REPLACE WITH:
//$_POST=$_POST=0; //clean crap. // MOD Help Topic by Masino Sinaga, April 19, 2009
FIND:
if($thisuser->canAccessDept($ticket->getDeptId())) {
REPLACE WITH:
if($thisuser->canAccessDept($ticket->getTopicId())) {
Open \include\class.ticket.php, and FIND:
var $dept_name;
AFTER, ADD:
var $topic_id; // MOD Help Topic by Masino Sinaga, April 19, 2009
var $topic_name; // MOD Help Topic by Masino Sinaga, April 19, 2009
FIND:
$sql =' SELECT ticket.*,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 '.TICKET_LOCK_TABLE.' tlock ON ticket.ticket_id=tlock.ticket_id AND tlock.expire>NOW() '.
' WHERE ticket.ticket_id='.db_input($id);
REPLACE WITH:
$sql =' SELECT ticket.*,lock_id,dept_name,priority_desc,topic FROM '.TICKET_TABLE.' ticket '.
' LEFT JOIN '.DEPT_TABLE.' dept ON ticket.dept_id=dept.dept_id '.
' LEFT JOIN '.TOPIC_TABLE.' topic ON ticket.topic_id=topic.topic_id '.
' LEFT JOIN '.TICKET_PRIORITY_TABLE.' pri ON ticket.priority_id=pri.priority_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);
// MOD Help Topic by Masino Sinaga, April 19, 2009
FIND:
$this->dept_name =$row;
AFTER, ADD:
$this->topic_id =$row; // MOD Help Topic by Masino Sinaga, April 19, 2009
$this->topic_name=$row; // MOD Help Topic by Masino Sinaga, April 19, 2009
FIND:
function getDeptName(){
return $this->dept_name;
}
AFTER, ADD:
// MOD Help Topic by Masino Sinaga, April 19, 2009
function getTopicId(){
return $this->topic_id;
}
function getTopicName(){
return $this->topic_name;
}
// MOD Help Topic by Masino Sinaga, April 19, 2009
FIND:
}elseif(strcasecmp($origin,'staff')==0){ //tickets created by staff...e.g on callins.
$fields = array('type'=>'int', 'required'=>1, 'error'=>'Dept. required');
$fields = array('type'=>'string', 'required'=>1, 'error'=>'Indicate source');
REPLACE WITH:
}elseif(strcasecmp($origin,'staff')==0){ //tickets created by staff...e.g on callins.
// MOD Help Topic by Masino Sinaga, April 19, 2009
// $fields = array('type'=>'int', 'required'=>1, 'error'=>I_C_T_DEPT_REQUIRED);
$fields = array('type'=>'int', 'required'=>1, 'error'=>I_C_T_SELECT_HELP_TOPIC);
// MOD Help Topic by Masino Sinaga, April 19, 2009
$fields = array('type'=>'string', 'required'=>1, 'error'=>I_C_T_INDICATE_SOURCE);
FIND:
$deptId=$var; //pre-selected Dept if any.
AFTER, ADD:
$topicId=$var; // MOD Help Topic by Masino Sinaga, April 19, 2009
FIND:
$deptId=$topic->getDeptId();
AFTER, ADD:
$topicId=$topic->getId(); // MOD Help Topic by Masino Sinaga, April 19, 2009
FIND:
$source='Web';
REPLACE WITH:
// MOD Help Topic by Masino Sinaga, April 19, 2009
if (!isset($source) || ($source=="")) {
$source='Web';
}
FIND:
$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).
',name='.db_input(Format:($var)).
',subject='.db_input(Format:($var)).
',phone='.db_input($var).
',ip_address='.db_input($ipaddress).
',source='.db_input($source);
REPLACE WITH:
$sql= 'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.
',ticketID='.db_input($extId).
',dept_id='.db_input($deptId).
',topic_id='.db_input($topicId). // MOD Help Topic by Masino Sinaga, April 19, 2009
',priority_id='.db_input($priorityId).
',email='.db_input($var).
',name='.db_input(Format:($var)).
',subject='.db_input(Format:($var)).
',phone='.db_input($var).
',ip_address='.db_input($ipaddress).
',source='.db_input($source);
Open \include\staff\newticket.inc.php, and FIND:
<tr>
<td align="left"><b>Department:</b></td>
<td>
<select name="deptId">
<option value="" selected >Select Department</option>
<?
$services= db_query('SELECT dept_id,dept_name FROM '.DEPT_TABLE.' ORDER BY dept_name');
while (list($deptId,$dept) = db_fetch_row($services)){
$selected = ($info==$deptId)?'selected':''; ?>
<option value="<?=$deptId?>"<?=$selected?>><?=$dept?></option>
<?
}?>
</select>
<font class="error"><b>*</b> <?=$errors?></font>
</td>
</tr>
REPLACE WITH:
<tr>
<td align="left"><b><?php echo (I_C_OPEN_HELP_TOPIC) ?></b></td>
<td>
<select name="topicId">
<option value="" selected ><?php echo (I_C_OPEN_SELECT_ONE) ?></option>
<?php // MOD Help Topic by Masino Sinaga, April 19, 2009
$services= db_query('SELECT topic_id,topic FROM '.TOPIC_TABLE.' WHERE isactive=1 ORDER BY topic_id');
while (list($topicId,$topic) = db_fetch_row($services)){
$selected = ($info==$topicId)?'selected':''; ?>
<option value="<?php echo $topicId?>"<?php echo $selected?>><?php echo $topic?></option>
<?php
}?>
// MOD Help Topic by Masino Sinaga, April 19, 2009
<option value="0" ><?php echo (I_C_OPEN_GENERAL_INQUIRY) ?></option>
</select>
<font class="error">* <?php echo $errors?></font>
</td>
</tr>
That's all for editing code.
Now, let's see what's new you will get after all modification above:
1. Each time Client add new ticket, the Help Topic that he/she select will be saved in ticket table. It means that help topic feature works good now.
2. Because of Help Topic is a part or member of Department, which is these two tables related to each other, the selected "topic_id" in help-topic will be automatically related to "dept_id" in Department table.
3. Each time Staff add new ticket, the Help Topic that Staff select (instead of Department) will be saved in database, and the point number 2 above will be implemented also while Staff add a new ticket. It means that help topic feature works good now also in Staff-side.
4. The source of ticket now also working as good as we want.
The most important thing that I want to let you know about this modification, I have tried this, and it works good now! I am so happy now, that is why I share this to you. Hope you like it.
Best regards,
Masino Sinaga