<?php 
 session_start();
?>





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

$menu=$_POST['menu'];
//$image_name=$_FILES['file']['name'];                 
//$image_size=$_FILES['file']['size'];
//$image_type=$_FILES['file']['type'];
//$image_tmp=$_FILES['file']['tmp_name'];
//$store="parler_image/".$image_name;                              
//$upload=move_uploaded_file($image_tmp,$store);
    
    //if($image_name=='')
    //{
     // $image_name=$_POST['hidden'];
    //}
     // else
      //{
      //$image_name=$_FILES['file']['name'];
   // }
   $query=mysqli_query($con,"UPDATE tbl_menu SET menu_name='$menu',date=now() where menu_id='$i'");
   if($query==true)
   {
     echo"<script>alert('Your details has been updated');
     window.location.href='category-detail.php';</script>";
   }
   else
   {
     echo"<script>alert('Your details has not been updated');window.location.href='category-detail.php';</script>";
   }
   }
   ?>
   
 <!--Edit Product code End -->

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

include('dbcon.php');
error_reporting(0);
if($_GET['state_id'])
{
$a=$_GET['state_id'];
$query=mysqli_query($con,"DELETE FROM tbl_menu WHERE menu_id='$a'");
if($query)
{
  echo"<script>alert('Details has been deleted');
  window.location.href='category-detail.php';</script>";
}
else
{
  echo"<script>alert('Details has not been 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>Category 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"/>
  
</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>Category Detail</div>
            <div class="card-body">
              <div class="table-responsive">
              <table id="example" class="table table-bordered">
                <thead>
                    <tr>
                        <th>Sr No.</th>
                        <th>Menu Name</th>
                       
                       
                       
                        <th>Date</th>
                          <th>Status</th>
                        
                         <th>Action</th>
                        
                    </tr>
                </thead>
                <tbody>
				
				<?php 
				$a=1;
				$query=mysqli_query($con,"SELECT * FROM tbl_menu order by 	menu_id desc");?>
				<?php while($row=mysqli_fetch_array($query)){ 
		$status="Active";
	if($row['Status']=='Deactive')
	{
		$status="Deactive";
	}
	
		?>
                    <tr>
                        <td><?php echo $a;?></td>
                        <!--title condition apply-->
<?php if($row['menu_name']!=''){ ?>
 <td class="center"><?php echo $row['menu_name']; ?></td>
<?php } else { ?>   
  <td class="center"><?php echo "............"; ?></td>
<?php }?>

<!--title condition end--->
                  

	



                      
					  
 


            <td><?php echo $row['date'];?></td>


         
 <?php if($row['status']=='0'){?>      
         <td><button type="submit"  class="btn btn-danger"><a onclick="return confirm('Are You Sure Want to Update status ?')" href="category-detail.php?menu_id=<?php echo $row['menu_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="category-detail.php?menu_id=<?php echo $row['menu_id'];?>&status=<?php echo $row['status']; ?>" style="color:white">Active</a></button></td>
        <?php }?>
 

                       

					
 <td>
					
<i class="fa fa-edit" data-toggle="modal" data-target="#m<?php echo $row['menu_id'];?>" style="font-size:23px;color:blue;cursor:pointer;"></i> / 
<a onclick="return confirm('Are you sure want to delete ?');" style="color:white" href="category-detail.php?state_id=<?php echo $row['menu_id'];?>"> <i class="fa fa-trash-o" style="font-size:23px;color:red"></i></a>					
					</td>
                    </tr>
					
					
<!-- start Popup Modal -->

<div class="modal fade" id="m<?php echo $row['menu_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="id" value="<?php echo $row['menu_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 Category</label>
              <input type="text" name="menu" id="" class="form-control validate" value="<?php echo $row['menu_name'];?>">
                </div>

 
         
                
	 
                

      </div>
	    <div class="modal-footer d-flex justify-content-center">
      <center>  <button 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>
