<?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();
$main		=	array();
$main2		=	array();
$arr3		=	array();
$main3		=	array();
$main4		=	array();
$model		=	(isset($_POST['current_model'])) ? str_replace('_',' ',trim(strip_tags($_POST['current_model']))) : "";
$mecon->query("SELECT Id, Model, Project, DefaultRequiredGrossIncome, DefaultAmortization, DefaultPricelistRemarks, Status,ReservationFee, DefaultStatus, DefaultSellingPrice, DefaultLoanablePrice FROM model WHERE Status = :status AND Model = :model ORDER BY Id DESC");
$mecon->bind(':status', 'active');
$mecon->bind(':model', $model);
$main = $mecon->resultset(); 
$counter = count($main); 
$arr1 = array();
$arr2 = array();
$arr3 = array(); 
for($a=0; $a<$counter; $a++){ 
		$arr1['id']			= $main[$a]['Id']; 
		$arr1['status']		= trim(html_entity_decode(stripslashes($main[$a]['DefaultStatus'])));
		$arr1['project']	= trim(html_entity_decode(stripslashes($main[$a]['Project'])));
		$arr1['model']		= trim(html_entity_decode(stripslashes($main[$a]['Model'])));
	//	$arr1['template']		=  trim(html_entity_decode(stripslashes($main[$a]['PricelistTemplate'])));
		$arr1['loanable_price']		=  ($main[$a]['DefaultLoanablePrice']!=0) ? $main[$a]['DefaultLoanablePrice']  : $main[$a]['DefaultLoanablePrice']; 
		$arr1['selling_price']		=  ($main[$a]['DefaultSellingPrice']!=0) ? $main[$a]['DefaultSellingPrice'] : $main[$a]['DefaultSellingPrice']; 
		$arr1['reservation_fee']		=  ($main[$a]['ReservationFee']!=0) ? $main[$a]['ReservationFee'] : $main[$a]['ReservationFee']; 
		$arr1['gross_income']		=  ($main[$a]['DefaultRequiredGrossIncome']!=0.00) ? $main[$a]['DefaultRequiredGrossIncome'] : $main[$a]['DefaultRequiredGrossIncome']; 
		$arr1['amortization']		=  ($main[$a]['DefaultAmortization']!=0) ? $main[$a]['DefaultAmortization'] : $main[$a]['DefaultAmortization']; 
		$arr1['remarks']		= trim(html_entity_decode(stripslashes($main[$a]['DefaultPricelistRemarks']))); 
		 
	 
	$arr2[] = $arr1;
} 
$arr3['data'] = $arr2;
echo json_encode($arr3); 
exit();
ob_end_flush();