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

Support Staff OnLine List

When you are logged into the Staff Panel it would be very handy if you could see a list of other staff members currently logged in.

That way I would know if I was the only one covering tickets at the moment.

Comments

  • Online Staff

    Dear Larry Levesque,

    I had the same requirement and I have successfully developed a piece of code for it.

    please follow the below steps in order to have this feature in your system.

    1. create the following table in your mysql table(with your respected table prefix)

    create table ost_staff_online (staff varchar(20),isonline int default 0,logged_at datetime,logged_from varchar(50));

    And then insert all your staff usernames and 0's and leave other fields blank.
    e.g insert into ost_staff_online values('bonapart',0,null,null,null);

    2. edit scp scp/login.php as follow
    fine line "if($user=Staff::login($_POST['username'],$_POST['passwd'],$errors))){
    and then write this code
    $user=$_POST['username'];
    $address=gethostbyaddr($_SERVER['REMOTE_ADDR']);
    $update_online=mysql_query("update ost_staff_online set isonline=1,logged_at=now(),logged_from='$address' where staff='$user'");

    2. create a new .php file in scp directory and call it as online_staff.php
    write the following code in it:
    require('staff.inc.php');
    $page='online_staff.inc.php';
    $nav->setTabActive('online_staff');
    require(STAFFINC_DIR.'header.inc.php');
    require(STAFFINC_DIR.$page);
    include(STAFFINC_DIR.'footer.inc.php');

    3. create new file online_staff.inc.php in include\staff directory
    and write the following code.

    Online Staff


    The following tables show the list of staff and their status







    <?php csrf_token(); ?>















    <?php
    $staff_query=mysql_query("select * from ost_staff_online order by isonline") or die ("Error while retrieving list of online staff".mysql_error());

    while ($row = mysql_fetch_array($staff_query)) {

    ?>
    ">









    <?php
    } //end of while.
    ?>

    <?php $staff_cnt_query=mysql_query("select count(staff) as staff_cnt from prefix_staff_online where isonline=1") or die("error while counting staff".mysql_error());
    while($os=mysql_fetch_array($staff_cnt_query))
    echo "Online Staff - ".$os['staff_cnt'];?>
    Staff Username Is Online Login At Login from

    <?php
    echo $row['staff'].'  ';
    if($row['isonline']==1)
    echo "<img src='../scp/images/icons/ok.png'>";
    else
    echo "image";
    ?>


    <?php
    $state=$row['isonline'];
    if($state==1)
    echo "Yes";
    else
    echo "No";
    ?>

    <?php echo $row['logged_at'];?> <?php echo $row['logged_from'];?>
    4. Edit Logout.php which resides in scp directory
    write the following code after sprintf("%s logged out [%s]",$thisstaff->getUserName(), $_SERVER['REMOTE_ADDR']));

    $address=gethostbyaddr($_SERVER['REMOTE_ADDR']);
    mysql_query("update ost_staff_onliine set isonline=0 where logged_from='$address'");

    5. the final step is to add the menu item by editing include\class.nav.php
    add the following code after $this->tabs[kbase']=array('desc'=>'Knowledgebase', 'href'=>'kb.php','title'=>Knowledgebase');

    $this->tabls['online_staff']=array('desc'=>'Online Staff','href'=>'online_staff.php','title'=>'online staff');


    Enjoy.
  • Excellent!!

    Thank you for the information.

    I just have one question:

    Could you be more specific about your procedure on #2?

    Where exactly in the file does the code go?

    You say first line, really before the php directive?

    And where does the rest of it in #2 go?

    Everything else is very clear.
  • Just create the file and name it as I have written in step #2 and then in that file write:

    <?php
    require('staff.inc.php');
    $page='online_staff.inc.php';
    $nav->setTabActive('online_staff');
    require(STAFFINC_DIR.'header.inc.php');
    require(STAFFINC_DIR.$page);
    include(STAFFINC_DIR.'footer.inc.php');
    ?>


    And that's it....
    Need more help, do post and ask...

    Bonapart....
  • Thank you. I managed to get it working with a little bit of tweaking of the code.
  • cool...........
Sign In or Register to comment.