<?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">Sub Sub Category </li>
                                        </ol>
                                    </div>
                                    <h4 class="page-title">Sub Sub Category</h4>
                                </div>
                            </div>
                        </div>
                        <!-- end page title --> 
                          <div>
                              <a href="add_sub_sub_cat.php"  class="btn btn-success"> Add Sub Category</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 `sub_sub_service` WHERE id='$id'";
                                           // print_r($sql);
                                            if(mysqli_query($conn,$sql)){

                                            echo "<script>document.location('sub_sub_service.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>Sub Sub Category Image</th>
                                                            <th>Sub Sub Category Name</th>
                                                            <th>Sub Service Charge</th>
                                                            <th>About Us</th>
                                                            <!--<th>Unique Id</th>-->
                                                            <th>Action</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                    <?php
                                                    $sql = "SELECT * FROM `sub_sub_service`";
                                                    $res = mysqli_query($conn, $sql);
                                                    $i = 1;
                                                    while ($row = mysqli_fetch_assoc($res)) {
                                                    ?>
                                                        <tr>
                                                            <td><?= $i; ?></td>
                                                            
                                                            <?php  
                                                             $fullImagePath = $row['sub_service_imge'];

                                                             $prefixToRemove = 'upload/image/';

                                                             $imageFilename = str_replace($prefixToRemove, '', $fullImagePath);
                                                             ?>
                                                             <td><img src="<?= '../upload/image/' . $imageFilename; ?>" style="width:100px; height:60px;"></td>
                                                            <td><?= $row['sub_sub_service_name'] ?></td>
                                                            <td><?= $row['sub_service_charges'] ?></td>
                                                            <td><?= $row['about_us'] ?></td>
                                                            <td>
                                                                <a href="sub_sub_category_edit.php?id=<?=$row['id']?>" class="action-icon"> <i class="mdi mdi-square-edit-outline"></i></a>
                                                                <a href="sub_sub_service.php?user=<?=$row['id']?>" 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'; 
?>