<?php
date_default_timezone_set('Asia/Kolkata'); 
$date = date("Y-m-d", time());
include ('../config.php');
@session_start();
@$user_id1=$_SESSION['user_id1'];
@$idvfied1=$_SESSION['idverified1'];
@$namevfied1=$_SESSION['namevfied1'];
if(!isset($_SESSION['user_id1'])){
	header("Location: index.php");
}

$timeout = 60 * 60 * 24 * 365;
$s_name = session_name();
if(isset( $_COOKIE[ $s_name ] )) {
  setcookie( $s_name, $_COOKIE[ $s_name ], time() + $timeout, '/' );
}

$sel1=mysqli_query($conn,"select * from hr_dump where empid='".@$user_id1."'");
$fetch1=mysqli_fetch_array($sel1);

$queryFR=mysqli_query($conn,"select * from tracker where Functional_Reporting='$fetch1[Employee_Number]'");
$dataFR=mysqli_fetch_array($queryFR);

$queryFR=mysqli_query($conn,"select * from emp_leave where Functional_Reporting='$fetch1[Employee_Number]'");
$dataFR=mysqli_fetch_array($queryFR);
?>

<!doctype html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, viewport-fit=cover" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>View Team Attendance</title>
	
	<?php	include ('header.php');	?>
	
	<div id="appCapsule">
        <div class="section wallet-card-section pt-1">
            <div class="wallet-card">
				<?php	include ('include/wallet-balance.php');	?>
				<div class="row text-center mb-4">
					<h6 class="text-center">Team Attendance</h6>
					<div class="table">
						<table class="table table-striped table-bordered bootstrap-datatable datatable responsive">
							<thead>
							<tr>
								<th>Date</th>
								<th>Office In</th> 
								<!--<th>Late</th>-->
								<th>Office Out</th>
								<!--<th>Early</th>-->
							</tr>
							</thead>
							<tbody> 
								<?php
								//$query="select * from tracker where empid='".@$user_id1."' AND created_at LIKE '%$date%' ORDER BY id ASC";
								$query="select * from ams_final where empid='".$_GET['empid']."' AND OfficeDate LIKE '%$date%' ORDER BY id ASC";
								$result=mysqli_query($conn,$query);
								while($data=mysqli_fetch_assoc($result))
								{
								@$sn++;
								?>
								<tr>
									<td><?php echo $data['OfficeDate'] ?></td>
									<td><?php echo $data['OfficeIn'] ?></td>
									<!--<td></?php echo "<div class='bg-danger'>".$data['OfficeLate']."</div>" ?></td>-->
									<td><?php echo $data ['OfficeOut']; ?></td>
									<!--<td></?php echo "<div class='bg-danger'>".$data['OfficeEarly']."</div>" ?></td>-->
								</tr>
								<?php    }    ?>
							</tbody>
						</table>
					</div>
			<h4>Attendance:
			<?php
			$now = new DateTime();
			$firstDayOfCurrentMonth = new DateTime($now->format('Y-m-01'));
			$lastDayOfPreviousMonth = $firstDayOfCurrentMonth->sub(new DateInterval('P1D'));
			$lastM = $lastDayOfPreviousMonth->format('Y-m');
			echo $monthP = $lastDayOfPreviousMonth->format('M-Y');
			//echo $lastM = date('Y-M', strtotime('-1 Months'));
			//$lastM = date('Y-m', strtotime('-1 Months'));
			//$lastM = '2023-02';
			?>
			</h4>
			
					<div class="table">
						<table class="table table-striped table-bordered bootstrap-datatable datatable responsive">
							<thead>
							<tr>
								<th>Date</th>
								<th>Office In</th> 
								<th>Office Out</th>
							</tr>
							</thead>
							<tbody> 
								<?php
								$query="select * from ams_final_hr where empid='".$_GET['empid']."' AND OfficeDate LIKE '%$lastM%' ORDER BY OfficeDate ASC";
								$result=mysqli_query($conn,$query);
								while($data=mysqli_fetch_assoc($result))
								{
								@$sn++;
								?>
								<tr>
									<td><?php echo $data['OfficeDate'] ?></td>
									<td><?php echo $data['InTime'] ?></td>
									<td><?php echo $data ['OutTime']; ?></td>
								</tr>
								<?php    }    ?>
							</tbody>
						</table>
					</div>
				</div>
            </div>
        </div>

		<!--</?php	include ('include/quik_links.php');	?>
		</?php	include ('include/extra_links.php');	?>-->
	
	<?php	include ('include/copyright.php');	?>
	</div>
	
	<?php	include ('footer.php');	?>