<?php 
 session_start();
?>



<?php 
include('dbcon.php');

error_reporting(0);
   if($_GET['status']==0)
   {
    
  $sub=$_GET['product_id'];
   //$qry="UPDATE tbl_submenu SET sub_menu='$submenu' where submenu_id='$sub'";
  $result=mysqli_query($con,"UPDATE tbl_product SET  status='1' where product_id='$sub'");
  if($result==true)
   {
     echo"<script>window.location.href='product-detail.php',</script>";
   }
   else
   {
     echo"<script>window.location.href='product-detail.php',</script>";
   }
   }
   ?>
 
 
 
 <?php 
include('dbcon.php');
   if($_GET['status']==1)
   {
    
  $sub=$_GET['product_id'];
   //$qry="UPDATE tbl_submenu SET sub_menu='$submenu' where submenu_id='$sub'";
  $result=mysqli_query($con,"UPDATE tbl_product SET  status='0' where product_id='$sub'");
  if($result==true)
   {
     echo"<script>window.location.href='product-detail.php',</script>";
   }
   else
   {
     echo"<script>window.location.href='product-detail.php',</script>";
   }
   }
   ?>
  <!--Edit Product code Start -->
 
 <?php 
 
 include('dbcon.php');


   if(isset($_POST['change']))
   {
    $i=$_POST['sbmid'];

    $menu=$_POST['menu'];
$submenu=$_POST['submenu'];
$cosubmenu=$_POST['cosubmenu'];
$brand=$_POST['brand'];
$product=$_POST['product'];
$desc=$_POST['desc'];

$image_name1=$_FILES['file1']['name'];                  /* Update a image 2*/
$image_size=$_FILES['file1']['size'];
$image_type=$_FILES['file1']['type'];
$image_tmp=$_FILES['file1']['tmp_name'];
$store="images/".$image_name1;                               /* location to store image 2 */
$upload=move_uploaded_file($image_tmp,$store);
    
    if($image_name1=='')
    {
     $image_name1=$_POST['hidden1'];
    }
      else
      {
      $image_name1=$_FILES['file1']['name'];
    }
    
    
    
    
    /*$image_name2=$_FILES['file2']['name'];                
$image_size=$_FILES['file2']['size'];
$image_type=$_FILES['file2']['type'];
$image_tmp=$_FILES['file2']['tmp_name'];
$store="images/".$image_name2;                               
$upload=move_uploaded_file($image_tmp,$store);
    
    if($image_name2=='')
    {
     $image_name2=$_POST['hidden2'];
    }
      else
      {
      $image_name2=$_FILES['file2']['name'];
    }
    
    
    $image_name3=$_FILES['file3']['name'];                  
$image_size=$_FILES['file3']['size'];
$image_type=$_FILES['file3']['type'];
$image_tmp=$_FILES['file3']['tmp_name'];
$store="images/".$image_name3;                               
$upload=move_uploaded_file($image_tmp,$store);
    
    if($image_name3=='')
    {
     $image_name3=$_POST['hidden3'];
    }
      else
      {
      $image_name3=$_FILES['file3']['name'];
    }
    
    
    
    $image_name4=$_FILES['file4']['name'];                 
$image_size=$_FILES['file4']['size'];
$image_type=$_FILES['file4']['type'];
$image_tmp=$_FILES['file4']['tmp_name'];
$store="images/".$image_name4;                               
$upload=move_uploaded_file($image_tmp,$store);
    
    if($image_name4=='')
    {
     $image_name4=$_POST['hidden4'];
    }
      else
      {
      $image_name4=$_FILES['file4']['name'];
    }*/
  
   $query="UPDATE tbl_product SET product_name='$product',description='$desc',menu_id='$menu',submenu_id='$submenu',cosubmenu_id='$cosubmenu',brand_id='$brand',image='$image_name1',date=now() where product_id='$i'";
  $result=mysqli_query($con,$query);
  if($result==true)
   {
     echo"<script>alert('Your details has been Updated');</script>";
   }
   else
   {
     echo"<script>alert('Your details has not Updated');</script>";
   }
   }
   ?>
   
 <!--Edit Product code End -->

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

error_reporting(0);
if($_GET['state_id'])
{
$j=$_GET['state_id'];
$query=mysqli_query($con,"DELETE FROM tbl_testimonial WHERE  id='$j'");
if($query)
{
   echo"<script>alert('Your details has been Deleted');
     window.location.href='testimonial-detail.php';
    </script>";
}
else{
  echo"<script>alert('Detail has not deleted');</script>";
}
}
?>

<!--Delete Product code End -->


 
 







