<?php
session_start();
require_once 'includes/config.php';

if (!isset($_SESSION['user_logged_in']) && $_SESSION['user_logged_in'] != TRUE) {
    header('Location:login.php');
}
$users=mysqli_query($con,'SELECT * FROM popupgroups ORDER BY id DESC');



if(isset($_GET['del_id']) && $_GET['del_id']!=''){
	$deleteEmployee=mysqli_query($con,"DELETE FROM popupgroups WHERE id=".$_GET['del_id']);
	if($deleteEmployee){
		$del_stat=1;
		$message='Popupgroups deleted successfully.';
	}
}
require_once 'includes/header.php';
?>




<?php
if (isset($del_stat) && $del_stat == 1) {
	echo '<div class="alert alert-info">'.$message.'</div>';
	}
?>
<div class="content">
        <div class="container-fluid">
          <div class="row">
            <div class="col-md-12">
			<a href="add_popupgroup.php" class="btn btn-primary btn-round">Add Popupgroup <div class="ripple-container"></div></a>

  
<div class="card">
                <div class="card-header card-header-primary">
                  <h4 class="card-title "> All Popup Groups</h4>
                  <p class="card-category"> </p>
                </div>
                <div class="card-body">
                  <div class="table-responsive">
	  <table class="table ">
		<tr>
		  <th>No.</th>
		 
		  <th>Group Name</th> 		  
		  <th> QR No</th> 		  
		 	  
		  
		  	  
		  <th>Action</th>
		  
		</tr>
		<?php
		if(mysqli_num_rows($users)>0){	
		$i=1;
		while($user=mysqli_fetch_array($users)){?>
		<tr>
		<td><?php echo $i;?></td>
		
		
		<td><?php echo $user['group_name'];?></td>
		<td><?php echo $user['qr_no'];?></td>
		
		
		
		<td>
		<a href="edit_popupgroup.php?id=<?php echo $user['id'];?>" title="Edit Product" class="btn btn-success"><i class="fa fa-edit"></i></a>
		<a href="popupgroups.php?del_id=<?php echo $user['id'];?>" class="btn btn-danger delete_btn" title="Products"><i class="fa fa-trash"></i></a>
		</td>
		
		</tr>	
		<?php $i++;}
		}
		?>   
	  </table>
 </div>
                </div>
              </div>
            </div>
            
          </div>
        </div>
      </div>
<?php include_once 'includes/footer.php'; ?>

<script type="text/javascript">
    $(document).ready(function () {
        $('.delete_btn').click(function () {
            var r = confirm("Are you sure?")
            if (r == true) {
                return true;
            } else {
                return false;
            }
        });
    });
</script> 