 <?php 
 include ('includes/connection.php'); 
 
if(isset($_GET['Id_3']))
{
$id=$_GET['Id_3'];
$status='Disable'; 
$sql =mysqli_query($conn,"update student_soes set student_status='$status' WHERE student_id='$id'");
header('location:admin.php?page=trainer"');
}

//code for active students
if(isset($_GET['Id_2']))
{
$id=$_GET['Id_2'];
$status='Enable'; 
$sql =mysqli_query($conn,"update student_soes set student_status='$status' WHERE student_id='$id'");
header('location:admin.php?page=trainer"');
} 

if(isset($_GET['Id_4']))
{
$id=$_GET['Id_4'];
$Role_id='Training'; 
$sql =mysqli_query($conn,"update student_soes set Role='$Role_id' WHERE student_id='$id'");
header('location:admin.php?page=trainer"');
}

//code for active students
if(isset($_GET['Id_5']))
{
$id=$_GET['Id_5'];
$Role_id='user'; 
$sql =mysqli_query($conn,"update student_soes set Role='$Role_id' WHERE student_id='$id'");
header('location:admin.php?page=trainer"');
}
?> 
<!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper"> 
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <a><strong>Training Management information</strong></a>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Home</a></li>
              <li class="breadcrumb-item"><a href="#">USER MANAGEMENT</a></li>
              <li class="breadcrumb-item active">Student</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>

   <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row"> 
          <!-- /.col -->
          <div class="col-md-12">
            <div class="card">
              <div class="card-header p-2"> 
                   <i class="fas fa-th-list"></i> Trainer List  
              </div>
              <!-- /.card-header --> 
              <div class="card-body">    
                <div class="row">
                  <div class="col-sm-12">   
                  <div class="card-body">
                <div class="table-responsive">
                    <table id="example1" class="table table-striped display table-bordered" >
                      <thead>
                        <tr>
                            <th>#</th> 
                            <th>Profile</th>
                            <th>Full Name</th>
                            <th>Email</th>
                            <th>Mobile</th> 
                            <th>Date of Birth</th> 
                            <th>Gender</th>  
                            <th>Company</th> 
                            <th>Status</th>
                            <th>Action</th>
                        </tr>
                        </thead>
                        <tbody>
                          <?php 
                            $i = 1;
                            $selected = mysqli_query($conn,"SELECT * From student_soes");
                             while($row = mysqli_fetch_array($selected)){ 
                        
                            ?> 
                        <tr>
                          <td class="text-center"><?php echo $i++ ?></td> 
                           <td> 
                          <img src="../<?php echo $row['student_image']; ?>" class="img-thumbnail" width="75" height="75" /></td>
                          <td><?php echo $row['student_name']; ?></td> 
                          <td><?php echo $row['student_email_id']; ?></td>
                          <td><?php echo $row['student_contact_no']; ?></td>
                          <td><?php echo $row['student_dob']; ?></td>  
                          <td><?php echo $row['student_gender']; ?></td>  
                          <td><?php echo $row['company']; ?></td>   
                          <td>
                            <?php
                              if($row["student_status"] == 'Enable')
                                 {?>
                                <a href="admin.php?page=trainer&Id_3=<?php echo $row['student_id']; ?>" onclick="return confirm('Are you sure you want to block a Trainer?');" >  <button class="btn btn-secondary"> Enable</button>
                                <?php } else if($row["student_status"]=='Disable'){?>
                                  <a href="admin.php?page=trainer&Id_2=<?php echo $row['student_id']; ?>" onclick="return confirm('Are you sure you want to active a Trainer?');"><button class="btn btn-danger"> Disable</button> 
                                 <?php } ?>

                             </td>
                          <td>
                             <div class="btn-group">
                            <a data-id='<?php echo $row['student_id'] ?>' href="admin.php?page=update_training&id=<?php echo $row['student_id']; ?>" class="btn btn-primary btn-flat manage_class">
                              <i class="fas fa-edit"></i>
                            </a>
                             <a href="delete_st.php?del=<?php echo $row['student_id']; ?>" onclick="return confirm('Are you sure you want to delete?');" class="btn btn-danger btn-flat">
                              <i class="fas fa-trash"></i>
                            </a>   
                        </div> </td>
                      </tr> 
                      <?php }?> 
                        </tbody>
                        <tfoot>
                        <tr>
                          <th>#</th> 
                            <th>Profile</th>
                            <th>Full Name</th>
                            <th>Email</th>
                            <th>Mobile</th> 
                            <th>Date of Birth</th> 
                            <th>Gender</th>  
                            <th>Company</th> 
                            <th>Status</th>
                            <th>Action</th>
                        </tr>
                      </tfoot>
                </table> 
            </div>  
    </section>
    <!-- /.content -->
  </div>
  <a id="back-to-top" href="#" class="btn btn-primary back-to-top" role="button" aria-label="Scroll to top">
      <i class="fas fa-chevron-up"></i>
    </a>
  <div id="preloader"></div>
 <script src="../stp_con/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../stp_con/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- DataTables  & Plugins -->
<script src="../stp_con/datatables/jquery.dataTables.min.js"></script>
<script src="../stp_con/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="../stp_con/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="../stp_con/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="../stp_con/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="../stp_con/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="../stp_con/jszip/jszip.min.js"></script> 
<script src="../stp_con/pdfmake/pdfmake.min.js"></script>
<script src="../stp_con/pdfmake/vfs_fonts.js"></script> 
<script src="../stp_con/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="../stp_con/datatables-buttons/js/buttons.print.min.js"></script>
<script src="../stp_con/datatables-buttons/js/buttons.colVis.min.js"></script>  
<script src="../assets/js/adminlte.min.js"></script>
 <script>
  $(function () {
    $("#example1").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)'); 
  });
</script>