<div class="main">

<header>
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <div class="logo_area">
                <?php if($_SESSION['user_role_session']=="Agent" || $_SESSION['user_role_session']=="Admin"){?>    
                <a href="dashboard.php"><h1>7ctech</h1></a>
                <?php } else {
                    echo '<a ><h1>7ctech</h1></a>';
                    
                }?>

        	</div>
            
            <div class="top_welcome">
                <?php echo 'Welcome '.$_SESSION['user_name_session'].' <span>('.$_SESSION['user_role_session'].')</span> ' ?>
                <?php if($_SESSION['user_role_session']=="Admin"){?>
                	<a href="change_password.php" style="line-height: 10px;position: absolute;color: #fff;top: 50px;font-size: 11px;">change password </a>
                <?php } ?>
            </div>
            
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
            </div>
            <div class="collapse navbar-collapse" id="navbar-collapse-1">
                <ul class="nav navbar-nav">
                </ul>
                
               <ul class="nav navbar-nav navbar-right"> 
                   <?php  
                   if($_SESSION['user_role_session']=="Admin"){
                       
                       $onlineUsers = $obj_jobs_class->getAgentsForSidebar();
                   $mytasks = $obj_jobs_class->getNotifications(); ?>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                        <i class="fa fa-globe"></i> <br> Notifications </a>
                        <ul class="dropdown-menu dd-light dd-large dd-msg"> 
                            <li>
                                <ul>
                                    <?php                                    
                                    if(count($mytasks)>0){
                                        $ii=1;
                                        foreach($mytasks as $noti){?>
                                        <li><a href="">
                                                <div class="media">
                                                    <div class="media-body">
                                                        <!--
                                                        <h5 class="media-heading">Media heading</h5>
                                                        <p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula...</p>
                                                        -->
                                                            <p><?php echo $noti['title']; ?></p>
                                                        
                                                        
                                                        <p class="pull-right"> <i> <?php echo $noti['date']; ?> </i></p>
                                                    </div> 
                                                </div>
                                            </a>
                                        </li>
                                    <?php 
                                    
                                    if($ii>5){break;}
                                    $ii++;}
                                        }else {
                                    ?>  
                                          <li><a href="">
                                                <div class="media">
                                                    <div class="media-body">
                                                        <p>No Notifications</p>
                                                    </div> 
                                                </div>
                                            </a>
                                        </li>
                                        <?php } ?>
                                </ul>
                            </li>
                                <?php   if(count($mytasks)>0){?>
                                        <li class="view-all"><a href="notifications.php">See All</a></li>
                                <?php } ?>
                        </ul>
                    </li> 
                   <?php   } ?>
                    
                    
                    <?php if($_SESSION['user_role_session']=="Agent"){?>
                    
                        <li class="dropdown">
                            <a href="task_calender.php"  >
                            <i class="fa fa-calendar"></i> <br> Calendar Task</a>
                        </li>
                        
                        <li>
                            <a href="event_tasks.php"   aria-haspopup="true" aria-expanded="false">
                            <i class="fa fa-pencil-square-o"></i> <br> Exhibition Tasks</a>
                        </li>
                        
                        
                        <li>
                            <a href="my_tasks.php"   aria-haspopup="true" aria-expanded="false">
                            <i class="fa fa-pencil-square-o"></i> <br> My Tasks</a>
                        </li>
                        
                    <?php } ?>
                        
                    <?php if($_SESSION['user_role_session']=="Agent" || $_SESSION['user_role_session']=="Admin" ||  $_SESSION['user_role_session']=="Marketing" ){?>    
                        <li>
                            <a href="event_graph.php">
                            <i class="fa fa-pie-chart"></i> <br> Graphs</a>
                        </li>
                    <?php } ?>
                     
                         <?php  if($_SESSION['user_role_session']=="Admin"){ ?>
                            <li>
                                <a href="logs.php">
                                <i class="fa fa-user"></i><br>User Log </a>
                            </li> 
                        
                         <?php } ?>
                        <li>
                            <a href="logout.php">
                            <i class="fa fa-user"></i><br>Log Out</a>
                        </li> 
                    
                </ul>
                
            </div>
        </div>
    </nav>
     <?php  if($_SESSION['user_role_session']=="Admin"){ ?>
    <nav class="navbar navbar-default side-nav cbp-spmenu cbp-spmenu-vertical cbp-spmenu-right" id="cbp-spmenu-s2">
        <div class="navbar-title">
            <p class="maincategory">Online Members</p>
        </div>
        <ul class="media-list">
            
           <?php  if(count($onlineUsers)>0){ 
               
               /*************************/
               $hours = 1;                  
               foreach($onlineUsers as $onu){
                
                      $LastUpdate =$obj_user_class->getUserLastUpdate($onu['agent_id']);
                     
                    if(!empty($LastUpdate)){
                          $today = date("Y-m-d H:i:s"); 
                        $datetime1 = new DateTime($today);
                        $datetime2 = new DateTime($LastUpdate);
                        $interval = $datetime1->diff($datetime2);
                         
                         $hours =  $interval->format('%h.%i');
                    }
                    
               ?>
            
                    <li class="media">
                        <a href="#" data-toggle-target="#users" data-toggle-class="chat-open">
                            
                            <?php if(!empty($onu['login_status']) && $onu['login_status'] >0 && $hours <= 0.5){?>
                                <i class="fa fa-circle status-online"></i>
                            <?php } else if(!empty($onu['login_status']) && $onu['login_status'] >0 && $hours > 0.5 && $hours < 1){?>
                                <i class="fa fa-circle status-away"></i>
                            <?php } else {?>
                                <i class="fa fa-circle status-offline"></i>
                            <?php } ?>
                                
                            <?php if(!empty($onu['profile_img']) && file_exists("uploads/profile/".$onu['profile_img']) ){?>
                                <img class="media-object" src="uploads/profile/<?= $onu['profile_img'] ?>" alt="...">
                            <?php }else { ?>
                                    <img class="media-object" src="img/user.png" alt="...">
                            <?php } ?>      
                            <div class="media-body">
                                <h4 class="media-heading"><?php echo $onu['name'] ?></h4>
                                <span><?php echo $onu['agent_type'] ?></span>
                            </div>
                        </a>
                    </li>
            
           <?php } } ?>
       
        </ul>
        <button id="showRight">
            <i class="fa fa-angle-double-left"></i>
        </button>
	</nav>
   <?php } ?>
