<?php
session_start();
include 'include/config.php';

if(!isset($_SESSION['id'])){
 echo "<script> window.location.href = 'index.php' </script>";
  }
?>

<?php  include 'include/head.php'; ?>
                    
                      <!-- Start Content-->
                      <div class="container-fluid">
                        
                        <!-- start page title -->
                        <div class="row">
                            <div class="col-12">
                                <div class="page-title-box">
                                    <div class="page-title-right">
                                        <ol class="breadcrumb m-0">
                                            <li class="breadcrumb-item"><a href="dashboard.php">Home</a></li>
                                            <li class="breadcrumb-item active">Subadmin</li>
                                        </ol>
                                    </div>
                                    <h4 class="page-title"> All Subadmin</h4>
                                </div>
                            </div>
                        </div>
                         <!--end page title -->
                          <div>
                              <a href="subadmin.php"  class="btn btn-success"> Add New Subadmin</a>
                          </div>

                        <div class="row">
                            <div class="col-12">
                                <div class="card">
                                    <div class="card-body">
                                        
                                        <?php
                                        if(isset($_GET['user'])){
                                            $id = $_GET['user'];
                                        
                                            $sql = "DELETE FROM `subadmin` WHERE id='$id'";
                                           // print_r($sql);
                                            if(mysqli_query($conn,$sql)){
                                             echo "<script>alert('Your Data deleted successfully');</script>";
                                            // echo "<script>document.location('user.php');</script>";
                                            echo "<script>window.location.href='subadmin_list.php';</script>";
                                            }
                                           
                                        }
                                        ?>
                                        <div class="table-responsive">
                                            <div class="tab-pane show active" id="basic-datatable-preview">
                                                <table id="datatable" class="table table-striped dt-responsive nowrap w-100">
                                                    <thead>
                                                        <tr>
                                                            <th>Sr. No.</th>
                                                            <th>Subadmin ID</th>
                                                            <th>Subadmin Name</th>
                                                             <th>SubadminEmail</th>
                                                             <th>Subadmin Account Number</th>
                                                             <th>Subadmin Phone Number</th>
                                                             <th>Subadmin Address</th>
                                                             <th>Subadmin Password:</th>
                                                             <th>Subadmin Aadhar Number:</th>
                                                             <th>Subadmin Pan Number:</th>
                                                             <th>Subadmin Created Date:</th>
                                                             <th>Subadmin Created Month:</th>
                                                             <th>Subadmin Profile Image:</th>
                                                             <th>Subadmin Aadhar Front Image:</th>
                                                             <th>Subadmin Aadhar Back Image:</th>
                                                             <th>Subadmin Pan Card Image:</th>
                                                             <th>Subadmin Electricity Bill Image:</th>
                                                             <th>Subadmin Signature Image:</th>
                                                             <th>Subadmin Rent Agreement Image:</th>
                                                             <th>Subadmin Bank Statment Image:</th>
                                                             <th>Subadmin Pass Book Image:</th>
                                                             <th>Subadmin Bank Account Number:</th>
                                                            
                                                            <th>Action</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                    <?php
                                                    $sql = "SELECT * FROM `subadmin` ORDER BY id DESC";
                                                    $res = mysqli_query($conn, $sql);
                                                    $i = 1;
                                                    while ($row = mysqli_fetch_assoc($res)) {
                                                    ?>
                                                        <tr>
                                                            <td><?= $i; ?></td>
                                                            <td><?= $row['id'] ?></td>
                                                            <td><?= $row['first_name']. ' ' .$row['last_name'] ?></td>
                                                            <td><?= $row['email'] ?></td>
                                                            <td><?= $row['a_c_number'] ?></td>
                                                            <td><?= $row['phone'] ?></td>
                                                            <td><?= $row['address'] ?></td>
                                                            <td><?= $row['password'] ?></td>
                                                            <td><?= $row['adhar_no'] ?></td>
                                                            <td><?= $row['pan_no'] ?></td>
                                                            <td><?= $row['created_at'] ?></td>
                                                            <td><?= $row['moth_name'] ?></td>
                                                            <td> <img src="<?= '../img/profile_image/'.$row['profile'];?>" style="width:100px; height:60px;"></td>
                                                            <td> <img src="<?= '../img/aadhar_image/'.$row['adhar_front_pic'];?>" style="width:100px; height:60px;"></td>
                                                            <td> <img src="<?= '../img/aadhar_image/'.$row['adhar_back_pic'];?>" style="width:100px; height:60px;"></td>
                                                            <td> <img src="<?= '../img/pan_image/'.$row['pan_image'];?>" style="width:100px; height:60px;"></td>
                                                            <td> <img src="<?= '../img/electricity_bill_image/'.$row['electricity_bill'];?>" style="width:100px; height:60px;"></td>
                                                            <td> <img src="<?= '../img/signature_image/'.$row['signature_image'];?>" style="width:100px; height:60px;"></td>
                                                            <td> <img src="<?= '../img/rent_agreement/'.$row['rent agreement_image'];?>" style="width:100px; height:60px;"></td>
                                                            <td> <img src="<?= '../img/rent_agreement/'.$row['bank_statement'];?>" style="width:100px; height:60px;"></td>
                                                            <td> <img src="<?= '../img/rent_agreement/'.$row['pass_book'];?>" style="width:100px; height:60px;"></td>
                                                           <td><?= $row['bank_account'] ?></td>
                                                            <td>
                                                                <a href="subadminedit.php?id=<?=$row['id']?>" class="action-icon"> <i class="mdi mdi-square-edit-outline"></i></a>
                                                                <a href="subadmin_list.php?user=<?= $row['id'] ?>" onclick="return confirm('Are You Sure Want To Delete This?');" class="action-icon"> <i class="mdi mdi-delete"></i></a>

                                                            </td>
                                                         </tr>
                                                        <?php
                                                       $i++;  } 
                                                        ?>
                                                    </tbody>
                                                </table>                                           
                                            </div> <!-- end preview-->
                                        
                                            
                                        </div> <!-- end tab-content-->

                                    </div> <!-- end card body-->
                                </div> <!-- end card -->
                            </div><!-- end col-->
                        </div> <!-- end row-->

                    
                    </div> <!-- container -->


<?php  
include 'include/footer.php'; 
?>