<?php
session_start();
?>

<!DOCTYPE html>
<html>
    <head>

       <?php include("header-js.php");?>	

		
<!-----hrm-------------->		
<link rel="stylesheet" href="css/style.css" />
<!-- Responsive -->
<link rel="stylesheet" href="css/responsive.css" />

<!-----hrm-------------->
        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
          <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
        <![endif]-->
    </head>


    <body class="skin-blue"> <?php 
	include("header.php");

?>

                    <!-- Small boxes (Stat box) -->
                    

                    <!-- Main row -->
                    <div class="row">
                    
					<div id="wrapper">



<div class="content">

<div class="report-tab">
<div class="employee-title">
<div class="report-left"><h2>Employee Lists <span></span></h2></div>


<div class="report-category"><!--<a href="employee_list_delete.php" style="font-size:14px; font-weight:bold;line-height:36px;text-align:center;border:1px solid #666;padding:5px 8px;width:auto;margin-left:2px;">Deleted Employee List</a>--></div>
<div class="report-category"><a href="create-person.php" style="font-size:14px; font-weight:bold;line-height:36px;text-align:center;border:1px solid #666;padding:5px 8px;width:auto;margin-left:2px;">ADD Employees</a><!--<img src="images/create-person.png" alt="" width="165" height="36" border="0" />--></div>

<!-- /report-category -->

<div class="clear-float"></div>
</div><!-- /employee-title -->


<div class="clear-float"></div>

<div class="report-cell-02">


<label>
<?php
if($_SESSION['usertype']=='SubadminHR' || $_SESSION['usertype']=='Superadmin')
{

?>

<?php 

	$emp_sel_stat = mysql_query("SELECT * FROM emp_status where (emply_stat='Terminated' || emply_stat='Resigned' || emply_stat='vacation') ");
   // $emp_sel_stat = mysql_fetch_array($emp_sel_stat);	
	while($emp_sel_statss=mysql_fetch_array($emp_sel_stat)){	
	 $em_stat[]=$emp_sel_statss['id'];
	}

 $emp_stats=join(',',$em_stat);

$date = date('Y-m-d');
$sel_bnch = mysql_query("SELECT * FROM branches ");
$sel_emps = mysql_query("SELECT * FROM employee where emp_status not in($emp_stats)");
$sel_depart = mysql_query("SELECT * FROM department ");
?>


<input type="hidden" name="valdhid" id="valdhid" value="1">
<select name="branch" class="BrhLists" id="branch" onChange="getbranch(this);">
<option value="">Branch</option>
<?php while($sel_bnchs=mysql_fetch_array($sel_bnch)){ ?>
<option value="<?php echo $sel_bnchs['branch_id'];?>"><?php echo $sel_bnchs['branch_name'];?></option>
<?php } ?>
</select>

<select name="emp_ids" id="emp_ids" class="emp_list" onChange="getbranch(this);">
<option value="">Emp name</option>
<?php while($sel_empss=mysql_fetch_array($sel_emps)){ ?>
<option value="<?php echo $sel_empss['e_id'];?>"><?php echo $sel_empss['e_fname'];?></option>
<?php } ?>
</select>

<select name="seldpt" id="seldpt" class="chgdept" onChange="getbranch(this);">
<option value="">Select Department</option>
<?php while($sel_departs=mysql_fetch_array($sel_depart)){ ?>
<option value="<?php echo $sel_departs['depart_id'];?>"><?php echo $sel_departs['depart_name'];?></option>
<?php } ?>
</select>

<?php
}

else
{
?><div style="background:#CC0066;width: 160px;height: 27px;padding: 3px 10px;font-size: 16px;color: #fff;font-weight: bold;border-radius: 15px;-webkit-border-radius: 15px;text-align:justify;">
<?php

echo $_SESSION['branch_name'];
?>
</div>
<?php

}
?>

</label>

<div id="tabletabheadlist">

</div>

<div class="clear-float"></div>
</div><!-- /report-cell-02 -->
<?php 
$date = date('Y-m-d');
$y = date('Y',strtotime($date));

//$sel_emp = mysql_query("SELECT * FROM employee e,time t,file f,designation d where e.e_id=t.e_id and t.e_date='$date' and e.e_post=d.desig_id and f.e_id=e.e_id");
$base_url = 'http://www.aadhocc.com/demo/AdminLTE-master/';

		$emp_sel_stat = mysql_query("SELECT * FROM emp_status where (emply_stat='Terminated' || emply_stat='Resigned' || emply_stat='vacation') ");
   // $emp_sel_stat = mysql_fetch_array($emp_sel_stat);	
	while($emp_sel_statss=mysql_fetch_array($emp_sel_stat)){	
	 $em_stat[]=$emp_sel_statss['id'];
	}

 $emp_stats=join(',',$em_stat);

 $levemp_psnt = mysql_query("SELECT distinct t.e_id FROM employee e,time t  where e.e_id=t.e_id and t.e_date='$date'");
  	while($levemp_psnts=mysql_fetch_array($levemp_psnt)){	
	 $em_ids[]=$levemp_psnts['e_id'];
	}
 $em_idss=join(',',$em_ids);

