<?php
session_start();
include('conn.php');
error_reporting(0);
   if($_GET['status']==0)
   {
    
  $sub=$_GET['id'];
   //$qry="UPDATE tbl_submenu SET sub_menu='$submenu' where submenu_id='$sub'";
  $result=mysqli_query($conn,"UPDATE add_adver SET  status='1' where id='$sub'");
  if($result==true)
   {
     echo"<script>window.location.href='adver-list.php',</script>";
   }
   else
   {
     echo"<script>window.location.href='adver-list.php',</script>";
   }
   }
   ?>
 
 
 
 <?php 
include('conn.php');
   if($_GET['status']==1)
   {
    
  $sub=$_GET['id'];
   //$qry="UPDATE tbl_submenu SET sub_menu='$submenu' where submenu_id='$sub'";
  $result=mysqli_query($conn,"UPDATE add_adver SET  status='0' where id='$sub'");
  if($result==true)
   {
     echo"<script>window.location.href='adver-list.php',</script>";
   }
   else
   {
     echo"<script>window.location.href='adver-list.php',</script>";
   }
   }
   ?>










 <!--Edit Product code Start -->
 
 
 <!--Edit Product code End -->

 
 <!--Delete Product code Start -->
 
<?php

include('conn.php');
error_reporting(0);
if($_GET['adver'])
{
$a=$_GET['adver'];
$query=mysqli_query($conn,"DELETE FROM add_adver WHERE id='$a'");
if($query)
{
  echo"<script>alert('Details has been deleted');
  window.location.href='adver-list.php';</script>";
}
else
{
  echo"<script>alert('Details has not been deleted');window.location.href='adver-list.php';</script>";
}
}


?>

<!DOCTYPE html>

<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Advertisment</title>

  <!-- Google Font: Source Sans Pro -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css">
  <!-- DataTables -->
  <link rel="stylesheet" href="plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
  <link rel="stylesheet" href="plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
  <link rel="stylesheet" href="plugins/datatables-buttons/css/buttons.bootstrap4.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/adminlte.min.css">
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
  <!-- Navbar -->
 <?php include "header.php";?>
  <!-- /.navbar -->

  <!-- Main Sidebar Container -->
  <?php include "sidebar.php"; ?>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1>Advertisment</h1>
          </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 active">Advertisment</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-12">
           

            <div class="card">
              <div class="card-header">
                <h3 class="card-title">Advertisment</h3>
              </div>
              <!-- /.card-header -->
              <div class="card-body">
                <table id="example1" class="table table-bordered table-striped">
                  <thead>
                  <tr>
                    <th>S.no</th>
                    <th>Image</th>
                    <th>Advertisment Name</th>
                    <th>About Advertisment</th>
                     <th>Category</th>
                     <th>Status</th>
                     <th>Date</th>
                     <th>Delete/Edit</th>


                  </tr>
                  </thead>
                  <tbody>
                  <?php 
        $a=1;
        $query=mysqli_query($conn,"SELECT * FROM  add_adver ORDER BY id DESC");?>
        <?php while($row=mysqli_fetch_array($query)){ 
    //$status="Active";
  //if($row['status']=='Deactive')
 // {
   // $status="Deactive";
 // }
  
    ?>
                  <tr>
                  <td><?php echo $a;?></td>
                     <td class="center"><img src="pic/<?php echo $row['product_img']; ?>" style="width:70px;height:70px;"> </td> 
                    <td class="center"><?php echo $row['product_name']; ?></td>
                    <td class="center"><?php echo $row['product_price']; ?></td>
                    <td class="center"><?php echo $row['cate_id']; ?></td>
                    <?php if($row['status']=='0'){?>      
         <td><button type="submit"  class="btn btn-danger"><a href="adver-list.php?id=<?php echo $row['id'];?>&status=<?php echo $row['status']; ?>" style="color:white">Deactive</a></button></td>
        <?php } else {?>
    <td><button type="submit"  class="btn btn-success"><a href="adver-list.php?id=<?php echo $row['id'];?>&status=<?php echo $row['status']; ?>" style="color:white">Active</a></button></td>
        <?php }?>
        <td><?php echo $row['Date'];?></td>

        <td>

<a onclick="return confirm('Are you sure want to delete ?');"  href="adver-list.php?adver=<?php echo $row['id'];?>"> <i class="fa fa-trash" aria-hidden="true" style="font-size:25px;color:red"></i></a>         
/

<a href="update_adver_list.php?change=<?php echo $row['id'];?>" > <i class="fa fa-edit" style="font-size:25px;color:blue "></i></a>
</td>			
               
</tr>

<?php $a++;}?>
                  </tbody>
                  
                </table>
              </div>
              <!-- /.card-body -->
            </div>
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div>
      <!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
  <?php  include " footer.php";    ?>

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
  </aside>
  <!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->

<!-- jQuery -->
<script src="plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- DataTables  & Plugins -->
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="plugins/jszip/jszip.min.js"></script>
<script src="plugins/pdfmake/pdfmake.min.js"></script>
<script src="plugins/pdfmake/vfs_fonts.js"></script>
<script src="plugins/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="plugins/datatables-buttons/js/buttons.print.min.js"></script>
<script src="plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<!-- Page specific script -->
<script>
  $(function () {
    $("#example1").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": false,
      "buttons": []
    }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
    $('#example2').DataTable({
      "paging": true,
      "lengthChange": false,
      "searching": false,
      "ordering": true,
      "info": true,
      "autoWidth": false,
      "responsive": true,
    });
  });
</script>
</body>
</html>
