<div class="card">                               
    <div class="card-header"><h4 class="card-title mb-1">Edit Attendance</h4></div>
    <div class="card-content">
        <div class="card-body">
								<div class="table-responsive col-12 s-right mb-75">
									<table class="table table-striped">
										<thead>
											<tr>
												<th>Pic</th>
												<th>Name</th>
												<th>F.Name</th>
												<th>Designation</th>
												<th>Department</th>
												<th>Edit Attendance</th>	
											</tr>
										</thead>
										<tbody>
<?php
include'../database.php';
$obj = new Database();
$getdate=$_POST['date'];
$date = date("j-n-Y", strtotime($getdate));
$cid=$_POST['cid'];
$obj->sql("SELECT * FROM employee WHERE exists (select * from attendances where staffid = employee.id AND date='$date' AND cid='$cid') AND  cid='$cid'");
$result = $obj->getResult();
	foreach ($result as list("id"=>$id,"username"=>$username,"name"=>$name,"fname"=>$fname,"paddress"=>$paddress,"address"=>$address,"designation"=>$designation,"gender"=>$gender,"phone"=>$phone,"aphone"=>$aphone,"email"=>$email,"role"=>$role,"department"=>$department,"status"=>$status,"dob"=>$dob,"blood"=>$blood,"dp"=>$dp)) { 
?>

   						<tr>
											<td><div class="avatar mr-1 avatar-lg"><img src="assets/file/dp/<?php echo $dp; ?>" alt="avtar img holder"></div></td>
											<td><?php echo $name; ?></td>
											<td><?php echo $fname; ?></td>
											<td><?php
$obj->sql("SELECT id AS desi_id, name designation_name FROM designation WHERE id = '$designation'");
$result = $obj->getResult();
	foreach ($result as list("desi_id"=>$desi_id,"designation_name"=>$designation_name)) { echo  $designation_name; } ?></td>
											<td><?php
$obj->sql("SELECT id AS department_id, name AS department_name FROM department WHERE id = '$department'");
$result = $obj->getResult();
	foreach ($result as list("department_id"=>$department_id,"department_name"=>$department_name)) { echo  $department_name; } ?></td>

											<td>
<?php
$col="attendances.id AS aid, attendances.attendance AS attendance";
$wheres = " attendances.staffid = $id AND attendances.date='$date' AND attendances.cid='$cid'";
$obj->select('attendances',$col,null,$wheres,null,null);
$result1 = $obj->getResult();
foreach ($result1 as list("aid"=>$aid,"attendance"=>$attendance)) { ?>
                                            <form action="" method="POST">
                                                <button type="button" data-id="<?php echo $aid; ?>" class="btn btn-sm btn-success mr-1 mb-1 ep" style="<?php if($attendance=='Present'){echo "display:none;";} ?>">Present</button>
                                                <button type="button" data-id="<?php echo $aid; ?>" class="btn btn-danger btn-sm mr-1 mb-1 ea" style="<?php if($attendance=='Absent'){echo "display:none;";} ?>">Absent</button>
                                                <button type="button" data-id="<?php echo $aid; ?>" class="btn btn-warning btn-sm mr-1 mb-1 eo" style="<?php if($attendance=='On_Leave'){echo "display:none;";} ?>">On Leave</button>
                                                <button type="button" data-id="<?php echo $aid; ?>" class="btn btn-info btn-sm mr-1 mb-1 eh" style="<?php if($attendance=='Half_day'){echo "display:none;";} ?>">Half Day</button>
                                                <button type="button" data-id="<?php echo $aid; ?>" class="btn btn-secondary btn-sm mr-1 mb-1 es" style="<?php if($attendance=='Short_Leave'){echo "display:none;";} ?>">Short Leave</button>
											</form>	
<?php } ?>
											</td>
											</tr>
<?php } ?>        

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