<!DOCTYPE html>
<html lang="en">  

<head>
<?php ob_start(); ?>
<?php   require_once 'head_link.php'; ?>

<style type="text/css"> 
.Yes{color:green;}
.No{color:red;}
</style>
</head>

<body>
 
<?php   require_once 'header1.php'; ?> 
 

<?php 
	if(isset($_GET['delete_id']))
	{  
		$stmt_delete = $DB_con->prepare('DELETE FROM attendance WHERE atnd_id =:uid');
		$stmt_delete->bindParam(':uid',$_GET['delete_id']);
		$stmt_delete->execute(); 
	}
	
	if(isset($_GET['update_yes']))
	{ 
		$stmt_update = $DB_con->prepare('UPDATE attendance  SET atnd_info="Yes" , status=1 WHERE atnd_id =:uid');
		$stmt_update->bindParam(':uid',$_GET['update_yes']);
		$stmt_update->execute(); 
	}
	
	
   if(isset($_GET['update_no']))
	{ 
		$stmt_update = $DB_con->prepare('UPDATE attendance  SET atnd_info="No" , status=0 WHERE atnd_id =:uid');
		$stmt_update->bindParam(':uid',$_GET['update_no']);
		$stmt_update->execute(); 
	}

?>

<?php  require_once 'sidebar.php'; ?>


  <main id="main" class="main">

    <div class="pagetitle bg-light rounded p-2">
     <h1>
Attendance List  <span class="d-none"> | <a href="atendance-list-today"> <i class="bi bi-calendar2-check"></i> </a> </span> |   <span> <a href="atendance">   <i class="bi bi-plus-square-fill"></i> </a> </span> </h1>
        
    </div> 

    <section class="section">
      <div class="row">
	  
        <div class="col-lg-12">

          <div class="card">
            <div class="card-body">
             
              <table class="table table-hover datatable">
                  
				  <thead class="bg-light">
                            
                            <tr>
								 
                                <th>SL</th> 
                                <th>Batch No</th>
                                <th>Students Name</th> 	 
                                <th>Date</th>								
                                <th>Photo</th>								
                                <th>Attends</th>								
								<th>Update</th>
								<th>Delete</th>
                            </tr>
                        </thead>
						
						
                   <tbody id="tbody">
							<?php
								date_default_timezone_set("Asia/Dhaka");
								$Date=date("Y/m/d");
							    $sl=0;
								$eq=mysqli_query($con,"SELECT * FROM attendance 
														LEFT JOIN customer ON customer.customer_id = attendance.student_id														
														left join batch on batch.id = customer.batch_no
														WHERE atnd_date='$Date' 
														ORDER BY attendance.atnd_id ASC ");
														while($eqrow=mysqli_fetch_array($eq)){ 
							?>
										<tr>
											 
											<td><?php echo ++$sl; ?></td> 
											<td><?php echo $eqrow['batch_name']; ?></td> 
											<td><?php echo $eqrow['customer_name']; ?></td>  
											<td><?php echo date("d-M-Y", strtotime($eqrow['atnd_date'])); ?></td>
										    <td> <img src="user_images/<?php echo $eqrow['userPic']; ?>" class="img-rounded" height="30px;" width="30px;" /></td> 
											<td class="<?php echo $eqrow['atnd_info']; ?>"> <b><?php echo $eqrow['atnd_info']; ?> </b></td>
				 
				
				<td>
					 <a class="btn-sm btn-info" href="?update_yes=<?php echo $eqrow['atnd_id']; ?>" title="Click For Absence"><span class="bi bi-check-circle"></span> Yes</a>    || 
					 <a class="btn-sm btn-warning" href="?update_no=<?php echo $eqrow['atnd_id']; ?>" title="Click For Absence"><i class="bi bi-x-circle"></i> No</a>  
		  		</td>  
				
				<td>
					<a class="btn-sm btn-danger" href="?delete_id=<?php echo $eqrow['atnd_id']; ?>" title="click for delete" onclick="return confirm('Are You Sure....?')"><span class="bi bi-trash"></span> Delete</a>
		 		</td>
			
				
			</tr>
		<?php
		}  
		?>

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

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

  </main>
  
  <?php  require_once 'footer1.php'; ?>