| 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/b2c.hellogtx.com/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 $TBO_AUTHENTICATE_URL;
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->gtxagencysysid = $BootStrap['gtxagencysysid']; // get gtxagencysysid from application config
$this->gtxagentsysid = $BootStrap['gtxagentsysid']; // get gtxagentsysid from application config
$this->TBO_AUTHENTICATE_URL = ($this->gtxagencysysid=='1' || $this->gtxagencysysid=='2656') ? "https://sharedapi.tektravels.com/SharedData.svc/rest/Authenticate" : TBO_AUTHENTICATE_URL ;
}
public function config()
{
$front = $this->getFrontController();
$bootstrap = $front->getParam('bootstrap');
if (null === $bootstrap) {
throw new Exception('Unable to find bootstrap');
}
return $bootstrap->getOptions()['bootstrap'];
}
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 CreateHotelSessionSearch($data, $TraceId,$nationality)
{
Zend_Session::namespaceUnset('SearchCarTraceId');
Zend_Session::namespaceUnset('SearchCarData');
Zend_Session::namespaceUnset('SearchHotelTraceId');
$SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
$SearchHotelTraceId->params = $TraceId;
$SearchRequestData = new Zend_Session_Namespace('SearchRequestData');
$SearchRequestData->params = $data;
$SearchHotelData = new Zend_Session_Namespace('SearchHotelData');
if($SearchCarData->params) {
$SearchCarData->params = $data;
}
// echo "data ===== <pre>"; print_r($data);die;
$countryTitle = $data['countryTitle'];
$device = isset($data['device'])?$data['device']:'';
$roominfojson = isset($data['roominfojson'])?$data['roominfojson']:'';
$checkIn = $data['checkIn'];
$checkOut = $data['CheckOut'];
$residence = $data['residence'];
$currency = $data['currency'];
$cityid = $data['cityid'];
$cityName = $data['cityName'];
$hotel_countryCode = $data['hotel_countryCode'];
$countryId = $data['countryId'];
$memberCount = $data['totadlt'] + $data['totchld'];
$room = $data['room'];
$adultAr = $data['adult'];
$childAr = $data['child'];
$child1_bed_typeAr = $data['child1_age'];
$child2_bed_typeAr = $data['child2_age'];
$countryTitle = ucwords(strtolower($countryTitle));
if ($countryTitle == 'India' || $countryTitle == 'IN') {
$interNationalSearch = false;
} else {
$interNationalSearch = true;
}
$days = Zend_Controller_Action_HelperBroker::getStaticHelper("Hotel")->calculateNoOfDays($checkIn, $checkOut);
$roomjson = json_decode($data['roominfojson'], true);
$NationalData = array_filter($nationality, function ($var) use ($residence) {
return ($var['countryid'] == $residence);
});
$NationalData = array_values($NationalData);
$code = isset($NationalData[0]['code']) ? $NationalData[0]['code'] : '';
$roominfo = [];
if ($room) {
for ($i = 0; $i < $room; $i++) {
$adult = (int) $adultAr[$i];
$child = (int) $childAr[$i];
$child1_bed_type = (int) $child1_bed_typeAr[$i];
$child2_bed_type = (int) $child2_bed_typeAr[$i];
$chAGe = ($child > 0) ? array($child1_bed_type) : null;
$chAGe2 = ($child > 0) ? array($child2_bed_type) : null;
$childArray = '';
if ($child > 0) {
if ($child == 1) {
$childArray = ($chAGe);
} elseif ($child == 2) {
$childArray = array_merge($chAGe, $chAGe2);
}
}
$roominfo[$i] = array(
'numberOfAdults' => $adult,
'numberOfChild' => $child,
);
if ($child > 0) {
$roominfo[$i]['childAge'] = $childArray;
}
// 'childAge' => $childArray
}
}
if($device == 'app'){
$roominfo = $roominfojson;
}
//5709 dubai
//110203 india
//4451 mumbai
$searchCriteria['city'] = $cityid;
$searchCriteria['currency'] = $currency;
$searchCriteria['nationality'] = $residence;
$fsc = false;
if (isset($data['specific']) && $data['specific'] == on) {
$fsc = true;
}
$stars = array();
if (isset($data['starrating'])) {
foreach ($data['starrating'] as $key => $value) {
$stars[] = (int)$value;
}
}
$searchPreferences['ratings'] = $stars;
$searchPreferences['fsc'] = $fsc;
$searchdata = array(
'checkinDate' => date('Y-m-d', strtotime($data['checkIn'])),
'checkoutDate' => date('Y-m-d', strtotime($data['CheckOut'])),
'roomInfo' => $roominfo,
'searchCriteria' => $searchCriteria,
'searchPreferences' => $searchPreferences,
);
//echo"<pre>"; echo json_encode($searchdata);die;
$finalarray = array('searchQuery' => $searchdata, 'sync' => true);
$SearchHotelData->params['hotelsearchdata'] = $finalarray;
$SearchHotelData->params['interNationalSearch'] = $interNationalSearch;
$SearchHotelData->params['cityName'] = $cityName;
$SearchHotelData->params['memberCount'] = $memberCount;
// add this code
$SearchHotelData->params['CountryId'] = $countryId;
$SearchHotelData->params['GuestNationality'] = $code;//$residence;
return $SearchHotelData->params;
}
public function getHotelSearchId($data)
{
$SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
$HotelTraceId = $SearchHotelTraceId->params;
$data_stringh = json_encode($data['hotelsearchdata']);
if (HOTEL_API_LOGS) {
$strFilePath = "hotels/" . $HotelTraceId . '/search-rq-' . 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);
$resultSearch = json_decode($response, true);
if (HOTEL_API_LOGS) {
$ResponseStatus = isset($resultSearch['status']['success']) ? $resultSearch['status']['success'] : 0;
$ErrorMessage = isset($resultSearch['errors'][0]['message']) ? $resultSearch['errors'][0]['message'] : '';
$logParams = [
"user_id" => 1,
"AgencySysId" => $this->gtxagencysysid,
"custom_error" => ($ResponseStatus == 1) ? "Hotel Search Query Success" : "Hotel Search Query Failed",
'error' => $ErrorMessage,
"text_udf" => ['response' => $resultSearch], // Response
"char_udf" => ['request' => $data], // Request
"udf1" => $HotelTraceId,
"status" => ($ResponseStatus == 1) ? 2 : 1,
];
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
}
return $resultSearch;
}
function getHotelSearchResult($data)
{
$SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
$HotelTraceId = $SearchHotelTraceId->params;
$jsonSearchID = json_encode($data);
//if($this->gtxagencysysid == '4539'){
// echo $jsonSearchID;die;
// echo '<pre>start '; echo date('d-m-Y H:i:s');
require_once('guzzle/vendor/autoload.php');
$headers = [
'Content-Type' => 'application/json',
'apikey' => hotel_api_key,
];
$client = new GuzzleHttp\Client([
'headers' => $headers
]);
$body = $jsonSearchID;
$r = $client->request('POST', hotel_search, [
'body' => $body,
'timeout' => 100,
'stream' => true
]);
$response = $r->getBody()->getContents();
// echo '<pre>finished '; echo date('d-m-Y H:i:s');
// echo '<pre>'; print_r($response);die;
//}
// $ch = curl_init();
// curl_setopt($ch, CURLOPT_URL, hotel_search);
// curl_setopt($ch, CURLOPT_ENCODING, '');
// 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_IPRESOLVE, CURL_IPRESOLVE_V4 );
// curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonSearchID);
// curl_setopt($ch, CURLOPT_HTTPHEADER, array(
// 'Content-Type: application/json',
// 'apikey:' . hotel_api_key,
// ));
// $resp = curl_exec($ch);
// $info = curl_getinfo($ch);
// if($this->gtxagencysysid == '4539'){
// echo '<pre>'; print_r($info);
// }
// curl_close($ch);
$hotelsResultS = json_decode($response, true);
if (HOTEL_API_LOGS) {
$ResponseStatus = isset($hotelsResultS['status']['success']) ? $hotelsResultS['status']['success'] : 0;
$ErrorMessage = isset($hotelsResultS['errors'][0]['message']) ? $hotelsResultS['errors'][0]['message'] : '';
$logParams = [
"user_id" => 1,
"AgencySysId" => $this->gtxagencysysid,
"custom_error" => ($ResponseStatus == 1) ? "Hotel Search Success" : "Hotel Search Failed",
'error' => $ErrorMessage,
"text_udf" => ['response' => $hotelsResultS], // Response
"char_udf" => ['request' => $data], // Request
"udf1" => $HotelTraceId,
"status" => ($ResponseStatus == 1) ? 2 : 1,
];
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
}
return $response;
}
function getHotelDetails($data)
{
$data_string = json_encode($data);
$SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
$HotelTraceId = $SearchHotelTraceId->params;
$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)
));
$resp = curl_exec($ch);
$response = json_decode($resp, true);
if (HOTEL_API_LOGS) {
$ResponseStatus = isset($response['status']['success']) ? $response['status']['success'] : 0;
$ErrorMessage = isset($response['errors'][0]['message']) ? $response['errors'][0]['message'] : '';
$logParams = [
"user_id" => 1,
"AgencySysId" => $this->gtxagencysysid,
"custom_error" => ($ResponseStatus == 1) ? "Hotel Details Success" : "Hotel Details Failed",
'error' => $ErrorMessage,
"text_udf" => ['response' => $response], // Response
"char_udf" => ['request' => $data], // Request
"udf1" => $HotelTraceId,
"status" => ($ResponseStatus == 1) ? 2 : 1,
];
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
}
curl_close($ch);
return $resp;
}
function getHotelReview($data)
{
$data_string = json_encode($data);
$SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
$HotelTraceId = $SearchHotelTraceId->params;
$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)
));
$resp = curl_exec($ch);
$response = json_decode($resp, true);
if (HOTEL_API_LOGS) {
$ResponseStatus = isset($response['status']['success']) ? $response['status']['success'] : 0;
$ErrorMessage = isset($response['errors'][0]['message']) ? $response['errors'][0]['message'] : '';
$logParams = [
"user_id" => 1,
"AgencySysId" => $this->gtxagencysysid,
"custom_error" => ($ResponseStatus == 1) ? "Hotel Review Success" : "Hotel Review Failed",
'error' => $ErrorMessage,
"text_udf" => ['response' => $response], // Response
"char_udf" => ['request' => $data], // Request
"udf1" => $HotelTraceId,
"status" => ($ResponseStatus == 1) ? 2 : 1,
];
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
}
curl_close($ch);
return $resp;
}
function hotelCancelationPlolicy($data)
{
$cancellationre['id'] = $data['hotelId'];
$cancellationre['optionId'] = $data['optionId'];
$data_string = json_encode($cancellationre);
$SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
$HotelTraceId = $SearchHotelTraceId->params;
$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)
));
$resp = curl_exec($ch);
$response = json_decode($resp, true);
if (HOTEL_API_LOGS) {
$ResponseStatus = isset($response['status']['success']) ? $response['status']['success'] : 0;
$ErrorMessage = isset($response['errors'][0]['message']) ? $response['errors'][0]['message'] : '';
$logParams = [
"user_id" => 1,
"AgencySysId" => $this->gtxagencysysid,
"custom_error" => ($ResponseStatus == 1) ? "Hotel Cancellation Policy Success" : "Hotel Cancellation Policy Failed",
'error' => $ErrorMessage,
"text_udf" => ['response' => $response], // Response
"char_udf" => ['request' => $data], // Request
"udf1" => $HotelTraceId,
"status" => ($ResponseStatus == 1) ? 2 : 1,
];
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
}
curl_close($ch);
return $resp;
}
function getHotelBooking($data)
{
$data_string = json_encode($data);
$SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
$HotelTraceId = $SearchHotelTraceId->params;
//echo $HotelTraceId; exit;
$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)
));
$resp = curl_exec($ch);
$response = json_decode($resp, true);
if (HOTEL_API_LOGS) {
$ResponseStatus = isset($response['status']['success']) ? $response['status']['success'] : 0;
$ErrorMessage = isset($response['errors'][0]['message']) ? $response['errors'][0]['message'] : '';
$logParams = [
"user_id" => 1,
"AgencySysId" => $this->gtxagencysysid,
"custom_error" => ($ResponseStatus == 1) ? "Hotel Book Success" : "Hotel Book Failed",
'error' => $ErrorMessage,
"text_udf" => ['response' => $response], // Response
"char_udf" => ['request' => $data], // Request
"udf1" => $HotelTraceId,
"status" => ($ResponseStatus == 1) ? 2 : 1,
];
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
}
curl_close($ch);
return $resp;
}
function getHotelBookingDetails($data)
{
$data_string = json_encode($data);
$SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
$HotelTraceId = $SearchHotelTraceId->params;
$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)
));
$resp = curl_exec($ch);
$response = json_decode($resp, true);
if (HOTEL_API_LOGS) {
$ResponseStatus = isset($response['status']['success']) ? $response['status']['success'] : 0;
$ErrorMessage = isset($response['errors'][0]['message']) ? $response['errors'][0]['message'] : '';
$logParams = [
"user_id" => 1,
"AgencySysId" => $this->gtxagencysysid,
"custom_error" => ($ResponseStatus == 1) ? "Hotel Booking Details Success" : "Hotel Booking Details Failed",
'error' => $ErrorMessage,
"text_udf" => ['response' => $response], // Response
"char_udf" => ['request' => $data], // Request
"udf1" => $HotelTraceId,
"status" => ($ResponseStatus == 1) ? 2 : 1,
];
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
}
curl_close($ch);
return $resp;
}
public function getCustomerDetails($tablename, $CustomerSysId)
{
$select = $this->db->select()->from("$tablename", "*");
$select->where("GTX_customerSysId=?", "$CustomerSysId");
$select->where("IsMarkForDel", 0);
$select->where("IsActive", 1);
$select->order("paxType", 'ASC');
$result = $this->db->fetchRow($select);
return $result;
}
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 getDateTimeFormatString($string, $type = 1)
{ // supplied 2017-12-20T21:10:00 format
if (empty($string))
return '';
if ($type == 1) {
$arr = explode("T", $string);
$date = new DateTime($arr[0]);
return $date->format('D, d M') . ' ' . substr(@$arr[1], 0, 5);
} elseif ($type == 2) { // supplied 2017/12/20 format
$date = new DateTime($string);
return $date->format('D, d M');
} elseif ($type == 3) { // supplied 2017/12/20 format
$arr = explode("T", $string);
return substr(@$arr[1], 0, 5);
}
}
public function convertMinutesToHoursFormat($minutes)
{
if ($minutes < 1) {
//return;
}
$hours = floor($minutes / 60);
$minutes = ($minutes % 60);
return $hours . 'h ' . $minutes . 'm';
}
public function CalculateTotalTime($time1, $time2)
{
$diff = abs(strtotime($time1) - strtotime($time2));
$tmins = $diff / 60;
$hours = floor($tmins / 60);
$mins = $tmins % 60;
return $hours . 'h ' . $mins . 'm';
}
public function agencyMarkUpAndCommisions($data = [])
{
$intCommissionEarned = !empty($data['CommissionEarned']) ? $data['CommissionEarned'] : 0;
$intIncentiveEarned = !empty($data['IncentiveEarned']) ? $data['IncentiveEarned'] : 0;
$intPLBEarned = !empty($data['PLBEarned']) ? $data['PLBEarned'] : 0;
$IsInternational = !empty($data['IsInternational']) ? $data['IsInternational'] : 0;
if ($IsInternational == 1) {
$intAirType = 2;
} else {
$intAirType = 1;
}
$AgencySysId = !empty($data['AgencySysId']) ? $data['AgencySysId'] : 0;
$objTblMPAirMarkup = new Flights_Model_TblMPAirMarkup();
$arrAgencyMarkups = $objTblMPAirMarkup->getAgencyMarkupsAir($intAirType, $AgencySysId);
if (count($arrAgencyMarkups) > 0) {
$intAgencyCurrencySysId = $arrAgencyMarkups[0]['Currency'];
$intAgencyMarkUpType = $arrAgencyMarkups[0]['MarkUpType'];
$intAgencyMarkUp = $arrAgencyMarkups[0]['StdMarkUpPer']; // Agency Fix Mark UP...
$percentAgencySTax = $arrAgencyMarkups[0]['TaxPer'];
$intCommssionType = $arrAgencyMarkups[0]['CommssionType']; // 2 For percentage
$intCommssionVal = $arrAgencyMarkups[0]['CommssionVal']; // Percntage Value For Agency Commision From Actual Commision Retuned From API...
if ($intCommssionType == 2) { // For Agency Commision In Percentage Only...
$intAgencyCommisionEarnedFromAcutalCommision = ($intCommissionEarned * $intCommssionVal) / 100;
$intAgencyPLBEarnedFromAcutalPLB = ($intPLBEarned * $intCommssionVal) / 100;
$intAgencyIncentiveEarnedFromAcutalIncentive = ($intIncentiveEarned * $intCommssionVal) / 100;
$TotalCommisions = $intAgencyCommisionEarnedFromAcutalCommision + $intAgencyPLBEarnedFromAcutalPLB + $intAgencyIncentiveEarnedFromAcutalIncentive;
}
$arrMarkUps = [
'CommissionEarned' => $intAgencyCommisionEarnedFromAcutalCommision,
'IncentiveEarned' => $intAgencyIncentiveEarnedFromAcutalIncentive,
'PLBEarned' => $intAgencyPLBEarnedFromAcutalPLB,
'TotalCommisions' => $TotalCommisions,
'MarkUp' => $intAgencyMarkUp
];
} else {
$arrMarkUps = [
'CommissionEarned' => 0,
'IncentiveEarned' => 0,
'PLBEarned' => 0,
'TotalCommisions' => 0,
'MarkUp' => 0
];
}
return $arrMarkUps;
}
public function GetCancelResponse($datastring)
{
// $url = CAR_CANCEL_URL;
//'api/v1/car/booking-cancel/'
//$datastring = http_build_query($requestdata);
$canelrequest = json_encode($datastring);
// $datastring = $url.'?tripId=RT2BI257922-32FC1972-B574-B132-55A2-E9534D5EAB02&UserID=ganesh@catpl.co.in&mobileNumber=8585960381&ApiKey=H5HZ5C-I5V6DZ-SSL0VN-1JR4G5-JJLNRB-JGHWKZ&UserIPAddress=127.0.0.1&UserAgent=Mozilla&responsetype=2&';
//return $url;
//return $datastring;
// echo"<pre>"; print_r($datastring);die;
$url = CAR_URL . 'api/v1/car/booking-cancel/';
// echo"<pre>"; print_r($URL);die;
try {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $canelrequest);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array());
$response = curl_exec($ch);
curl_close();
} catch (Exception $err) {
print_r($err);
$err->getMessage();
$issend = FALSE;
}
// echo"<pre>"; print_r($response);die;
// die($response);
if (CAR_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "cars/BookingConfirm/" . date('Y-m-d-H-i-s') . "_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $datastring);
$strFilePath = "cars/BookingConfirm/" . date('Y-m-d-H-i-s') . "_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $response);
}
return $response;
}
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; checkIn
$check_In = $getData['checkIn'];
$check_Out = $getData['CheckOut'];
$checkIn = (date('Y-m-d', strtotime($getData['checkIn'])));
$checkOut = (date('Y-m-d', strtotime($getData['CheckOut'])));
$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 ($getData['Nationality'] == 106) {
$interNationalSearch = false;
} else {
$interNationalSearch = true;
}
$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' => true
);
$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['SearchHotelTraceId'] = $TraceId;
$sessionHotelSearchParams->params['interNationalSearch'] = $interNationalSearch;
return true;
} else {
die('Oops something went wrong');
}
}
// public function CreateSessionSearchParams($getData)
// {
// Zend_Session::namespaceUnset('sessionFlightSearchParams');
// // Zend_Session::namespaceUnset('recentSearch');die;
// if (!empty($getData)) {
// $uri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
// $uriExp = explode('?', $uri);
// $recentSearch->params = [];
// $sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
// $recentSearch = new Zend_Session_Namespace('recentSearch');
// $sessionFlightSearchParams->params = $getData; // Putting all form data to Session
// $departure_dates = $getData['departure_date'];
// $return_dates = $getData['return_date'];
// if (!empty($departure_dates)) {
// $arrDepatureDate = explode("/", $departure_dates);
// if (count($arrDepatureDate) > 0) {
// $strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
// }
// }
// if (!empty($return_dates)) {
// $arrReturnDepatureDate = explode("/", $return_dates);
// if (count($arrReturnDepatureDate) > 0) {
// $strReturnDate = $arrReturnDepatureDate[2] . "-" . $arrReturnDepatureDate[1] . "-" . $arrReturnDepatureDate[0];
// }
// }
// $url = $this->baseUrl . "public/data/dynamic/flight_destinations.json";
// $ch = curl_init();
// curl_setopt($ch, CURLOPT_URL, $url);
// curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// $str = curl_exec($ch);
// // $str = file_get_contents($this->baseUrl . 'public/data/dynamic/flight_destinations.json',FILE_USE_INCLUDE_PATH);
// $Destinationjson = json_decode($str, true);
// $filterByFrom = $getData['source_city']; // or DEL,BLR etc.
// $filterByTo = $getData['destination_city']; // or DEL,BLR etc.
// // die('Due to some techincal server problem unable to search flight. we are working on it.');
// $arrSourceCityId_ = array_filter($Destinationjson, function ($var) use ($filterByFrom) {
// return ($var['AirportCode'] == $filterByFrom);
// });
// $arrdestinationCityId_ = array_filter($Destinationjson, function ($var) use ($filterByTo) {
// return ($var['AirportCode'] == $filterByTo);
// });
// //echo '<pre>';print_r($Destinationjson);die;
// $arrSourceCityId = array_values($arrSourceCityId_);
// $arrdestinationCityId = array_values($arrdestinationCityId_);
// if (count($arrSourceCityId) > 0) {
// $intSourceCityId = $arrSourceCityId[0]['CityID'];
// $intCountryCode = trim($arrSourceCityId[0]['CountryCode']);
// $intOriginCountryCode = trim($arrSourceCityId[0]['CountryCode']);
// } else {
// $intSourceCityId = "";
// $intCountryCode = "";
// }
// if (count($arrdestinationCityId) > 0) {
// $intdestinationCityId = $arrdestinationCityId[0]['CityID'];
// $intdestinationCountryCode = trim($arrdestinationCityId[0]['CountryCode']);
// $intDestinaionCountryCode = trim($arrdestinationCityId[0]['CountryCode']);
// } else {
// $intdestinationCityId = "";
// $intdestinationCountryCode = "";
// }
// if ($intCountryCode == $intdestinationCountryCode) {
// $intCountryCode = 'IN';
// } else {
// $intCountryCode = 'INT';
// }
// if ($intOriginCountryCode != "IN" || empty($intOriginCountryCode)) {
// $sessionFlightSearchParams->params['interNationalSearch'] = true;
// } else if ($intdestinationCountryCode != "IN" || empty($intdestinationCountryCode)) {
// $sessionFlightSearchParams->params['interNationalSearch'] = true;
// } else {
// $sessionFlightSearchParams->params['interNationalSearch'] = false;
// }
// $sessionFlightSearchParams->params['sourceCityAirportCode'] = $getData['source_city'];
// $sessionFlightSearchParams->params['destinationCityAirportCode'] = $getData['destination_city'];
// $sessionFlightSearchParams->params['from'] = $getData['source_city'];
// $sessionFlightSearchParams->params['to'] = $getData['destination_city'];
// $sessionFlightSearchParams->params['sourceCityText'] = $getData['source'];
// $sessionFlightSearchParams->params['destinationCityText'] = $getData['destination'];
// $sessionFlightSearchParams->params['sourceCityId'] = $intSourceCityId;
// $sessionFlightSearchParams->params['destinationCityId'] = $intdestinationCityId;
// $sessionFlightSearchParams->params['intCountryCode'] = $intCountryCode;
// $sessionFlightSearchParams->params['route'] = $getData['route'];
// $sessionFlightSearchParams->params['flight_class'] = $getData['class'];
// $sessionFlightSearchParams->params['adults'] = $getData['adults'];
// $sessionFlightSearchParams->params['child'] = $getData['childs'];
// $sessionFlightSearchParams->params['infant'] = $getData['infants'];
// $sessionFlightSearchParams->params['departure_dates'] = $getData['departure_date'];
// $sessionFlightSearchParams->params['return_dates'] = !empty($getData['return_date']) ? $getData['return_date'] : '';
// $sessionFlightSearchParams->params['ContSysId_1'] = $getData['ContSysId_1'];
// $sessionFlightSearchParams->params['ContSysId'] = $getData['ContSysId'];
// $sessionFlightSearchParams->params['strDepatureDate'] = $strDepatureDate;
// $sessionFlightSearchParams->params['strReturnDate'] = $strReturnDate;
// $source_cityC = $sessionFlightSearchParams->params['source_city'];
// $destination_cityC = $sessionFlightSearchParams->params['destination_city'];
// $strDepatureDate = $sessionFlightSearchParams->params['strDepatureDate'];
// $departure_dates = $sessionFlightSearchParams->params['departure_dates'];
// $strReturnDate = $sessionFlightSearchParams->params['strReturnDate'];
// $return_dates = $sessionFlightSearchParams->params['return_dates'];
// // echo '<pre>';print_r($recentSearch->params);
// // echo '<pre>';print_r($sessionFlightSearchParams->params);
// $NewArray = false;
// if (!empty($recentSearch->params)) {
// foreach ($recentSearch->params as $k => $val) {
// $source_city = $val['source_city'];
// $destination_city = $val['destination_city'];
// if ($source_cityC == $source_city && $destination_cityC == $destination_city) {
// $NewArray = false;
// $recentSearch->params[$k] = $val;
// $recentSearch->params[$k]['departure_dates'] = $departure_dates;
// $recentSearch->params[$k]['return_dates'] = $return_dates;
// $recentSearch->params[$k]['strDepatureDate'] = $strDepatureDate;
// $recentSearch->params[$k]['strReturnDate'] = $strReturnDate;
// $recentSearch->params[$k]['searchUrl'] = $uriExp[1];
// } else {
// $NewArray = true;
// $recentSearch->params[$k] = $val;
// $recentSearch->params[$k]['searchUrl'] = $uriExp[1];
// }
// //
// }
// } else {
// $recentSearch->params[0] = $sessionFlightSearchParams->params;
// $recentSearch->params[0]['searchUrl'] = $uriExp[1];
// }
// if ($NewArray) {
// $recentSearch->params[] = $sessionFlightSearchParams->params;
// $recentSearch->params[]['searchUrl'] = $uriExp[1];
// }
// // echo '<pre>';print_r($uriExp[1]);
// // echo '<pre>';print_r($sessionFlightSearchParams->params);
// //die('d');
// return true;
// } else {
// die('Oops something went wrong');
// }
// }
public function searchApiFlights($arrSessionData = array())
{
$arrFlightClass = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getFlightClassesTripJack();
$cabinClass = $arrFlightClass[$arrSessionData['flight_class']];
$interNationalSearch = isset($arrSessionData['interNationalSearch']) ? trim($arrSessionData['interNationalSearch']) : 0;
//echo '<pre>';print_r($arrSessionData);
$arrFlightSearchResponse = array();
$strFlightRoute = trim($arrSessionData['route']);
$fromCityOrAirport = $arrSessionData['from'];
$toCityOrAirport = $arrSessionData['to'];
$strDepatureDate = $arrSessionData['strDepatureDate'];
$strReturnDate = $arrSessionData['strReturnDate'];
$adultCount = $arrSessionData['adults'];
$childCount = $arrSessionData['child'];
$infantCount = $arrSessionData['infant'];
$intMemberCount = $adultCount + $childCount + $infantCount;
if (isset($arrSessionData['DirectFlight']) && $arrSessionData['DirectFlight'] == 1) {
$DirectFlight = true;
} else {
$DirectFlight = false;
}
if (isset($arrSessionData['isConnectingFlight']) && $arrSessionData['isConnectingFlight'] == 1) {
$isConnectingFlight = true;
} else {
$isConnectingFlight = false;
}
$routeInfo = [];
if ($strFlightRoute) {
for ($i = 0; $i < $strFlightRoute; $i++) {
if ($i == 0) {
$fromCity = $fromCityOrAirport;
$toCity = $toCityOrAirport;
$travelDate = $strDepatureDate;
} else {
$fromCity = $toCityOrAirport;
$toCity = $fromCityOrAirport;
$travelDate = $strReturnDate;
}
$routeInfo[] = array(
'fromCityOrAirport' => array('code' => $fromCity),
'toCityOrAirport' => array('code' => $toCity),
'travelDate' => $travelDate,
);
}
}
if ($strFlightRoute == 1 && $interNationalSearch == '') {
$SearchType = 'Oneway';
} elseif ($strFlightRoute == 2 && $interNationalSearch == '') {
$SearchType = 'DomReturn';
} elseif ($strFlightRoute == 1 && $interNationalSearch == 1) {
$SearchType = 'IntOneway';
} elseif ($strFlightRoute == 2 && $interNationalSearch == 1) {
$SearchType = 'IntReturn';
}
$data = array(
'searchQuery' => array(
'cabinClass' => ($cabinClass == 'All') ? 'ECONOMY' : strtoupper($cabinClass),
'paxInfo' => array(
'ADULT' => $adultCount,
'CHILD' => $childCount,
'INFANT' => $infantCount,
),
'routeInfos' => $routeInfo,
'searchModifiers' => array('isDirectFlight' => $DirectFlight, 'isConnectingFlight' => $isConnectingFlight),
),
);
$logFile = $SearchType . '_' . $fromCityOrAirport . '_' . $toCityOrAirport . '_' . $adultCount . 'A_' . $childCount . 'C_' . $infantCount . 'I_isDirect_' . $DirectFlight . '_isConnecting_' . $isConnectingFlight;
$data_stringh = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TRIPJACK_FL_SEARCHALL_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',
'apikey:' . APIKEY,
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
if (FLIGHT_API_LOGS) {
$strFilePath = "flight/FlightSearch/" . date('Y-m-d-H-i-s') . '_' . $logFile . "_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_stringh);
$strFilePath = "flight/FlightSearch/" . date('Y-m-d-H-i-s') . '_' . $logFile . "_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
}
if ($interNationalSearch && $strFlightRoute == 2) {
$searchResult = $response['searchResult'];
$COMBO = $searchResult['tripInfos']['COMBO'];
$intResponseStatus = $response['status']['success'];
$arrFlightSearchResponse['ResponseStatus'] = $intResponseStatus;
$arrFlightSearchResponse['ErrorCode'] = '';
$arrFlightSearchResponse['ErrorMessage'] = '';
$arrFlightSearchResponse['OutBoundFlightResults'] = isset($COMBO) ? $COMBO : array();
$arrFlightSearchResponse['InBoundFlightResults'] = array();
} else {
$searchResult = $response['searchResult'];
$ONWARD = $searchResult['tripInfos']['ONWARD'];
$RETURN = isset($searchResult['tripInfos']['RETURN']) ? $searchResult['tripInfos']['RETURN'] : [];
$intResponseStatus = $response['status']['success'];
$arrFlightSearchResponse['ResponseStatus'] = $intResponseStatus;
$arrFlightSearchResponse['TraceId'] = '';
$arrFlightSearchResponse['ErrorCode'] = '';
$arrFlightSearchResponse['ErrorMessage'] = '';
$arrFlightSearchResponse['OutBoundFlightResults'] = isset($ONWARD) ? $ONWARD : array();
$arrFlightSearchResponse['InBoundFlightResults'] = isset($RETURN) ? $RETURN : array();
}
Zend_Session::namespaceUnset('FlightSearchResults');
$FlightSearchResults = new Zend_Session_Namespace('FlightSearchResults');
$FlightSearchResults->params = $arrFlightSearchResponse; // store all serch result data to Session
Zend_Session::namespaceUnset('FlightSearchLogFile');
$FlightSearchLogFile = new Zend_Session_Namespace('FlightSearchLogFile');
$FlightSearchLogFile->params = $logFile; // store serch data to Session
return $arrFlightSearchResponse;
}
public function GetApiFlightsFareRulesTripJack($arrData = array())
{
if ($arrData) {
$FlightSearchLogFile = new Zend_Session_Namespace('FlightSearchLogFile');
$logFile = $FlightSearchLogFile->params;
$datah = array(
'id' => $arrData['TraceId'],
'flowType' => 'REVIEW',
);
$data_stringh = json_encode($datah);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TRIPJACK_FL_API_FARE_RULE_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',
'apikey:' . APIKEY,
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
if (FLIGHT_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "flight/FlightFareRules/" . date('Y-m-d-H-i-s') . '_' . $logFile . "_FareRules_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_stringh);
//Write Request Logs starts...
//Write Request Logs starts...
$strFilePath = "flight/FlightFareRules/" . date('Y-m-d-H-i-s') . '_' . $logFile . "_FareRules_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
//Write Request Logs starts...
}
Zend_Session::namespaceUnset('FlightFareRulesSession');
$FlightFareRulesSession = new Zend_Session_Namespace('FlightFareRulesSession');
$FlightFareRulesSession->params = $response; // store all serch result data to Session
return $response;
}
}
public function GetApiFlightsFareRules($arrData = array())
{
$tokenId = $this->authenticateAPI();
if ($arrData) {
$datah = array(
'EndUserIp' => $_SERVER['REMOTE_ADDR'],
'TokenId' => $tokenId,
'TraceId' => $arrData['TraceId'],
'ResultIndex' => $arrData['ApiResultIndex'],
);
//echo "<pre>";print_r($datah);exit;
$data_stringh = json_encode($datah);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, FLIGHT_API_FARE_RULE_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 "<pre>";print_r($response);exit;
if (FLIGHT_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "flight/FlightFareRules/" . time() . "_FareRules_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_stringh);
//Write Request Logs starts...
//Write Request Logs starts...
$strFilePath = "flight/FlightFareRules/" . time() . "_FareRules_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
//Write Request Logs starts...
}
}
Zend_Session::namespaceUnset('FlightFareRulesSession');
$FlightFareRulesSession = new Zend_Session_Namespace('FlightFareRulesSession');
$FlightFareRulesSession->params = $response; // store all serch result data to Session
return $response;
}
public function GetApiFlightsFareQuoteTripJack($arrData = array())
{
if ($arrData) {
$FlightSearchLogFile = new Zend_Session_Namespace('FlightSearchLogFile');
$logFile = $FlightSearchLogFile->params;
$priceIdArr = explode(',', $arrData['TraceId']);
$datah = array(
'priceIds' => $priceIdArr,
);
$data_stringh = json_encode($datah);
// echo "<pre>";print_r($logFile);die;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TRIPJACK_FL_API_REVIEW_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',
'apikey:' . APIKEY,
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
//echo "<pre>";print_r($response);exit;
if (FLIGHT_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "flight/FlightFareReview/" . date('Y-m-d-H-i-s') . '_' . $logFile . "_Review_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_stringh);
//Write Request Logs starts...
//Write Request Logs starts...
$strFilePath = "flight/FlightFareReview/" . date('Y-m-d-H-i-s') . '_' . $logFile . "_Review_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
//Write Request Logs starts...
}
}
if ($arrData['Inbound'] == 1) {
Zend_Session::namespaceUnset('FlightFareQuoteSessionInb');
$FlightFareQuoteSessionInb = new Zend_Session_Namespace('FlightFareQuoteSessionInb');
$FlightFareQuoteSessionInb->params = $response; // store all serch result data to Session
} else {
Zend_Session::namespaceUnset('FlightFareQuoteSession');
$FlightFareQuoteSession = new Zend_Session_Namespace('FlightFareQuoteSession');
$FlightFareQuoteSession->params = $response; // store all serch result data to Session
}
return $response;
}
public function apiFlightTicketTripJack($data)
{
// echo '<pre>';print_r($data);die('T');
$SelectedMealSessionNew = new Zend_Session_Namespace('SelectedMealSessionNew');
$SelectedBaggSessionNew = new Zend_Session_Namespace('SelectedBaggSessionNew');
$SelectedMealSessionNewInb = new Zend_Session_Namespace('SelectedMealSessionNewInb');
$SelectedBaggSessionNewInb = new Zend_Session_Namespace('SelectedBaggSessionNewInb');
$flightSSRDetails = new Zend_Session_Namespace('flightSSRDetails');
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$interNationalSearch = $sessionFlightSearchParams->params['interNationalSearch'];
$FlightSearchLogFile = new Zend_Session_Namespace('FlightSearchLogFile');
$logFile = $FlightSearchLogFile->params;
$MealSelected = $SelectedMealSessionNew->params;
$BaggSelected = $SelectedBaggSessionNew->params;
$arrSSR = $flightSSRDetails->params;
$bookingId = $data['FlightBookingData'][0]['bookingId'];
$isgstapply = isset($data['CustomerSession'][0]['isgstapply']) ? $data['CustomerSession'][0]['isgstapply'] : 0;
// echo '<pre>';print_r($isgstapply);
//echo '<pre>';print_r($data['FlightBookingData']);
//die;
$arrPassengers = [];
$deliveryInfo = [];
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_SALUTION_CHILD = unserialize(ARR_SALUTION_CHILD);
if ($bookingId && $data) {
if ($data['CustomerSession']) {
foreach ($data['CustomerSession'] as $key => $value) {
if ($key == 0) {
$CustomerSysId = $value['CustomerSysId'];
} else {
$CustomerSysId = $value['CustomerMemberSysId'];
}
if ($key == 0) {
$intMemberSysId = 1;
} else {
$intMemberSysId = 0;
}
if ($value['paxType'] == 1) {
$paxTitle = trim($ARR_SALUTION[$value['Salutation']], ".");
if ($key == 0) {
$deliveryInfo['emails'][$key] = $value['EmailId'];
$deliveryInfo['contacts'][$key] = '+' . $value['countryCode'] . '' . $value['Contacts'];
}
$paxType = 'ADULT';
} elseif ($value['paxType'] == 2) {
$paxTitle = trim($ARR_SALUTION_CHILD[$value['Salutation']], ".");
$paxType = 'CHILD';
} else {
$paxTitle = trim($ARR_SALUTION_CHILD[$value['Salutation']], ".");
$paxType = 'INFANT';
}
$arrPassengers[$key] = [
'ti' => $paxTitle,
'fN' => $value['FirstName'],
'lN' => $value['LastName'],
'dob' => $value['DOB'],
'pt' => $paxType,
];
$MealArr = [];
if (!empty($SelectedMealSessionNew->params)) {
if (isset($SelectedMealSessionNew->params[$CustomerSysId]) && !empty($SelectedMealSessionNew->params[$CustomerSysId])) {
$meal = $SelectedMealSessionNew->params[$CustomerSysId];
$MealArr[] = array('key' => $meal['key'], 'code' => $meal['Code']);
//$arrPassengers[$key]['ssrMealInfos'] = [$MealArr];
}
}
if (!empty($SelectedMealSessionNewInb->params)) {
if (isset($SelectedMealSessionNewInb->params[$CustomerSysId]) && !empty($SelectedMealSessionNewInb->params[$CustomerSysId])) {
$meal2 = $SelectedMealSessionNewInb->params[$CustomerSysId];
$MealArr[] = array('key' => $meal2['key'], 'code' => $meal2['Code']);
//$arrPassengers[$key]['ssrMealInfos'] = [$MealArr];
}
}
$BaggArr = [];
if (!empty($SelectedBaggSessionNew->params)) {
if (isset($SelectedBaggSessionNew->params[$CustomerSysId]) && !empty($SelectedBaggSessionNew->params[$CustomerSysId])) {
$bagg = $SelectedBaggSessionNew->params[$CustomerSysId];
$BaggArr[] = array('key' => $bagg['key'], 'code' => $bagg['Code']);
}
}
if (!empty($SelectedBaggSessionNewInb->params)) {
if (isset($SelectedBaggSessionNewInb->params[$CustomerSysId]) && !empty($SelectedBaggSessionNewInb->params[$CustomerSysId])) {
$bagg2 = $SelectedBaggSessionNewInb->params[$CustomerSysId];
$BaggArr[] = array('key' => $bagg2['key'], 'code' => $bagg2['Code']);
}
}
if (!empty($MealArr)) {
$arrPassengers[$key]['ssrMealInfos'] = $MealArr;
}
if (!empty($BaggArr)) {
$arrPassengers[$key]['ssrBaggageInfos'] = $BaggArr;
}
// if($value['paxType'] == 3){
// $arrPassengers[$key]['dob'] = $value['DOB'];
// }
if ($interNationalSearch == 1) {
$arrPassengers[$key]['pNum'] = $value['PassportNo'];
$arrPassengers[$key]['eD'] = $value['PassportExpiry'];
$arrPassengers[$key]['pid'] = $value['passporIssue'];
}
}
}
if ($isgstapply == 1) {
$gstInfo = array(
'gstNumber' => $data['CustomerSession'][0]['gstnnumber'],
'email' => $data['CustomerSession'][0]['EmailId'],
'registeredName' => $data['CustomerSession'][0]['companyname'],
'mobile' => $data['CustomerSession'][0]['Contacts'],
'address' => $data['CustomerSession'][0]['gstaddress'],
);
}
$PublishedFare = 0;
$baggageAmount = 0;
$mealAmount = 0;
$baggageAmount2 = 0;
$mealAmount2 = 0;
if ($data['FlightBookingData']) {
foreach ($data['FlightBookingData'] as $amount) {
$PublishedFare += $amount['FairRules']['intPublishedFare'];
}
}
if ($SelectedBaggSessionNew->params && !empty($SelectedBaggSessionNew->params)) {
foreach ($SelectedBaggSessionNew->params as $baggage) {
$baggageAmount += $baggage['Price'];
}
}
if ($SelectedMealSessionNew->params && !empty($SelectedMealSessionNew->params)) {
foreach ($SelectedMealSessionNew->params as $meals) {
$mealAmount += $meals['Price'];
}
}
if ($SelectedBaggSessionNewInb->params && !empty($SelectedBaggSessionNewInb->params)) {
foreach ($SelectedBaggSessionNewInb->params as $baggage2) {
$baggageAmount2 += $baggage2['Price'];
}
}
if ($SelectedMealSessionNewInb->params && !empty($SelectedMealSessionNewInb->params)) {
foreach ($SelectedMealSessionNewInb->params as $meals2) {
$mealAmount2 += $meals2['Price'];
}
}
$amount = ($PublishedFare + $baggageAmount + $mealAmount + $baggageAmount2 + $mealAmount2);
$paymentInfos[] = array('amount' => number_format($amount, 2, '.', ''));
$data = array(
'bookingId' => $bookingId,
'paymentInfos' => $paymentInfos,
'travellerInfo' => $arrPassengers,
'deliveryInfo' => $deliveryInfo,
);
if ($isgstapply == 1) {
$data['gstInfo'] = $gstInfo;
}
// echo '<pre>';
// print_r(($data));
// die('T');
$data_stringh = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TRIPJACK_FL_API_INSTANT_BOOK_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_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'apikey:' . APIKEY,
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
if (FLIGHT_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "flight/FlightTicket/" . date('Y-m-d-H-i-s') . '_' . $logFile . "_FlightTicket_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_stringh);
//Write Request Logs starts...
//Write Request Logs starts...
$strFilePath = "flight/FlightTicket/" . date('Y-m-d-H-i-s') . '_' . $logFile . "_FlightTicket_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
//Write Request Logs starts...
}
Zend_Session::namespaceUnset('FlightBookingTicket');
$FlightBookingTicket = new Zend_Session_Namespace('FlightBookingTicket');
$FlightBookingTicket->params = $response;
return $response;
} else {
return $response = [];
}
exit;
}
public function bookingDetailsTripJack($response)
{
$ResponseStatus = isset($response['status']['success']) ? $response['status']['success'] : '0';
if ($ResponseStatus == 1) {
$FlightSearchLogFile = new Zend_Session_Namespace('FlightSearchLogFile');
$logFile = $FlightSearchLogFile->params;
$bookingId = isset($response['bookingId']) ? $response['bookingId'] : '0';
$data = array(
'bookingId' => $bookingId
);
$data_stringh = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TRIPJACK_FL_API_BOOKINGDETAILS_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_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
//'Accept-Encoding: gzip',
'apikey:' . APIKEY,
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
//$res = json_decode($outputH, true);
//echo "<pre>";print_r($outputH);die('lcc');
if (FLIGHT_API_LOGS) {
$strFilePath = "flight/BookingDetails/" . date('Y-m-d-H-i-s') . '_' . $logFile . "_BookingDetails_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_stringh);
$strFilePath = "flight/BookingDetails/" . date('Y-m-d-H-i-s') . '_' . $logFile . "_BookingDetails_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
}
//echo "<pre>";print_r($outputH);die('lcc');
return json_decode($outputH, true);
} else {
return $response;
}
}
public function apiFlightTicket($data)
{
// echo '<pre>';print_r($data);die('T');
$SelectedMealSessionNew = new Zend_Session_Namespace('SelectedMealSessionNew');
$SelectedBaggSessionNew = new Zend_Session_Namespace('SelectedBaggSessionNew');
$flightSSRDetails = new Zend_Session_Namespace('flightSSRDetails');
$MealSelected = $SelectedMealSessionNew->params;
$BaggSelected = $SelectedBaggSessionNew->params;
$arrSSR = $flightSSRDetails->params;
//echo "<pre>";print_r($BaggSelected);exit;
$TraceId = $data['FlightBookingData']['apiTraceId'];
$ResultIndex = $data['FlightBookingData']['ApiResultIndex'];
$arrPassengers = [];
$ARR_SALUTION = unserialize(ARR_SALUTION);
if ($TraceId && $ResultIndex && $data) {
$arrFairDetails = $data['FlightBookingData']['FairRules']['FareBreakdown'];
$paxCountryTitle = $data['FlightBookingData']['Segments'][0]['originCountryName'];
$paxCountryCode = $data['sessionFlightSearchParams']['intCountryCode'];
$IsInternational = $data['sessionFlightSearchParams']['interNationalSearch'];
$GSTCompanyAddress = '';
$GSTCompanyContactNumber = '';
$GSTCompanyName = '';
$GSTNumber = '';
$GSTCompanyEmail = '';
$agencyEmailId = '';
if ($data['CustomerSession']) {
//$dataSSR = array('TraceId' => $TraceId, 'ResultIndex' => $ResultIndex);
//$arrSSR = $this->flightSSRDetails($dataSSR);
// $arrSSR = [];
foreach ($data['CustomerSession'] as $key => $value) {
if ($key == 0) {
$CustomerSysId = $value['CustomerSysId'];
} else {
$CustomerSysId = $value['CustomerMemberSysId'];
}
if (isset($MealSelected[$CustomerSysId]) && !empty($MealSelected[$CustomerSysId])) {
$WayType = $MealSelected[$CustomerSysId]['WayType'];
$Code = $MealSelected[$CustomerSysId]['Code'];
$Description = $MealSelected[$CustomerSysId]['Description'];
$AirlineDescription = $MealSelected[$CustomerSysId]['AirlineDescription'];
$Quantity = $MealSelected[$CustomerSysId]['Quantity'];
$Currency = $MealSelected[$CustomerSysId]['Currency'];
$Price = $MealSelected[$CustomerSysId]['Price'];
$Origin = $MealSelected[$CustomerSysId]['Origin'];
$Destination = $MealSelected[$CustomerSysId]['Destination'];
} else {
$WayType = isset($arrSSR['MealDynamic'][0][0]['WayType']) ? trim($arrSSR['MealDynamic'][0][0]['WayType']) : '2';
$Code = isset($arrSSR['MealDynamic'][0][0]['Code']) ? trim($arrSSR['MealDynamic'][0][0]['Code']) : 'No Meal';
$Description = isset($arrSSR['MealDynamic'][0][0]['Description']) ? trim($arrSSR['MealDynamic'][0][0]['Description']) : '2';
$AirlineDescription = isset($arrSSR['MealDynamic'][0][0]['AirlineDescription']) ? trim($arrSSR['MealDynamic'][0][0]['AirlineDescription']) : '';
$Quantity = isset($arrSSR['MealDynamic'][0][0]['Quantity']) ? trim($arrSSR['MealDynamic'][0][0]['Quantity']) : '0';
$Currency = isset($arrSSR['MealDynamic'][0][0]['Currency']) ? trim($arrSSR['MealDynamic'][0][0]['Currency']) : 'INR';
$Price = isset($arrSSR['MealDynamic'][0][0]['Price']) ? trim($arrSSR['MealDynamic'][0][0]['Price']) : '0';
$Origin = isset($arrSSR['MealDynamic'][0][0]['Origin']) ? trim($arrSSR['MealDynamic'][0][0]['Origin']) : trim($data['Origin']);
$Destination = isset($arrSSR['MealDynamic'][0][0]['Destination']) ? trim($arrSSR['MealDynamic'][0][0]['Destination']) : ($data['Destination']);
}
if (isset($BaggSelected[$CustomerSysId]) && !empty($BaggSelected[$CustomerSysId])) {
$WayTypeBaggage = $BaggSelected[$CustomerSysId]['WayType'];
$CodeBaggage = $BaggSelected[$CustomerSysId]['Code'];
$DescriptionBaggage = $BaggSelected[$CustomerSysId]['Description'];
$WeightBaggage = $BaggSelected[$CustomerSysId]['Weight'];
$CurrencyBaggage = $BaggSelected[$CustomerSysId]['Currency'];
$PriceBaggage = $BaggSelected[$CustomerSysId]['Price'];
} else {
$WayTypeBaggage = isset($arrSSR['Baggage'][0][0]['WayType']) ? trim($arrSSR['Baggage'][0][0]['WayType']) : '2';
$CodeBaggage = isset($arrSSR['Baggage'][0][0]['Code']) ? trim($arrSSR['Baggage'][0][0]['Code']) : 'No Baggage';
$DescriptionBaggage = isset($arrSSR['Baggage'][0][0]['Description']) ? trim($arrSSR['Baggage'][0][0]['Description']) : '2';
$WeightBaggage = isset($arrSSR['Baggage'][0][0]['Weight']) ? trim($arrSSR['Baggage'][0][0]['Weight']) : '0';
$CurrencyBaggage = isset($arrSSR['Baggage'][0][0]['Currency']) ? trim($arrSSR['Baggage'][0][0]['Currency']) : 'INR';
$PriceBaggage = isset($arrSSR['Baggage'][0][0]['Price']) ? trim($arrSSR['Baggage'][0][0]['Price']) : '0';
}
$paxTitle = trim($ARR_SALUTION[$value['Salutation']], ".");
if ($value['Salutation'] <= 2) {
$intGender = $value['Salutation'];
} else {
$intGender = 2;
}
$PassportNo = $value['PassportNo'];
$PassportExpiry = $value['PassportExpiry'];
$paxAddress = $value['Address'];
$paxCityTitle = $value['CityTitle'];
$paxContactNo = $value['Contacts'];
if ($key == 0) {
$intMemberSysId = 1;
} else {
$intMemberSysId = 0;
}
if ($arrFairDetails) {
foreach ($arrFairDetails as $fare) {
$PassengerType = $fare['PassengerType'];
if ($PassengerType == 1) {
$arrFairDetails2 = $arrFairDetails[0];
}
if ($PassengerType == 2) {
$arrFairDetails2 = $arrFairDetails[1];
}
if ($PassengerType == 3) {
$arrFairDetails2 = $arrFairDetails[2];
}
}
}
$intBaseFare = $arrFairDetails2['BaseFare'];
$intTax = $arrFairDetails2['Tax'];
$intYQTax = $arrFairDetails2['YQTax'];
$intAdditionalTxnFeeOfrd = $arrFairDetails2['AdditionalTxnFeeOfrd'];
$intAdditionalTxnFeePub = $arrFairDetails2['AdditionalTxnFeePub'];
$intAirTransFee = "00.00";
$intTransactionFee = "00.00";
$arrPassengers[] = [
'Title' => $paxTitle,
'FirstName' => $value['FirstName'],
'LastName' => $value['LastName'],
'PaxType' => $value['paxType'],
'DateOfBirth' => $value['DOB'],
'Gender' => $intGender,
'PassportNo' => ($IsInternational == 1) ? $PassportNo : '',
'PassportExpiry' => ($IsInternational == 1) ? $PassportExpiry : '',
'AddressLine1' => $paxAddress,
'AddressLine2' => '',
'City' => $paxCityTitle,
'CountryCode' => $paxCountryCode,
'CountryName' => $paxCountryTitle,
'ContactNo' => $paxContactNo,
'Email' => !empty($agencyEmailId) ? $agencyEmailId : "gaurav@hellogtx.com",
'IsLeadPax' => $intMemberSysId,
'FFAirline' => '',
'FFNumber' => '',
'GSTCompanyAddress' => $GSTCompanyAddress,
'GSTCompanyContactNumber' => $GSTCompanyContactNumber,
'GSTCompanyName' => $GSTCompanyName,
'GSTNumber' => $GSTNumber,
'GSTCompanyEmail' => $GSTCompanyEmail,
'Fare' =>
[
'BaseFare' => $intBaseFare,
'Tax' => $intTax,
'TransactionFee' => $intTransactionFee,
'YQTax' => $intYQTax,
'AdditionalTxnFeeOfrd' => $intAdditionalTxnFeeOfrd,
'AdditionalTxnFeePub' => $intAdditionalTxnFeePub,
'AirTransFee' => $intAirTransFee
],
'MealDynamic' =>
[
'WayType' => $WayType,
'Code' => $Code,
'Description' => $Description,
'AirlineDescription' => $AirlineDescription,
'Quantity' => $Quantity,
'Price' => $Price,
'Currency' => $Currency,
'Origin' => $Origin,
'Destination' => $Destination
],
'Baggage' =>
[
'WayType' => $WayTypeBaggage,
'Code' => $CodeBaggage,
'Description' => $DescriptionBaggage,
'Weight' => $WeightBaggage,
'Currency' => $CurrencyBaggage,
'Price' => $PriceBaggage,
'Origin' => $Origin,
'Destination' => $Destination
]
];
}
}
//echo "<pre>";print_r($arrPassengers);exit;
$tokenId = $this->authenticateAPI();
$data = array(
'PreferredCurrency' => 'INR',
'IsBaseCurrencyRequired' => 'true',
'EndUserIp' => $_SERVER['REMOTE_ADDR'],
'TokenId' => $tokenId,
'TraceId' => $TraceId,
'ResultIndex' => $ResultIndex,
'Passengers' => $arrPassengers
);
// echo "<pre>";print_r($data);die('TTT');
$data_stringh = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, FLIGHT_API_TICKET_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_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
//echo "<pre>";print_r($outputH);die('lcc');
$response = json_decode($outputH, true);
if (FLIGHT_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "flight/FlightTicket/" . time() . "_FlightTicket_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_stringh);
//Write Request Logs starts...
//Write Request Logs starts...
$strFilePath = "flight/FlightTicket/" . time() . "_FlightTicket_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
//Write Request Logs starts...
}
//echo "<pre>";print_r($response);exit;
// Zend_Session::namespaceUnset('FlightBookingTicketSession');
// $FlightBookingTicketSession = new Zend_Session_Namespace('FlightBookingTicketSession');
// $FlightBookingTicketSession->params = $response;
return $response;
} else {
return $response = [];
}
exit;
}
public function apiFlightBooking($data)
{
$SelectedMealSessionNew = new Zend_Session_Namespace('SelectedMealSessionNew');
$arrSSRSelected = $SelectedMealSessionNew->params;
$flightSSRDetails = new Zend_Session_Namespace('flightSSRDetails');
$TraceId = $data['FlightBookingData']['apiTraceId'];
$ResultIndex = $data['FlightBookingData']['ApiResultIndex'];
$arrPassengers = [];
$ARR_SALUTION = unserialize(ARR_SALUTION);
if ($TraceId && $ResultIndex && $data) {
$arrFairDetails = $data['FlightBookingData']['FairRules']['FareBreakdown'];
// $IsInternational = $data['FlightBookingData']['IsInternational'];
$paxCountryTitle = $data['FlightBookingData']['Segments'][0]['originCountryName'];
$paxCountryCode = $data['sessionFlightSearchParams']['intCountryCode'];
$IsInternational = $data['sessionFlightSearchParams']['interNationalSearch'];
$GSTCompanyAddress = '';
$GSTCompanyContactNumber = '';
$GSTCompanyName = '';
$GSTNumber = '';
$GSTCompanyEmail = '';
$agencyEmailId = '';
if ($data['CustomerSession']) {
//$dataSSR = array('TraceId' => $TraceId, 'ResultIndex' => $ResultIndex);
//$arrSSR = $this->flightSSRDetails($dataSSR);
// $arrSSR = [];
$MealCode = isset($flightSSRDetails->params['Meal'][0]['Code']) ? trim($flightSSRDetails->params['Meal'][0]['Code']) : 'VGML';
$MealDesc = isset($flightSSRDetails->params['Meal'][0]['Description']) ? trim($flightSSRDetails->params['Meal'][0]['Description']) : 'Veg/Non Dairy';
$SeatCode = isset($flightSSRDetails->params['SeatPreference'][0]['Code']) ? trim($flightSSRDetails->params['SeatPreference'][0]['Code']) : 'A';
$SeatDesc = isset($flightSSRDetails->params['SeatPreference'][0]['Description']) ? trim($flightSSRDetails->params['SeatPreference'][0]['Description']) : 'Window';
foreach ($data['CustomerSession'] as $key => $value) {
if ($key == 0) {
$CustomerSysId = $value['CustomerSysId'];
} else {
$CustomerSysId = $value['CustomerMemberSysId'];
}
if (isset($arrSSRSelected[$CustomerSysId]) && !empty($arrSSRSelected[$CustomerSysId])) {
$MealCode = $arrSSRSelected[$CustomerSysId]['Code'];
$MealDesc = $arrSSRSelected[$CustomerSysId]['Description'];
} else {
$MealCode = isset($flightSSRDetails->params['Meal'][0]['Code']) ? trim($flightSSRDetails->params['Meal'][0]['Code']) : 'VGML';
$MealDesc = isset($flightSSRDetails->params['Meal'][0]['Description']) ? trim($flightSSRDetails->params['Meal'][0]['Description']) : 'Veg/Non Dairy';
}
$paxTitle = trim($ARR_SALUTION[$value['Salutation']], ".");
if ($value['Salutation'] <= 2) {
$intGender = $value['Salutation'];
} else {
$intGender = 2;
}
$PassportNo = $value['PassportNo'];
$PassportExpiry = $value['PassportExpiry'];
$paxAddress = $value['Address'];
$paxCityTitle = $value['CityTitle'];
$paxContactNo = $value['Contacts'];
if ($key == 0) {
$intMemberSysId = 1;
} else {
$intMemberSysId = 0;
}
if ($arrFairDetails) {
foreach ($arrFairDetails as $fare) {
$PassengerType = $fare['PassengerType'];
if ($PassengerType == 1) {
$arrFairDetails2 = $arrFairDetails[0];
}
if ($PassengerType == 2) {
$arrFairDetails2 = $arrFairDetails[1];
}
if ($PassengerType == 3) {
$arrFairDetails2 = $arrFairDetails[2];
}
}
}
$intBaseFare = $arrFairDetails2['BaseFare'];
$intTax = $arrFairDetails2['Tax'];
$intYQTax = $arrFairDetails2['YQTax'];
$intAdditionalTxnFeeOfrd = $arrFairDetails2['AdditionalTxnFeeOfrd'];
$intAdditionalTxnFeePub = $arrFairDetails2['AdditionalTxnFeePub'];
$intAirTransFee = "00.00";
$intTransactionFee = "00.00";
$arrPassengers[] = [
'Title' => $paxTitle,
'FirstName' => $value['FirstName'],
'LastName' => $value['LastName'],
'PaxType' => $value['paxType'],
'DateOfBirth' => $value['DOB'],
'Gender' => $intGender,
'PassportNo' => ($IsInternational == 1) ? $PassportNo : '',
'PassportExpiry' => ($IsInternational == 1) ? $PassportExpiry : '',
'AddressLine1' => $paxAddress,
'AddressLine2' => '',
'City' => $paxCityTitle,
'CountryCode' => $paxCountryCode,
'CountryName' => $paxCountryTitle,
'ContactNo' => $paxContactNo,
'Email' => !empty($agencyEmailId) ? $agencyEmailId : "gaurav@hellogtx.com",
'IsLeadPax' => $intMemberSysId,
'FFAirline' => '',
'FFNumber' => '',
'GSTCompanyAddress' => $GSTCompanyAddress,
'GSTCompanyContactNumber' => $GSTCompanyContactNumber,
'GSTCompanyName' => $GSTCompanyName,
'GSTNumber' => $GSTNumber,
'GSTCompanyEmail' => $GSTCompanyEmail,
'Fare' =>
[
'BaseFare' => $intBaseFare,
'Tax' => $intTax,
'TransactionFee' => $intTransactionFee,
'YQTax' => $intYQTax,
'AdditionalTxnFeeOfrd' => $intAdditionalTxnFeeOfrd,
'AdditionalTxnFeePub' => $intAdditionalTxnFeePub,
'AirTransFee' => $intAirTransFee
],
'Meal' =>
[
'Code' => $MealCode,
'Description' => $MealDesc
],
'Seat' =>
[
'Code' => $SeatCode,
'Description' => $SeatDesc
]
];
}
}
// echo "<pre>";print_r($arrPassengers);exit;
$tokenId = $this->authenticateAPI();
$dataArr = array(
'EndUserIp' => $_SERVER['REMOTE_ADDR'],
'TokenId' => $tokenId,
'TraceId' => $TraceId,
'ResultIndex' => $ResultIndex,
'Passengers' => $arrPassengers
);
$data_stringh = json_encode($dataArr);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, FLIGHT_API_BOOKING_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_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
if (FLIGHT_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "flight/FlightBooking/" . time() . "_FlightBooking_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_stringh);
//Write Request Logs starts...
//Write Request Logs starts...
$strFilePath = "flight/FlightBooking/" . time() . "_FlightBooking_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
//Write Request Logs starts...
}
// Zend_Session::namespaceUnset('FlightBookingTicketSession');
// $FlightBookingTicketSession = new Zend_Session_Namespace('FlightBookingTicketSession');
// $FlightBookingTicketSession->params = $response;
return $response;
} else {
return $response = [];
}
}
public function generateRoundTripRequest($data, $IsLCC)
{
//echo '<pre>';print_r($data['FlightBookingData']['JourneyType']);die;
if ($IsLCC) {
if ($data['FlightBookingData']['JourneyType'] == 1) {
$SelectedMealSessionNew = new Zend_Session_Namespace('SelectedMealSessionNew');
$SelectedBaggSessionNew = new Zend_Session_Namespace('SelectedBaggSessionNew');
$flightSSRDetails = new Zend_Session_Namespace('flightSSRDetails');
$MealSelected = $SelectedMealSessionNew->params;
$BaggSelected = $SelectedBaggSessionNew->params;
$arrSSR = $flightSSRDetails->params;
} else {
$SelectedMealSessionNewInb = new Zend_Session_Namespace('SelectedMealSessionNewInb');
$SelectedBaggSessionNewInb = new Zend_Session_Namespace('SelectedBaggSessionNewInb');
$flightSSRDetailsInb = new Zend_Session_Namespace('flightSSRDetailsInb');
$MealSelected = $SelectedMealSessionNewInb->params;
$BaggSelected = $SelectedBaggSessionNewInb->params;
$arrSSR = $flightSSRDetailsInb->params;
}
//$SelectedMealSessionNew = new Zend_Session_Namespace('SelectedMealSessionNew');
//$SelectedBaggSessionNew = new Zend_Session_Namespace('SelectedBaggSessionNew');
//$flightSSRDetails = new Zend_Session_Namespace('flightSSRDetails');
$TraceId = $data['FlightBookingData']['apiTraceId'];
$ResultIndex = $data['FlightBookingData']['ApiResultIndex'];
$arrPassengers = [];
$ARR_SALUTION = unserialize(ARR_SALUTION);
if ($TraceId && $ResultIndex && $data) {
$arrFairDetails = $data['FlightBookingData']['FairRules']['FareBreakdown'];
$IsInternational = $data['FlightBookingData']['IsInternational'];
$paxCountryTitle = $data['FlightBookingData']['Segments'][0]['originCountryName'];
$paxCountryCode = $data['sessionFlightSearchParams']['intCountryCode'];
$GSTCompanyAddress = '';
$GSTCompanyContactNumber = '';
$GSTCompanyName = '';
$GSTNumber = '';
$GSTCompanyEmail = '';
$agencyEmailId = '';
if ($data['CustomerSession']) {
//$dataSSR = array('TraceId' => $TraceId, 'ResultIndex' => $ResultIndex);
//$arrSSR = $this->flightSSRDetails($dataSSR);
// $arrSSR = [];
foreach ($data['CustomerSession'] as $key => $value) {
if ($key == 0) {
$CustomerSysId = $value['CustomerSysId'];
} else {
$CustomerSysId = $value['CustomerMemberSysId'];
}
if (isset($MealSelected[$CustomerSysId]) && !empty($MealSelected[$CustomerSysId])) {
$WayType = $MealSelected[$CustomerSysId]['WayType'];
$Code = $MealSelected[$CustomerSysId]['Code'];
$Description = $MealSelected[$CustomerSysId]['Description'];
$AirlineDescription = $MealSelected[$CustomerSysId]['AirlineDescription'];
$Quantity = $MealSelected[$CustomerSysId]['Quantity'];
$Currency = $MealSelected[$CustomerSysId]['Currency'];
$Price = $MealSelected[$CustomerSysId]['Price'];
$Origin = $MealSelected[$CustomerSysId]['Origin'];
$Destination = $MealSelected[$CustomerSysId]['Destination'];
} else {
$WayType = isset($arrSSR['MealDynamic'][0][0]['WayType']) ? trim($arrSSR['MealDynamic'][0][0]['WayType']) : '2';
$Code = isset($arrSSR['MealDynamic'][0][0]['Code']) ? trim($arrSSR['MealDynamic'][0][0]['Code']) : 'No Meal';
$Description = isset($arrSSR['MealDynamic'][0][0]['Description']) ? trim($arrSSR['MealDynamic'][0][0]['Description']) : '2';
$AirlineDescription = isset($arrSSR['MealDynamic'][0][0]['AirlineDescription']) ? trim($arrSSR['MealDynamic'][0][0]['AirlineDescription']) : '';
$Quantity = isset($arrSSR['MealDynamic'][0][0]['Quantity']) ? trim($arrSSR['MealDynamic'][0][0]['Quantity']) : '0';
$Currency = isset($arrSSR['MealDynamic'][0][0]['Currency']) ? trim($arrSSR['MealDynamic'][0][0]['Currency']) : 'INR';
$Price = isset($arrSSR['MealDynamic'][0][0]['Price']) ? trim($arrSSR['MealDynamic'][0][0]['Price']) : '0';
$Origin = isset($arrSSR['MealDynamic'][0][0]['Origin']) ? trim($arrSSR['MealDynamic'][0][0]['Origin']) : trim($data['Origin']);
$Destination = isset($arrSSR['MealDynamic'][0][0]['Destination']) ? trim($arrSSR['MealDynamic'][0][0]['Destination']) : ($data['Destination']);
}
if (isset($BaggSelected[$CustomerSysId]) && !empty($BaggSelected[$CustomerSysId])) {
$WayTypeBaggage = $BaggSelected[$CustomerSysId]['WayType'];
$CodeBaggage = $BaggSelected[$CustomerSysId]['Code'];
$DescriptionBaggage = $BaggSelected[$CustomerSysId]['Description'];
$WeightBaggage = $BaggSelected[$CustomerSysId]['Weight'];
$CurrencyBaggage = $BaggSelected[$CustomerSysId]['Currency'];
$PriceBaggage = $BaggSelected[$CustomerSysId]['Price'];
} else {
$WayTypeBaggage = isset($arrSSR['Baggage'][0][0]['WayType']) ? trim($arrSSR['Baggage'][0][0]['WayType']) : '2';
$CodeBaggage = isset($arrSSR['Baggage'][0][0]['Code']) ? trim($arrSSR['Baggage'][0][0]['Code']) : 'No Baggage';
$DescriptionBaggage = isset($arrSSR['Baggage'][0][0]['Description']) ? trim($arrSSR['Baggage'][0][0]['Description']) : '2';
$WeightBaggage = isset($arrSSR['Baggage'][0][0]['Weight']) ? trim($arrSSR['Baggage'][0][0]['Weight']) : '0';
$CurrencyBaggage = isset($arrSSR['Baggage'][0][0]['Currency']) ? trim($arrSSR['Baggage'][0][0]['Currency']) : 'INR';
$PriceBaggage = isset($arrSSR['Baggage'][0][0]['Price']) ? trim($arrSSR['Baggage'][0][0]['Price']) : '0';
}
$paxTitle = trim($ARR_SALUTION[$value['Salutation']], ".");
if ($value['Salutation'] <= 2) {
$intGender = $value['Salutation'];
} else {
$intGender = 2;
}
$PassportNo = $value['PassportNo'];
$PassportExpiry = $value['PassportExpiry'];
$paxAddress = $value['Address'];
$paxCityTitle = $value['CityTitle'];
$paxContactNo = $value['Contacts'];
if ($key == 0) {
$intMemberSysId = 1;
} else {
$intMemberSysId = 0;
}
if ($arrFairDetails) {
foreach ($arrFairDetails as $fare) {
$PassengerType = $fare['PassengerType'];
if ($PassengerType == 1) {
$arrFairDetails2 = $arrFairDetails[0];
}
if ($PassengerType == 2) {
$arrFairDetails2 = $arrFairDetails[1];
}
if ($PassengerType == 3) {
$arrFairDetails2 = $arrFairDetails[2];
}
}
}
$intBaseFare = $arrFairDetails2['BaseFare'];
$intTax = $arrFairDetails2['Tax'];
$intYQTax = $arrFairDetails2['YQTax'];
$intAdditionalTxnFeeOfrd = $arrFairDetails2['AdditionalTxnFeeOfrd'];
$intAdditionalTxnFeePub = $arrFairDetails2['AdditionalTxnFeePub'];
$intAirTransFee = "00.00";
$intTransactionFee = "00.00";
$arrPassengers[] = [
'Title' => $paxTitle,
'FirstName' => $value['FirstName'],
'LastName' => $value['LastName'],
'PaxType' => $value['paxType'],
'DateOfBirth' => $value['DOB'],
'Gender' => $intGender,
'PassportNo' => ($IsInternational == 1) ? $PassportNo : '',
'PassportExpiry' => ($IsInternational == 1) ? $PassportExpiry : '',
'AddressLine1' => $paxAddress,
'AddressLine2' => '',
'City' => $paxCityTitle,
'CountryCode' => $paxCountryCode,
'CountryName' => $paxCountryTitle,
'ContactNo' => $paxContactNo,
'Email' => !empty($agencyEmailId) ? $agencyEmailId : "gaurav@hellogtx.com",
'IsLeadPax' => $intMemberSysId,
'FFAirline' => '',
'FFNumber' => '',
'GSTCompanyAddress' => $GSTCompanyAddress,
'GSTCompanyContactNumber' => $GSTCompanyContactNumber,
'GSTCompanyName' => $GSTCompanyName,
'GSTNumber' => $GSTNumber,
'GSTCompanyEmail' => $GSTCompanyEmail,
'Fare' =>
[
'BaseFare' => $intBaseFare,
'Tax' => $intTax,
'TransactionFee' => $intTransactionFee,
'YQTax' => $intYQTax,
'AdditionalTxnFeeOfrd' => $intAdditionalTxnFeeOfrd,
'AdditionalTxnFeePub' => $intAdditionalTxnFeePub,
'AirTransFee' => $intAirTransFee
],
'MealDynamic' =>
[
'WayType' => $WayType,
'Code' => $Code,
'Description' => $Description,
'AirlineDescription' => $AirlineDescription,
'Quantity' => $Quantity,
'Price' => $Price,
'Currency' => $Currency,
'Origin' => $Origin,
'Destination' => $Destination
],
'Baggage' =>
[
'WayType' => $WayTypeBaggage,
'Code' => $CodeBaggage,
'Description' => $DescriptionBaggage,
'Weight' => $WeightBaggage,
'Currency' => $CurrencyBaggage,
'Price' => $PriceBaggage,
'Origin' => $Origin,
'Destination' => $Destination
]
];
}
}
// echo "<pre>";print_r($arrPassengers);exit;
$tokenId = $this->authenticateAPI();
$request = array(
'PreferredCurrency' => 'INR',
'IsBaseCurrencyRequired' => 'true',
'EndUserIp' => $_SERVER['REMOTE_ADDR'],
'TokenId' => $tokenId,
'TraceId' => $TraceId,
'ResultIndex' => $ResultIndex,
'Passengers' => $arrPassengers
);
}
} else {
if ($data['FlightBookingData']['JourneyType'] == 1) {
$SelectedMealSessionNew = new Zend_Session_Namespace('SelectedMealSessionNew');
$arrSSRSelected = $SelectedMealSessionNew->params;
$flightSSRDetails = new Zend_Session_Namespace('flightSSRDetails');
$arrSSR = $flightSSRDetails->params;
} else {
$SelectedMealSessionNewInb = new Zend_Session_Namespace('SelectedMealSessionNewInb');
$arrSSRSelected = $SelectedMealSessionNewInb->params;
$flightSSRDetailsInb = new Zend_Session_Namespace('flightSSRDetailsInb');
$arrSSR = $flightSSRDetailsInb->params;
}
$TraceId = $data['FlightBookingData']['apiTraceId'];
$ResultIndex = $data['FlightBookingData']['ApiResultIndex'];
$arrPassengers = [];
$ARR_SALUTION = unserialize(ARR_SALUTION);
if ($TraceId && $ResultIndex && $data) {
$arrFairDetails = $data['FlightBookingData']['FairRules']['FareBreakdown'];
$IsInternational = $data['FlightBookingData']['IsInternational'];
$paxCountryTitle = $data['FlightBookingData']['Segments'][0]['originCountryName'];
$paxCountryCode = $data['sessionFlightSearchParams']['intCountryCode'];
$GSTCompanyAddress = '';
$GSTCompanyContactNumber = '';
$GSTCompanyName = '';
$GSTNumber = '';
$GSTCompanyEmail = '';
$agencyEmailId = '';
if ($data['CustomerSession']) {
//$dataSSR = array('TraceId' => $TraceId, 'ResultIndex' => $ResultIndex);
//$arrSSR = $this->flightSSRDetails($dataSSR);
$SeatCode = isset($arrSSR['SeatPreference'][0]['Code']) ? trim($arrSSR['SeatPreference'][0]['Code']) : 'A';
$SeatDesc = isset($arrSSR['SeatPreference'][0]['Description']) ? trim($arrSSR['SeatPreference'][0]['Description']) : 'Window';
foreach ($data['CustomerSession'] as $key => $value) {
if ($key == 0) {
$CustomerSysId = $value['CustomerSysId'];
} else {
$CustomerSysId = $value['CustomerMemberSysId'];
}
if (isset($arrSSRSelected[$CustomerSysId]) && !empty($arrSSRSelected[$CustomerSysId])) {
$MealCode = $arrSSRSelected[$CustomerSysId]['Code'];
$MealDesc = $arrSSRSelected[$CustomerSysId]['Description'];
} else {
$MealCode = isset($arrSSR['Meal'][0]['Code']) ? trim($arrSSR['Meal'][0]['Code']) : 'VGML';
$MealDesc = isset($arrSSR['Meal'][0]['Description']) ? trim($arrSSR['Meal'][0]['Description']) : 'Veg/Non Dairy';
}
$paxTitle = trim($ARR_SALUTION[$value['Salutation']], ".");
if ($value['Salutation'] <= 2) {
$intGender = $value['Salutation'];
} else {
$intGender = 2;
}
$PassportNo = $value['PassportNo'];
$PassportExpiry = $value['PassportExpiry'];
$paxAddress = $value['Address'];
$paxCityTitle = $value['CityTitle'];
$paxContactNo = $value['Contacts'];
if ($key == 0) {
$intMemberSysId = 1;
} else {
$intMemberSysId = 0;
}
if ($arrFairDetails) {
foreach ($arrFairDetails as $fare) {
$PassengerType = $fare['PassengerType'];
if ($PassengerType == 1) {
$arrFairDetails2 = $arrFairDetails[0];
}
if ($PassengerType == 2) {
$arrFairDetails2 = $arrFairDetails[1];
}
if ($PassengerType == 3) {
$arrFairDetails2 = $arrFairDetails[2];
}
}
}
$intBaseFare = $arrFairDetails2['BaseFare'];
$intTax = $arrFairDetails2['Tax'];
$intYQTax = $arrFairDetails2['YQTax'];
$intAdditionalTxnFeeOfrd = $arrFairDetails2['AdditionalTxnFeeOfrd'];
$intAdditionalTxnFeePub = $arrFairDetails2['AdditionalTxnFeePub'];
$intAirTransFee = "00.00";
$intTransactionFee = "00.00";
$arrPassengers[] = [
'Title' => $paxTitle,
'FirstName' => $value['FirstName'],
'LastName' => $value['LastName'],
'PaxType' => $value['paxType'],
'DateOfBirth' => $value['DOB'],
'Gender' => $intGender,
'PassportNo' => ($IsInternational == 1) ? $PassportNo : '',
'PassportExpiry' => ($IsInternational == 1) ? $PassportExpiry : '',
'AddressLine1' => $paxAddress,
'AddressLine2' => '',
'City' => $paxCityTitle,
'CountryCode' => $paxCountryCode,
'CountryName' => $paxCountryTitle,
'ContactNo' => $paxContactNo,
'Email' => !empty($agencyEmailId) ? $agencyEmailId : "gaurav@hellogtx.com",
'IsLeadPax' => $intMemberSysId,
'FFAirline' => '',
'FFNumber' => '',
'GSTCompanyAddress' => $GSTCompanyAddress,
'GSTCompanyContactNumber' => $GSTCompanyContactNumber,
'GSTCompanyName' => $GSTCompanyName,
'GSTNumber' => $GSTNumber,
'GSTCompanyEmail' => $GSTCompanyEmail,
'Fare' =>
[
'BaseFare' => $intBaseFare,
'Tax' => $intTax,
'TransactionFee' => $intTransactionFee,
'YQTax' => $intYQTax,
'AdditionalTxnFeeOfrd' => $intAdditionalTxnFeeOfrd,
'AdditionalTxnFeePub' => $intAdditionalTxnFeePub,
'AirTransFee' => $intAirTransFee
],
'Meal' =>
[
'Code' => $MealCode,
'Description' => $MealDesc
],
'Seat' =>
[
'Code' => $SeatCode,
'Description' => $SeatDesc
]
];
}
}
// echo "<pre>";print_r($arrPassengers);exit;
$tokenId = $this->authenticateAPI();
$request = array(
'EndUserIp' => $_SERVER['REMOTE_ADDR'],
'TokenId' => $tokenId,
'TraceId' => $TraceId,
'ResultIndex' => $ResultIndex,
'Passengers' => $arrPassengers
);
}
}
return $request;
}
public function cancelFlightBooking($data)
{
$intCancellationType = $data['CancellationType'];
$RequestType = $data['requestType'];
$TOKEN_ID = $this->authenticateAPI();
//echo "<pre>"; print_r($data);die('dd');
//if($intIsLCC == 1){
if ($RequestType == 2) {
$datah = array(
"BookingId" => $data['BookingId'],
"RequestType" => $RequestType,
"CancellationType" => $intCancellationType,
"Sectors" => $data['sectorsSelectors'],
"TicketId" => $data['TicketId'],
"Remarks" => $data['remarks'],
"EndUserIp" => $_SERVER['REMOTE_ADDR'],
"TokenId" => $TOKEN_ID,
);
} else {
$datah = array(
"BookingId" => $data['BookingId'],
"Source" => $data['source'],
"EndUserIp" => $_SERVER['REMOTE_ADDR'],
"TokenId" => $TOKEN_ID,
);
}
echo "<pre>";
print_r(json_encode($datah));
die('dd');
$cURL = FLIGHT_API_BOOKING_CHANGE_REQUEST;
//echo "<pre>"; print_r($datah); exit;
$data_stringh = json_encode($datah);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $cURL);
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(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$responseTBO = json_decode($outputH, true);
//echo $outputH;
//echo "<pre>"; print_r($responseTBO); exit;
if (FLIGHT_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "flight/FlightCancel/" . time() . "_FlightCancel_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_stringh);
//Write Request Logs starts...
//Write Request Logs starts...
$strFilePath = "flight/FlightCancel/" . time() . "_FlightCancel_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
//Write Request Logs starts...
}
//return $responseTBO;
//echo "<pre>"; print_r($responseTBO);
$FlightCancelSession = new Zend_Session_Namespace('FlightCancelSession');
$FlightCancelSession->params = $responseTBO;
$intChangeRequestId = isset($responseTBO['Response']['TicketCRInfo'][0]['ChangeRequestId']) ? $responseTBO['Response']['TicketCRInfo'][0]['ChangeRequestId'] : '';
$ResponseStatus = isset($responseTBO['Response']['ResponseStatus']) ? $responseTBO['Response']['ResponseStatus'] : '';
$TicketCRInfo = isset($responseTBO['Response']['TicketCRInfo']) ? $responseTBO['Response']['TicketCRInfo'] : array();
// $objFlight = new Travel_Model_TblFlight();
// if (!empty($ResponseStatus) && $ResponseStatus == 1) {
// if (isset($data['TicketId']) && !empty($data['TicketId'])) {
// foreach ($data['TicketId'] as $key => $value) {
// $TicketId = $TicketCRInfo[$key]['TicketId'];
// $ChangeRequestId = $TicketCRInfo[$key]['ChangeRequestId'];
// $ChangeRequestStatus = $TicketCRInfo[$key]['ChangeRequestStatus'];
// $datah = array(
// "ChangeRequestId" => $ChangeRequestId,
// "EndUserIp" => $_SERVER['REMOTE_ADDR'],
// "TokenId" => $TOKEN_ID
// );
// $data_stringh = json_encode($datah);
// $ch = curl_init();
// curl_setopt($ch, CURLOPT_URL, FLIGHT_API_BOOKING_CHANGE_REQUEST_STATUS);
// 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(
// 'Content-Type: application/json',
// 'Content-Length: ' . strlen($data_stringh)
// ));
// $outputH = curl_exec($ch);
// $responseCan = json_decode($outputH, true);
// $data = array(
// "ChangeRequestId" => $ChangeRequestId,
// "ChangeRequestRes" => json_encode($responseCan),
// "ChangeRequestStatus" => $ChangeRequestStatus
// );
// $objFlight->updateTravelPlanPaxByTicketId($data, '' . $TicketId . '');
// }
// }
// if (FLIGHT_API_LOGS) {
// //Write Request Logs starts...
// $strFilePath = "flight/FlightCancelStatus/" . time() . "_FlightCancelStatus_request.json";
// Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_stringh);
// //Write Request Logs starts...
// //Write Request Logs starts...
// $strFilePath = "flight/FlightCancelStatus/" . time() . "_FlightCancelStatus_response.json";
// Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
// //Write Request Logs starts...
// }
// return $responseTBO;
// //echo "<pre>"; print_r($responseTBO); exit;
// }
return $responseTBO;
}
public function GetAmendmentCharges($arrData = array())
{
if ($arrData) {
$data_stringh = json_encode($arrData);
//echo "<pre>"; print_r($data_stringh); exit;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TRIPJACK_FL_API_GETAMENDMENTCHARGES_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',
'apikey:' . APIKEY,
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
if (FLIGHT_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "flight/Amendment/" . date('Y-m-d-H-i-s') . "_AmendmentCharges_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_stringh);
//Write Request Logs starts...
//Write Request Logs starts...
$strFilePath = "flight/Amendment/" . date('Y-m-d-H-i-s') . "_AmendmentCharges_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
//Write Request Logs starts...
}
Zend_Session::namespaceUnset('AmendmentChargesSession');
$AmendmentChargesSession = new Zend_Session_Namespace('AmendmentChargesSession');
$AmendmentChargesSession->params = $response; // store all serch result data to Session
return $response;
}
}
public function GetSubmitAmendment($arrData = array())
{
if ($arrData) {
$data_stringh = json_encode($arrData);
//echo "<pre>"; print_r($data_stringh); exit;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TRIPJACK_FL_API_SUBMITAMENDMENT_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',
'apikey:' . APIKEY,
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
if (FLIGHT_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "flight/Amendment/" . date('Y-m-d-H-i-s') . "_SubmitAmendment_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_stringh);
//Write Request Logs starts...
//Write Request Logs starts...
$strFilePath = "flight/Amendment/" . date('Y-m-d-H-i-s') . "_SubmitAmendment_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
//Write Request Logs starts...
}
Zend_Session::namespaceUnset('SubmitAmendment');
$SubmitAmendment = new Zend_Session_Namespace('SubmitAmendment');
$SubmitAmendment->params = $response; // store all serch result data to Session
return $response;
}
}
public function GetAmendmentDetails($arrData = array())
{
if ($arrData) {
$data_stringh = json_encode($arrData);
//echo "<pre>"; print_r($data_stringh); exit;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TRIPJACK_FL_API_AMENDMENTDETAILS_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',
'apikey:' . APIKEY,
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
if (FLIGHT_API_LOGS) {
//Write Request Logs starts...
$strFilePath = "flight/Amendment/" . date('Y-m-d-H-i-s') . "_AmendmentDetails_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $data_stringh);
//Write Request Logs starts...
//Write Request Logs starts...
$strFilePath = "flight/Amendment/" . date('Y-m-d-H-i-s') . "_AmendmentDetails_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $outputH);
//Write Request Logs starts...
}
return $response;
}
}
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;
}
public function getMarkup($intCountryCode)
{
if ($intCountryCode) {
$this->postFields = "";
$this->postFields .= "&AgencySysId=$this->gtxagencysysid";
$this->postFields .= "&AgentSysId=$this->gtxagentsysid";
$this->postFields .= "&intCountryCode=$intCountryCode";
$this->postFields .= "&PlanType=2";
$model = new Gtxwebservices_Model_Webservices();
// echo"<pre>";print_r($this->postFields);exit;
$result = $model->getMarkupAndServiceTax($this->postFields);
//echo"<pre>";print_r($result);die();
$response = json_decode($result, true);
return $response;
} else {
$data = array('status' => false, 'message' => 'Invalid country code');
return ($data);
}
}
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 calculateHotelMarkupFromDB($data)
{
if ($data['interNationalSearch']) {
$AccomType = 2;
$intCountryCode = 'INT';
} else {
$AccomType = 1;
$intCountryCode = 'IN';
}
$type = isset($data['type'])?$data['type']:'';
$mPlanType = 2;
$getMarkup = $data['getMarkup'];
//echo"<pre>";print_r($data);die;
$TaxSettingDetail = $this->getTaxSettingDetail($getMarkup['TaxSetting'], 2);
$getMarkup['TaxSettingDetail'] = $TaxSettingDetail;
$TaxSettingDetail = isset($getMarkup['TaxSettingDetail']) ? $getMarkup['TaxSettingDetail'] : [];
$arrApiServiceTax = (isset($TaxSettingDetail['TaxPercentage']) && !empty($TaxSettingDetail['TaxPercentage'])) ? $TaxSettingDetail['TaxPercentage'] : 0;
$Tax = (isset($TaxSettingDetail['Tax']) && !empty($TaxSettingDetail['Tax'])) ? (int) $TaxSettingDetail['Tax'] : 1;
$TaxType = (isset($TaxSettingDetail['TaxType']) && !empty($TaxSettingDetail['TaxType'])) ? (int) $TaxSettingDetail['TaxType'] : 2;
$resultset = $getMarkup['arrAgencyMarkupsHotel'];
$markup = (isset($resultset[0]['MarkUp']) && !empty($resultset[0]['MarkUp']))?trim($resultset[0]['MarkUp']):0;
$markupType = ($resultset[0]['MarkUpType'] == 2) ? 'percentage' : 'fixed';
$HotelRoomPrice = $data['HotelRoomPrice'];
$Nights = $data['nights'];
$rooms = $data['rooms'];
if ($type == 'room') {
$rooms = 1;
} else {
$rooms = $rooms;
}
$pernightperroomprice = $HotelRoomPrice / ($Nights * $rooms);
if ($markupType == 'percentage') {
$MarkupAmtPerRPN = ($pernightperroomprice * $markup) / 100;
$RoomPrice = $MarkupAmtPerRPN + $pernightperroomprice;
} else {
$MarkupAmtPerRPN = $markup;
$RoomPrice = $pernightperroomprice + $markup;
}
if($TaxType == 1){
$arrGSTOnGTXMarkUp = $this->calculateServiceTax($RoomPrice, $arrApiServiceTax);
$intGSTOnGTXMarkUp = $arrGSTOnGTXMarkUp['serviceTaxAmount'];
}elseif($TaxType == 2){
$arrGSTOnGTXMarkUp = $this->calculateServiceTax($MarkupAmtPerRPN, $arrApiServiceTax);
$intGSTOnGTXMarkUp = $arrGSTOnGTXMarkUp['serviceTaxAmount'];
}else{
$arrApiServiceTax = 0;
$arrGSTOnGTXMarkUp = $this->calculateServiceTax($MarkupAmtPerRPN, $arrApiServiceTax);
$intGSTOnGTXMarkUp = $arrGSTOnGTXMarkUp['serviceTaxAmount'];
}
$withmarkupprice = ($RoomPrice + $intGSTOnGTXMarkUp);
$dataarray['HotelRoomPrice'] = $HotelRoomPrice;
$dataarray['pernightperroomprice'] = $pernightperroomprice;
$dataarray['RoomPrice'] = ($RoomPrice);
$dataarray['withmarkupprice'] = ($RoomPrice + $intGSTOnGTXMarkUp);
$dataarray['gtxMarkUp'] = $MarkupAmtPerRPN;
$dataarray['GSTOnGTXMarkUp'] = $intGSTOnGTXMarkUp;
$dataarray['rooms'] = $rooms;
$dataarray['Nights'] = $Nights;
$dataarray['markup__'] = $markup;
// echo"<pre>";print_r($dataarray);exit;
return $dataarray;
}
function calculateMarkup($data)
{
$HotelRoomPrice = $data['HotelRoomPrice'];
$Nights = $data['nights'];
$rooms = $data['rooms'];
$pernightperroomprice = $HotelRoomPrice / ($Nights * $rooms);
$interNationalSearch = $data['interNationalSearch'] ? true : false;
$hotelGtxMarkuparray = $data['getMarkup']['arrAgencyMarkupsHotel'][0];
$gtxmarkuptype = ($hotelGtxMarkuparray['MarkUpType'] == 2) ? 'percentage' : 'fixed';
$gtxMarkUp = $hotelGtxMarkuparray['MarkUp'];
$gtxTax = $hotelGtxMarkuparray['Tax'];
$gtxCurrency = $hotelGtxMarkuparray['Currency'];
if ($gtxmarkuptype == 'percentage') {
$RoomPrice = ((($HotelRoomPrice * $gtxMarkUp) / 100) + $HotelRoomPrice);
$RoomPrice = $RoomPrice / ($Nights * $rooms);
} else {
// $totalgtxmarkup = $gtxMarkUp*$Nights*$rooms;
$RoomPrice = $pernightperroomprice + $gtxMarkUp;
}
$dataarray['withmarkupprice'] = $RoomPrice;
//echo"<pre>";print_r($hotelGtxMarkuparray);exit;
if ($interNationalSearch == 1) {
// $dataArr['intGTXMarkUp'] = (($dataArr['intGTXMarkUp']) * $intFlightRoute);
// $dataArr['IntAgencyFixMarkUp'] = round(($totalAgencyMarkUp) * $intFlightRoute,2);
// $dataArr['IntTaxOnAgencyFixMarkUp'] = (($dataArr['IntTaxOnAgencyFixMarkUp']) * $intFlightRoute);
}
return $dataarray;
// echo '<pre>';print_r($commission + $intCommission);
// echo '<pre>';print_r($intCommission);
// echo '<pre>';print_r($intFareWithAgencyFixMarkUp);
// echo '<pre>';print_r($intTotalEarningsForAgency);
// echo '<pre>';print_r($data);
// die;
}
function calculateMarkupTripJack($data)
{
$arrGTXMarkups = isset($data['getMarkup']['arrGTXMarkups']) ? $data['getMarkup']['arrGTXMarkups'] : [];
$arrAgencyMarkups = isset($data['getMarkup']['arrAgencyMarkups']) ? $data['getMarkup']['arrAgencyMarkups'] : [];
$arrApiServiceTax = isset($data['getMarkup']['arrApiServiceTax'][0]) ? $data['getMarkup']['arrApiServiceTax'][0]['Percentage'] : [];
$intPublishedFare = isset($data['PublishedFare']) ? $data['PublishedFare'] : 0;
$intOfferedFare = isset($data['OfferedFare']) ? $data['OfferedFare'] : 0;
$intCommissionEarned = isset($data['intCommissionEarned']) ? $data['intCommissionEarned'] : 0;
$intPLBEarned = isset($data['intPLBEarned']) ? $data['intPLBEarned'] : 0;
$intIncentiveEarned = isset($data['intIncentiveEarned']) ? $data['intIncentiveEarned'] : 0;
$intMemberCount = isset($data['intMemberCount']) ? $data['intMemberCount'] : 1;
$intFlightRoute = isset($data['intFlightRoute']) ? $data['intFlightRoute'] : 1;
$interNationalSearch = isset($data['interNationalSearch']) ? $data['interNationalSearch'] : 0;
$commission = ($intPublishedFare - $intOfferedFare);
// For GTX MarkUps...
$intOfferedFareWithGTXCommision = 0;
$totalGTXMarkUp = 0;
if (count($arrGTXMarkups) > 0) {
foreach ($arrGTXMarkups as $GTXMarkups) {
$intGTXCurrencySysId = $GTXMarkups['Currency'];
$intGTXMarkUpType = $GTXMarkups['MarkUpType'];
$intGTXMarkUp = 0; //$GTXMarkups['MarkUp'];
$totalGTXMarkUp += $intGTXMarkUp;
if ($intGTXMarkUpType == 1) { // For Flat
$intGTXMarkUp = $intGTXMarkUp;
$intOfferedFareWithGTXCommision += $intOfferedFare + $intGTXMarkUp;
} else { // For Percentage
$intGTXMarkUp = ($intOfferedFare * $intGTXMarkUp) / 100;
$intOfferedFareWithGTXCommision += $intOfferedFare + $intGTXMarkUp;
}
}
} else {
$intGTXMarkUp = 0;
$intOfferedFareWithGTXCommision = $intOfferedFare + $intGTXMarkUp;
}
// For Agency MarkUps...
$intCommission = 0;
$totalAgencyMarkUp = 0;
$intFareWithAgencyFixMarkUp = 0;
$intAgencyCommisionEarnedFromAcutalCommision = 0;
$intAgencyPLBEarnedFromAcutalPLB = 0;
$intAgencyIncentiveEarnedFromAcutalIncentive = 0;
if (count($arrAgencyMarkups) > 0) {
foreach ($arrAgencyMarkups as $AgencyMarkups) {
$intAgencyCurrencySysId = $AgencyMarkups['Currency'];
$intAgencyMarkUp = $AgencyMarkups['StdMarkUpPer']; // Agency Fix Mark UP...
$totalAgencyMarkUp += $intAgencyMarkUp;
$intCommssionType = $AgencyMarkups['CommssionType']; // 2 For percentage
$intCommssionVal = $AgencyMarkups['CommssionVal']; // Percntage Value For Agency Commision From Actual Commision Retuned From API...
$intFareWithAgencyFixMarkUp += $intOfferedFareWithGTXCommision + $intAgencyMarkUp;
if ($intCommssionType == 2) { // For Agency Commision In Percentage Only...
$intAgencyCommisionEarnedFromAcutalCommision += (($intCommissionEarned * $intCommssionVal) / 100);
$intAgencyPLBEarnedFromAcutalPLB += (($intPLBEarned * $intCommssionVal) / 100);
$intAgencyIncentiveEarnedFromAcutalIncentive += (($intIncentiveEarned * $intCommssionVal) / 100);
$intCommission += (($commission * $intCommssionVal) / 100);
}
}
} else {
$intFareWithAgencyFixMarkUp = $intOfferedFareWithGTXCommision;
$intAgencyCommisionEarnedFromAcutalCommision = 0;
$intAgencyPLBEarnedFromAcutalPLB = 0;
$intAgencyIncentiveEarnedFromAcutalIncentive = 0;
}
//echo $intAgencyCommisionEarnedFromAcutalCommision.'=='.$intAgencyPLBEarnedFromAcutalPLB.'=='.$intAgencyIncentiveEarnedFromAcutalIncentive;
$arrGSTOnGTXMarkUp = $this->calculateServiceTax($totalGTXMarkUp, $arrApiServiceTax);
$intGSTOnGTXMarkUp = $arrGSTOnGTXMarkUp['serviceTaxAmount'];
$arrGSTOnAgencyFixMarkUp = $this->calculateServiceTax($totalAgencyMarkUp, $arrApiServiceTax);
$intGSTOnAgencyFixMarkUp = $arrGSTOnAgencyFixMarkUp['serviceTaxAmount'];
$arrGSTOnAgencyCommisionEarned = $this->calculateServiceTax($intAgencyCommisionEarnedFromAcutalCommision, $arrApiServiceTax);
$intGSTOnAgencyCommisionEarned = $arrGSTOnAgencyCommisionEarned['serviceTaxAmount'];
$arrGSTOnAgencyPLBEarned = $this->calculateServiceTax($intAgencyPLBEarnedFromAcutalPLB, $arrApiServiceTax);
$intGSTOnAgencyPLBEarned = $arrGSTOnAgencyPLBEarned['serviceTaxAmount'];
$arrGSTOnAgencyIncentiveEarned = $this->calculateServiceTax($intAgencyIncentiveEarnedFromAcutalIncentive, $arrApiServiceTax);
$intGSTOnAgencyIncentiveEarned = $arrGSTOnAgencyIncentiveEarned['serviceTaxAmount'];
$intTotalEarningsForAgency = $intAgencyCommisionEarnedFromAcutalCommision + $intAgencyPLBEarnedFromAcutalPLB + $intAgencyIncentiveEarnedFromAcutalIncentive;
$arrPriceAndMarkUps = array(
"intOfferedFare" => $intOfferedFare,
"intFareWithGTXMarkUp" => $intOfferedFareWithGTXCommision,
"intFareWithAgencyFixMarkUp" => $intFareWithAgencyFixMarkUp,
"intPublishFare" => ($intFareWithAgencyFixMarkUp + $intTotalEarningsForAgency + $intGSTOnGTXMarkUp + $intGSTOnAgencyFixMarkUp),
"intCommissionEarned" => $intCommissionEarned,
"intCommisionEarnedForAgency" => $intAgencyCommisionEarnedFromAcutalCommision,
"intPLBEarned" => $intPLBEarned,
"intPLBEarnedForAgency" => $intAgencyPLBEarnedFromAcutalPLB,
"intIncentiveEarned" => $intIncentiveEarned,
"intIncentiveEarnedForAgency" => $intAgencyIncentiveEarnedFromAcutalIncentive,
"intTotalEarningsForAgency" => $intTotalEarningsForAgency,
"intGTXMarkUp" => $intGTXMarkUp,
"intAgencyFixMarkUp" => $intAgencyMarkUp,
"intSTaxOnGTXMarkUp" => $intGSTOnGTXMarkUp,
"intSTaxOnAgencyFixMarkUp" => $intGSTOnAgencyFixMarkUp,
"intGSTOnAgencyCommisionEarned" => $intGSTOnAgencyCommisionEarned,
"intGSTOnAgencyPLBEarned" => $intGSTOnAgencyPLBEarned,
"intGSTOnAgencyIncentiveEarned" => $intGSTOnAgencyIncentiveEarned
);
return $arrPriceAndMarkUps;
}
public function getArrivalDepartureIndianFormat($string)
{
if (empty($string))
return '';
$arr = explode(" ", $string);
$date = new DateTime($arr[0]);
return $date->format('d M Y') . ' ' . substr(@$arr[1], 0, 5);
}
public function getTimeFromApiString($string)
{
if (empty($string))
return '';
$arr = explode("T", $string);
$date = new DateTime($arr[0]);
return substr(@$arr[1], 0, 5);
}
public function CalculateHoursMinutes($DepTime, $ArrTime)
{
if (empty($DepTime))
return '';
if (empty($ArrTime))
return '';
$date1 = new DateTime($DepTime . ':00');
$date2 = new DateTime($ArrTime . ':00');
$diff = $date2->diff($date1);
$hours = $diff->h;
$minutes = $diff->i;
$hours = $hours + ($diff->days * 24);
$travelTime = $hours . 'h ' . $minutes . 'm';
return $travelTime;
}
public function MinutesToHours($minutes)
{
if ($minutes) {
$hours = floor($minutes / 60);
$min = $minutes - ($hours * 60);
$LAYOVERTime = $hours . "h " . $min . 'm';
return $LAYOVERTime;
}
}
public function getDynamicPriceSlots($minPrice = NULL, $maxPrice = NULL)
{
if (!empty($minPrice) && !empty($maxPrice)) {
$intMinPrice = round($minPrice);
$intMaxPrice = round($maxPrice);
} else {
$intMinPrice = round(min($arrAirFare));
$intMaxPrice = round(max($arrAirFare));
}
$intStartRage = floor($intMinPrice / 100) * 100;
$intEndRage = floor($intMaxPrice / 100) * 100;
$rangeDifference = $intEndRage - $intStartRage;
$intTotalSlots = 4;
$intDifference = $rangeDifference / $intTotalSlots;
$intDifference = floor($intDifference / 100) * 100;
$base = $rangeDifference / $intTotalSlots;
$arr = array();
$minStartRange = $intStartRage;
$arr[] = "0-" . $intStartRage;
for ($i = 1; $i <= $intTotalSlots; $i++) {
$baseAmount = round($i * $base);
$baseAmount = floor($baseAmount / 100) * 100;
//if($i > 1){
$intNewUpRange = $baseAmount + $intDifference;
$arr[] = $minStartRange . "-" . ($intNewUpRange - 1);
$minStartRange = $intNewUpRange;
//}
}
$arr[] = $minStartRange . "-" . ($intNewUpRange);
return $arr;
}
function encrypt($sData, $secretKey)
{
$sResult = '';
for ($i = 0; $i < strlen($sData); $i++) {
$sChar = substr($sData, $i, 1);
$sKeyChar = substr($secretKey, ($i % strlen($secretKey)) - 1, 1);
$sChar = chr(ord($sChar) + ord($sKeyChar));
$sResult .= $sChar;
}
return $this->encode_base64($sResult);
}
function decrypt($sData, $secretKey)
{
$sResult = '';
$sData = $this->decode_base64($sData);
for ($i = 0; $i < strlen($sData); $i++) {
$sChar = substr($sData, $i, 1);
$sKeyChar = substr($secretKey, ($i % strlen($secretKey)) - 1, 1);
$sChar = chr(ord($sChar) - ord($sKeyChar));
$sResult .= $sChar;
}
return $sResult;
}
function encode_base64($sData)
{
$sBase64 = base64_encode($sData);
return str_replace('=', '', strtr($sBase64, '+/', '-_'));
}
function decode_base64($sData)
{
$sBase64 = strtr($sData, '-_', '+/');
return base64_decode($sBase64 . '==');
}
function GetAgencyCurrency($gtxagencysysid)
{
try {
$apiDataIV = array(
"AgencySysId" => $gtxagencysysid,
"SecurityKey" => SECURITYKEY
);
$curl_IV = curl_init(API_GET_IV_KEY);
curl_setopt($curl_IV, CURLOPT_POST, true);
//curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl_IV, CURLOPT_POSTFIELDS, http_build_query($apiDataIV));
curl_setopt($curl_IV, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_IV, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_IV, CURLOPT_TIMEOUT, 300);
$responseIV = curl_exec($curl_IV);
curl_close($curl_IV);
//
$IVData = Zend_Json::decode($responseIV, true);
$apiData = array(
"AgencySysId" => $gtxagencysysid,
);
$curl_p = curl_init(API_AGENCY_CURRENCY_RATE);
curl_setopt($curl_p, CURLOPT_POST, true);
//curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($curl_p, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_p, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_p, CURLOPT_TIMEOUT, 300);
$response_pro = curl_exec($curl_p);
curl_close($curl_p);
$data = Zend_Json::decode($response_pro, true);
//$agencyData = new Travel_Model_Encrytion($data['Message'], $apiDataIV['SecurityKey'], $IVData['Message']);
echo '<pre>';
print_r($data);
//echo '<pre>';print_r($data);
//echo '<pre>';print_r(Zend_Json::decode($agencyData->decrypt(),true));
die('wait');
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
}
function is_valid_gstin($gstin)
{
$regex = "/^([0][1-9]|[1-2][0-9]|[3][0-5])([a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}[1-9a-zA-Z]{1}[zZ]{1}[0-9a-zA-Z]{1})+$/";
return preg_match($regex, $gstin);
}
function getAgencyData($gtxagencysysid)
{
if ($gtxagencysysid) {
$apiDataIV = array(
"AgencySysId" => $gtxagencysysid,
"SecurityKey" => SECURITYKEY //'AE54AF70-3DC8-431B-BED1-FB8A92CC2FAE'
);
$curl_IV = curl_init(API_GET_IV_KEY);
curl_setopt($curl_IV, CURLOPT_POST, true);
//curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl_IV, CURLOPT_POSTFIELDS, http_build_query($apiDataIV));
curl_setopt($curl_IV, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_IV, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_IV, CURLOPT_TIMEOUT, 300);
$responseIV = curl_exec($curl_IV);
curl_close($curl_IV);
//echo '<pre>';print_r($responseIV);
//echo '<pre>';print_r(API_GET_IV_KEY);die;
$apiData = array(
"AgencySysId" => $gtxagencysysid,
);
$curl_p = curl_init(API_GET_AGENCY_DATA);
curl_setopt($curl_p, CURLOPT_POST, true);
//curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($curl_p, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_p, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_p, CURLOPT_TIMEOUT, 300);
$response_pro = curl_exec($curl_p);
curl_close($curl_p);
$IVData = Zend_Json::decode($responseIV, true);
$data = Zend_Json::decode($response_pro, true);
$agencyData = new Travel_Model_Encrytion($data['Message'], $apiDataIV['SecurityKey'], $IVData['Message']);
return Zend_Json::decode($agencyData->decrypt(), true);
//echo '<pre>';print_r(Zend_Json::decode($agencyData->decrypt(),true));
//die('wait');
} else {
return 'Bad request';
}
}
function createGUID()
{
// Create a token
$token = $_SERVER['HTTP_HOST'];
$token .= $_SERVER['REQUEST_URI'];
$token .= uniqid(rand(), true);
// GUID is 128-bit hex
$hash = strtoupper(md5($token));
// Create formatted GUID
$guid = '';
// GUID format is XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX for readability
$guid .= substr($hash, 0, 8) .
'-' .
substr($hash, 8, 4) .
'-' .
substr($hash, 12, 4) .
'-' .
substr($hash, 16, 4) .
'-' .
substr($hash, 20, 12);
return $guid;
}
function distance($lat1, $lon1, $lat2, $lon2)
{
$pi80 = M_PI / 180;
$lat1 *= $pi80;
$lon1 *= $pi80;
$lat2 *= $pi80;
$lon2 *= $pi80;
$r = 6372.797; // mean radius of Earth in km
$dlat = $lat2 - $lat1;
$dlon = $lon2 - $lon1;
$a = sin($dlat / 2) * sin($dlat / 2) + cos($lat1) * cos($lat2) * sin($dlon / 2) * sin($dlon / 2);
$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
$km = $r * $c;
//echo ' '.$km;
return $km;
}
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);
if($AgencySysid == '13527'){
//echo $outputH;exit;
}
//
$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, $outputH);
//$objXmlDocuments = simplexml_load_file("public/hotels/staticData/" . $TBBCityId . "_HotelStaticData.xml");
$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']));
// echo "<pre>";
// print_r($arrOutput);
// echo "<pre>";
// //print_r($arrOutput);
// die;
$objFlight = new Travel_Model_FlightMaster();
$this->objMdl = new Admin_Model_CRUD();
$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());
}
return $response;
}
}
public function authenticateAPI($AgencySysid)
{
$objFlight = new Travel_Model_FlightMaster();
$CheckFlightToken = $objFlight->CheckFlightToken('tbl_token', $AgencySysid);
if (empty($CheckFlightToken)) {
$data = array(
'ClientId' => FLIGHT_API_CLIENT_ID,
'UserName' => FLIGHT_API_USER,
'Password' => FLIGHT_API_PASSWORD,
'EndUserIp' => $_SERVER['REMOTE_ADDR'],
);
$data_string = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->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...
}
$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,
'created_at' => Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss'),
);
$objFlight->InsertFlightData('tbl_token', $insertArr);
return $insertArr;
} else {
$insertArr = array(
'token' => $CheckFlightToken['token'],
'AgencyId' => $CheckFlightToken['AgencyId'],
'MemberId' => $CheckFlightToken['MemberId'],
);
return $insertArr;
}
}
public function GetFullUrl(){
$s = &$_SERVER;
$ssl = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on') ? true : false;
$sp = strtolower($s['SERVER_PROTOCOL']);
$protocol = substr($sp, 0, strpos($sp, '/')) . (($ssl) ? 's' : '');
$port = $s['SERVER_PORT'];
$port = ((!$ssl && $port == '80') || ($ssl && $port == '443')) ? '' : ':' . $port;
$host = isset($s['HTTP_X_FORWARDED_HOST']) ? $s['HTTP_X_FORWARDED_HOST'] : (isset($s['HTTP_HOST']) ? $s['HTTP_HOST'] : null);
$host = isset($host) ? $host : $s['SERVER_NAME'] . $port;
$uri = $protocol . '://' . $host . $s['REQUEST_URI'];
$segments = explode('?', $uri, 2);
$url = $segments[0];
return $url;
}
public function CreateLogsHotel($data){
$agency_sys_id = isset($data['AgencySysId'])?$data['AgencySysId']:'';
$aConfig = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOptions();
$BootStrap = $aConfig['bootstrap'];
$requests = $this->getRequest()->getParams();
$data = [
"user_id" => isset($data['user_id']) ? $data['user_id'] : 1,
"agency_sys_id" => isset($agency_sys_id) ? $agency_sys_id : '',
"application_name" => isset($BootStrap['siteName']) ? $BootStrap['siteName'] : $_SERVER['HTTP_HOST'],
"site_url" => $this->GetFullUrl(),
"module_name" => isset($requests['module']) ? ucfirst($requests['module']) : '',
"controller_name" => isset($requests['controller']) ? ucfirst($requests['controller']) : '',
"action_name" => isset($requests['action']) ? ucfirst($requests['action']) : '',
"custom_error" => isset($data['custom_error']) ? $data['custom_error'] : '',
"error" => isset($data['error']) ? $data['error'] : '',
"ip_address" => $_SERVER['REMOTE_ADDR'],
"text_udf" => isset($data['text_udf']) ? json_encode($data['text_udf']) : '', // Response
"char_udf" => isset($data['char_udf']) ? json_encode($data['char_udf']) : '', // Request
"udf1" => isset($data['udf1']) ? $data['udf1'] : '',
"udf2" => isset($data['udf2']) ? $data['udf2'] : '',
"udf5" => isset($data['udf5']) ? $data['udf5'] : '',
"from_destination" => isset($data['from_destination']) ? $data['from_destination'] : '',
"to_destination" => isset($data['to_destination']) ? $data['to_destination'] : '',
"Pax" => isset($data['Pax']) ? $data['Pax'] : '',
"flight_type" => isset($data['flight_type']) ? $data['flight_type'] :5,
"source" => isset($data['source']) ? $data['source'] :1,
"Supplier" => isset($data['Supplier']) ? $data['Supplier'] : '',
"Airline" => isset($data['Airline']) ? $data['Airline'] : '',
"status" => isset($data['status']) ? $data['status'] : 1, //
"created_on" => date('Y-m-d H:i:s'),
"updated_on" => date('Y-m-d'),
"is_active" => isset($data['is_active']) ? $data['is_active'] : true, //,
"is_mark_for_delete" => isset($data['is_mark_for_delete']) ? $data['is_mark_for_delete'] : false, //,
];
$url = 'https://logs.hellogtx.com/api/v1/create-logs/';
$data_stringh = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
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',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
return $response;
}
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'] : [];
$getMarkupNew = isset($data['getMarkupNew']['data']) ? $data['getMarkupNew']['data'] : [];
$arrAgentMarkups = isset($data['getAgencyMarkups']) ? $data['getAgencyMarkups'] : [];
$intGTXMarkUp = isset($data['GTXMarkups']) ? $data['GTXMarkups'] : 0;
$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 = (($TotalAgencyMarkUp * $intAgentMarkUp) / 100);
$intAgentMarkUp = (($intAgentMarkUp * $Nights) * $rooms);
$TotalAgentMarkUp += $intAgentMarkUp;
}
}
} else {
$TotalAgentMarkUp = $TotalAgentMarkUp;
}
$TaxType = isset($TaxSetting[0]['TaxType']) ? $TaxSetting[0]['TaxType'] : 2;
$TaxPercentage = isset($TaxSetting[0]['TaxPercentage']) ? $TaxSetting[0]['TaxPercentage'] : 18;
if ($TaxType == 1) {
$arrGSTOnGTXMarkUp = $this->calculateServiceTax($intGTXMarkUp, $TaxPercentage);
$arrGSTOnAgencyMarkUp = $this->calculateServiceTax($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),
);
return $arrPriceAndMarkUps;
// echo '<pre>';
//print_r($TotalAgencyMarkUp.'='.$intGSTOnAgencyMarkUp);
}
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/?hotel_id='.$cityId,
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;
}
public function apiHttpRequest($Request, $arrData, $url)
{
if ($Request) {
$data_stringh = json_encode($Request);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
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',
'SecurityKey: ' . SECURITYKEY,
// 'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
return $response;
} else {
return $response = [];
}
exit;
}
public function httpBuildQuery($Request,$url)
{
if ($Request) {
// $data_stringh = http_build_query($Request);
// $ch = curl_init();
// curl_setopt($ch, CURLOPT_URL, $url);
// 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',
// 'SecurityKey: ' . SECURITYKEY,
// 'Content-Length: ' . strlen($data_stringh)
// ));
// $outputH = curl_exec($ch);
// echo "outputH<pre>";print_r($outputH);die;
// $response = json_decode($outputH, true);
// return $response;
$jsonEncode = http_build_query($Request);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $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, ($jsonEncode));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'SecurityKey: ' . SECURITYKEY,
'Content-Length: ' . strlen($jsonEncode),
));
$outputH = curl_exec($ch);
// print_r($outputH);die;
$response = json_decode($outputH, true);
return $response;
} else {
return $response = [];
}
exit;
}
public function CreateHotelSessionSearchNew($data, $TraceId)
{
Zend_Session::namespaceUnset('SearchCarTraceId');
Zend_Session::namespaceUnset('SearchCarData');
Zend_Session::namespaceUnset('SearchHotelTraceId');
Zend_Session::namespaceUnset('SearchHotelData');
$SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
$SearchHotelTraceId->params = $TraceId;
$SearchRequestData = new Zend_Session_Namespace('SearchRequestData');
$SearchRequestData->params = $data;
$SearchHotelData = new Zend_Session_Namespace('SearchHotelData');
$countryTitle = $data['countryTitle'];
$device = isset($data['device'])?$data['device']:'';
$checkIn = $data['checkIn'];
$checkOut = $data['CheckOut'];
$Nationality = $data['Nationality'];
$currency = isset($data['currency']) ? $data['currency'] : 'INR';
$cityid = $data['cityid'];
$cityName = $data['cityName'];
$hotel_countryCode = $data['hotel_countryCode'];
$countryId = $data['countryId'];
$memberCount = $data['totadlt'] + $data['totchld'];
$room = $data['room'];
$adultAr = $data['adult'];
$childAr = $data['child'];
$child1_bed_typeAr = $data['child1_age'];
$child2_bed_typeAr = $data['child2_age'];
$interNationalSearch = $data['interNationalSearch'];
$days = Zend_Controller_Action_HelperBroker::getStaticHelper("Hotel")->calculateNoOfDays($checkIn, $checkOut);
$roominfo = [];
if ($room) {
for ($i = 0; $i < $room; $i++) {
$adult = (int) $adultAr[$i];
$child = (int) $childAr[$i];
$child1_bed_type = (int) $child1_bed_typeAr[$i];
$child2_bed_type = (int) $child2_bed_typeAr[$i];
$chAGe = ($child > 0) ? array($child1_bed_type) : null;
$chAGe2 = ($child > 0) ? array($child2_bed_type) : null;
$childArray = '';
if ($child > 0) {
if ($child == 1) {
$childArray = ($chAGe);
} elseif ($child == 2) {
$childArray = array_merge($chAGe, $chAGe2);
}
}
$roominfo[$i] = array(
'numberOfAdults' => $adult,
'numberOfChild' => $child,
);
if ($child > 0) {
$roominfo[$i]['childAge'] = $childArray;
}
}
}
$searchCriteria['city'] = $cityid;
$searchCriteria['currency'] = $currency;
$searchCriteria['nationality'] = $Nationality;
$fsc = false;
if (isset($data['specific']) && $data['specific'] == on) {
$fsc = true;
}
$stars = array();
if (isset($data['starrating'])) {
foreach ($data['starrating'] as $key => $value) {
$stars[] = (int)$value;
}
}
$searchPreferences['ratings'] = $stars;
$searchPreferences['fsc'] = $fsc;
$searchdata = array(
'checkinDate' => $data['checkIn'],
'checkoutDate' => $data['CheckOut'],
'roomInfo' => $roominfo,
'searchCriteria' => $searchCriteria,
'searchPreferences' => $searchPreferences,
);
//echo"<pre>"; echo json_encode($searchdata);die;
$finalarray = array('searchQuery' => $searchdata, 'sync' => true);
$SearchHotelData->params['hotelsearchdata'] = $finalarray;
$SearchHotelData->params['interNationalSearch'] = $interNationalSearch;
$SearchHotelData->params['cityName'] = $cityName;
$SearchHotelData->params['memberCount'] = $memberCount;
// add this code
$SearchHotelData->params['CountryId'] = $countryId;
$SearchHotelData->params['GuestNationality'] = ($data['GuestNationality']) ? $data['GuestNationality'] : '';
return $SearchHotelData->params;
}
}