<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8"/>
  <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
  <meta name="description" content=""/>
  <meta name="author" content=""/>
  <title>Testimonial Detail</title>
  <!--favicon-->
  <link rel="icon" href="assets/images/favicon.ico" type="image/x-icon">
  <!-- simplebar CSS-->
  <link href="assets/plugins/simplebar/css/simplebar.css" rel="stylesheet"/>
  <!-- Bootstrap core CSS-->
  <link href="assets/css/bootstrap.min.css" rel="stylesheet"/>
  <!--Data Tables -->
  <link href="assets/plugins/bootstrap-datatable/css/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css">
  <link href="assets/plugins/bootstrap-datatable/css/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css">
  <!-- animate CSS-->
  <link href="assets/css/animate.css" rel="stylesheet" type="text/css"/>
  <!-- Icons CSS-->
  <link href="assets/css/icons.css" rel="stylesheet" type="text/css"/>
  <!-- Sidebar CSS-->
  <link href="assets/css/sidebar-menu.css" rel="stylesheet"/>
  <!-- Custom Style-->
  <link href="assets/css/app-style.css" rel="stylesheet"/>

  <script src="ckeditor/ckeditor/ckeditor.js"></script>

  <!---start code for dependent dropdown---->
      <script type="text/javascript">
    function myfunction(datavalue)
    {
        $.ajax({
        url: 'ajax.php',
        type: 'post',
        data: { datapost : datavalue},

        success : function(result){
        $('#dataget').html(result);
        }
        });
    }
    
    </script>     
<!---end code of dependent dropdown--->


<!---start code for dependent dropdown---->
      <script type="text/javascript">
    function myfunction1(datavalue)
    {
        $.ajax({
        url: 'ajax3.php',
        type: 'post',
        data: { datapost : datavalue},

        success : function(result){
        $('#dataget1').html(result);
        }
        });
    }
    
    </script>     
<!---end code of dependent dropdown--->
  
</head>

<body>

<!-- Start wrapper-->
 <div id="wrapper">
 
   <!--Start sidebar-wrapper-->
   
   <?php include('sidebar.php'); ?>
   
   <!--End sidebar-wrapper-->

<!--Start topbar header-->

<?php include('header.php'); ?>
<!--End topbar header-->

