Assign Staff from Ticket List in osTicket v1.6 RC5

One of the nice MODs on osTicket Discussion Forum is [ADD ON] Assign user from ticket list. This MOD will make you easier to assign the tickets simply from the ticket list page, and only admin and manager are able to do this task. Besides that, each time a ticket assigned to a staff, that staff will get an alert via email. Since there were two members on the forum asking the question whether this MOD working on v1.6 RC5, then I tried to implement it on that version, and everything worked fine. So this modification is for you.

  1. Open your \include\staff\tickets.inc.php file, and then at the first line in that file above, add this following code:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    
    <script type="text/javascript">
    function changeAssignee(ticketID)
    {
    	var obj = "staff_select"+ticketID;
    	var sel = document.getElementById(obj);
    	var assignee = sel.options[sel.selectedIndex].value;
     
    	var url = "index.php?update=staff&staffid="+assignee+"&ticket_id="+ticketID;
     
    	window.location.href = url;
    }
    </script>

    Find this code:

    14
    15
    16
    
    if(!defined('OSTSCPINC') || !@$thisuser->isStaff()) die('Access Denied');
     
    //Get ready for some deep shit..(I admit..this could be done better...but the shit just works... so shutup for now).

    after the last line of that code, please insert this following code:

    17
    18
    19
    20
    21
    22
    23
    24
    25
    
    // assign the user from the drop down list if one has been selected
    if(isset($_GET['update']) && $_GET['update'] == "staff")
    {
        $thisStaff = $_GET['staffid'];
        $ticketToUpdate = $_GET['ticket_id'];
        $tt = new Ticket($ticketToUpdate);
        $staffMessage = "You have been assigned a ticket.";
        $tt->assignStaff($thisStaff,$staffMessage);
    }

    Find this code:

    405
    406
    
                <th width="180" >From</th>
            </tr>

    then replace with this following code:

    405
    406
    407
    408
    409
    
                <th width="180" >From</th>
                <?php if($thisuser->isadmin() || $thisuser->isManager()){ ?> 
                <th width="180" >Assign...</th>
                <?php } ?>
            </tr>

    Find again this code:

    445
    446
    
                    <td nowrap><?=Format::truncate($row['name'],22,strpos($row['name'],'@'))?>&nbsp;</td>
                </tr>

    then replace with this following code:

    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    
                    <td nowrap><?=Format::truncate($row['name'],22,strpos($row['name'],'@'))?>&nbsp;</td>
                    <?php if($thisuser->isadmin() || $thisuser->isManager()){ ?>
                    <td nowrap>
                      <!-- staff select added by me -->
                      <?php
                      $thisTicket = new Ticket($row['ticket_id']);
                      ?>                    
                      <select id="staff_select<? echo $row['ticket_id'];?>" onchange="changeAssignee(<? echo $row['ticket_id'] ?>);">
                       <option <?if($row['staff_id'] == 0){?>SELECTED<?}?> value="0">Assign...</option>
                       <?php
                         $possibleAssignees = $thisTicket->getPossibleAssignees($row['staff_id']);
                       ?>
                     </select>
                    </td>                
                    <?php } ?>
                </tr>
  2. Open your \include\class.ticket.php file, and find this code:

    1359
    1360
    
    }
    ?>

    then replace with this following code:

    1359
    1360
    1361
    1362
    1363
    1364
    1365
    1366
    1367
    1368
    1369
    1370
    1371
    1372
    1373
    1374
    1375
    1376
    1377
    1378
    1379
    1380
    
      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['staff_id'];
          $name = $row['name'];
     
          if($currentStaffID == $id)
          {
               $option = "<option value=\"".$id."\" SELECTED>".$name."</option>";               
           } else {
               $option = "<option value=\"".$id."\">".$name."</option>";           
                }
     
             echo $option;
          }
      }  
    }
    ?>

Enjoy the result!

Share

1,331 viewsPrint This Post Print This Post

Comments

  1. Big Dummy says:

    Like a big dummy I did not back up my files prior to attempting this MOD. (I do have a back up) but have made a modification for tracking time spent on tickets. Now after following these steps problems will not display in our “staff” area.

    Does anyone have the source files with this MOD in place…if you had one with the time tracking in place that would be even greater! Not sure what I messed up.

  2. Probably you can rollback step by step carefully based on the original or unreplaced or unmodified code above. Remove the modification code, and then replace its area with the original code.

    I usually using this method to revert back to the original or the previous code if I had the problem after implementing such modification. Good luck!

  3. Matthew Reed says:

    I seem to be having problems with the send message on assignment. The ticket is assigned to the user, they’re just not getting an email about it.

    I had assumed that that was a standard feature at first, but I got to toying around with it and noticed it was consistently not notifying folks if they get assigned a ticket… that led me here to this mod.

    I’m sure this could be something dumb I did on setup, but I just can’t seem to find it. Any ideas?

  4. Matthew Reed says:

    @Matthew Reed

    Nevermind, sorry, found my error y’all… I setup all the email acct configs properly, except Alerts. :)

  5. Luis says:

    Is it possible to filter the dropdown based on the user’s department or group?

Speak Your Mind

*


*