<?php
error_reporting(0); //7dec25
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();
$utility	=	new utilityClass(); 


if(isset($_POST['mainid'])){
$task					= isset($_POST['action'])				? trim($_POST['action']) : "";
$mainid					= isset($_POST['mainid'])				? trim($_POST['mainid']) : "";
$conversionType			= isset($_POST['conversion_type'])		? trim($_POST['conversion_type']) : "";
$conversionValue		= isset($_POST['conversion_value'])		? trim($_POST['conversion_value']) : "";

$currentUser 	= $_SESSION['danvilles_username'];
$timeStamp		= date('Y-m-d H:i:s');

$mainArr	= array();
$output 	= "";

$mainArr['ReservationId'] 		= $mainid;
 //31DEC24
if($conversionType=='release pagibig'){ 

	$mainArr['ReleasedPagibig'] 	= date('Y-m-d', strtotime($conversionValue));

}else if($conversionType=='processed'){

	$mainArr['ProcessedDate'] 		= date('Y-m-d', strtotime($conversionValue));

}else if($conversionType=='released'){

	$mainArr['ReleasedDate'] 		= date('Y-m-d', strtotime($conversionValue));	

}else if($conversionType=='bir_date_submitted'){

	$mainArr['BirDateSubmitted'] 	= date('Y-m-d', strtotime($conversionValue));	

}else if($conversionType=='bir_date_released'){

	$mainArr['BirDateReleased'] 	= date('Y-m-d', strtotime($conversionValue));	

}else if($conversionType=='bir_ecar'){

	$mainArr['BirEcar'] 			= $conversionValue;	

}else if($conversionType=='registry_date_released'){

	$mainArr['RegistryDateReleased'] 	= date('Y-m-d', strtotime($conversionValue));	

}else if($conversionType=='registry_date_submitted'){

	$mainArr['RegistryDateSubmitted'] 	= date('Y-m-d', strtotime($conversionValue));	

}else if($conversionType=='registry_new_tct_no'){

	$mainArr['RegistryNewTCTNo'] 	= $conversionValue;

}else if($conversionType=='city_hall_date_submitted'){

	$mainArr['CityHallDateSubmitted'] 	= date('Y-m-d', strtotime($conversionValue));	

}else if($conversionType=='city_hall_date_released'){

	$mainArr['CityHallDateReleased'] 	= date('Y-m-d', strtotime($conversionValue));	

}else if($conversionType=='city_hall_new_tax_dec_land'){

	$mainArr['CityHallNewTaxDecLand'] 	= $conversionValue;

}else if($conversionType=='city_hall_new_tax_dec_bldg'){

	$mainArr['CityHallNewTaxDecBldg'] 	= $conversionValue;

}else if($conversionType=='remarks'){

	$mainArr['Remarks'] 	= $conversionValue;

}

$existReservation = $utility->checkExistField('ReservationId','conversion','reservationId',$mainid);
	if($existReservation===false){
		//insert 
			$mainArr['CreatedDate'] 	= $timeStamp;
			$mainArr['CreatedBy'] 		= $currentUser; 
			$output 					= $mecon->insertSingleQuery($mainArr,"conversion"); 

	}else{
		//reservation exist update record
			$mainArr['UpdatedDate'] 	= $timeStamp;
			$mainArr['UpdatedBy'] 		= $currentUser;
			$condArr['ReservationId']	= $mainid;
			$output 					= $mecon->updateQuery($mainArr,"conversion",$condArr);

	} 


$resultArr 						= array();
$resultArr['output']	  		= $output;
echo json_encode($resultArr);
}
exit();
ob_end_flush();