<script src="js/AdminLTE/app.js" type="text/javascript"></script>
        <script src="js/AdminLTE/app.js" type="text/javascript"></script>
		        <link href="css/AdminLTE.css" rel="stylesheet" type="text/css" />

<?php
@session_start();
    if(isset($_SESSION['username'])){
		$user=$_SESSION['username'];
		$userdept=$_SESSION['depart_id'];
		$userid=$_SESSION['admin_id'];
		$branch_id=$_SESSION['branch_id'];
	}else{
		?>
		<script>
			window.location = "index.php";
		</script>
		<?php
	}

	include_once("class/class.MySQL.php");
	$db	=new MySQL();
	$companyDetails = $db->Select('addhrm_company_master');
	$base_url = DOC_ROOT;
	$rowsg = mysql_query("SELECT e_post,e_id,departid FROM employee where e_id='$userid'");
    $rowsg = mysql_fetch_array($rowsg);
	$desigs = mysql_query("SELECT * FROM designation where desig_id='$rowsg[e_post]' and departs_id='$rowsg[departid]'");
    $desigs = mysql_fetch_array($desigs);
	$dateq = date('Y-m-d');
	$clockins = mysql_query("SELECT * FROM time t,employee e where t.e_id='$userid' and t.e_date='$dateq' and e.e_id=t.e_id  order by id desc");
    $clockins = mysql_fetch_array($clockins);
