
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
<?php

error_reporting(0);

/*
 * 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
 */
 $status = "";
 $chkf = "";
 //include('callapi.php');
 session_start();
 
 $user_id = $_SESSION['UID'];
 
	if(isset($_SESSION["prospect_filter"]))	 
	{	
		$chkf = $_SESSION["prospect_filter"];
	}
	if($chkf != '')
	{
		if($_SESSION['role_id'] == '1')
		{
	//		$status = "date_format(creation_date,'%Y') >= ((date_format(sysdate(),'%Y'))-1) and ".$_SESSION["prospect_filter"]." and "."lead_id <> '' and assignment_to_id = '".$user_id."'";
		}
		else
		{
			
			
	//		$status = "date_format(creation_date,'%Y') >= ((date_format(sysdate(),'%Y'))-1) and ".$_SESSION["prospect_filter"]." and "."lead_id <> ''";
		}
	}
	else
	{ 
		if($_SESSION['role_id'] == '1')
		{	
	//$status = "date_format(creation_date,'%Y') >= ((date_format(sysdate(),'%Y'))-1) and "."lead_id <> '' and assignment_to_id = '".$user_id."'";
			
		}
		else
		{
	//		$status = "date_format(creation_date,'%Y') >= ((date_format(sysdate(),'%Y'))-1) and "."lead_id <> ''";
		}
	}
//echo $status;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Easy set variables
 */

// DB table to use
$table = 'xx_accounts_vu';

// Table's primary key
$primaryKey = 'acc_id';

// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(

	array( 'db' => 'acc_id',  		'dt' => 0),
	array( 'db' => 'acc_id', 			'dt' => 1,
    		'formatter' => function( $d, $row ) {return '<a target="pta" class="btn btn-link" href="account_details.php?acc_id='.$d.'">'.$row['full_name']."</a>";}
	),
	array( 'db' => 'mobile1',  		'dt' => 2),
	array( 'db' => 'mobile2',  		'dt' => 3),
	array( 'db' => 'mobile3',  		'dt' => 4),
	array( 'db' => 'salary_cat',  		'dt' => 5),
	array( 'db' => 'income_type',	'dt' => 6 ),
	array( 'db' => 'bank', 'dt' => 7 ),
	array( 'db' => 'nationality', 'dt' => 8 ),
	array( 'db' => 'gender', 'dt' => 9 ),
	array( 'db' => 'work_sector', 'dt' => 10 ),
	array( 'db'  => 'creation_date',	'dt' => 11,
		'formatter' => function( $d, $row ) {if($d == ""){}else{ return date( 'jS M y', strtotime($d));}}
	),
	array( 'db' => 'created_by',  'dt' => 12 ),
	array( 'db'  => 'modified_date',	'dt' => 13,
		'formatter' => function( $d, $row ) {if($d == ""){}else{ return date( 'jS M y', strtotime($d));}}
	),
	array( 'db' => 'modified_by', 'dt' => 14 ),
	array( 'db' => 'full_name', 'dt' => 15 )
	
);

// SQL server connection information
$sql_details = array(
	'user' => 'balubaid_tajeer_crm',
	'pass' => 'BGCjeddah@69',
	'db'   => 'balubaid_tajeer_crm',
	'host' => 'localhost'
);


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * If you just want to use the basic configuration for DataTables with PHP
 * server-side, there is no need to edit below this line.
 */

require( 'ssp.class2.php' );

echo json_encode(
	SSP::complex( $_POST, $sql_details, $table, $primaryKey, $columns,null,$status )
	
);


