<?php 
session_start();
require_once '../../includes/conn.php';
?>

<!DOCTYPE html>
<html>
<head> 

<link rel="stylesheet" href="css/table_data_center_with_border_black.css">
</head>
<body>
 <div class="container-fluid">
 <br>

<center> <?php
				 
				   $pq=mysqli_query($con,"select * from stuff left join `user` on user.userid=stuff.userid where stuff.userid='".$_SESSION['id']."'");
				   while($pqrow=mysqli_fetch_array($pq)){
				?>
				 <span style="font-size:21;font-weight:bold;">
			  <?php echo $pqrow['business_name']; ?>
				 </span> 
	<?php }?> <br>
	<span style="font-size:19;">
Single Students Attendance Report 
</span>
<br>
<span style="font-size:18;">
<?php 
$startDate = $_POST['startDate'];  $endDate = $_POST['endDate'];
echo '  Date From  : ' ; echo date("d - M - Y", strtotime( $startDate));
echo ' |  Date To :  ' ; echo date("d - M - Y", strtotime( $endDate));
?> <br>
Print Date : <?php echo date("d-M-Y") ;?> | 
Time   : <?php date_default_timezone_set("Asia/Dhaka"); echo  date("h:i:sa");?>
 </span>
		 </center> <br>
 
<?php  
if($_POST) {
    
	$StuId = $_POST['StuId']; 
	
	$startDate = $_POST['startDate'];
	$date = DateTime::createFromFormat('m/d/Y',$startDate);
	$start_date = $date->format("Y-m-d");


	$endDate = $_POST['endDate'];
	$format = DateTime::createFromFormat('m/d/Y',$endDate);
	$end_date = $format->format("Y-m-d");
	
	$sql = "SELECT * FROM attendance
	LEFT JOIN customer ON customer.customer_id = attendance.student_id	
	left join product on product.product_id =customer.course_id
	
	where attendance.student_id='$StuId' and attendance.atnd_date >= '$start_date' AND attendance.atnd_date <= '$end_date'   
	 
	order by attendance.atnd_id asc ";
	
	$query = $con->query($sql);
    
	$sl=0;
	$table = '
	<table border="1" cellspacing="0" cellpadding="0" class="table table-bordered" style="width:100%;">
		
		<tr>          
                                <th>SL</th>							
                                <th>Student Name</th>
                                <th>Course</th>	
				            	<th>Date</th>  
								<th>Attends</th> 								
								<th>Comments</th>
							
		</tr>

		<tr>';
		
		while ($result = $query->fetch_assoc()) {
			$table .= '<tr>
				 
				<td><center>'.++$sl.'</center></td> 
				<td><center>'.$result['customer_name'].'</center></td>
				<td><center>'.$result['product_name'].'</center></td>
	     		<td><center>'.date("d-M-Y", strtotime($result['atnd_date'])).'</center></td>  
				<td><center>'.$result['atnd_info'].'</center></td> 
			    <td></td>
			</tr>';	
			
			
		}
		$table .= '
		</tr>
	
		
	</table>
	';	

	echo $table;

}

?>

</div>


</body>
</html>