if($em_idss)
{
	if($_SESSION['usertype']=='Superadmin')
	{
 		$levemp = mysql_query("SELECT * FROM employee e,time t,file f,designation d where e.e_id=t.e_id and t.e_date!='$date' and e.e_post=d.desig_id and f.e_id=e.e_id and  e.emp_status not in($emp_stats)  and e.e_id not in($em_idss) GROUP BY t.e_id");
	}
	else
	{
		
		$levemp = mysql_query("SELECT * FROM employee e,time t,file f,designation d where e.e_id=t.e_id and t.e_date!='$date' and e.e_post=d.desig_id and f.e_id=e.e_id and  e.emp_status not in($emp_stats)  and e.branchid=".$_SESSION['branch_id']." and e.e_id not in($em_idss) GROUP BY t.e_id");
	}
 }else
 {
	if($_SESSION['usertype']=='Superadmin')
	{
  		$levemp = mysql_query("SELECT * FROM employee e,time t,file f,designation d where e.e_id=t.e_id and t.e_date!='$date' and e.e_post=d.desig_id and f.e_id=e.e_id and  e.emp_status not in($emp_stats) GROUP BY t.e_id");
	}
	else
	{
		$levemp = mysql_query("SELECT * FROM employee e,time t,file f,designation d where e.e_id=t.e_id and t.e_date!='$date' and e.e_post=d.desig_id and f.e_id=e.e_id  and e.branchid=".$_SESSION['branch_id']." and  e.emp_status not in($emp_stats) GROUP BY t.e_id");
	}
 }
 $levemps = mysql_num_rows($levemp);


 
?>



<div id="tablelist">
<?php while($sel_emps=mysql_fetch_array($levemp)){ 

 $levemp_psnt = mysql_query("SELECT distinct t.e_id FROM employee e,time t  where e.e_id=t.e_id and t.e_date='$date'");
 $levemp_psnt = mysql_num_rows($levemp_psnt);
?>



<div class="employee-cell">
<?php /*?><div class="clocked-in">
<span class="clocked-status" style="width:1px"> <input type="button" name="btn" class="btn_<?php echo $sel_emps['e_id'];?> button-color-logout" id="'+bt_id+'" nums="'+num+'" value="Clocked In" style="width:80px"  /><input type="hidden" name="txt"  class="txt_'+employeeslist.e_id+'" id="txt_id" value="'+employeeslist.clock_status+'"/></span>
<a href="timesheet-individual.html?employees='+employeeslist.e_id+'"><span class="clocked-time" data-times="'+emp_in+'" id="e_time'+num+'" ><?php echo $sel_emps['time_in'];?></span></a>
</div><?php */?>
 <div class="employee-foto"><a href="profile-view.php?employ_id=<?php echo $sel_emps['e_id'];?>"><img src="<?php echo $base_url;?>upload/image/<?php echo $sel_emps['photo'];?>" alt="" border="0" width="170" height="172" /></a></div>
 <div class="employee-designation"><?php echo $sel_emps['desig_name'];?></div>
 <a class="findurl" href="profile-view.php?employ_id=<?php echo $sel_emps['e_id'];?>" data-link="'+ employeeslist.e_id + '" id="emps_id'+num+'"><h2 style="font-size:15px; font-weight:bold;"><?php echo $sel_emps['e_fname'];?></h2></a>
 <h3 title="'+e_mailtitle+'"><?php echo $sel_emps['e_mail'];?></h3>
<div style="float:left"><h4>Emp Code:<?php echo $sel_emps['employee_id'];?></h4></div>
<div class="timesheet-nav"><a href="timesheet-individual.php?employees=<?php echo $sel_emps['e_id'];?>"><translate>Timesheet</translate></a></div>

</div><!-------employee-cell------->
<?php } ?>
</div><!------------tablelist------------>




<div class="clear-float"></div>
</div><!-- /report-tab -->

<div class="clear-float"></div>
</div><!-- /content -->
<div id="busy">Loading...</div>
<div class="footer">
<strong>© add-HRM</strong><br />
<span>Developed by <a href="http://www.aadhocc.com" target="_blank">Aadhocc</a></span></div>
<!-- /footer -->

</div>
					
					
                    </div><!-- /.row (main row) -->

                </section><!-- /.content -->
            </aside><!-- /.right-side -->
        </div><!-- ./wrapper -->

        <!-- add new calendar event modal -->



                     <?php 
	include("footer-js.php");
?>

		
		<!--------------scripts for employee list-------------->
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.min.js"></script>

<!--<script src="js/common.js"></script>
<script src="js/employee.js"></script>-->
<script language="javascript" src="js/css3-mediaqueries.js" type="text/javascript"></script>
<script src="js/employee_sg.js"></script>
	<!--------------scripts for employee list-------------->
	<script type="text/javascript">
	function getbranch(obj)
	{
	bnchs=$('#branch').val();
	emps=$('#emp_ids').val();
	depts=$('#seldpt').val();
	$('#tablelist').load("load_leave_employee.php?bnch="+bnchs+"&dept="+depts+"&emp="+emps);
	}
	</script>
	
    </body>
</html>