<?php
include('../common/db_connection.php');
$Mainclass=new DB_Controller();
$Mainclass->Employee_COOKIE_Check();
$check_attendance=$Mainclass->Num_rows_Check('attendance_master','Attendance_Date',date('Y-m-d'));
if($check_attendance=="")
{
?>
<script>
//window.location.href="attendance.php";
</script>
<?php
}
?>
<!DOCTYPE html>
<html lang="en">

<!-- Mirrored from colorlib.com//polygon/admindek/default/form-validation.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 23 Nov 2019 12:53:49 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8" /><!-- /Added by HTTrack -->
<head>
<title>Attendance History</title>


<!--[if lt IE 10]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
      <![endif]-->

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="Admindek Bootstrap admin template made using Bootstrap 4 and it has huge amount of ready made feature, UI components, pages which completely fulfills any dashboard needs." />
<meta name="keywords" content="bootstrap, bootstrap admin template, admin theme, admin dashboard, dashboard template, admin template, responsive" />
<meta name="author" content="colorlib" />

 <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800" rel="stylesheet"><link href="https://fonts.googleapis.com/css?family=Quicksand:500,700" rel="stylesheet">

<link rel="stylesheet" type="text/css" href="files/bower_components/bootstrap/css/bootstrap.min.css">

<link rel="stylesheet" href="files/assets/pages/waves/css/waves.min.css" type="text/css" media="all">

<link rel="stylesheet" type="text/css" href="files/assets/icon/feather/css/feather.css">

<link rel="stylesheet" type="text/css" href="files/assets/icon/themify-icons/themify-icons.css">

<link rel="stylesheet" type="text/css" href="files/assets/icon/icofont/css/icofont.css">

<link rel="stylesheet" type="text/css" href="files/assets/icon/font-awesome/css/font-awesome.min.css">

<link rel="stylesheet" type="text/css" href="files/assets/css/style.css">
<link rel="stylesheet" type="text/css" href="files/assets/css/pages.css">

<script language="javascript">
//==========for clock ===============//
function startTime()
{
 
  var date=new Date();
  var p=date.toLocaleTimeString();
  //alert(p);
  document.getElementById("clock").innerHTML=p;
  setTimeout(function(){startTime()},500);
}
//==========for clock ===============//
</script>




 <style type="text/css">
#tooltip
{
text-align: center;
color: #fff;
background: #111;
position: absolute;
z-index: 100;
padding: 5px 10px;
font-size:10px !important;
line-height:12px !important;
}

#tooltip:after /* triangle decoration */
{
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-top: 10px solid #111;
content: '';
position: absolute;
left: 50%;
bottom: -10px;
margin-left: -10px;
}

#tooltip.top:after
{
border-top-color: transparent;
border-bottom: 10px solid #111;
top: -20px;
bottom: auto;
}

#tooltip.left:after
{
left: 10px;
margin: 0;
}

#tooltip.right:after
{
right: 10px;
left: auto;
margin: 0;
}

.message_maindiv{
float:left;
height:auto;
padding:15px;
background-color:#fff8e6;
text-align:left;
font-size:12px;
color:#503a27;
}

.time_border{
 border-right:1px solid #263544;
}

.table>thead>tr>th {
       border-bottom-color: #CCC; border-left-color: #CCC;
}


@media only screen and (max-width:480px){
.time_border{
 border-right:0px solid #0066FF;
}
}



</style>
        
<script>
function isNumberKey(evt) 
{
	var charCode = (evt.which) ? evt.which : event.keyCode; 
	if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) 
	{
		return false;
	} 
	else 
	{
		return true;
	} 
} 

</script> 
       
 <script>
function page_submit()
{
	var pan=$("#pan").val();
	
	var Error=0;
	if(pan=='')
	{
		$("#pan").css('border-bottom','1px solid red');
		Error=1;
	}
	if(pan!='')
	{
		$("#pan").css('border-bottom','1px solid #ccc');
	}
	if(Error==1)
	{
		return false;
	}
	if(Error==0)
	{
		$("#main").submit();
	}
}
</script>   
</head>
<body>



<div id="pcoded" class="pcoded">
<div class="pcoded-overlay-box"></div>
<div class="pcoded-container navbar-wrapper">

<?php include('register-top-header.php'); ?>





<div class="pcoded-main-container">
<div class="pcoded-wrapper">

<?php include('register-side-menu.php'); ?>



<div class="pcoded-content">

<div class="page-header card">
<div class="row align-items-end">
<div class="col-lg-8">
<div class="page-header-title">

<div class="d-inline">
<h5 style="text-transform:uppercase; font-size:25px; font-weight:600;">Attendance History</h5>

</div>
</div>
</div>

</div>
</div>

<div class="pcoded-inner-content">
<div class="main-body">
<div class="page-wrapper">

<div class="page-body">
<div class="row">
<div class="col-sm-12">

<div class="card">

<div class="card-block">



