| 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/junkdata/holidays.tripjack.comOLDSEP11bak/library/Helper/ |
Upload File : |
<?php
/* * *************************************************************
* Catabatic Technology Pvt. Ltd.
* File Name : Hotel.php
* File Desc. : Hotel helper to including supporting functions/methods for Hotels
* Created By : Pardeep Panchal <pardeep@catpl.co.in>
* Created Date : 24 Nov 2017
* Updated Date : 24 Nov 2017
* ************************************************************* */
class Zend_Controller_Action_Helper_Hotel extends Zend_Controller_Action_Helper_Abstract
{
public $baseUrl;
public $_session;
public $IsTJHotelAPI;
public function __construct()
{
$this->pluginLoader = new Zend_Loader_PluginLoader();
$this->db = Zend_Db_Table::getDefaultAdapter();
$BootStrap = $this->config();
$this->siteName = $BootStrap['siteName'];
$this->baseUrl = $BootStrap['siteUrl'];
$this->IsTJHotelAPI = isset($BootStrap['IsTJHotelAPI']) ? $BootStrap['IsTJHotelAPI'] : 0;
$this->gtxagencysysid = $BootStrap['gtxagencysysid']; // get gtxagencysysid from application config
$this->gtxagentsysid = $BootStrap['gtxagentsysid']; // get gtxagentsysid from application config
$this->_session = new Zend_Session_Namespace('User');
$this->objMdl = new Admin_Model_CRUD();
}
public function config()
{
$front = $this->getFrontController();
$bootstrap = $front->getParam('bootstrap');
if (null === $bootstrap) {
throw new Exception('Unable to find bootstrap');
}
// return $bootstrap->getOptions();
return $bootstrap->getOptions()['bootstrap'];
}
public function getRatingImage($rating, $fullRating = 5)
{
$ratingStar = '<img src="' . $this->baseUrl . 'public/images/red-star.png">';
$ratingStar_light = '<img src="' . $this->baseUrl . 'public/images/gray-star.png">';
$ratingImage = '';
for ($i = 0; $i < $rating; $i++) {
$ratingImage .= $ratingStar;
}
$grayStars = $fullRating - $rating;
for ($i = 0; $i < $grayStars; $i++) {
$ratingImage .= $ratingStar_light;
$ratingImage;
}
return $ratingImage;
}
public function getInclusionIcon($Inclusions, $stringSeparator = "")
{
//echo "<pre>";print_r($Inclusions);echo "</pre>";
$ret = $icon = '';
$InclusionsMaster = [
'wi-fi' => 'wifi',
'Internet' => 'wifi',
'tv' => 'television',
'minibar' => 'glass',
'bar' => 'glass',
'disability-friendly bathroom' => 'wheelchair',
'Disabled facilities' => 'wheelchair',
'secure parking' => 'car',
'parking' => 'car',
'Car parking (Payable to hotel, if applicable)' => 'car',
'Car parking' => 'car',
//'smoking rooms' => 'bath' ,
];
$ret = [];
if ($stringSeparator != "") {
foreach (explode($stringSeparator, $Inclusions) as $inc) {
$inc = trim($inc);
$icon = (isset($InclusionsMaster[$inc])) ? $InclusionsMaster[$inc] : "question";
if ($icon != 'question') {
if (!in_array($icon, $ret))
$ret[$InclusionsMaster[$inc]] = $icon;
}
}
} else {
foreach ($Inclusions as $inc) {
$inc = trim($inc);
$icon = (isset($InclusionsMaster[$inc])) ? $InclusionsMaster[$inc] : "question";
if ($icon != 'question') {
if (!in_array($icon, $ret))
$ret[$InclusionsMaster[$inc]] = $icon;
}
}
}
return $ret;
}
public function dataEncode($arrData)
{
return base64_encode(json_encode($arrData));
}
public function dataDecode($strData)
{
return json_decode(base64_decode($strData), 1);
}
public function sortArrayByColumn(&$arr = [], $col, $order = SORT_ASC)
{
$sort_col = array();
if (count($arr) > 0) {
foreach ($arr as $key => $row) {
@$sort_col[$key] = $row[$col];
}
}
@array_multisort($sort_col, $order, $arr);
}
public function dateFormat($date, $format = 1)
{
if ($format == 1) { // 2018-01-19T00:00:00
$arrDate = explode("T", $date);
return date('d-m-Y', strtotime($arrDate[0])); //30 Nov' 17 Thu
} elseif ($format == 2) {
return date('d M' . "'" . ' y D', strtotime($date)); //30 Nov' 17 Thu
} else {
return $date;
}
}
public function getRoomImagesByItemSysId(array $array, $ItemSysId)
{
$ret = [];
foreach ($array as $key => $value) {
if ($value['ItemSysId'] == $ItemSysId) {
$ret[] = ['index' => $value['ImgIndex'], 'img' => $value['Details']];
}
}
return $ret;
}
public function calculateNoOfDays($date1, $date2)
{
$diff = abs(strtotime($date2) - strtotime($date1));
$years = floor($diff / (365 * 60 * 60 * 24));
$months = floor(($diff - $years * 365 * 60 * 60 * 24) / (30 * 60 * 60 * 24));
$days = ceil(($diff - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 * 24) / (60 * 60 * 24)) + 1;
return $days;
}
public function getTotalCostOfHotelByTravelers($hotelArray, $roominfoarr, $arrMarkUp = [])
{
// echo "<pre>";print_r($hotelArray);
// echo "<pre>";print_r($roominfoarr);
// echo "<pre>";print_r($arrMarkUp);exit;
$MarkUpType = isset($arrMarkUp['MarkUpType']) ? $arrMarkUp['MarkUpType'] : '';
$MarkUp = isset($arrMarkUp['MarkUp']) ? $arrMarkUp['MarkUp'] : '';
$DOccupMarkUp = isset($arrMarkUp['DOccupMarkUp']) ? $arrMarkUp['DOccupMarkUp'] : '';
$SOccupMarkUp = isset($arrMarkUp['SOccupMarkUp']) ? $arrMarkUp['SOccupMarkUp'] : '';
$ExtraBedMarkUp = isset($arrMarkUp['ExtraBedMarkUp']) ? $arrMarkUp['ExtraBedMarkUp'] : '';
$ExtraWOBedMarkUp = isset($arrMarkUp['ExtraWOBedMarkUp']) ? $arrMarkUp['ExtraWOBedMarkUp'] : '';
if ($MarkUpType == 1) {
// Single
$NetSOccupCost = isset($hotelArray['NetSOccupCost']) ? $hotelArray['NetSOccupCost'] : 0;
$NetSOccupCostWidMrkp = $NetSOccupCost + $SOccupMarkUp;
// Single
// Double
$NetDOccupCost = isset($hotelArray['DOccupCost']) ? $hotelArray['DOccupCost'] : 0;
$NetDOccupCostWidMrkp = $NetDOccupCost + $DOccupMarkUp;
// Double
// ExtraBed
$NetExtraBedCost = isset($hotelArray['NetExtraBedCost']) ? $hotelArray['NetExtraBedCost'] : 0;
$NetExtraBedCostWidMrkp = $NetExtraBedCost + $ExtraBedMarkUp;
// ExtraBed
// ExtraWoBed
$NetExtraWOBedCost = isset($hotelArray['NetExtraWOBedCost']) ? $hotelArray['NetExtraWOBedCost'] : 0;
$NetExtraWOBedCostWidMrkp = $NetExtraWOBedCost + $ExtraWOBedMarkUp;
// ExtraWoBed
} else if ($MarkUpType == 2) {
// Single
$NetSOccupCost = isset($hotelArray['NetSOccupCost']) ? $hotelArray['NetSOccupCost'] : 0;
$SOccupMarkUpAmt = ($NetSOccupCost * $SOccupMarkUp) / 100;
$NetSOccupCostWidMrkp = $NetSOccupCost + $SOccupMarkUpAmt;
// Single
// Double
$NetDOccupCost = isset($hotelArray['DOccupCost']) ? $hotelArray['DOccupCost'] : 0;
$DOccupMarkUpAmt = ($NetDOccupCost * $DOccupMarkUp) / 100;
$NetDOccupCostWidMrkp = $NetDOccupCost + $DOccupMarkUpAmt;
// Double
// ExtraBed
$NetExtraBedCost = isset($hotelArray['NetExtraBedCost']) ? $hotelArray['NetExtraBedCost'] : 0;
$ExtraBedMarkUpAmt = ($NetExtraBedCost * $ExtraBedMarkUp) / 100;
$NetExtraBedCostWidMrkp = $NetExtraBedCost + $ExtraBedMarkUpAmt;
// ExtraBed
// ExtraBed
$NetExtraWOBedCost = isset($hotelArray['NetExtraWOBedCost']) ? $hotelArray['NetExtraWOBedCost'] : 0;
$ExtraBedMarkUpAmt = ($NetExtraWOBedCost * $ExtraWOBedMarkUp) / 100;
$NetExtraWOBedCostWidMrkp = $NetExtraWOBedCost + $ExtraBedMarkUpAmt;
// ExtraBed
} else {
// Single
$NetSOccupCost = isset($hotelArray['NetSOccupCost']) ? $hotelArray['NetSOccupCost'] : 0;
$SOccupMarkUpAmt = 0;
$NetSOccupCostWidMrkp = $NetSOccupCost + $SOccupMarkUpAmt;
// Single
// Double
$NetDOccupCost = isset($hotelArray['DOccupCost']) ? $hotelArray['DOccupCost'] : 0;
$DOccupMarkUpAmt = 0;
$NetDOccupCostWidMrkp = $NetDOccupCost + $DOccupMarkUpAmt;
// Double
// ExtraBed
$NetExtraBedCost = isset($hotelArray['NetExtraBedCost']) ? $hotelArray['NetExtraBedCost'] : 0;
$ExtraBedMarkUpAmt = 0;
$NetExtraBedCostWidMrkp = $NetExtraBedCost + $ExtraBedMarkUpAmt;
// ExtraBed
// ExtraBed
$NetExtraWOBedCost = isset($hotelArray['NetExtraWOBedCost']) ? $hotelArray['NetExtraWOBedCost'] : 0;
$ExtraBedMarkUpAmt = 0;
$NetExtraWOBedCostWidMrkp = $NetExtraWOBedCost + $ExtraBedMarkUpAmt;
// ExtraBed
}
$totalMember = 0;
$newcost = 0;
for ($m = 0; $m <= count($roominfoarr); $m++) {
$AdultPax = (int) @$roominfoarr[$m]['AdultPax'];
$ChildPax = (int) @$roominfoarr[$m]['ChildPax'];
$totalMember = $AdultPax + $ChildPax;
$ChildsAge = @$roominfoarr[$m]['ChildsAge'];
if ($totalMember == 1) {
$newcost = $newcost + (isset($hotelArray['NetSOccupCost']) ? $NetSOccupCostWidMrkp : $NetDOccupCostWidMrkp);
//$newcost = $newcost + $hotelArray['DOccupCost'];
} elseif ($totalMember == 2) {
$newcost = $newcost + $NetDOccupCostWidMrkp;
} else if ($totalMember > 2) {
if ($AdultPax == 3 && $ChildPax == 0) {
$newcost = $newcost + ($NetDOccupCostWidMrkp + $NetExtraBedCostWidMrkp);
} else if ($AdultPax == 2 && $ChildPax == 1) {
$newcost = $newcost + ($NetDOccupCostWidMrkp + $NetExtraWOBedCostWidMrkp);
} else if ($AdultPax == 3 && $ChildPax == 1) {
$newcost = $newcost + ($NetDOccupCostWidMrkp + $NetExtraBedCostWidMrkp + $NetExtraWOBedCostWidMrkp);
} else if ($AdultPax == 2 && $ChildPax == 2) {
$newcost = $newcost + ($NetDOccupCostWidMrkp + $NetExtraWOBedCostWidMrkp + $NetExtraWOBedCostWidMrkp);
} else if ($AdultPax == 1 && $ChildPax == 2) {
$newcost = $newcost + ($NetSOccupCostWidMrkp + $NetExtraWOBedCostWidMrkp + $NetExtraWOBedCostWidMrkp);
}
}
}
return round($newcost);
}
public function getTotalCostOfHotelByTravelersAPI($roomRate, $roominfoarr, $arrMarkUp = [])
{
// echo "<pre>";print_r($roomRate);
// echo "<pre>";print_r($roominfoarr);
// echo "<pre>";print_r($arrMarkUp);exit;
$MarkUpType = isset($arrMarkUp['MarkUpType']) ? $arrMarkUp['MarkUpType'] : '';
$MarkUp = isset($arrMarkUp['MarkUp']) ? $arrMarkUp['MarkUp'] : '';
$DOccupMarkUp = isset($arrMarkUp['DOccupMarkUp']) ? $arrMarkUp['DOccupMarkUp'] : '';
$SOccupMarkUp = isset($arrMarkUp['SOccupMarkUp']) ? $arrMarkUp['SOccupMarkUp'] : '';
$ExtraBedMarkUp = isset($arrMarkUp['ExtraBedMarkUp']) ? $arrMarkUp['ExtraBedMarkUp'] : '';
$ExtraWOBedMarkUp = isset($arrMarkUp['ExtraWOBedMarkUp']) ? $arrMarkUp['ExtraWOBedMarkUp'] : '';
if ($MarkUpType == 1) {
// Single
$SOccupMarkUpAmt = $SOccupMarkUp;
// Single
// Double
$DOccupMarkUpAmt = $DOccupMarkUp;
// Double
// ExtraBed
$ExtraBedMarkUpAmt = $ExtraBedMarkUp;
// ExtraBed
// ExtraWoBed
$ExtraWOBedMarkUpAmt = $ExtraWOBedMarkUp;
// ExtraWoBed
} else if ($MarkUpType == 2) {
// Single
$NetSOccupCost = !empty($roomRate) ? $roomRate : 0;
$SOccupMarkUpAmt = ($NetSOccupCost * $SOccupMarkUp) / 100;
// Single
// Double
$NetDOccupCost = !empty($roomRate) ? $roomRate : 0;
$DOccupMarkUpAmt = ($NetDOccupCost * $DOccupMarkUp) / 100;
// Double
// ExtraBed
$NetExtraBedCost = !empty($roomRate) ? $roomRate : 0;
$ExtraBedMarkUpAmt = ($NetExtraBedCost * $ExtraBedMarkUp) / 100;
// ExtraBed
// ExtraBed
$NetExtraWOBedCost = !empty($roomRate) ? $roomRate : 0;
$ExtraWOBedMarkUpAmt = ($NetExtraWOBedCost * $ExtraWOBedMarkUp) / 100;
// ExtraBed
} else {
// Single
$SOccupMarkUpAmt = 0;
// Single
// Double
$DOccupMarkUpAmt = 0;
// Double
// ExtraBed
$ExtraBedMarkUpAmt = 0;
// ExtraBed
// ExtraBed
$ExtraWOBedMarkUpAmt = 0;
// ExtraBed
}
$totalMember = 0;
$newcost = 0;
for ($m = 0; $m <= count($roominfoarr); $m++) {
$AdultPax = (int) @$roominfoarr[$m]['AdultPax'];
$ChildPax = (int) @$roominfoarr[$m]['ChildPax'];
$totalMember = $AdultPax + $ChildPax;
$ChildsAge = @$roominfoarr[$m]['ChildsAge'];
if ($totalMember == 1) {
$newcost = $newcost + (!empty($SOccupMarkUpAmt) ? $SOccupMarkUpAmt : $DOccupMarkUpAmt);
//$newcost = $newcost + $hotelArray['DOccupCost'];
} elseif ($totalMember == 2) {
$newcost = $newcost + $DOccupMarkUpAmt;
} else if ($totalMember > 2) {
if ($AdultPax == 3 && $ChildPax == 0) {
$newcost = $newcost + ($DOccupMarkUpAmt + $ExtraBedMarkUpAmt);
} else if ($AdultPax == 2 && $ChildPax == 1) {
$newcost = $newcost + ($DOccupMarkUpAmt + $ExtraWOBedMarkUpAmt);
} else if ($AdultPax == 3 && $ChildPax == 1) {
$newcost = $newcost + ($DOccupMarkUpAmt + $ExtraBedMarkUpAmt + $ExtraWOBedMarkUpAmt);
} else if ($AdultPax == 2 && $ChildPax == 2) {
$newcost = $newcost + ($DOccupMarkUpAmt + $ExtraWOBedMarkUpAmt + $ExtraWOBedMarkUpAmt);
} else if ($AdultPax == 1 && $ChildPax == 2) {
$newcost = $newcost + (!empty($SOccupMarkUpAmt) ? $SOccupMarkUpAmt : $DOccupMarkUpAmt + $ExtraWOBedMarkUpAmt + $ExtraWOBedMarkUpAmt);
}
}
}
return round($newcost + $roomRate);
}
public function markUpCalculation($cast, $roominfoarr)
{
// echo "<pre>";print_r($hotelArray);
// echo "<pre>";print_r($roominfoarr);
echo $cast;
exit;
$totalMember = 0;
$newcost = 0;
for ($m = 0; $m <= count($roominfoarr); $m++) {
$AdultPax = (int) @$roominfoarr[$m]['AdultPax'];
$ChildPax = (int) @$roominfoarr[$m]['ChildPax'];
$totalMember = $AdultPax + $ChildPax;
$ChildsAge = @$roominfoarr[$m]['ChildsAge'];
}
return round($newcost);
}
public function CreateSessionSearchParams($getData, $TraceId)
{
Zend_Session::namespaceUnset('sessionHotelSearchParams');
Zend_Session::namespaceUnset('sessionHotelTraceId');
if (!empty($getData)) {
$sessionHotelSearchParams = new Zend_Session_Namespace('sessionHotelSearchParams');
$SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
$sessionHotelSearchParams->params = $getData; // Putting all form data to Session
$SearchHotelTraceId->params = $TraceId;
// echo "<pre>";print_r($getData);die;
$check_In = $getData['check_in'];
$check_Out = $getData['check_out'];
$check_In2 = $getData['check_in2'];
$check_Out2 = $getData['check_out2'];
$checkbuttonDate = isset($getData['checkbuttonDate']) ? (int)$getData['checkbuttonDate'] : 0;
$room = $getData['room'];
$adultAr = $getData['adult'];
$childAr = $getData['child'];
$child1_bed_typeAr = $getData['child1_age'];
$child2_bed_typeAr = $getData['child2_age'];
$arrCheckInDate = explode("/", $check_In);
if (count($arrCheckInDate) > 0) {
$checkIn = $arrCheckInDate[2] . "-" . $arrCheckInDate[1] . "-" . $arrCheckInDate[0];
}
$arrCheckOutDate = explode("/", $check_Out);
if (count($arrCheckOutDate) > 0) {
$checkOut = $arrCheckOutDate[2] . "-" . $arrCheckOutDate[1] . "-" . $arrCheckOutDate[0];
}
$nightCoun = Zend_Controller_Action_HelperBroker::getStaticHelper("Hotel")->calculateNoOfDays($checkIn, $checkOut);
$nightCount = ($nightCoun > 1) ? ($nightCoun - 1) : 1;
if($checkbuttonDate == 1){
$arrCheckInDate2 = explode("/", $check_In2);
if (count($arrCheckInDate2) > 0) {
$checkIn2 = $arrCheckInDate2[2] . "-" . $arrCheckInDate2[1] . "-" . $arrCheckInDate2[0];
}
$arrCheckOutDate2 = explode("/", $check_Out2);
if (count($arrCheckOutDate2) > 0) {
$checkOut2 = $arrCheckOutDate2[2] . "-" . $arrCheckOutDate2[1] . "-" . $arrCheckOutDate2[0];
}
$nightCoun2 = Zend_Controller_Action_HelperBroker::getStaticHelper("Hotel")->calculateNoOfDays($checkIn2, $checkOut2);
$nightCount = $nightCount + (($nightCoun2 > 1) ? ($nightCoun2 - 1) : 1);
}
if($getData['CountryId'] != '101') {
$interNationalSearch = true;
}else{
$interNationalSearch = false;
}
// echo "<pre>";print_r($this->IsTJHotelAPI);
// echo "<pre>";print_r($interNationalSearch);
// echo "<pre>";print_r($getData);
// die;
$memberdata = [];
$roomInfo = [];
if ($room) {
for ($i = 0; $i < $room; $i++) {
$adult = $adultAr[$i];
$child = $childAr[$i];
$child1_bed_type = $child1_bed_typeAr[$i];
$child2_bed_type = $child2_bed_typeAr[$i];
$chAGe = ($child > 0) ? array($child1_bed_type) : null;
$chAGe2 = ($child > 0) ? array($child2_bed_type) : null;
$childArray = null;
if ($child == 1) {
$childArray = ($chAGe);
} elseif ($child == 2) {
$childArray = array_merge($chAGe, $chAGe2);
}
$memberdata[] = array(
'NoOfAdults' => $adult,
'NoOfChild' => $child,
'ChildAge' => $childArray
);
$roomInfo[] = array(
'numberOfAdults' => $adult,
'numberOfChild' => $child,
'childAge' => $childArray
);
}
}
$searchQuery = array(
'searchQuery' => array(
'checkinDate' => $checkIn,
'checkoutDate' => $checkOut,
'roomInfo' => $roomInfo,
'searchCriteria' => array(
'city' => $getData['TBBCityId'],
'currency' => 'INR',
'nationality' => $getData['Nationality'],
),
'searchPreferences' => array(
'ratings' => [0, 1, 2, 3, 4, 5],
'fsc' => true,
)
),
'sync' => false
);
$TBOdata = array(
'CheckInDate' => $check_In,
'NoOfNights' => $nightCount,
'CityId' => $getData['TBBCityId'], //'10409',
'CountryCode' => $getData['hotel_countryCode'],
'IsTBOMapped' => true,
'ResultCount' => null,
'PreferredCurrency' => 'INR',
'GuestNationality' => $getData['GuestNationality'],
'NoOfRooms' => $room,
'RoomGuests' => $memberdata,
'PreferredHotel' => '',
'MaxRating' => 5,
'MinRating' => 0,
'ReviewScore' => null,
'IsNearBySearchAllowed' => false
);
// echo "<pre>";print_r($TBOdata);
// echo "<pre>";print_r($getData);
// die;
$sessionHotelSearchParams->params['memberdata'] = $memberdata;
$sessionHotelSearchParams->params['TBOdata'] = $TBOdata;
$sessionHotelSearchParams->params['hotelsearchdata'] = $searchQuery;
$sessionHotelSearchParams->params['nightCount'] = $nightCount;
$sessionHotelSearchParams->params['strCheckin'] = $checkIn;
$sessionHotelSearchParams->params['strCheckout'] = $checkOut;
$sessionHotelSearchParams->params['strCheckin2'] = $checkIn2;
$sessionHotelSearchParams->params['strCheckout2'] = $checkOut2;
$sessionHotelSearchParams->params['SearchHotelTraceId'] = $TraceId;
$sessionHotelSearchParams->params['interNationalSearch'] = $interNationalSearch;
if ($this->IsTJHotelAPI == 1) {
$searchIds = $this->getHotelSearchId($sessionHotelSearchParams->params);
$sessionHotelSearchParams->params['searchIds'] = $searchIds;
}
if (HOTEL_API_LOGS) {
//Write Request Logs starts...
// $strFilePath = "hotels/SearchParam/" . $TraceId . '/' . date('Y-m-d-H-i-s') . "_SearchParam_request.json";
// Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($sessionHotelSearchParams->params));
}
return true;
} else {
die('Oops something went wrong');
}
}
public function getHotelSearchId($data)
{
$HotelTraceId = $data['SearchHotelTraceId'];
$data_stringh = json_encode($data['hotelsearchdata']);
if (HOTEL_API_LOGS) {
$strFilePath = "hotels/" . $HotelTraceId . '/hotel_searchquery_list/search-request-' . date('Y-m-d-H-i-s') . ".json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_stringh);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, hotel_searchquery_list);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'apikey:' . hotel_api_key,
'Content-Length: ' . strlen($data_stringh)
));
$response = curl_exec($ch);
curl_close($ch);
// print_r(hotel_searchquery_list);
// print_r($response);
// die('ddd');
$resultSearch = json_decode($response, true);
if (HOTEL_API_LOGS) {
$strFilePath = "hotels/" . $HotelTraceId . '/hotel_searchquery_list/search-response-' . date('Y-m-d-H-i-s') . ".json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $response);
}
return $resultSearch['searchIds'][0];
}
// TBO Api integration
public function authenticateAPI($AgencySysid)
{
$objFlight = new Travel_Model_FlightMaster();
$CheckFlightToken = $objFlight->CheckFlightToken('tbl_token', $AgencySysid, 1);
if (empty($CheckFlightToken)) {
$data = array(
'ClientId' => FLIGHT_API_CLIENT_ID_H,
'UserName' => FLIGHT_API_USER_H,
'Password' => FLIGHT_API_PASSWORD_H,
'EndUserIp' => $_SERVER['REMOTE_ADDR'],
);
$data_string = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TBO_AUTHENTICATE_URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
));
$output = curl_exec($ch);
//echo '<pre>';print_r($output);die;
$response = json_decode($output, true);
if (FLIGHT_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "flight/Auth/" . date('Y-m-d-H-i-s') . "_Auth_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_string);
//Write Request Logs starts...
//Write Request Logs starts...
$strFilePath = "flight/Auth/" . date('Y-m-d-H-i-s') . "_Auth_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $output);
//Write Request Logs starts...
}
$Status = isset($response['Status'])?$response['Status']:0;
$tokenId = $response['TokenId'];
$AgencyId = $response['Member']['AgencyId'];
$MemberId = $response['Member']['MemberId'];
curl_close($ch);
$insertArr = array(
'token' => $tokenId,
'AgencySysid' => $AgencySysid,
'AgencyId' => $AgencyId,
'MemberId' => $MemberId,
'authresponse' => $output,
'PlanType' => 1,
'created_at' => Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss'),
);
if($Status == 1){
$objFlight->InsertFlightData('tbl_token', $insertArr);
}
return $insertArr;
} else {
$insertArr = array(
'token' => $CheckFlightToken['token'],
'AgencyId' => $CheckFlightToken['AgencyId'],
'MemberId' => $CheckFlightToken['MemberId'],
);
return $insertArr;
}
}
public function searchApiHotel($arrSessionData = array(), $AgencySysid)
{
if ($arrSessionData) {
$SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
$HotelTraceId = $SearchHotelTraceId->params;
$tokenId = $this->authenticateAPI($AgencySysid);
$arrSessionData['EndUserIp'] = $_SERVER['REMOTE_ADDR'];
$arrSessionData['TokenId'] = $tokenId['token'];
$NoOfAdults = isset($arrSessionData['RoomGuests'][0]['NoOfAdults']) ? $arrSessionData['RoomGuests'][0]['NoOfAdults'] :1;
$NoOfChild = isset($arrSessionData['RoomGuests'][0]['NoOfChild']) ? $arrSessionData['RoomGuests'][0]['NoOfChild'] :0;
$totalPax = $NoOfAdults + $NoOfChild;
$data_stringh = json_encode($arrSessionData);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TBO_HOTEL_API_SEARCH_URL);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
// echo "arrSessionData<pre>";print_r($arrSessionData);die;
if (HOTEL_API_LOGS) {
$ResponseStatus = isset($response['HotelSearchResult']['ResponseStatus']) ? $response['HotelSearchResult']['ResponseStatus'] : 0;
$ErrorMessage = isset($response['HotelSearchResult']['Error']['ErrorMessage']) ? $response['HotelSearchResult']['Error']['ErrorMessage'] : '';
$logParams = [
"user_id" => 1,
"custom_error" => ($ResponseStatus == 1) ? "Hotel Search Success" : "Hotel Search Failed",
'error' => $ErrorMessage,
"text_udf" => ['response' => $response], // Response
"char_udf" => ['request' => $arrSessionData], // Request
"udf1" => $HotelTraceId,
"status" => ($ResponseStatus == 1) ? 2 : 1,
"udf5" => 'hotel search',
"from_destination" => '',
"to_destination" => '',
"flight_type" => 1,
"source" => 1,
"Pax" => $totalPax,
"Supplier" => 'TBO',
"Airline" => '',
];
$logs = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
//Write Request Logs starts...
$strFilePath = "hotels/SearchParam/" . $HotelTraceId . "/search/" . date('Y-m-d-H-i-s') . "_search_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_stringh);
//Write Request Logs starts...
//Write Request Logs starts...
$strFilePath = "hotels/SearchParam/" . $HotelTraceId . "/search/" . date('Y-m-d-H-i-s') . "_search_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
//Write Request Logs starts...
}
$arrHotelSearchResponse = array();
$arrHotelSearchResponse['ResponseStatus'] = $response['HotelSearchResult']['ResponseStatus'];
$arrHotelSearchResponse['TraceId'] = $response['HotelSearchResult']['TraceId'];
$arrHotelSearchResponse['ErrorCode'] = $response['HotelSearchResult']['Error']['ErrorCode'];
$arrHotelSearchResponse['ErrorMessage'] = $response['HotelSearchResult']['Error']['ErrorMessage'];
$arrHotelSearchResponse['Remarks'] = $response['HotelSearchResult']['Remarks'];
$arrHotelSearchResponse['CheckInDate'] = $response['HotelSearchResult']['CheckInDate'];
$arrHotelSearchResponse['CheckOutDate'] = $response['HotelSearchResult']['CheckOutDate'];
$arrHotelSearchResponse['HotelResults'] = $response['HotelSearchResult']['HotelResults'];
$RequestRoomInfo = [];
$RequestHotelInfo = [];
if ($arrHotelSearchResponse['ResponseStatus'] == 1) {
if ($arrHotelSearchResponse['HotelResults']) {
foreach ($arrHotelSearchResponse['HotelResults'] as $key => $value) {
// Get Room details //
$GetHotelRoom['EndUserIp'] = $_SERVER['REMOTE_ADDR'];
$GetHotelRoom['TokenId'] = $tokenId['token'];
$GetHotelRoom['TraceId'] = $arrHotelSearchResponse['TraceId'];
$GetHotelRoom['ResultIndex'] = $value['ResultIndex'];
$GetHotelRoom['HotelCode'] = $value['HotelCode'];
$RequestRoomInfo[$key] = array(
'url' => TBO_HOTEL_API_HOTEL_ROOM_INFO,
'post' => $GetHotelRoom,
);
$RequestHotelInfo[$key] = array(
'url' => TBO_HOTEL_API_HOTEL_INFO,
'post' => $GetHotelRoom,
);
}
}
}
$arrHotelSearchResponse['RequestRoomInfo'] = $RequestRoomInfo;
$arrHotelSearchResponse['RequestHotelInfo'] = $RequestHotelInfo;
Zend_Session::namespaceUnset('HotelSearchResults');
$HotelSearchResults = new Zend_Session_Namespace('HotelSearchResults');
$HotelSearchResults->params = $arrHotelSearchResponse;
return $arrHotelSearchResponse;
}
}
public function apiGenerateVoucher($BookingId)
{
$SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
$HotelTraceId = $SearchHotelTraceId->params;
$tokenId = $this->authenticateAPI();
$arrSessionData['EndUserIp'] = $_SERVER['REMOTE_ADDR'];
$arrSessionData['TokenId'] = $tokenId;
$arrSessionData['BookingId'] = $BookingId;
$data_string = json_encode($arrSessionData);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TBO_HOTEL_API_GENERATE_VOUCHER);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'Content-Length: ' . strlen($data_string)
));
$output = curl_exec($ch);
$response = json_decode($output, true);
if (HOTEL_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "hotels/SearchParam/" . $HotelTraceId . "/GenerateVoucher/" . date('Y-m-d-H-i-s') . "_GenerateVoucher_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_string);
//Write Request Logs starts...
//Write Request Logs starts...
$strFilePath = "hotels/SearchParam/" . $HotelTraceId . "/GenerateVoucher/" . date('Y-m-d-H-i-s') . "_GenerateVoucher_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $output);
//Write Request Logs starts...
}
curl_close($ch);
return $response;
}
public function ApiGetBookingDetail($BookingId)
{
$SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
$HotelTraceId = $SearchHotelTraceId->params;
$tokenId = $this->authenticateAPI();
$arrSessionData['EndUserIp'] = $_SERVER['REMOTE_ADDR'];
$arrSessionData['TokenId'] = $tokenId;
$arrSessionData['BookingId'] = $BookingId;
$data_string = json_encode($arrSessionData);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TBO_HOTEL_API_FETCH_BOOKING_DETAIL_URL);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'Content-Length: ' . strlen($data_string)
));
$output = curl_exec($ch);
$response = json_decode($output, true);
if (HOTEL_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "hotels/SearchParam/" . $HotelTraceId . "/BookingDetail/" . date('Y-m-d-H-i-s') . "_BookingDetail_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_string);
//Write Request Logs starts...
//Write Request Logs starts...
$strFilePath = "hotels/SearchParam/" . $HotelTraceId . "/BookingDetail/" . date('Y-m-d-H-i-s') . "_BookingDetail_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $output);
//Write Request Logs starts...
}
curl_close($ch);
return $response;
}
public function apiChangeRequest($BookingId, $Remarks)
{
$SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
$HotelTraceId = $SearchHotelTraceId->params;
$tokenId = $this->authenticateAPI();
$arrSessionData['EndUserIp'] = $_SERVER['REMOTE_ADDR'];
$arrSessionData['TokenId'] = $tokenId;
$arrSessionData['BookingMode'] = 5;
$arrSessionData['RequestType'] = 4;
$arrSessionData['Remarks'] = $Remarks;
$arrSessionData['BookingId'] = $BookingId;
$data_string = json_encode($arrSessionData);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TBO_HOTEL_API_CANCELLATION_URL);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'Content-Length: ' . strlen($data_string)
));
$output = curl_exec($ch);
$response = json_decode($output, true);
if (HOTEL_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "hotels/SearchParam/" . $HotelTraceId . "/HotelCancel/" . date('Y-m-d-H-i-s') . "_ChangeRequest_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_string);
//Write Request Logs starts...
//Write Request Logs starts...
$strFilePath = "hotels/SearchParam/" . $HotelTraceId . "/HotelCancel/" . date('Y-m-d-H-i-s') . "_ChangeRequest_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $output);
//Write Request Logs starts...
}
curl_close($ch);
return $response;
}
public function apiGetChangeRequestStatus($ChangeRequestId)
{
$SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
$HotelTraceId = $SearchHotelTraceId->params;
$tokenId = $this->authenticateAPI();
$arrSessionData['EndUserIp'] = $_SERVER['REMOTE_ADDR'];
$arrSessionData['TokenId'] = $tokenId;
$arrSessionData['ChangeRequestId'] = $ChangeRequestId;
$data_string = json_encode($arrSessionData);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TBO_HOTEL_API_CANCELLATION_STATUS_URL);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'Content-Length: ' . strlen($data_string)
));
$output = curl_exec($ch);
$response = json_decode($output, true);
if (HOTEL_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "hotels/SearchParam/" . $HotelTraceId . "/HotelCancelStatus/" . date('Y-m-d-H-i-s') . "_ChangeStatus_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_string);
//Write Request Logs starts...
//Write Request Logs starts...
$strFilePath = "hotels/SearchParam/" . $HotelTraceId . "/HotelCancelStatus/" . date('Y-m-d-H-i-s') . "_ChangeStatus_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $output);
//Write Request Logs starts...
}
curl_close($ch);
return $response;
}
public function apiHotelBlocking($arrSessionData = array(), $AgencySysid)
{
if ($arrSessionData) {
$SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
$HotelTraceId = $SearchHotelTraceId->params;
$HotelData = $arrSessionData['HotelData'];
$RoomInfo = $arrSessionData['RoomInfoData'];
$getData = $arrSessionData['sessionHotelSearchParams'];
$SupplierHotelCodes = $HotelData['SupplierHotelCodes'];
$post = $arrSessionData['post'];
$destination = isset($getData['destination']) ? $getData['destination'] :'';
$TotalGuest = ($getData['totadlt'] + $getData['totchld']);
$memberdata = ($getData['memberdata']);
$ARR_SALUTION = unserialize(ARR_SALUTION);
$CancelDateskipped = false;
$HotelPassenger = [];
if ($memberdata) {
foreach ($memberdata as $key => $mem) {
$RoomInfoData = $RoomInfo[$key];
$currentDate = date('Y-m-d');
$LastCancellationDate = str_replace('T', ' ', $RoomInfoData['LastCancellationDate']);
if (strtotime($currentDate) > strtotime($LastCancellationDate)) {
$CancelDateskipped = true;
}
$HotelRoomsDetails[$key] = array(
'RoomIndex' => $RoomInfoData['RoomIndex'],
'RoomTypeCode' => $RoomInfoData['RoomTypeCode'],
'RoomTypeName' => $RoomInfoData['RoomTypeName'],
'RatePlanCode' => $RoomInfoData['RatePlanCode'],
'BedTypeCode' => null,
'SmokingPreference' => 0,
'Supplements' => null,
'Price' => array(
'CurrencyCode' => $RoomInfoData['Price']['CurrencyCode'],
'RoomPrice' => number_format($RoomInfoData['Price']['RoomPrice'], 2, '.', ''),
'Tax' => number_format($RoomInfoData['Price']['Tax'], 2, '.', ''),
'ExtraGuestCharge' => number_format($RoomInfoData['Price']['ExtraGuestCharge'], 2, '.', ''),
'ChildCharge' => $RoomInfoData['Price']['ChildCharge'],
'OtherCharges' => number_format($RoomInfoData['Price']['OtherCharges'], 2, '.', ''),
'Discount' => $RoomInfoData['Price']['Discount'],
'PublishedPrice' => number_format($RoomInfoData['Price']['PublishedPrice'], 2, '.', ''),
'PublishedPriceRoundedOff' => $RoomInfoData['Price']['PublishedPriceRoundedOff'],
'OfferedPrice' => number_format($RoomInfoData['Price']['OfferedPrice'], 2, '.', ''),
'OfferedPriceRoundedOff' => $RoomInfoData['Price']['OfferedPriceRoundedOff'],
'AgentCommission' => $RoomInfoData['Price']['AgentCommission'],
'AgentMarkUp' => $RoomInfoData['Price']['AgentMarkUp'],
'ServiceTax' => number_format($RoomInfoData['Price']['ServiceTax'], 2, '.', ''),
'TDS' => $RoomInfoData['Price']['TDS'],
),
//'HotelPassenger'=> $HotelPassenger,
);
}
}
$TraceId = $HotelData['TraceId'];
$bookingArr = array(
'ResultIndex' => $HotelData['ResultIndex'],
'HotelCode' => $HotelData['HotelId'],
'HotelName' => $HotelData['HotelName'],
'GuestNationality' => 'IN',
'NoOfRooms' => $getData['room'],
'ClientReferenceNo' => 0,
'HotelRoomsDetails' => $HotelRoomsDetails,
);
if ($HotelData['IsTBOMapped'] == 1) {
//$bookingArr['CategoryId'] = isset($SupplierHotelCodes[0]['CategoryId']) ? $SupplierHotelCodes[0]['CategoryId'] : '';
$bookingArr['CategoryId'] = isset($RoomInfo[0]['CategoryId']) ? $RoomInfo[0]['CategoryId'] : '';
}
if ($CancelDateskipped) {
$bookingArr['IsVoucherBooking'] = true;
} else {
$bookingArr['IsVoucherBooking'] = false;
}
$tokenId = $this->authenticateAPI($AgencySysid);
$bookingArr['EndUserIp'] = $_SERVER['REMOTE_ADDR'];
$bookingArr['TokenId'] = $tokenId['token'];
$bookingArr['TraceId'] = $TraceId;
//echo "<pre>";print_r(($bookingArr));
$data_stringh = json_encode($bookingArr);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TBO_HOTEL_API_HOTEL_ROOM_BLOCK);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
// echo "<pre>";print_r(($response));
// die;
$ResponseStatus = isset($response['BlockRoomResult']['ResponseStatus']) ? $response['BlockRoomResult']['ResponseStatus'] : 0;
$ErrorMessage = isset($response['BlockRoomResult']['Error']['ErrorMessage']) ? $response['BlockRoomResult']['Error']['ErrorMessage'] : '';
$logParams = [
"user_id" => 1,
"custom_error" => ($ResponseStatus == 1) ? "Hotel Block Create Success" : "Hotel Block Create Failed",
'error' => $ErrorMessage,
"text_udf" => ['response' => $response], // Response
"char_udf" => ['request' => $bookingArr], // Request
"udf1" => $HotelTraceId,
"status" => ($ResponseStatus == 1) ? 2 : 1,
"udf5" => 'Hotel Block',
"from_destination" => $destination,
"to_destination" => $destination,
"flight_type" => 5,
"source" => 2,
"Pax" => $TotalGuest,
"Supplier" => 'TBO',
];
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
if (HOTEL_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "hotels/SearchParam/" . $HotelTraceId . "/Block/" . date('Y-m-d-H-i-s') . "_Block_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_stringh);
//Write Request Logs starts...
//Write Request Logs starts...
$strFilePath = "hotels/SearchParam/" . $HotelTraceId . "/Block/" . date('Y-m-d-H-i-s') . "_Block_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
//Write Request Logs starts...
}
Zend_Session::namespaceUnset('HotelBlockResponse');
$HotelBlockResponse = new Zend_Session_Namespace('HotelBlockResponse');
$HotelBlockResponse->params = $response;
return $response;
}
}
function getHotelBookingTripjack($data)
{
$HotelData = $data['HotelData'];
$RoomInfoData = $data['RoomInfoData'];
$HotelTraceId = $data['sessionHotelSearchParams']['SearchHotelTraceId'];
$HotelPassengerDetails = $data['post'];
$ARR_SALUTION = unserialize(ARR_SALUTION_TJ);
$ARR_SALUTION_CHILD = array("1" => "Miss", "2" => "Master");///unserialize(ARR_SALUTION_CHILD_HOTEL);
$bookingId = $HotelData['bookingId'];
$isHoldAllowed = $data['isHoldAllowed'];
$bookingHold = $data['bookingHold'];
$isIpr = true;
$sessionHotelSearchParams = new Zend_Session_Namespace('sessionHotelSearchParams');
$getsessionVal = $sessionHotelSearchParams->params;
$totadlt = $getsessionVal['totadlt'];
$totchld = $getsessionVal['totchld'];
$destination = $getsessionVal['destination'];
$TotalMembers = ($totadlt + $totchld);
$index = 0;
foreach ($HotelData['query']['roomInfo'] as $key => $rooms) {
$IsPassportMandatory = !empty($RoomInfoData['Rooms'][$key]['IsPassportMandatory']) ? $RoomInfoData['Rooms'][$key]['IsPassportMandatory'] : 0;
$IsPANMandatory = !empty($RoomInfoData['Rooms'][$key]['IsPANMandatory']) ? $RoomInfoData['Rooms'][$key]['IsPANMandatory'] : 0;
$travellerInfo = array();
for ($i = 1; $i <= $rooms['numberOfAdults']; $i++) {
$traveller['fN'] = $HotelPassengerDetails[$key][$index]['FirstName'];
$traveller['lN'] = $HotelPassengerDetails[$key][$index]['LastName'];
$traveller['ti'] = trim($ARR_SALUTION[$HotelPassengerDetails[$key][$index]['Salutation']]);
// $traveller['ti'] = 'Mr';
$traveller['pt'] = 'ADULT';
if ($IsPANMandatory == 1) {
if (!empty($HotelPassengerDetails[$key][$index]['panno'])) {
$traveller['pan'] = $HotelPassengerDetails[$key][$index]['panno'];
}
}
if ($IsPassportMandatory == 1) {
if (!empty($HotelPassengerDetails[$key][$index]['PassportNo'])) {
$traveller['pNum'] = $HotelPassengerDetails[$key][$index]['PassportNo'];
}
}
// if (!empty($HotelPassengerDetails[$key][$index]['passportno-'])) {
// $traveller['pNum'] = $HotelPassengerDetails[$key][$index]['passportno-'];
// }
$travellerInfo[] = $traveller;
$index++;
}
//childsalution_ ,passenger-child-firstname-, passenger-child-lastname-
for ($j = 1; $j <= $rooms['numberOfChild']; $j++) {
$traveller['fN'] = $HotelPassengerDetails[$key][$index]['FirstName'];
$traveller['lN'] = $HotelPassengerDetails[$key][$index]['LastName'];
$traveller['ti'] = trim($ARR_SALUTION_CHILD[$HotelPassengerDetails[$key][$index]['Salutation']]);
$traveller['pt'] = 'CHILD';
if ($IsPassportMandatory == 1) {
if (!empty($HotelPassengerDetails[$key][$index]['PassportNo'])) {
$traveller['pNum'] = $HotelPassengerDetails[$key][$index]['PassportNo'];
}
}
$travellerInfo[] = $traveller;
$alltraveller['travellerInfo'] = $travellerInfo;
$index++;
}
$alltraveller['travellerInfo'] = $travellerInfo;
$roomtravellerinfo[] = $alltraveller;
}
$emails[] = $HotelPassengerDetails[0][0]['EmailId'];
$contacts[] = $HotelPassengerDetails[0][0]['Contacts'];
$code[] = '+' . $HotelPassengerDetails[0][0]['countryCode'];
$deliveri['emails'] = $emails;
$deliveri['contacts'] = $contacts;
$deliveri['code'] = $code;
$amount = $RoomInfoData['RoomTotalPrice'];
$payments[] = array('amount' => (float)$amount);
$bookingrequest['bookingId'] = $bookingId;
$bookingrequest['roomTravellerInfo'] = $roomtravellerinfo;
$bookingrequest['deliveryInfo'] = $deliveri;
$bookingrequest['type'] = 'HOTEL';
$bookingrequest['paymentInfos'] = $payments;
if ($isHoldAllowed == 1 && $bookingHold == 1) {
unset($bookingrequest['paymentInfos']);
}
// echo '<pre>';
// print_r($bookingrequest);
// die('d');
$data_string = json_encode($bookingrequest);
if (HOTEL_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "hotels/" . $HotelTraceId . '/hotelBooking/request-' . date('Y-m-d-H-i-s') . ".json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_string);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, hotel_book);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'apikey:' . hotel_api_key,
'Content-Length: ' . strlen($data_string)
));
$outputH = curl_exec($ch);
if (HOTEL_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "hotels/" . $HotelTraceId . '/hotelBooking/response-' . date('Y-m-d-H-i-s') . ".json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
}
$response = json_decode($outputH, true);
// echo "response<pre>";print_r($response);
curl_close($ch);
$ResponseStatus = (isset($response['status']) && $response['status']) ? true : false;
$ErrorMessage = isset($response['BlockRoomResult']['Error']['ErrorMessage']) ? $response['BlockRoomResult']['Error']['ErrorMessage'] : '';
$logParams = [
"user_id" => 1,
"custom_error" => ($ResponseStatus == 1) ? "hotel booking Success" : "hotel booking Failed",
'error' => $ErrorMessage,
"text_udf" => ['response' => $response], // Response
"char_udf" => ['request' => $bookingrequest], // Request
"udf1" => $HotelTraceId,
"udf5" => 'hotelBooking',
"from_destination" => $destination,
"to_destination" => $destination,
"flight_type" => 5,
"source" => 2,
"Pax" => $TotalMembers,
"Supplier" => 'TRIPJACK',
"status" => ($response == 1) ? 2 : 1,
];
$dddddddddd = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
//echo "response<pre>";print_r($dddddddddd);
$HotelBookingResponse = new Zend_Session_Namespace('HotelBookingResponse');
$HotelBookingResponse->params = $response;
return $response;
}
function apiHoldConfirmTripJack($data)
{
$HotelData = $data['HotelData'];
$RoomInfoData = $data['RoomInfoData'];
$HotelTraceId = $data['sessionHotelSearchParams']['SearchHotelTraceId'];
$bookingId = $HotelData['bookingId'];
$isIpr = true;
$amount = $RoomInfoData['RoomTotalPrice'];
$payments[] = array('amount' => (float)$amount);
$bookingrequest['bookingId'] = $bookingId;
$bookingrequest['paymentInfos'] = $payments;
// echo '<pre>';
// print_r($bookingrequest);
// die('d');
$data_string = json_encode($bookingrequest);
if (HOTEL_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "hotels/" . $HotelTraceId . '/HoldConfirm/request-' . date('Y-m-d-H-i-s') . ".json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_string);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, hold_hotel_booking_confirm);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'apikey:' . hotel_api_key,
'Content-Length: ' . strlen($data_string)
));
$outputH = curl_exec($ch);
if (HOTEL_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "hotels/" . $HotelTraceId . '/HoldConfirm/response-' . date('Y-m-d-H-i-s') . ".json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
}
$response = json_decode($outputH, true);
curl_close($ch);
return $response;
}
function getHotelBookingDetails($data)
{
$bookingId['bookingId'] = $data['bookingId'];
$data_string = json_encode($bookingId);
$HotelTraceId = $data['SearchHotelTraceId'];
if (HOTEL_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "hotels/" . $HotelTraceId . '/hotelBookingDetails/request-' . date('Y-m-d-H-i-s') . ".json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_string);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, booking_hotel_details);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'apikey:' . hotel_api_key,
'Content-Length: ' . strlen($data_string)
));
$outputH = curl_exec($ch);
if (HOTEL_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "hotels/" . $HotelTraceId . '/hotelBookingDetails/response-' . date('Y-m-d-H-i-s') . ".json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
}
$response = json_decode($outputH, true);
curl_close($ch);
return $response;
}
public function apiHotelBooking($arrSessionData = array())
{
if ($arrSessionData) {
// $SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
//$HotelTraceId = $SearchHotelTraceId->params;
$HotelData = $arrSessionData['HotelData'];
$RoomInfo = $arrSessionData['RoomInfoData'];
$getData = $arrSessionData['sessionHotelSearchParams'];
$HotelTraceId = $arrSessionData['sessionHotelSearchParams']['SearchHotelTraceId'];
$SupplierHotelCodes = $HotelData['SupplierHotelCodes'];
$IsPackageFare = $RoomInfo['IsPackageFare'];
$post = $arrSessionData['post'];
//$HotelCusData = $arrSessionData['HotelCusData'];
$TotalGuest = ($getData['totadlt'] + $getData['totchld']);
$memberdata = ($getData['memberdata']);
$ARR_SALUTION = unserialize(ARR_SALUTION_HOTEL);
$CancelDateskipped = false;
$hotelPassengerArr = array();
$index = 0;
for ($i = 0; $i < count($memberdata); $i++) {
$IsPANMandatoryArr = isset($RoomInfo['IsPANMandatory']) ? $RoomInfo['IsPANMandatory'] : 0;
$panno = isset($post[$i][$index]['panno']) ? $post[$i][$index]['panno'] : null;
$AdultPaxTotal = $memberdata[$i]['NoOfAdults'];
$ChildPaxTotal = $memberdata[$i]['NoOfChild'];
$paxTitle = trim($ARR_SALUTION[$post[$i][$index]['Salutation']]);
if ($AdultPaxTotal > 0) {
for ($m = 0; $m < $AdultPaxTotal; $m++) {
$ind = ($index - 1);
if ($m == 0) {
$LeadPassenger = true;
} else {
$LeadPassenger = false;
}
$hotelPassengerArr[$i]["paxes"][] = array(
'Title' => $paxTitle,
'FirstName' => $post[$i][$index]['FirstName'],
'Middlename' => null,
'LastName' => $post[$i][$index]['LastName'],
'Phoneno' => $post[$i][$index]['Contacts'],
'Email' => $post[$i][$index]['EmailId'],
'PaxType' => 1,
'LeadPassenger' => $LeadPassenger,
'PAN' => ($IsPANMandatoryArr == 1)?$panno:null,
'Age' => 0,
);
// if ($IsPANMandatoryArr == 1) {
// $hotelPassengerArr[$i]["paxes"][$index]['PAN'] = $panno;
// }
$index++;
}
}
$ChildAge = $memberdata[$i]['ChildAge'];
if ($ChildPaxTotal > 0) {
$ch = 0;
for ($m = 0; $m < $ChildPaxTotal; $m++) {
$ind = ($index - 1);
$hotelPassengerArr[$i]["paxes"][] = array(
'Title' => $paxTitle,
'FirstName' => $post[$i][$index]['FirstName'],
'Middlename' => null,
'LastName' => $post[$i][$index]['LastName'],
'Phoneno' => $post[$i][$index]['Contacts'],
'Email' => $post[$i][$index]['EmailId'],
'PaxType' => 2,
'LeadPassenger' => false,
'Age' => isset($ChildAge[$ch]) ? $ChildAge[$ch] : 0,
'PAN' => isset($post[0][0]['panno']) ? $post[0][0]['panno'] : '',
);
$ch++;
$index++;
}
}
}
$currentDate = date('Y-m-d');
$LastCancellationDate = str_replace('T', ' ', $RoomInfo['LastCancellationDate']);
if (strtotime($currentDate) > strtotime($LastCancellationDate)) {
$CancelDateskipped = true;
}
$HotelRoomsDetails = [];
if ($memberdata) {
foreach ($memberdata as $key => $mem) {
$HotelPassenger = $hotelPassengerArr[$key]['paxes'];
$RoomInfoData = !empty($RoomInfo['Rooms'][$key]['IsPassportMandatory']) ? $RoomInfo['Rooms'][$key]['IsPassportMandatory'] : 0;;
$HotelRoomsDetails[$key] = array(
'RoomIndex' => $RoomInfo['RoomIndex'],
'RoomTypeCode' => $RoomInfo['RoomTypeCode'],
'RoomTypeName' => $RoomInfo['RoomTypeName'],
'RatePlanCode' => $RoomInfo['RatePlanCode'],
'BedTypeCode' => null,
'SmokingPreference' => 0,
'Supplements' => null,
'Price' => array(
'CurrencyCode' => $RoomInfo['Price']['CurrencyCode'],
'RoomPrice' => number_format($RoomInfo['Price']['RoomPrice'], 2, ".", ""),
'Tax' => number_format($RoomInfo['Price']['Tax'], 2, ".", ""),
'ExtraGuestCharge' => $RoomInfo['Price']['ExtraGuestCharge'],
'ChildCharge' => $RoomInfo['Price']['ChildCharge'],
'OtherCharges' => number_format($RoomInfo['Price']['OtherCharges'], 2, ".", ""),
'Discount' => $RoomInfo['Price']['Discount'],
'PublishedPrice' => number_format($RoomInfo['Price']['PublishedPrice'], 2, ".", ""),
'PublishedPriceRoundedOff' => $RoomInfo['Price']['PublishedPriceRoundedOff'],
'OfferedPrice' => number_format($RoomInfo['Price']['OfferedPrice'], 2, ".", ""),
'OfferedPriceRoundedOff' => $RoomInfo['Price']['OfferedPriceRoundedOff'],
'AgentCommission' => $RoomInfo['Price']['AgentCommission'],
'AgentMarkUp' => $RoomInfo['Price']['AgentMarkUp'],
'ServiceTax' => number_format($RoomInfo['Price']['ServiceTax'], 2, ".", ""),
'TDS' => $RoomInfo['Price']['TDS'],
),
'HotelPassenger' => $HotelPassenger,
);
}
}
$TraceId = $HotelData['TraceId'];
$Surfacedata = date('Y-m-d');
$ArrivalTransport = array(
'ArrivalTransportType' => 1,
'TransportInfoId' => 'Sadan',
'Time' => $Surfacedata . "T11:00:00",
);
$DepartureTransport = array(
'DepartureTransportType' => 1,
'TransportInfoId' => 'Sadan',
'Time' => $Surfacedata . "T11:00:00",
);
$bookingArr = array(
'ResultIndex' => $HotelData['ResultIndex'],
'HotelCode' => $HotelData['HotelId'],
'HotelName' => $HotelData['HotelName'],
'GuestNationality' => 'IN',
'NoOfRooms' => $HotelData['rooms'],
'ClientReferenceNo' => 0,
//'IsPackageFare'=> true,
'HotelRoomsDetails' => $HotelRoomsDetails,
'ArrivalTransport' => $ArrivalTransport,
'DepartureTransport' => $DepartureTransport,
);
if ($HotelData['IsTBOMapped'] == 1) {
$bookingArr['CategoryId'] = isset($SupplierHotelCodes[0]['CategoryId']) ? $SupplierHotelCodes[0]['CategoryId'] : '';
}
if ($RoomInfo['IsPackageFare']) {
$bookingArr['IsPackageFare'] = $IsPackageFare;
}
if ($CancelDateskipped) {
$bookingArr['IsVoucherBooking'] = true;
} else {
$bookingArr['IsVoucherBooking'] = false;
}
$tokenId = $this->authenticateAPI($post[0][0]['AgencySysId']);
$bookingArr['EndUserIp'] = $_SERVER['REMOTE_ADDR'];
$bookingArr['TokenId'] = $tokenId['token'];
$bookingArr['TraceId'] = $TraceId;
$sessionHotelSearchParams = new Zend_Session_Namespace('sessionHotelSearchParams');
$getsessionVal = $sessionHotelSearchParams->params;
$totadlt = $getsessionVal['totadlt'];
$totchld = $getsessionVal['totchld'];
$destination = $getsessionVal['destination'];
$TotalMembers = ($totadlt + $totchld);
$data_stringh = json_encode($bookingArr);
// echo "<pre>";
// print_r(($bookingArr));
// die;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TBO_HOTEL_API_HOTEL_ROOM_BOOK);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
// echo "<pre>";
// print_r(($outputH));
// die;
if (HOTEL_API_LOGS) {
$ResponseStatus = isset($response['BookResult']['ResponseStatus']) ? $response['BookResult']['ResponseStatus'] : 0;
$ErrorMessage = isset($response['Error']['ErrorMessage']) ? $response['Error']['ErrorMessage'] : '';
$logParams = [
"user_id" => 1,
"custom_error" => ($ResponseStatus == 1) ? "hotel booking Success" : "hotel booking Failed",
'error' => $ErrorMessage,
"text_udf" => ['response' => $response], // Response
"char_udf" => ['request' => $bookingArr], // Request
"udf1" => $HotelTraceId,
"udf5" => 'hotelBooking',
"from_destination" => $destination,
"to_destination" => $destination,
"flight_type" => 5,
"source" => 2,
"Pax" => $TotalMembers,
"Supplier" => 'TBO',
"status" => ($response == 1) ? 2 : 1,
];
$dddddd = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
//Write Request Logs starts...
$strFilePath = "hotels/SearchParam/" . $HotelTraceId . "/book/" . date('Y-m-d-H-i-s') . "_book_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_stringh);
//Write Request Logs starts...
//Write Request Logs starts...
$strFilePath = "hotels/SearchParam/" . $HotelTraceId . "/book/" . date('Y-m-d-H-i-s') . "_book_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
//Write Request Logs starts...
}
Zend_Session::namespaceUnset('HotelBookingResponse');
$HotelBookingResponse = new Zend_Session_Namespace('HotelBookingResponse');
$HotelBookingResponse->params = $response;
return $response;
}
}
public function searchTaggingStaticData($arrSessionData = array(), $AgencySysid)
{
if ($arrSessionData) {
$SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
$HotelTraceId = $SearchHotelTraceId->params;
$tokenId = $this->authenticateAPI($AgencySysid);
$arrSessionData['EndUserIp'] = $_SERVER['REMOTE_ADDR'];
$arrSessionData['TokenId'] = $tokenId['token'];
$data_stringh = json_encode($arrSessionData);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TBO_HOTEL_API_TAGGINGSTATIC_DATA_URL);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
try {
$TBBCityId = $arrSessionData['CityId'];
$HotelData = str_replace('encoding="utf-16"', 'encoding="utf-8"', $response['HotelData']);
// $XMLFilePath = "hotels/staticData/" . $TBBCityId . "_HotelStaticData.xml";
// Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiXMLLogs($XMLFilePath, $HotelData);
$objXmlDocuments = simplexml_load_string($HotelData, 'SimpleXMLElement', LIBXML_NOCDATA);
$objJsonDocument = json_encode($objXmlDocuments);
$arrOutput = json_decode($objJsonDocument, TRUE);
//echo "<pre>";print_r($this->XMLtoArray($response['HotelData']));
$objFlight = new Travel_Model_FlightMaster();
$checkExist = $this->objMdl->rv_select_row('tbl_hotel_static_data', ['hotel_name', 'CityName'], ['CityId' => $TBBCityId], ['id' => 'DESC']);
if ($arrOutput['BasicPropertyInfo'] && empty($checkExist)) {
foreach ($arrOutput['BasicPropertyInfo'] as $key => $value) {
$vl = $value['@attributes'];
$dataArray = array(
'CityId' => $TBBCityId,
'hotel_id' => $vl['TBOHotelCode'],
'hotel_name' => $vl['HotelName'],
'staticJson' => json_encode($value)
);
$objFlight->InsertHotelStaticData('tbl_hotel_static_data', $dataArray);
//echo "<pre>"; print_r($vl);
}
}
} catch (Exception $e) {
print_r($e->getMessage());
die('w');
}
return $response;
}
}
public function getTaxSettingDetail($TaxSetting, $PlanType)
{
$getTaxSettingDetail = [];
if ($PlanType) {
if ($TaxSetting) {
foreach ($TaxSetting as $val) {
$getTaxSettingDetail[$val['PlanType']] = $val;
}
}
$TaxSettingDetail = isset($getTaxSettingDetail[$PlanType]) ? $getTaxSettingDetail[$PlanType] : [];
if (!empty($TaxSettingDetail)) {
return ['TaxName' => $TaxSettingDetail['TaxName'], 'TaxPercentage' => $TaxSettingDetail['TaxPercentage'], 'TaxType' => $TaxSettingDetail['TaxType'], 'Tax' => $TaxSettingDetail['Tax']];
} else {
return ['TaxName' => 'Not Found', 'TaxPercentage' => 0, 'TaxType' => 2, 'Tax' => 1];
}
} else {
$data = array('status' => false, 'message' => 'Invalid request');
return ($data);
}
}
public function getApiPriceWithMarkupAndServiceTax($data, $type = null)
{
$B2BType = $this->_session->B2BType;
$HotelRoomPrice = isset($data['HotelRoomPrice']) ? $data['HotelRoomPrice'] : 0;
$interNationalSearch = isset($data['interNationalSearch']) ? $data['interNationalSearch'] : 0;
$Nights = isset($data['nights']) ? $data['nights'] : 0;
if ($type == 'room') {
$rooms = 1;
} else {
$rooms = isset($data['rooms']) ? $data['rooms'] : 0;
}
$TaxSetting = isset($data['getMarkupNew']['TaxSetting']) ? $data['getMarkupNew']['TaxSetting'] : [];
$TaxSettingDetail = $this->getTaxSettingDetail($TaxSetting, 2);
$getMarkupNew = isset($data['getMarkupNew']['data']) ? $data['getMarkupNew']['data'] : [];
$arrAgentMarkups = isset($data['getAgencyMarkups']) ? $data['getAgencyMarkups'] : [];
$intGTXMarkUp = isset($data['GTXMarkups']) ? $data['GTXMarkups'] : 0;
// echo "<pre>";print_r($TaxSettingDetail);die;
$AdminComminAmount = 0;
$TotalAgencyMarkUp = 0;
$TotalMarkUpValue = 0;
// echo "<pre>";print_r($getMarkupNew);die;
if (count($getMarkupNew) > 0) {
foreach ($getMarkupNew as $key => $AgencyMarkups) {
if ($AgencyMarkups['PlanType'] == 2) {
$ItemSourceType = $AgencyMarkups['ItemSourceType']; // 1 domestic / 2 international
if ($ItemSourceType == 1 && empty($interNationalSearch)) { /// for domestic
$MarkUpValue = $AgencyMarkups['MarkUpValue'];
$TotalMarkUpValue += $MarkUpValue;
$intAgencyMarkUp = $AgencyMarkups['MarkUpValue']; // Agency Fix Mark UP...
if ($AgencyMarkups['MarkUpType'] == '1') { // for Fixed
$intAgencyMarkUp = $intAgencyMarkUp;
} else { // for Percentage
$intAgencyMarkUp = (($HotelRoomPrice + $intGTXMarkUp) * $intAgencyMarkUp) / 100;
}
$intAgencyMarkUp = (($intAgencyMarkUp * $Nights) * $rooms);
$TotalAgencyMarkUp += $intAgencyMarkUp;
} elseif ($ItemSourceType == 2 && $interNationalSearch == 1) { /// for International
$MarkUpValue = $AgencyMarkups['MarkUpValue'];
$TotalMarkUpValue += $MarkUpValue;
$intAgencyMarkUp = $AgencyMarkups['MarkUpValue']; // Agency Fix Mark UP...
if ($AgencyMarkups['MarkUpType'] == '1') { // for Fixed
$intAgencyMarkUp = $intAgencyMarkUp;
} else { // for Percentage
$intAgencyMarkUp = (($HotelRoomPrice + $intGTXMarkUp) * $intAgencyMarkUp) / 100;
}
$intAgencyMarkUp = (($intAgencyMarkUp * $Nights) * $rooms);
$TotalAgencyMarkUp += $intAgencyMarkUp;
}
}
}
}
$TotalAgentMarkUp = 0;
if (count($arrAgentMarkups) > 0 && $B2BType != 2) {
foreach ($arrAgentMarkups as $key => $AgtMarkups) {
$MarkUpType = ($AgtMarkups['MarkUpType']); // Agent Fix Mark UP...
$intAgentMarkUp = $AgtMarkups['MarkUp']; // Agent Fix Mark UP...
if ($MarkUpType == 1) {
$intAgentMarkUp = $intAgentMarkUp;
$intAgentMarkUp = (($intAgentMarkUp * $Nights) * $rooms);
$TotalAgentMarkUp += $intAgentMarkUp;
} else {
$intAgentMarkUp = (($HotelRoomPrice * $intAgentMarkUp) / 100);
$intAgentMarkUp = (($intAgentMarkUp * $Nights) * $rooms);
$TotalAgentMarkUp += $intAgentMarkUp;
}
}
} else {
$TotalAgentMarkUp = $TotalAgentMarkUp;
}
$TaxType = isset($TaxSettingDetail['TaxType']) ? $TaxSettingDetail['TaxType'] : 2;
$TaxPercentage = isset($TaxSettingDetail['TaxPercentage']) ? $TaxSettingDetail['TaxPercentage'] : 0;
// echo "<pre>";print_r($TaxPercentage);die;
if ($TaxType == 1) {
$arrGSTOnGTXMarkUp = $this->calculateServiceTax(($HotelRoomPrice+$intGTXMarkUp), $TaxPercentage);
$arrGSTOnAgencyMarkUp = $this->calculateServiceTax(($HotelRoomPrice+$TotalAgencyMarkUp), $TaxPercentage);
//$arrGSTOnAgentFixMarkUp = $this->calculateServiceTax($TotalAgentMarkUp, $TaxPercentage);
} else {
$arrGSTOnGTXMarkUp = $this->calculateServiceTax($intGTXMarkUp, $TaxPercentage);
$arrGSTOnAgencyMarkUp = $this->calculateServiceTax($TotalAgencyMarkUp, $TaxPercentage);
//$arrGSTOnAgentFixMarkUp = $this->calculateServiceTax($TotalAgentMarkUp, $TaxPercentage);
}
$intGSTOnGTXMarkUp = $arrGSTOnGTXMarkUp['serviceTaxAmount'];
$intGSTOnAgencyMarkUp = $arrGSTOnAgencyMarkUp['serviceTaxAmount'];
$intGSTOnAgentFixMarkUp = (isset($arrGSTOnAgentFixMarkUp['serviceTaxAmount'])) ? $arrGSTOnAgentFixMarkUp['serviceTaxAmount'] : 0;
$CostToAgent = ($HotelRoomPrice + $intGSTOnAgencyMarkUp + $TotalAgencyMarkUp + $intGTXMarkUp + $intGSTOnGTXMarkUp);
$arrPriceAndMarkUps = array(
"intBasePrice" => $HotelRoomPrice,
"PublishFare" => $CostToAgent,
"intGTXMarkUp" => $intGTXMarkUp,
"intSTaxOnGTXMarkUp" => $intGSTOnGTXMarkUp,
"intGTXMarkUpWithSTax" => ($intGTXMarkUp + $intGSTOnGTXMarkUp),
"intAgencyMarkUp" => $TotalAgencyMarkUp,
"intSTaxOnAgencyMarkUp" => $intGSTOnAgencyMarkUp,
"intAgencyMarkUpWithSTax" => ($intGSTOnAgencyMarkUp + $TotalAgencyMarkUp),
"TotalMarkUpValue" => ($TotalMarkUpValue),
"BR" => '=',
"totalAgentMarkUp" => $TotalAgentMarkUp,
"intGSTOnAgentFixMarkUp" => $intGSTOnAgentFixMarkUp,
'AgentB2CEarning' => ($TotalAgentMarkUp),
'CostToAgentCustomer' => ($CostToAgent + $intGSTOnAgentFixMarkUp + $TotalAgentMarkUp),
'CostToAgent' => ($CostToAgent),
'TaxSetting' => ($TaxSettingDetail),
);
return $arrPriceAndMarkUps;
// echo '<pre>';
//print_r($TotalAgencyMarkUp.'='.$intGSTOnAgencyMarkUp);
}
public function getMarkup($intCountryCode)
{
if ($intCountryCode) {
$this->postFields = "";
$this->postFields .= "&AgencySysId=$this->gtxagencysysid";
$this->postFields .= "&AgentSysId=$this->gtxagentsysid";
$this->postFields .= "&intCountryCode=$intCountryCode";
$model = new Gtxwebservices_Model_Webservices();
$result = $model->getMarkupAndServiceTax($this->postFields);
$response = json_decode($result, true);
return $response;
} else {
$data = array('status' => false, 'message' => 'Invalid country code');
return ($data);
}
}
public function calculateServiceTax($intAmount, $percentAgencySTax)
{
$intAmount = (float) $intAmount;
$intNetSTax = (($intAmount * $percentAgencySTax) / 100);
$BasePriceWithSTax = $intNetSTax + $intAmount;
$arrSerciceTax = array(
"BasePrice" => $intAmount,
"serviceTaxAmount" => $intNetSTax,
"BasePriceWithSTax" => $BasePriceWithSTax,
"ServiceTaxPercentage" => $percentAgencySTax,
);
return $arrSerciceTax;
}
//// Tripjack Hotel api code . added by md sabir
function getHotelSearchResult($data)
{
$serachid['searchId'] = $data['searchIds'];
$HotelTraceId = $data['SearchHotelTraceId'];
$totadlt = $data['totadlt'];
$totchld = $data['totchld'];
$destination = $data['destination'];
$TotalMembers = ($totadlt + $totchld);
$jsonSearchID = json_encode($serachid);
//sleep(5);
if (HOTEL_API_LOGS) {
$strFilePath = "hotels/" . $HotelTraceId . '/hotel_search/request-' . date('Y-m-d-H-i-s') . ".json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $jsonSearchID);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, hotel_search);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonSearchID);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'apikey:' . hotel_api_key,
'Content-Length: ' . strlen($jsonSearchID)
));
$resp = curl_exec($ch);
curl_close($ch);
$hotelsResultS = json_decode($resp, true);
//echo"<pre>";print_r($hotelsResultS);die();
if (HOTEL_API_LOGS) {
$strFilePath = "hotels/" . $HotelTraceId . '/hotel_search/response-' . date('Y-m-d-H-i-s') . ".json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $resp);
}
$ResponseStatus = $hotelsResultS['status']['success'];
$ErrorMessage = isset($hotelsResultS['errors'][0]['message']) ? $hotelsResultS['errors'][0]['message'] : '';
$logParams = [
"user_id" => 1,
"custom_error" => ($ResponseStatus == 1) ? "Search Success" : "Search Failed",
'error' => $ErrorMessage,
"text_udf" => ['response' => $hotelsResultS], // Response
"char_udf" => ['request' => $serachid], // Request
"udf1" => $HotelTraceId,
"udf5" => 'search',
"from_destination" => $destination,
"to_destination" => $destination,
"flight_type" => 5,
"source" => 2,
"Pax" => $TotalMembers,
"Supplier" => 'TRIPJACK',
"status" => ($ResponseStatus == 1) ? 2 : 1,
];
$dddd = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
return $hotelsResultS;
}
function getHotelDetails($data)
{
$getData = $data['getData'];
$totadlt = $getData['totadlt'];
$totchld = $getData['totchld'];
$destination = $getData['destination'];
$TotalMembers = ($totadlt + $totchld);
$datas['id'] = $data['id'];
$data_string = json_encode($datas);
$HotelTraceId = $data['SearchHotelTraceId'];
if (HOTEL_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "hotels/" . $HotelTraceId . '/hoteldetail/request-' . date('Y-m-d-H-i-s') . ".json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_string);
}
//echo"<pre>";print_r($getData);die();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, hotelDetail_search);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'apikey:' . hotel_api_key,
'Content-Length: ' . strlen($data_string)
));
$response = curl_exec($ch);
$hotelsResultS = json_decode($response, true);
curl_close($ch);
if (HOTEL_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "hotels/" . $HotelTraceId . '/hoteldetail/response-' . date('Y-m-d-H-i-s') . ".json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $response);
}
$ResponseStatus = $hotelsResultS['status']['success'];
$ErrorMessage = isset($hotelsResultS['errors'][0]['message']) ? $hotelsResultS['errors'][0]['message'] : '';
$logParams = [
"user_id" => 1,
"custom_error" => ($ResponseStatus == 1) ? "hotel Details Success" : "hotel Details Failed",
'error' => $ErrorMessage,
"text_udf" => ['response' => $hotelsResultS], // Response
"char_udf" => ['request' => $datas], // Request
"udf1" => $HotelTraceId,
"udf5" => 'hotelDetails',
"from_destination" => $destination,
"to_destination" => $destination,
"flight_type" => 5,
"source" => 2,
"Pax" => $TotalMembers,
"Supplier" => 'TRIPJACK',
"status" => ($ResponseStatus == 1) ? 2 : 1,
];
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
return $hotelsResultS;
}
public function getRoomHotelDetails($arrSessionData = array(), $AgencySysid)
{
if ($arrSessionData) {
$SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
$HotelTraceId = $SearchHotelTraceId->params;
$tokenId = $this->authenticateAPI($AgencySysid);
$arrSessionData['EndUserIp'] = $_SERVER['REMOTE_ADDR'];
$arrSessionData['TokenId'] = $tokenId['token'];
$data_stringh = json_encode($arrSessionData);
$sessionHotelSearchParams = new Zend_Session_Namespace('sessionHotelSearchParams');
$getsessionVal = $sessionHotelSearchParams->params;
$totadlt = $getsessionVal['totadlt'];
$totchld = $getsessionVal['totchld'];
$destination = $getsessionVal['destination'];
$TotalMembers = ($totadlt + $totchld);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TBO_HOTEL_API_HOTEL_ROOM_INFO);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
// echo "<pre>";
// print_r($outputH);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TBO_HOTEL_API_HOTEL_INFO);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'Content-Length: ' . strlen($data_stringh)
));
$outputHOtel = curl_exec($ch);
$responseHotel = json_decode($outputHOtel, true);
// echo "<pre>";
// print_r($outputHOtel);
if (HOTEL_API_LOGS) {
$strFilePath = "hotels/SearchParam/" . $HotelTraceId . "/RoomHotelDetails/" . date('Y-m-d-H-i-s') . "_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_stringh);
$strFilePath = "hotels/SearchParam/" . $HotelTraceId . "/RoomHotelDetails/" . date('Y-m-d-H-i-s') . "room_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
$strFilePath = "hotels/SearchParam/" . $HotelTraceId . "/RoomHotelDetails/" . date('Y-m-d-H-i-s') . "hotel_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputHOtel);
}
$ResponseStatus = isset($response['GetHotelRoomResult']['ResponseStatus']) ? $response['GetHotelRoomResult']['ResponseStatus'] : 0;
$ErrorMessage = isset($response['message']) ? $response['message'] : '';
$logParams = [
"user_id" => 1,
"custom_error" => ($ResponseStatus == 1) ? "Room Info Success" : "Room Info Failed",
'error' => $ErrorMessage,
"text_udf" => ['response' => $response], // Response
"char_udf" => ['request' => $arrSessionData], // Request
"udf1" => $HotelTraceId,
"status" => ($ResponseStatus == 1) ? 2 : 1,
"udf5" => 'Room Info',
"from_destination" => $destination,
"to_destination" => $destination,
"flight_type" => 5,
"source" => 2,
"Pax" => $TotalMembers,
"Supplier" => 'TBO',
];
$logParams2 = [
"user_id" => 1,
"custom_error" => ($ResponseStatus == 1) ? "Hotel Info Success" : "Hotel Info Failed",
'error' => $ErrorMessage,
"text_udf" => ['response' => $responseHotel], // Response
"char_udf" => ['request' => $arrSessionData], // Request
"udf1" => $HotelTraceId,
"status" => ($ResponseStatus == 1) ? 2 : 1,
"udf5" => 'Hotel Info',
"from_destination" => $destination,
"to_destination" => $destination,
"flight_type" => 5,
"source" => 2,
"Pax" => $TotalMembers,
"Supplier" => 'TBO',
];
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams2);
$arrResponse = array();
$arrResponse['RequestRoomInfo'] = $response;
$arrResponse['RequestHotelInfo'] = $responseHotel;
return $arrResponse;
}
}
function hotelCancelationPlolicy($data)
{
$cancellationre['id'] = $data['hotelId'];
$cancellationre['optionId'] = $data['optionId'];
$data_string = json_encode($cancellationre);
$sessionHotelSearchParams = new Zend_Session_Namespace('sessionHotelSearchParams');
$getsessionVal = $sessionHotelSearchParams->params;
$totadlt = $getsessionVal['totadlt'];
$totchld = $getsessionVal['totchld'];
$destination = $getsessionVal['destination'];
$TotalMembers = ($totadlt + $totchld);
$HotelTraceId = $data['SearchHotelTraceId'];
if (HOTEL_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "hotels/" . $HotelTraceId . '/hotelCancellationPlolicy/request-' . date('Y-m-d-H-i-s') . ".json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_string);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, hotel_cancellation_policy);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'apikey:' . hotel_api_key,
'Content-Length: ' . strlen($data_string)
));
$response = curl_exec($ch);
$hotelsResultS = json_decode($response, true);
$ResponseStatus = isset($hotelsResultS['GetHotelRoomResult']['ResponseStatus']) ? $hotelsResultS['GetHotelRoomResult']['ResponseStatus'] : 0;
$ErrorMessage = isset($hotelsResultS['message']) ? $hotelsResultS['message'] : '';
if (HOTEL_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "hotels/" . $HotelTraceId . '/hotelCancellationPlolicy/response-' . date('Y-m-d-H-i-s') . ".json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $response);
}
$logParams = [
"user_id" => 1,
"custom_error" => ($ResponseStatus == 1) ? "hotelCancellationPlolicy Success" : "hotelCancellationPlolicy Failed",
'error' => $ErrorMessage,
"text_udf" => ['response' => $hotelsResultS], // Response
"char_udf" => ['request' => $cancellationre], // Request
"udf1" => $HotelTraceId,
"udf5" => 'hotelCancellationPlolicy',
"from_destination" => $destination,
"to_destination" => $destination,
"flight_type" => 5,
"source" => 2,
"Pax" => $TotalMembers,
"Supplier" => 'TRIPJACK',
"status" => ($ResponseStatus == 1) ? 2 : 1,
];
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
curl_close($ch);
return $hotelsResultS;
}
function getHotelReview($data)
{
$Review['hotelId'] = $data['hotelid'];
$Review['optionId'] = $data['optionId'];
$data_string = json_encode($Review);
$HotelTraceId = $data['SearchHotelTraceId'];
if (HOTEL_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "hotels/" . $HotelTraceId . '/hotelReview/request-' . date('Y-m-d-H-i-s') . ".json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_string);
}
$sessionHotelSearchParams = new Zend_Session_Namespace('sessionHotelSearchParams');
$getsessionVal = $sessionHotelSearchParams->params;
$totadlt = $getsessionVal['totadlt'];
$totchld = $getsessionVal['totchld'];
$destination = $getsessionVal['destination'];
$TotalMembers = ($totadlt + $totchld);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, hotel_review);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'apikey:' . hotel_api_key,
'Content-Length: ' . strlen($data_string)
));
$response = curl_exec($ch);
$hotelsResultS = json_decode($response, true);
curl_close($ch);
if (HOTEL_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "hotels/" . $HotelTraceId . '/hotelReview/response-' . date('Y-m-d-H-i-s') . ".json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $response);
}
$ResponseStatus = (isset($hotelsResultS['status']) && $hotelsResultS['status']) ? true : false;
$ErrorMessage = isset($response['message']) ? $response['message'] : '';
$logParams = [
"user_id" => 1,
"custom_error" => ($ResponseStatus == 1) ? "hotel review Success" : "hotel review Failed",
'error' => $ErrorMessage,
"text_udf" => ['response' => $hotelsResultS], // Response
"char_udf" => ['request' => $Review], // Request
"udf1" => $HotelTraceId,
"udf5" => 'hotelReview',
"from_destination" => $destination,
"to_destination" => $destination,
"flight_type" => 5,
"source" => 2,
"Pax" => $TotalMembers,
"Supplier" => 'TRIPJACK',
"status" => ($ResponseStatus == 1) ? 2 : 1,
];
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
return $hotelsResultS;
}
function is_valid_Pan($pannumber)
{
$regex = "/^([a-zA-Z]){5}([0-9]){4}([a-zA-Z]){1}?$/";
return preg_match($regex, $pannumber);
}
public function getStaticDataByCityId($cityId)
{
// echo 'https://ht.globaltravelexchange.com/api/v1/hotel/get-tbo-hotel-details/?city_id='.$cityId;die;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://ht.globaltravelexchange.com/api/v1/hotel/get-tbo-hotel-details/?city_id='.$cityId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'SECURITYKEY: 57320743-0163-44d3-a703-8a21ceb1a685'
),
));
$response = curl_exec($curl);
curl_close($curl);
$responseDecode = json_decode($response,true);
$cityResponsearra = [];
if($responseDecode){
foreach($responseDecode as $vl){
$cityResponsearra[$vl['TBOHotelCode']] = $vl;
}
}
return $cityResponsearra;
}
}