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

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

</head>

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

<?php 
	if(isset($_GET['delete_id']))
	{
		// select image from db to delete
		$stmt_select = $DB_con->prepare('SELECT userPic FROM teacher WHERE teacher_id =:uid');
		$stmt_select->execute(array(':uid'=>$_GET['delete_id']));
		$imgRow=$stmt_select->fetch(PDO::FETCH_ASSOC);
		//unlink("user_images/".$imgRow['userPic']);
		
		// it will delete an actual record from db
		$stmt_delete = $DB_con->prepare('DELETE FROM teacher WHERE teacher_id =:uid');
		$stmt_delete->bindParam(':uid',$_GET['delete_id']);
		$stmt_delete->execute();
		
		//header("Location:teacher.php");
	}
?>

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


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

    <div class="pagetitle bg-light rounded p-2">
     <h1>
Teacher List |  <a target="_blank" href="teacher-print"><i class="bi bi-printer"></i></a> |  <span> <a href="teacher-add">   <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 width="100%" class="table table-hover datatable" >
                        <thead class="alert-primary"> 
                           
                            <tr>
                                <th>SL</th>
                                <th>Id</th>
                                <th>Name</th>
                                <th>Course</th>
                    
								<!--<th>Address</th>-->
								<th>Phone</th>
                                <th>Photo</th>
                                <th>Join Date</th>
								
								<th>Edit</th>
								<th>Delete</th>
                            </tr>
                        </thead>
                       <tbody id="tbody">
							<?php
							$sl = 0;
								$eq=mysqli_query($con,"select * from  teacher
								left join product on product.product_id = teacher.subject
								where teacher.user_id='".$_SESSION['id']."' and teacher.status=1 ORDER BY teacher.teacher_id DESC  ");
								while($eqrow=mysqli_fetch_array($eq)){
									?>
										<tr>
											 
											
										    <td><?php echo ++$sl; ?></td>
										    <td><?php echo $eqrow['teacher_id']; ?></td>
											<td><?php echo  $eqrow['teacher_name'] ; ?></td>
											<td><?php echo  $eqrow['product_name'] ; ?></td>
											
											<!--<td> <?php echo $eqrow['address']; ?> </td>-->
											<td><?php echo $eqrow['contact_info']; ?></td>
											<td><?php echo date("d-M-Y", strtotime($eqrow['join_date'])); ?></td>
										 <td> <img src="user_images/<?php echo $eqrow['userPic']; ?>" class="img-rounded" height="30px;" width="30px;" /></td>
			
				<td><a  class="btn-sm btn-info" href="teacher-edit?update=<?php echo $eqrow['teacher_id']; ?>" title="click for edit"><span class="bi bi-pencil-square"></span> Edit</a> </td>
				
				<td>
				<a class="btn-sm btn-danger delete-btn" href="#"   data-id="<?php echo $eqrow['teacher_id']; ?>" 
                   data-bs-toggle="modal" data-bs-target="#confirmDeleteModal" 
				   title="Click for delete"> <span class="bi bi-trash"></span> Delete
                 </a>
				 
               <?php  require_once 'modal/delete_modal_for_all_list.php'; ?>
				</td>
			
				
			</tr>
		<?php
		}  
		?>

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

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

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