<?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.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
//*****************************************************
$script_base = 'in_bank';
$tableArray = array(
	'main' => 'i_bank',
	'primary_key' => 'id_bank',
);

//*****************************************************
// 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( 'user_defined' => '', 'dt' => 0),
	array( 'db' => 'desk_bank', 'dt' => 1, 'table' => 'i_bank' ),
    array( 'db' => 'kod_rentas', 'dt' => 2, 'table' => 'i_bank' ),
	array( 'db' => 'digit_bank', 'dt' => 3, 'table' => 'i_bank' ),
	array( 'dt' => 4, 
	'user_defined' => 
	'<a class="btn btn-sm btn-clean btn-icon mr-2" onclick="loadMyModal(\''.$script_base.'-tambah.php?id=%i_bank.id_bank%&readonly=1\', \'#ajax-modal\')" title="Papar">
		<span class="svg-icon svg-icon-primary svg-icon-2x">'.$File_svg.'</span>
	</a>
	<a class="btn btn-sm btn-clean btn-icon mr-2" onclick="loadMyModal(\''.$script_base.'-tambah.php?id=%i_bank.id_bank%\', \'#ajax-modal\')" title="Kemaskini">
		<span class="svg-icon svg-icon-primary svg-icon-2x">'.$Edit_svg.'</span>
	</a>'
	),
);
//*****************************************************
// WHERE SQL
// Array ($table_name, $column_name, $value, $symbol(default : '='))
//*****************************************************
$whereArray = array(

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