<?php
 
/*
 * DataTables example server-side processing script.
 *
 * Please note that this script is intentionally extremely simply to show how
 * server-side processing can be implemented, and probably shouldn't be used as
 * the basis for a large complex system. It is suitable for simple use cases as
 * for learning.
 *
 * See http://datatables.net/usage/server-side for full details on the server-
 * side processing requirements of DataTables.
 *
 * @license MIT - http://datatables.net/license_mit
 */
 
include_once ("includes/setup_pemohon.inc.php");
//*****************************************************
//Get all POST and GET value
//*****************************************************
$sqlOnly = fetch_postget_val('sqlOnly',$_POST, $_GET);
//*****************************************************
// MAIN TABLE AND JOIN TABLE
// main = main table name in the database,
// sub['name'] = join table name
// sub['sub_id'] = join table identifier
// sub['main_id'] = main table identifier
// sub['join_type'] = type of join. Default = 'LEFT'
// sub['aka'] = put alternative name for table
//*****************************************************
$tableArray = array(
	'main' => 'm_bantuan',
	'primary_key' => 'id_bantuan',
	/*'sub' => array(
		array('name' => 'i_statusmohon', 'sub_id' => 'id_statusmohon', 'main_id' => 'id_statusmohon'),
	),*/
);

//*****************************************************
// DATATABLE COLUMN
// db = column name in the database,
// dt = DataTables column identifier
// table = database table name
// akaFrom = use if and only if there is aka name for table
//*****************************************************
$columns = array(
    array( 'bil_col' => '', 'dt' => 0),
    array( 'db' => '1st_pilihan', 'dt' => 1, 'table' => 'm_bantuan' ),
    array( 'db' => '1st_subpilihan', 'dt' => 2, 'table' => 'm_bantuan' ),
    array( 'db' => '2nd_pilihan', 'dt' => 3, 'table' => 'm_bantuan' ),
    array( 'db' => '2nd_subpilihan', 'dt' => 4, 'table' => 'm_bantuan' ),
    array( 'db' => '3rd_pilihan', 'dt' => 5, 'table' => 'm_bantuan' ),
    array( 'db' => '3rd_subpilihan', 'dt' => 6, 'table' => 'm_bantuan' ),
);

//*****************************************************
// WHERE SQL
// Array ($table_name, $column_name, $value, $symbol(default : '='))
//*****************************************************
$whereArray = array(
	array('m_bantuan', 'id_pemohon', $my_details->usr_id),
);

//echo SSP::myComplex($_POST, $sql_details, buildSelectQuery($columns), buildFromQuery($tableArray), $tableArray['main'].'.'.$tableArray['primary_key'], $columns, 1, buildWhereQuery($whereArray));
//echo "whereArray = ".count($whereArray);
//exit(0);
//*****************************************************
// SSP GET JSON
// No need to modify below
//*****************************************************
if($sqlOnly == 1)
{
	//LEAVE EMPTY FOR FUTURE USAGE
}
else
{	
	$temp_result = SSP::myComplex($_POST, $sql_details, buildSelectQuery($columns), buildFromQuery($tableArray), $tableArray['main'].'.'.$tableArray['primary_key'], $columns, 0, buildWhereQuery($whereArray));
	for($num = 0; $num < count($temp_result['data']); $num++)
	{
		
	}
	echo json_encode(
		$temp_result
	);
}