<div class="row">
<?php
$condition="'".$_COOKIE['Payroll_Emp_Attendance']."'";
if($_POST['month']!="")
{
	$condition.=" AND MONTH(Attendance_Date) = '".$_POST['month']."'";
}
if($_POST['year']!="")
{
	$condition.=" AND YEAR(Attendance_Date) = '".$_POST['year']."'";
}
$ALL_attendances=$Mainclass->Fetch_All_datas("attendance_master","Emp_Temp_Id",$condition,"","","Attendance_Date");
?>
<form method="post">
<div class="col-sm-12" style="margin-bottom:20px;">
<div class="row">

<div class="col-sm-4"><div class="form-group row">

<div class="col-sm-12">
<select name="month" id="month" class="form-control fill">
<option value="">Select Month</option>
<?php
for($i=date('m')+1;$i<=date('m')+12;$i++)
{
if($i<=12)
{
$j=$i;
}
if($i>12)
{
$j=$i-12;
}
?>
<option value="<?php echo $j;?>" <?php if($_POST['month']==$j){ echo 'selected';}?>><?php echo date("F", mktime(0,0,0,$j,10));?></option>
<?php
}
?>
</select>

</div>
</div></div>

<div class="col-sm-4"><div class="form-group row">

<div class="col-sm-12">
<select name="year" id="year" class="form-control fill">
<option value="">Select Year</option>
<?php
for($i=date('Y')-1;$i<=date('Y')+2;$i++)
{
?>
<option value="<?php echo $i;?>" <?php if($_POST['year']==$i){ echo 'selected';}?>><?php echo $i;?></option>
<?php
}
?>
</select>

</div>
</div></div>

<div class="col-sm-4"><div class="form-group row">

<div class="col-sm-12">
<input name="submit" type="submit" value="SUBMIT" class="btn waves-effect waves-light btn-inverse btn-square" style="padding:5px 19px; width:100%;">

</div>
</div></div>

</div>

</div>
</form>


<div class="col-sm-12">

<div class="table-responsive">
<table class="table" border="1" cellpadding="0" cellspacing="0" bordercolor="#CCC" style="border-collapse:collapse;">
<thead >
<tr>
<th style="border-top:0px; font-weight:800; background-color:#f1f1f1;">SLN</th>
<th style="border-top:0px; font-weight:800; background-color:#f1f1f1;">DAY</th>
<th style="border-top:0px; font-weight:800; background-color:#f1f1f1;">DATE</th>
<th style="border-top:0px; font-weight:800; background-color:#f1f1f1;">P / A</th>
<th style="border-top:0px; font-weight:800; background-color:#f1f1f1;">TIME IN</th>
<th style="border-top:0px; font-weight:800; background-color:#f1f1f1;">TIME OUT</th>
<th style="border-top:0px; font-weight:800; background-color:#f1f1f1;">LATE BY</th>
<th style="border-top:0px; font-weight:800; background-color:#f1f1f1;">LOGOUT TYPE</th>
</tr>
</thead>
<tbody>
<?php
$i=1;
if($_POST['year']!="")

        {

			$Y=$_POST['year'];

		}

		else

		{

			$Y=date('Y');

		}

		if($_POST['month']!="")

		{

			$m=$_POST['month'];

		}

		else

		{

			$m=date('m');

		}

	$Total_Days_In_Month=cal_days_in_month(CAL_GREGORIAN,$m,$Y);

	

	$Off_Day=0;

	for($o=1;$o<=$Total_Days_In_Month;$o++)

	{

		

		$Field=$o."_Day";

		$conditions1=" `".$Field."`='OFF' and `Emp_Temp_Id`='".$attendance['Emp_Temp_Id']."' and `Roster_Month`='".$m."' and `Roster_Year`='".$Y."'";

		$Get_Off_Days=$Mainclass->Off_Num_rows_Check("roster_plan_master",$Field,$conditions1);

		//echo "xx=".$Get_Off_Days;

		if($Get_Off_Days>0)

		{

			$Off_Day++;

			//$Off_Day=$Off_Day + $Off_Day;

		}
		$Field=$o."_Day";

		$conditions2=" `".$Field."`='NH' and `Emp_Temp_Id`='".$attendance['Emp_Temp_Id']."' and `Roster_Month`='".$m."' and `Roster_Year`='".$Y."'";

		$Get_Nh_Days=$Mainclass->Off_Num_rows_Check("roster_plan_master",$Field,$conditions1);

		//echo "xx=".$Get_Off_Days;

		if($$Get_Nh_Days>0)

		{

			$Holiday++;

			//$Off_Day=$Off_Day + $Off_Day;

		}
foreach($ALL_attendances as $attendance)
{
?>
	<tr>
	<th scope="row" ><?php echo $i;?></th>
    <th><?php echo date('l', strtotime($attendance['Attendance_Date']));?></th>
    <th><?php echo date('d-M-y',strtotime($attendance['In_Time']));?></th>
    <th>Present</th>
    <th><?php echo date('h:i a',strtotime($attendance['In_Time']));?></th>
    <th><?php if($attendance['Out_Time']!="0000-00-00 00:00:00"){echo date('h:i a',strtotime($attendance['Out_Time']));}?></th>
    <th><?php if($attendance['Late_Count']=='1'){

$actual_in_time=$attendance['In_Time'];
$roster_in_time=$attendance['Attendance_Date']." ".$attendance['Roster_In_Time'].":00";		
	$dateDiff = intval((strtotime($actual_in_time)-strtotime($roster_in_time))/60);

									$hours = intval($dateDiff/60);
									$minutes = $dateDiff%60;
									if($hours!=0)
									{
										echo $hours." Hr ";
									}
									if($minutes!=0)
									{
										echo $minutes." Min";
									}} else { echo "No";}?></th>
    <th><?php echo $attendance['Out_With'];?></th>
	</td>
		

	</td>
	</tr>
<?php
$i++;
}
	}
