<?php include('lib/config.php');?>
<?php 
  //--------------- Category Info ----------
  $srno = 0;
								  
  $selQry_groups = "SELECT * FROM ".TBL_USERS_GROUPS." WHERE id !='1' ORDER BY group_name";
  $groupsInfo =  $con->getMultiRow($selQry_groups, __FILE__,__LINE__);
  $totGroupsListings = count($groupsInfo);
	if($totGroupsListings>0)
	{
		?>

<table id="tblGroupsListings" class="table table-striped table-bordered" style="width:100%">
  <thead>
    <tr>
      <th>Sr#</th>
      <th>Name</th>
      <th>Description</th>
      <th>Status</th>
      <th>Modules Access</th>
      <th>Edit</th>
      <th>Delete</th>
    </tr>
  </thead>
  <tbody>
    <?php 
		for($grp=0;$grp<$totGroupsListings;$grp++)
		{
			$srno++;
  //----------------------------------------
?>
    <tr>
      <td><?php echo $srno;?>.</td>
      <td style="text-align:left;"><?php echo $groupsInfo[$grp]['group_name'];?></td>
      <td style="text-align:left;"><?php echo $groupsInfo[$grp]['group_description'];?></td>
      <td style="text-align:left;"><?php if($groupsInfo[$grp]['status']=='1'){?>
        <button type="button" class="btn btn-sm btn-success">Active</button>
        <?php }else if($groupsInfo[$grp]['status']=='0'){?>
        <button type="button" class="btn btn-sm btn-danger">InActive</button>
        <?php }?>
      </td>
      <td><p data-placement="top" data-toggle="tooltip" title="">
          <button class="btn btn-info btn-xs openPopup" data-title="Groups Modules Access" data-toggle="modal" data-target="groups-modules-access.php?gid=<?php echo $groupsInfo[$grp]['id'];?>" ><span class="glyphicon glyphicon-user"></span> Modules Access</button>
      </td>
      <td><p data-placement="top" data-toggle="tooltip" title="">
          <button class="btn btn-primary btn-xs openPopup" data-title="Edit Group" data-target="edit-group.php?gid=<?php echo $groupsInfo[$grp]['id'];?>"><span class="glyphicon glyphicon-pencil"></span> Edit</button>
        </p></td>
      <td><p data-placement="top" data-toggle="tooltip" title="">
          <button class="btn btn-danger btn-xs openPopup" data-title="Delete Group" data-toggle="modal" data-target="del-group.php?gid=<?php echo $groupsInfo[$grp]['id'];?>" ><span class="glyphicon glyphicon-trash"></span> Delete</button>
      </td>
    </tr>
    <?php }?>
  </tbody>
</table>
<?php 
}?>
<script>
$(document).ready(function(e){
	
	$('#tblGroupsListings').DataTable();
	
	$( ".openPopup" ).click(function() {
	 
	  var dataURL = $(this).attr('data-target');
	  var dataTitle = $(this).attr('data-title');
	  
	  $('#myModal').find('.modal-title').text(dataTitle);
      //$('#myModal').modal({show:true});  
		$('.modal-body').load(dataURL,function(){
            $('#myModal').modal({show:true});
        });
	});
});
</script>
