Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

[MOD] Select only department which staff have access to, otherwise select staff default department.

Hello, I wanted to share some of my changes I have made to "customise" osTicket to my needs, thus I thought it would be nice to share the code with other people who might need this kind of functionality too.

For: osTicket 1.10

I had issue where I wanted to slightly change osTicket functionality of what staff could do when creating a new ticket, I did not like Help Topics idea too much, thus I made slight change of code, basically here are the changes:
  1. Staff can only select departments which they have access to (Extended Access)
  2. If staff does not select any department, don't default to osTicket system default department, but select agents own department.
Edit /yourosticketpath/include/staff/, find line <?php echo __('Department'); ?> and change the code from <tr> to </tr>.

            <td width="160">
                <?php echo __('Department'); ?>:
                <select name="deptId">
                    if($depts=Dept::getDepartments(array('dept_id' => $myDepts=$thisstaff->getDepts()))) {
                        foreach($depts as $id =>$name) {
                            if (!($role = $thisstaff->getRole($id))
                                || !$role->hasPerm(Ticket::PERM_CREATE)
                            ) {
                                // No access to create tickets in this dept
                                if ( in_array($id,$myDepts) ) {
                            echo sprintf('<option value="%d" %s>%s</option>',
                                    $id, ($mydepartment==$id)?'selected="selected"':'',$name);
                &nbsp;<font class="error"><?php echo $errors['deptId']; ?></font>

Please do note that this code may have been written better, but cause of my limited PHP skills it is what it is :)
Sign In or Register to comment.