<?php
include('config/minho.php');
include('config/autoloadClass.php');
$autoLoad		=	new autoloadClass();
$mecon			=	new condbClass();
$project		=	isset($_POST['project'])	? str_replace("_"," ",$_POST['project']) : "";
$model			=	isset($_POST['model'])		? str_replace("_"," ",$_POST['model']) : "";
$curphase		=	isset($_POST['curphase']) ? trim(strip_tags(htmlentities(addslashes($_POST['curphase'])))) : "";
$curblock		=	isset($_POST['curblock']) ? trim(strip_tags(htmlentities(addslashes($_POST['curblock'])))) : "";
$curlot			=	isset($_POST['curlot']) ? trim(strip_tags(htmlentities(addslashes($_POST['curlot'])))) : "";
   

  
$mecon->query("SELECT Id, Project, Model, Phase, Block, Lot, LastName, FirstName, MiddleName, ReservationStatus, Status FROM reservation WHERE ReservationStatus = :status AND Project = :project AND Model = :model  AND Phase = :phase AND Block = :block AND Lot = :lot ORDER BY Id DESC ");
$mecon->bind(':status', 'active'); 
$mecon->bind(':project', $project);
$mecon->bind(':model', $model);
$mecon->bind(':phase', $curphase);
$mecon->bind(':block', $curblock);
$mecon->bind(':lot', $curlot);
$main = $mecon->resultset(); 
$counter = count($main); 
$arr1 = array();
$arr2 = array(); 

if($counter>0){

	for($a=0; $a<$counter; $a++){ 
		$arr1['id']				= $main[$a]['Id'];
		$arr1['last_name']		= $main[$a]['LastName'];
		$arr1['first_name']		= $main[$a]['FirstName'];
		$arr1['middle_name']	= $main[$a]['MiddleName'];
		$arr1['phase']			= $main[$a]['Phase'];
		$arr1['block']			= $main[$a]['Block'];
		$arr1['lot']			= $main[$a]['Lot'];
		$arr2[] = $arr1;
	}  

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