?>	

</tbody>
</table>
</div>

</div>


 
  

</div>







</div>
</div>










</div>
</div>
</div>

</div>
</div>
</div>
</div>

<div id="styleSelector">
</div>
</div>
</div>
</div>
</div>


<!--[if lt IE 10]>
<div class="ie-warning">
    <h1>Warning!!</h1>
    <p>You are using an outdated version of Internet Explorer, please upgrade <br/>to any of the following web browsers to access this website.</p>
    <div class="iew-container">
        <ul class="iew-download">
            <li>
                <a href="http://www.google.com/chrome/">
                    <img src="../files/assets/images/browser/chrome.png" alt="Chrome">
                    <div>Chrome</div>
                </a>
            </li>
            <li>
                <a href="https://www.mozilla.org/en-US/firefox/new/">
                    <img src="../files/assets/images/browser/firefox.png" alt="Firefox">
                    <div>Firefox</div>
                </a>
            </li>
            <li>
                <a href="http://www.opera.com">
                    <img src="../files/assets/images/browser/opera.png" alt="Opera">
                    <div>Opera</div>
                </a>
            </li>
            <li>
                <a href="https://www.apple.com/safari/">
                    <img src="../files/assets/images/browser/safari.png" alt="Safari">
                    <div>Safari</div>
                </a>
            </li>
            <li>
                <a href="http://windows.microsoft.com/en-us/internet-explorer/download-ie">
                    <img src="../files/assets/images/browser/ie.png" alt="">
                    <div>IE (9 & above)</div>
                </a>
            </li>
        </ul>
    </div>
    <p>Sorry for the inconvenience!</p>
</div>
<![endif]-->


<script type="c3ff8485e8526425ac6f5b03-text/javascript" src="files/bower_components/jquery/js/jquery.min.js"></script>
<script type="c3ff8485e8526425ac6f5b03-text/javascript" src="files/bower_components/jquery-ui/js/jquery-ui.min.js"></script>
<script type="c3ff8485e8526425ac6f5b03-text/javascript" src="files/bower_components/popper.js/js/popper.min.js"></script>
<script type="c3ff8485e8526425ac6f5b03-text/javascript" src="files/bower_components/bootstrap/js/bootstrap.min.js"></script>

<script src="../files/assets/pages/waves/js/waves.min.js" type="c3ff8485e8526425ac6f5b03-text/javascript"></script>

<script type="c3ff8485e8526425ac6f5b03-text/javascript" src="files/bower_components/jquery-slimscroll/js/jquery.slimscroll.js"></script>

<script type="c3ff8485e8526425ac6f5b03-text/javascript" src="files/bower_components/modernizr/js/modernizr.js"></script>
<script type="c3ff8485e8526425ac6f5b03-text/javascript" src="files/bower_components/modernizr/js/css-scrollbars.js"></script>

<!--<script src="../../../../cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js" type="c3ff8485e8526425ac6f5b03-text/javascript"></script>
<script src="../../../../cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js" type="c3ff8485e8526425ac6f5b03-text/javascript"></script>-->
<script type="c3ff8485e8526425ac6f5b03-text/javascript" src="files/assets/pages/form-validation/validate.js"></script>

<script type="c3ff8485e8526425ac6f5b03-text/javascript" src="files/assets/pages/form-validation/form-validation.js"></script>
<script src="files/assets/js/pcoded.min.js" type="c3ff8485e8526425ac6f5b03-text/javascript"></script>
<script src="files/assets/js/vertical/vertical-layout.min.js" type="c3ff8485e8526425ac6f5b03-text/javascript"></script>
<script src="files/assets/js/jquery.mCustomScrollbar.concat.min.js" type="c3ff8485e8526425ac6f5b03-text/javascript"></script>
<script type="c3ff8485e8526425ac6f5b03-text/javascript" src="files/assets/js/script.js"></script>


<script src="files/assets/js/rocket-loader.min.js" data-cf-settings="c3ff8485e8526425ac6f5b03-|49" defer=""></script>





</body>

<!-- Mirrored from colorlib.com//polygon/admindek/default/form-validation.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 23 Nov 2019 12:53:50 GMT -->
</html>
<script>startTime();</script>