Howdy, Stranger!

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

In this Discussion

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

Add Department to Agent's Name

In our multiple-department osTicket deployment, in order to facilitate assignment of tickets to agents, it is helpful to immediately know which department an agent belongs to without having to view the agent's profile.  Therefore, we decided to prepend the department name to each agent's name throughout the system.

With this as a guide, we have done the following:

1) Modified the getName function in the Staff class in include/class.staff.php
    function getName() {
        return new AgentsName(array('dept' => $this->dept, 'first' => $this->ht['firstname'], 'last' => $this->ht['lastname']));
    }

2) Modifed the nsort static function in the Staff class in include/class.staff.php
    static function nsort(QuerySet $qs, $path='', $format=null) {
        global $cfg;

        $format = $format ?: $cfg->getAgentNameFormat();
        switch ($format) {
        case 'last':
        case 'lastfirst':
        case 'legal':
            $qs->order_by("{$path}lastname", "{$path}firstname");
            break;
        case 'deptfull':
            $qs->order_by("{$path}dept", "{$path}firstname", "{$path}lastname");
            break;
        default:
            $qs->order_by("${path}firstname", "${path}lastname");
        }

        return $qs;
    }

3) Add one entry to the static $formats array in the PersonsName class of include/class.user.php (line 651)
    static $formats = array(
        'first' => array(     /*@trans*/ "First", 'getFirst'),
        'last' => array(      /*@trans*/ "Last", 'getLast'),
        'full' => array(      /*@trans*/ "First Last", 'getFull'),
        'legal' => array(     /*@trans*/ "First M. Last", 'getLegal'),
        'lastfirst' => array( /*@trans*/ "Last, First", 'getLastFirst'),
        'formal' => array(    /*@trans*/ "Mr. Last", 'getFormal'),
        'short' => array(     /*@trans*/ "First L.", 'getShort'),
        'shortformal' => array(/*@trans*/ "F. Last", 'getShortFormal'),
        'complete' => array(  /*@trans*/ "Mr. First M. Last Sr.", 'getComplete'),
        'deptfull' => array(  /*@trans*/ "Dept - First Last", 'getDeptFull'),
        'original' => array(  /*@trans*/ '-- As Entered --', 'getOriginal'),
    );

to be continued..

Comments

  • 4) Define the getDeptFull function in the PersonsName class of include/class.user.php
        function getDeptFull() {
            $name = $this->parts['dept'].' - '.$this->parts['first'].' '.$this->parts['last'];
            if ($this->parts['suffix'])
                $name .= ', '.$this->parts['suffix'];
            return $name;
        }

    The results so far is good, the Agent's name is prepended with the department's name in the following pages:
    1) Agent's Directory
    2) Mentions of agent's name in individual tickets
    3) Agent's list in dropdown list when assigning tickets.

    However, the department is not displayed in the "Assigned To" column of the main tickets page. Only the dash '-' is displayed.

    My questions:

    1) Can anyone point us in the right direction to display the department name in front of the agent's name on the main tickets page?
    2) When modifying the getName function, why did 'dept' => $this->dept work, while'dept' => $this->ht['dept']  did not? What is the meaning of the ht[]?

    Thank you in advance for your time.
  • Screenshots:
    1) Agent Directory

    image

    2) Inside individual tickets

    image

    3) Dropdown menus


    image

    4) Not Working: Main tickets page


    image
    01 - AgentDirectory.PNG
    322 x 556 - 20K
    02 - Ticket.PNG
    719 x 89 - 8K
    03 - dropdown.png
    521 x 461 - 32K
    04 - NotWorking.PNG
    363 x 470 - 19K
  • Please help us to help you by reading and following the posting guidelines located in this thread: Please read before requesting assistance.  The more information you give us the better we will be able to assist you. Thank you.

Sign In or Register to comment.