<?php 
  if( !hasPermission($_SESSION['user_detail']['role_id'], 'user_list') ) {
    echo '<script>window.location.href="index.php?page=no_permission.php"</script>';
    die();
  }
?> 
<section class="content-header">
  <div class="row">
      <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 bottom20">
        <h3 class="capital font15 padding5 bold">VIEW ROLE DETAILS</h3>
      </div>
      <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 text-right bottom20">
        <h3>
          <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'user_add') ) { ?>
          <a href="index.php?page=role_management/permission.php" class="btn btn-danger capital bottom10 custome-btn">ADD NEW ROLE</a>
          <?php } ?>
        </h3>
      </div>
  </div>
</section>
<hr class="bottom35"> 
<section class="hitz-top-header">
  <div class="card bottom40">
    <div class="card-body">
      <table id="example1" class="table table-bordered table-striped list_data">
        <thead>
          <tr>
            <th width="50">SR NO.</th>
            <th>ROLE</th>
            <th width="60">Actions</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td colspan="3"><?php echo "NO RECORD FOUND"; ?></td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</section>
<div id="dataModal" class="modal fade">
   <div class="modal-dialog modal-lg">
      <div class="modal-content">
         <div class="modal-body" id="employee_detail">
            <div id="loadingDiv">
              <center><img src="loading.gif" style="width: 50px;height: 50px;"><BR/>
                <h6>PLEASE WAIT DATA LOADED</h6>
              </center>
            </div>  
         </div>
         <div class="modal-footer">  
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>  
         </div>
      </div>
   </div>
</div>
<script type="text/javascript">
    jQuery(document).ready(function() {
      loadDataTable();
    });

    
    function loadDataTable(){
        if(typeof dTable!='undefined'){dTable.fnDestroy();}
    
        dTable=jQuery('.list_data').dataTable({
            "bProcessing"       : true,
            "order"             : [ [0, 'asc'] ],
            "aLengthMenu"       : [ [5, 10, 15, 20, 25, 50, 100], [5, 10, 15, 20, 25, 50, 100] ],
            'iDisplayLength'    : 10,
            "aoColumns"         : [
                {"sClass": ""}, {"sClass": ""}, {"sClass": "text-center"}
            ],
            "bServerSide"       : true,
            "sAjaxSource"       : 'role_management/fetch.php',
        });
    }

    function viewData(e){
      var $i = $(e).attr("id");
      $.ajax({
      'type': 'POST',
      'url': 'role_management/role_details.php',
      'data': {
      'role_id': $i
      },
      dataType: 'JSON',
      success: function (data) {
        if(data.status == 1) {
          $('#employee_detail').html(data);  
          $('#dataModal').modal("show");
          $("#loadingDiv" ).remove();
        }else if(data.status == 0){
          $('#loadingDiv');
          $('#dataModal').modal("show");
          
        }
          
      }
    });
    }
  </script>
