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

	$where = '';
	$type  = $_GET['type'];
	

	if($type != '' && $type != 'null' && !empty($type)){
        $where .= ' AND  category_id = '.$type.'';
    }
	

	$obj = new Datatable($conn);

	$obj->aColumns 		= array('name', 'category_id', 'phone', 'mobile', 'mobile2', 'fax', 'email');
    $obj->eColumns 		= array('id');
    $obj->sIndexColumn 	= "id";
    $obj->sTable 		= " phone_book";
    $obj->myWhere 		= ' WHERE 1=1 ' . $where;
    $obj->datatable_process();

    
    $cou = 0;
    if(isset($_GET['iDisplayStart'])) {
    	$cou = $_GET['iDisplayStart'];
    }
    while ($aRow = mysqli_fetch_array($obj->rResult)) {
		$temp_arr = array();
		$temp_arr[] = $aRow['name'];
		$temp_arr[] = $aRow['phone'];
		$temp_arr[] = $aRow['mobile'];
		$temp_arr[] = $aRow['mobile2'];
		$temp_arr[] = $aRow['fax'];
		$temp_arr[] = $aRow['email'];
		$str = '';
		
		$str .= '<a href="index.php?page=phone_book/add.php&eid='.$aRow['id'].'" name="edit" class="btn btn-primary" data-toggle="tooltip" data-placement="top" title="EDIT CONTACT...!!"><em class="fa fa-pencil"></em></a>&nbsp;';
		
		/*$str .= '<button type="button" class="btn btn-danger delete_data" id="'.$aRow["id"].'" data-toggle="tooltip" data-placement="top" title="DELETE CONTACT..!!" onclick="confirmDelete(this);"><em class="fa fa-trash"></em></button>';*/

		$str .= '<button type="button" class="btn btn-danger delete_data" id="'.$aRow["id"].'" data-toggle="tooltip" data-placement="top" title="DELETE CONTACT..!!" onclick="confirmDelete(this);"><em class="fa fa-trash"></em></button>';
		
		$temp_arr[] = $str;

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

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