<?php
include("lib/config.php");

$groupID = isset($_GET["gid"])?$_GET["gid"]:'';
?>

<div class="box-content">
  <form method="post" name="frmGroups" id="frmGroups">
    <input type="hidden" name="action" value="delete">
    <input type="hidden" name="group_id" value="<?php echo(isset($groupID))?$groupID:'';?>">
    <div class="alert alert-danger" role="alert">
  		Are you sure want to delete this Group permanently?
	</div>
    <div style="text-align:right;">
      <button data-loading-text="Saving..." type="submit" class="btn btn-danger"> <i class="fa fa-floppy-o"></i> Delete</button>
      <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
    </div>
  </form>
</div>
<script>
$(document).ready(function(e){
    
	$("#frmGroups").on('submit', function(e){
	  
        e.preventDefault();
		
        $.ajax({
            type: 'POST',
            url: 'groups-config.php',
            data: new FormData(this),
            //data: userData,
            contentType: false,
            cache: false,
            processData:false,
			dataType: 'JSON',
            beforeSend: function(){
                //$('.submitBtn').attr("disabled","disabled");
                //$('#fupForm').css("opacity",".5");
            },
            success: function(msg){
			   				
                //$('.statusMsg').html('');
				
                if(msg[0].message == 'ok'){
				
                    $('#frmGroups')[0].reset();
					
					//$('.statusMMsg').html('<span style="font-size:18px;color:#34A853">Product(s) added successfully.</span>');
					$('#myModal').modal('hide');
					
					getGroups(); 
					
					Lobibox.notify('success', {
						title: 'Success',
						msg: 'Record deleted successfully.'
					});
					
                }
				else
				{   
					//$('.statusMMsg').html('<span style="font-size:18px;color:#EA4335">Some problem occurred, please try again.</span>');
					$('#myModal').modal('hide');
					
					Lobibox.notify('error', {
						title: 'Error',
						msg: 'Some problem occurred, please try again.'
					});
                }
            }
        });
    });
	
});
</script>