<div class="clearfix"></div>
  
  <div class="content-wrapper">
    <div class="container-fluid">
    



      <div class="row">
        <div class="col-lg-12">
          <div class="card">
            <div class="card-header"><i class="fa fa-table"></i>Testimonial Detail</div>
            <div class="card-body">
              <div class="table-responsive">
              <table id="example" class="table table-bordered">
                <thead>
                    <tr>
                        <th>Sr No.</th>
                        <th>Action</th>

                        <th>Name</th>
                      
                       
                            <th>Designation</th>
                            <th>Decription</th>
                             <th>Image</th>
                             
                           
                              
                       
                       
                       
                        <th>Date</th>
                        <!--<th>Status</th>-->
                         
                        
                    </tr>
                </thead>
                <tbody>
        
        <?php 
        $a=1;
        $query=mysqli_query($con,"SELECT * FROM tbl_testimonial 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>         
          
<a href="update-testimonial.php?update=<?php echo $row['id'];?>"><i class="fa fa-edit" data-toggle="modal"  style="font-size:23px;color:blue"></i></a> / 
<a onclick="return confirm('Are you sure want to delete ?');" style="color:white" href="testimonial-detail.php?state_id=<?php echo $row['id'];?>"> <i class="fa fa-trash-o" style="font-size:23px;color:red"></i></a>         
          </td>
                       
          
                    <td><?php echo $row['name'];?></td>    
              
<td><?php echo $row['designation'];?></td>
          
      
           <td><?php echo $row['description'];?></td>
               
                      <td class="center">
                          <?php if($row['image']==''){?>
                          <img src="images/male.png" style="width:70px;height:70px;">
                          <?php } else { ?>
                          <img src="images/<?php echo $row['image']; ?>" style="width:70px;height:70px;"> 
                          <?php } ?>
                          
                          
                          </td> 
                      
                      
                        
                 
            <td><?php echo $row['date'];?></td>


                    </tr>
          
          
<!-- start Popup Modal -->

<div class="modal fade" id="m<?php echo $row['product_id'];?>"  tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">Edit Your Details</h4>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
     <form method="post" action="#" enctype="multipart/form-data">
    <input type="hidden" name="sbmid" value="<?php echo $row['product_id'];?>">
      <div class="modal-body mx-3">
        

<div class="md-form mb-5">
          <i class="zmdi zmdi-star-outline"></i>
            <label data-error="wrong" data-success="right" for="defaultForm-email">Update Menu</label>
               <?php 
                 
                  $nitin=mysqli_query($con,"SELECT * FROM tbl_menu order by menu_id");
                  ?>
             <select class="form-control"    name="menu">
                    <?php while($sql=mysqli_fetch_array($nitin)){?>
                    <option value="<?php echo $sql['menu_id'];?>" <?php if($sql['menu_id']==$row['menu_id']) { echo "selected"; }?> ><?php echo $sql['menu_name'];?></option>
                  <?php }?>
                    </select>
                </div>


                 <div class="md-form mb-5">
          <i class="zmdi zmdi-star-outline"></i>
      <label data-error="wrong" data-success="right" for="defaultForm-email">Update Submenu Name</label>
             <?php 
                 
                  $nitin=mysqli_query($con,"SELECT * FROM tbl_submenu order by submenu_id");
                  ?>
             <select class="form-control"  name="submenu">
                    <?php while($sql=mysqli_fetch_array($nitin)){?>
                    <option value="<?php echo $sql['submenu_id'];?>" <?php if($sql['submenu_id']==$row['submenu_id']) { echo "selected"; }?> ><?php echo $sql['sub_menu'];?></option>
                  <?php }?>
                    </select>
                </div>

                

                <div class="md-form mb-5">
          <i class="zmdi zmdi-star-outline"></i>
      <label data-error="wrong" data-success="right" for="defaultForm-email">Update Cosubmenu Name</label>
             <?php 
                 
                  $nitin=mysqli_query($con,"SELECT * FROM tbl_cosubmenu order by cosubmenu_id");
                  ?>
             <select class="form-control"    name="cosubmenu">
                    <?php while($sql=mysqli_fetch_array($nitin)){?>
                    <option value="<?php echo $sql['cosubmenu_id'];?>" <?php if($sql['cosubmenu_id']==$row['cosubmenu_id']) { echo "selected"; }?> ><?php echo $sql['cosubmenu'];?></option>
                  <?php }?>
                    </select>
                </div>

                


                <div class="md-form mb-5">
          <i class="zmdi zmdi-star-outline"></i>
      <label data-error="wrong" data-success="right" for="defaultForm-email">Update Brand Name</label>
             <?php 
                 
                  $nitin=mysqli_query($con,"SELECT * FROM tbl_brand order by brand_id");
                  ?>
             <select class="form-control"  name="brand">
                    <?php while($sql=mysqli_fetch_array($nitin)){?>
                    <option value="<?php echo $sql['brand_id'];?>" <?php if($sql['brand_id']==$row['brand_id']) { echo "selected"; }?> ><?php echo $sql['brand_name'];?></option>
                  <?php }?>
                    </select>
                </div>






        <div class="md-form mb-5">
          <i class="zmdi zmdi-star-outline"></i>
      <label data-error="wrong" data-success="right" for="defaultForm-email">Update Product Name</label>
              <input type="text" name="product" id="" class="form-control validate" value="<?php echo $row['product_name'];?>">
                </div>
                
                
                
        <div class="md-form mb-5">
          <i class="fas fa-envelope prefix grey-text"></i>
      <label data-error="wrong" data-success="right" for="defaultForm-email" >News Description</label>
           <!--<textarea type="text" id="" name="desc" class="form-control validate" ><?php echo $row['description']; ?></textarea>-->
           
            <textarea type="text" id="" name="desc" class="ckeditor" ><?php echo $row['description']; ?></textarea>
        </div>
                
                
                
                 <div class="col-md-12">
          <i class="fas fa-lock prefix grey-text"></i>
      <label data-error="wrong" data-success="right" for="defaultForm-pass">Image1 </label>
          <input type="file" name="file1" id="defaultForm-pass" class="form-control validate" >
      <input type="hidden" name="hidden1" class="form-control" value="<?php echo $row['image'];?>" >
           <center> <img src="images/<?php echo $row['image']; ?>" style="width:100px;height:100px;"></center>
    </div><br>
    
     <!--<div class="col-md-12">
          <i class="fas fa-lock prefix grey-text"></i>
      <label data-error="wrong" data-success="right" for="defaultForm-pass">Image2 </label>
          <input type="file" name="file2" id="defaultForm-pass" class="form-control validate" >
      <input type="hidden" name="hidden2" class="form-control" value="<?php echo $row['image2'];?>" >
           <center> <img src="images/<?php echo $row['image2']; ?>" style="width:100px;height:100px;"></center>
    </div><br>
    
    
     <div class="col-md-12">
          <i class="fas fa-lock prefix grey-text"></i>
      <label data-error="wrong" data-success="right" for="defaultForm-pass">Image3 </label>
          <input type="file" name="file3" id="defaultForm-pass" class="form-control validate" >
      <input type="hidden" name="hidden3" class="form-control" value="<?php echo $row['image3'];?>" >
           <center> <img src="images/<?php echo $row['image3']; ?>" style="width:100px;height:100px;"></center>
    </div><br>
    
     <div class="col-md-12">
          <i class="fas fa-lock prefix grey-text"></i>
      <label data-error="wrong" data-success="right" for="defaultForm-pass">Image4 </label>
          <input type="file" name="file4" id="defaultForm-pass" class="form-control validate" >
      <input type="hidden" name="hidden4" class="form-control" value="<?php echo $row['image4'];?>" >
           <center> <img src="images/<?php echo $row['image4']; ?>" style="width:100px;height:100px;"></center>
    </div>-->
    
    
    <br>

 
         
                
   
                

      </div>
      <div class="modal-footer d-flex justify-content-center">
      <center>  <button type="submit" class="btn btn-primary" name="change">Save Changes</button></center>
      </div>
    </form>
    </div>
  </div>
</div>

<!-- End Popup Modal -->

          <?php $a++;}?>
          
                    <!--tr>
                        <td>Garrett Winters</td>
                        <td>Accountant</td>
                        <td>Tokyo</td>
                        <td>63</td>
                        <td>2011/07/25</td>
                        <td>$170,750</td>
                    </tr>
                    <tr>
                        <td>Ashton Cox</td>
                        <td>Junior Technical Author</td>
                        <td>San Francisco</td>
                        <td>66</td>
                        <td>2009/01/12</td>
                        <td>$86,000</td>
                    </tr>-->
                  
                </tbody>
                <!--tfoot>
                    <tr>
                        <th>Name</th>
                        <th>Position</th>
                        <th>Office</th>
                        <th>Age</th>
                        <th>Start date</th>
                        <th>Salary</th>
                    </tr>
                </tfoot>-->
            </table>
            </div>
            </div>
          </div>
        </div>
      </div><!-- End Row-->

    </div>
    <!-- End container-fluid-->
    
    </div><!--End content-wrapper-->
   <!--Start Back To Top Button-->
    <a href="javaScript:void();" class="back-to-top"><i class="fa fa-angle-double-up"></i> </a>
    <!--End Back To Top Button-->
  
  <!--Start footer-->
  <?php include('footer.php');?>
  <!--End footer-->
   
  </div><!--End wrapper-->


  <!-- Bootstrap core JavaScript-->
  <script src="assets/js/jquery.min.js"></script>
  <script src="assets/js/popper.min.js"></script>
  <script src="assets/js/bootstrap.min.js"></script>
  
  <!-- simplebar js -->
  <script src="assets/plugins/simplebar/js/simplebar.js"></script>
  <!-- waves effect js -->
  <script src="assets/js/waves.js"></script>
  <!-- sidebar-menu js -->
  <script src="assets/js/sidebar-menu.js"></script>
  <!-- Custom scripts -->
  <script src="assets/js/app-script.js"></script>

  <!--Data Tables js-->
  <script src="assets/plugins/bootstrap-datatable/js/jquery.dataTables.min.js"></script>
  <script src="assets/plugins/bootstrap-datatable/js/dataTables.bootstrap4.min.js"></script>
  <script src="assets/plugins/bootstrap-datatable/js/dataTables.buttons.min.js"></script>
  <script src="assets/plugins/bootstrap-datatable/js/buttons.bootstrap4.min.js"></script>
  <script src="assets/plugins/bootstrap-datatable/js/jszip.min.js"></script>
  <script src="assets/plugins/bootstrap-datatable/js/pdfmake.min.js"></script>
  <script src="assets/plugins/bootstrap-datatable/js/vfs_fonts.js"></script>
  <script src="assets/plugins/bootstrap-datatable/js/buttons.html5.min.js"></script>
  <script src="assets/plugins/bootstrap-datatable/js/buttons.print.min.js"></script>
  <script src="assets/plugins/bootstrap-datatable/js/buttons.colVis.min.js"></script>

    <script>
     $(document).ready(function() {
      //Default data table
       $('#default-datatable').DataTable();


       var table = $('#example').DataTable( {
        lengthChange: false,
        buttons: [ ]
      } );
 
     table.buttons().container()
        .appendTo( '#example_wrapper .col-md-6:eq(0)' );
      
      } );

    </script>
  
</body>

</html>
