now for the staff reasign in ticket view
Ok in continuing the above text explanation now its time to set the assign staff part of this... with each dept being its own company we want the assign staff tab on the bottom of the view ticket screen to only show those staff members that are in that dept...
As mentioned before you have choices in the way the staff members are listed... username or first name last name...
i finally decided to just go with firstname lastname even though username would be more unique, the firstname lastname display is basically how the sysytem is based so i didnt really want to go against the grain. so this first example is now i have i coded now using first name and last name.. then following that i will display my code for using the username in the drop down menu of the reassign ticket field (note: that part worked when i used it but its not perfected as of yet so just know u may have to restructure it, ill explay when i post it.
in the include/staff/viewticket.inc.php
find this section (its toward the bottom)
<div id="assign" class="tabbertab" align="left">
<h2><?=$staff?'Re Assign Ticket':'Assign to Staff'?></h2>
<p>
<form action="tickets.php?id=<?=$id?>#assign" name="notes" method="post" enctype="multipart/form-data">
<input type="hidden" name="ticket_id" value="<?=$id?>">
<input type="hidden" name="a" value="assign">
<div>
<span for="staffId">Staff Member:</span>
<select id="staffId" name="staffId">
<option value="0" selected="selected">-Select Staff Member.-</option>
<?
//TODO: make sure the user's group is also active....DO a join.
$sql=' SELECT staff_id,CONCAT_WS(", ",lastname,firstname) as name FROM '.STAFF_TABLE.
' WHERE isactive=1 AND onvacation=0 ';
if($ticket->isAssigned())
$sql.=' AND staff_id!='.db_input($ticket->getStaffId());
$depts= db_query($sql.' ORDER BY lastname,firstname ');
while (list($staffId,$staffName) = db_fetch_row($depts)){
$selected = ($info==$staffId)?'selected':''; ?>
<option value="<?=$staffId?>"<?=$selected?>><?=$staffName?></option>
<?
now remove this section:
$sql=' SELECT staff_id,CONCAT_WS(", ",lastname,firstname) as name FROM '.STAFF_TABLE.
' WHERE isactive=1 AND onvacation=0 ';
if($ticket->isAssigned())
$sql.=' AND staff_id!='.db_input($ticket->getStaffId());
and replace it with:
if($thisuser->isAdmin()) {
$sql=' SELECT staff_id,CONCAT_WS(", ",lastname,firstname) as name FROM '.STAFF_TABLE.' WHERE isactive=1 AND onvacation=0 '; }
else {
$deptID =$thisuser->getDeptID(); $sql=' SELECT staff_id,CONCAT_WS(", ",lastname,firstname) as name FROM '.STAFF_TABLE.' WHERE isactive=1 AND onvacation=0 AND dept_id='.$deptID;
}
so it looks like this (area view):
<?
//TODO: make sure the user's group is also active....DO a join.
if($thisuser->isAdmin()) {
$sql=' SELECT staff_id,CONCAT_WS(", ",lastname,firstname) as name FROM '.STAFF_TABLE.' WHERE isactive=1 AND onvacation=0 '; }
else {
$deptID =$thisuser->getDeptID(); $sql=' SELECT staff_id,CONCAT_WS(", ",lastname,firstname) as name FROM '.STAFF_TABLE.' WHERE isactive=1 AND onvacation=0 AND dept_id='.$deptID;
}
$depts= db_query($sql.' ORDER BY lastname,firstname ');
while (list($staffId,$staffName) = db_fetch_row($depts)){
now that will get the display to show username for only those staff in that dept.
if you want to use the firstname lastname then your done here. but if you want to play around with using the username in the drop down box then you can read on... (remember this following code is not perfected but it did work)
here is the code i used for displaying the username in the dropdown instead of the firstname lastname..
$sql=' SELECT staff_id,CONCAT_WS(", ",lastname,firstname) as name FROM '.STAFF_TABLE.
' WHERE isactive=1 AND onvacation=0 ';
if($ticket->isAssigned())
$sql.=' AND staff_id!='.db_input($ticket->getStaffId());
combine the sql above with the code below in each statement or you can just choose to use the where statment i suppose.
if($thisuser->isAdmin())
{
$depts=db_query('SELECT staff_id, username FROM '.STAFF_TABLE);
}
else
{
$deptID =$thisuser->getDeptID();
$depts= db_query('SELECT staff_id, username FROM '.STAFF_TABLE.' WHERE dept_id='.$deptID);
}
as you can see i left the sql from the original setup at the top and did not include it in the if statements, maybe i should have but i dont think it would really be used anyway, the only thing you might want do is maybe include the WHERE statement in the if else, that might help... you are free to play with it and see.
when i tested it, it worked and showed the username not the firstname lastname in the drop down box for staff members in that dept.
i tried to be as clear as i could on this, i know its alittle wordy but i hope its helps someone someday. ps you can do the same for the new ticket php file there is a routine in there to assign ticket also, whichever way you decide to go..
thanks...