?>
<input type="hidden" name="userid" class="userid" value="<?=$userid?>"  />
<input type="hidden" name="depart_id" class="depart_id" value="<?=$userdept?>"  />
<input type="hidden" name="user_name" class="user_name" value="<?=$user?>"  />
<input type="hidden" name="sessionbranch_id" class="sessionbranch_id" value="<?=$branch_id?>"  />
<input type="hidden" name="hiddenuser_type" id="hiddenuser_type" class="hiddenuser_type" value="<?php echo $_SESSION['usertype'];?>" />
<?php
	$db	=new MySQL();
	if($_SESSION['usertype']=='Superadmin')
	{
		$menu_list=$db->fetchQuery("SELECT * FROM menu where  sort_order!=0 order by sort_order");
	}
	elseif($_SESSION['branchadmin'] == 'Y')
	{
		$menu_list=$db->fetchQuery("SELECT * FROM menu where  sort_order!=0 order by sort_order");
	}
	else
	{
		$menu_list=$db->fetchQuery("SELECT * FROM menu where menu_id in(".$desigs['desig_rights'].") and sort_order!=0 order by sort_order");
	}
	$userdetailss = $db->fetchQuery("SELECT * FROM file where e_id='$userid'");
	$imgs=$userdetailss[0]['photo'];?>	
	<header class="header">
		<?php 
		if( $_SESSION['usertype']=='Superadmin'){ 
			?>
            <a href="../home.php" class="logo"><img src="images/mc_logo.png" width="150"></a>
			<?php 
		} 
		else {
			?>
			<a href="profile-view.php?employ_id=<?php echo $userid;?>" class="logo"><img src="images/mc_logo.png" width="150"></a>
			<?php 
		} ?>
			
		<nav class="navbar navbar-static-top" role="navigation">
	        <a href="#" class="navbar-btn sidebar-toggle" data-toggle="offcanvas" role="button">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </a>
			<div class="navbar-right">
				<ul class="nav navbar-nav">
                	<li class="dropdown user user-menu">
						<a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        	<i class="glyphicon glyphicon-user"></i>
                            <span><?=$_SESSION['username'];?> <i class="caret"></i></span>
                        </a>
                        <ul class="dropdown-menu">
							<li class="user-header bg-light-blue">
								<?php 
								if( $_SESSION['usertype']=='Superadmin'){ 
									?>
  									<img src="upload/thumb/<?php echo $companyDetails['company_logo']; ?>" class="img-circle" alt="User Image" />
									<?php 
								} else {
									?>
            						<img src="<?php if($imgs==''){?>img/avatar3.png<?php }else {?>upload/image/<?php echo $imgs;?><?php } ?>" class="img-circle" alt="User Image" />
									<?php 
								} ?>
								<p><?=$_SESSION['username'];?><small></small></p>
							</li>
                            <li class="user-footer">
                            	<div class="pull-left">
									<?php 
									if( $_SESSION['usertype']!='Superadmin'){ 
										?>
                                        <a href="profile-view.php?employ_id=<?php echo $userid;?>" class="btn btn-default btn-flat" style="color:#3c8dbc;"><translate>Profile</translate></a>
										<?php 
									} 
									?>
								</div>
                                <div class="pull-right"><a href="logout.php" class="btn btn-default btn-flat" style="color:#3c8dbc;"><translate>Sign out</translate></a></div>
							</li>
						</ul>
					</li>
				</ul>
			</div>
        </nav>
	</header>
	<div class="wrapper row-offcanvas row-offcanvas-left">
		<aside class="left-side sidebar-offcanvas">
        	<section class="sidebar">
            	<div class="user-panel">
               		<div class="pull-left image">
						<?php 
						if( $_SESSION['usertype']=='Superadmin'){ ?>
  							<img src="upload/thumb/<?php echo $companyDetails['company_logo']; ?>" class="img-circle" alt="User Image" />
							<?php 
						} 
						else { ?>
            				<img src="<?php if($imgs==''){?>img/avatar3.png<?php } else {?>upload/image/<?php echo $imgs;?><?php } ?>" class="img-circle" alt="User Image" />
							<?php 
						} 
						?>
					</div>
					<div class="pull-left info">
						<translate><p>Hello, <?php echo $_SESSION['username'];?></p></translate>
						<a href="#"><i class="fa fa-circle text-success"></i> <translate>Online</translate></a>
					</div>
				</div>
				<?php 
					if($clockins['time_in']=='' && $clockins['time_out']=='') {
						?>
						<div class="clockedin-admin-tab rrr">
							<div class="clockedin-admin-click" >
								<div class="timein-time"> </div>
								<input type="button"  onClick="clock('<?php echo $userid;?>',1);" value="Sign In" class="clockin-button">
							</div>
						</div>
						<?php 
					}
					else if($clockins['time_in']!='' && $clockins['time_out']!='') 
					{
						?>
						<div class="clockedin-admin-tab rrr">
							<?php 
							if($clockins['login_stat']==0){
								?>
								<div class="clockedin-admin-click">
									<div style="text-align:center;">You have <?php if($clockins['time_out'] !=''){echo 'Signed Out';}?></strong> @ <?php echo $clockins['time_out'].' '.$clockins['time_outloc'];?></div>

									<div class="timein-time" ></div>
									<input type="button"  onClick="clock('<?php echo $userid;?>',1);" value="Sign In" class="clockin-button">
								</div>
								<?php 
							} 
							else {
								?>
								<div class="clockedin-admin-click rrr">
									<div style="text-align:center;">You have <?php if($clockins['time_out'] !=''){echo 'Signed Out';}?></strong> @ <?php echo $clockins['time_out'].' '.$clockins['time_outloc'];?></div>
									<div class="timein-time" ></div>
									<input type="button"  onClick="clock('<?php echo $userid;?>',2);" value="Sign In" class="clockin-button">
								</div>
								<?php 
							}
							?>
						</div>
						<?php 
					}
					else {
						?>
						<div class="clockedin-admin-tab rrr">
							<div class="clockedin-admin-click">
								<div style="text-align:center;">You have <?php if($clockins['time_in'] !=''){echo 'Signed In';}?></strong> @ <?php echo $clockins['time_in'].' '.$clockins['time_inloc'];?></div>
								<div class="timein-time" ></div>
								<input type="button"  onClick="clock('<?php echo $userid;?>',2);" value="Sign Out" class="clockin-button">
							</div>
						</div>
						<?php 
					} 
					?>

                    <ul class="sidebar-menu">
                  		<?php 
						if($_SESSION['usertype'] == 'Superadmin')
						{
							?>
                        	<li class="active">
                            	<a href="dashboard.php">
                                	<i class="fa fa-dashboard"></i> <span><translate>Dashboard</translate></span>
                            	</a>
                       		</li>
							<?php 
						}
						elseif($_SESSION['branchadmin'] == 'Y')
						{
							?>
                        	<li class="active">
                            	<a href="dashboard-branch.php">
                                	<i class="fa fa-dashboard"></i> <span><translate>Dashboard</translate></span>
                            	</a>
                       		</li>
							<?php 
						}
						?>
						<?php 
						$i=2;
						foreach($menu_list as $menu_items)
						{
							if(($_SESSION['usertype'] == 'Superadmin' || $_SESSION['branchadmin'] == 'Y') && $menu_items['menu_link']=='add_project.php'){
								$act_done=$menu_items['menu_link'];
							} 
							else {
								$act_done='activities_done.php';
							}
							if(($_SESSION['usertype'] == 'Superadmin' || $_SESSION['branchadmin'] == 'Y') && $menu_items['menu_link']=='add_project.php'){
								?>
                        		<li>
                            		<a href="<?php echo $act_done;?>">
                                		<i class="fa fa-th"></i> <span><translate><?php echo $menu_items['menu_name'];?></translate></span> 
                            		</a>
                        		</li>
								<?php 
							} else {
								?>
							    <li>
                            		<a href="<?php echo $menu_items['menu_link'];?>">
                                		<i class="fa fa-th"></i> <span><translate><?php echo $menu_items['menu_name'];?></translate></span> 
                            		</a>
                        		</li>
								<?php 
							} 
						} 
						?>
						<li class="treeview"> <a href="#"> <i class="fa fa-folder"></i> Statutories <i class="fa fa-angle-left pull-right"></i> </a>
						  <ul class="treeview-menu">
							<!--<li class="treeview"> <a href="#"> Provident Fund <i class="fa fa-angle-left pull-right"></i> </a>
							  <ul class="treeview-menu">
								<li class="treeview"> <a href="#"> Monthly <i class="fa fa-angle-left pull-right"></i> </a>
								  <ul class="treeview-menu">
									<li> <a href="pf-forms.php?frm=5">Form 5</a> </li>
									<li> <a href="pf-forms.php?frm=10">Form 10</a> </li>-->
									<!--<li> <a href="pf-forms.php?frm=12a">Form 12A</a> </li>-->
									<!--<li> <a href="pf-forms.php?frm=mst">Monthly Statement</a> </li>
								  </ul>
								</li>-->
								<!-- /.third level-->
								<!--<li class="treeview"> <a href="#"> Yearly <i class="fa fa-angle-left pull-right"></i> </a>
								  <ul class="treeview-menu">
									<li> <a href="pf-forms.php?frm=3a">Form 3A</a> </li>
									<li> <a href="pf-forms.php?frm=6a">Form 6A</a> </li>-->
									<!--<li> <a href="pf-forms.php?frm=ert">E-Return</a> </li>-->
								  <!--</ul>
								</li>-->
								<!-- /.third level-->
							  <!--</ul>
							</li>-->
							<!-- /.second level-->
							<!--<li class="treeview"> <a href="#"> Employee State Insurance <i class="fa fa-angle-left pull-right"></i> </a>
							  <ul class="treeview-menu">-->
								<!--<li class="treeview"> <a href="#"> Monthly <i class="fa fa-angle-left pull-right"></i> </a>
								  <ul class="treeview-menu">
									<li> <a href="esi-forms.php?frm=3">ESI Form 3</a> </li>
									<li> <a href="esi-forms.php?frm=mst">Monthly Statement</a> </li>
									<li> <a href="esi-forms.php?frm=ert">E-Return</a> </li>
								  </ul>
								</li>-->
								<!-- /.third level-->
								<!--<li class="treeview"> <a href="#"> Yearly <i class="fa fa-angle-left pull-right"></i> </a>
								  <ul class="treeview-menu">-->
									<!--<li> <a href="esi-forms.php?frm=5">Form 5</a> </li>-->
									<!--<li> <a href="esi-forms.php?frm=6">Form 6</a> </li>
									<li> <a href="esi-forms.php?frm=6">Accident Register</a> </li>
								  </ul>
								</li>-->
								<!-- /.third level-->
							  <!--</ul>
							</li>
							<li class="treeview"> <a href="#">Professional Tax</a> <i class="fa fa-angle-left pull-right"></i>
							  <ul class="treeview-menu">-->
								<!--<li> <a href="tax-report.php?frm=rpt">Computation Report</a> </li>
								<li> <a href="tax-report.php?frm=stmnt">Statement</a> </li>-->
								<!--<li> <a href="tax-report.php?frm=5a">Form 5A</a> </li>
							  </ul>
							</li>-->
							<!-- /.third level-->
							<!--<li class="treeview"> <a href="#"> National Pension Scheme <i class="fa fa-angle-left pull-right"></i> </a>
							  <ul class="treeview-menu">
								<li class="treeview"> <a href="#"> Subscriber Contribution Details </a> </li>
								<li> <a href="#"> NPS Summary</a> </li>
								<li> <a href="#"> PRAN Not Available</a> </li>
							  </ul>
							</li>
							<li class="treeview"> <a href="#"> Gratuity </a> </li>
							<li class="treeview"> <a href="#"> Income Tax <i class="fa fa-angle-left pull-right"></i> </a>
							  <ul class="treeview-menu">
								<li class="treeview"> <a href="#"> Computation </a> </li>
								<li> <a href="#">Salary Projection</a> </li>
								<li> <a href="incometax-report.php?frm=chn">Challan Reconciliation</a> </li>
								<li> <a href="incometax-report.php?frm=rtn">Returns</a> </li>
								<li> <a href="incometax-report.php?frm=ert">E-Return</a> </li>
								<li> <a href="#">Exception Reports</a> </li>
							  </ul>
							</li>-->
							<li> <a href="muster-roll.php"> Muster Roll </a> </li>
							<li> <a href="register-wages.php"> Wage Register </a> </li>
						  </ul>
						</li>
						
						<!--<li>
						
						   <a href="income_tax_statement.php">
                                <i class="fa fa-th"></i> <span><translate>Income Tax Statement</translate></span>
                            </a>
                        </li>
                        <li>
                            <a href="income_tax_declarations.php">
                                <i class="fa fa-th"></i> <span><translate>Income Tax Declaration</translate></span>
                            </a>
                        </li>-->
                       
                        <li>
                            <a href="calendar.php">
                                <i class="fa fa-calendar"></i> <span><translate>Calendar</translate></span>
                               <?php /*?> <small class="badge pull-right bg-red">3</small><?php */?>
                            </a>
                        </li>
                    </ul>
			</section>
		</aside>
		<aside class="right-side">
			<section class="content-header"> </section>
            <section class="content">
			
