<div class="breadcrumb">
    <h1>User Permission </h1>
    <ul>
        <li><a href="<?php echo SITE_URL.ADMIN_DIR ?>">Dashboard</a></li>
        <li>User Permission list</li>
    </ul>
</div>
<div class="separator-breadcrumb border-top"></div>

<form action="" method="post" id="searchFrm" name="searchFrm">
<div class="row">
    <div class="col-lg-12 col-md-12">
        <div class="card mb-5">
            <div class="card-body">
                <div class="row row-xs">
                    
                    
                    <div class="col-md-2 mt-3 mt-md-0"  id="div_country_name">
                        <label for="title">Permission Name</label>
                        <input type="text" class="form-control" name="title" id="title"  />
                    </div>

                    
                    <div class="col-md-2 mt-3 mt-md-0">
                        
                        <label for="">&nbsp;</label>
                        <button type="submit" name="submit" class="btn btn-primary btn-block">Search</button>
                    </div>
                    <div class="col-md-2 mt-3 mt-md-0">
                        
                        <label for="">&nbsp;</label>
                        <button type="reset" name="reset" class="btn btn-primary btn-block" onClick="window.location.reload()">Reset</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</form>

<div class="row mb-4"> 
  <div class="col-md-6">
  </div>
  <div class="col-md-6 pull-right">
      <div class="button-group">
         <a href="userPermissionadd.php" class="btn btn-dark m-1"><i class="i-Add-Country"></i> Add Permission</a>
      </div>    
  </div>  
</div>
<div class="widget-body">
    <div class="portlet-body">
                        
    <?php echo (isset($successMsg) && $successMsg!='') ? "<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button>".base64_decode($successMsg)."</div>" : '' ; ?>
    <?php echo (isset($failedMsg) && $failedMsg!='') ? "<div class='alert alert-danger'><button data-dismiss='alert' class='close' type='button'>×</button>".base64_decode($failedMsg)."</div>" : '' ?>
   
    <div id="status_msg" style="display: none;"><div class="alert alert-success"><button data-dismiss='alert' class='close' type='button'>×</button>&nbsp;</div></div>
    <div id="alert_msg" style="display: none;"><div class="alert alert-danger"><button data-dismiss='alert' class='close' type='button'>×</button>&nbsp;</div></div>

    </div>
</div>


<div class="row mb-4">
    <div class="col-md-12 mb-4">
        <div class="card text-left">

            <div class="card-body">
                <div class="table-responsive">
                  <form id="listFrm" name="listFrm" action="" method="post">       
                    <input type="hidden" id="action" name="action" value="">
                    <table id="list" class="display table table-striped table-bordered" style="width:100%">
                        <thead>
                            <tr>
                                <th class="center"><input type="checkbox" name="checkall" id="checkall"></th>
                                 <th>ID</th>
                                <th>Permission Name</th>
                                <th>Created At</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                    </table>
                  </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="application/javascript">
   $(document).ready(function() {
    $('#list').DataTable( { 
          "ajax": "userPermission.php?act=load",
          "processing": true,
          "serverSide": true,
          "pageLength": 25,
                "aaSorting": [],
                "aoColumnDefs": [
                    { 'bSortable': false, 'aTargets': [0] }
                ],
          language: {
              "processing" : "<div class='loader-bubble loader-bubble-primary m-5'></div>",
              "sEmptyTable" :  "No records found."
          }
          
      });


      $( "#searchFrm" ).on( "submit", function(e) {
        e.preventDefault();

        var title = $("#title").val();
        
        $('#list').DataTable().destroy();
          $('#list').DataTable({ 
            "ajax": "userPermission.php?act=load&title="+title,
            "processing": true,
            "serverSide": true,
            "pageLength": 25,
                  "aaSorting": [],
                  "aoColumnDefs": [
                      { 'bSortable': false, 'aTargets': [0] }
                  ],
            language: {
                "processing" : "<div class='loader-bubble loader-bubble-primary m-5'></div>",
                "sEmptyTable" :  "No records found."
            }
            
        });

      });

    });
</script>