<?   
error_reporting(0);
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start();
session_start();
session_cache_limiter('private');
$cache_limiter 	= session_cache_limiter();
session_cache_expire(60);
$cache_expire 	= session_cache_expire(); 
date_default_timezone_set('Asia/Manila'); 
$CURRENT_DATE 	= date('Y-m-d H:i:s');
include_once('../config/minho.php');
include_once('../config/autoloadClass.php');
$autoload	=	new autoloadClass();
$mecon		=	new condbClass();
$main		=	array();
$main2		=	array();
$arr3		=	array();
$main3		=	array();
$main4		=	array();
$mainId		=	(isset($_POST['mainid']))	?	$_POST['mainid']	:	"";
$mecon->query("SELECT Id, Code, Fullname, Realty, DateApplicationReceived, DateAppliedAtMetrobank,
BrokerOrAgent, CashCardNumber, AccountNumber, Remarks, Status FROM brokeragent WHERE Status = :status AND Id = :id ORDER BY Id DESC");
$mecon->bind(':status', 'active');
$mecon->bind(':id', $mainId);
$main = $mecon->resultset(); 
$counter = count($main); 
$arr1 = array(); 
$arr2 = array(); 
$arr3 = array(); 
for($a=0; $a<$counter; $a++){ 
		$arr1['id']								= $main[$a]['Id'];
		$arr1['code']							=  trim(stripslashes(html_entity_decode($main[$a]['Code'])));
		$arr1['fullname']						=  trim(stripslashes(strtoupper(html_entity_decode(str_replace('&NTILDE;','&Ntilde;',$main[$a]['Fullname'])))));
		$arr1['realty']							=  trim(stripslashes(strtoupper(html_entity_decode(str_replace('&NTILDE;','&Ntilde;',$main[$a]['Realty'])))));
		$arr1['date_application_received']		=  (($main[$a]['DateApplicationReceived']=='0000-00-00') || ($main[$a]['DateApplicationReceived']=='1970-01-01') || ($main[$a]['DateApplicationReceived']=='')) ? "" : date('m/d/Y', strtotime($main[$a]['DateApplicationReceived'])); 
		$arr1['date_applied_at_metrobank']		=  (($main[$a]['DateAppliedAtMetrobank']=='0000-00-00') || ($main[$a]['DateAppliedAtMetrobank']=='1970-01-01') || ($main[$a]['DateAppliedAtMetrobank']=='')) ? "" : date('m/d/Y', strtotime($main[$a]['DateAppliedAtMetrobank'])); 
		$arr1['broker_or_agent']				=  $main[$a]['BrokerOrAgent'];
		$arr1['cashcardnumber']					=  $main[$a]['CashCardNumber'];
		$arr1['accountnumber']					=  $main[$a]['AccountNumber']; 
		$arr1['remarks']						=  trim(stripslashes(html_entity_decode($main[$a]['Remarks'])));
 
	$arr2[] = $arr1;
}
$arr3['data'] = $arr2;
echo json_encode($arr3); 
exit();
ob_end_flush();