 <?php include("includes/db_config.php"); ?>
 <!DOCTYPE html>
<html lang="en-IN">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>Orange Groceries</title>
	<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
	<?php include("includes/css.php")?>
</head>
<body class="hold-transition skin-blue sidebar-mini">
	<div class="wrapper">
		<?php include("includes/header.php");?>
		<?php include("includes/sidebar.php");?>
		<div class="content-wrapper">
			<!-- Content Header (Page header) -->
			<section class="content-header">
				<h1>
					Dashboard
					<small>Control panel</small>
				</h1>
				<ol class="breadcrumb">
					<li><a href="index.php"><i class="fa fa-dashboard"></i> Home</a></li>
					<li class="active">Dashboard</li>
				</ol>
			</section>
			<!-- Main content -->
			<section class="content">
				<div class="row">
					<div class="col-xs-12">
						<div class="box box-danger">
							<div class="box-header">
								<div class="row">
									<div class="col-md-4"><h3 class="box-title">Product Details</h3></div>
									
								</div>
							</div>
							<div class="box-body table-responsive">
								<table class="table table-bordered table-striped example3">
									<thead>
										<tr>
											
											<th>Pages</th>
											<!-- <th>checkbox</th>
											<th>Delete</th> -->
										</tr>
									</thead>
									<tbody>
										
											<?php  $user_id=$_GET['id']; 
										$sql_empp=mysqli_query($conn,"select * from assign_pages where emp_id='".$user_id."'");
							            $res_empp= mysqli_fetch_array($sql_empp);
							            $pid=$res_empp['pages_id'];  	
							            $name_id = explode(",",$pid);
										//var_dump($name_id);
										foreach ($name_id as $key => $det) {
							            $sql_sc="select * from pages where id='".$det."'";
							            $res_sc= mysqli_query($conn,$sql_sc);
										while($result_sc = mysqli_fetch_array($res_sc)){ ?>
											<tr>
											<!-- <td><input name="checkbox[]" type="checkbox" value="<?php echo $result_sc['id']; ?>"></td>	 -->
											<td><?php echo $result_sc['name'];?></td>
										    </tr>
										    <?php } } ?>
									
									</tbody>
									<!-- <tfoot>
											<tr>
												<td colspan="12"><input type="button" id="btn_delete" name="delete" class="btn btn-success btn-sm pull-right" value="Delele Products"></td>
											</tr>

										</tfoot> -->
								</table>
							</div>
							<!-- /.box-body -->
						</div>
						<!-- /.box -->
					</div>
					<!-- /.col -->
				</div>
				<!-- /.row -->
			</section>
			<!-- /.content -->
		</div>
		<!-- /.content-wrapper -->
		<?php include("includes/footer.php");?>
		<div class="control-sidebar-bg"></div>
	</div>
	<?php include("includes/js.php");?>
<script>

 	$(document).ready(function(){
 
 $('#btn_delete').click(function(){
  
  if(confirm("Are you sure you want to delete this?"))
  {
   var id = [];
   
   $(':checkbox:checked').each(function(i){
    id[i] = $(this).val();
   });
   
   if(id.length === 0) //tell you if the array is empty
   {
    alert("Please Select atleast one checkbox");
   }
   else
   {
    $.ajax({
     url:'all_page_delete.php',
     method:'POST',
     data:{id:id},
     success:function(data)
     {
          $("#row" + id).remove();
            alert('Post Deleted!');
        },
        error: function () {
            alert('Error Deleting Post');
        } 
    });
   }
  }
  else
  {
   return false;
  }
 });
 
});
</script>
</body>
</html>
