<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004-2007 ARMIA INC                                    |
// +----------------------------------------------------------------------+
// | This source file is a part of supportpro supportdesk                 |
// +----------------------------------------------------------------------+
// | Authors: programmer1<programmer1@armia.com>                          |
// |          programmer1<programmer2@armia.com>                          |
// +----------------------------------------------------------------------+
        require_once("./includes/applicationheader.php");
        $conn = getConnection();

       $sql1  = "UPDATE sptbl_staffs  ";
        $sql1 .= " SET vOnline = '0' WHERE nStaffId = '".$_SESSION['sess_staffid']."' ";
        $result1 = executeSelect($sql1,$conn);
   
  
        /*Added by Amaldev for Livechat*/
	    $sqlu  = "UPDATE sptbl_chat SET vStatus = 'finished', dTimeEnd = now() WHERE nStaffId = '".$_SESSION['sess_staffid']."' and vStatus != 'finished' ";
        $resultu = executeSelect($sqlu,$conn);
	    $sqls  = "UPDATE sptbl_operatorchat SET vStatus = 'finished', dTimeEnd=now() WHERE (nFirstStaffId = '".$_SESSION['sess_staffid']."' || nSecondStaffId = '".$_SESSION['sess_staffid']."' ) and vStatus != 'finished' ";
	    $results = executeSelect($sqls,$conn);

        session_destroy();

        header("Location: index.php");
        exit;
?>