<?php
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();
$utility	=	new utilityClass();
$task					= isset($_POST['action']) ? trim($_POST['action']) : "";
$house_construction		= isset($_POST['batch_update_house_construction']) ? trim($_POST['batch_update_house_construction']) : ""; 
$lots					= isset($_POST['batch_update_lot']) ? $_POST['batch_update_lot'] : ""; 
$model					= isset($_POST['batch_update_model']) ? trim(strip_tags($_POST['batch_update_model'])) : ""; 
$phase					= isset($_POST['batch_update_phase']) ? trim(strip_tags($_POST['batch_update_phase'])) : ""; 
$block					= isset($_POST['batch_update_block']) ? trim(strip_tags($_POST['batch_update_block'])) : ""; 
 
$currentUser 	= $_SESSION['castalia_username'];
$timeStamp		= date('Y-m-d H:i:s');
//SAVING CHECKLIST DETAILS   
$mainArr	= array();
$output 	= "";
$lotCtr		= count(array_filter($lots));
$lotFilter	= array_filter($lots);
 $output	= ""; 
 $outputArr	= array();

if($lotCtr!=0){
		 foreach($lotFilter as $lotIndex => $lotVal){  
				$lot_update = $lotVal;		
				$sql_update = "UPDATE reservation, monitoring_folders SET monitoring_folders.HouseConstruction = '$house_construction' WHERE  reservation.Id = monitoring_folders.ReservationId AND reservation.Phase='$phase' AND reservation.Block='$block' AND reservation.Lot='$lot_update' AND reservation.Model='$model' ";
				$mecon->query($sql_update);
				$main = $mecon->execute(); 
				$outputArr[] = $main;
		 }
}else{
				$sql_update = "UPDATE reservation, monitoring_folders SET monitoring_folders.HouseConstruction = '$house_construction' WHERE  reservation.Id = monitoring_folders.ReservationId AND reservation.Phase='$phase' AND reservation.Block='$block' AND reservation.Model='$model' ";
				$mecon->query($sql_update);
				$main = $mecon->execute(); 
				$outputArr[] = $main;
}
$output = array_unique($outputArr);
 
$resultArr 						= array();
$resultArr['output']	  		= $output; 

echo json_encode($resultArr); 
exit();
ob_end_flush();