</header>
    
    
<div class="container-fluid content">
    	<nav class="navbar navbar-default side-nav cbp-spmenu cbp-spmenu-vertical cbp-spmenu-left" id="cbp-spmenu-s1">
            <div class="">
                 
                <button id="showLeft">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                <div class="navbar-title">
                    <p class="maincategory">MAIN NAVIGATION</p>
                </div>
                
                 <?php if($_SESSION['user_role_session']== 'Admin' || $_SESSION['user_role_session']== 'Agent'){ ?>   
                <div id="MainMenu">
                	<div class="nav list-group panel">
                            <a href="dashboard.php" class="parent_m"><i class="fa fa-th"></i>&nbsp;Dashborad</a>
                            
                          
                        <a href="#demo3" class="parent_m" data-toggle="collapse" data-parent="#MainMenu"><i class="fa fa-th"></i>&nbsp;Manage Category</a>
                        <div class="collapse sub_m" id="demo3">
                        	<a href="category_controls.php">Create New Category</a>
                         	<a href="categories.php">View Category List</a>
                        </div>
                    	<a href="#demo4" class="parent_m" data-toggle="collapse" data-parent="#MainMenu"><i class="fa fa-th"></i>&nbsp;Manage Exhibition</a>
                    	<div class="collapse sub_m" id="demo4">
                                <a href="event_controls.php">Add New Exhibition</a>
                                <a href="events.php">View All Exhibition</a>
                    	</div>
                         <?php if($_SESSION['user_role_session']== 'Admin'){ ?>    
                     	<a href="#demo5" class="parent_m" data-toggle="collapse" data-parent="#MainMenu"><i class="fa fa-user-secret"></i>&nbsp;Manage Agent</a>
                    	<div class="collapse sub_m" id="demo5">
                     		<a href="agent_controls.php">Add New Agent</a>
                     		<a href="agents.php">View All Agents</a>
                    	</div> 
                         <?php } ?>
                        
                    	<a href="#demo6" class="parent_m" data-toggle="collapse" data-parent="#MainMenu"><i class="fa fa-user"></i>&nbsp;Manage Client</a>
                    	<div class="collapse sub_m" id="demo6">
                     		<a href="client_controls.php">Add New Client</a>
                     		<a href="clients.php">View All Clients</a>
                                
                                <?php if($_SESSION['user_role_session']== 'Admin'){ ?>    
					<a href="client_import.php">Import Clients</a>
                                <?php } ?>
                    	</div>
                        
                  	</div>
                    </div> 
                <?php } ?>   
            </div>
        </nav>
<?php  

if($_SESSION['user_role_session'] != 'Admin'){

        $user_log_id = $_SESSION['user_log_id'];
        $obj_user_class->updateLogin($user_log_id);
}
$obj_jobs_class->checkPermissions();
?>    