Hey everyone,
So I'm new here. Just stumbled upon osTicket the other day and have an add-on I've done that hopefully some others can put to use. I'm sure it's probably not the best or most efficient way to do it but it gets the job done. So if you'd like to be able to assign a staff user to a ticket from the list of tickets, here's how I did it.
First... I added the column header to the table in tickets.inc.php:
/include/staff/tickets.inc.php -- around line 412 (my line numbers are probably kinda high)
Assign...
Then I added the cell in the body of the table:
/include/staff/tickets.inc.php -- around line 479
<td nowrap>
staff select added by me
<?php
$thisTicket = new Ticket($row);
?>
<select id="staff_select<? echo $row;?>" onchange="changeAssignee(<? echo $row ?>);">
<option <?if($row == 0){?>SELECTED<?}?> value="0">Assign...</option>
<?php
$possibleAssignees = $thisTicket->getPossibleAssignees($row);
?>
</select>
</td>
Then I added a new function to class.ticket.php that is used in the code above:
/include/class.ticket.php -- at the end of the class
function getPossibleAssignees($currentStaffID)
{
$sql = "SELECT staff_id, CONCAT(firstname,' ',lastname) as name from ".STAFF_TABLE;
$query = db_query($sql);
$i=0;
while($row = db_fetch_array($query))
{
$id = $row;
$name = $row;
if($currentStaffID == $id)
{
$option = "<option value=\"".$id."\" SELECTED>".$name."</option>";
} else {
$option = "<option value=\"".$id."\">".$name."</option>";
}
echo $option;
}
}
So it's not the cleanest function in the world. I typically hate writing to the document within the function but hey, I was in a hurry at the time.
Then I added a the javascript used when the new select box is changed. Back to tickets.inc.php!:
/include/staff/tickets.inc.php -- very beginning of document, line 1!
<script type="text/javascript">
function changeAssignee(ticketID)
{
var obj = "staff_select"+ticketID;
var sel = document.getElementById(obj);
var assignee = sel.options.value;
var url = "index.php?update=staff&staffid="+assignee+"&ticket_id="+ticketID;
window.location.href = url;
}
</script>
Finally, we add code to actually change the assignee. Still in tickets.inc.php:
/include/staff/tickets.inc.php -- right after the first line of PHP code... line 17 for me, line 3 by default.
// assign the user from the drop down list if one has been selected
if(isset($_GET) && $_GET == "staff")
{
$thisStaff = $_GET;
$ticketToUpdate = $_GET;
$tt = new Ticket($ticketToUpdate);
$tt->setStaffId($thisStaff);
}
That's that... when you're all said in done you should look like (please ignore all the spam, still haven't gotten my filters perfected):

Oh yea... I also made the content holder in the /scp/ directory larger. I did that by modifying /scp/css/main.css
/scp/css/main.css -- about line 62 only thing I've changed are the widths
#container {
width;
text-align: left;
margin auto 0 auto;
background(../images/pagebg.jpg) top left repeat-x #fff;
border solid #ccc;
border-bottom;
padding-bottom: 20px;
}
#footer {
width;
_width;
padding 5px 2px 5px;
border solid #ccc;
border-top solid #666;
background:#ececec;
text-align;
margin auto 0 auto;
}
Have fun!