<script>
var userid = <?php echo $_SESSION['admin_id']; ?>;
<?php $userdetails = $db->fetchQuery("SELECT * FROM file where e_id='$userid'"); ?>
var userimage = "<?php echo $userdetails[0]['photo']; ?>";
</script>			
<link href="css/chat.css" rel="stylesheet" type="text/css" />
<script src="js/chat.js" type="text/javascript"></script>


<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment.min.js" type="text/javascript"></script>
<script type="text/javascript">

setClock();
var ClockSecond=0;
function setClock(){
	$('.timein-time').text(moment().format("hh.mm A"));
	setTimeout(function(){ $('.timein-time').text(moment().format("hh:mm A")); },100);
	setTimeout(setClock,1000);
}


function clock(eid,i)
{

if(i==1){
	c= confirm("You will Sign in @ "+moment().format("h:mm a"));
}else{
	c= confirm("You will Sign out @ "+moment().format("h:mm a"));
}

if(c==true){

if(i==1)
{

$(".clockedin-admin-click").hide();
$(".clockedin-admin-click-over").show();
}
if(i==2)
{

$(".clockedin-admin-click").show();
$(".clockedin-admin-click-over").hide();
}
			   $.ajax({
							type: "POST",
							url: "clockin.php",
							data: "rel_ID="+i,
							cache: false,
							beforeSend: function()
							{
						
							$(".clockedin-admin-click").html('Loading..');
							
							},
							success: function(data)
							{ if(i==2 || i==1){
								$(".rrr").html(data);}
							}
	 	 });
	}	 
}
</script>