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


	$obj = new Datatable($conn);

	$obj->aColumns 		= array('act_code', 'ac_name', 'account_group', 'dr_open_bal', 'cr_open_bal', 'created_id');
    $obj->eColumns 		= array('id');
    $obj->sIndexColumn 	= "id";
    $obj->sTable 		= "act_master";
   
    $obj->datatable_process();
    
    $cou = 0;
    if(isset($_GET['iDisplayStart'])) {
    	$cou = $_GET['iDisplayStart'];
    }
    $master_user = combine(getAllRecords('users'), 'id', 'name');
    while ($aRow = mysqli_fetch_array($obj->rResult)) {

    	$temp_arr = array();

		$temp_arr[] = ++$cou;
		$temp_arr[] = $aRow['act_code'];
		$temp_arr[] = $aRow['ac_name'];
		$temp_arr[] = $aRow['account_group'];
		$temp_arr[] = $aRow['dr_open_bal'];
		$temp_arr[] = $aRow['cr_open_bal'];
		$temp_arr[] = @$master_user[$aRow['created_id']];
		$str = '';
		$str .= '<a href="index.php?page=account_mst/manage.php&eid='.$aRow['id'].'" name="edit" class="btn btn-info" data-toggle="tooltip" data-placement="top" title="EDIT ACCOUNT...!!"><em class="fa fa-paperclip"></em></a>&nbsp;';

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

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

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

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