| 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/b2bzend/application/controllers/ |
Upload File : |
<?php
/* * ***************
* Zend Framework
* @category Zend
* @package Zend_Controller_Action
* @copyright Copyright (c) 2008-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DbTable.php 8862 2012-03-16 15:36:00Z thomas $
* @author Md Sabir(sabir@catpl.co.in).
* Deals with the flight booking comes through CRM emails to customer
*
* Create Date 01-27-2025
* Update Date 01-27-2025
* *** */
class FlightProposalNewController extends Catabatic_ValidateCustomer
{
public $AgencySysId = '';
public $AgentSysId = '';
public $baseUrl = '';
public $_objFlight;
public $CurrencyId;
public $CurrencyTitle;
public $CurrencyRate;
public $BITLYAPIKEY;
public $BITLYLOGIN;
public $SMSFORMAT;
public $SMSSENDER;
public $SMSAPIKEY;
public $SMSMETHOD;
public $SMSURL;
public $_HtmlPurifier;
public function init()
{
error_reporting(1);
$this->_helper->layout->setLayout('layout-flight-proposal');
$request = Zend_Controller_Front::getInstance()->getRequest();
$this->baseUrl = $request->getScheme() . '://' . $request->getHttpHost();
############## For HTML Purifer ####################
$this->_HtmlPurifier = new Zend_Filter_HtmlPurifier();
$this->SMSURL = Catabatic_Helper::getSMSURL();
$this->SMSMETHOD = Catabatic_Helper::getSMSMETHOD();
$this->SMSAPIKEY = Catabatic_Helper::getSMSAPIKEY();
$this->SMSSENDER = Catabatic_Helper::getSMSSENDER();
$this->SMSFORMAT = Catabatic_Helper::getSMSFORMAT();
$this->BITLYLOGIN = 'gpurwar';
$this->BITLYAPIKEY = 'R_c1c94b5c789249d5a59d585bc0e7ef80';
$this->CurrencyRate = 1;
$this->CurrencyTitle = 'INR';
$this->CurrencyId = 1;
$this->_objFlight = new Travel_Model_TblFlight();
}
public function viewFlightProposalCheckAction()
{
$objFlight = new Travel_Model_TblFlight();
$TPSysId = base64_decode($this->_request->getParam('id'));
$isagency = ($this->_request->getParam('isagency'));
Zend_Session::namespaceUnset('isagencySession');
$isagencySession = new Zend_Session_Namespace('isagencySession');
$isagencySession->params = $isagency;
$traceIDData = $objFlight->GetFlightTempDataByTPSysId($TPSysId);
// print_r($isagency);
// print_r($traceIDData);
// die;
if ($traceIDData) {
if ($isagency == 1) {
//$this->_redirect('/flight-proposal/view-flight-proposal-new/id/' . $traceIDData['TraceId']);
$this->_redirect('/flight/search-result-new/SearchID/' . $traceIDData['TraceId']);
} else {
$this->_redirect('/flight-proposal/view-flight-proposal-new/id/' . $traceIDData['TraceId']);
}
} else {
die('Invalid link');
}
}
public function viewFlightProposalAction()
{
try {
$objFlight = new Travel_Model_TblFlight();
$getData = $this->getRequest()->getParams();
$isCustomer = isset($getData['cust']) ? $getData['cust'] : 0;
$traceID = $this->view->traceID = ($this->_request->getParam('searchID'));
$TPSysId = $this->view->TPSysId = ($this->_request->getParam('TPSys'));
// if ($isCustomer == 1) {
// $isagencySession = new Zend_Session_Namespace('isagencySession');
// $isagencySession->params = $isCustomer;
// }
$FlightTempData = $objFlight->GetFlightTempData($traceID);
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
// echo "<pre>";
// print_r($arrUrlData);
// echo "<pre>";
// print_r($arrUrlData);
// exit;
$FlightBookingData = [];
$sessionFlightSearchParams = $this->view->sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
$bookingAllowed = $this->view->bookingAllowed = isset($sessionFlightSearchParams['bookingAllowed']) ? $sessionFlightSearchParams['bookingAllowed'] : 0;
$leadId = $sessionFlightSearchParams['editLeadId'];
$objFlightProposal = new Travel_Model_TblFlightProposal();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$arrAgencyDetails = $this->view->arrAgencyDetails = $objFlightProposal->getProposalAgencyDetails($leadId, 'query');
$AgencySysId = $arrAgencyDetails['AgencySysId'];
$AgentSysId = $arrAgencyDetails['AgentSysId'];
$getAgencyDetail = $crmcustomerObj->GetAgencyDetailById($AgencySysId);
$SecurityKey = isset($getAgencyDetail['SecurityKey']) ? $getAgencyDetail['SecurityKey'] : 0;
$crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$arrAgentDetail = $this->view->arrAgentDetail = $crmcusttravelplan->getAgentDetails($AgentSysId);
$this->view->IsCheckWallet = $IsCheckWallet = isset($getAgencyDetail['IsCheckWallet']) ? $getAgencyDetail['IsCheckWallet'] : 0;
//$TraceId = implode('-', str_split(substr(strtolower(md5(time() . rand(1000, 9999))), 0, 20), 5)); arrAgencyDetails
$sessionFlightSearchParams['SearchTraceId'] = $traceID;
$this->view->interNationalSearch = $interNationalSearch = $sessionFlightSearchParams['interNationalSearch'];
$this->view->route = $route = $sessionFlightSearchParams['route'];
$departureDates = $sessionFlightSearchParams['departure_dates'];
$arrDepartureDates = (is_array($departureDates)) ? explode("/", $departureDates[0]) : explode("/", $departureDates);
$this->view->departureDates = $arrDepartureDates[2] . "/" . $arrDepartureDates[1] . "/" . ($arrDepartureDates[0]);
$returnDates = $sessionFlightSearchParams['return_dates'];
$arrreturnDates = (is_array($returnDates)) ? explode("/", $returnDates[0]) : explode("/", $returnDates);
$this->view->returnDates = $arrreturnDates[2] . "/" . $arrreturnDates[1] . "/" . ($arrreturnDates[0]);
$this->view->baseUrl = $this->baseUrl;
$arrRoomInfoJson = json_decode($arrAgencyDetails['RoomInfoJson'], true);
if ($this->getRequest()->isXmlHttpRequest()) {
$getData['SecurityKey'] = $SecurityKey;
$PostData = ['TPSysId' => $TPSysId, 'version' => null];
$URL = $this->baseUrl . "/gtxwebservices/flight-api/bookingdetails/";
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($PostData, $getData, $URL);
$FlightBookingData = isset($apiResponse['FlightBookingData']) ? $apiResponse['FlightBookingData'] : [];
$ICSourceSysId = $FlightBookingData[0]['ICSourceSysId'];
//$PreferredAirline = $this->getPreferredAirline($FlightBookingData);
// $sessionFlightSearchParams['PreferredAirline'] = $PreferredAirline['PreferredAirline'];
$sessionFlightSearchParams['ICSourceSysId'] = $ICSourceSysId;
// $searchApiFlightsNew = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsNew($sessionFlightSearchParams, $AgencySysId);
// $searchApiFlightsNew['searchID'] = $traceID;
// $searchApiFlightsNew['ICSourceSysId'] = $ICSourceSysId;
$APIBookingData['SearchQueryid'] = $traceID;
$URLSQ = GTX_API_URL . '/flight/v4/search';
$searchApiFlightsNew['IsSfS'] = false;
$apiSearchRequest = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($APIBookingData, $getData, $URLSQ);
// echo "<pre>getData";
// print_r($searchApiFlightsNew);
// echo "<pre>apiSearchRequest";
// print_r($apiSearchRequest);
// exit;
$ResponseStatus = (isset($apiSearchRequest['status']) && $apiSearchRequest['status']) ? true : false;
if ($ResponseStatus) {
$outbound = (isset($apiSearchRequest['outbound']) && $apiSearchRequest['outbound']) ? $apiSearchRequest['outbound'] : [];
$inbound = (isset($apiSearchRequest['inbound']) && $apiSearchRequest['inbound']) ? $apiSearchRequest['inbound'] : [];
$PreferredAirline = $this->getPreferredAirline($FlightBookingData, true, $outbound, $inbound, $sessionFlightSearchParams);
$outboundSelect = (isset($PreferredAirline['outbound']) && $PreferredAirline['outbound']) ? $PreferredAirline['outbound'] : [];
$inboundSelect = (isset($PreferredAirline['inbound']) && $PreferredAirline['inbound']) ? $PreferredAirline['inbound'] : [];
$FiltAirlineName = (isset($apiSearchRequest['FiltAirlineName']) && $apiSearchRequest['FiltAirlineName']) ? $apiSearchRequest['FiltAirlineName'] : [];
$FiltAirlineNameSp = (isset($apiSearchRequest['FiltAirlineNameSp']) && $apiSearchRequest['FiltAirlineNameSp']) ? $apiSearchRequest['FiltAirlineNameSp'] : [];
$FiltStop = (isset($apiSearchRequest['FiltStop']) && $apiSearchRequest['FiltStop']) ? $apiSearchRequest['FiltStop'] : [];
$FiltPrice = (isset($apiSearchRequest['FiltPrice']) && $apiSearchRequest['FiltPrice']) ? $apiSearchRequest['FiltPrice'] : [];
$checkingBaggage = (isset($apiSearchRequest['checkingBaggage']) && $apiSearchRequest['checkingBaggage']) ? $apiSearchRequest['checkingBaggage'] : [];
$cabinBaggage = (isset($apiSearchRequest['cabinBaggage']) && $apiSearchRequest['cabinBaggage']) ? $apiSearchRequest['cabinBaggage'] : [];
$data = array(
'outbound' => $outboundSelect,
'inbound' => $inboundSelect,
'outboundSelect' => [],
'inboundSelect' => [],
'FlightRoute' => $route,
'interNationalSearch' => $interNationalSearch,
'arrAirlineName' => $FiltAirlineName,
'FiltStopCount' => $FiltStop,
'FiltPrice' => $FiltPrice,
'FiltSupplier' => [],
'cabinBaggage' => $cabinBaggage,
'checkingBaggage' => $checkingBaggage,
'FiltAirlineNameSp' => $FiltAirlineNameSp,
'MinriceRange' => 0,
'MaxriceRange' => 0
);
echo json_encode($data);
exit;
} else {
$data = array('outbound' => [], 'inbound' => [], 'FlightRoute' => $route, 'interNationalSearch' => $interNationalSearch, 'arrAirlineName' => [], 'FiltStopCount' => [], 'FiltPrice' => [], 'FiltSupplier' => [], 'FiltAirlineNameSp' => [], 'cabinBaggage' => [], 'checkingBaggage' => [], 'MinriceRange' => 0, 'MaxriceRange' => 0);
echo json_encode($data);
exit;
}
// echo "<pre>";
// print_r($apiResponse);
// exit;
}
} catch (Exception $e) {
//echo $e->getMessage();
$response = array('success' => false, 'message' => 'URL expired. please get another proposal');
echo json_encode($response);
exit;
}
}
public function getPreferredAirline($FlightBookingData, $filter = false, $outbound = [], $inbound = [], $sessionFlightSearchParams = [])
{
$interNationalSearch = $sessionFlightSearchParams['interNationalSearch'];
$route = $sessionFlightSearchParams['route'];
$AirLineCode = [];
$outbound_ = $inbound_ = $outbound_inbound = [];
if ($FlightBookingData) {
foreach ($FlightBookingData as $key => $value) {
$AirLineCode[] = $value['AirLineCode'];
if ($filter) {
$LocalFromTime = date('YmdHi', strtotime($value['LocalFromTime']));
$LocalToTime = date('YmdHi', strtotime($value['LocalToTime']));
$FairRulesKey = $value['FairRules']['fareIdentifier'] . '' . $value['FairRules']['classOfBooking'] . '' . $value['FairRules']['Refundable'];
$FlightNumber = $value['FlightNumber'];
$CustomKey = str_replace(' ', '', $value['TripType'] . '' . $FairRulesKey . '' . $LocalFromTime . '' . $LocalToTime . '' . $FlightNumber);
if ($route == 2 && $interNationalSearch == 1) {
$outbound_[$CustomKey][] = $value;
} else {
if ($value['TripType'] == 1) {
$outbound_[$CustomKey][] = $value;
}
if ($value['TripType'] == 2) {
$inbound_[$CustomKey][] = $value;
}
}
}
}
}
if (!empty($inbound)) {
$apiDataMerge = array_merge($outbound, $inbound);
} else {
$apiDataMerge = $outbound;
}
// echo "<pre>outbound";
// print_r($outbound);
// echo "<pre>inbound";
// print_r($inbound);
// die;
$outboundNew = [];
$inboundNew = [];
if ($apiDataMerge && $filter) {
foreach ($apiDataMerge as $keys => $value) {
$LocalFromTime = date('YmdHi', strtotime($value['FromUTCTime']));
$LocalToTime = date('YmdHi', strtotime($value['ToUTCTime']));
$TripType = $value['TripType'];
$FlightNumber = $value['FlightNumber'];
if ($route == 2 && $interNationalSearch == 1) {
$LocalFromTime = date('YmdHi', strtotime($value['origin']['FromUTCTime']));
$LocalToTime = date('YmdHi', strtotime($value['origin']['ToUTCTime']));
$FlightNumber = $value['origin']['FlightNumber'];
}
$FairRulesOut = [];
$FairRulesInb = [];
if ($value['FairRules']) {
foreach ($value['FairRules'] as $FRValue) {
$FairRulesKey = $FRValue['fareIdentifier'] . '' . $FRValue['classOfBooking'] . '' . $FRValue['Refundable'];
$CustomKey = str_replace(' ', '', $value['TripType'] . '' . $FairRulesKey . '' . $LocalFromTime . '' . $LocalToTime . '' . $FlightNumber);
if (isset($outbound_[$CustomKey])) {
$PublishedFare = isset($FRValue['PublishedFare']) ? (float)$FRValue['PublishedFare'] : 0;
$ExtraMarkup = isset($outbound_[$CustomKey][0]['ExtraMarkup']) ? (float)$outbound_[$CustomKey][0]['ExtraMarkup'] : 0;
$ExtraMarkupOnGST = isset($outbound_[$CustomKey][0]['ExtraMarkupOnGST']) ? (float)$outbound_[$CustomKey][0]['ExtraMarkupOnGST'] : 0;
$FRValue['ExtraMarkup'] = $ExtraMarkup;
$FRValue['ExtraMarkupOnGST'] = $ExtraMarkupOnGST;
$FRValue['PublishedFare'] = ($PublishedFare + $ExtraMarkup + $ExtraMarkupOnGST);
$FairRulesOut[] = $FRValue;
}
if (isset($inbound_[$CustomKey])) {
$PublishedFare = isset($FRValue['PublishedFare']) ? (float)$FRValue['PublishedFare'] : 0;
$ExtraMarkup = isset($inbound_[$CustomKey][0]['ExtraMarkup']) ? (float)$inbound_[$CustomKey][0]['ExtraMarkup'] : 0;
$ExtraMarkupOnGST = isset($inbound_[$CustomKey][0]['ExtraMarkupOnGST']) ? (float)$inbound_[$CustomKey][0]['ExtraMarkupOnGST'] : 0;
$FRValue['ExtraMarkup'] = $ExtraMarkup;
$FRValue['ExtraMarkupOnGST'] = $ExtraMarkupOnGST;
$FRValue['PublishedFare'] = ($PublishedFare + $ExtraMarkup + $ExtraMarkupOnGST);
$FairRulesInb[] = $FRValue;
}
}
}
if (!empty($FairRulesOut)) {
$value['FairRules'] = $FairRulesOut;
$outboundNew[] = $value;
}
if (!empty($FairRulesInb)) {
$value['FairRules'] = $FairRulesInb;
$inboundNew[] = $value;
}
}
}
// echo "<pre>outboundNew";
// print_r($outboundNew);
return ['PreferredAirline' => array_values(array_unique($AirLineCode)), 'outbound' => $outboundNew, 'inbound' => $inboundNew];
}
public function farerulesAction()
{
$post = json_decode(file_get_contents('php://input'), true);
if ($post['item']) {
$objFlight = new Travel_Model_TblFlight();
$ICSourceSysId = $post['item']['ICSourceSysId'];
$JourneyType = $post['item']['JourneyType'];
$IsInternational = $post['item']['IsInternational'];
$searchID = $post['item']['SearchTraceId'];
$FlightTempData = $objFlight->GetFlightTempData($searchID);
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
$leadId = $sessionFlightSearchParams['editLeadId'];
$objFlightProposal = new Travel_Model_TblFlightProposal();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$arrAgencyDetails = $this->view->arrAgencyDetails = $objFlightProposal->getProposalAgencyDetails($leadId, 'query');
$AgencySysId = $arrAgencyDetails['AgencySysId'];
$AgentSysId = $arrAgencyDetails['AgentSysId'];
$getAgencyDetail = $crmcustomerObj->GetAgencyDetailById($AgencySysId);
$SecurityKey = isset($getAgencyDetail['SecurityKey']) ? $getAgencyDetail['SecurityKey'] : 0;
$DataAPI = [
'CurrencyRate' => !empty($post['prices']['CurrencyRate']) ? $post['prices']['CurrencyRate'] : 1,
'CurrencyTitle' => !empty($post['prices']['Currency']) ? $post['prices']['Currency'] : 'INR',
'CurrencyId' => !empty($post['prices']['currencySysId']) ? $post['prices']['currencySysId'] : 1,
];
$flowType = (isset($post['flowType']) && !empty($post['flowType'])) ? $post['flowType'] : 'REVIEW';
if ($ICSourceSysId == 7) {
$datah = array(
'id' => $post['prices']['PriceID'],
'flowType' => $flowType,
);
} elseif ($ICSourceSysId == 3) {
$datah = array(
'EndUserIp' => $_SERVER['REMOTE_ADDR'],
'TokenId' => '',
'TraceId' => $post['item']['apiTraceId'],
'ResultIndex' => $post['prices']['PriceID']
);
} elseif ($ICSourceSysId == 11 || $ICSourceSysId == 13 || $ICSourceSysId == 14 || $ICSourceSysId == 20 || $ICSourceSysId == 30) {
$datah = array(
'Auth_Header' => array(
"IP_Address" => $_SERVER['REMOTE_ADDR'],
"Request_Id" => $post['item']['SearchTraceId'],
"IMEI_Number" => "3434334343111"
),
'Fare_Id' => $post['prices']['PriceID'],
'Search_Key' => $post['item']['Search_Key'],
'Flight_Key' => $post['item']['Flight_Key'],
);
}
$getData = [];
$DataAPI['farerule'] = $datah;
$DataAPI['ICSourceSysId'] = $ICSourceSysId;
$DataAPI['JourneyType'] = $JourneyType;
$DataAPI['IsInternational'] = $IsInternational;
$DataAPI['searchID'] = $searchID;
$DataAPI['B2B'] = [];
$getData['SecurityKey'] = $SecurityKey;
if ($AgencySysId == '1') {
$URL = GTX_API_URL . '/flight/v3/farerules';
} else {
$URL = 'https://gtxapi.hellogtx.com/flight/v3/farerules';
}
$apiSearchRequest = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataAPI, $getData, $URL);
$ResponseStatus = (isset($apiSearchRequest['status']) && $apiSearchRequest['status']) ? true : false;
// echo "<pre>";
// print_r($DataAPI);
// echo "<pre>";
// print_r($apiSearchRequest);
// die;
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight-proposal-new/');
$html->assign(array('apiResponse' => $apiSearchRequest, 'prices' => $post['prices'], 'item' => $post['item']));
$bodyText = $html->render('getflightfarerules.phtml');
$response = array('success' => true, 'message' => 'success', 'html' => $bodyText);
echo json_encode($response);
exit;
}
}
public function bookNowAction()
{
$post = json_decode(file_get_contents('php://input'), true);
$Outbound = isset($post['Outbound']) ? $post['Outbound'] : [];
$Inbound = isset($post['Inbound']) ? $post['Inbound'] : [];
$FareOption = isset($post['FareOption']) ? $post['FareOption'] : [];
$SearchTraceId = isset($Outbound['SearchTraceId']) ? $Outbound['SearchTraceId'] : '';
$ProposaltraceID = isset($post['ProposaltraceID']) ? $post['ProposaltraceID'] : '';
if (isset($post['sessionFlightSearchParams']) && !empty($post['sessionFlightSearchParams'])) {
$sessionParams = json_decode($post['sessionFlightSearchParams'], true);
}
$objFlight = new Travel_Model_TblFlight();
$route = ($sessionParams['route']);
$SearchTrace = ($sessionParams['SearchTraceId']);
$interNationalSearch = !empty($sessionParams['interNationalSearch']) ? $sessionParams['interNationalSearch'] : 0;
$FlightTempData = $objFlight->GetFlightTempData($SearchTraceId);
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
$GENERATE_FLIGHT_QUERY = $arrUrlData['GENERATE_FLIGHT_QUERY'];
$TPSysId = $ProposaltraceID = isset($GENERATE_FLIGHT_QUERY['arrIds']['TPSysId']) ? $GENERATE_FLIGHT_QUERY['arrIds']['TPSysId'] : 0;
if (!empty($Inbound) && $route == 2 && $interNationalSearch == 0) {
$Outbound['FairRules'] = $Outbound['FairRules'][0];
$FlightBookingData[0] = $Outbound;
$Inbound['FairRules'] = $Inbound['FairRules'][0];
$FlightBookingData[1] = $Inbound;
} else {
$Outbound['FairRules'] = $FareOption;
$FlightBookingData[0] = $Outbound;
}
// echo "<pre>";
// print_r(($FlightBookingData));
// die;
try {
$arrUrlData['FlightBookingData'] = $FlightBookingData;
$arrUrlData['apiTraceId'] = $SearchTrace;
$arrUrlData['SearchTraceId'] = $SearchTraceId;
$tempData = array(
'TraceId' => $SearchTraceId,
'TPSysId' => $TPSysId,
'APIBookingData' => json_encode($arrUrlData),
);
$objFlight->deleteFlightTempData($SearchTraceId);
$objFlight->insertFlightTempData($tempData);
//$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrData);
if ($FlightBookingData) {
if (!empty($ProposaltraceID)) {
$response = array('success' => true, 'message' => 'Plase wait...', 'url' => $this->baseUrl . '/flight-proposal-new/travellers/searchID/' . $SearchTraceId . '/TPSys/' . $ProposaltraceID);
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to continue please try again.', 'url' => '');
echo json_encode($response);
exit;
}
} else {
$response = array('success' => false, 'message' => 'Oops something went wrong', 'url' => '');
echo json_encode($response);
exit;
}
} catch (Exception $e) {
//echo $e->getMessage();
$response = array('success' => false, 'message' => 'Traceid expired. please search again', 'url' => '');
echo json_encode($response);
exit;
}
}
public function travellersAction()
{
$objFlight = new Travel_Model_TblFlight();
$getData = $this->getRequest()->getParams();
if ($this->getRequest()->isXmlHttpRequest()) {
$post = json_decode(file_get_contents('php://input'), true);
$getData['searchID'] = $post['SearchID'];
$getData['TPSys'] = $post['TPSysId'];
}
$isCustomer = isset($getData['cust']) ? $getData['cust'] : 0;
$traceID = $this->view->traceID = ($getData['searchID']);
$TPSysId = $this->view->TPSysId = ($getData['TPSys']);
$FlightTempData = $objFlight->GetFlightTempData($traceID);
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
$customerSaved = isset($arrUrlData['customer']) ? $arrUrlData['customer'] : [];
$FlightBookingData = [];
// echo '<pre>';
// print_r($arrUrlData['FlightBookingDataOld']);
// die;
$FlightBookingData = $this->view->FlightBookingData = $arrUrlData['FlightBookingData'];
$FlightBookingData = (isset($arrUrlData['FlightBookingDataOld']) && !empty($arrUrlData['FlightBookingDataOld'])) ? $arrUrlData['FlightBookingDataOld'] : $FlightBookingData;
$requestAPIOld = isset($arrUrlData['requestAPI']) ? $arrUrlData['requestAPI'] : '';
$sessionFlightSearchParams = $this->view->sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
$bookingAllowed = $this->view->bookingAllowed = isset($sessionFlightSearchParams['bookingAllowed']) ? $sessionFlightSearchParams['bookingAllowed'] : 0;
$leadId = $sessionFlightSearchParams['editLeadId'];
$objFlightProposal = new Travel_Model_TblFlightProposal();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$arrAgencyDetails = $this->view->arrAgencyDetails = $objFlightProposal->getProposalAgencyDetails($leadId, 'query');
$AgencySysId = $this->intLoggedinAgencyId = $arrAgencyDetails['AgencySysId'];
$AgentSysId = $arrAgencyDetails['AgentSysId'];
$getAgencyDetail = $crmcustomerObj->GetAgencyDetailById($AgencySysId);
$SecurityKey = isset($getAgencyDetail['SecurityKey']) ? $getAgencyDetail['SecurityKey'] : 0;
$crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$arrAgentDetail = $this->view->arrAgentDetail = $crmcusttravelplan->getAgentDetails($AgentSysId);
$this->view->IsCheckWallet = $IsCheckWallet = isset($getAgencyDetail['IsCheckWallet']) ? $getAgencyDetail['IsCheckWallet'] : 0;
//$TraceId = implode('-', str_split(substr(strtolower(md5(time() . rand(1000, 9999))), 0, 20), 5)); ICSourceSysId
$sessionFlightSearchParams['SearchTraceId'] = $traceID;
$this->view->interNationalSearch = $interNationalSearch = $sessionFlightSearchParams['interNationalSearch'];
$this->view->route = $route = $sessionFlightSearchParams['route'];
$ICSourceSysId = $FlightBookingData[0]['ICSourceSysId'];
$customerID = ($sessionFlightSearchParams['customerID']);
$B2BType = ($sessionFlightSearchParams['B2BType']);
$intCountryCode = ($sessionFlightSearchParams['intCountryCode']);
$adultCount = ($sessionFlightSearchParams['adults']);
$childCount = ($sessionFlightSearchParams['child']);
$infantCount = ($sessionFlightSearchParams['infant']);
$JourneyType = ($sessionFlightSearchParams['route']);
$interNationalSearch = !empty($sessionFlightSearchParams['interNationalSearch']) ? $sessionFlightSearchParams['interNationalSearch'] : 0;
$intMemberCount = ($adultCount + $childCount + $infantCount);
$flight_class = trim($sessionFlightSearchParams['flight_class']);
$arrFlightClass = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getFlightClasses();
$cabinClass = isset($arrFlightClass[$flight_class]) ? $arrFlightClass[$flight_class] : 'Economy';
$objMarkup = new Markup_Model_Markup();
if (!empty(trim($intCountryCode)) && trim($intCountryCode) != "IN") {
$intAirType = 2;
} else {
$intAirType = 1;
}
$arrAgencyUserDetail = $objMarkup->getAgencyUserDetail(array("AgencySysId" => $this->intLoggedinAgencyId, "ItemSourceType" => (int) $intAirType, "PlanType" => 0));
$this->view->arrAgencyUserDetail = $arrAgencyUserDetail;
$departureDates = $sessionFlightSearchParams['departure_dates'];
if ($JourneyType == '3') {
$departureDates = $sessionFlightSearchParams['departure_dates'][0];
}
$arrDepartureDates = explode("/", $departureDates);
$this->view->departureDates = $departureDates = $arrDepartureDates[2] . "/" . $arrDepartureDates[1] . "/" . ($arrDepartureDates[0] - 1);
$this->view->departureMonthInfant = $departureMonthInfant = $arrDepartureDates[1];
$this->view->departureDayInfant = $departureDayInfant = ($arrDepartureDates[0] + 1);
$this->view->departureMonthChild = $departureMonthChild = $arrDepartureDates[1];
$this->view->departureDayChild = $departureDayChild = ($arrDepartureDates[0]);
$this->view->AgencySysId = $AgencySysId;
$this->view->ICSourceSysId = $ICSourceSysId;
$this->view->intFlightRoute = $JourneyType;
$this->view->intAdultsCount = $adultCount;
$this->view->intChildrenCount = $childCount;
$this->view->intInfantCount = $infantCount;
$this->view->totalPaxCount = $adultCount + $childCount + $infantCount;
$customerDetails = isset($sessionFlightSearchParams['customerID']) ? $crmcustomerObj->GetAgencyCustomerById(trim($sessionFlightSearchParams['customerID'])) : '';
$this->view->arrTrevllerDetails = $customerDetails;
$this->view->GeoCountry = $objFlight->GetGeoCountry();
$B2BSearch = [];
if ($B2BType == 1) {
$crmcustomerObj = new Travel_Model_CRM_Customer();
$customerDetails = $crmcustomerObj->GetAgencyCustomerById($customerID);
$AgencySysId__ = isset($customerDetails['AgencySysId']) ? $customerDetails['AgencySysId'] : 0;
$IsB2BCustomer = isset($customerDetails['IsB2BAgent']) ? $customerDetails['IsB2BAgent'] : 0;
$B2bAgencyDetailById = $crmcustomerObj->GetAgencyDetailById($AgencySysId__);
$AgentUserDetail = $crmcustomerObj->getAgentDetailById($AgencySysId__);
$UserSysId = isset($AgentUserDetail[0]['UserSysId']) ? $AgentUserDetail[0]['UserSysId'] : 0;
$B2BAgencySysIdKey = $B2bAgencyDetailById['SecurityKey'];
$AgencyMarketPlaceSysId = $B2bAgencyDetailById['AgencyMarketPlaceSysId'];
$B2BSearch = array(
'B2BAgencySysIdKey' => $B2BAgencySysIdKey,
'B2CAgencySysIdKey' => $SecurityKey,
'MasterAgencySysId' => $AgencySysId,
'AgencyMarketPlaceSysId' => $AgencyMarketPlaceSysId
);
}
// $getData['SecurityKey'] = $SecurityKey; arrTrevllerDetails
// $PostData = ['TPSysId' => $TPSysId, 'version' => null];
// $URL = $this->baseUrl . "/gtxwebservices/flight-api/bookingdetails/";
// $apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($PostData, $getData, $URL);
// $FlightBookingData = isset($apiResponse['FlightBookingData']) ? $apiResponse['FlightBookingData'] : [];
// $this->view->FlightBookingData = $FlightBookingData;
if ($this->getRequest()->isXmlHttpRequest()) {
$ExtraMarkupArray = [];
$priceId = [];
$ItineraryInfo = [];
$AirRepriceRequests = [];
$AirSSRRequestDetails = [];
$intPublishedFareCheck = 0;
if ($FlightBookingData) {
foreach ($FlightBookingData as $key => $value) {
$ExtraMarkupArray[$key]['ExtraMarkup'] = isset($value['FairRules']['ExtraMarkup']) ? $value['FairRules']['ExtraMarkup'] : 0;
$ExtraMarkupArray[$key]['ExtraMarkupOnGST'] = isset($value['FairRules']['ExtraMarkupOnGST']) ? $value['FairRules']['ExtraMarkupOnGST'] : 0;
$priceId[] = $value['FairRules']['PriceID'];
$intPublishedFareCheck += $value['FairRules']['intPublishedFare'];
$arrData[$key]['TraceId'] = $value['FairRules']['PriceID'];
$arrData[$key]['ResultIndex'] = $value['FairRules']['ApiResultIndex'];
$FlightDetails = [];
if ($value['Segments']) {
foreach ($value['Segments'] as $i => $vl) {
$FlightDetails[] = array(
'FlightID' => $vl['segmentid'],
'FlightNumber' => str_replace('-', ' ', $vl['SegFlightNumber']),
'Origin' => $vl['originAirportCode'],
'Destination' => $vl['destinationAirportCode'],
'DepartureDateTime' => date('d M Y H:i', strtotime($vl['originDepTime'])),
'ArrivalDateTime' => date('d M Y H:i', strtotime($vl['destinationArrTime'])),
);
}
}
$BaseFare = $value['FairRules']['APIBaseFare'];
$GrossAmount = $value['FairRules']['GrossAmount'];
$ItineraryInfo[$key]['FlightDetails'] = $FlightDetails;
$ItineraryInfo[$key]['BaseAmount'] = $BaseFare;
$ItineraryInfo[$key]['GrossAmount'] = $GrossAmount;
// Etrav Data ExtraMarkup
$AirSSRRequestDetails[$key]['Flight_Key'] = isset($value['Flight_Key']) ? $value['Flight_Key'] : '';
$AirRepriceRequests[$key]['Flight_Key'] = isset($value['Flight_Key']) ? $value['Flight_Key'] : '';
$AirRepriceRequests[$key]['Fare_Id'] = isset($value['FairRules']['PriceID']) ? $value['FairRules']['PriceID'] : '';
}
}
$tripSeatMap = [];
$requestAPIArray = [];
$ResponseStatus = 0;
$farerulerequestArray = [];
if ($ICSourceSysId == 7) {
$requestAPI = array(
'priceIds' => $priceId
);
$requestAPIArray = $requestAPI;
$DataS = array(
'apidata' => !empty($requestAPIOld) ? $requestAPIOld : $requestAPI,
'memberCount' => $intMemberCount,
'JourneyType' => $JourneyType,
'interNationalSearch' => $interNationalSearch,
'searchID' => $traceID,
'ICSourceSysId' => $ICSourceSysId,
'cabinClass' => $cabinClass,
'AdultCount' => $adultCount,
'ChildCount' => $childCount,
'InfantCount' => $infantCount,
'AgentMarkUp' => 0,
'APIMode' => ($this->intLoggedinAgencyId == 1) ? 1 : 0,
);
$DataS['B2B'] = $B2BSearch;
// echo (json_encode($DataS));
// die('ddd');
$url = GTX_API_URL . '/flight/v3/farequote';
$getData['SecurityKey'] = $SecurityKey;
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
//$apiResponse = json_decode('{"status":true,"message":"SUCCESS","results":[{"bookingId":"GTX17441070360833","APIBookingId":"TJS109801388567","ApiResultIndex":"R15-2-10-1213731805_0DELCCUAI2702~30550353881872053","FlightNumber":"AI-2702","SegFlightNumberArr":"AI-2702","AirlineName":"Air india","AirlineCode":"AI","IsLCC":false,"SearchTraceId":"GTX17441070360833","IsRefundable":1,"IsRefundableTxt":"Refundable","FromUTCTime":"2025-05-02T02:00","ToUTCTime":"2025-05-02T04:15","FareClass":"Economy","SourceAirportCode":"DEL","DestAirportCode":"CCU","FlightDuration":"2h 15m","StopCount":"Non-stop","NoOfSeatAvailable":9,"logo":"http://local.gtxapi.com/public/AirlineLogo/AI.png","JourneyType":"2","TripType":1,"ICSourceSysId":7,"IsInternational":0,"IsPassMandatory":false,"IsPassExpiry":false,"IsPassIssue":false,"IsPassDateOfBirth":false,"isGSTMandatory":false,"isDobAdult":false,"isDobChild":false,"isDobInfant":true,"isSeatAppli":true,"isHoldAllowed":true,"isDocIdAllowedMandatory":false,"isDocIdAllowedAplicable":false,"Segments":[{"segmentid":"597","isReturnSegment":false,"arrivingnextday":false,"originAirportName":"Delhi Indira Gandhi Intl","destinationAirportName":"Netaji Subhas Chandra Bose Intl","originCityName":"Delhi","originCountryName":"India","destinationCityName":"Kolkata","destinationCountryName":"India","destinationAirportCode":"CCU","destinationArrTime":"2025-05-02T04:15","SegFlightNumber":"AI-2702","AirlineCode":"AI","AirlineName":"Air India","FareClass":"L","cabinClass":"Economy","originAirportCode":"DEL","originDepTime":"2025-05-02T02:00","TripIndicator":false,"IscheckinBagInc":true,"IscabinbagInc":true,"CheckinBaggage":"25kg(01pieceonly)","CabinBaggage":"7kg","IsMealIncludes":false,"Duration":135,"StopPoint":[],"StopOver":false,"GroundTime":0,"NoOfSeatAvailable":9,"strDepartureDtTime":"02:00","strArrivalDtTime":"04:15","FlightDuration":"2h 15m","LAYOVERDuration":null,"LAYOVERCity":"","DepTerminal":"Terminal 3","ArrTerminal":"","filePath":"http://local.gtxapi.com/public/AirlineLogo/AI.png","BAGGAGE":[],"MEAL":[{"symbol":"INR","Currency":"INR","key":"597","Code":"VGML","Price":0,"cost":0,"Description":"Vegan Veg Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"AVML","Price":0,"cost":0,"Description":"Hindu Veg Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"VJML","Price":0,"cost":0,"Description":"Jain Veg Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"VLML","Price":0,"cost":0,"Description":"Lacto-Ovo Veg Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"FPML","Price":0,"cost":0,"Description":"Fruit Platter Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"NVML","Price":0,"cost":0,"Description":"Non-Veg Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"MOML","Price":0,"cost":0,"Description":"Moslem Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"HNML","Price":0,"cost":0,"Description":"Hindu Non-Veg Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"SFML","Price":0,"cost":0,"Description":"Sea Food Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"DBML","Price":0,"cost":0,"Description":"Diabetic Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"NLML","Price":0,"cost":0,"Description":"Low Lactose Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"CHML","Price":0,"cost":0,"Description":"Child Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"BBML","Price":0,"cost":0,"Description":"Baby Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"BLML","Price":0,"cost":0,"Description":"Bland Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"GFML","Price":0,"cost":0,"Description":"Gluten Intolerant Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"KSML","Price":0,"cost":0,"Description":"Kosher Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"LCML","Price":0,"cost":0,"Description":"Low Calorie Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"LFML","Price":0,"cost":0,"Description":"Low Fat Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"LSML","Price":0,"cost":0,"Description":"ow Salt Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"RVML","Price":0,"cost":0,"Description":"Vegetarian Raw Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"VOML","Price":0,"cost":0,"Description":"Vegetarian Oriental Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"SPML","Price":0,"cost":0,"Description":"Special Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"PFML","Price":0,"cost":0,"Description":"Peanut Free Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"ORML","Price":0,"cost":0,"Description":"Oriental Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"NSML","Price":0,"cost":0,"Description":"No Salt Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"PRML","Price":0,"cost":0,"Description":"Low Purine Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"LPML","Price":0,"cost":0,"Description":"Low Protein Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"HFML","Price":0,"cost":0,"Description":"High Fiber Meal"},{"symbol":"INR","Currency":"INR","key":"597","Code":"NFML","Price":0,"cost":0,"Description":"No Fish Meal"}]}],"FairRules":{"Currency":"INR","CurrencyRate":1,"currencySysId":1,"BaseFare":11490,"Tax":2832,"intPublishedFare":14922,"PublishedFare":15738,"PublishedFareAgent":15738,"PublishedFarePerPax":5246,"OfferedFare":14322,"CommissionEarned":0,"CommDiscount":570,"TDS":30,"TDSEarn":0,"Refundable":1,"IsRefundableTxt":"Refundable","PriceID":"R15-2-10-1213731805_0DELCCUAI2702~30550353881872053","classOfBooking":"L","FareClass":"ECONOMY","fareIdentifier":"PUBLISHED","IsSpecialReturn":false,"colors":"#000000","SeatAvailable":9,"FixedMarkUp":1200,"GSTOnMarkUp":216,"AgentMarkUp":0,"IscheckinBagInc":true,"IscabinbagInc":true,"CheckinBaggage":"25kg(01pieceonly)","CabinBaggage":"7kg","IsMealIncludes":false,"FareBreakdown":[{"Currency":"INR","PassengerType":1,"PaxType":"ADULT","PassengerCount":"1","BaseFare":4870,"Tax":1283,"OfferedFare":6153,"PublishedFare":6625,"TDS":15,"TDSEarn":0,"TaxBR":{"MF":400,"YQ":0,"AGST":252,"MFT":72,"OT":389,"YR":170},"ApiNCM":285,"CommissionEarned":0,"FixedMarkUp":400,"GSTOnMarkUp":72,"CommDiscount":285,"AgentMarkUp":0,"Baggage":"25 Kg (01 Piece only)","CabinBaggage":"7 Kg","ProcessingAmount":0,"GSTOnProcessing":0},{"Currency":"INR","PassengerType":2,"PaxType":"CHILD","PassengerCount":"1","BaseFare":4870,"Tax":1283,"OfferedFare":6153,"PublishedFare":6625,"TDS":15,"TDSEarn":0,"TaxBR":{"MF":400,"YQ":0,"AGST":252,"MFT":72,"OT":389,"YR":170},"ApiNCM":285,"CommissionEarned":0,"FixedMarkUp":400,"GSTOnMarkUp":72,"CommDiscount":285,"AgentMarkUp":0,"Baggage":"25 Kg (01 Piece only)","CabinBaggage":"7 Kg","ProcessingAmount":0,"GSTOnProcessing":0},{"Currency":"INR","PassengerType":3,"PaxType":"INFANT","PassengerCount":"1","BaseFare":1750,"Tax":266,"OfferedFare":2016,"PublishedFare":2488,"TDS":0,"TDSEarn":0,"TaxBR":{"MF":0,"YQ":0,"AGST":96,"MFT":0,"OT":0,"YR":170},"ApiNCM":0,"CommissionEarned":0,"FixedMarkUp":400,"GSTOnMarkUp":72,"CommDiscount":0,"AgentMarkUp":0,"Baggage":"10 Kg (01 Piece only)","CabinBaggage":"7 Kg","ProcessingAmount":0,"GSTOnProcessing":0}],"tripbinfo":[],"IsFlexiPayment":false,"BookableAmount":0,"ProcessingFee":0,"ProcessingAmount":0,"GSTOnProcessing":0,"DeadLineDate":"","RewardsEarn":0,"RewardsPoints":0}},{"bookingId":"GTX17441070360833","APIBookingId":"TJS109801388567","ApiResultIndex":"R15-2-10-1213731805_1CCUATQ6E201ATQDEL6E2292~30550353883733865","FlightNumber":"6E-201","SegFlightNumberArr":"6E-201, 6E-2292","AirlineName":"Indigo","AirlineCode":"6E","IsLCC":true,"SearchTraceId":"GTX17441070360833","IsRefundable":1,"IsRefundableTxt":"Refundable","FromUTCTime":"2025-05-13T09:40","ToUTCTime":"2025-05-13T15:10","FareClass":"Economy","SourceAirportCode":"CCU","DestAirportCode":"DEL","FlightDuration":"5h 30m","StopCount":"1 Stop(s)","NoOfSeatAvailable":null,"logo":"http://local.gtxapi.com/public/AirlineLogo/6E.png","JourneyType":"2","TripType":1,"ICSourceSysId":7,"IsInternational":0,"IsPassMandatory":false,"IsPassExpiry":false,"IsPassIssue":false,"IsPassDateOfBirth":false,"isGSTMandatory":false,"isDobAdult":false,"isDobChild":false,"isDobInfant":true,"isSeatAppli":true,"isHoldAllowed":true,"isDocIdAllowedMandatory":false,"isDocIdAllowedAplicable":false,"Segments":[{"segmentid":"226","isReturnSegment":true,"arrivingnextday":false,"originAirportName":"Netaji Subhas Chandra Bose Intl","destinationAirportName":"Raja Sansi Arpt","originCityName":"Kolkata","originCountryName":"India","destinationCityName":"Amritsar","destinationCountryName":"India","destinationAirportCode":"ATQ","destinationArrTime":"2025-05-13T12:20","SegFlightNumber":"6E-201","AirlineCode":"6E","AirlineName":"IndiGo","FareClass":"R","cabinClass":"Economy","originAirportCode":"CCU","originDepTime":"2025-05-13T09:40","TripIndicator":false,"IscheckinBagInc":true,"IscabinbagInc":true,"CheckinBaggage":"15kg(01pieceonly)","CabinBaggage":"7kg","IsMealIncludes":false,"Duration":160,"StopPoint":[],"StopOver":false,"GroundTime":100,"NoOfSeatAvailable":null,"strDepartureDtTime":"09:40","strArrivalDtTime":"12:20","FlightDuration":"2h 40m","LAYOVERDuration":"1h 40m","LAYOVERCity":"Amritsar","DepTerminal":"","ArrTerminal":"","filePath":"http://local.gtxapi.com/public/AirlineLogo/6E.png","BAGGAGE":[{"symbol":"INR","Currency":"INR","key":"226","Code":"XBPE","Price":1350,"cost":1350,"Weight":"3 Kg"},{"symbol":"INR","Currency":"INR","key":"226","Code":"XBPA","Price":2250,"cost":2250,"Weight":"5 Kg"},{"symbol":"INR","Currency":"INR","key":"226","Code":"XBPB","Price":4500,"cost":4500,"Weight":"10 Kg"},{"symbol":"INR","Currency":"INR","key":"226","Code":"XBPC","Price":5630,"cost":5630,"Weight":"15 Kg"},{"symbol":"INR","Currency":"INR","key":"226","Code":"XBPD","Price":11250,"cost":11250,"Weight":"30 Kg"}],"MEAL":[{"symbol":"INR","Currency":"INR","key":"226","Code":"TCSW","Price":10,"cost":10,"Description":"Tomato Cucumber Cheese Lettuce Sandwich Combo"},{"symbol":"INR","Currency":"INR","key":"226","Code":"CJSW","Price":500,"cost":500,"Description":"Chicken Junglee Sandwich Combo"}]},{"segmentid":"227","isReturnSegment":true,"arrivingnextday":false,"originAirportName":"Raja Sansi Arpt","destinationAirportName":"Delhi Indira Gandhi Intl","originCityName":"Amritsar","originCountryName":"India","destinationCityName":"Delhi","destinationCountryName":"India","destinationAirportCode":"DEL","destinationArrTime":"2025-05-13T15:10","SegFlightNumber":"6E-2292","AirlineCode":"6E","AirlineName":"IndiGo","FareClass":"R","cabinClass":"Economy","originAirportCode":"ATQ","originDepTime":"2025-05-13T14:00","TripIndicator":1,"IscheckinBagInc":true,"IscabinbagInc":true,"CheckinBaggage":"15kg(01pieceonly)","CabinBaggage":"7kg","IsMealIncludes":false,"Duration":70,"StopPoint":[],"StopOver":false,"GroundTime":0,"NoOfSeatAvailable":null,"strDepartureDtTime":"14:00","strArrivalDtTime":"15:10","FlightDuration":"1h 10m","LAYOVERDuration":null,"LAYOVERCity":"","DepTerminal":"","ArrTerminal":"Terminal 2","filePath":"http://local.gtxapi.com/public/AirlineLogo/6E.png","BAGGAGE":[{"symbol":"INR","Currency":"INR","key":"227","Code":"XBPE","Price":0,"cost":0,"Weight":"3 Kg"},{"symbol":"INR","Currency":"INR","key":"227","Code":"XBPD","Price":0,"cost":0,"Weight":"30 Kg"},{"symbol":"INR","Currency":"INR","key":"227","Code":"XBPC","Price":0,"cost":0,"Weight":"15 Kg"},{"symbol":"INR","Currency":"INR","key":"227","Code":"XBPB","Price":0,"cost":0,"Weight":"10 Kg"},{"symbol":"INR","Currency":"INR","key":"227","Code":"XBPA","Price":0,"cost":0,"Weight":"5 Kg"}],"MEAL":[{"symbol":"INR","Currency":"INR","key":"227","Code":"TCSW","Price":10,"cost":10,"Description":"Tomato Cucumber Cheese Lettuce Sandwich Combo"},{"symbol":"INR","Currency":"INR","key":"227","Code":"CJSW","Price":500,"cost":500,"Description":"Chicken Junglee Sandwich Combo"}]}],"FairRules":{"Currency":"INR","CurrencyRate":1,"currencySysId":1,"BaseFare":11038,"Tax":3114,"intPublishedFare":14152,"PublishedFare":15568,"PublishedFareAgent":15568,"PublishedFarePerPax":5190,"OfferedFare":14152,"CommissionEarned":0,"CommDiscount":0,"TDS":0,"TDSEarn":0,"Refundable":1,"IsRefundableTxt":"Refundable","PriceID":"R15-2-10-1213731805_1CCUATQ6E201ATQDEL6E2292~30550353883733865","classOfBooking":"R","FareClass":"ECONOMY","fareIdentifier":"PUBLISHED","IsSpecialReturn":false,"colors":"#000000","SeatAvailable":null,"FixedMarkUp":1200,"GSTOnMarkUp":216,"AgentMarkUp":0,"IscheckinBagInc":true,"IscabinbagInc":true,"CheckinBaggage":"15kg(01pieceonly)","CabinBaggage":"7kg","IsMealIncludes":false,"FareBreakdown":[{"Currency":"INR","PassengerType":1,"PaxType":"ADULT","PassengerCount":"1","BaseFare":4644,"Tax":1557,"OfferedFare":6201,"PublishedFare":6673,"TDS":0,"TDSEarn":0,"TaxBR":{"MF":0,"YQ":0,"AGST":248,"MFT":0,"OT":1309,"YR":0},"ApiNCM":0,"CommissionEarned":0,"FixedMarkUp":400,"GSTOnMarkUp":72,"CommDiscount":0,"AgentMarkUp":0,"Baggage":"15 Kg (01 Piece only)","CabinBaggage":"7 Kg","ProcessingAmount":0,"GSTOnProcessing":0},{"Currency":"INR","PassengerType":2,"PaxType":"CHILD","PassengerCount":"1","BaseFare":4644,"Tax":1557,"OfferedFare":6201,"PublishedFare":6673,"TDS":0,"TDSEarn":0,"TaxBR":{"MF":0,"YQ":0,"AGST":248,"MFT":0,"OT":1309,"YR":0},"ApiNCM":0,"CommissionEarned":0,"FixedMarkUp":400,"GSTOnMarkUp":72,"CommDiscount":0,"AgentMarkUp":0,"Baggage":"15 Kg (01 Piece only)","CabinBaggage":"7 Kg","ProcessingAmount":0,"GSTOnProcessing":0},{"Currency":"INR","PassengerType":3,"PaxType":"INFANT","PassengerCount":"1","BaseFare":1750,"Tax":0,"OfferedFare":1750,"PublishedFare":2222,"TDS":0,"TDSEarn":0,"TaxBR":{"MF":0,"YQ":0,"AGST":0,"MFT":0,"OT":0,"YR":0},"ApiNCM":0,"CommissionEarned":0,"FixedMarkUp":400,"GSTOnMarkUp":72,"CommDiscount":0,"AgentMarkUp":0,"Baggage":"","CabinBaggage":"7 Kg","ProcessingAmount":0,"GSTOnProcessing":0}],"tripbinfo":[],"IsFlexiPayment":false,"BookableAmount":0,"ProcessingFee":0,"ProcessingAmount":0,"GSTOnProcessing":0,"DeadLineDate":"","RewardsEarn":0,"RewardsPoints":0}}],"FareChange":false,"FARERULE":{"fareRule":{"DEL-CCU":{"fr":[],"tfr":{"NO_SHOW":[{"policyInfo":"Non refundable (Only statutory taxes will be refunded)","st":"0","et":"8760"}],"DATECHANGE":[{"amount":3000,"policyInfo":"__nls__Changes permitted 02 Hrs before scheduled departure__nls__Change Penalty : INR 3,000/- or basic fare whichever is lower + Fare Difference","fcs":{"ARFT":0,"ARF":3000},"st":"4","et":"8760"}],"CANCELLATION":[{"amount":3000,"policyInfo":"__nls__Cancellation permitted 02 Hrs before scheduled departure__nls__Cancellation Penalty : INR 3,000/- or basic fare whichever is lower","fcs":{"ACFT":0,"ACF":3000},"st":"4","et":"8760"}],"SEAT_CHARGEABLE":[{"policyInfo":"","st":"0","et":"8760"}]}},"CCU-DEL":{"tfr":{"NO_SHOW":[{"policyInfo":"If Cancelled within 5 hrs of scheduled departure only statutory taxes will be Refunded.","st":"0","et":"5"}],"DATECHANGE":[{"amount":3250,"policyInfo":"+ Fare Difference if any","fcs":{"ARFT":0,"ARF":3250},"st":"5","et":"74"},{"amount":2750,"policyInfo":"+ Fare Difference if any","fcs":{"ARFT":0,"ARF":2750},"st":"74","et":"8760"}],"CANCELLATION":[{"amount":3500,"policyInfo":"","fcs":{"ACFT":0,"ACF":3500},"st":"5","et":"74"},{"amount":3000,"policyInfo":"","fcs":{"ACFT":0,"ACF":3000},"st":"74","et":"8760"}],"SEAT_CHARGEABLE":[{"policyInfo":"Paid Seat","st":"0","et":"8760"}]}}},"status":{"success":true,"httpStatus":200}},"SSRData":[],"tripSeatMap":[]}', 1);
// echo (json_encode($apiResponse));
// die('ddd');
} elseif ($ICSourceSysId == 3) {
$FlightData = [];
$FARERULE = [];
$FareChange = false;
$intPublishedFare = 0;
$intPublishedFareNew = 0;
if ($FlightBookingData) {
foreach ($FlightBookingData as $key => $vl) {
$intPublishedFare += $vl['FairRules']['PublishedFareAgent'];
$requestAPI = array(
'TraceId' => $vl['apiTraceId'],
'ResultIndex' => $vl['FairRules']['PriceID'],
);
$requestAPIArray[$key] = $requestAPI;
$DataS = array(
'apidata' => !empty($requestAPIOld[$key]) ? $requestAPIOld[$key] : $requestAPI,
'memberCount' => $intMemberCount,
'JourneyType' => $JourneyType,
'interNationalSearch' => $interNationalSearch,
'searchID' => $traceID,
'ICSourceSysId' => $ICSourceSysId,
'cabinClass' => $cabinClass,
'AdultCount' => $adultCount,
'ChildCount' => $childCount,
'InfantCount' => $infantCount,
'AgentMarkUp' => 0,
'APIMode' => ($this->intLoggedinAgencyId == 1) ? 1 : 0,
);
$DataS['B2B'] = $B2BSearch;
// echo '<pre>';
// print_r($DataS);
// die;
$url = GTX_API_URL . '/flight/v3/farequote';
$getData['SecurityKey'] = $SecurityKey;
$apiResponseTBO = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
$ResponseStatus = isset($apiResponseTBO['status']) ? $apiResponseTBO['status'] : false;
$ErrorMessage = isset($apiResponseTBO['message']) ? $apiResponseTBO['message'] : '';
$FlightDataTBO = isset($apiResponseTBO['results']) ? $apiResponseTBO['results'] : [];
$tripSeatMap[] = isset($apiResponseTBO['tripSeatMap']) ? $apiResponseTBO['tripSeatMap'] : [];
$FareChange = isset($apiResponseTBO['FareChange']) ? $apiResponseTBO['FareChange'] : 0;
$FARERULE[] = isset($apiResponseTBO['FARERULE']) ? $apiResponseTBO['FARERULE'] : [];
if ($FlightDataTBO) {
foreach ($FlightDataTBO as $kddd => $value) {
$intPublishedFareNew += $value['FairRules']['PublishedFareAgent'];
$FlightData[] = $value;
}
}
}
}
// if (ceil($intPublishedFare) != ceil($intPublishedFareNew)) {
// $FareChange = true;
// }
$apiResponse = ["status" => $ResponseStatus, "message" => $ErrorMessage, 'results' => $FlightData, 'FareChange' => $FareChange, 'FARERULE' => $FARERULE, 'tripSeatMap' => $tripSeatMap];
} elseif ($ICSourceSysId == 8) {
$apiResponse = ["status" => 1, "message" => 'Success', 'results' => $FlightBookingData, 'FareChange' => false, 'FARERULE' => [], 'tripSeatMap' => []];
} elseif ($ICSourceSysId == 11 || $ICSourceSysId == 13 || $ICSourceSysId == 14 || $ICSourceSysId == 20 || $ICSourceSysId == 30) {
$Contacts = !empty($this->agencyDetails['PrimaryContactNo']) ? $this->agencyDetails['PrimaryContactNo'] : '';
$requestAPIArray = $FlightBookingData;
$DataS = array(
'apidata' => [],
'requestSSR' => [],
'BookingData' => !empty($requestAPIOld) ? $requestAPIOld : $FlightBookingData,
'memberCount' => $intMemberCount,
'JourneyType' => $JourneyType,
'interNationalSearch' => $interNationalSearch,
'searchID' => $traceID,
'ICSourceSysId' => $ICSourceSysId,
'cabinClass' => $cabinClass,
'AdultCount' => $adultCount,
'ChildCount' => $childCount,
'InfantCount' => $infantCount,
'AgentMarkUp' => 0,
'Contacts' => $Contacts,
'APIMode' => ($this->intLoggedinAgencyId == 1) ? 1 : 0,
);
$DataS['B2B'] = $B2BSearch;
$url = GTX_API_URL . '/flight/v3/farequote';
$getData['SecurityKey'] = $SecurityKey;
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
}
// echo '<pre>';
// print_r($apiResponse);
// die('ddd');
$ResponseStatus = isset($apiResponse['status']) ? $apiResponse['status'] : false;
$ErrorMessage = isset($apiResponse['message']) ? $apiResponse['message'] : '';
if ($ResponseStatus == 1) {
$FlightData = isset($apiResponse['results']) ? $apiResponse['results'] : '';
$FareChange = isset($apiResponse['FareChange']) ? (bool)$apiResponse['FareChange'] : '';
$FARERULE = isset($apiResponse['FARERULE']) ? $apiResponse['FARERULE'] : '';
$tripSeatMap = isset($apiResponse['tripSeatMap']) ? $apiResponse['tripSeatMap'] : [];
if ($adultCount > 0) {
$intPaxCount = 1;
for ($i = 1; $i <= $adultCount; $i++) {
$SavedData = (isset($customerSaved[$i - 1]) && !empty($customerSaved[$i - 1])) ? $customerSaved[$i - 1] : [];
$memberDetails[$i]['index'] = $i;
$memberDetails[$i]['PaxCount'] = $intPaxCount;
$memberDetails[$i]['PaxType'] = 1;
$memberDetails[$i]['pax'] = 'ADULT';
$memberDetails[$i]['AgeR'] = '12 yrs+';
$memberDetails[$i]['cid'] = 0;
$memberDetails[$i]['fname'] = (isset($SavedData['firstname']) && !empty($SavedData['firstname'])) ? $SavedData['firstname'] : '';
$memberDetails[$i]['lname'] = (isset($SavedData['lastname']) && !empty($SavedData['lastname'])) ? $SavedData['lastname'] : '';
$memberDetails[$i]['name'] = '';
$memberDetails[$i]['title'] = (isset($SavedData['salution']) && !empty($SavedData['salution'])) ? $ARR_SALUTIONTBO[$SavedData['salution']] : '';
$memberDetails[$i]['dob'] = (isset($SavedData['dateofbirth']) && !empty($SavedData['dateofbirth'])) ? date('d/m/Y', strtotime($SavedData['dateofbirth'])) : '';
$memberDetails[$i]['FFAirlineCode'] = (isset($FlightData[0]['AirlineCode']) && !empty($FlightData[0]['AirlineCode'])) ? $FlightData[0]['AirlineCode'] : '';
$memberDetails[$i]['FFNumber'] = '';
$memberDetails[$i]['passno'] = (isset($SavedData['passportno']) && !empty($SavedData['passportno'])) ? $SavedData['passportno'] : '';
$memberDetails[$i]['passisse'] = (isset($SavedData['passporIssue']) && !empty($SavedData['passporIssue'])) ? date('d/m/Y', strtotime($SavedData['passporIssue'])) : '';
$memberDetails[$i]['passexp'] = (isset($SavedData['passportnoexpiry']) && !empty($SavedData['passportnoexpiry'])) ? date('d/m/Y', strtotime($SavedData['passportnoexpiry'])) : '';
$memberDetails[$i]['city'] = (isset($SavedData['city']) && !empty($SavedData['city'])) ? $SavedData['city'] : '';
$memberDetails[$i]['address'] = (isset($SavedData['address']) && !empty($SavedData['address'])) ? $SavedData['address'] : '';
$memberDetails[$i]['city_id'] = (isset($SavedData['city_id']) && !empty($SavedData['city_id'])) ? $SavedData['city_id'] : '';
$memberDetails[$i]['country_id'] = (isset($SavedData['country_id']) && !empty($SavedData['country_id'])) ? $SavedData['country_id'] : '';
$memberDetails[$i]['passnational'] = (isset($SavedData['PassportNationality']) && !empty($SavedData['PassportNationality'])) ? $SavedData['PassportNationality'] : 'IN';
$memberDetails[$i]['isdobr'] = (isset($FlightData[0]['isDobAdult']) && !empty($FlightData[0]['isDobAdult'])) ? $FlightData[0]['isDobAdult'] : $FlightData[0]['IsPassDateOfBirth'];
$memberDetails[$i]['IsPassM'] = isset($FlightData[0]['IsPassMandatory']) ? $FlightData[0]['IsPassMandatory'] : false;
$memberDetails[$i]['IsDocIdM'] = isset($FlightData[0]['isDocIdAllowedMandatory']) ? $FlightData[0]['isDocIdAllowedMandatory'] : false;
$memberDetails[$i]['addonns'] = true;
$memberDetails[$i]['selectedBad'] = 'NA@NA@@0';
$memberDetails[$i]['selectedMeal'] = 'NA@NA@@0';
$memberDetails[$i]['docid'] = (isset($SavedData['docid']) && !empty($SavedData['docid'])) ? $SavedData['docid'] : '';
$memberDetails[$i]['checked'] = ($i == 1) ? true : false;
$memberDetails[$i]['ICSourceSysId'] = $ICSourceSysId;
$intPaxCount++;
}
}
if ($childCount > 0) {
$intPaxCount = 1;
for ($kk = $i; $kk <= ($childCount + $adultCount); $kk++) {
$memberDetails[$kk]['index'] = $kk;
$memberDetails[$kk]['PaxCount'] = $intPaxCount;
$memberDetails[$kk]['PaxType'] = 2;
$memberDetails[$kk]['pax'] = 'CHILD';
$memberDetails[$kk]['AgeR'] = '2-12 Yrs';
$memberDetails[$kk]['cid'] = 0;
$memberDetails[$kk]['fname'] = (isset($SavedData['firstname']) && !empty($SavedData['firstname'])) ? $SavedData['firstname'] : '';
$memberDetails[$kk]['lname'] = (isset($SavedData['lastname']) && !empty($SavedData['lastname'])) ? $SavedData['lastname'] : '';
$memberDetails[$kk]['name'] = '';
$memberDetails[$kk]['title'] = (isset($SavedData['salution']) && !empty($SavedData['salution'])) ? $ARR_SALUTIONTBO[$SavedData['salution']] : '';
$memberDetails[$kk]['dob'] = (isset($SavedData['dateofbirth']) && !empty($SavedData['dateofbirth'])) ? date('d/m/Y', strtotime($SavedData['dateofbirth'])) : '';
$memberDetails[$kk]['FFAirlineCode'] = (isset($FlightData[0]['AirlineCode']) && !empty($FlightData[0]['AirlineCode'])) ? $FlightData[0]['AirlineCode'] : '';
$memberDetails[$kk]['FFNumber'] = '';
$memberDetails[$kk]['passno'] = (isset($SavedData['passportno']) && !empty($SavedData['passportno'])) ? $SavedData['passportno'] : '';
$memberDetails[$kk]['passisse'] = (isset($SavedData['passporIssue']) && !empty($SavedData['passporIssue'])) ? date('d/m/Y', strtotime($SavedData['passporIssue'])) : '';
$memberDetails[$kk]['passexp'] = (isset($SavedData['passportnoexpiry']) && !empty($SavedData['passportnoexpiry'])) ? date('d/m/Y', strtotime($SavedData['passportnoexpiry'])) : '';
$memberDetails[$kk]['city'] = '';
$memberDetails[$kk]['address'] = '';
$memberDetails[$kk]['passnational'] = (isset($SavedData['PassportNationality']) && !empty($SavedData['PassportNationality'])) ? $SavedData['PassportNationality'] : 'IN';
$memberDetails[$kk]['isdobr'] = (isset($FlightData[0]['isDobChild']) && !empty($FlightData[0]['isDobChild'])) ? $FlightData[0]['isDobChild'] : $FlightData[0]['IsPassDateOfBirth'];
$memberDetails[$kk]['IsPassM'] = isset($FlightData[0]['IsPassMandatory']) ? $FlightData[0]['IsPassMandatory'] : false;
$memberDetails[$kk]['addonns'] = true;
$memberDetails[$kk]['IsDocIdM'] = false;
$memberDetails[$kk]['selectedBad'] = 'NA@NA@@0';
$memberDetails[$kk]['selectedMeal'] = 'NA@NA@@0';
$memberDetails[$kk]['checked'] = false;
$memberDetails[$kk]['ICSourceSysId'] = $ICSourceSysId;
$intPaxCount++;
}
}
if ($infantCount > 0) {
$intPaxCount = 1;
if (isset($kk)) {
$kk = $kk;
} else {
$kk = $i;
}
for ($kkk = $kk; $kkk <= ($adultCount + $childCount + $infantCount); $kkk++) {
$memberDetails[$kkk]['index'] = $kkk;
$memberDetails[$kkk]['PaxCount'] = $intPaxCount;
$memberDetails[$kkk]['PaxType'] = 3;
$memberDetails[$kkk]['pax'] = 'INFANT';
$memberDetails[$kkk]['AgeR'] = '< 2 Yrs';
$memberDetails[$kkk]['cid'] = 0;
$memberDetails[$kkk]['fname'] = (isset($SavedData['firstname']) && !empty($SavedData['firstname'])) ? $SavedData['firstname'] : '';
$memberDetails[$kkk]['lname'] = (isset($SavedData['lastname']) && !empty($SavedData['lastname'])) ? $SavedData['lastname'] : '';
$memberDetails[$kkk]['title'] = (isset($SavedData['salution']) && !empty($SavedData['salution'])) ? $ARR_SALUTIONTBO[$SavedData['salution']] : '';
$memberDetails[$kkk]['dob'] = (isset($SavedData['dateofbirth']) && !empty($SavedData['dateofbirth'])) ? date('d/m/Y', strtotime($SavedData['dateofbirth'])) : '';
$memberDetails[$kkk]['FFAirlineCode'] = '';
$memberDetails[$kkk]['FFNumber'] = '';
$memberDetails[$kkk]['passno'] = (isset($SavedData['passportno']) && !empty($SavedData['passportno'])) ? $SavedData['passportno'] : '';
$memberDetails[$kkk]['passisse'] = (isset($SavedData['passporIssue']) && !empty($SavedData['passporIssue'])) ? date('d/m/Y', strtotime($SavedData['passporIssue'])) : '';
$memberDetails[$kkk]['passexp'] = (isset($SavedData['passportnoexpiry']) && !empty($SavedData['passportnoexpiry'])) ? date('d/m/Y', strtotime($SavedData['passportnoexpiry'])) : '';
$memberDetails[$kkk]['address'] = '';
$memberDetails[$kkk]['city'] = '';
$memberDetails[$kkk]['passnational'] = (isset($SavedData['PassportNationality']) && !empty($SavedData['PassportNationality'])) ? $SavedData['PassportNationality'] : 'IN';
$memberDetails[$kkk]['isdobr'] = (isset($FlightData[0]['isDobInfant']) && !empty($FlightData[0]['isDobInfant'])) ? $FlightData[0]['isDobInfant'] : $FlightData[0]['IsPassDateOfBirth'];
$memberDetails[$kkk]['IsPassM'] = isset($FlightData[0]['IsPassMandatory']) ? $FlightData[0]['IsPassMandatory'] : false;
$memberDetails[$kkk]['addonns'] = false;
$memberDetails[$kkk]['selectedBad'] = 'NA@NA@@0';
$memberDetails[$kkk]['selectedMeal'] = 'NA@NA@@0';
$memberDetails[$kkk]['checked'] = false;
$memberDetails[$kkk]['ICSourceSysId'] = $ICSourceSysId;
$intPaxCount++;
}
}
$BaseFare = 0;
$Taxesfee = 0;
$CommDiscount = 0;
$TotalPay = 0;
$ServiceFee__ = 0;
$AirlineTax = 0;
$FuelSurcharge = 0;
$GSTOnMarkUp_ = 0;
$FixedMarkUp_ = 0;
$CommissionEarned_ = 0;
$ExtraMarkup_ = 0;
$ExtraMarkupOnGST_ = 0;
$TDSEarn_ = 0;
$FlightDataNew = [];
if ($FlightData) {
foreach ($FlightData as $key => $value) {
$ExtraMarkup = isset($ExtraMarkupArray[$key]['ExtraMarkup']) ? $ExtraMarkupArray[$key]['ExtraMarkup'] : 0;
$ExtraMarkupOnGST = isset($ExtraMarkupArray[$key]['ExtraMarkupOnGST']) ? $ExtraMarkupArray[$key]['ExtraMarkupOnGST'] : 0;
$ExtraMarkup_ += $ExtraMarkup;
$ExtraMarkupOnGST_ += $ExtraMarkupOnGST;
$FlightDataNew[$key] = $value;
$FlightDataNew[$key]['FairRules']['FixedMarkUp'] = $value['FairRules']['FixedMarkUp'] + $ExtraMarkup;
$FlightDataNew[$key]['FairRules']['GSTOnMarkUp'] = $value['FairRules']['GSTOnMarkUp'] + $ExtraMarkupOnGST;
$ExtraMarkupBR = ($ExtraMarkup / count($value['FairRules']['FareBreakdown']));
$ExtraMarkupOnGSTBR = ($ExtraMarkupOnGST / count($value['FairRules']['FareBreakdown']));
$FareBreakdownNew = [];
foreach ($value['FairRules']['FareBreakdown'] as $brkey => $FareBreakdown) {
$FareBreakdownNew[$brkey] = $FareBreakdown;
$FareBreakdownNew[$brkey]['FixedMarkUp'] = $FareBreakdown['FixedMarkUp'] + $ExtraMarkupBR;
$FareBreakdownNew[$brkey]['GSTOnMarkUp'] = $FareBreakdown['GSTOnMarkUp'] + $ExtraMarkupOnGSTBR;
// echo "<pre>";
// print_r(($FareBreakdown));
// echo "</pre>";
$BaseFare += isset($FareBreakdown['BaseFare']) ? ($FareBreakdown['BaseFare']) : 0;
$BaseFare_ = isset($FareBreakdown['BaseFare']) ? ($FareBreakdown['BaseFare']) : 0;
$TDSEarn = isset($FareBreakdown['TDSEarn']) ? ($FareBreakdown['TDSEarn']) : 0;
$FixedMarkUp = isset($FareBreakdown['FixedMarkUp']) ? ($FareBreakdown['FixedMarkUp'] + $ExtraMarkupBR) : 0;
$GSTOnMarkUp = isset($FareBreakdown['GSTOnMarkUp']) ? ($FareBreakdown['GSTOnMarkUp'] + $ExtraMarkupOnGSTBR) : 0;
$CommissionEarned = isset($FareBreakdown['CommissionEarned']) ? ($FareBreakdown['CommissionEarned']) : 0;
$CommDiscount += isset($FareBreakdown['CommDiscount']) ? ($FareBreakdown['CommDiscount']) : 0;
$Tax = isset($FareBreakdown['Tax']) ? ($FareBreakdown['Tax']) : 0;
$YQ = isset($FareBreakdown['TaxBR']['YQ']) ? ($FareBreakdown['TaxBR']['YQ']) : 0;
$Taxesfee += ($FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
$TotalPay += ($BaseFare_ + $FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
$ServiceFee__ += ($FixedMarkUp + $GSTOnMarkUp);
$AirlineTax += ($Tax);
$FuelSurcharge += ($YQ);
$GSTOnMarkUp_ += ($GSTOnMarkUp);
$FixedMarkUp_ += ($FixedMarkUp);
$CommissionEarned_ += ($CommissionEarned);
$TDSEarn_ += ($TDSEarn);
}
$FlightDataNew[$key]['FairRules']['FareBreakdown'] = $FareBreakdownNew;
}
}
$fare = [
'Currency' => isset($FlightData[0]['FairRules']['Currency']) ? trim($FlightData[0]['FairRules']['Currency']) : 'INR',
'BaseFare' => round($BaseFare, 2),
'Taxesfee' => round($Taxesfee, 2),
'CommDiscount' => round($CommDiscount, 2),
'CommissionEarned' => round($CommissionEarned_, 2),
'TDSEarn' => round($TDSEarn_, 2),
'TotalPay' => round($TotalPay, 2),
'AirlineTax' => round($AirlineTax, 2),
'FuelSurcharge' => round($FuelSurcharge, 2),
'FixedMarkUp' => round($FixedMarkUp_, 2),
'GSTOnMarkUp' => round($GSTOnMarkUp_, 2),
'ExtraMarkup' => round($ExtraMarkup_, 2),
'ExtraMarkupOnGST' => round($ExtraMarkupOnGST_, 2),
'TotalExtraMarkup' => round(($ExtraMarkup_ + $ExtraMarkupOnGST_), 2),
'MealPrice' => 0,
'BagPrice' => 0,
'SeatPrice' => 0,
'TotalSSR' => 0,
];
// echo '<pre>';
// print_r($FlightDataNew);
// echo '<pre>';
// print_r($fare);
// die;
$response = array(
'success' => true,
'message' => $ErrorMessage,
'fareData' => $fare,
'arrFlightData' => $FlightDataNew,
'memberDetails' => array_values($memberDetails),
'FareChange' => $FareChange,
'TotalPay' => number_format($TotalPay, 2),
'CurrencyTitle' => $this->CurrencyTitle,
'departureDates' => $departureDates,
'departureMonthInfant' => $departureMonthInfant,
'departureDayInfant' => $departureDayInfant,
'departureMonthChild' => $departureMonthChild,
'departureDayChild' => $departureDayChild,
);
$arrUrlData['FlightBookingData'] = $FlightDataNew;
$arrUrlData['FlightBookingDataOld'] = $FlightBookingData;
$arrUrlData['tripSeatMap'] = $tripSeatMap;
$arrUrlData['requestAPI'] = !empty($requestAPIOld) ? $requestAPIOld : $requestAPIArray;;
$arrUrlData['FARERULE'] = $FARERULE;
$arrUrlData['fare'] = $fare;
$tempData = array(
'TraceId' => $traceID,
'TPSysId' => $TPSysId,
'APIBookingData' => json_encode($arrUrlData),
);
$objFlight->deleteFlightTempData($traceID);
$objFlight->insertFlightTempData($tempData);
echo json_encode($response);
exit;
// echo "<pre>";
// print_r($tempData);
// die;
} else {
$response = array('success' => false, 'message' => $ErrorMessage, 'apiResponse' => $apiResponse);
echo json_encode($response);
exit;
}
}
}
public function savePassengerDetailsAction()
{
if ($this->getRequest()->isXmlHttpRequest()) {
$objFlight = new Travel_Model_TblFlight();
$this->_helper->layout->disableLayout();
$post = json_decode(file_get_contents('php://input'), true);
parse_str($post['data'], $data);
$memberDetails = isset($post['memberDetails']) ? $post['memberDetails'] : [];
$selectedSeatSession = isset($post['selectedSeatSession']) ? $post['selectedSeatSession'] : [];
$SelectedSeats = isset($post['SelectedSeats']) ? $post['SelectedSeats'] : [];
$FlightTempData = $objFlight->GetFlightTempData($post['searchids']);
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
$FlightBooking = $arrUrlData['FlightBookingData'];
$FARERULE = (isset($arrUrlData['FARERULE']) && !empty($arrUrlData['FARERULE'])) ? $arrUrlData['FARERULE'] : '';
$tripSeatMap = (isset($arrUrlData['tripSeatMap']) && !empty($arrUrlData['tripSeatMap'])) ? $arrUrlData['tripSeatMap'][0] : '';
$sessionFlightSearchParams = (isset($arrUrlData['sessionFlightSearchParams']) && !empty($arrUrlData['sessionFlightSearchParams'])) ? $arrUrlData['sessionFlightSearchParams'] : '';
$searchId = $SearchTraceId = $FlightBooking[0]['SearchTraceId'];
$ICSourceSysId = $FlightBooking[0]['ICSourceSysId'];
$departureDates = isset($FlightBooking[0]['FromUTCTime']) ? date('Y-m-d', strtotime($FlightBooking[0]['FromUTCTime'])) : '';
$ResponseStatus = isset($tripSeatMap['status']['success']) ? $tripSeatMap['status']['success'] : false;
$ErrorMessage = (isset($tripSeatMap['message']) && !empty($tripSeatMap['message'])) ? $tripSeatMap['message'] : 'Record Not Found';
$apiResponse['tripSeatMap'] = isset($tripSeatMap['tripSeatMap']) ? $tripSeatMap['tripSeatMap'] : [];
$apiResponse['DataSet'] = isset($tripSeatMap['tripSeatMap']['DataSet']) ? $tripSeatMap['tripSeatMap']['DataSet'] : [];
$apiResponse['status'] = $ResponseStatus;
$DataSet = isset($apiResponse['DataSet']) ? $apiResponse['DataSet'] : [];
$CurrencyTitle = !empty($this->CurrencyTitle) ? trim($this->CurrencyTitle) : 'INR';
$CurrencyRate = !empty($this->CurrencyRate) ? $this->CurrencyRate : 1;
$countryCodeISO = strtoupper($data['countryCodeISO']);
$countrycode = $data['countrycode'];
$mobileNumber = $data['mobile_number'];
$email_id = $data['email_id'];
$airline_number = isset($data['airline_number']) ? $data['airline_number'] : '';
$airline_email = isset($data['airline_email']) ? $data['airline_email'] : '';
$leadId = $sessionFlightSearchParams['editLeadId'];
$objFlightProposal = new Travel_Model_TblFlightProposal();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$arrAgencyDetails = $this->view->arrAgencyDetails = $objFlightProposal->getProposalAgencyDetails($leadId, 'query');
$AgencySysId = $this->intLoggedinAgencyId = $arrAgencyDetails['AgencySysId'];
$AgentSysId = $arrAgencyDetails['AgentSysId'];
$getAgencyDetail = $crmcustomerObj->GetAgencyDetailById($AgencySysId);
$SecurityKey = isset($getAgencyDetail['SecurityKey']) ? $getAgencyDetail['SecurityKey'] : 0;
if (empty($mobileNumber)) {
$response = array('success' => false, 'message' => 'Please enter mobile number.', 'index' => 'airline_number');
echo json_encode($response);
exit;
}
if (strlen($mobileNumber) != 10 && strlen($mobileNumber) != 11) {
$response = array('success' => false, 'message' => 'Please enter a valid mobile number.', 'index' => 'mobile_number');
echo json_encode($response);
exit;
}
if (empty($email_id)) {
$response = array('success' => false, 'message' => 'Please enter Email ID.', 'index' => 'email_id');
echo json_encode($response);
exit;
}
if (!filter_var($email_id, FILTER_VALIDATE_EMAIL)) {
$msg = "Email address is not valid.";
$response = array('success' => false, 'message' => $msg, 'index' => 'email_id');
echo json_encode($response);
exit;
}
$paxArray = [];
$memberData = [];
if ($memberDetails) {
foreach ($memberDetails as $i => $value) {
$paxType = $value['PaxType'];
$pax = $value['pax'];
$isdobr = $value['isdobr'];
$IsPassM = $value['IsPassM'];
$firstName = $fname = $data['passenger-firstname-' . $i];
$lastName = $data['passenger-lastname-' . $i];
$relation = $data['relation-' . $i];
$salutation = $data['passenger-salutation-' . $i];
$cityName = ($data['passenger-city-name-0']) ? $data['passenger-city-name-0'] : '';
$CitySysId = ($data['passenger-city-1']) ? $data['passenger-city-1'] : 0;
$passengerCountry = ($data['passenger-country-0']) ? $data['passenger-country-0'] : 0;
$passengerAddress = ($data['passenger-address-0']) ? $data['passenger-address-0'] : '';
$passengerDob = isset($data['passenger-dob-' . $i]) ? $data['passenger-dob-' . $i] : '';
$nationality = isset($data['passenger-nationality-' . $i]) ? $data['passenger-nationality-' . $i] : '';
$passengerPassportNo = isset($data['passenger-PassportNo-' . $i]) ? $data['passenger-PassportNo-' . $i] : '';
$PassportExpiry = isset($data['passenger-PassportExpiry-' . $i]) ? $data['passenger-PassportExpiry-' . $i] : '';
$passporIssue = isset($data['passenger-passporIssue-' . $i]) ? $data['passenger-passporIssue-' . $i] : '';
$passengerDob = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($passengerDob, 'd/m/y');
$passporIssue = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($passporIssue, 'd/m/y');
$PassportExpiry = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($PassportExpiry, 'd/m/y');
$paxArray[] = ucfirst(trim($firstName)) . ' ' . ucfirst(trim($lastName));
$memberData[$i] = $value;
$memberData[$i]['relation'] = $relation;
$memberData[$i]['title'] = $salutation;
$memberData[$i]['passno'] = $passengerPassportNo;
$memberData[$i]['passisse'] = $passporIssue;
$memberData[$i]['passexp'] = $PassportExpiry;
$memberData[$i]['passnational'] = $nationality;
$memberData[$i]['fname'] = $firstName;
$memberData[$i]['lname'] = $lastName;
$memberData[$i]['city'] = $cityName;
$memberData[$i]['address'] = $passengerAddress;
$memberData[$i]['CountrySysId'] = $passengerCountry;
$memberData[$i]['CitySysId'] = $CitySysId;
$memberData[$i]['dob'] = $passengerDob;
$memberData[$i]['countrycode'] = $countrycode;
$memberData[$i]['countryCodeISO'] = $countryCodeISO;
if (empty($salutation)) {
$response = array('success' => false, 'message' => 'Please select title.', 'index' => 'passenger-salutation-' . $i);
echo json_encode($response);
exit;
}
if (empty($firstName)) {
$response = array('success' => false, 'message' => 'Please enter first name.', 'index' => 'passenger-firstname-' . $i);
echo json_encode($response);
exit;
}
if (empty($lastName)) {
$response = array('success' => false, 'message' => 'Please enter last name.', 'index' => 'passenger-lastname-' . $i);
echo json_encode($response);
exit;
}
if (strlen(trim($firstName)) < 2) {
$response = array('success' => false, 'message' => 'Length of first name should be between 2 to 32 alphabets for passenger.', 'index' => 'passenger-firstname-' . $i);
echo json_encode($response);
exit;
}
if (strlen(trim($lastName)) < 2) {
$response = array('success' => false, 'message' => 'Length of last name should be between 2 to 32 alphabets for passenger.', 'index' => 'passenger-lastname-' . $i);
echo json_encode($response);
exit;
}
if (empty($cityName)) {
$response = array('success' => false, 'message' => 'Please enter city name.', 'index' => 'passenger-city-name-0');
echo json_encode($response);
exit;
}
// if (empty($CitySysId)) {
// $response = array('success' => false, 'message' => 'Please enter valid city name.', 'index' => 'passenger-city-name-0');
// echo json_encode($response);
// exit;
// }
if (empty($passengerAddress)) {
$response = array('success' => false, 'message' => 'Please enter address.', 'index' => 'passenger-address-0');
echo json_encode($response);
exit;
}
if ($isdobr == 1 && $paxType == 1) {
if (empty($passengerDob) && ($passengerDob == '1900-01-01' || $passengerDob == '00/00/0000' || $passengerDob == '____-__-__')) {
$response = array('success' => false, 'message' => 'Please enter ' . $pax . ' date of birth.', 'index' => 'passenger-dob-' . $i);
echo json_encode($response);
exit;
}
$AdultAge = date_diff(date_create($passengerDob), date_create($departureDates))->y;
if ($AdultAge < 12) {
$response = array('success' => false, 'message' => " " . $pax . " age should be greater than 12 years. ", 'index' => 'passenger-dob-' . $i);
echo json_encode($response);
exit;
}
}
if ($isdobr == 1 && $paxType == 2) {
if (empty($passengerDob) && ($passengerDob == '1900-01-01' || $passengerDob == '00/00/0000' || $passengerDob == '____-__-__')) {
$response = array('success' => false, 'message' => 'Please enter ' . $pax . ' date of birth.', 'index' => 'passenger-dob-' . $i);
echo json_encode($response);
exit;
}
$childAge = date_diff(date_create($passengerDob), date_create($departureDates))->y;
if ($childAge < 2 || $childAge >= 12) {
$response = array('success' => false, 'message' => " " . $pax . " age should be greater than 12 years. ", 'index' => 'passenger-dob-' . $i);
echo json_encode($response);
exit;
}
}
if ($isdobr == 1 && $paxType == 3) {
if (empty($passengerDob) && ($passengerDob == '1900-01-01' || $passengerDob == '00/00/0000' || $passengerDob == '____-__-__')) {
$response = array('success' => false, 'message' => 'Please enter ' . $pax . ' date of birth.', 'index' => 'passenger-dob-' . $i);
echo json_encode($response);
exit;
}
$infantAge = date_diff(date_create($passengerDob), date_create($departureDates))->y;
if ($infantAge >= 2) {
$response = array('success' => false, 'message' => " " . $pax . " age should be greater than 12 years. ", 'index' => 'passenger-dob-' . $i);
echo json_encode($response);
exit;
}
}
if ($IsPassM == 1) {
if (empty($passengerPassportNo)) {
$response = array('success' => false, 'message' => 'Please enter passenger passport no.', 'index' => 'passenger-PassportNo-' . $i);
echo json_encode($response);
exit;
}
if (empty($nationality)) {
$response = array('success' => false, 'message' => 'Please select Nationality.', 'index' => 'passenger-nationality-' . $i);
echo json_encode($response);
exit;
}
if (empty($passporIssue) || ($passporIssue == '1900-01-01' || $passporIssue == '00/00/0000' || $passporIssue == '____-__-__')) {
$response = array('success' => false, 'message' => 'Please enter passport issue date.', 'index' => 'passenger-passporIssue-' . $i);
echo json_encode($response);
exit;
}
if (empty($PassportExpiry) || ($PassportExpiry == '1900-01-01' || $PassportExpiry == '00/00/0000' || $PassportExpiry == '____-__-__')) {
$response = array('success' => false, 'message' => 'Please enter passport expiry date.', 'index' => 'passenger-PassportExpiry-' . $i);
echo json_encode($response);
exit;
}
}
}
}
if (array_diff_assoc($paxArray, array_unique($paxArray))) {
$response = array('success' => false, 'message' => " Any two passengers can't have same name.", 'index' => '');
echo json_encode($response);
exit;
}
$isgstapply = isset($data['isgstapply']) ? trim($data['isgstapply']) : 0;
$gstnnumber = isset($data['gstnnumber']) ? trim($data['gstnnumber']) : '';
$companyname = isset($data['companyname']) ? trim($data['companyname']) : '';
$gstemail = isset($data['gstemail']) ? trim($data['gstemail']) : '';
$gstphone = isset($data['gstphone']) ? trim($data['gstphone']) : '';
$gstaddress = isset($data['gstaddress']) ? trim($data['gstaddress']) : '';
$gststate = isset($data['gststate']) ? trim($data['gststate']) : '';
$selectedBag = isset($post['SelectedBags']) ? $post['SelectedBags'] : [];
$selectedMeal = isset($post['SelectedMeals']) ? $post['SelectedMeals'] : [];
$selectedSeatSession = isset($post['selectedSeatSession']) ? $post['selectedSeatSession'] : [];
$gstData = array(
'GstNumber' => $gstnnumber,
'GstCompany' => $companyname,
'GstEmail' => $gstemail,
'GstPhone' => $gstphone,
'GstAddress' => $gstaddress,
'GstState' => $gststate,
);
$intCustomerSysId = isset($data['customerId']) ? trim($data['customerId']) : '';
$AgencySysId = isset($sessionFlightSearchParams['AgencySysId']) ? $sessionFlightSearchParams['AgencySysId'] : '';
$B2BType = isset($sessionFlightSearchParams['B2BType']) ? $sessionFlightSearchParams['B2BType'] : 0;
$editLeadId = isset($sessionFlightSearchParams['editLeadId']) ? $sessionFlightSearchParams['editLeadId'] : '';
$adultCount = isset($sessionFlightSearchParams['adults']) ? $sessionFlightSearchParams['adults'] : 0;
$childCount = isset($sessionFlightSearchParams['child']) ? $sessionFlightSearchParams['child'] : 0;
$infantCount = isset($sessionFlightSearchParams['infant']) ? $sessionFlightSearchParams['infant'] : 0;
$route = $JourneyType = isset($sessionFlightSearchParams['route']) ? $sessionFlightSearchParams['route'] : '';
$interNationalSearch = isset($sessionFlightSearchParams['interNationalSearch']) ? $sessionFlightSearchParams['interNationalSearch'] : '';
$totalPassengers = $adultCount + $childCount + $infantCount;
$departure_dates_string = $sessionFlightSearchParams['departure_dates'];
$return_dates_string = $sessionFlightSearchParams['return_dates'];
$oneway_origin_text = isset($sessionFlightSearchParams['from']) ? $sessionFlightSearchParams['from'] : $sessionFlightSearchParams['sourceCityText'];
$oneway_destination_text = isset($sessionFlightSearchParams['to']) ? $sessionFlightSearchParams['to'] : $sessionFlightSearchParams['destinationCityText'];
$flight_class = $sessionFlightSearchParams['flight_class'];
$roomjson = array();
$roomjson[1]['route'] = $route;
$roomjson[1]['Adult'] = $adultCount;
$roomjson[1]['Child'] = $childCount;
$roomjson[1]['Infant'] = $infantCount;
$roomjson[1]['bedtype'] = '';
$roomjson[1]['departuredate'] = $departure_dates_string;
$roomjson[1]['returndate'] = $return_dates_string;
$roomjson[1]['fromaircode'] = $oneway_origin_text;
$roomjson[1]['toaircode'] = $oneway_destination_text;
$roomjson[1]['airclass'] = $flight_class;
$FLData = [];
$BaggageArr = [];
$MealArr = [];
$segment_ssr = [];
$customer = [];
$baggageByPax = [];
$Sectors = [];
$BaseFare = 0;
$PublishedFare = 0;
$AgencyMarkUpINT_ = 0;
$AgencyMarkUpGSTINT_ = 0;
$CommissionEarnedAPI = 0;
if ($FlightBooking) {
foreach ($FlightBooking as $k => $value) {
$BagPrice = 0;
$MealPrice = 0;
$SeatPrice = 0;
$FareBreakdown_ = [];
$GrossAmount = 0;
$AgentMarkUp = 0;
$TotalCommDiscount = 0;
foreach ($value['FairRules']['FareBreakdown'] as $valueB) {
// echo '<pre>';print_r($valueB);
$baggageByPax[$valueB['PassengerType']]['Baggage'] = $valueB['Baggage'];
$baggageByPax[$valueB['PassengerType']]['CabinBaggage'] = $valueB['CabinBaggage'];
$FareBreakdown_[] = array(
"Currency" => $valueB['Currency'],
"PassengerCount" => $valueB['PassengerCount'],
"PassengerType" => $valueB['PassengerType'],
"BaseFare" => $valueB['BaseFare'],
"Tax" => isset($valueB['Tax']) ? ($valueB['Tax']) : (($valueB['TaxIN'])),
"OfferedFare" => ($valueB['OfferedFare']) ? $valueB['OfferedFare'] : 0,
"TotalFare" => $valueB['PublishedFare'],
"PublishedFare" => $valueB['PublishedFare'],
"TDSEarn" => $valueB['TDSEarn'],
"MF" => isset($valueB['TaxBR']['MF']) ? $valueB['TaxBR']['MF'] : $valueB['MF'],
"YQ" => isset($valueB['TaxBR']['YQ']) ? $valueB['TaxBR']['YQ'] : 0,
"AGST" => isset($valueB['TaxBR']['AGST']) ? $valueB['TaxBR']['AGST'] : $valueB['AGST'],
"MFT" => isset($valueB['TaxBR']['MFT']) ? $valueB['TaxBR']['MFT'] : $valueB['MFT'],
"OT" => isset($valueB['TaxBR']['OT']) ? $valueB['TaxBR']['OT'] : (($valueB['OT'])),
"YR" => isset($valueB['TaxBR']['YR']) ? $valueB['TaxBR']['YR'] : $valueB['YR'],
"CommissionEarned" => $valueB['CommissionEarned'],
"FixedMarkUp" => ($valueB['FixedMarkUp']) ? $valueB['FixedMarkUp'] : 0,
"GSTOnMarkUp" => ($valueB['GSTOnMarkUp']) ? $valueB['GSTOnMarkUp'] : 0,
"couponVal" => isset($valueB['couponVal']) ? $valueB['couponVal'] : 0,
"CommDiscount" => $valueB['CommDiscount'],
"AgentMarkUp" => isset($valueB['AgentMarkUp']) ? (($valueB['AgentMarkUp'])) : 0
);
}
$couponApply = isset($value['FairRules']['couponApply']) ? $value['FairRules']['couponApply'] : 0;
$couponVal = 0;
if ($couponApply == 1) {
$couponVal = isset($value['FairRules']['couponVal']) ? $value['FairRules']['couponVal'] : 0;
}
$BaseFare += (($value['FairRules']['BaseFare'] + $value['FairRules']['Tax']) - $couponVal);
$PublishedFare += ($value['FairRules']['PublishedFare'] - $couponVal);
$AgencyMarkUpINT_ += $value['FairRules']['FixedMarkUp'];
$AgencyMarkUpGSTINT_ += $value['FairRules']['GSTOnMarkUp'];
$CommissionEarnedAPI += ($value['FairRules']['CommissionEarned'] + $value['FairRules']['TDSEarn']);
$fareRuless = array(
"Currency" => $value['FairRules']['Currency'],
"BaseFare" => $value['FairRules']['BaseFare'],
"Tax" => isset($value['FairRules']['Tax']) ? (($value['FairRules']['Tax'])) : 0,
"PublishedFare" => ($value['FairRules']['PublishedFare']) ? $value['FairRules']['PublishedFare'] : 0,
"OfferedFare" => ($value['FairRules']['OfferedFare']) ? $value['FairRules']['OfferedFare'] : 0,
"CommissionEarned" => ($value['FairRules']['CommissionEarned']) ? (($value['FairRules']['CommissionEarned'])) : 0,
"FixedMarkUp" => ($value['FairRules']['FixedMarkUp']) ? $value['FairRules']['FixedMarkUp'] : 0,
"GSTOnMarkUp" => ($value['FairRules']['GSTOnMarkUp']) ? $value['FairRules']['GSTOnMarkUp'] : 0,
"CommDiscount" => ($value['FairRules']['CommDiscount']) ? (($value['FairRules']['CommDiscount'])) : 0,
"couponVal" => isset($value['FairRules']['couponVal']) ? (($value['FairRules']['couponVal'])) : 0,
"TDSEarn" => ($value['FairRules']['TDSEarn']) ? (($value['FairRules']['TDSEarn'])) : 0,
"AgentMarkUp" => 0,
"BagPrice" => isset($BagPrice) ? $BagPrice : 0,
"MealPrice" => isset($MealPrice) ? $MealPrice : 0,
"SeatPrice" => isset($SeatPrice) ? $SeatPrice : 0,
"FareBreakdown" => $FareBreakdown_
);
$segment_ = [];
if ($value['Segments']) {
foreach ($value['Segments'] as $seg) {
if (isset($seg['BAGGAGE'])) {
foreach ($seg['BAGGAGE'] as $b => $bag) {
$BaggageArr[] = $bag;
}
}
if (isset($seg['MEAL'])) {
foreach ($seg['MEAL'] as $m => $meals) {
$MealArr[] = $meals;
}
}
$Sectors[] = $seg['originAirportCode'] . '-' . $seg['destinationAirportCode'];
$segment_[] = $segment_ssr[$seg['segmentid']] = array(
"id" => intval($seg['segmentid']),
"flight_booking_id" => '',
"TraceId" => $value['SearchTraceId'],
"segmentid" => intval($seg['segmentid']),
"segmentids" => isset($seg['segmentids']) ? intval($seg['segmentids']) : 0,
"isReturnSegment" => $seg['isReturnSegment'],
"arrivingnextday" => $seg['arrivingnextday'],
"originAirportName" => $seg['originAirportName'],
"destinationAirportName" => $seg['destinationAirportName'],
"originCityName" => $seg['originCityName'],
"originCountryName" => $seg['originCountryName'],
"destinationCityName" => $seg['destinationCityName'],
"destinationCountryName" => $seg['destinationCountryName'],
"destinationAirportCode" => $seg['destinationAirportCode'],
"destinationArrTime" => date('Y-m-d H:i', strtotime($seg['destinationArrTime'])),
"SegFlightNumber" => $seg['SegFlightNumber'],
"AirlineCode" => $seg['AirlineCode'],
"AirlineName" => $seg['AirlineName'],
"FareClass" => $seg['FareClass'],
"cabinClass" => ($seg['cabinClass']) ? $seg['cabinClass'] : $value['FlightClass'],
"originAirportCode" => $seg['originAirportCode'],
"originDepTime" => date('Y-m-d H:i', strtotime($seg['originDepTime'])),
"CheckinBaggage" => !empty($seg['CheckinBaggage']) ? $seg['CheckinBaggage'] : $value['FairRules']['CheckinBaggage'],
"CabinBaggage" => !empty($seg['CabinBaggage']) ? $seg['CabinBaggage'] : $value['FairRules']['CabinBaggage'],
"IsBaggage" => isset($seg['IsBaggage']) ? $seg['IsBaggage'] : false,
"IsMealIncludes" => isset($seg['IsMealIncludes']) ? $seg['IsMealIncludes'] : false,
"Duration" => $seg['Duration'],
"GroundTime" => $seg['GroundTime'],
"NoOfSeatAvailable" => $seg['NoOfSeatAvailable'],
"FlightDuration" => $seg['FlightDuration'],
"LAYOVERDuration" => $seg['LAYOVERDuration'],
"LAYOVERCity" => $seg['LAYOVERCity'],
"DepTerminal" => $seg['DepTerminal'],
"ArrTerminal" => $seg['ArrTerminal'],
"filePath" => isset($seg['filePath']) ? $seg['filePath'] : '',
"SourceAirportCode" => $seg['originAirportCode'],
"DestAirportCode" => $seg['destinationAirportCode'],
"strArrivalDtTime" => $seg['strArrivalDtTime'],
"strDepartureDtTime" => $seg['strDepartureDtTime'],
"TravelDate" => $seg['originDepTime'],
"BagPrice" => 0,
"MealPrice" => 0,
"SeatPrice" => 0
);
}
}
// print_r($value);
$FLData[$k]['FlightNumber'] = $value['FlightNumber'];
$FLData[$k]['AirlineName'] = $value['AirlineName'];
$FLData[$k]['SupplierSysId'] = isset($value['SupplierSysId']) ? $value['SupplierSysId'] : 0;
$FLData[$k]['BookingId'] = isset($value['bookingId']) ? $value['bookingId'] : '';
$FLData[$k]['APIBookingId'] = isset($value['APIBookingId']) ? $value['APIBookingId'] : '';
$FLData[$k]['IsLCC'] = $value['IsLCC'];
$FLData[$k]['LocalFromTime'] = date('Y-m-d H:i', strtotime($value['FromUTCTime']));
$FLData[$k]['LocalToTime'] = date('Y-m-d H:i', strtotime($value['ToUTCTime']));
$FLData[$k]['ICSourceSysId'] = $value['ICSourceSysId'];
$FLData[$k]['apiTraceId'] = $value['SearchTraceId'];
$FLData[$k]['ApiResultIndex'] = $value['FairRules']['PriceID'];
$FLData[$k]['JourneyType'] = $value['JourneyType'];
$FLData[$k]['TripType'] = intval($value['TripType']);
$FLData[$k]['IsRefundable'] = ($value['IsRefundable']) ? $value['IsRefundable'] : false;
$FLData[$k]['IsInternational'] = $interNationalSearch;
$FLData[$k]['SourceAirportCode'] = $value['SourceAirportCode'];
$FLData[$k]['DestAirportCode'] = $value['DestAirportCode'];
$FLData[$k]['FairRules'] = $fareRuless;
$FLData[$k]['Segments'] = $segment_;
$FLData[$k]['FARERULE'] = isset($FARERULE[$k]) ? $FARERULE[$k] : [];
}
}
if ($JourneyType == 2 && $interNationalSearch == 1) {
$TripCount = 1;
} else {
$TripCount = 1; //count($FlightBooking);
}
$ARR_SALUTIONTBO = $ARR_SALUTIONTBO = array("1" => "Mr", "2" => "Mrs", "3" => "Ms", "4" => "Mstr", "5" => "Miss");
$TotalBG = 0;
$TotalML = 0;
$TotalST = 0;
if ($memberData) {
$A = 1;
$C = 1;
$I = 1;
$ARR_SALUTION = array_flip($ARR_SALUTIONTBO);
$ARR_SALUTION_CHILD = array_flip($ARR_SALUTIONTBO);
foreach ($memberData as $kkkk => $ValCustomer) {
$paxType = $ValCustomer['PaxType'];
if ($ValCustomer['PaxType'] == 1) {
$paxType = 'ADULT' . $A;
$A++;
} elseif ($ValCustomer['PaxType'] == 2) {
$paxType = 'CHILD' . $C;
$C++;
} else {
$paxType = 'INFANT' . $I;
$I++;
}
$CheckinBaggage = isset($baggageByPax[$ValCustomer['PaxType']]['Baggage']) ? $baggageByPax[$ValCustomer['PaxType']]['Baggage'] : '';
$CabinBaggage = isset($baggageByPax[$ValCustomer['PaxType']]['CabinBaggage']) ? $baggageByPax[$ValCustomer['PaxType']]['CabinBaggage'] : '';
$getSelectedAddon = $this->getSelectedAddon($selectedBag, $selectedMeal, $paxType, $BaggageArr, $MealArr);
$paxTypeBag = (isset($getSelectedAddon['paxTypeBag']) && !empty($getSelectedAddon['paxTypeBag'])) ? $getSelectedAddon['paxTypeBag'] : [];
$paxTypeMeal = (isset($getSelectedAddon['paxTypeMeal']) && !empty($getSelectedAddon['paxTypeMeal'])) ? $getSelectedAddon['paxTypeMeal'] : [];
$BagPrice = (isset($getSelectedAddon['BagPrice']) && !empty($getSelectedAddon['BagPrice'])) ? $getSelectedAddon['BagPrice'] : 0;
$MealPrice = (isset($getSelectedAddon['MealPrice']) && !empty($getSelectedAddon['MealPrice'])) ? $getSelectedAddon['MealPrice'] : 0;
$SeatPrice_c = 0;
$SelectedSeat = [];
if ($selectedSeatSession && ($ValCustomer['PaxType'] == 1 || $ValCustomer['PaxType'] == 2)) {
foreach ($selectedSeatSession as $segmentid => $value) {
$sorcdes = isset($segment_ssr[$segmentid]) ? $segment_ssr[$segmentid] : [];
$Orgin = isset($v['Origin']) ? $v['Origin'] : @$sorcdes['originAirportCode'];
$Destination = isset($v['Destination']) ? $v['Destination'] : @$sorcdes['destinationAirportCode'];
if (isset($value[$kkkk])) {
$SelectedSeat[$Orgin . '-' . $Destination][] = isset($value[$kkkk]) ? $value[$kkkk] : [];
$SeatPrice_c += $value[$kkkk]['Price'];
$SeatPrice += $value[$kkkk]['Price'];
}
}
}
// echo "<pre>";
// print_r(($getSelectedAddon));
$TotalBG += (float) $BagPrice;
$TotalML += (float) $MealPrice;
$TotalST += (float) $SeatPrice_c;
if ($ValCustomer['PaxType'] == 1) {
$paxTitle = ($ARR_SALUTION[$ValCustomer['title']]);
} elseif ($ValCustomer['PaxType'] == 2) {
$paxTitle = ($ARR_SALUTION_CHILD[$ValCustomer['title']]);
} else {
$paxTitle = ($ARR_SALUTION_CHILD[$ValCustomer['title']]);
}
$docid = isset($ValCustomer['docid']) ? $ValCustomer['docid'] : '';
$customer[] = array(
"city_id" => $ValCustomer['CitySysId'],
"country_id" => $ValCustomer['CountrySysId'],
"countryName" => isset($ValCustomer['countryName']) ? $ValCustomer['countryName'] : '',
"city" => $ValCustomer['city'],
"address" => $ValCustomer['address'],
"email" => $email_id,
"airline_number" => $airline_number,
"airline_email" => $airline_email,
"mobile" => (int)$mobileNumber,
"countryCode" => (int)isset($ValCustomer['countrycode']) ? $ValCustomer['countrycode'] : '',
"countryCodeISO" => isset($countryCodeISO) ? $countryCodeISO : '',
"relation" => isset($ValCustomer['relation']) ? $ValCustomer['relation'] : '9',
"firstname" => $ValCustomer['fname'],
"lastname" => $ValCustomer['lname'],
"salution" => $paxTitle, //$ValCustomer['title'],
"dateofbirth" => $ValCustomer['dob'],
"docid" => $docid,
"isgstapply" => $isgstapply,
"passportnoexpiry" => isset($ValCustomer['passexp']) ? $ValCustomer['passexp'] : '',
"passporIssue" => isset($ValCustomer['passisse']) ? $ValCustomer['passisse'] : '',
"PassportNationality" => isset($ValCustomer['passnational']) ? $ValCustomer['passnational'] : '',
"passportno" => isset($ValCustomer['passno']) ? $ValCustomer['passno'] : '',
"paxType" => $ValCustomer['PaxType'],
"sectors" => isset($ValCustomer['sectors']) ? $ValCustomer['sectors'] : '',
"CheckinBaggage" => isset($CheckinBaggage) ? $CheckinBaggage : '',
"CabinBaggage" => isset($CabinBaggage) ? $CabinBaggage : '',
"BagPrice" => (!empty($BagPrice)) ? ($BagPrice / $TripCount) : $BagPrice,
"MealPrice" => (!empty($MealPrice)) ? ($MealPrice / $TripCount) : $MealPrice,
"SeatPrice" => (!empty($SeatPrice_c)) ? ($SeatPrice_c / $TripCount) : $SeatPrice_c,
// "BagPrice" => (!empty($BagPrice) && $ICSourceSysId != 3) ? ($BagPrice / $TripCount) : $BagPrice,
// "MealPrice" => (!empty($MealPrice) && $ICSourceSysId != 3) ? ($MealPrice / $TripCount) : $MealPrice,
// "SeatPrice" => (!empty($SeatPrice_c) && $ICSourceSysId != 3) ? ($SeatPrice_c / $TripCount) : $SeatPrice_c,
"SelectedBag" => (!empty($paxTypeBag)) ? json_encode($paxTypeBag) : '',
"SelectedMeal" => (!empty($paxTypeMeal)) ? json_encode($paxTypeMeal) : '',
"SelectedSeat" => (!empty($SelectedSeat)) ? json_encode($SelectedSeat) : ''
);
}
}
$TripCount = count($FlightBooking);
$FLDataNew = [];
if ($FLData) {
foreach ($FLData as $kfl => $vlfl) {
$vlfl['FairRules']['BagPrice'] = round($TotalBG / $TripCount, 2);
$vlfl['FairRules']['MealPrice'] = round($TotalML / $TripCount, 2);
$vlfl['FairRules']['SeatPrice'] = round($TotalST / $TripCount, 2);
$FLDataNew[$kfl] = $vlfl;
}
}
$customerNew = [];
if ($customer) {
foreach ($customer as $kfl => $vlfl) {
$vlfl['BagPrice'] = round($TotalBG / $TripCount, 2);
$vlfl['MealPrice'] = round($TotalML / $TripCount, 2);
$vlfl['SeatPrice'] = round($TotalST / $TripCount, 2);
$customerNew[$kfl] = $vlfl;
}
}
$sourceCityId = $sessionFlightSearchParams['sourceCityId'];
$destinationCityId = $sessionFlightSearchParams['destinationCityId'];
$UserSysId = $sessionFlightSearchParams['UserSysId'];
$MasterAgencySysId = $sessionFlightSearchParams['MasterAgencySysId'];
$FlightBookingDataRiya = array(
"FlightBookingData" => $FLDataNew,
"customer" => $customerNew,
"roominfojson" => $roomjson,
"Cities" => $oneway_origin_text . '-' . $oneway_destination_text,
"IsHotelFromApi" => 1,
"ICSourceSysId" => $ICSourceSysId,
'AgencySysId' => $MasterAgencySysId,
'AgentSysId' => $UserSysId,
"SourcePlaces" => $oneway_origin_text,
"DestinationPlaces" => $oneway_destination_text,
"SourcePlaceSysId" => $sourceCityId,
"DestinationPlacesSysId" => $destinationCityId,
"BaseAmount" => $BaseFare + $TotalBG + $TotalML + $TotalST,
"PublishedFare" => ($BaseFare + $AgencyMarkUpINT_ + $AgencyMarkUpGSTINT_ + $CommissionEarnedAPI + $TotalBG + $TotalML + $TotalST),
"AgencyMarkUp" => $AgencyMarkUpINT_,
"AgencyMarkUpGST" => $AgencyMarkUpGSTINT_,
"AgentCommisionEarned" => $CommissionEarnedAPI,
"AgentCommisionEarnedGST" => 0,
"adults" => $adultCount,
"childs" => $childCount,
"infants" => $infantCount,
"route" => $JourneyType,
"email" => $email_id,
"mobile" => $mobileNumber,
"editLeadId" => $editLeadId,
"CustomerSysId" => $intCustomerSysId,
'IsB2BQuery' => $B2BType,
'B2BAgentSysId' => $UserSysId,
'B2BAgencySysId' => $AgencySysId,
'leadsource' => 'Agency',
'IsB2BProposal' => $B2BType,
'ExchangeCurrencyRate' => $CurrencyRate,
'APIMode' => 0,
'IsNewMigration' => 3,
);
if ($isgstapply == 1) {
$FlightBookingDataRiya['gstData'] = $gstData;
}
$getData['SecurityKey'] = $SecurityKey;
$URL = $this->baseUrl . '/gtxwebservices/flight-api';
$GENERATE_FLIGHT_QUERY = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($FlightBookingDataRiya, $getData, $URL);
$GTXQueryStatus = isset($GENERATE_FLIGHT_QUERY['status']) ? $GENERATE_FLIGHT_QUERY['status'] : false;
$TPSysId = isset($GENERATE_FLIGHT_QUERY['arrIds']['TPSysId']) ? $GENERATE_FLIGHT_QUERY['arrIds']['TPSysId'] : false;
// echo "<pre>";
// print_r(($GENERATE_FLIGHT_QUERY));
// echo "<pre>";
// print_r(json_encode($FlightBookingDataRiya));
// die;
if ($GTXQueryStatus == 1) {
$gstData['isgstapply'] = $isgstapply;
if (!empty($arrUrlData)) {
$arrUrlData['FlightBookingData'] = $FlightBooking;
$arrUrlData['customer'] = $customer;
$arrUrlData['gstData'] = $gstData;
$arrUrlData['FARERULE'] = $FARERULE;
$arrUrlData['GENERATE_FLIGHT_QUERY'] = $GENERATE_FLIGHT_QUERY;
$tempData = array(
'TraceId' => $SearchTraceId,
'TPSysId' => $TPSysId,
'APIBookingData' => json_encode($arrUrlData),
);
$objFlight->deleteFlightTempData($SearchTraceId);
$objFlight->insertFlightTempData($tempData);
$response = array(
'success' => true,
'message' => 'success',
'SearchTraceId' => $SearchTraceId,
'TPSysId' => $TPSysId,
);
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'record not found');
echo json_encode($response);
exit;
}
} else {
$response = array('success' => false, 'message' => 'Unable to create query. please contact administrator.',);
echo json_encode($response);
exit;
}
// echo "<pre>";
// print_r(($FlightBookingDataRiya));
// print_r(($data));
// die;
}
}
public function getSelectedAddon($selectedBag, $selectedMeal, $paxType, $BaggageArr, $MealArr)
{
$paxTypeBag = [];
$paxTypeMeal = [];
if ($selectedBag) {
foreach ($selectedBag as $key => $val) {
$value = strstr($val, '@@', true);
$valueEXP = explode('_', $value);
if ($paxType == $valueEXP[0]) {
$filterBy = ($valueEXP[1]);
$sector = ($valueEXP[2]);
$bnew = array_filter($BaggageArr, function ($var) use ($filterBy) {
$keyCode = $var['Code'] . '@' . $var['key'];
return ($keyCode == $filterBy);
});
$paxTypeBag[$sector] = array_values($bnew);
}
}
}
if ($selectedMeal) {
foreach ($selectedMeal as $key => $val) {
$value = strstr($val, '@@', true);
$valueEXP = explode('_', $value);
if ($paxType == $valueEXP[0]) {
$filterBy = ($valueEXP[1]);
$sector = ($valueEXP[2]);
$new = array_filter($MealArr, function ($var) use ($filterBy) {
$keyCode = $var['Code'] . '@' . $var['key'];
return ($keyCode == $filterBy);
});
$paxTypeMeal[$sector] = array_values($new);
}
}
}
$BagPrice = 0;
$paxTypeBag_ = [];
if ($paxTypeBag) {
foreach ($paxTypeBag as $sec => $val) {
foreach ($val as $v) {
$paxTypeBag_[] = $v;
$BagPrice += $v['Price'];
}
}
}
$MealPrice = 0;
$paxTypeMeal_ = [];
if ($paxTypeMeal) {
foreach ($paxTypeMeal as $sec => $val) {
foreach ($val as $v) {
$paxTypeMeal_[] = $v;
$MealPrice += $v['Price'];
}
}
}
// pr($paxTypeBag_);
// pr($paxTypeMeal_);
// die;
return ['paxTypeBag' => $paxTypeBag, 'paxTypeMeal' => $paxTypeMeal, 'BagPrice' => $BagPrice, 'MealPrice' => $MealPrice];
}
public function reviewAction()
{
$getData = $this->getRequest()->getParams();
$objFlight = new Travel_Model_TblFlight();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
if ($this->getRequest()->isXmlHttpRequest()) {
$post = json_decode(file_get_contents('php://input'), true);
$strUrlData = $post['SearchID'];
}
$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
$this->view->TPSysId = $TPSysId = ($FlightTempData['TPSysId'] > 0) ? $FlightTempData['TPSysId'] : 0;
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
$FlightBookingData = $arrUrlData['FlightBookingData'];
$customer = $arrUrlData['customer'];
$gstData = isset($arrUrlData['gstData']) ? $arrUrlData['gstData'] : [];
$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
$leadId = $sessionFlightSearchParams['editLeadId'];
$objFlightProposal = new Travel_Model_TblFlightProposal();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$arrAgencyDetails = $this->view->arrAgencyDetails = $objFlightProposal->getProposalAgencyDetails($leadId, 'query');
$AgencySysId = $this->view->AgencySysId = $this->intLoggedinAgencyId = $arrAgencyDetails['AgencySysId'];
$AgentSysId = $arrAgencyDetails['AgentSysId'];
$getAgencyDetail = $crmcustomerObj->GetAgencyDetailById($AgencySysId);
$SecurityKey = isset($getAgencyDetail['SecurityKey']) ? $getAgencyDetail['SecurityKey'] : 0;
$getData['SecurityKey'] = $SecurityKey;
$PostData = ['TPSysId' => $TPSysId, 'version' => null];
$URL = $this->baseUrl . "/gtxwebservices/flight-api/bookingdetails/";
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($PostData, $getData, $URL);
$bookingDataByAPI = isset($apiResponse['FlightBookingData']) ? $apiResponse['FlightBookingData'] : [];
$CurrentStatus = isset($bookingDataByAPI[0]['CurrentStatus']) ? $bookingDataByAPI[0]['CurrentStatus'] : 0;
$PaymentStatus = isset($bookingDataByAPI[0]['PaymentStatus']) ? $bookingDataByAPI[0]['PaymentStatus'] : 0;
if (empty($arrUrlData) || ($CurrentStatus == 142 && $PaymentStatus == 130)) {
echo 'Link expired!';
exit;
}
$BaseFare = 0;
$Taxesfee = 0;
$CommDiscount = 0;
$TotalPay = 0;
$ServiceFee__ = 0;
$AirlineTax = 0;
$FuelSurcharge = 0;
$GSTOnMarkUp_ = 0;
$FixedMarkUp_ = 0;
$CommissionEarned_ = 0;
$TDSEarn_ = 0;
if ($FlightBookingData) {
foreach ($FlightBookingData as $key => $value) {
foreach ($value['FairRules']['FareBreakdown'] as $FareBreakdown) {
$BaseFare += isset($FareBreakdown['BaseFare']) ? ($FareBreakdown['BaseFare']) : 0;
$BaseFare_ = isset($FareBreakdown['BaseFare']) ? ($FareBreakdown['BaseFare']) : 0;
$TDSEarn = isset($FareBreakdown['TDSEarn']) ? ($FareBreakdown['TDSEarn']) : 0;
$FixedMarkUp = isset($FareBreakdown['FixedMarkUp']) ? ($FareBreakdown['FixedMarkUp']) : 0;
$GSTOnMarkUp = isset($FareBreakdown['GSTOnMarkUp']) ? ($FareBreakdown['GSTOnMarkUp']) : 0;
$CommissionEarned = isset($FareBreakdown['CommissionEarned']) ? ($FareBreakdown['CommissionEarned']) : 0;
$CommDiscount += isset($FareBreakdown['CommDiscount']) ? ($FareBreakdown['CommDiscount']) : 0;
$Tax = isset($FareBreakdown['Tax']) ? ($FareBreakdown['Tax']) : 0;
$YQ = isset($FareBreakdown['TaxBR']['YQ']) ? ($FareBreakdown['TaxBR']['YQ']) : 0;
$Taxesfee += ($FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
$TotalPay += ($BaseFare_ + $FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
$ServiceFee__ += ($FixedMarkUp + $GSTOnMarkUp);
$AirlineTax += ($Tax);
$FuelSurcharge += ($YQ);
$GSTOnMarkUp_ += ($GSTOnMarkUp);
$FixedMarkUp_ += ($FixedMarkUp);
$CommissionEarned_ += ($CommissionEarned);
$TDSEarn_ += ($TDSEarn);
}
}
}
$BagPrice = 0;
$MealPrice = 0;
$SeatPrice = 0;
foreach ($customer as $kkkk => $ValCustomer) {
$BagPrice += !empty($ValCustomer['BagPrice']) ? $ValCustomer['BagPrice'] : 0;
$MealPrice += !empty($ValCustomer['MealPrice']) ? $ValCustomer['MealPrice'] : 0;
$SeatPrice += !empty($ValCustomer['SeatPrice']) ? $ValCustomer['SeatPrice'] : 0;
}
$fare = [
'Currency' => isset($FlightBookingData[0]['FairRules']['Currency']) ? trim($FlightBookingData[0]['FairRules']['Currency']) : 'INR',
'BaseFare' => round($BaseFare, 2),
'Taxesfee' => round($Taxesfee, 2),
'CommDiscount' => round($CommDiscount, 2),
'CommissionEarned' => round($CommissionEarned_, 2),
'TDSEarn' => round($TDSEarn_, 2),
'TotalPay' => round($TotalPay + $MealPrice + $BagPrice + $SeatPrice, 2),
'AirlineTax' => round($AirlineTax, 2),
'FuelSurcharge' => round($FuelSurcharge, 2),
'FixedMarkUp' => round($FixedMarkUp_, 2),
'GSTOnMarkUp' => round($GSTOnMarkUp_, 2),
'MealPrice' => $MealPrice,
'BagPrice' => $BagPrice,
'SeatPrice' => $SeatPrice,
'TotalSSR' => ($MealPrice + $BagPrice + $SeatPrice),
'TotalProfit' => round(($TDSEarn_ + $CommissionEarned_ + $FixedMarkUp_ + $GSTOnMarkUp_), 2),
];
$this->view->FlightBookingData = $FlightBookingData;
$this->view->arrtravellerList = $customer;
$this->view->fare = $fare;
$this->view->gstData = $gstData;
$this->view->sessionFlightSearchParams = $sessionFlightSearchParams;
$adultCount = ($sessionFlightSearchParams['adults']);
$childCount = ($sessionFlightSearchParams['child']);
$infantCount = ($sessionFlightSearchParams['infant']);
$intCustomerSysId = ($sessionFlightSearchParams['CustomerSysId']);
$interNationalSearch = !empty($sessionFlightSearchParams['interNationalSearch']) ? $sessionFlightSearchParams['interNationalSearch'] : 0;
$intMemberCount = ($adultCount + $childCount + $infantCount);
$intPublishFareNew = $fare['TotalPay'];
$arrPriceAndMarkups = array(
"intAgentMarkUpAmount" => 0,
"intAgencyMarkUpAmount" => ($FixedMarkUp_ - $GSTOnMarkUp_),
"intGTXMarkUpAmount" => 0,
"intTotalAmount" => $intPublishFareNew,
"intTax" => 0,
"GTXServiceTaxAmount" => 0,
"AgentServiceTaxAmount" => $GSTOnMarkUp_,
"AgentsCustomServiceTaxAmount" => "0",
"Pax" => $intMemberCount,
"SupplierSourceStr" => "API",
"MarketPlaceId" => "1",
"TotalDiscount" => 0,
"CurrencyType" => 1
);
$strPriceAndMarkups = json_encode($arrPriceAndMarkups);
$this->view->stringData = $strStringData = $this->getEnc($strPriceAndMarkups);
$IsPaymentGateway = !empty($arrAgencyDetails['IsPaymentGateway']) ? $arrAgencyDetails['IsPaymentGateway'] : 0;
$IsCheckWallet = !empty($arrAgencyDetails['IsCheckWallet']) ? $arrAgencyDetails['IsCheckWallet'] : 0;
if ($IsPaymentGateway == true && $IsCheckWallet == true) {
$this->view->strPayWithPaymentGatewayUrl = Catabatic_Helper::getSiteUrl() . "payment/payment-options/customer-pay-by-agency";
} else {
$this->view->strPayWithPaymentGatewayUrl = Catabatic_Helper::getSiteUrl() . "payment/payment-options/customer-pay-by-agency";
}
$secureCode = Zend_Controller_Action_HelperBroker::getStaticHelper('SecureCode')->secureCode(trim(base64_encode($strUrlData)), 1);
$this->view->TPSysId = $TPSysId;
$this->view->secureCode = $secureCode;
$this->view->intCustomerSysId = $intCustomerSysId;
$this->view->intPlanType = "1";
$this->view->strTrxType = "A";
$this->view->strReturnURL = "/flight-proposal-new/book-proposal-flight/data/" . $strUrlData . '/code/' . $secureCode;
$this->view->strErrorURL = "/flight-proposal-new/review/data/" . $strUrlData . '/code/' . $secureCode;
$this->view->intLoggedinAgencySysId = $AgencySysId;
$this->view->IsCardChrgToCustomer = 1;
$this->view->intLoggedinUserAgencySysId = $AgentSysId;
$this->view->intPublishFare = ceil($intPublishFareNew);
$this->view->intPublishFareNew = $intPublishFareNew;
$this->view->Symbol = $fare['Currency'];
$this->view->guid = $this->GUID();
$this->view->walletCode = $this->walletCode($AgentSysId, $this->view->guid, ceil($intPublishFareNew), $AgencySysId, $TPSysId, $intCustomerSysId, $strStringData);
$this->view->securecode = $this->secureCode($AgencySysId, $this->view->guid);
$objPaymentDetail = new Payment_Model_Payment();
$getPaymentCompanyName = $objPaymentDetail->getPaymentCompanyNameAllDetail($AgencySysId);
$PaymentMerchantId = $getPaymentCompanyName['PaymentMerchantId'];
$PaymentOption = $getPaymentCompanyName['PaymentOption'];
$this->view->getPaymentCompanyName = $PaymentOption;
$this->view->PaymentMerchantId = $PaymentMerchantId;
// echo '<pre>getPaymentCompanyName';
// print_r(($getPaymentCompanyName));
// echo '<pre>';
// print_r(($strPriceAndMarkups));
// die;
}
public function verifyingbookingAction()
{
if ($this->getRequest()->isXmlHttpRequest() && $this->getRequest()->getPost()) {
$post = $this->getRequest()->getPost();
$code = $post['code'];
$data = $strUrlData = $post['data'];
$secureCode = Catabatic_ValidateCustomer::secureCode(base64_encode($data), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
$objFlight = new Travel_Model_TblFlight();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
$this->view->TPSysId = $intTPSysId = ($FlightTempData['TPSysId'] > 0) ? $FlightTempData['TPSysId'] : 0;
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
$FlightBookingData = $arrUrlData['FlightBookingData'];
$customer = $arrUrlData['customer'];
$gstData = isset($arrUrlData['gstData']) ? $arrUrlData['gstData'] : [];
$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
$leadId = $sessionFlightSearchParams['editLeadId'];
$objFlightProposal = new Travel_Model_TblFlightProposal();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$arrAgencyDetails = $this->view->arrAgencyDetails = $objFlightProposal->getProposalAgencyDetails($leadId, 'query');
$AgencySysId = $this->view->AgencySysId = $this->intLoggedinAgencyId = $arrAgencyDetails['AgencySysId'];
$AgentSysId = $arrAgencyDetails['AgentSysId'];
$getAgencyDetail = $agencyDetails = $crmcustomerObj->GetAgencyDetailById($AgencySysId);
$SecurityKey = isset($getAgencyDetail['SecurityKey']) ? $getAgencyDetail['SecurityKey'] : 0;
$PrimaryEmail = isset($agencyDetails['PrimaryEmail']) ? $agencyDetails['PrimaryEmail'] : 0;
$getData['SecurityKey'] = $SecurityKey;
$PostData = ['TPSysId' => $intTPSysId, 'version' => null];
$URL = $this->baseUrl . "/gtxwebservices/flight-api/bookingdetails/";
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($PostData, $getData, $URL);
$bookingDataByAPI = isset($apiResponse['FlightBookingData']) ? $apiResponse['FlightBookingData'] : [];
$MasterTPSysId = isset($bookingDataByAPI[0]['MasterTPSysId']) ? $bookingDataByAPI[0]['MasterTPSysId'] : 0;
$ICSourceSysId = isset($bookingDataByAPI[0]['ICSourceSysId']) ? $bookingDataByAPI[0]['ICSourceSysId'] : 0;
$getAgentDetailById = $crmcustomerObj->getAgentDetailById($AgencySysId);
$IsAllowFlightBooking = isset($getAgentDetailById[0]['IsAllowFlightBooking']) ? $getAgentDetailById[0]['IsAllowFlightBooking'] : 0;
$ContactNo1 = isset($getAgentDetailById[0]['ContactNo1']) ? trim($getAgentDetailById[0]['ContactNo1']) : 0;
$countrycode = isset($getAgentDetailById[0]['countrycode']) ? trim($getAgentDetailById[0]['countrycode']) : 0;
$EmailId = isset($getAgentDetailById[0]['EmailId']) ? trim($getAgentDetailById[0]['EmailId']) : 0;
$EmailId_cus = isset($customer[0]['email']) ? trim($customer[0]['email']) : 0;
$Contacts_cus = isset($customer[0]['mobile']) ? trim($customer[0]['mobile']) : 0;
$MobileNumber = $countrycode . $Contacts_cus;
$LoggedinUserMobileNumber = $countrycode . $ContactNo1;
$generateNumericOTP = $this->generateNumericOTP(6);
$customHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom');
$IsSMSApi = isset($agencyDetails['IsSMSApi']) ? trim($agencyDetails['IsSMSApi']) : 0;
$isagency = 0;
if ($isagency == '1') {
$smsemail = $EmailId;
$smsmobile = $LoggedinUserMobileNumber;
if ($IsAllowFlightBooking == 0) {
$response = array('success' => false, 'checkOTP' => false, 'msg' => 'Booking not allowed', 'urlData' => '');
echo json_encode($response);
exit;
}
} else {
$smsemail = $EmailId_cus;
$smsmobile = $Contacts_cus;
}
if (isset($post['verifying']) && $post['verifying'] == 'true' && !empty($post['verifying'])) {
$getBooingOTP = $objFlight->getBooingOTP($intTPSysId);
$OTPNumber = trim($post['OTPNumber']);
if ($getBooingOTP == $OTPNumber) {
$objFlight->updateBookingStatusTravelPlan(array("CustomerRemark" => '1'), $intTPSysId, $MasterTPSysId);
$response = array('success' => true, 'checkOTP' => false, 'msg' => 'success', 'urlData' => '');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'checkOTP' => false, 'msg' => 'Invalid otp', 'urlData' => '');
echo json_encode($response);
exit;
}
}
$objFlight->updateBookingStatusTravelPlan(array("CustomerRemark" => $generateNumericOTP), $intTPSysId, $MasterTPSysId);
$currentDate = date('Y-m-d H:i:s');
$dateTime = new DateTime($currentDate);
$dateTime->modify('+2 minutes');
$RandomCodeValidTo = $dateTime->format('Y-m-d H:i:s');
$col = array('RandomCode' => $generateNumericOTP, 'RandomCodeValidFrom' => $currentDate, 'RandomCodeValidTo' => $RandomCodeValidTo);
$message = "OTP for CRM access is $generateNumericOTP do not share it with anyone.\nTRVCRM";
$postFields = "";
$postFields .= "&method=$this->SMSMETHOD";
$postFields .= "&api_key=$this->SMSAPIKEY";
$postFields .= "&sender=$this->SMSSENDER";
$postFields .= "&message=$message";
$postFields .= "&format=$this->SMSFORMAT";
$postURL = $this->SMSURL;
$data = new Payment_Model_Checkotp();
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$html->assign(array('getBooingOTP' => $generateNumericOTP, 'agencyDetails' => $agencyDetails));
$bodyText = $html->render('OTPEmail.phtml');
$fromName = (isset($agencyDetails['DisplayName']) && !empty($agencyDetails['DisplayName'])) ? trim($agencyDetails['DisplayName']) : trim(trim($agencyDetails['Title']));
$emailData = array(
'fromEmail' => $PrimaryEmail,
'fromName' => $fromName,
'subject' => 'OTP for booking ' . date('Y-m-d H:i:s'),
'to' => array($smsemail),
'bodyHtml' => $bodyText,
'bodyText' => ''
);
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $AgencySysId,
"AgentSysId" => 0,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[1], // 1 For Vouchers
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:i:s')
);
$smsmobile = $smsmobile;
$postFields .= "&to=" . substr($smsmobile, -10);
$hidePhoneNumberDigit = $customHelper->hidePhoneNumberDigit($smsmobile, 1);
$emailResponse = json_decode($this->mailSentByElastice($emailData, $arrEmailStatistics), true);
$resultVal = $data->sendSmsDetails($postURL, $postFields, $arrEmailStatistics, $IsSMSApi);
if ($ICSourceSysId == 3) {
}
// echo '<pre>emailResponse';
// print_r(($emailResponse));
// echo '<pre>resultVal';
// print_r(($resultVal));
// echo '<pre>postFields';
// print_r(($postFields));
// die;
$response = array('success' => true, 'checkOTP' => true, 'msg' => '', 'urlData' => '', 'PhoneNumberDigit' => $hidePhoneNumberDigit);
echo json_encode($response);
exit;
}
}
public function validatePaymentAction()
{
if ($this->_request->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$this->paymentMdl = new Payment_Model_Payment();
$AgencySysId = $this->getRequest()->getParam('AgencySysId');
$intPublishFare = $this->getRequest()->getParam('intPublishFare');
$wallet = $this->paymentMdl->getDetailsByUniqueId("TB_Agency_Wallet", "AgencySysId", $AgencySysId);
$post = $this->getRequest()->getPost();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$response = array('success' => true, 'message' => '');
echo json_encode($response);
exit;
if ($wallet['BalanceAmount'] >= $intPublishFare) {
$response = array('success' => true, 'message' => '');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to continue payment! please contact agency with this message');
echo json_encode($response);
exit;
}
}
}
public function bookProposalFlightAction()
{
$getData = $this->getRequest()->getParams();
$objFlight = new Travel_Model_TblFlight();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$code = $getData['code'];
$data = $strUrlData = $getData['data'];
$secureCode = Catabatic_ValidateCustomer::secureCode(base64_encode($data), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
if ($this->getRequest()->isXmlHttpRequest()) {
$post = json_decode(file_get_contents('php://input'), true);
$strUrlData = $post['SearchID'];
}
$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
$this->view->TPSysId = $TPSysId = ($FlightTempData['TPSysId'] > 0) ? $FlightTempData['TPSysId'] : 0;
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
$FlightBookingData = $BookingData = $arrUrlData['FlightBookingData'];
$customer = $arrUrlData['customer'];
$gstData = isset($arrUrlData['gstData']) ? $arrUrlData['gstData'] : [];
$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
$leadId = $sessionFlightSearchParams['editLeadId'];
$objFlightProposal = new Travel_Model_TblFlightProposal();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$paymentMdl = new Payment_Model_Payment();
$arrAgencyDetails = $this->view->arrAgencyDetails = $objFlightProposal->getProposalAgencyDetails($leadId, 'query');
$AgencySysId = $this->view->AgencySysId = $this->intLoggedinAgencyId = $arrAgencyDetails['AgencySysId'];
$AgentSysId = $arrAgencyDetails['AgentSysId'];
$getAgencyDetail = $crmcustomerObj->GetAgencyDetailById($AgencySysId);
$SecurityKey = isset($getAgencyDetail['SecurityKey']) ? $getAgencyDetail['SecurityKey'] : 0;
$getData['SecurityKey'] = $SecurityKey;
$PostData = ['TPSysId' => $TPSysId, 'version' => null];
$URL = $this->baseUrl . "/gtxwebservices/flight-api/bookingdetails/";
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($PostData, $getData, $URL);
$bookingDataByAPI = isset($apiResponse['FlightBookingData']) ? $apiResponse['FlightBookingData'] : [];
$CurrentStatus = isset($bookingDataByAPI[0]['CurrentStatus']) ? $bookingDataByAPI[0]['CurrentStatus'] : 0;
$PaymentStatus = isset($bookingDataByAPI[0]['PaymentStatus']) ? $bookingDataByAPI[0]['PaymentStatus'] : 0;
if (empty($arrUrlData) || ($CurrentStatus == 142 && $PaymentStatus == 130)) {
echo 'Link expired!';
exit;
}
$checkPaymentStatus = $paymentMdl->checkPaymentStatus($AgencySysId, $TPSysId);
$bookingId = !empty($FlightBookingData[0]['bookingId']) ? $FlightBookingData[0]['bookingId'] : $strUrlData;
$BaseFare = 0;
$Taxesfee = 0;
$CommDiscount = 0;
$TotalPay = 0;
$ServiceFee__ = 0;
$AirlineTax = 0;
$FuelSurcharge = 0;
$GSTOnMarkUp_ = 0;
$FixedMarkUp_ = 0;
$CommissionEarned_ = 0;
$TDSEarn_ = 0;
$misxItems_name = [];
if ($FlightBookingData) {
foreach ($FlightBookingData as $key => $value) {
$PublishedFare__ = 0;
$GSTOnMarkUp__ = 0;
$FixedMarkUp__ = 0;
foreach ($value['FairRules']['FareBreakdown'] as $FareBreakdown) {
$BaseFare += isset($FareBreakdown['BaseFare']) ? ($FareBreakdown['BaseFare']) : 0;
$BaseFare_ = isset($FareBreakdown['BaseFare']) ? ($FareBreakdown['BaseFare']) : 0;
$TDSEarn = isset($FareBreakdown['TDSEarn']) ? ($FareBreakdown['TDSEarn']) : 0;
$FixedMarkUp = isset($FareBreakdown['FixedMarkUp']) ? ($FareBreakdown['FixedMarkUp']) : 0;
$GSTOnMarkUp = isset($FareBreakdown['GSTOnMarkUp']) ? ($FareBreakdown['GSTOnMarkUp']) : 0;
$CommissionEarned = isset($FareBreakdown['CommissionEarned']) ? ($FareBreakdown['CommissionEarned']) : 0;
$CommDiscount += isset($FareBreakdown['CommDiscount']) ? ($FareBreakdown['CommDiscount']) : 0;
$Tax = isset($FareBreakdown['Tax']) ? ($FareBreakdown['Tax']) : 0;
$YQ = isset($FareBreakdown['TaxBR']['YQ']) ? ($FareBreakdown['TaxBR']['YQ']) : 0;
$Taxesfee += ($FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
$TotalPay += ($BaseFare_ + $FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
$ServiceFee__ += ($FixedMarkUp + $GSTOnMarkUp);
$AirlineTax += ($Tax);
$FuelSurcharge += ($YQ);
$GSTOnMarkUp_ += ($GSTOnMarkUp);
$FixedMarkUp_ += ($FixedMarkUp);
$CommissionEarned_ += ($CommissionEarned);
$TDSEarn_ += ($TDSEarn);
$PublishedFare__ += ($BaseFare_ + $CommissionEarned + $Tax + $TDSEarn);
$FixedMarkUp__ += ($FixedMarkUp);
$GSTOnMarkUp__ += ($GSTOnMarkUp);
}
$TotalFare = ($PublishedFare__);
$TotalAmount = ($PublishedFare__ + $FixedMarkUp__ + $GSTOnMarkUp__);
$TotalGST = $GSTOnMarkUp__;
$SubTotal = ($TotalAmount - $GSTOnMarkUp__);
$TotalcouponVal = 0;
$SourceAirportCode = $value['SourceAirportCode'];
$DestAirportCode = $value['DestAirportCode'];
$FlightNumber = $value['FlightNumber'];
$AirlineName = $value['AirlineName'];
$Description = $SourceAirportCode . '-' . $DestAirportCode . '-' . $AirlineName . ' ' . $FlightNumber;
$misxItems_name[] = [
'AgencySysId' => $AgencySysId,
'AgentSysId' => $AgentSysId,
'MisxItems_name' => 'Flight',
'Description' => $Description,
'ItemQty' => 1,
'ItemRates' => round(($TotalFare), 2),
'Total' => round(($TotalFare), 2),
'DiscountType' => 1,
'Discount' => 1,
'TotalDiscount' => round(($TotalcouponVal), 2),
'TotalAmount' => round(($TotalAmount), 2),
'MarkupType' => '',
'Markup' => round(($FixedMarkUp__), 2),
'TotalMarkup' => round(($FixedMarkUp__), 2),
'SubTotal' => round(($SubTotal), 2),
'ServiceFeeTotal' => $TotalGST,
'GSTPercentage' => '18',
'TotalGST' => round($TotalGST, 2),
'SGST' => round((($TotalGST / 2)), 2),
'CGST' => round((($TotalGST / 2)), 2),
'IGST' => round(($TotalGST), 2),
'ItemsSACCode' => '',
];
}
}
$BagPrice = 0;
$MealPrice = 0;
$SeatPrice = 0;
foreach ($customer as $kkkk => $ValCustomer) {
$BagPrice += !empty($ValCustomer['BagPrice']) ? $ValCustomer['BagPrice'] : 0;
$MealPrice += !empty($ValCustomer['MealPrice']) ? $ValCustomer['MealPrice'] : 0;
$SeatPrice += !empty($ValCustomer['SeatPrice']) ? $ValCustomer['SeatPrice'] : 0;
}
$fare = [
'Currency' => isset($FlightBookingData[0]['FairRules']['Currency']) ? trim($FlightBookingData[0]['FairRules']['Currency']) : 'INR',
'BaseFare' => round($BaseFare, 2),
'Taxesfee' => round($Taxesfee, 2),
'CommDiscount' => round($CommDiscount, 2),
'CommissionEarned' => round($CommissionEarned_, 2),
'TDSEarn' => round($TDSEarn_, 2),
'TotalPay' => round($TotalPay, 2),
'AirlineTax' => round($AirlineTax, 2),
'FuelSurcharge' => round($FuelSurcharge, 2),
'FixedMarkUp' => round($FixedMarkUp_, 2),
'GSTOnMarkUp' => round($GSTOnMarkUp_, 2),
'MealPrice' => $MealPrice,
'BagPrice' => $BagPrice,
'SeatPrice' => $SeatPrice,
'TotalSSR' => ($MealPrice + $BagPrice + $SeatPrice),
'TotalProfit' => round(($TDSEarn_ + $CommissionEarned_ + $FixedMarkUp_ + $GSTOnMarkUp_), 2),
];
$JourneyType = ($sessionFlightSearchParams['route']);
$adultCount = ($sessionFlightSearchParams['adults']);
$childCount = ($sessionFlightSearchParams['child']);
$infantCount = ($sessionFlightSearchParams['infant']);
$intCustomerSysId = ($sessionFlightSearchParams['CustomerSysId']);
$interNationalSearch = !empty($sessionFlightSearchParams['interNationalSearch']) ? $sessionFlightSearchParams['interNationalSearch'] : 0;
$intMemberCount = ($adultCount + $childCount + $infantCount);
$GENERATE_FLIGHT_QUERY = !empty($arrUrlData['GENERATE_FLIGHT_QUERY']['arrIds']) ? $arrUrlData['GENERATE_FLIGHT_QUERY']['arrIds'] : [];
if ($checkPaymentStatus == 1) {
// echo '<pre>checkPaymentStatus';
// print_r(($sessionFlightSearchParams));
// die;
$MasterTPSysId = !empty($GENERATE_FLIGHT_QUERY['MasterTPSysId']) ? $GENERATE_FLIGHT_QUERY['MasterTPSysId'] : 0;
$CustomerSysIdGTX = !empty($GENERATE_FLIGHT_QUERY['CustomerSysId']) ? $GENERATE_FLIGHT_QUERY['CustomerSysId'] : 0;
$TrxId = !empty($GENERATE_FLIGHT_QUERY['TrxId']) ? $GENERATE_FLIGHT_QUERY['TrxId'] : 0;
$TPSysId = !empty($GENERATE_FLIGHT_QUERY['TPSysId']) ? $GENERATE_FLIGHT_QUERY['TPSysId'] : 0;
$VersionId = !empty($GENERATE_FLIGHT_QUERY['VersionId']) ? $GENERATE_FLIGHT_QUERY['VersionId'] : [];
$GstNumber = !empty($customer[0]['GstNumber']) ? $customer[0]['GstNumber'] : '';
$isgstapply = !empty($customer[0]['isgstapply']) ? $customer[0]['isgstapply'] : 0;
$ServiceTaxNo = $getAgencyDetail['ServiceTaxNo'];
$gstvalidate = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->gstvalidate($GstNumber, $ServiceTaxNo);
$itemCount = count($misxItems_name);
if (!empty($BagPrice)) {
$misxItems_name[$itemCount] = array(
'MisxItems_name' => 'Add ons',
'Description' => 'Baggage',
'ItemQty' => 1,
'ItemRates' => ($BagPrice),
'Total' => $BagPrice,
'DiscountType' => 0,
'Discount' => 0,
'TotalDiscount' => 0,
'TotalAmount' => 0,
'MarkupType' => '',
'Markup' => 0,
'TotalMarkup' => 0,
'SubTotal' => $BagPrice,
'ServiceFeeTotal' => 0,
'GSTPercentage' => 0,
'TotalGST' => 0,
'SGST' => 0,
'CGST' => 0,
'IGST' => 0,
'ItemsSACCode' => '',
);
}
$itemCount = count($misxItems_name);
if (!empty($MealPrice)) {
$misxItems_name[$itemCount] = array(
'MisxItems_name' => 'Add ons',
'Description' => 'Meal',
'ItemQty' => 1,
'ItemRates' => ($MealPrice),
'Total' => $MealPrice,
'DiscountType' => 0,
'Discount' => 0,
'TotalDiscount' => 0,
'TotalAmount' => 0,
'MarkupType' => '',
'Markup' => 0,
'TotalMarkup' => 0,
'SubTotal' => $MealPrice,
'ServiceFeeTotal' => 0,
'GSTPercentage' => 0,
'TotalGST' => 0,
'SGST' => 0,
'CGST' => 0,
'IGST' => 0,
'ItemsSACCode' => '',
);
}
$itemCount = count($misxItems_name);
if (!empty($SeatPrice)) {
$misxItems_name[$itemCount] = array(
'MisxItems_name' => 'Add ons',
'Description' => 'Seat',
'ItemQty' => 1,
'ItemRates' => ($SeatPrice),
'Total' => $SeatPrice,
'DiscountType' => 0,
'Discount' => 0,
'TotalDiscount' => 0,
'TotalAmount' => 0,
'MarkupType' => '',
'Markup' => 0,
'TotalMarkup' => 0,
'SubTotal' => $SeatPrice,
'ServiceFeeTotal' => 0,
'GSTPercentage' => 0,
'TotalGST' => 0,
'SGST' => 0,
'CGST' => 0,
'IGST' => 0,
'ItemsSACCode' => '',
);
}
$TotalInvoiceValue = ($fare['TotalPay'] + $fare['MealPrice'] + $fare['BagPrice'] + $fare['SeatPrice'] - $fare['GSTOnMarkUp']);
$PublishedFare = ($fare['TotalPay'] + $fare['MealPrice'] + $fare['BagPrice'] + $fare['SeatPrice']);
$agencyMarkUpGST = ($fare['GSTOnMarkUp']);
$TotalDiscount = 0;
$Invoicedata = [
'AgentSysId' => $AgentSysId,
'CustomerSysId' => $intCustomerSysId,
'TPSysId' => $TPSysId,
'MasterTPSysId' => $MasterTPSysId,
'ProposalID' => $TPSysId . '/V1',
'InvoiceDate' => date('Y-m-d'),
'isDisplayMarkup' => true,
'PaymentDueDate' => date('Y-m-d'),
'PaymentDate' => date('Y-m-d'),
'ClientGST' => $isgstapply,
'ClientGSTNumber' => $GstNumber,
'Currency' => $this->CurrencyId,
'TotalInvoiceValue' => round(($TotalInvoiceValue), 2),
'InvoiceStatus' => ($checkPaymentStatus == 1) ? 1 : 5,
'TotalSGST' => ($gstvalidate['SGST'] == 1) ? round((($agencyMarkUpGST / 2)), 2) : 0,
'TotalCGST' => ($gstvalidate['CGST'] == 1) ? round((($agencyMarkUpGST / 2)), 2) : 0,
'TotalIGST' => ($gstvalidate['IGST'] == 1) ? round(($agencyMarkUpGST), 2) : 0,
'SumdiscountItem' => 0,
'OtherDiscount' => round(($TotalDiscount), 2),
'otherDiscountVal' => round(($TotalDiscount), 2),
'TotalAdvance' => ($checkPaymentStatus == 1) ? round(($PublishedFare), 2) : 0,
'TotalDueAmount' => ($checkPaymentStatus == 1) ? 0 : round(($PublishedFare), 2),
'InvoiceValue' => round(($PublishedFare), 2),
'notes' => 'Flight Ticket',
'termsandcondition' => '',
'client_state' => '',
'Advance' => 0,
'PaymentType' => 4,
'paymentNote' => 'Online',
'misxItems_name' => $misxItems_name,
];
$ICSourceSysId = isset($FlightBookingData[0]['ICSourceSysId']) ? $FlightBookingData[0]['ICSourceSysId'] : 0;
$APIBookingresponse = [];
$GTXUpdateresponse = [];
$Bookres = [];
$InvoiceCreate = [];
if ($ICSourceSysId == 30) {
$request = array(
'Auth_Header' => array(
"IP_Address" => $_SERVER['REMOTE_ADDR'],
"Request_Id" => $post['strUrlData'],
"IMEI_Number" => "3434334343111"
)
);
} elseif ($ICSourceSysId == 7) {
$request = array(
"EndUserIp" => $_SERVER['REMOTE_ADDR'],
'TokenAgencyId' => '',
'TokenMemberId' => '',
);
} else {
$request = array(
"EndUserIp" => $_SERVER['REMOTE_ADDR'],
'TokenAgencyId' => '',
'TokenMemberId' => '',
);
}
$DataS = array(
'apidata' => $request,
'memberCount' => $intMemberCount,
'JourneyType' => $JourneyType,
'interNationalSearch' => $interNationalSearch,
'searchID' => $bookingId,
'ICSourceSysId' => $ICSourceSysId,
'APIMode' => ($AgencySysId == 1) ? 1 : 0
);
$url = GTX_API_URL . '/flight/v3/getbalnace';
$getData['SecurityKey'] = $SecurityKey;
if ($ICSourceSysId == 8 || $ICSourceSysId == 9) {
$CashBalance = 999999;
} else {
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
$CashBalance = (isset($apiResponse['results']) && !empty($apiResponse['results'])) ? (float)$apiResponse['results'] : 0;
}
if ($FlightBookingData && $CashBalance >= (float) ceil($PublishedFare)) {
} else {
$response = array('success' => false, 'TrackId' => base64_encode($TPSysId), 'msg' => 'Sorry we could not process your booking. Please contact our customer support. (API Insufficient Balance)');
echo json_encode($response);
exit;
}
if ($ICSourceSysId == 8) {
$DataS = array(
'apidata' => [],
'BookingData' => $BookingData,
'customer' => $customer,
'gstData' => $gstData,
'memberCount' => $intMemberCount,
'JourneyType' => $JourneyType,
'interNationalSearch' => $interNationalSearch,
'searchID' => $bookingId,
'ICSourceSysId' => $ICSourceSysId,
'AgentMarkUp' => 0,
'APIMode' => ($AgencySysId == 1) ? 1 : 0
);
$url = GTX_API_URL . '/flight/v3/ticketing';
$getData['SecurityKey'] = $SecurityKey;
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
//$apiResponse = json_decode('{"status":true,"message":"SUCCESS","results":[{"FlightNumber":"SG-42563","SegFlightNumberArr":"SG-42563","AirlineName":"Spicejet","AirlineCode":"SG","IsLCC":true,"IsRefundable":"1","OnwardAutoTicket":"0","InwardAutoTicket":0,"IsRefundableTxt":"Refundable","SearchTraceId":"GTX000000008600","SearchFlightTraceId":"GTX000000008600","ApiResultIndex":"","DepartureTime":"02:00","ArrivalTime":"04:00","FromUTCTime":"2024-12-10 02:00","ToUTCTime":"2024-12-10 04:00:00","FareClass":"Economy","FlightDuration":"2h ","SourceAirportCode":"BOM","DestAirportCode":"DEL","StopCount":"Non-stop","NoOfSeatAvailable":96,"PublishedFare":3220,"JourneyType":2,"TripType":1,"IsInternational":0,"ICSourceSysId":8,"logo":"https://gtxapi.hellogtx.com/public/AirlineLogo/SG.png","FairRules":{"Currency":"INR","CurrencyRate":1,"currencySysId":1,"BaseFare":3000,"Tax":200,"intPublishedFare":3220,"PublishedFare":3220,"PublishedFareAgent":3220,"PublishedFarePerPax":1073,"CommDiscount":0,"TDS":0,"TDSEarn":0,"fareremarks":"","colors":"","IscheckinBagInc":true,"IscabinbagInc":true,"CheckinBaggage":"4KG","CabinBaggage":"4KG","IsMealIncludes":false,"IsSpecialReturn":false,"OfferedFare":3220,"OnwardAutoTicket":"0","Refundable":"1","IsRefundableTxt":"Refundable","PriceID":"2191_26240","fareIdentifier":"SPECIAL DEALS","SeatAvailable":"96","classOfBooking":"","FareClass":"Economy","FixedMarkUp":20,"GSTOnMarkUp":0,"CommissionEarned":0,"AgentMarkUp":0,"FareBreakdown":[{"Currency":"INR","PassengerType":1,"PassengerCount":"1","PaxType":"ADULT","Tax":100,"BaseFare":1500,"PublishedFare":1610,"OfferedFare":1500,"CommissionEarned":0,"TaxBR":{"TDS":0,"MF":0,"YQ":0,"AGST":0,"MFT":0,"OT":100,"MU":0,"YR":0},"FixedMarkUp":10,"GSTOnMarkUp":0,"TDSEarn":0,"TDS":0,"ApiNCM":0,"CommDiscount":0,"Baggage":"4KG","CabinBaggage":"4KG"},{"Currency":"INR","PassengerType":2,"PaxType":"CHILD","PassengerCount":"1","BaseFare":1500,"OfferedFare":1500,"PublishedFare":1610,"CommissionEarned":0,"TaxBR":{"TDS":0,"MF":0,"YQ":0,"AGST":0,"MFT":0,"OT":100,"MU":0,"YR":0},"FixedMarkUp":10,"GSTOnMarkUp":0,"Tax":100,"TDSEarn":0,"TDS":0,"ApiNCM":0,"CommDiscount":0,"Baggage":"4KG","CabinBaggage":"4KG"},{"Currency":"INR","PassengerType":3,"PaxType":"INFANT","PassengerCount":"1","BaseFare":0,"OfferedFare":0,"PublishedFare":0,"CommissionEarned":0,"TaxBR":{"TDS":0,"MF":0,"YQ":0,"AGST":0,"MFT":0,"OT":0,"MU":0,"YR":0},"FixedMarkUp":0,"GSTOnMarkUp":0,"TDSEarn":0,"Tax":100,"ApiNCM":0,"TDS":0,"CommDiscount":0,"Baggage":"4KG","CabinBaggage":"4KG"}],"OnwardGroupPNR":"","InwardGroupPNR":"","OnwardGroupPNRDummy":"HGYFJK","tripbinfo":{"BOM-DEL":{"ADULT":{"cabin":"4KG","checkin":"4KG"}}}},"Segments":[{"segmentid":"","isReturnSegment":false,"destinationAirportCode":"DEL","SegFlightNumber":"SG-42563","AirlineCode":"SG","AirlineName":"SpiceJet","originAirportCode":"BOM","IscabinbagInc":true,"NoOfSeatAvailable":"96","strDepartureDtTime":"02:00","strArrivalDtTime":"04:00","FlightDuration":"02 hours 00 minute","filePath":"https://gtxapi.hellogtx.com/public/AirlineLogo/SG.png","originAirportName":" Chhatrapati Shivaji (BOM), India","destinationAirportName":" Delhi Indira Gandhi Intl (DEL), India","originCityName":"Mumbai","originCountryName":"India","destinationCityName":"Delhi","destinationCountryName":"India","destinationArrTime":"2024-12-10 04:00","FareClass":"Economy","originDepTime":"2024-12-10 02:00","TripIndicator":"","Duration":120,"GroundTime":0,"LAYOVERDuration":null,"LAYOVERCity":"","DepTerminal":"","ArrTerminal":"","arrivingnextday":"","cabinClass":"Economy","IscheckinBagInc":true,"CheckinBaggage":"4KG","CabinBaggage":"4KG","IsMealIncludes":false}],"FareRules":"","CancellationPolicy":"","InternalRemarks":"","FilterDepartureDtTime":"00:00-10:00","FilterArrivalDtTime":"00:00-10:00","OnwardGroupPNR":"","InwardGroupPNR":"","OnwardGroupPNRDummy":"HGYFJK","IsSeriesFareData":true,"SupplierSysId":"11952","isDobAdult":false,"isDobChild":false,"isDobInfant":true,"Ispassengercity":false,"Ispassengeraddress":false,"isGSTMandatory":false,"IsPassMandatory":false,"IsPassExpiry":false,"IsPassIssue":false,"IsPassDateOfBirth":false,"isHoldAllowed":false,"ResponseStatus":true,"ErrorMessage":"Inventory Sold","bookingId":"GTX000000008600","APIBookingId":"419DBB52D41947B6A4CE97DA98BFC616"},{"FlightNumber":"6E-85692","SegFlightNumberArr":"6E-85692","AirlineName":"Indigo","AirlineCode":"6E","IsLCC":true,"IsRefundable":"1","OnwardAutoTicket":"1","InwardAutoTicket":0,"IsRefundableTxt":"Refundable","SearchTraceId":"GTX000000008600","SearchFlightTraceId":"GTX000000008600","ApiResultIndex":"","DepartureTime":"01:00","ArrivalTime":"03:00","FromUTCTime":"2024-12-15 01:00","ToUTCTime":"2024-12-15 03:00:00","FareClass":"Economy","FlightDuration":"2h ","SourceAirportCode":"DEL","DestAirportCode":"BOM","StopCount":"Non-stop","NoOfSeatAvailable":98,"PublishedFare":2220,"JourneyType":2,"TripType":1,"IsInternational":0,"ICSourceSysId":8,"logo":"https://gtxapi.hellogtx.com/public/AirlineLogo/6E.png","FairRules":{"Currency":"INR","CurrencyRate":1,"currencySysId":1,"BaseFare":2000,"Tax":200,"intPublishedFare":2220,"PublishedFare":2220,"PublishedFareAgent":2220,"PublishedFarePerPax":740,"CommDiscount":0,"TDS":0,"TDSEarn":0,"fareremarks":"","colors":"","IscheckinBagInc":true,"IscabinbagInc":true,"CheckinBaggage":"5kg","CabinBaggage":"4kg","IsMealIncludes":false,"IsSpecialReturn":false,"OfferedFare":2220,"OnwardAutoTicket":"1","Refundable":"1","IsRefundableTxt":"Refundable","PriceID":"2190_26239","fareIdentifier":"SPECIAL DEALS","SeatAvailable":"98","classOfBooking":"","FareClass":"Economy","FixedMarkUp":20,"GSTOnMarkUp":0,"CommissionEarned":0,"AgentMarkUp":0,"FareBreakdown":[{"Currency":"INR","PassengerType":1,"PassengerCount":"1","PaxType":"ADULT","Tax":100,"BaseFare":1000,"PublishedFare":1110,"OfferedFare":1000,"CommissionEarned":0,"TaxBR":{"TDS":0,"MF":0,"YQ":0,"AGST":0,"MFT":0,"OT":100,"MU":0,"YR":0},"FixedMarkUp":10,"GSTOnMarkUp":0,"TDSEarn":0,"TDS":0,"ApiNCM":0,"CommDiscount":0,"Baggage":"5kg","CabinBaggage":"4kg"},{"Currency":"INR","PassengerType":2,"PaxType":"CHILD","PassengerCount":"1","BaseFare":1000,"OfferedFare":1000,"PublishedFare":1110,"CommissionEarned":0,"TaxBR":{"TDS":0,"MF":0,"YQ":0,"AGST":0,"MFT":0,"OT":100,"MU":0,"YR":0},"FixedMarkUp":10,"GSTOnMarkUp":0,"Tax":100,"TDSEarn":0,"TDS":0,"ApiNCM":0,"CommDiscount":0,"Baggage":"5kg","CabinBaggage":"4kg"},{"Currency":"INR","PassengerType":3,"PaxType":"INFANT","PassengerCount":"1","BaseFare":0,"OfferedFare":0,"PublishedFare":0,"CommissionEarned":0,"TaxBR":{"TDS":0,"MF":0,"YQ":0,"AGST":0,"MFT":0,"OT":0,"MU":0,"YR":0},"FixedMarkUp":0,"GSTOnMarkUp":0,"TDSEarn":0,"Tax":100,"ApiNCM":0,"TDS":0,"CommDiscount":0,"Baggage":"5kg","CabinBaggage":"4kg"}],"OnwardGroupPNR":"QAHGYT","InwardGroupPNR":"","OnwardGroupPNRDummy":"QAHGYT","tripbinfo":{"DEL-BOM":{"ADULT":{"cabin":"4kg","checkin":"5kg"}}}},"Segments":[{"segmentid":"","isReturnSegment":false,"destinationAirportCode":"BOM","SegFlightNumber":"6E-85692","AirlineCode":"6E","AirlineName":"IndiGo","originAirportCode":"DEL","IscabinbagInc":true,"NoOfSeatAvailable":"98","strDepartureDtTime":"01:00","strArrivalDtTime":"03:00","FlightDuration":"02 hours 00 minute","filePath":"https://gtxapi.hellogtx.com/public/AirlineLogo/6E.png","originAirportName":" Delhi Indira Gandhi Intl (DEL), India","destinationAirportName":" Chhatrapati Shivaji (BOM), India","originCityName":"Delhi","originCountryName":"India","destinationCityName":"Mumbai","destinationCountryName":"India","destinationArrTime":"2024-12-15 03:00","FareClass":"Economy","originDepTime":"2024-12-15 01:00","TripIndicator":"","Duration":120,"GroundTime":0,"LAYOVERDuration":null,"LAYOVERCity":"","DepTerminal":"3","ArrTerminal":"2","arrivingnextday":"","cabinClass":"Economy","IscheckinBagInc":true,"CheckinBaggage":"5kg","CabinBaggage":"4kg","IsMealIncludes":false}],"FareRules":"","CancellationPolicy":"","InternalRemarks":"","FilterDepartureDtTime":"00:00-10:00","FilterArrivalDtTime":"00:00-10:00","OnwardGroupPNR":"QAHGYT","InwardGroupPNR":"","OnwardGroupPNRDummy":"QAHGYT","IsSeriesFareData":true,"SupplierSysId":"11952","isDobAdult":false,"isDobChild":false,"isDobInfant":true,"Ispassengercity":false,"Ispassengeraddress":false,"isGSTMandatory":false,"IsPassMandatory":false,"IsPassExpiry":false,"IsPassIssue":false,"IsPassDateOfBirth":false,"isHoldAllowed":false,"ResponseStatus":true,"ErrorMessage":"Inventory Sold","bookingId":"GTX000000008600","APIBookingId":"EFD60F24FFE648BF833721B71722D869"}],"Invoicedata":{"AgentSysId":0,"CustomerSysId":0,"TPSysId":0,"MasterTPSysId":0,"ProposalID":"0/V1","InvoiceDate":"2024-12-03","isDisplayMarkup":true,"PaymentDueDate":"2024-12-03","PaymentDate":"2024-12-03","ClientGST":0,"ClientGSTNumber":"","Currency":1,"TotalInvoiceValue":5640,"InvoiceStatus":1,"TotalSGST":0,"TotalCGST":0,"TotalIGST":0,"SumdiscountItem":0,"OtherDiscount":0,"otherDiscountVal":0,"TotalAdvance":5640,"TotalDueAmount":5640,"InvoiceValue":5640,"notes":"Flight Ticket","termsandcondition":"","client_state":"","Advance":0,"PaymentType":4,"paymentNote":"Online","misxItems_name":[{"AgencySysId":1,"AgentSysId":0,"MisxItems_name":"Flight","Description":"BOM-DEL-Spicejet SG-42563","ItemQty":1,"ItemRates":3300,"Total":3300,"DiscountType":1,"Discount":1,"TotalDiscount":0,"TotalAmount":3320,"MarkupType":"","Markup":20,"TotalMarkup":20,"SubTotal":3320,"ServiceFeeTotal":0,"GSTPercentage":"18","TotalGST":0,"SGST":0,"CGST":0,"IGST":0,"ItemsSACCode":""},{"AgencySysId":1,"AgentSysId":0,"MisxItems_name":"Flight","Description":"DEL-BOM-Indigo 6E-85692","ItemQty":1,"ItemRates":2300,"Total":2300,"DiscountType":1,"Discount":1,"TotalDiscount":0,"TotalAmount":2320,"MarkupType":"","Markup":20,"TotalMarkup":20,"SubTotal":2320,"ServiceFeeTotal":0,"GSTPercentage":"18","TotalGST":0,"SGST":0,"CGST":0,"IGST":0,"ItemsSACCode":""}]}}', 1);
// echo (json_encode($apiResponse));
// die('ddd');
$ResponseStatus = isset($apiResponse['status']) ? $apiResponse['status'] : false;
$ErrorMessage = isset($apiResponse['message']) ? $apiResponse['message'] : '';
$BookingData = isset($apiResponse['results']) ? $apiResponse['results'] : [];
$BookStatus = $ResponseStatus;
$Bookres = $apiResponse;
} else if ($ICSourceSysId == 3) {
if ($BookingData && $CashBalance >= (float) ceil($PublishedFare)) {
$DataS = array(
'apidata' => [],
'BookingData' => $BookingData,
'customer' => $customer,
'gstData' => $gstData,
'memberCount' => $intMemberCount,
'JourneyType' => $JourneyType,
'interNationalSearch' => $interNationalSearch,
'searchID' => $bookingId,
'ICSourceSysId' => $ICSourceSysId,
'AgentMarkUp' => 0,
'APIMode' => ($AgencySysId == 1) ? 1 : 0
);
// echo (json_encode($DataS));
// die('wwwwwww');
$url = GTX_API_URL . '/flight/v3/ticketing';
$getData['SecurityKey'] = $SecurityKey;
$Bookres = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
// echo json_encode($Bookres);
// die('ddd');
$ErrorMessage = isset($Bookres['message']) ? $Bookres['message'] : '';
foreach ($BookingData as $k => $value) {
$response = isset($Bookres['results'][$k]) ? $Bookres['results'][$k] : [];
$APIBookingresponse[] = $response;
$IsBookingStatus = isset($response['IsBookingStatus']) ? $response['IsBookingStatus'] : 0;
if ($IsBookingStatus == 1) {
if ($k == 0) {
$InvoiceCreate = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->InvoiceCreate($Invoicedata, $BookingData, $SecurityKey, $AgencySysId);
}
$response['PublishedFare'] = $PublishedFare;
$response['MasterTPSysId'] = $MasterTPSysId;
$response['TPSysId'] = $TPSysId;
$response['TrxId'] = $TrxId;
$response['TrxOrdDocId'] = 19;
$response['VersionId'] = $VersionId[$k];
$URL = $this->baseUrl . "/gtxwebservices/flight-api/updatebooking";
$result = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($response, $getData, $URL);
} else {
$response = array(
'MasterTPSysId' => $MasterTPSysId,
'TPSysId' => $TPSysId,
'TrxId' => $TrxId,
'field' => 'BookingStatus',
'XRefBookingId' => '',
'ErrorCode' => 6,
'StatusCode' => 144,
'APIMode' => ($AgencySysId == 1) ? 1 : 0,
);
$URL = $this->baseUrl . "/gtxwebservices/flight/update-api-payment-failed";
$result = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getHttpRequestArray($response, $URL);
}
$GTXUpdateresponse[] = $result;
}
}
} else if ($ICSourceSysId == 9) {
$ResponseStatus = true;
$ErrorMessage = 'Offline';
$BookStatus = true;
$Bookres = [];
} else {
if ($BookingData && $CashBalance >= (float) ceil($PublishedFare)) {
$DataS = array(
'apidata' => [],
'BookingData' => $BookingData,
'customer' => $customer,
'memberCount' => $intMemberCount,
'JourneyType' => $JourneyType,
'interNationalSearch' => $interNationalSearch,
'searchID' => $bookingId,
'ICSourceSysId' => $ICSourceSysId,
'AgentMarkUp' => 0,
'gstData' => $gstData,
'APIMode' => ($AgencySysId == 1) ? 1 : 0
);
// echo (json_encode($DataS));
// die('ddd');
$url = GTX_API_URL . '/flight/v3/book';
$getData['SecurityKey'] = $SecurityKey;
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
//$apiResponse = json_decode('{"status":true,"message":"SUCCESS","results":{"bookingId":"TJS102801558376","status":{"success":true,"httpStatus":200}},"TransactionStatus":"","BookingId":"","Invoicedata":{"AgentSysId":0,"CustomerSysId":0,"TPSysId":0,"MasterTPSysId":0,"ProposalID":"0/V1","InvoiceDate":"2025-07-30","isDisplayMarkup":true,"PaymentDueDate":"2025-07-30","PaymentDate":"2025-07-30","ClientGST":0,"ClientGSTNumber":"","Currency":1,"TotalInvoiceValue":2887,"InvoiceStatus":1,"TotalSGST":45,"TotalCGST":45,"TotalIGST":0,"SumdiscountItem":0,"OtherDiscount":0,"otherDiscountVal":0,"TotalAdvance":2977,"TotalDueAmount":2977,"InvoiceValue":2977,"notes":"Flight Ticket","termsandcondition":"","client_state":"","Advance":0,"PaymentType":4,"paymentNote":"Online","misxItems_name":[{"AgencySysId":1,"AgentSysId":0,"MisxItems_name":"Flight","Description":"DEL-JAI-Indigo 6E-2042","ItemQty":1,"ItemRates":2387,"Total":2387,"DiscountType":1,"Discount":1,"TotalDiscount":0,"TotalAmount":2977,"MarkupType":"","Markup":500,"TotalMarkup":500,"SubTotal":2887,"ServiceFeeTotal":90,"GSTPercentage":"18","TotalGST":90,"SGST":45,"CGST":45,"IGST":90,"ItemsSACCode":""}]}}', 1);
// echo (json_encode($apiResponse));
// die;
$ResponseStatus = isset($apiResponse['status']) ? $apiResponse['status'] : false;
$ErrorMessage = isset($apiResponse['message']) ? $apiResponse['message'] : '';
$InvoicedataApi = isset($apiResponse['Invoicedata']) ? $apiResponse['Invoicedata'] : '';
$BookStatus = isset($apiResponse['results']['status']['success']) ? $apiResponse['results']['status']['success'] : false;
$Bookres = $apiResponse;
}
}
if ($ResponseStatus == 1) {
$requestDetail = [];
$DataS = array(
'apidata' => $requestDetail,
'BookingData' => $BookingData,
'customer' => $customer,
'memberCount' => $intMemberCount,
'JourneyType' => $JourneyType,
'interNationalSearch' => $interNationalSearch,
'searchID' => $bookingId,
'ICSourceSysId' => $ICSourceSysId,
'AgentMarkUp' => 0,
'APIMode' => ($AgencySysId == 1) ? 1 : 0
);
$url = GTX_API_URL . '/flight/v3/reprint';
$getData['SecurityKey'] = $SecurityKey;
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
$APIBookingresponse = $apiResponse;
$status = isset($apiResponse['status']) ? $apiResponse['status'] : false;
$message = isset($apiResponse['message']) ? $apiResponse['message'] : '';
$response = isset($apiResponse['results']) ? $apiResponse['results'] : [];
$OrderBookingStatus = isset($response['order']['status']) ? $response['order']['status'] : '';
$BookStatus = isset($response['status']['success']) ? $response['status']['success'] : $BookStatus;
if ($status == 1 && $BookStatus == 1 && $OrderBookingStatus != 'ABORTED') {
$InvoiceCreate = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->InvoiceCreate($Invoicedata, $BookingData, $SecurityKey, $AgencySysId);
foreach ($BookingData as $k => $value) {
$postField = isset($apiResponse['postField'][$k]) ? $apiResponse['postField'][$k] : [];
$postField['PublishedFare'] = $PublishedFare;
$postField['MasterTPSysId'] = $MasterTPSysId;
$postField['TPSysId'] = $TPSysId;
$postField['TrxId'] = $TrxId;
$postField['TrxOrdDocId'] = 19;
$postField['VersionId'] = $VersionId[$k];
$URL = $this->baseUrl . "/gtxwebservices/flight-api/updatebooking";
$result = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($postField, $getData, $URL);
$GTXUpdateresponse = $result;
// echo '<pre>';
// print_r(($result));
// die;
}
} else {
$response = array(
'MasterTPSysId' => $MasterTPSysId,
'TPSysId' => $TPSysId,
'TrxId' => $TrxId,
'field' => 'BookingStatus',
'XRefBookingId' => '',
'ErrorCode' => 6,
'StatusCode' => 144,
'APIMode' => ($AgencySysId == 1) ? 1 : 0,
);
$URL = $this->baseUrl . "/gtxwebservices/flight/update-api-payment-failed";
$result = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getHttpRequestArray($response, $URL);
$GTXUpdateresponse = $result;
}
} else {
$response = array(
'MasterTPSysId' => $MasterTPSysId,
'TPSysId' => $TPSysId,
'TrxId' => $TrxId,
'field' => 'BookingStatus',
'XRefBookingId' => '',
'ErrorCode' => 6,
'StatusCode' => 144,
'APIMode' => ($AgencySysId == 1) ? 1 : 0,
);
$URL = $this->baseUrl . "/gtxwebservices/flight/update-api-payment-failed";
$result = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getHttpRequestArray($response, $URL);
$GTXUpdateresponse = $result;
}
$arrUrlData['Bookres'] = $Bookres;
$arrUrlData['InvoiceCreate'] = $InvoiceCreate;
$arrUrlData['GTXUpdateresponse'] = $GTXUpdateresponse;
$arrUrlData['APIBookingresponse'] = $APIBookingresponse;
$arrUrlData['message'] = $message;
$tempData = array(
'TPSysId' => $TPSysId,
'TraceId' => $bookingId,
'APIBookingData' => json_encode($arrUrlData),
);
$objFlight->deleteFlightTempData($bookingId);
$objFlight->insertFlightTempData($tempData);
$URLDATA = base64_encode(json_encode(['TPSysId' => $TPSysId, 'SecurityKey' => $SecurityKey]));
$secureCode = Catabatic_ValidateCustomer::secureCode(base64_encode($TPSysId), 1);
$this->_redirect('/flight-proposal-new/booking-confirmation/data/' . $URLDATA . '/code/' . $secureCode);
// echo '<pre>apiResponse';
// print_r(($apiResponse));
// die;
}
}
public function bookingConfirmationAction()
{
$getData = $this->getRequest()->getParams();
$objFlight = new Travel_Model_TblFlight();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$code = $getData['code'];
$strUrlData = json_decode(base64_decode($getData['data']), 1);
$data = isset($strUrlData['TPSysId']) ? $strUrlData['TPSysId'] : 0;
$SecurityKey = isset($strUrlData['SecurityKey']) ? $strUrlData['SecurityKey'] : '';
$secureCode = Catabatic_ValidateCustomer::secureCode(base64_encode($data), 1);
// echo '<pre>strUrlData';
// print_r(($strUrlData));
// echo '<pre>apiResponse';
// print_r(($getData));
// die;
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
$getData['SecurityKey'] = $SecurityKey;
$PostData = ['TPSysId' => ($data), 'version' => null, 'IsApproved' => 0];
$URL = $this->baseUrl . "/gtxwebservices/flight-api/bookingdetails/";
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($PostData, $getData, $URL);
$FlightBookingData = $bookingDataByAPI = isset($apiResponse['FlightBookingData']) ? $apiResponse['FlightBookingData'] : [];
$passengerData = $arrtravellerList = isset($apiResponse['customer']) ? $apiResponse['customer'] : [];
$CustomerDetails = isset($apiResponse['CustomerDetails']) ? $apiResponse['CustomerDetails'] : [];
$MasterTPSysId = isset($FlightBookingData[0]['MasterTPSysId']) ? trim($FlightBookingData[0]['MasterTPSysId']) : '0';
$objFlightProposal = new Travel_Model_TblFlightProposal();
$arrAgencyDetails = $this->view->arrAgencyDetails = $objFlightProposal->getProposalAgencyDetails($data);
// echo '<pre>apiResponse';
// print_r(($apiResponse));
// die;
$BaseFare = 0;
$Taxesfee = 0;
$CommDiscount = 0;
$TotalPay = 0;
$ServiceFee__ = 0;
$AirlineTax = 0;
$FuelSurcharge = 0;
$GSTOnMarkUp_ = 0;
$FixedMarkUp_ = 0;
$CommissionEarned_ = 0;
$TDSEarn_ = 0;
$XRefBookingId = [];
$AirlineRefPNR = [];
$AirlineRefGDSPNR = [];
if ($FlightBookingData) {
foreach ($FlightBookingData as $key => $value) {
$XRefBookingId[] = trim($value['XRefBookingId']);
if (!empty(trim($value['AirlineRefPNR']))) {
$AirlineRefPNR[] = trim($value['AirlineRefPNR']);
}
if (!empty(trim($value['AirlineRefGDSPNR']))) {
$AirlineRefGDSPNR[] = trim($value['AirlineRefGDSPNR']);
}
foreach ($value['FareBreakdown'] as $FareBreakdown) {
$BaseFare += isset($FareBreakdown['BaseFare']) ? ($FareBreakdown['BaseFare']) : 0;
$BaseFare_ = isset($FareBreakdown['BaseFare']) ? ($FareBreakdown['BaseFare']) : 0;
$TDSEarn = isset($FareBreakdown['TDSEarn']) ? ($FareBreakdown['TDSEarn']) : 0;
$FixedMarkUp = isset($FareBreakdown['FixedMarkUp']) ? ($FareBreakdown['FixedMarkUp']) : 0;
$GSTOnMarkUp = isset($FareBreakdown['GSTOnMarkUp']) ? ($FareBreakdown['GSTOnMarkUp']) : 0;
$CommissionEarned = isset($FareBreakdown['CommissionEarned']) ? ($FareBreakdown['CommissionEarned']) : 0;
$CommDiscount += isset($FareBreakdown['CommDiscount']) ? ($FareBreakdown['CommDiscount']) : 0;
$Tax = isset($FareBreakdown['Tax']) ? ($FareBreakdown['Tax']) : 0;
$YQ = isset($FareBreakdown['TaxBR']['YQ']) ? ($FareBreakdown['TaxBR']['YQ']) : 0;
$Taxesfee += ($FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
$TotalPay += ($BaseFare_ + $FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
$ServiceFee__ += ($FixedMarkUp + $GSTOnMarkUp);
$AirlineTax += ($Tax);
$FuelSurcharge += ($YQ);
$GSTOnMarkUp_ += ($GSTOnMarkUp);
$FixedMarkUp_ += ($FixedMarkUp);
$CommissionEarned_ += ($CommissionEarned);
$TDSEarn_ += ($TDSEarn);
}
}
}
$BagPrice = 0;
$MealPrice = 0;
$SeatPrice = 0;
foreach ($passengerData as $kkkk => $ValCustomer) {
$BagPrice += !empty($ValCustomer['BagPrice']) ? $ValCustomer['BagPrice'] : 0;
$MealPrice += !empty($ValCustomer['MealPrice']) ? $ValCustomer['MealPrice'] : 0;
$SeatPrice += !empty($ValCustomer['SeatPrice']) ? $ValCustomer['SeatPrice'] : 0;
}
$fare = [
'Currency' => isset($FlightBookingData[0]['CurrencySymbol']) ? trim($FlightBookingData[0]['CurrencySymbol']) : 'INR',
'BaseFare' => round($BaseFare, 2),
'Taxesfee' => round($Taxesfee, 2),
'CommDiscount' => round($CommDiscount, 2),
'CommissionEarned' => round($CommissionEarned_, 2),
'TDSEarn' => round($TDSEarn_, 2),
'TotalPay' => round($TotalPay + $MealPrice + $BagPrice + $SeatPrice, 2),
'AirlineTax' => round($AirlineTax, 2),
'FuelSurcharge' => round($FuelSurcharge, 2),
'FixedMarkUp' => round($FixedMarkUp_, 2),
'GSTOnMarkUp' => round($GSTOnMarkUp_, 2),
'MealPrice' => $MealPrice,
'BagPrice' => $BagPrice,
'SeatPrice' => $SeatPrice,
'TotalSSR' => ($MealPrice + $BagPrice + $SeatPrice),
'TotalProfit' => round(($TDSEarn_ + $CommissionEarned_ + $FixedMarkUp_ + $GSTOnMarkUp_), 2),
];
$this->view->FlightBookingData = $FlightBookingData;
$this->view->arrtravellerList = $passengerData;
$this->view->fare = $fare;
$this->view->CustomerDetails = $CustomerDetails;
$this->view->TPSysId = $data;
$this->view->code = $code;
$this->view->getData = $getData;
$this->view->AirlineRefPNR = array_values(array_unique($AirlineRefPNR));
$this->view->AirlineRefGDSPNR = array_values(array_unique($AirlineRefGDSPNR));
$this->view->XRefBookingId = array_values(array_unique($XRefBookingId));
$this->view->intTPSysId = base64_decode($data);
// echo '<pre>apiResponse';
// print_r(($arrAgencyDetails));
// echo '<pre>apiResponse';
// print_r(($apiResponse));
// die;
}
public function eTicketMailAction()
{
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
$this->_helper->layout->disableLayout();
$versionId = 0;
$getData = $this->getRequest()->getParams();
$code = $getData['code'];
$strUrlData = json_decode(base64_decode($getData['data']), 1);
$intTPSysId = isset($strUrlData['TPSysId']) ? $strUrlData['TPSysId'] : 0;
$SecurityKey = isset($strUrlData['SecurityKey']) ? $strUrlData['SecurityKey'] : '';
$secureCode = Catabatic_ValidateCustomer::secureCode(base64_encode($intTPSysId), 1);
// echo '<pre>strUrlData';
// print_r(($strUrlData));
// echo '<pre>apiResponse';
// print_r(($getData));
// die;
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
$objFlight = new Travel_Model_TblFlight();
$objAgency = new Travel_Model_TblAgency();
$getData['SecurityKey'] = $SecurityKey;
$PostData = ['TPSysId' => $intTPSysId, 'IsApproved' => 0, 'version' => $versionId];
$URL = $this->baseUrl . "/gtxwebservices/flight-api/bookingdetails/";
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($PostData, $getData, $URL);
$this->view->CustomerDetails = $apiResponse['CustomerDetails'];
$bookingDataByAPI = isset($apiResponse['FlightBookingData']) ? $apiResponse['FlightBookingData'] : [];
$arrtravellerList = isset($apiResponse['customer']) ? $apiResponse['customer'] : [];
$arrtraveller = [];
if ($arrtravellerList) {
foreach ($arrtravellerList as $valpax) {
$arrtraveller[$valpax['VersionId']][] = $valpax;
}
}
// echo "<pre>";
// print_r($arrtraveller);
// print_r($arrtravellerList);
// die;
$IsInternational = $bookingDataByAPI[0]['IsInternational'];
if ($IsInternational == 1) {
$ItemSourceType = 2;
} else {
$ItemSourceType = 1;
}
$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getSupportContact(1, 1, $ItemSourceType, '', $SecurityKey);
$this->view->arrtraveller = $arrtraveller;
$this->view->arrtravellerList = $arrtravellerList;
$this->view->getSupportContact = $getSupportContact;
$this->view->bookingDataByAPI = $bookingDataByAPI;
$this->view->intTPSysId = $this->getRequest()->getParam("id");
$this->view->version = $versionId;
$this->view->withprice = 1;
$intCustomerSysId = $bookingDataByAPI[0]['CustomerSysId'];
}
public function eTicketMailDownloadAction()
{
$this->_helper->layout->disableLayout();
$versionId = 0;
$getData = $this->getRequest()->getParams();
$code = $getData['code'];
$strUrlData = json_decode(base64_decode($getData['data']), 1);
$intTPSysId = isset($strUrlData['TPSysId']) ? $strUrlData['TPSysId'] : 0;
$SecurityKey = isset($strUrlData['SecurityKey']) ? $strUrlData['SecurityKey'] : '';
$secureCode = Catabatic_ValidateCustomer::secureCode(base64_encode($intTPSysId), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
$objFlight = new Travel_Model_TblFlight();
$objAgency = new Travel_Model_TblAgency();
$getData['SecurityKey'] = $SecurityKey;
$PostData = ['TPSysId' => $intTPSysId, 'IsApproved' => 0, 'version' => $versionId];
$URL = $this->baseUrl . "/gtxwebservices/flight-api/bookingdetails/";
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($PostData, $getData, $URL);
$CustomerDetails = $apiResponse['CustomerDetails'];
$bookingDataByAPI = isset($apiResponse['FlightBookingData']) ? $apiResponse['FlightBookingData'] : [];
$arrtravellerList = isset($apiResponse['customer']) ? $apiResponse['customer'] : [];
$arrtraveller = [];
if ($arrtravellerList) {
foreach ($arrtravellerList as $valpax) {
$arrtraveller[$valpax['VersionId']][] = $valpax;
}
}
$IsInternational = $bookingDataByAPI[0]['IsInternational'];
if ($IsInternational == 1) {
$ItemSourceType = 2;
} else {
$ItemSourceType = 1;
}
$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getSupportContact(1, 1, $ItemSourceType, '', $SecurityKey);
$this->view->arrtraveller = $arrtraveller;
$this->view->arrtravellerList = $arrtravellerList;
$this->view->getSupportContact = $getSupportContact;
$this->view->bookingDataByAPI = $bookingDataByAPI;
$this->view->intTPSysId = $this->getRequest()->getParam("id");
$this->view->version = $versionId;
$this->view->withprice = 1;
$XRefBookingId = $bookingDataByAPI[0]['XRefBookingId'];
$intCustomerSysId = $bookingDataByAPI[0]['CustomerSysId'];
$params = array(
'baseUrl' => $this->baseUrl,
'intTPSysId' => $intTPSysId,
'arrtraveller' => $arrtraveller,
'arrtravellerList' => $arrtravellerList,
'getSupportContact' => $getSupportContact,
'bookingDataByAPI' => $bookingDataByAPI,
'version' => $versionId,
'CustomerDetails' => $CustomerDetails,
'withprice' => 1,
);
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight-proposal-new/');
$html->assign($params);
$Body = $html->render('e-ticket-mail-download.phtml');
$html = <<<EOF
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
$Body
EOF;
// echo $html;
// exit;
Zend_Controller_Action_HelperBroker::getStaticHelper("DownloadPdf")->savedownloadpdf($html, $XRefBookingId);
exit();
}
public function invoiceNewAction()
{
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
$this->_helper->layout->disableLayout();
$versionId = 0;
$getData = $this->getRequest()->getParams();
$code = $getData['code'];
$strUrlData = json_decode(base64_decode($getData['data']), 1);
$intTPSysId = isset($strUrlData['TPSysId']) ? $strUrlData['TPSysId'] : 0;
$SecurityKey = isset($strUrlData['SecurityKey']) ? $strUrlData['SecurityKey'] : '';
$secureCode = Catabatic_ValidateCustomer::secureCode(base64_encode($intTPSysId), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
$objFlight = new Travel_Model_TblFlight();
$objAgency = new Travel_Model_TblAgency();
$getData['SecurityKey'] = $SecurityKey;
$PostData = ['TPSysId' => $intTPSysId, 'IsApproved' => 0, 'version' => $versionId];
$URL = $this->baseUrl . "/gtxwebservices/flight-api/bookingdetails/";
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($PostData, $getData, $URL);
$CustomerDetails = $apiResponse['CustomerDetails'];
$bookingDataByAPI = isset($apiResponse['FlightBookingData']) ? $apiResponse['FlightBookingData'] : [];
$arrtravellerList = isset($apiResponse['customer']) ? $apiResponse['customer'] : [];
$arrtraveller = [];
if ($arrtravellerList) {
foreach ($arrtravellerList as $valpax) {
$arrtraveller[$valpax['VersionId']][] = $valpax;
}
}
// echo "<pre>";
// print_r($bookingDataByAPI);
// die;
$AgencySysId = $bookingDataByAPI[0]['AgencySysId'];
$IsInternational = $bookingDataByAPI[0]['IsInternational'];
if ($IsInternational == 1) {
$ItemSourceType = 2;
} else {
$ItemSourceType = 1;
}
$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getSupportContact(1, 1, $ItemSourceType, '', $SecurityKey);
$FareBreakdownarr = [];
$FlightNumber = [];
if ($bookingDataByAPI) {
foreach ($bookingDataByAPI as $value) {
if ($value['Segments']) {
foreach ($value['Segments'] as $flight) {
//$FlightNumber[] = $flight['FlightNumber'];
$FlightNumber[$flight['OriginAirportCode'] . '-' . $flight['DestAirportCode']] = $flight['FlightNumber'];
}
}
$AddTotalCost = isset($value['AddTotalCost']) ? ($value['AddTotalCost'] / count($value['FareBreakdown'])) : 0;
// echo "<pre>";
// print_r($value);
// echo "</pre>";
if ($value['FareBreakdown']) {
foreach ($value['FareBreakdown'] as $fare) {
$PassengerCount = $fare['PassengerCount'];
$FareBreakdownarr[$fare['PassengerType']]['PassengerCount'] = $fare['PassengerCount'];
$FareBreakdownarr[$fare['PassengerType']]['BaseFare'] += ($fare['BaseFare'] / $PassengerCount);
$FareBreakdownarr[$fare['PassengerType']]['Tax'] += $fare['Tax'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['YQTax'] += $fare['YQTax'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['CommissionEarned'] += $fare['CommissionEarned'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['OtherCharges'] += $fare['OtherCharges'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['FixedMarkUp'] += $fare['FixedMarkUp'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['GSTOnMarkUp'] += $fare['GSTOnMarkUp'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['Discount'] += $fare['Discount'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['TDSEarn'] += $fare['TDSEarn'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['MF'] += $fare['MF'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['AGST'] += $fare['AGST'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['MFT'] += $fare['MFT'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['YR'] += $fare['YR'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['couponVal'] += $fare['couponVal'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['AddTotalCost'] += $AddTotalCost / $PassengerCount;
}
}
}
}
$URL = GTX_API_URL . '/flight/v3/get-agency-term-and-condtions';
$getDatas['SecurityKey'] = $SecurityKey;
$PostData = ['AgencySysId' => $AgencySysId];
$TermsAndCondition = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($PostData, $getDatas, $URL);
$FlightInvoice = isset($TermsAndCondition['results']['FlightInvoice']) ? $TermsAndCondition['results']['FlightInvoice'] : '';
// echo "<pre>";
// print_r($TermsAndCondition);
// echo "<pre>";
// print_r($URL);
// echo "<pre>";
// print_r($getDatas);
// die;
$this->view->TaxLabelId = 0;
$this->view->arrtravellerList = $arrtravellerList;
$this->view->FlightInvoice = $FlightInvoice;
$this->view->getSupportContact = $getSupportContact;
$this->view->bookingDataByAPI = $bookingDataByAPI;
$this->view->FareBreakdownarr = $FareBreakdownarr;
$this->view->FlightNumber = $FlightNumber;
$this->view->intTPSysId = $this->getRequest()->getParam("id");
$this->view->version = $versionId;
$this->view->withprice = 1;
$intCustomerSysId = $bookingDataByAPI[0]['CustomerSysId'];
}
public function generateNumericOTP($n)
{
$generator = "1357902468";
$result = "";
for ($i = 1; $i <= $n; $i++) {
$result .= substr($generator, (rand() % (strlen($generator))), 1);
}
// Return result
return $result;
}
public function seatmapAction() {
$crmcustomerObj = new Travel_Model_CRM_Customer();
$objFlightProposal = new Travel_Model_TblFlightProposal();
if ($this->getRequest()->isXmlHttpRequest()) {
$objFlight = new Travel_Model_TblFlight();
$this->_helper->layout->disableLayout();
$post = json_decode(file_get_contents('php://input'), true);
$itemSg = $post['itemSg'];
$FlightTempData = $objFlight->GetFlightTempData($post['searchids']);
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
$FlightBooking = $arrUrlData['FlightBookingData'];
$tripSeatMap = (isset($arrUrlData['tripSeatMap']) && !empty($arrUrlData['tripSeatMap'])) ? $arrUrlData['tripSeatMap'][0] : '';
$searchId = $SearchTraceId = $FlightBooking[0]['SearchTraceId'];
$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
$ICSourceSysId = $FlightBooking[0]['ICSourceSysId'];
$SecKey = $itemSg['originAirportCode'] . '-' . $itemSg['destinationAirportCode'];
$segmentid = $itemSg['segmentid'];
$memberDetails = $post['memberDetails'];
$selectedSeatSession = isset($post['selectedSeatSession']) ? $post['selectedSeatSession'] : [];
$adultCount = ($sessionFlightSearchParams['adults']);
$childCount = ($sessionFlightSearchParams['child']);
$infantCount = ($sessionFlightSearchParams['infant']);
$JourneyType = ($sessionFlightSearchParams['route']);
$interNationalSearch = !empty($sessionFlightSearchParams['interNationalSearch']) ? $sessionFlightSearchParams['interNationalSearch'] : 0;
$SegmentsArr = [];
if ($FlightBooking) {
foreach ($FlightBooking as $Datass) {
if ($Datass['Segments']) {
foreach ($Datass['Segments'] as $keys => $value) {
unset($value['BAGGAGE']);
unset($value['MEAL']);
$SegmentsArr[$SecKey] = $value;
}
}
}
}
$selectedSeat = isset($selectedSeatSession[$segmentid]) ? $selectedSeatSession[$segmentid] : [];
$CurrencyTitle = !empty($this->CurrencyTitle) ? trim($this->CurrencyTitle) : 'INR';
$CurrencyRate = !empty($this->CurrencyRate) ? $this->CurrencyRate : 1;
$POSTSEAT = [];
if ($selectedSeat) {
foreach ($selectedSeat as $pst) {
$POSTSEAT[] = [
'seatNo' => $pst['seatNo'],
'segmentid' => $segmentid,
];
}
}
if ($ICSourceSysId == 7) {
$TPSysId = $arrUrlData['GENERATE_FLIGHT_QUERY']['arrIds']['TPSysId'];
$arrAgencyDetails = $objFlightProposal->getProposalAgencyDetails($TPSysId);
$AgencySysId = $arrAgencyDetails['AgencySysId'];
$getAgencyDetail = $crmcustomerObj->GetAgencyDetailById($AgencySysId);
$SecurityKey = isset($getAgencyDetail['SecurityKey']) ? $getAgencyDetail['SecurityKey'] : 0;
$requestAPI = array(
'bookingId' => $FlightBooking[0]['APIBookingId'],
);
$DataS = array(
'apidata' => $requestAPI,
'JourneyType' => $JourneyType,
'interNationalSearch' => $interNationalSearch,
'searchID' => $SearchTraceId,
'ICSourceSysId' => $ICSourceSysId,
'AdultCount' => $adultCount,
'ChildCount' => $childCount,
'InfantCount' => $infantCount,
'segmentid' => $segmentid,
'SecKey' => $SecKey,
'APIMode' => ($this->intLoggedinAgencyId == 1) ? 1 : 0,
);
$url = GTX_API_URL . '/flight/v3/getseatmap';
$getData['SecurityKey'] = $SecurityKey;
// echo "<pre>";print_r($DataS);
// echo "<pre>";print_r($getData);
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
$ResponseStatus = isset($apiResponse['status']) ? $apiResponse['status'] : false;
$ErrorMessage = isset($apiResponse['message']) ? $apiResponse['message'] : '';
$arrUrlData['tripSeatMap'] = $apiResponse;
$tempData = array(
'TraceId' => $SearchTraceId,
'TPSysId' => 0,
'APIBookingData' => json_encode($arrUrlData),
);
$objFlight->deleteFlightTempData($SearchTraceId);
$objFlight->insertFlightTempData($tempData);
// echo "<pre>";
// print_r(($apiResponse['DataSet']));
// echo "<pre>";
// print_r(json_encode($apiResponse));
// die;
} else {
$ResponseStatus = isset($tripSeatMap['status']['success']) ? $tripSeatMap['status']['success'] : false;
$ErrorMessage = (isset($tripSeatMap['message']) && !empty($tripSeatMap['message'])) ? $tripSeatMap['message'] : 'Record Not Found';
$apiResponse['tripSeatMap'] = isset($tripSeatMap['tripSeatMap']) ? $tripSeatMap['tripSeatMap'] : [];
$apiResponse['DataSet'] = isset($tripSeatMap['tripSeatMap']['DataSet']) ? $tripSeatMap['tripSeatMap']['DataSet'] : [];
$apiResponse['status'] = $ResponseStatus;
}
if ($ResponseStatus == 1) {
$DataSet = isset($apiResponse['DataSet']) ? $apiResponse['DataSet'] : [];
$status = isset($apiResponse['status']) ? $apiResponse['status'] : false;
if (isset($DataSet[$segmentid]) && $DataSet) {
$Data = $SegmentsArr[$SecKey];
$value = $DataSet[$segmentid];
$SelectedSeatArr = [];
$rows = (int) $value['rows'];
$column = (int) $value['column'];
$items = $value['items'];
$seats = $value['seats'];
$ColorArr = $value['ColorArr'];
// echo '<pre>';
// print_r($selectedSeat);
// echo '</pre>';
// echo '<pre>';
// print_r($memberDetails);
// echo '</pre>';
// die;
$SeatPrice = 0;
$memberData = [];
if ($memberDetails) {
foreach ($memberDetails as $key => $vl) {
if ($vl['PaxType'] != 3) {
$selectedData = isset($selectedSeat[$key]) ? $selectedSeat[$key] : '';
$SelectedSeatArr[] = $seatno = !empty($selectedData['seatNo']) ? $selectedData['seatNo'] : 'NA';
$amount = !empty($selectedData['amount']) ? $selectedData['amount'] : 0;
$SeatPrice += $amount;
$memberData[$key] = $vl;
$memberData[$key]['seatno'] = $seatno;
$memberData[$key]['amount'] = $amount;
}
}
}
$seatLayout = [];
$trr = 0;
for ($tr = 1; $tr <= $rows; $tr++) {
$tdd = 0;
for ($td = 1; $td <= $column; $td++) {
$SeatData = isset($seats[$tr . '-' . $td]) ? $seats[$tr . '-' . $td] : [];
$amounts = isset($SeatData['amount']) && !empty($SeatData['amount']) ? $SeatData['amount'] : 0;
$Prices = isset($SeatData['Price']) && !empty($SeatData['Price']) ? $SeatData['Price'] : 0;
$amount = round($amounts, 2);
$Price = round($Prices, 2);
$isAisle = isset($SeatData['isAisle']) ? $SeatData['isAisle'] : 0;
$isBooked = isset($SeatData['isBooked']) ? $SeatData['isBooked'] : 0;
$seatNo__ = isset($SeatData['seatNo']) ? $SeatData['seatNo'] : '';
if ($isBooked == 1) {
$CellColor = 'a4b4c1';
$Cell = 'CellBoked';
$tools = 'This seat is taken';
} else {
$CellColor = isset($ColorArr['' . $Price . '']) ? $ColorArr['' . $Price . ''] : '';
$Cell = 'Cell';
$tools = 'Seat No. ' . $seatNo__ . ' ' . $CurrencyTitle . ' ' . $Price;
}
if (in_array($seatNo__, $SelectedSeatArr)) {
$Cell = 'CellSelected';
} elseif ($isBooked != 1) {
$Cell = 'Cell';
}
if ($td == 3 && $ICSourceSysId == 3) {
$CellTypeC = 'CellTypeC';
} else {
$CellTypeC = '';
}
$seatLayout[$trr][$tdd] = [
'CellColor' => $CellColor,
'Cell' => $Cell,
'CellTypeC' => $CellTypeC,
'tools' => $tools,
'seatNo' => $seatNo__,
'isBooked' => $isBooked,
'isAisle' => $isAisle,
'amount' => $amount,
'Price' => $Price,
];
$tdd++;
}
$trr++;
}
$ColorArray = [];
if ($ColorArr) {
foreach ($ColorArr as $key => $vl) {
$ColorArray[] = [
'color' => $vl,
'amount' => $key,
];
}
}
$value['ColorArr'] = $ColorArray;
if ($seatLayout) {
foreach ($seatLayout as $x => $trValue) {
}
}
$response = array(
'success' => true,
'message' => 'success',
'APIstatus' => $status,
'CurrencyTitle' => trim($CurrencyTitle),
'CurrencyRate' => $CurrencyRate,
'ICSourceSysId' => $ICSourceSysId,
'BookingID' => $SearchTraceId,
'memberData' => array_values($memberData),
'value' => $value,
'segmentid' => $segmentid,
'SecKey' => $SecKey,
'Data' => $Data,
'seatLayout' => $seatLayout,
'POSTSEAT' => $POSTSEAT,
'SeatPrice' => round($SeatPrice, 2),
);
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight-new/');
$html->assign(array('response' => $response));
$bodyText = $html->render('seatmap.phtml');
$response['bodyText'] = $bodyText;
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Seat Selection Not Applicable for this Itinerary');
echo json_encode($response);
exit;
}
} else {
$response = array('success' => false, 'message' => $ErrorMessage);
echo json_encode($response);
exit;
}
// echo "<pre>";
// print_r(($apiResponse));
// echo "<pre>";
// print_r(($post));
// die;
}
}
public function continuewithseatmapAction() {
if ($this->getRequest()->isXmlHttpRequest()) {
$objFlight = new Travel_Model_TblFlight();
$this->_helper->layout->disableLayout();
$post = json_decode(file_get_contents('php://input'), true);
$segmentid = $post['segmentid'];
$MemberData = $post['MemberData'];
$actiontype = $post['actiontype'];
$selectedSeatSession = isset($post['selectedSeatSession']) ? $post['selectedSeatSession'] : [];
$SelectedSeats = isset($post['SelectedSeats']) ? $post['SelectedSeats'] : [];
$FlightTempData = $objFlight->GetFlightTempData($post['searchids']);
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
$FlightBooking = $arrUrlData['FlightBookingData'];
// echo "<pre>";
// print_r(($post));
// die;
$searchId = $SearchTraceId = $FlightBooking[0]['SearchTraceId'];
$ICSourceSysId = $FlightBooking[0]['ICSourceSysId'];
if ($ICSourceSysId == 3) {
$tripSeatMap = (isset($arrUrlData['tripSeatMap']) && !empty($arrUrlData['tripSeatMap'])) ? $arrUrlData['tripSeatMap'][0] : '';
$DataSet = isset($tripSeatMap['tripSeatMap']['DataSet']) ? $tripSeatMap['tripSeatMap']['DataSet'] : [];
}
$ResponseStatus = isset($tripSeatMap['status']['success']) ? $tripSeatMap['status']['success'] : false;
$ErrorMessage = (isset($tripSeatMap['message']) && !empty($tripSeatMap['message'])) ? $tripSeatMap['message'] : 'Record Not Found';
$apiResponse['tripSeatMap'] = isset($tripSeatMap['tripSeatMap']) ? $tripSeatMap['tripSeatMap'] : [];
$apiResponse['DataSet'] = isset($tripSeatMap['tripSeatMap']['DataSet']) ? $tripSeatMap['tripSeatMap']['DataSet'] : [];
$apiResponse['status'] = $ResponseStatus;
if ($ICSourceSysId == 7) {
$DataSet = isset($arrUrlData['tripSeatMap']['DataSet']) ? $arrUrlData['tripSeatMap']['DataSet'] : [];
}
// echo "<pre>";
// print_r(($DataSet));
// die;
$CurrencyTitle = !empty($this->CurrencyTitle) ? trim($this->CurrencyTitle) : 'INR';
$CurrencyRate = !empty($this->CurrencyRate) ? $this->CurrencyRate : 1;
if ($post['segmentid'] && $post['MemberData'] && $post['actiontype'] && $post['SelectedSeats'] && $post['searchids']) {
if (!empty($DataSet)) {
$value = $DataSet[$segmentid];
if (isset($DataSet[$segmentid]) && $DataSet) {
$items = $value['items'];
$selectedSeat = [];
$SelectedSegment = [];
if ($MemberData) {
foreach ($MemberData as $keys => $Customer) {
$seatNo = isset($SelectedSeats[$keys]['seatNo']) ? $SelectedSeats[$keys]['seatNo'] : '';
$paxType = $Customer['pax'] . '-' . ($keys + 1);
$checkSeat = str_replace(' ', '', $seatNo);
if (trim($checkSeat) != 'NA' && !empty($checkSeat)) {
$SelectedSegment[] = $paxType . ': ' . $seatNo;
} else {
$SelectedSegment[] = '';
}
foreach ($items as $k => $val) {
if ($val['seatNo'] == $seatNo) {
$val['cost'] = round($val['Price'], 2);
$selectedSeat[$segmentid][$keys] = $val;
}
}
}
}
if (count(array_filter($SelectedSegment)) == count($SelectedSegment)) {
$SelectedSegmentst = implode(', ', $SelectedSegment);
} else {
$SelectedSegmentst = '----';
}
$selectedSeatSession = !empty($selectedSeatSession) ? $selectedSeatSession : [];
// pr($selectedSeat);
// pr($selectedSeatSession);
// die;
if (!empty($selectedSeatSession)) {
foreach ($selectedSeatSession as $segid => $value) {
$index = 0;
if ($segid == $segmentid) {
foreach ($value as $CustomerId => $val) {
$seatNo = isset($SelectedSeats[$index]['seatNo']) ? $SelectedSeats[$index]['seatNo'] : '';
$itemsdata = isset($items[$seatNo]) ? $items[$seatNo] : [];
if (trim($val['seatNo']) == trim($seatNo)) {
$val['cost'] = round($val['Price'], 2);
$selectedSeatSession[$segmentid][$CustomerId] = $val;
} else {
$selectedSeatSession[$segmentid][$CustomerId] = $itemsdata;
}
$index++;
}
} else {
if ($MemberData) {
foreach ($MemberData as $keys => $CustomerSysId) {
$seatNo = isset($SelectedSeats[$keys]['seatNo']) ? $SelectedSeats[$keys]['seatNo'] : '';
foreach ($items as $k => $val) {
if ($val['seatNo'] == $seatNo) {
$val['cost'] = round($val['Price'], 2);
$selectedSeatSession[$segmentid][$keys] = $val;
}
}
}
}
}
}
} else {
$selectedSeatSession = $selectedSeat;
}
if ($actiontype == '2') {
$selectedSeatSession = [];
$SelectedSegmentst = '----';
}
// echo "<pre>";
// print_r(($selectedSeatSession));
// die;
$SeatPrice = 0;
if ($selectedSeatSession) {
foreach ($selectedSeatSession as $values) {
foreach ($values as $val) {
$SeatPrice += isset($val['Price']) ? $val['Price'] : 0;
}
}
}
$response = array(
'success' => true,
'message' => 'success',
'SelectedSegmentst' => $SelectedSegmentst,
'selectedSeatSession' => $selectedSeatSession,
'CurrencyTitle' => trim($CurrencyTitle),
'CurrencyRate' => $CurrencyRate,
'ICSourceSysId' => $ICSourceSysId,
'BookingID' => $SearchTraceId,
'SeatPrice' => round($SeatPrice, 2),
);
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Seat Selection Not Applicable for this Itinerary');
echo json_encode($response);
exit;
}
} else {
$response = array('success' => false, 'message' => 'record not found');
echo json_encode($response);
exit;
}
}
echo "<pre>";
print_r(($tripSeatMap));
echo "<pre>";
print_r(($post));
die;
}
}
}