| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/tripstring.com/application/models/ |
Upload File : |
<?php
class Travel_Model_HotelMaster {
protected $db = NULL;
public $intId = NULL;
protected $objHelperGeneral;
/* * ************************************ */
public function __construct() {
$request = Zend_Controller_Front::getInstance()->getRequest();
$this->baseUrl = $request->getScheme() . '://' . $request->getHttpHost();
$this->db = Zend_Db_Table::getDefaultAdapter();
}
public function __destruct() {
$this->db->closeConnection();
}
public function getHotel($destinationId, $table, $checkInDate, $checkOutDate, $adults, $child, $infent, $refId, $destIndex,$roomJsonInfo,$filterType = NULL) {
$objHelperGeneral = Zend_Controller_Action_HelperBroker::getStaticHelper('General');
$objHelperGeneral = Zend_Controller_Action_HelperBroker::getStaticHelper('General');
$AgencyMarkupData = $objHelperGeneral->getAgencyMarkupData();
$MarkUpType = $AgencyMarkupData['MarkUpType'];
$MarkUp = $AgencyMarkupData['MarkUp'];
$destinationId = trim($destinationId);
//$destinationId = 6000;
$order = 'StarRating ASC';
if($filterType == 1){
$order = 'StarRating ASC';
}else if($filterType == 2){
$order = 'StarRating DESC';
}
$response = array();
$sql = "select * FROM $table A WHERE DestinationsId = $destinationId AND ItemType = 2 AND IsActive = '1' and IsMarkForDel = '0' order by IsFeatured DESC, $order";
$res = $this->db->query($sql)->fetchAll();
$totalAdult = (int) $adults + (int) $child + (int) $infent;
$Adult = (int) $adults;
$roomJsonInfo = json_decode($roomJsonInfo, TRUE);
$ChildWithOutBed = 0;
$ChildWithOutBed = $Child = (int)$child;
$currencyTypeArray = $objHelperGeneral->getCurrencyData();
if (count($res) > 0) {
foreach ($res as $row) {
$longJsonDecode = $row['LongJsonInfo'];
$longJson = json_decode($longJsonDecode, TRUE);
$checkPlan = array();
$RoomInfo = $roomJsonInfoArr = $roomJsonInfoArrfinal = array();
$calculateRoomJsonPax = $this->calculateRoomJsonPax($roomJsonInfo,$Adult,$Child,$longJson['RoomInfo']);
$RoomInfo = $calculateRoomJsonPax['RoomInfo'];
$roomJsonInfoArrfinal = $calculateRoomJsonPax['roomJsonInfoArrfinal'];
$Currency = $longJson['PriceAdditional'][0]['Currency'];
$CurrencyType = $currencyTypeArray[$Currency];
foreach ($longJson['PriceAdditional'] as $priceVal) {
if ($priceVal['CreateDate'] >= $checkInDate && $priceVal['CreateDate'] < $checkOutDate ) {
$checkPlan['category']['Name'] = $priceVal['Title'];
$checkPlan['category']['HotelName'] = $longJson['Title'];
$checkPlan['category']['Stars'] = $longJson['Stars'];
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['CreateDate'][] = $priceVal['CreateDate'];
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['Title'] = $priceVal['MPTitle'];
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['ETitle'] = $priceVal['Title'];
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['MPTypeId'] = $priceVal['MPType'];
$getPriceF = 0;
foreach ($roomJsonInfoArrfinal[$priceVal['EType']] as $paxKey => $paxVal) {
$roomMinAdult = $RoomInfo[$priceVal['EType']]['Adult'];
$roomMaxAdult = $RoomInfo[$priceVal['EType']]['MAdult'];
$roomMinChild = $RoomInfo[$priceVal['EType']]['Child'];
$roomMaxChild = $RoomInfo[$priceVal['EType']]['MChild'];
$roomMaxGuest = $RoomInfo[$priceVal['EType']]['TGuest'];
$adults = $paxVal['Adult'];
$child = $paxVal['Child'];
$infent = $paxVal['infent'];
$totalAdult = (int) $adults + (int) $child + (int) $infent;
$Adult = (int) $adults;
$ChildWithOutBed = 0;
$ChildWithOutBed = (int)$child;
$childAge = 8;
$adultPrice = $childPrice = 0;
if($adults <= $roomMinAdult){
$adultPrice = (float) $priceVal['NDOC'];
}else {
$NEBC = $adults - $roomMinAdult;
$adultPrice = (float) ($priceVal['NEBC'] * $NEBC) ;
}
if($childAge>2){
$childPrice = (float) ($priceVal['NEBC'] * $child);
}else {
$childPrice =0;
}
$getPrice = $adultPrice + $childPrice;
// switch ($totalAdult) {
// case 1 : {
// if((int)$priceVal['NSOC'] > 0){
// $getPrice = (float) $priceVal['NSOC'];
// } else {
// $getPrice = (float) $priceVal['NDOC'];
// }
// break;
// }
// case 2 : {
// if ($Adult == 2) {
// $getPrice = (float) $priceVal['NDOC'];
// } else if ($ChildWithOutBed == 2) {
// $getPrice = (float) $priceVal['NDOC'];
// } else if (($Adult + $ChildWithOutBed) == 2) {
// $getPrice = (float) $priceVal['NDOC'];
// } else {
// $getPrice = (float) $priceVal['NDOC'] + (float) $priceVal['NEBC'];
// }
// break;
// }
// case 3 : {
// if ($Adult == 3) {
// $getPrice = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC'];
// } else if ($ChildWithOutBed == 3) {
// $getPrice = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC'];
// } else {
// $getPrice = (float) $priceVal['NDOC'] + (float) $priceVal['NEBC'];
// }
// break;
// }
// case 4 : {
// if ($ChildWithOutBed + $Adult == 4) {
// $getPrice = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC']+(float) $priceVal['NEWOBC'];
// } else {
// $getPrice = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC']+ (float) $priceVal['NEBC'];
// }
// break;
// }
// default : {
// $getPrice = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC']+ (float) $priceVal['EWOBC'];
// break;
// }
// }
$getPriceF = $getPriceF + $getPrice;
}
$exchangerate = 1;
// if(isset($priceVal['Currency']) && $priceVal['Currency'] != 1) {
// $exchangerate = $objHelperGeneral->currencyExchangeRate($priceVal['Currency'],1,0);
// }
$getPriceF = $getPriceF * $exchangerate;
//echo "<pre>";print_r($exchangerate);die;
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['basePrice'] = $getPriceF;
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['agencyMarkUp'] = Catabatic_Helper::calculateAgencyMarkup($getPriceF,$MarkUpType,$MarkUp);
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['Price'] = Catabatic_Helper::calculateMarkup($getPriceF,$MarkUpType,$MarkUp);
//echo "<pre>";print_r($getPrice);die;
}
}
// echo "<pre>";print_r($checkPlan['category']);die;
$datetime1 = new DateTime($checkInDate);
$datetime2 = new DateTime($checkOutDate);
$interval = $datetime1->diff($datetime2);
$totalNight = (int) $interval->format('%a');
$countval = array();
$finalArray = array();$Price = 0;
foreach ($checkPlan['category'] as $checkhotelkey => $checkHotelPrice) {
foreach ($checkHotelPrice as $SUBkey => $SUBVal) {
$i = 0;
foreach ($SUBVal as $keyItem => $checkRNd) {
$countval[$i] = count($checkRNd["CreateDate"]);
if ($countval[$i] == $totalNight) {
$finalArray['category']['Name'] = $checkHotelPrice['Title'];
$finalArray['category']['HotelName'] = $longJson['Title'];
$finalArray['category']['Stars'] = $longJson['Stars'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['CreateDate'][] = $checkRNd['CreateDate'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['Title'] = $checkRNd['Title'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['ETitle'] = $checkRNd['ETitle'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['MPTypeId'] = $checkRNd['MPTypeId'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['Price'] = $checkRNd['Price'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['basePrice'] = $checkRNd['basePrice'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['agencyMarkUp'] = $checkRNd['agencyMarkUp'];
if($Price == 0 || $Price > $checkRNd['Price']){
$Price = $checkRNd['Price'];
}
}
$i++;
}
}
}
if (!empty($finalArray)) {
$response[] = array(
'destIndex' => $destIndex,
'refId' => $refId,
'GTXPkgId' => $row['GTXPkgId'],
'PkgSysId' => $row['PkgSysId'],
'DestinationId' => $row['DestinationsId'],
'Destinations' => $row['Destinations'],
'Title' => $longJson['Title'],
'Details' => $longJson['Details'],
'adults' => $adults,
'child' => $child,
'infent' => $infent,
'Stars' => $longJson['Stars'],
'ThumnailImg' => $longJson['ThumnailImg'],
'DetailImg' => $longJson['DetailImg'],
'PropertyType' => $longJson['PropertyType'],
'CheckinTime' => $longJson['CheckinTime'],
'Address' => str_replace(',',', ',$longJson['Address']),
'latitude' => $longJson['latitude'],
'longitude' => $longJson['longitude'],
'CitySysId' => $longJson['CitySysId'],
'ContSysId' => $longJson['ContSysId'],
'PinCode' => $longJson['PinCode'],
'Location' => $longJson['Location'],
'checkPlan' => base64_encode(json_encode($finalArray)),
'AccoAminitiesMask' => $longJson['AccoAminitiesMask'],
'IsFeatured' => $row['IsFeatured'],
'totalNight' => $totalNight,
'checkInDate' => $checkInDate,
'checkOutDate' => $checkOutDate,
'Price' => $Price,
'CurrencyType' => $CurrencyType,
'Category' => $row['PackageCategory'],
);
}
}
}
return $response;
}
function getHotelDetail($hotelRefSysId) {
$objHelperGeneral = Zend_Controller_Action_HelperBroker::getStaticHelper('General');
$select = $this->db->select()->from(array("t1" => "tb_travelplan_hotel"));
$select->joinLeft(array('t2' => 'tb_tbb2c_packages_master'), 't1.HotelId = t2.GTXPkgId', array("LongJsonInfo"));
$select->joinLeft(array('t3' => 'tb_master_geo_city'), 't1.DestinationId = t3.CityId', array("Title"));
$select->joinLeft(array('t4' => 'tb_traavelplan_destination'), 't1.destsysId = t4.Id', array("StartDate", "EndDate"));
$select->where("t1.ID IN(?)", $hotelRefSysId);
$select->order("t4.Id ASC");
$getZsontoArray = $this->db->fetchAll($select);
// echo "<pre>";print_r($getZsontoArray);die;
$selectionHotelByOption = array();
$i = 0;
$TSys = array();
foreach ($getZsontoArray as $key => $val) {
$TPSysId = (int) trim($val['TpsysId']);
$ROOM_TYPE_DATA = unserialize(ROOM_TYPE_DATA);
foreach ($ROOM_TYPE_DATA as $RTKey => $RTValue) {
if($val['RoomTypeId'] == $RTKey){
$RoomTypeIdNew = $RTValue;
}
}
$MEAL_TYPE = unserialize(MEAL_TYPE);
foreach ($MEAL_TYPE as $MTKey => $MTValue) {
if($val['MealPlanId'] == $MTKey){
$MealTypeIdNew = $MTValue;
}
}
$keyVal = $val['DestinationId'] . "_" . $val['destSeq'];
$selectionHotelByOption[$keyVal]['Title'] = $val['Title'];
$longJson = json_decode($val['LongJsonInfo'], TRUE);
$selectionHotelByOption[$keyVal]['Hotel'][$val['HotelId']]['Title'] = $longJson['Title'];
$selectionHotelByOption[$keyVal]['Hotel'][$val['HotelId']]['Stars'] = $longJson['Stars'];
$selectionHotelByOption[$keyVal]['Hotel'][$val['HotelId']]['RoomTypeId'][] = $RoomTypeIdNew;
$selectionHotelByOption[$keyVal]['Hotel'][$val['HotelId']]['MealPlanId'][] = $MealTypeIdNew;
$selectionHotelByOption[$keyVal]['StartDate'] = $val['StartDate'];
$selectionHotelByOption[$keyVal]['EndDate'] = $val['EndDate'];
// $selectionHotelByOption[$keyVal]['RoomTypeId'][] = $val['RoomTypeId'];
// $selectionHotelByOption[$keyVal]['MealPlanId'][] = $val['MealPlanId'];
$TSys['TPSysId'] = $TPSysId;
// $selectionHotelByOption[$val['DestinationId']]['Hotel'][$val['HotelId']]['Price'][] = $getPrice;
$i++;
}
return $selectionHotelByOption = array(
"TPSysId" => $TSys,
"selectionHotelByOption" => $selectionHotelByOption,
);
}
function hotelPriceCalculation($hotelRefSysId, $TPSysId) {
$objHelperGeneral = Zend_Controller_Action_HelperBroker::getStaticHelper('General');
$selectionHotelByOption = array();
$select = $this->db->select()->from(array("t1" => "tb_travelplan_hotel"));
$select->joinLeft(array('t2' => 'tb_tbb2c_packages_master'), 't1.HotelId = t2.GTXPkgId', array("LongJsonInfo"));
$select->joinLeft(array('t3' => 'tb_master_geo_city'), 't1.DestinationId = t3.CityId', array("Title"));
$select->joinLeft(array('t4' => 'tb_traavelplan_destination'), 't1.destsysId = t4.Id');
$select->where("t1.HotelId IN(?)", $hotelRefSysId);
$select->where("t2.IsActive = ? ", 1);
$select->where("t1.IsMarkForDel = ? ", '0');
//$select->where("t1.HotelId IN(?)", $hotelRefSysId);
$select->where("t1.TpsysId = ?", $TPSysId);
$getZsontoArray = $this->db->fetchAll($select);
//echo "<pre>";print_r($getZsontoArray);exit;
foreach ($getZsontoArray as $key => $val) {
$longJson = json_decode($val['LongJsonInfo'], TRUE);
$checkInDate = $val['StartDate'];
$checkOutDate = $val['EndDate'];
$RoomTypeId = (int) trim($val['RoomTypeId']);
$MealPlanId = (int) trim($val['MealPlanId']);
$Adult = (int) trim($val['Adult']);
$AdultExtraBed = (int) trim($val['AdultExtraBed']);
$ChildWithBed = (int) trim($val['ChildWithBed']);
$ChildWithOutBed = (int) trim($val['ChildWithOutBed']);
$Infent = (int) trim($val['Infent']);
$totalAdult = (int) $Adult + (int) $AdultExtraBed + (int) $ChildWithBed + (int) $ChildWithOutBed;
$getPrice = array();
// echo "<pre>";
// print_r($longJson['PriceAdditional']);
// exit;
foreach ($longJson['PriceAdditional'] as $priceVal) {
if ((trim($priceVal['EType']) == $RoomTypeId && trim($priceVal['MPType']) == $MealPlanId) && ($priceVal['CreateDate'] >= $checkInDate && $priceVal['CreateDate'] < $checkOutDate)) {
switch ($totalAdult) {
case 1 : {
if((int)$priceVal['NSOC'] > 0){
$getPrice[] = (float) $priceVal['NSOC'];
} else {
$getPrice[] = (float) $priceVal['NDOC'];
}
break;
}
case 2 : {
if ($Adult == 2) {
$getPrice[] = (float) $priceVal['NDOC'];
} else if ($ChildWithOutBed == 2) {
$getPrice[] = (float) $priceVal['NDOC'];
} else if (($Adult + $ChildWithOutBed) == 2) {
$getPrice[] = (float) $priceVal['NDOC'];
} else {
$getPrice[] = (float) $priceVal['NDOC'] + (float) $priceVal['NEBC'];
}
break;
}
case 3 : {
if ($Adult == 3) {
$getPrice[] = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC'];
} else if ($ChildWithOutBed == 3) {
$getPrice[] = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC'];
} else {
$getPrice[] = (float) $priceVal['NDOC'] + (float) $priceVal['NEBC'];
}
break;
}
case 4 : {
if ($ChildWithOutBed + $Adult == 4) {
$getPrice[] = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC']+(float) $priceVal['NEWOBC'];
} else {
$getPrice[] = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC']+ (float) $priceVal['NEBC'];
}
break;
}
default : {
$getPrice[] = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC']+ (float) $priceVal['EWOBC'];
break;
}
}
$Currency = $priceVal['Currency'];
}
}
$selectionHotelByOption['Hotel'][$val['HotelId']]['Price'][] =$getPrice;
$selectionHotelByOption['Hotel'][$val['HotelId']]['Currency'] =$Currency;
}
$finalval = 0;
foreach ($selectionHotelByOption['Hotel'] as $priceVal) {
foreach ($priceVal['Price'] as $hPrice) {
for ($p = 0; $p < count($hPrice); $p++) {
$exchangerate = 1;
// if(isset($priceVal['Currency']) && $priceVal['Currency'] != 1) {
// $exchangerate = $objHelperGeneral->currencyExchangeRate($priceVal['Currency'],1,0);
// }
//echo "<pre>";print_r($exchangerate);exit;
$hPrice[$p] = $hPrice[$p] * $exchangerate;
$finalval = (float) $finalval + (float) Catabatic_Helper::calculateMarkup($hPrice[$p]);
}
//echo "<pre>";print_r($hPrice);exit;
}
// echo "<pre>";print_r($priceVal);exit;
//$finalval =
}
return $finalval;
// echo "<pre>";print_r($selectionHotelByOption);exit;
}
public function getTotalDays($TPSysId, $startDate) {
$select = $this->db->select()->from(array("t1" => "tb_traavelplan_destination"), array("Sum(NoDay) as TotalNight"));
$select->where("t1.TPSysId = ?", $TPSysId);
// echo $select;exit;
$getZsontoArray = $this->db->fetchRow($select);
$totalDays = (int) $getZsontoArray["TotalNight"] + 1;
$datetime = new DateTime($startDate);
$datetime->modify("+$totalDays days");
$EndData = $datetime->format('Y-m-d');
$returnArray = array(
"startDate" => $startDate,
"endDate" => $EndData,
"totalDays" => $totalDays,
);
return $returnArray;
}
public function getItnaryDays($TPSysId) {
$select = $this->db->select()->from(array("t1" => "tb_traavelplan"), array("EndCityId", "EndCity", "StartCity", "TotalAdult", "TotalChild", "TotalInfant", "StartDate","EndContId","StartCityId"));
$select->joinLeft(array('t2' => 'tb_traavelplan_destination'), 't1.TPSysId = t2.TPSysId', array("CitySysId", "NoDay"));
$select->joinLeft(array('t3' => 'tb_master_geo_city'), 't2.CitySysId = t3.CityId', array("Title", "ContSysId"));
$select->where("t1.TPSysId = ?", $TPSysId);
$select->order("t2.StartDate ASC");
// echo $select;exit;
$getZsontoArray = $this->db->fetchAll($select);
// echo "<pre>";print_r($getZsontoArray);die;
$totalDays = 0;
$arraycity = array();
$i = 0;
foreach ($getZsontoArray as $key => $val) {
$days = (int) $val['NoDay'];
$totalDays = $totalDays + $days;
$arraycity['CitySysId'][$i]['days'] = (int) $days;
$arraycity['CitySysId'][$i]['cityId'] = (int) $val['CitySysId'];
$arraycity['CitySysId'][$i]['cityIdName'] = $val['Title'];
$arraycity['CitySysId'][$i]['ContSysId'] = $val['ContSysId'];
$arraycity['EndCityId'] = (int) $val['EndCityId'];
$arraycity['EndContId'] = (int) $val['EndContId'];
$arraycity['EndCity'] = $val['EndCity'];
$arraycity['StartCity'] = $val['StartCity'];
$arraycity['StartCityId'] = $val['StartCityId'];
$arraycity['TotalAdult'] = (int) $val['TotalAdult'];
$arraycity['TotalChild'] = (int) $val['TotalChild'];
$arraycity['TotalInfant'] = (int) $val['TotalInfant'];
$arraycity['StartDate'] = $val['StartDate'];
$i++;
}
$returnArray = array();
$d = 0;
foreach ($arraycity['CitySysId'] as $valueCity) {
for ($k = 0; $k < $valueCity['days']; $k++) {
$returnArray[$d]['destSysId'] = $valueCity['cityId'];
$returnArray[$d]['CityName'] = $valueCity['cityIdName'];
$returnArray[$d]['ContSysId'] = $valueCity['ContSysId'];
$d++;
}
}
$returnArray[$d]['destSysId'] = $arraycity['EndCityId'];
$arraycityEndCity = explode('(',$arraycity['EndCity']);
$returnArray[$d]['CityName'] = $arraycityEndCity[0];
$returnArray[$d]['ContSysId'] = $arraycity['EndContId'];
$returnAr = array(
"arraycity" => $arraycity,
"returnArray" => $returnArray
);
return $returnAr;
}
public function getTravelPlanHistory($TPSysId) {
$select = $this->db->select()->from(array("t1" => "tb_traavelplan"), array("EndCityId", "EndCity", "StartCity", "TotalAdult", "TotalChild", "TotalInfant", "StartDate", "StartCityId"));
$select->where("t1.TPSysId = ?", $TPSysId);
$getZsontoArray = $this->db->fetchAll($select);
return $getZsontoArray;
//$select->order("t.StartDate ASC");
}
public function getTransportRoute($TPSysId,$StartSysId,$totaldays,$endCityID){
$select = $this->db->select()->from(array("t1" => "tb_transport_route"));
$select->where("t1.StartCitySysId = ?", $StartSysId);
$select->where("t1.EndCitySysId = ?", $endCityID);
$select->where("t1.Noofnights = ?", $totaldays);
$select->where("t1.IsActive = ?", 1);
$select->where("t1.IsMarkForDel = '0'");
// echo $select;
$getZsontoArray = $this->db->fetchAll($select);
$select1 = $this->db->select()->from(array("t2" => "tb_traavelplan_destination"),array("CitySysId"));
$select1->where("t2.TPSysId = ?", $TPSysId);
$CitySysIdArray = $this->db->fetchAll($select1);
// echo "<pre>";print_r($CitySysIdArray);
//
// echo "<br>";
//
// echo "<pre>";print_r($getZsontoArray);exit;
$arrCitySysId = array();
// $arrCitySysId[0] = 0;
foreach ($CitySysIdArray as $cityIdKey => $cityIdValue) {
$arrCitySysId[] = $cityIdValue['CitySysId'];
}
// echo "<pre>";print_r($arrCitySysId);
// echo "<br>";
$finalArray = array();
if(!empty($getZsontoArray)) {
foreach($getZsontoArray as $key => $routeName){
$category = json_decode($routeName['category'], TRUE);
$cityIncludes = json_decode($routeName['cityIncludes'], TRUE);
// echo "<pre>";print_r($category);
// echo "<br>";
$arrdesId = array();
$testResult = 0;
foreach ($cityIncludes as $ciKey => $ciValue) {
if($ciValue['DestSysId'] == $arrCitySysId[$ciKey]){
$testResult++;
}
}
$i = 0;
if((count($cityIncludes) == count($arrCitySysId)) && (count($cityIncludes) == $testResult)) {
foreach ($category as $catKey => $catValue) {
$finalArray[$i] = [
'transport_route_id' => $routeName['transport_route_id'],
'RouteSysId' => $routeName['RouteSysId'],
'RouteName' => $routeName['RouteName'],
'SupplierSysId' => $routeName['SupplierSysId'],
'Title' => $routeName['Title'],
'Description' => $routeName['Description'],
'StartCitySysId' => $routeName['StartCitySysId'],
'Noofnights' => $routeName['Noofnights'],
'CityName' => $routeName['CityName'],
'EndCityName' => $routeName['EndCityName'],
'RouteVechSysId' => $catValue['RouteVechSysId'],
'VehicleSysId' => $catValue['VehicleSysId'],
'VehicleTypeSysId' => $catValue['VehicleTypeSysId'],
'Cost' => $catValue['Cost'],
'Capacity' => $catValue['Capacity'],
'CurrencyType' => $catValue['CurrencyType'],
'SupplierName' => $catValue['SupplierName'],
'VehName' => $catValue['VehName'],
'VehicleTypeName' => $catValue['VehicleTypeName'],
'CurrencySymbol' => $catValue['CurrencySymbol'],
'cityIncludes' => $cityIncludes,
];
$i++;
}
}
}
// exit;
// echo "<pre>";print_r($finalArray);exit;
}
return $finalArray;
//$select->order("t2.StartDate ASC");
}
public function getTncMasterData() {
$select = $this->db->select()->from(array("t1" => "tb_traavelplan_tnc_master"), '*');
$tncDataArray = $this->db->fetchAll($select);
return $tncDataArray;
//$select->order("t.StartDate ASC");
}
public function getAutosuggestTransportRouteData($StartSysId,$endCityID,$noofdays = NULL,$transferType = NULL,$categoryTransport = NULL){
$select = $this->db->select()->from(array("t1" => "tb_transport_route"));
$select->where("t1.StartCitySysId = ?", $StartSysId);
$select->where("t1.EndCitySysId = ?", $endCityID);
if($noofdays){
$select->where("t1.Noofnights = ?", $noofdays);
}
if($transferType){
$select->where("t1.TransportType = ?", $transferType);
}
if($categoryTransport){
$select->where("t1.TransportSubType = ?", $categoryTransport);
}
$select->where("t1.IsActive = ?", 1);
$select->where("t1.IsMarkForDel = '0'");
// echo $select;die;
$finalArray = $this->db->fetchAll($select);
return $finalArray;
//$select->order("t2.StartDate ASC");
}
public function getAutosuggestTransportRouteDataById($transport_route_id){
$select = $this->db->select()->from(array("t1" => "tb_transport_route"));
$select->where("t1.transport_route_id = ?", $transport_route_id);
$select->where("t1.IsActive = ?", 1);
$select->where("t1.IsMarkForDel = '0'");
$finalArray = $this->db->fetchAll($select);
return $finalArray;
//$select->order("t2.StartDate ASC");
}
public function getHotelByHotelid($table,$hotelIds,$nights,$ROOMTYPE,$MEALPLANTYPE,$getcheckIn,$roomJsonInfo,$DestinationsIds,$package_destination_night_detail = NULL) {
$objHelperGeneral = Zend_Controller_Action_HelperBroker::getStaticHelper('General');
//echo "<pre>";print_r($hotelIds);exit;
$hotelIds = trim($hotelIds);
$nightsE = explode(',',$nights);
$ROOMTYPEE = explode(',',$ROOMTYPE);
$MEALPLANTYPEE = explode(',',$MEALPLANTYPE);
$package_destination_night_detailE = json_decode($package_destination_night_detail,1);
$roomJsonInfo = json_decode($roomJsonInfo,1);
//$destinationId = 6000;
$response = array();
$sql = "select * FROM $table A WHERE GTXPkgId IN ($hotelIds) AND ItemType = 2 AND IsActive = '1' and IsMarkForDel = '0' ";
$res = $this->db->query($sql)->fetchAll();
$resArr = $resFinalArr = array();
foreach($res as $resKey => $resVal){
$resArr[$resVal['DestinationsId']] = $resVal;
}
foreach($DestinationsIds as $desKey => $desVal){
$resFinalArr[] = $resArr[$desVal];
}
//$resFinalArr = $res;
//echo "<pre>";print_r($package_destination_night_detailE);die;
if (count($resFinalArr) > 0) {
$inc=0;
foreach ($resFinalArr as $rKey => $row) {
$longJsonDecode = $row['LongJsonInfo'];
$longJson = json_decode($longJsonDecode, TRUE);
$checkPlan = array();
$checkInDate = $getcheckIn;
$NoofNights = $nightsE[$rKey];
$checkOutDate = date('Y-m-d', strtotime($checkInDate . ' + ' . ($NoofNights) . ' days'));;
//echo "<pre>";print_r($longJson);die;
$getPriceF = 0;
foreach ($longJson['PriceAdditional'] as $priceVal) {
if ($priceVal['CreateDate'] >= $checkInDate && $priceVal['CreateDate'] < $checkOutDate && $ROOMTYPEE[$rKey] == $priceVal['EType'] && $MEALPLANTYPEE[$rKey] == $priceVal['MPType']) {
$checkPlan['category']['Name'] = $priceVal['Title'];
$checkPlan['category']['HotelName'] = $longJson['Title'];
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['CreateDate'][] = $priceVal['CreateDate'];
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['Title'] = $priceVal['MPTitle'];
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['ETitle'] = $priceVal['Title'];
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['MPTypeId'] = $priceVal['MPType'];
$getPriceF = 0;
foreach ($roomJsonInfo as $paxKey => $paxVal) {
$adults = $paxVal['Adult'];
$child = $paxVal['Child'];
$infent = $paxVal['infent'];
$totalAdult = (int) $adults + (int) $child + (int) $infent;
$Adult = (int) $adults;
$ChildWithOutBed = 0;
$ChildWithOutBed = (int)$child;
switch ($totalAdult) {
case 1 : {
if((int)$priceVal['NSOC'] > 0){
$getPrice = (float) $priceVal['NSOC'];
} else {
$getPrice = (float) $priceVal['NDOC'];
}
break;
}
case 2 : {
if ($Adult == 2) {
$getPrice = (float) $priceVal['NDOC'];
} else if ($ChildWithOutBed == 2) {
$getPrice = (float) $priceVal['NDOC'];
} else if (($Adult + $ChildWithOutBed) == 2) {
$getPrice = (float) $priceVal['NDOC'];
} else {
$getPrice = (float) $priceVal['NDOC'] + (float) $priceVal['NEBC'];
}
break;
}
case 3 : {
if ($Adult == 3) {
$getPrice = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC'];
} else if ($ChildWithOutBed == 3) {
$getPrice = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC'];
} else {
$getPrice = (float) $priceVal['NDOC'] + (float) $priceVal['NEBC'];
}
break;
}
case 4 : {
if ($ChildWithOutBed + $Adult == 4) {
$getPrice = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC']+(float) $priceVal['NEWOBC'];
} else {
$getPrice = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC']+ (float) $priceVal['NEBC'];
}
break;
}
default : {
$getPrice = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC']+ (float) $priceVal['EWOBC'];
break;
}
}
$getPriceF = $getPriceF + $getPrice;
}
$exchangerate = 1;
// if(isset($priceVal['Currency']) && $priceVal['Currency'] != 1) {
// $exchangerate = $objHelperGeneral->currencyExchangeRate($priceVal['Currency'],1,0);
// }
$getPriceF = $getPriceF * $exchangerate;
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['Price'] = Catabatic_Helper::calculateMarkup($getPriceF);
}
}
$datetime1 = new DateTime($checkInDate);
$datetime2 = new DateTime($checkOutDate);
$interval = $datetime1->diff($datetime2);
$totalNight = (int) $interval->format('%a');
$countval = array();
$finalArray = array();
foreach ($checkPlan['category'] as $checkhotelkey => $checkHotelPrice) {
foreach ($checkHotelPrice as $SUBkey => $SUBVal) {
$i = 0;
foreach ($SUBVal as $keyItem => $checkRNd) {
$countval[$i] = count($checkRNd["CreateDate"]);
if ($countval[$i] == $totalNight) {
$finalArray['category']['Name'] = $checkHotelPrice['Title'];
$finalArray['category']['HotelName'] = $longJson['Title'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['CreateDate'][] = $checkRNd['CreateDate'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['Title'] = $checkRNd['Title'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['ETitle'] = $checkRNd['ETitle'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['MPTypeId'] = $checkRNd['MPTypeId'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['Price'] = $checkRNd['Price'];
}
$i++;
}
}
}
if (!empty($finalArray)) {
$response[] = array(
'destIndex' => $destIndex,
'refId' => $refId,
'NoofNights' => $NoofNights,
'GTXPkgId' => $row['GTXPkgId'],
'DestinationId' => $row['DestinationsId'],
'Destinations' => $row['Destinations'],
'Title' => $longJson['Title'],
'Details' => $longJson['Details'],
'adults' => $adults,
'child' => $child,
'infent' => $infent,
'Stars' => $longJson['Stars'],
'ThumnailImg' => $longJson['ThumnailImg'],
'DetailImg' => $longJson['DetailImg'],
'PropertyType' => $longJson['PropertyType'],
'CheckinTime' => $longJson['CheckinTime'],
'Address' => $longJson['Address'],
'latitude' => $longJson['latitude'],
'longitude' => $longJson['longitude'],
'CitySysId' => $longJson['CitySysId'],
'ContSysId' => $longJson['ContSysId'],
'PinCode' => $longJson['PinCode'],
'Location' => $longJson['Location'],
'checkPlan' => base64_encode(json_encode($finalArray)),
'IsFeatured' => $row['IsFeatured'],
'checkInDate' => $checkInDate,
'checkOutDate' => $checkOutDate,
'ROOMTYPE' => $ROOMTYPEE[$rKey],
'MEALPLANTYPE' => $MEALPLANTYPEE[$rKey],
'isPrice' =>1,
);
}else{
$response[] = array(
'destIndex' => $destIndex,
'refId' => $refId,
'NoofNights' => $package_destination_night_detailE[$inc]['nights'],
'GTXPkgId' => 121212+$inc,
'DestinationId' => $package_destination_night_detailE[$inc]['cityId'],
'Destinations' => $package_destination_night_detailE[$inc]['title'],
'ContSysId' => $package_destination_night_detailE[$inc]['CountryIds'],
'checkInDate' => $checkInDate,
'checkOutDate' => $checkOutDate,
'isPrice' =>0,
);
}
$getcheckIn = $checkOutDate;
$inc++;
}
}
return $response;
}
public function getHotelDetailByHotelIds($table,$hotelIds) {
$sql = "select * FROM $table A WHERE GTXPkgId IN ($hotelIds) AND ItemType = 2 AND IsActive = '1' and IsMarkForDel = '0' ";
$res = $this->db->query($sql)->fetchAll();
return $res;
}
public function getTableDataByIds($table,$column,$Ids) {
//$where = "AND ItemType = 2 AND IsActive = '1' and IsMarkForDel = '0'";
$sql = "select * FROM $table A WHERE RouteSysId IN ($Ids)";
$res = $this->db->query($sql)->fetchAll();
return $res;
}
public function getTransportRouteDataByTransportSubType($StartSysId,$endCityID,$noofdays,$TransportSubType = 1){
$select = $this->db->select()->from(array("t1" => "tb_transport_route"));
$select->where("t1.StartCitySysId = ?", $StartSysId);
$select->where("t1.EndCitySysId = ?", $endCityID);
$select->where("t1.Noofnights = ?", $noofdays);
$select->where("t1.TransportSubType IN ($TransportSubType)");
$select->where("t1.IsActive = ?", 1);
$select->where("t1.IsMarkForDel = '0'");
$finalArray = $this->db->fetchAll($select);
return $finalArray;
//$select->order("t2.StartDate ASC");
}
public function getHotelByPackageId($PkgSysId, $table, $checkInDate, $checkOutDate, $adults, $child, $infent, $refId, $destIndex,$roomJsonInfo,$filterType = NULL) {
$objHelperGeneral = Zend_Controller_Action_HelperBroker::getStaticHelper('General');
$AgencyMarkupData = $objHelperGeneral->getAgencyMarkupData();
$MarkUpType = $AgencyMarkupData['MarkUpType'];
$MarkUp = $AgencyMarkupData['MarkUp'];
$PkgSysId = trim($PkgSysId);
//$destinationId = 6000;
$order = 'StarRating ASC';
if($filterType == 1){
$order = 'StarRating ASC';
}else if($filterType == 2){
$order = 'StarRating DESC';
}
$response = array();
$sql = "select * FROM $table A WHERE PkgSysId = $PkgSysId AND ItemType = 2 AND IsActive = '1' and IsMarkForDel = '0' order by IsFeatured DESC, $order";
$res = $this->db->query($sql)->fetchAll();
$totalAdult = (int) $adults + (int) $child + (int) $infent;
$Adult = (int) $adults;
$Child = (int) $child;
$roomJsonInfo = json_decode($roomJsonInfo, TRUE);
$rooms = count($roomJsonInfo);
$ChildWithOutBed = 0;
$ChildWithOutBed = (int)$child;
$currencyTypeArray = $objHelperGeneral->getCurrencyData();
if (count($res) > 0) {
foreach ($res as $row) {
$longJsonDecode = $row['LongJsonInfo'];
$longJson = json_decode($longJsonDecode, TRUE);
$checkPlan = array();
$RoomInfo = $roomJsonInfoArr = $roomJsonInfoArrfinal = array();
$calculateRoomJsonPax = $this->calculateRoomJsonPax($roomJsonInfo,$Adult,$Child,$longJson['RoomInfo']);
$RoomInfo = $calculateRoomJsonPax['RoomInfo'];
$roomJsonInfoArrfinal = $calculateRoomJsonPax['roomJsonInfoArrfinal'];
$Currency = $longJson['PriceAdditional'][0]['Currency'];
$CurrencyType = $currencyTypeArray[$Currency];
// echo "<pre>";print_r($longJson['PriceAdditional']);die;
foreach ($longJson['PriceAdditional'] as $priceVal) {
$checkPlan['category']['Name'] = $priceVal['Title'];
$checkPlan['category']['HotelName'] = $longJson['Title'];
$checkPlan['category']['Stars'] = $longJson['Stars'];
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['Title'] = $priceVal['MPTitle'];
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['ETitle'] = $priceVal['Title'];
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['EType'] = $priceVal['EType'];
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['MPTypeId'] = $priceVal['MPType'];
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['roomInfo'] = $RoomInfo[$priceVal['EType']];
if ($priceVal['CreateDate'] >= $checkInDate && $priceVal['CreateDate'] < $checkOutDate ) {
$getPriceF = 0;
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['CreateDate'][] = $priceVal['CreateDate'];
foreach ($roomJsonInfoArrfinal[$priceVal['EType']] as $paxKey => $paxVal) {
$roomMinAdult = $RoomInfo[$priceVal['EType']]['Adult'];
$roomMaxAdult = $RoomInfo[$priceVal['EType']]['MAdult'];
$roomMinChild = $RoomInfo[$priceVal['EType']]['Child'];
$roomMaxChild = $RoomInfo[$priceVal['EType']]['MChild'];
$roomMaxGuest = $RoomInfo[$priceVal['EType']]['TGuest'];
$adults = $paxVal['Adult'];
$child = $paxVal['Child'];
$infent = $paxVal['infent'];
$totalAdult = (int) $adults + (int) $child + (int) $infent;
$Adult = (int) $adults;
$ChildWithOutBed = 0;
$ChildWithOutBed = (int)$child;
$childAge = 8;
$adultPrice = $childPrice = 0;
if($adults <= $roomMinAdult){
$adultPrice = (float) $priceVal['NDOC'];
}else {
$NEBC = $adults - $roomMinAdult;
$adultPrice = (float) ($priceVal['NEBC'] * $NEBC) ;
}
if($childAge>2){
$childPrice = (float) ($priceVal['NEBC'] * $child);
}else {
$childPrice =0;
}
$getPrice = $adultPrice + $childPrice;
// switch ($totalAdult) {
// case 1 : {
// if((int)$priceVal['NSOC'] > 0){
// $getPrice = (float) $priceVal['NSOC'];
// } else {
// $getPrice = (float) $priceVal['NDOC'];
// }
// break;
// }
// case 2 : {
// if ($Adult == 2) {
// $getPrice = (float) $priceVal['NDOC'];
// } else if ($ChildWithOutBed == 2) {
// $getPrice = (float) $priceVal['NDOC'];
// } else if (($Adult + $ChildWithOutBed) == 2) {
// $getPrice = (float) $priceVal['NDOC'];
// } else {
// $getPrice = (float) $priceVal['NDOC'] + (float) $priceVal['NEBC'];
// }
// break;
// }
// case 3 : {
// if ($Adult == 3) {
// $getPrice = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC'];
// } else if ($ChildWithOutBed == 3) {
// $getPrice = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC'];
// } else {
// $getPrice = (float) $priceVal['NDOC'] + (float) $priceVal['NEBC'];
// }
// break;
// }
// case 4 : {
// if ($ChildWithOutBed + $Adult == 4) {
// $getPrice = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC']+(float) $priceVal['NEWOBC'];
// } else {
// $getPrice = (float) $priceVal['NDOC']+(float) $priceVal['NEWOBC']+ (float) $priceVal['NEBC'];
// }
// break;
// }
// default : {
// if($Adult%2 == 0){
// $DOAdult = $Adult/2;
// $SOAdult = 0;
// }else{
// $DOAdult = $Adult/2;
// $SOAdult = 1;
// }
// $EBChild = $child;
// $getPrice = (float) $priceVal['NDOC'] * $DOAdult + (float) $priceVal['NSOC'] * $SOAdult + (float) $priceVal['NEBC'] * $EBChild ;
// break;
// }
// }
$getPriceF = $getPriceF + $getPrice;
}
$exchangerate = 1;
// if(isset($priceVal['Currency']) && $priceVal['Currency'] != 1) {
// $exchangerate = $objHelperGeneral->currencyExchangeRate($priceVal['Currency'],1,0);
// }
$getPriceF = $getPriceF * $exchangerate;
//$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['Price'] = Catabatic_Helper::calculateMarkup($getPriceF,$MarkUpType,$MarkUp);
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['basePrice'] = $getPriceF;
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['agencyMarkUp'] = Catabatic_Helper::calculateAgencyMarkup($getPriceF,$MarkUpType,$MarkUp);
$checkPlan['category']['SUB'][$priceVal['EType']][$priceVal['MPType']]['Price'] = Catabatic_Helper::calculateMarkup($getPriceF,$MarkUpType,$MarkUp);
}
}
$datetime1 = new DateTime($checkInDate);
$datetime2 = new DateTime($checkOutDate);
$interval = $datetime1->diff($datetime2);
$totalNight = (int) $interval->format('%a');
$countval = array();
$finalArray = array();$Price = 0;
foreach ($checkPlan['category'] as $checkhotelkey => $checkHotelPrice) {
foreach ($checkHotelPrice as $SUBkey => $SUBVal) {
$i = 0;
foreach ($SUBVal as $keyItem => $checkRNd) {
// echo "<pre>";print_r($SUBVal);die;
$countval[$i] = count($checkRNd["CreateDate"]);
if ($countval[$i] == $totalNight) {
$finalArray['category']['SUB'][$SUBkey][$keyItem]['CreateDate'][] = $checkRNd['CreateDate'];
}
$finalArray['category']['Name'] = $checkHotelPrice['Title'];
$finalArray['category']['HotelName'] = $longJson['Title'];
$finalArray['category']['Stars'] = $longJson['Stars'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['Title'] = $checkRNd['Title'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['ETitle'] = $checkRNd['ETitle'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['EType'] = $checkRNd['EType'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['MPTypeId'] = $checkRNd['MPTypeId'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['roomInfo'] = $checkRNd['roomInfo'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['Price'] = $checkRNd['Price'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['basePrice'] = $checkRNd['basePrice'];
$finalArray['category']['SUB'][$SUBkey][$keyItem]['agencyMarkUp'] = $checkRNd['agencyMarkUp'];
if($Price == 0 || $Price > $checkRNd['Price']){
$Price = $checkRNd['Price'];
}
$i++;
}
}
}
if (!empty($finalArray)) {
$response[] = array(
'destIndex' => $destIndex,
'refId' => $refId,
'GTXPkgId' => $row['GTXPkgId'],
'PkgSysId' => $row['PkgSysId'],
'DestinationId' => $row['DestinationsId'],
'Destinations' => $row['Destinations'],
'CountryIds' => $row['CountryIds'],
'Countries' => $row['Countries'],
'Title' => $longJson['Title'],
'Details' => $longJson['Details'],
'adults' => $adults,
'child' => $child,
'infent' => $infent,
'Stars' => $longJson['Stars'],
'ThumnailImg' => $longJson['ThumnailImg'],
'Images' => $longJson['Images'],
'DetailImg' => $longJson['DetailImg'],
'PropertyType' => $longJson['PropertyType'],
'CheckinTime' => $longJson['CheckinTime'],
'CheckOutTime' => $longJson['CheckOutTime'],
'Address' => $longJson['Address'],
'latitude' => $longJson['latitude'],
'longitude' => $longJson['longitude'],
'CitySysId' => $longJson['CitySysId'],
'ContSysId' => $longJson['ContSysId'],
'PinCode' => $longJson['PinCode'],
'Location' => $longJson['Location'],
'checkPlan' => base64_encode(json_encode($finalArray)),
'AccoAminitiesMask' => $longJson['AccoAminitiesMask'],
'IsFeatured' => $row['IsFeatured'],
'totalNight' => $totalNight,
'checkInDate' => $checkInDate,
'checkOutDate' => $checkOutDate,
'Price' => $Price,
'CurrencyType' => $CurrencyType,
'roomJsonInfo' => $roomJsonInfoArrfinal,
);
}else{
$response[] = array(
'destIndex' => 1,
'refId' => 0,
'GTXPkgId' => $row['GTXPkgId'],
'PkgSysId' => $row['PkgSysId'],
'DestinationId' => $row['DestinationsId'],
'Destinations' => $row['Destinations'],
'CountryIds' => $row['CountryIds'],
'Countries' => $row['Countries'],
'Title' => $longJson['Title'],
'Details' => $longJson['Details'],
'adults' => $adults,
'child' => $child,
'infent' => $infent,
'Stars' => $longJson['Stars'],
'ThumnailImg' => $longJson['ThumnailImg'],
'Images' => $longJson['Images'],
'DetailImg' => $longJson['DetailImg'],
'PropertyType' => $longJson['PropertyType'],
'CheckinTime' => $longJson['CheckinTime'],
'CheckOutTime' => $longJson['CheckOutTime'],
'Address' => $longJson['Address'],
'latitude' => $longJson['latitude'],
'longitude' => $longJson['longitude'],
'CitySysId' => $longJson['CitySysId'],
'ContSysId' => $longJson['ContSysId'],
'PinCode' => $longJson['PinCode'],
'Location' => $longJson['Location'],
'checkPlan' => array(),
'AccoAminitiesMask' => $longJson['AccoAminitiesMask'],
'IsFeatured' => $row['IsFeatured'],
'totalNight' => $totalNight,
'checkInDate' => $checkInDate,
'checkOutDate' => $checkOutDate,
'Price' => $Price,
'CurrencyType' => $CurrencyType,
'roomJsonInfo' => $roomJsonInfoArrfinal,
);
}
}
}
return $response;
}
public function calculateRoomJsonPax($roomJsonInfo,$Adult,$Child,$RoomInfo){
$RoomInfo1 = $roomJsonInfoArr = $roomJsonInfoArrfinal = array();
foreach ($RoomInfo as $RoomInfoVal) {
$searchAdult = $Adult;
$totalCh = $searchChild = $Child;
$searchTotal = $Adult + $Child;
$roomMinAdult = $RoomInfoVal['Adult'];
$roomMaxAdult = $RoomInfoVal['MAdult'];
$roomMinChild = $RoomInfoVal['Child'];
$roomMaxChild = $RoomInfoVal['MChild'];
$roomMaxGuest = $RoomInfoVal['TGuest'];
$RoomType = $RoomInfoVal['RoomType'];
$RoomInfo1[$RoomInfoVal['RoomType']] = $RoomInfoVal;
$rooms = count($roomJsonInfo);
$checkRoomAvailability = 0;
foreach($roomJsonInfo as $key => $val){
$TotalAdultChild = $val['Adult'] + $val['Child'];
// if($val['Adult'] >= $roomMinAdult && $val['Adult'] <= $roomMaxAdult && $val['Child'] >= $roomMinChild && $val['Child'] <= $roomMaxChild && $TotalAdultChild <= $roomMaxGuest){
if($val['Adult'] >= $roomMinAdult && $val['Adult'] <= $roomMaxAdult && $val['Child'] <= $roomMaxChild && $TotalAdultChild <= $roomMaxGuest){
$checkRoomAvailability++;
}
}
if($checkRoomAvailability == $rooms){
$roomJsonInfoArr[$RoomType] = $roomJsonInfo;
}else{
for($k=1;$k<=$searchTotal;$k++){
if($searchAdult>0){
$roomJsonInfoArr[$RoomType][$k]['Adult'] = ($searchAdult>=$roomMinAdult) ? $roomMinAdult : $searchAdult;
$searchAdult = $searchAdult - $roomMinAdult;
}
if($searchChild>0){
$roomJsonInfoArr[$RoomType][$k]['Child'] = ($searchChild>=$roomMinChild) ? $roomMinChild : $searchChild;
$searchChild = $searchChild - $roomMinChild;
}
}
}
// foreach($roomJsonInfoArr[$RoomType] as $rKey => $rVal){
// $roomJsonInfoArrfinal[$RoomType][$rKey]['Adult'] = $rVal['Adult'];
// $roomJsonInfoArrfinal[$RoomType][$rKey]['Child'] = (count($roomJsonInfoArr[$RoomType]) >= $totalCh && $totalCh>0 )? 1 : $totalCh ;
// $totalCh = $totalCh - (count($roomJsonInfoArr[$RoomType]) >= $totalCh ? 1 : $totalCh) ;
// }
// if($checkRoomAvailability == $rooms){
// $roomJsonInfoArrfinal[$RoomType] = $roomJsonInfo;
// }
}
$roomJsonInfoArrfinal = $roomJsonInfoArr;
$return = array('RoomInfo'=>$RoomInfo1,'roomJsonInfoArrfinal'=>$roomJsonInfoArrfinal);
return $return;
}
}