<?php
require_once("header.php");
require_once("menu.php");
$databaseService = new DatabaseService();
$con = $databaseService->getConnection();

if(isset($_REQUEST['del']))
{
    $service_id = base64_decode($_REQUEST['del']);
    $service_status = '0';
    $ex = $obj->softdel_service($service_id,$service_status);
    echo '<script>window.location="service.php"</script>';
}

?>

<div id="layoutSidenav_content">
<main class="mt-4">
    <div class="container-fluid">        
        <div class="card mb-4">
            <div class="card-header">
                <i class="fas fa-border-style mr-1"></i>Service List
                <a href="add_service.php" class="btn btn-primary btn-sm float-right add_right">Add New Service</a>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                        <thead>
                            <tr>
                                <!-- <th>Icon</th> -->
                                <th>Name</th>
                                <th>Banner</th>
                                <th>Action</th>
                                <th>Page Content</th>
                                <!-- <th>Services</th> -->
                               
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $ex = $obj->view_service();
                            while($row=mysqli_fetch_array($ex))
                            {
                                $service_id=$row['service_id'];
                            ?>
                            <tr>
                                
                                <td><?php echo ucwords($row['service_name']);?></td>
                                <td><img src="<?php echo ucwords($row['service_banner']);?>" style="width: 300px; height:auto;"></td> 
                                <td>
                                   <a href="add_service.php?edit=<?php echo base64_encode($row['service_id']);?>" class="btn btn-primary btn-sm edit_right" title="Edit"><i class="fas fa-edit"></i></a>
                                    <a href="service.php?del=<?php echo base64_encode($row['service_id']);?>" class="btn btn-danger btn-sm delete_right" title="Delete"><i class="fas fa-trash"></i></a>
                               </td>
							     
							      
							   <td>
                      
               <?php 
               $query= $obj-> view_service_content($row['service_id']);
               $qu= mysqli_num_rows($query);

                        if($qu==0)
                                    {
                                    ?>

            <a href="add_service_page.php" class="btn btn-success btn-sm edit_right" title="Add"><i class="fas fa-plus"></i></a>
               <?php
            }
            
            else
            { 
                ?>
              <a href="add_service_page.php?edit=<?php echo base64_encode($row['service_id']);?>" class="edit_right btn btn-primary btn-sm" title="Edit"><i class="fas fa-edit"></i></a>
               <a href="view_service_page.php?id=<?php echo base64_encode($row['service_id']);?>" class="btn btn-info btn-sm " title="View"><i class="fa fa-eye"></i></a>

           <?php
            } 
            ?>
              </td>
                                 </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</main>



<?php require_once("footer.php");?>


