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


	$obj = new Datatable($conn);

	$obj->aColumns 		= array('name', 'permissions');
    $obj->eColumns 		= array('id');
    $obj->sIndexColumn 	= "id";
    $obj->sTable 		= "roles";
    $obj->datatable_process();
    
    $cou = 0;
    if(isset($_GET['iDisplayStart'])) {
    	$cou = $_GET['iDisplayStart'];
    }
    while ($aRow = mysqli_fetch_array($obj->rResult)) {
        $temp_arr = array();

        $temp_arr[] = ++$cou;
		$temp_arr[] = $aRow['name'];
		
		$str = '';

		if( hasPermission($_SESSION['user_detail']['role_id'], 'user_edit') ) {
		$str .= '<a href="index.php?page=role_management/edit.php&eid='.$aRow['id'].'" name="edit" class="btn btn-primary" data-toggle="tooltip" data-placement="top" title="EDIT USER...!!"><em class="fa fa-pencil"></em></a>&nbsp;';
		}

		
		$temp_arr[] = $str;

        $obj->output['aaData'][] = $temp_arr;
    }

    echo json_encode($obj->output);
    exit();
?>