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


	$obj = new Datatable($conn);

	$obj->aColumns 		= array('name', 'phone', 'email', 'panno', 'gst', 'address', 'status');
    $obj->eColumns 		= array('id');
    $obj->sIndexColumn 	= "id";
    $obj->sTable 		= " company_mst";
    $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'];
		$temp_arr[] = $aRow['phone'];
		$temp_arr[] = $aRow['address'];
		$temp_arr[] = $aRow['email'];
		$temp_arr[] = $aRow['panno'];
		$temp_arr[] = $aRow['gst'];
		
		$label = '';
		if($aRow['status'] == '0'){ 
			$label .='<span class="label label-md label-warning">ACTIVE</span>';
		}else{
			$label .='<span class="label label-md label-danger">IN-ACTIVE</span>';
		}
		
		$temp_arr[] = $label;

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

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

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

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