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


	$obj = new Datatable($conn);

	$obj->aColumns 		= array('account_group', 'descr');
    $obj->eColumns 		= array('id');
    $obj->sIndexColumn 	= "id";
    $obj->sTable 		= "account_control";
    $obj->myWhere 		= " WHERE company_id = '".$_SESSION['company_id']."' AND branch_id = '".$_SESSION['branch_id']."'";
    $obj->datatable_process();
    
    $cou = 0;
    if(isset($_GET['iDisplayStart'])) {
    	$cou = $_GET['iDisplayStart'];
    }
    while ($aRow = mysqli_fetch_array($obj->rResult)) {

    	$state     = "select * from act_master where id ='".$aRow['account_group']."'";
        $state_res = mysqli_query($conn,$state);
        $state_row = mysqli_fetch_array($state_res);

        $temp_arr = array();

		$temp_arr[] = ++$cou;
		$temp_arr[] = $aRow['descr'];
		$temp_arr[] = $state_row['ac_name'];
		
        $str = '';
		if( hasPermission($_SESSION['user_detail']['role_id'], 'ac_edit') ) {
		$str .= '<a href="index.php?page=account_control/add.php&eid='.$aRow['id'].'" name="edit" class="btn btn-primary" data-toggle="tooltip" data-placement="top" title="EDIT CONTROLING...!!"><em class="fa fa-pencil"></em></a>&nbsp;';
		}

		if( hasPermission($_SESSION['user_detail']['role_id'], 'ac_delete') ) {
		$str .= '<button type="button" class="btn btn-danger delete_data" id="'.$aRow["id"].'" data-toggle="tooltip" data-placement="top" title="DELETE CONTROLING..!!" onclick="confirmDelete(this);"><em class="fa fa-trash"></em></button>';
		}
		$temp_arr[] = $str;

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

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