403Webshell
Server IP : 103.234.187.230  /  Your IP : 216.73.216.216
Web Server : Apache
System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/b2c.hellogtx.com/application/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/b2c.hellogtx.com/application/controllers/FlightController.php
<?php

/***************************************************************
 * Catabatic Technology Pvt. Ltd.
 * File Name     : FlightController.php
 * File Desc.    : Flight controller for First page front end
 * Created By    : Md Sabir <sabir@catpl.co.in>
 * Created Date  : 14 Feb 2020
 * Updated Date  : 17 Feb 2020
 ***************************************************************/

class FlightController extends Catabatic_ValidateCustomer
{

	protected $objMdl;
	protected $tablename;
	protected $tablenameDestination;
	protected $baseUrl;
	protected $siteName;
	protected $IsTBOFlightAPI;
	protected $IsNEXTRAFlightAPI;
	protected $IsETRAVFlightAPI;
	protected $IsTJPFlightAPI;
	protected $IsTBONewFlightAPI;
	protected $APIMode;
	protected $IsAIRIQFlightAPI;
	protected $tollfreenumber;
	protected $getTemplateId;
	protected $apimulticity;
	protected $OTPVerified;
	protected $ShowPriceNoMarkup;
	protected $db = NULL;

	protected $objHelperGeneral;
	protected $per_page_record;

	public $_session;
	public $customerbookinglistAPIUrl;

	public $uploadPakcagePath;
	public $uploadDestinationPath;
	public $dummyImagePackage;
	public $dummyImageDestination;
	public $IsTJFlightAPI;
	public $IsSeriesFare;
	public $stylecss;
	public $IsAllowFlight;
	public $WhatsappMsgAllow;
	public $gtxagencysysid;
	public $gtxagentsysid;
	public $tablenameTes;
	public $hotelTypeArr;
	public $enableCache;
	public $packageTypeStatic;
	public $tableClients;
	public $table;
	public $tablePopularCity;
	public $tablePopularLogo;
	public $currencyRates;
	public $GetIvKey;
	public $AgencyDataAPI;
	public $CurrencyRate;
	public $CurrencyTitle;
	public $CurrencyId;

	public $myNamespace;
	private $respHashKey;
	private $aesResponseKey;
	private $aesResponseIv;
	private $aesRequestKey;

	private $SMSURL;
	private $SMSMETHOD;
	private $SMSAPIKEY;
	private $SMSSENDER;
	private $SMSFORMAT;
	public $gtxBtoBsite;
	public $CCAVENUEWorkingKey;
	public $GTXAPIDEFAULT;
	public $postFields;
	public $MasterAgencySysId;

	public function init()
	{

		parent::init();
		$this->db = Zend_Db_Table::getDefaultAdapter();
		$this->_helper->layout->disableLayout();
		$this->_helper->_layout->setLayout('layout-flight')->setLayoutPath(APPLICATION_PATH . '/layouts/scripts');
		$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
		$BootStrap = $aConfig['bootstrap'];
		
		$this->respHashKey = Catabatic_Helper::getRespHashKey();
		$this->aesResponseKey = Catabatic_Helper::getAesResponseKey();
		$this->aesResponseIv = Catabatic_Helper::getAesResponseIv();
		$this->aesRequestKey = Catabatic_Helper::getAesRequestKey();
		$this->CCAVENUEWorkingKey = Catabatic_Helper::getCCAVENUEWorkingKey();

		$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->gtxagencysysid = $BootStrap['gtxagencysysid']; 
		$ApiActivated = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getHttpRequestAgency();

		$this->IsTJFlightAPI = isset($ApiActivated['IsTJFlightAPI']) ? $ApiActivated['IsTJFlightAPI'] : ($BootStrap['IsTJFlightAPI'] ?? 0);
		$this->IsAIRIQFlightAPI  = isset($ApiActivated['IsAIRIQFlightAPI']) ? $ApiActivated['IsAIRIQFlightAPI'] : ($BootStrap['IsAIRIQFlightAPI'] ?? 0);
		
		$this->IsNEXTRAFlightAPI  = isset($ApiActivated['IsNEXTRAFlightAPI']) ? $ApiActivated['IsNEXTRAFlightAPI'] : ($BootStrap['IsNEXTRAFlightAPI'] ?? 0);
		$this->IsTBOFlightAPI  = isset($ApiActivated['IsTBOFlightAPI']) ? $ApiActivated['IsTBOFlightAPI'] : ($BootStrap['IsTBOFlightAPI'] ?? 0);
		if($this->gtxagencysysid == 33164){
			$this->IsTBOFlightAPI = 0;
		}
		$this->IsETRAVFlightAPI  = isset($ApiActivated['IsETRAVFlightAPI']) ? $ApiActivated['IsETRAVFlightAPI'] : ($BootStrap['IsETRAVFlightAPI'] ?? 0);
		
		
		$this->IsSeriesFare = $BootStrap['IsSeriesFare'];
		$this->siteName = $this->websiteName = $BootStrap['siteName'];
		$this->baseUrl = $BootStrap['siteUrl'];
		$this->gtxBtoBsite  = $BootStrap['gtxBtoBsite'];
		$this->view->stylecss = $this->stylecss = $BootStrap['stylecss'];
		$this->tollfreenumber = $BootStrap['tollfreenumber'];
		$this->APIMode = isset($BootStrap['APIMode']) ? $BootStrap['APIMode'] : 0;
		$this->IsAllowFlight = isset($BootStrap['IsAllowFlight']) ? $BootStrap['IsAllowFlight'] : 0;
		// $this->IsNEXTRAFlightAPI = isset($BootStrap['IsNEXTRAFlightAPI']) ? $BootStrap['IsNEXTRAFlightAPI'] : 0;
		// $this->IsETRAVFlightAPI = isset($BootStrap['IsETRAVFlightAPI']) ? $BootStrap['IsETRAVFlightAPI'] : 0;
		$this->IsTBONewFlightAPI = isset($BootStrap['IsTBONewFlightAPI']) ? $BootStrap['IsTBONewFlightAPI'] : 0;
		$this->IsTJPFlightAPI = isset($BootStrap['IsTJPFlightAPI']) ? $BootStrap['IsTJPFlightAPI'] : 0;
		// $this->IsAIRIQFlightAPI = isset($BootStrap['IsAIRIQFlightAPI']) ? $BootStrap['IsAIRIQFlightAPI'] : 0;
		$this->getTemplateId = isset($BootStrap["TemplateType"]) ? $BootStrap["TemplateType"] : 0;
		$this->WhatsappMsgAllow = isset($BootStrap["WhatsappMsgAllow"]) ? $BootStrap["WhatsappMsgAllow"] : 0;
		$this->apimulticity = isset($BootStrap["apimulticity"]) ? $BootStrap["apimulticity"] : 0;
		$this->view->OTPVerified = $this->OTPVerified = isset($BootStrap["OTPVerified"]) ? $BootStrap["OTPVerified"] : 0;
		$this->view->ShowPriceNoMarkup = $this->ShowPriceNoMarkup = isset($BootStrap["ShowPriceNoMarkup"]) ? $BootStrap["ShowPriceNoMarkup"] : 0;

		// get gtxagencysysid from application config
		$this->gtxagentsysid = $BootStrap['gtxagentsysid']; // get gtxagentsysid from application config

		// $this->GTXAPIDEFAULT = 'https://gtxapi.hellogtx.com';
		$this->GTXAPIDEFAULT = ($this->gtxagencysysid=='1'|| $this->gtxagencysysid=='2656') ? GTXAPIDEFAULT : 'https://gtxapi.hellogtx.com' ;

		$this->objMdl = new Admin_Model_CRUD();

		$this->tablename = "tb_tbb2c_packages_master";
		$this->tablenameTes = "tbl_testimonials";

		$this->tablenameDestination = "tb_tbb2c_destinations";
		$this->hotelTypeArr = ['Standard', 'Deluxe', 'Luxury'];

		$this->objHelperGeneral = $this->_helper->General;
		$this->per_page_record = 10;
		$this->_session = new Zend_Session_Namespace('User');

		$this->uploadPakcagePath = 'public/upload/tours/';
		$this->uploadDestinationPath = 'public/upload/destinations/';

		$this->dummyImagePackage = 'default-tour.jpg';
		$this->dummyImageDestination = 'default-destination.jpg';

		$this->enableCache = $BootStrap['enableCache'];
		$this->packageTypeStatic = $BootStrap['packageTypeDynamic'];
		$this->tableClients = 'tbl_accreditations_client';
		$this->table = 'tbl_about_yit';
		$this->tablePopularCity = 'tbl_popular_city';
		$this->tablePopularLogo = 'tbl_popular_logo';

		$this->customerbookinglistAPIUrl = API_CUSTOMER_LIST; // from constant file

		$this->currencyRates = API_AGENCY_CURRENCY_RATE; // from constant file
		$this->GetIvKey = API_GET_IV_KEY; // from constant file
		$this->AgencyDataAPI = API_GET_AGENCY_DATA; // from constant file

		$this->myNamespace = new Zend_Session_Namespace('MypopSess'); // get user end infomations
		//         $this->_helper->layout->disableLayout();
		//        $this->_helper->_layout->setLayout('layout1')->setLayoutPath(APPLICATION_PATH.'/layouts/scripts');

		//$currencyType = $this->objMdl->selectOne('tbl_currency', ['*'], ['isActive' => 1, 'Title' => 'INR'], ['id' => 'ASC']);
		//$currency_rate = $this->objMdl->selectOne('tbl_currency_rate', ['*'], ['FCurrencyType' => 1, 'TCurrencyType' => $currencyType->CurrencyId, 'isActive' => 1], ['cid' => 'ASC']);
		$CurrencyRate = new Zend_Session_Namespace('CurrencyRate');
		$CurrencyTitle = new Zend_Session_Namespace('CurrencyTitle');
		$CurrencyId = new Zend_Session_Namespace('CurrencyId');
		// echo "<pre>";print_r($_SESSION);die;
		$this->CurrencyRate = (isset($CurrencyRate->params) && !empty($CurrencyRate->params)) ? (float) $CurrencyRate->params : 1;
		$this->CurrencyTitle = $this->view->CurrencyTitle = (isset($CurrencyTitle->params) && !empty($CurrencyTitle->params)) ? $CurrencyTitle->params : 'INR';
		$this->CurrencyId = (isset($CurrencyId->params) && !empty($CurrencyId->params)) ? $CurrencyId->params : 1;
		//$_SERVER["DOCUMENT_ROOT"] = $_SERVER["DOCUMENT_ROOT"] . '/holidaybazaar';

	}


	public function indexAction()
	{
		if ($this->IsAllowFlight == 0) {
			$this->_redirect("404");
		}
		$this->_redirect('');
		//die('test');
		//header("Access-Control-Allow-Origin: *");
		$crud = new Admin_Model_CRUD();
		Zend_Session::namespaceUnset('FlightSeatSession');
		Zend_Session::namespaceUnset('FlightBookingData');
		Zend_Session::namespaceUnset('FlightBookingDataInbound');
		Zend_Session::namespaceUnset('FlightFareQuoteSession');
		Zend_Session::namespaceUnset('FlightFareQuoteSessionInb');
		Zend_Session::namespaceUnset('FlightSearchUrl');
		Zend_Session::namespaceUnset('FlightSearchGuard');
		Zend_Session::namespaceUnset('CustomerSession');
		Zend_Session::namespaceUnset('CustomerMemberSysIds');
		// Zend_Session::namespaceUnset('FlightBookingTicketSession');
		Zend_Session::namespaceUnset('flight_booking_id');
		Zend_Session::namespaceUnset('SelectedMealSessionNew');
		Zend_Session::namespaceUnset('SelectedBaggSessionNew');
		Zend_Session::namespaceUnset('SelectedMealSessionNewInb');
		Zend_Session::namespaceUnset('SelectedBaggSessionNewInb');
		Zend_Session::namespaceUnset('FlightBookingDataRoundInter');
		//Zend_Session::namespaceUnset('sessionFlightSearchParams');
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$recentSearch = new Zend_Session_Namespace('recentSearch');
		$existingOffer = $crud->rv_select_all($this->table, ['*'], ['IsMarkForDel' => 0], ['AboutId' => 'DESC']);
		$DomesPopularCity = $crud->rv_select_all($this->tablePopularCity, ['*'], ['popularCityType' => 0, 'IsMarkForDel' => 0], ['AboutId' => 'DESC']);
		$DomesPopularLogo = $crud->rv_select_all($this->tablePopularLogo, ['*'], ['IsMarkForDel' => 0], ['AboutId' => 'DESC']);
		$InterPopularCity = $crud->rv_select_all($this->tablePopularCity, ['*'], ['popularCityType' => 1, 'IsMarkForDel' => 0], ['AboutId' => 'DESC']);
		$this->view->sessionFlightSearchParams = $sessionFlightSearchParams->params;
		$this->view->recentSearch = $recentSearch->params;
		$this->view->existingOffer = $existingOffer;
		$this->view->DomesPopularCity = $DomesPopularCity;
		$this->view->DomesPopularLogo = $DomesPopularLogo;
		$this->view->InterPopularCity = $InterPopularCity;
		foreach ($DomesPopularCity as $key => $value) {
			if (trim($value['AboutImage']) != '') {
				$flightImage1 = explode(',', $value['AboutImage']);
				if ($flightImage1[0] != '') {
					$flightImage = $this->baseUrl . 'public/upload/aboutyit/' . $value['AboutId'] . '/{size}/' . $flightImage1[0];
				} else if ($flightImage1[1] != '') {
					$flightImage = $this->baseUrl . 'public/upload/aboutyit/' . $value['AboutId'] . '/{size}/' . $flightImage1[1];
				}
			} else {
				$flightImage =  $Flight['package']['ImgThumbnail'];
			}
			$DomesPopularCity1[] = [
				'AboutId' => $value['AboutId'],
				'AboutImage' => $flightImage,
				'price' => $value['price'],
				'Fromcity' => $value['Fromcity'],
				'Tocity' => $value['Tocity'],
				'source' => $value['source'],
				'destination' => $value['destination'],
				'source_city' => $value['source_city'],
				'destination_city' => $value['destination_city'],
				'ContSysId1' => $value['ContSysId1'],
				'ContSysId2' => $value['ContSysId2'],
				'popularCityType' => $value['popularCityType'],
				'AboutDescription' => $value['AboutDescription'],
				'url' => $value['url'],
				'opt' => $value['opt'],
				'status' => $value['status'],
				'isMarkForDel' => $value['isMarkForDel'],
			];
		}

		// foreach ($DomesPopularLogo as $key => $value) {
		// 	if (trim($value['AboutImage']) != '') {
		// 		$flightImage1 = explode(',', $value['AboutImage']);
		// 		if ($flightImage1[0] != '') {
		// 			$flightImage = $this->baseUrl . 'public/upload/aboutyit/' . $value['AboutId'] . '/{size}/' . $flightImage1[0];
		// 		} else if ($flightImage1[1] != '') {
		// 			$flightImage = $this->baseUrl . 'public/upload/aboutyit/' . $value['AboutId'] . '/{size}/' . $flightImage1[1];
		// 		}
		// 	} else {
		// 		$flightImage =  $Flight['package']['ImgThumbnail'];
		// 	}
		// 	$DomesPopularLogo[] = [
		// 		'AboutId' => $value['AboutId'],
		// 		'AboutImage' => $flightImage,
		// 		'title' => $value['title'],
		// 		//'Fromcity' => $value['Fromcity'],
		// 		//'Tocity' => $value['Tocity'],
		// 		//'source' => $value['source'],
		// 		//'destination' => $value['destination'],
		// 		//'source_city' => $value['source_city'],
		// 		//'destination_city' => $value['destination_city'],
		// 		//'ContSysId1' => $value['ContSysId1'],
		// 		//'ContSysId2' => $value['ContSysId2'],
		// 		//'popularCityType' => $value['popularCityType'],
		// 		//'AboutDescription' => $value['AboutDescription'],
		// 		//'url' => $value['url'],
		// 		//'opt' => $value['opt'],
		// 		'status' => $value['status'],
		// 		'isMarkForDel' => $value['isMarkForDel'],

		// 	];
		// }
		$InterPopularCity1 = [];
		foreach ($InterPopularCity as $key => $value) {
			if (trim($value['AboutImage']) != '') {
				$flightImage1 = explode(',', $value['AboutImage']);
				if ($flightImage1[0] != '') {
					$flightImage = $this->baseUrl . 'public/upload/aboutyit/' . $value['AboutId'] . '/{size}/' . $flightImage1[0];
				} else if ($flightImage1[1] != '') {
					$flightImage = $this->baseUrl . 'public/upload/aboutyit/' . $value['AboutId'] . '/{size}/' . $flightImage1[1];
				}
			} else {
				$flightImage =  $Flight['package']['ImgThumbnail'];
			}
			$InterPopularCity1[] = [
				'AboutId' => $value['AboutId'],
				'AboutImage' => $flightImage,
				'price' => $value['price'],
				'Fromcity' => $value['Fromcity'],
				'Tocity' => $value['Tocity'],
				'source' => $value['source'],
				'destination' => $value['destination'],
				'source_city' => $value['source_city'],
				'destination_city' => $value['destination_city'],
				'ContSysId1' => $value['ContSysId1'],
				'ContSysId2' => $value['ContSysId2'],
				'popularCityType' => $value['popularCityType'],
				'AboutDescription' => $value['AboutDescription'],
				'url' => $value['url'],
				'opt' => $value['opt'],
				'status' => $value['status'],
				'isMarkForDel' => $value['isMarkForDel'],

			];
		}
		$this->view->DomesPopularCity1 = $DomesPopularCity1;
		// $this->view->DomesPopularLogo = $DomesPopularLogo;

		$this->view->InterPopularCity1 = $InterPopularCity1;
		//$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetAgencyCurrency($this->gtxagencysysid);
		//echo '<pre>';print_r($apiResponse);die;
		$getPageDetail = $this->objMdl->rv_select_row('tbl_static_pages', ['*'], ['sid' => 195], ['sid' => 'desc']);
		//echo"<pre>";print_r($getPageDetail);die;
		$this->view->getPageDetail    = $getPageDetail;
		$resultsetSeoForBlog['TravTitle'] = $getPageDetail['page_title']; // get Keyword
		$resultsetSeoForBlog['Keyword'] = $getPageDetail['meta_keywords']; // get Keyword
		$resultsetSeoForBlog['Description'] = $getPageDetail['meta_description']; // get Description
		$resultsetSeoForBlog['page_description'] = $getPageDetail['page_description']; // get page_description
		$resultsetSeoForBlog['metaTitle'] = (trim($getPageDetail['meta_title']) != '') ? $getPageDetail['meta_title'] : $getPageDetail['page_title']; // get package Metatag
		$this->view->detailLayout = $resultsetSeoForBlog;
		$destinatonTopdomest = $this->objMdl->rv_select_all($this->tablenameDestination, ['DesSysId', 'Title', 'Activities', 'Hotels', 'Tours', 'Image', 'DestDescription'], ['IsActive' => 1, 'IsFeatured' => 1, 'IsMarkForDel' => 0, 'countryIds' => 101], ['rand()' => ''], 8);
		$destinatonTopArr = array();
		foreach ($destinatonTopdomest as $topdesKey => $topdesValue) {
			$desTitleValue = $topdesValue['Title'];
			$whereCustom = ($desTitleValue) ? " ( Destinations LIKE '%{$desTitleValue}%' )" : "";

			$tourResult = $this->objMdl->rv_select_row_where_custom($this->tablename, ['count(*) as totalCount'], ['IsMarkForDel' => 0, 'IsActive' => 1, 'IsPublish' => 1, 'ItemType' => 1], $whereCustom, [], '');


			$destinatonTopArr[] = [
				'DesSysId' => $topdesValue['DesSysId'],
				'Title' => $topdesValue['Title'],
				'Activities' => $topdesValue['Activities'],
				'Hotels' => $topdesValue['Hotels'],
				'Tours' => $topdesValue['Tours'],
				'Image' => $topdesValue['Image'],
				'DestDescription' => $topdesValue['DestDescription'],
				'totalCount' => $tourResult['totalCount'],

			];
		}
		$destinatonTopinetr = $this->objMdl->rv_select_all($this->tablenameDestination, ['DesSysId', 'Title', 'Activities', 'Hotels', 'Tours', 'Image', 'DestDescription'], ['IsActive' => 1, 'IsFeatured' => 1, 'IsMarkForDel' => 0, 'countryIds!' => 101], ['rand()' => ''], 8);
		$destinatonTopArrInter = array();
		foreach ($destinatonTopinetr as $topdesKeyint => $topdesValueint) {
			$desTitleValue = $topdesValueint['Title'];
			$whereCustom = ($desTitleValue) ? " ( Destinations LIKE '%{$desTitleValue}%' )" : "";

			$tourResult = $this->objMdl->rv_select_row_where_custom($this->tablename, ['count(*) as totalCount'], ['IsMarkForDel' => 0, 'IsActive' => 1, 'IsPublish' => 1, 'ItemType' => 1], $whereCustom, [], '');

			$destinatonTopArrInter[] = [
				'DesSysId' => $topdesValueint['DesSysId'],
				'Title' => $topdesValueint['Title'],
				'Activities' => $topdesValue['Activities'],
				'Hotels' => $topdesValueint['Hotels'],
				'Tours' => $topdesValueint['Tours'],
				'Image' => $topdesValueint['Image'],
				'DestDescription' => $topdesValueint['DestDescription'],
				'totalCount' => $tourResult['totalCount'],

			];
		}

		$trendingTours = $this->objMdl->rv_select_all('tb_tbb2c_packages_master', ['PkgSysId', 'Image', 'GTXPkgId', 'Destinations', 'Countries', 'BookingValidUntil', 'LongJsonInfo', 'Nights', 'StarRating', 'PackageType', 'PackageSubType'], ['IsActive' => 1, 'IsPublish' => 1, 'IsMarkForDel' => 0, 'ItemType' => 1, 'IsFeatured' => 1], ['PkgSysId' => 'DESC'], 12);
		foreach ($trendingTours as $key => $value) {

			//$destinationArr = explode(',', $value['Destinations']); // get the first destination only by extracting array
			$LongJsonInfo = Zend_Json::decode($value['LongJsonInfo']);
			if (isset($_SESSION['TravelAgent']['session']) && !empty($_SESSION['TravelAgent']['session'])) {
				$categoryDetails = $this->objHelperGeneral->getCategoryAndPriceArray($LongJsonInfo['package']['TourTypes']['MarketType'], 'B2B', $value['PackageType'], $value['PackageSubType']); // get default category
			} else {
				$categoryDetails = $this->objHelperGeneral->getCategoryAndPriceArray($LongJsonInfo['package']['TourTypes']['MarketType'], 'B2C', $value['PackageType'], $value['PackageSubType']); // get default category
			}
			//$categoryDetails = $this->objHelperGeneral->getCategoryAndPriceArray($LongJsonInfo['package']['TourTypes']['MarketType'], 'B2C', $value['PackageType'], $value['PackageSubType']); // get default category

			if (trim($LongJsonInfo['package']['ImgThumbnail']) != '') {
				$tourImage = $LongJsonInfo['package']['ImgThumbnail'];
			} else {
				$tourImage1 = explode(',', $value['Image']);
				$tourImage = $this->baseUrl . 'public/upload/tours/' . $value['PkgSysId'] . '/images/medium/' . $tourImage1[0];
			}
			$defaultCategoryId = $categoryDetails['defaultCategoryId'];
			$defaultCategory = $categoryDetails['defaultCategory'];
			$defaultTourType = $categoryDetails['defaultTourType'];
			$TPId = ($value['PackageType'] == $this->packageTypeStatic) ? $LongJsonInfo['package']['TPId'] : $categoryDetails['TPId'];
			$MPType = (!empty($categoryDetails['MPType']) && ($categoryDetails['MPType'] != 'LowestCost')) ? array_search($categoryDetails['MPType'], unserialize(CONST_MEAL_PLAN_ARR)) : 0;

			$tourTypeChar = ($defaultTourType == 1) ? 'P' : 'G'; // if private than P else G for Group tour type
			$priceArrJson = $categoryDetails['priceArrJson'];

			$displayFinalPrice = $this->objHelperGeneral->getPackagePrice($defaultCategory, $tourTypeChar, $priceArrJson, true); // Param 4: true ( if calculate discounted price )

			$toursFinal[] = [
				'name' => $this->objHelperGeneral->trimContent($LongJsonInfo['package']['Name'], 15),
				'nameF' => $LongJsonInfo['package']['Name'], // full name of package name
				'img' => $tourImage,
				'night' => $value['Nights'],
				'price' => $this->objHelperGeneral->moneyFormatINR(round($displayFinalPrice)),
				'star' => $value['StarRating'],
				'Destination' => $value['Destinations'],
				'PkgSysId' => $value['PkgSysId'],
				'GTXPkgId' => $value['GTXPkgId'],
				'defaultCategoryId' => $defaultCategoryId,
				'defaultCategory' => $defaultCategory,
				'tourtype' => $defaultTourType,
				'TPId' => $TPId,
				'PackageType' => $value['PackageType'],
				'mp' => $MPType,
				'Countries' => $value['Countries'],
				'BookingValidUntil' => $value['BookingValidUntil'],
				'Inclusions' => $LongJsonInfo['package']['Inclusions'],
			];
		}
		//    echo '<pre>';print_r($this->_session->session);die;
		$this->view->baseUrl = $this->baseUrl;
		$this->view->destinationsInt = $destinatonTopArrInter;
		$this->view->destinations = $destinatonTopArr;
		$this->view->toursFinal = $toursFinal;
		$this->view->MobileDetect = $this->objHelperGeneral->getDevice();
	}

	public function flightsearchapiAction()
	{
		if ($this->getRequest()->isPost()) {
			$json = file_get_contents('php://input');
			$post = json_decode($json, true);

			$Faretype = [1 => 'REGULAR', 2 => 'STUDENT', 3 => 'SENIOR_CITIZEN'];
			$http_build_query = $post; //json_decode('{"fromCity":{"AirportCode":"DEL","CityID":"7701","ContSysId":"101","label":"Delhi, IN - Delhi Indira Gandhi Intl (DEL), India"},"toCity":{"AirportCode":"BOM","CityID":"18676","ContSysId":"101","label":"Mumbai, IN - Chhatrapati Shivaji (BOM), India"},"departureDate":"2023-11-21 00:00:00.000","returnDate":"2023-11-23 00:00:00.000","class":"2","adults":"1","children":" 0","infant":"0","directFlight":true,"fares":"1","tripType":"2"}',1);
			$http_build_query['route'] = $http_build_query['tripType'];
			$http_build_query['childs'] = $http_build_query['children'];
			$http_build_query['infants'] = $http_build_query['infant'];
			$http_build_query['DirectFlight'] = $http_build_query['directFlight'];
			$http_build_query['source_city'] = $http_build_query['fromCity']['AirportCode'];
			$http_build_query['ContSysId_1'] = $http_build_query['fromCity']['ContSysId'];
			$http_build_query['destination_city'] = $http_build_query['toCity']['AirportCode'];
			$http_build_query['ContSysId'] = $http_build_query['toCity']['ContSysId'];
			$http_build_query['source'] = $http_build_query['fromCity']['label'];
			$http_build_query['destination'] = $http_build_query['toCity']['label'];
			$http_build_query['departure_date'] = date('d/m/Y', strtotime($http_build_query['departureDate']));
			$http_build_query['return_date'] = date('d/m/Y', strtotime($http_build_query['returnDate']));
			$from_mytrip_city = explode(',', $http_build_query['fromCity']['label']);
			$to_mytrip_city = explode(',', $http_build_query['toCity']['label']);
			$http_build_query['from_mytrip_city'] = $from_mytrip_city[1];
			$http_build_query['to_mytrip_city'] = $to_mytrip_city[1];
			$http_build_query['mytrip_city_from'] = $from_mytrip_city[0];
			$http_build_query['mytrip_city_to'] = $to_mytrip_city[0];
			$http_build_query['FareTypes'] = $Faretype[$http_build_query['fares']];
			unset($http_build_query['directFlight']);
			unset($http_build_query['departureDate']);
			unset($http_build_query['returnDate']);
			unset($http_build_query['children']);
			unset($http_build_query['fromCity']);
			unset($http_build_query['toCity']);
			unset($http_build_query['tripType']);

			$TraceId = implode('-', str_split(substr(strtolower(md5(time() . rand(1000, 9999))), 0, 20), 5));
			$SearchFlightTraceId = new Zend_Session_Namespace('SearchFlightTraceId');
			$SearchFlightTraceId->params = $TraceId;
			Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CreateSessionSearchParams($http_build_query, $TraceId);
			
			$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');

			$AdditionalMarkup = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAdditionalMarkup();
			$ApiRoundTrip = $AdditionalMarkup['ApiRoundTrip'];
			$apiResponseTBO = [];
			$apiResponse = [];
			if ($this->IsTBOFlightAPI == 1) {
				$apiResponseTBO = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsTBO($sessionFlightSearchParams->params);
			}
			if ($this->IsTJFlightAPI == 1) {
				$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlights($sessionFlightSearchParams->params);
			}
			$random = $this->generateRandomNumber(12);
			$MergeRequest = (array_merge($apiResponse, $apiResponseTBO));
			$apiSearchRequest = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->otherapiRequest($sessionFlightSearchParams->params, $MergeRequest, $ApiRoundTrip);
			$i = 1;
			
			$objFlight = new Travel_Model_FlightMaster();
			$searchidarr = [];
			$SearchRequestData = [];
			if($apiSearchRequest['data']){
					foreach($apiSearchRequest['data'] as $key=>$value){
						$searchid = $i . '-' . $random;
						$insertData = $apiSearchRequest['dataother'];
						$insertData[$key] = $value;
						$SearchRequestData[$searchid] = $insertData;
						if($http_build_query['device'] == 'app'){
							$insertArr = array(
								'TraceId' => $searchid,
								'json_data' => json_encode($insertData),
								'created_at' => date('Y-m-d H:i:s'),
							);
							$objFlight->InsertFlightData('tbl_temp_data', $insertArr);
						}
						
					
					$searchidarr[] = $searchid;
					$i++;
				}
			}
			$sessionSearchRequestData = new Zend_Session_Namespace('SessionSearchRequestData');
			$sessionSearchRequestData->params = $SearchRequestData;
			$url = 'flight/flight-search?' . http_build_query($http_build_query).'&searchids='.implode(',',$searchidarr);
			// $url = $this->baseUrl.'flight/flight-search?'.http_build_query($http_build_query);
			$data = array('status' => true, 'url' => $url, 'message' => 'success');
			echo json_encode($data);
			exit;
			
		} else {
			$data = array('status' => false, 'url' => '', 'message' => 'post method allow.');
			echo json_encode($data);
			exit;
		}
	}
	private function generateRandomNumber(int $len): int
    {
        static $track = [];

        $min = 1 . str_repeat(0, $len - 1);
        $max = str_repeat(9, $len);
        $num = mt_rand($min, $max);
        // if was generated before, try again
        if (in_array($num, $track)) {
            return self::generateRandomNumber($len);
        }
        // store and return
        return $track[] = $num;
    }

	public function flightsearchdataAction()
	{
		//die('Wait.');
		$getData = $this->getRequest()->getParams();
		$uri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
		$uriExp = explode('?', $uri);
		$PreferredAirline_1 = isset($getData['PreferredAirline_1']) ? $getData['PreferredAirline_1'] : [];
		$arrayAirline = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getAirlinesName();
		if ($PreferredAirline_1) {
			foreach ($PreferredAirline_1 as $value) {
				foreach ($arrayAirline as $key => $values) {
					if ($value == $values['AIRLINENAME']) {
						$getData['PreferredAirline'][] = $values['AIRLINECODE'];
					}
				}
			}
		}
		// echo "date before create session".date('i:s');
		$TraceId = implode('-', str_split(substr(strtolower(md5(time() . rand(1000, 9999))), 0, 20), 5));
		$SearchFlightTraceId = new Zend_Session_Namespace('SearchFlightTraceId');
		$SearchFlightTraceId->params = $TraceId;

		Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CreateSessionSearchParams($getData, $TraceId);
		// echo "date after create session".date('i:s');
		$FlightSearchGuard = new Zend_Session_Namespace('FlightSearchGuard');
		$FlightSearchGuard->params = base64_encode($uriExp[1]); // Putting all form data to Session

	
		$this->view->getData = $getData;
		
		
		// jyt commenting old code
		// $objFlight = new Travel_Model_FlightMaster();
		// $sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		// $AdditionalMarkup = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAdditionalMarkup();
		// $ApiRoundTrip = $AdditionalMarkup['ApiRoundTrip'];
	
		// $apiResponseTBO = [];
		// $apiResponse = [];
		// if ($this->IsTBOFlightAPI == 1) {
		// 	$apiResponseTBO = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsTBO($sessionFlightSearchParams->params);
		// }
		// if ($this->IsTJFlightAPI == 1) {
		// 	$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlights($sessionFlightSearchParams->params);
		// }
		// $random = $this->generateRandomNumber(12);
		// $MergeRequest = (array_merge($apiResponse, $apiResponseTBO));
		// $apiSearchRequest = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->otherapiRequest($sessionFlightSearchParams->params, $MergeRequest, $ApiRoundTrip);
		// $i = 1;
		$objFlight = new Travel_Model_FlightMaster();
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$searchidarr = [];
		$data_req = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchQueryReq($getData,$sessionFlightSearchParams->params);
	
		$url = $this->GTXAPIDEFAULT.'/flight/v4/searchquery';
		$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($data_req, [], $url);
		$searchidarr = !empty($apiResponse['searchids']) ? $apiResponse['searchids'] :[];
		$FlightSearchUrl = new Zend_Session_Namespace('FlightSearchUrl');
		$FlightSearchUrl->params = ($uriExp[1].'&searchids='.implode(',',$searchidarr)); // Putting all form data to Session
		// echo "date after apiResponse session".date('i:s');
		// die;
		// jyt commenting old code
		// if($apiSearchRequest['data']){
		// 	foreach($apiSearchRequest['data'] as $key=>$value){
		// 		$searchid = $i . '-' . $random;
		// 		$insertData = $apiSearchRequest['dataother'];
		// 		$insertData[$key] = $value;
		// 		$SearchRequestData[$searchid] = $insertData;
		// 		$searchidarr[] = $searchid;
		// 		$i++;
		// 	}
		// }
		// $sessionSearchRequestData = new Zend_Session_Namespace('SessionSearchRequestData');
		// $sessionSearchRequestData->params = $SearchRequestData;
		
		$this->_redirect('flight/flight-search?' . $uriExp[1].'&searchids='.implode(',',$searchidarr));
	}

	public function flightSearchAction()
	{

		$getData = $this->getRequest()->getParams();

		$PreferredAirline_1 = isset($getData['PreferredAirline_1']) ? $getData['PreferredAirline_1'] : [];
		$device = isset($getData['device']) ? $getData['device'] : '';
		// echo '<pre>';print_r($getData);die;
		// $arrayAirline = ['6E'=>"Indigo","SG" => "Spicejet","G8" => "Go First","AI" => "Air India","UK" => "Vistara","I5" => "AirAsia india","2T"=>"Trujet"];
		$arrayAirline = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getAirlinesName();
		if ($PreferredAirline_1) {
			foreach ($PreferredAirline_1 as $value) {
				foreach ($arrayAirline as $key => $values) {
					if ($value == $values['AIRLINENAME']) {
						$getData['PreferredAirline'][] = $values['AIRLINECODE'];
					}
				}
			}
		}
		//$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		if($device == 'app'){
			$searchid = isset($getData['searchids'])?explode(',',$getData['searchids']):'';
			$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['json_data'], ['TraceId' => $searchid[0]], ['id' => 'ASC']);
			$arrUrlData = json_decode($temp_data['json_data'], true);
			$TraceId = implode('-', str_split(substr(strtolower(md5(time() . rand(1000, 9999))), 0, 20), 5));
			$searchID = (isset($arrUrlData['searchID']) && !empty($arrUrlData['searchID']))?$arrUrlData['searchID']:$TraceId;
			$SearchFlightTraceId->params = (!empty($SearchFlightTraceId->params))?$SearchFlightTraceId->params:$searchID;
			// if ($this->gtxagencysysid == '110804') {
			// 	echo '<pre>';print_r($searchid);
			// 	echo '<pre>';print_r($searchID);
			// 	echo '<pre>';print_r($SearchFlightTraceId->params);
			// 	die;
			// }
			Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CreateSessionSearchParams($getData, $SearchFlightTraceId->params);
	
		}

		$FlightSearchResults = new Zend_Session_Namespace('FlightSearchResults');
		$this->view->getData = $getData;
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		//echo '<pre>';print_r($sessionFlightSearchParams->params);die;
		$recentSearch = new Zend_Session_Namespace('recentSearch');
		$adultCount = $sessionFlightSearchParams->params['adults'];
		$childCount = $sessionFlightSearchParams->params['child'];
		$infantCount = $sessionFlightSearchParams->params['infant'];
		$intMemberCount = $adultCount + $childCount + $infantCount;
		$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);

		$data = array(
			'AgencySysId' => $this->gtxagencysysid,
			'ServiceFee' => 0,
			'CriteriaValue' => 0,
			'ProductType' => 1,
			'TravelDate' => date('Y-m-d'),
		);

		$availableCoupon = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->availableCoupon($data);
		$availableCouponList = isset($availableCoupon['data']) ? $availableCoupon['data'] : [];
		$this->view->intMemberCount = $intMemberCount;
		$this->view->interNationalSearch = $interNationalSearch;
		$this->view->sessionFlightSearchParams = $sessionFlightSearchParams->params;
		$this->view->availableCouponList = $availableCouponList;
		$this->view->apimulticity = $this->apimulticity;
		$this->view->SECURITYKEY = SECURITYKEY;
	}
	public function getflightlogo($strAirlineCodeLogo)
	{
		$filePath = $_SERVER['DOCUMENT_ROOT'] . "/public/upload/AirlineLogo/";
		if (file_exists($filePath . $strAirlineCodeLogo . ".gif")) {
			$strAirlineLogo = $strAirlineCodeLogo . ".gif";
			$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
		} elseif (file_exists($filePath . $strAirlineCodeLogo . ".png")) {
			$strAirlineLogo = $strAirlineCodeLogo . ".png";
			$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
		} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpg")) {
			$strAirlineLogo = $strAirlineCodeLogo . ".jpg";
			$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
		} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpeg")) {
			$strAirlineLogo = $strAirlineCodeLogo . ".jpeg";
			$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
		} else {
			$filePath = $this->baseUrl . "public/upload/AirlineLogo/noimage.png";
		}
		return $filePath;
	}

	public function getTaxSettingDetail($TaxSetting, $PlanType)
	{
		$getTaxSettingDetail = [];
		if ($PlanType) {
			if ($TaxSetting) {
				foreach ($TaxSetting as $val) {
					$getTaxSettingDetail[$val['PlanType']] = $val;
				}
			}
			$TaxSettingDetail = isset($getTaxSettingDetail[$PlanType]) ? $getTaxSettingDetail[$PlanType] : [];
			if (!empty($TaxSettingDetail)) {
				return ['TaxName' => $TaxSettingDetail['TaxName'], 'TaxPercentage' => $TaxSettingDetail['TaxPercentage'], 'TaxType' => $TaxSettingDetail['TaxType'], 'Tax' => $TaxSettingDetail['Tax']];
			} else {
				return ['TaxName' => 'Not Found', 'TaxPercentage' => 0, 'TaxType' => 2, 'Tax' => 1];
			}
		} else {
			$data = array('status' => false, 'message' => 'Invalid request');
			return ($data);
		}
	}

	public function getMarkup($intCountryCode)
	{
		if ($intCountryCode) {
			$this->postFields = "";
			$this->postFields .= "&AgencySysId=$this->gtxagencysysid";
			$this->postFields .= "&AgentSysId=$this->gtxagentsysid";
			$this->postFields .= "&intCountryCode=$intCountryCode";
			$model = new Gtxwebservices_Model_Webservices();
			$result = $model->getMarkupAndServiceTax($this->postFields);
			$response = json_decode($result, true);
			return $response;
		} else {
			$data = array('status' => false, 'message' => 'Invalid country code');
			return ($data);
		}
	}
	public function getCancellationChargeNew($intCountryCode, $PlanType, $SupplierType)
	{
		if ($intCountryCode) {
			$dataArray = array(
				'PlanType' => $PlanType,
				'CountryCode' => $intCountryCode,
				'SupplierType' => $SupplierType,
				'IsB2C' => true,
				'AgencySysId' => $this->gtxagencysysid,
			);
			$model = new Gtxwebservices_Model_Webservices();
			$result = $model->CancellationChargeNew($dataArray, SECURITYKEY);
			$response = json_decode($result, true);
			return $response;
		} else {
			$data = array('status' => false, 'message' => 'Invalid country code');
			return ($data);
		}
	}
	public function getMarkupNew($intCountryCode, $PlanType)
	{
		if (SECURITYKEY && $intCountryCode) {
			if ($intCountryCode == 'IN') {
				$ItemSourceType = 1;
			} else {
				$ItemSourceType = 2;
			}
			$dataArray = array(
				'B2CAgencySysIdKey' => SECURITYKEY,
				'PlanType' => $PlanType,
				'IsB2C' => 1,
				'MasterAgencySysId' => $this->gtxagencysysid,
				'IsB2CLoggedIn' => (isset($this->_session->session) && !empty($this->_session->session)) ? 1 : 0,
			);
			$model = new Gtxwebservices_Model_Webservices();
			$result = $model->getMarkupAndServiceTaxNew($dataArray);
			$response = json_decode($result, true);

			$Markuparray = [];
			if ($response['data']) {
				foreach ($response['data'] as $key => $value) {
					if ($ItemSourceType == $value['ItemSourceType']) {
						$Markuparray[$key] = $value;
						$Markuparray[$key]['CommssionVal'] = $value['Commission'];
						$Markuparray[$key]['CommssionType'] = 2;
						$Markuparray[$key]['StdMarkUpPer'] = $value['MarkUpValue'];
					}
				}
			}
			$TaxSetting = isset($response['TaxSetting']) ? $response['TaxSetting'] : [];
			return ['TaxSetting' => $TaxSetting, 'arrAgencyMarkups' => array_values($Markuparray)];
		} else {
			$data = array('status' => false, 'message' => 'Invalid request');
			return ($data);
		}
	}

	public function array_searcher($AdditionalMarkup, $array)
	{
		$faretypeArr = $AdditionalMarkup['faretypeArr'];
		$keys = [];
		foreach ($array as $key => $value) {
			$showhide_b2c = isset($AdditionalMarkup['finalArr'][$value['fareIdentifier']]['showhide_b2c']) ? $AdditionalMarkup['finalArr'][$value['fareIdentifier']]['showhide_b2c'] : 0;
			$faretype = isset($AdditionalMarkup['finalArr'][$value['fareIdentifier']]['faretype']) ? $AdditionalMarkup['finalArr'][$value['fareIdentifier']]['faretype'] : '';
			if (in_array($value['fareIdentifier'], $faretypeArr)) {
				if ($showhide_b2c == 1) {
					$keys[] = $value;
				} 
				// else {
				// 	$keys[] = [];
				// }
			} elseif ($value['fareIdentifier'] != $faretype) {
				$keys[] = $value;
			}
		}
		return $keys;
	}
	public function array_searcher_tbo($AdditionalMarkup, $array)
	{
		$faretypeArr = $AdditionalMarkup['faretypeArr'];


		$keys = [];
		foreach ($array as $key => $value) {
			$ResultFareType = !empty($value['ResultFareType']) ? $value['ResultFareType'] : '';
			//$fareIdentifier = !empty($value['FareClassification']['Type']) ? $value['FareClassification']['Type'] : $ResultFareType;
			$fareIdentifier = $fareIdentifier__ = !empty($value['FareClassification']['Type']) ? str_replace('.', '_', strtoupper($value['FareClassification']['Type'])) : strtoupper(trim($value['ResultFareType']));

			// echo '<pre>';print_r($fareIdentifier);
			$showhide_b2c = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['showhide_b2c']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['showhide_b2c'] : 0;
			$faretype = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['faretype']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['faretype'] : '';

			if($fareIdentifier == 'PUBLISH'){
				$showhide_b2c = 1;
			}
			// if ($this->gtxagencysysid == '2656') {
			// 	echo "<pre>";
			// 	print_r($fareIdentifier);
			// 	echo "<pre>";
			// 	print_r($faretype);
			// 	echo "<pre>showhide_b2c";
			// 	print_r($showhide_b2c);
			// 	echo "<pre>";
			// 	print_r($faretypeArr);
			// 	echo "<pre>";
			// 	print_r($AdditionalMarkup);
			// 	die;
			// }
			if (in_array($fareIdentifier, $faretypeArr)) {
				if ($showhide_b2c == 1) {
					$keys[] = $value;
				} else {
					$keys[] = [];
				}
			} elseif ($fareIdentifier != $faretype) {
				$keys[] = $value;
			}
		}


		return $keys;
	}
	// start jyt add multicity tbo
	public function FlightDataMultiCityTbo($apiResponse, $sessionFlightSearchParams, $getMarkup, $AdditionalMarkup)
	{
		// echo json_encode($apiResponse);die;
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');

		$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
		//$getMarkup = $this->getMarkup($intCountryCode);
		//$TaxSettingDetail = $this->getTaxSettingDetail($getMarkup['TaxSetting'], 1);
		//$getMarkup['TaxSettingDetail'] = $TaxSettingDetail;
		$intResponseStatus = !empty($apiResponse['ResponseStatus']) ? $apiResponse['ResponseStatus'] : '0';

		$SupplierType = 1;
		$ //TaxSettingDetail = $this->getTaxSettingDetail($getMarkup['TaxSetting'], 1);
		$getCancelCharge = $this->getCancelCharge($intCountryCode, $SupplierType);

		if ($intResponseStatus == 1) {
			// For getting All Airlines Array
			$arrAirlineList = $this->getAirlineIdsAndCodeList();
			// For getting All currency Array
			$arrCurrencyList = $this->getCurrencyIdsAndSymbolList();
			// For getting All Source & Destination CitySysId Array
			$arrCityIds = $this->getCityIdsAndAirPortCodeList();
			$FlightClasses = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getFlightClassesTripJack();
			$strFlightRoute = trim($sessionFlightSearchParams->params['route']);

			$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';

			$flight_class = $FlightClasses[$sessionFlightSearchParams->params['flight_class']];
			$strDepatureDate = $sessionFlightSearchParams->params['departure_dates'];
			$strReturnDate = !empty($sessionFlightSearchParams->params['return_dates']) ? $sessionFlightSearchParams->params['return_dates'] : '';
			$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);
			$strSourceAirportCode = $sessionFlightSearchParams->params['from'];
			$strDestinationAirportCode = $sessionFlightSearchParams->params['to'];
			$adultCount = $sessionFlightSearchParams->params['adults'];
			$childCount = $sessionFlightSearchParams->params['child'];
			$infantCount = $sessionFlightSearchParams->params['infant'];
			$SearchFlightTraceId = $sessionFlightSearchParams->params['SearchFlightTraceId'];
			$intMemberCount = $adultCount + $childCount + $infantCount;

			$this->view->intMemberCount = $intMemberCount;
			$this->view->interNationalSearch = $interNationalSearch;

			$intSourceCityId = ($sessionFlightSearchParams->params['sourceCityId']);
			$intDestinationCityId = ($sessionFlightSearchParams->params['destinationCityId']);

			$arrDepatureDate = explode("/", $strDepatureDate);
			if (count($arrDepatureDate) > 0) {
				$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
			}

			if (!empty($strReturnDate)) {
				$arrReturnDepatureDate = explode("/", $strReturnDate);
				if (count($arrReturnDepatureDate) > 0) {
					$strReturnDate = $arrReturnDepatureDate[2] . "-" . $arrReturnDepatureDate[1] . "-" . $arrReturnDepatureDate[0];
				}
			}
			$intJourneyType = 1;
			$intTripType = 1;

			$localFromDateTime = date("Y-m-d h:i", strtotime($strDepatureDate));
			$localToDateTime = date("Y-m-d h:i", strtotime($strReturnDate));
			$arrCommonInsVariables = array(
				'strTraceId' => $strTraceId,
				'localFromDateTime' => $localFromDateTime,
				'localToDateTime' => $localToDateTime,
				'strSourceAirportCode' => $strSourceAirportCode,
				'strDestinationAirportCode' => $strDestinationAirportCode,
				'intMemberCount' => $intMemberCount,
				'intSourceCityId' => $intSourceCityId,
				'intDestinationCityId' => $intDestinationCityId,
				'JourneyType' => 1, // For Single Trips API Search LocalToTime
				'TripType' => 1,
				'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0
			);

			$strTraceId         = $arrCommonInsVariables['strTraceId'];
			$localFromDateTime  = $arrCommonInsVariables['localFromDateTime'];
			$localToDateTime    = $arrCommonInsVariables['localToDateTime'];

			$strSourceAirportCode    = $arrCommonInsVariables['strSourceAirportCode'];
			$strDestinationAirportCode    = $arrCommonInsVariables['strDestinationAirportCode'];
			$intMemberCount    = $arrCommonInsVariables['intMemberCount'];
			$intSourceCityId    = $arrCommonInsVariables['intSourceCityId'];
			$intDestinationCityId    = $arrCommonInsVariables['intDestinationCityId'];
			$intJourneyType    = $arrCommonInsVariables['JourneyType'];
			$intTripType    = $arrCommonInsVariables['TripType'];
			$interNationalSearch    = isset($arrCommonInsVariables['interNationalSearch']) ? $arrCommonInsVariables['interNationalSearch'] : '0';

			$DayLightSavingDiff = 0;
			$AirportHaultMinutes = 0;
			$arrInsertFlightData = [];

			$keysIndexes = [];
			$arrAirlineName = [];
			$FiltStopCount = [];
			$FiltPriceRange = [];
			$AttPriceRange = [];
			if ($interNationalSearch == 1) {
				$OutBoundFlightResults = $this->array_searcher_tbo($AdditionalMarkup, $apiResponse['InterNationalFlightResults']);
			} else {
				$OutBoundFlightResults = $this->array_searcher_tbo($AdditionalMarkup, $apiResponse['OutBoundFlightResults']);
			}

			//echo '<pre>';print_r($interNationalSearch);die;
			foreach ($OutBoundFlightResults as $keys => $result) {

				$IsGSTMandatory = isset($result['IsGSTMandatory']) ? $result['IsGSTMandatory'] : 0;
				$ResultIndex = $result['ResultIndex'];
				$fareIdcolor = !empty($result['FareClassification']['Color']) ? $result['FareClassification']['Color'] : '#FFFFFF';
				$fareIdentifier = $fareIdentifier__ = !empty($result['FareClassification']['Type']) ? str_replace('.', '_', strtoupper($result['FareClassification']['Type'])) : strtoupper(trim($result['ResultFareType']));
				$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
				$fareremarks = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['remarks']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['remarks'] : '';

				$fareIdentifier = (isset($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier']) && !empty($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'])) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'] : $fareIdentifier__;

				$MiniFareRules = (isset($result['MiniFareRules']) && !empty($result['MiniFareRules'])) ? $result['MiniFareRules'] : [];
				$MiniFR = [];
				if ($MiniFareRules) {
					foreach ($MiniFareRules as $Minivalue) {
						if ($Minivalue) {
							foreach ($Minivalue as $kk => $Mini) {
								$Type = !empty($Mini['Type']) ? strtoupper($Mini['Type']) : 'NA';
								if (empty($Mini['To'])) {
									$TimeFrame = 'from ' . $Mini['From'] . ' ' . $Mini['Unit'] . ' & above before dept';
								} else {
									$TimeFrame = 'from ' . $Mini['From'] . ' To ' . $Mini['To'] . ' ' . $Mini['Unit'] . ' before dept';
								}
								//$MiniFR[$Type][$kk] = $Mini;
								$MiniFR[$Type][$kk]['sector'] = $Mini['JourneyPoints'];
								$MiniFR[$Type][$kk]['amount'] = $Mini['Details'];
								$MiniFR[$Type][$kk]['additionalFee'] = $getCancelCharge;
								$MiniFR[$Type][$kk]['TimeFrame'] = $TimeFrame;
								$MiniFR[$Type][$kk]['policyInfo'] = [];
							}
						}
					}
				}
				$tripbinfo = [];
				if ($result['Segments']) {
					foreach ($result['Segments'] as $value) {
						if ($value) {
							foreach ($value as $kk => $vl) {
								$Baggage = $vl['Baggage'];
								$CabinBaggage = $vl['CabinBaggage'];
								$SectorsCode = $vl['Origin']['Airport']['AirportCode'] . '-' . $vl['Destination']['Airport']['AirportCode'];
								$tripbinfo[$SectorsCode]['ADULT'] = ['cabin' => $CabinBaggage, 'checkin' => $Baggage];
								if (!empty($childCount)) {
									$tripbinfo[$SectorsCode]['CHILD'] = ['cabin' => $CabinBaggage, 'checkin' => $Baggage];
								}
								if (!empty($infantCount)) {
									$tripbinfo[$SectorsCode]['INFANT'] = ['cabin' => $CabinBaggage, 'checkin' => 'NA'];
								}
							}
						}
					}
				}
				$Source = $result['Source'];
				$IsLCC = $result['IsLCC'];
				$IsRefundable = $result['IsRefundable'];
				$AirlineRemark = $result['AirlineRemark'];

				$LastTicketDate = $result['LastTicketDate'];
				$TicketAdvisory = $result['TicketAdvisory'];
				$Currency = $result['Fare']['Currency'];
				$currencySysId = !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
				$BaseFare = $result['Fare']['BaseFare'];
				$Tax = $result['Fare']['Tax'];

				$YQTax = $result['Fare']['YQTax'];
				$AdditionalTxnFeeOfrd = $result['Fare']['AdditionalTxnFeeOfrd'];
				$AdditionalTxnFeePub = $result['Fare']['AdditionalTxnFeePub'];
				$OtherCharges = $result['Fare']['OtherCharges'];
				$Discount = $result['Fare']['Discount'];
				$PublishedFare = $result['Fare']['PublishedFare'];
				$CommissionEarned = $result['Fare']['CommissionEarned'];
				$PLBEarned = $result['Fare']['PLBEarned'];
				$IncentiveEarned = $result['Fare']['IncentiveEarned'];
				$OfferedFare = $result['Fare']['OfferedFare'];
				$TdsOnCommission = $result['Fare']['TdsOnCommission'];
				$TdsOnPLB = $result['Fare']['TdsOnPLB'];
				$TdsOnIncentive = $result['Fare']['TdsOnIncentive'];
				$ServiceFee = $result['Fare']['ServiceFee'];
				$FareBreakdown = $result['FareBreakdown'];
				$totalCommissions = $result['Fare']['CommissionEarned'] + $result['Fare']['PLBEarned'] + $result['Fare']['IncentiveEarned'];
				$TotalPassengerCountForDiscount = $adultCount + $childCount;
				//$intDiscountPerHead = $totalCommissions / $TotalPassengerCountForDiscount;
				$intDiscountPerHead = $totalCommissions;

				$totalCommissionsOnTds = $result['Fare']['TdsOnCommission'] + $result['Fare']['TdsOnIncentive'] + $result['Fare']['TdsOnPLB'];
				$markUpArr = array(
					'getMarkup' => $getMarkup,
					'PublishedFare' => $PublishedFare,
					'OfferedFare' => $OfferedFare,
					'intCommissionEarned' => $CommissionEarned,
					'intPLBEarned' => $PLBEarned,
					'intIncentiveEarned' => $IncentiveEarned,
					'intMemberCount' => $intMemberCount,
					'intFlightRoute' => $strFlightRoute,
					'interNationalSearch' => $interNationalSearch,
					'AddMarkup' => $AddMarkup,
				);

				$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTBO($markUpArr);
				//
				$AgencyMarkUp      = $arrMarkUps['intAgencyFixMarkUp'];
				$intGTXMarkUp      = $arrMarkUps['intGTXMarkUp'];
				$intFareWithGTXMarkUp = $arrMarkUps['intFareWithGTXMarkUp'];

				$intOfferedFare = $arrMarkUps['intOfferedFare'];
				if ($interNationalSearch == 1) {
					$intGTXMarkUp = (($arrMarkUps['intGTXMarkUp'] * $intMemberCount) * $strFlightRoute);
					$intSTaxOnGTXMarkUp = (($arrMarkUps['intSTaxOnGTXMarkUp'] * $intMemberCount) * $strFlightRoute);
					$intAgencyFixMarkUp = (($arrMarkUps['intAgencyFixMarkUp'] * $intMemberCount) * $strFlightRoute);
					$intSTaxOnAgencyFixMarkUp = (($arrMarkUps['intSTaxOnAgencyFixMarkUp'] * $intMemberCount) * $strFlightRoute);
				} else {
					$intGTXMarkUp = ($arrMarkUps['intGTXMarkUp'] * $intMemberCount);
					$intSTaxOnGTXMarkUp = ($arrMarkUps['intSTaxOnGTXMarkUp'] * $intMemberCount);
					$intAgencyFixMarkUp = ($arrMarkUps['intAgencyFixMarkUp'] * $intMemberCount);
					$intSTaxOnAgencyFixMarkUp = ($arrMarkUps['intSTaxOnAgencyFixMarkUp'] * $intMemberCount);
				}

				$CommisionPass = $arrMarkUps['CommisionPass'];
				$intCommisionEarnedForAgency = $arrMarkUps['intCommisionEarnedForAgency'];
				$intPLBEarnedForAgency = $arrMarkUps['intPLBEarnedForAgency'];
				$intIncentiveEarnedForAgency = $arrMarkUps['intIncentiveEarnedForAgency'];
				$intTotalEarningsForAgency = $arrMarkUps['intTotalEarningsForAgency'] + $intAgencyFixMarkUp;

				$intGSTOnAgencyCommisionEarned = $arrMarkUps['intGSTOnAgencyCommisionEarned'];
				$intGSTOnAgencyPLBEarned = $arrMarkUps['intGSTOnAgencyPLBEarned'];
				$intGSTOnAgencyIncentiveEarned = $arrMarkUps['intGSTOnAgencyIncentiveEarned'];
				//$intTotalGSTAgencyEarnings = $intSTaxOnAgencyFixMarkUp + $intGSTOnAgencyCommisionEarned + $intGSTOnAgencyPLBEarned + $intGSTOnAgencyIncentiveEarned;
				$intTotalGSTAgencyEarnings = $intSTaxOnAgencyFixMarkUp;

				$intPublishedFare = 0; // CommisionPass $intOfferedFare+ $ServiceFee + $intGTXMarkUp + $intAgencyFixMarkUp + $intCommisionEarnedForAgency + $intPLBEarnedForAgency + $intIncentiveEarnedForAgency + $intTotalGSTAgencyEarnings;
				$intTotalOfferedForAllPax = 0;
				$intTotalCommissionEarned = 0;
				$countBreakUp = count($FareBreakdown);
				foreach ($FareBreakdown as $pk => $pax) {
					$intPassengerType       = $pax['PassengerType'];
					$intPassengerCount = isset($pax['PassengerCount']) ? $pax['PassengerCount'] : 0;
					$intBaseFare       = $pax['BaseFare'];
					$intTax            = $pax['Tax'];
					$OtherCharges_         = ($OtherCharges / $countBreakUp);
					$intDiscountPerHead_         = ($intDiscountPerHead / $countBreakUp);
					$intBaseFareCal             = $intBaseFare - $intDiscountPerHead_;
					$intFareOfferedToPax       = $intBaseFareCal + $intTax;
					//echo '<pre>';print_r($intBaseFareCal);
					$arrFareBreakdown[$pk] = [
						'intDiscountPerHead'      => $intDiscountPerHead_,
						'Currency'      => $pax['Currency'],
						'APIBaseFare'      => $pax['BaseFare'],
						'BaseFare'      => $pax['BaseFare'], //$intBaseFareCal,
						'Tax'           => $pax['Tax'],
						'YQTax'         => $pax['YQTax'],
						'OtherCharges'         => $OtherCharges_,
						'PassengerType' => $pax['PassengerType'],
						'PassengerCount' => $pax['PassengerCount'],
						'PGCharge'      => $pax['PGCharge'],
						'AdditionalTxnFeePub'   => $pax['AdditionalTxnFeePub'],
						'AdditionalTxnFeeOfrd'  => $pax['AdditionalTxnFeeOfrd'],
						'AgencyMarkUp'  => $AgencyMarkUp,
						'GTXMarkUp'  => $intGTXMarkUp,
						'FareOfferedToPax'  => $intFareOfferedToPax,
						'FixedMarkUp'  => ($intAgencyFixMarkUp / $countBreakUp),
						'GSTOnMarkUp'  => ($intSTaxOnAgencyFixMarkUp / $countBreakUp),
						'intTotalGST'  => ($intSTaxOnAgencyFixMarkUp / $countBreakUp),
						'ServiceFee'  => ($ServiceFee / $countBreakUp),
						'CommisionPass'  => ($CommisionPass / $countBreakUp),
						'intGTXMarkUp'  => $intGTXMarkUp,
						'GTXMarkUpGST'  => $intSTaxOnGTXMarkUp,
						'CommissionEarned'  => ($intCommisionEarnedForAgency / $countBreakUp),
						'IntCommission'  => $arrMarkUps['intCommissionEarned'],
					];
					if ($intPassengerType == 3) {
						$arrFareBreakdown[$pk]['CommisionPass'] = 0;
					}
					$arrFareBreakdown[$pk]['TDS'] = ($totalCommissionsOnTds / $countBreakUp);
					$arrFareBreakdown[$pk]['MF'] = 0;
					$arrFareBreakdown[$pk]['YQ'] = $pax['YQTax'];
					$arrFareBreakdown[$pk]['AGST'] = 0;
					$arrFareBreakdown[$pk]['MFT'] = 0;
					$arrFareBreakdown[$pk]['OT'] = ($pax['Tax'] + $OtherCharges_);
					$arrFareBreakdown[$pk]['MU'] = 0;
					$arrFareBreakdown[$pk]['YR'] = 0;
					$arrFareBreakdown[$pk]['ResultIndex'] = $ResultIndex;
					$arrFareBreakdown[$pk]['intCommisionEarnedForAgency'] = ($intCommisionEarnedForAgency / $countBreakUp);
					$arrFareBreakdown[$pk]['intPLBEarnedForAgency'] = ($intPLBEarnedForAgency / $countBreakUp);
					$arrFareBreakdown[$pk]['intIncentiveEarnedForAgency'] = ($intIncentiveEarnedForAgency / $countBreakUp);
					$arrFareBreakdown[$pk]['Baggage'] = '';
					$arrFareBreakdown[$pk]['CabinBaggage'] = '';

					$intTotalOfferedForAllPax += $intFareOfferedToPax;
					$intTotalCommissionEarned += $intCommisionEarnedForAgency;

					$intPublishedFare += $intBaseFare + $OtherCharges_ + $intTax + ($intAgencyFixMarkUp / $countBreakUp) + ($intSTaxOnAgencyFixMarkUp / $countBreakUp) + ($ServiceFee / $countBreakUp) - ($CommisionPass / $countBreakUp);
				}
				$arrFairRules[0] = array(
					"Currency" => $this->CurrencyTitle, //$Currency,
					"CurrencyRate" => $this->CurrencyRate, //$Currency,
					"currencySysId" => $this->CurrencyId,
					"BaseFare" => $BaseFare,
					"Tax" => $Tax,
					"YQTax" => $YQTax,
					"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
					"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
					"OtherCharges" => $OtherCharges,
					"Discount" => $Discount,
					"ServiceFee" => $ServiceFee,
					"PublishedFare" => ceil($intPublishedFare * $this->CurrencyRate),
					"PublishedFarePerPax" => ceil(($intPublishedFare / $intMemberCount)),
					"CommissionEarned" => $intTotalCommissionEarned,
					"PLBEarned" => $PLBEarned,
					"IncentiveEarned" => $IncentiveEarned,
					"OfferedFare" => $OfferedFare,
					"TdsOnCommission" => $TdsOnCommission,
					"TdsOnPLB" => $TdsOnPLB,
					"TdsOnIncentive" => $TdsOnIncentive,
					//"FareBreakdown" => $FareBreakdown, IsCabinBaggage
					"fareIdentifier" => $fareIdentifier,
					"fareIdcolor" => $fareIdcolor,
					"Refundable" => $IsRefundable,
					"IsRefundableTxt" => $fareIdentifier,
					"AirlineRemark" => $AirlineRemark,
					"fareremarks" =>  $fareremarks,
					"PriceID" => $ResultIndex,
					"Baggage" => '',
					"CabinBaggage" => '',
					"FareBreakdown" => array_values($arrFareBreakdown),
					"arrMarkUps" => $arrMarkUps,
					"TaxSettingDetail" => $arrMarkUps['TaxSettingDetail'],
					"tripbinfo" => $tripbinfo,
				);

				$AccumulatedDuration = 0;
				$arrSegments = [];
				$arrSegmentsPro = [];
				foreach ($result['Segments'] as $key => $results) {

					$AirlineCode = $results[0]['Airline']['AirlineCode'];
					$ValidatingAirline = $result['ValidatingAirline'];
					$Baggage = $results[0]['Baggage'];

					if ($IsLCC) {
						$CabinBaggage = !empty($results[0]['CabinBaggage']) ? $results[0]['CabinBaggage'] : '';
					} else {
						$CabinBaggage = !empty($results[0]['CabinBaggage']) ? $results[0]['CabinBaggage'] : '7 KG';
					}

					array_multisort($arrFairRules);
					$col = array_column($arrFairRules, "PublishedFare");
					array_multisort($col, SORT_ASC, $arrFairRules);
					$originCity = $results[0]['Origin']['Airport']['CityName'];
					$DestinationCity = $results[0]['Destination']['Airport']['CityName'];
					$AirlineCode = $results[0]['Airline']['AirlineCode'];
					$FlightNumber = $results[0]['Airline']['FlightNumber'];
					$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
					$strAirlineName = trim($results[0]['Airline']['AirlineName']);
					$strFareClass = $results[0]['Airline']['FareClass'];
					$AccumulatedDuration = 0;
					$arrSegmentsInternal = [];
					if (count($results[0]) > 0) {


						$FlyingMinutes = 0;
						$countSeg = count($results[0]);
						foreach ($results as $segmentsResult) {

							$Duration = $segmentsResult['Duration'];
							// if ($countSeg >= 2) {
							// 	$AccumulatedDuration += isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : (0);
							// } else {
							// 	$AccumulatedDuration += ($segmentsResult['Duration'] + $segmentsResult['GroundTime']);
							// }
							//$AccumulatedDuration += isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : ($segmentsResult['Duration'] + isset($segmentsResult['GroundTime'])?$segmentsResult['GroundTime']:0);
							// echo "<pre>";print_r($segmentsResult);
							$Duration = isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0;
							$GroundTime = isset($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : 0;
							$AccumulatedDuration += isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : ($Duration + $GroundTime);
							$FlyingMinutes = $AccumulatedDuration;
							$LAYOVERMinutes = ((isset($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : 0));
							$DepTime = $segmentsResult['Origin']['DepTime'];
							$ArrTime = $segmentsResult['Destination']['ArrTime'];
							$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($LAYOVERMinutes);
							// FOR FLIGHT SEGMENTS.....
							$strBaggage = $segmentsResult['Baggage'];
							//$strCabinBaggage = $segmentsResult['CabinBaggage'];
							if ($IsLCC) {
								$strCabinBaggage = $segmentsResult['CabinBaggage'];
							} else {
								$strCabinBaggage = !empty($segmentsResult['CabinBaggage']) ? $segmentsResult['CabinBaggage'] : '7 KG ';
							}
							if (!empty($strBaggage)) {
								$IsBaggage = true;
							} else {
								$IsBaggage = false;
							}
							// if (!empty($strCabinBaggage)) {
							// 	$strCabinBaggage = $strCabinBaggage;
							// } else {
							// 	$strCabinBaggage = '';
							// }
							$TripIndicator = $segmentsResult['TripIndicator'];
							$SegmentIndicator = $segmentsResult['SegmentIndicator'];

							$strAirlineCode = $segmentsResult['Airline']['AirlineCode'];
							$AirlineName = $segmentsResult['Airline']['AirlineName'];
							$FlightNumber = $segmentsResult['Airline']['FlightNumber'];
							$FareClass = $segmentsResult['Airline']['FareClass'];

							$SegFlightNumber = $strAirlineCode . "-" . $FlightNumber;

							$DepTerminal = $segmentsResult['Origin']['Airport']['Terminal'];
							if (!empty($DepTerminal)) {
								$DepTerminal = $DepTerminal;
							} else {
								$DepTerminal = 0;
							}
							$ArrTerminal = $segmentsResult['Destination']['Airport']['Terminal'];
							if (!empty($ArrTerminal)) {
								$ArrTerminal = $ArrTerminal;
							} else {
								$ArrTerminal = 0;
							}

							$originAirportName = $segmentsResult['Origin']['Airport']['AirportName'];
							$originAirportCode = $segmentsResult['Origin']['Airport']['AirportCode'];
							$originCityName = $segmentsResult['Origin']['Airport']['CityName'];
							$originCountryName = $segmentsResult['Origin']['Airport']['CountryName'];
							$originDepTime = $segmentsResult['Origin']['DepTime'];

							$destinationAirportName = $segmentsResult['Destination']['Airport']['AirportName'];
							$destinationAirportCode = $segmentsResult['Destination']['Airport']['AirportCode'];
							$destinationCityName = $segmentsResult['Destination']['Airport']['CityName'];
							$destinationCountryName = $segmentsResult['Destination']['Airport']['CountryName'];
							$destinationArrTime = $segmentsResult['Destination']['ArrTime'];

							$Duration = $segmentsResult['Duration'];
							$GroundTime = $segmentsResult['GroundTime'];
							$Mile = $segmentsResult['Mile'];
							$StopOver = $segmentsResult['StopOver'];
							$StopPoint = $segmentsResult['StopPoint'];
							$StopPointArrivalTime = $segmentsResult['StopPointArrivalTime'];
							$StopPointDepartureTime = $segmentsResult['StopPointDepartureTime'];
							$Craft = $segmentsResult['Craft'];
							$Remark = $segmentsResult['Remark'];
							$IsETicketEligible = $segmentsResult['IsETicketEligible'];
							$NoOfSeatAvailable = !empty($segmentsResult['NoOfSeatAvailable']) ? $segmentsResult['NoOfSeatAvailable'] : 0;
							$FlightStatus = $segmentsResult['FlightStatus'];
							$Status = $segmentsResult['Status'];

							if ($GroundTime > 0) {
								$LAYOVERCity = $originCityName;
							} else {
								$LAYOVERCity = '';
							}
							$strAirlineCodeLogo = $strAirlineCode;

							$filePath = $_SERVER['DOCUMENT_ROOT'] . "/public/upload/AirlineLogo/";
							if (file_exists($filePath . $strAirlineCodeLogo . ".gif")) {
								$strAirlineLogo = $strAirlineCodeLogo . ".gif";
								$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
							} elseif (file_exists($filePath . $strAirlineCodeLogo . ".png")) {
								$strAirlineLogo = $strAirlineCodeLogo . ".png";
								$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
							} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpg")) {
								$strAirlineLogo = $strAirlineCodeLogo . ".jpg";
								$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
							} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpeg")) {
								$strAirlineLogo = $strAirlineCodeLogo . ".jpeg";
								$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
							} else {
								$filePath = $this->baseUrl . "public/upload/AirlineLogo/noimage.png";
							}


							$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->convertMinutesToHoursFormat((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0));

							$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($ArrTime);
							$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($DepTime);
							$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);

							$arrSegments[] = $arrSegmentsInternal[] = array(
								"segmentid" => $FlightNumber,
								"originAirportName" => $originAirportName,
								"destinationAirportName" => $destinationAirportName,
								"originCityName" => $originCityName,
								"originCountryName" => $originCountryName,
								"destinationCityName" => $destinationCityName,
								"destinationCountryName" => $destinationCountryName,
								"destinationAirportCode" => $destinationAirportCode,
								"destinationAirportCode" => $destinationAirportCode,
								"destinationArrTime" => $destinationArrTime,
								"SegFlightNumber" => $SegFlightNumber,
								"AirlineCode" => $strAirlineCode,
								"AirlineName" => $AirlineName,
								"FareClass" => $FareClass,
								"originAirportCode" => $originAirportCode,
								"originDepTime" => $originDepTime,
								"TripIndicator" => $TripIndicator,
								"Baggage" => $strBaggage,
								"CabinBaggage" => $strCabinBaggage,
								"IsBaggage" => $IsBaggage,
								"IsCabinBaggage" => !empty($strCabinBaggage) ? true : false,
								"SegmentIndicator" => $SegmentIndicator,
								"Duration" => $Duration,
								"GroundTime" => $GroundTime,
								"Mile" => $Mile,
								"StopOver" => $StopOver,
								"StopPoint" => $StopPoint,
								"StopPointArrivalTime" => $StopPointArrivalTime,
								"StopPointDepartureTime" => $StopPointDepartureTime,
								"Craft" => $Craft,
								"Remark" => $Remark,
								"IsETicketEligible" => $IsETicketEligible,
								"FlightStatus" => $FlightStatus,
								"Status" => $Status,
								"NoOfSeatAvailable" => $NoOfSeatAvailable,
								"strDepartureDtTime" => $strDepartureDtTime,
								"strArrivalDtTime" => $strArrivalDtTime,
								"FlightDuration" => $strDuration,
								"LAYOVERDuration" => $LAYOVERDuration,
								"LAYOVERCity" => $LAYOVERCity,
								"DepTerminal" => $DepTerminal,
								"ArrTerminal" => $ArrTerminal,
								"filePath" => $filePath,
							);
							// FOR FLIGHT SEGMENTS.....
						}
					}

					$airlineSysId = !empty($arrAirlineList[$result['AirlineCode']]) ? $arrAirlineList[$result['AirlineCode']] : '0';
					$FlyingMinutes = $AccumulatedDuration;

					//$DepOrigin = $results[0]['Origin'];
					//$DepDestination = $results[0]['Destination'];
					//
					if (count($results) == 1) {
						$DepOrigin = $results[0]['Origin'];
						$DepDestination = $results[0]['Destination'];
					} elseif (count($results) == 2) {
						$DepOrigin = $results[0]['Origin'];
						$DepDestination = $results[1]['Destination'];
					} elseif (count($results) == 3) {
						$DepOrigin = $results[0]['Origin'];
						$DepDestination = $results[2]['Destination'];
					} elseif (count($results) == 4) {
						$DepOrigin = $results[0]['Origin'];
						$DepDestination = $results[3]['Destination'];
					}
					//echo '<pre>DepOrigin';print_r($DepOrigin);
					//echo '<pre>DepDestination';print_r($DepDestination);
					$strSourceAirportCode = $DepOrigin['Airport']['AirportCode'];
					$strDestinationAirportCode = $DepDestination['Airport']['AirportCode'];

					if (count($results) > 1) {
						$SegmentsCount = count($results);
						$StopCount = $SegmentsCount - 1;
						$IsDirect = '0';
						$initialOriginDepTime = $DepOrigin['DepTime'];
						$initialOriginArrTime = $DepDestination['ArrTime'];
					} else {
						$StopOver_ = isset($results[$key]['StopOver']) ? $results[$key]['StopOver'] : false;
						$StopCount = ($StopOver_) ? $StopOver_ : '0';
						$IsDirect = '1';
						$initialOriginDepTime = $results[0]['Origin']['DepTime'];
						$initialOriginArrTime = $results[0]['Destination']['ArrTime'];
					}

					$strAirlineCodeEX = explode("-", trim($strFlightNumber));
					$strAirlineCodeLogo = $strAirlineCodeEX[0];

					$filePath = $_SERVER['DOCUMENT_ROOT'] . "/public/upload/AirlineLogo/";
					if (file_exists($filePath . $strAirlineCodeLogo . ".gif")) {
						$strAirlineLogo = $strAirlineCodeLogo . ".gif";
						$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
					} elseif (file_exists($filePath . $strAirlineCodeLogo . ".png")) {
						$strAirlineLogo = $strAirlineCodeLogo . ".png";
						$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
					} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpg")) {
						$strAirlineLogo = $strAirlineCodeLogo . ".jpg";
						$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
					} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpeg")) {
						$strAirlineLogo = $strAirlineCodeLogo . ".jpeg";
						$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
					} else {
						$filePath = $this->baseUrl . "public/upload/AirlineLogo/noimage.png";
					}


					$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($initialOriginArrTime);
					$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($initialOriginDepTime);
					$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
					if ($StopCount == 0) {
						$StopCountTxt = "Non-stop";
					} else {
						$StopCountTxt = $StopCount . " Stop(s)";
					}
					if ($IsRefundable) {
						$IsRefundableTxt = 'Refundable';
					} else {
						$IsRefundableTxt = 'Non Refundable';
					}
					$arrSegmentsPro[$key]['FlightNumber'] = $strFlightNumber;
					$arrSegmentsPro[$key]['SegFlightNumberArr'] = $strFlightNumber;
					$arrSegmentsPro[$key]['AirlineName'] = ucfirst(strtolower($strAirlineName));
					$arrSegmentsPro[$key]['AirlineCode'] = $AirlineCode;
					$arrSegmentsPro[$key]['AirInvenSysId'] = $arrAirlineList[$AirlineCode];
					$arrSegmentsPro[$key]['IsGSTMandatory'] = $IsGSTMandatory;
					$arrSegmentsPro[$key]['IsMealIncludes'] = ($IsLCC == 1) ? false : true;
					$arrSegmentsPro[$key]['IsBagIncludes'] = !empty($strBaggage) ? true : false;
					$arrSegmentsPro[$key]['IsCabinBagIncludes'] = !empty($strCabinBaggage) ? true : false;
					$arrSegmentsPro[$key]['IsRefundable'] = $IsRefundable;
					$arrSegmentsPro[$key]['IsRefundableTxt'] = $IsRefundableTxt;
					$arrSegmentsPro[$key]['apiTraceId'] = $strTraceId;
					$arrSegmentsPro[$key]['AirlineSysId'] = $airlineSysId;
					$arrSegmentsPro[$key]['TravelDate'] = date('Y-m-d', strtotime($initialOriginDepTime));
					$arrSegmentsPro[$key]['LocalFromTime'] = str_replace('T', ' ', $initialOriginDepTime);
					$arrSegmentsPro[$key]['FromUTCTime'] = $initialOriginDepTime;
					$arrSegmentsPro[$key]['LocalToTime'] = str_replace('T', ' ', $initialOriginArrTime);
					$arrSegmentsPro[$key]['DepartureDateTxt'] = date('D, d M', strtotime($initialOriginDepTime));
					$arrSegmentsPro[$key]['ArrivalDateTxt'] = date('D, d M', strtotime($initialOriginArrTime));
					$arrSegmentsPro[$key]['ToUTCTime'] = $initialOriginArrTime;
					$arrSegmentsPro[$key]['DepartureTime'] = $strDepartureDtTime;
					$arrSegmentsPro[$key]['ArrivalTime'] = $strArrivalDtTime;
					$arrSegmentsPro[$key]['IsDirect'] = $IsDirect;
					$arrSegmentsPro[$key]['FareClass'] = $strFareClass;
					$arrSegmentsPro[$key]['DayLightSavingDiff'] = $DayLightSavingDiff;
					$arrSegmentsPro[$key]['FlyingMinutes'] = $FlyingMinutes;
					$arrSegmentsPro[$key]['FlightDuration'] = $FlightDuration;
					$arrSegmentsPro[$key]['SourcePlaceSysId'] = $intSourceCityId[$key];
					$arrSegmentsPro[$key]['DestPlaceSysId'] = $intDestinationCityId[$key];
					$arrSegmentsPro[$key]['SourceAirportCode'] = $strSourceAirportCode;
					$arrSegmentsPro[$key]['DestAirportCode'] = $strDestinationAirportCode;
					$arrSegmentsPro[$key]['AirportHaultMinutes'] = $AirportHaultMinutes;
					$arrSegmentsPro[$key]['StopCount'] = $StopCountTxt;
					$arrSegmentsPro[$key]['Stops'] = $StopCount;
					$arrSegmentsPro[$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
					$arrSegmentsPro[$key]['TotalFlightMembers'] = $intMemberCount;
					$arrSegmentsPro[$key]['CurrencyType'] = $this->CurrencyId;
					$arrSegmentsPro[$key]['IsLCC'] = $IsLCC;
					$arrSegmentsPro[$key]['ApiResultIndex'] = $ResultIndex;
					$arrSegmentsPro[$key]['JourneyType'] = $intJourneyType;
					$arrSegmentsPro[$key]['TripType'] = $intTripType;
					$arrSegmentsPro[$key]['ICSourceSysId'] = 3;
					$arrSegmentsPro[$key]['IsInternational'] = $interNationalSearch;
					$arrSegmentsPro[$key]['SearchFlightTraceId'] = $SearchFlightTraceId;
					$arrSegmentsPro[$key]['logo'] = $filePath;
					$arrSegmentsPro[$key]['IsNewMigration'] = true;
					$arrSegmentsPro[$key]['Segments'] = $arrSegmentsInternal;
					$arrAirlineName[] = $AirlineCode . '-' . ucfirst(strtolower($strAirlineName));
					$FiltStopCount[] = $StopCountTxt;
					$AttPriceRange[] = $intPublishedFare;
				}

				if ($StopCount == 0) {
					$StopCountTxt = "Non-stop";
				} else {
					$StopCountTxt = $StopCount . " Stop(s)";
				}
				if ($IsRefundable) {
					$IsRefundableTxt = 'Refundable';
				} else {
					$IsRefundableTxt = 'Non Refundable';
				}
				$LocalFromTime = str_replace('T', ' ', $initialOriginDepTime);
				$LocalToTime = str_replace('T', ' ', $initialOriginArrTime);
				$FlightNumber = $strFlightNumber;
				$FareClass = ''; //!empty($strFareClass)?$strFareClass:'';

				$arrFairRules[0]['classOfBooking'] = $strFareClass;
				$arrFairRules[0]['FareClass'] = $flight_class;
				$arrFairRules[0]['Refundable'] = $IsRefundable;
				$arrFairRules[0]['IsRefundableTxt'] = $IsRefundableTxt;
				$arrFairRules[0]['SeatAvailable'] = $NoOfSeatAvailable;
				$arrFairRules[0]['IsGSTRequired'] = $IsGSTMandatory;
				$arrFairRules[0]['IsMealIncludes'] = ($IsLCC == 1) ? false : true;
				$arrFairRules[0]['IsBaggage'] = !empty($strBaggage) ? true : false;
				$arrFairRules[0]['IsCabinBaggage'] = !empty($strCabinBaggage) ? true : false;

				$arrInsertFlightData[$keys]['DepartureTime'] = $strDepartureDtTime;
				$arrInsertFlightData[$keys]['ArrivalTime'] = $strArrivalDtTime;
				$arrInsertFlightData[$keys]['FlightDuration'] = $FlightDuration;
				$arrInsertFlightData[$keys]['AirlineName'] = $strAirlineName;
				$arrInsertFlightData[$keys]['PublishedFare'] = $intPublishedFare;
				$arrInsertFlightData[$keys]['FairRules'] = $arrFairRules;
				$arrInsertFlightData[$keys]['Segments'] = $arrSegments;
				$arrInsertFlightData[$keys]['arrSegmentsPro'] = $arrSegmentsPro;
				$arrInsertFlightData[$keys]['ApiResultIndex'] = $ResultIndex;
				$arrInsertFlightData[$keys]['apiTraceId'] = $strTraceId;
				$arrInsertFlightData[$keys]['ICSourceSysId'] = 3;
				$arrInsertFlightData[$keys]['IsInternational'] = $interNationalSearch;
				$arrInsertFlightData[$keys]['SearchFlightTraceId'] = $SearchFlightTraceId;
				$arrInsertFlightData[$keys]['JourneyType'] = $intJourneyType;
				$arrInsertFlightData[$keys]['TripType'] = $intTripType;
				$arrInsertFlightData[$keys]['IsNewMigration'] = true;
				$arrInsertFlightData[$keys]['MiniFR'] = $MiniFR;
			}

			$FiltStopCount = array_values(array_unique($FiltStopCount));
			$arrAirlineName = array_values(array_unique($arrAirlineName));
			$AttPriceRange = array_values(array_unique($AttPriceRange));

			$MinriceRange = (min($AttPriceRange));
			$MaxriceRange = (max($AttPriceRange));
			$MultiHead = [];
			$sessionFlightSearchParams = $sessionFlightSearchParams->params;

			// echo json_encode($arrInsertFlightData);
			// die;
			// exit;
			$data = array('outbound' => array_values($arrInsertFlightData), 'MultiHead' => [], 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute, 'CurrencyTitle' => $this->CurrencyTitle, 'inbound' => [], 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'ArrPriceUnique' => [], 'MinriceRange' => round($MinriceRange), 'MaxriceRange' => round($MaxriceRange));
			echo json_encode($data);
			exit;
			// return ($data);
		} else {
			$data = array('outbound' => [], 'inbound' => [], 'arrAirlineName' => [], 'FiltStopCount' => [], 'ArrPriceUnique' => [], 'MinriceRange' => 0, 'MaxriceRange' => 0);
			return ($data);
		}
	}
	// end jyt add
	public function FlightDataMultiCity($apiResponse, $sessionFlightSearchParams, $getMarkup, $AdditionalMarkup)
	{
		$arrAirlineList = $this->getAirlineIdsAndCodeList();
		$intSourceCityId = ($sessionFlightSearchParams['sourceCityId']);
		$intDestinationCityId = ($sessionFlightSearchParams['destinationCityId']);
		$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
		$strFlightRoute = trim($sessionFlightSearchParams['route']);
		$adultCount = $sessionFlightSearchParams['adults'];
		$childCount = $sessionFlightSearchParams['child'];
		$infantCount = $sessionFlightSearchParams['infant'];
		$intMemberCount = $adultCount + $childCount + $infantCount;
		$strFlightRoute = trim($sessionFlightSearchParams['route']);
		$strDepatureDate = $sessionFlightSearchParams['departure_dates'];
		$strReturnDate = $sessionFlightSearchParams['return_dates'];
		$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
		$SearchFlightTraceId = $sessionFlightSearchParams['SearchFlightTraceId'];

		//echo"<pre>";print_r($intSourceCityId);
		//echo"<pre>";print_r($sessionFlightSearchParams);
		//die;
		if (!empty(trim($interNationalSearch)) && trim($interNationalSearch) == 1) {
			$this->FlightDataMultiCityInterNational($apiResponse, $sessionFlightSearchParams, $getMarkup, $AdditionalMarkup);
		}
		$intJourneyType = 1;
		$intTripType = 1;
		$arrInsertFlightData = [];
		$arrAirlineName = [];
		$FiltStopCount = [];
		$FiltPriceRange = [];
		$AttPriceRange = [];
		$dddddddd = [];
		$intResponseStatus = $apiResponse['ResponseStatus'];
		$ONWARD = $apiResponse['OutBoundFlightResults'];
		if ($intResponseStatus == 1) {
			if ($ONWARD) {
				foreach ($ONWARD as $keys => $tripInfos) {
					foreach ($tripInfos as $key => $result) {

						//echo"<pre>";print_r($result);die;
						$SegmentInformation = $result['sI'];
						$totalPriceList = current($result['totalPriceList']);
						$IsRefundable = $totalPriceList['fd']['ADULT']['rT'];
						$NoOfSeatAvailable = $totalPriceList['fd']['ADULT']['sR'];
						$strFareClass = $totalPriceList['fd']['ADULT']['cB']; //Cabin Baggage
						$IsMealIncludes = isset($totalPriceList['fd']['ADULT']['mI']) ? $totalPriceList['fd']['ADULT']['mI'] : false;

						$bagInfo = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Check In Baggage
						$cabinbagInfo = $totalPriceList['fd']['ADULT']['bI']['cB']; ///Cabin Baggage
						$strTraceId = $totalPriceList['id'];
						$ResultIndex = $totalPriceList['id'];
						if (!empty($bagInfo)) {
							$IsBagIncludes = true;
						} else {
							$IsBagIncludes = false;
						}
						if (!empty($cabinbagInfo)) {
							$IscabinbagIncludes = true;
						} else {
							$IscabinbagIncludes = false;
						}


						if ($IsRefundable == 0) {
							$IsRefundableTxt = 'Non Refundable';
						} elseif ($IsRefundable == 1) {
							$IsRefundableTxt = 'Refundable';
						} else {
							$IsRefundableTxt = 'Partial Refundable';
						}
						$OriginSegments = current($SegmentInformation);
						$DestinationSegments = end($SegmentInformation);

						// echo '<pre>';print_r($DestinationSegments);echo '</pre>';
						$arrSegments = [];
						$FlyingMinutes = 0;
						$TotalLAYOVERMinutes = 0;
						$LAYOVERCityArr = [];
						$PublishedFare = 0;
						$PublishedFareReverse = 0;
						$BaseFare = 0;
						$Tax = 0;
						$YQTax = 0;
						$OtherCharges = 0;
						$ServiceFee = 0;
						$FareBreakdown = [];
						$FairRulesArr = [];
						$intYQTaxToT = 0;
						$intTotalOfferedForAllPax = 0;
						$intBaseFareAllPax = 0;
						$intTaxAllPax = 0;

						// echo '<pre>';print_r($FairRulesArr);
						$TotalLAYOVERMinutes = 0;
						$SegFlightNumberArr = [];
						if ($SegmentInformation) {
							foreach ($SegmentInformation as $segments) {
								//echo '<pre>';print_r($segments);

								$segmentid = $segments['id'];
								$duration = $segments['duration'];
								$LAYOVERMinutes = $GroundTime = isset($segments['cT']) ? $segments['cT'] : 0;
								$LAYOVERCity = $LAYOVERCityArr[] = isset($segments['cT']) ? $segments['aa']['city'] : '';
								$FlyingMinutes += ($duration + $LAYOVERMinutes);
								$TotalLAYOVERMinutes += $LAYOVERMinutes;

								$FareClass = $totalPriceList['fd']['ADULT']['cB'];
								$strBaggage = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Checking Baggage
								$strCabinBaggage = $totalPriceList['fd']['ADULT']['bI']['cB']; ////Cabin Baggage

								if (!empty($strCabinBaggage)) {
									$IsCabinBaggage = true;
								} else {
									$IsCabinBaggage = false;
								}



								if (!empty($strCabinBaggage)) {
									$IsBaggage = true;
								} else {
									$IsBaggage = false;
								}

								$AirlineCode = $segments['fD']['aI']['code'];
								$AirlineName = $segments['fD']['aI']['name'];
								$FlightNumber = $segments['fD']['fN'];
								$SegFlightNumber = $AirlineCode . "-" . $FlightNumber;

								$originAirportName = $segments['da']['name'];
								$originAirportCode = $segments['da']['code'];
								$originCityName = $segments['da']['city'];
								$originCountryName = $segments['da']['country'];
								$originDepTime = $segments['dt'];

								$destinationAirportName = $segments['aa']['name'];
								$destinationAirportCode = $segments['aa']['code'];
								$destinationCityName = $segments['aa']['city'];
								$destinationCountryName = $segments['aa']['country'];
								$destinationArrTime = $segments['at'];

								$DepTerminal = isset($segments['da']['terminal']) ? $segments['da']['terminal'] : '';
								$ArrTerminal = isset($segments['aa']['terminal']) ? $segments['aa']['terminal'] : '';

								$filePath = $this->getflightlogo($AirlineCode);

								$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->MinutesToHours($LAYOVERMinutes);

								$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($destinationArrTime);
								$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($originDepTime);
								$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($duration);
								$arrSegments[] = array(
									"originAirportName" => $originAirportName,
									"destinationAirportName" => $destinationAirportName,
									"originCityName" => $originCityName,
									"originCountryName" => $originCountryName,
									"destinationCityName" => $destinationCityName,
									"destinationCountryName" => $destinationCountryName,
									"destinationAirportCode" => $destinationAirportCode,
									"destinationAirportCode" => $destinationAirportCode,
									"destinationArrTime" => $destinationArrTime,
									"SegFlightNumber" => $SegFlightNumber,
									"AirlineCode" => $AirlineCode,
									"AirlineName" => $AirlineName,
									"FareClass" => $FareClass,
									"originAirportCode" => $originAirportCode,
									"originDepTime" => $originDepTime,
									"TripIndicator" => '', //$TripIndicator,
									"Baggage" => $strBaggage,
									"IsBaggage" => $IsBaggage,
									"IsCabinBaggage" => $IsCabinBaggage,
									"CabinBaggage" => $strCabinBaggage,
									"IsMealIncludes" => $IsMealIncludes,
									"Duration" => $duration,
									"GroundTime" => $GroundTime,
									"NoOfSeatAvailable" => $NoOfSeatAvailable,
									"strDepartureDtTime" => $strDepartureDtTime,
									"strArrivalDtTime" => $strArrivalDtTime,
									"FlightDuration" => $strDuration,
									"LAYOVERDuration" => $LAYOVERDuration,
									"LAYOVERCity" => $LAYOVERCity,
									"DepTerminal" => $DepTerminal,
									"ArrTerminal" => $ArrTerminal,
									"filePath" => $filePath,
								);
								$SegFlightNumberArr[] = $SegFlightNumber;
								$segmentSector[$segmentid] = ['origin' => $originAirportCode, 'destination' => $destinationAirportCode];
							}
						}

						$array_searcher = $this->array_searcher($AdditionalMarkup, $result['totalPriceList']);
						array_multisort($array_searcher);
						if ($array_searcher) {
							foreach ($array_searcher as $kp => $price) {
								$fareDetail = $price['fd'];
								$tripbaggageinfo = [];
								if ($price['tai']['tbi']) {
									foreach ($price['tai']['tbi'] as $keyss => $tbi) {
										$segc = isset($segmentSector[$keyss]) ? $segmentSector[$keyss] : '';
										$sectorKey = $segc['origin'] . '-' . $segc['destination'];
										if ($tbi) {
											foreach ($tbi as $kgk => $pbi) {
												if ($pbi) {
													foreach ($pbi as $gk => $vll) {
														$tripbaggageinfo[$sectorKey][$gk] = ['cabin' => isset($vll['cB']) ? $vll['cB'] : 'NA', 'checkin' => isset($vll['iB']) ? $vll['iB'] : 'NA'];
													}
												}
											}
										}
									}
								}
								//echo '<pre>';print_r(($fareDetail));echo '</pre>';
								$Refundable = $fareDetail['ADULT']['rT'];
								$PriceID = $price['id'];
								$fareIdentifier = $price['fareIdentifier'];
								$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
								$IsMealIncludes = $fareDetail['ADULT']['mI'];
								$strBaggage = $price['fd']['ADULT']['bI']['iB']; ///Checking Baggage
								$strCabinBaggage = $price['fd']['ADULT']['bI']['cB']; ////Cabin Baggage

								if (!empty($strCabinBaggage)) {
									$IsCabinBaggage = true;
								} else {
									$IsCabinBaggage = false;
								}

								if (!empty($strCabinBaggage)) {
									$IsBaggage = true;
								} else {
									$IsBaggage = false;
								}

								if ($fareIdentifier == 'SME') {
									$IsGSTRequired = true;
								} else {
									$IsGSTRequired = false;
								}
								if ($fareIdentifier == 'TACTICAL' || $fareIdentifier == 'COUPON') {
									$fareIdentifier = 'PROMO';
								}
								if ($Refundable == 0) {
									$IsRefundableTxt = 'Non Refundable';
								} elseif ($Refundable == 1) {
									$IsRefundableTxt = 'Refundable';
								} else {
									$IsRefundableTxt = 'Partial Refundable';
								}
								$ADULT = $fareDetail['ADULT']['fC']; //fare Components
								$CHILD = isset($fareDetail['CHILD']['fC']) ? $fareDetail['CHILD']['fC'] : []; //fare Components
								$INFANT = isset($fareDetail['INFANT']['fC']) ? $fareDetail['INFANT']['fC'] : []; //fare Components
								if (!empty($ADULT)) {
									$PaxTypeCount = 1;
								}
								if (!empty($CHILD)) {
									$PaxTypeCount = 2;
								}
								if (!empty($INFANT)) {
									$PaxTypeCount = 3;
								}
								$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
								$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
								$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents

								$ADULTNCMTDS = isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
								$CHILDNCMTDS = isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
								$INFANTNCMTDS = isset($fareDetail['INFANT']['afC']['NCM']['TDS']) ? $fareDetail['INFANT']['afC']['NCM']['TDS'] : 0; //TDS

								$ADULTNCMTOT = isset($fareDetail['ADULT']['afC']['NCM']['OT']) ? $fareDetail['ADULT']['afC']['NCM']['OT'] : 0; //- Gross Commission
								$CHILDNCMTOT = isset($fareDetail['CHILD']['afC']['NCM']['OT']) ? $fareDetail['CHILD']['afC']['NCM']['OT'] : 0; //- Gross Commission
								$INFANTNCMTOT = isset($fareDetail['INFANT']['afC']['NCM']['OT']) ? $fareDetail['INFANT']['afC']['NCM']['OT'] : 0; //- Gross Commission

								$AD_MF = isset($ADULTafC['MF']) ? $ADULTafC['MF'] : 0; //Management Fee
								$AD_YQ = isset($ADULTafC['YQ']) ? $ADULTafC['YQ'] : 0; //Fuel Surcharge
								$AD_AGST = isset($ADULTafC['AGST']) ? $ADULTafC['AGST'] : 0; //Airline GST Component
								$AD_MFT = isset($ADULTafC['MFT']) ? $ADULTafC['MFT'] : 0; //Management Fee Tax
								$AD_OT = isset($ADULTafC['OT']) ? $ADULTafC['OT'] : 0; //Other Charges
								$AD_MU = isset($ADULTafC['MU']) ? $ADULTafC['MU'] : 0; //markup
								$AD_YR = isset($ADULTafC['YR']) ? $ADULTafC['YR'] : 0; //Carrier Misc Fee

								$CH_MF = isset($CHILDafC['MF']) ? $CHILDafC['MF'] : 0; //Management Fee
								$CH_YQ = isset($CHILDafC['YQ']) ? $CHILDafC['YQ'] : 0; //Fuel Surcharge
								$CH_AGST = isset($CHILDafC['AGST']) ? $CHILDafC['AGST'] : 0; //Airline GST Component
								$CH_MFT = isset($CHILDafC['MFT']) ? $CHILDafC['MFT'] : 0; //Management Fee Tax
								$CH_OT = isset($CHILDafC['OT']) ? $CHILDafC['OT'] : 0; //Other Charges
								$CH_MU = isset($CHILDafC['MU']) ? $CHILDafC['MU'] : 0; //markup
								$CH_YR = isset($CHILDafC['YR']) ? $CHILDafC['YR'] : 0; //Carrier Misc Fee

								$IN_MF = isset($INFANTafC['MF']) ? $INFANTafC['MF'] : 0; //Management Fee
								$IN_YQ = isset($INFANTafC['YQ']) ? $INFANTafC['YQ'] : 0; //Fuel Surcharge
								$IN_AGST = isset($INFANTafC['AGST']) ? $INFANTafC['AGST'] : 0; //Airline GST Component
								$IN_MFT = isset($INFANTafC['MFT']) ? $INFANTafC['MFT'] : 0; //Management Fee Tax
								$IN_OT = isset($INFANTafC['OT']) ? $INFANTafC['OT'] : 0; //Other Charges
								$IN_MU = isset($INFANTafC['MU']) ? $INFANTafC['MU'] : 0; //markup
								$IN_YR = isset($INFANTafC['YR']) ? $INFANTafC['YR'] : 0; //Carrier Misc Fee

								if ($kp == 0) {
									$PublishedFare += (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
									$BaseFare += (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
									$Tax += (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
								}

								$PublishedFareIN = (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
								$BaseFareIN = (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
								$TaxIN = (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
								$NetFare = (($ADULT['NF'] * $adultCount) + ($CHILD['NF'] * $childCount) + ($INFANT['NF'] * $infantCount)); //Taxes and Fees
								$NetCommission = (($ADULT['NCM'] * $adultCount) + ($CHILD['NCM'] * $childCount) + ($INFANT['NCM'] * $infantCount)); //Taxes and Fees
								//echo '<pre>';print_r(($ADULTafC));echo '</pre>';
								$YQTax = (($AD_YQ * $adultCount) + ($CH_YQ * $childCount) + ($IN_YQ * $infantCount));
								$OtherCharges = (($AD_OT * $adultCount) + ($CH_OT * $childCount) + ($IN_OT * $infantCount));
								$ServiceFee = (($AD_MF * $adultCount) + ($CH_MF * $childCount) + ($IN_MF * $infantCount));
								$ManagementFeeTax = (($AD_MFT * $adultCount) + ($CH_MFT * $childCount) + ($IN_MFT * $infantCount));
								$AirlineGSTComponent = (($AD_AGST * $adultCount) + ($CH_AGST * $childCount) + ($IN_AGST * $infantCount));
								$CarrierMiscFee = (($AD_YR * $adultCount) + ($CH_YR * $childCount) + ($IN_YR * $infantCount));
								$MUFee = (($AD_MU * $adultCount) + ($CH_MU * $childCount) + ($IN_MU * $infantCount));
								$TdsOnPLB = (($ADULTNCMTDS * $adultCount) + ($CHILDNCMTDS * $childCount) + ($INFANTNCMTDS * $infantCount));
								//$NetCommission = (($ADULTNCMTOT * $adultCount) + ($CHILDNCMTOT * $childCount) + ($INFANTNCMTOT * $infantCount));

								//$PublishedFareIN = $NetFare;
								$PublishedFare = $PublishedFareIN;
								$CommissionEarned = $NetCommission;
								$PLBEarned = 0; //$result['Fare']['PLBEarned'];
								$IncentiveEarned = 0; //$result['Fare']['IncentiveEarned'];
								$OfferedFare = $PublishedFareIN;
								$markUpArr = array(
									'getMarkup' => $getMarkup,
									'PublishedFare' => $PublishedFare,
									'OfferedFare' => $NetFare,
									'intCommissionEarned' => $CommissionEarned,
									'TdsOnPLB' => $TdsOnPLB,
									'MUFee' => $MUFee,
									'intPLBEarned' => $PLBEarned,
									'intIncentiveEarned' => $IncentiveEarned,
									'intMemberCount' => $intMemberCount,
									'intFlightRoute' => $strFlightRoute,
									'interNationalSearch' => $interNationalSearch,
									'AddMarkup' => $AddMarkup,
								);
								//echo '<pre>';print_r(($markUpArr));echo '</pre>';
								$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr);
								if ($kp == 0) {
									$PublishedFareReverse += ($arrMarkUps['PublishFare']);
								}
								//echo '<pre>';print_r(($arrMarkUps));echo '</pre>';
								$markUpArrBR = array(
									'getMarkup' => $getMarkup,
									'PublishedFare' => ($ADULT['TF'] * $adultCount),
									'OfferedFare' => ($ADULT['NF'] * $adultCount),
									'intCommissionEarned' => ($ADULT['NCM'] * $adultCount),
									'TdsOnPLB' => ($ADULTNCMTDS * $adultCount),
									'MUFee' => ($AD_MU * $adultCount),
									'intPLBEarned' => $PLBEarned,
									'intIncentiveEarned' => $IncentiveEarned,
									'intMemberCount' => $adultCount,
									'intFlightRoute' => $strFlightRoute,
									'interNationalSearch' => $interNationalSearch,
									'AddMarkup' => $AddMarkup,
								);
								$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);

								$FareBreakdown[0]['Currency'] = 'INR';
								$FareBreakdown[0]['PassengerType'] = 1;
								$FareBreakdown[0]['PassengerCount'] = $adultCount;
								$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $adultCount);
								$FareBreakdown[0]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
								$FareBreakdown[0]['BaseFare'] = ($ADULT['BF'] * $adultCount);
								$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $adultCount);
								$FareBreakdown[0]['TDS'] = ($ADULTNCMTDS * $adultCount);
								$FareBreakdown[0]['MF'] = ($AD_MF * $adultCount);
								$FareBreakdown[0]['YQ'] = ($AD_YQ * $adultCount);
								$FareBreakdown[0]['AGST'] = ($AD_AGST * $adultCount);
								$FareBreakdown[0]['MFT'] = ($AD_MFT * $adultCount);
								$FareBreakdown[0]['OT'] = ($AD_OT * $adultCount);
								$FareBreakdown[0]['MU'] = ($AD_MU * $adultCount);
								$FareBreakdown[0]['YR'] = ($AD_YR * $adultCount);
								$FareBreakdown[0]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
								$FareBreakdown[0]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
								$FareBreakdown[0]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
								$FareBreakdown[0]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
								$FareBreakdown[0]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
								$FareBreakdown[0]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
								$FareBreakdown[0]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
								$FareBreakdown[0]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
								$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
								$FareBreakdown[0]['GSTonComm'] = 0;
								$FareBreakdown[0]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
								$FareBreakdown[0]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
								$FareBreakdown[0]['AdditionalTxnFeeOfrd'] = 0;
								$FareBreakdown[0]['AdditionalTxnFeePub'] = 0;
								$FareBreakdown[0]['PGCharge'] = 0;
								$FareBreakdown[0]['Baggage'] = isset($fareDetail['ADULT']['bI']['iB']) ? $fareDetail['ADULT']['bI']['iB'] : []; //Check In Baggage;
								$FareBreakdown[0]['CabinBaggage'] = isset($fareDetail['ADULT']['bI']['cB']) ? $fareDetail['ADULT']['bI']['cB'] : []; //Cabin Baggage ;
								if (isset($fareDetail['CHILD'])) {
									$markUpArrBR = array(
										'getMarkup' => $getMarkup,
										'PublishedFare' => ($CHILD['TF'] * $childCount),
										'OfferedFare' => ($CHILD['NF'] * $childCount),
										'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
										'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
										'MUFee' => ($CH_MU * $childCount),
										'intPLBEarned' => $PLBEarned,
										'intIncentiveEarned' => $IncentiveEarned,
										'intMemberCount' => $childCount,
										'intFlightRoute' => $strFlightRoute,
										'interNationalSearch' => $interNationalSearch,
										'AddMarkup' => $AddMarkup,
									);
									$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
									$FareBreakdown[1]['Currency'] = 'INR';
									$FareBreakdown[1]['PassengerType'] = 2;
									$FareBreakdown[1]['PassengerCount'] = $childCount;
									$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
									$FareBreakdown[1]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
									$FareBreakdown[1]['BaseFare'] = ($CHILD['BF'] * $childCount);
									$FareBreakdown[1]['CommissionEarned'] = ($CHILD['NCM'] * $childCount);
									$FareBreakdown[1]['TDS'] = ($CHILDNCMTDS * $childCount);
									$FareBreakdown[1]['MF'] = ($CH_MF * $childCount);
									$FareBreakdown[1]['YQ'] = ($CH_YQ * $childCount);
									$FareBreakdown[1]['AGST'] = ($CH_AGST * $childCount);
									$FareBreakdown[1]['MFT'] = ($CH_MFT * $childCount);
									$FareBreakdown[1]['OT'] = ($CH_OT * $childCount);
									$FareBreakdown[1]['MU'] = ($CH_MU * $childCount);
									$FareBreakdown[1]['YR'] = ($CH_YR * $childCount);
									$FareBreakdown[1]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
									$FareBreakdown[1]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
									$FareBreakdown[1]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
									$FareBreakdown[1]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
									$FareBreakdown[1]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
									$FareBreakdown[1]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
									$FareBreakdown[1]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
									$FareBreakdown[1]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
									$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
									$FareBreakdown[1]['GSTonComm'] = 0;
									$FareBreakdown[1]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
									$FareBreakdown[1]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
									$FareBreakdown[1]['AdditionalTxnFeeOfrd'] = 0;
									$FareBreakdown[1]['AdditionalTxnFeePub'] = 0;
									$FareBreakdown[1]['PGCharge'] = 0;
									$FareBreakdown[1]['Baggage'] = isset($fareDetail['CHILD']['bI']['iB']) ? $fareDetail['CHILD']['bI']['iB'] : []; //Check In Baggage;
									$FareBreakdown[1]['CabinBaggage'] = isset($fareDetail['CHILD']['bI']['cB']) ? $fareDetail['CHILD']['bI']['cB'] : []; //Cabin Baggage ;
								}
								if (isset($fareDetail['INFANT'])) {
									$markUpArrBR = array(
										'getMarkup' => $getMarkup,
										'PublishedFare' => ($INFANT['TF'] * $infantCount),
										'OfferedFare' => ($INFANT['NF'] * $infantCount),
										'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
										'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
										'MUFee' => ($IN_MU * $infantCount),
										'intPLBEarned' => $PLBEarned,
										'intIncentiveEarned' => $IncentiveEarned,
										'intMemberCount' => $infantCount,
										'intFlightRoute' => $strFlightRoute,
										'interNationalSearch' => $interNationalSearch,
										'AddMarkup' => $AddMarkup,
									);
									$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
									$FareBreakdown[2]['Currency'] = 'INR';
									$FareBreakdown[2]['PassengerType'] = 3;
									$FareBreakdown[2]['PassengerCount'] = $infantCount;
									$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
									$FareBreakdown[2]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
									$FareBreakdown[2]['BaseFare'] = ($INFANT['BF'] * $infantCount);
									$FareBreakdown[2]['CommissionEarned'] = ($INFANT['NCM'] * $infantCount);
									$FareBreakdown[2]['TDS'] = ($INFANTNCMTDS * $infantCount);
									$FareBreakdown[2]['MF'] = ($IN_MF * $infantCount);
									$FareBreakdown[2]['YQ'] = ($IN_YQ * $infantCount);
									$FareBreakdown[2]['AGST'] = ($IN_AGST * $infantCount);
									$FareBreakdown[2]['OT'] = ($IN_OT * $infantCount);
									$FareBreakdown[2]['MFT'] = ($IN_MFT * $infantCount);
									$FareBreakdown[2]['MU'] = ($IN_MU * $infantCount);
									$FareBreakdown[2]['YR'] = ($IN_YR * $infantCount);
									$FareBreakdown[2]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
									$FareBreakdown[2]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
									$FareBreakdown[2]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
									$FareBreakdown[2]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
									$FareBreakdown[2]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
									$FareBreakdown[2]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
									$FareBreakdown[2]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
									$FareBreakdown[2]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
									$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
									$FareBreakdown[2]['GSTonComm'] = 0;
									$FareBreakdown[2]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
									$FareBreakdown[2]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
									$FareBreakdown[2]['AdditionalTxnFeeOfrd'] = 0;
									$FareBreakdown[2]['AdditionalTxnFeePub'] = 0;
									$FareBreakdown[2]['PGCharge'] = 0;
									$FareBreakdown[2]['Baggage'] = isset($fareDetail['INFANT']['bI']['iB']) ? $fareDetail['INFANT']['bI']['iB'] : []; //Check In Baggage;
									$FareBreakdown[2]['CabinBaggage'] = isset($fareDetail['INFANT']['bI']['cB']) ? $fareDetail['INFANT']['bI']['cB'] : []; //Cabin Baggage ;
								}
								//echo '<pre>';print_r($price);
								$FairRulesArr[$kp] = array(
									"Currency" => $this->CurrencyTitle, //$Currency,
									"CurrencyRate" => $this->CurrencyRate, //$Currency,
									"currencySysId" => $this->CurrencyId,
									"BaseFare" => $BaseFareIN,
									"Tax" => $TaxIN,
									"YQTax" => $YQTax,
									"OtherCharges" => $OtherCharges,
									"Discount" => 0, //$Discount,
									"ServiceFee" => $ServiceFee,
									"ManagementFeeTax" => $ManagementFeeTax,
									"AirlineGSTComponent" => $AirlineGSTComponent,
									"CarrierMiscFee" => $CarrierMiscFee,
									"MUFee" => $MUFee,
									"intPublishedFare" => $PublishedFareIN,
									"PublishedFare" => ceil($arrMarkUps['PublishFare'] * $this->CurrencyRate),
									"OfferedFare" => $arrMarkUps['intOfferedFare'],
									"CommissionEarned" => $CommissionEarned,
									"PLBEarned" => $PLBEarned,
									"IncentiveEarned" => $IncentiveEarned,
									"TdsOnPLB" => $TdsOnPLB,
									"TdsOnIncentive" => 0,
									"AdditionalTxnFeeOfrd" => 0,
									"AdditionalTxnFeePub" => 0,
									"Refundable" => $Refundable,
									"IsRefundableTxt" => $IsRefundableTxt,
									"PriceID" => $PriceID,
									"IsGSTRequired" => $IsGSTRequired,
									"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
									"FareClass" => ucfirst(strtolower($fareDetail['ADULT']['cc'])),
									"intTotalGST" => $arrMarkUps['intTotalGST'],
									"apiMarkup" => $arrMarkUps['apiMarkup'],
									"IntCommission" => $arrMarkUps['IntCommission'],
									"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
									"NoOfSeatAvailable" => $fareDetail['ADULT']['sR'],
									"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
									"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
									"CommEarned" => $arrMarkUps['intCommisionEarnedForAgency'],
									"GSTonComm" => 0,
									"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
									"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
									"AddiMarkup" => $arrMarkUps['AddiMarkup'],
									"AddiTaxOnMarkup" => $arrMarkUps['AddiTaxOnMarkup'],
									"IsBaggage" => $IsBaggage,
									"IsCabinBaggage" => $IsCabinBaggage,
									"Baggage" => $strBaggage,
									"CabinBaggage" => $strCabinBaggage,
									"IsMealIncludes" => $IsMealIncludes,
									"FareBreakdown" => $FareBreakdown,
									"arrMarkUps" => $arrMarkUps,
									"tripbinfo" => $tripbaggageinfo,
								);
							}
						}

						$LAYOVERTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($TotalLAYOVERMinutes);

						$AirlineCode = $OriginSegments['fD']['aI']['code'];
						$FlightNumber = $OriginSegments['fD']['fN'];
						$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
						$strAirlineName = $OriginSegments['fD']['aI']['name'];
						$IsLCC = $OriginSegments['fD']['aI']['isLcc'];
						$strSourceAirportCode = $OriginSegments['da']['code'];
						$strDestinationAirportCode = $DestinationSegments['aa']['code'];

						$Stops = $DestinationSegments['sN'];
						if ($Stops == 0) {
							$StopCountTxt = "Non-stop";
						} else {
							$StopCountTxt = $Stops . " Stop(s)";
						}
						$filePath = $this->getflightlogo($AirlineCode);
						$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
						$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($DestinationSegments['at']);
						$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($OriginSegments['dt']);
						$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
						if ($FairRulesArr) {
							$arrInsertFlightData[$keys][$key]['FlightNumber'] = $strFlightNumber;
							$arrInsertFlightData[$keys][$key]['SegFlightNumberArr'] = implode(', ', $SegFlightNumberArr);
							$arrInsertFlightData[$keys][$key]['AirlineName'] = $strAirlineName;
							$arrInsertFlightData[$keys][$key]['AirlineCode'] = $AirlineCode;
							$arrInsertFlightData[$keys][$key]['AirInvenSysId'] = 0;
							$arrInsertFlightData[$keys][$key]['IsLCC'] = $IsLCC;
							$arrInsertFlightData[$keys][$key]['IsMealIncludes'] = $IsMealIncludes;
							$arrInsertFlightData[$keys][$key]['IsBagIncludes'] = $IsBagIncludes;
							$arrInsertFlightData[$keys][$key]['IsCabinBagIncludes'] = $IscabinbagIncludes;
							$arrInsertFlightData[$keys][$key]['IsRefundable'] = $IsRefundable;
							$arrInsertFlightData[$keys][$key]['IsRefundableTxt'] = $IsRefundableTxt;
							$arrInsertFlightData[$keys][$key]['apiTraceId'] = $strTraceId;
							$arrInsertFlightData[$keys][$key]['AirlineSysId'] = $airlineSysId;
							$arrInsertFlightData[$keys][$key]['DepartureTime'] = $strDepartureDtTime;
							$arrInsertFlightData[$keys][$key]['ArrivalTime'] = $strArrivalDtTime;
							$arrInsertFlightData[$keys][$key]['TravelDate'] = $OriginSegments['dt'];
							$arrInsertFlightData[$keys][$key]['LocalFromTime'] = str_replace('T', ' ', $OriginSegments['dt']);
							$arrInsertFlightData[$keys][$key]['FromUTCTime'] = $OriginSegments['dt'];
							$arrInsertFlightData[$keys][$key]['LocalToTime'] = str_replace('T', ' ', $DestinationSegments['at']);
							$arrInsertFlightData[$keys][$key]['ToUTCTime'] = $DestinationSegments['at'];
							$arrInsertFlightData[$keys][$key]['IsDirect'] = 0;
							$arrInsertFlightData[$keys][$key]['FareClass'] = $strFareClass;
							$arrInsertFlightData[$keys][$key]['LAYOVERCity'] = isset($LAYOVERCityArr[0]) ? $LAYOVERCityArr[0] : '';
							$arrInsertFlightData[$keys][$key]['GroundTime'] = $TotalLAYOVERMinutes;
							$arrInsertFlightData[$keys][$key]['LAYOVERDuration'] = $LAYOVERTime;
							$arrInsertFlightData[$keys][$key]['FlyingMinutes'] = $FlyingMinutes;
							$arrInsertFlightData[$keys][$key]['DepartureDateTxt'] = date('D, d M', strtotime($OriginSegments['dt']));
							$arrInsertFlightData[$keys][$key]['ArrivalDateTxt'] = date('D, d M', strtotime($DestinationSegments['at']));
							$arrInsertFlightData[$keys][$key]['FlightDuration'] = $FlightDuration;
							$arrInsertFlightData[$keys][$key]['SourcePlaceSysId'] = $intSourceCityId[$keys];
							$arrInsertFlightData[$keys][$key]['DestPlaceSysId'] = $intDestinationCityId[$keys];
							$arrInsertFlightData[$keys][$key]['SourceAirportCode'] = $strSourceAirportCode;
							$arrInsertFlightData[$keys][$key]['DestAirportCode'] = $strDestinationAirportCode;
							$arrInsertFlightData[$keys][$key]['StopCount'] = $StopCountTxt;
							$arrInsertFlightData[$keys][$key]['Stops'] = $Stops;
							$arrInsertFlightData[$keys][$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
							$arrInsertFlightData[$keys][$key]['TotalFlightMembers'] = $intMemberCount;
							$arrInsertFlightData[$keys][$key]['CurrencyType'] = $this->CurrencyId;
							$arrInsertFlightData[$keys][$key]['PublishedFare'] = ($PublishedFareReverse * $this->CurrencyRate); // As Discussed with GG
							$arrInsertFlightData[$keys][$key]['PublishedFareTxt'] = number_format(($PublishedFareReverse * $this->CurrencyRate)); // As Discussed with GG

							$arrInsertFlightData[$keys][$key]['ICSourceSysId'] = 7;
							$arrInsertFlightData[$keys][$key]['ApiResultIndex'] = $ResultIndex;
							$arrInsertFlightData[$keys][$key]['SearchFlightTraceId'] = $SearchFlightTraceId;
							$arrInsertFlightData[$keys][$key]['JourneyType'] = $intJourneyType;
							$arrInsertFlightData[$keys][$key]['TripType'] = $intTripType;
							$arrInsertFlightData[$keys][$key]['IsInternational'] = $interNationalSearch;
							$arrInsertFlightData[$keys][$key]['logo'] = $filePath;
							$arrInsertFlightData[$keys][$key]['FairRules'] = $FairRulesArr;
							$arrInsertFlightData[$keys][$key]['Segments'] = $arrSegments;

							$arrAirlineName[$keys][] = $strAirlineName;
							$AttPriceRange[$keys][] = $PublishedFareReverse;
							$FiltStopCount[$keys][] = $StopCountTxt;

							if ($FairRulesArr) {
								foreach ($FairRulesArr as $Fare) {
									$dddddddd[] = $Fare['PublishedFare'];
								}
							}

							$FiltPriceRange[] = $FilterPrice = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_PRICE_RANGE_5000), ($PublishedFare * $this->CurrencyRate));
							$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
							$FilterArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strArrivalDtTime);
							//$FiltPriceRange[] = $FilterPrice = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_PRICE_RANGE_AED), ($PublishedFare * $this->CurrencyRate));
							//$arrInsertFlightData[$key]['FilterPrice'] = $FilterPrice;

							if ($FilterPrice) {
								$arrInsertFlightData[$keys][$key]['FilterPrice'] = $FilterPrice;
							}
							$arrInsertFlightData[$keys][$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
							$arrInsertFlightData[$keys][$key]['FilterArrivalDtTime'] = $FilterArrivalDtTime;
						}
					}
				}
			}

			$arrAirlineName__ = [];
			if ($arrAirlineName) {
				foreach ($arrAirlineName as $key => $value) {
					$arrAirlineName__[] = array_values(array_unique($value));
				}
			}
			$FiltStopCount__ = [];
			if ($FiltStopCount) {
				foreach ($FiltStopCount as $key => $value) {
					$FiltStopCount__[] = array_values(array_unique($value));
				}
			}
			$AttPriceRange__ = [];
			if ($AttPriceRange) {
				foreach ($AttPriceRange as $key => $value) {
					$MinriceRange = (min(array_values(array_unique($value))));
					$MaxriceRange = (max(array_values(array_unique($value))));
					$AttPriceRange__[] = ['MinriceRange' => floor($MinriceRange), 'MaxriceRange' => floor($MaxriceRange)];
				}
			}
			$MinriceRange = (min($AttPriceRange));
			$MaxriceRange = (max($AttPriceRange));
			$MultiHead = [];
			if ($sessionFlightSearchParams['source']) {
				foreach ($sessionFlightSearchParams['source'] as $sk => $source_) {
					$destination_ = isset($sessionFlightSearchParams['destination'][$sk]) ? explode(',', $sessionFlightSearchParams['destination'][$sk]) : '';
					$source_ = isset($source_) ? explode(',', $source_) : '';
					$departure_date_ = isset($sessionFlightSearchParams['departure_date'][$sk]) ? $sessionFlightSearchParams['departure_date'][$sk] : '';
					$MultiHead[] = array(
						'source' => $source_[0],
						'destination' => $destination_[0],
						'departure_date' => $departure_date_,
						'dep_date' => date('d M Y', strtotime($departure_date_)),
					);
				}
			}
			// echo '<pre>';
			// print_r($MultiHead);die('ddd');
			sort($FiltStopCount__);
			$data = array('outbound' => array_values($arrInsertFlightData), 'MultiHead' => $MultiHead, 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute, 'CurrencyTitle' => $this->CurrencyTitle, 'inbound' => [], 'arrAirlineName' => $arrAirlineName__, 'FiltStopCount' => $FiltStopCount__, 'ArrPriceUnique' => $AttPriceRange__, 'MinriceRange' => round($MinriceRange), 'MaxriceRange' => round($MaxriceRange));
			echo json_encode($data);
			exit;
		} else {
			$data = array('outbound' => [], 'inbound' => [], 'MultiHead' => [], 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute, 'CurrencyTitle' => $this->CurrencyTitle, 'arrAirlineName' => [], 'FiltStopCount' => [], 'ArrPriceUnique' => [], 'MinriceRange' => 0, 'MaxriceRange' => 0);
			echo json_encode($data);
			exit;
		}
	}

	public function FlightDataMultiCityInterNational($apiResponse, $sessionFlightSearchParams, $getMarkup, $AdditionalMarkup)
	{
		$arrAirlineList = $this->getAirlineIdsAndCodeList();
		$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId']);
		$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId']);
		$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
		$strFlightRoute = trim($sessionFlightSearchParams['route']);
		$adultCount = $sessionFlightSearchParams['adults'];
		$childCount = $sessionFlightSearchParams['child'];
		$infantCount = $sessionFlightSearchParams['infant'];
		$intMemberCount = $adultCount + $childCount + $infantCount;
		$strFlightRoute = trim($sessionFlightSearchParams['route']);
		$source_city = isset($sessionFlightSearchParams['source_city']) ? $sessionFlightSearchParams['source_city'][0] : '';
		$destination_city = isset($sessionFlightSearchParams['destination_city']) ? $sessionFlightSearchParams['destination_city'][0] : '';
		$source = isset($sessionFlightSearchParams['source']) ? $sessionFlightSearchParams['source'][0] : '';
		$destination = isset($sessionFlightSearchParams['destination']) ? $sessionFlightSearchParams['destination'][0] : '';
		$sourceCityText = explode(',', $sessionFlightSearchParams['sourceCityText'][0]);
		$destinationCityText = explode(',', $sessionFlightSearchParams['destinationCityText'][0]);
		$SearchFlightTraceId = $sessionFlightSearchParams['SearchFlightTraceId'];
		//echo '<pre>';print_r($sessionFlightSearchParams);die('ddd');
		$MultiHead = [];
		if ($sessionFlightSearchParams['source']) {
			foreach ($sessionFlightSearchParams['source'] as $sk => $source_) {
				$sourceCityAirportCode = isset($sessionFlightSearchParams['sourceCityAirportCode'][$sk]) ? $sessionFlightSearchParams['sourceCityAirportCode'][$sk] : '';
				$destinationCityAirportCode = isset($sessionFlightSearchParams['destinationCityAirportCode'][$sk]) ? $sessionFlightSearchParams['destinationCityAirportCode'][$sk] : '';
				$destination_ = isset($sessionFlightSearchParams['destination'][$sk]) ? explode(',', $sessionFlightSearchParams['destination'][$sk]) : '';
				$source_ = isset($source_) ? explode(',', $source_) : '';
				$departure_date_ = isset($sessionFlightSearchParams['departure_date'][$sk]) ? $sessionFlightSearchParams['departure_date'][$sk] : '';
				$MultiHead[] = array(
					'source' => $source_[0],
					'destination' => $destination_[0],
					'soCode' => $sourceCityAirportCode,
					'deCode' => $destinationCityAirportCode,
					'departure_date' => $departure_date_,
					'dep_date' => date('d M Y', strtotime($departure_date_)),
				);
			}
		}
		$intJourneyType = 1;
		$intTripType = 3;
		$arrInsertFlightData = [];
		$arrAirlineName = [];
		$FiltStopCount = [];
		$FiltPriceRange = [];
		$AttPriceRange = [];
		$dddddddd = [];
		$FilterData = [];
		$arrAirlineName = [];
		$FiltStopCount = [];
		$intResponseStatus = $apiResponse['ResponseStatus'];
		$ONWARD = $apiResponse['OutBoundFlightResults'];
		if ($intResponseStatus == 1) {
			if ($ONWARD) {
				foreach ($ONWARD as $keys => $result) {
					$SegmentInformation = $result['sI'];
					$totalPriceList = current($result['totalPriceList']);
					$IsRefundable = $totalPriceList['fd']['ADULT']['rT'];
					$NoOfSeatAvailable = $totalPriceList['fd']['ADULT']['sR'];
					$strFareClass = $totalPriceList['fd']['ADULT']['cB']; //Cabin Baggage
					$IsMealIncludes = $IsMealIncludesTrue = isset($totalPriceList['fd']['ADULT']['mI']) ? $totalPriceList['fd']['ADULT']['mI'] : false;

					$bagInfo = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Check In Baggage
					$cabinbagInfo = $totalPriceList['fd']['ADULT']['bI']['cB']; ///Cabin Baggage
					$strTraceId = $totalPriceList['id'];
					$ResultIndex = $totalPriceList['id'];
					if (!empty($bagInfo)) {
						$IsBagIncludes = true;
					} else {
						$IsBagIncludes = false;
					}
					if (!empty($cabinbagInfo)) {
						$IscabinbagIncludes = true;
					} else {
						$IscabinbagIncludes = false;
					}


					if ($IsRefundable == 0) {
						$IsRefundableTxt = 'Non Refundable';
					} elseif ($IsRefundable == 1) {
						$IsRefundableTxt = 'Refundable';
					} else {
						$IsRefundableTxt = 'Partial Refundable';
					}

					$PublishedFare = 0;
					$PublishedFareReverse = 0;
					$BaseFare = 0;
					$Tax = 0;
					$YQTax = 0;
					$OtherCharges = 0;
					$ServiceFee = 0;
					$FareBreakdown = [];
					$FairRulesArr = [];
					$intYQTaxToT = 0;
					$intTotalOfferedForAllPax = 0;
					$intBaseFareAllPax = 0;
					$intTaxAllPax = 0;


					$ArrivalArr = [];
					$departureArr = [];
					$arrSegments = [];
					if ($SegmentInformation) {
						foreach ($SegmentInformation as $k => $segments) {
							$segmentid = $segments['id'];
							$duration = $segments['duration'];
							$LAYOVERMinutes = $GroundTime = isset($segments['cT']) ? $segments['cT'] : 0;
							$LAYOVERCity = $LAYOVERCityArr[] = isset($segments['cT']) ? $segments['aa']['city'] : '';
							//$FlyingMinutes += ($duration + $LAYOVERMinutes);
							//$TotalLAYOVERMinutes += $LAYOVERMinutes;

							$FareClass = $totalPriceList['fd']['ADULT']['cB'];
							$strBaggage = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Checking Baggage
							$strCabinBaggage = $totalPriceList['fd']['ADULT']['bI']['cB']; ////Cabin Baggage

							if (!empty($strCabinBaggage)) {
								$IsCabinBaggage = true;
							} else {
								$IsCabinBaggage = false;
							}
							if (!empty($strCabinBaggage)) {
								$IsBaggage = true;
							} else {
								$IsBaggage = false;
							}
							$Stops = $segments['sN'];
							if ($Stops == 0) {
								$StopCountTxt = "Non-stop";
							} else {
								$StopCountTxt = $Stops . " Stop(s)";
							}
							$AirlineCode = $segments['fD']['aI']['code'];
							$AirlineName = $segments['fD']['aI']['name'];
							$FlightNumber = $segments['fD']['fN'];
							$SegFlightNumber = $AirlineCode . "-" . $FlightNumber;

							$originAirportName = $segments['da']['name'];
							$originAirportCode = $segments['da']['code'];
							$originCityName = $segments['da']['city'];
							$originCountryName = $segments['da']['country'];
							$originDepTime = $segments['dt'];

							$destinationAirportName = $segments['aa']['name'];
							$destinationAirportCode = $segments['aa']['code'];
							$destinationCityName = $segments['aa']['city'];
							$destinationCountryName = $segments['aa']['country'];
							$destinationArrTime = $segments['at'];

							$DepTerminal = isset($segments['da']['terminal']) ? $segments['da']['terminal'] : '';
							$ArrTerminal = isset($segments['aa']['terminal']) ? $segments['aa']['terminal'] : '';

							$filePath = $this->getflightlogo($AirlineCode);

							$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->MinutesToHours($LAYOVERMinutes);

							$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($destinationArrTime);
							$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($originDepTime);
							$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($duration);
							$arrSegments[] = array(
								"originAirportName" => $originAirportName,
								"destinationAirportName" => $destinationAirportName,
								"originCityName" => $originCityName,
								"originCountryName" => $originCountryName,
								"destinationCityName" => $destinationCityName,
								"destinationCountryName" => $destinationCountryName,
								"destinationAirportCode" => $destinationAirportCode,
								"destinationAirportCode" => $destinationAirportCode,
								"destinationArrTime" => $destinationArrTime,
								"SegFlightNumber" => $SegFlightNumber,
								"AirlineCode" => $AirlineCode,
								"AirlineName" => $AirlineName,
								"FareClass" => $FareClass,
								"originAirportCode" => $originAirportCode,
								"originDepTime" => $originDepTime,
								"TripIndicator" => '', //$TripIndicator,
								"Baggage" => $strBaggage,
								"IsBaggage" => $IsBaggage,
								"IsCabinBaggage" => $IsCabinBaggage,
								"CabinBaggage" => $strCabinBaggage,
								"IsMealIncludes" => $IsMealIncludes,
								"Duration" => $duration,
								"GroundTime" => $GroundTime,
								"NoOfSeatAvailable" => $NoOfSeatAvailable,
								"strDepartureDtTime" => $strDepartureDtTime,
								"strArrivalDtTime" => $strArrivalDtTime,
								"FlightDuration" => $strDuration,
								"LAYOVERDuration" => $LAYOVERDuration,
								"LAYOVERCity" => $LAYOVERCity,
								"DepTerminal" => $DepTerminal,
								"ArrTerminal" => $ArrTerminal,
								"ConectingTime" => isset($segments['cT']) ? $segments['cT'] : 0,
								"SegmentNumber" => isset($segments['sN']) ? $segments['sN'] : false,
								"filePath" => $filePath,
								'StopCountTxt' => $StopCountTxt,
							);
							$segmentSector[$segmentid] = ['origin' => $originAirportCode, 'destination' => $destinationAirportCode];

							$Segmentsss = $segments;
							$ConectingTime = isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0;
							$SegmentNumber = isset($Segmentsss['sN']) ? $Segmentsss['sN'] : false;
							if ($ConectingTime == 0 && $SegmentNumber == 1) {
								$ArrivalArr[$k] = array(
									'fD' => $Segmentsss['fD'],
									'oB' => $Segmentsss['oB'],
									'stops' => $Segmentsss['stops'],
									'so' => $Segmentsss['so'],
									'duration' => $Segmentsss['duration'],
									//'da' => $Segmentsss['da'],
									'aa' => $Segmentsss['aa'],
									//'dt' => $Segmentsss['dt'],
									'at' => $Segmentsss['at'],
									'iand' => $Segmentsss['iand'],
									'cT' => isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0,
									'sN' => $Segmentsss['sN'],
								);
							} elseif ($ConectingTime == 0 && $SegmentNumber == 2) {
								$ArrivalArr[$k] = array(
									'fD' => $Segmentsss['fD'],
									'oB' => $Segmentsss['oB'],
									'stops' => $Segmentsss['stops'],
									'so' => $Segmentsss['so'],
									'duration' => $Segmentsss['duration'],
									//'da' => $Segmentsss['da'],
									'aa' => $Segmentsss['aa'],
									//'dt' => $Segmentsss['dt'],
									'at' => $Segmentsss['at'],
									'iand' => $Segmentsss['iand'],
									'cT' => isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0,
									'sN' => $Segmentsss['sN'],
								);
							} elseif ($ConectingTime == 0 && $SegmentNumber == 3) {
								$ArrivalArr[$k] = array(
									'fD' => $Segmentsss['fD'],
									'oB' => $Segmentsss['oB'],
									'stops' => $Segmentsss['stops'],
									'so' => $Segmentsss['so'],
									'duration' => $Segmentsss['duration'],
									//'da' => $Segmentsss['da'],
									'aa' => $Segmentsss['aa'],
									//'dt' => $Segmentsss['dt'],
									'at' => $Segmentsss['at'],
									'iand' => $Segmentsss['iand'],
									'cT' => isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0,
									'sN' => $Segmentsss['sN'],
								);
							} elseif ($ConectingTime == 0 && $SegmentNumber == 4) {
								$ArrivalArr[$k] = array(
									'fD' => $Segmentsss['fD'],
									'oB' => $Segmentsss['oB'],
									'stops' => $Segmentsss['stops'],
									'so' => $Segmentsss['so'],
									'duration' => $Segmentsss['duration'],
									//'da' => $Segmentsss['da'],
									'aa' => $Segmentsss['aa'],
									//'dt' => $Segmentsss['dt'],
									'at' => $Segmentsss['at'],
									'iand' => $Segmentsss['iand'],
									'cT' => isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0,
									'sN' => $Segmentsss['sN'],
								);
							} elseif ($ConectingTime == 0 && $SegmentNumber == 0) {
								$ArrivalArr[$k] = array(
									'fD' => $Segmentsss['fD'],
									'oB' => $Segmentsss['oB'],
									'stops' => $Segmentsss['stops'],
									'so' => $Segmentsss['so'],
									'duration' => $Segmentsss['duration'],
									//'da' => $Segmentsss['da'],
									'aa' => $Segmentsss['aa'],
									//'dt' => $Segmentsss['dt'],
									'at' => $Segmentsss['at'],
									'iand' => $Segmentsss['iand'],
									'cT' => isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0,
									'sN' => $Segmentsss['sN'],
								);
							}
							if ($SegmentNumber == 0) { // departure
								$departureArr[$k] = array(
									'fD' => $Segmentsss['fD'],
									'oB' => $Segmentsss['oB'],
									'stops' => $Segmentsss['stops'],
									'so' => $Segmentsss['so'],
									'duration' => $Segmentsss['duration'],
									'da' => $Segmentsss['da'],
									//'aa' => $Segmentsss['aa'],
									'dt' => $Segmentsss['dt'],
									//'at' => $Segmentsss['at'],
									'iand' => $Segmentsss['iand'],
									'cT' => isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0,
									'sN' => $Segmentsss['sN'],
								);
							}
						}
					}
					$array_searcher = $this->array_searcher($AdditionalMarkup, $result['totalPriceList']);
					array_multisort($array_searcher);
					if ($array_searcher) {
						foreach ($array_searcher as $kp => $price) {
							$fareDetail = $price['fd'];
							$tripbaggageinfo = [];
							if ($price['tai']['tbi']) {
								foreach ($price['tai']['tbi'] as $keyss => $tbi) {
									$segc = isset($segmentSector[$keyss]) ? $segmentSector[$keyss] : '';
									$sectorKey = $segc['origin'] . '-' . $segc['destination'];
									if ($tbi) {
										foreach ($tbi as $kgk => $pbi) {
											if ($pbi) {
												foreach ($pbi as $gk => $vll) {
													$tripbaggageinfo[$sectorKey][$gk] = ['cabin' => isset($vll['cB']) ? $vll['cB'] : 'NA', 'checkin' => isset($vll['iB']) ? $vll['iB'] : 'NA'];
												}
											}
										}
									}
								}
							}
							//echo '<pre>';print_r(($fareDetail));echo '</pre>';
							$Refundable = $fareDetail['ADULT']['rT'];
							$PriceID = $price['id'];
							$fareIdentifier = $price['fareIdentifier'];
							$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
							$IsMealIncludes = $fareDetail['ADULT']['mI'];
							$strBaggage = $price['fd']['ADULT']['bI']['iB']; ///Checking Baggage
							$strCabinBaggage = $price['fd']['ADULT']['bI']['cB']; ////Cabin Baggage

							if (!empty($strCabinBaggage)) {
								$IsCabinBaggage = true;
							} else {
								$IsCabinBaggage = false;
							}

							if (!empty($strCabinBaggage)) {
								$IsBaggage = true;
							} else {
								$IsBaggage = false;
							}

							if ($fareIdentifier == 'SME') {
								$IsGSTRequired = true;
							} else {
								$IsGSTRequired = false;
							}
							if ($fareIdentifier == 'TACTICAL' || $fareIdentifier == 'COUPON') {
								$fareIdentifier = 'PROMO';
							}
							if ($Refundable == 0) {
								$IsRefundableTxt = 'Non Refundable';
							} elseif ($Refundable == 1) {
								$IsRefundableTxt = 'Refundable';
							} else {
								$IsRefundableTxt = 'Partial Refundable';
							}
							$ADULT = $fareDetail['ADULT']['fC']; //fare Components
							$CHILD = isset($fareDetail['CHILD']['fC']) ? $fareDetail['CHILD']['fC'] : []; //fare Components
							$INFANT = isset($fareDetail['INFANT']['fC']) ? $fareDetail['INFANT']['fC'] : []; //fare Components
							if (!empty($ADULT)) {
								$PaxTypeCount = 1;
							}
							if (!empty($CHILD)) {
								$PaxTypeCount = 2;
							}
							if (!empty($INFANT)) {
								$PaxTypeCount = 3;
							}
							$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
							$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
							$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents

							$ADULTNCMTDS = isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
							$CHILDNCMTDS = isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
							$INFANTNCMTDS = isset($fareDetail['INFANT']['afC']['NCM']['TDS']) ? $fareDetail['INFANT']['afC']['NCM']['TDS'] : 0; //TDS

							$ADULTNCMTOT = isset($fareDetail['ADULT']['afC']['NCM']['OT']) ? $fareDetail['ADULT']['afC']['NCM']['OT'] : 0; //- Gross Commission
							$CHILDNCMTOT = isset($fareDetail['CHILD']['afC']['NCM']['OT']) ? $fareDetail['CHILD']['afC']['NCM']['OT'] : 0; //- Gross Commission
							$INFANTNCMTOT = isset($fareDetail['INFANT']['afC']['NCM']['OT']) ? $fareDetail['INFANT']['afC']['NCM']['OT'] : 0; //- Gross Commission

							$AD_MF = isset($ADULTafC['MF']) ? $ADULTafC['MF'] : 0; //Management Fee
							$AD_YQ = isset($ADULTafC['YQ']) ? $ADULTafC['YQ'] : 0; //Fuel Surcharge
							$AD_AGST = isset($ADULTafC['AGST']) ? $ADULTafC['AGST'] : 0; //Airline GST Component
							$AD_MFT = isset($ADULTafC['MFT']) ? $ADULTafC['MFT'] : 0; //Management Fee Tax
							$AD_OT = isset($ADULTafC['OT']) ? $ADULTafC['OT'] : 0; //Other Charges
							$AD_MU = isset($ADULTafC['MU']) ? $ADULTafC['MU'] : 0; //markup
							$AD_YR = isset($ADULTafC['YR']) ? $ADULTafC['YR'] : 0; //Carrier Misc Fee

							$CH_MF = isset($CHILDafC['MF']) ? $CHILDafC['MF'] : 0; //Management Fee
							$CH_YQ = isset($CHILDafC['YQ']) ? $CHILDafC['YQ'] : 0; //Fuel Surcharge
							$CH_AGST = isset($CHILDafC['AGST']) ? $CHILDafC['AGST'] : 0; //Airline GST Component
							$CH_MFT = isset($CHILDafC['MFT']) ? $CHILDafC['MFT'] : 0; //Management Fee Tax
							$CH_OT = isset($CHILDafC['OT']) ? $CHILDafC['OT'] : 0; //Other Charges
							$CH_MU = isset($CHILDafC['MU']) ? $CHILDafC['MU'] : 0; //markup
							$CH_YR = isset($CHILDafC['YR']) ? $CHILDafC['YR'] : 0; //Carrier Misc Fee

							$IN_MF = isset($INFANTafC['MF']) ? $INFANTafC['MF'] : 0; //Management Fee
							$IN_YQ = isset($INFANTafC['YQ']) ? $INFANTafC['YQ'] : 0; //Fuel Surcharge
							$IN_AGST = isset($INFANTafC['AGST']) ? $INFANTafC['AGST'] : 0; //Airline GST Component
							$IN_MFT = isset($INFANTafC['MFT']) ? $INFANTafC['MFT'] : 0; //Management Fee Tax
							$IN_OT = isset($INFANTafC['OT']) ? $INFANTafC['OT'] : 0; //Other Charges
							$IN_MU = isset($INFANTafC['MU']) ? $INFANTafC['MU'] : 0; //markup
							$IN_YR = isset($INFANTafC['YR']) ? $INFANTafC['YR'] : 0; //Carrier Misc Fee

							if ($kp == 0) {
								$PublishedFare += (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
								$BaseFare += (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
								$Tax += (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
							}

							$PublishedFareIN = (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
							$BaseFareIN = (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
							$TaxIN = (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
							$NetFare = (($ADULT['NF'] * $adultCount) + ($CHILD['NF'] * $childCount) + ($INFANT['NF'] * $infantCount)); //Taxes and Fees
							$NetCommission = (($ADULT['NCM'] * $adultCount) + ($CHILD['NCM'] * $childCount) + ($INFANT['NCM'] * $infantCount)); //Taxes and Fees
							//echo '<pre>';print_r(($ADULTafC));echo '</pre>';
							$YQTax = (($AD_YQ * $adultCount) + ($CH_YQ * $childCount) + ($IN_YQ * $infantCount));
							$OtherCharges = (($AD_OT * $adultCount) + ($CH_OT * $childCount) + ($IN_OT * $infantCount));
							$ServiceFee = (($AD_MF * $adultCount) + ($CH_MF * $childCount) + ($IN_MF * $infantCount));
							$ManagementFeeTax = (($AD_MFT * $adultCount) + ($CH_MFT * $childCount) + ($IN_MFT * $infantCount));
							$AirlineGSTComponent = (($AD_AGST * $adultCount) + ($CH_AGST * $childCount) + ($IN_AGST * $infantCount));
							$CarrierMiscFee = (($AD_YR * $adultCount) + ($CH_YR * $childCount) + ($IN_YR * $infantCount));
							$MUFee = (($AD_MU * $adultCount) + ($CH_MU * $childCount) + ($IN_MU * $infantCount));
							$TdsOnPLB = (($ADULTNCMTDS * $adultCount) + ($CHILDNCMTDS * $childCount) + ($INFANTNCMTDS * $infantCount));
							//$NetCommission = (($ADULTNCMTOT * $adultCount) + ($CHILDNCMTOT * $childCount) + ($INFANTNCMTOT * $infantCount));

							//$PublishedFareIN = $NetFare;
							$PublishedFare = $PublishedFareIN;
							$CommissionEarned = $NetCommission;
							$PLBEarned = 0; //$result['Fare']['PLBEarned'];
							$IncentiveEarned = 0; //$result['Fare']['IncentiveEarned'];
							$OfferedFare = $PublishedFareIN;
							$markUpArr = array(
								'getMarkup' => $getMarkup,
								'PublishedFare' => $PublishedFare,
								'OfferedFare' => $NetFare,
								'intCommissionEarned' => $CommissionEarned,
								'TdsOnPLB' => $TdsOnPLB,
								'MUFee' => $MUFee,
								'intPLBEarned' => $PLBEarned,
								'intIncentiveEarned' => $IncentiveEarned,
								'intMemberCount' => $intMemberCount,
								'intFlightRoute' => $strFlightRoute,
								'interNationalSearch' => $interNationalSearch,
								'AddMarkup' => $AddMarkup,
							);
							//echo '<pre>';print_r(($markUpArr));echo '</pre>';
							$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr);
							if ($kp == 0) {
								$PublishedFareReverse += ($arrMarkUps['PublishFare']);
							}
							//echo '<pre>';print_r(($arrMarkUps));echo '</pre>';
							$markUpArrBR = array(
								'getMarkup' => $getMarkup,
								'PublishedFare' => ($ADULT['TF'] * $adultCount),
								'OfferedFare' => ($ADULT['NF'] * $adultCount),
								'intCommissionEarned' => ($ADULT['NCM'] * $adultCount),
								'TdsOnPLB' => ($ADULTNCMTDS * $adultCount),
								'MUFee' => ($AD_MU * $adultCount),
								'intPLBEarned' => $PLBEarned,
								'intIncentiveEarned' => $IncentiveEarned,
								'intMemberCount' => $adultCount,
								'intFlightRoute' => $strFlightRoute,
								'interNationalSearch' => $interNationalSearch,
								'AddMarkup' => $AddMarkup,
							);
							$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);

							$FareBreakdown[0]['Currency'] = 'INR';
							$FareBreakdown[0]['PassengerType'] = 1;
							$FareBreakdown[0]['PassengerCount'] = $adultCount;
							$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $adultCount);
							$FareBreakdown[0]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
							$FareBreakdown[0]['BaseFare'] = ($ADULT['BF'] * $adultCount);
							$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $adultCount);
							$FareBreakdown[0]['TDS'] = ($ADULTNCMTDS * $adultCount);
							$FareBreakdown[0]['MF'] = ($AD_MF * $adultCount);
							$FareBreakdown[0]['YQ'] = ($AD_YQ * $adultCount);
							$FareBreakdown[0]['AGST'] = ($AD_AGST * $adultCount);
							$FareBreakdown[0]['MFT'] = ($AD_MFT * $adultCount);
							$FareBreakdown[0]['OT'] = ($AD_OT * $adultCount);
							$FareBreakdown[0]['MU'] = ($AD_MU * $adultCount);
							$FareBreakdown[0]['YR'] = ($AD_YR * $adultCount);
							$FareBreakdown[0]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
							$FareBreakdown[0]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
							$FareBreakdown[0]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
							$FareBreakdown[0]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
							$FareBreakdown[0]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
							$FareBreakdown[0]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
							$FareBreakdown[0]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
							$FareBreakdown[0]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
							$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
							$FareBreakdown[0]['GSTonComm'] = 0;
							$FareBreakdown[0]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
							$FareBreakdown[0]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
							$FareBreakdown[0]['AdditionalTxnFeeOfrd'] = 0;
							$FareBreakdown[0]['AdditionalTxnFeePub'] = 0;
							$FareBreakdown[0]['PGCharge'] = 0;
							$FareBreakdown[0]['Baggage'] = isset($fareDetail['ADULT']['bI']['iB']) ? $fareDetail['ADULT']['bI']['iB'] : []; //Check In Baggage;
							$FareBreakdown[0]['CabinBaggage'] = isset($fareDetail['ADULT']['bI']['cB']) ? $fareDetail['ADULT']['bI']['cB'] : []; //Cabin Baggage ;
							if (isset($fareDetail['CHILD'])) {
								$markUpArrBR = array(
									'getMarkup' => $getMarkup,
									'PublishedFare' => ($CHILD['TF'] * $childCount),
									'OfferedFare' => ($CHILD['NF'] * $childCount),
									'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
									'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
									'MUFee' => ($CH_MU * $childCount),
									'intPLBEarned' => $PLBEarned,
									'intIncentiveEarned' => $IncentiveEarned,
									'intMemberCount' => $childCount,
									'intFlightRoute' => $strFlightRoute,
									'interNationalSearch' => $interNationalSearch,
									'AddMarkup' => $AddMarkup,
								);
								$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
								$FareBreakdown[1]['Currency'] = 'INR';
								$FareBreakdown[1]['PassengerType'] = 2;
								$FareBreakdown[1]['PassengerCount'] = $childCount;
								$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
								$FareBreakdown[1]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
								$FareBreakdown[1]['BaseFare'] = ($CHILD['BF'] * $childCount);
								$FareBreakdown[1]['CommissionEarned'] = ($CHILD['NCM'] * $childCount);
								$FareBreakdown[1]['TDS'] = ($CHILDNCMTDS * $childCount);
								$FareBreakdown[1]['MF'] = ($CH_MF * $childCount);
								$FareBreakdown[1]['YQ'] = ($CH_YQ * $childCount);
								$FareBreakdown[1]['AGST'] = ($CH_AGST * $childCount);
								$FareBreakdown[1]['MFT'] = ($CH_MFT * $childCount);
								$FareBreakdown[1]['OT'] = ($CH_OT * $childCount);
								$FareBreakdown[1]['MU'] = ($CH_MU * $childCount);
								$FareBreakdown[1]['YR'] = ($CH_YR * $childCount);
								$FareBreakdown[1]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
								$FareBreakdown[1]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
								$FareBreakdown[1]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
								$FareBreakdown[1]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
								$FareBreakdown[1]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
								$FareBreakdown[1]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
								$FareBreakdown[1]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
								$FareBreakdown[1]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
								$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
								$FareBreakdown[1]['GSTonComm'] = 0;
								$FareBreakdown[1]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
								$FareBreakdown[1]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
								$FareBreakdown[1]['AdditionalTxnFeeOfrd'] = 0;
								$FareBreakdown[1]['AdditionalTxnFeePub'] = 0;
								$FareBreakdown[1]['PGCharge'] = 0;
								$FareBreakdown[1]['Baggage'] = isset($fareDetail['CHILD']['bI']['iB']) ? $fareDetail['CHILD']['bI']['iB'] : []; //Check In Baggage;
								$FareBreakdown[1]['CabinBaggage'] = isset($fareDetail['CHILD']['bI']['cB']) ? $fareDetail['CHILD']['bI']['cB'] : []; //Cabin Baggage ;
							}
							if (isset($fareDetail['INFANT'])) {
								$markUpArrBR = array(
									'getMarkup' => $getMarkup,
									'PublishedFare' => ($INFANT['TF'] * $infantCount),
									'OfferedFare' => ($INFANT['NF'] * $infantCount),
									'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
									'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
									'MUFee' => ($IN_MU * $infantCount),
									'intPLBEarned' => $PLBEarned,
									'intIncentiveEarned' => $IncentiveEarned,
									'intMemberCount' => $infantCount,
									'intFlightRoute' => $strFlightRoute,
									'interNationalSearch' => $interNationalSearch,
									'AddMarkup' => $AddMarkup,
								);
								$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
								$FareBreakdown[2]['Currency'] = 'INR';
								$FareBreakdown[2]['PassengerType'] = 3;
								$FareBreakdown[2]['PassengerCount'] = $infantCount;
								$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
								$FareBreakdown[2]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
								$FareBreakdown[2]['BaseFare'] = ($INFANT['BF'] * $infantCount);
								$FareBreakdown[2]['CommissionEarned'] = ($INFANT['NCM'] * $infantCount);
								$FareBreakdown[2]['TDS'] = ($INFANTNCMTDS * $infantCount);
								$FareBreakdown[2]['MF'] = ($IN_MF * $infantCount);
								$FareBreakdown[2]['YQ'] = ($IN_YQ * $infantCount);
								$FareBreakdown[2]['AGST'] = ($IN_AGST * $infantCount);
								$FareBreakdown[2]['OT'] = ($IN_OT * $infantCount);
								$FareBreakdown[2]['MFT'] = ($IN_MFT * $infantCount);
								$FareBreakdown[2]['MU'] = ($IN_MU * $infantCount);
								$FareBreakdown[2]['YR'] = ($IN_YR * $infantCount);
								$FareBreakdown[2]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
								$FareBreakdown[2]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
								$FareBreakdown[2]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
								$FareBreakdown[2]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
								$FareBreakdown[2]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
								$FareBreakdown[2]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
								$FareBreakdown[2]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
								$FareBreakdown[2]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
								$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
								$FareBreakdown[2]['GSTonComm'] = 0;
								$FareBreakdown[2]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
								$FareBreakdown[2]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
								$FareBreakdown[2]['AdditionalTxnFeeOfrd'] = 0;
								$FareBreakdown[2]['AdditionalTxnFeePub'] = 0;
								$FareBreakdown[2]['PGCharge'] = 0;
								$FareBreakdown[2]['Baggage'] = isset($fareDetail['INFANT']['bI']['iB']) ? $fareDetail['INFANT']['bI']['iB'] : []; //Check In Baggage;
								$FareBreakdown[2]['CabinBaggage'] = isset($fareDetail['INFANT']['bI']['cB']) ? $fareDetail['INFANT']['bI']['cB'] : []; //Cabin Baggage ;
							}
							//echo '<pre>';print_r($price);
							$FairRulesArr[$kp] = array(
								"Currency" => $this->CurrencyTitle, //$Currency,
								"CurrencyRate" => $this->CurrencyRate, //$Currency,
								"currencySysId" => $this->CurrencyId,
								"BaseFare" => $BaseFareIN,
								"Tax" => $TaxIN,
								"YQTax" => $YQTax,
								"OtherCharges" => $OtherCharges,
								"Discount" => 0, //$Discount,
								"ServiceFee" => $ServiceFee,
								"ManagementFeeTax" => $ManagementFeeTax,
								"AirlineGSTComponent" => $AirlineGSTComponent,
								"CarrierMiscFee" => $CarrierMiscFee,
								"MUFee" => $MUFee,
								"intPublishedFare" => $PublishedFareIN,
								"PublishedFare" => ceil($arrMarkUps['PublishFare'] * $this->CurrencyRate),
								"OfferedFare" => $arrMarkUps['intOfferedFare'],
								"CommissionEarned" => $CommissionEarned,
								"PLBEarned" => $PLBEarned,
								"IncentiveEarned" => $IncentiveEarned,
								"TdsOnPLB" => $TdsOnPLB,
								"TdsOnIncentive" => 0,
								"AdditionalTxnFeeOfrd" => 0,
								"AdditionalTxnFeePub" => 0,
								"Refundable" => $Refundable,
								"IsRefundableTxt" => $IsRefundableTxt,
								"PriceID" => $PriceID,
								"IsGSTRequired" => $IsGSTRequired,
								"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
								"FareClass" => ucfirst(strtolower($fareDetail['ADULT']['cc'])),
								"intTotalGST" => $arrMarkUps['intTotalGST'],
								"apiMarkup" => $arrMarkUps['apiMarkup'],
								"IntCommission" => $arrMarkUps['IntCommission'],
								"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
								"NoOfSeatAvailable" => $fareDetail['ADULT']['sR'],
								"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
								"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
								"CommEarned" => $arrMarkUps['intCommisionEarnedForAgency'],
								"GSTonComm" => 0,
								"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
								"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
								"AddiMarkup" => $arrMarkUps['AddiMarkup'],
								"AddiTaxOnMarkup" => $arrMarkUps['AddiTaxOnMarkup'],
								"IsBaggage" => $IsBaggage,
								"IsCabinBaggage" => $IsCabinBaggage,
								"Baggage" => $strBaggage,
								"CabinBaggage" => $strCabinBaggage,
								"IsMealIncludes" => $IsMealIncludes,
								"FareBreakdown" => $FareBreakdown,
								"arrMarkUps" => $arrMarkUps,
								"tripbinfo" => $tripbaggageinfo,
							);
						}
					}
					$arrv = array_values($ArrivalArr);
					$depa = array_values($departureArr);
					$FlightData = [];
					if ($depa) {
						foreach ($depa as $sk => $depval) {
							$arrival = isset($arrv[$sk]) ? $arrv[$sk] : '';
							// echo '<pre>';
							// print_r([$depval,$arrival]);
							// echo '</pre>';
							$LAYOVERMinutes = $GroundTime = isset($arrival['cT']) ? $depval['cT'] : 0;
							$LAYOVERTimeO = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($LAYOVERMinutes);
							if ($depval['cT']) {
								$TotalDurationOnward = $FlyingMinutesO = ($depval['cT'] + $arrival['cT'] + $depval['duration'] + $arrival['duration']);
							} else {
								$TotalDurationOnward = $FlyingMinutesO = ($depval['duration']);
							}
							$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($TotalDurationOnward);
							$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($arrival['at']);
							$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($depval['dt']);
							$Stops = $arrival['sN'];
							if ($Stops == 0) {
								$OrStopCountTxt = "Non-stop";
							} else {
								$OrStopCountTxt = $Stops . " Stop(s)";
							}
							$AirlineCode = $depval['fD']['aI']['code'];
							$FlightNumber = $depval['fD']['fN'];
							$strAirlineName = $depval['fD']['aI']['name'];
							$OrFlightNumber = $AirlineCode . '-' . $FlightNumber;
							$IsLCC = $depval['fD']['aI']['isLcc'];
							$strSourceAirportCode = $depval['da']['code'];
							$strDestinationAirportCode = $arrival['aa']['code'];
							$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
							$filePath = $this->getflightlogo($AirlineCode);
							$deFlightNumber = $arrival['fD']['aI']['code'] . '-' . $arrival['fD']['fN'];
							if ($depval['cT']) {
								$SegFlightNumberArr = [$OrFlightNumber, $deFlightNumber];
							} else {
								$SegFlightNumberArr = [$OrFlightNumber];
							}

							$FlightData[$sk]['FlightNumber'] = $FlightNumber;
							$FlightData[$sk]['SegFlightNumberArr'] = implode(', ', $SegFlightNumberArr);
							$FlightData[$sk]['AirlineName'] = $strAirlineName;
							$FlightData[$sk]['AirlineCode'] = $AirlineCode;
							$FlightData[$sk]['OrFlightNumber'] = $OrFlightNumber;
							$FlightData[$sk]['AirInvenSysId'] = 0;
							$FlightData[$sk]['IsLCC'] = $IsLCC;
							$FlightData[$sk]['IsMealIncludes'] = $IsMealIncludes;
							$FlightData[$sk]['IsBagIncludes'] = $IsBagIncludes;
							$FlightData[$sk]['IsRefundable'] = $IsRefundable;
							$FlightData[$sk]['IsRefundableTxt'] = $IsRefundableTxt;
							//$FlightData[$sk]['SearchTraceId'] = $FlightTraceId;
							$FlightData[$sk]['apiTraceId'] = $strTraceId;
							$FlightData[$sk]['AirlineSysId'] = $airlineSysId;
							$FlightData[$sk]['DepartureTime'] = $strDepartureDtTime;
							$FlightData[$sk]['ArrivalTime'] = $strArrivalDtTime;
							$FlightData[$sk]['TravelDate'] = $depval['dt'];
							$FlightData[$sk]['LocalFromTime'] = str_replace('T', ' ', $depval['dt']);
							$FlightData[$sk]['FromUTCTime'] = $depval['dt'];
							$FlightData[$sk]['LocalToTime'] = str_replace('T', ' ', $arrival['at']);
							$FlightData[$sk]['ToUTCTime'] = $arrival['at'];
							$FlightData[$sk]['IsDirect'] = 0;
							$FlightData[$sk]['FareClass'] = $strFareClass;
							$FlightData[$sk]['LAYOVERCity'] = isset($LAYOVERCityArrO[0]) ? $LAYOVERCityArrO[0] : '';
							$FlightData[$sk]['GroundTime'] = $LAYOVERMinutes;
							$FlightData[$sk]['LAYOVERDuration'] = $LAYOVERTimeO;
							$FlightData[$sk]['FlyingMinutes'] = $FlyingMinutesO;
							$FlightData[$sk]['DepartureDateTxt'] = date('D, d M', strtotime($depval['dt']));
							$FlightData[$sk]['ArrivalDateTxt'] = date('D, d M', strtotime($arrival['at']));
							$FlightData[$sk]['FlightDuration'] = $FlightDuration;
							$FlightData[$sk]['SourcePlaceSysId'] = $intSourceCityId;
							$FlightData[$sk]['DestPlaceSysId'] = $intDestinationCityId;
							$FlightData[$sk]['SourceAirportCode'] = $strSourceAirportCode;
							$FlightData[$sk]['DestAirportCode'] = $strDestinationAirportCode;
							$FlightData[$sk]['SourcePlaceName'] = $sourceCityText[0];
							$FlightData[$sk]['DestPlaceName'] = $destinationCityText[0];
							$FlightData[$sk]['StopCount'] = $OrStopCountTxt;
							$FlightData[$sk]['Stops'] = $Stops;
							$FlightData[$sk]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
							$FlightData[$sk]['TotalFlightMembers'] = $intMemberCount;
							$FlightData[$sk]['CurrencyType'] = $this->CurrencyId;
							$FlightData[$sk]['JourneyType'] = 1;
							$FlightData[$sk]['TripType'] = $intTripType;
							$FlightData[$sk]['IsInternational'] = $interNationalSearch;
							$FlightData[$sk]['strFlightRoute'] = $strFlightRoute;
							$FlightData[$sk]['ICSourceSysId'] = 7;
							$FlightData[$sk]['SearchFlightTraceId'] = $SearchFlightTraceId;
							$FlightData[$sk]['logo'] = $filePath;


							$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
							$FilterArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strArrivalDtTime);
							$FlightData[$sk]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
							$FlightData[$sk]['FilterArrivalDtTime'] = $FilterArrivalDtTime;

							$arrAirlineName[] = $strAirlineName;
							$FiltStopCount[] = $OrStopCountTxt;
						}
					}

					$arrInsertFlightData[$keys]['PublishedFare'] = ($PublishedFareReverse * $this->CurrencyRate);
					$arrInsertFlightData[$keys]['AirlineName'] = $strAirlineName;
					$arrInsertFlightData[$keys]['DepartureTime'] = $strDepartureDtTime;
					$arrInsertFlightData[$keys]['FlyingMinutes'] = $FlightDuration;
					$arrInsertFlightData[$keys]['ArrivalTime'] = $strArrivalDtTime;
					$arrInsertFlightData[$keys]['JourneyType'] = $intJourneyType;
					$arrInsertFlightData[$keys]['TripType'] = $intTripType;
					$arrInsertFlightData[$keys]['IsInternational'] = $interNationalSearch;
					//$arrInsertFlightData[$keys]['ApiResultIndex'] = $ApiResultIndex;
					//$arrInsertFlightData[$keys]['SearchTraceId'] = $FlightTraceId;
					$arrInsertFlightData[$keys]['FairRules'] = $FairRulesArr;
					$arrInsertFlightData[$keys]['Segments'] = $arrSegments;
					$arrInsertFlightData[$keys]['FlightData'] = $FlightData;
					$arrInsertFlightData[$keys]['MultiHead'] = $MultiHead;
					$arrInsertFlightData[$keys]['IsBagIncludes'] = $IsBagIncludes;
					$arrInsertFlightData[$keys]['SearchFlightTraceId'] = $SearchFlightTraceId;
					$arrInsertFlightData[$keys]['ICSourceSysId'] = 7;
					$arrInsertFlightData[$keys]['IsMealIncludes'] = $IsMealIncludesTrue;
					if ($FairRulesArr) {
						foreach ($FairRulesArr as $Fare) {
							$dddddddd[] = $Fare['PublishedFare'];
						}
					}
				}
			}

			$FiltStopCount = array_values(array_unique($FiltStopCount));
			$arrAirlineName = array_values(array_unique($arrAirlineName));

			$AttPriceRange__ = [];

			$MinriceRange = (min($dddddddd));
			$MaxriceRange = (max($dddddddd));

			sort($FiltStopCount);
			$data = array('outbound' => $arrInsertFlightData, 'inbound' => [], 'MultiHead' => $MultiHead, 'ReturnDateArr' => '', 'DepartDateArr' => '', 'source' => $source, 'destination' => $destination, 'source_city' => $source_city, 'destination_city' => $destination_city, 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute, 'CurrencyTitle' => $this->CurrencyTitle, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'ArrPriceUnique' => $AttPriceRange__, 'MinriceRange' => (round($MinriceRange)), 'MaxriceRange' => (round($MaxriceRange)));
			echo json_encode($data);
			exit;
		} else {
			$data = array('outbound' => [], 'inbound' => [], 'MultiHead' => [], 'source' => $source, 'destination' => $destination, 'source_city' => $source_city, 'destination_city' => $destination_city, 'route' => $strFlightRoute, 'interNationalSearch' => $interNationalSearch, 'arrAirlineName' => [], 'FiltStopCount' => [], 'ArrPriceUnique' => []);
			echo json_encode($data);
			exit;
		}
		echo '<pre>';
		print_r($apiResponse);
		die('ddd');
	}

	public function FlightDataSeriesFare($response, $sessionFlightSearchParams, $intJourneyType = null, $AdditionalMarkup = 0)
	{
		$arrAirlineList = $this->getAirlineIdsAndCodeList();
		$objFlight = new Travel_Model_FlightMaster();
		$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId']);
		$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId']);
		$sourceCityText = explode(',', $sessionFlightSearchParams['sourceCityText']);
		$destinationCityText = explode(',', $sessionFlightSearchParams['destinationCityText']);
		$adultCount = $sessionFlightSearchParams['adults'];
		$childCount = $sessionFlightSearchParams['child'];
		$infantCount = $sessionFlightSearchParams['infant'];
		$intMemberCount = $adultCount + $childCount + $infantCount;
		$strFlightRoute = trim($sessionFlightSearchParams['route']);
		$FlightTraceId = trim($sessionFlightSearchParams['FlightTraceId']);
		$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
		$flight_class = trim($sessionFlightSearchParams['flight_class']);
		$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
		$source_city = isset($sessionFlightSearchParams['source_city']) ? $sessionFlightSearchParams['source_city'] : '';
		$destination_city = isset($sessionFlightSearchParams['destination_city']) ? $sessionFlightSearchParams['destination_city'] : '';
		$source = isset($sessionFlightSearchParams['source']) ? $sessionFlightSearchParams['source'] : '';
		$destination = isset($sessionFlightSearchParams['destination']) ? $sessionFlightSearchParams['destination'] : '';
		$SearchFlightTraceId = $sessionFlightSearchParams['SearchFlightTraceId'];
		//$intJourneyType = 1;  FlyingMinutes
		$intTripType = 1;
		$$arrInsertFlightData = [];
		$arrAirlineName = [];
		$FiltStopCount = [];
		$FiltPriceRange = [];
		$AttPriceRange = [];
		if ($response) {
			$key = 0;
			foreach ($response as $result) {
				$FlightType1 = isset($result['FlightType']) ? $result['FlightType'] : '';
				$strTraceId = $result['id'];
				$CheckInLuggage = $result['CheckInLuggage'];
				$InCabinLuggage = $result['InCabinLuggage'];
				$SupplierSysId = $result['Supplier'];
				$FareRules = $result['Fare'];
				$CancellationPolicy = $result['CancellationPolicy'];
				$InternalRemarks = $result['InternalRemarks'];
				$SegmentInformation = $result['airlineinventories'];
				$airlineprices = $result['airlineprices'];
				$CurrentAirlineprices = current($airlineprices);
				$OriginSegments = current($SegmentInformation);
				$DestinationSegments = end($SegmentInformation);
				$FNEX = explode('-', $OriginSegments['FlightNumber']);
				$AirlineCode = $FNEX[0];
				$FlightNumber = $FNEX[1];
				$strFlightNumber = $OriginSegments['FlightNumber'];
				$strAirlineName = $OriginSegments['AirLines'];
				$strDepartureDtTime = date('H:i', strtotime($OriginSegments['DepartureTime']));
				$strArrivalDtTime = $OriginSegments['ArrivalTime'];
				$FlightDuration = $OriginSegments['EstimateHours'];
				$strSourceAirportCode = $OriginSegments['FromCityCode'];
				$strDestinationAirportCode = $DestinationSegments['ToCityCode'];
				$Stops = $OriginSegments['Stops'];
				$IsLCC = true;
				$Currency = $result['Markup'];
				$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
				$filePath = $this->getflightlogo($AirlineCode);
				if (!empty($CheckInLuggage)) {
					$IsBaggage = true;
				} else {
					$IsBaggage = false;
				}
				if ($strFlightRoute == 2 && $interNationalSearch == 1) {
					$AllSeg = [];
					if ($SegmentInformation) {
						foreach ($SegmentInformation as $keyseg => $Segv) {
							$AllSeg[$Segv['FlightType']][] = $Segv;
						}
					}
					$OriginSegments = current($AllSeg[1]);
					$DestinationSegments = end($AllSeg[1]);
				} else {
					$OriginSegments = current($SegmentInformation);
					$DestinationSegments = end($SegmentInformation);
				}
				$totalMarkup = 0;
				$arrSegments = [];
				if ($airlineprices) {
					foreach ($airlineprices as $price) {
						$arrSegments = array();
						if ((int) $price['CurrentSeat'] > 0) {
							if ($SegmentInformation) {
								foreach ($SegmentInformation as $sgk => $segments) {
									$isReturnSegment = false;
									if ($sgk == 1) {
										$isReturnSegment = true;
									}
									if ($segments['FlightType'] == 2 && ($strFlightRoute == 2) && $interNationalSearch == 1) {
										$isReturnSegment = true;
									} else {
										$isReturnSegment = false;
									}
									$FNEX = explode('-', $segments['FlightNumber']);
									$AirlineCode = $FNEX[0];
									$FlightNumber = $FNEX[1];
									$FromTerminal = $segments['FromTerminal'];
									$ToTerminal = $segments['ToTerminal'];
									$SegFlightNumber = $segments['FlightNumber'];
									$AirlineName = $segments['AirLines'];
									$strDepartureDtTime = $segments['DepartureTime'];
									$strArrivalDtTime = $segments['ArrivalTime'];
									$strDuration = $segments['EstimateHours'];
									$originAirportCode = $segments['FromCityCode'];
									$destinationAirportCode = $segments['ToCityCode'];
									$Stops = $segments['Stops'];
									$filePathS = $this->getflightlogo($AirlineCode);
									$originAirportCodeData = $objFlight->getflightAirportData($originAirportCode);
									$destinationAirportCodeData = $objFlight->getflightAirportData($destinationAirportCode);
									$originCityName = isset($originAirportCodeData[0]['AirportName']) ? explode(',', $originAirportCodeData[0]['AirportName']) : '';
									$destinationCityName = isset($destinationAirportCodeData[0]['AirportName']) ? explode(',', $destinationAirportCodeData[0]['AirportName']) : '';
									$FlightDurationArr = explode(':', $strDuration);
									$hours = isset($FlightDurationArr[0]) ? (int)$FlightDurationArr[0] : 0;
									$minutes = isset($FlightDurationArr[1]) ? (int)$FlightDurationArr[1] : 0;
									$FlightDurationTxt = $hours . ($hours > 1 ? ' hours' : 'hour') . ' ' . $minutes . ($minutes > 1 ? ' minutes' : ' minute');
									$totalhoures = $totalhoures + $hours;
									$totalminutes = $totalminutes + $minutes;
									$FromDate = date('Y-m-d', strtotime($price['FromDate'])) . ' ' . $strDepartureDtTime;
									$originDepTime = $price['FromDate'];
									$InwardFromDate = date('Y-m-d', strtotime($price['InwardFromDate'])) . ' ' . $strDepartureDtTime;
									$LocalToTime = date('Y-m-d H:i:s', strtotime('+' . $hours . ' hour +' . $minutes . ' minutes', strtotime($FromDate)));
									$destinationArrTime = date('Y-m-d', strtotime('+' . $hours . ' hour +' . $minutes . ' minutes', strtotime($FromDate)));
									if (($strFlightRoute == 2) && $interNationalSearch == 1 && $sgk == 1) {
										$destinationArrTime = date('Y-m-d', strtotime('+' . $hours . ' hour +' . $minutes . ' minutes', strtotime($InwardFromDate)));
										$originDepTime = $price['InwardFromDate'];
									}
									$duration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->convertMinutes($strDepartureDtTime, $strArrivalDtTime);
									$arrSegments[] = array(
										"isReturnSegment" => $isReturnSegment,
										"destinationAirportCode" => $destinationAirportCode,
										"SegFlightNumber" => $SegFlightNumber,
										"AirlineCode" => $AirlineCode,
										"AirlineName" => $AirlineName,
										"originAirportCode" => $originAirportCode,
										"Baggage" => $CheckInLuggage,
										"CabinBaggage" => $InCabinLuggage,
										"IsBaggage" => $IsBaggage,
										"NoOfSeatAvailable" => $NoOfSeatAvailable,
										"strDepartureDtTime" => $strDepartureDtTime,
										"strArrivalDtTime" => $strArrivalDtTime,
										"FlightDuration" => $strDuration,
										"filePath" => $filePathS,
										"originAirportName" => isset($originAirportCodeData[0]['AirportName']) ? $originAirportCodeData[0]['AirportName'] : '',
										"destinationAirportName" => isset($destinationAirportCodeData[0]['AirportName']) ? $destinationAirportCodeData[0]['AirportName'] : '',
										"originCityName" => isset($originCityName[0]) ? $originCityName[0] : '',
										"originCountryName" => '',
										"destinationCityName" => isset($destinationCityName[0]) ? $destinationCityName[0] : '',
										"destinationCountryName" => '',
										"destinationArrTime" => $destinationArrTime . 'T' . $strArrivalDtTime,
										"FareClass" => '',
										"originDepTime" => $originDepTime . 'T' . $strDepartureDtTime,
										"TripIndicator" => '', //$TripIndicator,
										"IsMealIncludes" => 0,
										"Duration" => $duration,
										"GroundTime" => '',
										"LAYOVERDuration" => '',
										"LAYOVERCity" => '',
										"DepTerminal" => $FromTerminal,
										"ArrTerminal" => $ToTerminal,
									);
								}
							}
							$BaseFare = $price['Fare'];
							$InfantFare = $price['InfantFare'];
							$Taxes = $price['Taxes'];
							$Markup = $price['B2CMarkup'];
							$MarkupType = $price['MarkupType'];
							$InfantMarkup = $price['InfantMarkup'];
							if ($MarkupType == 1) {
								$totalMarkup = $Markup;
							} else {
								$totalMarkup = ((($BaseFare + $Taxes) * $Markup) / 100);
							}
							$PublishedFareReverseAdultChild = ($BaseFare + $Taxes + $totalMarkup) * ($adultCount + $childCount);
							$PublishedFareReverseInfant = ($InfantFare + $InfantMarkup) * $infantCount;
							$PublishedFareReverse = $PublishedFareReverseAdultChild + $PublishedFareReverseInfant;
							$NoOfSeatAvailable = $price['CurrentSeat'];
							$BaseFareIN = $BaseFare;
							$TraceId = implode('-', str_split(substr(strtolower(md5(time() . rand(1000, 9999))), 0, 20), 5));
							$PriceID = $result['id'] . '_' . $price['id'] . '-' . $TraceId;
							$ADULT = array();
							$ADULT = array('TAF' => 0, 'TF' => 0, 'BF' => $BaseFare, 'NCM' => 0);
							$AD_MF = $AD_YQ = $AD_AGST = $AD_MFT = $AD_OT = $AD_MU = $AD_YR = $TdsOnPLBCal = $ADULTNCMTDS = $PLBEarned = $IncentiveEarned = 0;
							$fareIdentifier = isset($AdditionalMarkup['finalArr']['SPECIAL_DEAL']['fareIdentifier']) ? $AdditionalMarkup['finalArr']['SPECIAL_DEAL']['fareIdentifier'] : 'SPECIAL_DEAL';
							$FareBreakdown = $FairRulesArr = [];
							$FareBreakdown[0]['Currency'] = isset($result['Currency']) ? $result['Currency'] : 'INR';
							$FareBreakdown[0]['PassengerType'] = 1;
							$FareBreakdown[0]['PassengerCount'] = $intMemberCount;
							$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $intMemberCount);
							$FareBreakdown[0]['TotalBaseFare'] = ($ADULT['TF'] * $intMemberCount);
							$FareBreakdown[0]['BaseFareCal'] = ($BaseFare * ($adultCount + $childCount)) + ($InfantFare * $infantCount);
							$FareBreakdown[0]['BaseFare'] = ($BaseFare * ($adultCount + $childCount)) + ($InfantFare * $infantCount);
							$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $intMemberCount);
							$FareBreakdown[0]['TDS'] = (float) str_replace('-', '', ($ADULTNCMTDS * $intMemberCount));
							$FareBreakdown[0]['MF'] = ($AD_MF * $intMemberCount);
							$FareBreakdown[0]['YQ'] = ($AD_YQ * $intMemberCount);
							$FareBreakdown[0]['AGST'] = ($AD_AGST * $intMemberCount);
							$FareBreakdown[0]['MFT'] = ($AD_MFT * $intMemberCount);
							$FareBreakdown[0]['OT'] = ($AD_OT * $intMemberCount);
							$FareBreakdown[0]['MU'] = ($AD_MU * $intMemberCount);
							$FareBreakdown[0]['YR'] = ($AD_YR * $intMemberCount);
							$FareBreakdown[0]['intTotalGST'] = 0;
							$FareBreakdown[0]['apiMarkup'] = $Taxes * $intMemberCount;
							$FareBreakdown[0]['IntCommission'] = 0;
							$FareBreakdown[0]['apiTaxOnMarkup'] = 0;
							$FareBreakdown[0]['FixedMarkUp'] = ($totalMarkup * ($adultCount + $childCount)) + ($InfantMarkup * $infantCount);
							$FareBreakdown[0]['GSTOnMarkUp'] = 0;
							$FareBreakdown[0]['CommEarned'] = 0;
							$FareBreakdown[0]['GSTonComm'] = 0;
							$FareBreakdown[0]['intGTXMarkUp'] = 0;
							$FareBreakdown[0]['GTXMarkUpGST'] = 0;
							$FareBreakdown[0]['AgentMarkUp'] = 0;
							$FareBreakdown[0]['GSTOnAgentMarkUp'] = 0;
							$FareBreakdown[0]['Agencycommission'] = 0;
							$FareBreakdown[0]['TotalCommssionVal_ag'] = 0;
							$FareBreakdown[0]['AdminComminAmount_ag'] = 0;
							$FareBreakdown[0]['AgentB2CEarning'] = 0;
							$FareBreakdown[0]['CostToAgentCustomer'] = (int) ($PublishedFareReverse * $this->CurrencyRate);
							$FareBreakdown[0]['CostToAgent'] = 0;
							$FareBreakdown[0]['AdditionalTxnFeeOfrd'] = 0;
							$FareBreakdown[0]['AdditionalTxnFeePub'] = 0;
							$FareBreakdown[0]['PGCharge'] = 0;
							$FareBreakdown[0]['Baggage'] = $CheckInLuggage; //Check In Baggage;
							$FareBreakdown[0]['CabinBaggage'] = $InCabinLuggage; //Cabin Baggage ;
							$FairRulesArr[] = array(
								"Currency" => isset($result['Currency']) ? $result['Currency'] : 'INR', //$Currency,
								"CurrencyRate" => $this->CurrencyRate, //$Currency,
								"currencySysId" => $this->CurrencyId,
								"BaseFare" => $BaseFareIN,
								"Tax" => '',
								"YQTax" => '',
								"OtherCharges" => 0,
								"Discount" => 0, //$Discount,
								"ServiceFee" => 0,
								"ManagementFeeTax" => 0,
								"AirlineGSTComponent" => 0,
								"CarrierMiscFee" => 0,
								"MUFee" => 0,
								"intPublishedFare" => $PublishedFareReverse,
								"PublishedFare" => ($PublishedFareReverse * $this->CurrencyRate),
								"PublishedFareAgent" => (int) ($PublishedFareReverse * $this->CurrencyRate),
								"PublishedFarePerPax" => ceil(($PublishedFareReverse / $intMemberCount)),
								"OfferedFareAgent" => (int) ($PublishedFareReverse * $this->CurrencyRate),
								"OfferedFare" => 0,
								"PLBEarned" => 0,
								"IncentiveEarned" => 0,
								"TdsOnPLB" => 0,
								"TdsOnIncentive" => 0,
								"AdditionalTxnFeeOfrd" => 0,
								"AdditionalTxnFeePub" => 0,
								"OnwardAutoTicket" => $price['OnwardAutoTicket'],
								"Refundable" => $price['IsRefundable'],
								"IsRefundableTxt" => ($price['IsRefundable'] == 1) ? 'Refundable' : 'Non-Refundable',
								"PriceID" => $PriceID,
								"ApiResultIndex" => $PriceID,
								"IsGSTRequired" => 0,
								// "fareIdentifier" => 'Special Deal',
								"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
								"SeatAvailable" => $NoOfSeatAvailable,
								"classOfBooking" => 0,
								"FareClass" => '',
								"intTotalGST" => 0,
								"apiMarkup" => 0,
								"IntCommission" => 0,
								"apiTaxOnMarkup" => 0,
								"FixedMarkUp" => 0,
								"GSTOnMarkUp" => 0,
								"CommEarned" => 0,
								"CommEarnedAgent" => 0,
								"GSTonComm" => 0,
								"intGTXMarkUp" => (int) 0,
								"GTXMarkUpGST" => 0,
								"AgentMarkUp" => 0,
								"GSTOnAgentMarkUp" => 0,
								'Agencycommission' => 0,
								'TotalCommssionVal_ag' => 0,
								'AdminComminAmount_ag' => 0,
								'AgentB2CEarning' => 0,
								'CostToAgentCustomer' => (int) ($PublishedFareReverse * $this->CurrencyRate),
								'CostToAgent' => 0,
								"FareBreakdown" => $FareBreakdown,
								"newFare" => 0,
								"oldFare" => 0,
								"arrMarkUps" => 0,
								"Baggage" => $CheckInLuggage,
								"CabinBaggage" => $InCabinLuggage,
							);
							if (($strFlightRoute == 2 || $strFlightRoute == 4) && $interNationalSearch == 1 && $FlightType1 == '2') {
								$strDestinationAirportCode = $DestinationSegments['ToCityCode'];
								$FlightDuration = $OriginSegments['EstimateHours'];
								$FlightDurationArr = explode(':', $FlightDuration);
								$hours = isset($FlightDurationArr[0]) ? $FlightDurationArr[0] : 0;
								$minutes = isset($FlightDurationArr[1]) ? $FlightDurationArr[1] : 0;
								$FlightDurationTxt = $hours . ($hours > 1 ? 'h' : 'h') . ' ' . $minutes . ($minutes > 1 ? 'm' : ' m');
								$DepartureTime = $OriginSegments['DepartureTime'];
								$ArrivalTime = $DestinationSegments['ArrivalTime'];
								$originTime1 = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($preferredArrivalTime, 'y/m/d') . "T00:00:00";
								$originTimedate = date('Y-m-d', strtotime($originTime1)) . "T00:00:00";

								$arrInsertFlightData[$key]['origin']['FlightNumber'] = $strFlightNumber;
								$arrInsertFlightData[$key]['origin']['SegFlightNumberArr'] = $strFlightNumber;
								$arrInsertFlightData[$key]['origin']['AirlineName'] = ucwords(strtolower($strAirlineName));;
								$arrInsertFlightData[$key]['origin']['AirlineCode'] = $AirlineCode;
								$arrInsertFlightData[$key]['origin']['IsRefundableTxt'] = ($price['IsRefundable'] == 1) ? 'Refundable' : 'Non-Refundable';
								$arrInsertFlightData[$key]['origin']['DepartureDateTxt'] = date('D, d M', strtotime($price['FromDate']));
								$arrInsertFlightData[$key]['origin']['DepartureTime'] = $DepartureTime;
								$arrInsertFlightData[$key]['origin']['ArrivalTime'] = $ArrivalTime;
								$arrInsertFlightData[$key]['origin']['FareClass'] = $strFareClass;
								$arrInsertFlightData[$key]['origin']['FlightDuration'] = $FlightDurationTxt;
								$arrInsertFlightData[$key]['origin']['SourceAirportCode'] = $strSourceAirportCode;
								$arrInsertFlightData[$key]['origin']['DestAirportCode'] = $strDestinationAirportCode;
								$arrInsertFlightData[$key]['origin']['StopCount'] = ($Stops > 0) ? $Stops . ' Stop(s)' : 'Non-stop';;
								$arrInsertFlightData[$key]['origin']['logo'] = $filePath;
								$arrInsertFlightData[$key]['origin']['IsLCC'] = $IsLCC;
								// $arrInsertFlightData[$key]['origin']['TravelDate'] = $originTimedate;

								$arrInsertFlightData[$key]['origin']['TravelDate'] = date('Y-m-d', strtotime($price['FromDate']));
								$arrInsertFlightData[$key]['origin']['LocalFromTime'] = date('Y-m-d', strtotime($price['FromDate'])) . ' ' . $strDepartureDtTime;
								$arrInsertFlightData[$key]['origin']['FromUTCTime'] = date('Y-m-d', strtotime($price['FromDate'])) . ' ' . $strDepartureDtTime;
								$arrInsertFlightData[$key]['origin']['LocalToTime'] = date('Y-m-d', strtotime($price['FromDate'])) . ' ' . $strArrivalDtTime;
								$arrInsertFlightData[$key]['origin']['ToUTCTime'] = date('Y-m-d', strtotime($price['FromDate'])) . ' ' . $strArrivalDtTime;
								$arrInsertFlightData[$key]['origin']['IsDirect'] = 0;
								$arrInsertFlightData[$key]['origin']['SourcePlaceSysId'] = $intSourceCityId;
								$arrInsertFlightData[$key]['origin']['DestPlaceSysId'] = $intDestinationCityId;
								$arrInsertFlightData[$key]['origin']['SourcePlaceName'] = $sourceCityText[0];
								$arrInsertFlightData[$key]['origin']['DestPlaceName'] = $destinationCityText[0];
								$arrInsertFlightData[$key]['origin']['StopCountShow'] = ($Stops > 0) ? $Stops . ' Stop(s)' : 'Non Stop';
								$arrInsertFlightData[$key]['origin']['Stops'] = $Stops;
								$arrInsertFlightData[$key]['origin']['NoOfSeatAvailable'] = (int) ($NoOfSeatAvailable);
								$arrInsertFlightData[$key]['origin']['TotalFlightMembers'] = $intMemberCount;
								$arrInsertFlightData[$key]['origin']['CurrencyType'] = $this->CurrencyId;
								$arrInsertFlightData[$key]['origin']['PublishedFare'] = ($PublishedFareReverse * $this->CurrencyRate);
								$arrInsertFlightData[$key]['origin']['PublishedFareTxt'] = number_format(($PublishedFareReverse * $this->CurrencyRate));
								$arrInsertFlightData[$key]['origin']['ApiResultIndex'] = $PriceID;
								$arrInsertFlightData[$key]['origin']['JourneyType'] = $intJourneyType;
								$arrInsertFlightData[$key]['origin']['FlyingMinutes'] = 0;
								$arrInsertFlightData[$key]['origin']['TripType'] = $intTripType;
								$arrInsertFlightData[$key]['origin']['IsInternational'] = $interNationalSearch;

								$arrInsertFlightData[$key]['origin']['ICSourceSysId'] = 8;
								$arrInsertFlightData[$key]['origin']['OrFlightNumber'] = $strFlightNumber;


								$OriginSegments = current($AllSeg[2]);
								$DestinationSegments = end($AllSeg[2]);

								$FNEX = explode('-', $DestinationSegments['FlightNumber']);
								$AirlineCode = $FNEX[0];
								$FlightNumber = $FNEX[1];
								$strFlightNumber__ = $DestinationSegments['FlightNumber'];
								$strAirlineName = $DestinationSegments['AirLines'];
								$strDepartureDtTime = date('H:i', strtotime($DestinationSegments['DepartureTime']));
								$strArrivalDtTime = $DestinationSegments['ArrivalTime'];
								$FlightDuration = $DestinationSegments['EstimateHours'];
								$FlightDurationArr = explode(':', $FlightDuration);
								$hours = isset($FlightDurationArr[0]) ? $FlightDurationArr[0] : 0;
								$minutes = isset($FlightDurationArr[1]) ? $FlightDurationArr[1] : 0;
								$strSourceAirportCode_ = $OriginSegments['FromCityCode'];
								$strDestinationAirportCode_ = $DestinationSegments['ToCityCode'];
								$Stops = $DestinationSegments['Stops'];
								$DepartureTime = $OriginSegments['DepartureTime'];
								$ArrivalTime = $DestinationSegments['ArrivalTime'];
								$filePath = $this->getflightlogo($AirlineCode);
								$FlightDurationTxt = $hours . ($hours > 1 ? 'h' : 'h') . ' ' . $minutes . ($minutes > 1 ? 'm' : 'm');

								$arrInsertFlightData[$key]['destination']['FlightNumber'] = $strFlightNumber__;
								$arrInsertFlightData[$key]['destination']['SegFlightNumberArr'] = $strFlightNumber__;
								$arrInsertFlightData[$key]['destination']['AirlineName'] = ucwords(strtolower($strAirlineName));;
								$arrInsertFlightData[$key]['destination']['AirlineCode'] = $AirlineCode;
								$arrInsertFlightData[$key]['destination']['IsRefundableTxt'] = ($price['IsRefundable'] == 1) ? 'Refundable' : 'Non-Refundable';
								$arrInsertFlightData[$key]['destination']['DepartureDateTxt'] = date('D, d M', strtotime($price['InwardFromDate']));
								$arrInsertFlightData[$key]['destination']['DepartureTime'] = $DepartureTime;
								$arrInsertFlightData[$key]['destination']['ArrivalTime'] = $ArrivalTime;
								$arrInsertFlightData[$key]['destination']['FareClass'] = $strFareClass;
								$arrInsertFlightData[$key]['destination']['FlightDuration'] = $FlightDurationTxt;
								$arrInsertFlightData[$key]['destination']['SourceAirportCode'] = $strSourceAirportCode_;
								$arrInsertFlightData[$key]['destination']['DestAirportCode'] = $strDestinationAirportCode_;
								$arrInsertFlightData[$key]['destination']['StopCount'] = ($Stops > 0) ? $Stops . ' Stop(s)' : 'Non-stop';;
								$arrInsertFlightData[$key]['destination']['logo'] = $filePath;
								$arrInsertFlightData[$key]['destination']['IsLCC'] = $IsLCC;
								$arrInsertFlightData[$key]['ToDate'] = date('d/m/Y', strtotime($price['InwardFromDate']));

								$arrInsertFlightData[$key]['destination']['TravelDate'] = date('Y-m-d', strtotime($price['InwardFromDate']));
								$arrInsertFlightData[$key]['destination']['LocalFromTime'] = date('Y-m-d', strtotime($price['InwardFromDate'])) . ' ' . $strDepartureDtTime;
								$arrInsertFlightData[$key]['destination']['FromUTCTime'] = date('Y-m-d', strtotime($price['InwardFromDate'])) . ' ' . $strDepartureDtTime;
								$arrInsertFlightData[$key]['destination']['LocalToTime'] = date('Y-m-d', strtotime($price['InwardFromDate'])) . ' ' . $strArrivalDtTime;
								$arrInsertFlightData[$key]['destination']['ToUTCTime'] = date('Y-m-d', strtotime($price['InwardFromDate'])) . ' ' . $strArrivalDtTime;
								$arrInsertFlightData[$key]['destination']['IsDirect'] = 0;
								$arrInsertFlightData[$key]['destination']['SourcePlaceSysId'] = $intSourceCityId;
								$arrInsertFlightData[$key]['destination']['DestPlaceSysId'] = $intDestinationCityId;
								$arrInsertFlightData[$key]['destination']['SourcePlaceName'] = $sourceCityText[0];
								$arrInsertFlightData[$key]['destination']['DestPlaceName'] = $destinationCityText[0];
								$arrInsertFlightData[$key]['destination']['StopCountShow'] = ($Stops > 0) ? $Stops . ' Stop(s)' : 'Non Stop';
								$arrInsertFlightData[$key]['destination']['Stops'] = $Stops;
								$arrInsertFlightData[$key]['destination']['NoOfSeatAvailable'] = (int) ($NoOfSeatAvailable);
								$arrInsertFlightData[$key]['destination']['TotalFlightMembers'] = $intMemberCount;
								$arrInsertFlightData[$key]['destination']['CurrencyType'] = $this->CurrencyId;
								$arrInsertFlightData[$key]['destination']['PublishedFare'] = ($PublishedFareReverse * $this->CurrencyRate);
								$arrInsertFlightData[$key]['destination']['PublishedFareTxt'] = number_format(($PublishedFareReverse * $this->CurrencyRate));
								$arrInsertFlightData[$key]['destination']['ApiResultIndex'] = $PriceID;
								$arrInsertFlightData[$key]['destination']['JourneyType'] = $intJourneyType;
								$arrInsertFlightData[$key]['destination']['FlyingMinutes'] = 0;
								$arrInsertFlightData[$key]['destination']['TripType'] = $intTripType;
								$arrInsertFlightData[$key]['destination']['IsInternational'] = $interNationalSearch;
								$arrInsertFlightData[$key]['destination']['ICSourceSysId'] = 8;
								$arrInsertFlightData[$key]['destination']['OrFlightNumber'] = $strFlightNumber__;
							}
							$arrInsertFlightData[$key]['Currency'] = isset($result['Currency']) ? $result['Currency'] : 'INR';
							$arrInsertFlightData[$key]['CurrencyRate'] = $this->CurrencyRate;
							$arrInsertFlightData[$key]['currencySysId'] = $this->CurrencyId;
							$arrInsertFlightData[$key]['SegFlightNumberArr'] = $strFlightNumber;
							$arrInsertFlightData[$key]['FlightNumber'] = $strFlightNumber;
							$arrInsertFlightData[$key]['AirlineName'] = $strAirlineName;
							$arrInsertFlightData[$key]['AirlineCode'] = $AirlineCode;
							$arrInsertFlightData[$key]['AirInvenSysId'] = 0;
							$arrInsertFlightData[$key]['IsLCC'] = $IsLCC;
							$arrInsertFlightData[$key]['IsRefundable'] = $price['IsRefundable'];
							$arrInsertFlightData[$key]['OnwardAutoTicket'] = $price['OnwardAutoTicket'];
							$arrInsertFlightData[$key]['InwardAutoTicket'] = $price['InwardAutoTicket'];
							$arrInsertFlightData[$key]['IsRefundableTxt'] = ($price['IsRefundable'] == 1) ? 'Refundable' : 'Non-Refundable';
							$arrInsertFlightData[$key]['SearchTraceId'] = $FlightTraceId;
							$arrInsertFlightData[$key]['apiTraceId'] = $PriceID;
							//$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
							$arrInsertFlightData[$key]['AirlineSysId'] = $airlineSysId;
							$arrInsertFlightData[$key]['DepartureTime'] = $strDepartureDtTime;
							$arrInsertFlightData[$key]['ArrivalTime'] = $strArrivalDtTime;
							$arrInsertFlightData[$key]['TravelDate'] = date('Y-m-d', strtotime($price['FromDate']));
							$arrInsertFlightData[$key]['LocalFromTime'] = date('Y-m-d', strtotime($price['FromDate'])) . ' ' . $strDepartureDtTime;
							$arrInsertFlightData[$key]['FromUTCTime'] = date('Y-m-d', strtotime($price['FromDate'])) . 'T' . $strDepartureDtTime;
							$arrInsertFlightData[$key]['LocalToTime'] = date('Y-m-d', strtotime($price['FromDate'])) . ' ' . $strArrivalDtTime;
							$arrInsertFlightData[$key]['ToUTCTime'] = date('Y-m-d', strtotime($price['FromDate'])) . ' ' . $strArrivalDtTime;
							$arrInsertFlightData[$key]['IsDirect'] = 0;
							$arrInsertFlightData[$key]['FlightDuration'] = $FlightDuration;
							$arrInsertFlightData[$key]['SourcePlaceSysId'] = $intSourceCityId;
							$arrInsertFlightData[$key]['DestPlaceSysId'] = $intDestinationCityId;
							$arrInsertFlightData[$key]['SourceAirportCode'] = $strSourceAirportCode;
							$arrInsertFlightData[$key]['DestAirportCode'] = $strDestinationAirportCode;
							$arrInsertFlightData[$key]['SourcePlaceName'] = $sourceCityText[0];
							$arrInsertFlightData[$key]['DestPlaceName'] = $destinationCityText[0];
							$arrInsertFlightData[$key]['StopCount'] = ($Stops > 0) ? $Stops . ' Stop(s)' : 'Non-stop';
							$arrInsertFlightData[$key]['StopCountShow'] = ($Stops > 0) ? $Stops . ' Stop(s)' : 'Non Stop';
							$arrInsertFlightData[$key]['Stops'] = $Stops;
							$arrInsertFlightData[$key]['NoOfSeatAvailable'] = (int) ($NoOfSeatAvailable);
							$arrInsertFlightData[$key]['TotalFlightMembers'] = $intMemberCount;
							$arrInsertFlightData[$key]['CurrencyType'] = $this->CurrencyId;
							$arrInsertFlightData[$key]['PublishedFare'] = ($PublishedFareReverse * $this->CurrencyRate);
							$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format(($PublishedFareReverse * $this->CurrencyRate));
							$arrInsertFlightData[$key]['ApiResultIndex'] = $PriceID;
							$arrInsertFlightData[$key]['JourneyType'] = $intJourneyType;
							$arrInsertFlightData[$key]['FlyingMinutes'] = 0;
							$arrInsertFlightData[$key]['TripType'] = $intTripType;
							$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
							$arrInsertFlightData[$key]['logo'] = $filePath;
							$arrInsertFlightData[$key]['FairRules'] = $FairRulesArr;
							$arrInsertFlightData[$key]['Segments'] = $arrSegments;
							$arrInsertFlightData[$key]['FareRules'] = strip_tags(html_entity_decode($FareRules));
							$arrInsertFlightData[$key]['CancellationPolicy'] = strip_tags(html_entity_decode($CancellationPolicy));
							$arrInsertFlightData[$key]['InternalRemarks'] = strip_tags(html_entity_decode($InternalRemarks));
							$arrInsertFlightData[$key]['FromDate'] = date('d/m/Y', strtotime($price['FromDate']));
							$arrInsertFlightData[$key]['IsRefundable'] = $price['IsRefundable'];
							$arrInsertFlightData[$key]['DepartureDateTxt'] = date('D, d M', strtotime($price['FromDate']));
							$arrInsertFlightData[$key]['ArrivalDateTxt'] = date('D, d M', strtotime($price['FromDate']));
							$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
							$arrInsertFlightData[$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
							$arrInsertFlightData[$key]['OnwardGroupPNR'] = ($price['OnwardAutoTicket'] == 1) ? $price['OnwardGroupPNR'] : '';
							$arrInsertFlightData[$key]['InwardGroupPNR'] = ($price['InwardAutoTicket'] == 1) ? $price['InwardGroupPNR'] : '';
							$arrInsertFlightData[$key]['OnwardGroupPNRDummy'] = $price['OnwardGroupPNR'];
							$arrInsertFlightData[$key]['IsSeriesFareData'] = true;
							$arrInsertFlightData[$key]['ICSourceSysId'] = 8;
							$arrInsertFlightData[$key]['SupplierSysId'] = $SupplierSysId;
							$arrInsertFlightData[$key]['SearchFlightTraceId'] = $SearchFlightTraceId;
							$arrInsertFlightData[$key]['isDobInfant'] = ($infantCount > 0) ? true : false;
							$arrInsertFlightData[$key]['OrFlightNumber'] = $strFlightNumber;
							$key++;
							//$arrAirlineName[] = $AirlineCode . '-' . $strAirlineName;
							$arrAirlineName[] = '-' . $strAirlineName;
							$AttPriceRange[] = $PublishedFareReverse * $this->CurrencyRate;
							$FiltStopCount[] = $Stops . ' Stop(s)';
						}
					}
				}
			}
		}
		// echo '<pre>';
		// print_r($arrInsertFlightData);
		// die;
		$arrAirlineName = array_values(array_unique($arrAirlineName));
		$FiltStopCount = array_values(array_unique($FiltStopCount));
		$MinriceRange = (min($AttPriceRange));
		$MaxriceRange = (max($AttPriceRange));
		$data = array('outbound' => $arrInsertFlightData, 'inbound' => '', 'ReturnDateArr' => '', 'DepartDateArr' => '', 'source' => $source, 'destination' => $destination, 'source_city' => $source_city, 'destination_city' => $destination_city, 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute, 'CurrencyTitle' => isset($result['Currency']) ? $result['Currency'] : 'INR', 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'MinriceRange' => round($MinriceRange), 'MaxriceRange' => round($MaxriceRange), 'AttPriceRange' => $AttPriceRange, 'FlightType' => $FlightType1);
		return $data;
	}

	private function getMarketPlace($filterData = array(), $MarketPlaceSysId=null)
	{
		$URLMarketPlace = 'https://admin.globaltravelexchange.com/api/v1/agency/air-fare-type-b2b-market-place/?market_place_sys_id=' . $MarketPlaceSysId;
		$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyMarketPlace([], $URLMarketPlace, SECURITYKEY); ///'F38C55F4-5771-4EED-AAB2-D1CE094AEB4E'

		// $AgencyMarketPlaceSysId = $this->_session->data['AgencyMarketPlaceSysId'];
		// $url = $this->baseUrl . "public/logs/AgencyMarketPlace/".$this->MasterAgencySysId.'_'.$AgencyMarketPlaceSysId."/response.json";
		// $ch = curl_init();
		// curl_setopt($ch, CURLOPT_URL, $url);
		// curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
		// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		// $str = curl_exec($ch);
		// $response = json_decode($str, true);
		// echo "<pre>";
		// print_r($response);die;
		$Market_Wise = isset($response['data']['Market_Wise']) ? $response['data']['Market_Wise'] : [];
		$Flight_Full_API = isset($response['data']['Flight_Full_API']) ? $response['data']['Flight_Full_API'] : [];
		$Flight_Series_Fare = isset($response['data']['Flight_Series_Fare']) ? $response['data']['Flight_Series_Fare'] : [];

		if ($filterData['ApiSourceSysId'] == 1 || $filterData['ApiSourceSysId'] == 3) {
			$new = array_filter($Market_Wise, function ($var) use ($filterData) {
				return ($var['ApiSourceSysId'] == $filterData['ApiSourceSysId']);
			});
			$newFullAPI = array_filter($Flight_Full_API, function ($var) use ($filterData) {
				return ($var['ApiSourceSysId'] == $filterData['ApiSourceSysId']);
			});

			$finalArr = [];
			$faretypeArr = [];
			if ($new) {
				foreach ($new as $value) {
					$markup_b2b = $value['mark_up_value'];
					$color = $value['color_code'];
					$faretype = $value['old_title'];
					$faretype_rename = $value['title'];
					$showhide_b2b = $value['is_display'];
					$B2BRemark = $value['B2CRemark'];
					$faretypeArr[] = $faretype;
					$finalArr[$faretype] = array(
						'faretype' => $faretype,
						'faretype_rename' => $faretype_rename,
						'fareIdentifier' => $faretype_rename,
						'markup_b2c' => $markup_b2b,
						'showhide_b2c' => $showhide_b2b,
						'color' => $color,
						'remarks' => $B2BRemark,
						'ApiRoundTrip' => 0,
					);
				}
			}
			$AirlineWiseMarkup = [];
			if ($newFullAPI) {
				foreach ($newFullAPI as $value) {
					$Code = trim($value['Code']);
					$AirlineWiseMarkup[$Code]['MarkUpType'] = $value['MarkUpType'];
					$AirlineWiseMarkup[$Code]['MarkUpValue'] = $value['MarkUpValue'];
				}
			}

			$DataSet = ['finalArr' => $finalArr, 'faretypeArr' => $faretypeArr, 'AirlineWiseMarkup' => $AirlineWiseMarkup];
			return $DataSet;
		} else {
			$new = array_filter($Flight_Series_Fare, function ($var) use ($filterData) {
				return ($var['ApiSourceSysId'] == $filterData['ApiSourceSysId']
					&& trim($var['Code']) == $filterData['FlightCode']
					&& trim($var['FromAirportCode']) == $filterData['FromAirportCode']
					&& trim($var['ToAirportCode']) == $filterData['ToAirportCode']
				);
			});
			$Series_Fare = [];
			if (!empty(array_values($new))) {
				$fareNode = array_values($new);
				$MarkUpType = isset($fareNode[0]['MarkUpType']) ? $fareNode[0]['MarkUpType'] : 0;
				$MarkUpValue = isset($fareNode[0]['MarkUpValue']) ? $fareNode[0]['MarkUpValue'] : 0;
				$Series_Fare = ['MarkUpValue' => $MarkUpValue, 'MarkUpType' => $MarkUpType];
			}
			$DataSet = ['Series_Fare' => $Series_Fare];
			return $DataSet;
		}
	}
	public function getflightsearchAction()
	{
		$this->_helper->layout->disableLayout();
		$this->_helper->viewRenderer->setNoRender(true);

		$CustomerSession = new Zend_Session_Namespace('CustomerSession');
		$CustomerSession->unsetAll();
		ini_set('memory_limit', '2048M');

		if ($this->gtxagencysysid == '31540') {
			// ini_set('display_errors', 1);
			// ini_set('display_startup_errors', 1);
			// error_reporting(E_ALL);
		}
		$getData = $this->getRequest()->getParams();
		//
		$arrAirlineList = $this->getAirlineIdsAndCodeList();
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		// echo"<pre>";print_r($this->CurrencyTitle);die();
		$FlightSearchResults = new Zend_Session_Namespace('FlightSearchResults');
		$intSourceCityId = trim($sessionFlightSearchParams->params['sourceCityId']);
		$intDestinationCityId = trim($sessionFlightSearchParams->params['destinationCityId']);
		$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);
		$strFlightRoute = trim($sessionFlightSearchParams->params['route']);
		$adultCount = $sessionFlightSearchParams->params['adults'];
		$childCount = $sessionFlightSearchParams->params['child'];
		$infantCount = $sessionFlightSearchParams->params['infant'];
		$intMemberCount = $adultCount + $childCount + $infantCount;
		$strFlightRoute = trim($sessionFlightSearchParams->params['route']);
		$strDepatureDate = $sessionFlightSearchParams->params['departure_dates'];
		$strReturnDate = $sessionFlightSearchParams->params['return_dates'];
		$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
		$SearchFlightTraceId = $sessionFlightSearchParams->params['SearchFlightTraceId'];
		$DepatureDate = $sessionFlightSearchParams->params['strDepatureDate'];
		$begin = new DateTime($DepatureDate);
		//$begin = new DateTime(date('Y-m-d'));
		$end = new DateTime($DepatureDate);
		if ($strFlightRoute == 2 && $interNationalSearch == '') {
			$end = $end->modify('+30 day');
		} else {
			$end = $end->modify('+30 day');
		}
		$interval = new DateInterval('P1D');
		$daterange = new DatePeriod($begin, $interval, $end);
		$DepartDateArr = [];
		foreach ($daterange as $date) {
			$DepartDateArr[] = ['formatDate' => $date->format("Y-m-d"), 'depDate' => $date->format("d/m/Y")];
		}

		$intTatalPaxCT = $adultCount + $childCount;

		// $getMarkup___ = $this->getMarkup($intCountryCode);
		// $getCancellationChargeNew = $this->getCancellationChargeNew($intCountryCode, 1);
		$getMarkup = $this->getMarkupNew($intCountryCode, 1);
		if (empty($getMarkup['arrAgencyMarkups'])) {
			$getMarkup = $this->getMarkup($intCountryCode);
		}
		$MarketPlaceSysId = isset($getMarkup['arrAgencyMarkups'][0]['MarketPlaceSysId']) ? $getMarkup['arrAgencyMarkups'][0]['MarketPlaceSysId'] : 0;
		$MasterId = isset($getMarkup['arrAgencyMarkups'][0]['MasterId']) ? $getMarkup['arrAgencyMarkups'][0]['MasterId'] : 0;
		if(empty($MasterId) || $MasterId == 0){
			$MarketPlaceSysId = $MarketPlaceSysId;
		}else{
			$MarketPlaceSysId = $MasterId;
		}
		$TaxSettingDetail = $this->getTaxSettingDetail($getMarkup['TaxSetting'], 1);
		$getMarkup['TaxSettingDetail'] = $TaxSettingDetail;
		$AdditionalMarkup = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAdditionalMarkup();
		$faretypeArr = $AdditionalMarkup['faretypeArr'];
		$ApiRoundTrip = $AdditionalMarkup['ApiRoundTrip'];
		$IsSeriesFareAllow = $AdditionalMarkup['IsSeriesFareAllow'];
		// if ($this->gtxagencysysid == '2656') {
			// $filterData = ['ApiSourceSysId' => 1];
			// $getMarketPlace = $this->getMarketPlace($filterData, $MarketPlaceSysId);
			// echo "<pre>";
			// print_r($MarketPlaceSysId);
			// echo "<pre>";
			// print_r($getMarketPlace);
			// echo "<pre>";
			// print_r($getMarkup);
			// die;
		// }
		// $CurrentDateTime = date('Y-m-d-H-i-s');
		// $strFilePath = "flight/Time/" . $SearchFlightTraceId . "/request_Hit.json";
		// Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $CurrentDateTime);

		$intJourneyType = 1;
		$intTripType = 1;
		$FlightDataTBO = [];
		$apiResponseTBO = [];
		$apiResponse = [];
		$outboundAPI = [];
		$inboundAPI = [];
		$FiltPricearAPI = [];
		$arrAirlineNameAPI = [];
		$FiltStopAPI = [];
		$FlightDataSeriesFare = [];
		if($this->IsNEXTRAFlightAPI || $this->IsAIRIQFlightAPI || $this->IsETRAVFlightAPI){
				// $url = "http://local.travelidea.com/public/logs/flight/search_response.json";
                // $str = file_get_contents($url);
                // $apiSearchRequest = json_decode($str, true);
				$apiSearchRequest = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiSearchRequest($sessionFlightSearchParams->params);
				$ResponseStatus = (isset($apiSearchRequest['status']) && $apiSearchRequest['status']) ? true : false;
				$CurrentDateTime = date('Y-m-d-H-i-s');
				// $strFilePath = "flight/Time/" . $SearchFlightTraceId . "/response_gtxapi.json";
				// Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $CurrentDateTime);
				// echo "<pre>dd";
				// echo json_encode($apiSearchRequest);die;
				if($ResponseStatus){
					$outbound = $outboundAPI = (isset($apiSearchRequest['outbound']) && $apiSearchRequest['outbound']) ? $apiSearchRequest['outbound'] : [];
					$inbound = $inboundAPI = (isset($apiSearchRequest['inbound']) && $apiSearchRequest['inbound']) ? $apiSearchRequest['inbound'] : [];
					$FiltPrice = (isset($apiSearchRequest['FiltPrice']) && $apiSearchRequest['FiltPrice']) ? $apiSearchRequest['FiltPrice'] : [];
					$FiltStop = (isset($apiSearchRequest['FiltStop']) && $apiSearchRequest['FiltStop']) ? $apiSearchRequest['FiltStop'] : [];
					$FiltAirlineName = (isset($apiSearchRequest['FiltAirlineName']) && $apiSearchRequest['FiltAirlineName']) ? $apiSearchRequest['FiltAirlineName'] : [];
					
					if($FiltPrice){
						foreach($FiltPrice as $price){
							if($price){
								foreach($price as $pr){
									$FiltPricearAPI[] = $pr;
								}
							}
						}
					}
					if($FiltStop){
						foreach($FiltStop as $values){
							if($values){
								foreach($values as $vl){
									$FiltStopAPI[] = $vl;
								}
							}
						}
					}
					
					if($FiltAirlineName){
						foreach($FiltAirlineName as $values){
							if($values){
								foreach($values as $vl){
									$arrAirlineNameAPI[] = $vl;
								}
							}
						}
					}
					$MinriceRange = min($FiltPricearAPI);
					$MaxriceRange = max($FiltPricearAPI);
				

					if(($interNationalSearch == '1' || $interNationalSearch == '') && $strFlightRoute == '2' && ($ApiRoundTrip == '16' || $ApiRoundTrip == '17')){
						if($interNationalSearch == '1' && $strFlightRoute == 2){
							$data = array('outboundCombine' => $outbound,'outbound' => $outbound,'inbound' => $inbound, 'DepartDateArr' => $DepartDateArr, 'ReturnDateArr' => $ReturnDateArr,
							'travelDates' => $travelDates, 'travelDatesReturn' => $travelDatesReturn, 'source' => $source, 'destination' => $destination,
							'source_city' => $source_city, 'destination_city' => $destination_city, 'interNationalSearch' => $interNationalSearch,
							'route' => $strFlightRoute, 'CurrencyTitle' => $this->CurrencyTitle, 'arrAirlineName' => array_values(array_unique($arrAirlineNameAPI)),
							'FiltStopCount' =>  array_values(array_unique($FiltStopAPI)), 'ArrPriceUnique' => [],
							'MinriceRange' => (ceil($MinriceRange)), 'MaxriceRange' => (ceil($MaxriceRange)));
						}else{
							$data = array('outbound' => $outbound,'inbound' => $inbound, 'DepartDateArr' => $DepartDateArr, 'ReturnDateArr' => $ReturnDateArr,
							'travelDates' => $travelDates, 'travelDatesReturn' => $travelDatesReturn, 'source' => $source, 'destination' => $destination,
							'source_city' => $source_city, 'destination_city' => $destination_city, 'interNationalSearch' => $interNationalSearch,
							'route' => $strFlightRoute, 'CurrencyTitle' => $this->CurrencyTitle, 'arrAirlineName' => array_values(array_unique($arrAirlineNameAPI)),
							'FiltStopCount' =>  array_values(array_unique($FiltStopAPI)), 'ArrPriceUnique' => [],
							'MinriceRange' => (ceil($MinriceRange)), 'MaxriceRange' => (ceil($MaxriceRange)));
						}
						echo json_encode($data);
						exit;
					}
					// if(isset($outboundAPI) && !empty($outboundAPI)){
					// 	$arrInsertFlightDataNew__ = $outboundAPI;
					// 	$RoundTripinbound = $inboundAPI;
					// 	$MinriceRange = (min(($FiltPricearAPI)));
					// 	$MaxriceRange = (max(($FiltPricearAPI)));
	
					// 	$arrAirlineName = $arrAirlineNameAPI;
					// 	$FiltStopCount = $FiltStopAPI;
						
					// 	$data = array('outbound' => array_values($arrInsertFlightDataNew__), 'inbound' => $RoundTripinbound, 'travelDates' => $travelDates, 'travelDatesReturn' => $travelDatesReturn, 'ReturnDateArr' => $ReturnDateArr, 'DepartDateArr' => $DepartDateArr, 'source' => $source, 'destination' => $destination, 'source_city' => $source_city, 'destination_city' => $destination_city, 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute, 'CurrencyTitle' => $this->CurrencyTitle, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'MinriceRange' => (ceil($MinriceRange)), 'MaxriceRange' => (ceil($MaxriceRange) + 1));
					// 	echo json_encode($data);
					// 	exit;
					// }
					// $data = array('outbound' => [], 'inbound' => [], 'travelDates' => $travelDates, 'travelDatesReturn' => $travelDatesReturn, 'source' => $source, 'destination' => $destination, 'source_city' => $source_city, 'destination_city' => $destination_city, 'route' => $strFlightRoute, 'interNationalSearch' => $interNationalSearch, 'arrAirlineName' => [], 'FiltStopCount' => [], 'ArrPriceUnique' => [], 'CurrencyTitle' => $this->CurrencyTitle, 'MinriceRange' => 0, 'MaxriceRange' => 0);
					// echo json_encode($data);
					// exit;
				}

				// else{
				// 	$data = array('outbound' => [], 'inbound' => [], 'travelDates' => $travelDates, 'travelDatesReturn' => $travelDatesReturn, 'source' => $source, 'destination' => $destination, 'source_city' => $source_city, 'destination_city' => $destination_city, 'route' => $strFlightRoute, 'interNationalSearch' => $interNationalSearch, 'arrAirlineName' => [], 'FiltStopCount' => [], 'ArrPriceUnique' => [], 'CurrencyTitle' => $this->CurrencyTitle, 'MinriceRange' => 0, 'MaxriceRange' => 0);
				// 	echo json_encode($data);
				// 	exit;
				// }
		}
		if ($this->IsSeriesFare && ($strFlightRoute == '1' || $strFlightRoute == '2') && ($IsSeriesFareAllow == 1)) {

			// echo "seriesfare";die;exit;
			$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsSeriesFare($sessionFlightSearchParams->params, '');
			// if ($this->gtxagencysysid == '2656') {
			// 	echo "<pre>";
			// 	print_r($apiResponse);
			// 	die;
			// }
			$FlightDataSeriesFare = $this->FlightDataSeriesFare($apiResponse, $sessionFlightSearchParams->params, $strFlightRoute, $AdditionalMarkup);
		}
		if ($ApiRoundTrip == 3 && $interNationalSearch == '' && $strFlightRoute == 2) {
			if ($this->IsTBOFlightAPI) {
				$apiResponseTBO = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsTBO($sessionFlightSearchParams->params);
			}
		} elseif ($ApiRoundTrip == 7 && $interNationalSearch == '' && $strFlightRoute == 2) {
			$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlights($sessionFlightSearchParams->params);
		} else {
			if ($this->IsTBOFlightAPI) { // && $strFlightRoute != 3
				$apiResponseTBO = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsTBO($sessionFlightSearchParams->params);
			}
			if ($this->IsTJFlightAPI == 1) {
				$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlights($sessionFlightSearchParams->params);
			}
		}

		$MergeRequest = (array_merge($apiResponse, $apiResponseTBO));

		
		// $CurrentDateTime = date('Y-m-d-H-i-s');
		// $strFilePath = "flight/Time/" . $SearchFlightTraceId . "/request_tj.json";
		// Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $CurrentDateTime);

		$multiRequest = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->multiRequest($MergeRequest);
		// if ($this->gtxagencysysid == '5310') {
		// 	echo "<pre>";
		// 	print_r($MergeRequest);
		// 	echo "<pre>";
		// 	print_r($multiRequest);
		// 	die;
		// }
		// $CurrentDateTime = date('Y-m-d-H-i-s');
		// $strFilePath = "flight/Time/" . $SearchFlightTraceId . "/response_multicurl.json";
		// Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $CurrentDateTime);


		// $FlightSearchResults = new Zend_Session_Namespace('FlightSearchResults');
		// $multiRequest = $FlightSearchResults->params;

		$apiResponse = (isset($multiRequest['TPJ']) && !empty($multiRequest['TPJ'])) ? $multiRequest['TPJ'] : [];
		$apiResponseTBO = (isset($multiRequest['TBO']) && !empty($multiRequest['TBO'])) ? $multiRequest['TBO'] : [];

		if ($strFlightRoute != 3) {
			$filterData = ['ApiSourceSysId' => 1];
			$AdditionalMarkup = $this->getMarketPlace($filterData, $MarketPlaceSysId);
			$FlightDataTBO = $this->FlightDataTBO($apiResponseTBO, $AdditionalMarkup, $getMarkup);
		}

		if ($strFlightRoute == 3 && $this->IsTBOFlightAPI == 1 && $this->apimulticity == 3) {
			$filterData = ['ApiSourceSysId' => 1];
			$AdditionalMarkup = $this->getMarketPlace($filterData, $MarketPlaceSysId);
			$this->FlightDataMultiCityTbo($apiResponseTBO, $sessionFlightSearchParams->params, $getMarkup, $AdditionalMarkup);
		} elseif ($strFlightRoute == 3 && $this->IsTJFlightAPI == 1) {
			$filterData = ['ApiSourceSysId' => 3];
			$AdditionalMarkup = $this->getMarketPlace($filterData, $MarketPlaceSysId);
			$this->FlightDataMultiCity($apiResponse, $sessionFlightSearchParams->params, $getMarkup, $AdditionalMarkup);
		}

		$arrInsertFlightData = [];
		$arrAirlineName = [];
		$FiltStopCount = [];
		$FiltPriceRange = [];
		$AttPriceRange = [];
		$dddddddd = [];
		$keysIndexes = [];
		$arrInsertFlightDataNew = [];

		$localFromDateTime = date("Y-m-d h:i", strtotime($strDepatureDate));
		$localToDateTime = date("Y-m-d h:i", strtotime($strReturnDate));
		if (isset($apiResponse['ResponseStatus']) && !empty($apiResponse['ResponseStatus'])) {
			$intResponseStatus = $apiResponse['ResponseStatus'];
		} elseif (isset($apiResponseTBO['ResponseStatus']) && !empty($apiResponseTBO['ResponseStatus'])) {
			$intResponseStatus = $apiResponseTBO['ResponseStatus'];
		}

		//$intResponseStatus = (isset($apiResponse['ResponseStatus']) && !empty($apiResponse['ResponseStatus'])) ? $apiResponse['ResponseStatus'] : iseet($apiResponseTBO['ResponseStatus'])?$apiResponseTBO['ResponseStatus']:0;

		//
		$ONWARD = $apiResponse['OutBoundFlightResults'];
		// echo json_encode($apiResponse);die;
		if ($intResponseStatus == 1) {
			$filterData = ['ApiSourceSysId' => 3];
			$AdditionalMarkup = $this->getMarketPlace($filterData, $MarketPlaceSysId);
			if ($ONWARD) {
				foreach ($ONWARD as $key => $result) {

					//
					$SegmentInformation = $result['sI'];
					$totalPriceList = current($result['totalPriceList']);
					$IsRefundable = isset($totalPriceList['fd']['ADULT']['rT']) ? $totalPriceList['fd']['ADULT']['rT'] : 0;
					$NoOfSeatAvailable = $totalPriceList['fd']['ADULT']['sR'];
					$strFareClass = $totalPriceList['fd']['ADULT']['cB']; //Cabin Baggage
					$IsMealIncludes = isset($totalPriceList['fd']['ADULT']['mI']) ? $totalPriceList['fd']['ADULT']['mI'] : false;
					// if ($this->gtxagencysysid == '69705') {
					// 	echo '<pre>';print_r($totalPriceList);

					// }
					$bagInfo = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Check In Baggage
					$cabinbagInfo = $totalPriceList['fd']['ADULT']['bI']['cB']; ///Cabin Baggage
					$strTraceId = $totalPriceList['id'];
					$ResultIndex = $totalPriceList['id'];
					if (!empty($bagInfo)) {
						$IsBagIncludes = true;
					} else {
						$IsBagIncludes = false;
					}
					if (!empty($cabinbagInfo)) {
						$IscabinbagIncludes = true;
					} else {
						$IscabinbagIncludes = false;
					}


					if ($IsRefundable == 0) {
						$IsRefundableTxt = 'Non Refundable';
					} elseif ($IsRefundable == 1) {
						$IsRefundableTxt = 'Refundable';
					} else {
						$IsRefundableTxt = 'Partial Refundable';
					}
					$OriginSegments = current($SegmentInformation);
					$DestinationSegments = end($SegmentInformation);

					// echo '<pre>';print_r($DestinationSegments);echo '</pre>';
					$arrSegments = [];
					$FlyingMinutes = 0;
					$TotalLAYOVERMinutes = 0;
					$LAYOVERCityArr = [];
					$PublishedFare = 0;
					$PublishedFareReverse = 0;
					$BaseFare = 0;
					$Tax = 0;
					$YQTax = 0;
					$OtherCharges = 0;
					$ServiceFee = 0;
					$FareBreakdown = [];
					$FairRulesArr = [];
					$intYQTaxToT = 0;
					$intTotalOfferedForAllPax = 0;
					$intBaseFareAllPax = 0;
					$intTaxAllPax = 0;


					$col = array_column($FairRulesArr, "PublishedFare");
					array_multisort($col, SORT_ASC, $FairRulesArr);
					// echo '<pre>';print_r($FairRulesArr);
					$TotalLAYOVERMinutes = 0;
					$SegFlightNumberArr = [];
					if ($SegmentInformation) {
						foreach ($SegmentInformation as $segments) {
							// echo '<pre>';print_r($segments);die;
							$segmentid_ = $segments['id'];
							$duration = $segments['duration'];
							$LAYOVERMinutes = $GroundTime = isset($segments['cT']) ? $segments['cT'] : 0;
							$LAYOVERCity = $LAYOVERCityArr[] = isset($segments['cT']) ? $segments['aa']['city'] : '';
							$FlyingMinutes += ($duration + $LAYOVERMinutes);
							$TotalLAYOVERMinutes += $LAYOVERMinutes;

							$FareClass = $totalPriceList['fd']['ADULT']['cB'];
							$strBaggage = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Checking Baggage
							$strCabinBaggage = $totalPriceList['fd']['ADULT']['bI']['cB']; ////Cabin Baggage

							if (!empty($strCabinBaggage)) {
								$IsCabinBaggage = true;
							} else {
								$IsCabinBaggage = false;
							}

							if (!empty($strCabinBaggage)) {
								$IsBaggage = true;
							} else {
								$IsBaggage = false;
							}

							$AirlineCode = $segments['fD']['aI']['code'];
							$AirlineName = $segments['fD']['aI']['name'];
							$FlightNumber = $segments['fD']['fN'];
							$SegFlightNumber = $AirlineCode . "-" . $FlightNumber;

							$originAirportName = $segments['da']['name'];
							$originAirportCode = $segments['da']['code'];
							$originCityName = $segments['da']['city'];
							$originCountryName = $segments['da']['country'];
							$originDepTime = $segments['dt'];

							$destinationAirportName = $segments['aa']['name'];
							$destinationAirportCode = $segments['aa']['code'];
							$destinationCityName = $segments['aa']['city'];
							$destinationCountryName = $segments['aa']['country'];
							$destinationArrTime = $segments['at'];

							$DepTerminal = isset($segments['da']['terminal']) ? $segments['da']['terminal'] : '';
							$ArrTerminal = isset($segments['aa']['terminal']) ? $segments['aa']['terminal'] : '';

							$filePath = $this->getflightlogo($AirlineCode);

							$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->MinutesToHours($LAYOVERMinutes);

							$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($destinationArrTime);
							$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($originDepTime);
							$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($duration);
							$arrSegments[] = array(
								"segmentid" => $segmentid_,
								"originAirportName" => $originAirportName,
								"destinationAirportName" => $destinationAirportName,
								"originCityName" => $originCityName,
								"originCountryName" => $originCountryName,
								"destinationCityName" => $destinationCityName,
								"destinationCountryName" => $destinationCountryName,
								"destinationAirportCode" => $destinationAirportCode,
								"destinationAirportCode" => $destinationAirportCode,
								"destinationArrTime" => $destinationArrTime,
								"SegFlightNumber" => $SegFlightNumber,
								"AirlineCode" => $AirlineCode,
								"AirlineName" => $AirlineName,
								"FareClass" => $FareClass,
								"originAirportCode" => $originAirportCode,
								"originDepTime" => $originDepTime,
								"TripIndicator" => '', //$TripIndicator,
								"Baggage" => $strBaggage,
								"IsBaggage" => $IsBaggage,
								"IsCabinBaggage" => $IsCabinBaggage,
								"CabinBaggage" => $strCabinBaggage,
								"IsMealIncludes" => $IsMealIncludes,
								"Duration" => $duration,
								"GroundTime" => $GroundTime,
								"NoOfSeatAvailable" => $NoOfSeatAvailable,
								"strDepartureDtTime" => $strDepartureDtTime,
								"strArrivalDtTime" => $strArrivalDtTime,
								"FlightDuration" => $strDuration,
								"LAYOVERDuration" => $LAYOVERDuration,
								"LAYOVERCity" => $LAYOVERCity,
								"DepTerminal" => $DepTerminal,
								"ArrTerminal" => $ArrTerminal,
								"filePath" => $filePath,
							);
							$SegFlightNumberArr[] = $SegFlightNumber;
							$segmentSector[$segmentid_] = ['origin' => $originAirportCode, 'destination' => $destinationAirportCode];
							//echo '<pre>';print_r($arrSegments);
						}
					}
					$AirlineCode = $OriginSegments['fD']['aI']['code'];
					$array_searcher = $this->array_searcher($AdditionalMarkup, $result['totalPriceList']);
					array_multisort($array_searcher);
					$tripbaggageinfo = [];
					if ($array_searcher) {
						foreach ($array_searcher as $kp => $price) {
							if (!empty($price)) {
								if ($price['tai']['tbi']) {
									foreach ($price['tai']['tbi'] as $keyss => $tbi) {
										$segc = isset($segmentSector[$keyss]) ? $segmentSector[$keyss] : '';
										$sectorKey = $segc['origin'] . '-' . $segc['destination'];
										if ($tbi) {
											foreach ($tbi as $kgk => $pbi) {
												if ($pbi) {
													foreach ($pbi as $gk => $vll) {
														$tripbaggageinfo[$sectorKey][$gk] = ['cabin' => isset($vll['cB']) ? $vll['cB'] : 'NA', 'checkin' => isset($vll['iB']) ? $vll['iB'] : 'NA'];
													}
												}
											}
										}
									}
								}
								$fareDetail = $price['fd'];

								$Refundable = isset($fareDetail['ADULT']['rT']) ? $fareDetail['ADULT']['rT'] : 0;
								$PriceID = $price['id'];
								$fareIdentifier = $price['fareIdentifier'];
								$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];

								$fareremarks = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['remarks']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['remarks'] : '';
								$fareIdentifier = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'] : '';
								$colors = !empty($AddMarkup['color']) ? $AddMarkup['color'] : '#000000';
								$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']) ? $AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'] : 0;
								$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);

								if (empty($fareIdentifier)) {
									$fareIdentifier = $price['fareIdentifier'];
								}
								$IsMealIncludes = isset($fareDetail['ADULT']['mI']) ? $fareDetail['ADULT']['mI'] : false;
								$strBaggage = $price['fd']['ADULT']['bI']['iB']; ///Checking Baggage
								$strCabinBaggage = $price['fd']['ADULT']['bI']['cB']; ////Cabin Baggage

								if (!empty($strCabinBaggage)) {
									$IsCabinBaggage = true;
								} else {
									$IsCabinBaggage = false;
								}

								if (!empty($strCabinBaggage)) {
									$IsBaggage = true;
								} else {
									$IsBaggage = false;
								}

								if ($price['fareIdentifier'] == 'SME') {
									$IsGSTRequired = true;
								} else {
									$IsGSTRequired = false;
								}
								if ($fareIdentifier == 'TACTICAL' || $fareIdentifier == 'COUPON') {
									$fareIdentifier = 'PROMO';
								}
								if ($Refundable == 0) {
									$IsRefundableTxt = 'Non Refundable';
								} elseif ($Refundable == 1) {
									$IsRefundableTxt = 'Refundable';
								} else {
									$IsRefundableTxt = 'Partial Refundable';
								}
								$ADULT = $fareDetail['ADULT']['fC']; //fare Components
								$CHILD = isset($fareDetail['CHILD']['fC']) ? $fareDetail['CHILD']['fC'] : []; //fare Components
								$INFANT = isset($fareDetail['INFANT']['fC']) ? $fareDetail['INFANT']['fC'] : []; //fare Components
								if (!empty($ADULT)) {
									$PaxTypeCount = 1;
								}
								if (!empty($CHILD)) {
									$PaxTypeCount = 2;
								}
								if (!empty($INFANT)) {
									$PaxTypeCount = 3;
								}
								$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
								$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
								$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents

								$ADULTNCMTDS = isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
								$CHILDNCMTDS = isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
								$INFANTNCMTDS = isset($fareDetail['INFANT']['afC']['NCM']['TDS']) ? $fareDetail['INFANT']['afC']['NCM']['TDS'] : 0; //TDS

								$ADULTNCMTOT = isset($fareDetail['ADULT']['afC']['NCM']['OT']) ? $fareDetail['ADULT']['afC']['NCM']['OT'] : 0; //- Gross Commission
								$CHILDNCMTOT = isset($fareDetail['CHILD']['afC']['NCM']['OT']) ? $fareDetail['CHILD']['afC']['NCM']['OT'] : 0; //- Gross Commission
								$INFANTNCMTOT = isset($fareDetail['INFANT']['afC']['NCM']['OT']) ? $fareDetail['INFANT']['afC']['NCM']['OT'] : 0; //- Gross Commission

								$AD_MF = isset($ADULTafC['MF']) ? $ADULTafC['MF'] : 0; //Management Fee
								$AD_YQ = isset($ADULTafC['YQ']) ? $ADULTafC['YQ'] : 0; //Fuel Surcharge
								$AD_AGST = isset($ADULTafC['AGST']) ? $ADULTafC['AGST'] : 0; //Airline GST Component
								$AD_MFT = isset($ADULTafC['MFT']) ? $ADULTafC['MFT'] : 0; //Management Fee Tax
								$AD_OT = isset($ADULTafC['OT']) ? $ADULTafC['OT'] : 0; //Other Charges
								$AD_MU = isset($ADULTafC['MU']) ? $ADULTafC['MU'] : 0; //markup
								$AD_YR = isset($ADULTafC['YR']) ? $ADULTafC['YR'] : 0; //Carrier Misc Fee

								$CH_MF = isset($CHILDafC['MF']) ? $CHILDafC['MF'] : 0; //Management Fee
								$CH_YQ = isset($CHILDafC['YQ']) ? $CHILDafC['YQ'] : 0; //Fuel Surcharge
								$CH_AGST = isset($CHILDafC['AGST']) ? $CHILDafC['AGST'] : 0; //Airline GST Component
								$CH_MFT = isset($CHILDafC['MFT']) ? $CHILDafC['MFT'] : 0; //Management Fee Tax
								$CH_OT = isset($CHILDafC['OT']) ? $CHILDafC['OT'] : 0; //Other Charges
								$CH_MU = isset($CHILDafC['MU']) ? $CHILDafC['MU'] : 0; //markup
								$CH_YR = isset($CHILDafC['YR']) ? $CHILDafC['YR'] : 0; //Carrier Misc Fee

								$IN_MF = isset($INFANTafC['MF']) ? $INFANTafC['MF'] : 0; //Management Fee
								$IN_YQ = isset($INFANTafC['YQ']) ? $INFANTafC['YQ'] : 0; //Fuel Surcharge
								$IN_AGST = isset($INFANTafC['AGST']) ? $INFANTafC['AGST'] : 0; //Airline GST Component
								$IN_MFT = isset($INFANTafC['MFT']) ? $INFANTafC['MFT'] : 0; //Management Fee Tax
								$IN_OT = isset($INFANTafC['OT']) ? $INFANTafC['OT'] : 0; //Other Charges
								$IN_MU = isset($INFANTafC['MU']) ? $INFANTafC['MU'] : 0; //markup
								$IN_YR = isset($INFANTafC['YR']) ? $INFANTafC['YR'] : 0; //Carrier Misc Fee

								if ($kp == 0) {
									$PublishedFare += (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
									$BaseFare += (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
									$Tax += (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
								}

								$PublishedFareIN = (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
								$BaseFareIN = (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
								$TaxIN = (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
								$NetFare = (($ADULT['NF'] * $adultCount) + ($CHILD['NF'] * $childCount) + ($INFANT['NF'] * $infantCount)); //Taxes and Fees
								$NetCommission = (($ADULT['NCM'] * $adultCount) + ($CHILD['NCM'] * $childCount) + ($INFANT['NCM'] * $infantCount)); //Taxes and Fees
								//echo '<pre>';print_r(($ADULTafC));echo '</pre>';
								$YQTax = (($AD_YQ * $adultCount) + ($CH_YQ * $childCount) + ($IN_YQ * $infantCount));
								$OtherCharges = (($AD_OT * $adultCount) + ($CH_OT * $childCount) + ($IN_OT * $infantCount));
								$ServiceFee = (($AD_MF * $adultCount) + ($CH_MF * $childCount) + ($IN_MF * $infantCount));
								$ManagementFeeTax = (($AD_MFT * $adultCount) + ($CH_MFT * $childCount) + ($IN_MFT * $infantCount));
								$AirlineGSTComponent = (($AD_AGST * $adultCount) + ($CH_AGST * $childCount) + ($IN_AGST * $infantCount));
								$CarrierMiscFee = (($AD_YR * $adultCount) + ($CH_YR * $childCount) + ($IN_YR * $infantCount));
								$MUFee = (($AD_MU * $adultCount) + ($CH_MU * $childCount) + ($IN_MU * $infantCount));
								$TdsOnPLB = (($ADULTNCMTDS * $adultCount) + ($CHILDNCMTDS * $childCount) + ($INFANTNCMTDS * $infantCount));
								//$NetCommission = (($ADULTNCMTOT * $adultCount) + ($CHILDNCMTOT * $childCount) + ($INFANTNCMTOT * $infantCount));

								//$PublishedFareIN = $NetFare;
								$PublishedFare = $PublishedFareIN;
								$CommissionEarned = $NetCommission;
								$PLBEarned = 0; //$result['Fare']['PLBEarned'];
								$IncentiveEarned = 0; //$result['Fare']['IncentiveEarned'];
								$OfferedFare = $PublishedFareIN;
								$markUpArr = array(
									'getMarkup' => $getMarkup,
									'PublishedFare' => $PublishedFare,
									'OfferedFare' => $NetFare,
									'intCommissionEarned' => $CommissionEarned,
									'TdsOnPLB' => $TdsOnPLB,
									'MUFee' => $MUFee,
									'intPLBEarned' => $PLBEarned,
									'intIncentiveEarned' => $IncentiveEarned,
									'intMemberCount' => $intMemberCount,
									'intFlightRoute' => $strFlightRoute,
									'interNationalSearch' => $interNationalSearch,
									'AddMarkup' => $AddMarkup,
								);
								
								$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr);
								if ($kp == 0) {
									$PublishedFareReverse += ($arrMarkUps['PublishFare']);
								}
								$markUpArrBR = array(
									'getMarkup' => $getMarkup,
									'PublishedFare' => ($ADULT['TF'] * $adultCount),
									'OfferedFare' => ($ADULT['NF'] * $adultCount),
									'intCommissionEarned' => ($ADULT['NCM'] * $adultCount),
									'TdsOnPLB' => ($ADULTNCMTDS * $adultCount),
									'MUFee' => ($AD_MU * $adultCount),
									'intPLBEarned' => $PLBEarned,
									'intIncentiveEarned' => $IncentiveEarned,
									'intMemberCount' => $adultCount,
									'intFlightRoute' => $strFlightRoute,
									'interNationalSearch' => $interNationalSearch,
									'AddMarkup' => $AddMarkup,
								);
								$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);

								$FareBreakdown[0]['Currency'] = $this->CurrencyTitle;
								$FareBreakdown[0]['PassengerType'] = 1;
								$FareBreakdown[0]['PassengerCount'] = $adultCount;
								$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $adultCount);
								$FareBreakdown[0]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
								$FareBreakdown[0]['BaseFare'] = ($ADULT['BF'] * $adultCount);
								$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $adultCount);
								$FareBreakdown[0]['TDS'] = ($ADULTNCMTDS * $adultCount);
								$FareBreakdown[0]['MF'] = ($AD_MF * $adultCount);
								$FareBreakdown[0]['YQ'] = ($AD_YQ * $adultCount);
								$FareBreakdown[0]['AGST'] = ($AD_AGST * $adultCount);
								$FareBreakdown[0]['MFT'] = ($AD_MFT * $adultCount);
								$FareBreakdown[0]['OT'] = ($AD_OT * $adultCount);
								$FareBreakdown[0]['MU'] = ($AD_MU * $adultCount);
								$FareBreakdown[0]['YR'] = ($AD_YR * $adultCount);
								$FareBreakdown[0]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
								$FareBreakdown[0]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
								$FareBreakdown[0]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
								$FareBreakdown[0]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
								$FareBreakdown[0]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
								$FareBreakdown[0]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
								$FareBreakdown[0]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
								$FareBreakdown[0]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
								$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
								$FareBreakdown[0]['GSTonComm'] = 0;
								$FareBreakdown[0]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
								$FareBreakdown[0]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
								$FareBreakdown[0]['AdditionalTxnFeeOfrd'] = 0;
								$FareBreakdown[0]['AdditionalTxnFeePub'] = 0;
								$FareBreakdown[0]['PGCharge'] = 0;
								$FareBreakdown[0]['Baggage'] = isset($fareDetail['ADULT']['bI']['iB']) ? $fareDetail['ADULT']['bI']['iB'] : []; //Check In Baggage;
								$FareBreakdown[0]['CabinBaggage'] = isset($fareDetail['ADULT']['bI']['cB']) ? $fareDetail['ADULT']['bI']['cB'] : []; //Cabin Baggage ;
								if (isset($fareDetail['CHILD'])) {
									$markUpArrBR = array(
										'getMarkup' => $getMarkup,
										'PublishedFare' => ($CHILD['TF'] * $childCount),
										'OfferedFare' => ($CHILD['NF'] * $childCount),
										'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
										'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
										'MUFee' => ($CH_MU * $childCount),
										'intPLBEarned' => $PLBEarned,
										'intIncentiveEarned' => $IncentiveEarned,
										'intMemberCount' => $childCount,
										'intFlightRoute' => $strFlightRoute,
										'interNationalSearch' => $interNationalSearch,
										'AddMarkup' => $AddMarkup,
									);
									$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
									$FareBreakdown[1]['Currency'] = $this->CurrencyTitle;
									$FareBreakdown[1]['PassengerType'] = 2;
									$FareBreakdown[1]['PassengerCount'] = $childCount;
									$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
									$FareBreakdown[1]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
									$FareBreakdown[1]['BaseFare'] = ($CHILD['BF'] * $childCount);
									$FareBreakdown[1]['CommissionEarned'] = ($CHILD['NCM'] * $childCount);
									$FareBreakdown[1]['TDS'] = ($CHILDNCMTDS * $childCount);
									$FareBreakdown[1]['MF'] = ($CH_MF * $childCount);
									$FareBreakdown[1]['YQ'] = ($CH_YQ * $childCount);
									$FareBreakdown[1]['AGST'] = ($CH_AGST * $childCount);
									$FareBreakdown[1]['MFT'] = ($CH_MFT * $childCount);
									$FareBreakdown[1]['OT'] = ($CH_OT * $childCount);
									$FareBreakdown[1]['MU'] = ($CH_MU * $childCount);
									$FareBreakdown[1]['YR'] = ($CH_YR * $childCount);
									$FareBreakdown[1]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
									$FareBreakdown[1]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
									$FareBreakdown[1]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
									$FareBreakdown[1]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
									$FareBreakdown[1]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
									$FareBreakdown[1]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
									$FareBreakdown[1]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
									$FareBreakdown[1]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
									$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
									$FareBreakdown[1]['GSTonComm'] = 0;
									$FareBreakdown[1]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
									$FareBreakdown[1]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
									$FareBreakdown[1]['AdditionalTxnFeeOfrd'] = 0;
									$FareBreakdown[1]['AdditionalTxnFeePub'] = 0;
									$FareBreakdown[1]['PGCharge'] = 0;
									$FareBreakdown[1]['Baggage'] = isset($fareDetail['CHILD']['bI']['iB']) ? $fareDetail['CHILD']['bI']['iB'] : []; //Check In Baggage;
									$FareBreakdown[1]['CabinBaggage'] = isset($fareDetail['CHILD']['bI']['cB']) ? $fareDetail['CHILD']['bI']['cB'] : []; //Cabin Baggage ;
								}
								if (isset($fareDetail['INFANT'])) {
									$markUpArrBR = array(
										'getMarkup' => $getMarkup,
										'PublishedFare' => ($INFANT['TF'] * $infantCount),
										'OfferedFare' => ($INFANT['NF'] * $infantCount),
										'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
										'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
										'MUFee' => ($IN_MU * $infantCount),
										'intPLBEarned' => $PLBEarned,
										'intIncentiveEarned' => $IncentiveEarned,
										'intMemberCount' => $infantCount,
										'intFlightRoute' => $strFlightRoute,
										'interNationalSearch' => $interNationalSearch,
										'AddMarkup' => $AddMarkup,
									);
									$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
									$FareBreakdown[2]['Currency'] = $this->CurrencyTitle;
									$FareBreakdown[2]['PassengerType'] = 3;
									$FareBreakdown[2]['PassengerCount'] = $infantCount;
									$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
									$FareBreakdown[2]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
									$FareBreakdown[2]['BaseFare'] = ($INFANT['BF'] * $infantCount);
									$FareBreakdown[2]['CommissionEarned'] = ($INFANT['NCM'] * $infantCount);
									$FareBreakdown[2]['TDS'] = ($INFANTNCMTDS * $infantCount);
									$FareBreakdown[2]['MF'] = ($IN_MF * $infantCount);
									$FareBreakdown[2]['YQ'] = ($IN_YQ * $infantCount);
									$FareBreakdown[2]['AGST'] = ($IN_AGST * $infantCount);
									$FareBreakdown[2]['OT'] = ($IN_OT * $infantCount);
									$FareBreakdown[2]['MFT'] = ($IN_MFT * $infantCount);
									$FareBreakdown[2]['MU'] = ($IN_MU * $infantCount);
									$FareBreakdown[2]['YR'] = ($IN_YR * $infantCount);
									$FareBreakdown[2]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
									$FareBreakdown[2]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
									$FareBreakdown[2]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
									$FareBreakdown[2]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
									$FareBreakdown[2]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
									$FareBreakdown[2]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
									$FareBreakdown[2]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
									$FareBreakdown[2]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
									$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
									$FareBreakdown[2]['GSTonComm'] = 0;
									$FareBreakdown[2]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
									$FareBreakdown[2]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
									$FareBreakdown[2]['AdditionalTxnFeeOfrd'] = 0;
									$FareBreakdown[2]['AdditionalTxnFeePub'] = 0;
									$FareBreakdown[2]['PGCharge'] = 0;
									$FareBreakdown[2]['Baggage'] = isset($fareDetail['INFANT']['bI']['iB']) ? $fareDetail['INFANT']['bI']['iB'] : []; //Check In Baggage;
									$FareBreakdown[2]['CabinBaggage'] = isset($fareDetail['INFANT']['bI']['cB']) ? $fareDetail['INFANT']['bI']['cB'] : []; //Cabin Baggage ;
								}
								//echo '<pre>';print_r($price);
								$FairRulesArr[$kp] = array(
									"Currency" => $this->CurrencyTitle, //$Currency,
									"CurrencyRate" => $this->CurrencyRate, //$Currency,
									"currencySysId" => $this->CurrencyId,
									"BaseFare" => $BaseFareIN,
									"Tax" => $TaxIN,
									"YQTax" => $YQTax,
									"OtherCharges" => $OtherCharges,
									"Discount" => 0, //$Discount,
									"ServiceFee" => $ServiceFee,
									"ManagementFeeTax" => $ManagementFeeTax,
									"AirlineGSTComponent" => $AirlineGSTComponent,
									"CarrierMiscFee" => $CarrierMiscFee,
									"MUFee" => $MUFee,
									"intPublishedFare" => $PublishedFareIN,
									"PublishedFare" => ceil($arrMarkUps['PublishFare'] * $this->CurrencyRate),
									"PublishedFarePerPax" => ceil((($arrMarkUps['PublishFare'] * $this->CurrencyRate) / $intMemberCount)),
									"OfferedFare" => $arrMarkUps['intOfferedFare'],
									"CommissionEarned" => $CommissionEarned,
									"PLBEarned" => $PLBEarned,
									"IncentiveEarned" => $IncentiveEarned,
									"TdsOnPLB" => $TdsOnPLB,
									"TdsOnIncentive" => 0,
									"AdditionalTxnFeeOfrd" => 0,
									"AdditionalTxnFeePub" => 0,
									"Refundable" => $Refundable,
									"IsRefundableTxt" => $IsRefundableTxt,
									"PriceID" => $PriceID,
									"IsGSTRequired" => $IsGSTRequired,
									"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
									"colors" => $colors,
									"fareremarks" => $fareremarks,
									"FareClass" => ucfirst(strtolower($fareDetail['ADULT']['cc'])),
									"CommisionPass" => $arrMarkUps['CommisionPass'],
									"intTotalGST" => $arrMarkUps['intTotalGST'],
									"apiMarkup" => $arrMarkUps['apiMarkup'],
									"IntCommission" => $arrMarkUps['IntCommission'],
									"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
									"NoOfSeatAvailable" => $fareDetail['ADULT']['sR'],
									"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
									"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
									"CommEarned" => $arrMarkUps['IntCommission'], //$arrMarkUps['intCommisionEarnedForAgency'],
									"GSTonComm" => 0,
									"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
									"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
									"AddiMarkup" => $arrMarkUps['AddiMarkup'],
									"AddiTaxOnMarkup" => $arrMarkUps['AddiTaxOnMarkup'],
									"IsBaggage" => $IsBaggage,
									"IsCabinBaggage" => $IsCabinBaggage,
									"Baggage" => $strBaggage,
									"CabinBaggage" => $strCabinBaggage,
									"tripbinfo" => $tripbaggageinfo,
									"IsMealIncludes" => $IsMealIncludes,

									// "FixedMarkUp" => $intAgencyFixMarkUp,
									// "GSTOnMarkUp" => $intSTaxOnAgencyFixMarkUp,
									// "CommEarned" => $intCommisionEarnedForAgency,
									// "GSTonComm" => $intGSTOnAgencyCommisionEarned,
									// "intGTXMarkUp" => $intGTXMarkUp,
									// "GTXMarkUpGST" => $intSTaxOnGTXMarkUp,
									"FareBreakdown" => $FareBreakdown,
									// "arrMarkUps" => $arrMarkUps,
									"TaxSettingDetail" => $arrMarkUps['TaxSettingDetail'],
								);
							}
						}
					}

					$col = array_column($FairRulesArr, "PublishedFare");
					array_multisort($col, SORT_ASC, $FairRulesArr);
					$LAYOVERTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($TotalLAYOVERMinutes);

					$AirlineCode = $OriginSegments['fD']['aI']['code'];
					$FlightNumber = $OriginSegments['fD']['fN'];
					$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
					$strAirlineName = $OriginSegments['fD']['aI']['name'];
					$IsLCC = $OriginSegments['fD']['aI']['isLcc'];
					$strSourceAirportCode = $OriginSegments['da']['code'];
					$strDestinationAirportCode = $DestinationSegments['aa']['code'];

					$Stops = $DestinationSegments['sN'];
					if ($Stops == 0) {
						$StopCountTxt = "Non-stop";
					} else {
						$StopCountTxt = $Stops . " Stop(s)";
					}
					$filePath = $this->getflightlogo($AirlineCode);
					$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
					$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($DestinationSegments['at']);
					$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($OriginSegments['dt']);
					$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
					$newKey = str_replace('T', ' ', $OriginSegments['dt']) . '' . str_replace('T', ' ', $DestinationSegments['at']) . '' . $strFlightNumber;
					if ($FairRulesArr) {
						$arrInsertFlightData[$key]['FlightNumber'] = $strFlightNumber;
						$arrInsertFlightData[$key]['keyIndex'] = $key;
						if (count($SegFlightNumberArr) > 1) {
							$arrInsertFlightData[$key]['SegFlightNumberArr'] = $strFlightNumber . ' +' . (count($SegFlightNumberArr) - 1);
						} else {
							$arrInsertFlightData[$key]['SegFlightNumberArr'] = $strFlightNumber;
						}

						$arrInsertFlightData[$key]['AirlineName'] = ucfirst(strtolower($strAirlineName));
						$arrInsertFlightData[$key]['AirlineCode'] = $AirlineCode;
						$arrInsertFlightData[$key]['AirInvenSysId'] = 0;
						$arrInsertFlightData[$key]['IsLCC'] = $IsLCC;
						$arrInsertFlightData[$key]['IsMealIncludes'] = $IsMealIncludes;
						$arrInsertFlightData[$key]['IsBagIncludes'] = $IsBagIncludes;
						$arrInsertFlightData[$key]['IsCabinBagIncludes'] = $IscabinbagIncludes;
						$arrInsertFlightData[$key]['IsRefundable'] = $IsRefundable;
						$arrInsertFlightData[$key]['IsRefundableTxt'] = $IsRefundableTxt;
						$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
						$arrInsertFlightData[$key]['AirlineSysId'] = $airlineSysId;
						$arrInsertFlightData[$key]['DepartureTime'] = $strDepartureDtTime;
						$arrInsertFlightData[$key]['ArrivalTime'] = $strArrivalDtTime;
						$arrInsertFlightData[$key]['TravelDate'] = $OriginSegments['dt'];
						$arrInsertFlightData[$key]['LocalFromTime'] = str_replace('T', ' ', $OriginSegments['dt']);
						$arrInsertFlightData[$key]['FromUTCTime'] = $OriginSegments['dt'];
						$arrInsertFlightData[$key]['LocalToTime'] = str_replace('T', ' ', $DestinationSegments['at']);
						$arrInsertFlightData[$key]['ToUTCTime'] = $DestinationSegments['at'];
						$arrInsertFlightData[$key]['IsDirect'] = 0;
						$arrInsertFlightData[$key]['FareClass'] = $strFareClass;
						$arrInsertFlightData[$key]['LAYOVERCity'] = isset($LAYOVERCityArr[0]) ? $LAYOVERCityArr[0] : '';
						$arrInsertFlightData[$key]['GroundTime'] = $TotalLAYOVERMinutes;
						$arrInsertFlightData[$key]['LAYOVERDuration'] = $LAYOVERTime;
						$arrInsertFlightData[$key]['FlyingMinutes'] = $FlyingMinutes;
						$arrInsertFlightData[$key]['DepartureDateTxt'] = date('D, d M', strtotime($OriginSegments['dt']));
						$arrInsertFlightData[$key]['ArrivalDateTxt'] = date('D, d M', strtotime($DestinationSegments['at']));
						$arrInsertFlightData[$key]['FlightDuration'] = $FlightDuration;
						$arrInsertFlightData[$key]['SourcePlaceSysId'] = $intSourceCityId;
						$arrInsertFlightData[$key]['DestPlaceSysId'] = $intDestinationCityId;
						$arrInsertFlightData[$key]['SourceAirportCode'] = $strSourceAirportCode;
						$arrInsertFlightData[$key]['DestAirportCode'] = $strDestinationAirportCode;
						//$arrInsertFlightData[$key]['AirportHaultMinutes'] = $AirportHaultMinutes;
						$arrInsertFlightData[$key]['StopCount'] = $StopCountTxt;
						$arrInsertFlightData[$key]['Stops'] = $Stops;
						$arrInsertFlightData[$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
						$arrInsertFlightData[$key]['TotalFlightMembers'] = $intMemberCount;
						$arrInsertFlightData[$key]['CurrencyType'] = $this->CurrencyId;
						$arrInsertFlightData[$key]['PublishedFare'] = ceil($FairRulesArr[0]['PublishedFare'] * $this->CurrencyRate); // As Discussed with GG
						$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format(($FairRulesArr[0]['PublishedFare'] * $this->CurrencyRate)); // As Discussed with GG
						//                $arrInsertFlightData[$key]['CommissionEarned'] = $CommissionEarned;
						$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
						$arrInsertFlightData[$key]['JourneyType'] = $intJourneyType;
						$arrInsertFlightData[$key]['TripType'] = $intTripType;
						$arrInsertFlightData[$key]['ICSourceSysId'] = 7;
						$arrInsertFlightData[$key]['SearchFlightTraceId'] = $SearchFlightTraceId;
						$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
						$arrInsertFlightData[$key]['logo'] = $filePath;
						$arrInsertFlightData[$key]['FairRules'] = $FairRulesArr;
						$arrInsertFlightData[$key]['Segments'] = $arrSegments;

						$arrAirlineName[] = $AirlineCode . '-' . ucfirst(strtolower($strAirlineName));
						$AttPriceRange[] = $FairRulesArr[0]['PublishedFare'];
						$FiltStopCount[] = $StopCountTxt;

						if ($FairRulesArr) {
							foreach ($FairRulesArr as $Fare) {
								$dddddddd[] = $Fare['PublishedFare'];
							}
						}

						$FiltPriceRange[] = $FilterPrice = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_PRICE_RANGE_5000), ($PublishedFare * $this->CurrencyRate));
						$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
						$FilterArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strArrivalDtTime);
						//$FiltPriceRange[] = $FilterPrice = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_PRICE_RANGE_AED), ($PublishedFare * $this->CurrencyRate));
						//$arrInsertFlightData[$key]['FilterPrice'] = $FilterPrice;

						if ($FilterPrice) {
							$arrInsertFlightData[$key]['FilterPrice'] = $FilterPrice;
						}
						$arrInsertFlightData[$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
						$arrInsertFlightData[$key]['FilterArrivalDtTime'] = $FilterArrivalDtTime;
						$arrInsertFlightData[$key]['CombineTripInfo'] = [];

						$value = ($arrInsertFlightData[$key]);
						if (!array_key_exists($newKey, $keysIndexes)) {
							array_push($arrInsertFlightDataNew, $value);
							$keysIndexes[$newKey] = sizeof($keysIndexes);
						} else {
							array_push($arrInsertFlightDataNew[$keysIndexes[$newKey]]['FairRules'], $value['FairRules'][0]);
						}
					}
				}
			}

			$arrInsertFlightDataNew__ = [];
			if ($arrInsertFlightDataNew) {
				foreach ($arrInsertFlightDataNew as $kk => $vl) {
					$FairRules = $vl['FairRules'];
					$col = array_column($FairRules, "PublishedFare");
					array_multisort($col, SORT_ASC, $FairRules);
					$arrInsertFlightDataNew__[$kk] = $vl;
					$arrInsertFlightDataNew__[$kk]['PublishedFare'] = ceil($FairRules[0]['PublishedFare']);
					$arrInsertFlightDataNew__[$kk]['FairRules'] = $FairRules;
				}
			}

			// $CurrentDateTime = date('Y-m-d-H-i-s');
			// $strFilePath = "flight/Time/" . $SearchFlightTraceId . "/response_final.json";
			// Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $CurrentDateTime);
			
			if ($interNationalSearch == 1 && $strFlightRoute == 2) {
				$RoundInterTrip = $this->FlightDataRoundTripInternational($apiResponse, $getMarkup, $AdditionalMarkup);
				if (isset($FlightDataTBO['ArrPriceUnique']) && !empty($FlightDataTBO['ArrPriceUnique']) && $this->IsTBOFlightAPI == 1) {

					if (isset($RoundInterTrip['arrFlightData']) && !empty($RoundInterTrip['arrFlightData'])) {
						$dddddddd = array_merge($RoundInterTrip['AttPriceRange'], $FlightDataTBO['ArrPriceUnique']);
						$arrAirlineName = array_values(array_unique(array_merge($RoundInterTrip['arrAirlineName'], $FlightDataTBO['arrAirlineName'])));
						$FiltStopCount = array_values(array_unique(array_merge($RoundInterTrip['FiltStopCount'], $FlightDataTBO['FiltStopCount'])));
						$inboundFlightData = array_values(array_merge($RoundInterTrip['arrFlightData'], $FlightDataTBO['outbound']));
					} else {
						$dddddddd = $FlightDataTBO['ArrPriceUnique'];
						$arrAirlineName = array_values(array_unique($FlightDataTBO['arrAirlineName']));
						$FiltStopCount = array_values(array_unique($FlightDataTBO['FiltStopCount']));
						$inboundFlightData = array_values($FlightDataTBO['outbound']);
					}
					//echo '<pre>TBTBTBTBTBTBTBT';print_r($inboundFlightData);die('TBO');

				} else {
					$dddddddd = $RoundInterTrip['AttPriceRange'];
					$arrAirlineName = $RoundInterTrip['arrAirlineName'];
					$FiltStopCount = $RoundInterTrip['FiltStopCount'];
					$inboundFlightData = $RoundInterTrip['arrFlightData'];
				}
				$MinriceRange = (min($dddddddd));
				$MaxriceRange = (max($dddddddd));
				$data = array('outbound' => [], 'CurrencyTitle' => $this->CurrencyTitle, 'outboundCombine' => array_values($inboundFlightData), 'inbound' => [], 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'ArrPriceUnique' => $RoundInterTrip['ArrPriceUnique'], 'MinriceRange' => round($MinriceRange), 'MaxriceRange' => round($MaxriceRange), 'DepartDateArr' => $DepartDateArr, 'travelDates' => $DepatureDate);
			} else {
				if ($interNationalSearch == 1 && ($strFlightRoute == 1) && $this->IsTJFlightAPI == 1) {
					foreach ($arrInsertFlightDataNew__ as $k => $v) {
						$new_arr[$v['PublishedFare']][] = $v;
					}
					$arrFlightData = [];
					foreach ($arrInsertFlightDataNew__ as $ke => $vl) {
						$processedTripInfo = isset($new_arr[$vl['PublishedFare']]) ? $new_arr[$vl['PublishedFare']] : [];
						$arrFlightData[$vl['PublishedFare']] =  $vl;
						$arrFlightData[$vl['PublishedFare']]['CombineTripInfo'] =  $processedTripInfo;
					}
				} else {
					$arrFlightData = [];
				}

				$RoundTrip = $this->FlightDataRoundTripJack($apiResponse, $getMarkup, $AdditionalMarkup);

				if (array_values(array_unique($dddddddd))) {
					foreach (array_values(array_unique($dddddddd)) as $Fares) {
						if ($this->CurrencyTitle == 'INR') {
							$CONST_PRICE_RANGE = unserialize(CONST_PRICE_RANGE_5000);
						} else {
							$CONST_PRICE_RANGE = unserialize(CONST_PRICE_RANGE_AED);
						}
						$FiltPriceRange[] = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue($CONST_PRICE_RANGE, round($Fares));
					}
				}

				if (isset($FlightDataTBO['ArrPriceUnique']) && !empty($FlightDataTBO['ArrPriceUnique']) && $this->IsTBOFlightAPI == 1) {
					$dddddddd = array_merge($dddddddd, isset($RoundTrip['dddddddd']) ? $RoundTrip['dddddddd'] : [], array_values($FlightDataTBO['ArrPriceUnique']));
					$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, isset($RoundTrip['arrAirlineName']) ? $RoundTrip['arrAirlineName'] : [], $FlightDataTBO['arrAirlineName'])));
					$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, isset($RoundTrip['FiltStopCount']) ? $RoundTrip['FiltStopCount'] : [], $FlightDataTBO['FiltStopCount'])));
				} else {
					$dddddddd = array_merge($dddddddd, isset($RoundTrip['dddddddd']) ? $RoundTrip['dddddddd'] : []);
					$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, $RoundTrip['arrAirlineName'])));
					$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, $RoundTrip['FiltStopCount'])));
				}
				if (isset($FlightDataSeriesFare['AttPriceRange']) && !empty($FlightDataSeriesFare['AttPriceRange'])) {
					$dddddddd = (array_merge($dddddddd, $FlightDataSeriesFare['AttPriceRange']));
					$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, $FlightDataSeriesFare['arrAirlineName'])));
					$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, $FlightDataSeriesFare['FiltStopCount'])));
				}
				// arrAirlineName


				$FiltPriceRangeU = (array_unique($FiltPriceRange));

				sort($dddddddd);
				$MinriceRange =  ($dddddddd) ? (min($dddddddd)) : 0;
				$MaxriceRange = ($dddddddd) ? (max($dddddddd)) : 0;

				if (isset($FlightDataTBO['outbound']) && !empty($FlightDataTBO['outbound'])) {
					$arrInsertFlightDataNew__ = array_values(array_merge($arrInsertFlightDataNew__, $FlightDataTBO['outbound']));
					$SFoutbound = [];
					if (isset($FlightDataSeriesFare['outbound']) && !empty($FlightDataSeriesFare['outbound'])) {
						$SFoutbound = $FlightDataSeriesFare['outbound'];
					}
					$outboundCombine = array_values(array_merge(array_values($arrFlightData), $FlightDataTBO['outbound'], $SFoutbound));
				} else {
					$outboundCombine = $arrFlightData;
				}
				if (isset($FlightDataTBO['inbound']) && !empty($FlightDataTBO['inbound']) && $this->IsTBOFlightAPI == 1) {
					if (isset($RoundTrip['inbound']) && !empty($RoundTrip['inbound'])) {
						$inboundFlightData = array_values(array_merge($RoundTrip['inbound'], $FlightDataTBO['inbound']));
					} else {
						$inboundFlightData = array_values($FlightDataTBO['inbound']);
					}
				} else {
					$inboundFlightData = $RoundTrip['inbound'];
				}
				if (isset($FlightDataSeriesFare['outbound']) && !empty($FlightDataSeriesFare['outbound'])) {
					$arrInsertFlightDataNew__ = array_values(array_merge($arrInsertFlightDataNew__, $FlightDataSeriesFare['outbound']));
				}
				// jyt add condition 
				if(isset($outboundAPI) && !empty($outboundAPI) && !empty($arrInsertFlightDataNew__)){
					if($interNationalSearch == '' && $strFlightRoute == '2' && ($ApiRoundTrip == '7')){
						$arrInsertFlightDataNew__ = ($arrInsertFlightDataNew__);
					}else{
						$arrInsertFlightDataNew__ = array_values(array_merge($arrInsertFlightDataNew__, $outboundAPI));
					}
					
				}elseif(isset($outboundAPI) && !empty($outboundAPI) && empty($arrInsertFlightDataNew__)){
					$arrInsertFlightDataNew__ = $outboundAPI;
				}
				//end condition add for search multipal api run
				if (!empty($inboundFlightData)) {
					$inboundFlightData = array_values($inboundFlightData);
				} else {
					$inboundFlightData = [];
				}

				$data = array('outbound' => array_values($arrInsertFlightDataNew__), 'inbound' => ($inboundFlightData), 'outboundCombine' => array_values($outboundCombine), 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute, 'CurrencyTitle' => $this->CurrencyTitle, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'MinriceRange' => round($MinriceRange), 'MaxriceRange' => round($MaxriceRange), 'DepartDateArr' => $DepartDateArr, 'travelDates' => $DepatureDate);
			}
			echo json_encode($data);
			exit;
		} else if ($ApiRoundTrip == 3 && $interNationalSearch == '' && $strFlightRoute == 2) {
			$dddddddd = [];
			$arrAirlineName = [];
			$FiltStopCount = [];
			$arrInsertFlightData = [];

			if (isset($FlightDataTBO['ArrPriceUnique']) && !empty($FlightDataTBO['ArrPriceUnique']) && $this->IsTBOFlightAPI == 1) {
				$dddddddd = $FlightDataTBO['ArrPriceUnique'];
				$arrAirlineName = array_values(array_unique($FlightDataTBO['arrAirlineName']));
				$FiltStopCount = array_values(array_unique($FlightDataTBO['FiltStopCount']));
			}
			sort($dddddddd);
			$MinriceRange = (min($dddddddd));
			$MaxriceRange = (max($dddddddd));
			if (isset($FlightDataTBO['outbound']) && !empty($FlightDataTBO['outbound']) && $this->IsTBOFlightAPI == 1) {
				$arrInsertFlightData = ($FlightDataTBO['outbound']);
			}
			if (isset($FlightDataTBO['inbound']) && !empty($FlightDataTBO['inbound']) && $this->IsTBOFlightAPI == 1) {
				$inboundFlightData = ($FlightDataTBO['inbound']);
			} else {
				$inboundFlightData = [];
			}

			$data = array('outbound' => array_values($arrInsertFlightData), 'inbound' => array_values($inboundFlightData), 'outboundCombine' => [], 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute, 'CurrencyTitle' => $this->CurrencyTitle, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'MinriceRange' => round($MinriceRange), 'MaxriceRange' => round($MaxriceRange), 'DepartDateArr' => $DepartDateArr, 'travelDates' => $DepatureDate);
			echo json_encode($data);
			exit;
		} else if ($this->IsSeriesFare == 1 && $this->IsTBOFlightAPI == 0 && $this->IsTJFlightAPI == 0) {
			echo json_encode($FlightDataSeriesFare);
			exit;
		} else {
			// if($this->gtxagencysysid == '2656'){
			// 	echo"<pre>";print_r($outboundAPI);
			// 	echo"<pre>";print_r($FlightDataSeriesFare);
			// 	die('hi');
			// }
			if (isset($FlightDataSeriesFare['outbound']) && !empty($FlightDataSeriesFare['outbound'])) {
				$outboundAPI = array_merge($outboundAPI,$FlightDataSeriesFare['outbound']);
			}
			if (isset($FlightDataSeriesFare['AttPriceRange']) && !empty($FlightDataSeriesFare['AttPriceRange'])) {
				$FiltPricearAPI = array_merge($FiltPricearAPI,$FlightDataSeriesFare['AttPriceRange']);
			}
			if (isset($FlightDataSeriesFare['arrAirlineName']) && !empty($FlightDataSeriesFare['arrAirlineName'])) {
				$arrAirlineNameAPI = array_values(array_unique(array_merge($arrAirlineNameAPI,$FlightDataSeriesFare['arrAirlineName'])));
			}
			if (isset($FlightDataSeriesFare['FiltStopCount']) && !empty($FlightDataSeriesFare['FiltStopCount'])) {
				$FiltStopAPI = array_values(array_unique(array_merge($FiltStopAPI,$FlightDataSeriesFare['FiltStopCount'])));
			}
			if(isset($outboundAPI) && !empty($outboundAPI)){
				$arrInsertFlightDataNew__ = $outboundAPI;
				$RoundTripinbound = $inboundAPI;
				$MinriceRange = (min(($FiltPricearAPI)));
				$MaxriceRange = (max(($FiltPricearAPI)));

				$arrAirlineName = $arrAirlineNameAPI;
				$FiltStopCount = $FiltStopAPI;
			
				$data = array('outbound' => array_values($arrInsertFlightDataNew__), 'inbound' => $RoundTripinbound, 'travelDates' => $travelDates, 'travelDatesReturn' => $travelDatesReturn, 'ReturnDateArr' => $ReturnDateArr, 'DepartDateArr' => $DepartDateArr, 'source' => $source, 'destination' => $destination, 'source_city' => $source_city, 'destination_city' => $destination_city, 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute, 'CurrencyTitle' => $this->CurrencyTitle, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'MinriceRange' => (ceil($MinriceRange)), 'MaxriceRange' => (ceil($MaxriceRange) + 1));
				echo json_encode($data);
				exit;
			}
			$data = array('outbound' => [], 'inbound' => [], 'travelDates' => $travelDates, 'travelDatesReturn' => $travelDatesReturn, 'source' => $source, 'destination' => $destination, 'source_city' => $source_city, 'destination_city' => $destination_city, 'route' => $strFlightRoute, 'interNationalSearch' => $interNationalSearch, 'arrAirlineName' => [], 'FiltStopCount' => [], 'ArrPriceUnique' => [], 'CurrencyTitle' => $this->CurrencyTitle, 'MinriceRange' => 0, 'MaxriceRange' => 0);
			echo json_encode($data);
			exit;
			// }
			// $data = array('outbound' => [], 'CurrencyTitle' => $this->CurrencyTitle, 'outboundCombine' => [], 'inbound' => [], 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute, 'arrAirlineName' => [], 'FiltStopCount' => [], 'ArrPriceUnique' => [], 'MinriceRange' => 0, 'MaxriceRange' => 0);
			// echo json_encode($data);
		}
	}
	public function FlightDataTBO($apiResponse, $AdditionalMarkup, $getMarkup)
	{
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
		//$getMarkup = $this->getMarkup($intCountryCode);
		$SupplierType = 1;
		$getCancelCharge = $this->getCancelCharge($intCountryCode, $SupplierType);
		$TaxSettingDetail = $this->getTaxSettingDetail($getMarkup['TaxSetting'], 1);
		//$getMarkup['TaxSettingDetail'] = $TaxSettingDetail;
		$intResponseStatus = !empty($apiResponse['ResponseStatus']) ? $apiResponse['ResponseStatus'] : '0';
		$faretypeArr = $AdditionalMarkup['faretypeArr'];

		if ($intResponseStatus == 1) {
			// For getting All Airlines Array
			$arrAirlineList = $this->getAirlineIdsAndCodeList();
			// For getting All currency Array
			$arrCurrencyList = $this->getCurrencyIdsAndSymbolList();
			// For getting All Source & Destination CitySysId Array
			$arrCityIds = $this->getCityIdsAndAirPortCodeList();
			$FlightClasses = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getFlightClassesTripJack();
			$strFlightRoute = trim($sessionFlightSearchParams->params['route']);

			$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';

			$flight_class = $FlightClasses[$sessionFlightSearchParams->params['flight_class']];
			$strDepatureDate = $sessionFlightSearchParams->params['departure_dates'];
			$strReturnDate = !empty($sessionFlightSearchParams->params['return_dates']) ? $sessionFlightSearchParams->params['return_dates'] : '';
			$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);
			$strSourceAirportCode = $sessionFlightSearchParams->params['from'];
			$strDestinationAirportCode = $sessionFlightSearchParams->params['to'];
			$adultCount = $sessionFlightSearchParams->params['adults'];
			$childCount = $sessionFlightSearchParams->params['child'];
			$infantCount = $sessionFlightSearchParams->params['infant'];
			$SearchFlightTraceId = $sessionFlightSearchParams->params['SearchFlightTraceId'];
			$intMemberCount = $adultCount + $childCount + $infantCount;

			$this->view->intMemberCount = $intMemberCount;
			$this->view->interNationalSearch = $interNationalSearch;

			$intSourceCityId = trim($sessionFlightSearchParams->params['sourceCityId']);
			$intDestinationCityId = trim($sessionFlightSearchParams->params['destinationCityId']);

			$arrDepatureDate = explode("/", $strDepatureDate);
			if (count($arrDepatureDate) > 0) {
				$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
			}

			if (!empty($strReturnDate)) {
				$arrReturnDepatureDate = explode("/", $strReturnDate);
				if (count($arrReturnDepatureDate) > 0) {
					$strReturnDate = $arrReturnDepatureDate[2] . "-" . $arrReturnDepatureDate[1] . "-" . $arrReturnDepatureDate[0];
				}
			}
			$intJourneyType = 1;
			$intTripType = 1;

			$localFromDateTime = date("Y-m-d h:i", strtotime($strDepatureDate));
			$localToDateTime = date("Y-m-d h:i", strtotime($strReturnDate));
			$arrCommonInsVariables = array(
				'strTraceId' => $strTraceId,
				'localFromDateTime' => $localFromDateTime,
				'localToDateTime' => $localToDateTime,
				'strSourceAirportCode' => $strSourceAirportCode,
				'strDestinationAirportCode' => $strDestinationAirportCode,
				'intMemberCount' => $intMemberCount,
				'intSourceCityId' => $intSourceCityId,
				'intDestinationCityId' => $intDestinationCityId,
				'JourneyType' => 1, // For Single Trips API Search LocalToTime
				'TripType' => 1,
				'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0
			);

			$strTraceId         = $arrCommonInsVariables['strTraceId'];
			$localFromDateTime  = $arrCommonInsVariables['localFromDateTime'];
			$localToDateTime    = $arrCommonInsVariables['localToDateTime'];

			$strSourceAirportCode    = $arrCommonInsVariables['strSourceAirportCode'];
			$strDestinationAirportCode    = $arrCommonInsVariables['strDestinationAirportCode'];
			$intMemberCount    = $arrCommonInsVariables['intMemberCount'];
			$intSourceCityId    = $arrCommonInsVariables['intSourceCityId'];
			$intDestinationCityId    = $arrCommonInsVariables['intDestinationCityId'];
			$intJourneyType    = $arrCommonInsVariables['JourneyType'];
			$intTripType    = $arrCommonInsVariables['TripType'];
			$interNationalSearch    = isset($arrCommonInsVariables['interNationalSearch']) ? $arrCommonInsVariables['interNationalSearch'] : '0';

			$DayLightSavingDiff = 0;
			$AirportHaultMinutes = 0;
			$arrInsertFlightData = [];
			$arrInsertFlightDataNew = [];
			$keysIndexes = [];
			$arrAirlineName = [];
			$FiltStopCount = [];
			$FiltPriceRange = [];
			$AttPriceRange = [];
			$OutBoundFlightResults = $this->array_searcher_tbo($AdditionalMarkup, $apiResponse['OutBoundFlightResults']);

			foreach ($OutBoundFlightResults as $key => $result) {
				if(!empty($result)){
					$IsGSTMandatory = isset($result['IsGSTMandatory']) ? $result['IsGSTMandatory'] : 0;
					$ResultIndex = $result['ResultIndex'];
					$fareIdcolor = !empty($result['FareClassification']['Color']) ? $result['FareClassification']['Color'] : '#FFFFFF';
					$fareIdentifier = $fareIdentifier__ = !empty($result['FareClassification']['Type']) ? str_replace('.', '_', strtoupper($result['FareClassification']['Type'])) : strtoupper(trim($result['ResultFareType']));

					$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
					$fareremarks = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['remarks']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['remarks'] : '';
					$fareIdcolor = !empty($AddMarkup['color']) ? $AddMarkup['color'] : $fareIdcolor;
					$fareIdentifier = (isset($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier']) && !empty($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'])) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'] : $fareIdentifier__;

					$MiniFareRules = (isset($result['MiniFareRules']) && !empty($result['MiniFareRules'])) ? $result['MiniFareRules'] : [];
					$MiniFR = [];
					if ($MiniFareRules) {
						foreach ($MiniFareRules as $Minivalue) {
							if ($Minivalue) {
								foreach ($Minivalue as $kk => $Mini) {
									$Type = !empty($Mini['Type']) ? strtoupper($Mini['Type']) : 'NA';
									if (empty($Mini['To'])) {
										$TimeFrame = 'from ' . $Mini['From'] . ' ' . $Mini['Unit'] . ' & above before dept';
									} else {
										$TimeFrame = 'from ' . $Mini['From'] . ' To ' . $Mini['To'] . ' ' . $Mini['Unit'] . ' before dept';
									}
									//$MiniFR[$Type][$kk] = $Mini;
									$MiniFR[$Type][$kk]['sector'] = $Mini['JourneyPoints'];
									$MiniFR[$Type][$kk]['amount'] = $Mini['Details'];
									$MiniFR[$Type][$kk]['additionalFee'] = $getCancelCharge;
									$MiniFR[$Type][$kk]['TimeFrame'] = $TimeFrame;
									$MiniFR[$Type][$kk]['policyInfo'] = [];
								}
							}
						}
					}
					$tripbinfo = [];
					if ($result['Segments']) {
						foreach ($result['Segments'] as $value) {
							if ($value) {
								foreach ($value as $kk => $vl) {
									$Baggage = $vl['Baggage'];
									$CabinBaggage = $vl['CabinBaggage'];
									$SectorsCode = $vl['Origin']['Airport']['AirportCode'] . '-' . $vl['Destination']['Airport']['AirportCode'];
									$tripbinfo[$SectorsCode]['ADULT'] = ['cabin' => $CabinBaggage, 'checkin' => $Baggage];
									if (!empty($childCount)) {
										$tripbinfo[$SectorsCode]['CHILD'] = ['cabin' => $CabinBaggage, 'checkin' => $Baggage];
									}
									if (!empty($infantCount)) {
										$tripbinfo[$SectorsCode]['INFANT'] = ['cabin' => $CabinBaggage, 'checkin' => 'NA'];
									}
								}
							}
						}
					}

					$Source = $result['Source'];
					$IsLCC = $result['IsLCC'];
					$IsRefundable = $result['IsRefundable'];
					$AirlineRemark = $result['AirlineRemark'];

					$LastTicketDate = $result['LastTicketDate'];
					$TicketAdvisory = $result['TicketAdvisory'];
					$AirlineCode = $result['AirlineCode'];
					$ValidatingAirline = $result['ValidatingAirline'];
					$Baggage = $result['Segments'][0][0]['Baggage'];
					if ($IsLCC) {
						$CabinBaggage = !empty($result['Segments'][0][0]['CabinBaggage']) ? $result['Segments'][0][0]['CabinBaggage'] : '';
					} else {
						$CabinBaggage = !empty($result['Segments'][0][0]['CabinBaggage']) ? $result['Segments'][0][0]['CabinBaggage'] : '7 KG';
					}

					$Currency = $result['Fare']['Currency'];
					$currencySysId = !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
					$BaseFare = $result['Fare']['BaseFare'];
					$Tax = $result['Fare']['Tax'];

					$YQTax = $result['Fare']['YQTax'];
					$AdditionalTxnFeeOfrd = $result['Fare']['AdditionalTxnFeeOfrd'];
					$AdditionalTxnFeePub = $result['Fare']['AdditionalTxnFeePub'];
					$OtherCharges = $result['Fare']['OtherCharges'];
					$Discount = $result['Fare']['Discount'];
					$PublishedFare = $result['Fare']['PublishedFare'];
					$CommissionEarned = $result['Fare']['CommissionEarned'];
					$PLBEarned = $result['Fare']['PLBEarned'];
					$IncentiveEarned = $result['Fare']['IncentiveEarned'];
					$OfferedFare = $result['Fare']['OfferedFare'];
					$TdsOnCommission = $result['Fare']['TdsOnCommission'];
					$TdsOnPLB = $result['Fare']['TdsOnPLB'];
					$TdsOnIncentive = $result['Fare']['TdsOnIncentive'];
					$ServiceFee = $result['Fare']['ServiceFee'];
					$FareBreakdown = $result['FareBreakdown'];
					$totalCommissions = $result['Fare']['CommissionEarned'] + $result['Fare']['PLBEarned'] + $result['Fare']['IncentiveEarned'];
					$TotalPassengerCountForDiscount = $adultCount + $childCount;
					//$intDiscountPerHead = $totalCommissions / $TotalPassengerCountForDiscount;
					$intDiscountPerHead = $totalCommissions;

					$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']) ? $AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'] : 0;
					$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);

					$totalCommissionsOnTds = $result['Fare']['TdsOnCommission'] + $result['Fare']['TdsOnIncentive'] + $result['Fare']['TdsOnPLB'];
					$markUpArr = array(
						'getMarkup' => $getMarkup,
						'PublishedFare' => $PublishedFare,
						'OfferedFare' => $OfferedFare,
						'intCommissionEarned' => $totalCommissions,
						'TdsOnPLB' => $totalCommissionsOnTds,
						'intPLBEarned' => 0, //$PLBEarned,
						'intIncentiveEarned' => 0, //$IncentiveEarned,
						'intMemberCount' => $intMemberCount,
						'intFlightRoute' => $strFlightRoute,
						'interNationalSearch' => $interNationalSearch,
						'AddMarkup' => $AddMarkup,
					);

					$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTBO($markUpArr);
					//
					$AgencyMarkUp      = $arrMarkUps['intAgencyFixMarkUp'];
					$intGTXMarkUp      = $arrMarkUps['intGTXMarkUp'];
					$intFareWithGTXMarkUp = $arrMarkUps['intFareWithGTXMarkUp'];

					$intOfferedFare = $arrMarkUps['intOfferedFare'];
					if ($interNationalSearch == 1) {
						$intGTXMarkUp = (($arrMarkUps['intGTXMarkUp'] * $intMemberCount) * $strFlightRoute);
						$intSTaxOnGTXMarkUp = (($arrMarkUps['intSTaxOnGTXMarkUp'] * $intMemberCount) * $strFlightRoute);
						$intAgencyFixMarkUp = (($arrMarkUps['intAgencyFixMarkUp'] * $intMemberCount) * $strFlightRoute);
						$intSTaxOnAgencyFixMarkUp = (($arrMarkUps['intSTaxOnAgencyFixMarkUp'] * $intMemberCount) * $strFlightRoute);
					} else {
						$intGTXMarkUp = ($arrMarkUps['intGTXMarkUp'] * $intMemberCount);
						$intSTaxOnGTXMarkUp = ($arrMarkUps['intSTaxOnGTXMarkUp'] * $intMemberCount);
						$intAgencyFixMarkUp = ($arrMarkUps['intAgencyFixMarkUp'] * $intMemberCount);
						$intSTaxOnAgencyFixMarkUp = ($arrMarkUps['intSTaxOnAgencyFixMarkUp'] * $intMemberCount);
					}

					$CommisionPass = $arrMarkUps['CommisionPass'];
					$intCommisionEarnedForAgency = $arrMarkUps['intCommisionEarnedForAgency'];
					$intPLBEarnedForAgency = $arrMarkUps['intPLBEarnedForAgency'];
					$intIncentiveEarnedForAgency = $arrMarkUps['intIncentiveEarnedForAgency'];
					$intTotalEarningsForAgency = $arrMarkUps['intTotalEarningsForAgency'] + $intAgencyFixMarkUp;

					$intGSTOnAgencyCommisionEarned = $arrMarkUps['intGSTOnAgencyCommisionEarned'];
					$intGSTOnAgencyPLBEarned = $arrMarkUps['intGSTOnAgencyPLBEarned'];
					$intGSTOnAgencyIncentiveEarned = $arrMarkUps['intGSTOnAgencyIncentiveEarned'];
					//$intTotalGSTAgencyEarnings = $intSTaxOnAgencyFixMarkUp + $intGSTOnAgencyCommisionEarned + $intGSTOnAgencyPLBEarned + $intGSTOnAgencyIncentiveEarned;
					$intTotalGSTAgencyEarnings = $intSTaxOnAgencyFixMarkUp;

					$intPublishedFare = 0; // CommisionPass $intOfferedFare+ $ServiceFee + $intGTXMarkUp + $intAgencyFixMarkUp + $intCommisionEarnedForAgency + $intPLBEarnedForAgency + $intIncentiveEarnedForAgency + $intTotalGSTAgencyEarnings;
					$intTotalOfferedForAllPax = 0;
					$intTotalCommissionEarned = 0;
					$countBreakUp = count($FareBreakdown);
					foreach ($FareBreakdown as $pk => $pax) {
						$intPassengerType       = $pax['PassengerType'];
						$intPassengerCount = isset($pax['PassengerCount']) ? $pax['PassengerCount'] : 0;
						$intBaseFare       = $pax['BaseFare'];
						$intTax            = $pax['Tax'];
						$OtherCharges_         = ($OtherCharges / $countBreakUp);
						$intDiscountPerHead_         = ($intDiscountPerHead / $countBreakUp);
						$intBaseFareCal             = $intBaseFare - $intDiscountPerHead_;
						$intFareOfferedToPax       = $intBaseFareCal + $intTax;
						//echo '<pre>';print_r($intBaseFareCal);
						$arrFareBreakdown[$pk] = [
							'intDiscountPerHead'      => $intDiscountPerHead_,
							'Currency'      => $pax['Currency'],
							'APIBaseFare'      => $pax['BaseFare'],
							'BaseFare'      => $pax['BaseFare'], //$intBaseFareCal,
							'Tax'           => $pax['Tax'],
							'YQTax'         => $pax['YQTax'],
							'OtherCharges'         => $OtherCharges_,
							'PassengerType' => $pax['PassengerType'],
							'PassengerCount' => $pax['PassengerCount'],
							'PGCharge'      => $pax['PGCharge'],
							'AdditionalTxnFeePub'   => $pax['AdditionalTxnFeePub'],
							'AdditionalTxnFeeOfrd'  => $pax['AdditionalTxnFeeOfrd'],
							'AgencyMarkUp'  => $AgencyMarkUp,
							'GTXMarkUp'  => $intGTXMarkUp,
							'FareOfferedToPax'  => $intFareOfferedToPax,
							'FixedMarkUp'  => ($intAgencyFixMarkUp / $countBreakUp),
							'GSTOnMarkUp'  => ($intSTaxOnAgencyFixMarkUp / $countBreakUp),
							'intTotalGST'  => ($intSTaxOnAgencyFixMarkUp / $countBreakUp),
							'ServiceFee'  => ($ServiceFee / $countBreakUp),
							'CommisionPass'  => ($CommisionPass / $countBreakUp),
							'intGTXMarkUp'  => $intGTXMarkUp,
							'GTXMarkUpGST'  => $intSTaxOnGTXMarkUp,
							'CommissionEarned'  => ($intCommisionEarnedForAgency / $countBreakUp),
							'IntCommission'  => $arrMarkUps['intCommissionEarned'],
						];
						if ($intPassengerType == 3) {
							$arrFareBreakdown[$pk]['CommisionPass'] = 0;
						}
						$arrFareBreakdown[$pk]['TDS'] = ($totalCommissionsOnTds / $countBreakUp);
						$arrFareBreakdown[$pk]['MF'] = 0;
						$arrFareBreakdown[$pk]['YQ'] = $pax['YQTax'];
						$arrFareBreakdown[$pk]['AGST'] = 0;
						$arrFareBreakdown[$pk]['MFT'] = 0;
						$arrFareBreakdown[$pk]['OT'] = ($pax['Tax'] + $OtherCharges_);
						$arrFareBreakdown[$pk]['MU'] = 0;
						$arrFareBreakdown[$pk]['YR'] = 0;
						$arrFareBreakdown[$pk]['ResultIndex'] = $ResultIndex;
						$arrFareBreakdown[$pk]['intCommisionEarnedForAgency'] = ($intCommisionEarnedForAgency / $countBreakUp);
						$arrFareBreakdown[$pk]['intPLBEarnedForAgency'] = ($intPLBEarnedForAgency / $countBreakUp);
						$arrFareBreakdown[$pk]['intIncentiveEarnedForAgency'] = ($intIncentiveEarnedForAgency / $countBreakUp);
						$arrFareBreakdown[$pk]['Baggage'] = ($Baggage);
						$arrFareBreakdown[$pk]['CabinBaggage'] = ($CabinBaggage);

						$intTotalOfferedForAllPax += $intFareOfferedToPax;
						$intTotalCommissionEarned += $intCommisionEarnedForAgency;

						$intPublishedFare += $intBaseFare + $OtherCharges_ + $intTax + ($totalCommissionsOnTds / $countBreakUp) + ($intAgencyFixMarkUp / $countBreakUp) + ($intSTaxOnAgencyFixMarkUp / $countBreakUp) + ($ServiceFee / $countBreakUp) - ($CommisionPass / $countBreakUp);
					}
					$arrFairRules[0] = array(
						"Currency" => $this->CurrencyTitle, //$Currency,
						"CurrencyRate" => $this->CurrencyRate, //$Currency,
						"currencySysId" => $this->CurrencyId,
						"BaseFare" => $BaseFare,
						"Tax" => $Tax,
						"YQTax" => $YQTax,
						"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
						"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
						"OtherCharges" => $OtherCharges,
						"Discount" => $Discount,
						"ServiceFee" => $ServiceFee,
						"PublishedFare" => ceil($intPublishedFare * $this->CurrencyRate),
						"PublishedFarePerPax" => ceil(($intPublishedFare / $intMemberCount)),
						"CommissionEarned" => $intTotalCommissionEarned,
						"FixedMarkUp" => $intAgencyFixMarkUp,
						"GSTOnMarkUp" => $intSTaxOnAgencyFixMarkUp,
						"PLBEarned" => $PLBEarned,
						"IncentiveEarned" => $IncentiveEarned,
						"OfferedFare" => $OfferedFare,
						"TdsOnCommission" => $TdsOnCommission,
						"TdsOnPLB" => $TdsOnPLB,
						"TdsOnIncentive" => $TdsOnIncentive,
						//"FareBreakdown" => $FareBreakdown, IsCabinBaggage
						"fareIdentifier" => $fareIdentifier,
						"colors" => $fareIdcolor,
						"Refundable" => $IsRefundable,
						"IsRefundableTxt" => $fareIdentifier,
						"AirlineRemark" => $AirlineRemark,
						"fareremarks" =>  $fareremarks,
						"PriceID" => $ResultIndex,
						"Baggage" => $Baggage,
						"CabinBaggage" => $CabinBaggage,
						"FareBreakdown" => $arrFareBreakdown,
						"arrMarkUps" => $arrMarkUps,
						"tripbinfo" => $tripbinfo,
						"MiniFR" => $MiniFR,
						"TaxSettingDetail" => $arrMarkUps['TaxSettingDetail'],
					);

					array_multisort($arrFairRules);
					$col = array_column($arrFairRules, "PublishedFare");
					array_multisort($col, SORT_ASC, $arrFairRules);
					$originCity = $result['Segments'][0][0]['Origin']['Airport']['CityName'];
					$DestinationCity = $result['Segments'][0][0]['Destination']['Airport']['CityName'];
					$AirlineCode = $result['Segments'][0][0]['Airline']['AirlineCode'];
					$FlightNumber = $result['Segments'][0][0]['Airline']['FlightNumber'];
					$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
					$strAirlineName = trim($result['Segments'][0][0]['Airline']['AirlineName']);
					$strFareClass = $result['Segments'][0][0]['Airline']['FareClass'];
					$AccumulatedDuration = 0;
					$arrSegments = [];
					if (count($result['Segments'][0]) > 0) {
						$FlyingMinutes = 0;
						$countSeg = count($result['Segments'][0]);
						foreach ($result['Segments'][0] as $segmentsResult) {
							$Duration = $segmentsResult['Duration'];
							if ($countSeg >= 2) {
								$AccumulatedDuration += isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : (0);
							} else {
								$AccumulatedDuration += ($segmentsResult['Duration'] + $segmentsResult['GroundTime']);
							}
							//$AccumulatedDuration += isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : ($segmentsResult['Duration'] + isset($segmentsResult['GroundTime'])?$segmentsResult['GroundTime']:0);
							$FlyingMinutes = $FlyingMinutes + (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : ($segmentsResult['Duration'] + isset($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : 0));
							$LAYOVERMinutes = ((isset($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : 0));
							$DepTime = $segmentsResult['Origin']['DepTime'];
							$ArrTime = $segmentsResult['Destination']['ArrTime'];
							$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($LAYOVERMinutes);
							// FOR FLIGHT SEGMENTS.....
							$strBaggage = $segmentsResult['Baggage'];
							//$strCabinBaggage = $segmentsResult['CabinBaggage'];
							if ($IsLCC) {
								$strCabinBaggage = $segmentsResult['CabinBaggage'];
							} else {
								$strCabinBaggage = !empty($segmentsResult['CabinBaggage']) ? $segmentsResult['CabinBaggage'] : '7 KG ';
							}
							if (!empty($strBaggage)) {
								$IsBaggage = true;
							} else {
								$IsBaggage = false;
							}
							// if (!empty($strCabinBaggage)) {
							// 	$strCabinBaggage = $strCabinBaggage;
							// } else {
							// 	$strCabinBaggage = '';
							// }
							$TripIndicator = $segmentsResult['TripIndicator'];
							$SegmentIndicator = $segmentsResult['SegmentIndicator'];

							$strAirlineCode = $segmentsResult['Airline']['AirlineCode'];
							$AirlineName = $segmentsResult['Airline']['AirlineName'];
							$FlightNumber = $segmentsResult['Airline']['FlightNumber'];
							$FareClass = $segmentsResult['Airline']['FareClass'];

							$SegFlightNumber = $strAirlineCode . "-" . $FlightNumber;

							$DepTerminal = $segmentsResult['Origin']['Airport']['Terminal'];
							if (!empty($DepTerminal)) {
								$DepTerminal = $DepTerminal;
							} else {
								$DepTerminal = 0;
							}
							$ArrTerminal = $segmentsResult['Destination']['Airport']['Terminal'];
							if (!empty($ArrTerminal)) {
								$ArrTerminal = $ArrTerminal;
							} else {
								$ArrTerminal = 0;
							}

							$originAirportName = $segmentsResult['Origin']['Airport']['AirportName'];
							$originAirportCode = $segmentsResult['Origin']['Airport']['AirportCode'];
							$originCityName = $segmentsResult['Origin']['Airport']['CityName'];
							$originCountryName = $segmentsResult['Origin']['Airport']['CountryName'];
							$originDepTime = $segmentsResult['Origin']['DepTime'];

							$destinationAirportName = $segmentsResult['Destination']['Airport']['AirportName'];
							$destinationAirportCode = $segmentsResult['Destination']['Airport']['AirportCode'];
							$destinationCityName = $segmentsResult['Destination']['Airport']['CityName'];
							$destinationCountryName = $segmentsResult['Destination']['Airport']['CountryName'];
							$destinationArrTime = $segmentsResult['Destination']['ArrTime'];

							$Duration = $segmentsResult['Duration'];
							$GroundTime = $segmentsResult['GroundTime'];
							$Mile = $segmentsResult['Mile'];
							$StopOver = $segmentsResult['StopOver'];
							$StopPoint = $segmentsResult['StopPoint'];
							$StopPointArrivalTime = $segmentsResult['StopPointArrivalTime'];
							$StopPointDepartureTime = $segmentsResult['StopPointDepartureTime'];
							$Craft = $segmentsResult['Craft'];
							$Remark = $segmentsResult['Remark'];
							$IsETicketEligible = $segmentsResult['IsETicketEligible'];
							$NoOfSeatAvailable = !empty($segmentsResult['NoOfSeatAvailable']) ? $segmentsResult['NoOfSeatAvailable'] : 0;
							$FlightStatus = $segmentsResult['FlightStatus'];
							$Status = $segmentsResult['Status'];

							if ($GroundTime > 0) {
								$LAYOVERCity = $originCityName;
							} else {
								$LAYOVERCity = '';
							}


							$strAirlineCodeLogo = $strAirlineCode;

							$filePath = $_SERVER['DOCUMENT_ROOT'] . "/public/upload/AirlineLogo/";
							if (file_exists($filePath . $strAirlineCodeLogo . ".gif")) {
								$strAirlineLogo = $strAirlineCodeLogo . ".gif";
								$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
							} elseif (file_exists($filePath . $strAirlineCodeLogo . ".png")) {
								$strAirlineLogo = $strAirlineCodeLogo . ".png";
								$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
							} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpg")) {
								$strAirlineLogo = $strAirlineCodeLogo . ".jpg";
								$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
							} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpeg")) {
								$strAirlineLogo = $strAirlineCodeLogo . ".jpeg";
								$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
							} else {
								$filePath = $this->baseUrl . "public/upload/AirlineLogo/noimage.png";
							}


							$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->convertMinutesToHoursFormat((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0));

							$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($ArrTime);
							$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($DepTime);
							$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);

							$arrSegments[] = array(
								"segmentid" => $FlightNumber,
								"originAirportName" => $originAirportName,
								"destinationAirportName" => $destinationAirportName,
								"originCityName" => $originCityName,
								"originCountryName" => $originCountryName,
								"destinationCityName" => $destinationCityName,
								"destinationCountryName" => $destinationCountryName,
								"destinationAirportCode" => $destinationAirportCode,
								"destinationAirportCode" => $destinationAirportCode,
								"destinationArrTime" => $destinationArrTime,
								"SegFlightNumber" => $SegFlightNumber,
								"AirlineCode" => $strAirlineCode,
								"AirlineName" => $AirlineName,
								"FareClass" => $FareClass,
								"originAirportCode" => $originAirportCode,
								"originDepTime" => $originDepTime,
								"TripIndicator" => $TripIndicator,
								"Baggage" => $strBaggage,
								"CabinBaggage" => $strCabinBaggage,
								"IsBaggage" => $IsBaggage,
								"IsCabinBaggage" => !empty($strCabinBaggage) ? true : false,
								"SegmentIndicator" => $SegmentIndicator,
								"Duration" => $Duration,
								"GroundTime" => $GroundTime,
								"Mile" => $Mile,
								"StopOver" => $StopOver,
								"StopPoint" => $StopPoint,
								"StopPointArrivalTime" => $StopPointArrivalTime,
								"StopPointDepartureTime" => $StopPointDepartureTime,
								"Craft" => $Craft,
								"Remark" => $Remark,
								"IsETicketEligible" => $IsETicketEligible,
								"FlightStatus" => $FlightStatus,
								"Status" => $Status,
								"NoOfSeatAvailable" => $NoOfSeatAvailable,
								"strDepartureDtTime" => $strDepartureDtTime,
								"strArrivalDtTime" => $strArrivalDtTime,
								"FlightDuration" => $strDuration,
								"LAYOVERDuration" => $LAYOVERDuration,
								"LAYOVERCity" => $LAYOVERCity,
								"DepTerminal" => $DepTerminal,
								"ArrTerminal" => $ArrTerminal,
								"filePath" => $filePath,
							);
							// FOR FLIGHT SEGMENTS.....
						}
					}
					$airlineSysId = !empty($arrAirlineList[$result['AirlineCode']]) ? $arrAirlineList[$result['AirlineCode']] : '0';
					$FlyingMinutes = $AccumulatedDuration;

					if (count($result['Segments'][0]) == 1) {
						$DepOrigin = $result['Segments'][0][0]['Origin'];
						$DepDestination = $result['Segments'][0][0]['Destination'];
					} elseif (count($result['Segments'][0]) == 2) {
						$DepOrigin = $result['Segments'][0][0]['Origin'];
						$DepDestination = $result['Segments'][0][1]['Destination'];
					} elseif (count($result['Segments'][0]) == 3) {
						$DepOrigin = $result['Segments'][0][0]['Origin'];
						$DepDestination = $result['Segments'][0][2]['Destination'];
					}

					$strSourceAirportCode = $DepOrigin['Airport']['AirportCode'];
					$strDestinationAirportCode = $DepDestination['Airport']['AirportCode'];
					if (count($result['Segments'][0]) > 1) {
						$SegmentsCount = count($result['Segments'][0]);
						$StopCount = $SegmentsCount - 1;
						$IsDirect = '0';
						$initialOriginDepTime = $result['Segments'][0][0]['Origin']['DepTime'];
						$initialOriginArrTime = $result['Segments'][0][1]['Destination']['ArrTime'];
					} else {
						$StopOver_ = isset($result['Segments'][0][0]['StopOver']) ? $result['Segments'][0][0]['StopOver'] : false;
						$StopCount = ($StopOver_) ? $StopOver_ : '0';
						$IsDirect = '1';
						$initialOriginDepTime = $result['Segments'][0][0]['Origin']['DepTime'];
						$initialOriginArrTime = $result['Segments'][0][0]['Destination']['ArrTime'];
					}
					$strAirlineCodeEX = explode("-", trim($strFlightNumber));
					$strAirlineCodeLogo = $strAirlineCodeEX[0];

					$filePath = $_SERVER['DOCUMENT_ROOT'] . "/public/upload/AirlineLogo/";
					if (file_exists($filePath . $strAirlineCodeLogo . ".gif")) {
						$strAirlineLogo = $strAirlineCodeLogo . ".gif";
						$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
					} elseif (file_exists($filePath . $strAirlineCodeLogo . ".png")) {
						$strAirlineLogo = $strAirlineCodeLogo . ".png";
						$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
					} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpg")) {
						$strAirlineLogo = $strAirlineCodeLogo . ".jpg";
						$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
					} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpeg")) {
						$strAirlineLogo = $strAirlineCodeLogo . ".jpeg";
						$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
					} else {
						$filePath = $this->baseUrl . "public/upload/AirlineLogo/noimage.png";
					}


					$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($initialOriginArrTime);
					$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($initialOriginDepTime);
					$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
					if ($StopCount == 0) {
						$StopCountTxt = "Non-stop";
					} else {
						$StopCountTxt = $StopCount . " Stop(s)";
					}
					if ($IsRefundable) {
						$IsRefundableTxt = 'Refundable';
					} else {
						$IsRefundableTxt = 'Non Refundable';
					}
					$LocalFromTime = str_replace('T', ' ', $initialOriginDepTime);
					$LocalToTime = str_replace('T', ' ', $initialOriginArrTime);
					$FlightNumber = $strFlightNumber;
					$FareClass = ''; //!empty($strFareClass)?$strFareClass:'';
					$newKey = $LocalFromTime . '' . $LocalToTime . '' . $FlightNumber . '' . $FareClass;

					$arrFairRules[0]['classOfBooking'] = $strFareClass;
					$arrFairRules[0]['FareClass'] = $flight_class;
					$arrFairRules[0]['Refundable'] = $IsRefundable;
					$arrFairRules[0]['IsRefundableTxt'] = $IsRefundableTxt;
					$arrFairRules[0]['SeatAvailable'] = $NoOfSeatAvailable;
					$arrFairRules[0]['IsGSTRequired'] = $IsGSTMandatory;
					$arrFairRules[0]['IsMealIncludes'] = ($IsLCC == 1) ? false : true;
					$arrFairRules[0]['IsBaggage'] = !empty($strBaggage) ? true : false;
					$arrFairRules[0]['IsCabinBaggage'] = !empty($strCabinBaggage) ? true : false;

					$arrInsertFlightData[$key]['FlightNumber'] = $strFlightNumber;
					$arrInsertFlightData[$key]['SegFlightNumberArr'] = $strFlightNumber;
					$arrInsertFlightData[$key]['AirlineName'] = ucfirst(strtolower($strAirlineName));
					$arrInsertFlightData[$key]['AirlineCode'] = $AirlineCode;
					$arrInsertFlightData[$key]['AirInvenSysId'] = $arrAirlineList[$AirlineCode];
					$arrInsertFlightData[$key]['IsLCC'] = $IsLCC;
					$arrInsertFlightData[$key]['IsGSTMandatory'] = $IsGSTMandatory;
					$arrInsertFlightData[$key]['IsMealIncludes'] = ($IsLCC == 1) ? false : true;
					$arrInsertFlightData[$key]['IsBagIncludes'] = !empty($strBaggage) ? true : false;
					$arrInsertFlightData[$key]['IsCabinBagIncludes'] = !empty($strCabinBaggage) ? true : false;
					$arrInsertFlightData[$key]['IsRefundable'] = $IsRefundable;
					$arrInsertFlightData[$key]['IsRefundableTxt'] = $IsRefundableTxt;
					$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
					$arrInsertFlightData[$key]['AirlineSysId'] = $airlineSysId;
					$arrInsertFlightData[$key]['LocalFromTime'] = str_replace('T', ' ', $initialOriginDepTime);
					$arrInsertFlightData[$key]['FromUTCTime'] = $initialOriginDepTime;
					$arrInsertFlightData[$key]['LocalToTime'] = str_replace('T', ' ', $initialOriginArrTime);
					$arrInsertFlightData[$key]['DepartureDateTxt'] = date('D, d M', strtotime($initialOriginDepTime));
					$arrInsertFlightData[$key]['ArrivalDateTxt'] = date('D, d M', strtotime($initialOriginArrTime));
					$arrInsertFlightData[$key]['ToUTCTime'] = $initialOriginArrTime;
					$arrInsertFlightData[$key]['DepartureTime'] = $strDepartureDtTime;
					$arrInsertFlightData[$key]['ArrivalTime'] = $strArrivalDtTime;
					$arrInsertFlightData[$key]['IsDirect'] = $IsDirect;
					$arrInsertFlightData[$key]['FareClass'] = $strFareClass;
					$arrInsertFlightData[$key]['DayLightSavingDiff'] = $DayLightSavingDiff;
					$arrInsertFlightData[$key]['FlyingMinutes'] = $FlyingMinutes;
					$arrInsertFlightData[$key]['FlightDuration'] = $FlightDuration;
					$arrInsertFlightData[$key]['SourcePlaceSysId'] = $intSourceCityId;
					$arrInsertFlightData[$key]['DestPlaceSysId'] = $intDestinationCityId;
					$arrInsertFlightData[$key]['SourceAirportCode'] = $strSourceAirportCode;
					$arrInsertFlightData[$key]['DestAirportCode'] = $strDestinationAirportCode;
					$arrInsertFlightData[$key]['AirportHaultMinutes'] = $AirportHaultMinutes;
					$arrInsertFlightData[$key]['StopCount'] = $StopCountTxt;
					$arrInsertFlightData[$key]['Stops'] = $StopCount;
					$arrInsertFlightData[$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
					$arrInsertFlightData[$key]['TotalFlightMembers'] = $intMemberCount;
					$arrInsertFlightData[$key]['CurrencyType'] = $this->CurrencyId;
					$arrInsertFlightData[$key]['PublishedFare'] = $intPublishedFare; // As Discussed with GG
					$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format($intPublishedFare); // As Discussed with GG
					$arrInsertFlightData[$key]['CommissionEarned'] = $CommissionEarned;
					$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
					$arrInsertFlightData[$key]['JourneyType'] = $intJourneyType;
					$arrInsertFlightData[$key]['TripType'] = $intTripType;
					$arrInsertFlightData[$key]['ICSourceSysId'] = 3;
					$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
					$arrInsertFlightData[$key]['SearchFlightTraceId'] = $SearchFlightTraceId;
					$arrInsertFlightData[$key]['logo'] = $filePath;
					$arrInsertFlightData[$key]['FairRules'] = $arrFairRules;
					$arrInsertFlightData[$key]['Segments'] = $arrSegments;
					$arrInsertFlightData[$key]['IsNewMigration'] = true;
					$value = ($arrInsertFlightData[$key]);
					//

					if (!array_key_exists($newKey, $keysIndexes)) {
						array_push($arrInsertFlightDataNew, $value);
						$keysIndexes[$newKey] = sizeof($keysIndexes);
					} else {
						array_push($arrInsertFlightDataNew[$keysIndexes[$newKey]]['FairRules'], $value['FairRules'][0]);
					}

					// $valueAmt = '';
					// $valueFT = '';
					// $FairRulesNew = array();
					// foreach ($arrInsertFlightDataNew[$key]['FairRules'] as $keyF => $valuess) {
					// 	if ($valuess['fareIdentifier'] == $valueFT) {
					// 		if ($valuess['PublishedFarePerPax'] <= $valueAmt) {
					// 			unset($FairRulesNew[$keyF - 1]);
					// 			$FairRulesNew[$keyF] = $valuess;
					// 			$valueAmt = $valuess['PublishedFarePerPax'];
					// 			$valueFT = $valuess['fareIdentifier'];
					// 		}
					// 	} else {
					// 		$FairRulesNew[$keyF] = $valuess;
					// 		$valueAmt = $valuess['PublishedFarePerPax'];
					// 		$valueFT = $valuess['fareIdentifier'];
					// 	}
					// }
					// $arrInsertFlightDataNew[$key]['FairRules'] = $FairRulesNew;
					//echo '<pre>';
					//print_r($arrInsertFlightDataNew[$key]['FairRules']);
					$arrAirlineName[] = $AirlineCode . '-' . ucfirst(strtolower($strAirlineName));
					$FiltStopCount[] = $StopCountTxt;
					$AttPriceRange[] = $intPublishedFare;
				}
			}

			//echo '<pre>';print_r($arrInsertFlightData);die;
			if ($strFlightRoute == 2) {
				$RoundTrip = $this->FlightDataRoundTripTBO($apiResponse, $AdditionalMarkup, $getMarkup);
			} else {
				$RoundTrip = ['arrAirlineName' => [], 'ArrPriceUnique' => [], 'FiltStopCount' => [], 'AttPriceRange' => []];
			}
			$ArrPriceUnique = array_unique(array_filter(array_values(array_merge($AttPriceRange, $RoundTrip['ArrPriceUnique']))));
			$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, $RoundTrip['arrAirlineName'])));
			$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, $RoundTrip['FiltStopCount'])));
			//echo count($arrInsertFlightDataNew);die('sss');
			if ($interNationalSearch == 1 && $strFlightRoute == 2) {
				$RoundInterTrip = $this->FlightDataRoundTripInternationalTBO($apiResponse, $getMarkup, $AdditionalMarkup);
				$MinriceRange = (min($RoundInterTrip['AttPriceRange']));
				$MaxriceRange = (max($RoundInterTrip['AttPriceRange']));
				$data = array('outbound' => $RoundInterTrip['outbound'], 'inbound' => [], 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute,  'arrAirlineName' => $RoundInterTrip['arrAirlineName'], 'FiltStopCount' => $RoundInterTrip['FiltStopCount'], 'ArrPriceUnique' => $RoundInterTrip['ArrPriceUnique']);
			} else {
				$data = array('outbound' => $arrInsertFlightDataNew, 'inbound' => $RoundTrip['inbound'], 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute,  'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'ArrPriceUnique' => $ArrPriceUnique);
			}

			return ($data);
		} else {
			$data = array('outbound' => [], 'inbound' => [], 'arrAirlineName' => [], 'FiltStopCount' => [], 'ArrPriceUnique' => [], 'MinriceRange' => 0, 'MaxriceRange' => 0);
			return ($data);
		}
	}
	public function FlightDataRoundTripTBO($apiResponse, $AdditionalMarkup, $getMarkup)
	{
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
		//$getMarkup = $this->getMarkup($intCountryCode);
		$SupplierType = 1;
		//$TaxSettingDetail = $this->getTaxSettingDetail($getMarkup['TaxSetting'], 1);
		$getCancelCharge = $this->getCancelCharge($intCountryCode, $SupplierType);
		//$TaxSettingDetail = $this->getTaxSettingDetail($getMarkup['TaxSetting'], 1);
		//$getMarkup['TaxSettingDetail'] = $TaxSettingDetail;
		$intResponseStatus = !empty($apiResponse['ResponseStatus']) ? $apiResponse['ResponseStatus'] : '0';
		//echo '<pre>';print_r($apiResponse);die('bbb');
		if ($intResponseStatus == 1) {
			// For getting All Airlines Array
			$arrAirlineList = $this->getAirlineIdsAndCodeList();
			// For getting All currency Array
			$arrCurrencyList = $this->getCurrencyIdsAndSymbolList();
			// For getting All Source & Destination CitySysId Array
			$arrCityIds = $this->getCityIdsAndAirPortCodeList();
			$FlightClasses = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getFlightClassesTripJack();
			$strFlightRoute = trim($sessionFlightSearchParams->params['route']);

			$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';

			$flight_class = $FlightClasses[$sessionFlightSearchParams->params['flight_class']];
			$strDepatureDate = $sessionFlightSearchParams->params['departure_dates'];
			$strReturnDate = !empty($sessionFlightSearchParams->params['return_dates']) ? $sessionFlightSearchParams->params['return_dates'] : '';
			$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);
			$strSourceAirportCode = $sessionFlightSearchParams->params['from'];
			$strDestinationAirportCode = $sessionFlightSearchParams->params['to'];
			$adultCount = $sessionFlightSearchParams->params['adults'];
			$childCount = $sessionFlightSearchParams->params['child'];
			$infantCount = $sessionFlightSearchParams->params['infant'];
			$SearchFlightTraceId = $sessionFlightSearchParams->params['SearchFlightTraceId'];
			$intMemberCount = $adultCount + $childCount + $infantCount;

			$this->view->intMemberCount = $intMemberCount;
			$this->view->interNationalSearch = $interNationalSearch;

			$intSourceCityId = trim($sessionFlightSearchParams->params['sourceCityId']);
			$intDestinationCityId = trim($sessionFlightSearchParams->params['destinationCityId']);

			$arrDepatureDate = explode("/", $strDepatureDate);
			if (count($arrDepatureDate) > 0) {
				$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
			}

			if (!empty($strReturnDate)) {
				$arrReturnDepatureDate = explode("/", $strReturnDate);
				if (count($arrReturnDepatureDate) > 0) {
					$strReturnDate = $arrReturnDepatureDate[2] . "-" . $arrReturnDepatureDate[1] . "-" . $arrReturnDepatureDate[0];
				}
			}

			$localFromDateTime = date("Y-m-d h:i", strtotime($strDepatureDate));
			$localToDateTime = date("Y-m-d h:i", strtotime($strReturnDate));
			$arrCommonInsVariables = array(
				'strTraceId' => $strTraceId,
				'localFromDateTime' => $localFromDateTime,
				'localToDateTime' => $localToDateTime,
				'strSourceAirportCode' => $strSourceAirportCode,
				'strDestinationAirportCode' => $strDestinationAirportCode,
				'intMemberCount' => $intMemberCount,
				'intSourceCityId' => $intSourceCityId,
				'intDestinationCityId' => $intDestinationCityId,
				'JourneyType' => 2, // For round Trips API Search
				'TripType' => 1,
				'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0
			);

			$strTraceId         = $arrCommonInsVariables['strTraceId'];
			$localFromDateTime  = $arrCommonInsVariables['localFromDateTime'];
			$localToDateTime    = $arrCommonInsVariables['localToDateTime'];

			$strSourceAirportCode    = $arrCommonInsVariables['strSourceAirportCode'];
			$strDestinationAirportCode    = $arrCommonInsVariables['strDestinationAirportCode'];
			$intMemberCount    = $arrCommonInsVariables['intMemberCount'];
			$intSourceCityId    = $arrCommonInsVariables['intSourceCityId'];
			$intDestinationCityId    = $arrCommonInsVariables['intDestinationCityId'];
			$intJourneyType    = $arrCommonInsVariables['JourneyType'];
			$intTripType    = $arrCommonInsVariables['TripType'];
			$interNationalSearch    = isset($arrCommonInsVariables['interNationalSearch']) ? $arrCommonInsVariables['interNationalSearch'] : '0';

			$DayLightSavingDiff = 0;
			$AirportHaultMinutes = 0;
			$arrInsertFlightData = [];
			$arrInsertFlightDataNew = [];
			$keysIndexes = [];
			$arrAirlineName = [];
			$FiltStopCount = [];
			$FiltPriceRange = [];
			$AttPriceRange = [];
			$InBoundFlightResults = $this->array_searcher_tbo($AdditionalMarkup, $apiResponse['InBoundFlightResults']);
			foreach ($InBoundFlightResults as $key => $result) {
				if(!empty($result)){
					$IsGSTMandatory = isset($result['IsGSTMandatory']) ? $result['IsGSTMandatory'] : 0;
					$ResultIndex = $result['ResultIndex'];
					//$fareIdentifier = $result['ResultFareType'];
					$fareIdcolor = !empty($result['FareClassification']['Color']) ? $result['FareClassification']['Color'] : '#FFFFFF';

					$fareIdentifier = $fareIdentifier__ = !empty($result['FareClassification']['Type']) ? str_replace('.', '_', strtoupper($result['FareClassification']['Type'])) : strtoupper(trim($result['ResultFareType']));
					$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
					$fareremarks = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['remarks']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['remarks'] : '';
					$fareIdcolor = !empty($AddMarkup['color']) ? $AddMarkup['color'] : $fareIdcolor;

					$fareIdentifier = (isset($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier']) && !empty($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'])) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'] : $fareIdentifier__;
					$MiniFareRules = (isset($result['MiniFareRules']) && !empty($result['MiniFareRules'])) ? $result['MiniFareRules'] : [];
					$MiniFR = [];
					if ($MiniFareRules) {
						foreach ($MiniFareRules as $Minivalue) {
							if ($Minivalue) {
								foreach ($Minivalue as $kk => $Mini) {
									$Type = !empty($Mini['Type']) ? strtoupper($Mini['Type']) : 'NA';
									if (empty($Mini['To'])) {
										$TimeFrame = 'from ' . $Mini['From'] . ' ' . $Mini['Unit'] . ' & above before dept';
									} else {
										$TimeFrame = 'from ' . $Mini['From'] . ' To ' . $Mini['To'] . ' ' . $Mini['Unit'] . ' before dept';
									}
									//$MiniFR[$Type][$kk] = $Mini;
									$MiniFR[$Type][$kk]['sector'] = $Mini['JourneyPoints'];
									$MiniFR[$Type][$kk]['amount'] = $Mini['Details'];
									$MiniFR[$Type][$kk]['additionalFee'] = $getCancelCharge;
									$MiniFR[$Type][$kk]['TimeFrame'] = $TimeFrame;
									$MiniFR[$Type][$kk]['policyInfo'] = [];
								}
							}
						}
					}
					$tripbinfo = [];
					if ($result['Segments']) {
						foreach ($result['Segments'] as $value) {
							if ($value) {
								foreach ($value as $kk => $vl) {
									$Baggage = $vl['Baggage'];
									$CabinBaggage = $vl['CabinBaggage'];
									$SectorsCode = $vl['Origin']['Airport']['AirportCode'] . '-' . $vl['Destination']['Airport']['AirportCode'];
									$tripbinfo[$SectorsCode]['ADULT'] = ['cabin' => $CabinBaggage, 'checkin' => $Baggage];
									if (!empty($childCount)) {
										$tripbinfo[$SectorsCode]['CHILD'] = ['cabin' => $CabinBaggage, 'checkin' => $Baggage];
									}
									if (!empty($infantCount)) {
										$tripbinfo[$SectorsCode]['INFANT'] = ['cabin' => $CabinBaggage, 'checkin' => 'NA'];
									}
								}
							}
						}
					}

					$Source = $result['Source'];
					$IsLCC = $result['IsLCC'];
					$IsRefundable = $result['IsRefundable'];
					$AirlineRemark = $result['AirlineRemark'];

					$LastTicketDate = $result['LastTicketDate'];
					$TicketAdvisory = $result['TicketAdvisory'];
					$AirlineCode = $result['AirlineCode'];
					$ValidatingAirline = $result['ValidatingAirline'];
					$Baggage = $result['Segments'][0][0]['Baggage'];
					if ($IsLCC) {
						$CabinBaggage = !empty($result['Segments'][0][0]['CabinBaggage']) ? $result['Segments'][0][0]['CabinBaggage'] : '';
					} else {
						$CabinBaggage = !empty($result['Segments'][0][0]['CabinBaggage']) ? $result['Segments'][0][0]['CabinBaggage'] : '7 KG';
					}

					$Currency = $result['Fare']['Currency'];
					$currencySysId = !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
					$BaseFare = $result['Fare']['BaseFare'];
					$Tax = $result['Fare']['Tax'];

					$YQTax = $result['Fare']['YQTax'];
					$AdditionalTxnFeeOfrd = $result['Fare']['AdditionalTxnFeeOfrd'];
					$AdditionalTxnFeePub = $result['Fare']['AdditionalTxnFeePub'];
					$OtherCharges = $result['Fare']['OtherCharges'];
					$Discount = $result['Fare']['Discount'];
					$PublishedFare = $result['Fare']['PublishedFare'];
					$CommissionEarned = $result['Fare']['CommissionEarned'];
					$PLBEarned = $result['Fare']['PLBEarned'];
					$IncentiveEarned = $result['Fare']['IncentiveEarned'];
					$OfferedFare = $result['Fare']['OfferedFare'];
					$TdsOnCommission = $result['Fare']['TdsOnCommission'];
					$TdsOnPLB = $result['Fare']['TdsOnPLB'];
					$TdsOnIncentive = $result['Fare']['TdsOnIncentive'];
					$ServiceFee = $result['Fare']['ServiceFee'];
					$FareBreakdown = $result['FareBreakdown'];
					$totalCommissions = $result['Fare']['CommissionEarned'] + $result['Fare']['PLBEarned'] + $result['Fare']['IncentiveEarned'];
					$TotalPassengerCountForDiscount = $adultCount + $childCount;
					//$intDiscountPerHead = $totalCommissions / $TotalPassengerCountForDiscount;
					$intDiscountPerHead = $totalCommissions;

					$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']) ? $AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'] : 0;
					$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);

					$totalCommissionsOnTds = $result['Fare']['TdsOnCommission'] + $result['Fare']['TdsOnIncentive'] + $result['Fare']['TdsOnPLB'];
					$markUpArr = array(
						'getMarkup' => $getMarkup,
						'PublishedFare' => $PublishedFare,
						'OfferedFare' => $OfferedFare,
						'intCommissionEarned' => $totalCommissions,
						'TdsOnPLB' => $totalCommissionsOnTds,
						'intPLBEarned' => 0, //$PLBEarned,
						'intIncentiveEarned' => 0, //$IncentiveEarned,
						'intMemberCount' => $intMemberCount,
						'intFlightRoute' => $strFlightRoute,
						'interNationalSearch' => $interNationalSearch,
						'AddMarkup' => $AddMarkup,
					);

					$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTBO($markUpArr);
					//
					$AgencyMarkUp      = $arrMarkUps['intAgencyFixMarkUp'];
					$intGTXMarkUp      = $arrMarkUps['intGTXMarkUp'];
					$intFareWithGTXMarkUp = $arrMarkUps['intFareWithGTXMarkUp'];

					$intOfferedFare = $arrMarkUps['intOfferedFare'];
					if ($interNationalSearch == 1) {
						$intGTXMarkUp = (($arrMarkUps['intGTXMarkUp'] * $intMemberCount) * $strFlightRoute);
						$intSTaxOnGTXMarkUp = (($arrMarkUps['intSTaxOnGTXMarkUp'] * $intMemberCount) * $strFlightRoute);
						$intAgencyFixMarkUp = (($arrMarkUps['intAgencyFixMarkUp'] * $intMemberCount) * $strFlightRoute);
						$intSTaxOnAgencyFixMarkUp = (($arrMarkUps['intSTaxOnAgencyFixMarkUp'] * $intMemberCount) * $strFlightRoute);
					} else {
						$intGTXMarkUp = ($arrMarkUps['intGTXMarkUp'] * $intMemberCount);
						$intSTaxOnGTXMarkUp = ($arrMarkUps['intSTaxOnGTXMarkUp'] * $intMemberCount);
						$intAgencyFixMarkUp = ($arrMarkUps['intAgencyFixMarkUp'] * $intMemberCount);
						$intSTaxOnAgencyFixMarkUp = ($arrMarkUps['intSTaxOnAgencyFixMarkUp'] * $intMemberCount);
					}

					$CommisionPass = $arrMarkUps['CommisionPass'];
					$intCommisionEarnedForAgency = $arrMarkUps['intCommisionEarnedForAgency'];
					$intPLBEarnedForAgency = $arrMarkUps['intPLBEarnedForAgency'];
					$intIncentiveEarnedForAgency = $arrMarkUps['intIncentiveEarnedForAgency'];
					$intTotalEarningsForAgency = $arrMarkUps['intTotalEarningsForAgency'] + $intAgencyFixMarkUp;

					$intGSTOnAgencyCommisionEarned = $arrMarkUps['intGSTOnAgencyCommisionEarned'];
					$intGSTOnAgencyPLBEarned = $arrMarkUps['intGSTOnAgencyPLBEarned'];
					$intGSTOnAgencyIncentiveEarned = $arrMarkUps['intGSTOnAgencyIncentiveEarned'];
					//$intTotalGSTAgencyEarnings = $intSTaxOnAgencyFixMarkUp + $intGSTOnAgencyCommisionEarned + $intGSTOnAgencyPLBEarned + $intGSTOnAgencyIncentiveEarned;
					$intTotalGSTAgencyEarnings = $intSTaxOnAgencyFixMarkUp;

					$intPublishedFare = 0; // CommisionPass $intOfferedFare+ $ServiceFee + $intGTXMarkUp + $intAgencyFixMarkUp + $intCommisionEarnedForAgency + $intPLBEarnedForAgency + $intIncentiveEarnedForAgency + $intTotalGSTAgencyEarnings;
					$intTotalOfferedForAllPax = 0;
					$intTotalCommissionEarned = 0;
					$countBreakUp = count($FareBreakdown);
					foreach ($FareBreakdown as $pk => $pax) {
						$intPassengerType       = $pax['PassengerType'];
						$intPassengerCount = isset($pax['PassengerCount']) ? $pax['PassengerCount'] : 0;
						$intBaseFare       = $pax['BaseFare'];
						$intTax            = $pax['Tax'];
						$OtherCharges_         = ($OtherCharges / $countBreakUp);
						$intDiscountPerHead_         = ($intDiscountPerHead / $countBreakUp);
						$intBaseFareCal             = $intBaseFare - $intDiscountPerHead_;
						$intFareOfferedToPax       = $intBaseFareCal + $intTax;
						//echo '<pre>';print_r($intBaseFareCal);
						$arrFareBreakdown[$pk] = [
							'intDiscountPerHead'      => $intDiscountPerHead_,
							'Currency'      => $pax['Currency'],
							'APIBaseFare'      => $pax['BaseFare'],
							'BaseFare'      => $pax['BaseFare'], //$intBaseFareCal,
							'Tax'           => $pax['Tax'],
							'YQTax'         => $pax['YQTax'],
							'OtherCharges'         => $OtherCharges_,
							'PassengerType' => $pax['PassengerType'],
							'PassengerCount' => $pax['PassengerCount'],
							'PGCharge'      => $pax['PGCharge'],
							'AdditionalTxnFeePub'   => $pax['AdditionalTxnFeePub'],
							'AdditionalTxnFeeOfrd'  => $pax['AdditionalTxnFeeOfrd'],
							'AgencyMarkUp'  => $AgencyMarkUp,
							'GTXMarkUp'  => $intGTXMarkUp,
							'FareOfferedToPax'  => $intFareOfferedToPax,
							'FixedMarkUp'  => ($intAgencyFixMarkUp / $countBreakUp),
							'GSTOnMarkUp'  => ($intSTaxOnAgencyFixMarkUp / $countBreakUp),
							'intTotalGST'  => ($intSTaxOnAgencyFixMarkUp / $countBreakUp),
							'ServiceFee'  => ($ServiceFee / $countBreakUp),
							'CommisionPass'  => ($CommisionPass / $countBreakUp),
							'intGTXMarkUp'  => $intGTXMarkUp,
							'GTXMarkUpGST'  => $intSTaxOnGTXMarkUp,
							'CommissionEarned'  => ($intCommisionEarnedForAgency / $countBreakUp),
							'IntCommission'  => $arrMarkUps['intCommissionEarned'],
						];
						if ($intPassengerType == 3) {
							$arrFareBreakdown[$pk]['CommisionPass'] = 0;
						}
						$arrFareBreakdown[$pk]['TDS'] = ($totalCommissionsOnTds / $countBreakUp);
						$arrFareBreakdown[$pk]['MF'] = 0;
						$arrFareBreakdown[$pk]['YQ'] = $pax['YQTax'];
						$arrFareBreakdown[$pk]['AGST'] = 0;
						$arrFareBreakdown[$pk]['MFT'] = 0;
						$arrFareBreakdown[$pk]['OT'] = ($pax['Tax'] + $OtherCharges_);
						$arrFareBreakdown[$pk]['MU'] = 0;
						$arrFareBreakdown[$pk]['YR'] = 0;
						$arrFareBreakdown[$pk]['ResultIndex'] = $ResultIndex;
						$arrFareBreakdown[$pk]['intCommisionEarnedForAgency'] = ($intCommisionEarnedForAgency / $countBreakUp);
						$arrFareBreakdown[$pk]['intPLBEarnedForAgency'] = ($intPLBEarnedForAgency / $countBreakUp);
						$arrFareBreakdown[$pk]['intIncentiveEarnedForAgency'] = ($intIncentiveEarnedForAgency / $countBreakUp);
						$arrFareBreakdown[$pk]['Baggage'] = ($Baggage);
						$arrFareBreakdown[$pk]['CabinBaggage'] = ($CabinBaggage);

						$intTotalOfferedForAllPax += $intFareOfferedToPax;
						$intTotalCommissionEarned += $intCommisionEarnedForAgency;

						$intPublishedFare += $intBaseFare + $OtherCharges_ + $intTax + ($totalCommissionsOnTds / $countBreakUp) + ($intAgencyFixMarkUp / $countBreakUp) + ($intSTaxOnAgencyFixMarkUp / $countBreakUp) + ($ServiceFee / $countBreakUp) - ($CommisionPass / $countBreakUp);
					}
					$arrFairRules[0] = array(
						"Currency" => $this->CurrencyTitle, //$Currency,
						"CurrencyRate" => $this->CurrencyRate, //$Currency,
						"currencySysId" => $this->CurrencyId,
						"BaseFare" => $BaseFare,
						"Tax" => $Tax,
						"YQTax" => $YQTax,
						"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
						"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
						"OtherCharges" => $OtherCharges,
						"Discount" => $Discount,
						"ServiceFee" => $ServiceFee,
						"PublishedFare" => ceil($intPublishedFare * $this->CurrencyRate),
						"PublishedFarePerPax" => ceil(($intPublishedFare / $intMemberCount)),
						"CommissionEarned" => $intTotalCommissionEarned,
						"FixedMarkUp" => $intAgencyFixMarkUp,
						"GSTOnMarkUp" => $intSTaxOnAgencyFixMarkUp,
						"PLBEarned" => $PLBEarned,
						"IncentiveEarned" => $IncentiveEarned,
						"OfferedFare" => $OfferedFare,
						"TdsOnCommission" => $TdsOnCommission,
						"TdsOnPLB" => $TdsOnPLB,
						"TdsOnIncentive" => $TdsOnIncentive,
						//"FareBreakdown" => $FareBreakdown, IsCabinBaggage
						"fareIdentifier" => $fareIdentifier,
						"colors" => $fareIdcolor,
						"Refundable" => $IsRefundable,
						"IsRefundableTxt" => $fareIdentifier,
						"AirlineRemark" => $AirlineRemark,
						"fareremarks" =>  $fareremarks,
						"PriceID" => $ResultIndex,
						"Baggage" => $Baggage,
						"CabinBaggage" => $CabinBaggage,
						"FareBreakdown" => $arrFareBreakdown,
						"arrMarkUps" => $arrMarkUps,
						"tripbinfo" => $tripbinfo,
						"MiniFR" => $MiniFR,
						"TaxSettingDetail" => $arrMarkUps['TaxSettingDetail'],
					);

					$originCity = $result['Segments'][0][0]['Origin']['Airport']['CityName'];
					$DestinationCity = $result['Segments'][0][0]['Destination']['Airport']['CityName'];
					$AirlineCode = $result['Segments'][0][0]['Airline']['AirlineCode'];
					$FlightNumber = $result['Segments'][0][0]['Airline']['FlightNumber'];
					$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
					$strAirlineName = $result['Segments'][0][0]['Airline']['AirlineName'];
					$strFareClass = $result['Segments'][0][0]['Airline']['FareClass'];
					$AccumulatedDuration = 0;
					$arrSegments = [];
					if (count($result['Segments'][0]) > 0) {
						$FlyingMinutes = 0;
						$countSeg = count($result['Segments'][0]);
						foreach ($result['Segments'][0] as $segmentsResult) {
							$Duration = $segmentsResult['Duration'];
							if ($countSeg >= 2) {
								$AccumulatedDuration += isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : (0);
							} else {
								$AccumulatedDuration += ($segmentsResult['Duration'] + $segmentsResult['GroundTime']);
							}
							//$AccumulatedDuration += isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : ($segmentsResult['Duration'] + isset($segmentsResult['GroundTime'])?$segmentsResult['GroundTime']:0);
							$FlyingMinutes = $FlyingMinutes + (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : ($segmentsResult['Duration'] + isset($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : 0));
							$LAYOVERMinutes = ((isset($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : 0));
							$DepTime = $segmentsResult['Origin']['DepTime'];
							$ArrTime = $segmentsResult['Destination']['ArrTime'];
							$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($LAYOVERMinutes);
							// FOR FLIGHT SEGMENTS.....
							$strBaggage = $segmentsResult['Baggage'];
							//$strCabinBaggage = $segmentsResult['CabinBaggage'];
							if ($IsLCC) {
								$strCabinBaggage = $segmentsResult['CabinBaggage'];
							} else {
								$strCabinBaggage = !empty($segmentsResult['CabinBaggage']) ? $segmentsResult['CabinBaggage'] : '7 KG ';
							}
							if (!empty($strBaggage)) {
								$IsBaggage = true;
							} else {
								$IsBaggage = false;
							}
							// if (!empty($strCabinBaggage)) {
							// 	$strCabinBaggage = $strCabinBaggage;
							// } else {
							// 	$strCabinBaggage = '';
							// }
							$TripIndicator = $segmentsResult['TripIndicator'];
							$SegmentIndicator = $segmentsResult['SegmentIndicator'];

							$strAirlineCode = $segmentsResult['Airline']['AirlineCode'];
							$AirlineName = $segmentsResult['Airline']['AirlineName'];
							$FlightNumber = $segmentsResult['Airline']['FlightNumber'];
							$FareClass = $segmentsResult['Airline']['FareClass'];

							$SegFlightNumber = $strAirlineCode . "-" . $FlightNumber;

							$DepTerminal = $segmentsResult['Origin']['Airport']['Terminal'];
							if (!empty($DepTerminal)) {
								$DepTerminal = $DepTerminal;
							} else {
								$DepTerminal = 0;
							}
							$ArrTerminal = $segmentsResult['Destination']['Airport']['Terminal'];
							if (!empty($ArrTerminal)) {
								$ArrTerminal = $ArrTerminal;
							} else {
								$ArrTerminal = 0;
							}

							$originAirportName = $segmentsResult['Origin']['Airport']['AirportName'];
							$originAirportCode = $segmentsResult['Origin']['Airport']['AirportCode'];
							$originCityName = $segmentsResult['Origin']['Airport']['CityName'];
							$originCountryName = $segmentsResult['Origin']['Airport']['CountryName'];
							$originDepTime = $segmentsResult['Origin']['DepTime'];

							$destinationAirportName = $segmentsResult['Destination']['Airport']['AirportName'];
							$destinationAirportCode = $segmentsResult['Destination']['Airport']['AirportCode'];
							$destinationCityName = $segmentsResult['Destination']['Airport']['CityName'];
							$destinationCountryName = $segmentsResult['Destination']['Airport']['CountryName'];
							$destinationArrTime = $segmentsResult['Destination']['ArrTime'];

							$Duration = $segmentsResult['Duration'];
							$GroundTime = $segmentsResult['GroundTime'];
							$Mile = $segmentsResult['Mile'];
							$StopOver = $segmentsResult['StopOver'];
							$StopPoint = $segmentsResult['StopPoint'];
							$StopPointArrivalTime = $segmentsResult['StopPointArrivalTime'];
							$StopPointDepartureTime = $segmentsResult['StopPointDepartureTime'];
							$Craft = $segmentsResult['Craft'];
							$Remark = $segmentsResult['Remark'];
							$IsETicketEligible = $segmentsResult['IsETicketEligible'];
							$NoOfSeatAvailable = !empty($segmentsResult['NoOfSeatAvailable']) ? $segmentsResult['NoOfSeatAvailable'] : 0;
							$FlightStatus = $segmentsResult['FlightStatus'];
							$Status = $segmentsResult['Status'];

							if ($GroundTime > 0) {
								$LAYOVERCity = $originCityName;
							} else {
								$LAYOVERCity = '';
							}
							$strAirlineCodeLogo = $strAirlineCode;

							$filePath = $_SERVER['DOCUMENT_ROOT'] . "/public/upload/AirlineLogo/";
							if (file_exists($filePath . $strAirlineCodeLogo . ".gif")) {
								$strAirlineLogo = $strAirlineCodeLogo . ".gif";
								$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
							} elseif (file_exists($filePath . $strAirlineCodeLogo . ".png")) {
								$strAirlineLogo = $strAirlineCodeLogo . ".png";
								$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
							} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpg")) {
								$strAirlineLogo = $strAirlineCodeLogo . ".jpg";
								$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
							} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpeg")) {
								$strAirlineLogo = $strAirlineCodeLogo . ".jpeg";
								$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
							} else {
								$filePath = $this->baseUrl . "public/upload/AirlineLogo/noimage.png";
							}


							$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->convertMinutesToHoursFormat((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0));

							$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($ArrTime);
							$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($DepTime);
							$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);

							//                        $strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CalculateTotalTime($strArrivalDtTime,$strDepartureDtTime);
							$arrSegments[] = array(
								"segmentid" => $FlightNumber,
								"originAirportName" => $originAirportName,
								"destinationAirportName" => $destinationAirportName,
								"originCityName" => $originCityName,
								"originCountryName" => $originCountryName,
								"destinationCityName" => $destinationCityName,
								"destinationCountryName" => $destinationCountryName,
								"destinationAirportCode" => $destinationAirportCode,
								"destinationAirportCode" => $destinationAirportCode,
								"destinationArrTime" => $destinationArrTime,
								"SegFlightNumber" => $SegFlightNumber,
								"AirlineCode" => $strAirlineCode,
								"AirlineName" => $AirlineName,
								"FareClass" => $FareClass,
								"originAirportCode" => $originAirportCode,
								"originDepTime" => $originDepTime,
								"TripIndicator" => $TripIndicator,
								"Baggage" => $strBaggage,
								"CabinBaggage" => $strCabinBaggage,
								"IsBaggage" => $IsBaggage,
								"IsCabinBaggage" => !empty($strCabinBaggage) ? true : false,
								"SegmentIndicator" => $SegmentIndicator,
								"Duration" => $Duration,
								"GroundTime" => $GroundTime,
								"Mile" => $Mile,
								"StopOver" => $StopOver,
								"StopPoint" => $StopPoint,
								"StopPointArrivalTime" => $StopPointArrivalTime,
								"StopPointDepartureTime" => $StopPointDepartureTime,
								"Craft" => $Craft,
								"Remark" => $Remark,
								"IsETicketEligible" => $IsETicketEligible,
								"FlightStatus" => $FlightStatus,
								"Status" => $Status,
								"NoOfSeatAvailable" => $NoOfSeatAvailable,
								"strDepartureDtTime" => $strDepartureDtTime,
								"strArrivalDtTime" => $strArrivalDtTime,
								"FlightDuration" => $strDuration,
								"LAYOVERDuration" => $LAYOVERDuration,
								"LAYOVERCity" => $LAYOVERCity,
								"DepTerminal" => $DepTerminal,
								"ArrTerminal" => $ArrTerminal,
								"filePath" => $filePath,
							);
							// FOR FLIGHT SEGMENTS.....
						}
					}
					$airlineSysId = !empty($arrAirlineList[$result['AirlineCode']]) ? $arrAirlineList[$result['AirlineCode']] : '0';
					$FlyingMinutes = $AccumulatedDuration;

					if (count($result['Segments'][0]) == 1) {
						$DepOrigin = $result['Segments'][0][0]['Origin'];
						$DepDestination = $result['Segments'][0][0]['Destination'];
					} elseif (count($result['Segments'][0]) == 2) {
						$DepOrigin = $result['Segments'][0][0]['Origin'];
						$DepDestination = $result['Segments'][0][1]['Destination'];
					} elseif (count($result['Segments'][0]) == 3) {
						$DepOrigin = $result['Segments'][0][0]['Origin'];
						$DepDestination = $result['Segments'][0][2]['Destination'];
					}

					$strSourceAirportCode = $DepOrigin['Airport']['AirportCode'];
					$strDestinationAirportCode = $DepDestination['Airport']['AirportCode'];
					if (count($result['Segments'][0]) > 1) {
						$SegmentsCount = count($result['Segments'][0]);
						$StopCount = $SegmentsCount - 1;
						$IsDirect = '0';
						$initialOriginDepTime = $result['Segments'][0][0]['Origin']['DepTime'];
						$initialOriginArrTime = $result['Segments'][0][1]['Destination']['ArrTime'];
					} else {
						$StopCount = '0';
						$IsDirect = '1';
						$initialOriginDepTime = $result['Segments'][0][0]['Origin']['DepTime'];
						$initialOriginArrTime = $result['Segments'][0][0]['Destination']['ArrTime'];
					}
					$strAirlineCodeEX = explode("-", trim($strFlightNumber));
					$strAirlineCodeLogo = $strAirlineCodeEX[0];

					$filePath = $_SERVER['DOCUMENT_ROOT'] . "/public/upload/AirlineLogo/";
					if (file_exists($filePath . $strAirlineCodeLogo . ".gif")) {
						$strAirlineLogo = $strAirlineCodeLogo . ".gif";
						$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
					} elseif (file_exists($filePath . $strAirlineCodeLogo . ".png")) {
						$strAirlineLogo = $strAirlineCodeLogo . ".png";
						$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
					} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpg")) {
						$strAirlineLogo = $strAirlineCodeLogo . ".jpg";
						$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
					} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpeg")) {
						$strAirlineLogo = $strAirlineCodeLogo . ".jpeg";
						$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
					} else {
						$filePath = $this->baseUrl . "public/upload/AirlineLogo/noimage.png";
					}


					$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($initialOriginArrTime);
					$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($initialOriginDepTime);
					$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
					if ($StopCount == 0) {
						$StopCountTxt = "Non-stop";
					} else {
						$StopCountTxt = $StopCount . " Stop(s)";
					}
					if ($IsRefundable) {
						$IsRefundableTxt = 'Refundable';
					} else {
						$IsRefundableTxt = 'Non Refundable';
					}
					$arrFairRules[0]['classOfBooking'] = $strFareClass;
					$arrFairRules[0]['FareClass'] = $flight_class;
					$arrFairRules[0]['Refundable'] = $IsRefundable;
					$arrFairRules[0]['IsRefundableTxt'] = $IsRefundableTxt;
					$arrFairRules[0]['SeatAvailable'] = $NoOfSeatAvailable;
					$arrFairRules[0]['IsGSTRequired'] = $IsGSTMandatory;
					$arrFairRules[0]['IsMealIncludes'] = ($IsLCC == 1) ? false : true;
					$arrFairRules[0]['IsBaggage'] = !empty($strBaggage) ? true : false;
					$arrFairRules[0]['IsCabinBaggage'] = !empty($strCabinBaggage) ? true : false;

					$LocalFromTime = str_replace('T', ' ', $initialOriginDepTime);
					$LocalToTime = str_replace('T', ' ', $initialOriginArrTime);
					$FlightNumber = $strFlightNumber;
					$FareClass = ''; //!empty($strFareClass)?$strFareClass:'';
					$newKey = $LocalFromTime . '' . $LocalToTime . '' . $FlightNumber . '' . $FareClass;

					$arrInsertFlightData[$key]['FlightNumber'] = $strFlightNumber;
					$arrInsertFlightData[$key]['SegFlightNumberArr'] = $strFlightNumber;
					$arrInsertFlightData[$key]['AirlineName'] = ucfirst(strtolower($strAirlineName));
					$arrInsertFlightData[$key]['AirlineCode'] = $AirlineCode;
					$arrInsertFlightData[$key]['AirInvenSysId'] = $arrAirlineList[$AirlineCode];
					$arrInsertFlightData[$key]['IsLCC'] = $IsLCC;
					$arrInsertFlightData[$key]['IsGSTMandatory'] = $IsGSTMandatory;
					$arrInsertFlightData[$key]['IsMealIncludes'] = ($IsLCC == 1) ? false : true;
					$arrInsertFlightData[$key]['IsBagIncludes'] = !empty($strBaggage) ? true : false;
					$arrInsertFlightData[$key]['IsCabinBagIncludes'] = !empty($strCabinBaggage) ? true : false;
					$arrInsertFlightData[$key]['IsRefundable'] = $IsRefundable;
					$arrInsertFlightData[$key]['IsRefundableTxt'] = $IsRefundableTxt;
					$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
					$arrInsertFlightData[$key]['AirlineSysId'] = $airlineSysId;
					$arrInsertFlightData[$key]['LocalFromTime'] = str_replace('T', ' ', $initialOriginDepTime);
					$arrInsertFlightData[$key]['FromUTCTime'] = $initialOriginDepTime;
					$arrInsertFlightData[$key]['LocalToTime'] = str_replace('T', ' ', $initialOriginArrTime);
					$arrInsertFlightData[$key]['DepartureDateTxt'] = date('D, d M', strtotime($initialOriginDepTime));
					$arrInsertFlightData[$key]['ArrivalDateTxt'] = date('D, d M', strtotime($initialOriginArrTime));
					$arrInsertFlightData[$key]['ToUTCTime'] = $initialOriginArrTime;
					$arrInsertFlightData[$key]['DepartureTime'] = $strDepartureDtTime;
					$arrInsertFlightData[$key]['ArrivalTime'] = $strArrivalDtTime;
					$arrInsertFlightData[$key]['IsDirect'] = $IsDirect;
					$arrInsertFlightData[$key]['FareClass'] = $strFareClass;
					$arrInsertFlightData[$key]['DayLightSavingDiff'] = $DayLightSavingDiff;
					$arrInsertFlightData[$key]['FlyingMinutes'] = $FlyingMinutes;
					$arrInsertFlightData[$key]['FlightDuration'] = $FlightDuration;
					$arrInsertFlightData[$key]['SourcePlaceSysId'] = $intSourceCityId;
					$arrInsertFlightData[$key]['DestPlaceSysId'] = $intDestinationCityId;
					$arrInsertFlightData[$key]['SourceAirportCode'] = $strSourceAirportCode;
					$arrInsertFlightData[$key]['DestAirportCode'] = $strDestinationAirportCode;
					$arrInsertFlightData[$key]['AirportHaultMinutes'] = $AirportHaultMinutes;
					$arrInsertFlightData[$key]['StopCount'] = $StopCountTxt;
					$arrInsertFlightData[$key]['Stops'] = '';
					$arrInsertFlightData[$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
					$arrInsertFlightData[$key]['TotalFlightMembers'] = $intMemberCount;
					$arrInsertFlightData[$key]['CurrencyType'] = $this->CurrencyId;
					$arrInsertFlightData[$key]['PublishedFare'] = $intPublishedFare; // As Discussed with GG
					$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format($intPublishedFare); // As Discussed with GG
					$arrInsertFlightData[$key]['CommissionEarned'] = $CommissionEarned;
					$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
					$arrInsertFlightData[$key]['JourneyType'] = $intJourneyType;
					$arrInsertFlightData[$key]['TripType'] = $intTripType;
					$arrInsertFlightData[$key]['ICSourceSysId'] = 3;
					$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
					$arrInsertFlightData[$key]['SearchFlightTraceId'] = $SearchFlightTraceId;
					$arrInsertFlightData[$key]['logo'] = $filePath;
					$arrInsertFlightData[$key]['FairRules'] = $arrFairRules;
					$arrInsertFlightData[$key]['Segments'] = $arrSegments;
					$arrInsertFlightData[$key]['IsNewMigration'] = true;

					$value = ($arrInsertFlightData[$key]);
					//echo '<pre>';print_r($arrInsertFlightData[$key]);

					if (!array_key_exists($newKey, $keysIndexes)) {
						array_push($arrInsertFlightDataNew, $value);
						$keysIndexes[$newKey] = sizeof($keysIndexes);
					} else {
						array_push($arrInsertFlightDataNew[$keysIndexes[$newKey]]['FairRules'], $value['FairRules'][0]);
					}

					$arrAirlineName[] = $AirlineCode . '-' . ucfirst(strtolower($strAirlineName));
					$FiltStopCount[] = $StopCountTxt;
					$AttPriceRange[] = $intPublishedFare;
				}
			}
			$ArrPriceUnique = array_unique(array_filter(array_values(array_merge($AttPriceRange, []))));
			$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, [])));
			$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, [])));
			$data = array('outbound' => [], 'inbound' => $arrInsertFlightDataNew, 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute,  'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'ArrPriceUnique' => $ArrPriceUnique);

			return ($data);
		} else {
			$data = array('outbound' => [], 'inbound' => [], 'arrAirlineName' => [], 'FiltStopCount' => [], 'ArrPriceUnique' => [], 'MinriceRange' => 0, 'MaxriceRange' => 0);
			return ($data);
		}
	}

	public function FlightDataRoundTripInternationalTBO($apiResponse, $getMarkup = null, $AdditionalMarkup = null)
	{
		$intResponseStatus = !empty($apiResponse['ResponseStatus']) ? $apiResponse['ResponseStatus'] : '0';
		if ($intResponseStatus == 1) {
			//$TaxSettingDetail = $this->getTaxSettingDetail($getMarkup['TaxSetting'], 1);
			//$getMarkup['TaxSettingDetail'] = $TaxSettingDetail;
			$arrAirlineList = $this->getAirlineIdsAndCodeList();

			// echo '<pre>';print_r($AdditionalMarkup['finalArr']);
			// For getting All currency Array
			$arrCurrencyList = $this->getCurrencyIdsAndSymbolList();
			$FlightClasses = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getFlightClassesTripJack();
			$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
			$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
			$SupplierType = 1;
			$getCancelCharge = $this->getCancelCharge($intCountryCode, $SupplierType);
			$strFlightRoute = trim($sessionFlightSearchParams->params['route']);
			$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';
			$flight_class = $FlightClasses[$sessionFlightSearchParams->params['flight_class']];
			$strDepatureDate = $sessionFlightSearchParams->params['departure_dates'];
			$strReturnDate = !empty($sessionFlightSearchParams->params['return_dates']) ? $sessionFlightSearchParams->params['return_dates'] : '';
			$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);
			$strSourceAirportCode = $sessionFlightSearchParams->params['from'];
			$strDestinationAirportCode = $sessionFlightSearchParams->params['to'];
			$adultCount = $sessionFlightSearchParams->params['adults'];
			$childCount = $sessionFlightSearchParams->params['child'];
			$infantCount = $sessionFlightSearchParams->params['infant'];
			$SearchFlightTraceId = $sessionFlightSearchParams->params['SearchFlightTraceId'];

			$intMemberCount = $adultCount + $childCount + $infantCount;

			$intSourceCityId = trim($sessionFlightSearchParams->params['sourceCityId']);
			$intDestinationCityId = trim($sessionFlightSearchParams->params['destinationCityId']);

			$arrDepatureDate = explode("/", $strDepatureDate);
			if (count($arrDepatureDate) > 0) {
				$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
			}

			if (!empty($strReturnDate)) {
				$arrReturnDepatureDate = explode("/", $strReturnDate);
				if (count($arrReturnDepatureDate) > 0) {
					$strReturnDate = $arrReturnDepatureDate[2] . "-" . $arrReturnDepatureDate[1] . "-" . $arrReturnDepatureDate[0];
				}
			}

			$localFromDateTime = date("Y-m-d h:i", strtotime($strDepatureDate));
			$localToDateTime = date("Y-m-d h:i", strtotime($strReturnDate));
			$arrCommonInsVariables = array(
				'strTraceId' => $strTraceId,
				'localFromDateTime' => $localFromDateTime,
				'localToDateTime' => $localToDateTime,
				'strSourceAirportCode' => $strSourceAirportCode,
				'strDestinationAirportCode' => $strDestinationAirportCode,
				'intMemberCount' => $intMemberCount,
				'intSourceCityId' => $intSourceCityId,
				'intDestinationCityId' => $intDestinationCityId,
				'JourneyType' => 2, // For Round Trips API Search
				'TripType' => 2,
				'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0,
			);

			$strTraceId = $arrCommonInsVariables['strTraceId'];
			$localFromDateTime = $arrCommonInsVariables['localFromDateTime'];
			$localToDateTime = $arrCommonInsVariables['localToDateTime'];

			$strSourceAirportCode = $arrCommonInsVariables['strSourceAirportCode'];
			$strDestinationAirportCode = $arrCommonInsVariables['strDestinationAirportCode'];
			$intMemberCount = $arrCommonInsVariables['intMemberCount'];
			$intSourceCityId = $arrCommonInsVariables['intSourceCityId'];
			$intDestinationCityId = $arrCommonInsVariables['intDestinationCityId'];
			$intJourneyType = $arrCommonInsVariables['JourneyType'];
			$intTripType = $arrCommonInsVariables['TripType'];
			$interNationalSearch = isset($arrCommonInsVariables['interNationalSearch']) ? $arrCommonInsVariables['interNationalSearch'] : '0';
			$DayLightSavingDiff = 0;
			$AirportHaultMinutes = 0;
			$arrInsertFlightData = [];
			$arrInsertFlightDataNew = [];
			$keysIndexes = [];
			$arrAirlineName = [];
			$FiltStopCount = [];
			$DesFiltStopCount = [];
			$AttPriceRange = [];
			$FiltPriceRange = [];
			$InterNationalFlightResults = $this->array_searcher_tbo($AdditionalMarkup, $apiResponse['InterNationalFlightResults']);
			foreach ($InterNationalFlightResults as $key => $result) {
				$IsGSTMandatory = isset($result['IsGSTMandatory']) ? $result['IsGSTMandatory'] : 0;
				$ResultIndex = $result['ResultIndex'];
				//$fareIdentifier = $result['ResultFareType'];
				$fareIdcolor = !empty($result['FareClassification']['Color']) ? $result['FareClassification']['Color'] : '#FFFFFF';

				// $fareIdentifier = $fareIdentifier__ = !empty($result['FareClassification']['Type']) ? $result['FareClassification']['Type'] : $result['ResultFareType'];
				$fareIdentifier = $fareIdentifier__ = !empty($result['FareClassification']['Type']) ? str_replace('.', '_', strtoupper($result['FareClassification']['Type'])) : strtoupper(trim($result['ResultFareType']));
				$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
				$fareremarks = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['remarks']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['remarks'] : '';
				$fareIdcolor = !empty($AddMarkup['color']) ? $AddMarkup['color'] : $fareIdcolor;
				$fareIdentifier = (isset($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier']) && !empty($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'])) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'] : $fareIdentifier__;

				$MiniFareRules = (isset($result['MiniFareRules']) && !empty($result['MiniFareRules'])) ? $result['MiniFareRules'] : [];
				$MiniFR = [];
				if ($MiniFareRules) {
					foreach ($MiniFareRules as $Minivalue) {
						if ($Minivalue) {
							foreach ($Minivalue as $kk => $Mini) {
								$Type = !empty($Mini['Type']) ? strtoupper($Mini['Type']) : 'NA';
								if (empty($Mini['To'])) {
									$TimeFrame = 'from ' . $Mini['From'] . ' ' . $Mini['Unit'] . ' & above before dept';
								} else {
									$TimeFrame = 'from ' . $Mini['From'] . ' To ' . $Mini['To'] . ' ' . $Mini['Unit'] . ' before dept';
								}
								//$MiniFR[$Type][$kk] = $Mini;
								$MiniFR[$Type][$kk]['sector'] = $Mini['JourneyPoints'];
								$MiniFR[$Type][$kk]['amount'] = $Mini['Details'];
								$MiniFR[$Type][$kk]['additionalFee'] = $getCancelCharge;
								$MiniFR[$Type][$kk]['TimeFrame'] = $TimeFrame;
								$MiniFR[$Type][$kk]['policyInfo'] = [];
							}
						}
					}
				}
				// echo "MiniFR<pre>";print_r($MiniFR);die;
				$tripbinfo = [];
				if ($result['Segments']) {
					foreach ($result['Segments'] as $value) {
						if ($value) {
							foreach ($value as $kk => $vl) {
								$Baggage = $vl['Baggage'];
								$CabinBaggage = $vl['CabinBaggage'];
								$SectorsCode = $vl['Origin']['Airport']['AirportCode'] . '-' . $vl['Destination']['Airport']['AirportCode'];
								$tripbinfo[$SectorsCode]['ADULT'] = ['cabin' => $CabinBaggage, 'checkin' => $Baggage];
								if (!empty($childCount)) {
									$tripbinfo[$SectorsCode]['CHILD'] = ['cabin' => $CabinBaggage, 'checkin' => $Baggage];
								}
								if (!empty($infantCount)) {
									$tripbinfo[$SectorsCode]['INFANT'] = ['cabin' => $CabinBaggage, 'checkin' => 'NA'];
								}
							}
						}
					}
				}

				$Source = $result['Source'];
				$IsLCC = $result['IsLCC'];
				$IsRefundable = $result['IsRefundable'];
				$AirlineRemark = $result['AirlineRemark'];
				$AirlineCode = isset($result['AirlineCode']) ? $result['AirlineCode'] : '';
				if (count($result['Segments'][0]) == 1) {
					$DepOrigin = $result['Segments'][0][0]['Origin'];
					$DepDestination = $result['Segments'][0][0]['Destination'];
					$DepData = $result['Segments'][0][0];
				} elseif (count($result['Segments'][0]) == 2) {
					$DepOrigin = $result['Segments'][0][0]['Origin'];
					$DepDestination = $result['Segments'][0][1]['Destination'];
					$DepData = $result['Segments'][0][1];
				} elseif (count($result['Segments'][0]) == 3) {
					$DepOrigin = $result['Segments'][0][0]['Origin'];
					$DepDestination = $result['Segments'][0][2]['Destination'];
					$DepData = $result['Segments'][0][2];
				}

				if (count($result['Segments'][1]) == 1) {
					$ArrOrigin = $result['Segments'][1][0]['Origin'];
					$ArrDestination = $result['Segments'][1][0]['Destination'];
					$ArrData = $result['Segments'][1][0];
				} elseif (count($result['Segments'][1]) == 2) {
					$ArrOrigin = $result['Segments'][1][0]['Origin'];
					$ArrDestination = $result['Segments'][1][1]['Destination'];
					$ArrData = $result['Segments'][1][1];
				} elseif (count($result['Segments'][1]) == 3) {
					$ArrOrigin = $result['Segments'][1][0]['Origin'];
					$ArrDestination = $result['Segments'][1][2]['Destination'];
					$ArrData = $result['Segments'][1][2];
				}elseif (count($result['Segments'][1]) == 4) {
					$ArrOrigin = $result['Segments'][1][0]['Origin'];
					$ArrDestination = $result['Segments'][1][3]['Destination'];
					$ArrData = $result['Segments'][1][3];
				}

				$Currency = $result['Fare']['Currency'];
				//                echo '<pre>';print_r($arrSegments);echo '</pre>';
				$currencySysId = !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
				$BaseFare = $result['Fare']['BaseFare'];
				$Tax = $result['Fare']['Tax'];

				$YQTax = $result['Fare']['YQTax'];
				$AdditionalTxnFeeOfrd = $result['Fare']['AdditionalTxnFeeOfrd'];
				$AdditionalTxnFeePub = $result['Fare']['AdditionalTxnFeePub'];
				$OtherCharges = $result['Fare']['OtherCharges'];
				$Discount = $result['Fare']['Discount'];
				$PublishedFare = $result['Fare']['PublishedFare'];
				$CommissionEarned = $result['Fare']['CommissionEarned'];
				$PLBEarned = $result['Fare']['PLBEarned'];
				$IncentiveEarned = $result['Fare']['IncentiveEarned'];
				$OfferedFare = $result['Fare']['OfferedFare'];
				$TdsOnCommission = $result['Fare']['TdsOnCommission'];
				$TdsOnPLB = $result['Fare']['TdsOnPLB'];
				$TdsOnIncentive = $result['Fare']['TdsOnIncentive'];
				$ServiceFee = $result['Fare']['ServiceFee'];
				$FareBreakdown = $result['FareBreakdown'];
				$totalCommissions = $result['Fare']['CommissionEarned'] + $result['Fare']['PLBEarned'] + $result['Fare']['IncentiveEarned'];
				$intDiscountPerHead = $totalCommissions;
				$totalCommissionsOnTds = $result['Fare']['TdsOnCommission'] + $result['Fare']['TdsOnIncentive'] + $result['Fare']['TdsOnPLB'];

				$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']) ? $AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'] : 0;
				$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);

				$markUpArr = array(
					'getMarkup' => $getMarkup,
					'PublishedFare' => $PublishedFare,
					'OfferedFare' => $OfferedFare,
					'intCommissionEarned' => $CommissionEarned,
					'intPLBEarned' => $PLBEarned,
					'intIncentiveEarned' => $IncentiveEarned,
					'intMemberCount' => $intMemberCount,
					'intFlightRoute' => $strFlightRoute,
					'interNationalSearch' => $interNationalSearch,
					'AddMarkup' => $AddMarkup,
				);
				// echo '<pre>';print_r($markUpArr);die;
				$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTBO($markUpArr);

				$AgencyMarkUp = $arrMarkUps['intAgencyFixMarkUp'];
				$intGTXMarkUp = $arrMarkUps['intGTXMarkUp'];
				$intFareWithGTXMarkUp = $arrMarkUps['intFareWithGTXMarkUp'];

				$intOfferedFare = $arrMarkUps['intOfferedFare'];
				if ($interNationalSearch == 1) {
					$intGTXMarkUp = (($arrMarkUps['intGTXMarkUp'] * $intMemberCount) * $strFlightRoute);
					$intSTaxOnGTXMarkUp = (($arrMarkUps['intSTaxOnGTXMarkUp'] * $intMemberCount) * $strFlightRoute);
					$intAgencyFixMarkUp = (($arrMarkUps['intAgencyFixMarkUp'] * $intMemberCount) * $strFlightRoute);
					$intSTaxOnAgencyFixMarkUp = (($arrMarkUps['intSTaxOnAgencyFixMarkUp'] * $intMemberCount) * $strFlightRoute);
				} else {
					$intGTXMarkUp = ($arrMarkUps['intGTXMarkUp'] * $intMemberCount);
					$intSTaxOnGTXMarkUp = ($arrMarkUps['intSTaxOnGTXMarkUp'] * $intMemberCount);
					$intAgencyFixMarkUp = ($arrMarkUps['intAgencyFixMarkUp'] * $intMemberCount);
					$intSTaxOnAgencyFixMarkUp = ($arrMarkUps['intSTaxOnAgencyFixMarkUp'] * $intMemberCount);
				}

				$CommisionPass = $arrMarkUps['CommisionPass'];
				$intCommisionEarnedForAgency = $arrMarkUps['intCommisionEarnedForAgency'];
				$intPLBEarnedForAgency = $arrMarkUps['intPLBEarnedForAgency'];
				$intIncentiveEarnedForAgency = $arrMarkUps['intIncentiveEarnedForAgency'];
				$intTotalEarningsForAgency = $arrMarkUps['intTotalEarningsForAgency'] + $intAgencyFixMarkUp;

				$intGSTOnAgencyCommisionEarned = $arrMarkUps['intGSTOnAgencyCommisionEarned'];
				$intGSTOnAgencyPLBEarned = $arrMarkUps['intGSTOnAgencyPLBEarned'];
				$intGSTOnAgencyIncentiveEarned = $arrMarkUps['intGSTOnAgencyIncentiveEarned'];
				$intTotalGSTAgencyEarnings = $intSTaxOnAgencyFixMarkUp + $intGSTOnAgencyCommisionEarned + $intGSTOnAgencyPLBEarned + $intGSTOnAgencyIncentiveEarned;

				$intPublishedFare = 0; //$intOfferedFare + $intGTXMarkUp + $intAgencyFixMarkUp + $intCommisionEarnedForAgency + $intPLBEarnedForAgency + $intIncentiveEarnedForAgency + $intTotalGSTAgencyEarnings;
				$intTotalOfferedForAllPax = 0;
				$intTotalCommissionEarned = 0;
				$countBreakUp = count($FareBreakdown);
				foreach ($FareBreakdown as $pk => $pax) {
					$intPassengerType       = $pax['PassengerType'];
					$intPassengerCount = isset($pax['PassengerCount']) ? $pax['PassengerCount'] : 0;
					$intBaseFare       = $pax['BaseFare'];
					$intTax            = $pax['Tax'];
					$OtherCharges_         = ($OtherCharges / $countBreakUp);
					$intDiscountPerHead_         = ($intDiscountPerHead / $countBreakUp);
					$intBaseFareCal             = $intBaseFare - $intDiscountPerHead_;
					$intFareOfferedToPax       = $intBaseFareCal + $intTax;
					//echo '<pre>';print_r($intBaseFareCal);
					$arrFareBreakdown[$pk] = [
						'intDiscountPerHead'      => $intDiscountPerHead_,
						'Currency'      => $pax['Currency'],
						'APIBaseFare'      => $pax['BaseFare'],
						'BaseFare'      => $pax['BaseFare'], //$intBaseFareCal,
						'Tax'           => $pax['Tax'],
						'YQTax'         => $pax['YQTax'],
						'OtherCharges'         => $OtherCharges_,
						'PassengerType' => $pax['PassengerType'],
						'PassengerCount' => $pax['PassengerCount'],
						'PGCharge'      => $pax['PGCharge'],
						'AdditionalTxnFeePub'   => $pax['AdditionalTxnFeePub'],
						'AdditionalTxnFeeOfrd'  => $pax['AdditionalTxnFeeOfrd'],
						'AgencyMarkUp'  => $AgencyMarkUp,
						'GTXMarkUp'  => $intGTXMarkUp,
						'FareOfferedToPax'  => $intFareOfferedToPax,
						'FixedMarkUp'  => ($intAgencyFixMarkUp / $countBreakUp),
						'GSTOnMarkUp'  => ($intSTaxOnAgencyFixMarkUp / $countBreakUp),
						'intTotalGST'  => ($intSTaxOnAgencyFixMarkUp / $countBreakUp),
						'ServiceFee'  => ($ServiceFee / $countBreakUp),
						'CommisionPass'  => ($CommisionPass / $countBreakUp),
						'intGTXMarkUp'  => $intGTXMarkUp,
						'GTXMarkUpGST'  => $intSTaxOnGTXMarkUp,
						'CommissionEarned'  => ($intCommisionEarnedForAgency / $countBreakUp),
						'IntCommission'  => $arrMarkUps['intCommissionEarned'],
					];
					$arrFareBreakdown[$pk]['TDS'] = ($totalCommissionsOnTds / $countBreakUp);
					$arrFareBreakdown[$pk]['MF'] = 0;
					$arrFareBreakdown[$pk]['YQ'] = $pax['YQTax'];
					$arrFareBreakdown[$pk]['AGST'] = 0;
					$arrFareBreakdown[$pk]['MFT'] = 0;
					$arrFareBreakdown[$pk]['OT'] = ($pax['Tax'] + $OtherCharges_);
					$arrFareBreakdown[$pk]['MU'] = 0;
					$arrFareBreakdown[$pk]['YR'] = 0;
					$arrFareBreakdown[$pk]['ResultIndex'] = $ResultIndex;
					$arrFareBreakdown[$pk]['intCommisionEarnedForAgency'] = ($intCommisionEarnedForAgency / $countBreakUp);
					$arrFareBreakdown[$pk]['intPLBEarnedForAgency'] = ($intPLBEarnedForAgency / $countBreakUp);
					$arrFareBreakdown[$pk]['intIncentiveEarnedForAgency'] = ($intIncentiveEarnedForAgency / $countBreakUp);

					$intTotalOfferedForAllPax += $intFareOfferedToPax;
					$intTotalCommissionEarned += $intCommisionEarnedForAgency;

					$intPublishedFare += $intBaseFare + $OtherCharges_ + $intTax + ($intAgencyFixMarkUp / $countBreakUp) + ($intSTaxOnAgencyFixMarkUp / $countBreakUp) + ($ServiceFee / $countBreakUp) - ($CommisionPass / $countBreakUp);
				}
				$arrFairRules[0] = array(
					"Currency" => $this->CurrencyTitle, //$Currency,
					"CurrencyRate" => $this->CurrencyRate, //$Currency,
					"currencySysId" => $this->CurrencyId,
					"BaseFare" => $BaseFare,
					"Tax" => $Tax,
					"YQTax" => $YQTax,
					"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
					"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
					"OtherCharges" => $OtherCharges,
					"Discount" => $Discount,
					"ServiceFee" => $ServiceFee,
					"PublishedFare" => ceil($intPublishedFare * $this->CurrencyRate),
					"PublishedFarePerPax" => ceil(($intPublishedFare / $intMemberCount)),
					"CommissionEarned" => $intTotalCommissionEarned,
					"FixedMarkUp" => $intAgencyFixMarkUp,
					"GSTOnMarkUp" => $intSTaxOnAgencyFixMarkUp,
					"PLBEarned" => $PLBEarned,
					"IncentiveEarned" => $IncentiveEarned,
					"OfferedFare" => $OfferedFare,
					"TdsOnCommission" => $TdsOnCommission,
					"TdsOnPLB" => $TdsOnPLB,
					"TdsOnIncentive" => $TdsOnIncentive,
					"fareIdentifier" => $fareIdentifier,
					"colors" => $fareIdcolor,
					"Refundable" => $IsRefundable,
					"IsRefundableTxt" => $fareIdentifier,
					"AirlineRemark" => $AirlineRemark,
					"fareremarks" =>  $fareremarks,
					"PriceID" => $ResultIndex,
					"FareBreakdown" => $arrFareBreakdown,
					"arrMarkUps" => $arrMarkUps,
					"TaxSettingDetail" => $arrMarkUps['TaxSettingDetail'],
					"tripbinfo" => $tripbinfo,
					"MiniFR" => $MiniFR,
				);

				if (count($result['Segments'][0]) > 1) {
					$SegmentsCount = count($result['Segments'][0]);
					$OriginStopCount = $SegmentsCount - 1;
				} else {
					$OriginStopCount = '0';
				}
				if (count($result['Segments'][1]) > 1) {
					$SegmentsCountDe = count($result['Segments'][1]);
					$DestinationStopCount = $SegmentsCountDe - 1;
				} else {
					$DestinationStopCount = '0';
				}
				if ($OriginStopCount == 0) {
					$OrStopCountTxt = "Non-stop";
				} else {
					$OrStopCountTxt = $OriginStopCount . " Stop(s)";
				}
				if ($DestinationStopCount == 0) {
					$DeStopCountTxt = "Non-stop";
				} else {
					$DeStopCountTxt = $DestinationStopCount . " Stop(s)";
				}
				//                echo $DestinationStopCount;
				if ($result['IsRefundable']) {
					$IsRefundableTxt = 'Refundable';
				} else {
					$IsRefundableTxt = 'Non Refundable';
				}

				$OrDepTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($DepOrigin['DepTime']);
				$OrArrTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($DepDestination['ArrTime']);

				$DeDepTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($ArrOrigin['DepTime']);
				$DeArrTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($ArrDestination['ArrTime']);

				$FlyingMinutes = (isset($DepData['AccumulatedDuration']) ? $DepData['AccumulatedDuration'] : ($DepData['Duration'] + $DepData['GroundTime']));
				//$FlyingMinutes = ((isset($DepData['Duration']) ? $DepData['Duration'] : 0) + (!empty($DepData['GroundTime']) ? $DepData['GroundTime'] : (isset($DepData['AccumulatedDuration']) ? $DepData['AccumulatedDuration'] : 0)));
				$OriFlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);

				$DeFlyingMinutes = ((isset($ArrData['AccumulatedDuration']) && $ArrData['AccumulatedDuration'] > 0) ? $ArrData['AccumulatedDuration'] : ($ArrData['Duration'] + $ArrData['GroundTime']));
				//$DeFlyingMinutes = ((isset($ArrData['Duration']) ? $ArrData['Duration'] : 0) + (!empty($ArrData['GroundTime']) ? $ArrData['GroundTime'] : (isset($ArrData['AccumulatedDuration']) ? $ArrData['AccumulatedDuration'] : 0)));
				$DesFlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($DeFlyingMinutes);

				$OrFlightNumber = $DepData['Airline']['AirlineCode'] . "-" . $DepData['Airline']['FlightNumber'];
				$DeFlightNumber = $ArrData['Airline']['AirlineCode'] . "-" . $ArrData['Airline']['FlightNumber'];
				$strAirlineCodeLogo = $DepData['Airline']['AirlineCode'];
				$DesAirlineCodeLogo = $ArrData['Airline']['AirlineCode'];
				$filePath = $_SERVER['DOCUMENT_ROOT'] . "/public/upload/AirlineLogo/";
				if (file_exists($filePath . $strAirlineCodeLogo . ".gif")) {
					$strAirlineLogo = $strAirlineCodeLogo . ".gif";
					$OrifilePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
				} elseif (file_exists($filePath . $strAirlineCodeLogo . ".png")) {
					$strAirlineLogo = $strAirlineCodeLogo . ".png";
					$OrifilePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
				} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpg")) {
					$strAirlineLogo = $strAirlineCodeLogo . ".jpg";
					$OrifilePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
				} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpeg")) {
					$strAirlineLogo = $strAirlineCodeLogo . ".jpeg";
					$OrifilePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
				} else {
					$OrifilePath = $this->baseUrl . "public/upload/AirlineLogo/noimage.png";
				}

				if (file_exists($filePath . $DesAirlineCodeLogo . ".gif")) {
					$strAirlineLogo = $DesAirlineCodeLogo . ".gif";
					$DesfilePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
				} elseif (file_exists($filePath . $DesAirlineCodeLogo . ".png")) {
					$strAirlineLogo = $DesAirlineCodeLogo . ".png";
					$DesfilePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
				} elseif (file_exists($filePath . $DesAirlineCodeLogo . ".jpg")) {
					$strAirlineLogo = $DesAirlineCodeLogo . ".jpg";
					$DesfilePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
				} elseif (file_exists($filePath . $DesAirlineCodeLogo . ".jpeg")) {
					$strAirlineLogo = $DesAirlineCodeLogo . ".jpeg";
					$DesfilePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
				} else {
					$DesfilePath = $this->baseUrl . "public/upload/AirlineLogo/noimage.png";
				}
				// FOR ONWARD TRIP SEGMENT
				$arroOriginSegments = [];
				if (count($result['Segments'][0]) > 0) {
					$FlyingMinutes = 0;
					foreach ($result['Segments'][0] as $kk => $segmentsResult) {
						$FlyingMinutes = $FlyingMinutes + (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : ($segmentsResult['Duration'] + $segmentsResult['GroundTime']));
						//$FlyingMinutes = $FlyingMinutes + ((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0) + (!empty($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : 0)));
						$LAYOVERMinutes = ((isset($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : 0));
						$DepTime = $segmentsResult['Origin']['DepTime'];
						$ArrTime = $segmentsResult['Destination']['ArrTime'];
						$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($LAYOVERMinutes);
						// FOR FLIGHT SEGMENTS.....
						$strBaggage = $segmentsResult['Baggage'];
						//$strCabinBaggage = $segmentsResult['CabinBaggage'];
						if ($IsLCC) {
							$strCabinBaggage = $segmentsResult['CabinBaggage'];
						} else {
							$strCabinBaggage = !empty($segmentsResult['CabinBaggage']) ? $segmentsResult['CabinBaggage'] : '7 KG ';
						}
						if (!empty($strBaggage)) {
							$IsBaggage = 1;
						} else {
							$IsBaggage = 0;
						}
						// if (!empty($strCabinBaggage)) {
						// 	$strCabinBaggage = $strCabinBaggage;
						// } else {
						// 	$strCabinBaggage = '0 KG';
						// }
						$TripIndicator = $segmentsResult['TripIndicator'];
						$SegmentIndicator = $segmentsResult['SegmentIndicator'];

						$strAirlineCode = $segmentsResult['Airline']['AirlineCode'];
						$AirlineName = $segmentsResult['Airline']['AirlineName'];
						$FlightNumber = $segmentsResult['Airline']['FlightNumber'];
						$FareClass = $segmentsResult['Airline']['FareClass'];

						$SegFlightNumber = $strAirlineCode . "-" . $FlightNumber;

						$DepTerminal = $segmentsResult['Origin']['Airport']['Terminal'];
						if (!empty($DepTerminal)) {
							$DepTerminal = $DepTerminal;
						} else {
							$DepTerminal = 0;
						}
						$ArrTerminal = $segmentsResult['Destination']['Airport']['Terminal'];
						if (!empty($ArrTerminal)) {
							$ArrTerminal = $ArrTerminal;
						} else {
							$ArrTerminal = 0;
						}

						$originAirportName = $segmentsResult['Origin']['Airport']['AirportName'];
						$originAirportCode = $segmentsResult['Origin']['Airport']['AirportCode'];
						$originCityName = $segmentsResult['Origin']['Airport']['CityName'];
						$originCountryName = $segmentsResult['Origin']['Airport']['CountryName'];
						$originDepTime = $segmentsResult['Origin']['DepTime'];

						$destinationAirportName = $segmentsResult['Destination']['Airport']['AirportName'];
						$destinationAirportCode = $segmentsResult['Destination']['Airport']['AirportCode'];
						$destinationCityName = $segmentsResult['Destination']['Airport']['CityName'];
						$destinationCountryName = $segmentsResult['Destination']['Airport']['CountryName'];
						$destinationArrTime = $segmentsResult['Destination']['ArrTime'];

						$Duration = $segmentsResult['Duration'];
						$GroundTime = $segmentsResult['GroundTime'];
						$Mile = $segmentsResult['Mile'];
						$StopOver = $segmentsResult['StopOver'];
						$StopPoint = $segmentsResult['StopPoint'];
						$StopPointArrivalTime = $segmentsResult['StopPointArrivalTime'];
						$StopPointDepartureTime = $segmentsResult['StopPointDepartureTime'];
						$Craft = $segmentsResult['Craft'];
						$Remark = $segmentsResult['Remark'];
						$IsETicketEligible = $segmentsResult['IsETicketEligible'];
						$NoOfSeatAvailable = !empty($segmentsResult['NoOfSeatAvailable']) ? $segmentsResult['NoOfSeatAvailable'] : 0;
						$FlightStatus = $segmentsResult['FlightStatus'];
						$Status = $segmentsResult['Status'];

						$strAirlineCodeLogo = $strAirlineCode;

						$filePath = $_SERVER['DOCUMENT_ROOT'] . "/public/upload/AirlineLogo/";
						if (file_exists($filePath . $strAirlineCodeLogo . ".gif")) {
							$strAirlineLogo = $strAirlineCodeLogo . ".gif";
							$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
						} elseif (file_exists($filePath . $strAirlineCodeLogo . ".png")) {
							$strAirlineLogo = $strAirlineCodeLogo . ".png";
							$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
						} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpg")) {
							$strAirlineLogo = $strAirlineCodeLogo . ".jpg";
							$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
						} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpeg")) {
							$strAirlineLogo = $strAirlineCodeLogo . ".jpeg";
							$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
						} else {
							$filePath = $this->baseUrl . "public/upload/AirlineLogo/noimage.png";
						}


						$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->convertMinutesToHoursFormat((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0));

						$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($ArrTime);
						$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($DepTime);

						$arroOriginSegments[$kk] = array(
							"isReturnSegment" => false,
							"originAirportName" => $originAirportName,
							"destinationAirportName" => $destinationAirportName,
							"originCityName" => $originCityName,
							"originCountryName" => $originCountryName,
							"destinationCityName" => $destinationCityName,
							"destinationCountryName" => $destinationCountryName,
							"originAirportCode" => $originAirportCode,
							"destinationAirportCode" => $destinationAirportCode,
							"originDepTime" => $originDepTime,
							"destinationArrTime" => $destinationArrTime,
							"SegFlightNumber" => $SegFlightNumber,
							"AirlineCode" => $strAirlineCode,
							"AirlineName" => $AirlineName,
							"FareClass" => $FareClass,
							"TripIndicator" => $TripIndicator,
							"Baggage" => $strBaggage,
							"CabinBaggage" => $strCabinBaggage,
							"IsBaggage" => $IsBaggage,
							"SegmentIndicator" => $SegmentIndicator,
							"Duration" => $Duration,
							"GroundTime" => $GroundTime,
							"Mile" => $Mile,
							"StopOver" => $StopOver,
							"StopPoint" => $StopPoint,
							"StopPointArrivalTime" => $StopPointArrivalTime,
							"StopPointDepartureTime" => $StopPointDepartureTime,
							"Craft" => $Craft,
							"Remark" => $Remark,
							"IsETicketEligible" => $IsETicketEligible,
							"FlightStatus" => $FlightStatus,
							"Status" => $Status,
							"NoOfSeatAvailable" => $NoOfSeatAvailable,
							"strDepartureDtTime" => $strDepartureDtTime,
							"strArrivalDtTime" => $strArrivalDtTime,
							"FlightDuration" => $strDuration,
							"LAYOVERDuration" => $LAYOVERDuration,
							"DepTerminal" => $DepTerminal,
							"ArrTerminal" => $ArrTerminal,
							"filePath" => $filePath,
						);
						$arrSegments[] = array(
							"Baggage" => $strBaggage,
							"CabinBaggage" => $strCabinBaggage,
							"IsBaggage" => $IsBaggage,
							"SegmentIndicator" => $SegmentIndicator,

						);
					}
				}
				// FOR RETURN TRIP SEGMENT
				$arrDestinationSegments = [];
				if (count($result['Segments'][1]) > 0) {
					$FlyingMinutes = 0;
					foreach ($result['Segments'][1] as $kkk => $segmentsResult1) {
						$FlyingMinutes = $FlyingMinutes + (isset($segmentsResult1['AccumulatedDuration']) ? $segmentsResult1['AccumulatedDuration'] : ($segmentsResult1['Duration'] + $segmentsResult1['GroundTime']));
						//$FlyingMinutes = $FlyingMinutes + ((isset($segmentsResult1['Duration']) ? $segmentsResult1['Duration'] : 0) + (!empty($segmentsResult1['GroundTime']) ? $segmentsResult1['GroundTime'] : (isset($segmentsResult1['AccumulatedDuration']) ? $segmentsResult1['AccumulatedDuration'] : 0)));
						$LAYOVERMinutes = ((isset($segmentsResult1['GroundTime']) ? $segmentsResult1['GroundTime'] : 0));
						$DepTime = $segmentsResult1['Origin']['DepTime'];
						$ArrTime = $segmentsResult1['Destination']['ArrTime'];
						$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($LAYOVERMinutes);
						// FOR FLIGHT SEGMENTS.....

						$strBaggage = $segmentsResult1['Baggage'];
						//$strCabinBaggage = $segmentsResult1['CabinBaggage'];
						if ($IsLCC) {
							$strCabinBaggage = $segmentsResult['CabinBaggage'];
						} else {
							$strCabinBaggage = !empty($segmentsResult['CabinBaggage']) ? $segmentsResult['CabinBaggage'] : '7 KG ';
						}
						if (!empty($strBaggage)) {
							$IsBaggage = 1;
						} else {
							$IsBaggage = 0;
						}
						// if (!empty($strCabinBaggage)) {
						// 	$strCabinBaggage = $strCabinBaggage;
						// } else {
						// 	$strCabinBaggage = '0 KG';
						// }
						$TripIndicator = $segmentsResult1['TripIndicator'];
						$SegmentIndicator = $segmentsResult1['SegmentIndicator'];

						$strAirlineCode = $segmentsResult1['Airline']['AirlineCode'];
						$AirlineName = $segmentsResult1['Airline']['AirlineName'];
						$FlightNumber = $segmentsResult1['Airline']['FlightNumber'];
						$FareClass = $segmentsResult1['Airline']['FareClass'];

						$SegFlightNumber = $strAirlineCode . "-" . $FlightNumber;

						$DepTerminal = $segmentsResult1['Origin']['Airport']['Terminal'];
						if (!empty($DepTerminal)) {
							$DepTerminal = $DepTerminal;
						} else {
							$DepTerminal = 0;
						}
						$ArrTerminal = $segmentsResult1['Destination']['Airport']['Terminal'];
						if (!empty($ArrTerminal)) {
							$ArrTerminal = $ArrTerminal;
						} else {
							$ArrTerminal = 0;
						}

						$originAirportName = $segmentsResult1['Origin']['Airport']['AirportName'];
						$originAirportCode = $segmentsResult1['Origin']['Airport']['AirportCode'];
						$originCityName = $segmentsResult1['Origin']['Airport']['CityName'];
						$originCountryName = $segmentsResult1['Origin']['Airport']['CountryName'];
						$originDepTime = $segmentsResult1['Origin']['DepTime'];

						$destinationAirportName = $segmentsResult1['Destination']['Airport']['AirportName'];
						$destinationAirportCode = $segmentsResult1['Destination']['Airport']['AirportCode'];
						$destinationCityName = $segmentsResult1['Destination']['Airport']['CityName'];
						$destinationCountryName = $segmentsResult1['Destination']['Airport']['CountryName'];
						$destinationArrTime = $segmentsResult1['Destination']['ArrTime'];

						$Duration = $segmentsResult1['Duration'];
						$GroundTime = $segmentsResult1['GroundTime'];
						$Mile = $segmentsResult1['Mile'];
						$StopOver = $segmentsResult1['StopOver'];
						$StopPoint = $segmentsResult1['StopPoint'];
						$StopPointArrivalTime = $segmentsResult1['StopPointArrivalTime'];
						$StopPointDepartureTime = $segmentsResult1['StopPointDepartureTime'];
						$Craft = $segmentsResult1['Craft'];
						$Remark = $segmentsResult1['Remark'];
						$IsETicketEligible = $segmentsResult1['IsETicketEligible'];
						$NoOfSeatAvailable = !empty($segmentsResult1['NoOfSeatAvailable']) ? $segmentsResult1['NoOfSeatAvailable'] : 0;
						$FlightStatus = $segmentsResult1['FlightStatus'];
						$Status = $segmentsResult1['Status'];

						$strAirlineCodeLogo = $strAirlineCode;

						$filePath = $_SERVER['DOCUMENT_ROOT'] . "/public/upload/AirlineLogo/";
						if (file_exists($filePath . $strAirlineCodeLogo . ".gif")) {
							$strAirlineLogo = $strAirlineCodeLogo . ".gif";
							$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
						} elseif (file_exists($filePath . $strAirlineCodeLogo . ".png")) {
							$strAirlineLogo = $strAirlineCodeLogo . ".png";
							$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
						} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpg")) {
							$strAirlineLogo = $strAirlineCodeLogo . ".jpg";
							$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
						} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpeg")) {
							$strAirlineLogo = $strAirlineCodeLogo . ".jpeg";
							$filePath = $this->baseUrl . "public/upload/AirlineLogo/" . $strAirlineLogo;
						} else {
							$filePath = $this->baseUrl . "public/upload/AirlineLogo/noimage.png";
						}


						$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->convertMinutesToHoursFormat((isset($segmentsResult1['Duration']) ? $segmentsResult1['Duration'] : 0));

						$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($ArrTime);
						$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($DepTime);

						$arrDestinationSegments[$kkk] = array(
							"isReturnSegment" => true,
							"originAirportName" => $originAirportName,
							"destinationAirportName" => $destinationAirportName,
							"originCityName" => $originCityName,
							"originCountryName" => $originCountryName,
							"destinationCityName" => $destinationCityName,
							"destinationCountryName" => $destinationCountryName,
							"originAirportCode" => $originAirportCode,
							"destinationAirportCode" => $destinationAirportCode,
							"originDepTime" => $originDepTime,
							"destinationArrTime" => $destinationArrTime,
							"SegFlightNumber" => $SegFlightNumber,
							"AirlineCode" => $strAirlineCode,
							"AirlineName" => $AirlineName,
							"FareClass" => $FareClass,
							"TripIndicator" => $TripIndicator,
							"Baggage" => $strBaggage,
							"CabinBaggage" => $strCabinBaggage,
							"IsBaggage" => $IsBaggage,
							"SegmentIndicator" => $SegmentIndicator,
							"Duration" => $Duration,
							"GroundTime" => $GroundTime,
							"Mile" => $Mile,
							"StopOver" => $StopOver,
							"StopPoint" => $StopPoint,
							"StopPointArrivalTime" => $StopPointArrivalTime,
							"StopPointDepartureTime" => $StopPointDepartureTime,
							"Craft" => $Craft,
							"Remark" => $Remark,
							"IsETicketEligible" => $IsETicketEligible,
							"FlightStatus" => $FlightStatus,
							"Status" => $Status,
							"NoOfSeatAvailable" => $NoOfSeatAvailable,
							"strDepartureDtTime" => $strDepartureDtTime,
							"strArrivalDtTime" => $strArrivalDtTime,
							"FlightDuration" => $strDuration,
							"LAYOVERDuration" => $LAYOVERDuration,
							"DepTerminal" => $DepTerminal,
							"ArrTerminal" => $ArrTerminal,
							"filePath" => $filePath,
						);
					}
				}
				$segmentMerge = array_values(array_merge($arroOriginSegments, $arrDestinationSegments));

				$LocalFromTime = $OrDepTime . $DeDepTime;
				$LocalToTime = $OrArrTime . $DeArrTime;
				$FlightNumber = $OrFlightNumber . $DeFlightNumber;
				$FareClass = ''; //!empty($strFareClass)?$strFareClass:'';
				$newKey = $LocalFromTime . '' . $LocalToTime . '' . $FlightNumber . '' . $FareClass;
				//echo json_encode($segmentMerge);
				//exit;
				$strFareClass = $DepDestination['Airline']['FareClass'];
				$arrFairRules[0]['classOfBooking'] = $strFareClass;
				$arrFairRules[0]['FareClass'] = $flight_class;
				$arrFairRules[0]['Refundable'] = $result['IsRefundable'];
				$arrFairRules[0]['IsRefundableTxt'] = $IsRefundableTxt;
				$arrFairRules[0]['SeatAvailable'] = $NoOfSeatAvailable;
				$arrFairRules[0]['IsGSTRequired'] = $IsGSTMandatory;
				$arrFairRules[0]['IsMealIncludes'] = ($result['IsLCC'] == 1) ? false : true;
				$arrFairRules[0]['IsBaggage'] = !empty($strBaggage) ? true : false;
				$arrFairRules[0]['IsCabinBaggage'] = !empty($strCabinBaggage) ? true : false;

				$arrInsertFlightData[$key]['origin']['FlightNumber'] = $DepData['Airline']['FlightNumber'];
				$arrInsertFlightData[$key]['origin']['AirlineName'] = $strAirlineName = $DepData['Airline']['AirlineName'];
				$arrInsertFlightData[$key]['origin']['AirlineCode'] = $AirlineCode = $DepData['Airline']['AirlineCode'];
				$arrInsertFlightData[$key]['origin']['OrFlightNumber'] = $OrFlightNumber;
				$arrInsertFlightData[$key]['origin']['SegFlightNumberArr'] = $OrFlightNumber;
				$arrInsertFlightData[$key]['origin']['Currency'] = $this->CurrencyTitle;
				$arrInsertFlightData[$key]['origin']['ResultIndex'] = $ResultIndex;
				$arrInsertFlightData[$key]['origin']['IsLCC'] = $result['IsLCC'];
				$arrInsertFlightData[$key]['origin']['IsGSTMandatory'] = $IsGSTMandatory;
				$arrInsertFlightData[$key]['origin']['IsRefundable'] = $result['IsRefundable'];
				$arrInsertFlightData[$key]['origin']['IsRefundableTxt'] = $IsRefundableTxt;
				$arrInsertFlightData[$key]['origin']['TravelDate'] = $strDepatureDate;
				$arrInsertFlightData[$key]['origin']['DepatureDate'] = date('d M Y', strtotime($strDepatureDate));
				$arrInsertFlightData[$key]['origin']['DepartureTime'] = $OrDepTime;
				$arrInsertFlightData[$key]['origin']['ArrivalTime'] = $OrArrTime;
				$arrInsertFlightData[$key]['origin']['SourceAirportCode'] = $DepOrigin['Airport']['AirportCode'];
				$arrInsertFlightData[$key]['origin']['SourceCityName'] = $DepOrigin['Airport']['CityName'];
				$arrInsertFlightData[$key]['origin']['DestAirportCode'] = $DepDestination['Airport']['AirportCode'];
				$arrInsertFlightData[$key]['origin']['DestCityName'] = $DepDestination['Airport']['CityName'];
				$arrInsertFlightData[$key]['origin']['StopCount'] = $OrStopCountTxt;
				$arrInsertFlightData[$key]['origin']['NoOfSeatAvailable'] = isset($DepData['NoOfSeatAvailable']) ? $DepData['NoOfSeatAvailable'] : 0;
				$arrInsertFlightData[$key]['origin']['TotalFlightMembers'] = $intMemberCount;
				$arrInsertFlightData[$key]['origin']['FlightDuration'] = $OriFlightDuration;
				$arrInsertFlightData[$key]['origin']['JourneyType'] = $intJourneyType;
				$arrInsertFlightData[$key]['origin']['TripType'] = $intTripType;
				$arrInsertFlightData[$key]['origin']['IsInternational'] = $interNationalSearch;
				$arrInsertFlightData[$key]['origin']['logo'] = $OrifilePath;
				$arrInsertFlightData[$key]['origin']['DepartureDateTxt'] = date('D, d M', strtotime($strDepatureDate));

				// $arrInsertFlightData[$key]['origin']['Segments'] = $arroOriginSegments;


				$arrInsertFlightData[$key]['destination']['FlightNumber'] = $ArrData['Airline']['FlightNumber'];
				$arrInsertFlightData[$key]['destination']['AirlineName'] = $ArrData['Airline']['AirlineName'];
				$arrInsertFlightData[$key]['destination']['DeFlightNumber'] = $DeFlightNumber;
				$arrInsertFlightData[$key]['destination']['SegFlightNumberArr'] = $DeFlightNumber;
				$arrInsertFlightData[$key]['destination']['Currency'] = $this->CurrencyTitle;
				$arrInsertFlightData[$key]['destination']['ResultIndex'] = $ResultIndex;
				$arrInsertFlightData[$key]['destination']['IsLCC'] = $result['IsLCC'];
				$arrInsertFlightData[$key]['destination']['IsGSTMandatory'] = $IsGSTMandatory;
				$arrInsertFlightData[$key]['destination']['IsRefundable'] = $result['IsRefundable'];
				$arrInsertFlightData[$key]['destination']['IsRefundableTxt'] = $IsRefundableTxt;
				$arrInsertFlightData[$key]['destination']['TravelDate'] = $strReturnDate;
				$arrInsertFlightData[$key]['destination']['ReturnDate'] = date('d M Y', strtotime($strReturnDate));
				$arrInsertFlightData[$key]['destination']['DepartureTime'] = $DeDepTime;
				$arrInsertFlightData[$key]['destination']['ArrivalTime'] = $DeArrTime;
				$arrInsertFlightData[$key]['destination']['SourceAirportCode'] = $ArrOrigin['Airport']['AirportCode'];
				$arrInsertFlightData[$key]['destination']['SourceCityName'] = $ArrOrigin['Airport']['CityName'];
				$arrInsertFlightData[$key]['destination']['DestAirportCode'] = $ArrDestination['Airport']['AirportCode'];
				$arrInsertFlightData[$key]['destination']['DestCityName'] = $ArrDestination['Airport']['CityName'];
				$arrInsertFlightData[$key]['destination']['StopCount'] = $DeStopCountTxt;
				$arrInsertFlightData[$key]['destination']['NoOfSeatAvailable'] = isset($ArrData['NoOfSeatAvailable']) ? $ArrData['NoOfSeatAvailable'] : 0;
				$arrInsertFlightData[$key]['destination']['TotalFlightMembers'] = $intMemberCount;
				$arrInsertFlightData[$key]['destination']['FlightDuration'] = $DesFlightDuration;
				$arrInsertFlightData[$key]['destination']['JourneyType'] = $intJourneyType;
				$arrInsertFlightData[$key]['destination']['TripType'] = $intTripType;
				$arrInsertFlightData[$key]['destination']['IsInternational'] = $interNationalSearch;
				$arrInsertFlightData[$key]['destination']['logo'] = $DesfilePath;
				$arrInsertFlightData[$key]['destination']['DepartureDateTxt'] = date('D, d M', strtotime($strReturnDate));
				// $arrInsertFlightData[$key]['destination']['Segments'] = $arrDestinationSegments;

				$arrInsertFlightData[$key]['FlightNumber']  = $DepData['Airline']['FlightNumber'];
				$arrInsertFlightData[$key]['AirlineCode']  = $DepData['Airline']['AirlineCode'];
				$arrInsertFlightData[$key]['SourcePlaceSysId'] = $arrCommonInsVariables['intSourceCityId'];
				$arrInsertFlightData[$key]['DestPlaceSysId'] = $arrCommonInsVariables['intDestinationCityId'];
				$arrInsertFlightData[$key]['SourceAirportCode'] = $arrCommonInsVariables['strSourceAirportCode'];
				$arrInsertFlightData[$key]['DestAirportCode']   = $arrCommonInsVariables['strDestinationAirportCode'];
				$arrInsertFlightData[$key]['PublishedFare'] = $intPublishedFare; // As Discussed with GG
				$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format($intPublishedFare);
				$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
				$arrInsertFlightData[$key]['IsLCC'] = $result['IsLCC'];
				$arrInsertFlightData[$key]['LocalFromTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? $arrCommonInsVariables['localFromDateTime'] : '';
				$arrInsertFlightData[$key]['FromUTCTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? $arrCommonInsVariables['localFromDateTime'] : '';
				$arrInsertFlightData[$key]['LocalToTime'] = isset($arrCommonInsVariables['localToDateTime']) ? $arrCommonInsVariables['localToDateTime'] : '';
				$arrInsertFlightData[$key]['ToUTCTime'] = isset($arrCommonInsVariables['localToDateTime']) ? $arrCommonInsVariables['localToDateTime'] : '';
				$arrInsertFlightData[$key]['IsGSTMandatory'] = $IsGSTMandatory;
				$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
				$arrInsertFlightData[$key]['FairRules'] = $arrFairRules;
				$arrInsertFlightData[$key]['StopCount'] = $OrStopCountTxt;
				$arrInsertFlightData[$key]['AirlineName'] = $strAirlineName;
				$arrInsertFlightData[$key]['IsRefundable'] = $result['IsRefundable'];
				$arrInsertFlightData[$key]['IsRefundableTxt'] = $IsRefundableTxt;
				$arrInsertFlightData[$key]['ICSourceSysId'] = 3;
				$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
				$arrInsertFlightData[$key]['SearchFlightTraceId'] = $SearchFlightTraceId;
				$arrInsertFlightData[$key]['DepartureTime'] = $OrDepTime;
				$arrInsertFlightData[$key]['ArrivalTime'] = $OrArrTime;
				$arrInsertFlightData[$key]['Segments'] = $segmentMerge;
				$arrInsertFlightData[$key]['IsNewMigration'] = true;
				///$InternationalData['FairRules'] = $arrFairRules; arrFareBreakdown
				$apiResponse['InterNationalFlightResults'][$key]['FareBreakdown'] = $arrFareBreakdown;
				// echo "<pre>";
				// print_r($arrFareBreakdown);
				// echo "<pre>";
				// print_r($apiResponse['InterNationalFlightResults'][$key]);
				// die; ArrPriceUnique
				$arrInsertFlightData[$key]['InternationalData'] = $apiResponse['InterNationalFlightResults'][$key];
				$arrInsertFlightData[$key]['arrCommonInsVariables'] = $arrCommonInsVariables;

				$value = ($arrInsertFlightData[$key]);
				//echo '<pre>';print_r($arrInsertFlightData[$key]);

				// if (!array_key_exists($newKey, $keysIndexes)) {
				// 	array_push($arrInsertFlightDataNew, $value);
				// 	$keysIndexes[$newKey] = sizeof($keysIndexes);
				// } else {
				// 	array_push($arrInsertFlightDataNew[$keysIndexes[$newKey]]['FairRules'], $value['FairRules'][0]);
				// }

				$AttPriceRange[] = ceil($intPublishedFare * $this->CurrencyRate);
				$arrAirlineName[] = $AirlineCode . '-' . $strAirlineName;
				$FiltStopCount[] = $OrStopCountTxt;
				$DesFiltStopCount[] = $DeStopCountTxt;
			}

			$arrAirlineName = array_unique($arrAirlineName);
			$FiltStopCount = array_unique($FiltStopCount);
			$AttPriceRange = array_unique($AttPriceRange);
			$data = array('outbound' => $arrInsertFlightData, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'ArrPriceUnique' => $AttPriceRange, 'AttPriceRange' => $AttPriceRange);

			return $data;
		} else {
			return false;
		}
	}
	public function get_duplicate_elements($array)
	{
		$res = array();
		$counts = array_count_values($array);
		foreach ($counts as $id => $count) {
			if ($count > 1) {
				$r = array();
				$keys = array_keys($array, $id);
				foreach ($keys as $k) $r[$k] = $id;
				$res[] = $r;
			}
		}
		return sizeof($res) > 0 ? $res : false;
	}
	public function FlightDataRoundTripJack($apiResponse, $getMarkup, $AdditionalMarkup)
	{

		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$intSourceCityId = trim($sessionFlightSearchParams->params['sourceCityId']);
		$intDestinationCityId = trim($sessionFlightSearchParams->params['destinationCityId']);
		$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);
		$adultCount = $sessionFlightSearchParams->params['adults'];
		$childCount = $sessionFlightSearchParams->params['child'];
		$infantCount = $sessionFlightSearchParams->params['infant'];
		$intMemberCount = $adultCount + $childCount + $infantCount;
		$strFlightRoute = trim($sessionFlightSearchParams->params['route']);
		$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
		$SearchFlightTraceId = $sessionFlightSearchParams->params['SearchFlightTraceId'];
		$intTatalPaxCT = $adultCount + $childCount;
		//$getMarkup = $this->getMarkup($intCountryCode);
		//$TaxSettingDetail = $this->getTaxSettingDetail($getMarkup['TaxSetting'], 1);
		//$getMarkup['TaxSettingDetail'] = $TaxSettingDetail;
		//$AdditionalMarkup = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAdditionalMarkup();
		$faretypeArr = $AdditionalMarkup['faretypeArr'];
		$arrAirlineList = $this->getAirlineIdsAndCodeList();
		$intJourneyType = 2;
		$intTripType = 1;
		$arrInsertFlightData = [];
		$arrAirlineName = [];
		$FiltStopCount = [];
		$FiltPriceRange = [];
		$AttPriceRange = [];
		$dddddddd = [];
		$keysIndexes = [];
		$arrInsertFlightDataNew = [];
		$intResponseStatus = $apiResponse['ResponseStatus'];
		$RETURN = $apiResponse['InBoundFlightResults'];
		if ($intResponseStatus == 1) {
			if ($RETURN) {
				foreach ($RETURN as $key => $result) {
					$SegmentInformation = $result['sI'];
					$totalPriceList = current($result['totalPriceList']);
					$IsRefundable = $totalPriceList['fd']['ADULT']['rT'];
					$NoOfSeatAvailable = $totalPriceList['fd']['ADULT']['sR']; //NoOfSeatAvailable
					$strFareClass = $totalPriceList['fd']['ADULT']['cB']; ///Cabin Baggage
					$IsMealIncludes = $totalPriceList['fd']['ADULT']['mI'];
					$bagInfo = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Check In Baggage
					$cabinbagInfo = $totalPriceList['fd']['ADULT']['bI']['cB']; ///Cabin Baggage
					$strTraceId = $totalPriceList['id'];
					$ResultIndex = $totalPriceList['id'];

					if (!empty($bagInfo)) {
						$IsBagIncludes = true;
					} else {
						$IsBagIncludes = false;
					}

					if (!empty($cabinbagInfo)) {
						$IscabinbagIncludes = true;
					} else {
						$IscabinbagIncludes = false;
					}

					if ($IsRefundable == 0) {
						$IsRefundableTxt = 'Non Refundable';
					} elseif ($IsRefundable == 1) {
						$IsRefundableTxt = 'Refundable';
					} else {
						$IsRefundableTxt = 'Partial Refundable';
					}
					$OriginSegments = current($SegmentInformation);
					$DestinationSegments = end($SegmentInformation);
					$arrSegments = [];
					$FlyingMinutes = 0;
					$TotalLAYOVERMinutes = 0;
					$LAYOVERCityArr = [];
					$PublishedFare = 0;
					$PublishedFareReverse = 0;
					$BaseFare = 0;
					$Tax = 0;
					$YQTax = 0;
					$OtherCharges = 0;
					$ServiceFee = 0;
					$FareBreakdown = [];
					$FairRulesArr = [];


					$SegFlightNumberArr = [];
					if ($SegmentInformation) {
						foreach ($SegmentInformation as $segments) {
							//echo '<pre>';print_r($segments);
							$segmentid = $segments['id'];
							$duration = $segments['duration'];
							$LAYOVERMinutes = $GroundTime = isset($segments['cT']) ? $segments['cT'] : 0;
							$LAYOVERCity = $LAYOVERCityArr[] = isset($segments['cT']) ? $segments['aa']['city'] : '';
							$FlyingMinutes += ($duration + $LAYOVERMinutes);
							$TotalLAYOVERMinutes += $LAYOVERMinutes;

							$FareClass = $segments['fd']['ADULT']['cB'];

							//$strBaggage = $segments['fd']['ADULT']['bI']['iB']; ///Checking Baggage
							//$strCabinBaggage = $segments['fd']['ADULT']['bI']['cB']; ////Cabin Baggage

							$FareClass = $totalPriceList['fd']['ADULT']['cB'];
							$strBaggage = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Checking Baggage
							$strCabinBaggage = $totalPriceList['fd']['ADULT']['bI']['cB']; ////Cabin Baggage

							if (!empty($strCabinBaggage)) {
								$IsCabinBaggage = true;
							} else {
								$IsCabinBaggage = false;
							}

							if (!empty($strCabinBaggage)) {
								$IsBaggage = true;
							} else {
								$IsBaggage = false;
							}

							if (!empty($strCabinBaggage)) {
								$IsCabinBaggage = true;
							} else {
								$IsCabinBaggage = false;
							}

							if (!empty($strBaggage)) {
								$IsBaggage = true;
							} else {
								$IsBaggage = false;
							}

							$AirlineCode = $segments['fD']['aI']['code'];
							$AirlineName = $segments['fD']['aI']['name'];
							$FlightNumber = $segments['fD']['fN'];
							$SegFlightNumber = $AirlineCode . "-" . $FlightNumber;

							$originAirportName = $segments['da']['name'];
							$originAirportCode = $segments['da']['code'];
							$originCityName = $segments['da']['city'];
							$originCountryName = $segments['da']['country'];
							$originDepTime = $segments['dt'];

							$destinationAirportName = $segments['aa']['name'];
							$destinationAirportCode = $segments['aa']['code'];
							$destinationCityName = $segments['aa']['city'];
							$destinationCountryName = $segments['aa']['country'];
							$destinationArrTime = $segments['at'];

							$DepTerminal = isset($segments['da']['terminal']) ? $segments['da']['terminal'] : '';
							$ArrTerminal = isset($segments['aa']['terminal']) ? $segments['aa']['terminal'] : '';

							$filePath = $this->getflightlogo($AirlineCode);

							$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->MinutesToHours($LAYOVERMinutes);

							$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($destinationArrTime);
							$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($originDepTime);
							$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($duration);
							$arrSegments[] = array(
								"originAirportName" => $originAirportName,
								"destinationAirportName" => $destinationAirportName,
								"originCityName" => $originCityName,
								"originCountryName" => $originCountryName,
								"destinationCityName" => $destinationCityName,
								"destinationCountryName" => $destinationCountryName,
								"destinationAirportCode" => $destinationAirportCode,
								"destinationAirportCode" => $destinationAirportCode,
								"destinationArrTime" => $destinationArrTime,
								"SegFlightNumber" => $SegFlightNumber,
								"AirlineCode" => $AirlineCode,
								"AirlineName" => $AirlineName,
								"FareClass" => $FareClass,
								"originAirportCode" => $originAirportCode,
								"originDepTime" => $originDepTime,
								"TripIndicator" => '', //$TripIndicator,
								"IsBaggage" => $IsBaggage,
								"IsCabinBaggage" => $IsCabinBaggage,
								"Baggage" => $strBaggage,
								"IsCabinBaggage" => $IscabinbagIncludes,
								"CabinBaggage" => $strCabinBaggage,
								"IsMealIncludes" => $IsMealIncludes,
								"Duration" => $duration,
								"GroundTime" => $GroundTime,
								"NoOfSeatAvailable" => $NoOfSeatAvailable,
								"strDepartureDtTime" => $strDepartureDtTime,
								"strArrivalDtTime" => $strArrivalDtTime,
								"FlightDuration" => $strDuration,
								"LAYOVERDuration" => $LAYOVERDuration,
								"LAYOVERCity" => $LAYOVERCity,
								"DepTerminal" => $DepTerminal,
								"ArrTerminal" => $ArrTerminal,
								"filePath" => $filePath,
							);
							$SegFlightNumberArr[] = $SegFlightNumber;
							$segmentSector[$segmentid] = ['origin' => $originAirportCode, 'destination' => $destinationAirportCode];
						}
					}
					$AirlineCode = $OriginSegments['fD']['aI']['code'];
					$array_searcher = $this->array_searcher($AdditionalMarkup, $result['totalPriceList']);
					array_multisort($array_searcher);
					$tripbaggageinfo = [];
					if ($array_searcher) {
						foreach ($array_searcher as $kp => $price) {
							if (!empty($price)) {
								if ($price['tai']['tbi']) {
									foreach ($price['tai']['tbi'] as $keyss => $tbi) {
										$segc = isset($segmentSector[$keyss]) ? $segmentSector[$keyss] : '';
										$sectorKey = $segc['origin'] . '-' . $segc['destination'];
										if ($tbi) {
											foreach ($tbi as $kgk => $pbi) {
												if ($pbi) {
													foreach ($pbi as $gk => $vll) {
														$tripbaggageinfo[$sectorKey][$gk] = ['cabin' => isset($vll['cB']) ? $vll['cB'] : 'NA', 'checkin' => isset($vll['iB']) ? $vll['iB'] : 'NA'];
													}
												}
											}
										}
									}
								}
								$fareDetail = $price['fd'];

								$Refundable = isset($fareDetail['ADULT']['rT']) ? $fareDetail['ADULT']['rT'] : 0;
								$PriceID = $price['id'];
								$fareIdentifier = $price['fareIdentifier'];
								$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];

								$fareremarks = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['remarks']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['remarks'] : '';
								$fareIdentifier = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'] : '';
								$colors = !empty($AddMarkup['color']) ? $AddMarkup['color'] : '#000000';
								$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']) ? $AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'] : 0;
								$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);

								if (empty($fareIdentifier)) {
									$fareIdentifier = $price['fareIdentifier'];
								}
								$IsMealIncludes = isset($fareDetail['ADULT']['mI']) ? $fareDetail['ADULT']['mI'] : false;
								$strBaggage = $price['fd']['ADULT']['bI']['iB']; ///Checking Baggage
								$strCabinBaggage = $price['fd']['ADULT']['bI']['cB']; ////Cabin Baggage

								if (!empty($strCabinBaggage)) {
									$IsCabinBaggage = true;
								} else {
									$IsCabinBaggage = false;
								}

								if (!empty($strCabinBaggage)) {
									$IsBaggage = true;
								} else {
									$IsBaggage = false;
								}

								if ($price['fareIdentifier'] == 'SME') {
									$IsGSTRequired = true;
								} else {
									$IsGSTRequired = false;
								}
								if ($fareIdentifier == 'TACTICAL' || $fareIdentifier == 'COUPON') {
									$fareIdentifier = 'PROMO';
								}
								if ($Refundable == 0) {
									$IsRefundableTxt = 'Non Refundable';
								} elseif ($Refundable == 1) {
									$IsRefundableTxt = 'Refundable';
								} else {
									$IsRefundableTxt = 'Partial Refundable';
								}
								$ADULT = $fareDetail['ADULT']['fC']; //fare Components
								$CHILD = isset($fareDetail['CHILD']['fC']) ? $fareDetail['CHILD']['fC'] : []; //fare Components
								$INFANT = isset($fareDetail['INFANT']['fC']) ? $fareDetail['INFANT']['fC'] : []; //fare Components
								if (!empty($ADULT)) {
									$PaxTypeCount = 1;
								}
								if (!empty($CHILD)) {
									$PaxTypeCount = 2;
								}
								if (!empty($INFANT)) {
									$PaxTypeCount = 3;
								}
								$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
								$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
								$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents

								$ADULTNCMTDS = isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
								$CHILDNCMTDS = isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
								$INFANTNCMTDS = isset($fareDetail['INFANT']['afC']['NCM']['TDS']) ? $fareDetail['INFANT']['afC']['NCM']['TDS'] : 0; //TDS

								$ADULTNCMTOT = isset($fareDetail['ADULT']['afC']['NCM']['OT']) ? $fareDetail['ADULT']['afC']['NCM']['OT'] : 0; //- Gross Commission
								$CHILDNCMTOT = isset($fareDetail['CHILD']['afC']['NCM']['OT']) ? $fareDetail['CHILD']['afC']['NCM']['OT'] : 0; //- Gross Commission
								$INFANTNCMTOT = isset($fareDetail['INFANT']['afC']['NCM']['OT']) ? $fareDetail['INFANT']['afC']['NCM']['OT'] : 0; //- Gross Commission

								$AD_MF = isset($ADULTafC['MF']) ? $ADULTafC['MF'] : 0; //Management Fee
								$AD_YQ = isset($ADULTafC['YQ']) ? $ADULTafC['YQ'] : 0; //Fuel Surcharge
								$AD_AGST = isset($ADULTafC['AGST']) ? $ADULTafC['AGST'] : 0; //Airline GST Component
								$AD_MFT = isset($ADULTafC['MFT']) ? $ADULTafC['MFT'] : 0; //Management Fee Tax
								$AD_OT = isset($ADULTafC['OT']) ? $ADULTafC['OT'] : 0; //Other Charges
								$AD_MU = isset($ADULTafC['MU']) ? $ADULTafC['MU'] : 0; //markup
								$AD_YR = isset($ADULTafC['YR']) ? $ADULTafC['YR'] : 0; //Carrier Misc Fee

								$CH_MF = isset($CHILDafC['MF']) ? $CHILDafC['MF'] : 0; //Management Fee
								$CH_YQ = isset($CHILDafC['YQ']) ? $CHILDafC['YQ'] : 0; //Fuel Surcharge
								$CH_AGST = isset($CHILDafC['AGST']) ? $CHILDafC['AGST'] : 0; //Airline GST Component
								$CH_MFT = isset($CHILDafC['MFT']) ? $CHILDafC['MFT'] : 0; //Management Fee Tax
								$CH_OT = isset($CHILDafC['OT']) ? $CHILDafC['OT'] : 0; //Other Charges
								$CH_MU = isset($CHILDafC['MU']) ? $CHILDafC['MU'] : 0; //markup
								$CH_YR = isset($CHILDafC['YR']) ? $CHILDafC['YR'] : 0; //Carrier Misc Fee

								$IN_MF = isset($INFANTafC['MF']) ? $INFANTafC['MF'] : 0; //Management Fee
								$IN_YQ = isset($INFANTafC['YQ']) ? $INFANTafC['YQ'] : 0; //Fuel Surcharge
								$IN_AGST = isset($INFANTafC['AGST']) ? $INFANTafC['AGST'] : 0; //Airline GST Component
								$IN_MFT = isset($INFANTafC['MFT']) ? $INFANTafC['MFT'] : 0; //Management Fee Tax
								$IN_OT = isset($INFANTafC['OT']) ? $INFANTafC['OT'] : 0; //Other Charges
								$IN_MU = isset($INFANTafC['MU']) ? $INFANTafC['MU'] : 0; //markup
								$IN_YR = isset($INFANTafC['YR']) ? $INFANTafC['YR'] : 0; //Carrier Misc Fee

								if ($kp == 0) {
									$PublishedFare += (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
									$BaseFare += (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
									$Tax += (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
								}

								$PublishedFareIN = (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
								$BaseFareIN = (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
								$TaxIN = (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
								$NetFare = (($ADULT['NF'] * $adultCount) + ($CHILD['NF'] * $childCount) + ($INFANT['NF'] * $infantCount)); //Taxes and Fees
								$NetCommission = (($ADULT['NCM'] * $adultCount) + ($CHILD['NCM'] * $childCount) + ($INFANT['NCM'] * $infantCount)); //Taxes and Fees
								//echo '<pre>';print_r(($ADULTafC));echo '</pre>';
								$YQTax = (($AD_YQ * $adultCount) + ($CH_YQ * $childCount) + ($IN_YQ * $infantCount));
								$OtherCharges = (($AD_OT * $adultCount) + ($CH_OT * $childCount) + ($IN_OT * $infantCount));
								$ServiceFee = (($AD_MF * $adultCount) + ($CH_MF * $childCount) + ($IN_MF * $infantCount));
								$ManagementFeeTax = (($AD_MFT * $adultCount) + ($CH_MFT * $childCount) + ($IN_MFT * $infantCount));
								$AirlineGSTComponent = (($AD_AGST * $adultCount) + ($CH_AGST * $childCount) + ($IN_AGST * $infantCount));
								$CarrierMiscFee = (($AD_YR * $adultCount) + ($CH_YR * $childCount) + ($IN_YR * $infantCount));
								$MUFee = (($AD_MU * $adultCount) + ($CH_MU * $childCount) + ($IN_MU * $infantCount));
								$TdsOnPLB = (($ADULTNCMTDS * $adultCount) + ($CHILDNCMTDS * $childCount) + ($INFANTNCMTDS * $infantCount));
								//$NetCommission = (($ADULTNCMTOT * $adultCount) + ($CHILDNCMTOT * $childCount) + ($INFANTNCMTOT * $infantCount));

								//$PublishedFareIN = $NetFare;
								$PublishedFare = $PublishedFareIN;
								$CommissionEarned = $NetCommission;
								$PLBEarned = 0; //$result['Fare']['PLBEarned'];
								$IncentiveEarned = 0; //$result['Fare']['IncentiveEarned'];
								$OfferedFare = $PublishedFareIN;
								$markUpArr = array(
									'getMarkup' => $getMarkup,
									'PublishedFare' => $PublishedFare,
									'OfferedFare' => $NetFare,
									'intCommissionEarned' => $CommissionEarned,
									'TdsOnPLB' => $TdsOnPLB,
									'MUFee' => $MUFee,
									'intPLBEarned' => $PLBEarned,
									'intIncentiveEarned' => $IncentiveEarned,
									'intMemberCount' => $intMemberCount,
									'intFlightRoute' => $strFlightRoute,
									'interNationalSearch' => $interNationalSearch,
									'AddMarkup' => $AddMarkup,
								);
								//echo '<pre>';print_r(($markUpArr));echo '</pre>';die;
								$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr);
								if ($kp == 0) {
									$PublishedFareReverse += ($arrMarkUps['PublishFare']);
								}
								//echo '<pre>';print_r(($arrMarkUps));echo '</pre>';die;
								$markUpArrBR = array(
									'getMarkup' => $getMarkup,
									'PublishedFare' => ($ADULT['TF'] * $adultCount),
									'OfferedFare' => ($ADULT['NF'] * $adultCount),
									'intCommissionEarned' => ($ADULT['NCM'] * $adultCount),
									'TdsOnPLB' => ($ADULTNCMTDS * $adultCount),
									'MUFee' => ($AD_MU * $adultCount),
									'intPLBEarned' => $PLBEarned,
									'intIncentiveEarned' => $IncentiveEarned,
									'intMemberCount' => $adultCount,
									'intFlightRoute' => $strFlightRoute,
									'interNationalSearch' => $interNationalSearch,
									'AddMarkup' => $AddMarkup,
								);
								$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);

								$FareBreakdown[0]['Currency'] = $this->CurrencyTitle;
								$FareBreakdown[0]['PassengerType'] = 1;
								$FareBreakdown[0]['PassengerCount'] = $adultCount;
								$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $adultCount);
								$FareBreakdown[0]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
								$FareBreakdown[0]['BaseFare'] = ($ADULT['BF'] * $adultCount);
								$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $adultCount);
								$FareBreakdown[0]['TDS'] = ($ADULTNCMTDS * $adultCount);
								$FareBreakdown[0]['MF'] = ($AD_MF * $adultCount);
								$FareBreakdown[0]['YQ'] = ($AD_YQ * $adultCount);
								$FareBreakdown[0]['AGST'] = ($AD_AGST * $adultCount);
								$FareBreakdown[0]['MFT'] = ($AD_MFT * $adultCount);
								$FareBreakdown[0]['OT'] = ($AD_OT * $adultCount);
								$FareBreakdown[0]['MU'] = ($AD_MU * $adultCount);
								$FareBreakdown[0]['YR'] = ($AD_YR * $adultCount);
								$FareBreakdown[0]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
								$FareBreakdown[0]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
								$FareBreakdown[0]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
								$FareBreakdown[0]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
								$FareBreakdown[0]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
								$FareBreakdown[0]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
								$FareBreakdown[0]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
								$FareBreakdown[0]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
								$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
								$FareBreakdown[0]['GSTonComm'] = 0;
								$FareBreakdown[0]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
								$FareBreakdown[0]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
								$FareBreakdown[0]['AdditionalTxnFeeOfrd'] = 0;
								$FareBreakdown[0]['AdditionalTxnFeePub'] = 0;
								$FareBreakdown[0]['PGCharge'] = 0;
								$FareBreakdown[0]['Baggage'] = isset($fareDetail['ADULT']['bI']['iB']) ? $fareDetail['ADULT']['bI']['iB'] : []; //Check In Baggage;
								$FareBreakdown[0]['CabinBaggage'] = isset($fareDetail['ADULT']['bI']['cB']) ? $fareDetail['ADULT']['bI']['cB'] : []; //Cabin Baggage ;
								if (isset($fareDetail['CHILD'])) {
									$markUpArrBR = array(
										'getMarkup' => $getMarkup,
										'PublishedFare' => ($CHILD['TF'] * $childCount),
										'OfferedFare' => ($CHILD['NF'] * $childCount),
										'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
										'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
										'MUFee' => ($CH_MU * $childCount),
										'intPLBEarned' => $PLBEarned,
										'intIncentiveEarned' => $IncentiveEarned,
										'intMemberCount' => $childCount,
										'intFlightRoute' => $strFlightRoute,
										'interNationalSearch' => $interNationalSearch,
										'AddMarkup' => $AddMarkup,
									);
									$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
									$FareBreakdown[1]['Currency'] = $this->CurrencyTitle;
									$FareBreakdown[1]['PassengerType'] = 2;
									$FareBreakdown[1]['PassengerCount'] = $childCount;
									$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
									$FareBreakdown[1]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
									$FareBreakdown[1]['BaseFare'] = ($CHILD['BF'] * $childCount);
									$FareBreakdown[1]['CommissionEarned'] = ($CHILD['NCM'] * $childCount);
									$FareBreakdown[1]['TDS'] = ($CHILDNCMTDS * $childCount);
									$FareBreakdown[1]['MF'] = ($CH_MF * $childCount);
									$FareBreakdown[1]['YQ'] = ($CH_YQ * $childCount);
									$FareBreakdown[1]['AGST'] = ($CH_AGST * $childCount);
									$FareBreakdown[1]['MFT'] = ($CH_MFT * $childCount);
									$FareBreakdown[1]['OT'] = ($CH_OT * $childCount);
									$FareBreakdown[1]['MU'] = ($CH_MU * $childCount);
									$FareBreakdown[1]['YR'] = ($CH_YR * $childCount);
									$FareBreakdown[1]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
									$FareBreakdown[1]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
									$FareBreakdown[1]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
									$FareBreakdown[1]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
									$FareBreakdown[1]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
									$FareBreakdown[1]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
									$FareBreakdown[1]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
									$FareBreakdown[1]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
									$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
									$FareBreakdown[1]['GSTonComm'] = 0;
									$FareBreakdown[1]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
									$FareBreakdown[1]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
									$FareBreakdown[1]['AdditionalTxnFeeOfrd'] = 0;
									$FareBreakdown[1]['AdditionalTxnFeePub'] = 0;
									$FareBreakdown[1]['PGCharge'] = 0;
									$FareBreakdown[1]['Baggage'] = isset($fareDetail['CHILD']['bI']['iB']) ? $fareDetail['CHILD']['bI']['iB'] : []; //Check In Baggage;
									$FareBreakdown[1]['CabinBaggage'] = isset($fareDetail['CHILD']['bI']['cB']) ? $fareDetail['CHILD']['bI']['cB'] : []; //Cabin Baggage ;
								}
								if (isset($fareDetail['INFANT'])) {
									$markUpArrBR = array(
										'getMarkup' => $getMarkup,
										'PublishedFare' => ($INFANT['TF'] * $infantCount),
										'OfferedFare' => ($INFANT['NF'] * $infantCount),
										'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
										'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
										'MUFee' => ($IN_MU * $infantCount),
										'intPLBEarned' => $PLBEarned,
										'intIncentiveEarned' => $IncentiveEarned,
										'intMemberCount' => $infantCount,
										'intFlightRoute' => $strFlightRoute,
										'interNationalSearch' => $interNationalSearch,
										'AddMarkup' => $AddMarkup,
									);
									$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
									$FareBreakdown[2]['Currency'] = $this->CurrencyTitle;
									$FareBreakdown[2]['PassengerType'] = 3;
									$FareBreakdown[2]['PassengerCount'] = $infantCount;
									$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
									$FareBreakdown[2]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
									$FareBreakdown[2]['BaseFare'] = ($INFANT['BF'] * $infantCount);
									$FareBreakdown[2]['CommissionEarned'] = ($INFANT['NCM'] * $infantCount);
									$FareBreakdown[2]['TDS'] = ($INFANTNCMTDS * $infantCount);
									$FareBreakdown[2]['MF'] = ($IN_MF * $infantCount);
									$FareBreakdown[2]['YQ'] = ($IN_YQ * $infantCount);
									$FareBreakdown[2]['AGST'] = ($IN_AGST * $infantCount);
									$FareBreakdown[2]['OT'] = ($IN_OT * $infantCount);
									$FareBreakdown[2]['MFT'] = ($IN_MFT * $infantCount);
									$FareBreakdown[2]['MU'] = ($IN_MU * $infantCount);
									$FareBreakdown[2]['YR'] = ($IN_YR * $infantCount);
									$FareBreakdown[2]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
									$FareBreakdown[2]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
									$FareBreakdown[2]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
									$FareBreakdown[2]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
									$FareBreakdown[2]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
									$FareBreakdown[2]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
									$FareBreakdown[2]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
									$FareBreakdown[2]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
									$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
									$FareBreakdown[2]['GSTonComm'] = 0;
									$FareBreakdown[2]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
									$FareBreakdown[2]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
									$FareBreakdown[2]['AdditionalTxnFeeOfrd'] = 0;
									$FareBreakdown[2]['AdditionalTxnFeePub'] = 0;
									$FareBreakdown[2]['PGCharge'] = 0;
									$FareBreakdown[2]['Baggage'] = isset($fareDetail['INFANT']['bI']['iB']) ? $fareDetail['INFANT']['bI']['iB'] : []; //Check In Baggage;
									$FareBreakdown[2]['CabinBaggage'] = isset($fareDetail['INFANT']['bI']['cB']) ? $fareDetail['INFANT']['bI']['cB'] : []; //Cabin Baggage ;
								}
								//echo '<pre>';print_r($price);
								$FairRulesArr[$kp] = array(
									"Currency" => $this->CurrencyTitle, //$Currency,
									"CurrencyRate" => $this->CurrencyRate, //$Currency,
									"currencySysId" => $this->CurrencyId,
									"BaseFare" => $BaseFareIN,
									"Tax" => $TaxIN,
									"YQTax" => $YQTax,
									"OtherCharges" => $OtherCharges,
									"Discount" => 0, //$Discount,
									"ServiceFee" => $ServiceFee,
									"ManagementFeeTax" => $ManagementFeeTax,
									"AirlineGSTComponent" => $AirlineGSTComponent,
									"CarrierMiscFee" => $CarrierMiscFee,
									"MUFee" => $MUFee,
									"intPublishedFare" => $PublishedFareIN,
									"PublishedFare" => ceil($arrMarkUps['PublishFare'] * $this->CurrencyRate),
									"PublishedFarePerPax" => ceil((($arrMarkUps['PublishFare'] * $this->CurrencyRate) / $intMemberCount)),
									"OfferedFare" => $arrMarkUps['intOfferedFare'],
									"CommissionEarned" => $CommissionEarned,
									"PLBEarned" => $PLBEarned,
									"IncentiveEarned" => $IncentiveEarned,
									"TdsOnPLB" => $TdsOnPLB,
									"TdsOnIncentive" => 0,
									"AdditionalTxnFeeOfrd" => 0,
									"AdditionalTxnFeePub" => 0,
									"Refundable" => $Refundable,
									"IsRefundableTxt" => $IsRefundableTxt,
									"PriceID" => $PriceID,
									"IsGSTRequired" => $IsGSTRequired,
									"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
									"colors" => $colors,
									"fareremarks" => $fareremarks,
									"FareClass" => ucfirst(strtolower($fareDetail['ADULT']['cc'])),
									"CommisionPass" => $arrMarkUps['CommisionPass'],
									"intTotalGST" => $arrMarkUps['intTotalGST'],
									"apiMarkup" => $arrMarkUps['apiMarkup'],
									"IntCommission" => $arrMarkUps['IntCommission'],
									"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
									"NoOfSeatAvailable" => $fareDetail['ADULT']['sR'],
									"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
									"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
									"CommEarned" => $arrMarkUps['IntCommission'], //$arrMarkUps['intCommisionEarnedForAgency'],
									"GSTonComm" => 0,
									"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
									"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
									"AddiMarkup" => $arrMarkUps['AddiMarkup'],
									"AddiTaxOnMarkup" => $arrMarkUps['AddiTaxOnMarkup'],
									"IsBaggage" => $IsBaggage,
									"IsCabinBaggage" => $IsCabinBaggage,
									"Baggage" => $strBaggage,
									"CabinBaggage" => $strCabinBaggage,
									"tripbinfo" => $tripbaggageinfo,
									"IsMealIncludes" => $IsMealIncludes,

									// "FixedMarkUp" => $intAgencyFixMarkUp,
									// "GSTOnMarkUp" => $intSTaxOnAgencyFixMarkUp,
									// "CommEarned" => $intCommisionEarnedForAgency,
									// "GSTonComm" => $intGSTOnAgencyCommisionEarned,
									// "intGTXMarkUp" => $intGTXMarkUp,
									// "GTXMarkUpGST" => $intSTaxOnGTXMarkUp,
									"FareBreakdown" => $FareBreakdown,
									// "arrMarkUps" => $arrMarkUps,
									"TaxSettingDetail" => $arrMarkUps['TaxSettingDetail'],
								);
							}
						}
					}
					// $array_searcher = $this->array_searcher($AdditionalMarkup, $result['totalPriceList']);
					// array_multisort($array_searcher);
					// if ($array_searcher) {
					// 	foreach ($array_searcher as $kp => $price) {
					// 		if (!empty($price)) {
					// 			$fareDetail = $price['fd'];

					// 			$tripbaggageinfo = [];
					// 			if ($price['tai']['tbi']) {
					// 				foreach ($price['tai']['tbi'] as $keyss => $tbi) {
					// 					$segc = isset($segmentSector[$keyss]) ? $segmentSector[$keyss] : '';
					// 					$sectorKey = $segc['origin'] . '-' . $segc['destination'];
					// 					if ($tbi) {
					// 						foreach ($tbi as $kgk => $pbi) {
					// 							if ($pbi) {
					// 								foreach ($pbi as $gk => $vll) {
					// 									$tripbaggageinfo[$sectorKey][$gk] = ['cabin' => isset($vll['cB']) ? $vll['cB'] : 'NA', 'checkin' => isset($vll['iB']) ? $vll['iB'] : 'NA'];
					// 								}
					// 							}
					// 						}
					// 					}
					// 				}
					// 			}
					// 			//echo '<pre>';print_r(($fareDetail));echo '</pre>';
					// 			$Refundable = isset($fareDetail['ADULT']['rT']) ? $fareDetail['ADULT']['rT'] : 0;
					// 			$PriceID = $price['id'];
					// 			$fareIdentifier = $price['fareIdentifier'];
					// 			$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
					// 			$fareremarks = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['remarks']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['remarks'] : '';
					// 			//echo '<pre>';print_r(($fareremarks));echo '</pre>';
					// 			$fareIdentifier = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'] : '';

					// 			$colors = !empty($AddMarkup['color']) ? $AddMarkup['color'] : '#000000';
					// 			$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']) ? $AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'] : 0;
					// 			$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);

					// 			if (empty($fareIdentifier)) {
					// 				$fareIdentifier = $price['fareIdentifier'];
					// 			}
					// 			$IsMealIncludes = $fareDetail['ADULT']['mI'];
					// 			$strBaggage = $price['fd']['ADULT']['bI']['iB']; ///Checking Baggage
					// 			$strCabinBaggage = $price['fd']['ADULT']['bI']['cB']; ////Cabin Baggage

					// 			if (!empty($strCabinBaggage)) {
					// 				$IsCabinBaggage = true;
					// 			} else {
					// 				$IsCabinBaggage = false;
					// 			}

					// 			if (!empty($strCabinBaggage)) {
					// 				$IsBaggage = true;
					// 			} else {
					// 				$IsBaggage = false;
					// 			}

					// 			if ($price['fareIdentifier'] == 'SME') {
					// 				$IsGSTRequired = true;
					// 			} else {
					// 				$IsGSTRequired = false;
					// 			}
					// 			if ($fareIdentifier == 'TACTICAL' || $fareIdentifier == 'COUPON') {
					// 				$fareIdentifier = 'PROMO';
					// 			}
					// 			if ($Refundable == 0) {
					// 				$IsRefundableTxt = 'Non Refundable';
					// 			} elseif ($Refundable == 1) {
					// 				$IsRefundableTxt = 'Refundable';
					// 			} else {
					// 				$IsRefundableTxt = 'Partial Refundable';
					// 			}
					// 			$ADULT = $fareDetail['ADULT']['fC']; //fare Components
					// 			$CHILD = isset($fareDetail['CHILD']['fC']) ? $fareDetail['CHILD']['fC'] : []; //fare Components
					// 			$INFANT = isset($fareDetail['INFANT']['fC']) ? $fareDetail['INFANT']['fC'] : []; //fare Components
					// 			if (!empty($ADULT)) {
					// 				$PaxTypeCount = 1;
					// 			}
					// 			if (!empty($CHILD)) {
					// 				$PaxTypeCount = 2;
					// 			}
					// 			if (!empty($INFANT)) {
					// 				$PaxTypeCount = 3;
					// 			}
					// 			$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
					// 			$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
					// 			$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents

					// 			$ADULTNCMTDS = isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
					// 			$CHILDNCMTDS = isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
					// 			$INFANTNCMTDS = isset($fareDetail['INFANT']['afC']['NCM']['TDS']) ? $fareDetail['INFANT']['afC']['NCM']['TDS'] : 0; //TDS

					// 			$ADULTNCMTOT = isset($fareDetail['ADULT']['afC']['NCM']['OT']) ? $fareDetail['ADULT']['afC']['NCM']['OT'] : 0; //- Gross Commission
					// 			$CHILDNCMTOT = isset($fareDetail['CHILD']['afC']['NCM']['OT']) ? $fareDetail['CHILD']['afC']['NCM']['OT'] : 0; //- Gross Commission
					// 			$INFANTNCMTOT = isset($fareDetail['INFANT']['afC']['NCM']['OT']) ? $fareDetail['INFANT']['afC']['NCM']['OT'] : 0; //- Gross Commission

					// 			$AD_MF = isset($ADULTafC['MF']) ? $ADULTafC['MF'] : 0; //Management Fee
					// 			$AD_YQ = isset($ADULTafC['YQ']) ? $ADULTafC['YQ'] : 0; //Fuel Surcharge
					// 			$AD_AGST = isset($ADULTafC['AGST']) ? $ADULTafC['AGST'] : 0; //Airline GST Component
					// 			$AD_MFT = isset($ADULTafC['MFT']) ? $ADULTafC['MFT'] : 0; //Management Fee Tax
					// 			$AD_OT = isset($ADULTafC['OT']) ? $ADULTafC['OT'] : 0; //Other Charges
					// 			$AD_MU = isset($ADULTafC['MU']) ? $ADULTafC['MU'] : 0; //markup
					// 			$AD_YR = isset($ADULTafC['YR']) ? $ADULTafC['YR'] : 0; //Carrier Misc Fee

					// 			$CH_MF = isset($CHILDafC['MF']) ? $CHILDafC['MF'] : 0; //Management Fee
					// 			$CH_YQ = isset($CHILDafC['YQ']) ? $CHILDafC['YQ'] : 0; //Fuel Surcharge
					// 			$CH_AGST = isset($CHILDafC['AGST']) ? $CHILDafC['AGST'] : 0; //Airline GST Component
					// 			$CH_MFT = isset($CHILDafC['MFT']) ? $CHILDafC['MFT'] : 0; //Management Fee Tax
					// 			$CH_OT = isset($CHILDafC['OT']) ? $CHILDafC['OT'] : 0; //Other Charges
					// 			$CH_MU = isset($CHILDafC['MU']) ? $CHILDafC['MU'] : 0; //markup
					// 			$CH_YR = isset($CHILDafC['YR']) ? $CHILDafC['YR'] : 0; //Carrier Misc Fee

					// 			$IN_MF = isset($INFANTafC['MF']) ? $INFANTafC['MF'] : 0; //Management Fee
					// 			$IN_YQ = isset($INFANTafC['YQ']) ? $INFANTafC['YQ'] : 0; //Fuel Surcharge
					// 			$IN_AGST = isset($INFANTafC['AGST']) ? $INFANTafC['AGST'] : 0; //Airline GST Component
					// 			$IN_MFT = isset($INFANTafC['MFT']) ? $INFANTafC['MFT'] : 0; //Management Fee Tax
					// 			$IN_OT = isset($INFANTafC['OT']) ? $INFANTafC['OT'] : 0; //Other Charges
					// 			$IN_MU = isset($INFANTafC['MU']) ? $INFANTafC['MU'] : 0; //markup
					// 			$IN_YR = isset($INFANTafC['YR']) ? $INFANTafC['YR'] : 0; //Carrier Misc Fee

					// 			if ($kp == 0) {
					// 				$PublishedFare += (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
					// 				$BaseFare += (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
					// 				$Tax += (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
					// 			}

					// 			$PublishedFareIN = (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
					// 			$BaseFareIN = (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
					// 			$TaxIN = (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
					// 			$NetFare = (($ADULT['NF'] * $adultCount) + ($CHILD['NF'] * $childCount) + ($INFANT['NF'] * $infantCount)); //Taxes and Fees
					// 			$NetCommission = (($ADULT['NCM'] * $adultCount) + ($CHILD['NCM'] * $childCount) + ($INFANT['NCM'] * $infantCount)); //Taxes and Fees
					// 			//echo '<pre>';print_r(($ADULTafC));echo '</pre>';
					// 			$YQTax = (($AD_YQ * $adultCount) + ($CH_YQ * $childCount) + ($IN_YQ * $infantCount));
					// 			$OtherCharges = (($AD_OT * $adultCount) + ($CH_OT * $childCount) + ($IN_OT * $infantCount));
					// 			$ServiceFee = (($AD_MF * $adultCount) + ($CH_MF * $childCount) + ($IN_MF * $infantCount));
					// 			$ManagementFeeTax = (($AD_MFT * $adultCount) + ($CH_MFT * $childCount) + ($IN_MFT * $infantCount));
					// 			$AirlineGSTComponent = (($AD_AGST * $adultCount) + ($CH_AGST * $childCount) + ($IN_AGST * $infantCount));
					// 			$CarrierMiscFee = (($AD_YR * $adultCount) + ($CH_YR * $childCount) + ($IN_YR * $infantCount));
					// 			$MUFee = (($AD_MU * $adultCount) + ($CH_MU * $childCount) + ($IN_MU * $infantCount));
					// 			$TdsOnPLB = (($ADULTNCMTDS * $adultCount) + ($CHILDNCMTDS * $childCount) + ($INFANTNCMTDS * $infantCount));
					// 			//$NetCommission = (($ADULTNCMTOT * $adultCount) + ($CHILDNCMTOT * $childCount) + ($INFANTNCMTOT * $infantCount));

					// 			//$PublishedFareIN = $NetFare;
					// 			$PublishedFare = $PublishedFareIN;
					// 			$CommissionEarned = $NetCommission;
					// 			$PLBEarned = 0; //$result['Fare']['PLBEarned'];
					// 			$IncentiveEarned = 0; //$result['Fare']['IncentiveEarned'];
					// 			$OfferedFare = $PublishedFareIN;
					// 			$markUpArr = array(
					// 				'getMarkup' => $getMarkup,
					// 				'PublishedFare' => $PublishedFare,
					// 				'OfferedFare' => $NetFare,
					// 				'intCommissionEarned' => $CommissionEarned,
					// 				'TdsOnPLB' => $TdsOnPLB,
					// 				'MUFee' => $MUFee,
					// 				'intPLBEarned' => $PLBEarned,
					// 				'intIncentiveEarned' => $IncentiveEarned,
					// 				'intMemberCount' => $intMemberCount,
					// 				'intFlightRoute' => $strFlightRoute,
					// 				'interNationalSearch' => $interNationalSearch,
					// 				'AddMarkup' => $AddMarkup,
					// 			);
					// 			//echo '<pre>';print_r(($markUpArr));echo '</pre>';
					// 			$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr);
					// 			if ($kp == 0) {
					// 				$PublishedFareReverse += ($arrMarkUps['PublishFare']);
					// 			}
					// 			//echo '<pre>';print_r(($arrMarkUps));echo '</pre>';
					// 			$markUpArrBR = array(
					// 				'getMarkup' => $getMarkup,
					// 				'PublishedFare' => ($ADULT['TF'] * $adultCount),
					// 				'OfferedFare' => ($ADULT['NF'] * $adultCount),
					// 				'intCommissionEarned' => ($ADULT['NCM'] * $adultCount),
					// 				'TdsOnPLB' => ($ADULTNCMTDS * $adultCount),
					// 				'MUFee' => ($AD_MU * $adultCount),
					// 				'intPLBEarned' => $PLBEarned,
					// 				'intIncentiveEarned' => $IncentiveEarned,
					// 				'intMemberCount' => $adultCount,
					// 				'intFlightRoute' => $strFlightRoute,
					// 				'interNationalSearch' => $interNationalSearch,
					// 				'AddMarkup' => $AddMarkup,
					// 			);
					// 			$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);

					// 			$FareBreakdown[0]['Currency'] = $this->CurrencyTitle;
					// 			$FareBreakdown[0]['PassengerType'] = 1;
					// 			$FareBreakdown[0]['PassengerCount'] = $adultCount;
					// 			$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $adultCount);
					// 			$FareBreakdown[0]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
					// 			$FareBreakdown[0]['BaseFare'] = ($ADULT['BF'] * $adultCount);
					// 			$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $adultCount);
					// 			$FareBreakdown[0]['TDS'] = ($ADULTNCMTDS * $adultCount);
					// 			$FareBreakdown[0]['MF'] = ($AD_MF * $adultCount);
					// 			$FareBreakdown[0]['YQ'] = ($AD_YQ * $adultCount);
					// 			$FareBreakdown[0]['AGST'] = ($AD_AGST * $adultCount);
					// 			$FareBreakdown[0]['MFT'] = ($AD_MFT * $adultCount);
					// 			$FareBreakdown[0]['OT'] = ($AD_OT * $adultCount);
					// 			$FareBreakdown[0]['MU'] = ($AD_MU * $adultCount);
					// 			$FareBreakdown[0]['YR'] = ($AD_YR * $adultCount);
					// 			$FareBreakdown[0]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
					// 			$FareBreakdown[0]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
					// 			$FareBreakdown[0]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
					// 			$FareBreakdown[0]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
					// 			$FareBreakdown[0]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
					// 			$FareBreakdown[0]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
					// 			$FareBreakdown[0]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
					// 			$FareBreakdown[0]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
					// 			$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
					// 			$FareBreakdown[0]['GSTonComm'] = 0;
					// 			$FareBreakdown[0]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
					// 			$FareBreakdown[0]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
					// 			$FareBreakdown[0]['AdditionalTxnFeeOfrd'] = 0;
					// 			$FareBreakdown[0]['AdditionalTxnFeePub'] = 0;
					// 			$FareBreakdown[0]['PGCharge'] = 0;
					// 			$FareBreakdown[0]['Baggage'] = isset($fareDetail['ADULT']['bI']['iB']) ? $fareDetail['ADULT']['bI']['iB'] : []; //Check In Baggage;
					// 			$FareBreakdown[0]['CabinBaggage'] = isset($fareDetail['ADULT']['bI']['cB']) ? $fareDetail['ADULT']['bI']['cB'] : []; //Cabin Baggage ;
					// 			if (isset($fareDetail['CHILD'])) {
					// 				$markUpArrBR = array(
					// 					'getMarkup' => $getMarkup,
					// 					'PublishedFare' => ($CHILD['TF'] * $childCount),
					// 					'OfferedFare' => ($CHILD['NF'] * $childCount),
					// 					'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
					// 					'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
					// 					'MUFee' => ($CH_MU * $childCount),
					// 					'intPLBEarned' => $PLBEarned,
					// 					'intIncentiveEarned' => $IncentiveEarned,
					// 					'intMemberCount' => $childCount,
					// 					'intFlightRoute' => $strFlightRoute,
					// 					'interNationalSearch' => $interNationalSearch,
					// 					'AddMarkup' => $AddMarkup,
					// 				);
					// 				$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
					// 				$FareBreakdown[1]['Currency'] = $this->CurrencyTitle;
					// 				$FareBreakdown[1]['PassengerType'] = 2;
					// 				$FareBreakdown[1]['PassengerCount'] = $childCount;
					// 				$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
					// 				$FareBreakdown[1]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
					// 				$FareBreakdown[1]['BaseFare'] = ($CHILD['BF'] * $childCount);
					// 				$FareBreakdown[1]['CommissionEarned'] = ($CHILD['NCM'] * $childCount);
					// 				$FareBreakdown[1]['TDS'] = ($CHILDNCMTDS * $childCount);
					// 				$FareBreakdown[1]['MF'] = ($CH_MF * $childCount);
					// 				$FareBreakdown[1]['YQ'] = ($CH_YQ * $childCount);
					// 				$FareBreakdown[1]['AGST'] = ($CH_AGST * $childCount);
					// 				$FareBreakdown[1]['MFT'] = ($CH_MFT * $childCount);
					// 				$FareBreakdown[1]['OT'] = ($CH_OT * $childCount);
					// 				$FareBreakdown[1]['MU'] = ($CH_MU * $childCount);
					// 				$FareBreakdown[1]['YR'] = ($CH_YR * $childCount);
					// 				$FareBreakdown[1]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
					// 				$FareBreakdown[1]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
					// 				$FareBreakdown[1]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
					// 				$FareBreakdown[1]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
					// 				$FareBreakdown[1]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
					// 				$FareBreakdown[1]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
					// 				$FareBreakdown[1]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
					// 				$FareBreakdown[1]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
					// 				$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
					// 				$FareBreakdown[1]['GSTonComm'] = 0;
					// 				$FareBreakdown[1]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
					// 				$FareBreakdown[1]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
					// 				$FareBreakdown[1]['AdditionalTxnFeeOfrd'] = 0;
					// 				$FareBreakdown[1]['AdditionalTxnFeePub'] = 0;
					// 				$FareBreakdown[1]['PGCharge'] = 0;
					// 				$FareBreakdown[1]['Baggage'] = isset($fareDetail['CHILD']['bI']['iB']) ? $fareDetail['CHILD']['bI']['iB'] : []; //Check In Baggage;
					// 				$FareBreakdown[1]['CabinBaggage'] = isset($fareDetail['CHILD']['bI']['cB']) ? $fareDetail['CHILD']['bI']['cB'] : []; //Cabin Baggage ;
					// 			}
					// 			if (isset($fareDetail['INFANT'])) {
					// 				$markUpArrBR = array(
					// 					'getMarkup' => $getMarkup,
					// 					'PublishedFare' => ($INFANT['TF'] * $infantCount),
					// 					'OfferedFare' => ($INFANT['NF'] * $infantCount),
					// 					'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
					// 					'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
					// 					'MUFee' => ($IN_MU * $infantCount),
					// 					'intPLBEarned' => $PLBEarned,
					// 					'intIncentiveEarned' => $IncentiveEarned,
					// 					'intMemberCount' => $infantCount,
					// 					'intFlightRoute' => $strFlightRoute,
					// 					'interNationalSearch' => $interNationalSearch,
					// 					'AddMarkup' => $AddMarkup,
					// 				);
					// 				$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
					// 				$FareBreakdown[2]['Currency'] = $this->CurrencyTitle;
					// 				$FareBreakdown[2]['PassengerType'] = 3;
					// 				$FareBreakdown[2]['PassengerCount'] = $infantCount;
					// 				$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
					// 				$FareBreakdown[2]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
					// 				$FareBreakdown[2]['BaseFare'] = ($INFANT['BF'] * $infantCount);
					// 				$FareBreakdown[2]['CommissionEarned'] = ($INFANT['NCM'] * $infantCount);
					// 				$FareBreakdown[2]['TDS'] = ($INFANTNCMTDS * $infantCount);
					// 				$FareBreakdown[2]['MF'] = ($IN_MF * $infantCount);
					// 				$FareBreakdown[2]['YQ'] = ($IN_YQ * $infantCount);
					// 				$FareBreakdown[2]['AGST'] = ($IN_AGST * $infantCount);
					// 				$FareBreakdown[2]['OT'] = ($IN_OT * $infantCount);
					// 				$FareBreakdown[2]['MFT'] = ($IN_MFT * $infantCount);
					// 				$FareBreakdown[2]['MU'] = ($IN_MU * $infantCount);
					// 				$FareBreakdown[2]['YR'] = ($IN_YR * $infantCount);
					// 				$FareBreakdown[2]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
					// 				$FareBreakdown[2]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
					// 				$FareBreakdown[2]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
					// 				$FareBreakdown[2]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
					// 				$FareBreakdown[2]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
					// 				$FareBreakdown[2]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
					// 				$FareBreakdown[2]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
					// 				$FareBreakdown[2]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
					// 				$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
					// 				$FareBreakdown[2]['GSTonComm'] = 0;
					// 				$FareBreakdown[2]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
					// 				$FareBreakdown[2]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
					// 				$FareBreakdown[2]['AdditionalTxnFeeOfrd'] = 0;
					// 				$FareBreakdown[2]['AdditionalTxnFeePub'] = 0;
					// 				$FareBreakdown[2]['PGCharge'] = 0;
					// 				$FareBreakdown[2]['Baggage'] = isset($fareDetail['INFANT']['bI']['iB']) ? $fareDetail['INFANT']['bI']['iB'] : []; //Check In Baggage;
					// 				$FareBreakdown[2]['CabinBaggage'] = isset($fareDetail['INFANT']['bI']['cB']) ? $fareDetail['INFANT']['bI']['cB'] : []; //Cabin Baggage ;
					// 			}
					// 			//echo '<pre>';print_r($price);
					// 			$FairRulesArr[$kp] = array(
					// 				"Currency" => $this->CurrencyTitle, //$Currency,
					// 				"CurrencyRate" => $this->CurrencyRate, //$Currency,
					// 				"currencySysId" => $this->CurrencyId,
					// 				"BaseFare" => $BaseFareIN,
					// 				"Tax" => $TaxIN,
					// 				"YQTax" => $YQTax,
					// 				"OtherCharges" => $OtherCharges,
					// 				"Discount" => 0, //$Discount,
					// 				"ServiceFee" => $ServiceFee,
					// 				"ManagementFeeTax" => $ManagementFeeTax,
					// 				"AirlineGSTComponent" => $AirlineGSTComponent,
					// 				"CarrierMiscFee" => $CarrierMiscFee,
					// 				"MUFee" => $MUFee,
					// 				"intPublishedFare" => $PublishedFareIN,
					// 				"PublishedFare" => ceil($arrMarkUps['PublishFare'] * $this->CurrencyRate),
					// 				"PublishedFarePerPax" => ceil((($arrMarkUps['PublishFare'] * $this->CurrencyRate) / $intMemberCount)),
					// 				"OfferedFare" => $arrMarkUps['intOfferedFare'],
					// 				"CommissionEarned" => $CommissionEarned,
					// 				"PLBEarned" => $PLBEarned,
					// 				"IncentiveEarned" => $IncentiveEarned,
					// 				"TdsOnPLB" => $TdsOnPLB,
					// 				"TdsOnIncentive" => 0,
					// 				"AdditionalTxnFeeOfrd" => 0,
					// 				"AdditionalTxnFeePub" => 0,
					// 				"Refundable" => $Refundable,
					// 				"IsRefundableTxt" => $IsRefundableTxt,
					// 				"PriceID" => $PriceID,
					// 				"IsGSTRequired" => $IsGSTRequired,
					// 				"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
					// 				"colors" => $colors,
					// 				"fareremarks" => $fareremarks,
					// 				"FareClass" => ucfirst(strtolower($fareDetail['ADULT']['cc'])),
					// 				"intTotalGST" => $arrMarkUps['intTotalGST'],
					// 				"apiMarkup" => $arrMarkUps['apiMarkup'],
					// 				"IntCommission" => $arrMarkUps['IntCommission'],
					// 				"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
					// 				"NoOfSeatAvailable" => $fareDetail['ADULT']['sR'],
					// 				"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
					// 				"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
					// 				"CommEarned" => $arrMarkUps['IntCommission'], //$arrMarkUps['intCommisionEarnedForAgency'],
					// 				"GSTonComm" => 0,
					// 				"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
					// 				"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
					// 				"AddiMarkup" => $arrMarkUps['AddiMarkup'],
					// 				"AddiTaxOnMarkup" => $arrMarkUps['AddiTaxOnMarkup'],
					// 				"IsBaggage" => $IsBaggage,
					// 				"IsCabinBaggage" => $IsCabinBaggage,
					// 				"Baggage" => $strBaggage,
					// 				"CabinBaggage" => $strCabinBaggage,
					// 				"IsMealIncludes" => $IsMealIncludes,

					// 				// "FixedMarkUp" => $intAgencyFixMarkUp,
					// 				// "GSTOnMarkUp" => $intSTaxOnAgencyFixMarkUp,
					// 				// "CommEarned" => $intCommisionEarnedForAgency,
					// 				// "GSTonComm" => $intGSTOnAgencyCommisionEarned,
					// 				// "intGTXMarkUp" => $intGTXMarkUp,
					// 				// "GTXMarkUpGST" => $intSTaxOnGTXMarkUp,
					// 				"FareBreakdown" => $FareBreakdown,
					// 				// "arrMarkUps" => $arrMarkUps,
					// 				"TaxSettingDetail" => $arrMarkUps['TaxSettingDetail'],
					// 				"tripbinfo" => $tripbaggageinfo,
					// 			);
					// 		}
					// 	}
					// }
					$LAYOVERTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($TotalLAYOVERMinutes);

					$AirlineCode = $OriginSegments['fD']['aI']['code'];
					$FlightNumber = $OriginSegments['fD']['fN'];
					$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
					$strAirlineName = $OriginSegments['fD']['aI']['name'];
					$IsLCC = $OriginSegments['fD']['aI']['isLcc'];
					$strSourceAirportCode = $OriginSegments['da']['code'];
					$strDestinationAirportCode = $DestinationSegments['aa']['code'];

					$Stops = $DestinationSegments['sN'];

					if ($Stops == 0) {
						$StopCountTxt = "Non-stop";
					} else {
						$StopCountTxt = $Stops . " Stop(s)";
					}
					$filePath = $this->getflightlogo($AirlineCode);
					$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
					//$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
					$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($DestinationSegments['at']);
					$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($OriginSegments['dt']);
					$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
					$newKey = str_replace('T', ' ', $OriginSegments['dt']) . '' . str_replace('T', ' ', $DestinationSegments['at']) . '' . $strFlightNumber;
					if (!empty($FairRulesArr)) {
						$arrInsertFlightData[$key]['keyIndex'] = $key;
						$arrInsertFlightData[$key]['FlightNumber'] = $strFlightNumber;
						//$arrInsertFlightData[$key]['SegFlightNumberArr'] = implode(', ', $SegFlightNumberArr);
						if (count($SegFlightNumberArr) > 1) {
							$arrInsertFlightData[$key]['SegFlightNumberArr'] = $strFlightNumber . ' +' . (count($SegFlightNumberArr) - 1);
						} else {
							$arrInsertFlightData[$key]['SegFlightNumberArr'] = $strFlightNumber;
						}
						$arrInsertFlightData[$key]['AirlineName'] = $strAirlineName;
						$arrInsertFlightData[$key]['AirlineCode'] = $AirlineCode;
						//                $arrInsertFlightData[$key]['AirInvenSysId'] = 0;
						$arrInsertFlightData[$key]['IsLCC'] = $IsLCC;
						$arrInsertFlightData[$key]['IsMealIncludes'] = $IsMealIncludes;
						$arrInsertFlightData[$key]['IsBagIncludes'] = $IsBagIncludes;
						$arrInsertFlightData[$key]['IsRefundable'] = $IsRefundable;
						$arrInsertFlightData[$key]['IsRefundableTxt'] = $IsRefundableTxt;
						$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
						$arrInsertFlightData[$key]['AirlineSysId'] = $airlineSysId;
						$arrInsertFlightData[$key]['DepartureTime'] = $strDepartureDtTime;
						$arrInsertFlightData[$key]['ArrivalTime'] = $strArrivalDtTime;
						$arrInsertFlightData[$key]['TravelDate'] = $OriginSegments['dt'];
						$arrInsertFlightData[$key]['LocalFromTime'] = str_replace('T', ' ', $OriginSegments['dt']);
						$arrInsertFlightData[$key]['FromUTCTime'] = $OriginSegments['dt'];
						$arrInsertFlightData[$key]['LocalToTime'] = str_replace('T', ' ', $DestinationSegments['at']);
						$arrInsertFlightData[$key]['ToUTCTime'] = $DestinationSegments['at'];
						$arrInsertFlightData[$key]['IsDirect'] = 0;
						$arrInsertFlightData[$key]['FareClass'] = $strFareClass;
						//                $arrInsertFlightData[$key]['DayLightSavingDiff'] = $DayLightSavingDiff;
						$arrInsertFlightData[$key]['LAYOVERCity'] = isset($LAYOVERCityArr[0]) ? $LAYOVERCityArr[0] : '';
						$arrInsertFlightData[$key]['GroundTime'] = $TotalLAYOVERMinutes;
						$arrInsertFlightData[$key]['LAYOVERDuration'] = $LAYOVERTime;
						$arrInsertFlightData[$key]['FlyingMinutes'] = $FlyingMinutes;
						$arrInsertFlightData[$key]['DepartureDateTxt'] = date('D, d M', strtotime($OriginSegments['dt']));
						$arrInsertFlightData[$key]['ArrivalDateTxt'] = date('D, d M', strtotime($DestinationSegments['at']));
						$arrInsertFlightData[$key]['FlightDuration'] = $FlightDuration;
						$arrInsertFlightData[$key]['SourcePlaceSysId'] = $intSourceCityId;
						$arrInsertFlightData[$key]['DestPlaceSysId'] = $intDestinationCityId;
						$arrInsertFlightData[$key]['SourceAirportCode'] = $strSourceAirportCode;
						$arrInsertFlightData[$key]['DestAirportCode'] = $strDestinationAirportCode;
						//                $arrInsertFlightData[$key]['AirportHaultMinutes'] = $AirportHaultMinutes;
						$arrInsertFlightData[$key]['StopCount'] = $StopCountTxt;
						$arrInsertFlightData[$key]['Stops'] = $Stops;
						$arrInsertFlightData[$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
						$arrInsertFlightData[$key]['TotalFlightMembers'] = $intMemberCount;
						$arrInsertFlightData[$key]['CurrencyType'] = $this->CurrencyId;
						$arrInsertFlightData[$key]['PublishedFare'] = ($PublishedFareReverse * $this->CurrencyRate); // As Discussed with GG
						$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format(($PublishedFareReverse * $this->CurrencyRate)); // As Discussed with GG
						//                $arrInsertFlightData[$key]['CommissionEarned'] = $CommissionEarned;
						$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
						$arrInsertFlightData[$key]['JourneyType'] = $intJourneyType;
						$arrInsertFlightData[$key]['TripType'] = $intTripType;
						$arrInsertFlightData[$key]['SearchFlightTraceId'] = $SearchFlightTraceId;
						$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
						$arrInsertFlightData[$key]['logo'] = $filePath;
						$arrInsertFlightData[$key]['FairRules'] = $FairRulesArr;
						$arrInsertFlightData[$key]['Segments'] = $arrSegments;
						$arrInsertFlightData[$key]['ICSourceSysId'] = 7;

						$arrAirlineName[] = $AirlineCode . '-' . $strAirlineName;
						$AttPriceRange[] = $PublishedFareReverse;
						$FiltStopCount[] = $StopCountTxt;

						if ($FairRulesArr) {
							foreach ($FairRulesArr as $Fare) {
								$dddddddd[] = $Fare['PublishedFare'];
							}
						}
						$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
						$FilterArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strArrivalDtTime);
						$arrInsertFlightData[$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
						$arrInsertFlightData[$key]['FilterArrivalDtTime'] = $FilterArrivalDtTime;

						$value = ($arrInsertFlightData[$key]);
						if (!array_key_exists($newKey, $keysIndexes)) {
							array_push($arrInsertFlightDataNew, $value);
							$keysIndexes[$newKey] = sizeof($keysIndexes);
						} else {
							array_push($arrInsertFlightDataNew[$keysIndexes[$newKey]]['FairRules'], $value['FairRules'][0]);
						}
						//$FiltPriceRange[] = $FilterPrice = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_PRICE_RANGE_AED), ($PublishedFare * $this->CurrencyRate));
						//$arrInsertFlightData[$key]['FilterPrice'] = $FilterPrice;
					}
				}
			}

			$arrInsertFlightDataNew__ = [];
			if ($arrInsertFlightDataNew) {
				foreach ($arrInsertFlightDataNew as $kk => $vl) {
					$FairRules = $vl['FairRules'];
					$col = array_column($FairRules, "PublishedFare");
					array_multisort($col, SORT_ASC, $FairRules);
					$arrInsertFlightDataNew__[$kk] = $vl;
					$arrInsertFlightDataNew__[$kk]['PublishedFare'] = ceil($FairRules[0]['PublishedFare']);
					$arrInsertFlightDataNew__[$kk]['FairRules'] = $FairRules;
				}
			}
			sort($dddddddd);
			if (array_values(array_unique($dddddddd))) {
				foreach (array_values(array_unique($dddddddd)) as $Fares) {
					if ($this->CurrencyTitle == 'INR') {
						$CONST_PRICE_RANGE = unserialize(CONST_PRICE_RANGE_5000);
					} else {
						$CONST_PRICE_RANGE = unserialize(CONST_PRICE_RANGE_AED);
					}
					$FiltPriceRange[] = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue($CONST_PRICE_RANGE, round($Fares));
				}
			}

			$FiltPriceRangeU = (array_unique($FiltPriceRange));
			$arrAirlineName = array_unique($arrAirlineName);
			$FiltStopCount = array_unique($FiltStopCount);
			$AttPriceRange = array_unique($AttPriceRange);
			$data = array('inbound' => array_values($arrInsertFlightDataNew__), 'dddddddd' => $dddddddd, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'ArrPriceUnique' => $FiltPriceRangeU, 'AttPriceRange' => $AttPriceRange);
			return ($data);
		} else {
			return false;
		}
	}

	public function FlightDataRoundTripInternational($apiResponse, $getMarkup, $AdditionalMarkup)
	{

		$intResponseStatus = !empty($apiResponse['ResponseStatus']) ? $apiResponse['ResponseStatus'] : '0';
		if ($intResponseStatus == 1) {
			$arrAirlineList = $this->getAirlineIdsAndCodeList();
			// For getting All currency Array
			$arrCurrencyList = $this->getCurrencyIdsAndSymbolList();
			$arrAirlineList = $this->getAirlineIdsAndCodeList();
			$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
			$strFlightRoute = trim($sessionFlightSearchParams->params['route']);
			$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';
			//echo"<pre>";print_r($sessionFlightSearchParams);die;
			$strDepatureDate = $sessionFlightSearchParams->params['departure_dates'];
			$strReturnDate = !empty($sessionFlightSearchParams->params['return_dates']) ? $sessionFlightSearchParams->params['return_dates'] : '';
			$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);
			$strSourceAirportCode = $sessionFlightSearchParams->params['from'];
			$strDestinationAirportCode = $sessionFlightSearchParams->params['to'];
			$adultCount = $sessionFlightSearchParams->params['adults'];
			$childCount = $sessionFlightSearchParams->params['child'];
			$infantCount = $sessionFlightSearchParams->params['infant'];
			$SearchFlightTraceId = $sessionFlightSearchParams->params['SearchFlightTraceId'];

			$intMemberCount = $adultCount + $childCount + $infantCount;
			$strFlightRoute = trim($sessionFlightSearchParams->params['route']);
			$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
			$intTatalPaxCT = $adultCount + $childCount;
			//$getMarkup = $this->getMarkup($intCountryCode);
			//$TaxSettingDetail = $this->getTaxSettingDetail($getMarkup['TaxSetting'], 1);
			//$getMarkup['TaxSettingDetail'] = $TaxSettingDetail;
			//$AdditionalMarkup = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAdditionalMarkup();
			$faretypeArr = $AdditionalMarkup['faretypeArr'];
			

			$intSourceCityId = trim($sessionFlightSearchParams->params['sourceCityId']);
			$intDestinationCityId = trim($sessionFlightSearchParams->params['destinationCityId']);

			$arrDepatureDate = explode("/", $strDepatureDate);
			if (count($arrDepatureDate) > 0) {
				$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
			}

			if (!empty($strReturnDate)) {
				$arrReturnDepatureDate = explode("/", $strReturnDate);
				if (count($arrReturnDepatureDate) > 0) {
					$strReturnDate = $arrReturnDepatureDate[2] . "-" . $arrReturnDepatureDate[1] . "-" . $arrReturnDepatureDate[0];
				}
			}

			$localFromDateTime = date("Y-m-d h:i", strtotime($strDepatureDate));
			$localToDateTime = date("Y-m-d h:i", strtotime($strReturnDate));
			$arrCommonInsVariables = array(
				'strTraceId' => $strTraceId,
				'localFromDateTime' => $localFromDateTime,
				'localToDateTime' => $localToDateTime,
				'strSourceAirportCode' => $strSourceAirportCode,
				'strDestinationAirportCode' => $strDestinationAirportCode,
				'intMemberCount' => $intMemberCount,
				'intSourceCityId' => $intSourceCityId,
				'intDestinationCityId' => $intDestinationCityId,
				'JourneyType' => 2, // For Round Trips API Search
				'TripType' => 1,
				'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0
			);

			$strTraceId         = $arrCommonInsVariables['strTraceId'];
			$localFromDateTime  = $arrCommonInsVariables['localFromDateTime'];
			$localToDateTime    = $arrCommonInsVariables['localToDateTime'];

			$strSourceAirportCode    = $arrCommonInsVariables['strSourceAirportCode'];
			$strDestinationAirportCode    = $arrCommonInsVariables['strDestinationAirportCode'];
			$intMemberCount    = $arrCommonInsVariables['intMemberCount'];
			$intSourceCityId    = $arrCommonInsVariables['intSourceCityId'];
			$intDestinationCityId    = $arrCommonInsVariables['intDestinationCityId'];
			$intJourneyType    = $arrCommonInsVariables['JourneyType'];
			$intTripType    = $arrCommonInsVariables['TripType'];
			$interNationalSearch    = isset($arrCommonInsVariables['interNationalSearch']) ? $arrCommonInsVariables['interNationalSearch'] : '0';
			$DayLightSavingDiff = 0;
			$AirportHaultMinutes = 0;
			$arrInsertFlightData = [];
			$arrAirlineName = [];
			$FiltStopCount = [];
			$DesFiltStopCount = [];
			$AttPriceRange = [];
			$FiltPriceRange = [];
			$dddddddd = [];

			//echo json_encode(current($apiResponse['OutBoundFlightResults']));die;
			foreach ($apiResponse['OutBoundFlightResults'] as $key => $result) {
				$SegmentInformation = $result['sI'];
				$totalPriceList = $result['totalPriceList'];
				$totalPriceList = current($result['totalPriceList']);
				$IsRefundable = $totalPriceList['fd']['ADULT']['rT'];

				$NoOfSeatAvailable = $totalPriceList['fd']['ADULT']['sR'];

				$strFareClass = $totalPriceList['fd']['ADULT']['cB']; //Cabin Baggage

				$IsMealIncludes = isset($totalPriceList['fd']['ADULT']['mI']) ? $totalPriceList['fd']['ADULT']['mI'] : false;

				$bagInfo = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Check In Baggage
				$strCabinBaggage = $totalPriceList['fd']['ADULT']['bI']['cB']; ///Cabin Baggage

				$strTraceId = $totalPriceList['id'];

				$ResultIndex = $totalPriceList['id'];
				if (!empty($bagInfo)) {
					$IsBagIncludes = true;
				} else {
					$IsBagIncludes = false;
				}

				if (!empty($strCabinBaggage)) {
					$IsCabinBaggage = true;
				} else {
					$IsCabinBaggage = false;
				}
				if ($IsRefundable == 0) {
					$IsRefundableTxt = 'Non Refundable';
				} elseif ($IsRefundable == 1) {
					$IsRefundableTxt = 'Refundable';
				} else {
					$IsRefundableTxt = 'Partial Refundable';
				}
				$TempArr = [];
				if ($SegmentInformation) {
					$tp = 0;
					foreach ($SegmentInformation as $k => $Segmentsss) {
						$isReturnSegment = isset($Segmentsss['isRs']) ? $Segmentsss['isRs'] : false;
						if (!$isReturnSegment) {
							$TempArr['onward'][$k] = $Segmentsss;
						} else {
							$TempArr['return'][$k] = $Segmentsss;
						}
					}
				}
				//echo '<pre>';print_r($TempArr['onward']);
				$OriginOnward = current($TempArr['onward']);
				$DestinationOnward = end($TempArr['onward']);
				$arrSegments = [];
				$FlyingMinutes = 0;
				$TotalLAYOVERMinutes = 0;
				$LAYOVERCityArr = [];
				$PublishedFare = 0;
				$PublishedFareReverse = 0;
				$BaseFare = 0;
				$Tax = 0;
				$YQTax = 0;
				$OtherCharges = 0;
				$ServiceFee = 0;
				$FareBreakdown = [];
				$FairRulesArr = [];

				$TotalDurationReturn = 0;
				$TotalDurationOnward = 0;
				$TotalLAYOVERMinutes = 0;
				if ($SegmentInformation) {
					foreach ($SegmentInformation as $segments) {
						//echo '<pre>';print_r($segments);
						$segmentid = $segments['id'];
						$duration = $segments['duration'];
						$LAYOVERMinutes = $GroundTime = isset($segments['cT']) ? $segments['cT'] : 0;
						$LAYOVERCity = $LAYOVERCityArr[] = isset($segments['cT']) ? $segments['aa']['city'] : '';
						$FlyingMinutes += ($duration + $LAYOVERMinutes);
						$TotalLAYOVERMinutes += $LAYOVERMinutes;

						$FareClass = $totalPriceList['fd']['ADULT']['cB'];
						$strBaggage = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Checking Baggage
						$strCabinBaggage = $totalPriceList['fd']['ADULT']['bI']['cB']; ////Cabin Baggage

						if (!empty($strCabinBaggage)) {
							$IsCabinBaggage = true;
						} else {
							$IsCabinBaggage = false;
						}

						if (!empty($strCabinBaggage)) {
							$IsBaggage = true;
						} else {
							$IsBaggage = false;
						}

						$AirlineCode = $segments['fD']['aI']['code'];
						$AirlineName = $segments['fD']['aI']['name'];
						$FlightNumber = $segments['fD']['fN'];
						$SegFlightNumber = $AirlineCode . "-" . $FlightNumber;

						$originAirportName = $segments['da']['name'];
						$originAirportCode = $segments['da']['code'];
						$originCityName = $segments['da']['city'];
						$originCountryName = $segments['da']['country'];
						$originDepTime = $segments['dt'];

						$destinationAirportName = $segments['aa']['name'];
						$destinationAirportCode = $segments['aa']['code'];
						$destinationCityName = $segments['aa']['city'];
						$destinationCountryName = $segments['aa']['country'];
						$destinationArrTime = $segments['at'];
						if (isset($segments['isRs']) && $segments['isRs'] == true) {
							$isReturnSegment = true;
							$TotalDurationReturn += ($duration + $LAYOVERMinutes);
						} else {
							$isReturnSegment = false;
							$TotalDurationOnward += ($duration + $LAYOVERMinutes);
						}

						$DepTerminal = isset($segments['da']['terminal']) ? $segments['da']['terminal'] : '';
						$ArrTerminal = isset($segments['aa']['terminal']) ? $segments['aa']['terminal'] : '';

						$filePath = $this->getflightlogo($AirlineCode);

						$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($LAYOVERMinutes);

						$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($destinationArrTime);
						$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($originDepTime);
						$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($duration);
						$arrSegments[] = array(
							"isReturnSegment" => $isReturnSegment,
							"originAirportName" => $originAirportName,
							"destinationAirportName" => $destinationAirportName,
							"originCityName" => $originCityName,
							"originCountryName" => $originCountryName,
							"destinationCityName" => $destinationCityName,
							"destinationCountryName" => $destinationCountryName,
							"destinationAirportCode" => $destinationAirportCode,
							"destinationAirportCode" => $destinationAirportCode,
							"destinationArrTime" => $destinationArrTime,
							"SegFlightNumber" => $SegFlightNumber,
							"AirlineCode" => $AirlineCode,
							"AirlineName" => $AirlineName,
							"FareClass" => $FareClass,
							"originAirportCode" => $originAirportCode,
							"originDepTime" => $originDepTime,
							"TripIndicator" => '', //$TripIndicator,IsCabinBaggage,IsBaggage,Baggage,CabinBaggage
							"IsBaggage" => $IsBaggage,
							"Baggage" => $strBaggage,
							"IsCabinBaggage" => $IsCabinBaggage,
							"CabinBaggage" => $strCabinBaggage,
							"IsMealIncludes" => $IsMealIncludes,
							"Duration" => $duration,
							"GroundTime" => $GroundTime,
							"NoOfSeatAvailable" => $NoOfSeatAvailable,
							"strDepartureDtTime" => $strDepartureDtTime,
							"strArrivalDtTime" => $strArrivalDtTime,
							"FlightDuration" => $strDuration,
							"LAYOVERDuration" => $LAYOVERDuration,
							"LAYOVERCity" => $LAYOVERCity,
							"DepTerminal" => $DepTerminal,
							"ArrTerminal" => $ArrTerminal,
							"filePath" => $filePath,
						);
						$segmentSector[$segmentid] = ['origin' => $originAirportCode, 'destination' => $destinationAirportCode];
					}
				}
				$AirlineCode = $OriginOnward['fD']['aI']['code'];
				$array_searcher = $this->array_searcher($AdditionalMarkup, $result['totalPriceList']);
				array_multisort($array_searcher);
				if ($array_searcher) {
					foreach ($array_searcher as $kp => $price) {
						$tripbaggageinfo = [];
						if ($price['tai']['tbi']) {
							foreach ($price['tai']['tbi'] as $keyss => $tbi) {
								$segc = isset($segmentSector[$keyss]) ? $segmentSector[$keyss] : '';
								$sectorKey = $segc['origin'] . '-' . $segc['destination'];
								if ($tbi) {
									foreach ($tbi as $kgk => $pbi) {
										if ($pbi) {
											foreach ($pbi as $gk => $vll) {
												$tripbaggageinfo[$sectorKey][$gk] = ['cabin' => isset($vll['cB']) ? $vll['cB'] : 'NA', 'checkin' => isset($vll['iB']) ? $vll['iB'] : 'NA'];
											}
										}
									}
								}
							}
						}
						$fareDetail = $price['fd'];

						//echo '<pre>';print_r($fareDetail);echo '</pre>';
						$Refundable = $fareDetail['ADULT']['rT'];
						$PriceID = $price['id'];
						$fareIdentifier = $price['fareIdentifier'];
						$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
						$fareremarks = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['remarks']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['remarks'] : '';
						$fareIdentifier = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'] : '';
						$IsMealIncludes = $IsMealIncludes = $price['fd']['ADULT']['mI'];
						$colors = !empty($AddMarkup['color']) ? $AddMarkup['color'] : '#000000';
						$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']) ? $AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'] : 0;
						$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);
						$strBaggage = $price['fd']['ADULT']['bI']['iB']; ///Checking Baggage
						$strCabinBaggage = $price['fd']['ADULT']['bI']['cB']; ////Cabin Baggage
						if (!empty($strCabinBaggage)) {
							$IsCabinBaggage = true;
						} else {
							$IsCabinBaggage = false;
						}

						if (!empty($strCabinBaggage)) {
							$IsBaggage = true;
						} else {
							$IsBaggage = false;
						}
						if ($price['fareIdentifier'] == 'SME') {
							$IsGSTRequired = true;
						} else {
							$IsGSTRequired = false;
						}


						if ($Refundable == 0) {
							$IsRefundableTxt = 'Non Refundable';
						} elseif ($Refundable == 1) {
							$IsRefundableTxt = 'Refundable';
						} else {
							$IsRefundableTxt = 'Partial Refundable';
						}
						$ADULT = $fareDetail['ADULT']['fC']; //fare Components
						$CHILD = isset($fareDetail['CHILD']['fC']) ? $fareDetail['CHILD']['fC'] : []; //fare Components
						$INFANT = isset($fareDetail['INFANT']['fC']) ? $fareDetail['INFANT']['fC'] : []; //fare Components
						if (!empty($ADULT)) {
							$PaxTypeCount = 1;
						}
						if (!empty($CHILD)) {
							$PaxTypeCount = 2;
						}
						if (!empty($INFANT)) {
							$PaxTypeCount = 3;
						}
						$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
						$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
						$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents

						$ADULTNCMTDS = isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
						$CHILDNCMTDS = isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
						$INFANTNCMTDS = isset($fareDetail['INFANT']['afC']['NCM']['TDS']) ? $fareDetail['INFANT']['afC']['NCM']['TDS'] : 0; //TDS

						$ADULTNCMTOT = isset($fareDetail['ADULT']['afC']['NCM']['OT']) ? $fareDetail['ADULT']['afC']['NCM']['OT'] : 0; //- Gross Commission
						$CHILDNCMTOT = isset($fareDetail['CHILD']['afC']['NCM']['OT']) ? $fareDetail['CHILD']['afC']['NCM']['OT'] : 0; //- Gross Commission
						$INFANTNCMTOT = isset($fareDetail['INFANT']['afC']['NCM']['OT']) ? $fareDetail['INFANT']['afC']['NCM']['OT'] : 0; //- Gross Commission

						$AD_MF = isset($ADULTafC['MF']) ? $ADULTafC['MF'] : 0; //Management Fee
						$AD_YQ = isset($ADULTafC['YQ']) ? $ADULTafC['YQ'] : 0; //Fuel Surcharge
						$AD_AGST = isset($ADULTafC['AGST']) ? $ADULTafC['AGST'] : 0; //Airline GST Component
						$AD_MFT = isset($ADULTafC['MFT']) ? $ADULTafC['MFT'] : 0; //Management Fee Tax
						$AD_OT = isset($ADULTafC['OT']) ? $ADULTafC['OT'] : 0; //Other Charges
						$AD_MU = isset($ADULTafC['MU']) ? $ADULTafC['MU'] : 0; //markup
						$AD_YR = isset($ADULTafC['YR']) ? $ADULTafC['YR'] : 0; //Carrier Misc Fee

						$CH_MF = isset($CHILDafC['MF']) ? $CHILDafC['MF'] : 0; //Management Fee
						$CH_YQ = isset($CHILDafC['YQ']) ? $CHILDafC['YQ'] : 0; //Fuel Surcharge
						$CH_AGST = isset($CHILDafC['AGST']) ? $CHILDafC['AGST'] : 0; //Airline GST Component
						$CH_MFT = isset($CHILDafC['MFT']) ? $CHILDafC['MFT'] : 0; //Management Fee Tax
						$CH_OT = isset($CHILDafC['OT']) ? $CHILDafC['OT'] : 0; //Other Charges
						$CH_MU = isset($CHILDafC['MU']) ? $CHILDafC['MU'] : 0; //markup
						$CH_YR = isset($CHILDafC['YR']) ? $CHILDafC['YR'] : 0; //Carrier Misc Fee

						$IN_MF = isset($INFANTafC['MF']) ? $INFANTafC['MF'] : 0; //Management Fee
						$IN_YQ = isset($INFANTafC['YQ']) ? $INFANTafC['YQ'] : 0; //Fuel Surcharge
						$IN_AGST = isset($INFANTafC['AGST']) ? $INFANTafC['AGST'] : 0; //Airline GST Component
						$IN_MFT = isset($INFANTafC['MFT']) ? $INFANTafC['MFT'] : 0; //Management Fee Tax
						$IN_OT = isset($INFANTafC['OT']) ? $INFANTafC['OT'] : 0; //Other Charges
						$IN_MU = isset($INFANTafC['MU']) ? $INFANTafC['MU'] : 0; //markup
						$IN_YR = isset($INFANTafC['YR']) ? $INFANTafC['YR'] : 0; //Carrier Misc Fee

						if ($kp == 0) {
							$PublishedFare += (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
							$BaseFare += (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
							$Tax += (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
						}

						$PublishedFareIN = (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
						$BaseFareIN = (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
						$TaxIN = (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
						$NetFare = (($ADULT['NF'] * $adultCount) + ($CHILD['NF'] * $childCount) + ($INFANT['NF'] * $infantCount)); //Taxes and Fees
						$NetCommission = (($ADULT['NCM'] * $adultCount) + ($CHILD['NCM'] * $childCount) + ($INFANT['NCM'] * $infantCount)); //Taxes and Fees
						//echo '<pre>';print_r(($ADULTafC));echo '</pre>';
						$YQTax = (($AD_YQ * $adultCount) + ($CH_YQ * $childCount) + ($IN_YQ * $infantCount));
						$OtherCharges = (($AD_OT * $adultCount) + ($CH_OT * $childCount) + ($IN_OT * $infantCount));
						$ServiceFee = (($AD_MF * $adultCount) + ($CH_MF * $childCount) + ($IN_MF * $infantCount));
						$ManagementFeeTax = (($AD_MFT * $adultCount) + ($CH_MFT * $childCount) + ($IN_MFT * $infantCount));
						$AirlineGSTComponent = (($AD_AGST * $adultCount) + ($CH_AGST * $childCount) + ($IN_AGST * $infantCount));
						$CarrierMiscFee = (($AD_YR * $adultCount) + ($CH_YR * $childCount) + ($IN_YR * $infantCount));
						$MUFee = (($AD_MU * $adultCount) + ($CH_MU * $childCount) + ($IN_MU * $infantCount));
						$TdsOnPLB = (($ADULTNCMTDS * $adultCount) + ($CHILDNCMTDS * $childCount) + ($INFANTNCMTDS * $infantCount));
						//$NetCommission = (($ADULTNCMTOT * $adultCount) + ($CHILDNCMTOT * $childCount) + ($INFANTNCMTOT * $infantCount));

						//$PublishedFareIN = $NetFare;
						$PublishedFare = $PublishedFareIN;
						$CommissionEarned = $NetCommission;
						$PLBEarned = 0; //$result['Fare']['PLBEarned'];
						$IncentiveEarned = 0; //$result['Fare']['IncentiveEarned'];
						$OfferedFare = $PublishedFareIN;
						$markUpArr = array(
							'getMarkup' => $getMarkup,
							'PublishedFare' => $PublishedFare,
							'OfferedFare' => $NetFare,
							'intCommissionEarned' => $CommissionEarned,
							'TdsOnPLB' => $TdsOnPLB,
							'MUFee' => $MUFee,
							'intPLBEarned' => $PLBEarned,
							'intIncentiveEarned' => $IncentiveEarned,
							'intMemberCount' => $intMemberCount,
							'intFlightRoute' => $strFlightRoute,
							'interNationalSearch' => $interNationalSearch,
							'AddMarkup' => $AddMarkup,
						);
						// if ($this->gtxagencysysid == '2656') {
						// 	echo '<pre>';print_r(($markUpArr));echo '</pre>';
						// }
						
						$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr);
						if ($kp == 0) {
							$PublishedFareReverse += ($arrMarkUps['PublishFare']);
						}
						// if ($this->gtxagencysysid == '2596' && ceil($arrMarkUps['PublishFare'] * $this->CurrencyRate) == 708) {
						// 	echo '<pre>';print_r($markUpArr);echo '</pre>';
						// 	echo '<pre>';print_r($arrMarkUps);echo '</pre>';
						// 	die;
						// }

						$markUpArrBR = array(
							'getMarkup' => $getMarkup,
							'PublishedFare' => ($ADULT['TF'] * $adultCount),
							'OfferedFare' => ($ADULT['NF'] * $adultCount),
							'intCommissionEarned' => ($ADULT['NCM'] * $adultCount),
							'TdsOnPLB' => ($ADULTNCMTDS * $adultCount),
							'MUFee' => ($AD_MU * $adultCount),
							'intPLBEarned' => $PLBEarned,
							'intIncentiveEarned' => $IncentiveEarned,
							'intMemberCount' => $adultCount,
							'intFlightRoute' => $strFlightRoute,
							'interNationalSearch' => $interNationalSearch,
							'AddMarkup' => $AddMarkup,
						);
						$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);

						$FareBreakdown[0]['Currency'] = $this->CurrencyTitle;
						$FareBreakdown[0]['PassengerType'] = 1;
						$FareBreakdown[0]['PassengerCount'] = $adultCount;
						$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $adultCount);
						$FareBreakdown[0]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
						$FareBreakdown[0]['BaseFare'] = ($ADULT['BF'] * $adultCount);
						$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $adultCount);
						$FareBreakdown[0]['TDS'] = ($ADULTNCMTDS * $adultCount);
						$FareBreakdown[0]['MF'] = ($AD_MF * $adultCount);
						$FareBreakdown[0]['YQ'] = ($AD_YQ * $adultCount);
						$FareBreakdown[0]['AGST'] = ($AD_AGST * $adultCount);
						$FareBreakdown[0]['MFT'] = ($AD_MFT * $adultCount);
						$FareBreakdown[0]['OT'] = ($AD_OT * $adultCount);
						$FareBreakdown[0]['MU'] = ($AD_MU * $adultCount);
						$FareBreakdown[0]['YR'] = ($AD_YR * $adultCount);
						$FareBreakdown[0]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
						$FareBreakdown[0]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
						$FareBreakdown[0]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
						$FareBreakdown[0]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
						$FareBreakdown[0]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
						$FareBreakdown[0]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
						$FareBreakdown[0]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
						$FareBreakdown[0]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
						$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
						$FareBreakdown[0]['GSTonComm'] = 0;
						$FareBreakdown[0]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
						$FareBreakdown[0]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
						$FareBreakdown[0]['AdditionalTxnFeeOfrd'] = 0;
						$FareBreakdown[0]['AdditionalTxnFeePub'] = 0;
						$FareBreakdown[0]['PGCharge'] = 0;
						$FareBreakdown[0]['Baggage'] = isset($fareDetail['ADULT']['bI']['iB']) ? $fareDetail['ADULT']['bI']['iB'] : []; //Check In Baggage;
						$FareBreakdown[0]['CabinBaggage'] = isset($fareDetail['ADULT']['bI']['cB']) ? $fareDetail['ADULT']['bI']['cB'] : []; //Cabin Baggage ;
						if (isset($fareDetail['CHILD'])) {
							$markUpArrBR = array(
								'getMarkup' => $getMarkup,
								'PublishedFare' => ($CHILD['TF'] * $childCount),
								'OfferedFare' => ($CHILD['NF'] * $childCount),
								'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
								'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
								'MUFee' => ($CH_MU * $childCount),
								'intPLBEarned' => $PLBEarned,
								'intIncentiveEarned' => $IncentiveEarned,
								'intMemberCount' => $childCount,
								'intFlightRoute' => $strFlightRoute,
								'interNationalSearch' => $interNationalSearch,
								'AddMarkup' => $AddMarkup,
							);
							$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
							$FareBreakdown[1]['Currency'] = $this->CurrencyTitle;
							$FareBreakdown[1]['PassengerType'] = 2;
							$FareBreakdown[1]['PassengerCount'] = $childCount;
							$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
							$FareBreakdown[1]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
							$FareBreakdown[1]['BaseFare'] = ($CHILD['BF'] * $childCount);
							$FareBreakdown[1]['CommissionEarned'] = ($CHILD['NCM'] * $childCount);
							$FareBreakdown[1]['TDS'] = ($CHILDNCMTDS * $childCount);
							$FareBreakdown[1]['MF'] = ($CH_MF * $childCount);
							$FareBreakdown[1]['YQ'] = ($CH_YQ * $childCount);
							$FareBreakdown[1]['AGST'] = ($CH_AGST * $childCount);
							$FareBreakdown[1]['MFT'] = ($CH_MFT * $childCount);
							$FareBreakdown[1]['OT'] = ($CH_OT * $childCount);
							$FareBreakdown[1]['MU'] = ($CH_MU * $childCount);
							$FareBreakdown[1]['YR'] = ($CH_YR * $childCount);
							$FareBreakdown[1]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
							$FareBreakdown[1]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
							$FareBreakdown[1]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
							$FareBreakdown[1]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
							$FareBreakdown[1]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
							$FareBreakdown[1]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
							$FareBreakdown[1]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
							$FareBreakdown[1]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
							$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
							$FareBreakdown[1]['GSTonComm'] = 0;
							$FareBreakdown[1]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
							$FareBreakdown[1]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
							$FareBreakdown[1]['AdditionalTxnFeeOfrd'] = 0;
							$FareBreakdown[1]['AdditionalTxnFeePub'] = 0;
							$FareBreakdown[1]['PGCharge'] = 0;
							$FareBreakdown[1]['Baggage'] = isset($fareDetail['CHILD']['bI']['iB']) ? $fareDetail['CHILD']['bI']['iB'] : []; //Check In Baggage;
							$FareBreakdown[1]['CabinBaggage'] = isset($fareDetail['CHILD']['bI']['cB']) ? $fareDetail['CHILD']['bI']['cB'] : []; //Cabin Baggage ;
						}
						if (isset($fareDetail['INFANT'])) {
							$markUpArrBR = array(
								'getMarkup' => $getMarkup,
								'PublishedFare' => ($INFANT['TF'] * $infantCount),
								'OfferedFare' => ($INFANT['NF'] * $infantCount),
								'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
								'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
								'MUFee' => ($IN_MU * $infantCount),
								'intPLBEarned' => $PLBEarned,
								'intIncentiveEarned' => $IncentiveEarned,
								'intMemberCount' => $infantCount,
								'intFlightRoute' => $strFlightRoute,
								'interNationalSearch' => $interNationalSearch,
								'AddMarkup' => $AddMarkup,
							);
							$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
							$FareBreakdown[2]['Currency'] = $this->CurrencyTitle;
							$FareBreakdown[2]['PassengerType'] = 3;
							$FareBreakdown[2]['PassengerCount'] = $infantCount;
							$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
							$FareBreakdown[2]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
							$FareBreakdown[2]['BaseFare'] = ($INFANT['BF'] * $infantCount);
							$FareBreakdown[2]['CommissionEarned'] = ($INFANT['NCM'] * $infantCount);
							$FareBreakdown[2]['TDS'] = ($INFANTNCMTDS * $infantCount);
							$FareBreakdown[2]['MF'] = ($IN_MF * $infantCount);
							$FareBreakdown[2]['YQ'] = ($IN_YQ * $infantCount);
							$FareBreakdown[2]['AGST'] = ($IN_AGST * $infantCount);
							$FareBreakdown[2]['OT'] = ($IN_OT * $infantCount);
							$FareBreakdown[2]['MFT'] = ($IN_MFT * $infantCount);
							$FareBreakdown[2]['MU'] = ($IN_MU * $infantCount);
							$FareBreakdown[2]['YR'] = ($IN_YR * $infantCount);
							$FareBreakdown[2]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
							$FareBreakdown[2]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
							$FareBreakdown[2]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
							$FareBreakdown[2]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
							$FareBreakdown[2]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
							$FareBreakdown[2]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
							$FareBreakdown[2]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
							$FareBreakdown[2]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
							$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
							$FareBreakdown[2]['GSTonComm'] = 0;
							$FareBreakdown[2]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
							$FareBreakdown[2]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
							$FareBreakdown[2]['AdditionalTxnFeeOfrd'] = 0;
							$FareBreakdown[2]['AdditionalTxnFeePub'] = 0;
							$FareBreakdown[2]['PGCharge'] = 0;
							$FareBreakdown[2]['Baggage'] = isset($fareDetail['INFANT']['bI']['iB']) ? $fareDetail['INFANT']['bI']['iB'] : []; //Check In Baggage;
							$FareBreakdown[2]['CabinBaggage'] = isset($fareDetail['INFANT']['bI']['cB']) ? $fareDetail['INFANT']['bI']['cB'] : []; //Cabin Baggage ;
						}
						//echo '<pre>';print_r($price);
						$FairRulesArr[$kp] = array(
							"Currency" => $this->CurrencyTitle, //$Currency,
							"CurrencyRate" => $this->CurrencyRate, //$Currency,
							"currencySysId" => $this->CurrencyId,
							"BaseFare" => $BaseFareIN,
							"Tax" => $TaxIN,
							"YQTax" => $YQTax,
							"OtherCharges" => $OtherCharges,
							"Discount" => 0, //$Discount,
							"ServiceFee" => $ServiceFee,
							"ManagementFeeTax" => $ManagementFeeTax,
							"AirlineGSTComponent" => $AirlineGSTComponent,
							"CarrierMiscFee" => $CarrierMiscFee,
							"MUFee" => $MUFee,
							"intPublishedFare" => $PublishedFareIN,
							"PublishedFare" => ceil($arrMarkUps['PublishFare'] * $this->CurrencyRate),
							"PublishedFarePerPax" => ceil((($arrMarkUps['PublishFare'] * $this->CurrencyRate) / $intMemberCount)),
							"OfferedFare" => $arrMarkUps['intOfferedFare'],
							"CommissionEarned" => $CommissionEarned,
							"PLBEarned" => $PLBEarned,
							"IncentiveEarned" => $IncentiveEarned,
							"TdsOnPLB" => $TdsOnPLB,
							"TdsOnIncentive" => 0,
							"AdditionalTxnFeeOfrd" => 0,
							"AdditionalTxnFeePub" => 0,
							"Refundable" => $Refundable,
							"IsRefundableTxt" => $IsRefundableTxt,
							"PriceID" => $PriceID,
							"IsGSTRequired" => $IsGSTRequired,
							"fareremarks" => $fareremarks,
							"colors" => $colors,
							"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
							"FareClass" => ucfirst(strtolower($fareDetail['ADULT']['cc'])),
							"NoOfSeatAvailable" => $fareDetail['ADULT']['sR'],
							"intTotalGST" => $arrMarkUps['intTotalGST'],
							"apiMarkup" => $arrMarkUps['apiMarkup'],
							"IntCommission" => $arrMarkUps['IntCommission'],
							"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
							"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
							"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
							"CommEarned" => $arrMarkUps['IntCommission'], //$arrMarkUps['intCommisionEarnedForAgency'],
							"GSTonComm" => 0,
							"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
							"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
							"AddiMarkup" => $arrMarkUps['AddiMarkup'],
							"AddiTaxOnMarkup" => $arrMarkUps['AddiTaxOnMarkup'],
							"FareBreakdown" => $FareBreakdown,
							"IsMealIncludes" => $IsMealIncludes,
							"Baggage" => $strBaggage,
							"CabinBaggage" => $strCabinBaggage,
							"IsCabinBaggage" => $IsCabinBaggage,
							"IsBaggage" => $IsBaggage,
							// "arrMarkUps" => $arrMarkUps,
							"TaxSettingDetail" => $arrMarkUps['TaxSettingDetail'],
							"tripbinfo" => $tripbaggageinfo,
						);
					}
				}

				$col = array_column($FairRulesArr, "PublishedFare");
				array_multisort($col, SORT_ASC, $FairRulesArr);
				$TotalLAYOVERMinutesO = 0;
				$FlyingMinutesO = 0;
				$LAYOVERCityArrO = [];

				$OnwdFlightNumberArr = [];
				if ($TempArr['onward']) {
					foreach ($TempArr['onward'] as $onwd) {
						$duration = isset($segments['duration']) ? $segments['duration'] : 0;
						$LAYOVERMinutes = $GroundTime = isset($onwd['cT']) ? $onwd['cT'] : 0;
						$LAYOVERCity = $LAYOVERCityArrO[] = isset($onwd['cT']) ? $onwd['aa']['city'] : '';
						$FlyingMinutesO += ($duration + $LAYOVERMinutes);
						$TotalLAYOVERMinutesO += $LAYOVERMinutes;
						$AirlineCode = $onwd['fD']['aI']['code'];
						$FlightNumber = $onwd['fD']['fN'];
						$OnwdFlightNumber = $AirlineCode . "-" . $FlightNumber;
						$OnwdFlightNumberArr[] = $OnwdFlightNumber;
						//echo '<pre>';print_r($onwd);
					}
				}

				// if ($TempArr['onward']) {
				// 	foreach ($TempArr['onward'] as $onwd) {
				// 		$duration = isset($segments['duration']) ? $segments['duration'] : 0;
				// 		$LAYOVERMinutes = $GroundTime = isset($onwd['cT']) ? $onwd['cT'] : 0;
				// 		$LAYOVERCity = $LAYOVERCityArrO[] = isset($onwd['cT']) ? $onwd['aa']['city'] : '';
				// 		$FlyingMinutesO += ($duration + $LAYOVERMinutes);
				// 		$TotalLAYOVERMinutesO += $LAYOVERMinutes;
				// 	}
				// }
				//echo '<pre>';print_r($OriginOnward['dt'].$DestinationOnward['at']);echo '</pre>';
				//echo $TotalLAYOVERMinutesO.'=='.$FlyingMinutesO.'<br>';
				$LAYOVERTimeO = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($TotalLAYOVERMinutesO);
				$AirlineCode = $OriginOnward['fD']['aI']['code'];
				$FlightNumber = $OriginOnward['fD']['fN'];
				//$strFlightNumber = $OriginOnward . "-" . $FlightNumber;
				$strAirlineName = $OriginOnward['fD']['aI']['name'];
				$OrFlightNumber = $AirlineCode . '-' . $FlightNumber;
				$IsLCC = $OriginOnward['fD']['aI']['isLcc'];
				$strSourceAirportCode = $OriginOnward['da']['code'];
				$strDestinationAirportCode = $DestinationOnward['aa']['code'];
				$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
				$filePath = $this->getflightlogo($AirlineCode);
				$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($TotalDurationOnward);
				$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($DestinationOnward['at']);
				$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($OriginOnward['dt']);
				$Stops = $DestinationOnward['sN'];
				if ($Stops == 0) {
					$OrStopCountTxt = "Non-stop";
				} else {
					$OrStopCountTxt = $Stops . " Stop(s)";
				}

				if (!empty($FairRulesArr)) {
					$arrInsertFlightData[$key]['origin']['keyIndex'] = $key;
					$arrInsertFlightData[$key]['origin']['FlightNumber'] = $FlightNumber;
					//$arrInsertFlightData[$key]['origin']['SegFlightNumberArr'] = implode(', ', $OnwdFlightNumberArr);
					if (count($OnwdFlightNumberArr) > 1) {
						$arrInsertFlightData[$key]['origin']['SegFlightNumberArr'] = implode(', ', $OnwdFlightNumberArr) . ' +' . (count($OnwdFlightNumberArr) - 1);
					} else {
						$arrInsertFlightData[$key]['origin']['SegFlightNumberArr'] = implode(', ', $OnwdFlightNumberArr);
					}
					$arrInsertFlightData[$key]['origin']['AirlineName'] = $strAirlineName;
					$arrInsertFlightData[$key]['origin']['AirlineCode'] = $AirlineCode;
					$arrInsertFlightData[$key]['origin']['OrFlightNumber'] = $OrFlightNumber;
					$arrInsertFlightData[$key]['origin']['AirInvenSysId'] = 0;
					$arrInsertFlightData[$key]['origin']['IsLCC'] = $IsLCC;
					$arrInsertFlightData[$key]['origin']['IsMealIncludes'] = $IsMealIncludes;
					$arrInsertFlightData[$key]['origin']['IsBagIncludes'] = $IsBagIncludes;
					$arrInsertFlightData[$key]['origin']['IsCabinBagIncludes'] = $IsCabinBagIncludes;
					$arrInsertFlightData[$key]['origin']['IsRefundable'] = $IsRefundable;
					$arrInsertFlightData[$key]['origin']['IsRefundableTxt'] = $IsRefundableTxt;
					$arrInsertFlightData[$key]['origin']['apiTraceId'] = $strTraceId;
					$arrInsertFlightData[$key]['origin']['AirlineSysId'] = $airlineSysId;
					$arrInsertFlightData[$key]['origin']['DepartureTime'] = $strDepartureDtTime;
					$arrInsertFlightData[$key]['origin']['ArrivalTime'] = $strArrivalDtTime;
					$arrInsertFlightData[$key]['origin']['TravelDate'] = $OriginOnward['dt'];
					$arrInsertFlightData[$key]['origin']['LocalFromTime'] = str_replace('T', ' ', $OriginOnward['dt']);
					$arrInsertFlightData[$key]['origin']['FromUTCTime'] = $OriginOnward['dt'];
					$arrInsertFlightData[$key]['origin']['LocalToTime'] = str_replace('T', ' ', $DestinationOnward['at']);
					$arrInsertFlightData[$key]['origin']['ToUTCTime'] = $DestinationOnward['at'];
					$arrInsertFlightData[$key]['origin']['IsDirect'] = 0;
					$arrInsertFlightData[$key]['origin']['FareClass'] = $strFareClass;
					$arrInsertFlightData[$key]['origin']['LAYOVERCity'] = isset($LAYOVERCityArrO[0]) ? $LAYOVERCityArrO[0] : '';
					$arrInsertFlightData[$key]['origin']['GroundTime'] = $TotalLAYOVERMinutesO;
					$arrInsertFlightData[$key]['origin']['LAYOVERDuration'] = $LAYOVERTimeO;
					$arrInsertFlightData[$key]['origin']['FlyingMinutes'] = $FlyingMinutesO;
					$arrInsertFlightData[$key]['origin']['DepartureDateTxt'] = date('D, d M', strtotime($OriginOnward['dt']));
					$arrInsertFlightData[$key]['origin']['ArrivalDateTxt'] = date('D, d M', strtotime($DestinationOnward['at']));
					$arrInsertFlightData[$key]['origin']['FlightDuration'] = $FlightDuration;
					$arrInsertFlightData[$key]['origin']['SourcePlaceSysId'] = $intSourceCityId;
					$arrInsertFlightData[$key]['origin']['DestPlaceSysId'] = $intDestinationCityId;
					$arrInsertFlightData[$key]['origin']['SourceAirportCode'] = $strSourceAirportCode;
					$arrInsertFlightData[$key]['origin']['DestAirportCode'] = $strDestinationAirportCode;
					$arrInsertFlightData[$key]['origin']['StopCount'] = $OrStopCountTxt;
					$arrInsertFlightData[$key]['origin']['Stops'] = $Stops;
					$arrInsertFlightData[$key]['origin']['NoOfSeatAvailable'] = $NoOfSeatAvailable;
					$arrInsertFlightData[$key]['origin']['TotalFlightMembers'] = $intMemberCount;
					$arrInsertFlightData[$key]['origin']['CurrencyType'] = $this->CurrencyId;
					$arrInsertFlightData[$key]['origin']['JourneyType'] = 1;
					$arrInsertFlightData[$key]['origin']['TripType'] = $intTripType;
					$arrInsertFlightData[$key]['origin']['IsInternational'] = $interNationalSearch;
					$arrInsertFlightData[$key]['origin']['SearchFlightTraceId'] = $SearchFlightTraceId;
					$arrInsertFlightData[$key]['origin']['logo'] = $filePath;

					//// Rrturn variable

					$TotalLAYOVERMinutesD = 0;
					$FlyingMinutesD = 0;
					$LAYOVERCityArrD = [];
					$OnwdFlightNumberArr = [];
					if ($TempArr['return']) {
						foreach ($TempArr['return'] as $onwd) {
							$duration = $segments['duration'];
							$LAYOVERMinutes = $GroundTime = isset($onwd['cT']) ? $onwd['cT'] : 0;
							$LAYOVERCity = $LAYOVERCityArrD[] = isset($onwd['cT']) ? $onwd['aa']['city'] : '';
							$FlyingMinutesD += ($duration + $LAYOVERMinutes);
							$TotalLAYOVERMinutesD += $LAYOVERMinutes;
							$AirlineCode = $onwd['fD']['aI']['code'];
							$FlightNumber = $onwd['fD']['fN'];
							$OnwdFlightNumber = $AirlineCode . "-" . $FlightNumber;
							$OnwdFlightNumberArr[] = $OnwdFlightNumber;
						}
					}



					$OriginReturn = current($TempArr['return']);
					$DestinationReturn = end($TempArr['return']);

					$AirlineCode = $OriginReturn['fD']['aI']['code'];
					$FlightNumber = $OriginReturn['fD']['fN'];
					//$strFlightNumber = $OriginReturn . "-" . $FlightNumber;
					$strAirlineName = $OriginReturn['fD']['aI']['name'];
					$DeFlightNumber = $AirlineCode . '-' . $FlightNumber;
					$IsLCC = $OriginReturn['fD']['aI']['isLcc'];
					$strSourceAirportCode = $OriginReturn['da']['code'];
					$strDestinationAirportCode = $DestinationReturn['aa']['code'];
					$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
					$filePath = $this->getflightlogo($AirlineCode);
					$LAYOVERTimeD = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($TotalLAYOVERMinutesD);
					$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($TotalDurationReturn);
					$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($DestinationReturn['at']);
					$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($OriginReturn['dt']);
					//// end return variable.

					$Stops = $DestinationReturn['sN'];
					if ($Stops == 0) {
						$DeStopCountTxt = "Non-stop";
					} else {
						$DeStopCountTxt = $Stops . " Stop(s)";
					}
					$arrInsertFlightData[$key]['destination']['FlightNumber'] = $FlightNumber;
					//$arrInsertFlightData[$key]['destination']['SegFlightNumberArr'] = implode(', ', $OnwdFlightNumberArr);
					if (count($OnwdFlightNumberArr) > 1) {
						$arrInsertFlightData[$key]['destination']['SegFlightNumberArr'] = implode(', ', $OnwdFlightNumberArr) . ' +' . (count($OnwdFlightNumberArr) - 1);
					} else {
						$arrInsertFlightData[$key]['destination']['SegFlightNumberArr'] = implode(', ', $OnwdFlightNumberArr);
					}
					$arrInsertFlightData[$key]['destination']['AirlineName'] = $strAirlineName;
					$arrInsertFlightData[$key]['destination']['AirlineCode'] = $AirlineCode;
					$arrInsertFlightData[$key]['destination']['DeFlightNumber'] = $DeFlightNumber;
					$arrInsertFlightData[$key]['destination']['AirInvenSysId'] = 0;
					$arrInsertFlightData[$key]['destination']['IsLCC'] = $IsLCC;
					$arrInsertFlightData[$key]['destination']['IsMealIncludes'] = $IsMealIncludes;
					$arrInsertFlightData[$key]['destination']['IsBagIncludes'] = $IsBagIncludes;
					$arrInsertFlightData[$key]['destination']['IsCabinBagIncludes'] = $IsCabinBagIncludes;
					$arrInsertFlightData[$key]['destination']['IsRefundable'] = $IsRefundable;
					$arrInsertFlightData[$key]['destination']['IsRefundableTxt'] = $IsRefundableTxt;
					$arrInsertFlightData[$key]['destination']['apiTraceId'] = $strTraceId;
					$arrInsertFlightData[$key]['destination']['AirlineSysId'] = $airlineSysId;
					$arrInsertFlightData[$key]['destination']['DepartureTime'] = $strDepartureDtTime;
					$arrInsertFlightData[$key]['destination']['ArrivalTime'] = $strArrivalDtTime;
					$arrInsertFlightData[$key]['destination']['TravelDate'] = $OriginReturn['dt'];
					$arrInsertFlightData[$key]['destination']['LocalFromTime'] = str_replace('T', ' ', $OriginReturn['dt']);
					$arrInsertFlightData[$key]['destination']['FromUTCTime'] = $OriginReturn['dt'];
					$arrInsertFlightData[$key]['destination']['LocalToTime'] = str_replace('T', ' ', $DestinationReturn['at']);
					$arrInsertFlightData[$key]['destination']['ToUTCTime'] = $DestinationReturn['at'];
					$arrInsertFlightData[$key]['destination']['IsDirect'] = 0;
					$arrInsertFlightData[$key]['destination']['FareClass'] = $strFareClass;
					$arrInsertFlightData[$key]['destination']['LAYOVERCity'] = isset($LAYOVERCityArrD[0]) ? $LAYOVERCityArrD[0] : '';
					$arrInsertFlightData[$key]['destination']['GroundTime'] = $TotalLAYOVERMinutesD;
					$arrInsertFlightData[$key]['destination']['LAYOVERDuration'] = $LAYOVERTimeD;
					$arrInsertFlightData[$key]['destination']['FlyingMinutes'] = $FlyingMinutesD;
					$arrInsertFlightData[$key]['destination']['DepartureDateTxt'] = date('D, d M', strtotime($OriginReturn['dt']));
					$arrInsertFlightData[$key]['destination']['ArrivalDateTxt'] = date('D, d M', strtotime($DestinationReturn['at']));
					$arrInsertFlightData[$key]['destination']['FlightDuration'] = $FlightDuration;
					$arrInsertFlightData[$key]['destination']['SourcePlaceSysId'] = $intSourceCityId;
					$arrInsertFlightData[$key]['destination']['DestPlaceSysId'] = $intDestinationCityId;
					$arrInsertFlightData[$key]['destination']['SourceAirportCode'] = $strSourceAirportCode;
					$arrInsertFlightData[$key]['destination']['DestAirportCode'] = $strDestinationAirportCode;
					$arrInsertFlightData[$key]['destination']['StopCount'] = $DeStopCountTxt;
					$arrInsertFlightData[$key]['destination']['Stops'] = $Stops;
					$arrInsertFlightData[$key]['destination']['NoOfSeatAvailable'] = $NoOfSeatAvailable;
					$arrInsertFlightData[$key]['destination']['TotalFlightMembers'] = $intMemberCount;
					$arrInsertFlightData[$key]['destination']['CurrencyType'] = $this->CurrencyId;
					$arrInsertFlightData[$key]['destination']['JourneyType'] = $intJourneyType;
					$arrInsertFlightData[$key]['destination']['TripType'] = $intTripType;
					$arrInsertFlightData[$key]['destination']['IsInternational'] = $interNationalSearch;
					$arrInsertFlightData[$key]['destination']['SearchFlightTraceId'] = $SearchFlightTraceId;
					$arrInsertFlightData[$key]['destination']['logo'] = $filePath;

					$arrInsertFlightData[$key]['AirlineName'] = $strAirlineName; // As Discussed with GG
					$arrInsertFlightData[$key]['PublishedFare'] = $PublishedFareReverse; // As Discussed with GG
					$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format($PublishedFareReverse);
					$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
					$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
					$arrInsertFlightData[$key]['FairRules'] = $FairRulesArr;
					$arrInsertFlightData[$key]['Segments'] = $arrSegments;
					$arrInsertFlightData[$key]['DepartureTime'] = $strDepartureDtTime;
					$arrInsertFlightData[$key]['StopCount'] = $OrStopCountTxt;
					$arrInsertFlightData[$key]['SearchFlightTraceId'] = $SearchFlightTraceId;
					$arrInsertFlightData[$key]['keyIndex'] = $key;
					$arrInsertFlightData[$key]['ICSourceSysId'] = 7;

					if ($FairRulesArr) {
						foreach ($FairRulesArr as $Fare) {
							$dddddddd[] = $Fare['PublishedFare'];
						}
					}

					$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
					$FilterArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strArrivalDtTime);

					$arrInsertFlightData[$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
					$arrInsertFlightData[$key]['FilterArrivalDtTime'] = $FilterArrivalDtTime;

					// $arrInsertFlightData[$key]['fffffffffffff'] = $arrFairRules;
					//$FiltPriceRange[] = $FilterPrice = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_PRICE_RANGE_AED), ($PublishedFare * $this->CurrencyRate));
					$AttPriceRange[] = ($PublishedFareReverse * $this->CurrencyRate);
					$arrAirlineName[] = $AirlineCode . '-' . $strAirlineName;
					$FiltStopCount[] = $OrStopCountTxt;
					//$DesFiltStopCount[] = $DeStopCountTxt;
					//$arrInsertFlightData[$key]['FilterPrice'] = $FilterPrice;
				}
			}
			
			foreach ($arrInsertFlightData as $k => $v) {
				$new_arr[$v['FairRules'][0]['PublishedFare']][] = $v;
			}
			$arrFlightData = [];
			foreach ($arrInsertFlightData as $ke => $vl) {
				$processedTripInfo = isset($new_arr[$vl['FairRules'][0]['PublishedFare']]) ? $new_arr[$vl['FairRules'][0]['PublishedFare']] : [];
				$arrFlightData[$vl['FairRules'][0]['PublishedFare']] =  $vl;
				$arrFlightData[$vl['FairRules'][0]['PublishedFare']]['CombineTripInfo'] =  $processedTripInfo;
			}

			sort($dddddddd);
			if (array_values(array_unique($dddddddd))) {
				foreach (array_values(array_unique($dddddddd)) as $Fares) {
					if ($this->CurrencyTitle == 'INR') {
						$CONST_PRICE_RANGE = unserialize(CONST_PRICE_RANGE_5000);
					} else {
						$CONST_PRICE_RANGE = unserialize(CONST_PRICE_RANGE_AED);
					}
					$FiltPriceRange[] = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue($CONST_PRICE_RANGE, round($Fares));
				}
			}

			$FiltPriceRangeU = (array_unique($FiltPriceRange));
			//$ArrPriceUnique = array_filter(array_values($FiltPriceRangeU));
			$arrAirlineName = array_unique($arrAirlineName);
			$FiltStopCount = array_unique($FiltStopCount);
			$AttPriceRange = array_unique($AttPriceRange);
			//krsort($ArrPriceUnique);
			// if ($this->gtxagencysysid == '2596') {
			// 	// echo json_encode(($arrInsertFlightData));
			// 	die;
			// }
			$data = array('outbound' => array_values($arrInsertFlightData), 'arrFlightData' => $arrFlightData, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'ArrPriceUnique' => $FiltPriceRangeU, 'AttPriceRange' => $AttPriceRange);

			return $data;
		} else {
			return false;
		}
	}
	public function cryptoJsAesEncrypt($passphrase, $value){
		$salt = openssl_random_pseudo_bytes(8);
		$salted = '';
		$dx = '';
		while (strlen($salted) < 48) {
			$dx = md5($dx.$passphrase.$salt, true);
			$salted .= $dx;
		}
		$key = substr($salted, 0, 32);
		$iv  = substr($salted, 32,16);
		$encrypted_data = openssl_encrypt(json_encode($value), 'aes-256-cbc', $key, true, $iv);
		$data = array("ct" => base64_encode($encrypted_data), "iv" => bin2hex($iv), "s" => bin2hex($salt));
		return json_encode($data);
	}
	public function cryptoJsAesDecrypt($passphrase, $jsonString){
		$jsondata = json_decode($jsonString, true);
		$salt = hex2bin($jsondata["s"]);
		$ct = base64_decode($jsondata["ct"]);
		$iv  = hex2bin($jsondata["iv"]);
		$concatedPassphrase = $passphrase.$salt;
		$md5 = array();
		$md5[0] = md5($concatedPassphrase, true);
		$result = $md5[0];
		for ($i = 1; $i < 3; $i++) {
			$md5[$i] = md5($md5[$i - 1].$concatedPassphrase, true);
			$result .= $md5[$i];
		}
		$key = substr($result, 0, 32);
		$data = openssl_decrypt($ct, 'aes-256-cbc', $key, true, $iv);
		return json_decode($data, true);
	}
	// jyt comment this code
	// public function getflightfarerulesAction()
	// {
	// 	if ($this->getRequest()->isXmlHttpRequest()) {
	// 		$this->_helper->layout->disableLayout();
	// 		$getData = $this->getRequest()->getParams();
	// 		//echo"<pre>";print_r($getData);die();
	// 		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
	// 		$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
	// 		$adultCount = $sessionFlightSearchParams->params['adults'];
	// 		$childCount = $sessionFlightSearchParams->params['child'];
	// 		$infantCount = $sessionFlightSearchParams->params['infant'];
	// 		$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);
	// 		$ICSourceSysId = !empty($getData['ICSourceSysId']) ? $getData['ICSourceSysId'] : 0;
	// 		$SupplierType = ($ICSourceSysId == 3) ? 1 : 2;
	// 		$intMemberCount = $adultCount + $childCount + $infantCount;
	// 		$intMarkUp = $this->getCancelCharge($intCountryCode, $SupplierType);
	// 		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
	// 		$SearchFlightTraceId = trim($sessionFlightSearchParams->params['SearchFlightTraceId']);
	// 		$route = trim($sessionFlightSearchParams->params['route']);
	// 		$getData['SearchFlightTraceId'] = $SearchFlightTraceId;
	// 		// 
	// 		$getData['flowType'] = 'SEARCH';
	// 		$FareRulesCancel = [];
	// 		if ($ICSourceSysId == 3) {
	// 			// if($this->gtxagencysysid == '87401'){
	// 			// 	echo "<pre>";   print_r($getData); die;
	// 			// }
	// 			$getData['TraceId'] = isset($getData['apiTraceId']) ? $getData['apiTraceId'] : $getData['TraceId'];
	// 			$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareRules($getData);
	// 		} elseif ($ICSourceSysId == 7) {
	// 			$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareRulesTripJack($getData);
	// 			// echo json_encode($apiResponse);
	// 			// echo "<pre>";   print_r($apiResponse); echo "</pre>";die;
	// 			$FareRules = isset($apiResponse['fareRule']) ? $apiResponse['fareRule'] : [];
	// 			$success = $apiResponse['status']['success'];

	// 			if ($FareRules) {
	// 				foreach ($FareRules as $key => $val) {
	// 					$CANCELLATION = isset($val['tfr']['CANCELLATION']) ? $val['tfr']['CANCELLATION'] : '';
	// 					$DATECHANGE = isset($val['tfr']['DATECHANGE']) ? $val['tfr']['DATECHANGE'] : '';
	// 					$NO_SHOW = isset($val['tfr']['NO_SHOW']) ? $val['tfr']['NO_SHOW'] : '';
	// 					$SEAT_CHARGEABLE = isset($val['tfr']['SEAT_CHARGEABLE']) ? $val['tfr']['SEAT_CHARGEABLE'] : '';
	// 					$cancel = [];
	// 					if ($CANCELLATION) {
	// 						foreach ($CANCELLATION as $keys => $cl) {
	// 							$policyInfo_ = isset($cl['policyInfo']) ? array_values(array_filter(explode('__nls__', $cl['policyInfo']))) : ['Airline Cancellation Charges + Taxes + Surcharges'];
	// 							$startTime = (isset($cl['st']) && !empty($cl['st'])) ? $cl['st'] : 0;
	// 							$endTime = (isset($cl['et']) && !empty($cl['et'])) ? $cl['et'] : 0;
	// 							$additionalFee = (isset($cl['additionalFee']) && !empty($cl['additionalFee'])) ? $cl['additionalFee'] : 0;
	// 							$amount = (isset($cl['amount']) && !empty($cl['amount'])) ? $cl['amount'] : 0;
	// 							$policyperiod = (isset($cl['pp']) && !empty($cl['pp'])) ? $cl['pp'] : '';
	// 							$st = $this->hoursTodays($startTime);
	// 							$et = $this->hoursTodays($endTime);
	// 							$TimeFrame = $st . ' to ' . $et;
	// 							$cancel[$keys] = $cl;
	// 							$cancel[$keys]['CurrencyTitle'] = $this->CurrencyTitle;
	// 							$cancel[$keys]['amount'] = $amount;
	// 							$cancel[$keys]['sector'] = $key;
	// 							$cancel[$keys]['policyInfo'] = $policyInfo_;
	// 							$cancel[$keys]['TimeFrame'] = (!empty($policyperiod)) ? $policyperiod : $TimeFrame;
	// 							$cancel[$keys]['additionalFee'] = round($additionalFee + (float) ($intMarkUp * $intMemberCount));
	// 						}
	// 					} else {
	// 						$cancel[0]['sector'] = $key;
	// 						$cancel[0]['TimeFrame'] = 'As Per Airline';
	// 						$cancel[0]['policyInfo'] = ['As Per Airline'];
	// 					}
	// 					$datechange = [];
	// 					if ($DATECHANGE) {
	// 						foreach ($DATECHANGE as $keys => $cl) {
	// 							$policyInfo_ = (isset($cl['policyInfo']) && !empty($cl['policyInfo'])) ? array_values(array_filter(explode('__nls__', $cl['policyInfo']))) : ['Difference in Fare + Taxes + Surcharges'];
	// 							$startTime = (isset($cl['st']) && !empty($cl['st'])) ? $cl['st'] : 0;
	// 							$endTime = (isset($cl['et']) && !empty($cl['et'])) ? $cl['et'] : 0;
	// 							$additionalFee = (isset($cl['additionalFee']) && !empty($cl['additionalFee'])) ? $cl['additionalFee'] : 0;
	// 							$amount = (isset($cl['amount']) && !empty($cl['amount'])) ? $cl['amount'] : 0;
	// 							$policyperiod = (isset($cl['pp']) && !empty($cl['pp'])) ? $cl['pp'] : '';
	// 							$st = $this->hoursTodays($startTime);
	// 							$et = $this->hoursTodays($endTime);
	// 							$TimeFrame = $st . ' to ' . $et;
	// 							$datechange[$keys] = $cl;
	// 							$datechange[$keys]['CurrencyTitle'] = $this->CurrencyTitle;
	// 							$datechange[$keys]['amount'] = $amount;
	// 							$datechange[$keys]['sector'] = $key;
	// 							$datechange[$keys]['policyInfo'] = $policyInfo_;
	// 							$datechange[$keys]['TimeFrame'] = (!empty($policyperiod)) ? $policyperiod : $TimeFrame;
	// 							$datechange[$keys]['additionalFee'] = round($additionalFee + (float) ($intMarkUp * $intMemberCount));
	// 						}
	// 					} else {
	// 						$datechange[0]['sector'] = $key;
	// 						$datechange[0]['TimeFrame'] = 'As Per Airline';
	// 						$datechange[0]['policyInfo'] = ['As Per Airline'];
	// 					}
	// 					$noshow = [];
	// 					if ($NO_SHOW) {
	// 						foreach ($NO_SHOW as $keys => $cl) {
	// 							$policyInfo_ = (isset($cl['policyInfo']) && !empty($cl['policyInfo'])) ? array_values(array_filter(explode('__nls__', $cl['policyInfo']))) : ['Fees As Per Airline Rule + Surcharges'];
	// 							$startTime = (isset($cl['st']) && !empty($cl['st'])) ? $cl['st'] : 0;
	// 							$endTime = (isset($cl['et']) && !empty($cl['et'])) ? $cl['et'] : 0;
	// 							$additionalFee = (isset($cl['additionalFee']) && !empty($cl['additionalFee'])) ? $cl['additionalFee'] : 0;
	// 							$amount = (isset($cl['amount']) && !empty($cl['amount'])) ? $cl['amount'] : 0;
	// 							$policyperiod = (isset($cl['pp']) && !empty($cl['pp'])) ? $cl['pp'] : '';
	// 							$st = $this->hoursTodays($startTime);
	// 							$et = $this->hoursTodays($endTime);
	// 							$TimeFrame = $st . ' to ' . $et;
	// 							$noshow[$keys] = $cl;
	// 							$noshow[$keys]['CurrencyTitle'] = $this->CurrencyTitle;
	// 							$noshow[$keys]['amount'] = $amount;
	// 							$noshow[$keys]['sector'] = $key;
	// 							$noshow[$keys]['policyInfo'] = $policyInfo_;
	// 							$noshow[$keys]['TimeFrame'] = (!empty($policyperiod)) ? $policyperiod : $TimeFrame;
	// 							$noshow[$keys]['additionalFee'] = round($additionalFee + (float) ($intMarkUp * $intMemberCount));
	// 						}
	// 					} else {
	// 						$noshow[0]['sector'] = $key;
	// 						$noshow[0]['TimeFrame'] = 'As Per Airline';
	// 						$noshow[0]['policyInfo'] = ['As Per Airline'];
	// 					}
	// 					$seatchange = [];
	// 					if ($SEAT_CHARGEABLE) {
	// 						foreach ($SEAT_CHARGEABLE as $keys => $cl) {
	// 							$policyInfo_ = (isset($cl['policyInfo']) && !empty($cl['policyInfo'])) ? array_values(array_filter(explode('__nls__', $cl['policyInfo']))) : ['As per Airlines'];
	// 							$startTime = (isset($cl['st']) && !empty($cl['st'])) ? $cl['st'] : 0;
	// 							$endTime = (isset($cl['et']) && !empty($cl['et'])) ? $cl['et'] : 0;
	// 							$additionalFee = (isset($cl['additionalFee']) && !empty($cl['additionalFee'])) ? $cl['additionalFee'] : 0;
	// 							$amount = (isset($cl['amount']) && !empty($cl['amount'])) ? $cl['amount'] : 0;
	// 							$policyperiod = (isset($cl['pp']) && !empty($cl['pp'])) ? $cl['pp'] : '';
	// 							$st = $this->hoursTodays($startTime);
	// 							$et = $this->hoursTodays($endTime);
	// 							$TimeFrame = $st . ' to ' . $et;
	// 							$seatchange[$keys] = $cl;
	// 							$seatchange[$keys]['CurrencyTitle'] = $this->CurrencyTitle;
	// 							$seatchange[$keys]['amount'] = $amount;
	// 							$seatchange[$keys]['sector'] = $key;
	// 							$seatchange[$keys]['policyInfo'] = $policyInfo_;
	// 							$seatchange[$keys]['TimeFrame'] = (!empty($policyperiod)) ? $policyperiod : $TimeFrame;
	// 							$seatchange[$keys]['additionalFee'] = round($additionalFee + (float) ($intMarkUp * $intMemberCount));
	// 						}
	// 					} else {
	// 						$seatchange[0]['sector'] = $key;
	// 						$seatchange[0]['TimeFrame'] = 'As Per Airline';
	// 						$seatchange[0]['policyInfo'] = ['Fees As Per Airline Rule + Surcharges'];
	// 					}
	// 					$FareRulesCancel['CANCELLATION'] = $cancel;
	// 					$FareRulesCancel['DATECHANGE'] = $datechange;
	// 					$FareRulesCancel['NO_SHOW'] = $noshow;
	// 					$FareRulesCancel['SEAT_CHARGEABLE'] = $seatchange;
	// 				}
	// 			}
	// 		} elseif ($ICSourceSysId == 17) {
	// 			$selectedflight = isset($getData['ApiResultIndex']) ? $getData['ApiResultIndex'] : 0;
					
	// 				$request = array(
	// 					"farerulerequest" => [
	// 						'selectedflight'=>$selectedflight,
	// 						'selectedflighttw'=>'',
	// 					],
	// 				);
					
	// 				$DataS = array(
	// 					'farerule'=>$request,
	// 					'memberCount'=>$intMemberCount,
	// 					'JourneyType'=>$route,
	// 					'interNationalSearch'=>$interNationalSearch,
	// 					'searchID'=>$getData['SearchFlightTraceId'],
	// 					'ICSourceSysId'=>$ICSourceSysId,
	// 				);
	// 				// echo '<pre>';print_r(json_encode($DataS));die;
	// 				$getData['BookingData'] = $intOutBoundId;
	// 				$url = $this->GTXAPIDEFAULT.'/flight/v3/farerules';
	// 				$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
	// 				// echo "apiResponse<pre>";
	// 				// print_r($apiResponse);
	// 				// echo "</pre>";die;
	// 		} elseif ($ICSourceSysId == 16) {
	// 			$TraceId = explode('-',$getData['TraceId']);
	// 			$TraceId__ = [];
	// 			if($TraceId){
	// 				foreach($TraceId as $tr){
	// 					$TraceId__[] = ['FlightID'=>$tr];
	// 				}
	// 			}
	// 			$request = array(
	// 				'FlightsInfo'=>$TraceId__,
	// 				'Trackid'=>$getData['ApiResultIndex'],
	// 			);
	// 			$DataS = array(
	// 				'farerule'=>$request,
	// 				'memberCount'=>$intMemberCount,
	// 				'JourneyType'=>$route,
	// 				'interNationalSearch'=>$interNationalSearch,
	// 				'searchID'=>$getData['SearchFlightTraceId'],
	// 				'ICSourceSysId'=>$ICSourceSysId,
	// 				'SegmentId'=>$getData['TraceId'],
	// 			);
	// 			$getData['BookingData'] = $intOutBoundId;
	// 			$url = $this->GTXAPIDEFAULT.'/flight/v3/farerules';
	// 			$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);

	// 		}
	// 		$this->view->FareRulesCancel = $FareRulesCancel;
	// 		$this->view->apiResponse = $apiResponse;
	// 		$this->view->ICSourceSysId = $ICSourceSysId;
	// 		$this->view->getData = $getData;
	// 		$this->view->route = $route;
	// 		$this->view->intMarkUp = ceil(($intMarkUp * $intMemberCount) * $this->CurrencyRate);
	// 		$this->view->IsLCC = $getData['IsLCC'];
	// 		$this->view->CurrencyTitle = $this->CurrencyTitle;
	// 		$this->view->interNationalSearch = $interNationalSearch;
	// 	} else {
	// 		die('Page not found!');
	// 	}
	// }
	public function getflightfarerulesnewAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$getData = $this->getRequest()->getParams();
			$key = SECURITYKEY;
			$decrypted = $this->cryptoJsAesDecrypt($key, $getData['item']);
			$item = json_decode($decrypted,1);
			// echo "getData getData ==== <pre>";print_r(json_encode($getData));
			// echo "getData item ==== <pre>";print_r(json_encode($item));
			// // echo"<pre>";print_r($item);
			// die();
			$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
			$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
			$adultCount = $sessionFlightSearchParams->params['adults'];
			$childCount = $sessionFlightSearchParams->params['child'];
			$infantCount = $sessionFlightSearchParams->params['infant'];
			$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);
			$PriceID = !empty($getData['PriceID']) ? $getData['PriceID'] : '';
			$ICSourceSysId = !empty($item['ICSourceSysId']) ? $item['ICSourceSysId'] : ($getData['ICSourceSysId'] ?? 0);
			$SupplierType = ($ICSourceSysId == 3) ? 1 : 2;
			$intMemberCount = $adultCount + $childCount + $infantCount;
			$intMarkUp = $this->getCancelCharge($intCountryCode, $SupplierType);
			$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
			$SearchFlightTraceId = trim($sessionFlightSearchParams->params['SearchFlightTraceId']);
			$route = trim($sessionFlightSearchParams->params['route']);
			$getData['SearchFlightTraceId'] = $SearchFlightTraceId;
			// 
			$getData['flowType'] = 'SEARCH';
			$getData['SearchFlightTraceId'] = ($item['searchID']) ? $item['searchID'] : ($getData['searchID'] ?? '');
			$getData['apiTraceId'] = isset($item['apiTraceId'])?$item['apiTraceId']:$PriceID;
			if(!isset($getData['ApiResultIndex'])){
				$getData['ApiResultIndex'] = isset($item['ApiResultIndex'])?$item['ApiResultIndex']:$PriceID;
			}
			
			$FairRules = [];
			if ($item['FairRules']) {
				foreach ($item['FairRules'] as $price) {
					if ($price['PriceID'] == $PriceID) {
						$FairRules = $price;
					}
				}
			}
			$item['FairRules'] = $FairRules;
			$FareRulesCancel = [];
		
			if ($ICSourceSysId == 3) {
				$request = array(
					'TraceId' =>  (isset($getData['apiTraceId']) && !empty($getData['apiTraceId'])) ? $getData['apiTraceId'] : $getData['TraceId'],
					'ResultIndex' => $getData['ApiResultIndex'],
				);
				$DataS = array(
					'farerule' => $request,
					'memberCount'=> $intMemberCount,
					'JourneyType'=> $route,
					'interNationalSearch'=> $interNationalSearch,
					'searchID'=> $getData['SearchFlightTraceId'],
					'ICSourceSysId'=> $ICSourceSysId
				);
		
				$url = $this->GTXAPIDEFAULT.'/flight/v3/farerules';
				$apiResponseAPI = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
			
				$apiResponse = isset($apiResponseAPI['results']) ? $apiResponseAPI['results'] : [];
				$status = isset($apiResponseAPI['status']) ? $apiResponseAPI['status'] : false;
				$message = isset($apiResponseAPI['message']) ? $apiResponseAPI['message'] : '';
				$NewFareRules = isset($apiResponseAPI['NewFareRules']) ? $apiResponseAPI['NewFareRules'] : [];
				$FareRulesCancel = $NewFareRules;

				// $getData['TraceId'] = isset($getData['apiTraceId']) ? $getData['apiTraceId'] : $getData['TraceId'];
				// $apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareRules($getData);
			
			} elseif ($ICSourceSysId == 7) {
				$request = array(
					'id' => $PriceID,
					'flowType' => 'SEARCH',
				);
				$DataS = array(
					'farerule' => $request,
					'memberCount'=> $intMemberCount,
					'JourneyType'=> $route,
					'interNationalSearch'=> $interNationalSearch,
					'searchID'=> $getData['SearchFlightTraceId'],
					'ICSourceSysId'=> $ICSourceSysId
				);
				$url = $this->GTXAPIDEFAULT.'/flight/v3/farerules';
				$apiResponseAPI = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
				$apiResponse = isset($apiResponseAPI['results']) ? $apiResponseAPI['results'] : [];
				$status = isset($apiResponseAPI['status']) ? $apiResponseAPI['status'] : false;
				$message = isset($apiResponseAPI['message']) ? $apiResponseAPI['message'] : '';
				$NewFareRules = isset($apiResponseAPI['NewFareRules']) ? $apiResponseAPI['NewFareRules'] : [];
				$FareRulesCancel = $NewFareRules;
					// old data
				// $getData['TraceId'] = $PriceID;
				// $apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareRulesTripJack($getData);
				// // echo json_encode($apiResponse);
				// // echo "<pre>";   print_r($apiResponse); echo "</pre>";die;
				// $FareRules = isset($apiResponse['fareRule']) ? $apiResponse['fareRule'] : [];
				// $success = $apiResponse['status']['success'];

				// if ($FareRules) {
				// 	foreach ($FareRules as $key => $val) {
				// 		$CANCELLATION = isset($val['tfr']['CANCELLATION']) ? $val['tfr']['CANCELLATION'] : '';
				// 		$DATECHANGE = isset($val['tfr']['DATECHANGE']) ? $val['tfr']['DATECHANGE'] : '';
				// 		$NO_SHOW = isset($val['tfr']['NO_SHOW']) ? $val['tfr']['NO_SHOW'] : '';
				// 		$SEAT_CHARGEABLE = isset($val['tfr']['SEAT_CHARGEABLE']) ? $val['tfr']['SEAT_CHARGEABLE'] : '';
				// 		$cancel = [];
				// 		if ($CANCELLATION) {
				// 			foreach ($CANCELLATION as $keys => $cl) {
				// 				$policyInfo_ = isset($cl['policyInfo']) ? array_values(array_filter(explode('__nls__', $cl['policyInfo']))) : ['Airline Cancellation Charges + Taxes + Surcharges'];
				// 				$startTime = (isset($cl['st']) && !empty($cl['st'])) ? $cl['st'] : 0;
				// 				$endTime = (isset($cl['et']) && !empty($cl['et'])) ? $cl['et'] : 0;
				// 				$additionalFee = (isset($cl['additionalFee']) && !empty($cl['additionalFee'])) ? $cl['additionalFee'] : 0;
				// 				$amount = (isset($cl['amount']) && !empty($cl['amount'])) ? $cl['amount'] : 0;
				// 				$policyperiod = (isset($cl['pp']) && !empty($cl['pp'])) ? $cl['pp'] : '';
				// 				$st = $this->hoursTodays($startTime);
				// 				$et = $this->hoursTodays($endTime);
				// 				$TimeFrame = $st . ' to ' . $et;
				// 				$cancel[$keys] = $cl;
				// 				$cancel[$keys]['CurrencyTitle'] = $this->CurrencyTitle;
				// 				$cancel[$keys]['amount'] = $amount;
				// 				$cancel[$keys]['sector'] = $key;
				// 				$cancel[$keys]['policyInfo'] = $policyInfo_;
				// 				$cancel[$keys]['TimeFrame'] = (!empty($policyperiod)) ? $policyperiod : $TimeFrame;
				// 				$cancel[$keys]['additionalFee'] = round($additionalFee + (float) ($intMarkUp * $intMemberCount));
				// 			}
				// 		} else {
				// 			$cancel[0]['sector'] = $key;
				// 			$cancel[0]['TimeFrame'] = 'As Per Airline';
				// 			$cancel[0]['policyInfo'] = ['As Per Airline'];
				// 		}
				// 		$datechange = [];
				// 		if ($DATECHANGE) {
				// 			foreach ($DATECHANGE as $keys => $cl) {
				// 				$policyInfo_ = (isset($cl['policyInfo']) && !empty($cl['policyInfo'])) ? array_values(array_filter(explode('__nls__', $cl['policyInfo']))) : ['Difference in Fare + Taxes + Surcharges'];
				// 				$startTime = (isset($cl['st']) && !empty($cl['st'])) ? $cl['st'] : 0;
				// 				$endTime = (isset($cl['et']) && !empty($cl['et'])) ? $cl['et'] : 0;
				// 				$additionalFee = (isset($cl['additionalFee']) && !empty($cl['additionalFee'])) ? $cl['additionalFee'] : 0;
				// 				$amount = (isset($cl['amount']) && !empty($cl['amount'])) ? $cl['amount'] : 0;
				// 				$policyperiod = (isset($cl['pp']) && !empty($cl['pp'])) ? $cl['pp'] : '';
				// 				$st = $this->hoursTodays($startTime);
				// 				$et = $this->hoursTodays($endTime);
				// 				$TimeFrame = $st . ' to ' . $et;
				// 				$datechange[$keys] = $cl;
				// 				$datechange[$keys]['CurrencyTitle'] = $this->CurrencyTitle;
				// 				$datechange[$keys]['amount'] = $amount;
				// 				$datechange[$keys]['sector'] = $key;
				// 				$datechange[$keys]['policyInfo'] = $policyInfo_;
				// 				$datechange[$keys]['TimeFrame'] = (!empty($policyperiod)) ? $policyperiod : $TimeFrame;
				// 				$datechange[$keys]['additionalFee'] = round($additionalFee + (float) ($intMarkUp * $intMemberCount));
				// 			}
				// 		} else {
				// 			$datechange[0]['sector'] = $key;
				// 			$datechange[0]['TimeFrame'] = 'As Per Airline';
				// 			$datechange[0]['policyInfo'] = ['As Per Airline'];
				// 		}
				// 		$noshow = [];
				// 		if ($NO_SHOW) {
				// 			foreach ($NO_SHOW as $keys => $cl) {
				// 				$policyInfo_ = (isset($cl['policyInfo']) && !empty($cl['policyInfo'])) ? array_values(array_filter(explode('__nls__', $cl['policyInfo']))) : ['Fees As Per Airline Rule + Surcharges'];
				// 				$startTime = (isset($cl['st']) && !empty($cl['st'])) ? $cl['st'] : 0;
				// 				$endTime = (isset($cl['et']) && !empty($cl['et'])) ? $cl['et'] : 0;
				// 				$additionalFee = (isset($cl['additionalFee']) && !empty($cl['additionalFee'])) ? $cl['additionalFee'] : 0;
				// 				$amount = (isset($cl['amount']) && !empty($cl['amount'])) ? $cl['amount'] : 0;
				// 				$policyperiod = (isset($cl['pp']) && !empty($cl['pp'])) ? $cl['pp'] : '';
				// 				$st = $this->hoursTodays($startTime);
				// 				$et = $this->hoursTodays($endTime);
				// 				$TimeFrame = $st . ' to ' . $et;
				// 				$noshow[$keys] = $cl;
				// 				$noshow[$keys]['CurrencyTitle'] = $this->CurrencyTitle;
				// 				$noshow[$keys]['amount'] = $amount;
				// 				$noshow[$keys]['sector'] = $key;
				// 				$noshow[$keys]['policyInfo'] = $policyInfo_;
				// 				$noshow[$keys]['TimeFrame'] = (!empty($policyperiod)) ? $policyperiod : $TimeFrame;
				// 				$noshow[$keys]['additionalFee'] = round($additionalFee + (float) ($intMarkUp * $intMemberCount));
				// 			}
				// 		} else {
				// 			$noshow[0]['sector'] = $key;
				// 			$noshow[0]['TimeFrame'] = 'As Per Airline';
				// 			$noshow[0]['policyInfo'] = ['As Per Airline'];
				// 		}
				// 		$seatchange = [];
				// 		if ($SEAT_CHARGEABLE) {
				// 			foreach ($SEAT_CHARGEABLE as $keys => $cl) {
				// 				$policyInfo_ = (isset($cl['policyInfo']) && !empty($cl['policyInfo'])) ? array_values(array_filter(explode('__nls__', $cl['policyInfo']))) : ['As per Airlines'];
				// 				$startTime = (isset($cl['st']) && !empty($cl['st'])) ? $cl['st'] : 0;
				// 				$endTime = (isset($cl['et']) && !empty($cl['et'])) ? $cl['et'] : 0;
				// 				$additionalFee = (isset($cl['additionalFee']) && !empty($cl['additionalFee'])) ? $cl['additionalFee'] : 0;
				// 				$amount = (isset($cl['amount']) && !empty($cl['amount'])) ? $cl['amount'] : 0;
				// 				$policyperiod = (isset($cl['pp']) && !empty($cl['pp'])) ? $cl['pp'] : '';
				// 				$st = $this->hoursTodays($startTime);
				// 				$et = $this->hoursTodays($endTime);
				// 				$TimeFrame = $st . ' to ' . $et;
				// 				$seatchange[$keys] = $cl;
				// 				$seatchange[$keys]['CurrencyTitle'] = $this->CurrencyTitle;
				// 				$seatchange[$keys]['amount'] = $amount;
				// 				$seatchange[$keys]['sector'] = $key;
				// 				$seatchange[$keys]['policyInfo'] = $policyInfo_;
				// 				$seatchange[$keys]['TimeFrame'] = (!empty($policyperiod)) ? $policyperiod : $TimeFrame;
				// 				$seatchange[$keys]['additionalFee'] = round($additionalFee + (float) ($intMarkUp * $intMemberCount));
				// 			}
				// 		} else {
				// 			$seatchange[0]['sector'] = $key;
				// 			$seatchange[0]['TimeFrame'] = 'As Per Airline';
				// 			$seatchange[0]['policyInfo'] = ['Fees As Per Airline Rule + Surcharges'];
				// 		}
				// 		$FareRulesCancel['CANCELLATION'] = $cancel;
				// 		$FareRulesCancel['DATECHANGE'] = $datechange;
				// 		$FareRulesCancel['NO_SHOW'] = $noshow;
				// 		$FareRulesCancel['SEAT_CHARGEABLE'] = $seatchange;
				// 	}
				// }
			} elseif ($ICSourceSysId == 17) {
				$selectedflight = isset($getData['ApiResultIndex']) ? $getData['ApiResultIndex'] : 0;
					
					$request = array(
						"farerulerequest" => [
							'selectedflight'=>$selectedflight,
							'selectedflighttw'=>'',
						],
					);
					
					$DataS = array(
						'farerule'=>$request,
						'memberCount'=>$intMemberCount,
						'JourneyType'=>$route,
						'interNationalSearch'=>$interNationalSearch,
						'searchID'=>$getData['SearchFlightTraceId'],
						'ICSourceSysId'=>$ICSourceSysId,
					);
					// echo '<pre>';print_r(json_encode($DataS));die;
					$getData['BookingData'] = $intOutBoundId;
					$url = $this->GTXAPIDEFAULT.'/flight/v3/farerules';
					$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
					// echo "apiResponse<pre>";
					// print_r($apiResponse);
					// echo "</pre>";die;
			} elseif ($ICSourceSysId == 16) {
				$TraceId = explode('-',$getData['TraceId']);
				$TraceId__ = [];
				if($TraceId){
					foreach($TraceId as $tr){
						$TraceId__[] = ['FlightID'=>$tr];
					}
				}
				$request = array(
					'FlightsInfo'=>$TraceId__,
					'Trackid'=>$getData['ApiResultIndex'],
				);
				$DataS = array(
					'farerule'=>$request,
					'memberCount'=>$intMemberCount,
					'JourneyType'=>$route,
					'interNationalSearch'=>$interNationalSearch,
					'searchID'=>$getData['SearchFlightTraceId'],
					'ICSourceSysId'=>$ICSourceSysId,
					'SegmentId'=>$getData['TraceId'],
				);
				$getData['BookingData'] = $intOutBoundId;
				$url = $this->GTXAPIDEFAULT.'/flight/v3/farerules';
				$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);

			} elseif ($ICSourceSysId == 11) {
				
				
				$request = array(
					'Auth_Header'=>array(
						"IP_Address" => $_SERVER['REMOTE_ADDR'],
						"Request_Id" => $item['SearchTraceId'],
						"IMEI_Number" => "3434334343111"
					),
					'Fare_Id'=>$getData['PriceID'],
					'Search_Key'=>$item['Search_Key'],
					'Flight_Key'=>$item['Flight_Key'],
				);
				$DataS = array(
					'farerule'=>$request,
					'memberCount'=>$intMemberCount,
					'JourneyType'=>$route,
					'interNationalSearch'=>$interNationalSearch,
					'searchID'=>$item['SearchTraceId'],
					'ICSourceSysId'=>$ICSourceSysId,
					'APIMode' => $this->APIMode
				);
				// echo "apiResponse<pre>";print_r(json_encode($DataS));die;
				$getData['BookingData'] = $intOutBoundId;
				$url = $this->GTXAPIDEFAULT.'/flight/v3/farerules';
				$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
				
			}

			$this->view->FareRulesCancel = $FareRulesCancel;
			$this->view->apiResponse = $apiResponse;
			$this->view->ICSourceSysId = $ICSourceSysId;
			$this->view->getData = $getData;
			$this->view->route = $route;
			$this->view->item = $item;
			$this->view->intMarkUp = ceil(($intMarkUp * $intMemberCount) * $this->CurrencyRate);
			$this->view->IsLCC = $getData['IsLCC'];
			$this->view->CurrencyTitle = $this->CurrencyTitle;
			$this->view->interNationalSearch = $interNationalSearch;
		} else {
			die('Page not found!');
		}
	}

	public function getCancelCharge($intCountryCode, $SupplierType = null)
	{
		if ($intCountryCode) {
			$getMarkup = $this->getCancellationChargeNew($intCountryCode, 1, $SupplierType); ///$this->getMarkup($intCountryCode);

			$intMarkUp = 0;
			if ($getMarkup['status'] == 1) {
				if ($getMarkup['arrAgencyMarkupsCancellation']) {
					foreach ($getMarkup['arrAgencyMarkupsCancellation'] as $value) {
						if ($value['SupplierType'] == $SupplierType && $value['ServiceType'] == 1 && $value['MPType'] == 1) {
							$intGTXMarkUpType = $value['MarkUpType'];
							$MarkUp = $value['MarkUp'];
							$intGTXMarkUpType = $value['MarkUpType'];
							if ($intGTXMarkUpType == 1) { // For Flat
								$intMarkUp += $MarkUp;
							} else { // For Percentage
								$intMarkUp += $MarkUp; //($intOfferedFare * $MarkUp) / 100;
							}
						}
					}
				}
			}
			return $intMarkUp;
		} else {
			$data = array('status' => false, 'message' => 'Invalid request');
			return ($data);
		}
	}

	public function bookNoowAction()
	{
		$post = json_decode(file_get_contents('php://input'), true);
		$roundSelect = isset($post['roundSelect']) ? $post['roundSelect'] : 0;
		$SingleSelect = isset($post['SingleSelect']) ? $post['SingleSelect'] : 0;
		$Outbound = json_decode($post['Outbound'], true);
		$SearchFlightTraceId = isset($Outbound['SearchFlightTraceId']) ? $Outbound['SearchFlightTraceId'] : $Outbound['SearchTraceId'];
		$ICSourceSysId = ($Outbound['ICSourceSysId']) ? $Outbound['ICSourceSysId'] : 0;
		// $Inbound = json_decode(($post['Inbound']) ? $post['Inbound'] : [], true);
		// die('sjsjjsjkjdskjdskjdsskjd');
		if ($post['Inbound']) {
			$Inbound = json_decode(($post['Inbound']) ? $post['Inbound'] : [], true);
		}
		if($ICSourceSysId == 17 || $ICSourceSysId == 16 || $ICSourceSysId == 3 || $ICSourceSysId == 7 || $ICSourceSysId == 11){
			$SearchFlightTraceId = $Outbound['SearchTraceId'];
			$Outbound['SearchFlightTraceId'] = $Outbound['SearchTraceId'];
		}
		// die("tttttt");
		$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $SearchFlightTraceId], ['id' => 'ASC']);
		$arrUrlData = json_decode($temp_data['json_data'], true);
		//echo '<pre>';print_r($SingleSelect);
		//echo '<pre>';print_r($Outbound);die;


		$FairRules = [];
		if ($Outbound['FairRules']) {
			foreach ($Outbound['FairRules'] as $price) {
				if ($price['PriceID'] == $SingleSelect) {
					$FairRules = $price;
				}
			}
		}
		if ($ICSourceSysId == 7) {
			$Outbound['apiTraceId'] = $SingleSelect;
		}
		if ($ICSourceSysId == 3) {
			$Outbound['ApiResultIndex'] = $SingleSelect;
		}

		$Outbound['FairRules'] = $FairRules;
		// echo '<pre>';print_r($Outbound);die;
		$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
		$FlightBookingDataRoundInter = new Zend_Session_Namespace('FlightBookingDataRoundInter');
		$FlightBookingDataInbound = new Zend_Session_Namespace('FlightBookingDataInbound');
		$FlightBookingData->params[0] = $Outbound; // Putting all form data to Session
		$FlightBookingDataRoundInter->params[0] = $Outbound; // Putting all form data to Session
		$apiTraceId = $SingleSelect;

		if (!empty($Inbound)) {
			$RoundFairRules = [];
			if ($Inbound['FairRules']) {
				foreach ($Inbound['FairRules'] as $price2) {
					if ($price2['PriceID'] == $roundSelect) {
						$RoundFairRules = $price2;
					}
				}
			}
			if ($ICSourceSysId == 7) {
				$Inbound['apiTraceId'] = $roundSelect;
			}
			if ($ICSourceSysId == 3) {
				$Inbound['ApiResultIndex'] = $roundSelect;
			}

			$Inbound['FairRules'] = $RoundFairRules;
			$FlightBookingData->params[1] = $Inbound; // Putting all form data to Session
			$FlightBookingDataInbound->params = $Inbound; // Putting all form data to Session
			$apiTraceId = $SingleSelect . ',' . $roundSelect;
		}
		// if($this->gtxagencysysid == '2596'){
		// 	echo "<pre>";
		// 	print_r($post);
		// 	echo "<pre>";
		// 	print_r($FlightBookingData->params);
		// 	die;
		// }
		//echo '<pre>';print_r($BookingDataTemp);
		//echo '<pre>';print_r($ICSourceSysId);
		$arrUrlData['BookingData'] = $FlightBookingData->params;
		$arrUrlData['FlightBookingDataInbound'] = $FlightBookingDataInbound->params;
		$insertArr = array(
			'TraceId' => $SearchFlightTraceId,
			'json_data' => json_encode($arrUrlData),
			'created_at' => date('Y-m-d H:i:s'),
		);
		$this->objMdl->rv_delete('tbl_temp_data', array('TraceId = ?' => $SearchFlightTraceId));
		$objFlight = new Travel_Model_FlightMaster();
		$objFlight->InsertFlightData('tbl_temp_data', $insertArr);
		// echo $apiTraceId;die('dd');
		if ($FlightBookingData->params) {
			$response = array('success' => true, 'message' => 'Plase wait...', 'url' => $this->baseUrl . 'flight/travellers/' . $SearchFlightTraceId);
			echo json_encode($response);
			exit;
		} else {
			$response = array('success' => false, 'message' => 'Oops something went wrong', 'url' => '');
			echo json_encode($response);
			exit;
		}
	}
	public function bookNowMultiAction()
	{
		$post = json_decode(file_get_contents('php://input'), true);
		$roundSelect = isset($post['roundSelect']) ? $post['roundSelect'] : 0;
		$SingleSelect = isset($post['SingleSelect']) ? $post['SingleSelect'] : 0;
		$Outbound = json_decode($post['Outbound'], true);
		
		$FareArr = json_decode(($post['FareArr']) ? $post['FareArr'] : json_encode([]), true);
		$FlightBookingDataArr = [];
		$apiTraceId = [];
		if ($Outbound) {
			foreach ($Outbound as $key => $item) {
				$FairRules = isset($FareArr[$key]) ? $FareArr[$key] : [];
				$apiTraceId[$key] = $FairRules['PriceID'];
				$FlightBookingDataArr[$key] = $item;
				$FlightBookingDataArr[$key]['FairRules'] = $FairRules;
			}
		}
		
		$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
		$FlightBookingData->params = $FlightBookingDataArr; // Putting all form data to Session

		$apiTraceId = implode(',', $apiTraceId);

		$SearchFlightTraceId = ($Outbound[0]['SearchFlightTraceId']) ? $Outbound[0]['SearchFlightTraceId'] : $Outbound[0]['SearchTraceId'];
		
		
		$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $SearchFlightTraceId], ['id' => 'ASC']);
		$arrUrlData = json_decode($temp_data['json_data'], true);
		//
		if ($FlightBookingData->params) {
			$arrUrlData['BookingData'] = $FlightBookingData->params;
			$arrUrlData['FlightBookingDataInbound'] = [];
			$insertArr = array(
				'TraceId' => $SearchFlightTraceId,
				'json_data' => json_encode($arrUrlData),
				'created_at' => date('Y-m-d H:i:s'),
			);
			$this->objMdl->rv_delete('tbl_temp_data', array('TraceId = ?' => $SearchFlightTraceId));
			$objFlight = new Travel_Model_FlightMaster();
			$objFlight->InsertFlightData('tbl_temp_data', $insertArr);
			$response = array('success' => true, 'message' => 'Plase wait...', 'url' => $this->baseUrl . 'flight/travellers/' . $SearchFlightTraceId);
			echo json_encode($response);
			exit;
		} else {
			$response = array('success' => false, 'message' => 'Oops something went wrong', 'url' => '');
			echo json_encode($response);
			exit;
		}
	}

	public function reviewAction()
	{
		$param = $this->getRequest()->getParams();
		$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
		$FlightBookingDataInbound = new Zend_Session_Namespace('FlightBookingDataInbound');
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$FlightSearchUrl = new Zend_Session_Namespace('FlightSearchUrl');
		//$FlightBookingDataRoundInter = new Zend_Session_Namespace('FlightBookingDataRoundInter');
		$this->view->FlightSearchUrl = $FlightSearchUrl->params;
		$class = $sessionFlightSearchParams->params['class'];
		$this->view->traceId = $param['traceId'];
		$this->view->param = $param;
		$this->view->departure_date = $sessionFlightSearchParams->params['strDepatureDate'];
		$this->view->return_dates = $sessionFlightSearchParams->params['strReturnDate'];
		$this->view->class = $class;
		$this->view->CurrencyRate = $this->CurrencyRate;
		$this->view->CurrencyTitle = $this->CurrencyTitle;
		$this->view->sessionFlightSearchParams = $sessionFlightSearchParams->params;
		$this->view->FlightBookingData = $FlightBookingData->params;
		$this->view->FlightBookingDataInbound = $FlightBookingDataInbound->params;
		//echo '<pre>';print_r($FlightBookingDataRoundInter->params);die;
		//   echo '<pre>';print_r($param);
		//   die;
	}

	public function travellersAction()
	{
		//  echo("hello here"); die('hddhdggd');
		// ini_set('display_errors', 1);
		// ini_set('display_startup_errors', 1);
		// error_reporting(E_ALL);Customerdata

		$param = $this->getRequest()->getParams();
		$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');

		$FlightBookingDataInbound = new Zend_Session_Namespace('FlightBookingDataInbound');
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$FlightSearchUrl = new Zend_Session_Namespace('FlightSearchUrl');
		//  echo $this->gtxagencysysid;die;

		$getAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->gtxagencysysid);
		$this->siteName = (isset($getAgencyData['DisplayName']) && !empty($getAgencyData['DisplayName']))?$getAgencyData['DisplayName']: $this->siteName;

		$getData = $this->getRequest()->getParams();

		$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $getData['traceId']], ['id' => 'ASC']);

		$arrUrlData = json_decode($temp_data['json_data'], true);
		$FlightBookingData->params = isset($arrUrlData['BookingData']) ? $arrUrlData['BookingData'] : [];

		if ($FlightBookingData->params[0]['FairRules']['IsGSTRequired']) {
			$isgstsmondatory = 'mondatory';
		} else {
			$isgstsmondatory = 'optional';
		}

		if (isset($FlightBookingData->params[0]['isDobAdult'])) {
			$dobadult = "required";
		}
		if (isset($FlightBookingData->params[0]['isDobChild'])) {
			$dobchild = "required";
		}
		if (isset($FlightBookingData->params[0]['isDobInfant'])) {
			$dobinfant = "required";
		}


		$dobadult = '';
		$dobchild = '';
		$dobinfant = '';
		$this->view->siteName = $this->siteName;
		$this->view->dobadult = $dobadult;
		$this->view->dobchild = $dobchild;
		$this->view->dobinfant = $dobinfant;
		$this->view->isgstsmondatory = $isgstsmondatory;
		$this->view->FlightSearchUrl = $FlightSearchUrl->params;
		$class = $sessionFlightSearchParams->params['class'];
		$this->view->traceId = $param['traceId'];
		$this->view->departure_date = $sessionFlightSearchParams->params['strDepatureDate'];
		$this->view->return_dates = $sessionFlightSearchParams->params['strReturnDate'];
		$this->view->class = $class;
		$this->view->param = $param;
		$this->view->CurrencyRate = $this->CurrencyRate;
		$this->view->CurrencyTitle = $this->CurrencyTitle;
		$this->view->sessionFlightSearchParams = $sessionFlightSearchParams->params;
		$this->view->FlightBookingData = $FlightBookingData->params;
		$this->view->FlightBookingDataInbound = $FlightBookingDataInbound->params;
		$objFlight = new Travel_Model_FlightMaster();
		$GetCustomerData = [];
		if (!empty($this->_session->session)) {
			$GetCustomerData = $objFlight->GetCustomerData('tbl_customer', null, $this->_session->session['ContactNo1'], $this->_session->session['EmailId'], $this->gtxagencysysid);
		}

		//  
		$Customerdata = [];
		if (!empty($this->_session->session['CustomerSysId'])) {
			$Customerdata = $this->objMdl->selectOne('tbl_customer', ['*'], ['GTX_customerSysId' => $this->_session->session['CustomerSysId'], 'IsMarkForDel' => 0, 'IsActive' => 1]);
			//$Customerdata = $objFlight->CheckCustomer('tbl_customer', ['CustomerSysId' => $GetCustomerData['CustomerSysId']]);
		}
		if(empty($Customerdata)){
			$Customerdata['Contacts'] = $this->_session->session['ContactNo1'];
			$Customerdata['EmailId'] = $this->_session->session['EmailId'];
			$Customerdata['GTX_customerSysId'] = $this->_session->session['CustomerSysId'];
		}
		// echo"<pre>";print_r($this->_session->session);
		// echo"<pre>";print_r($Customerdata); 
		// die('ninini');
		$this->view->Customerdata = $Customerdata;
		$this->view->loginuserdata = $this->_session->session;
		$CountryCode = $this->getCountryCodeList();
		$this->view->CountryCode = $CountryCode;
		$this->view->getAgencyData = $getAgencyData;

		if ($this->getRequest()->isXmlHttpRequest() && $this->getRequest()->isPost()) {
			$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
			$apiTraceId = $FlightBookingData->params[0]['SearchFlightTraceId'];
			$ICSourceSysId = $FlightBookingData->params[0]['ICSourceSysId'];
			$ServiceFee__ = 0;
			$PublishedFare = 0;
			if ($FlightBookingData->params) {
				foreach ($FlightBookingData->params as $value) {
					$ServiceFee__ += $value['FairRules']['FixedMarkUp'];
					$AdditionalTxnFeePub = 0;
					$TotalBaseFare = 0;
					$TotalTaxsandFees = 0;
					if ($value['FairRules']['FareBreakdown']) {
						foreach ($value['FairRules']['FareBreakdown'] as $value) {

							$MF = $value['MF']; //Management Fee
							$TDS = $value['TDS']; //Management Fee
							$YQ = $value['YQ']; //Fuel Surcharge
							$AGST = $value['AGST']; //Airline GST Component
							$MFT = $value['MFT']; //Management Fee Tax
							// $OT = $value['OT']; //Other Charges
							$OT = isset($value['OT'])?$value['OT']:$value['TaxBR']['OT']; //Other 
							$MU = $value['MU']; //Markup
							$YR = $value['YR']; //Carrier Misc Fee
							$other = $MF + $YQ + $AGST + $MFT + $OT + $YR;
							if ($ICSourceSysId == 3) {
								$other =  $MF + $AGST + $MFT + $OT + $YR;
							}
							$PBaseFare = $value['BaseFare'];
							$intTotalGST = $value['intTotalGST'];
							$FixedMarkUp = $value['FixedMarkUp'];
							$apiMarkup = $value['apiMarkup'];
							$IntCommission = $value['IntCommission'];
							$CommissionEarned = $value['CommissionEarned'];
							$CommisionPass = $value['CommisionPass'];
							$ServiceFee = $value['ServiceFee'];

							$paxPublishedFare = ($PBaseFare);
							$PassengerType = $value['PassengerType'];
							$PassengerCount = $value['PassengerCount'];
							$AdditionalTxnFeePub += $value['AdditionalTxnFeePub'];

							$TaxesFees = ($other + $intTotalGST + $FixedMarkUp + $apiMarkup + $IntCommission - $CommissionEarned);
							if ($ICSourceSysId == 3) {
								$TaxesFees = ($other + $intTotalGST + $FixedMarkUp + $apiMarkup + $ServiceFee - $CommisionPass);
							}
							$TotalBaseFare += ($paxPublishedFare);
							$TotalTaxsandFees += ($TaxesFees);
						}
					}
					$PublishedFare += $PublishedFare__ = ($TotalBaseFare + $TotalTaxsandFees);
				}
				$CurrencyTitle = isset($FlightBookingData->params[0]['FairRules']['Currency']) ? $FlightBookingData->params[0]['FairRules']['Currency'] : 'INR';
			}
			$data = array(
				'AgencySysId' => $this->gtxagencysysid,
				'ServiceFee' => ceil($ServiceFee__ * $this->CurrencyRate),
				'CriteriaValue' => ceil($PublishedFare * $this->CurrencyRate),
				'ProductType' => 1,
				'TravelDate' => date('Y-m-d'),
			);
			$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->availableCoupon($data);
			$this->view->availableCoupon = $apiResponse;
			// if($this->gtxagencysysid == '21'){
			// 	echo "<pre>";
			// 	print_r($data);
			// 	echo "<pre>";
			// 	print_r($apiResponse);
			// 	die;
			// }
			if ($apiResponse['status']) {
				$response = array('success' => true, 'message' => 'Done', 'response' => $apiResponse, 'CurrencyTitle' => $CurrencyTitle);
				echo json_encode($response);
				exit;
			} else {
				$response = array('success' => false, 'message' => 'Done', 'response' => []);
				echo json_encode($response);
				exit;
			}
		}
		// echo "<pre>";
		// print_r($apiResponse);
		// echo "</pre>";
		// echo '<pre>';print_r($Customerdata);
		//       echo '<pre>';print_r($this->_session->session);
		//  die;
	}


	public function travellerspageAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$getData = $this->getRequest()->getParams();
			$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
			$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
			$adultCount = $sessionFlightSearchParams->params['adults'];
			$childCount = $sessionFlightSearchParams->params['child'];
			$infantCount = $sessionFlightSearchParams->params['infant'];
			$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);
			$customerarray = $this->getsearchcutomer($getData);
			$intMemberCount = $adultCount + $childCount + $infantCount;
			$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
			$flightSSRDetails = new Zend_Session_Namespace('flightSSRDetails');

			$this->view->FlightBookingData = $FlightBookingData->params;
			$this->view->flightSSRDetails = $flightSSRDetails->params;
			$this->view->getData = $getData;
			$this->view->interNationalSearch = $interNationalSearch;
			$this->view->sessionFlightSearchParams = $sessionFlightSearchParams->params;
			$CountryCode = $this->getCountryCodeList();
			$this->view->CountryCode = $CountryCode;
			$this->view->customerarray = $customerarray;
		} else {
			die('Page not found!');
		}
	}

	public function loadAddOnsAction()
	{
		$getData = $this->getRequest()->getParams();
		$CustomerSession = new Zend_Session_Namespace('CustomerSession');
		$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
		$FlightBookingDataInbound = new Zend_Session_Namespace('FlightBookingDataInbound');
		$flightSSRDetails = new Zend_Session_Namespace('flightSSRDetails');
		$flightSSRDetailsInb = new Zend_Session_Namespace('flightSSRDetailsInb');
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$ResponseInb = $flightSSRDetailsInb->params;
		$Response = $flightSSRDetails->params;
		$TraceId = $getData['TraceId'];
		$getData = $this->getRequest()->getParams();
		$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $getData['TraceId']], ['id' => 'ASC']);

		$arrUrlData = json_decode($temp_data['json_data'], true);
		$SSRArr = $Response;
		$BookingData = $arrUrlData['BookingData'];
		$CustomerSession = $arrUrlData['CustomerSession'];
		// echo '<pre>';print_r($CustomerSession);
		// echo '<pre>';print_r($BookingData);
		// die;
		$html = new Zend_View();
		$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
		$html->assign(array('CustomerSession' => $CustomerSession, 'SSRArr' => $SSRArr, 'SSRArrInb' => [], 'flightSSRDetails' => $flightSSRDetails->params, 'FlightBookingData' => $BookingData, 'FlightBookingDataInbound' => $FlightBookingDataInbound->params, 'sessionFlightSearchParams' => $sessionFlightSearchParams->params));
		$bodyText = $html->render('load-add-ons.phtml');
		$response = array('success' => true, 'message' => 'Done', 'html' => $bodyText);
		echo json_encode($response);
		exit;
		//print_r($getData);
	}

	public function searchcustomermemberAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			$param = $this->getRequest()->getParams();
			if (isset($param['CustomerSysId']) && $param['CustomerSysId'] > 0) {
				$objFlight = new Travel_Model_FlightMaster();
				$customerMember = $objFlight->GetFlightCustomerMember('tbl_customer_member', array('CustomerSysId' => $param['CustomerSysId']));
				$customerMemberArr = [];
				//       echo '<pre>';print_r($customerMember);die;
				if (!empty($customerMember)) {
					foreach ($customerMember as $key => $member) {
						$DOBm = explode('-', $member['DOB']);
						if ($member['paxType'] == 1) {
							$paxtype = 'Adult';
						} elseif ($member['paxType'] == 2) {
							$paxtype = 'Child';
						} else {
							$paxtype = 'Infant';
						}
						$PassportExpirym = ($member['PassportExpiry'] != '0000-00-00') ? date('d/m/Y', strtotime($member['PassportExpiry'])) : '';
						$customerMemberArr[] = array(
							'label' => $member['EmailId'] . '(' . $member['FirstName'] . ' ' . $member['LastName'] . ')',
							'value' => $member['EmailId'],
							'index' => $key + 2,
							'CustomerMemberSysId' => $member['CustomerMemberSysId'],
							'CustomerSysId' => $member['CustomerSysId'],
							'Salutation' => $member['Salutation'],
							'Relation' => $member['Relation'],
							'Contacts' => $member['Contacts'],
							'FirstName' => $member['FirstName'],
							'LastName' => $member['LastName'],
							'Address' => $member['Address'],
							'CityTitle' => $member['CityTitle'],
							'CitySysId' => !empty($member['CitySysId']) ? $member['CitySysId'] : 0,
							'CountrySysId' => $member['CountrySysId'],
							'countryCode' => $member['countryCode'],
							'PassportNo' => $member['PassportNo'],
							'PassportNation' => $member['PassportNation'],
							'paxType' => $member['paxType'],
							'paxTypeName' => $paxtype,
							'PassportExpiry' => $PassportExpirym,
							'dobday' => $DOBm[2],
							'dobmonth' => $DOBm[1],
							'dobyear' => $DOBm[0],
						);
					}
					$response = array(
						'label' => '',
						'success' => true,
						'CustomerSysId' => 0,
						'customerMember' => $customerMemberArr,
					);
					echo json_encode($response);
					exit;
				} else {
					$response = array(
						'label' => '',
						'success' => false,
						'CustomerSysId' => 0,
						'customerMember' => []
					);
					echo json_encode($response);
					exit;
				}
			} else {
				$response = array(
					'label' => '',
					'success' => false,
					'CustomerSysId' => 0,
					'customerMember' => []
				);
				echo json_encode($response);
				exit;
			}
		}
	}
	public function searchcutomerAction()
	{

		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$this->_helper->viewRenderer->setNoRender(true);
			$param = $this->getRequest()->getParams();
			$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
			$ARR_SALUTION = unserialize(ARR_SALUTION);
			$ARR_SALUTION_CHILD = unserialize(ARR_SALUTION_CHILD);
			$modulename = isset($param['modulename']) ? $param['modulename'] : '';
			$apiData = array(
                "AgencySysId" => $this->gtxagencysysid,
                "EmailId" => $param['leadEmail'],
                "Contacts" => $param['leadMobile'],
            );
			$customermembers = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getcustomermembers($apiData);
			$result = isset($customermembers['result'])?$customermembers['result']:[];
			echo json_encode($result);
			exit;
			
			$customer = isset($customermembers['customer'])?$customermembers['customer']:[];
			$customerMemberArr = [];

			if ($getdataMemeber) {
				foreach ($getdataMemeber as $member) {
					if ($member['paxType'] == 1) {
						$paxtype = 'Adult';
						$SalutationTxt = $ARR_SALUTION[$member['Title']];
					} elseif ($member['paxType'] == 2) {
						$paxtype = 'Child';
						$SalutationTxt = $ARR_SALUTION_CHILD[$member['Title']];
					} else {
						$paxtype = 'Infant';
						$SalutationTxt = $ARR_SALUTION_CHILD[$member['Title']];
					}
					
					if (!empty($member['PassportExpiry'])) {
						$PassportExpiry = (array)$member['PassportExpiry'];
						$PassportExpirym = ($PassportExpiry['date'] != '1900-01-01 00:00:00.000000') ? date('d/m/Y', strtotime($PassportExpiry['date'])) : '';
					} else {
						$PassportExpirym = '';
					}
					if (!empty($member['PassportIssue'])) {
						$PassportIssue = (array)$member['PassportIssue'];
						$passporIssuem = ($PassportIssue['date'] != '1900-01-01 00:00:00.000000') ? date('d/m/Y', strtotime($PassportIssue['date'])) : '';
					} else {
						$passporIssuem = '';
					}
					if (!empty($member['DOB'])) {
						$DOB = (array)$member['DOB'];
						$DOBem = ($DOB['date'] != '1900-01-01 00:00:00.000000') ? date('d/m/Y', strtotime($DOB['date'])) : '';
					} else {
						$DOBem = '';
					}

					$customerMemberArr[$member['MemberSysId']] = array(
						'label' => $member['EmailId'] . '(' . trim($member['FirstName']) . ' ' . trim($member['LastName']) . ')',
						'value' => $member['EmailId'],
						'index' => $key + 2,
						'CustomerMemberSysId' => $member['MemberSysId'],
						'CustomerSysId' => $member['CustomerSysId'],
						'Salutation' => $member['Title'],
						'SalutationTxt' => $SalutationTxt,
						'Relation' => $member['Relation'],
						'RelationTxt' => $ARR_CUSTOMER_RELATION[$member['Relation']],
						'Contacts' => $member['Contacts'],
						'FirstName' => trim($member['FirstName']),
						'LastName' => trim($member['LastName']),
						'Address' => $member['Address'],
						'CityTitle' => isset($member['CityTitle'])?$member['CityTitle']:'',
						'CitySysId' => !empty($member['CitySysId']) ? $member['CitySysId'] : 0,
						'CountrySysId' => !empty($member['CountrySysId']) ? $member['CountrySysId'] : 0,
						'countryCode' => $member['countrycode'],
						'PassportNo' => $member['PassportNo'],
						'PassportNation' => $member['PassportNationality'],
						'paxType' => $member['paxType'],
						'paxTypeName' => $paxtype,
						'companyname' => $value['companyname'],
						'gstnnumber' => $value['gstnnumber'],
						'gstaddress' => $value['gstaddress'],
						'gstemail' => $value['gstemail'],
						'gststate' => $value['gststate'],
						'gstphone' => $value['gstphone'],
						'panno' => $member['PanCard'],
						'PassportExpiry' => $PassportExpirym,
						'passporIssue' => $passporIssuem,
						'DOB' => $DOBem,
					);
				}
			}
			$response = [];
			if($customer){
				if ($customer['paxType'] == 1) {
					$paxtype = 'Adult';
					$SalutationTxt = $ARR_SALUTION[$customer['Title']];
				} elseif ($customer['paxType'] == 2) {
					$paxtype = 'Child';
					$SalutationTxt = $ARR_SALUTION_CHILD[$customer['Title']];
				} else {
					$paxtype = 'Infant';
					$SalutationTxt = $ARR_SALUTION_CHILD[$customer['Title']];
				}
				
				if (!empty($customer['PassportExpiry'])) {
					$PassportExpiry = $customer['PassportExpiry'];
					$PassportExpirym = ($PassportExpiry != '1900-01-01 00:00:00.000000') ? ($PassportExpiry) : '';
				} else {
					$PassportExpirym = '';
				}
				if (!empty($customer['PassportIssue'])) {
					$PassportIssue = $customer['PassportIssue'];
					$passporIssuem = ($PassportIssue != '1900-01-01 00:00:00.000000') ? ($PassportIssue) : '';
				} else {
					$passporIssuem = '';
				}
				if (!empty($customer['DOB'])) {
					$DOB = $customer['DOB'];
					$DOBem = ($DOB != '1900-01-01 00:00:00.000000') ? ($DOB) : '';
				} else {
					$DOBem = '';
				}

				$response[$customer['CustomerSysId']] = $leadPax = array(
					'label' => $customer['EmailId'] . '(' . trim($customer['FirstName']) . ' ' . trim($customer['LastName']) . ')',
					'value' => $customer['EmailId'],
					'index' => $key + 2,
					'CustomerMemberSysId' => $customer['CustomerSysId'],
					'CustomerSysId' => $customer['CustomerSysId'],
					'Salutation' => $customer['Title'],
					'SalutationTxt' => $SalutationTxt,
					'Relation' => $customer['Relation'],
					'RelationTxt' => $ARR_CUSTOMER_RELATION[$customer['Relation']],
					'Contacts' => $customer['Contacts'],
					'FirstName' => trim($customer['FirstName']),
					'LastName' => trim($customer['LastName']),
					'Address' => $customer['Address'],
					'CityTitle' => isset($customer['CityTitle'])?$customer['CityTitle']:'',
					'CitySysId' => !empty($customer['CitySysId']) ? $customer['CitySysId'] : 0,
					'CountrySysId' => !empty($customer['CountrySysId']) ? $customer['CountrySysId'] : 0,
					'countryCode' => $customer['countrycode'],
					'PassportNo' => $customer['PassportNo'],
					'PassportNation' => $customer['PassportNationality'],
					'paxType' => $customer['paxType'],
					'paxTypeName' => $paxtype,
					'companyname' => $value['companyname'],
					'gstnnumber' => $value['gstnnumber'],
					'gstaddress' => $value['gstaddress'],
					'gstemail' => $value['gstemail'],
					'gststate' => $value['gststate'],
					'gstphone' => $value['gstphone'],
					'panno' => $customer['PanCard'],
					'PassportExpiry' => $PassportExpirym,
					'passporIssue' => $passporIssuem,
					'DOB' => $DOBem,
				);

				$responseArray = [];
				$array_merge = array_merge($response, $customerMemberArr);
				if ($array_merge) {
					foreach ($array_merge as $key => $val) {
						if ($key == 0) {
							$responseArray['_' . $val['CustomerSysId']] = $val;
						} else {
							$responseArray['_' . $val['CustomerMemberSysId']] = $val;
						}
					}
				}
				
				if (!empty($responseArray)) {
					$array = array();
					$array = array('success' => true, 'leadPax' => $leadPax, 'msg' => 'success', 'data' => $responseArray);
					echo json_encode($array);
					exit;
				} else {
					echo json_encode(array('success' => false, 'msg' => 'no record found', 'data' => $responseArray));
					exit;
				}
			}
			// echo '<pre>';print_r($response);
			// echo '<pre>';print_r($customerMemberArr);
			// Old Code
			die;
			
		} else {
			die('Page not found');
		}
		//        echo '<pre>';print_r($response);die;
	}

	public function getsearchcutomer($param)
	{
		$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
		$ARR_SALUTION = unserialize(ARR_SALUTION);
		$ARR_SALUTION_CHILD = unserialize(ARR_SALUTION_CHILD);
		$objFlight = new Travel_Model_FlightMaster();

		$tbl_customer = $objFlight->SearchFlightCustomer('tbl_customer', $param);
		$customerMemberArr = [];
		//echo '<pre>';print_r($tbl_customer);die;
		if ($tbl_customer) {
			foreach ($tbl_customer as $value) {
				$DOB = explode('-', $value['DOB']);
				$customerMember = $objFlight->GetFlightCustomerMember('tbl_customer_member', array('CustomerSysId' => $value['CustomerSysId']));
				if ($customerMember) {
					foreach ($customerMember as $key => $member) {
						$DOBm = explode('-', $member['DOB']);
						if ($member['paxType'] == 1) {
							$paxtype = 'Adult';
							$SalutationTxt = $ARR_SALUTION[$member['Salutation']];
						} elseif ($member['paxType'] == 2) {
							$paxtype = 'Child';
							$SalutationTxt = $ARR_SALUTION_CHILD[$member['Salutation']];
						} else {
							$paxtype = 'Infant';
							$SalutationTxt = $ARR_SALUTION_CHILD[$member['Salutation']];
						}
						if (!empty($member['PassportExpiry'])) {
							$PassportExpirym = ($member['PassportExpiry'] != '0000-00-00') ? date('d/m/Y', strtotime($member['PassportExpiry'])) : '';
						} else {
							$PassportExpirym = '';
						}
						if (!empty($member['passporIssue'])) {
							$passporIssuem = ($member['passporIssue'] != '0000-00-00') ? date('d/m/Y', strtotime($member['passporIssue'])) : '';
						} else {
							$passporIssuem = '';
						}
						if (!empty($member['DOB'])) {
							$DOBirth = ($member['DOB'] != '0000-00-00') ? date('d/m/Y', strtotime($member['DOB'])) : '';
						} else {
							$DOBirth = '';
						}

						$customerMemberArr[$member['CustomerMemberSysId']] = array(
							'label' => $member['EmailId'] . '(' . $member['FirstName'] . ' ' . $member['LastName'] . ')',
							'value' => $member['EmailId'],
							'index' => $key + 2,
							'CustomerMemberSysId' => $member['CustomerMemberSysId'],
							'CustomerSysId' => $member['CustomerSysId'],
							'Salutation' => $member['Salutation'],
							'SalutationTxt' => $SalutationTxt,
							'Relation' => $member['Relation'],
							'RelationTxt' => $ARR_CUSTOMER_RELATION[$member['Relation']],
							'Contacts' => $member['Contacts'],
							'FirstName' => $member['FirstName'],
							'LastName' => $member['LastName'],
							'Address' => $member['Address'],
							'CityTitle' => $member['CityTitle'],
							'CitySysId' => $member['CitySysId'],
							'CountrySysId' => $member['CountrySysId'],
							'countryCode' => $member['countryCode'],
							'PassportNo' => $member['PassportNo'],
							'PassportNation' => $member['PassportNation'],
							'paxType' => $member['paxType'],
							'DOB' => $DOBirth,
							'paxTypeName' => $paxtype,
							'companyname' => $value['companyname'],
							'gstnnumber' => $value['gstnnumber'],
							'gstaddress' => $value['gstaddress'],
							'gstemail' => $value['gstemail'],
							'gststate' => $value['gststate'],
							'gstphone' => $value['gstphone'],
							'PassportExpiry' => $PassportExpirym,
							'passporIssue' => $passporIssuem,
							'dobday' => $DOBm[2],
							'dobmonth' => $DOBm[1],
							'dobyear' => $DOBm[0],
						);
					}
				}
				if (!empty($value['PassportExpiry'])) {
					$PassportExpiry = ($value['PassportExpiry'] != '0000-00-00') ? date('d/m/Y', strtotime($value['PassportExpiry'])) : '';
				} else {
					$PassportExpiry = '';
				}
				if (!empty($value['passporIssue'])) {
					$passporIssue = ($value['passporIssue'] != '0000-00-00') ? date('d/m/Y', strtotime($value['passporIssue'])) : '';
				} else {
					$passporIssue = '';
				}
				if (!empty($value['DOB'])) {
					$DOBirth = ($value['DOB'] != '0000-00-00') ? date('d/m/Y', strtotime($value['DOB'])) : '';
				} else {
					$DOBirth = '';
				}
				//                $PassportExpiry = ($value['PassportExpiry'] != '0000-00-00')?date('d/m/Y',strtotime($value['PassportExpiry'])):'';
				if ($value['paxType'] == 1) {
					$paxtype = 'Adult';
					$SalutationTxt = $ARR_SALUTION[$value['Salutation']];
				} elseif ($value['paxType'] == 2) {
					$paxtype = 'Child';
					$SalutationTxt = $ARR_SALUTION_CHILD[$value['Salutation']];
				} else {
					$paxtype = 'Infant';
					$SalutationTxt = $ARR_SALUTION_CHILD[$value['Salutation']];
				}
				$response[$member['CustomerSysId']] = $leadPax = array(
					'label' => $value['EmailId'] . '(' . $value['FirstName'] . ' ' . $value['LastName'] . ')',
					'value' => $value['EmailId'],
					'CustomerSysId' => $value['CustomerSysId'],
					'CustomerMemberSysId' => $value['CustomerSysId'],
					'Salutation' => $value['Salutation'],
					'SalutationTxt' => $SalutationTxt,
					'Relation' => $value['Relation'],
					'RelationTxt' => $ARR_CUSTOMER_RELATION[$value['Relation']],
					'Contacts' => $value['Contacts'],
					'FirstName' => $value['FirstName'],
					'LastName' => $value['LastName'],
					'Address' => $value['Address'],
					'CityTitle' => $value['CityTitle'],
					'CitySysId' => $value['CitySysId'],
					'CountrySysId' => $value['CountrySysId'],
					'countryCode' => $value['countryCode'],
					'PassportNo' => $value['PassportNo'],
					'PassportNation' => $value['PassportNation'],
					'paxType' => $value['paxType'],
					'DOB' => $DOBirth,
					'paxTypeName' => $paxtype,
					'companyname' => $value['companyname'],
					'gstnnumber' => $value['gstnnumber'],
					'gstaddress' => $value['gstaddress'],
					'gstcity' => $value['gstcity'],
					'gststate' => $value['gststate'],
					'gstpincode' => $value['gstpincode'],
					'PassportExpiry' => $PassportExpiry,
					'passporIssue' => $passporIssue,
					'dobday' => $DOB[2],
					'dobmonth' => $DOB[1],
					'dobyear' => $DOB[0],
					//'customerMember' => $customerMemberArr
				);
			}
			$responseArray = [];
			$paxtypeArr = [];
			$array_merge = array_merge($response, $customerMemberArr);
			if ($array_merge) {
				foreach ($array_merge as $key => $val) {
					if ($key == 0) {
						$responseArray['_' . $val['CustomerSysId']] = $val;
					} else {
						$responseArray['_' . $val['CustomerMemberSysId']] = $val;
					}
					$paxtypeArr[$val['paxType']][] = $val;
				}
			}
			return $paxtypeArr;
		} else {
			$response = array();
			return $response;
		}
	}

	public function genrateFlightQuery($post, $Test = null)
	{
		//echo"<pre>";print_r($post);die;
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$class = $sessionFlightSearchParams->params['class'];
		$interNationalSearch = $sessionFlightSearchParams->params['interNationalSearch'];
		$route = $sessionFlightSearchParams->params['route'];
		$departureDates = $sessionFlightSearchParams->params['departure_date'];
		$returnDate = $sessionFlightSearchParams->params['return_date'];
		if (!empty($departureDates)) {
			$arrDepartureDates = explode("/", $departureDates);
			$departureDatesAD = $arrDepartureDates[2] . "-" . $arrDepartureDates[1] . "-" . $arrDepartureDates[0];
		}
		$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
		$FlightBookingDataInbound = new Zend_Session_Namespace('FlightBookingDataInbound');
		$apiTraceId = $FlightBookingData->params['apiTraceId'];

		$BookingData = $FlightBookingData->params;
		// if ($FlightBookingDataInbound->params) {
		//     $BookingData[] = $FlightBookingDataInbound->params;
		// }
		$ICSourceSysId = $BookingData[0]['ICSourceSysId'];
		$BookingDataTemp = [];
		if ($ICSourceSysId == 3 && $route == 3) {
			if ($BookingData) {
				foreach ($BookingData as $k => $value) {
					if ($value['arrSegmentsPro']) {
						foreach ($value['arrSegmentsPro'] as $psk => $val) {
							$BookingDataTemp[$psk] = $val;
							$BookingDataTemp[$psk]['FairRules'] = $value['FairRules'];
							//$BookingDataTemp[$psk]['Segments'] = $value['Segments'];
							$BookingDataTemp[$psk]['ApiResultIndex'] = $value['ApiResultIndex'];
							$BookingDataTemp[$psk]['apiTraceId'] = $value['apiTraceId'];
							$BookingDataTemp[$psk]['ICSourceSysId'] = $value['ICSourceSysId'];
							$BookingDataTemp[$psk]['IsInternational'] = $value['IsInternational'];
							$BookingDataTemp[$psk]['SearchFlightTraceId'] = $value['SearchFlightTraceId'];
							$BookingDataTemp[$psk]['JourneyType'] = $value['JourneyType'];
							$BookingDataTemp[$psk]['TripType'] = $value['TripType'];
							$BookingDataTemp[$psk]['IsNewMigration'] = $value['IsNewMigration'];
							$BookingDataTemp[$psk]['IsPassExpiry'] = $value['IsPassExpiry'];
							$BookingDataTemp[$psk]['IsPassIssue'] = $value['IsPassIssue'];
							$BookingDataTemp[$psk]['isGSTMandatory'] = $value['isGSTMandatory'];
							$BookingDataTemp[$psk]['isDobAdult'] = $value['isDobAdult'];
							$BookingDataTemp[$psk]['isDobChild'] = $value['isDobChild'];
							$BookingDataTemp[$psk]['isDobInfant'] = $value['isDobInfant'];
							$BookingDataTemp[$psk]['isSeatAppli'] = $value['isSeatAppli'];
						}
					}
					//echo"<pre>";print_r($value['arrSegmentsPro']);
				}
			}
			$BookingData = $BookingDataTemp;
		}
		$Segments_c = current($BookingData);
		$Segments_E = end($BookingData);
		$arrCurrentSegments1 = current($Segments_c['Segments']);
		$arrEndSegments1 = end($Segments_c['Segments']);
		//echo '<pre>';print_r($Segments);die;
		$Mobile = !empty($post['leadMobile']) ? $post['leadMobile'] : $post[0]['Contacts'];
		$emailId = !empty($post['leadEmail']) ? $post['leadEmail'] : $post[0]['EmailId'];

		$apiCustomer = $post['apiCustomer'];

		$adultCount = isset($sessionFlightSearchParams->params['adults']) ? $sessionFlightSearchParams->params['adults'] : 0;
		$childCount = isset($sessionFlightSearchParams->params['childs']) ? $sessionFlightSearchParams->params['childs'] : 0;
		$infantCount = isset($sessionFlightSearchParams->params['infants']) ? $sessionFlightSearchParams->params['infants'] : 0;

		$SourcePlaceSysId = isset($sessionFlightSearchParams->params['sourceCityId']) ? $sessionFlightSearchParams->params['sourceCityId'] : '';
		$DestinationPlacesSysId = isset($sessionFlightSearchParams->params['destinationCityId']) ? $sessionFlightSearchParams->params['destinationCityId'] : '';

		$OriginCity = isset($arrCurrentSegments1['originCityName']) ? $arrCurrentSegments1['originCityName'] : '';
		$Destcity = isset($arrEndSegments1['destinationCityName']) ? $arrEndSegments1['destinationCityName'] : '';
		$originAirCode = isset($sessionFlightSearchParams->params['sourceCityAirportCode']) ? $sessionFlightSearchParams->params['sourceCityAirportCode'] : '';
		$destinationAirCode = isset($sessionFlightSearchParams->params['destinationCityAirportCode']) ? $sessionFlightSearchParams->params['destinationCityAirportCode'] : '';

		$departuredate = str_replace('T', ' ', $arrCurrentSegments1['originDepTime']);
		$arrivaldate = str_replace('T', ' ', $arrEndSegments1['destinationArrTime']);
		$FlightNumber = $BookingData[0]['FlightNumber'];
		//$PublishedFare = $FlightBookingData->params['PublishedFare'];
		$oneway_origin_text = isset($arrCurrentSegments1['originCityName']) ? $arrCurrentSegments1['originCityName'] : '';
		$oneway_destination_text = isset($arrEndSegments1['destinationCityName']) ? $arrEndSegments1['destinationCityName'] : '';
		$originAirportCode = isset($arrEndSegments1['originAirportCode']) ? $arrEndSegments1['originAirportCode'] : '';
		$destinationAirportCode = isset($arrEndSegments1['destinationAirportCode']) ? $arrEndSegments1['destinationAirportCode'] : '';

		$Cities__ = [];
		if ($route == 3) {
			$departureDates = [];
			if ($originAirCode && $route == '3') {
				foreach ($originAirCode as $key => $value) {
					$string = isset($sourceCityText[$key]) ? $sourceCityText[$key] : '';
					$departureDates[] = isset($departure_dates[$key]) ? date('d/m/Y', strtotime($departure_dates[$key])) : '';
					$sourceCityText__ = substr($string, 0, strpos($string, ','));
					$string2 = isset($destinationCityText[$key]) ? $destinationCityText[$key] : '';
					$destinationCityText__ = substr($string2, 0, strpos($string2, ','));
					$Cities__[] = $sourceCityText__ . '-' . $destinationCityText__;
				}
			}
		}
		$PublishedFare = 0;
		$BaseAmount = 0;
		$AgentCommisionEarned = 0;
		$AgentCommisionEarnedGST = 0;
		$AgencyMarkUp = 0;
		$AgencyMarkUpGST = 0;
		$GTXMarkUp = 0;
		$GTXMarkUpGST = 0;
		$FareSummary = [];
		// $finalFareSummary = $this->getfinalFareSummary($FlightBookingData->params);
		// $AgentCommisionEarned = ($finalFareSummary['CommEarned'] + $finalFareSummary['PLBEarned'] + $finalFareSummary['IncentiveEarned']);
		// $AgentCommisionEarnedGST = ($finalFareSummary['GSTonComm'] + $finalFareSummary['GSTonPLB'] + $finalFareSummary['GSTonIncentive']);
		// $AgencyMarkUp = $finalFareSummary['intAgencyFixMarkUp'];
		// $AgencyMarkUpGST = $finalFareSummary['intSTaxOnAgencyFixMarkUp'];
		// $GTXMarkUp = $finalFareSummary['intGTXMarkUp'];
		// $BaseAmount = ($PublishedFare - ($AgentCommisionEarnedGST + $AgencyMarkUpGST + $AgentCommisionEarned + $AgencyMarkUp + $GTXMarkUp));
		$ICSourceSysId = $BookingData[0]['ICSourceSysId'];
		$BookingDataArray = [];
		//
		if ($BookingData) {
			foreach ($BookingData as $k => $booking) {
				$BookingDataArray[$k] = $booking;
				$BookingDataArray[$k]['ApiResultIndex'] = 'NA';
				$finalFareSummary = $booking['FairRules'];
				$PublishedFare += $booking['FairRules']['PublishedFare'];
				$PublishedFareINT = $booking['FairRules']['PublishedFare'];
				// $finalFareSummary = $this->getfinalFareSummary($booking);
				$AgentCommisionEarned += ($finalFareSummary['CommissionEarned']);
				$AgentCommisionEarnedINT = ($finalFareSummary['CommissionEarned']) * $this->CurrencyRate;
				$AgentCommisionEarnedGST += ($finalFareSummary['GSTonComm'] + isset($finalFareSummary['GSTonPLB']) ? $finalFareSummary['GSTonPLB'] : 0) * $this->CurrencyRate;
				$AgentCommisionEarnedGSTINT = ($finalFareSummary['GSTonComm'] + isset($finalFareSummary['GSTonPLB']) ? $finalFareSummary['GSTonPLB'] : 0) * $this->CurrencyRate;
				$AgencyMarkUp += $finalFareSummary['FixedMarkUp'];
				$AgencyMarkUpINT = $finalFareSummary['FixedMarkUp'] * $this->CurrencyRate;
				$AgencyMarkUpGST += $finalFareSummary['GSTOnMarkUp'];
				$AgencyMarkUpGSTINT = $finalFareSummary['GSTOnMarkUp'] * $this->CurrencyRate;
				$GTXMarkUp += $finalFareSummary['intGTXMarkUp'];
				$GTXMarkUpINT = $finalFareSummary['intGTXMarkUp'] * $this->CurrencyRate;
				$BaseAmount += ($PublishedFareINT - ($AgentCommisionEarnedGSTINT + $AgencyMarkUpGSTINT + $AgentCommisionEarnedINT + $AgencyMarkUpINT + $GTXMarkUpINT));
				$BaseAmountINT = ($PublishedFareINT - ($AgentCommisionEarnedGSTINT + $AgencyMarkUpGSTINT + $AgentCommisionEarnedINT + $AgencyMarkUpINT + $GTXMarkUpINT));
				$FareSummary[$k] = array(
					'PublishedFare' => ($PublishedFareINT),
					'AgentCommisionEarned' => ($AgentCommisionEarnedINT),
					'AgentCommisionEarnedGST' => ($AgentCommisionEarnedGSTINT),
					'AgencyMarkUp' => ($AgencyMarkUpINT),
					'AgencyMarkUpGST' => ($AgencyMarkUpGSTINT),
					'GTXMarkUp' => ($GTXMarkUpINT),
					'BaseAmount' => ($BaseAmountINT),
				);
			}
		}
		// echo '<pre>';print_r($FareSummary);die;
		$roomjson = array();
		$roomjson[1]['route'] = $route;
		$roomjson[1]['Adult'] = $adultCount;
		$roomjson[1]['Child'] = $childCount;
		$roomjson[1]['Infant'] = $infantCount;
		$roomjson[1]['bedtype'] = '';
		$roomjson[1]['departuredate'] = $departureDates;
		$roomjson[1]['returndate'] = $returnDate;
		$roomjson[1]['fromaircode'] = $originAirportCode;
		$roomjson[1]['toaircode'] = $destinationAirportCode;
		$roomjson[1]['airclass'] = $class;
		for ($c = 1; $c <= $childCount; $c++) {
			$childsage = $infantCount;
			$roomjson[$c]['route'] = $route;
			$roomjson[$c]['Adult'] = $adultCount;
			$roomjson[$c]['Child'] = $childCount;
			$roomjson[$c]['Infant'] = $infantCount;
			$roomjson[$c]['ChildAge_' . $c] = $childsage;
			$roomjson[$c]['bedtype'] = '';
			$roomjson[$c]['departuredate'] = $departureDates;
			$roomjson[$c]['returndate'] = $returnDate;
			$roomjson[$c]['fromaircode'] = $originAirportCode;
			$roomjson[$c]['toaircode'] = $destinationAirportCode;
			$roomjson[$c]['airclass'] = $class;
		}
		$RoomInfoJson = json_encode($roomjson);
		$totalPassengers = $adultCount + $childCount + $infantCount;
		$arrPax = [];
		$passengerAddress = isset($post['passenger-address-1']) ? $post['passenger-address-1'] : '';

		if ($Test == 1) {
			foreach ($post as $i => $travel) {
				$passengerAddress = isset($travel['Address']) ? $travel['Address'] : '';
				$paxType = $travel['paxType'];
				$firstName = $travel['FirstName'];
				$lastName = $travel['LastName'];
				$relation = $travel['Relation'];
				$salutation = $travel['Salutation'];
				$dateofbirth = $travel['DOB'];
				$arrPax[] = [
					"PassengerType" => $paxType,
					"salutation" => $salutation,
					"fname" => $firstName,
					"lname" => $lastName,
					"dob" => $dateofbirth,
					"address" => $passengerAddress,
				];
			}
		} else {
			$PrimaryCustomerId = $apiCustomer['Message'];

			for ($i = 1; $i <= $totalPassengers; $i++) {
				$paxType = $post['paxType-' . $i];
				$firstName = $post['passenger-firstname-' . $i];
				$lastName = $post['passenger-lastname-' . $i];
				$relation = $post['relation-' . $i];
				$salutation = $post['salution-' . $i];
				//$dateofbirth = $post['dateofbirth-' . $i];

				$dateofbirth = explode('/', $post['dateofbirth-' . $i]);
				if (isset($dateofbirth)) {
					$dobday = $dateofbirth[0];
					$dobmonth = $dateofbirth[1];
					$dobyear = $dateofbirth[2];
					$passengerDob = $dobyear . '-' . $dobmonth . '-' . $dobday;
				} else {
					$passengerDob = $dateofbirth[0];
				}
				if ($i == 1) {
					$memberId = $PrimaryCustomerId;
				} else {
					$memberId = isset($apiCustomer['memberId'][$i - 2]) ? $apiCustomer['memberId'][$i - 2] : 0;
				}

				$arrPax[] = [
					"memberId" => $memberId,
					"PassengerType" => $paxType,
					"salutation" => $salutation,
					"fname" => $firstName,
					"lname" => $lastName,
					"dob" => ($passengerDob == '-null-null' || $passengerDob == '--') ? '' : $passengerDob,
					"address" => $passengerAddress,
				];
			}
		}
		if ($ICSourceSysId == 3 || $ICSourceSysId == '3') {
			$BookingDataArray[0]['InternationalData']['Fare']['Currency'] = $this->CurrencyTitle;
		}

		// print_r($BookingData[0]['InternationalData']);
		// echo '<pre>';die;

		$jsonPaxDetails = json_encode($arrPax);
		$jsonBookingData = json_encode($BookingDataArray);


		$postFields = array(
			"AgencySysId" => $this->gtxagencysysid,
			"AgentSysId" => $this->gtxagentsysid,
			"Email" => $emailId,
			"mobile" => $Mobile,
			"jsonPaxDetails" => $jsonPaxDetails,
			"jsonBookingData" => $jsonBookingData,
			"FareSummary" => json_encode($FareSummary),
			"interNationalSearch" => $interNationalSearch,
			"route" => $route,
			"SourcePlaceSysId" => $SourcePlaceSysId,
			"DestinationPlacesSysId" => $DestinationPlacesSysId,
			"SourcePlaces" => $OriginCity,
			"DestinationPlaces" => $Destcity,
			"SourceAirportCode" => $originAirCode,
			"DestAirportCode" => $destinationAirCode,
			"FlightNumber" => $FlightNumber,
			"departuredate" => $departuredate,
			"arrivaldate" => $arrivaldate,

			"AdultPax" => $adultCount,
			"ChildPax" => $childCount,
			"InfantPax" => $infantCount,

			"Cities" => ($route == "3") ? implode(',', $Cities__) : $OriginCity . '-' . $Destcity,
			"IsHotelFromApi" => 1,
			"ICSourceSysId" => $ICSourceSysId,
			"leadsource" => 'Website',
			"roominfojson" => $RoomInfoJson,

			"AgentCommisionEarned" => $AgentCommisionEarned,
			"AgentCommisionEarnedGST" => $AgentCommisionEarnedGST,
			"AgencyMarkUp" => $AgencyMarkUp,
			"AgencyMarkUpGST" => $AgencyMarkUpGST,
			"GTXMarkUp" => $GTXMarkUp,
			"GTXMarkUpGST" => $GTXMarkUpGST,
			"BaseAmount" => $BaseAmount,
			"PublishedFare" => $PublishedFare,
			"sessionFlightSearchParams" => json_encode($sessionFlightSearchParams->params),
		);
		$strFilePath = "flight/SearchParam/" . $post['traceId'] . '/FlightQuery-' . date('Y-m-d-H-i-s') . "request.json";
		Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($postFields));
		$model = new Gtxwebservices_Model_Webservices();
		$result = $model->genrateFlightQuery($postFields);
		$response = json_decode($result, true);
		// if ($this->gtxagencysysid == '2656') {
		// 	echo '<pre>';
		// 	print_r($response);die;
		// }
		// echo '<pre>';print_r($postFields);
		// echo '<pre>';print_r($result);
		// die;
		Zend_Session::namespaceUnset('ResponseFlightQuery');
		$ResponseFlightQuery = new Zend_Session_Namespace('ResponseFlightQuery');
		$ResponseFlightQuery->params = $response;

		return $response;
	}
	public function IsValidDate($date)
	{
		if (preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $date)) {
			return true;
		} else {
			return false;
		}
	}
	public function SetSegmentsPro($BookingData, $route)
	{
		$route = (int) $route;
		$BookingDataTemp = [];
		if ($BookingData) {
			foreach ($BookingData as $k => $value) {
				
				if ($value['SegPro']) {
					$route = (int) count($value['SegPro']);
					foreach ($value['SegPro'] as $psk => $val) {
						$BookingDataTemp[$psk] = $val;
						$FareBreakdown = [];
						$value['FairRules'] = $value['NewPrice'];
						if ($value['FairRules']['FareBreakdown']) {
							foreach ($value['FairRules']['FareBreakdown'] as $brk => $Break) {
								$FareBreakdown[$brk] = $Break;
								$FareBreakdown[$brk]['APIBaseFare'] = round($Break['APIBaseFare'] / $route);
								$FareBreakdown[$brk]['BaseFare'] = round($Break['BaseFare'] / $route);
								$FareBreakdown[$brk]['Tax'] = round($Break['Tax'] / $route);
								$FareBreakdown[$brk]['YQTax'] = round($Break['YQTax'] / $route);
								$FareBreakdown[$brk]['OtherCharges'] = round($Break['OtherCharges'] / $route);
								$FareBreakdown[$brk]['PGCharge'] = round($Break['PGCharge'] / $route);
								$FareBreakdown[$brk]['AdditionalTxnFeePub'] = round($Break['AdditionalTxnFeePub'] / $route);
								$FareBreakdown[$brk]['AdditionalTxnFeeOfrd'] = round($Break['AdditionalTxnFeeOfrd'] / $route);
								$FareBreakdown[$brk]['AgencyMarkUp'] = round($Break['AgencyMarkUp'] / $route);
								$FareBreakdown[$brk]['GTXMarkUp'] = round($Break['GTXMarkUp'] / $route);
								$FareBreakdown[$brk]['FareOfferedToPax'] = round($Break['FareOfferedToPax'] / $route);
								$FareBreakdown[$brk]['FixedMarkUp'] = round($Break['FixedMarkUp'] / $route);
								$FareBreakdown[$brk]['GSTOnMarkUp'] = round($Break['GSTOnMarkUp'] / $route);
								$FareBreakdown[$brk]['intTotalGST'] = round($Break['intTotalGST'] / $route);
								$FareBreakdown[$brk]['ServiceFee'] = round($Break['ServiceFee'] / $route);
								$FareBreakdown[$brk]['CommisionPass'] = round($Break['CommisionPass'] / $route);
								$FareBreakdown[$brk]['intGTXMarkUp'] = round($Break['intGTXMarkUp'] / $route);
								$FareBreakdown[$brk]['GTXMarkUpGST'] = round($Break['GTXMarkUpGST'] / $route);
								$FareBreakdown[$brk]['CommissionEarned'] = round($Break['CommissionEarned'] / $route);
								$FareBreakdown[$brk]['IntCommission'] = round($Break['IntCommission'] / $route);
								$FareBreakdown[$brk]['TDS'] = round($Break['TDS'] / $route);
								$FareBreakdown[$brk]['MF'] = round($Break['MF'] / $route);
								$FareBreakdown[$brk]['YQ'] = round($Break['YQ'] / $route);
								$FareBreakdown[$brk]['AGST'] = round($Break['AGST'] / $route);
								$FareBreakdown[$brk]['MFT'] = round($Break['MFT'] / $route);
								$FareBreakdown[$brk]['OT'] = round($Break['OT'] / $route);
								$FareBreakdown[$brk]['MU'] = round($Break['MU'] / $route);
								$FareBreakdown[$brk]['YR'] = round($Break['YR'] / $route);
								$FareBreakdown[$brk]['intCommisionEarnedForAgency'] = round($Break['intCommisionEarnedForAgency'] / $route);
								$FareBreakdown[$brk]['intPLBEarnedForAgency'] = round($Break['intPLBEarnedForAgency'] / $route);
								$FareBreakdown[$brk]['intIncentiveEarnedForAgency'] = round($Break['intIncentiveEarnedForAgency'] / $route);
							}
						}
						$FairRules = [];
						$FairRules = $value['FairRules'];
						$FairRules['BaseFare'] = round($value['FairRules']['BaseFare'] / $route);
						$FairRules['Tax'] = round($value['FairRules']['Tax'] / $route);
						$FairRules['YQTax'] = round($value['FairRules']['YQTax'] / $route);
						$FairRules['AdditionalTxnFeeOfrd'] = round($value['FairRules']['AdditionalTxnFeeOfrd'] / $route);
						$FairRules['AdditionalTxnFeePub'] = round($value['FairRules']['AdditionalTxnFeePub'] / $route);
						$FairRules['OtherCharges'] = round($value['FairRules']['OtherCharges'] / $route);
						$FairRules['Discount'] = round($value['FairRules']['Discount'] / $route);
						$FairRules['ServiceFee'] = round($value['FairRules']['ServiceFee'] / $route);
						$FairRules['PublishedFare'] = round($value['FairRules']['PublishedFare'] / $route);
						$FairRules['CommissionEarned'] = round($value['FairRules']['CommissionEarned'] / $route);
						$FairRules['PLBEarned'] = round($value['FairRules']['PLBEarned'] / $route);
						$FairRules['IncentiveEarned'] = round($value['FairRules']['IncentiveEarned'] / $route);
						$FairRules['OfferedFare'] = round($value['FairRules']['OfferedFare'] / $route);
						$FairRules['TdsOnCommission'] = round($value['FairRules']['TdsOnCommission'] / $route);
						$FairRules['TdsOnPLB'] = round($value['FairRules']['TdsOnPLB'] / $route);
						$FairRules['TdsOnIncentive'] = round($value['FairRules']['TdsOnIncentive'] / $route);
						$FairRules['CommEarned'] = round($value['FairRules']['CommEarned'] / $route);
						$FairRules['CommisionPass'] = round($value['FairRules']['CommisionPass'] / $route);
						$FairRules['FixedMarkUp'] = round($value['FairRules']['FixedMarkUp'] / $route);
						$FairRules['GSTOnMarkUp'] = round($value['FairRules']['GSTOnMarkUp'] / $route);
						$FairRules['FareBreakdown'] = $FareBreakdown;

						
						$BookingDataTemp[$psk]['FairRules'] = $FairRules;
						$BookingDataTemp[$psk]['NewPrice'] = $FairRules;
						if ($value['Segments']) {
							foreach ($value['Segments'] as $segkey => $valSeg) {
								if($valSeg['isReturnSegment'] == $psk){
									$BookingDataTemp[$psk]['Segments'][] = $valSeg;
								}
							}
						}
						
						$BookingDataTemp[$psk]['ApiResultIndex'] = $value['ApiResultIndex'];
						$BookingDataTemp[$psk]['apiTraceId'] = $value['apiTraceId'];
						$BookingDataTemp[$psk]['ICSourceSysId'] = $value['ICSourceSysId'];
						$BookingDataTemp[$psk]['IsInternational'] = $value['IsInternational'];
						$BookingDataTemp[$psk]['SearchFlightTraceId'] = $value['SearchFlightTraceId'];
						$BookingDataTemp[$psk]['JourneyType'] = $value['JourneyType'];
						$BookingDataTemp[$psk]['TripType'] = $value['TripType'];
						$BookingDataTemp[$psk]['IsNewMigration'] = $value['IsNewMigration'];
						$BookingDataTemp[$psk]['IsPassExpiry'] = $value['IsPassExpiry'];
						$BookingDataTemp[$psk]['IsPassIssue'] = $value['IsPassIssue'];
						$BookingDataTemp[$psk]['isGSTMandatory'] = $value['isGSTMandatory'];
						$BookingDataTemp[$psk]['isDobAdult'] = $value['isDobAdult'];
						$BookingDataTemp[$psk]['isDobChild'] = $value['isDobChild'];
						$BookingDataTemp[$psk]['isDobInfant'] = $value['isDobInfant'];
						$BookingDataTemp[$psk]['isSeatAppli'] = $value['isSeatAppli'];
					}
				}
			}
		}
		return $BookingDataTemp;
	}

	public function savePassengerDetailsAction()
	{
		if ($this->getRequest()->isPost()) {
			// ini_set('display_errors', 1);
			// ini_set('display_startup_errors', 1);
			// error_reporting(E_ALL);
			$this->_helper->layout->disableLayout();
			$this->_helper->viewRenderer->setNoRender(true);
			$post = $this->getRequest()->getPost();
			$objFlight = new Travel_Model_FlightMaster();
			$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
			$class = $sessionFlightSearchParams->params['class'];
			$FareTypes__ = isset($sessionFlightSearchParams->params['FareTypes']) ? $sessionFlightSearchParams->params['FareTypes'] :'';
			$interNationalSearch = $sessionFlightSearchParams->params['interNationalSearch'];
			$route = $sessionFlightSearchParams->params['route'];
			$departureDates = $sessionFlightSearchParams->params['departure_date'];
			if ($route == 3) {
				$departureDates = $sessionFlightSearchParams->params['departure_date'][0];
			} else {
				$departureDates = $sessionFlightSearchParams->params['departure_date'];
			}
			$departure_dates = $sessionFlightSearchParams->params['departure_dates'];
			$strDepatureDate = $sessionFlightSearchParams->params['strDepatureDate'];
			$strReturnDate = $sessionFlightSearchParams->params['strReturnDate'];
			$returnDate = $sessionFlightSearchParams->params['return_date'];
			$originAirCode = isset($sessionFlightSearchParams->params['sourceCityAirportCode']) ? $sessionFlightSearchParams->params['sourceCityAirportCode'] : '';			
			$traceId = $post['traceId'];
			$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
			$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $traceId], ['id' => 'ASC']);
			$arrUrlData = json_decode($temp_data['json_data'], true);
			$FlightBookingData->params = isset($arrUrlData['BookingData']) ? $arrUrlData['BookingData'] : [];
			$tripSeatMap = isset($arrUrlData['tripSeatMap']) ? $arrUrlData['tripSeatMap'] :[];
			$FARERULE = isset($arrUrlData['FARERULE']) ? $arrUrlData['FARERULE'] :[];
			if (!empty($departureDates)) {
				$arrDepartureDates = explode("/", $departureDates);
				$departureDatesAD = $arrDepartureDates[2] . "-" . $arrDepartureDates[1] . "-" . $arrDepartureDates[0];
			}
			if ($route == 3) {
				$departureDates = [];
				if ($originAirCode && $route == '3') {
					foreach ($originAirCode as $key => $value) {
						$departureDates[] = isset($departure_dates[$key]) ? date('d/m/Y', strtotime($departure_dates[$key])) : '';
					}
				}
			}
			// echo "flight_booking_customer<pre>";print_r($arrUrlData);die('sss');
			$FlightBookingDataInbound = new Zend_Session_Namespace('FlightBookingDataInbound');
			$FlightBookingDataRoundInter = new Zend_Session_Namespace('FlightBookingDataRoundInter');
			$apiTraceId = isset($FlightBookingData->params['apiTraceId']) ? $FlightBookingData->params['apiTraceId']:'';
			$isDobAdult = isset($FlightBookingData->params[0]['isDobAdult']) ? $FlightBookingData->params[0]['isDobAdult'] :'';
			$isDobChild = isset($FlightBookingData->params[0]['isDobChild']) ? $FlightBookingData->params[0]['isDobChild'] :'';
			$isDobInfant = isset($FlightBookingData->params[0]['isDobInfant']) ? $FlightBookingData->params[0]['isDobInfant']:'';
			$isDocIdAllowedMandatory = isset($FlightBookingData->params[0]['isDocIdAllowedMandatory']) ? $FlightBookingData->params[0]['isDocIdAllowedMandatory'] : false;
			$ICSourceSysId = isset($FlightBookingData->params[0]['ICSourceSysId']) ? $FlightBookingData->params[0]['ICSourceSysId'] :'';

			$BookingData = isset($FlightBookingData->params) ? $FlightBookingData->params:[];
			$arrPlanAir = [];
			$flight_booking_id_Arr = [];
			$CustomerMembersSessionArr = [];
			$ICSourceSysId = isset($BookingData[0]['ICSourceSysId']) ? $BookingData[0]['ICSourceSysId'] :'';
			$adultCount = isset($sessionFlightSearchParams->params['adults']) ? $sessionFlightSearchParams->params['adults'] : 0;
			$childCount = isset($sessionFlightSearchParams->params['childs']) ? $sessionFlightSearchParams->params['childs'] : 0;
			$infantCount = isset($sessionFlightSearchParams->params['infants']) ? $sessionFlightSearchParams->params['infants'] : 0;
			$sourceCityId = !empty($sessionFlightSearchParams->params['sourceCityId']) ? $sessionFlightSearchParams->params['sourceCityId'] : '';
			$destinationCityId = !empty($sessionFlightSearchParams->params['destinationCityId']) ? $sessionFlightSearchParams->params['destinationCityId'] : '';
			
			$totalPassengers = $adultCount + $childCount + $infantCount;

			$BookingDataTemp = [];
			// if ($ICSourceSysId == 3 && $route == 3) {
			// 	$route = (int) $route;
			// 	$BookingDataTemp = $this->SetSegmentsPro($BookingData, $route);
			// 	$BookingData = $BookingDataTemp;
			// }
			
			if ($this->getTemplateId == 7) {
				if (count($post['CustomerSysId']) == $totalPassengers) {
					foreach ($post['CustomerSysId'] as $key => $val) {
						$post['CustomerSysId-' . ($key + 1)] = $val;
						$post['passenger-firstname-' . ($key + 1)] = $post['passenger-firstname'][$key];
						$post['passenger-lastname-' . ($key + 1)] = $post['passenger-lastname'][$key];
						$post['relation-' . ($key + 1)] = $post['relation'][$key];
						$post['passportno-' . ($key + 1)] = $post['passportno'][$key];
						$post['passportnoexpiry-' . ($key + 1)] = $post['passportnoexpiry'][$key];
						$post['passporIssue-' . ($key + 1)] = $post['passporIssue'][$key];
						$post['PassportNationality-' . ($key + 1)] = $post['PassportNationality'][$key];
						$post['dateofbirth-' . ($key + 1)] = $post['dateofbirth'][$key];
						$post['salution-' . ($key + 1)] = $post['salution'][$key];
						$post['paxType-' . ($key + 1)] = $post['paxType'][$key];
						$post['passenger-city-' . ($key + 1)] = $post['passenger-city'][$key];
						$post['passenger-country-' . ($key + 1)] = $post['passenger-country'][$key];
						$post['passenger-city-name-' . ($key + 1)] = $post['passenger-city-name'][$key];
						$post['passenger-address-' . ($key + 1)] = $post['passenger-address'][$key];
						$post['docId-' . ($key + 1)] = $post['docId'][$key];
					}
				} else {
					$response = array('success' => false, 'msg' => 'Please select ' . $adultCount . ' Adult, ' . $childCount . ' Child and ' . $infantCount . ' Infant.');
					echo json_encode($response);
					exit;
				}
			}


			$this->ValidateSavePassenger($post, $BookingData);
			// if ($this->gtxagencysysid == '16486') {
			
			// }
			try {
				$this->objMdl->rv_delete('tbl_customer', array('apiTraceId = ?' => $post['traceId']));
				$this->objMdl->rv_delete('tbl_customer_member', array('apiTraceId = ?' => $post['traceId']));
				if (!empty($this->_session->session)) {
					$param = array(
						'leadMobile' => $this->_session->session['ContactNo1'],
						'leadEmail' => $this->_session->session['EmailId'],
					);
				} else {
					$param = array(
						'leadMobile' => isset($post['leadMobile']) ? $post['leadMobile'] :'',
						'leadEmail' => isset($post['leadEmail']) ? $post['leadEmail'] :'',
					);
				}

				$tbl_customer = $objFlight->SearchFlightCustomer('tbl_customer', $param);
				$getAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->gtxagencysysid);
				$this->siteName = (isset($getAgencyData['DisplayName']) && !empty($getAgencyData['DisplayName']))?$getAgencyData['DisplayName']: $this->siteName;
				$adultCount = isset($sessionFlightSearchParams->params['adults']) ? $sessionFlightSearchParams->params['adults'] : 0;
				$childCount = isset($sessionFlightSearchParams->params['childs']) ? $sessionFlightSearchParams->params['childs'] : 0;
				$infantCount = isset($sessionFlightSearchParams->params['infants']) ? $sessionFlightSearchParams->params['infants'] : 0;
				$oneway_origin_text = isset($sessionFlightSearchParams->params['sourceCityAirportCode']) ? $sessionFlightSearchParams->params['sourceCityAirportCode'] : '';
				$oneway_destination_text = isset($sessionFlightSearchParams->params['destinationCityAirportCode']) ? $sessionFlightSearchParams->params['destinationCityAirportCode'] : '';
				$originAirportCode = isset($sessionFlightSearchParams->params['originAirportCode']) ? $sessionFlightSearchParams->params['originAirportCode'] : '';
				$destinationAirportCode = isset($sessionFlightSearchParams->params['destinationAirportCode']) ? $sessionFlightSearchParams->params['destinationAirportCode'] : '';

				$getCity = isset($getAgencyData['CityName']) ? $getAgencyData['CityName'] : 'Delhi';
				$Address = isset($getAgencyData['Address']) ? $getAgencyData['Address'] : 'Delhi';
				$CitySysId = isset($getAgencyData['CitySysId']) ? $getAgencyData['CitySysId'] : '7701';
				$CountrySysId = isset($getAgencyData['CountrySysId']) ? $getAgencyData['CountrySysId'] : '101';

				$leadMobile = isset($post['leadMobile']) ? $post['leadMobile'] : '';
				$leadEmail = isset($post['leadEmail']) ? $post['leadEmail'] : '';
				$countryCode = isset($post['countryCode']) ? $post['countryCode'] : '';
				$companyname = isset($post['companyname']) ? $post['companyname'] : '';
				$gstnnumber = isset($post['gstnnumber']) ? $post['gstnnumber'] : '';
				$gstaddress = isset($post['gstaddress']) ? $post['gstaddress'] : '';
				$gstemail = isset($post['gstemail']) ? $post['gstemail'] : '';
				$gststate = isset($post['gststate']) ? $post['gststate'] : '';
				$gstphone = isset($post['gstphone']) ? $post['gstphone'] : '';
				$gstcity = isset($post['gstcity']) ? $post['gstcity'] : '';
				$gststate = isset($post['gststate']) ? $post['gststate'] : '';
				$gstpincode = isset($post['gstpincode']) ? $post['gstpincode'] : '';
				$CityTitle = isset($post['passenger-city-name-1']) && !empty($post['passenger-city-name-1']) ? $post['passenger-city-name-1'] : $getCity;
				$passengerCity = (isset($post['passenger-city-1']) && !empty($post['passenger-city-1'])) ? $post['passenger-city-1'] : $CitySysId;
				$CountrySysId = (isset($post['passenger-country-1']) && !empty($post['passenger-country-1'])) ? $post['passenger-country-1'] : $CountrySysId;
				$passengerAddress = (isset($post['passenger-address-1']) && !empty($post['passenger-address-1'])) ? $post['passenger-address-1'] : $Address;
				$accepttandc = isset($post['accepttandc']) ? $post['accepttandc'] : 0;
				$isgstapply = isset($post['isgstapply']) ? $post['isgstapply'] : 0;
				$countryCodeISO = isset($post['countryCodeISO']) ? $post['countryCodeISO'] : 0;
				$passengercountryName = isset($post['passenger-countryName-1']) ? $post['passenger-countryName-1'] : '';

				//echo"<pre>";print_r($post);die;
				$roomjson = array();
				$roomjson[1]['Adult'] = isset($adultCount) ? $adultCount:1;
				$roomjson[1]['Child'] = isset($childCount) ? $childCount:'';
				$roomjson[1]['bedtype'] = '';
				$roomjson[1]['departuredate'] =  isset($departureDates) ? $departureDates :'';
				$roomjson[1]['returndate'] =  isset($returnDate) ? $returnDate :'';
				$roomjson[1]['fromaircode'] = isset($originAirportCode) ? $originAirportCode :'';
				$roomjson[1]['toaircode'] = isset($destinationAirportCode) ? $destinationAirportCode :'';
				$roomjson[1]['airclass'] =  isset($class) ? $class :'';
				for ($c = 1; $c <= $childCount; $c++) {
					$childsage = $infantCount;
					$roomjson[$c]['Adult'] = isset($adultCount) ? $adultCount:1;
					$roomjson[$c]['Child'] = isset($childCount) ? $childCount :'';
					$roomjson[$c]['ChildAge_' . $c] = isset($childsage) ? $childsage :'';
					$roomjson[$c]['bedtype'] = '';
					$roomjson[$c]['departuredate'] = isset($departureDates) ? $departureDates :'';
					$roomjson[$c]['returndate'] = isset($returnDate) ? $returnDate :'';
					$roomjson[$c]['fromaircode'] = isset($originAirportCode) ? $originAirportCode :'';
					$roomjson[$c]['toaircode'] = isset($destinationAirportCode) ? $destinationAirportCode :'';
					$roomjson[$c]['airclass'] = isset($class) ? $class :'';
				}
				$RoomInfoJson = json_encode($roomjson);
				$totalPassengers = $adultCount + $childCount + $infantCount;
				$arrCustomer = array();
				$apiDataMember = array();
				$ForCustomerSession = array();
				$ForMemberSession = array();
				$arrCustomerMembers = array();
				$arrmembersId = array();

				$apiData = array(
					"AgencySysId" => $this->gtxagencysysid,
					"Salutation" => $post['salution-1'],
					"EmailId" => $leadEmail,
					"FirstName" => $post['passenger-firstname-1'],
					"LastName" => $post['passenger-lastname-1'],
					"CountryCode" => $countryCode,
					"MobileNo" => $leadMobile,
					"Relation" => 9,
					"B2B" => false,
				);

				$key = 0;
				if ($totalPassengers > 0) {
					for ($i = 1; $i <= $totalPassengers; $i++) {

						$paxType = $post['paxType-' . $i];
						$firstName = $post['passenger-firstname-' . $i];
						$lastName = $post['passenger-lastname-' . $i];
						$docId = $post['docId-' . $i];
						$relation = $post['relation-' . $i] ? $post['relation-' . $i] : 0;
						$salutation = $post['salution-' . $i];
						$FFAirlineCode       = isset($post['addFFAirlineCode-' . $i]) ? $post['addFFAirlineCode-' . $i] : '';
						$FFNumber       = isset($post['FFNumber-' . $i]) ? $post['FFNumber-' . $i] : '';
						$isAprove = isset($post['masterData-' . $i]) ?  $post['masterData-' . $i] : 0;

						if ($this->stylecss == 'bookoair') {
							$dyas = isset($post['dyas-' . $i]) ?  $post['dyas-' . $i] : '00';
							$months = isset($post['months-' . $i]) ?  $post['months-' . $i] : '00';
							$years = isset($post['years-' . $i]) ?  $post['years-' . $i] : '0000';

							$post['dateofbirth-' . $i] = $dyas . '/' . $months . '/' . $years;
						}
						// echo '<pre>';
						// print_r($post);
						// die;
						// echo $isAprove;die;

						$add_travellerslist = 1; //isset($post['add_travellerslist-' . $i]) ? $post['add_travellerslist-' . $i] : 0;
						//$getSalutation = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getSalutationByid($salutation);
						$CustomerSysIdPost = $post['CustomerSysId-' . $i];
						$IsExistcustomer = '';
						if (!empty($CustomerSysIdPost) && $CustomerSysIdPost != '0') {
							$IsExistcustomer = $objFlight->CheckCustomer('tbl_customer', array('CustomerSysId' => $CustomerSysIdPost));
							//$IsExistMember = $objFlight->CheckMember('tbl_customer_member', array('CustomerMemberSysId' => $CustomerSysIdPost));
						}

						$passengerPassportNo = isset($post['passportno-' . $i]) ? $post['passportno-' . $i] : '';
						$passengerPassportExpiry = isset($post['passportnoexpiry-' . $i]) ? $post['passportnoexpiry-' . $i] : '00/00/0000';
						$passporIssue        = isset($post['passporIssue-' . $i]) ? $post['passporIssue-' . $i] : '00/00/0000';
						$passporNation        = isset($post['PassportNationality-' . $i]) ? $post['PassportNationality-' . $i] : '';

						if (!empty($passengerPassportExpiry)) {
							$passengerPassportExpiry = explode("/", $passengerPassportExpiry);
							if (isset($passengerPassportExpiry[2])) {
								$passengerPassportExpiry = $passengerPassportExpiry[2] . "-" . $passengerPassportExpiry[1] . "-" . $passengerPassportExpiry[0];
							} else {
								$passengerPassportExpiry = $passengerPassportExpiry[0];
							}
						}
						if (!empty($passporIssue)) {
							$passporIssue       = explode("/", $passporIssue);
							if (isset($passporIssue[2])) {
								$passporIssue  = $passporIssue[2] . "-" . $passporIssue[1] . "-" . $passporIssue[0];
							} else {
								$passporIssue = $passporIssue[0];
							}
						}

						if (empty(trim($firstName))) {
							$response = array('succes' => false, 'msg' => 'Please fill out all first name.', 'index' => 'passenger-firstname-' . $i);
							echo json_encode($response);
							exit;
						}
						

						if (empty($salutation)) {
							$response = array('succes' => false, 'msg' => 'Please Select Title', 'index' => 'salution-' . $i);
							echo json_encode($response);
							exit;
						}
						if (empty(trim($lastName))) {
							$response = array('succes' => false, 'msg' => 'Please fill out all last name.', 'index' => 'passenger-lastname-' . $i);
							echo json_encode($response);
							exit;
						}
						
						if($ICSourceSysId != 8){
							if (strlen(trim($firstName)) < 2) {
								$response = array('succes' => false, 'msg' => '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('succes' => false, 'msg' => 'Length of last name should be between 2 to 32 alphabets for passenger.', 'index' => 'passenger-firstname-' . $i);
								echo json_encode($response);
								exit;
							}

						}
						
						if ($paxType == 1) {
							if ($isDobAdult) {
								$dateofbirth = (isset($post['dateofbirth-' . $i]) && !empty($post['dateofbirth-' . $i])) ? explode('/', $post['dateofbirth-' . $i]):'';
								if (isset($dateofbirth) && !empty($dateofbirth)) {
									$dobday = $dateofbirth[0];
									$dobmonth = $dateofbirth[1];
									$dobyear = $dateofbirth[2];
									$passengerDob = $dobyear . '-' . $dobmonth . '-' . $dobday;
								} else {
									$passengerDob = $dateofbirth[0];
								}
								if (!$this->IsValidDate($passengerDob)) {
									$response = array('succes' => false, 'msg' => 'Please fill out all adult date of birth.', 'index' => 'dateofbirth-' . $i);
									echo json_encode($response);
									exit;
								}
							}
						}
						//
						if ($paxType == 2) {
							if ($isDobChild) {
								$dateofbirth = (isset($post['dateofbirth-' . $i]) && !empty($post['dateofbirth-' . $i])) ? explode('/', $post['dateofbirth-' . $i]):'';
								if (isset($dateofbirth) && !empty($dateofbirth)) {
									$dobday = $dateofbirth[0];
									$dobmonth = $dateofbirth[1];
									$dobyear = $dateofbirth[2];
									$passengerDob = $dobyear . '-' . $dobmonth . '-' . $dobday;
								} else {
									$passengerDob = $dateofbirth[0];
								}
								if (!$this->IsValidDate($passengerDob)) {
									$response = array('succes' => false, 'msg' => 'Please fill out all child date of birth.', 'index' => 'dateofbirth-' . $i);
									echo json_encode($response);
									exit;
								}
							}
						}
						if ($paxType == 3) {
							if ($isDobInfant) {
								$dateofbirth = (isset($post['dateofbirth-' . $i]) && !empty($post['dateofbirth-' . $i])) ? explode('/', $post['dateofbirth-' . $i]) :'';
								if (isset($dateofbirth) && !empty($dateofbirth)) {
									$dobday = $dateofbirth[0];
									$dobmonth = $dateofbirth[1];
									$dobyear = $dateofbirth[2];
									$passengerDob = $dobyear . '-' . $dobmonth . '-' . $dobday;
								} else {
									$passengerDob = $dateofbirth[0];
								}
								if (!$this->IsValidDate($passengerDob)) {
									$response = array('succes' => false, 'msg' => 'Please fill out all infant date of birth.', 'index' => 'dateofbirth-' . $i);
									echo json_encode($response);
									exit;
								}
							}
						}
						// echo"<pre>";print_r($post['dateofbirth-' . $i]);
						// echo"<pre>";print_r($post);
						// die('test');

						// if (isset($dobday) && empty($dobday)) {
						// 	$response = array('succes' => false, 'msg' => 'Please fill out all date of birth.', 'index' => 'dobday' . $i);
						// 	echo json_encode($response);
						// 	exit;
						// }

						// if (isset($dobmonth) && empty($dobmonth)) {
						// 	$response = array('succes' => false, 'msg' => 'Please fill out all date of birth.', 'index' => 'dobmonth' . $i);
						// 	echo json_encode($response);
						// 	exit;
						// }
						// if (isset($dobyear) && empty($dobyear)) {
						// 	$response = array('succes' => false, 'msg' => 'Please fill out all date of birth.', 'index' => 'dobyear' . $i);
						// 	echo json_encode($response);
						// 	exit;
						// }
						if ($isDobAdult && isset($passengerDob)) {
							if (!empty($paxType) && $paxType == 1) {
								$AdultAge = date_diff(date_create($passengerDob), date_create($departureDatesAD))->y;
								if ($AdultAge < 12) {
									$response = array('succes' => false, 'msg' => "Adult age should be greater than 12 years. ", 'index' => 'dobyear' . $i);
									echo json_encode($response);
									exit;
								}
							}
						}
						if ($isDobChild && isset($passengerDob)) {
							if (!empty($paxType) && $paxType == 2) {
								$childAge = date_diff(date_create($passengerDob), date_create($departureDatesAD))->y;
								if ($childAge < 2 || $childAge >= 12) {
									$response = array('succes' => false, 'msg' => "Child age should be 2 years or less than 12 years. ", 'index' => 'dobyear' . $i);
									echo json_encode($response);
									exit;
								}
							}
						}
						if ($isDobInfant && isset($passengerDob)) {
							if (!empty($paxType) && $paxType == 3) {
								$infantAge = date_diff(date_create($passengerDob), date_create($departureDatesAD))->y;
								if ($infantAge >= 2) {
									$response = array('succes' => false, 'msg' => "Infant age should be less than 2 years. ", 'index' => 'dobyear' . $i);
									echo json_encode($response);
									exit;
								}
							}
						}
						if($isDocIdAllowedMandatory){
							if(empty($docId)){
								$response = array('succes' => false, 'msg' => 'Please fill out all document details.', 'index' => 'docId-' . $i);
								echo json_encode($response);
								exit;
							}
							
						}
						if($FareTypes__ == "SENIOR_CITIZEN"){
							if (isset($passengerDob)) {
								if (!empty($paxType) && $paxType == 1) {
									$AdultAge = date_diff(date_create($passengerDob), date_create($departureDatesAD))->y;
									if ($AdultAge < 60) {
										$response = array('succes' => false, 'msg' => "Adult age should be greater than 60 years. ", 'index' => 'dobyear' . $i);
										echo json_encode($response);
										exit;
									}
								}
							}
						}
						if (empty(trim($passengerCity)) && ($ICSourceSysId == 3 || $ICSourceSysId == 17)) {
							$response = array('succes' => false, 'msg' => 'Please enter City.', 'index' => 'passenger-city-1');
							echo json_encode($response);
							exit;
						}

						if (empty(trim($passengerAddress)) && ($ICSourceSysId == 3 || $ICSourceSysId == 17)) {
							$response = array('succes' => false, 'msg' => 'Please enter Address.', 'index' => 'passenger-address-1');
							echo json_encode($response);
							exit;
						}
						if (empty(trim($leadMobile))) {
							$response = array('succes' => false, 'msg' => 'Please enter lead pax mobile.', 'index' => 'leadMobile');
							echo json_encode($response);
							exit;
						}
						if (empty(trim($leadEmail))) {
							$response = array('succes' => false, 'msg' => 'Please enter lead pax email id.', 'index' => 'leadEmail');
							echo json_encode($response);
							exit;
						}
						if ($interNationalSearch == 1) {

							if (empty(trim($passporNation))) {
								$response = array('succes' => false, 'msg' => 'Please Select Nation', 'index' => 'PassportNationality-' . $i);
								echo json_encode($response);
								exit;
							}
							if (empty(trim($passengerPassportNo))) {
								$response = array('succes' => false, 'msg' => 'Please enter Passport No.', 'index' => 'passportno-' . $i);
								echo json_encode($response);
								exit;
							}
							$expiry_date = $this->get_months_between_dates($departureDatesAD, $passengerPassportExpiry);
							//print_r($expiry_date);
							if (empty($passengerPassportExpiry) && $passengerPassportExpiry != '0000-00-00') {
								$response = array('succes' => false, 'msg' => 'Please enter Passport Expiry.', 'index' => 'passportnoexpiry-' . $i);
								echo json_encode($response);
								exit;
							}
							if (!$this->IsValidDate($passengerPassportExpiry)) {
								$response = array('succes' => false, 'msg' => 'Please enter valid Passport Expiry..', 'index' => 'passportnoexpiry-' . $i);
								echo json_encode($response);
								exit;
							}
							if ($expiry_date < '7' || $expiry_date < 7) {
								$response = array('succes' => false, 'msg' => 'Passport Expiry Date cannot be less than 6 months from last travel date.', 'index' => 'passportnoexpiry-' . $i);
								echo json_encode($response);
								exit;
							}
							if (empty($passporIssue) && $passporIssue != '0000-00-00' && $ICSourceSysId != 3) {
								$response = array('succes' => false, 'msg' => 'Please enter Passport Issue Date.', 'index' => 'passporIssue-' . $i);
								echo json_encode($response);
								exit;
							}
							if (!$this->IsValidDate($passporIssue) && $ICSourceSysId != 3) {
								$response = array('succes' => false, 'msg' => 'Please enter valid Passport Issue Date..', 'index' => 'passporIssue-' . $i);
								echo json_encode($response);
								exit;
							}
						}

						if ($isgstapply == 1 && $this->getTemplateId == 7) {
							if (empty(trim($gstnnumber))) {
								$response = array('succes' => false, 'msg' => 'Please enter GSTIN number.', 'index' => 'gstnnumber');
								echo json_encode($response);
								exit;
							}
							$is_valid_gstin = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->is_valid_gstin($gstnnumber);
							if ($is_valid_gstin == 0) {
								$response = array('succes' => false, 'msg' => 'Enter Valid GST Number', 'index' => 'gstnnumber');
								echo json_encode($response);
								exit;
							}
							if (empty(trim($companyname))) {
								$response = array('succes' => false, 'msg' => 'Please enter company name.', 'index' => 'companyname');
								echo json_encode($response);
								exit;
							}
							if (empty(trim($gstemail))) {
								$response = array('succes' => false, 'msg' => 'Please enter registered email.', 'index' => 'gstemail');
								echo json_encode($response);
								exit;
							}
							if (!filter_var($gstemail, FILTER_VALIDATE_EMAIL)) {
								$msg = "GST Email address is not valid.";
								$response = array('success' => false, 'msg' => $msg, 'index' => 'gstemail');
								echo json_encode($response);
								exit;
							}
							if (empty(trim($gstphone))) {
								$response = array('succes' => false, 'msg' => 'Please enter  registered phone number.', 'index' => 'gstphone');
								echo json_encode($response);
								exit;
							}
							if (strlen(trim($gstphone)) != 10 && strlen(trim($gstphone)) != 11) {
								$response = array('succes' => false, 'msg' => 'Please enter a valid GST phone number.', 'index' => 'gstphone');
								echo json_encode($response);
								exit;
							}
							if (empty(trim($gstaddress))) {
								$response = array('succes' => false, 'msg' => 'Please enter GST address.', 'index' => 'gstaddress');
								echo json_encode($response);
								exit;
							}
						}

						$ForCustomerSession[$key]['CityTitle'] = $CityTitle;
						if ($i == 1 && $relation == 0) {
							// $apiData = array(
							// 	"AgencySysId" => $this->gtxagencysysid,
							// 	"Salutation" => $salutation,
							// 	"EmailId" => $leadEmail,
							// 	"FirstName" => $firstName,
							// 	"LastName" => $lastName,
							// 	"CountryCode" => $countryCode,
							// 	"MobileNo" => $leadMobile,
							// );
							// $model = new Gtxwebservices_Model_Webservices();
							// $result = $model->CreateCustomer($apiData);
							// $apiCustomer = json_decode($result, true);

							$arrCustomer = $ForCustomerSession[$key] = array(
								'AgencySysId' => isset($this->gtxagencysysid) ? $this->gtxagencysysid:0,
								'EmailId' => isset($leadEmail) ? $leadEmail:'',
								'Salutation' => isset($salutation) ? $salutation:'',
								//'Gender_Id' => 0) ? :'',//isset($getSalutation['Gender_Id']) ? :'',
								'Relation' => isset($relation) ? $relation:'',
								'Contacts' => isset($leadMobile) ? $leadMobile:'',
								'FirstName' => isset($firstName) ? $firstName:'',
								'LastName' => isset($lastName) ? $lastName:'',
								'Password' => '',
								'IsPswExpire' => 0,
								'CreatedByUserSysId' => ($this->gtxagencysysid) ? $this->gtxagencysysid:0,
								'DOB' => $passengerDob,//isset($passengerDob) ? $passengerDob :'',
								//'PassportNo' => $passengerPassportNo,
								//'PassportExpiry' => ($interNationalSearch == 1)?$passengerPassportExpiry:'',
								'Address' => isset($passengerAddress) ? $passengerAddress :'',
								'CityTitle' => isset($CityTitle) ? $CityTitle :'',
								'CitySysId' => !empty($passengerCity) ? $passengerCity : 0,
								'paxType' => isset($paxType) ? $paxType :'',
								'StateOrZoneSysId' => 0,
								'CountrySysId' => !empty($CountrySysId) ? $CountrySysId : 0,
								'countryCode' => isset($countryCode) ? $countryCode:'',
								'RegisterDate' => date('Y-m-d-H-i-s'),
								'IsActive' => 1,
								'IsMarkForDel' => '0',
							);
							//echo '<pre>';print_r($arrCustomer);die('1');
							// if ($apiCustomer['status'] == 1) {
							// 	$arrCustomer['GTX_customerSysId'] = $apiCustomer['Message'];
							// }
							if ($ICSourceSysId == 17) {
								$arrCustomer['Address'] = $ForCustomerSession[$key]['Address'] = $passengerAddress;
								$arrCustomer['CityTitle'] = $ForCustomerSession[$key]['CityTitle'] = $CityTitle;
								$arrCustomer['CitySysId'] = $ForCustomerSession[$key]['CitySysId'] = $passengerCity;
								$arrCustomer['CountrySysId'] = $ForCustomerSession[$key]['CountrySysId'] = $CountrySysId;
								$arrCustomer['countryName'] = $ForCustomerSession[$key]['countryName'] = $passengercountryName;
							}
							if ($isgstapply == 1) {
								$arrCustomer['companyname'] = $ForCustomerSession[$key]['companyname'] = $companyname;
								$arrCustomer['gstnnumber'] = $ForCustomerSession[$key]['gstnnumber'] = $gstnnumber;
								$arrCustomer['gstaddress'] = $ForCustomerSession[$key]['gstaddress'] = $gstaddress;
								$arrCustomer['gstcity'] = $ForCustomerSession[$key]['gstcity'] = $gstcity;
								$arrCustomer['gststate'] = $ForCustomerSession[$key]['gststate'] = $gststate;
								$arrCustomer['gstpincode'] = $ForCustomerSession[$key]['gstpincode'] = $gstpincode;
							}
							if ($interNationalSearch == 1) {
								$arrCustomer['PassportNo'] = $ForCustomerSession[$key]['PassportNo'] = ($interNationalSearch == 1) ? $passengerPassportNo : '';
								$arrCustomer['PassportNation'] = $ForCustomerSession[$key]['PassportNation'] = ($interNationalSearch == 1) ? $passporNation : '';
								$arrCustomer['PassportExpiry'] = $ForCustomerSession[$key]['PassportExpiry'] = ($interNationalSearch == 1) ? $passengerPassportExpiry : '';
								$arrCustomer['passporIssue'] = $ForCustomerSession[$key]['passporIssue'] = ($interNationalSearch == 1) ? $passporIssue : '';
							}
							
							if (!empty($IsExistcustomer)) {
								$arrCustomer['modified'] = date('Y-m-d-H-i-s');
								// $model = new Gtxwebservices_Model_Webservices();
								// $result = $model->UpdateCustomer($arrCustomer);
								// $apiCustomer = json_decode($result, true);
								// if ($apiCustomer['status'] == 1) {
								// 	$arrCustomer['GTX_customerSysId'] = $apiCustomer['Message'];
								// }
								$where = "CustomerSysId = " . $CustomerSysIdPost; //exit;
								$objFlight->UpdateFlightData('tbl_customer', $arrCustomer, $where);

								$CustomerSysId = $CustomerSysIdPost;
							} elseif ($add_travellerslist == 1 && empty($tbl_customer)) {
								$arrCustomer['IsApproved'] = $isAprove;
								$arrCustomer['apiTraceId'] = $post['traceId'];
								$arrCustomer['modified'] = date('Y-m-d-H-i-s');
								$arrCustomer['created'] = date('Y-m-d-H-i-s');

								$CustomerSysId = $objFlight->InsertFlightData('tbl_customer', $arrCustomer);
							} else {
								$arrCustomer['IsApproved'] = $isAprove;
								$arrCustomer['CustomerSysId'] = $tbl_customer[0]['CustomerSysId'];
								$arrCustomer['apiTraceId'] = $post['traceId'];
								$arrCustomer['modified'] = date('Y-m-d-H-i-s');
								$arrCustomer['created'] = date('Y-m-d-H-i-s');
								$CustomerSysId = $Isadultmem = $objFlight->InsertFlightData('tbl_customer_member', $arrCustomer);
							}
							// if ($this->gtxagencysysid == '21') {
							// 	echo '<pre>';
							// 	print_r($arrCustomer);
							// 	die;
							// }
							$arrmembersId[] = $CustomerSysId;

							$ForCustomerSession[$key]['CustomerSysId'] = $CustomerSysId;
							$ForCustomerSession[$key]['FFAirlineCode'] = $FFAirlineCode;
							$ForCustomerSession[$key]['FFNumber'] = $FFNumber;
							$CustomerSysIdSession = new Zend_Session_Namespace('CustomerSysIdSession');
							$LeadPaxSession = new Zend_Session_Namespace('LeadPaxSession');
							$CustomerSysIdSession->params = $CustomerSysId;
							$arrCustomer['CustomerSysId'] = $CustomerSysId;
							$LeadPaxSession->params = $arrCustomer;

						} else {

							$IsExistMember = '';
							if (!empty($CustomerSysIdPost) && $CustomerSysIdPost != '0') {
								$IsExistMember = $objFlight->CheckMember('tbl_customer_member', array('CustomerMemberSysId' => $CustomerSysIdPost));
							}
							$CustomerSysId = (!empty($CustomerSysId) && $Isadultmem == 0) ? $CustomerSysId : @$tbl_customer[0]['CustomerSysId'];
							$arrCustomerMembers = $ForCustomerSession[$key] = array(
								'AgencySysId' => $this->gtxagencysysid,
								'CustomerSysId' => (!empty($CustomerSysId) && $Isadultmem == 0) ? $CustomerSysId : @$tbl_customer[0]['CustomerSysId'],
								'EmailId' => $leadEmail,
								'Salutation' => $salutation,
								//'Gender_Id' => $getSalutation['Gender_Id'],
								'Relation' => $relation,
								'Contacts' => $leadMobile,
								'FirstName' => $firstName,
								'LastName' => $lastName,
								'Password' => '',
								'IsPswExpire' => 0,
								'CreatedByUserSysId' => $this->gtxagencysysid,
								'DOB' => $passengerDob,
								//'PassportNo' => $passengerPassportNo,
								//'PassportExpiry' => ($interNationalSearch == 1)?$passengerPassportExpiry:'',
								'Address' => $passengerAddress,
								'CityTitle' => $CityTitle,
								'CitySysId' => !empty($passengerCity) ? $passengerCity : 0,
								'paxType' => $paxType,
								'StateOrZoneSysId' => 0,
								'CountrySysId' => !empty($CountrySysId) ? $CountrySysId : 0,
								'countryCode' => $countryCode,
								'RegisterDate' => date('Y-m-d-H-i-s'),
								'IsActive' => 1,
								'IsMarkForDel' => '0',

							);

							if ($isgstapply == 1) {
								$arrCustomerMembers['companyname'] = $ForCustomerSession[$key]['companyname'] = $companyname;
								$arrCustomerMembers['gstnnumber'] = $ForCustomerSession[$key]['gstnnumber'] = $gstnnumber;
								$arrCustomerMembers['gstaddress'] = $ForCustomerSession[$key]['gstaddress'] = $gstaddress;
								$arrCustomerMembers['gstcity'] = $ForCustomerSession[$key]['gstcity'] = $gstcity;
								$arrCustomerMembers['gststate'] = $ForCustomerSession[$key]['gststate'] = $gststate;
								$arrCustomerMembers['gstpincode'] = $ForCustomerSession[$key]['gstpincode'] = $gstpincode;
							}
							if ($interNationalSearch == 1) {
								$arrCustomerMembers['PassportNo'] = $ForCustomerSession[$key]['PassportNo'] = ($interNationalSearch == 1) ? $passengerPassportNo : '';
								$arrCustomerMembers['PassportNation'] = $ForCustomerSession[$key]['PassportNation'] = ($interNationalSearch == 1) ? $passporNation : '';
								$arrCustomerMembers['PassportExpiry'] = $ForCustomerSession[$key]['PassportExpiry'] = ($interNationalSearch == 1) ? $passengerPassportExpiry : '';
								$arrCustomerMembers['passporIssue'] = $ForCustomerSession[$key]['passporIssue'] = ($interNationalSearch == 1) ? $passporIssue : '';
							}
							//$IsExistcustomer = $objFlight->CheckCustomer('tbl_customer', array('CustomerSysId' => $leadMobile, 'EmailId' => $leadEmail));
							//$CustomerSysId = $CustomerSysIdPost;

							if (!empty($IsExistMember)) {
								$arrCustomerMembers['CustomerSysId'] = $ForCustomerSession[$key]['CustomerSysId'] = $IsExistMember['CustomerSysId'];
								$arrCustomerMembers['modified'] = date('Y-m-d-H-i-s');
								$where = "CustomerMemberSysId = " . $CustomerSysIdPost; //exit;
								$objFlight->UpdateFlightData('tbl_customer_member', $arrCustomerMembers, $where);
								$CustomerMemberSysId = $CustomerSysIdPost;
								if ($i == 1) {
									$bookCustomerId = $CustomerSysIdPost;
								}
							} elseif ($add_travellerslist == 1) {
								//$arrCustomerMembers['CustomerSysId'] = $ForCustomerSession[$key]['CustomerSysId'] = $IsExistcustomer['CustomerSysId'];
								$arrCustomerMembers['IsApproved'] = $isAprove;
								$arrCustomerMembers['apiTraceId'] = $post['traceId'];
								$arrCustomerMembers['modified'] = date('Y-m-d-H-i-s');
								$arrCustomerMembers['created'] = date('Y-m-d-H-i-s');
								$CustomerMemberSysId = $bookCustomerId = $objFlight->InsertFlightData('tbl_customer_member', $arrCustomerMembers);
							} else {
								$CustomerMemberSysId = 0;
							}
							
							$ForCustomerSession[$key]['CustomerMemberSysId'] = $CustomerMemberSysId;

							$apiDataMember[$key] = $arrCustomerMembers;
							$apiDataMember[$key]['EmailId'] = $post['leadEmail'];
							$apiDataMember[$key]['MobileNo'] = $post['leadMobile'];
							$apiDataMember[$key]['B2B'] = false;

							$arrCustomerMembers['CustomerMemberSysId'] = $CustomerMemberSysId;
							$CustomerMembersSessionArr[] = $arrCustomerMembers;
							$arrmembersId[] = $CustomerMemberSysId;
						}
						$ForCustomerSession[$key]['isgstapply'] = $isgstapply;
						$ForCustomerSession[$key]['countryCodeISO'] = $countryCodeISO;
						$ForCustomerSession[$key]['FFAirlineCode'] = $FFAirlineCode;
						$ForCustomerSession[$key]['FFNumber'] = $FFNumber;
						$ForCustomerSession[$key]['docId'] = isset($docId) ? $docId :'';
						$key++;
					}
				} else {
					$response = array('succes' => false, 'msg' => 'Your session has ben expired. Please refresh your page or search again.', 'index' => '');
					echo json_encode($response);
					exit;
				}

				$this->objMdl->rv_delete('tbl_flight_booking', array('apiTraceId = ?' => $post['traceId']));
				$this->objMdl->rv_delete('tbl_flight_booking_customer', array('apiTraceId = ?' => $post['traceId']));
				$flight_booking_customer = [];

				$IsSeriesFareData = isset($BookingData[0]['IsSeriesFareData']) ? $BookingData[0]['IsSeriesFareData'] : 0;
				if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
					$checkInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckInventorycheckRetriveUpdateNew($BookingData, $sessionFlightSearchParams->params);
					// if ($this->gtxagencysysid == '79137') {
					// 	echo '<pre>';
					// 	print_r($checkInventory);
					// 	die;
					// }
					if ($checkInventory[0]['Status'] == 1) {
						$BookingData[0]['bookingId'] = isset($checkInventory[0]['data']['RefNo']) ? $checkInventory[0]['data']['RefNo'] : 0;
						$intOutBoundId = json_decode($post['intOutBoundId'], 1);
						$intOutBoundId[0]['bookingId'] = isset($checkInventory[0]['data']['RefNo']) ? $checkInventory[0]['data']['RefNo'] : 0;
						$intOutBoundIdJson = json_encode($intOutBoundId);
						$post['intOutBoundId'] = $intOutBoundIdJson;
					} else {
						$checkInventoryResponse = array('success' => $checkInventory[0]['Status'], 'status' => $checkInventory[0]['Status'], 'msg' => ($checkInventory[0]['message'] != '') ? $checkInventory[0]['message'] : 'Oops ! No Seats are available');
						echo json_encode($checkInventoryResponse);
						exit;
					}
					if (isset($checkInventory[1]['Status']) && !empty($checkInventory[1]) && $route == 2) {
						if ($checkInventory[1]['Status'] == 1) {
							$BookingData[1]['bookingId'] = isset($checkInventory[1]['data']['RefNo']) ? $checkInventory[1]['data']['RefNo'] : 0;
							$intOutBoundId = json_decode($post['intOutBoundId'], 1);
							$intOutBoundId[1]['bookingId'] = isset($checkInventory[1]['data']['RefNo']) ? $checkInventory[1]['data']['RefNo'] : 0;
							$intOutBoundIdJson = json_encode($intOutBoundId);
							$post['intOutBoundId'] = $intOutBoundIdJson;
						} else {
							$checkInventoryResponse = array('success' => $checkInventory[1]['Status'], 'status' => $checkInventory[1]['Status'], 'msg' => ($checkInventory[1]['message'] != '') ? $checkInventory[1]['message'] : 'Oops ! No Seats are available');
							echo json_encode($checkInventoryResponse);
							exit;
						}
					}
				}
				// echo json_encode($BookingData);

				if ($interNationalSearch == 1 && $route == 2 && $route != 3) {
					$dataArrInter = $this->CreateInternationDataArr($FlightBookingDataRoundInter->params, !empty($CustomerSysId) ? $CustomerSysId : $bookCustomerId);
					// echo 'dataArrInter<pre>';
					// print_r($dataArrInter);
					// die;
					$flight_booking_id = $flight_booking_id_Arr[] = $objFlight->InsertFlightData('tbl_flight_booking', $dataArrInter['origin']);
					$dataArrInter['destination']['parent_id'] = $flight_booking_id;

					$flight_booking_id = $flight_booking_id_Arr[] = $objFlight->InsertFlightData('tbl_flight_booking', $dataArrInter['destination']);
					$flight_booking_customer[0] = $this->InsertFlightBookingCustomer($ForCustomerSession, $arrmembersId, $BookingData[0]);
					$flight_booking_customer_id = new Zend_Session_Namespace('flight_booking_customer_id');
					$flight_booking_customer_id->params = $flight_booking_customer;
				} else {
					if ($BookingData) {
						foreach ($BookingData as $k => $value) {
							if ($k == 0) {
								$travelDate = $strDepatureDate;
							} else {
								$travelDate = $strReturnDate;
							}
							if($value['ICSourceSysId'] == 3){
								$value['DepartureTime'] =  date('H:i:s', strtotime($value['FromUTCTime']));
								$value['ArrivalTime'] =  date('H:i:s', strtotime($value['ToUTCTime']));
							}
							if($value['JourneyType'] == 3 && $value['ICSourceSysId'] == 3){
								$travelDate = date('Y-m-d', strtotime($value['FromUTCTime']));
							}
							if($value['ICSourceSysId'] == 17 || $value['ICSourceSysId'] == 16 || $value['ICSourceSysId'] == 3){
								$value['JourneyType'] = ($k == 0) ? 1 : 2;
							}
							
							//print_r($arrmembersId);die; FlyingMinutes
							$arrPlanAir['AgencySysId'] = $this->gtxagencysysid;
							$arrPlanAir['CustomerSysId'] = !empty($CustomerSysId) ? $CustomerSysId : $bookCustomerId;
							$arrPlanAir['API_Response'] = json_encode($value);
							$arrPlanAir['BookingId'] = $value['bookingId'];
							$arrPlanAir['APIBookingId'] = $value['bookingId_TJ'];
							$arrPlanAir['FlightNumber'] = $value['FlightNumber'];
							$arrPlanAir['AirlineName'] = $value['AirlineName'];
							$arrPlanAir['ICSourceSysId'] = $value['ICSourceSysId'];
							$arrPlanAir['TravelDate'] = ($route == 3 && isset($value['TravelDate'])) ? $value['TravelDate'] : $travelDate;
							$arrPlanAir['IsLCC'] = $value['IsLCC'];
							$arrPlanAir['IsRefundable'] = ($value['IsRefundable']) ? $value['IsRefundable'] : 0;
							$arrPlanAir['apiTraceId'] = !empty($value['SearchFlightTraceId']) ? $value['SearchFlightTraceId'] : 'NA';
							$arrPlanAir['AirlineSysId'] = isset($value['AirlineSysId']) ? $value['AirlineSysId'] : 0;
							$arrPlanAir['DepartureTime'] = !empty($value['DepartureTime'])?$value['DepartureTime']:'';
							$arrPlanAir['ArrivalTime'] = !empty($value['ArrivalTime'])?$value['ArrivalTime']:'';
							$arrPlanAir['IsDirect'] = isset($value['IsDirect']) ? (int)$value['IsDirect'] :0;
							$arrPlanAir['FareClass'] = $value['FareClass'];
							$arrPlanAir['FlyingMinutes'] = isset($value['FlyingMinutes']) ? $value['FlyingMinutes'] : 0;
							$arrPlanAir['FlightDuration'] = isset($value['FlightDuration']) ? $value['FlightDuration'] : '';
							$arrPlanAir['SourcePlaceSysId'] = (int)$value['SourcePlaceSysId'];
							$arrPlanAir['DestPlaceSysId'] = (int)$value['DestPlaceSysId'];
							$arrPlanAir['SourceAirportCode'] = $value['SourceAirportCode'];
							$arrPlanAir['DestAirportCode'] = $value['DestAirportCode'];
							$arrPlanAir['StopCount'] = $value['StopCount'];
							$arrPlanAir['TotalFlightMembers'] = isset($value['TotalFlightMembers']) ? $value['TotalFlightMembers'] : $totalPassengers;
							$arrPlanAir['CurrencyType'] = isset($value['CurrencyType']) ? $value['CurrencyType'] : 1;
							$arrPlanAir['PublishedFare'] = isset($value['FairRules']['PublishedFare']) ? $value['FairRules']['PublishedFare'] : 0;
							$arrPlanAir['ApiResultIndex'] = (!empty($value['ApiResultIndex']) && $value['ICSourceSysId'] != 3) ? $value['ApiResultIndex'] : 'NA';
							$arrPlanAir['JourneyType'] = $value['JourneyType'];
							$arrPlanAir['TripType'] = $value['TripType'];
							$arrPlanAir['IsInternational'] = ($value['IsInternational']) ? $value['IsInternational'] : 0;
							$arrPlanAir['logo'] = $value['logo'];
							$arrPlanAir['Currency'] = isset($value['FairRules']['Currency']) ? $value['FairRules']['Currency'] : 'INR';
							$arrPlanAir['BaseFare'] = isset($value['FairRules']['BaseFare']) ? $value['FairRules']['BaseFare'] : 0;
							$arrPlanAir['Tax'] = (float) !empty($value['FairRules']['Tax']) ? $value['FairRules']['Tax'] : 0;
							$arrPlanAir['YQTax'] = !empty($value['FairRules']['YQTax']) ? $value['FairRules']['YQTax'] : 0;
							$arrPlanAir['OtherCharges'] = !empty($value['FairRules']['OtherCharges']) ? $value['FairRules']['OtherCharges'] : 0;
							$arrPlanAir['Discount'] = !empty($value['FairRules']['Discount']) ? $value['FairRules']['Discount'] :0;
							$arrPlanAir['ServiceFee'] = !empty($value['FairRules']['ServiceFee']) ? $value['FairRules']['ServiceFee'] : 0;
							$arrPlanAir['OfferedFare'] = !empty($value['FairRules']['PublishedFare']) ? $value['FairRules']['PublishedFare'] :0;
							$arrPlanAir['AgentCommisionEarned'] = !empty($value['FairRules']['CommEarned']) ? $value['FairRules']['CommEarned'] :0;
							$arrPlanAir['AgentCommisionEarnedGST'] = isset($value['FairRules']['GSTonComm']) ? $value['FairRules']['GSTonComm'] : 0;
							$arrPlanAir['AgencyMarkUp'] = isset($value['FairRules']['apiMarkup']) ? $value['FairRules']['apiMarkup'] : $value['FairRules']['FixedMarkUp'];
							$arrPlanAir['AgencyMarkUpGST'] = $value['FairRules']['GSTOnMarkUp'];
							$arrPlanAir['GTXMarkUp'] = isset($value['FairRules']['intGTXMarkUp']) ? $value['FairRules']['intGTXMarkUp'] : 0;
							$arrPlanAir['GTXMarkUpGST'] = isset($value['FairRules']['GTXMarkUpGST']) ? $value['FairRules']['GTXMarkUpGST'] : 0;
							$arrPlanAir['CancelCharge'] = isset($value['FairRules']['CancelCharge']) ? $value['FairRules']['CancelCharge'] : 0;
							$arrPlanAir['couponName'] = isset($value['FairRules']['couponName']) ? $value['FairRules']['couponName'] : 0;
							$arrPlanAir['couponVal'] = isset($value['FairRules']['couponVal']) ? $value['FairRules']['couponVal'] : 0;
							$arrPlanAir['couponApply'] = isset($value['FairRules']['couponApply']) ? $value['FairRules']['couponApply'] : 0;
							$arrPlanAir['couponexpiryDate'] = isset($value['FairRules']['couponexpiryDate']) ? $value['FairRules']['couponexpiryDate'] : NULL;
							$arrPlanAir['status'] = 0;
							$arrPlanAir['IsMarkForDel'] = 0;
							$arrPlanAir['created_at'] = date('Y-m-d-H-i-s');
							$arrPlanAir['updated_at'] = date('Y-m-d-H-i-s');
							$arrPlanAir['ip_address'] = $_SERVER['REMOTE_ADDR'];
							if ($this->getTemplateId == 7) {
								$arrPlanAir['gstnnumber'] = $gstnnumber;
								$arrPlanAir['companyname'] = $companyname;
								$arrPlanAir['gstemail'] = $gstemail;
								$arrPlanAir['gstphone'] = $gstphone;
								$arrPlanAir['gstaddress'] = $gstaddress;
								$arrPlanAir['gststate'] = $gststate;
							}
							// if ($this->gtxagencysysid == '6060') {
							// 	echo 'arrPlanAir<pre>';
							//    print_r(($arrPlanAir));
							// }


							if ($k == 0) {
								$flight_booking_id = $flight_booking_id_Arr[] = $objFlight->InsertFlightData('tbl_flight_booking', $arrPlanAir);
							} else {
								$arrPlanAir['parent_id'] = $flight_booking_id;
								$flight_booking_id = $flight_booking_id_Arr[] = $objFlight->InsertFlightData('tbl_flight_booking', $arrPlanAir);
							}
							if ($route == 3 && $k == 0) {
								$flight_booking_customer[$k] = $this->InsertFlightBookingCustomer($ForCustomerSession, $arrmembersId, $value);
							}
							if ($route != 3) {
								$flight_booking_customer[$k] = $this->InsertFlightBookingCustomer($ForCustomerSession, $arrmembersId, $value);
							}
						}
						$flight_booking_customer_id = new Zend_Session_Namespace('flight_booking_customer_id');
						$flight_booking_customer_id->params = $flight_booking_customer;
					}
				}

				$CustomerSession = new Zend_Session_Namespace('CustomerSession');
				$CustomerSession->params = $ForCustomerSession;
				$CustomerMembersSession = new Zend_Session_Namespace('CustomerMembersSession');
				$CustomerMembersSession->params = $CustomerMembersSessionArr;
				$sessionData = array('CustomerSysId' => $CustomerSysId, 'CustomerMemSysId' => $arrmembersId, 'flight_booking_id' => $flight_booking_id_Arr);
				$CustomerMemberSysIds = new Zend_Session_Namespace('CustomerMemberSysIds');
				$CustomerMemberSysIds->params = $sessionData;

				
				if ($flight_booking_customer) {
					$objFlight = new Travel_Model_FlightMaster();

					$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $post['traceId']], ['id' => 'ASC']);
					$arrUrlData = json_decode($temp_data['json_data'], true);
					$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
					$FlightBookingData->params = $BookingData; // Putting all form data to Session
					$arrData = array(
						'BookingData' => $BookingData,
						'flight_booking_id_Arr' => $flight_booking_id_Arr,
						'CustomerMemberSysIds' => $sessionData,
						'CustomerSession' => $ForCustomerSession,
						'CustomerMembersSessionArr' => $CustomerMembersSessionArr,
						'CustomerSysId' => $CustomerSysId,
						'CustomerMemSysId' => $arrmembersId,
						'flight_booking_customer' => $flight_booking_customer,
						'SearchTraceId' => $post['FlightTraceId'],
						'sessionFlightSearchParams' => $sessionFlightSearchParams->params,
						'genrateFlightQuery' => $genrateFlightQuery,
						'sessionData' => $sessionData,
						'validateCoupon' => $arrUrlData['validateCoupon'],
						'validateData' => $arrUrlData['validateData'],
						'apiData' => $apiData,
						'tripSeatMap' => $tripSeatMap,
						'FARERULE' => $FARERULE,
						'apiDataMember' => array_values($apiDataMember),
					);
					// echo json_encode($arrData);
					// echo 'arrData<pre>';
					// print_r($arrData);
					// die;
					$tempData = array(
						'TraceId' => $post['traceId'],
						'json_data' => json_encode($arrData),
					);
					$objFlight->deleteFlightTempData($post['traceId']);
					$objFlight->insertFlightTempData($tempData);
					$response = array('success' => true, 'msg' => 'Done', 'apiTraceId' => $traceId, 'ForCustomerSession' => $ForCustomerSession);
					echo json_encode($response);
					exit;
				} else {
					$response = array('success' => false, 'msg' => 'oops somehting went wrong.');
					echo json_encode($response);
					exit;
				}
			} catch (Exception $e) {
				//$this->db->rollBack();
				print_r($e->getMessage());
			}
		}
	}
	function arry_salutaion_com(){
		return array("1" => "Mr", "2" => "Mrs", "3" => "Ms", "4" => "Mstr", "5" => "Miss");
	} 
	public function saveGstDetailsAction()
	{
		if ($this->getRequest()->isPost()) {
			$this->_helper->layout->disableLayout();
			$this->_helper->viewRenderer->setNoRender(true);
			$post = $this->getRequest()->getPost();

			$objFlight = new Travel_Model_FlightMaster();
			$FlightTempData = $objFlight->GetFlightTempData($post['traceId']);
			$arrUrlData = json_decode($FlightTempData['json_data'], true);
			$CustomerSysId = $arrUrlData['CustomerSysId'];
			$apiData = $arrUrlData['apiData'];
			$apiDataMember = $arrUrlData['apiDataMember'];
			$BookingData = $arrUrlData['BookingData'];
			$flight_booking_id_Arr = $arrUrlData['flight_booking_id_Arr'];
			$ForCustomerSession = $arrUrlData['CustomerSession'];
			$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
			$ICSourceSysId = $BookingData[0]['ICSourceSysId'];

			
			$class = $sessionFlightSearchParams['class'];
			$FareTypes__ = isset($sessionFlightSearchParams['FareTypes']) ? $sessionFlightSearchParams['FareTypes'] :'';
			$interNationalSearch = $sessionFlightSearchParams['interNationalSearch'];
			$route = $sessionFlightSearchParams['route'];
			$departureDates = $sessionFlightSearchParams['departure_date'];
			if ($route == 3) {
				$departureDates = $sessionFlightSearchParams['departure_date'][0];
			} else {
				$departureDates = $sessionFlightSearchParams['departure_date'];
			}
			$departure_dates = $sessionFlightSearchParams['departure_dates'];
			$strDepatureDate = $sessionFlightSearchParams['strDepatureDate'];
			$strReturnDate = $sessionFlightSearchParams['strReturnDate'];
			$returnDate = $sessionFlightSearchParams['return_date'];
			$originAirCode = isset($sessionFlightSearchParams['sourceCityAirportCode']) ? $sessionFlightSearchParams['sourceCityAirportCode'] : '';			
			

			$adultCount = isset($sessionFlightSearchParams['adults']) ? $sessionFlightSearchParams['adults'] : 0;
			$childCount = isset($sessionFlightSearchParams['childs']) ? $sessionFlightSearchParams['childs'] : 0;
			$infantCount = isset($sessionFlightSearchParams['infants']) ? $sessionFlightSearchParams['infants'] : 0;
			$sourceCityId = !empty($sessionFlightSearchParams['sourceCityId']) ? $sessionFlightSearchParams['sourceCityId'] : '';
			$destinationCityId = !empty($sessionFlightSearchParams['destinationCityId']) ? $sessionFlightSearchParams['destinationCityId'] : '';
			
			$totalPassengers = $adultCount + $childCount + $infantCount;

			if (!empty($departureDates)) {
				$arrDepartureDates = explode("/", $departureDates);
				$departureDatesAD = $arrDepartureDates[2] . "-" . $arrDepartureDates[1] . "-" . $arrDepartureDates[0];
			}
			if ($route == 3) {
				$departureDates = [];
				if ($originAirCode && $route == '3') {
					foreach ($originAirCode as $key => $value) {
						$departureDates[] = isset($departure_dates[$key]) ? date('d/m/Y', strtotime($departure_dates[$key])) : '';
					}
				}
			}

			$oneway_origin_text = isset($sessionFlightSearchParams['sourceCityAirportCode']) ? $sessionFlightSearchParams['sourceCityAirportCode'] : '';
			$oneway_destination_text = isset($sessionFlightSearchParams['destinationCityAirportCode']) ? $sessionFlightSearchParams['destinationCityAirportCode'] : '';
			$originAirportCode = isset($sessionFlightSearchParams['originAirportCode']) ? $sessionFlightSearchParams['originAirportCode'] : '';
			$destinationAirportCode = isset($sessionFlightSearchParams['destinationAirportCode']) ? $sessionFlightSearchParams['destinationAirportCode'] : '';

			$SelectedMealSessionNew = new Zend_Session_Namespace('SelectedMealSessionNew');
			$SelectedBaggSessionNewInb = new Zend_Session_Namespace('SelectedBaggSessionNewInb');
			$SelectedBaggSessionNew = new Zend_Session_Namespace('SelectedBaggSessionNew');
			$selectedSeatSession = new Zend_Session_Namespace('selectedSeatSession');
			$SelectedMealSessionNewInb = new Zend_Session_Namespace('SelectedMealSessionNewInb');
			
			
			$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
			$CustomerSession = new Zend_Session_Namespace('CustomerSession');
			$CustomerMemberSysIds = new Zend_Session_Namespace('CustomerMemberSysIds');
			$flight_booking_id = isset($CustomerMemberSysIds->params['flight_booking_id']) ? $CustomerMemberSysIds->params['flight_booking_id'] : 0;
			$CustomerData = $CustomerSession->params;
			//$BookingData = $FlightBookingData->params;
			$objFlight = new Travel_Model_FlightMaster();
			$SelectMeals = isset($post['SelectMeals']) ? $post['SelectMeals'] : '';
			$SelectBaggage = isset($post['SelectBaggage']) ? $post['SelectBaggage'] : '';
			$companyname = isset($post['companyname']) ? $post['companyname'] : '';
			$gstnnumber = isset($post['gstnnumber']) ? $post['gstnnumber'] : '';
			$gstaddress = isset($post['gstaddress']) ? $post['gstaddress'] : '';
			$gstemail = isset($post['gstemail']) ? $post['gstemail'] : '';
			$gststate = isset($post['gststate']) ? $post['gststate'] : '';
			$gstphone = isset($post['gstphone']) ? $post['gstphone'] : '';
			$isgstapply = isset($post['isgstapply']) ? $post['isgstapply'] : 0;
			$selectedMealAR = [];
			$selectedBagAR = [];
			// echo "SelectMeals<pre>";print_r($ForCustomerSession);"</pre>";die;
			if ($SelectMeals) {
				foreach ($SelectMeals as $values) {
					if($values !== 'NA'){
						$selectedMealAR[] = $values;
					}
				}
			}
			if ($SelectBaggage) {
				foreach ($SelectBaggage as $values) {
					if($values !== 'NA'){
						$selectedBagAR[] = $values;
					}
				}
			}
			
			$traceId = $post['traceId'];
			if ($BookingData && $isgstapply == 0) {
				foreach ($BookingData as $values) {

					if ($values['isGSTMandatory'] == 1) {
						$response = array('succes' => false, 'msg' => 'GST mandatory for this flight.', 'index' => 'gstnnumber');
						echo json_encode($response);
						exit;
					}
				}
			}

			if ($isgstapply == 1) {
				if (empty(trim($gstnnumber))) {
					$response = array('succes' => false, 'msg' => 'Please enter GSTIN number.', 'index' => 'gstnnumber');
					echo json_encode($response);
					exit;
				}
				$is_valid_gstin = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->is_valid_gstin($gstnnumber);
				if ($is_valid_gstin == 0) {
					$response = array('succes' => false, 'msg' => 'Enter Valid GST Number', 'index' => 'gstnnumber');
					echo json_encode($response);
					exit;
				}
				if (empty(trim($companyname))) {
					$response = array('succes' => false, 'msg' => 'Please enter company name.', 'index' => 'companyname');
					echo json_encode($response);
					exit;
				}
				if (empty(trim($gstemail))) {
					$response = array('succes' => false, 'msg' => 'Please enter registered email.', 'index' => 'gstemail');
					echo json_encode($response);
					exit;
				}
				if (!filter_var($gstemail, FILTER_VALIDATE_EMAIL)) {
					$msg = "GST Email address is not valid.";
					$response = array('success' => false, 'msg' => $msg, 'index' => 'gstemail');
					echo json_encode($response);
					exit;
				}
				if (empty(trim($gstphone))) {
					$response = array('succes' => false, 'msg' => 'Please enter  registered phone number.', 'index' => 'gstphone');
					echo json_encode($response);
					exit;
				}
				if (strlen(trim($gstphone)) != 10 && strlen(trim($gstphone)) != 11) {
					$response = array('succes' => false, 'msg' => 'Please enter a valid GST phone number.', 'index' => 'gstphone');
					echo json_encode($response);
					exit;
				}
				if (empty(trim($gstaddress))) {
					$response = array('succes' => false, 'msg' => 'Please enter GST address.', 'index' => 'gstaddress');
					echo json_encode($response);
					exit;
				}
			}

			$CustomerData[0]['isgstapply'] = $isgstapply;
			$CustomerData[0]['gstnnumber'] = $gstnnumber;
			$CustomerData[0]['companyname'] = $companyname;
			$CustomerData[0]['gstemail'] = $gstemail;
			$CustomerData[0]['gstphone'] = $gstphone;
			$CustomerData[0]['gstaddress'] = $gstaddress;
			$CustomerData[0]['gststate'] = $gststate;
			$gstData = array(
					'GstNumber' => $gstnnumber,
					'GstCompany' => $companyname,
					'GstEmail' => $gstemail,
					'GstPhone' => $gstphone,
					'GstAddress' => $gstaddress,
					'GstState' => $gststate,
				);
			if ($flight_booking_id) {
				if ($isgstapply == 1) {
					$update = array(
						'gstnnumber' => $gstnnumber,
						'companyname' => $companyname,
						'gstemail' => $gstemail,
						'gstphone' => $gstphone,
						'gstaddress' => $gstaddress,
						'gststate' => $gststate,
					);
				}

				foreach ($flight_booking_id as $key => $booking_id) {
					$update['couponName'] = isset($BookingData[$key]['FairRules']['couponName']) ? $BookingData[$key]['FairRules']['couponName'] : '';
					$update['couponVal'] = isset($BookingData[$key]['FairRules']['couponVal']) ? $BookingData[$key]['FairRules']['couponVal'] : 0;
					$update['couponApply'] = isset($BookingData[$key]['FairRules']['couponApply']) ? $BookingData[$key]['FairRules']['couponApply'] : 0;
					$update['couponexpiryDate'] = isset($BookingData[$key]['FairRules']['couponexpiryDate']) ? $BookingData[$key]['FairRules']['couponexpiryDate'] : NULL;
					$where = "id = " . $booking_id; //exit;
					$objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
				}
			}


			if ($ICSourceSysId != 17 && $ICSourceSysId != 16 && $ICSourceSysId != 7 && $ICSourceSysId != 3 && $ICSourceSysId != 11) {
				$model = new Gtxwebservices_Model_Webservices();
				$apiData['memberDetailArray'] = json_encode(array_values($apiDataMember));
				$result = $model->CreateCustomer($apiData);
				$apiCustomer = json_decode($result, true);
				if ($apiCustomer['status'] == 1) {
					$arrCustomer['GTX_customerSysId'] = $apiCustomer['Message'];
					$where = "CustomerSysId = " . $CustomerSysId;
					$objFlight->UpdateFlightData('tbl_customer', $arrCustomer, $where);
				}
				$post['apiCustomer'] = $apiCustomer;
				$genrateFlightQuery = $this->genrateFlightQuery($post);
				$strFilePath = "flight/SearchParam/" . $post['traceId'] . '/FlightQuery-' . date('Y-m-d-H-i-s') . ".json";
				Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($genrateFlightQuery));
				//echo '<pre>';print_r($genrateFlightQuery);die;
				$queryStatus = isset($genrateFlightQuery['status']) ? $genrateFlightQuery['status'] : 0;
				if ($queryStatus == 0) {
					
					$response = array('succes' => false, 'msg' => 'This booking is not processed. Please contact to administrator.', 'index' => '');
					echo json_encode($response);
					exit;
				}
			} else {
				$leadMobile = isset($post['leadMobile']) ? $post['leadMobile'] : '';
				$leadEmail = isset($post['leadEmail']) ? $post['leadEmail'] : '';
				$roomjson = array();
				$roomjson[1]['Adult'] = $adultCount;
				$roomjson[1]['Child'] = $childCount;
				$roomjson[1]['Infant']  = $infantCount;
				$roomjson[1]['bedtype'] = '';
				$roomjson[1]['departuredate'] = $departureDates;
				$roomjson[1]['returndate'] = $returnDate;
				$roomjson[1]['fromaircode'] = $oneway_origin_text;
				$roomjson[1]['toaircode'] = $oneway_destination_text;
				$roomjson[1]['route'] = $route;
				$roomjson[1]['airclass'] = $class;
				// for ($c = 1; $c <= $childCount; $c++) {
				// 	$childsage = $infantCount;
				// 	$roomjson[$c]['Adult'] = $adultCount;
				// 	$roomjson[$c]['Child'] = $childCount;
				// 	$roomjson[$c]['Infant']  = $infantCount;
				// 	$roomjson[$c]['ChildAge_' . $c] = $childsage;
				// 	$roomjson[$c]['bedtype'] = '';
				// 	$roomjson[$c]['departuredate'] = $departureDates;
				// 	$roomjson[$c]['returndate'] = $returnDate;
				// 	$roomjson[$c]['fromaircode'] = $oneway_origin_text;
				// 	$roomjson[$c]['toaircode'] = $oneway_destination_text;
				// 	$roomjson[$c]['route'] = $route;
				// 	$roomjson[$c]['airclass'] = $class;
				// }
				$BaggageArr = [];
				$MealArr = [];
				$segArray = [];
				$segmentArray = [];
				if ($BookingData) {
					foreach ($BookingData as $k => $value) {
						// if($ICSourceSysId == 7 || $ICSourceSysId == 3){
						// 	$FareBreakdownArray__ = [];
						// 	$couponApply__ = isset($value['FairRules']['couponApply']) ? $value['FairRules']['couponApply']:'';
						// 	$couponVal__ = isset($value['FairRules']['couponVal']) ? $value['FairRules']['couponVal']:'';
						// 	foreach($value['FairRules']['FareBreakdown'] as $fareKey => $fareBreakD){
						// 		$FareBreakdownArray__[$fareKey] = $fareBreakD;
						// 		$FareBreakdownArray__[$fareKey]['couponVal'] = isset($value['FairRules']['FareBreakdown'][$fareKey]['couponVal']) ? $value['FairRules']['FareBreakdown'][$fareKey]['couponVal']:0;
						// 		$FareBreakdownArray__[$fareKey]['couponApply'] = isset($value['FairRules']['FareBreakdown'][$fareKey]['couponApply']) ? $value['FairRules']['FareBreakdown'][$fareKey]['couponApply']:0;
						// 	}
						// 	$NewPrice = $value['FairRules'];
						// 	$value['FairRules'] = $NewPrice;
						// 	$value['FairRules']['FareBreakdown'] = $FareBreakdownArray__;
						// 	$value['FairRules']['couponApply'] = $couponApply__;
						// 	$value['FairRules']['couponVal'] = $couponVal__;
						// }
						$intPublishedFare += $value['FairRules']['intPublishedFare'];
						$Amount = $value['FairRules']['BaseFare'];
						$Amount__ +=$Amount;
						$NetAmount = $value['FairRules']['PublishedFare'];
						$TDS = 0;//isset($value['FairRules']['TDS'])?$value['FairRules']['TDS']:0;
						$TDSEarn = isset($value['FairRules']['TDSEarn'])?$value['FairRules']['TDSEarn']:0;

						$PublishedFareAgent = (isset($value['FairRules']['PublishedFare'])) ? $value['FairRules']['PublishedFare'] : 0;
						$ExtraMarkup = (isset($value['FairRules']['ExtraMarkup'])) ? $value['FairRules']['ExtraMarkup'] : 0;
						$ExtraMarkupOnGST = (isset($value['FairRules']['ExtraMarkupOnGST'])) ? $value['FairRules']['ExtraMarkupOnGST'] : 0;

						$AgentCommisionEarnedINT__ = ($value['FairRules']['CommEarned'] + $value['FairRules']['PLBEarned']);
						$AgentCommisionEarnedGSTINT_ += ($value['FairRules']['GSTonComm'] + isset($value['FairRules']['GSTonPLB']) ? $value['FairRules']['GSTonPLB'] : 0);
						$AgencyMarkUpINT__ = $value['FairRules']['FixedMarkUp'];
						$AgencyMarkUpGSTINT__ = $value['FairRules']['GSTOnMarkUp'];
						$GTXMarkUpINT = $value['FairRules']['intGTXMarkUp'];

						$BaseAmountINT_ += ($PublishedFareAgent - $AgentCommisionEarnedINT__ - $AgencyMarkUpINT__ - $AgencyMarkUpGSTINT__);
						$PublishedFareAgentFinalRF += round(($PublishedFareAgent + $ExtraMarkup + $ExtraMarkupOnGST), 2);
						$PublishedFareAgent_ += round(($PublishedFareAgent));
						$AgencyMarkUpGSTINT_ += round(($AgencyMarkUpGSTINT__));
						$AgencyMarkUpINT_ += round(($AgencyMarkUpINT__));
						$AgentCommisionEarnedINT_ += round(($AgentCommisionEarnedINT__));
						$FlighstInfo = [];
						$BaggSSRInfo = [];
						$MealsSSRInfo = [];
						$SeatsSSRInfo = [];
						$segment_ = [];
						
						$SeatPrice = 0;
						$BagPrice = 0;
						$MealPrice = 0;
						if ($value['Segments']) {
							foreach ($value['Segments'] as $seg) {
								if($ICSourceSysId == 11){
									$seg['BAGGAGE'] = $seg['Baggage'];
								}
								if (isset($seg['BAGGAGE'])) {
									foreach ($seg['BAGGAGE'] as $b => $bag) {
										$BaggageArr[] = $bag;
									}
								}
								if (isset($seg['MEAL'])) {
									foreach ($seg['MEAL'] as $m => $meals) {
										$MealArr[] = $meals;
									}
								}

								if (!empty($selectedSeatSession->params) && isset($selectedSeatSession->params[$seg['segmentid']]) && !empty($selectedSeatSession->params[$seg['segmentid']])) {
									$selectedSeat = $selectedSeatSession->params[$seg['segmentid']];
									foreach ($selectedSeat as $ck=>$val) {
										$SeatPrice_ += $val['amount'];
										$SeatPrice += $val['amount'];
										$SeatsSSRInfo[] = ['SeatID'=>$val['SeatID'],'PaxRefNumber'=>$ck];
									}
								}
								if (!empty($SelectedBaggSessionNew->params) && isset($SelectedBaggSessionNew->params[$seg['segmentid']]) && !empty($SelectedBaggSessionNew->params[$seg['segmentid']])) {
									$selectedBag = $SelectedBaggSessionNew->params[$seg['segmentid']];
									foreach ($selectedBag as $ck=>$val) {
										$BagPrice_ += $val['Price'];
										$BagPrice += $val['Price'];
										$BaggSSRInfo[] = ['BaggageID'=>$val['BaggageID'],'PaxRefNumber'=>$ck];
									}
								}
								if (!empty($SelectedMealSessionNew->params) && isset($SelectedMealSessionNew->params[$seg['segmentid']]) && !empty($SelectedMealSessionNew->params[$seg['segmentid']])) {
									$selectedMeal = $SelectedMealSessionNew->params[$seg['segmentid']];
									foreach ($selectedMeal as $ck=>$val) {
										$MealPrice_ += $val['Price'];
										$MealPrice += $val['Price'];
										$MealsSSRInfo[] = ['MealID'=>$val['MealID'],'PaxRefNumber'=>$ck];
									}
								}

								$FlighstInfo[] = array(
									'FlightID'=>$seg['segmentid'],
									'FlightNumber'=>str_replace('-',' ',$seg['SegFlightNumber']),
									'Origin'=>$seg['originAirportCode'],
									'Destination'=>$seg['destinationAirportCode'],
									'DepartureDateTime'=>date('d M Y H:i', strtotime($seg['originDepTime'])),
									'ArrivalDateTime'=>date('d M Y H:i', strtotime($seg['destinationArrTime'])),
								);
								$segment_[] = $segment_ssr[] = array(
									  "id" => intval($seg['segmentid']),
									  "flight_booking_id" => '',
									  "TraceId" => (isset($value['SearchTraceId']) && !empty($value['SearchTraceId'])) ? $value['SearchTraceId'] : $value['SearchFlightTraceId'],
									  "segmentid" => intval($seg['segmentid']),
									  "segmentids" => ($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" =>  !empty($seg['cabinClass']) ? $seg['cabinClass'] : $value['FairRules']['FareClass'],
									  "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" =>  $seg['IsBaggage'],
									  "IsMealIncludes" =>  $seg['IsMealIncludes'],
									  "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" =>  $seg['filePath'],
									  "SourceAirportCode" =>  $seg['SourceAirportCode'],
									  "DestAirportCode" =>  $seg['DestAirportCode'],
									  "strArrivalDtTime" =>  $seg['strArrivalDtTime'],
									  "strDepartureDtTime" =>  $seg['strDepartureDtTime'],
									  "TravelDate" => $seg['TravelDate'],
									  "BagPrice" => 0,
									  "MealPrice" => 0,
									  "SeatPrice" => 0
								);
								$segArray[$seg['segmentid']]  = $seg;
								$segmentArray[] = $seg['originAirportCode'] . '-' . $seg['destinationAirportCode'];
							}
						}
						//
						$FareBreakdown_ = [];
						$GrossAmount = 0;
						$AgentMarkUp = 0;
						$TotalCommDiscount = 0;
						foreach($value['FairRules']['FareBreakdown'] as $valueB){

							$baggageByPax[$valueB['PassengerType']]['Baggage'] = $valueB['Baggage'];
							$baggageByPax[$valueB['PassengerType']]['CabinBaggage'] = $valueB['CabinBaggage'];

							$ExtraMarkup_ = isset($valueB['ExtraMarkup'])?$valueB['ExtraMarkup']:0;
							$ExtraMarkupOnGST_ = isset($valueB['ExtraMarkupOnGST'])?$valueB['ExtraMarkupOnGST']:0;
							$TotalExtraMarkup_ = ($ExtraMarkup_ + $ExtraMarkupOnGST_);
							
							$GrossAmount += (isset($valueB['GrossAmount'])) ? $valueB['GrossAmount'] : 0;
							$AgentMarkUp += (isset($valueB['AgentMarkUp'])) ? ($valueB['AgentMarkUp'] + $TotalExtraMarkup_) : 0;
							$CommissionEarned = ($valueB['CommissionEarned']) ? $valueB['CommissionEarned'] :0;
							$TDSEarn = ($valueB['TDSEarn']) ? $valueB['TDSEarn'] :0;
							$TDSB = 0;//($valueB['TDS']) ? $valueB['TDS'] :0;
							$CommDiscount = ($valueB['CommDiscount']) ? $valueB['CommDiscount'] :0;
							$BaseFareB = ($valueB['BaseFare']) ? $valueB['BaseFare'] :0;
							$TotalFare = ($valueB['PublishedFare']) ?  $valueB['PublishedFare'] : $valueB['TotalBaseFare'];
							$OtherCharges = 0;
							
							$BaseFareB = ($BaseFareB);
							
							$FareBreakdown_[] = array(
								"Currency" => $valueB['Currency'],
								"PassengerCount" => $valueB['PassengerCount'],
								"PassengerType" => $valueB['PassengerType'],
								"BaseFare" => (($BaseFareB) * $this->CurrencyRate),
								"Tax" => ($valueB['Tax']) ? ($valueB['Tax'] * $this->CurrencyRate) : (($valueB['TaxIN'] + $OtherCharges) * $this->CurrencyRate),
								"OfferedFare" => ($valueB['OfferedFare']) ? $valueB['OfferedFare'] * $this->CurrencyRate :0,
								"TotalFare" => $TotalFare * $this->CurrencyRate,
								"PublishedFare" => ($ICSourceSysId == 7)?($TotalFare + $TDSB):$TotalFare * $this->CurrencyRate,
								"TDSEarn" => ($ICSourceSysId == 7)?($TDSEarn + $TDSB):$TDSEarn,
								"MF" => ($valueB['TaxBR']['MF']) ? $valueB['TaxBR']['MF'] * $this->CurrencyRate : $valueB['MF'] * $this->CurrencyRate,
								"YQ" => ($valueB['TaxBR']['YQ']) ? $valueB['TaxBR']['YQ'] * $this->CurrencyRate : 0,
								"AGST" => ($valueB['TaxBR']['AGST']) ? $valueB['TaxBR']['AGST'] * $this->CurrencyRate : $valueB['AGST'] * $this->CurrencyRate,
								"MFT" => ($valueB['TaxBR']['MFT']) ? $valueB['TaxBR']['MFT'] * $this->CurrencyRate : $valueB['MFT'] * $this->CurrencyRate,
								"OT" => ($valueB['TaxBR']['OT']) ? $valueB['TaxBR']['OT'] * $this->CurrencyRate : (($valueB['OT'] + $OtherCharges) * $this->CurrencyRate),
								"YR" =>( $valueB['TaxBR']['YR']) ?  $valueB['TaxBR']['YR'] * $this->CurrencyRate :  $valueB['YR'] * $this->CurrencyRate,
								"CommissionEarned" => $CommissionEarned * $this->CurrencyRate,
								"FixedMarkUp" => ($valueB['FixedMarkUp']) ? $valueB['FixedMarkUp'] * $this->CurrencyRate :0,
								"GSTOnMarkUp" => ($valueB['GSTOnMarkUp']) ? $valueB['GSTOnMarkUp'] * $this->CurrencyRate :0,
								"couponVal" => isset($valueB['couponVal']) ? $valueB['couponVal'] : 0,
								"CommDiscount" => $CommDiscount * $this->CurrencyRate,
								"AgentMarkUp" => isset($valueB['AgentMarkUp']) ? (($valueB['AgentMarkUp'] + $TotalExtraMarkup_) * $this->CurrencyRate) :0
							);
						}
						//print_r($value['FairRules']);
						$CommissionEarned = ($value['FairRules']['CommissionEarned']) ? $value['FairRules']['CommissionEarned'] : 0;
						$TDSEarn = ($value['FairRules']['TDSEarn']) ? $value['FairRules']['TDSEarn'] :0;
						$CommDiscount = ($value['FairRules']['CommDiscount']) ? $value['FairRules']['CommDiscount'] :0;
						$BaseFare_ = ($value['FairRules']['BaseFare']) ? $value['FairRules']['BaseFare'] :0;
						
						$OtherCharges = 0;
						
						$BaseFare_ = ($BaseFare_);
						
						$couponApply = isset($value['FairRules']['couponApply']) ? $value['FairRules']['couponApply'] : 0;
						$couponVal = 0;
						if ($couponApply == 1) {
							$couponVal = isset($value['FairRules']['couponVal']) ? $value['FairRules']['couponVal'] : 0;
						}
						$fareRuless = array(
							"Currency" => $value['FairRules']['Currency'],
							"BaseFare" => (($BaseFare_) * $this->CurrencyRate),
							"Tax" => ($value['FairRules']['Tax']) ? (($value['FairRules']['Tax'] + $OtherCharges) * $this->CurrencyRate) :0,
							"PublishedFare" => ($ICSourceSysId == 7) ? ($value['FairRules']['PublishedFare'] + $TDS) :$value['FairRules']['PublishedFare'],
							"OfferedFare" => ($value['FairRules']['OfferedFare']) ? $value['FairRules']['OfferedFare'] * $this->CurrencyRate:0,
							"CommissionEarned" => $CommissionEarned * $this->CurrencyRate,
							"FixedMarkUp" => ($value['FairRules']['FixedMarkUp']) ? $value['FairRules']['FixedMarkUp'] * $this->CurrencyRate :0,
							"GSTOnMarkUp" => ($value['FairRules']['GSTOnMarkUp']) ? $value['FairRules']['GSTOnMarkUp'] * $this->CurrencyRate :0,
							"CommDiscount" => $CommDiscount * $this->CurrencyRate,
							"couponVal" => isset($value['FairRules']['couponVal']) ? (($value['FairRules']['couponVal'])) : 0,
							"TDSEarn" => ($ICSourceSysId == 7)?($TDSEarn + $TDS):$TDSEarn * $this->CurrencyRate,
							"AgentMarkUp" => ($AgentMarkUp) ? ($AgentMarkUp * $this->CurrencyRate) :0,
							"BagPrice" => 0,//isset($BagPrice)?$BagPrice * $this->CurrencyRate:0,
							"MealPrice" => 0,//isset($MealPrice) ? $MealPrice * $this->CurrencyRate :0,
							"SeatPrice" => 0,//isset($SeatPrice) ? $SeatPrice * $this->CurrencyRate : 0,
							"FareBreakdown" => $FareBreakdown_
						);
						$FLData[$k]['FlightNumber'] = ($value['FlightNumber']) ? $value['FlightNumber'] :'';
						$FLData[$k]['AirlineName'] = $value['AirlineName'];
						$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'] = (isset($value['SearchTraceId']) && !empty($value['SearchTraceId'])) ? $value['SearchTraceId'] : $value['SearchFlightTraceId'];
						$FLData[$k]['ApiResultIndex'] = $value['ApiResultIndex'];
						$FLData[$k]['JourneyType'] = $value['JourneyType'];
						$FLData[$k]['TripType'] = intval($value['TripType']);
						$FLData[$k]['IsRefundable'] = ($value['IsRefundable']) ? $value['IsRefundable'] :false;
						$FLData[$k]['IsInternational'] = ($value['IsInternational']) ? $value['IsInternational'] :0;
						$FLData[$k]['SourceAirportCode'] = $value['SourceAirportCode'];
						$FLData[$k]['DestAirportCode'] = $value['DestAirportCode'];
						$FLData[$k]['FairRules'] = $fareRuless;
						$FLData[$k]['Segments'] = $segment_;
						// echo "FlightNumber == ".$value['FlightNumber'];
						// echo "FLData<pre>";print_r($FLData);die;
						$TotalAmount_ = ($GrossAmount + $BagPrice + $MealPrice + $SeatPrice);

						$ItineraryFlightsInfo[$k]['Token'] = $value['Token'];
						$ItineraryFlightsInfo[$k]['FlighstInfo'] = $FlighstInfo;
						$ItineraryFlightsInfo[$k]['PaymentMode'] = 'T';
						$ItineraryFlightsInfo[$k]['PaymentInfo'] = [['TotalAmount'=>$TotalAmount_]];
						if(!empty($BaggSSRInfo)){
							$ItineraryFlightsInfo[$k]['BaggSSRInfo'] = $BaggSSRInfo;
						}
						if(!empty($MealsSSRInfo)){
							$ItineraryFlightsInfo[$k]['MealsSSRInfo'] = $MealsSSRInfo;
						}
						if(!empty($SeatsSSRInfo)){
							$ItineraryFlightsInfo[$k]['SeatsSSRInfo'] = $SeatsSSRInfo;
						}
						//print_r($value['FairRules']);
						
						// $BaseFare += $value['FairRules']['BaseFare'] + $value['FairRules']['Tax'];
						// if($ICSourceSysId == 7){
						// 	$PublishedFare += (((float)$value['FairRules']['PublishedFare'] - $couponVal) + (float)$TDS);
						// 	$CommissionEarnedAPI += ($value['FairRules']['CommissionEarned'] + $value['FairRules']['TDSEarn']);
						// }else{
						// 	$PublishedFare += $value['FairRules']['PublishedFare'];
						// 	$CommissionEarnedAPI += ($value['FairRules']['CommissionEarned'] + $value['FairRules']['TDSEarn']);
						// }
						$BaseFare += (($value['FairRules']['BaseFare'] + $value['FairRules']['Tax']) - $couponVal);
						$PublishedFare += ($value['FairRules']['PublishedFare'] - $couponVal);
					}
					
				}
				// if ($route == 2 && $interNationalSearch == 1) {
					$TripCount = 1;
				// } else {
				// 	$TripCount = count($BookingData);
				// }
				$customer = [];
				$BagPrice = 0;
				$MealPrice = 0;
				$SeatPrice = 0;

				$A = 1;
				$C = 1;
				$I = 1;
				$SelectedBag = [];
				$SelectedMeal = [];
				$SelectedSeat = [];
				foreach($ForCustomerSession as $ck=>$ValCustomer){
					if($ck == 0){
						$CustomerSysId = $ValCustomer['CustomerSysId'];
					}else{
						$CustomerSysId = $ValCustomer['CustomerMemberSysId'];
					}
					
					if ($ValCustomer['paxType'] == 1) {
						$paxType = 'ADULT' . $A;
						$A++;
					} elseif ($ValCustomer['paxType'] == 2) {
						$paxType = 'CHILD' . $C;
						$C++;
					} else {
						$paxType = 'INFANT' . $I;
						$I++;
					}
					$SelectedBag__ = [];
					$SelectedMeal__ = [];
					$SelectedSeat__ = [];
					$pk = $ck;
					$BagPrice_c = 0;
					$MealPrice_c = 0;
					$SeatPrice_c = 0;
					
					if($selectedSeatSession->params && ($CustomerSession->params[$pk]['paxType'] == 1 || $CustomerSession->params[$pk]['paxType'] == 2)){
							foreach ($selectedSeatSession->params as $keySeg => $valueSeat) {
								if($ICSourceSysId == 7){
									$segmentData = isset($segArray[$keySeg]) ? $segArray[$keySeg] : [];
									$Orgin = $segmentData['originAirportCode'];
									$Destination = $segmentData['destinationAirportCode'];
								}
								$SeatSession = isset($valueSeat[$ck+1])?[$valueSeat[$ck+1]]:[];
								foreach ($SeatSession as $ValSeat) {
									if($ICSourceSysId != 7){
										$Orgin = $ValSeat['Origin'];
										$Destination = $ValSeat['Destination'];
									}

									if(!empty($Orgin) && !empty($Destination)){
										$ValSeat['key'] = $keySeg;
										$SelectedSeat[$Orgin.'-'.$Destination][] = $ValSeat;
										$SeatPrice += $ValSeat['amount'];
										$SeatPrice_c += $ValSeat['amount'];
									}
								}
						}
					}
					
					$CheckinBaggage = isset($baggageByPax[$ValCustomer['paxType']]['Baggage']) ? $baggageByPax[$ValCustomer['paxType']]['Baggage'] : '';
					$CabinBaggage = isset($baggageByPax[$ValCustomer['paxType']]['CabinBaggage']) ? $baggageByPax[$ValCustomer['paxType']]['CabinBaggage'] : '';
					if($ValCustomer['paxType'] != 3){
						foreach($segmentArray as $sgvl){
							// if($SelectedBag[$sgvl][$pk]){
							// 	$SelectedBag__[$sgvl][0] = $SelectedBag[$sgvl][$pk];
							// }
							// if($SelectedMeal[$sgvl][$pk]){
							// 	$SelectedMeal__[$sgvl][0] = $SelectedMeal[$sgvl][$pk];
							// }
							if($SelectedSeat[$sgvl][$pk]){
								$SelectedSeat__[$sgvl][0] = $SelectedSeat[$sgvl][$pk];
							}
						}
					}
					$arry_salutaion_com = $this->arry_salutaion_com();
					$title = $arry_salutaion_com[$ValCustomer['Salutation']];
					$getSelectedAddon = $this->getSelectedAddon($selectedBagAR, $selectedMealAR, $paxType, $BaggageArr, $MealArr);
			
					$paxTypeBag = (isset($getSelectedAddon['paxTypeBag']) && !empty($getSelectedAddon['paxTypeBag'])) ? $getSelectedAddon['paxTypeBag'] : [];
					$paxTypeMeal = (isset($getSelectedAddon['paxTypeMeal']) && !empty($getSelectedAddon['paxTypeMeal'])) ? $getSelectedAddon['paxTypeMeal'] : [];
					$BagPrice_c = (isset($getSelectedAddon['BagPrice']) && !empty($getSelectedAddon['BagPrice'])) ? $getSelectedAddon['BagPrice'] : 0;
					$MealPrice_c = (isset($getSelectedAddon['MealPrice']) && !empty($getSelectedAddon['MealPrice'])) ? $getSelectedAddon['MealPrice'] : 0;
					$BagPrice += $BagPrice_c;
					$MealPrice += $MealPrice_c;
					$docid = isset($ValCustomer['docid']) ? $ValCustomer['docid'] : '';
					
					$customer[] = array(
						"city_id" => $ValCustomer['CitySysId'],
						"country_id" => $ValCustomer['CountrySysId'],
						"countryName" => isset($ValCustomer['countryName']) ? $ValCustomer['countryName'] : '',
						"city" => $ValCustomer['CityTitle'],
						"airline_number" => (int)$ValCustomer['Contacts'],
						"airline_email" =>  $ValCustomer['EmailId'],
						"docid" => $docid,
						"address" => $ValCustomer['Address'],
						"email" => $ValCustomer['EmailId'],
						"mobile" => (int)$ValCustomer['Contacts'],
						"title" => $title,
						"countryCode" => $ValCustomer['countryCode'],
						"countryCodeISO" => $ValCustomer['countryCodeISO'],
						"relation" =>  9,//$ValCustomer['Relation'],
						"firstname" => $ValCustomer['FirstName'],
						"lastname" => $ValCustomer['LastName'],
						"salution" => (int)$ValCustomer['Salutation'],
						"dateofbirth" => $ValCustomer['DOB'],
						"passportnoexpiry" => isset($ValCustomer['PassportExpiry']) ? $ValCustomer['PassportExpiry'] :'',
						"passporIssue" => isset($ValCustomer['passporIssue'])? $ValCustomer['passporIssue']:'',
						"PassportNationality" => isset($ValCustomer['PassportNation']) ? $ValCustomer['PassportNation']:'',
						"passportno" => isset($ValCustomer['PassportNo']) ? $ValCustomer['PassportNo']:'',
						"paxType" => (int)$ValCustomer['paxType'],
						"isgstapply" => $isgstapply,
						"sectors" => isset($ValCustomer['sectors']) ? $ValCustomer['sectors'] :'',
						"CheckinBaggage" => isset($CheckinBaggage) ? $CheckinBaggage:'',
						"CabinBaggage" => isset($CabinBaggage) ? $CabinBaggage :'',
						"BagPrice" => (!empty($BagPrice_c)) ? ($BagPrice_c / $TripCount) : $BagPrice_c,
						"MealPrice" => (!empty($MealPrice_c)) ? ($MealPrice_c / $TripCount) : $MealPrice_c,
						"SeatPrice" => (!empty($SeatPrice_c)) ? ($SeatPrice_c / $TripCount) : $SeatPrice_c,

						"SelectedBag" => (!empty($paxTypeBag)) ? json_encode($paxTypeBag) : '',
						"SelectedMeal" => (!empty($paxTypeMeal)) ? json_encode($paxTypeMeal) : '',
						"SelectedSeat" => (!empty($SelectedSeat__))? json_encode($SelectedSeat__) :'',

						// "companyname" => (isset($companyname) && !empty($companyname)) ? $companyname : '',
						// "gstnnumber" => (isset($gstnnumber) && !empty($gstnnumber)) ? $gstnnumber : '',
						// "gstaddress" => (isset($gstaddress) && !empty($gstaddress)) ? $gstaddress : '',
						// "gstemail" => (isset($gstemail) && !empty($gstemail)) ? $gstemail : '',
						// "gststate" => (isset($gststate) && !empty($gststate)) ? $gststate : '',
						// "gstphone" => (isset($gstphone) && !empty($gstphone)) ? (int)$gstphone : 0,
					);
					
					$ForCustomerSession[$ck] = $ValCustomer;
				}
				$TripCount = count($BookingData);
				$FLDataNew = [];
				if($FLData){
					foreach($FLData as $kfl=>$vlfl){
						$vlfl['FairRules']['BagPrice'] = round($BagPrice / $TripCount,2);
						$vlfl['FairRules']['MealPrice'] = round($MealPrice / $TripCount,2);
						$vlfl['FairRules']['SeatPrice'] = round($SeatPrice / $TripCount,2);
						$FLDataNew[$kfl] = $vlfl;
					}
				}
				$FlightBookingDataRiya = array(
					"FlightBookingData" => $FLDataNew,
					"customer" => $customer,
					"roominfojson" => $roomjson,
					"Cities" => ($route == 3)?implode(',',$oneway_origin_text).'-'.implode(',',$oneway_destination_text):$oneway_origin_text.'-'.$oneway_destination_text,
					"IsHotelFromApi" => 1,
					"ICSourceSysId" => $ICSourceSysId,
					'AgencySysId' => $this->gtxagencysysid,
					'AgentSysId' => $this->gtxagentsysid,
					"SourcePlaces" => ($route == 3)?current($oneway_origin_text):$oneway_origin_text,
					"DestinationPlaces" => ($route == 3)?current($oneway_destination_text):$oneway_destination_text,
					"SourcePlaceSysId" => ($route == 3)?current($sourceCityId):$sourceCityId,
					"DestinationPlacesSysId" => ($route == 3)?current($destinationCityId):$destinationCityId,
					"BaseAmount" => $BaseFare + $BagPrice + $MealPrice + $SeatPrice,
					"PublishedFare" => $PublishedFare + $BagPrice + $MealPrice + $SeatPrice,
					"AgencyMarkUp" => $AgencyMarkUpINT_,
					"AgencyMarkUpGST" => $AgencyMarkUpGSTINT_,
					"AgentCommisionEarned" => $CommissionEarnedAPI,
					"AgentCommisionEarnedGST" => 0,
					"adults" => $adultCount,
					"childs" => $childCount,
					"infants" => $infantCount,
					"route" => $route,
					"email" => $leadEmail,
					"mobile" => (string)$leadMobile,
					'IsB2BQuery' => false,
					'B2BAgentSysId' => 0,
					'B2BAgencySysId' => 0,
					'leadsource' => 'Website',
					'IsB2BProposal' => 0,
					'BillingType' => 0,
					'IsNewMigration' => 3,
					'ExchangeCurrencyRate' => $this->CurrencyRate
				);
				if ($isgstapply == 1) {
					$FlightBookingDataRiya['gstData'] = $gstData;
				}
				// if ($this->gtxagencysysid == '110804') {
					
					// echo "PublishedFare<pre>";print_r(($PublishedFare));
					// echo "PublishedFare<pre>";print_r(($BagPrice));
					// echo "PublishedFare<pre>";print_r(($MealPrice));
					// echo 'FlightBookingDataRiya<pre>';print_r(json_encode($FlightBookingDataRiya));
					
				// }
			//   die('ddddd'); 
				// 

				$strFilePath = "flight/FlightQueryids/" . $post['traceId'] . "/__request.json";
				Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($FlightBookingDataRiya));
				
				$model = new Gtxwebservices_Model_Webservices();
				$result = $model->GENERATE_FLIGHT_QUERY($FlightBookingDataRiya);
				$strFilePath = "flight/FlightQueryids/" . $post['traceId'] . "/response.json";
				Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, ($result));
				
				$FlightQueryids = json_decode($result,true);
				Zend_Session::namespaceUnset('ResponseFlightQuery');
				$ResponseFlightQuery = new Zend_Session_Namespace('ResponseFlightQuery');
				$ResponseFlightQuery->params = $FlightQueryids;
				$CustomerSysIdGTX = isset($FlightQueryids['arrIds']['CustomerSysId']) ? $FlightQueryids['arrIds']['CustomerSysId'] : '';
				if ($apiCustomer['status'] == 1) {
					$arrCustomer['GTX_customerSysId'] = $CustomerSysIdGTX;
					$where = "CustomerSysId = " . $CustomerSysId;
					$objFlight->UpdateFlightData('tbl_customer', $arrCustomer, $where);
				}
				$genrateFlightQuery = $FlightQueryids;
				$queryStatus = isset($FlightQueryids['status']) ? $FlightQueryids['status'] : 0;
				if ($queryStatus == 0) {
					
					$response = array('succes' => false, 'msg' => 'This booking is not processed. Please contact to administrator.', 'index' => '');
					echo json_encode($response);
					exit;
				}
				$arrUrlData['FlightBookingDataRiya'] = $FlightBookingDataRiya;
				$arrUrlData['genrateFlightQuery'] = $genrateFlightQuery;
				$arrUrlData['isgstapply'] = $isgstapply;
				$arrUrlData['gstData'] = $gstData;
				$arrUrlData['post'] = $post;
				
				$tempData = array(
					'TraceId' => $post['traceId'],
					'json_data' => json_encode($arrUrlData),
				);
				$objFlight->deleteFlightTempData($post['traceId']);
				$objFlight->insertFlightTempData($tempData);
				// echo "arrUrlData<pre>";print_r(json_encode($arrUrlData));die;
				$CustomerSession->params = $CustomerData;
				$response = array('success' => true, 'msg' => 'Done', 'apiTraceId' => $traceId);
				echo json_encode($response);
				exit;
				

			}
			// $model = new Gtxwebservices_Model_Webservices();
			// $apiData['memberDetailArray'] = json_encode(array_values($apiDataMember));
			// $result = $model->CreateCustomer($apiData);
			// $apiCustomer = json_decode($result, true);
			// if ($apiCustomer['status'] == 1) {
			// 	$arrCustomer['GTX_customerSysId'] = $apiCustomer['Message'];
			// 	$where = "CustomerSysId = " . $CustomerSysId;
			// 	$objFlight->UpdateFlightData('tbl_customer', $arrCustomer, $where);
			// }
			// $post['apiCustomer'] = $apiCustomer;
			// $genrateFlightQuery = $this->genrateFlightQuery($post);

			// $queryStatus = isset($genrateFlightQuery['status']) ? $genrateFlightQuery['status'] : 0;
			// if ($queryStatus == 0) {
			// 	// $this->objMdl->rv_delete('tbl_customer', array('apiTraceId = ?' => $post['traceId']));
			// 	// $this->objMdl->rv_delete('tbl_customer_member', array('apiTraceId = ?' => $post['traceId']));

			// 	// $this->objMdl->rv_delete('tbl_flight_booking', array('apiTraceId = ?' => $post['traceId']));
			// 	// $this->objMdl->rv_delete('tbl_flight_booking_customer', array('apiTraceId = ?' => $post['traceId']));

			// 	$response = array('succes' => false, 'msg' => 'This booking is not processed. Please contact to administrator.', 'index' => '');
			// 	echo json_encode($response);
			// 	exit;
			// }
			// $arrUrlData['genrateFlightQuery'] = $genrateFlightQuery;
			$arrUrlData['genrateFlightQuery'] = $genrateFlightQuery;
			$arrUrlData['post'] = $post;
			$tempData = array(
				'TraceId' => $post['traceId'],
				'json_data' => json_encode($arrUrlData),
			);
			$objFlight->deleteFlightTempData($post['traceId']);
			$objFlight->insertFlightTempData($tempData);
			$CustomerSession->params = $CustomerData;
			$response = array('success' => true, 'msg' => 'Done', 'apiTraceId' => $traceId);
			echo json_encode($response);
			exit;
		}
	}

	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 saveNewTravAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$post = $this->getRequest()->getPost();

			if (isset($post['Form']) && $post['Form'] == 'Form') {
				$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
				$interNationalSearch = $sessionFlightSearchParams->params['interNationalSearch'];
				$html = new Zend_View();
				$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/template7/');
				$html->assign(array('paxType' => $post['paxType'], 'relation' => $post['relation_new'], 'interNationalSearch' => $interNationalSearch));
				$bodyText = $html->render('addnewpaxform.phtml');
				$response = array('success' => true, 'message' => 'Done', 'html' => $bodyText);
				echo json_encode($response);
				exit;
			} else {
				$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
				$class = $sessionFlightSearchParams->params['class'];
				$interNationalSearch = $sessionFlightSearchParams->params['interNationalSearch'];
				$departureDates = $sessionFlightSearchParams->params['departure_date'];

				if (!empty($departureDates)) {
					$arrDepartureDates = explode("/", $departureDates);
					$departureDatesAD = $arrDepartureDates[2] . "-" . $arrDepartureDates[1] . "-" . $arrDepartureDates[0];
				}
				$paxType     = isset($post['paxType']) ? $post['paxType'] : '0';
				$leadMobile     = isset($post['leadMobile']) ? $post['leadMobile'] : '';
				$leadEmail      = isset($post['leadEmail']) ? $post['leadEmail'] : '';
				$firstName      = isset($post['firstname']) ? $post['firstname'] : '';
				$lastName      = isset($post['lastname']) ? $post['lastname'] : '';
				$relation      = isset($post['relation']) ? $post['relation'] : '0';
				$salution      = isset($post['salution']) ? $post['salution'] : '0';
				$countryCode      = isset($post['countryCode']) ? $post['countryCode'] : '0';
				$passengerPassportNo = isset($post['passportno']) ? $post['passportno'] : '';
				$passengerPassportExpiry = isset($post['passportnoexpiry']) ? $post['passportnoexpiry'] : '00/00/0000';
				$getSalutation = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getSalutationByid($salution);
				if (!empty($passengerPassportExpiry)) {
					$passengerPassportExpiry = explode("/", $passengerPassportExpiry);
					$passengerPassportExpiry = $passengerPassportExpiry[2] . "" . $passengerPassportExpiry[1] . "" . $passengerPassportExpiry[0];
				}
				if (empty(trim($leadMobile))) {
					$response = array('succes' => false, 'msg' => 'Please enter lead pax mobile.', 'index' => 'leadMobile');
					echo json_encode($response);
					exit;
				}
				if (empty(trim($leadEmail))) {
					$response = array('succes' => false, 'msg' => 'Please enter lead pax email id.', 'index' => 'leadEmail');
					echo json_encode($response);
					exit;
				}
				if (empty(trim($firstName))) {
					$response = array('succes' => false, 'msg' => 'Please fill out first name.', 'index' => 'firstname_');
					echo json_encode($response);
					exit;
				}
				if (empty(trim($lastName))) {
					$response = array('succes' => false, 'msg' => 'Please fill out last name.', 'index' => 'lastname_');
					echo json_encode($response);
					exit;
				}
				if (isset($post['dateofbirth']) && !empty($post['dateofbirth'])) {
					$dateofbirth = explode('/', $post['dateofbirth']);
					$dobday = $dateofbirth[0];
					$dobmonth = $dateofbirth[1];
					$dobyear = $dateofbirth[2];
					$passengerDob = $dobyear . '-' . $dobmonth . '-' . $dobday;
				} elseif ($interNationalSearch == 1) {
					$response = array('succes' => false, 'msg' => 'Please fill out date of birth.', 'index' => 'dob_');
					echo json_encode($response);
					exit;
				} elseif ($interNationalSearch == '' && $paxType != 1) {
					$response = array('succes' => false, 'msg' => 'Please fill out date of birth.', 'index' => 'dob_');
					echo json_encode($response);
					exit;
				}
				if (!empty($paxType) && $paxType == 1 && $interNationalSearch == 1) {
					$AdultAge = date_diff(date_create($passengerDob), date_create($departureDatesAD))->y;
					if ($AdultAge < 12) {
						$response = array('succes' => false, 'msg' => "Adult age should be greater than 12 years. ", 'index' => 'dob_');
						echo json_encode($response);
						exit;
					}
				}
				if (!empty($paxType) && $paxType == 2) {
					$childAge = date_diff(date_create($passengerDob), date_create($departureDatesAD))->y;
					if ($childAge < 2 || $childAge >= 12) {
						$response = array('succes' => false, 'msg' => "Child age should be 2 years or less than 12 years. ", 'index' => 'dob_');
						echo json_encode($response);
						exit;
					}
				}
				if (!empty($paxType) && $paxType == 3) {
					$infantAge = date_diff(date_create($passengerDob), date_create($departureDatesAD))->y;
					if ($infantAge >= 2) {
						$response = array('succes' => false, 'msg' => "Infant age should be less than 2 years. ", 'index' => 'dob_');
						echo json_encode($response);
						exit;
					}
				}
				if ($interNationalSearch == 1) {
					if (empty(trim($passengerPassportNo))) {
						$response = array('succes' => false, 'msg' => 'Please enter Passport No.', 'index' => 'passportno_');
						echo json_encode($response);
						exit;
					}
					if (empty($passengerPassportExpiry) && $passengerPassportExpiry != '0000-00-00') {
						$response = array('succes' => false, 'msg' => 'Please enter Passport Expiry.', 'index' => 'passportnoexpiry_');
						echo json_encode($response);
						exit;
					}
					$expiry_date = date_diff(date_create($passengerPassportExpiry), date_create($departureDatesAD))->y;
					if ($expiry_date <= 1 / 2) {
						$response = array('succes' => false, 'msg' => "Passenger Passport should have at least six months of validity from the date of travel.", 'index' => 'passportnoexpiry_');
						echo json_encode($response);
						exit;
					}
				}
				$param = array(
					'leadMobile' => $post['leadMobile'],
					'leadEmail' => $post['leadEmail']
				);
				$objFlight = new Travel_Model_FlightMaster();
				$tbl_customer = $objFlight->SearchFlightCustomer('tbl_customer', $param);
				$arrCustomer =  array(
					'AgencySysId' => $this->gtxagencysysid,
					'EmailId' => $leadEmail,
					'Salutation' => $salution,
					'Gender_Id' => $getSalutation['Gender_Id'],
					'Relation' => $relation,
					'Contacts' => $leadMobile,
					'FirstName' => $firstName,
					'LastName' => $lastName,
					'Password' => '',
					'IsPswExpire' => 0,
					'CreatedByUserSysId' => $this->gtxagencysysid,
					'paxType' => $paxType,
					'StateOrZoneSysId' => 0,
					'CountrySysId' => 0,
					'countryCode' => $countryCode,
					'RegisterDate' => date('Y-m-d H:i:s'),
					'IsApproved' => 0,
					'IsActive' => 1,
					'IsMarkForDel' => '0',
				);
				$arrCustomer['DOB'] =  $passengerDob;


				if ($interNationalSearch == 1) {
					$arrCustomer['DOB'] =  $passengerDob;
					$arrCustomer['PassportNo'] =  ($interNationalSearch == 1) ? $passengerPassportNo : '';
					$arrCustomer['PassportExpiry'] = ($interNationalSearch == 1) ? $passengerPassportExpiry : '';
				}
				if (empty($tbl_customer)) {
					$arrCustomer['apiTraceId'] = $post['TraceId'];
					$arrCustomer['modified'] = date('Y-m-d H:i:s');
					$arrCustomer['created'] = date('Y-m-d H:i:s');
					$CustomerSysId = $objFlight->InsertFlightData('tbl_customer', $arrCustomer);
				} else {
					$arrCustomer['CustomerSysId'] = $tbl_customer[0]['CustomerSysId'];
					$arrCustomer['apiTraceId'] = $post['TraceId'];
					$arrCustomer['modified'] = date('Y-m-d H:i:s');
					$arrCustomer['created'] = date('Y-m-d H:i:s');
					$CustomerSysId = $objFlight->InsertFlightData('tbl_customer_member', $arrCustomer);
				}
				if ($CustomerSysId) {
					$response = array('success' => true, 'msg' => 'Save successfully done.', 'CId' => $CustomerSysId);
					echo json_encode($response);
					exit;
				} else {
					$response = array('success' => false, 'msg' => 'Unable to save please try again.');
					echo json_encode($response);
					exit;
				}
			}
		} else {
			die('Invalid request');
		}
	}
	public function calculateDiff($departureDate, $ExpirtyDate)
	{
		$date1 = strtotime($departureDate);
		$date2 = strtotime($ExpirtyDate);
		// Formulate the Difference between two dates
		$diff = abs($date2 - $date1);
		$years = floor($diff / (365 * 60 * 60 * 24));
		$months = floor(($diff - $years * 365 * 60 * 60 * 24) / (30 * 60 * 60 * 24));
		$days = floor(($diff - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 * 24) / (60 * 60 * 24));
		return abs((date('Y', $date2) - date('Y', $date1)) * 12 + (date('m', $date2) - date('m', $date1)));
		//return ['years' => $years, 'months' => $months, 'days' => $days];
	}

	public function get_months_between_dates(string $start_date, string $end_date)
	{
		$startDate = $start_date instanceof Datetime ? $start_date : new DateTime($start_date);
		$endDate = $end_date instanceof Datetime ? $end_date : new DateTime($end_date);
		$interval = $startDate->diff($endDate);
		$months = ($interval->y * 12) + $interval->m;

		return $startDate > $endDate ? -$months : $months;
	}

	public function InsertFlightBookingCustomer($data, $arrmembersId, $arrPlain)
	{
		$objFlight = new Travel_Model_FlightMaster();
		$flight_booking_customer = [];
		$i = 0;
		//echo '<pre>';print_r($arrPlain['FairRules']);die;
		if ($data) {
			foreach ($data as $k => $value) {
				$baggage = $arrPlain['FairRules']['FareBreakdown'][$k];
				$paxType = ($value['paxType'] - 1);
				$baggInfo = isset($arrPlain['FairRules']['FareBreakdown'][$paxType]) ? $arrPlain['FairRules']['FareBreakdown'][$paxType] : '';
				// echo '<pre>';print_r($baggInfo);
				$arrCustomerMembers = array(
					'AgencySysId' => $this->gtxagencysysid,
					'CustomerSysId' => $arrmembersId[$i],
					'apiTraceId' => !empty($arrPlain['SearchFlightTraceId']) ? $arrPlain['SearchFlightTraceId'] : '',
					'JourneyType' => !empty($arrPlain['JourneyType']) ? $arrPlain['JourneyType'] : 0,
					'EmailId' => $value['EmailId'],
					'Salutation' => $value['Salutation'],
					'Relation' => $value['Relation'],
					'Contacts' => $value['Contacts'],
					'FirstName' => $value['FirstName'],
					'LastName' => $value['LastName'],
					'Password' => $value['Password'],
					'IsPswExpire' => $value['IsPswExpire'],
					'CreatedByUserSysId' => $value['CreatedByUserSysId'],
					'DOB' => $value['DOB'],
					'PassportNo' => $value['PassportNo'],
					'PassportNation' => $value['PassportNation'],
					'PassportExpiry' => $value['PassportExpiry'],
					'passporIssue' => $value['passporIssue'],
					'Address' => $value['Address'],
					'CityTitle' => $value['CityTitle'],
					'CitySysId' => !empty($value['CitySysId']) ? $value['CitySysId'] : 0,
					'paxType' => $value['paxType'],
					'StateOrZoneSysId' => $value['StateOrZoneSysId'],
					'CountrySysId' => !empty($value['CountrySysId']) ? $value['CountrySysId'] : 0,
					'countryCode' => $value['countryCode'],
					'companyname' => $value['companyname'],
					'gstnnumber' => $value['gstnnumber'],
					//'Baggage' => !empty($arrPlain['FairRules']['Baggage']) ? $arrPlain['FairRules']['Baggage'] : '',
					//'CabinBaggage' => !empty($arrPlain['FairRules']['CabinBaggage']) ? $arrPlain['FairRules']['CabinBaggage'] : '',
					'RegisterDate' => date('Y-m-d-H-i-s'),
					'IsApproved' => 0,
					'IsActive' => 1,
					'IsMarkForDel' => '0',
				);

				$arrCustomerMembers['Baggage'] = !empty($baggInfo['Baggage']) ? $baggInfo['Baggage'] : '';
				$arrCustomerMembers['CabinBaggage'] = !empty($baggInfo['CabinBaggage']) ? $baggInfo['CabinBaggage'] : '';
				$flight_booking_customer[$k] = $objFlight->InsertFlightData('tbl_flight_booking_customer', $arrCustomerMembers);
				$i++;
			}
			return $flight_booking_customer;
		}
	}

	public function CreateInternationDataArr($BookingData, $CustomerSysId)
	{
		$arrPlanAir = [];
		$arrPlanAirDes = [];
		$url = $this->baseUrl . "public/data/dynamic/flight_destinations.json";
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		$str = curl_exec($ch);
		//        $str = file_get_contents($this->baseUrl . 'public/data/dynamic/flight_destinations.json');
		$Destinationjson = json_decode($str, true);
		$arrCurrencyList = $this->getCurrencyIdsAndSymbolList();
		$arrAirlineList = $this->getAirlineIdsAndCodeList();
	
		if ($BookingData) {
			foreach ($BookingData as $k => $val) {
				$value = $val['origin'];
				if($val['ICSourceSysId'] == 16 || $val['ICSourceSysId'] == 17){
					$value['OrFlightNumber'] = $value['FlightNumber'];
					$value['TravelDate'] = date('Y-m-d', strtotime($value['FromUTCTime']));
				}
				$filterByFrom = $value['SourceAirportCode'];
				$filterByTo = $value['DestAirportCode'];
				$arrSourceCityId_ = array_filter($Destinationjson, function ($var) use ($filterByFrom) {
					return ($var['AirportCode'] == $filterByFrom);
				});

				$arrdestinationCityId_ = array_filter($Destinationjson, function ($var) use ($filterByTo) {
					return ($var['AirportCode'] == $filterByTo);
				});
				$Currency = isset($value['FairRules']['Currency']) ? $value['FairRules']['Currency'] :'INR';
				$currencySysId = !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
				$arrSourceCityId = array_values($arrSourceCityId_);
				$arrdestinationCityId = array_values($arrdestinationCityId_);
				if(isset($value['Segments'])){
					if (count($value['Segments']) > 1) {
						$IsDirect = '1';
					} else {
						$IsDirect = '0';
					}
				}
				$FlyingMinutes = 0;
				if(isset($value['Segments'])){
					if (count($value['Segments']) > 0) {
						foreach ($value['Segments'] as $segmentsResult) {
							$FlyingMinutes = $FlyingMinutes + ((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0) + (!empty($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : 0)));
						}
					}
				}
				// echo "<pre>";print_r($value);die;
				if(isset($value['Segments'][0]['AirlineCode']) && isset($arrAirlineList[$value['Segments'][0]['AirlineCode']])){
					$airlineSysId = !empty($arrAirlineList[$value['Segments'][0]['AirlineCode']]) ? $arrAirlineList[$value['Segments'][0]['AirlineCode']] : '0';
				}
				$arrPlanAir['AgencySysId'] = isset($this->gtxagencysysid) ? $this->gtxagencysysid :0;
				$arrPlanAir['CustomerSysId'] = ($CustomerSysId) ? $CustomerSysId :'';
				$arrPlanAir['FlightNumber'] = !empty($value['OrFlightNumber'])?$value['OrFlightNumber']:$value['FlightNumber'];
				$arrPlanAir['ICSourceSysId'] = isset($val['ICSourceSysId']) ? $val['ICSourceSysId'] :'';
				$arrPlanAir['AirlineName'] = isset($value['AirlineName']) ? $value['AirlineName'] :'';
				$arrPlanAir['TravelDate'] = isset($value['TravelDate'])?$value['TravelDate']:date('Y-m-d',strtotime($value['FromUTCTime']));
				$arrPlanAir['IsLCC'] = isset($value['IsLCC']) ? $value['IsLCC'] :false;
				$arrPlanAir['IsRefundable'] = isset($value['IsRefundable']) ? (int)$value['IsRefundable'] : 0;
				$arrPlanAir['apiTraceId'] = isset($val['SearchFlightTraceId']) ? $val['SearchFlightTraceId'] :'';
				$arrPlanAir['AirlineSysId'] = isset($airlineSysId) ? $airlineSysId:'';
				$arrPlanAir['DepartureTime'] = isset($value['DepartureTime']) ? $value['DepartureTime']:'';
				$arrPlanAir['ArrivalTime'] = isset($value['ArrivalTime']) ? $value['ArrivalTime']:'';
				$arrPlanAir['IsDirect'] = isset($IsDirect) ? (int)$IsDirect:0;
				$arrPlanAir['FareClass'] = isset($value['FareClass']) ? $value['FareClass']:'';
				$arrPlanAir['FlyingMinutes'] = isset($FlyingMinutes) ? $FlyingMinutes:'';
				$arrPlanAir['FlightDuration'] = isset($value['FlightDuration']) ? $value['FlightDuration']:'';
				$arrPlanAir['SourcePlaceSysId'] = isset($arrSourceCityId[0]['CityID']) ? $arrSourceCityId[0]['CityID']:'';
				$arrPlanAir['DestPlaceSysId'] = isset($arrdestinationCityId[0]['CityID']) ? $arrdestinationCityId[0]['CityID']:'';
				$arrPlanAir['SourceAirportCode'] = isset($value['SourceAirportCode']) ? $value['SourceAirportCode']:'';
				$arrPlanAir['DestAirportCode'] = isset($value['DestAirportCode']) ? $value['DestAirportCode']:'';
				$arrPlanAir['StopCount'] = isset($value['StopCount']) ? $value['StopCount']:'';
				$arrPlanAir['TotalFlightMembers'] = isset($value['TotalFlightMembers'])?$value['TotalFlightMembers']:0;
				$arrPlanAir['CurrencyType'] = isset($this->CurrencyId) ? $this->CurrencyId:'';
				$arrPlanAir['PublishedFare'] = isset($val['FairRules']['PublishedFare']) ? $val['FairRules']['PublishedFare'] :0;
				$arrPlanAir['ApiResultIndex'] = ($val['ICSourceSysId'] != 3) ? $val['FairRules']['PriceID'] :'';
				$arrPlanAir['JourneyType'] = isset($value['JourneyType'])?$value['JourneyType']:1;
				$arrPlanAir['TripType'] = isset($value['TripType'])?$value['TripType']:1;
				$arrPlanAir['IsInternational'] = isset($value['IsInternational']) ? $value['IsInternational'] : 0;
				$arrPlanAir['logo'] = isset($value['logo']) ? $value['logo'] :'';
				$arrPlanAir['Currency'] = isset($this->CurrencyTitle) ? $this->CurrencyTitle:'INR';
				$arrPlanAir['BaseFare'] = isset($val['FairRules']['BaseFare']) ? $val['FairRules']['BaseFare'] :0;
				$arrPlanAir['Tax'] = isset($val['FairRules']['Tax']) ? $val['FairRules']['Tax']:0;
				$arrPlanAir['YQTax'] = isset($val['FairRules']['YQTax']) ? $val['FairRules']['YQTax'] :0;
				$arrPlanAir['OtherCharges'] = isset($val['FairRules']['OtherCharges']) ? $val['FairRules']['OtherCharges'] :0;
				$arrPlanAir['Discount'] = isset($val['FairRules']['Discount']) ? $val['FairRules']['Discount'] :0;
				$arrPlanAir['ServiceFee'] = isset($val['FairRules']['ServiceFee']) ? $val['FairRules']['ServiceFee'] :0;
				$arrPlanAir['OfferedFare'] = isset($val['FairRules']['PublishedFare']) ? $val['FairRules']['PublishedFare'] :0;
				$arrPlanAir['OfferedFare'] = isset($val['FairRules']['PublishedFare']) ? $val['FairRules']['PublishedFare'] :0;
				$arrPlanAir['AgentCommisionEarned'] = isset($val['FairRules']['CommEarned']) ? $val['FairRules']['CommEarned'] : $val['FairRules']['CommissionEarned'];
				$arrPlanAir['AgentCommisionEarnedGST'] = isset($val['FairRules']['GSTonComm']) ? $val['FairRules']['GSTonComm'] : 0;
				$arrPlanAir['AgencyMarkUp'] = isset($val['FairRules']['FixedMarkUp']) ? $val['FairRules']['FixedMarkUp'] : 0;
				$arrPlanAir['AgencyMarkUpGST'] = isset($val['FairRules']['GSTOnMarkUp']) ? $val['FairRules']['GSTOnMarkUp'] : 0;
				$arrPlanAir['GTXMarkUp'] = isset($val['FairRules']['intGTXMarkUp']) ? $val['FairRules']['intGTXMarkUp'] : 0;
				$arrPlanAir['GTXMarkUpGST'] = isset($val['FairRules']['GTXMarkUpGST']) ? $val['FairRules']['GTXMarkUpGST'] : 0;
				$arrPlanAir['status'] = 0;
				$arrPlanAir['IsMarkForDel'] = 0;
				$arrPlanAir['created_at'] = date('Y-m-d-H-i-s');
				$arrPlanAir['updated_at'] = date('Y-m-d-H-i-s');

				$values = isset($val['destination']) ? $val['destination'] :'';
				$filterByFrom = isset($values['SourceAirportCode']) ? $values['SourceAirportCode'] :'';
				$filterByTo = isset($values['DestAirportCode']) ? $values['DestAirportCode'] :'';
				$arrSourceCityId_ = array_filter($Destinationjson, function ($var) use ($filterByFrom) {
					return ($var['AirportCode'] == $filterByFrom);
				});

				$arrdestinationCityId_ = array_filter($Destinationjson, function ($var) use ($filterByTo) {
					return ($var['AirportCode'] == $filterByTo);
				});
				$Currency = isset($values['FairRules']['Currency']) ? $values['FairRules']['Currency']:'INR';
				$currencySysId = !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
				$arrSourceCityId = array_values($arrSourceCityId_);
				$arrdestinationCityId = array_values($arrdestinationCityId_);
				if (isset($values['Segments']) && count($values['Segments']) > 1) {
					$IsDirect = '1';
				} else {
					$IsDirect = '0';
				}
				$FlyingMinutes = 0;
				if (isset($values['Segments']) && count($values['Segments']) > 0) {
					foreach ($values['Segments'] as $segmentsResult) {
						$FlyingMinutes = $FlyingMinutes + ((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0) + (!empty($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : 0)));
					}
				}
				if(isset($values['Segments'][0]['AirlineCode']) && isset($arrAirlineList[$values['Segments'][0]['AirlineCode']])){
					$airlineSysId = !empty($arrAirlineList[$values['Segments'][0]['AirlineCode']]) ? $arrAirlineList[$values['Segments'][0]['AirlineCode']] : '0';
				}
				$arrPlanAirDes['AgencySysId'] = isset($this->gtxagencysysid) ? $this->gtxagencysysid:'';
				$arrPlanAirDes['CustomerSysId'] = isset($CustomerSysId) ? $CustomerSysId :'';
				$arrPlanAirDes['FlightNumber'] = !empty($values['OrFlightNumber'])?$values['OrFlightNumber']:$values['FlightNumber'];
				$arrPlanAirDes['ICSourceSysId'] = isset($val['ICSourceSysId']) ? $val['ICSourceSysId']:'';
				$arrPlanAirDes['AirlineName'] = isset($values['AirlineName']) ? $values['AirlineName']:'';
				$arrPlanAirDes['TravelDate'] = isset($value['TravelDate'])?$value['TravelDate']:date('Y-m-d',strtotime($value['FromUTCTime']));
				$arrPlanAirDes['IsLCC'] = isset($values['IsLCC']) ? $values['IsLCC']:false;
				$arrPlanAirDes['IsRefundable'] = isset($values['IsRefundable']) ? (int)$values['IsRefundable'] : 0;
				$arrPlanAirDes['apiTraceId'] = isset($val['SearchFlightTraceId']) ? $val['SearchFlightTraceId']:'';
				$arrPlanAirDes['AirlineSysId'] = isset($airlineSysId) ? $airlineSysId :0;
				$arrPlanAirDes['DepartureTime'] = isset($values['DepartureTime']) ? $values['DepartureTime'] :'';
				$arrPlanAirDes['ArrivalTime'] = isset($values['ArrivalTime']) ? $values['ArrivalTime']:'';
				$arrPlanAirDes['IsDirect'] = isset($IsDirect) ? (int)$IsDirect :0;
				$arrPlanAirDes['FareClass'] = isset($values['FareClass']) ? $values['FareClass'] :'';
				$arrPlanAirDes['FlyingMinutes'] = isset($FlyingMinutes) ? $FlyingMinutes:'';
				$arrPlanAirDes['FlightDuration'] = isset($values['FlightDuration']) ? $values['FlightDuration']:'';
				$arrPlanAirDes['SourcePlaceSysId'] = isset($arrSourceCityId[0]['CityID']) ? $arrSourceCityId[0]['CityID'] :'';
				$arrPlanAirDes['DestPlaceSysId'] = isset($arrdestinationCityId[0]['CityID']) ? $arrdestinationCityId[0]['CityID'] :'';
				$arrPlanAirDes['SourceAirportCode'] = isset($values['SourceAirportCode']) ? $values['SourceAirportCode']:'';
				$arrPlanAirDes['DestAirportCode'] = isset($values['DestAirportCode']) ? $values['DestAirportCode']:'';
				$arrPlanAirDes['StopCount'] = isset($values['StopCount']) ? $values['StopCount']:'';
				$arrPlanAirDes['TotalFlightMembers'] = isset($values['TotalFlightMembers'])? $values['TotalFlightMembers']:0;
				$arrPlanAirDes['CurrencyType'] = isset($this->CurrencyId) ? $this->CurrencyId :'';
				$arrPlanAirDes['PublishedFare'] = isset($val['FairRules']['PublishedFare'])? $val['FairRules']['PublishedFare']:0;
				$arrPlanAirDes['ApiResultIndex'] = ($val['ICSourceSysId'] != 3) ? $val['FairRules']['PriceID'] :'';
				$arrPlanAirDes['JourneyType'] = isset($values['JourneyType'])? $values['JourneyType']:2;
				$arrPlanAirDes['TripType'] = isset($values['TripType'])? $values['TripType']:1;
				$arrPlanAirDes['IsInternational'] = isset($values['IsInternational']) ? $values['IsInternational'] : 0;
				$arrPlanAirDes['logo'] = isset($values['logo']) ? $values['logo'] :'';
				$arrPlanAirDes['Currency'] = isset($val['FairRules']['Currency']) ? $val['FairRules']['Currency'] : "INR";
				$arrPlanAirDes['BaseFare'] = isset($val['FairRules']['BaseFare']) ? $val['FairRules']['BaseFare']:0;
				$arrPlanAirDes['Tax'] = isset($val['FairRules']['Tax']) ? $val['FairRules']['Tax']:0;
				$arrPlanAirDes['YQTax'] = isset($val['FairRules']['YQTax']) ? $val['FairRules']['YQTax'] : 0;
				$arrPlanAirDes['OtherCharges'] = isset($val['FairRules']['OtherCharges']) ? $val['FairRules']['OtherCharges'] : 0;
				$arrPlanAirDes['Discount'] = isset($val['FairRules']['Discount']) ? $val['FairRules']['Discount'] : 0;
				$arrPlanAirDes['ServiceFee'] = isset($val['FairRules']['ServiceFee']) ? $val['FairRules']['ServiceFee'] : 0;
				$arrPlanAirDes['OfferedFare'] = isset($val['FairRules']['PublishedFare']) ? $val['FairRules']['PublishedFare'] : 0;
				$arrPlanAirDes['AgentCommisionEarned'] = isset($val['FairRules']['CommEarned']) ? $val['FairRules']['CommEarned'] : $val['FairRules']['CommissionEarned'];
				$arrPlanAirDes['AgentCommisionEarnedGST'] = isset($val['FairRules']['GSTonComm']) ? $val['FairRules']['GSTonComm'] : 0;
				$arrPlanAirDes['AgencyMarkUp'] = isset($val['FairRules']['FixedMarkUp']) ? $val['FairRules']['FixedMarkUp'] : 0;
				$arrPlanAirDes['AgencyMarkUpGST'] = isset($val['FairRules']['GSTOnMarkUp']) ? $val['FairRules']['GSTOnMarkUp'] : 0;
				$arrPlanAirDes['GTXMarkUp'] = isset($val['FairRules']['intGTXMarkUp']) ? $val['FairRules']['intGTXMarkUp'] : 0;
				$arrPlanAirDes['GTXMarkUpGST'] = isset($val['FairRules']['GTXMarkUpGST']) ? $val['FairRules']['GTXMarkUpGST'] : 0;
				$arrPlanAirDes['status'] = 0;
				$arrPlanAirDes['IsMarkForDel'] = 0;
				$arrPlanAirDes['created_at'] = date('Y-m-d-H-i-s');
				$arrPlanAirDes['updated_at'] = date('Y-m-d-H-i-s');
				// echo 'arrPlanAir<pre>';print_r($arrPlanAir);
				// echo 'arrPlanAirDes<pre>';print_r($arrPlanAirDes);die("arrPlanAir");
				return array('origin' => $arrPlanAir, 'destination' => $arrPlanAirDes);
			}
		}
	}

	public function ValidateSavePassenger($post, $BookingData)
	{
		$objFlight = new Travel_Model_FlightMaster();
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$class = $sessionFlightSearchParams->params['class'];
		$interNationalSearch = $sessionFlightSearchParams->params['interNationalSearch'];
		$route = $sessionFlightSearchParams->params['route'];
		if ($route == 3) {
			$departureDates = $sessionFlightSearchParams->params['departure_date'][0];
		} else {
			$departureDates = $sessionFlightSearchParams->params['departure_date'];
		}

		$returnDate = $sessionFlightSearchParams->params['return_date'];
		if (!empty($departureDates)) {
			$arrDepartureDates = explode("/", $departureDates);
			$departureDatesAD = $arrDepartureDates[2] . "-" . $arrDepartureDates[1] . "-" . $arrDepartureDates[0];
		}
		$param = array(
			'leadMobile' => $post['leadMobile'],
			'leadEmail' => $post['leadEmail'],
		);

		$tbl_customer = $objFlight->SearchFlightCustomer('tbl_customer', $param);
		$RelationExist = isset($tbl_customer[0]['Relation']) ? $tbl_customer[0]['Relation'] : '';
		/*if (!empty($tbl_customer) && $post['CustomerSysId-1'] == '0') {
			$response = array('succes' => false, 'msg' => "It's seems your account already registered with us!. so please search and select from saved travellers list.", 'index' => 'passenger-firstname-' . $i);
			echo json_encode($response);
			exit;
		}*/

		//echo '<pre>';print_r($departureDatesAD);
		//echo '<pre>';print_r($departureDates);

		$adultCount = isset($sessionFlightSearchParams->params['adults']) ? $sessionFlightSearchParams->params['adults'] : 0;
		$childCount = isset($sessionFlightSearchParams->params['childs']) ? $sessionFlightSearchParams->params['childs'] : 0;
		$infantCount = isset($sessionFlightSearchParams->params['infants']) ? $sessionFlightSearchParams->params['infants'] : 0;
		$isDocIdAllowedMandatory = isset($sessionFlightSearchParams->params['isDocIdAllowedMandatory']) ? $sessionFlightSearchParams->params['isDocIdAllowedMandatory'] : false;
		$FareTypes__ = isset($sessionFlightSearchParams->params['FareTypes']) ? $sessionFlightSearchParams->params['FareTypes'] : '';
		$oneway_origin_text = isset($sessionFlightSearchParams->params['sourceCityAirportCode']) ? $sessionFlightSearchParams->params['sourceCityAirportCode'] : '';
		$oneway_destination_text = isset($sessionFlightSearchParams->params['destinationCityAirportCode']) ? $sessionFlightSearchParams->params['destinationCityAirportCode'] : '';
		$leadMobile = isset($post['leadMobile']) ? $post['leadMobile'] : '';
		$leadEmail = isset($post['leadEmail']) ? $post['leadEmail'] : '';
		$countryCode = isset($post['countryCode']) ? $post['countryCode'] : '';
		$companyname = isset($post['companyname']) ? $post['companyname'] : '';
		$gstnnumber = isset($post['gstnnumber']) ? $post['gstnnumber'] : '';
		$gstaddress = isset($post['gstaddress']) ? $post['gstaddress'] : '';
		$gstcity = isset($post['gstcity']) ? $post['gstcity'] : '';
		$gststate = isset($post['gststate']) ? $post['gststate'] : '';
		$gstpincode = isset($post['gstpincode']) ? $post['gstpincode'] : '';
		$CityTitle = isset($post['passenger-city-name-1']) ? $post['passenger-city-name-1'] : '';
		$passengerCity = isset($post['passenger-city-1']) ? $post['passenger-city-1'] : 'Noida';
		$CountrySysId = isset($post['passenger-country-1']) ? $post['passenger-country-1'] : 0;
		$passengerAddress = isset($post['passenger-address-1']) ? $post['passenger-address-1'] : 'Noida Sector 64';
		$accepttandc = isset($post['accepttandc']) ? $post['accepttandc'] : 0;
		$isgstapply = isset($post['isgstapply']) ? $post['isgstapply'] : 0;
		$totalPassengers = $adultCount + $childCount + $infantCount;

		if (empty($leadMobile)) {
			$response = array('succes' => false, 'msg' => 'Please enter mobile number.', 'index' => 'leadMobile');
			echo json_encode($response);
			exit;
		}

		if (strlen($leadMobile) != 10 && strlen($leadMobile) != 11) {
			$response = array('succes' => false, 'msg' => 'Please enter a valid mobile number.', 'index' => 'leadMobile');
			echo json_encode($response);
			exit;
		}
		if (empty($leadEmail)) {
			$response = array('succes' => false, 'msg' => 'Please enter Email ID.', 'index' => 'leadEmail');
			echo json_encode($response);
			exit;
		}

		if (!filter_var($leadEmail, FILTER_VALIDATE_EMAIL)) {
			$msg = "Email address is not valid.";
			$response = array('success' => false, 'msg' => $msg, 'index' => 'leadEmail');
			echo json_encode($response);
			exit;
		}

		$key = 0;
		$relation = [];
		$NameUnique = [];
		for ($i = 1; $i <= $totalPassengers; $i++) {


			$paxType = isset($post['paxType-' . $i]) ? $post['paxType-' . $i] :'';
			$firstName = isset($post['passenger-firstname-' . $i]) ? $post['passenger-firstname-' . $i] :'';
			$docId = isset($post['docId-' . $i]) ? $post['docId-' . $i] :'';
			$lastName = isset($post['passenger-lastname-' . $i]) ? $post['passenger-lastname-' . $i]:'';
			$relation[] = isset($post['relation-' . $i]) ? $post['relation-' . $i] : 'Other';
			$NameUnique[] = strtolower($firstName) . '-' . strtolower($lastName);
			$salutation = isset($post['salution-' . $i]) ? $post['salution-' . $i] :'';
			if ($this->stylecss == 'bookoair') {
				$dyas = isset($post['dyas-' . $i]) ?  $post['dyas-' . $i] : '00';
				$months = isset($post['months-' . $i]) ?  $post['months-' . $i] : '00';
				$years = isset($post['years-' . $i]) ?  $post['years-' . $i] : '0000';

				$post['dateofbirth-' . $i] = $dyas . '/' . $months . '/' . $years;
			}
			//echo '<pre>';print_r($getSalutation);die;
			$CustomerSysIdPost = isset($post['CustomerSysId-' . $i]) ? $post['CustomerSysId-' . $i]:'';
			$IsExistcustomer = '';
			if (!empty($CustomerSysIdPost) && $CustomerSysIdPost != '0') {
				$IsExistcustomer = $objFlight->CheckCustomer('tbl_customer', array('CustomerSysId' => $CustomerSysIdPost));
			}
			// echo '<pre>';print_r($IsExistcustomer);die;
			$passengerPassportNo = isset($post['passportno-' . $i]) ? $post['passportno-' . $i] : '00/00/0000';
			$passengerPassportExpiry = isset($post['passportnoexpiry-' . $i]) ? $post['passportnoexpiry-' . $i] : '00/00/0000';
			$passporIssue        = isset($post['passporIssue-' . $i]) ? $post['passporIssue-' . $i] : '00/00/0000';

			if (!empty($passengerPassportExpiry)) {
				$passengerPassportExpiry = explode("/", $passengerPassportExpiry);
				$passengerPassportExpiry = $passengerPassportExpiry[2] . "-" . $passengerPassportExpiry[1] . "-" . $passengerPassportExpiry[0];
			}
			if (!empty($passporIssue)) {
				$passporIssue       = explode("/", $passporIssue);
				$passporIssue       = $passporIssue[2] . "-" . $passporIssue[1] . "-" . $passporIssue[0];
			}

			if (empty(trim($firstName))) {
				$response = array('succes' => false, 'msg' => 'Please fill out all first name.', 'index' => 'passenger-firstname-' . $i);
				echo json_encode($response);
				exit;
			}
			if($isDocIdAllowedMandatory){
				if (empty($docId)) {
					$response = array('succes' => false, 'msg' => 'Please fill out all document details.', 'index' => 'docId-' . $i);
					echo json_encode($response);
					exit;
				}
			}
			if($FareTypes__ == "SENIOR_CITIZEN"){
				if($passengerDob){
					if (!empty($paxType) && $paxType == 1) {
						$AdultAge = date_diff(date_create($passengerDob), date_create($departureDatesAD))->y;
						if ($AdultAge < 60) {
							$response = array('succes' => false, 'msg' => "Adult age should be greater than 60 years. ", 'index' => 'dobyear' . $i);
							echo json_encode($response);
							exit;
						}
					}
				}
			}
			if (empty(trim($lastName))) {
				$response = array('succes' => false, 'msg' => 'Please fill out all last name.', 'index' => 'passenger-lastname-' . $i);
				echo json_encode($response);
				exit;
			}



			if (isset($passengerDob)) {
				if (!empty($paxType) && $paxType == 1) {
					$AdultAge = date_diff(date_create($passengerDob), date_create($departureDatesAD))->y;
					if ($AdultAge < 12) {
						$response = array('succes' => false, 'msg' => "Adult age should be greater than 12 years. ", 'index' => 'dobyear' . $i);
						echo json_encode($response);
						exit;
					}
				}
			}

			if (isset($passengerDob)) {
				if (!empty($paxType) && $paxType == 2) {
					$childAge = date_diff(date_create($passengerDob), date_create($departureDatesAD))->y;
					if ($childAge < 2 || $childAge >= 12) {
						$response = array('succes' => false, 'msg' => "Child age should be 2 years or less than 12 years. ", 'index' => 'dobyear' . $i);
						echo json_encode($response);
						exit;
					}
				}
			}

			if (isset($passengerDob)) {
				if (!empty($paxType) && $paxType == 3) {
					$infantAge = date_diff(date_create($passengerDob), date_create($departureDatesAD))->y;
					if ($infantAge >= 2) {
						$response = array('succes' => false, 'msg' => "Infant age should be less than 2 years. ", 'index' => 'dobyear' . $i);
						echo json_encode($response);
						exit;
					}
				}
			}

			if (empty(trim($leadMobile))) {
				$response = array('succes' => false, 'msg' => 'Please enter lead pax mobile.', 'index' => 'leadMobile');
				echo json_encode($response);
				exit;
			}
			if (empty(trim($leadEmail))) {
				$response = array('succes' => false, 'msg' => 'Please enter lead pax email id.', 'index' => 'leadEmail');
				echo json_encode($response);
				exit;
			}

			if ($interNationalSearch == 1) {
				if (empty(trim($passengerPassportNo))) {
					$response = array('succes' => false, 'msg' => 'Please enter Passport No.', 'index' => 'passportno-' . $i);
					echo json_encode($response);
					exit;
				}
				if (empty($passengerPassportExpiry) && $passengerPassportExpiry != '0000-00-00') {
					$response = array('succes' => false, 'msg' => 'Please enter Passport Expiry.', 'index' => 'passportnoexpiry-' . $i);
					echo json_encode($response);
					exit;
				}
				if (empty($passporIssue) && $passporIssue != '0000-00-00') {
					$response = array('succes' => false, 'msg' => 'Please enter Passport Issue Date.', 'index' => 'passportnoexpiry-' . $i);
					echo json_encode($response);
					exit;
				}
			}
			// if ($BookingData && $isgstapply == 0) {
			// 	foreach ($BookingData as $values) {
			// 		if ($values['IsGSTMandatory'] == 1) {
			// 			$response = array('succes' => false, 'msg' => 'GST mandatory for this flight.', 'index' => 'gstnnumber');
			// 			echo json_encode($response);
			// 			exit;
			// 		}
			// 	}
			// }




			// if ($isgstapply == 1) {
			// 	if (empty(trim($gstnnumber))) {
			// 		$response = array('succes' => false, 'msg' => 'Please enter GSTIN number.', 'index' => 'gstnnumber');
			// 		echo json_encode($response);
			// 		exit;
			// 	}
			// 	$is_valid_gstin = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->is_valid_gstin($gstnnumber);
			// 	if ($is_valid_gstin == 0) {
			// 		$response = array('succes' => false, 'msg' => 'Enter Valid GST Number', 'index' => 'gstnnumber');
			// 		echo json_encode($response);
			// 		exit;
			// 	}
			// 	if (empty(trim($companyname))) {
			// 		$response = array('succes' => false, 'msg' => 'Please enter company name.', 'index' => 'companyname');
			// 		echo json_encode($response);
			// 		exit;
			// 	}
			// 	if (empty(trim($gstaddress))) {
			// 		$response = array('succes' => false, 'msg' => 'Please enter GST address.', 'index' => 'gstaddress');
			// 		echo json_encode($response);
			// 		exit;
			// 	}
			// 	if (empty(trim($gstcity))) {
			// 		$response = array('succes' => false, 'msg' => 'Please enter GST city.', 'index' => 'gstcity');
			// 		echo json_encode($response);
			// 		exit;
			// 	}
			// 	if (empty(trim($gststate))) {
			// 		$response = array('succes' => false, 'msg' => 'Please enter GST state.', 'index' => 'gststate');
			// 		echo json_encode($response);
			// 		exit;
			// 	}
			// 	if (empty(trim($gstpincode))) {
			// 		$response = array('succes' => false, 'msg' => 'Please enter GST pincode.', 'index' => 'gstpincode');
			// 		echo json_encode($response);
			// 		exit;
			// 	}
			// }
			// if ($accepttandc == 0) {
			//     $response = array('succes' => false, 'msg' => 'please accept the terms and conditions', 'index' => 'accepttandc');
			//     echo json_encode($response);
			//     exit;
			// }
			//                die;
		}
		if (count(array_unique($NameUnique)) != $totalPassengers) {
			$response = array('success' => false, 'msg' => 'Passengers name should be unique.', 'index' => 'relation');
			echo json_encode($response);
			exit;
		}

		// if($RelationExist == 0){
		// 	$RelationExist = (array)$RelationExist;
		// 	$FinalRelation = array_merge($RelationExist,$relation);
		// }else{
		// 	$FinalRelation = $relation;
		// }

		// $indexes = array_keys(array_unique($FinalRelation), 0);
		$array_count_values = array_count_values($relation);
		$indexes = isset($array_count_values[0]) ? $array_count_values[0] : '';



		// if ($indexes == 1 && $RelationExist == 0 && $post['CustomerSysId-1'] == 0) {
		// 	$response = array('success' => false, 'msg' => 'Self relation should be unique.', 'index' => 'relation');
		// 	echo json_encode($response);
		// 	exit;
		// }
		//die;
		// if(count($relation) < count($indexes)){
		// 	$response = array('success' => false, 'msg' => 'Self relation should be unique.', 'index' => 'relation');
		// 	echo json_encode($response);
		// 	exit;
		// }
		// if ($BookingData && $isgstapply == 0) {
		// 	foreach ($BookingData as $values) {

		// 		if ($values['FairRules']['IsGSTRequired'] == 1) {
		// 			$response = array('succes' => false, 'msg' => 'GST mandatory for this flight.', 'index' => 'gstnnumber');
		// 			echo json_encode($response);
		// 			exit;
		// 		}
		// 	}
		// }
		// if ($isgstapply == 1) {
		// 	if (empty(trim($gstnnumber))) {
		// 		$response = array('succes' => false, 'msg' => 'Please enter GSTIN number.', 'index' => 'gstnnumber');
		// 		echo json_encode($response);
		// 		exit;
		// 	}
		// 	$is_valid_gstin = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->is_valid_gstin($gstnnumber);
		// 	if ($is_valid_gstin == 0) {
		// 		$response = array('succes' => false, 'msg' => 'Enter Valid GST Number', 'index' => 'gstnnumber');
		// 		echo json_encode($response);
		// 		exit;
		// 	}
		// 	if (empty(trim($companyname))) {
		// 		$response = array('succes' => false, 'msg' => 'Please enter company name.', 'index' => 'companyname');
		// 		echo json_encode($response);
		// 		exit;
		// 	}
		// 	if (empty(trim($gstaddress))) {
		// 		$response = array('succes' => false, 'msg' => 'Please enter GST address.', 'index' => 'gstaddress');
		// 		echo json_encode($response);
		// 		exit;
		// 	}
		// 	if (empty(trim($gstcity))) {
		// 		$response = array('succes' => false, 'msg' => 'Please enter GST city.', 'index' => 'gstcity');
		// 		echo json_encode($response);
		// 		exit;
		// 	}
		// 	if (empty(trim($gststate))) {
		// 		$response = array('succes' => false, 'msg' => 'Please enter GST state.', 'index' => 'gststate');
		// 		echo json_encode($response);
		// 		exit;
		// 	}
		// 	if (empty(trim($gstpincode))) {
		// 		$response = array('succes' => false, 'msg' => 'Please enter GST pincode.', 'index' => 'gstpincode');
		// 		echo json_encode($response);
		// 		exit;
		// 	}
		// }
		// print_r($FinalRelation);
		// print_r($relation);
		// print_r($indexes);
		// die;
	}
	public function addOnnServiceAction()
	{
		// ini_set('display_errors', 1);
		//     ini_set('display_startup_errors', 1);
		//     error_reporting(E_ALL);
		$param = $this->getRequest()->getParams();
		$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $param['traceId']], ['id' => 'ASC']);

		$arrUrlData = json_decode($temp_data['json_data'], true);
		$TPSysId = ($arrUrlData['genrateFlightQuery']['arrIds']['TPSysId']) ? $arrUrlData['genrateFlightQuery']['arrIds']['TPSysId'] :0;
		$PostData = ['TPSysId' => $TPSysId, 'version' => null,'IsApproved'=>0];
		$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingdetailsapi($PostData);

		$PaymentStatus = isset($apiResponse['FlightBookingData'][0]['PaymentStatus']) ? $apiResponse['FlightBookingData'][0]['PaymentStatus'] : '0';
		$CurrentStatus = isset($apiResponse['FlightBookingData'][0]['CurrentStatus']) ? $apiResponse['FlightBookingData'][0]['CurrentStatus'] : '0';
		if ($PaymentStatus == 130 && ($CurrentStatus == 142 || $CurrentStatus == 141)) {
			$strReturnURL = $this->baseUrl . "flight/booking-confirmed-new/".$TPSysId;
			$this->_redirect($strReturnURL);
		}
		if ($PaymentStatus == 22) {
			$strReturnURL = $this->baseUrl . "flight/booking-confirmed-new/".$TPSysId;
			$this->_redirect($strReturnURL);
		}
		// echo '<pre>';print_r($apiResponse);die;
		$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
		$FlightBookingDataInbound = new Zend_Session_Namespace('FlightBookingDataInbound');
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$FlightSearchUrl = new Zend_Session_Namespace('FlightSearchUrl');
		$CustomerSession = new Zend_Session_Namespace('CustomerSession');
		$CustomerMemberSysIds = new Zend_Session_Namespace('CustomerMemberSysIds');
		$LeadPaxSession = new Zend_Session_Namespace('LeadPaxSession');
		$CustomerMembersSession = new Zend_Session_Namespace('CustomerMembersSession');

		$FlightBookingData->params = isset($arrUrlData['BookingData']) ? $arrUrlData['BookingData'] : [];
		//$FlightBookingDataInbound->params = isset($arrUrlData['FlightBookingDataInbound']) ? $arrUrlData['FlightBookingDataInbound'] : [];
		// echo"<pre>";print_r($sessionFlightSearchParams->params);
		// echo"<pre>";print_r($arrUrlData);
		// exit;

		$getCmsPageDetail = $this->objMdl->rv_select_row('tbl_static_pages', ['identifier'], ['sid' => '162', 'status' => 'Activate'], ['sid' => 'desc']);
		$termsofuse = isset($getCmsPageDetail['identifier']) ? $getCmsPageDetail['identifier'] :[];
		//echo"<pre>";print_r($CustomerSession->params);die;
		$this->view->baseUrl = $this->baseUrl;
		$this->view->apiResponse = isset($apiResponse) ? $apiResponse : [];
		$this->view->termsofuse = isset($termsofuse) ? $termsofuse : [];
		$this->view->gtxagencysysid = isset($this->gtxagencysysid) ? $this->gtxagencysysid :0;
		$this->view->CustomerMemberSysIds = isset($CustomerMemberSysIds->params) ? $CustomerMemberSysIds->params:[];
		// $this->view->LeadPaxSession = $LeadPaxSession->params;
		// $this->view->CustomerMembersSession = $CustomerMembersSession->params;
		$this->view->CustomerSession = isset($CustomerSession->params) ? $CustomerSession->params :[];
		// $this->view->FlightSearchUrl = $FlightSearchUrl->params;
		$class = isset($sessionFlightSearchParams->params['class']) ? $sessionFlightSearchParams->params['class'] :'';
		$this->view->traceId = isset($param['traceId']) ? $param['traceId'] :'';
		$this->view->departure_date = isset($sessionFlightSearchParams->params['strDepatureDate']) ? $sessionFlightSearchParams->params['strDepatureDate']:'';
		$this->view->return_dates = isset($sessionFlightSearchParams->params['strReturnDate']) ? $sessionFlightSearchParams->params['strReturnDate'] :'';
		$this->view->class = $class;
		$this->view->param = $param;
		$this->view->CurrencyRate = $this->CurrencyRate;
		$this->view->CurrencyTitle = $this->CurrencyTitle;
		// $this->view->OTPVerified = $this->OTPVerified;
		$this->view->sessionFlightSearchParams = isset($sessionFlightSearchParams->params) ? $sessionFlightSearchParams->params :[];
		$this->view->FlightBookingData = isset($FlightBookingData->params) ? $FlightBookingData->params :'';
		$this->view->FlightBookingDataInbound = isset($FlightBookingDataInbound->params) ? $FlightBookingDataInbound->params:'';
		$intCountryCode = isset($sessionFlightSearchParams->params['intCountryCode']) ? $sessionFlightSearchParams->params['intCountryCode'] :'';
		if($this->IsTJFlightAPI){
			$SupplierType = 2;
		}else{
			$SupplierType = 1;
		}

		$getMarkup = $this->getCancellationChargeNew($intCountryCode, 1,$SupplierType); ///$this->getMarkup($intCountryCode);


		$CencelattionData = (isset($getMarkup['CencelattionData'][0]['IsCancellationProtection']) && trim($getMarkup['CencelattionData'][0]['IsCancellationProtection']) == 1) ? 1 : 0;
		$CPPercentVal = (isset($getMarkup['CencelattionData'][0]['CPPercentVal']) && !empty($getMarkup['CencelattionData'][0]['CPPercentVal'])) ? (int)$getMarkup['CencelattionData'][0]['CPPercentVal'] : 0;
		$this->view->CencelattionData = $CencelattionData;
		$this->view->CPPercentVal = $CPPercentVal;

		$this->view->WalletStatus = (isset($this->_session->wallet['WalletStatus']) && !empty($this->_session->wallet['WalletStatus'])) ? $this->_session->wallet['WalletStatus'] : 0;
		$this->view->WalletBalance = (isset($this->_session->wallet['WalletBalance'][0]['BalanceAmount']) && !empty($this->_session->wallet['WalletBalance'][0]['BalanceAmount'])) ? $this->_session->wallet['WalletBalance'][0]['BalanceAmount'] : 0;
		// if($this->gtxagencysysid == '2656'){
		// 	echo"<pre>";print_r($this->_session->wallet);die;
		// }

		// echo "apiResponse<pre>";print_r($apiResponse);die;

	}

	public function updatefareAction()
	{
		// ini_set('display_errors', 1);
		//     ini_set('display_startup_errors', 1);
		//     error_reporting(E_ALL);
		header('Access-Control-Allow-Origin: ' . $this->baseUrl . '');
		if ($this->getRequest()->isXmlHttpRequest() && $this->getRequest()->getPost()) {
			$getData = $this->getRequest()->getParams();
			$FlightBookingDataInbound = new Zend_Session_Namespace('FlightBookingDataInbound');
			$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
			$flightSSRDetails = new Zend_Session_Namespace('flightSSRDetails');

			$SelectedMealSessionNew = new Zend_Session_Namespace('SelectedMealSessionNew');
			$SelectedBaggSessionNew = new Zend_Session_Namespace('SelectedBaggSessionNew');

			$SelectedMealSessionNewInb = new Zend_Session_Namespace('SelectedMealSessionNewInb');
			$SelectedBaggSessionNewInb = new Zend_Session_Namespace('SelectedBaggSessionNewInb');
			$key = $getData['data']['key'];
			$Code = $getData['data']['Code'];
			$segmentid = $getData['data']['segmentid'];
			$ICSourceSysId = isset($FlightBookingData->params[0]['ICSourceSysId'])?$FlightBookingData->params[0]['ICSourceSysId']:0;
			$Baggage = [];
			$Meal = [];
			$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $getData['TraceId']], ['id' => 'ASC']);
			$arrUrlData = json_decode($temp_data['json_data'], true);
			$BookingData = $arrUrlData['BookingData'];
			$CustomerSession = $arrUrlData['CustomerSession'];
			$actiontype = $getData['actiontype'];
			$Price = $getData['Price'];
			if($actiontype == 'baggage'){
				$SelectedBaggSessionNew->params['Price'] = $Price;
			}
			if($actiontype == 'meal'){
				$SelectedMealSessionNew->params['Price'] = $Price;
			}
			// echo "getData<pre>";print_r($SelectedBaggSessionNew->params);
			// echo "getData<pre>";print_r($SelectedMealSessionNew->params);
			// echo "getData<pre>";print_r($getData);
			// die;
			// echo "ICSourceSysId($ICSourceSysId)";
			// if ($FlightBookingData->params) {
			// 	foreach ($FlightBookingData->params as $value) {
			// 		$Baggage[] = $value['Baggage'];
			// 		$Meal[] = $value['Meal'];
			// 	}
			// }
			// if ($this->getTemplateId == 7 || $ICSourceSysId == 16) {
			// 	$Baggage = $flightSSRDetails->params['Baggage'];
			// 	$Meal = $flightSSRDetails->params['Meal'];
			// }
			// if ($Meal) {
			// 	foreach ($Meal as $ml) {
			// 		if ($ml) {
			// 			foreach ($ml as $mlv) {
			// 				if ($Code == $mlv['Code'] && $key == $mlv['key']) {
			// 					//$mlv['check'] = 'pppp';
			// 					$getData['data'] = $mlv;
			// 				}
			// 			}
			// 		}
			// 	}
			// }
			// if ($Baggage) {
			// 	foreach ($Baggage as $bg) {
			// 		if ($bg) {
			// 			foreach ($bg as $bgv) {
			// 				if ($Code == $bgv['Code'] && $key == $bgv['key']) {
			// 					//$bgv['check'] = 'pppp';
			// 					$getData['data'] = $bgv;
			// 				}
			// 			}
			// 		}
			// 	}
			// }
			// $CustomerSysId = $getData['CustomerSysId'];
			// $NewArray = false;
			// if ($getData['tripType'] == '1') {
			// 	if ($getData['actiontype'] == 'meal') {
			// 		if (!empty($SelectedMealSessionNew->params)) {
			// 			foreach ($SelectedMealSessionNew->params as $CustomerId => $val) {
			// 				if ($CustomerId == $CustomerSysId) {
			// 					if($ICSourceSysId == 16){
			// 						$SelectedMealSessionNew->params[$val['segmentid']][$CustomerId] = $getData['data'];
			// 					}else{
			// 						$SelectedMealSessionNew->params[$CustomerId] = $getData['data'];
			// 					}
			// 				} else {
			// 					$NewArray = true;
			// 					if($ICSourceSysId == 16){
			// 						$SelectedMealSessionNew->params[$val['segmentid']][$CustomerId] = $val;
			// 					}else{
			// 						$SelectedMealSessionNew->params[$CustomerId] = $val;
			// 					}
			// 				}
			// 			}
			// 		} else {
			// 			if($ICSourceSysId == 16){
			// 				$SelectedMealSessionNew->params[$getData['data']['segmentid']][$CustomerSysId] = $getData['data'];
			// 			}else{
			// 				$SelectedMealSessionNew->params[$CustomerSysId] = $getData['data'];
			// 			}
			// 		}
			// 		if ($NewArray) {
			// 			if($ICSourceSysId == 16){
			// 				$SelectedMealSessionNew->params[$getData['data']['segmentid']][$CustomerSysId] = $getData['data'];
			// 			}else{
			// 				$SelectedMealSessionNew->params[$CustomerSysId] = $getData['data'];
			// 			}
			// 		}
			// 		$Mealdata = $getData['data'];
			// 	} else {
			// 		/// Baggage
			// 		if (!empty($SelectedBaggSessionNew->params)) {
			// 			foreach ($SelectedBaggSessionNew->params as $CustomerId => $val) {
			// 				if ($CustomerId == $CustomerSysId) {
			// 					if($ICSourceSysId == 16){
			// 						$SelectedBaggSessionNew->params[$getData['data']['segmentid']][$CustomerId] = $getData['data'];
			// 					}else{
			// 						$SelectedBaggSessionNew->params[$CustomerId] = $getData['data'];
			// 					}
			// 				} else {
			// 					$NewArray = true;
			// 					if($ICSourceSysId == 16){
			// 						$SelectedBaggSessionNew->params[$val['segmentid']][$CustomerId] = $val;
			// 					}else{
			// 						$SelectedBaggSessionNew->params[$CustomerId] = $val;
			// 					}
			// 				}
			// 			}
			// 		} else {
			// 			if($ICSourceSysId == 16){
			// 				$SelectedBaggSessionNew->params[$getData['data']['segmentid']][$CustomerSysId] = $getData['data'];
			// 			}else{
			// 				$SelectedBaggSessionNew->params[$CustomerSysId] = $getData['data'];
			// 			}
			// 		}
			// 		if ($NewArray) {
			// 			if($ICSourceSysId == 16){
			// 				$SelectedBaggSessionNew->params[$getData['data']['segmentid']][$CustomerSysId] = $getData['data'];
			// 			}else{
			// 				$SelectedBaggSessionNew->params[$CustomerSysId] = $getData['data'];
			// 			}
			// 		}
			// 		$Baggdata = $getData['data'];
			// 	}
			// } elseif ($getData['tripType'] == '2') {
			// 	if ($getData['actiontype'] == 'meal') {
			// 		if (!empty($SelectedMealSessionNewInb->params)) {
			// 			foreach ($SelectedMealSessionNewInb->params as $CustomerId => $val) {
			// 				if ($CustomerId == $CustomerSysId) {
			// 					if($ICSourceSysId == 16){
			// 						$SelectedMealSessionNewInb->params[$val['segmentid']][$CustomerId] = $getData['data'];
			// 					}else{
			// 						$SelectedMealSessionNewInb->params[$CustomerId] = $getData['data'];
			// 					}
			// 				} else {
			// 					$NewArray = true;
			// 					if($ICSourceSysId == 16){
			// 						$SelectedMealSessionNewInb->params[$val['segmentid']][$CustomerId] = $val;
			// 					}else{
			// 						$SelectedMealSessionNewInb->params[$CustomerId] = $val;
			// 					}
			// 				}
			// 			}
			// 		} else {
			// 			if($ICSourceSysId == 16){
			// 				$SelectedMealSessionNewInb->params[$getData['data']['segmentid']][$CustomerSysId] = $getData['data'];
			// 			}else{
			// 				$SelectedMealSessionNewInb->params[$CustomerSysId] = $getData['data'];
			// 			}
			// 		}
			// 		if ($NewArray) {
			// 			if($ICSourceSysId == 16){
			// 				$SelectedMealSessionNewInb->params[$getData['data']['segmentid']][$CustomerSysId] = $getData['data'];
			// 			}else{
			// 				$SelectedMealSessionNewInb->params[$CustomerSysId] = $getData['data'];
			// 			}
			// 		}
			// 		$MealdataInb = $getData['data'];
			// 	} else {
			// 		/// Baggage
			// 		if (!empty($SelectedBaggSessionNewInb->params)) {
			// 			foreach ($SelectedBaggSessionNewInb->params as $CustomerId => $val) {
			// 				if ($CustomerId == $CustomerSysId) {
			// 					if($ICSourceSysId == 16){
			// 						$SelectedBaggSessionNewInb->params[$getData['data']['segmentid']][$CustomerSysId] = $getData['data'];
			// 					}else{
			// 						$SelectedBaggSessionNewInb->params[$CustomerId] = $getData['data'];
			// 					}
			// 				} else {
			// 					$NewArray = true;
			// 					if($ICSourceSysId == 16){
			// 						$SelectedBaggSessionNewInb->params[$val['segmentid']][$CustomerId] = $val;
			// 					}else{
			// 						$SelectedBaggSessionNewInb->params[$CustomerId] = $val;
			// 					}
			// 				}
			// 			}
			// 		} else {
			// 			if($ICSourceSysId == 16){
			// 				$SelectedBaggSessionNewInb->params[$val['segmentid']][$CustomerId] = $getData['data'];
			// 			}else{
			// 				$SelectedBaggSessionNewInb->params[$CustomerSysId] = $getData['data'];
			// 			}
			// 		}
			// 		if ($NewArray) {
			// 			if($ICSourceSysId == 16){
			// 				$SelectedBaggSessionNewInb->params[$getData['data']['segmentid']][$CustomerSysId] = $getData['data'];
			// 			}else{
			// 				$SelectedBaggSessionNewInb->params[$CustomerSysId] = $getData['data'];
			// 			}
			// 		}
			// 		$BaggdataInb = $getData['data'];
			// 	}
			// }

			$BagPrice = !empty($SelectedBaggSessionNew->params['Price'])?$SelectedBaggSessionNew->params['Price']:0;
			// $InbBagPrice = 0;
			$MealPrice = !empty($SelectedMealSessionNew->params['Price'])?$SelectedMealSessionNew->params['Price']:0;
			// $InbMealPrice = 0;

			// if ($SelectedBaggSessionNew->params) {
			// 	foreach ($SelectedBaggSessionNew->params as $val) {
			// 		$BagPrice += $val['Price'];
			// 	}
			// }
			// if ($SelectedMealSessionNew->params) {
			// 	foreach ($SelectedMealSessionNew->params as $val) {
			// 		$MealPrice += $val['Price'];
			// 	}
			// }

			// if ($SelectedMealSessionNewInb->params) {
			// 	foreach ($SelectedMealSessionNewInb->params as $val) {
			// 		$InbMealPrice += $val['Price'];
			// 	}
			// }
			// if ($SelectedBaggSessionNewInb->params) {
			// 	foreach ($SelectedBaggSessionNewInb->params as $val) {
			// 		$InbBagPrice += $val['Price'];
			// 	}
			// }
			$MealFare = ($MealPrice + $InbMealPrice);
			$BaggFare = ($BagPrice + $InbBagPrice);
			//echo"<pre>";print_r($BaggFare);die;
			$intNetPublishedFare = 0;
			if ($FlightBookingData) {
				foreach ($FlightBookingData->params as $value) {
					$intNetPublishedFare += $value['FairRules']['PublishedFare'];
				}
			}
			// echo 'getData<pre>';print_r($getData);
			
			$apiResponse = ($FlightBookingData->params);
			$apiResponseInbound = ($FlightBookingDataInbound->params);
			$Data = $apiResponse;
			$DataInb = $apiResponseInbound;
			$intPublishedFare = $Data['FairRules']['PublishedFare'];
			$intPublishedFareInb = !empty($DataInb['FairRules']['PublishedFare']) ? $DataInb['Fare']['PublishedFare'] : 0;
			$MobilePublishedFare = ($intNetPublishedFare + $MealFare + $BaggFare);

			$html = new Zend_View();
			$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
			$html->assign(array('apiResponse' => $FlightBookingData->params, 'stylecss' => $this->stylecss, 'apiResponseInbound' => $FlightBookingDataInbound->params, 'Mealdata' => $Mealdata, 'Baggdata' => $Baggdata, 'MealdataInb' => $MealdataInb, 'BaggdataInb' => $BaggdataInb, 'actiontype' => $getData['actiontype'], 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
			$bodyText = $html->render('getflightfarequote.phtml');
			$response = array('success' => true, 'message' => 'Done', 'MobilePublishedFare' => number_format(ceil($MobilePublishedFare), 2), 'html' => $bodyText);
			echo json_encode($response);
			exit;
			//print_r($getData);
		} else {
			die('Page not found');
		}
	}
	function is_decimal($val)
	{
		return is_numeric($val) && floor($val) != $val;
	}
	public function verifySessionAction()
	{

		$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
		$FlightBookingDataInbound = new Zend_Session_Namespace('FlightBookingDataInbound');
		$IsLCC = $FlightBookingData->params['IsLCC'];
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$route = $sessionFlightSearchParams->params['route'];
		$interNationalSearch = $sessionFlightSearchParams->params['interNationalSearch'];


		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$this->_helper->viewRenderer->setNoRender(true);
			$getData = $this->getRequest()->getParams();
			$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $getData['TraceId']], ['id' => 'ASC']);

			$arrUrlData = json_decode($temp_data['json_data'], true);
			$ICSourceSysId = $arrUrlData['BookingData'][0]['ICSourceSysId'];
			$PriceID = $arrUrlData['BookingData'][0]['FairRules']['PriceID'];
			$PriceIDInb = $arrUrlData['BookingData'][1]['FairRules']['PriceID'];
			$apiTraceId = $arrUrlData['BookingData'][0]['apiTraceId'];
			$arrUrlData['FlightBookingDataInbound'];
			$FlightSearchUrl = new Zend_Session_Namespace('FlightSearchUrl');
			// echo"<pre>==";print_r($ICSourceSysId);
			// echo"<pre>==";print_r($arrUrlData);
			// // echo"<pre>==";print_r($FlightBookingData->params);
			// die;
			if ($ICSourceSysId == 7 || $ICSourceSysId == 8) {

				$apiResponseInbound = [];
				$getQ = array(
					'ApiResultIndex' => $getData['ApiResultIndex'],
					'TraceId' => $PriceID,
					'ApiResultIndexInb' => $getData['ApiResultIndexInb'],
					'SearchFlightTraceId' => $getData['TraceId'],
					'Inbound' => false,
					'FlightBookingData' => $arrUrlData['BookingData'][0],
				);
				if ($route == 2 && $interNationalSearch == '') {
					$getQ['TraceId'] = $PriceID . ',' . $PriceIDInb;
				}

				if ($route == 3 && $interNationalSearch == '') {
					$PriceIDarr = [];
					if ($arrUrlData['BookingData']) {
						foreach ($arrUrlData['BookingData'] as $multi) {
							$PriceIDarr[] = $multi['FairRules']['PriceID'];
						}
					}

					$getQ['TraceId'] = implode(',', $PriceIDarr);
					//echo"<pre>==";print_r($getQ);
				}
				$SSRData = array(
					'ResultIndex' => $getData['ApiResultIndex'],
					'TraceId' => $getData['TraceId'],
				);
				if ($ICSourceSysId == 8) {
					$apiResponse = array('status' => array('success' => 1), 'bookingId' => $FlightBookingData->params[0]['bookingId']);
					if ($route == 2 && $interNationalSearch == 1) {
						$this->UpdateFlightBookingDataSFInter($FlightBookingData->params, $getData['TraceId'], $sessionFlightSearchParams->params);
					}
				} else {
					$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareQuoteTripJack($getQ);
					$requestData = array(
						'TraceId' => $apiResponse['bookingId'],
						'flowType' => 'REVIEW',
						'FlightTraceId' => $getData['TraceId'],
						'BookingData' => $arrUrlData['BookingData'][0]
					);
					$FareRulesTripJack = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareRulesTripJack($requestData);
					$FareRuleRequest = $FareRulesTripJack;
				}


				$ResponseStatus = $apiResponse['status']['success'];
				$FareChange = (isset($apiResponse['alerts']) && !empty($apiResponse['alerts'])) ? true : false;
				// $FareChange = true;
				$ErrorMessage = isset($apiResponse['errors'][0]['message']) ? $apiResponse['errors'][0]['message'] : '';
				if ($ResponseStatus == 1) {
					$response = array('success' => true, 'message' => 'Sorry for the inconvenience. The Airline has just changed the fare for this flight.You can continue with the revised fare or explore other flights at your convenience.', 'FareChange' => $FareChange);
					echo json_encode($response);
					exit;
				} else {
					$response = array('success' => false, 'message' => $ErrorMessage, 'FareChange' => false, 'SearchUrl' => $FlightSearchUrl->params);
					echo json_encode($response);
					exit;
				}
			} elseif ($ICSourceSysId == 3) {
				if ($FlightBookingData->params) {
					$newFare = 0;
					$oldFare = 0;
					$intPublishedFare = 0;
					$FlightBookingDataArr = [];
					$SSRArr = [];
					$FareChange = false;
					foreach ($FlightBookingData->params as $key => $vl) {
						$arrData['TraceId'] = $vl['apiTraceId'];
						$arrData['ApiResultIndex'] = $vl['ApiResultIndex'];
						$arrData['SearchFlightTraceId'] = $getData['TraceId'];
						$arrData['TraceId'] = $apiTraceId;
						$arrData['BookingData'] = $vl;
						$IsLCC = $vl['IsLCC'];
						$strAirlineCode = $vl['AirlineCode'];

						$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareQuote($arrData);
						$IsPriceChanged = $apiResponse['Response']['IsPriceChanged'];
						$ResponseStatus = $apiResponse['Response']['ResponseStatus'];
						$ErrorMessage = $apiResponse['Response']['Error']['ErrorMessage'];
						if ($ResponseStatus == 1) {
							$response = array('success' => true, 'message' => 'Sorry for the inconvenience. The Airline has just changed the fare for this flight.You can continue with the revised fare or explore other flights at your convenience.', 'FareChange' => $IsPriceChanged);
							echo json_encode($response);
							exit;
						} else {
							$response = array('success' => false, 'message' => $ErrorMessage, 'FareChange' => false, 'SearchUrl' => $FlightSearchUrl->params);
							echo json_encode($response);
							exit;
						}
					}
				}
			} else {
				$response = array('success' => false, 'message' => 'Bad request', 'SearchUrl' => $FlightSearchUrl->params, 'FareChange' => false, 'SearchUrl' => $FlightSearchUrl->params);
				echo json_encode($response);
				exit;
			}
		} else {
			die('Page not found!');
		}
	}
	public function getflightfarequoteAction()
	{
		// ini_set('display_errors', 1);
		//     ini_set('display_startup_errors', 1);
		//     error_reporting(E_ALL);
		$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
		$FlightBookingDataInbound = new Zend_Session_Namespace('FlightBookingDataInbound');
		$IsLCC = $FlightBookingData->params['IsLCC'];
		$SessionPublishedFare = $FlightBookingData->params['PublishedFare'];
		$SessionPublishedFareInb = isset($FlightBookingDataInbound->params['PublishedFare']) ? $FlightBookingDataInbound->params['PublishedFare'] : 0;
		$SessionPublishedFare = ($SessionPublishedFare + $SessionPublishedFareInb);
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$route = $sessionFlightSearchParams->params['route'];
		$interNationalSearch = $sessionFlightSearchParams->params['interNationalSearch'];

		$adultCount = $sessionFlightSearchParams->params['adults'];
		$childCount = $sessionFlightSearchParams->params['child'];
		$infantCount = $sessionFlightSearchParams->params['infant'];
		$flight_class = $sessionFlightSearchParams->params['flight_class'];
		$intMemberCount = $adultCount + $childCount + $infantCount;
		$intSourceCityId = $sessionFlightSearchParams->params['sourceCityId'];
		$intDestinationCityId = $sessionFlightSearchParams->params['destinationCityId'];
		$sourceCityAirportCode = isset($sessionFlightSearchParams->params['sourceCityAirportCode']) ? $sessionFlightSearchParams->params['sourceCityAirportCode'] :'';
		$destinationCityAirportCode = isset($sessionFlightSearchParams->params['destinationCityAirportCode']) ? $sessionFlightSearchParams->params['destinationCityAirportCode'] :'';
		$departure_dateG = ($sessionFlightSearchParams->params['departure_dateG']);
		$strDepatureDate = ($sessionFlightSearchParams->params['strDepatureDate']);
		$arrFlightClass = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getFlightClasses();
		$FlightClass = $arrFlightClass[$flight_class];
		
		$ItineraryInfo = [];
		$AirRepriceRequests = [];
		$AirSSRRequestDetails = [];
		$intPublishedFareCheck = 0;
		$PublishedFareFareCheck = 0;
		if ($FlightBookingData->params) {
			foreach ($FlightBookingData->params as $kk => $value) {
				
				$intPublishedFareCheck += $value['FairRules']['intPublishedFare'];
				$PublishedFareFareCheck += $value['FairRules']['PublishedFare'];
				$apiTraceId[] = $value['FairRules']['PriceID'];
				$arrData[$kk]['TraceId'] = $value['FairRules']['PriceID'];
				$arrData[$kk]['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[$kk]['FlightDetails'] = $FlightDetails;
				$ItineraryInfo[$kk]['BaseAmount'] = $BaseFare;
				$ItineraryInfo[$kk]['GrossAmount'] = $GrossAmount;
				// Etrav Data
				$AirSSRRequestDetails[$kk]['Flight_Key'] = isset($value['Flight_Key'])?$value['Flight_Key']:'';
				$AirRepriceRequests[$kk]['Flight_Key'] = isset($value['Flight_Key'])?$value['Flight_Key']:'';
				$AirRepriceRequests[$kk]['Fare_Id'] = isset($value['FairRules']['PriceID'])?$value['FairRules']['PriceID']:'';
			}
		}
			
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$this->_helper->viewRenderer->setNoRender(true);
			$getData = $this->getRequest()->getParams();
			$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $getData['TraceId']], ['id' => 'ASC']);

			$arrUrlData = json_decode($temp_data['json_data'], true);
			$SearchTraceId = isset($arrUrlData['BookingData'][0]['SearchFlightTraceId']) ? $arrUrlData['BookingData'][0]['SearchFlightTraceId'] : $arrUrlData['BookingData'][0]['SearchTraceId'];
			$ApiResultIndex = isset($arrUrlData['BookingData'][0]['ApiResultIndex']) ? $arrUrlData['BookingData'][0]['ApiResultIndex'] : '';
			
			$ICSourceSysId = $arrUrlData['BookingData'][0]['ICSourceSysId'];
			$Search_Key = $arrUrlData['BookingData'][0]['Search_Key'];
			$PriceID = $arrUrlData['BookingData'][0]['FairRules']['PriceID'];
			$PriceIDInb = $arrUrlData['BookingData'][1]['FairRules']['PriceID'];
			$apiTraceId = $arrUrlData['BookingData'][0]['apiTraceId'];
			$arrUrlData['FlightBookingDataInbound'];
			$FareQuoteReq = isset($arrUrlData['FareQuoteReq'])?$arrUrlData['FareQuoteReq']:[];
			$BookingData = $arrUrlData['BookingData'];
			Zend_Session::namespaceUnset('FlightSeatSession');
			Zend_Session::namespaceUnset('selectedSeatSession');
			//echo $route;

			if ($getData['page'] != 'payment') {
				Zend_Session::namespaceUnset('SelectedMealSessionNew');
				Zend_Session::namespaceUnset('SelectedBaggSessionNew');
				Zend_Session::namespaceUnset('SelectedMealSessionNewInb');
				Zend_Session::namespaceUnset('SelectedBaggSessionNewInb');
				Zend_Session::namespaceUnset('flightSSRDetailsInb');
				Zend_Session::namespaceUnset('flightSSRDetails');
			}
			$bookingId_create = 'GTX'.floor(microtime(true) *1000);
			if ($ICSourceSysId == 7 || $ICSourceSysId == 8) {

				$apiResponseInbound = [];
				$getQ = array(
					'ApiResultIndex' => $getData['ApiResultIndex'],
					'TraceId' => $PriceID,
					'ApiResultIndexInb' => $getData['ApiResultIndexInb'],
					'SearchFlightTraceId' => $getData['TraceId'],
					'Inbound' => false,
					'FlightBookingData' => $arrUrlData['BookingData'][0],
				);
				if ($route == 2 && $interNationalSearch == '') {
					$getQ['TraceId'] = $PriceID . ',' . $PriceIDInb;
				}

				if ($route == 3 && $interNationalSearch == '') {
					$PriceIDarr = [];
					if ($arrUrlData['BookingData']) {
						foreach ($arrUrlData['BookingData'] as $multi) {
							$PriceIDarr[] = $multi['FairRules']['PriceID'];
						}
					}

					$getQ['TraceId'] = implode(',', $PriceIDarr);
					//echo"<pre>==";print_r($getQ);
				}
				$SSRData = array(
					'ResultIndex' => $getData['ApiResultIndex'],
					'TraceId' => $getData['TraceId'],
				);
				if ($ICSourceSysId == 8) {
					$apiResponse = array('status' => array('success' => 1), 'bookingId' => $FlightBookingData->params[0]['bookingId']);
					if ($route == 2 && $interNationalSearch == 1) {
						$this->UpdateFlightBookingDataSFInter($FlightBookingData->params, $getData['TraceId'], $sessionFlightSearchParams->params);
					}
				} else {
					$requestAPI = array(
						'priceIds' => explode(',',$getQ['TraceId'])
					);
					$requestAPIArray = $requestAPI;
					$FlightClasses = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getFlightClassesTripJack();
					$cabinClass = $FlightClasses[$sessionFlightSearchParams->params['flight_class']];
					
					// $route = count($post['TPJ']['post']['searchQuery']['routeInfos']);
					$DataS = array(
						'apidata' => !empty($FareQuoteReq) ? $FareQuoteReq : $requestAPI,
						'memberCount' => $intMemberCount,
						'JourneyType' => $route,
						'SegmentCount' => $SegmentCount,
						'interNationalSearch' => $interNationalSearch,
						'searchID' => $SearchTraceId,
						'ICSourceSysId' => $ICSourceSysId,
						'cabinClass' => $cabinClass,
						'ADULT' => $adultCount,
						'CHILD' => $childCount,
						'INFANT' => $infantCount,
						'AgentMarkUp' => 0,
						'APIMode' => $this->APIMode,
					);
					// echo "apiResponse<pre>";print_r(json_encode($DataS));die;
					$url = $this->GTXAPIDEFAULT.'/flight/v3/farequote';
					$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
					
				}

				if (!empty($getData['ApiResultIndexInb'])) {
					$getQInb = array(
						'ApiResultIndex' => $getData['ApiResultIndexInb'],
						'TraceId' => $getData['ApiResultIndexInb'],
						'Inbound' => true,
					);
					//$apiResponseInbound = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareQuoteTripJack($getQInb);
				}
				$ResponseStatus = $apiResponse['status'];
				$FareChange = $apiResponse['FareChange'];
				$ErrorMessage = isset($apiResponse['message']) ? $apiResponse['message'] : '';
				// $ResponseStatus = $apiResponse['status']['success'];
				// $ErrorMessage = isset($apiResponse['errors'][0]['message']) ? $apiResponse['errors'][0]['message'] : '';
				// $ErrorMessageInb = isset($apiResponseInbound['errors'][0]['message']) ? $apiResponseInbound['errors'][0]['message'] : '';
				// $ResponseStatusInb = isset($apiResponseInbound['status']['success']) ? $apiResponseInbound['status']['success'] : 0;
				if ($ResponseStatus == 1) {
					$FlightBookingData__ = isset($apiResponse['results']) ? $apiResponse['results'] : [];
					$FARERULE = isset($apiResponse['FARERULE']) ? $apiResponse['FARERULE'] : [];
					$FlightBookingDataArr = [];
				
					if($FlightBookingData__){
						foreach($FlightBookingData__ as $key=>$valdata){
							$AirlineCode = $valdata['AirlineCode'];
							$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
							$FlightBookingDataArr[$key] = $valdata;
							$FlightBookingDataArr[$key]['isSeatAppli'] = true;
							$FlightBookingDataArr[$key]['AirlineSysId'] = $airlineSysId;
							$FlightBookingDataArr[$key]['bookingId'] = $bookingId_create;
							$FlightBookingDataArr[$key]['SearchFlightTraceId'] = $valdata['SearchTraceId'];
							$FlightBookingDataArr[$key]['CurrencyType'] = $this->CurrencyId;
							$FlightBookingDataArr[$key]['SourcePlaceSysId'] = $intSourceCityId;
							$FlightBookingDataArr[$key]['DestPlaceSysId'] = $intDestinationCityId;
							$FlightBookingDataArr[$key]['TravelDate'] = date('Y-m-d', strtotime($valdata['FromUTCTime']));

							// if($valdata['IsPassDateOfBirth'] && $interNationalSearch){
							// 	$FlightBookingDataArr[$key]['isDobAdult'] = true;
							// 	$FlightBookingDataArr[$key]['isDobChild'] = true;
							// 	$FlightBookingDataArr[$key]['isDobInfant'] = true;
							// }
						}
					}
					
					// $alerts = isset($apiResponse['alerts']) ? $apiResponse['alerts'] : '';
					// if ($ICSourceSysId == 7) {
					// 	$this->UpdateFlightBookingData($apiResponse, $alerts, $FareRulesTripJack);
					// }
					$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
					$FlightBookingData->params = $FlightBookingDataArr;
					// $estimetedTime1 = isset($FlightBookingData->params[0]['estimetedTime']) ? $FlightBookingData->params[0]['estimetedTime'] : '';
					// $estimetedDateTime = isset($FlightBookingData->params[0]['estimetedDateTime']) ? $FlightBookingData->params[0]['estimetedDateTime'] : '';

					// if ($this->is_decimal($estimetedTime1)) {
					// 	$estimetedTime = $estimetedTime1;
					// } else {
					// 	$estimetedTime = $estimetedTime1 . ':00';
					// }
					// if ($ICSourceSysId == 8) {
					// 	$estimetedTime = '14:00';
					// }
					$estimetedTime = '14:00';
					$newFare = 0;
					$oldFare = 0;
					$PublishedFare = 0;
					$intPublishedFare = 0;
					$Baggage = [];
					$Meal = [];

					if ($FlightBookingData->params) {
						foreach ($FlightBookingData->params as $value) {
							$intPublishedFare += isset($value['FairRules']['PublishedFare'])?$value['FairRules']['PublishedFare']:$value['FairRules']['PublishedFare'];
							$Baggage[] = $value['Baggage'];
							$Meal[] = $value['Meal'];
						}
					}

					$SSRArr = array('Meal' => $Meal, 'Baggage' => $Baggage, 'SeatPreference' => array());
					// $flightSSRDetails = new Zend_Session_Namespace('flightSSRDetails');
					// $flightSSRDetails->params = $SSRArr;
					// echo '<pre>';print_r($intPublishedFare); 
					// echo '<pre>';print_r($FlightBookingData->params); 
					// die;
					
					$TempData = array(
						'BookingData' => $FlightBookingData->params,
						'sessionFlightSearchParams' => $sessionFlightSearchParams->params,
						'FareQuoteReq' => $requestAPIArray,
						'FARERULE' => $FARERULE,
					);

					$insertArr = array(
						'TraceId' => $getData['TraceId'],
						'json_data' => json_encode($TempData),
						'created_at' => date('Y-m-d-H-i-s'),
					);
					$this->objMdl->rv_delete('tbl_temp_data', array('TraceId = ?' => $getData['TraceId']));
					$objFlight = new Travel_Model_FlightMaster();
					$objFlight->InsertFlightData('tbl_temp_data', $insertArr);
					//echo '<pre>';print_r($FlightBookingData->params);die;
					$html = new Zend_View();
					$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
					$html->assign(array('apiResponse' => $FlightBookingData->params, 'apiResponseInbound' => [], 'stylecss' => $this->stylecss, 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
					$bodyText = $html->render('getflightfarequote.phtml');
					$response = array('success' => true, 'message' => 'Done', 'FareChange' => $FareChange, 'html' => $bodyText, 'intPublishedFare' => number_format(ceil($intPublishedFare * $this->CurrencyRate)), 'SSRArr' => $SSRArr, 'SSRArrInb' => [], 'apiResponse' => $FlightBookingData->params, 'estimetedTime' => $estimetedTime, 'estimetedDateTime' => $estimetedDateTime);
					echo json_encode($response);
					exit;
				} else {
					$response = array('success' => false, 'message' => $ErrorMessage, 'FareChange' => false, 'html' => '');
					echo json_encode($response);
					exit;
				}
			} elseif ($ICSourceSysId == 3) {
				if ($BookingData) {
					$newFare = 0;
					$oldFare = 0;
					$intPublishedFare = 0;
					$FlightBookingDataArr = [];
					$SSRArr = [];
					$FareChange = false;
					$Baggage = [];
					$Meal = [];
					$SSRArr = [];
					$SSRMeal = [];
					$SSRBaggage = [];

					$tripSeatMap = [];
					$FlightData = [];
					$FARERULE = [];
					$requestAPIArray = [];
					$keys = 0;
					
					foreach ($BookingData as $key => $vl) {
						$arrData['TraceId'] = $vl['apiTraceId'];
						$arrData['ApiResultIndex'] = $vl['ApiResultIndex'];
						$SearchTraceId = $arrData['SearchFlightTraceId'] = $getData['TraceId'];
						$arrData['TraceId'] = $apiTraceId;
						$arrData['BookingData'] = $vl;
						$IsLCC = $vl['IsLCC'];
						$strAirlineCode = $vl['AirlineCode'];

						$oldFare += $vl['FairRules']['CostToAgentCustomer'];

						$request = array(
							'TraceId' => $vl['apiTraceId'],
							'ResultIndex' => $vl['FairRules']['PriceID'],
						);
						
						$DataS = array(
							'apidata'=> $request,
							'memberCount'=> $intMemberCount,
							'JourneyType'=> $route,
							'interNationalSearch'=> $interNationalSearch,
							'searchID'=> $getData['TraceId'],
							'ICSourceSysId'=> $ICSourceSysId,
							'cabinClass'=> $FlightClass,
							'AgentMarkUp'=>0,
							'AdultCount'=> $adultCount,
							'ChildCount'=> $childCount,
							'InfantCount'=> $infantCount,
							'APIMode' => $this->APIMode
						);
						if(!empty($FareQuoteReq)){
							$DataS = isset($FareQuoteReq[$key])?$FareQuoteReq[$key]:[];
						}
						
						$requestAPIArray[$key] = $DataS;
						$getData['BookingData'] = $vl;
						$url = $this->GTXAPIDEFAULT.'/flight/v3/farequote';
						// echo "DataS ==== <pre>";print_r(json_encode($DataS));die;
						$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
						// $apiResponse = json_decode('{"status":true,"message":"SUCCESS","results":[{"bookingId":"","flightKey":"eb6da129-db2e-4ffc-9e22-f40d0cb3c344","apiTraceId":"eb6da129-db2e-4ffc-9e22-f40d0cb3c344","FairRules":{"Currency":"INR","CurrencyRate":1,"currencySysId":1,"BaseFare":22232,"Tax":1765.39,"intPublishedFare":25509,"PublishedFare":26277.84,"PublishedFareAgent":26277.84,"PublishedFarePerPax":26277.84,"OfferedFare":23997.39,"CommissionEarned":786.04,"CommDiscount":0,"TDS":604.64,"TDSEarn":314.41,"Refundable":1,"IsRefundableTxt":1,"PriceID":"OB2[TBO]SZeTqqxw83QtmDr95LLWFUPpJrMMlaaHMDO3Di2fM8XAsXRBr8N4gY+WMdgKkKjAtz2sCMJTrneOmeVXGFMv2h24DIOGy1D6dT7OFIvXExnNx7V296GjHrJ3Wk8aYBSyh5Su/5CHNHHY66ih+3kSkw5wX/xiWDdtmcXvSnkD60+wFqjXdnjQfEGA9P5U+pP/PQeitGsqTiq1hb1BR7S+f5fWi/n8wrxY8x7D2kAwK7tY9brRKck0gfmvIYUrq+vXEb7Vpb3CQ7FUp5bMtcIBHLX30OLlJiojsZ1GAdLDIPDX0t0ClhVdxCCtkb0MBg1ZuPi+sdz/up+58Ynjc/aB6wbJKjh+xaimXmfUgQVcnBt01DBshSt5a0G61TN6eAC7t20xAj9Q8E7vFqbgO0gnwgh7srz7vsAddrKbIvdicC/WBFDRdOj+kWZKL1Ttbu1wq8AUvqIzu0HluQ5P41w3/a4AOcQTNeG+LqBQybfmp8zbZELQJRGYW8Q6pvodY5icSLQZRzzBUBIYy2yv+VDDykLdPjWmeELCBhcXTJiUKcetdE9WXq3q5zbSibii9bumpniYCAUgOZNV/WWe/aPtDqXghJvUBn7/fhP0MLuALNytmvrMrfRPEsgmOgIv/UfV8Ld8xU44Sr7DU4GWHC1NwVrqSPn2fVs7kmdzBW3kc6sPClmm/TT09r6gPCFFu5vMPnRon70fhYR1EAmRL62atvngKPlhKOeK4BeCcYRl3dARnEfN/qmaiBs5uz/AY2fLaxoR3Ub7XkWKWM7FirDmUj74nUeIsaOJKW+3dl4L/ro=","classOfBooking":"","FareClass":"Economy","fareIdentifier":"PUBLISH","IsSpecialReturn":false,"colors":"lightBlue","FixedMarkUp":1000,"GSTOnMarkUp":180,"IscheckinBagInc":true,"IscabinbagInc":true,"CheckinBaggage":"15KG","CabinBaggage":"Included","IsMealIncludes":false,"IsGSTRequired":null,"FareBreakdown":[{"Currency":"INR","PassengerType":1,"PaxType":"ADULT","PassengerCount":1,"intBaseFare":22232,"intTax":3277,"BaseFare":22232,"Tax":1765.39,"TaxBR":{"OT":1765.39,"MF":0,"YQ":0,"intYQ":0,"AGST":0,"MFT":0,"AdditionalTxnFeeOfrd":0,"AdditionalTxnFeePub":0,"YR":0},"OfferedFare":23997.39,"PublishedFare":26277.84,"TDS":604.64,"TDSEarn":314.41,"ApiNCM":1511.61,"CommissionEarned":786.04,"FixedMarkUp":1000,"GSTOnMarkUp":180,"CommDiscount":725.57,"AgentMarkUp":0,"CostToAgentCustomer":26277.84,"Baggage":"15KG","CabinBaggage":"Included"}],"tripbinfo":{"DEL-BOM":{"ADULT":{"cabin":"Included","checkin":"15KG"}},"BOM-VNS":{"ADULT":{"cabin":"Included","checkin":"15KG"}},"VNS-BOM":{"ADULT":{"cabin":"Included","checkin":"15KG"}},"BOM-GOI":{"ADULT":{"cabin":"Included","checkin":"15KG"}}},"MiniFR":{"REISSUE":[{"sector":"DEL-BOM-VNS-GOI","amount":"INR 9000*","additionalFee":null,"TimeFrame":"from   & above before dept","policyInfo":[]}],"CANCELLATION":{"1":{"sector":"DEL-BOM-VNS-GOI","amount":"INR 12000*","additionalFee":null,"TimeFrame":"from   & above before dept","policyInfo":[]}}}},"Segments":[{"segmentid":"863","isReturnSegment":0,"arrivingnextday":null,"originAirportName":"Indira Gandhi Airport","destinationAirportName":"Chhatrapati Shivaji International Airport","originCityName":"Delhi","originCountryName":"India","destinationCityName":"Mumbai","destinationCountryName":"India","destinationAirportCode":"BOM","destinationArrTime":"2024-11-05T16:20:00","SegFlightNumber":"AI-863","AirlineCode":"AI","AirlineName":"Air India","FareClass":"U","cabinClass":"Economy","originAirportCode":"DEL","originDepTime":"2024-11-05T14:10:00","TripIndicator":1,"IscheckinBagInc":true,"IscabinbagInc":true,"CheckinBaggage":"15KG","CabinBaggage":"Included","IsMealIncludes":false,"Duration":130,"GroundTime":0,"NoOfSeatAvailable":0,"strDepartureDtTime":"14:10","strArrivalDtTime":"16:20","FlightDuration":"2h 10m","LAYOVERDuration":"0h 0m","LAYOVERCity":"Delhi","DepTerminal":"Terminal 3","ArrTerminal":"Terminal 2","Remark":null,"logo":"http://local.gtxapi.com/public/AirlineLogo/AI.png","BAGGAGE":[],"MEAL":[]}],"Ispassengercity":true,"Ispassengeraddress":true,"isGSTMandatory":false,"IsPassMandatory":false,"IsPassExpiry":false,"IsPassIssue":false,"IsPassDateOfBirth":false,"isDobAdult":false,"isDobChild":true,"isDobInfant":true,"isSeatAppli":true,"NoOfSeatAvailable":0,"logo":"http://local.gtxapi.com/public/AirlineLogo/AI.png","IsInternational":0,"ICSourceSysId":3,"TripType":1,"JourneyType":"3","StopCount":"Non-stop","FlightDuration":"2h 10m","FlightNumber":"AI-863","SegFlightNumberArr":"AI-863","AirlineName":"Air india","AirlineCode":"AI","IsLCC":false,"SearchTraceId":"94880-115d5-2d2f2-83d4f","IsRefundable":1,"IsRefundableTxt":"Refundable","FromUTCTime":"2024-11-05 14:10","ToUTCTime":"2024-11-05 16:20","FareClass":"Economy","SourceAirportCode":"DEL","DestAirportCode":"BOM","isDocIdAllowedMandatory":false,"isHoldAllowed":true,"IsHoldAllowedWithSSR":true,"pricechanged":false,"isSessionTime":"0:00"},{"bookingId":"","flightKey":"eb6da129-db2e-4ffc-9e22-f40d0cb3c344","apiTraceId":"eb6da129-db2e-4ffc-9e22-f40d0cb3c344","FairRules":{"Currency":"INR","CurrencyRate":1,"currencySysId":1,"BaseFare":22232,"Tax":1765.39,"intPublishedFare":25509,"PublishedFare":26277.84,"PublishedFareAgent":26277.84,"PublishedFarePerPax":26277.84,"OfferedFare":23997.39,"CommissionEarned":786.04,"CommDiscount":0,"TDS":604.64,"TDSEarn":314.41,"Refundable":1,"IsRefundableTxt":1,"PriceID":"OB2[TBO]SZeTqqxw83QtmDr95LLWFUPpJrMMlaaHMDO3Di2fM8XAsXRBr8N4gY+WMdgKkKjAtz2sCMJTrneOmeVXGFMv2h24DIOGy1D6dT7OFIvXExnNx7V296GjHrJ3Wk8aYBSyh5Su/5CHNHHY66ih+3kSkw5wX/xiWDdtmcXvSnkD60+wFqjXdnjQfEGA9P5U+pP/PQeitGsqTiq1hb1BR7S+f5fWi/n8wrxY8x7D2kAwK7tY9brRKck0gfmvIYUrq+vXEb7Vpb3CQ7FUp5bMtcIBHLX30OLlJiojsZ1GAdLDIPDX0t0ClhVdxCCtkb0MBg1ZuPi+sdz/up+58Ynjc/aB6wbJKjh+xaimXmfUgQVcnBt01DBshSt5a0G61TN6eAC7t20xAj9Q8E7vFqbgO0gnwgh7srz7vsAddrKbIvdicC/WBFDRdOj+kWZKL1Ttbu1wq8AUvqIzu0HluQ5P41w3/a4AOcQTNeG+LqBQybfmp8zbZELQJRGYW8Q6pvodY5icSLQZRzzBUBIYy2yv+VDDykLdPjWmeELCBhcXTJiUKcetdE9WXq3q5zbSibii9bumpniYCAUgOZNV/WWe/aPtDqXghJvUBn7/fhP0MLuALNytmvrMrfRPEsgmOgIv/UfV8Ld8xU44Sr7DU4GWHC1NwVrqSPn2fVs7kmdzBW3kc6sPClmm/TT09r6gPCFFu5vMPnRon70fhYR1EAmRL62atvngKPlhKOeK4BeCcYRl3dARnEfN/qmaiBs5uz/AY2fLaxoR3Ub7XkWKWM7FirDmUj74nUeIsaOJKW+3dl4L/ro=","classOfBooking":"","FareClass":"Economy","fareIdentifier":"PUBLISH","IsSpecialReturn":false,"colors":"lightBlue","FixedMarkUp":1000,"GSTOnMarkUp":180,"IscheckinBagInc":true,"IscabinbagInc":true,"CheckinBaggage":"15KG","CabinBaggage":"Included","IsMealIncludes":false,"IsGSTRequired":null,"FareBreakdown":[{"Currency":"INR","PassengerType":1,"PaxType":"ADULT","PassengerCount":1,"intBaseFare":22232,"intTax":3277,"BaseFare":22232,"Tax":1765.39,"TaxBR":{"OT":1765.39,"MF":0,"YQ":0,"intYQ":0,"AGST":0,"MFT":0,"AdditionalTxnFeeOfrd":0,"AdditionalTxnFeePub":0,"YR":0},"OfferedFare":23997.39,"PublishedFare":26277.84,"TDS":604.64,"TDSEarn":314.41,"ApiNCM":1511.61,"CommissionEarned":786.04,"FixedMarkUp":1000,"GSTOnMarkUp":180,"CommDiscount":725.57,"AgentMarkUp":0,"CostToAgentCustomer":26277.84,"Baggage":"15KG","CabinBaggage":"Included"}],"tripbinfo":{"DEL-BOM":{"ADULT":{"cabin":"Included","checkin":"15KG"}},"BOM-VNS":{"ADULT":{"cabin":"Included","checkin":"15KG"}},"VNS-BOM":{"ADULT":{"cabin":"Included","checkin":"15KG"}},"BOM-GOI":{"ADULT":{"cabin":"Included","checkin":"15KG"}}},"MiniFR":{"REISSUE":[{"sector":"DEL-BOM-VNS-GOI","amount":"INR 9000*","additionalFee":null,"TimeFrame":"from   & above before dept","policyInfo":[]}],"CANCELLATION":{"1":{"sector":"DEL-BOM-VNS-GOI","amount":"INR 12000*","additionalFee":null,"TimeFrame":"from   & above before dept","policyInfo":[]}}}},"Segments":[{"segmentid":"695","isReturnSegment":1,"arrivingnextday":null,"originAirportName":"Chhatrapati Shivaji International Airport","destinationAirportName":"Varanasi","originCityName":"Mumbai","originCountryName":"India","destinationCityName":"Varanasi","destinationCountryName":"India","destinationAirportCode":"VNS","destinationArrTime":"2024-11-08T12:30:00","SegFlightNumber":"AI-695","AirlineCode":"AI","AirlineName":"Air India","FareClass":"L","cabinClass":"Economy","originAirportCode":"BOM","originDepTime":"2024-11-08T10:15:00","TripIndicator":2,"IscheckinBagInc":true,"IscabinbagInc":true,"CheckinBaggage":"15KG","CabinBaggage":"Included","IsMealIncludes":false,"Duration":135,"GroundTime":0,"NoOfSeatAvailable":0,"strDepartureDtTime":"10:15","strArrivalDtTime":"12:30","FlightDuration":"2h 15m","LAYOVERDuration":"0h 0m","LAYOVERCity":"Mumbai","DepTerminal":"Terminal 2","ArrTerminal":"Terminal 0","Remark":null,"logo":"http://local.gtxapi.com/public/AirlineLogo/AI.png","BAGGAGE":[],"MEAL":[]}],"Ispassengercity":true,"Ispassengeraddress":true,"isGSTMandatory":false,"IsPassMandatory":false,"IsPassExpiry":false,"IsPassIssue":false,"IsPassDateOfBirth":false,"isDobAdult":false,"isDobChild":true,"isDobInfant":true,"isSeatAppli":true,"NoOfSeatAvailable":0,"logo":"http://local.gtxapi.com/public/AirlineLogo/AI.png","IsInternational":0,"ICSourceSysId":3,"TripType":1,"JourneyType":"3","StopCount":"Non-stop","FlightDuration":"2h 15m","FlightNumber":"AI-863","SegFlightNumberArr":"AI-863, AI-695","AirlineName":"Air india","AirlineCode":"AI","IsLCC":false,"SearchTraceId":"94880-115d5-2d2f2-83d4f","IsRefundable":1,"IsRefundableTxt":"Refundable","FromUTCTime":"2024-11-08 10:15","ToUTCTime":"2024-11-08 12:30","FareClass":"Economy","SourceAirportCode":"BOM","DestAirportCode":"VNS","isDocIdAllowedMandatory":false,"isHoldAllowed":true,"IsHoldAllowedWithSSR":true,"pricechanged":false,"isSessionTime":"0:00"},{"bookingId":"","flightKey":"eb6da129-db2e-4ffc-9e22-f40d0cb3c344","apiTraceId":"eb6da129-db2e-4ffc-9e22-f40d0cb3c344","FairRules":{"Currency":"INR","CurrencyRate":1,"currencySysId":1,"BaseFare":22232,"Tax":1765.39,"intPublishedFare":25509,"PublishedFare":26277.84,"PublishedFareAgent":26277.84,"PublishedFarePerPax":26277.84,"OfferedFare":23997.39,"CommissionEarned":786.04,"CommDiscount":0,"TDS":604.64,"TDSEarn":314.41,"Refundable":1,"IsRefundableTxt":1,"PriceID":"OB2[TBO]SZeTqqxw83QtmDr95LLWFUPpJrMMlaaHMDO3Di2fM8XAsXRBr8N4gY+WMdgKkKjAtz2sCMJTrneOmeVXGFMv2h24DIOGy1D6dT7OFIvXExnNx7V296GjHrJ3Wk8aYBSyh5Su/5CHNHHY66ih+3kSkw5wX/xiWDdtmcXvSnkD60+wFqjXdnjQfEGA9P5U+pP/PQeitGsqTiq1hb1BR7S+f5fWi/n8wrxY8x7D2kAwK7tY9brRKck0gfmvIYUrq+vXEb7Vpb3CQ7FUp5bMtcIBHLX30OLlJiojsZ1GAdLDIPDX0t0ClhVdxCCtkb0MBg1ZuPi+sdz/up+58Ynjc/aB6wbJKjh+xaimXmfUgQVcnBt01DBshSt5a0G61TN6eAC7t20xAj9Q8E7vFqbgO0gnwgh7srz7vsAddrKbIvdicC/WBFDRdOj+kWZKL1Ttbu1wq8AUvqIzu0HluQ5P41w3/a4AOcQTNeG+LqBQybfmp8zbZELQJRGYW8Q6pvodY5icSLQZRzzBUBIYy2yv+VDDykLdPjWmeELCBhcXTJiUKcetdE9WXq3q5zbSibii9bumpniYCAUgOZNV/WWe/aPtDqXghJvUBn7/fhP0MLuALNytmvrMrfRPEsgmOgIv/UfV8Ld8xU44Sr7DU4GWHC1NwVrqSPn2fVs7kmdzBW3kc6sPClmm/TT09r6gPCFFu5vMPnRon70fhYR1EAmRL62atvngKPlhKOeK4BeCcYRl3dARnEfN/qmaiBs5uz/AY2fLaxoR3Ub7XkWKWM7FirDmUj74nUeIsaOJKW+3dl4L/ro=","classOfBooking":"","FareClass":"Economy","fareIdentifier":"PUBLISH","IsSpecialReturn":false,"colors":"lightBlue","FixedMarkUp":1000,"GSTOnMarkUp":180,"IscheckinBagInc":true,"IscabinbagInc":true,"CheckinBaggage":"15KG","CabinBaggage":"Included","IsMealIncludes":false,"IsGSTRequired":null,"FareBreakdown":[{"Currency":"INR","PassengerType":1,"PaxType":"ADULT","PassengerCount":1,"intBaseFare":22232,"intTax":3277,"BaseFare":22232,"Tax":1765.39,"TaxBR":{"OT":1765.39,"MF":0,"YQ":0,"intYQ":0,"AGST":0,"MFT":0,"AdditionalTxnFeeOfrd":0,"AdditionalTxnFeePub":0,"YR":0},"OfferedFare":23997.39,"PublishedFare":26277.84,"TDS":604.64,"TDSEarn":314.41,"ApiNCM":1511.61,"CommissionEarned":786.04,"FixedMarkUp":1000,"GSTOnMarkUp":180,"CommDiscount":725.57,"AgentMarkUp":0,"CostToAgentCustomer":26277.84,"Baggage":"15KG","CabinBaggage":"Included"}],"tripbinfo":{"DEL-BOM":{"ADULT":{"cabin":"Included","checkin":"15KG"}},"BOM-VNS":{"ADULT":{"cabin":"Included","checkin":"15KG"}},"VNS-BOM":{"ADULT":{"cabin":"Included","checkin":"15KG"}},"BOM-GOI":{"ADULT":{"cabin":"Included","checkin":"15KG"}}},"MiniFR":{"REISSUE":[{"sector":"DEL-BOM-VNS-GOI","amount":"INR 9000*","additionalFee":null,"TimeFrame":"from   & above before dept","policyInfo":[]}],"CANCELLATION":{"1":{"sector":"DEL-BOM-VNS-GOI","amount":"INR 12000*","additionalFee":null,"TimeFrame":"from   & above before dept","policyInfo":[]}}}},"Segments":[{"segmentid":"696","isReturnSegment":2,"arrivingnextday":null,"originAirportName":"Varanasi","destinationAirportName":"Chhatrapati Shivaji International Airport","originCityName":"Varanasi","originCountryName":"India","destinationCityName":"Mumbai","destinationCountryName":"India","destinationAirportCode":"BOM","destinationArrTime":"2024-11-11T15:50:00","SegFlightNumber":"AI-696","AirlineCode":"AI","AirlineName":"Air India","FareClass":"U","cabinClass":"Economy","originAirportCode":"VNS","originDepTime":"2024-11-11T13:25:00","TripIndicator":3,"IscheckinBagInc":true,"IscabinbagInc":true,"CheckinBaggage":"15KG","CabinBaggage":"Included","IsMealIncludes":false,"Duration":145,"GroundTime":0,"NoOfSeatAvailable":0,"strDepartureDtTime":"13:25","strArrivalDtTime":"15:50","FlightDuration":"2h 25m","LAYOVERDuration":"0h 0m","LAYOVERCity":"Varanasi","DepTerminal":"Terminal 0","ArrTerminal":"Terminal 2","Remark":null,"logo":"http://local.gtxapi.com/public/AirlineLogo/AI.png","BAGGAGE":[],"MEAL":[]},{"segmentid":"683","isReturnSegment":2,"arrivingnextday":null,"originAirportName":"Chhatrapati Shivaji International Airport","destinationAirportName":"Dabolim","originCityName":"Mumbai","originCountryName":"India","destinationCityName":"Goa","destinationCountryName":"India","destinationAirportCode":"GOI","destinationArrTime":"2024-11-11T22:15:00","SegFlightNumber":"AI-683","AirlineCode":"AI","AirlineName":"Air India","FareClass":"U","cabinClass":"Economy","originAirportCode":"BOM","originDepTime":"2024-11-11T21:10:00","TripIndicator":3,"IscheckinBagInc":true,"IscabinbagInc":true,"CheckinBaggage":"15KG","CabinBaggage":"Included","IsMealIncludes":false,"Duration":65,"GroundTime":0,"NoOfSeatAvailable":0,"strDepartureDtTime":"21:10","strArrivalDtTime":"22:15","FlightDuration":"1h 5m","LAYOVERDuration":"0h 0m","LAYOVERCity":"Mumbai","DepTerminal":"Terminal 2","ArrTerminal":"Terminal 0","Remark":null,"logo":"http://local.gtxapi.com/public/AirlineLogo/AI.png","BAGGAGE":[],"MEAL":[]}],"Ispassengercity":true,"Ispassengeraddress":true,"isGSTMandatory":false,"IsPassMandatory":false,"IsPassExpiry":false,"IsPassIssue":false,"IsPassDateOfBirth":false,"isDobAdult":false,"isDobChild":true,"isDobInfant":true,"isSeatAppli":true,"NoOfSeatAvailable":0,"logo":"http://local.gtxapi.com/public/AirlineLogo/AI.png","IsInternational":0,"ICSourceSysId":3,"TripType":1,"JourneyType":"3","StopCount":"Non-stop","FlightDuration":"11h 15m","FlightNumber":"AI-863","SegFlightNumberArr":"AI-863, AI-695, AI-696, AI-683","AirlineName":"Air india","AirlineCode":"AI","IsLCC":false,"SearchTraceId":"94880-115d5-2d2f2-83d4f","IsRefundable":1,"IsRefundableTxt":"Refundable","FromUTCTime":"2024-11-11 13:25","ToUTCTime":"2024-11-11 22:15","FareClass":"Economy","SourceAirportCode":"VNS","DestAirportCode":"GOI","isDocIdAllowedMandatory":false,"isHoldAllowed":true,"IsHoldAllowedWithSSR":true,"pricechanged":false,"isSessionTime":"0:00"}],"FareChange":null,"FARERULE":null,"SSRData":[],"tripSeatMap":{"tripSeatMap":{"tripSeat":[],"DataSet":[]},"status":{"success":false,"httpStatus":400}}}',1);
						// echo "apiResponse<pre>";print_r(json_encode($DataS));
						// echo "apiResponse<pre>";print_r(json_encode($FlightBookingDataArr));
						// die('qqqqq');
						$ResponseStatus = $apiResponse['status'];
						
						$ErrorMessage = isset($apiResponse['message']) ? $apiResponse['message'] : '';
						if ($ResponseStatus == 1) {
							$FlightBookingData__ = isset($apiResponse['results']) ? $apiResponse['results'] : '';

							$PublishedFare = 0;
							$intPublishedFare = 0;

							$tripSeatMap[] = isset($apiResponse['tripSeatMap']) ? $apiResponse['tripSeatMap'] : [];
							$FareChange = isset($apiResponse['FareChange']) ? $apiResponse['FareChange'] : 0;
							$FARERULE[] = isset($apiResponse['FARERULE']) ? $apiResponse['FARERULE'] : [];
							
							// $FlightBookingDataArr = [];
							if ($FlightBookingData__) {
								foreach ($FlightBookingData__ as $value) {
									if($value['Segments']){
										foreach($value['Segments'] as $kkkk => $val){
											$mealArray = isset($val['MEAL'])?array_values($val['MEAL']):[];
											$baggageArray = isset($val['BAGGAGE'])?array_values($val['BAGGAGE']):[];
											// $baggageArray = [];
											// if(isset($val['BAGGAGE']) && !empty($val['BAGGAGE'])){
											// 	$baggageArray = array_values($val['BAGGAGE']);
											// }
											foreach($baggageArray as $keydd => $csm){
												$baggageArray[$keydd]['segmentid'] = $val['segmentid'];
												$baggageArray[$keydd]['amount'] = $csm['Price'];
											}
											foreach($mealArray as $keysdd => $csm){
												$mealArray[$keysdd]['segmentid'] = $val['segmentid'];
												$mealArray[$keysdd]['amount'] = $csm['Price'];
											}
											if(!empty($baggageArray)){
												$SSRBaggage[] = isset($baggageArray) ? $baggageArray : [];
											}
											if(!empty($mealArray)){
												$SSRMeal[] = isset($mealArray) ? $mealArray : [];
											}
										}
										// foreach($SSRMeal__ as $valMeal){
										// 	$SSRMeal[] = array_values($valMeal);
										// }
										// $SSRMeal[] = isset($mealArray) ? $mealArray : [];
										
									}
									$AirlineCode = $value['AirlineCode'];
									$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
									$FlightBookingDataArr[$keys] = $value;
									$FlightBookingDataArr[$key]['bookingId'] = $bookingId_create;
									$FlightBookingDataArr[$keys]['isSeatAppli'] = $value['isSeatAppli'];
									$FlightBookingDataArr[$keys]['AirlineSysId'] = $airlineSysId;
									$FlightBookingDataArr[$keys]['SearchFlightTraceId'] = $value['SearchTraceId'];
									$FlightBookingDataArr[$keys]['CurrencyType'] = $this->CurrencyId;
									$FlightBookingDataArr[$keys]['SourcePlaceSysId'] = $intSourceCityId;
									$FlightBookingDataArr[$keys]['DestPlaceSysId'] = $intDestinationCityId;
									$FlightBookingDataArr[$keys]['TravelDate'] = date('Y-m-d', strtotime($value['FromUTCTime']));
									$intPublishedFare += $value['FairRules']['PublishedFareAgent'];
									$Baggage[] = $value['Baggage'];
									$Meal[] = $value['Meal'];
									$keys++;
								}
							}
							
									
						} else {
							$response = array('success' => false, 'message' => 'Session is expired. Please try again with new session', 'FareChange' => false, 'html' => '');
							echo json_encode($response);
							exit;
						}


						// echo "FlightBookingDataArr<pre>";print_r(json_encode($FlightBookingDataArr));die;

						// old code below
						// $apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareQuote($arrData);
						// $arrSSR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->flightSSRDetails($arrData);
						// $IsPriceChanged = $apiResponse['Response']['IsPriceChanged'];
						// $ResponseStatus = $apiResponse['Response']['ResponseStatus'];
						// $ErrorMessage = $apiResponse['Response']['Error']['ErrorMessage'];
						// if ($ResponseStatus == 1) {
						// 	$FBD = $this->UpdateFlightBookingDataTBO($apiResponse, $arrSSR, $vl);
						// 	$SSRArr[$key] = isset($FBD['SSRArr']) ? $FBD['SSRArr'] : [];
						// 	// echo '<pre>';print_r($FBD);
						// 	// $tripSeatMap = isset($FBD['tripSeatMap']) ? $FBD['tripSeatMap'] : [];
						// 	if ($IsLCC) {
						// 	}
						// 	$FlightBookingDataArr[$key] = $FBD['BookingData'];
						// } else {
						// 	$response = array('success' => false, 'message' => $ErrorMessage, 'FareChange' => false, 'html' => '');
						// 	echo json_encode($response);
						// 	exit;
						// }
					}
					// echo "FlightData<pre>";print_r(json_encode($FlightBookingDataArr));die;
					$SSRArr_ = array('Meal' => $SSRMeal, 'Baggage' => $SSRBaggage, 'SeatPreference' => []);
					// echo "SSRArr_<pre>";print_r(($requestAPIArray));die;
					$flightSSRDetails = new Zend_Session_Namespace('flightSSRDetails');
					$flightSSRDetails->params = $SSRArr_;
					
					$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
					$FlightBookingData->params = $FlightBookingDataArr;

					$arrUrlData['BookingData'] = $FlightBookingDataArr;
					// $arrUrlData['FlightBookingData'] = $FlightBookingDataArr;
					// $arrUrlData['SSRArr'] = $SSRArr;
					$arrUrlData['FareQuoteReq'] = $requestAPIArray;
					$arrUrlData['tripSeatMap'] = $tripSeatMap;
					$arrUrlData['FARERULE'] = $FARERULE;
					// $arrUrlData['flightSSRDetails'] = isset($SSRArr_) ? $SSRArr_ : [];
					$arrUrlData['FareRuleRequest'] = $FARERULE;
					// 
					$isHoldAllowed = isset($FlightBookingDataArr[0]['isHoldAllowed']) ? $FlightBookingDataArr[0]['isHoldAllowed'] : false;
					$tempData = array(
						'TraceId' => $SearchTraceId,
						'json_data' => json_encode($arrUrlData),
					);
					$objFlight = new Travel_Model_FlightMaster();
					// echo "arrUrlData<pre>";print_r(($tempData));die;
					$objFlight->deleteFlightTempData($SearchTraceId);
					$objFlight->insertFlightTempData($tempData);
					$FareChange = $pricechanged;
					$html = new Zend_View();
					$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
					$html->assign(array('apiResponse' => $FlightBookingDataArr, 'gtxagencysysid' => $this->gtxagencysysid, 'stylecss' => $this->stylecss, 'apiResponseInbound' => [], 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
					$bodyText = $html->render('getflightfarequote.phtml');
					$response = array('success' => true, 'message' => 'Done', 'FareChange' => $FareChange, 'html' => $bodyText, 'intPublishedFare' => number_format(ceil($intPublishedFare * $this->CurrencyRate)), 'SSRArr' => isset($SSRArr_) ? $SSRArr_ : [], 'SSRArrInb' => [], 'apiResponse' => $FlightBookingDataArr);
					echo json_encode($response);
					exit;




					// echo '<pre>';print_r($FlightBookingDataArr); die;
					$MealArray = [];
					$BaggageArray = [];
					$SeatArray = [];
					if ($SSRArr) {
						foreach ($SSRArr as $bg) {
							//$SeatArray[] = $bg['SeatPreference'];
							if ($bg['Meal']) {
								foreach ($bg['Meal'] as $ml) {
									$MealArray[] = $ml;
								}
							}
							if ($bg['Baggage']) {
								foreach ($bg['Baggage'] as $vl) {
									$BaggageArray[] = $vl;
								}
							}
							if ($bg['SeatPreference']) {
								foreach ($bg['SeatPreference'] as $sgi => $val) {
									$SeatArray[$sgi] = $val;
								}
							}
						}
					}

					$SSRArr_ = array('Meal' => $MealArray, 'Baggage' => $BaggageArray, 'SeatPreference' => $SeatArray);
					$flightSSRDetails = new Zend_Session_Namespace('flightSSRDetails');
					$flightSSRDetails->params = $SSRArr_;
					// echo '<pre>';print_r($MealArray);
					// echo '<pre>';print_r($FlightBookingDataArr);
					// die;
					$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
					$FlightBookingData->params = $FlightBookingDataArr;
					$FareChange = $IsPriceChanged;
					$PublishedFare = 0;
					if ($FlightBookingData->params) {
						foreach ($FlightBookingData->params as $value) {
							$value['FairRules'] = $value['NewPrice'];
							$newFare += $value['FairRules']['newFare'];
							$PublishedFare += $value['FairRules']['newFare'];
							$intPublishedFare += $value['FairRules']['PublishedFare'];
							$oldFare += $value['FairRules']['oldFare'];
						}
					}
					$arrUrlData['BookingData'] = $apiResponse;//$FlightBookingDataArr;
					$arrUrlData['FlightBookingDataInbound'] = [];
					$arrUrlData['sessionFlightSearchParams'] = $sessionFlightSearchParams->params;
					$arrUrlData['flightSSRDetails'] = isset($SSRArr_) ? $SSRArr_ : [];
					$arrUrlData['flightSSRDetailsInb'] = isset($SSRArr[1]) ? $SSRArr[1] : [];
					$arrUrlData['FareRuleRequest'] = $FareRuleRequest;
					$insertArr = array(
						'TraceId' => $getData['TraceId'],
						'json_data' => json_encode($arrUrlData),
						'created_at' => date('Y-m-d H:i:s'),
					);
					$this->objMdl->rv_delete('tbl_temp_data', array('TraceId = ?' => $getData['TraceId']));
					$objFlight = new Travel_Model_FlightMaster();
					$objFlight->InsertFlightData('tbl_temp_data', $insertArr);
					// echo '<pre>';
					// print_r($FlightBookingDataArr);
					// die;
					$html = new Zend_View();
					$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
					$html->assign(array('apiResponse' => $FlightBookingData->params, 'gtxagencysysid' => $this->gtxagencysysid, 'stylecss' => $this->stylecss, 'apiResponseInbound' => [], 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
					$bodyText = $html->render('getflightfarequote.phtml');
					$response = array('success' => true, 'message' => 'Done', 'FareChange' => $FareChange, 'html' => $bodyText, 'intPublishedFare' => number_format(ceil($intPublishedFare * $this->CurrencyRate)), 'SSRArr' => isset($SSRArr_) ? $SSRArr_ : [], 'SSRArrInb' => [], 'apiResponse' => $FlightBookingData->params);
					echo json_encode($response);
					exit;
				}
			} elseif($ICSourceSysId == 17) {
				$ApiResultIndex = isset($arrUrlData['BookingData'][0]['FairRules']['PriceID']) ? $arrUrlData['BookingData'][0]['FairRules']['PriceID'] : '';
				$SearchTraceId = isset($arrUrlData['BookingData'][0]['SearchTraceId']) ? $arrUrlData['BookingData'][0]['SearchTraceId'] : '';
				if($route == 2 && $interNationalSearch == 1){
					$ApiResultIndex = isset($arrUrlData['BookingData'][0]['origin']['ApiResultIndex']) ? $arrUrlData['BookingData'][0]['origin']['ApiResultIndex'] : '';
					$ApiResultIndexReturn = isset($arrUrlData['BookingData'][0]['destination']['ApiResultIndex']) ? $arrUrlData['BookingData'][0]['destination']['ApiResultIndex'] : '';
			
				}elseif($route == 2 && $interNationalSearch != 1){
					$ApiResultIndex = isset($arrUrlData['BookingData'][0]['FairRules']['PriceID']) ? $arrUrlData['BookingData'][0]['FairRules']['PriceID'] : '';
					$ApiResultIndexReturn = isset($arrUrlData['BookingData'][1]['FairRules']['PriceID']) ? $arrUrlData['BookingData'][1]['FairRules']['PriceID'] : '';
				
					if($arrUrlData['BookingData'][0]['AirlineName'] != $arrUrlData['BookingData'][1]['AirlineName'] || $arrUrlData['BookingData'][0]['FairRules']['fareIdentifier'] != $arrUrlData['BookingData'][1]['FairRules']['fareIdentifier']){
						$response = array('success' => false, 'message' => 'Please select same both airline and fare type', 'html' => '');
						// echo "response<pre>";print_r(json_encode($response));die("tttttttt");
						echo json_encode($response);
						exit;
					}
				}
				$selectedflight = isset($ApiResultIndex) ? $ApiResultIndex : 0;
				$request = array(
					"pricingrequest" => [
						'selectedflight'=>$selectedflight,
						'domint'=>($interNationalSearch)?'international':'domestic',
						'selectedflight_return'=>isset($ApiResultIndexReturn) ? $ApiResultIndexReturn :"",
					],
				);
				$farerulerequest = array(
					"farerulerequest" => [
						'selectedflight'=>$selectedflight,
						'selectedflighttw'=>isset($ApiResultIndexReturn) ? $ApiResultIndexReturn : "",
					],
				);
				
				$DataS = array(
					'apidata'=>$request,
					'farerule'=>$farerulerequest,
					'memberCount'=>$intMemberCount,
					'JourneyType'=>$route,
					'interNationalSearch'=>$interNationalSearch,
					'searchID'=>$SearchTraceId,
					'ICSourceSysId'=>$ICSourceSysId,
					'cabinClass'=>$FlightClass,
					'AgentMarkUp'=>0,
					'AdultCount'=>$adultCount,
					'ChildCount'=>$childCount,
					'InfantCount'=>$infantCount,
					'APIMode' => $this->APIMode
				);
				// echo "DataS<pre>";print_r(json_encode($DataS));die("DataS");
				$getData['BookingData'] = $arrUrlData['BookingData'][0];
				$url = $this->GTXAPIDEFAULT.'/flight/v3/farequote';
				$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
				// $apiResponse = json_decode('{"status":true,"message":"SUCCESS","results":[{"ApiResultIndex":"catabatic_deeplinkbooking_ATI_1728625093245-0.4742140149085894@@saas_gatewaytest","bookingkey":"catabatic_deeplinkbooking_ATI_1728625093245-0.4742140149085894@@saas_gatewaytest","flightKey":"_deeplink_ATI_1728625093246-0.2505506647029674-0@@saas_gatewaytest","FairRules":{"Currency":"INR","CurrencyRate":1,"currencySysId":1,"BaseFare":8200,"Tax":3146,"intPublishedFare":11346,"PublishedFare":13116,"PublishedFarePerPax":4372,"OfferedFare":11346,"CommissionEarned":0,"CommDiscount":0,"TDS":"0","TDSEarn":0,"Refundable":true,"IsRefundableTxt":"Refundable","PriceID":"_deeplink_ATI_1728625093246-0.2505506647029674-0@@saas_gatewaytest","NoOfSeatAvailable":3,"FixedMarkUp":1500,"GSTOnMarkUp":270,"fareremarks":"","IsMealIncludes":false,"FareBreakdown":[{"Currency":"INR","PassengerType":1,"PaxType":"ADULT","PassengerCount":"1","BaseFare":4100,"Tax":698,"OfferedFare":3782,"PublishedFare":4372,"TDS":"0","TDSEarn":0,"TaxBR":{"MF":0,"YQ":0,"AGST":0,"MFT":0,"OT":698,"YR":0},"ApiNCM":0,"CommissionEarned":0,"FixedMarkUp":500,"GSTOnMarkUp":90,"CommDiscount":0,"CostToAgent":4372,"intTotalGST":90,"AgentMarkUp":0,"CostToAgentCustomer":4372},{"Currency":"INR","PassengerType":2,"PaxType":"CHILD","PassengerCount":"1","BaseFare":4100,"Tax":698,"OfferedFare":3782,"PublishedFare":4372,"TDS":"0","TDSEarn":0,"TaxBR":{"MF":0,"YQ":0,"AGST":0,"MFT":0,"OT":698,"YR":0},"ApiNCM":0,"CommissionEarned":0,"FixedMarkUp":500,"GSTOnMarkUp":90,"CommDiscount":0,"CostToAgent":4372,"intTotalGST":90,"AgentMarkUp":0,"CostToAgentCustomer":4372},{"Currency":"INR","PassengerType":3,"PaxType":"INFANT","PassengerCount":"1","BaseFare":0,"Tax":1750,"OfferedFare":3782,"PublishedFare":8744,"TDS":"0","TDSEarn":0,"TaxBR":{"MF":0,"YQ":0,"AGST":0,"MFT":0,"OT":1750,"YR":0},"ApiNCM":0,"CommissionEarned":0,"FixedMarkUp":500,"GSTOnMarkUp":90,"CommDiscount":0,"CostToAgent":4372,"intTotalGST":90,"AgentMarkUp":0,"CostToAgentCustomer":4372}],"OfferedFareAgent":13116,"CostToAgent":13116,"PublishedFareAgent":13116,"CostToAgentCustomer":13116,"Fare_Key":"","colors":"#000000","FareClass":"Economy","classOfBooking":"R","GSTMandatory":false,"fareIdentifier":"NORMAL","SeatAvailable":3,"CommEarnedAgent":0},"Ispassengercity":true,"Ispassengeraddress":true,"isGSTMandatory":false,"IsPassMandatory":false,"IsPassExpiry":false,"IsPassIssue":false,"IsPassDateOfBirth":false,"isAdobrMandatory":true,"isCdobrMandatory":true,"isIdobrMandatory":true,"isSeatApplicable":false,"isHoldAllowed":true,"pricechanged":false,"isSessionTime":"14:00"}],"FareChange":null,"FARERULE":{"wsstatus":{"operation":"getFareRules","transactionStatus":"","resultFormat":"JSON","statusCode":"200","result":"SUCCESS","status":"OK","message":"Fare rules fetched"},"farerules":[],"baggagerules":[],"farerules_html":[],"fromapi":"","refundamount":0},"SSRData":{"meal":{"DEL-BOM":{"6":{"ssrcode":"VLML","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":85,"flightnumber":9519,"ssrtype":"meal","addedon":"","chargeableamount":400,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/mealicon.svg","currency":"INR","ssrname":"Veg Lactose Meal","Currency":"INR","key":"","Code":"VLML","Price":400,"cost":400,"amount":400,"Description":"Veg Lactose Meal"},"7":{"ssrcode":"VGML","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":85,"flightnumber":9519,"ssrtype":"meal","addedon":"","chargeableamount":400,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/mealicon.svg","currency":"INR","ssrname":"Veg-Meal","Currency":"INR","key":"","Code":"VGML","Price":400,"cost":400,"amount":400,"Description":"Veg-Meal"},"8":{"ssrcode":"VGAN","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":85,"flightnumber":9519,"ssrtype":"meal","addedon":"","chargeableamount":400,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/mealicon.svg","currency":"INR","ssrname":"Vegan Meal","Currency":"INR","key":"","Code":"VGAN","Price":400,"cost":400,"amount":400,"Description":"Vegan Meal"},"9":{"ssrcode":"TCSW","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":85,"flightnumber":9519,"ssrtype":"meal","addedon":"","chargeableamount":400,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/mealicon.svg","currency":"INR","ssrname":"Tomato Cucumber Cheese Lettuce Sandwich","Currency":"INR","key":"","Code":"TCSW","Price":400,"cost":400,"amount":400,"Description":"Tomato Cucumber Cheese Lettuce Sandwich"},"10":{"ssrcode":"PTSW","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":85,"flightnumber":9519,"ssrtype":"meal","addedon":"","chargeableamount":500,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/mealicon.svg","currency":"INR","ssrname":"Paneer Tikka Sandwich","Currency":"INR","key":"","Code":"PTSW","Price":500,"cost":500,"amount":500,"Description":"Paneer Tikka Sandwich"},"11":{"ssrcode":"LCVG","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":85,"flightnumber":9519,"ssrtype":"meal","addedon":"","chargeableamount":400,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/mealicon.svg","currency":"INR","ssrname":"Low Calorie Veg","Currency":"INR","key":"","Code":"LCVG","Price":400,"cost":400,"amount":400,"Description":"Low Calorie Veg"},"12":{"ssrcode":"JNML","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":85,"flightnumber":9519,"ssrtype":"meal","addedon":"","chargeableamount":400,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/mealicon.svg","currency":"INR","ssrname":"Jain Meal","Currency":"INR","key":"","Code":"JNML","Price":400,"cost":400,"amount":400,"Description":"Jain Meal"},"16":{"ssrcode":"GFNV","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":85,"flightnumber":9519,"ssrtype":"meal","addedon":"","chargeableamount":500,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/mealicon.svg","currency":"INR","ssrname":"Glutten free Non veg","Currency":"INR","key":"","Code":"GFNV","Price":500,"cost":500,"amount":500,"Description":"Glutten free Non veg"},"18":{"ssrcode":"DBVG","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":85,"flightnumber":9519,"ssrtype":"meal","addedon":"","chargeableamount":400,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/mealicon.svg","currency":"INR","ssrname":"Diabetic Veg Meal","Currency":"INR","key":"","Code":"DBVG","Price":400,"cost":400,"amount":400,"Description":"Diabetic Veg Meal"},"19":{"ssrcode":"DBNV","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":85,"flightnumber":9519,"ssrtype":"meal","addedon":"","chargeableamount":500,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/mealicon.svg","currency":"INR","ssrname":"Diabetic Non Veg","Currency":"INR","key":"","Code":"DBNV","Price":500,"cost":500,"amount":500,"Description":"Diabetic Non Veg"},"20":{"ssrcode":"DBML","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":85,"flightnumber":9519,"ssrtype":"meal","addedon":"","chargeableamount":400,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/mealicon.svg","currency":"INR","ssrname":"Vegetarian Diabetic Hot Meal","Currency":"INR","key":"","Code":"DBML","Price":400,"cost":400,"amount":400,"Description":"Vegetarian Diabetic Hot Meal"},"21":{"ssrcode":"CPML","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":0,"flightnumber":9519,"ssrtype":"meal","addedon":"","chargeableamount":650,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/mealicon.svg","currency":"INR","ssrname":"Corporate Meal","Currency":"INR","key":"","Code":"CPML","Price":650,"cost":650,"amount":650,"Description":"Corporate Meal"},"22":{"ssrcode":"CJSW","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":85,"flightnumber":9519,"ssrtype":"meal","addedon":"","chargeableamount":500,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/mealicon.svg","currency":"INR","ssrname":"Chicken Junglee Sandwich","Currency":"INR","key":"","Code":"CJSW","Price":500,"cost":500,"amount":500,"Description":"Chicken Junglee Sandwich"},"23":{"ssrcode":"CHVM","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":85,"flightnumber":9519,"ssrtype":"meal","addedon":"","chargeableamount":500,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/mealicon.svg","currency":"INR","ssrname":"Child Meal Veg","Currency":"INR","key":"","Code":"CHVM","Price":500,"cost":500,"amount":500,"Description":"Child Meal Veg"},"24":{"ssrcode":"CHNM","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":85,"flightnumber":9519,"ssrtype":"meal","addedon":"","chargeableamount":500,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/mealicon.svg","currency":"INR","ssrname":"Child Meal Non Veg","Currency":"INR","key":"","Code":"CHNM","Price":500,"cost":500,"amount":500,"Description":"Child Meal Non Veg"},"25":{"ssrcode":"CHBR","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":50,"flightnumber":9519,"ssrtype":"meal","addedon":"","chargeableamount":450,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/mealicon.svg","currency":"INR","ssrname":"Chicken Biryani","Currency":"INR","key":"","Code":"CHBR","Price":450,"cost":450,"amount":450,"Description":"Chicken Biryani"}}},"baggage":{"DEL-BOM":{"0":{"ssrcode":"XBPJ","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":0,"flightnumber":9519,"ssrtype":"baggage","addedon":"","chargeableamount":9000,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/excessbaggage.svg","currency":"INR","ssrname":"Extra Baggage 20KG","Currency":"INR","key":"","Code":"XBPJ","Price":9000,"cost":9000,"amount":9000,"Weight":"Extra Baggage 20KG"},"1":{"ssrcode":"XBPE","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":0,"flightnumber":9519,"ssrtype":"baggage","addedon":"","chargeableamount":1515,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/excessbaggage.svg","currency":"INR","ssrname":"Extra Baggage 3KG","Currency":"INR","key":"","Code":"XBPE","Price":1515,"cost":1515,"amount":1515,"Weight":"Extra Baggage 3KG"},"2":{"ssrcode":"XBPD","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":0,"flightnumber":9519,"ssrtype":"baggage","addedon":"","chargeableamount":13500,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/excessbaggage.svg","currency":"INR","ssrname":"Extra Baggage 30KG","Currency":"INR","key":"","Code":"XBPD","Price":13500,"cost":13500,"amount":13500,"Weight":"Extra Baggage 30KG"},"3":{"ssrcode":"XBPC","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":0,"flightnumber":9519,"ssrtype":"baggage","addedon":"","chargeableamount":7260,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/excessbaggage.svg","currency":"INR","ssrname":"Extra Baggage 15KG","Currency":"INR","key":"","Code":"XBPC","Price":7260,"cost":7260,"amount":7260,"Weight":"Extra Baggage 15KG"},"4":{"ssrcode":"XBPB","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":0,"flightnumber":9519,"ssrtype":"baggage","addedon":"","chargeableamount":4950,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/excessbaggage.svg","currency":"INR","ssrname":"Extra Baggage 10KG","Currency":"INR","key":"","Code":"XBPB","Price":4950,"cost":4950,"amount":4950,"Weight":"Extra Baggage 10KG"},"5":{"ssrcode":"XBPA","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":0,"flightnumber":9519,"ssrtype":"baggage","addedon":"","chargeableamount":2525,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/excessbaggage.svg","currency":"INR","ssrname":"Extra Baggage 5KG","Currency":"INR","key":"","Code":"XBPA","Price":2525,"cost":2525,"amount":2525,"Weight":"Extra Baggage 5KG"},"13":{"ssrcode":"IXBC","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":0,"flightnumber":9519,"ssrtype":"baggage","addedon":"","chargeableamount":6000,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/excessbaggage.svg","currency":"INR","ssrname":"INTL Conne 30 KG","Currency":"INR","key":"","Code":"IXBC","Price":6000,"cost":6000,"amount":6000,"Weight":"INTL Conne 30 KG"},"14":{"ssrcode":"IXBB","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":0,"flightnumber":9519,"ssrtype":"baggage","addedon":"","chargeableamount":3000,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/excessbaggage.svg","currency":"INR","ssrname":"INTL Conne 15 KG","Currency":"INR","key":"","Code":"IXBB","Price":3000,"cost":3000,"amount":3000,"Weight":"INTL Conne 15 KG"},"15":{"ssrcode":"IXBA","clientid":"all","markup":0,"ssrid":"","origin":"DEL","destination":"BOM","available":0,"flightnumber":9519,"ssrtype":"baggage","addedon":"","chargeableamount":1600,"carrier":"6E","imageurl":"https://static.iween.co.in/airlinelogos/excessbaggage.svg","currency":"INR","ssrname":"INTL Conne 8 KG","Currency":"INR","key":"","Code":"IXBA","Price":1600,"cost":1600,"amount":1600,"Weight":"INTL Conne 8 KG"}}}},"tripSeatMap":[]}',1);
				// echo json_encode($apiResponse);
				// echo "apiResponse<pre>";print_r($arrUrlData);die("apiResponse");
				$ResponseStatus = $apiResponse['status'];
				// echo "ResponseStatus($ResponseStatus)";die;
				$ErrorMessage = isset($apiResponse['message']) ? $apiResponse['message'] : '';
				if ($ResponseStatus == 1) {
					$FlightBookingData = $arrUrlData['BookingData'];
					$results = isset($apiResponse['results']) ? $apiResponse['results'] : '';
					$FARERULE = isset($apiResponse['FARERULE']) ? $apiResponse['FARERULE'] : '';
					$SSRData = isset($apiResponse['SSRData']) ? $apiResponse['SSRData'] : '';
					$pricechanged = !empty($results[0]['pricechanged']) ? $results[0]['pricechanged'] : false;
					$intPublishedFare = 0;
					$Baggage = [];
					$Meal = [];
					$SSRArr = [];
					$FlightBookingDataArr = [];

					if ($FlightBookingData) {
						foreach ($FlightBookingData as $keys=>$value) {
							$SegmentsArray = [];
							if($value['Segments']){
								foreach($value['Segments'] as $kkkk=>$val){
									$sectors = $val['originAirportCode'].'-'.$val['destinationAirportCode'];
									$sectorsMain = $value['SourceAirportCode'].'-'.$value['DestAirportCode'];
									$mealArray = isset($SSRData['meal'][$sectors])?array_values($SSRData['meal'][$sectors]):[];
									$baggageArray = [];
									$baggageArrayMain = isset($SSRData['baggage'][$sectorsMain])?array_values($SSRData['baggage'][$sectorsMain]):[];
									if(isset($SSRData['baggage'][$sectors]) && !empty($SSRData['baggage'][$sectors])){
										$baggageArray = array_values($SSRData['baggage'][$sectors]);
									}elseif($kkkk == 0){
										$baggageArray = $baggageArrayMain;
									}

									foreach($baggageArray as $keydd => $csm){
										$baggageArray[$keydd]['segmentid'] = $val['segmentid'];
										$baggageArray[$keydd]['key'] = $val['segmentid'];
									}
									foreach($mealArray as $keysdd => $csm){
										$mealArray[$keysdd]['segmentid'] = $val['segmentid'];
										$mealArray[$keysdd]['key'] = $val['segmentid'];
									}
									$SegmentsArray[$kkkk] = $val;
									$SegmentsArray[$kkkk]['MEAL'] = $mealArray;
									$SegmentsArray[$kkkk]['BAGGAGE'] = $baggageArray;
								}
							}
							// echo "<pre>";print_r($SegmentsArray);die;
							// // $value['Segments'] = $SegmentsArray;
							$AirlineCode = $value['AirlineCode'];
							$APIBookingData = !empty($results[$keys]) ? $results[$keys] : '';
							// 
							$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
							$FlightBookingDataArr[$keys] = $value;
							$FlightBookingDataArr[$keys]['ApiResultIndex'] = $APIBookingData['ApiResultIndex'];
							$FlightBookingDataArr[$keys]['bookingkey'] = $APIBookingData['bookingkey'];
							$FlightBookingDataArr[$keys]['flightKey'] = $APIBookingData['flightKey'];
							$FlightBookingDataArr[$keys]['AirlineSysId'] = $airlineSysId;
							$FlightBookingDataArr[$keys]['CurrencyType'] = $this->CurrencyId;
							$FlightBookingDataArr[$keys]['SourcePlaceSysId'] = $intSourceCityId;
							$FlightBookingDataArr[$keys]['DestPlaceSysId'] = $intDestinationCityId;
							$FlightBookingDataArr[$keys]['TravelDate'] = date('Y-m-d', strtotime($value['FromUTCTime']));

							$FlightBookingDataArr[$keys]['Ispassengercity'] = $APIBookingData['Ispassengercity'];
							$FlightBookingDataArr[$keys]['isDocIdAllowedMandatory'] = $APIBookingData['isDocIdAllowedMandatory'];
							$FlightBookingDataArr[$keys]['Ispassengeraddress'] = $APIBookingData['Ispassengeraddress'];
							$FlightBookingDataArr[$keys]['isGSTMandatory'] = $APIBookingData['isGSTMandatory'];
							$FlightBookingDataArr[$keys]['IsPassMandatory'] = $APIBookingData['IsPassMandatory'];
							$FlightBookingDataArr[$keys]['IsPassExpiry'] = $APIBookingData['IsPassExpiry'];
							$FlightBookingDataArr[$keys]['IsPassIssue'] = $APIBookingData['IsPassIssue'];
							$FlightBookingDataArr[$keys]['IsPassDateOfBirth'] = $APIBookingData['IsPassDateOfBirth'];
							$FlightBookingDataArr[$keys]['isDobAdult'] = $APIBookingData['isAdobrMandatory'];
							$FlightBookingDataArr[$keys]['isDobChild'] = $APIBookingData['isCdobrMandatory'];
							$FlightBookingDataArr[$keys]['isDobInfant'] = $APIBookingData['isIdobrMandatory'];
							$FlightBookingDataArr[$keys]['isSeatApplicable'] = $APIBookingData['isSeatApplicable'];
							$FlightBookingDataArr[$keys]['isHoldAllowed'] = $APIBookingData['isHoldAllowed'];
							$FlightBookingDataArr[$keys]['pricechanged'] = $APIBookingData['pricechanged'];
							$FlightBookingDataArr[$keys]['isSessionTime'] = $APIBookingData['isSessionTime'];
							if($value['JourneyType'] == 2 && $value['IsInternational'] == 1){
								$FlightBookingDataArr[$keys]['FlightNumber'] = $APIBookingData['FlightNumber'];
								$FlightBookingDataArr[$keys]['SourceAirportCode'] = $APIBookingData['SourceAirportCode'];
								$FlightBookingDataArr[$keys]['DestAirportCode'] = $APIBookingData['DestAirportCode'];
								$FlightBookingDataArr[$keys]['IsLCC'] = $APIBookingData['IsLCC'];
							}
							$intPublishedFare += $APIBookingData['FairRules']['PublishedFareAgent'];
							$Baggage[] = isset($value['Baggage'])?$value['Baggage']:[];
							$Meal[] = isset($value['Meal'])?$value['Meal']:[];

							$tripbinfo = $value['FairRules']['tripbinfo'];
							$FareBreakdown = $APIBookingData['FairRules']['FareBreakdown'];
							$FareBreakdownArray = [];
							if($FareBreakdown){
								foreach($FareBreakdown as $bk=>$brkval){
									$Baggage__ = isset($value['FairRules']['FareBreakdown'][$bk]['Baggage'])?$value['FairRules']['FareBreakdown'][$bk]['Baggage']:'';
									$CabinBaggage = isset($value['FairRules']['FareBreakdown'][$bk]['CabinBaggage'])?$value['FairRules']['FareBreakdown'][$bk]['CabinBaggage']:'';
									$FareBreakdownArray[$bk] = $brkval;
									$FareBreakdownArray[$bk]['Baggage'] = $Baggage__;
									$FareBreakdownArray[$bk]['CabinBaggage'] = $CabinBaggage;
								}
							}
							$APIBookingData['FairRules']['FareBreakdown'] = $FareBreakdownArray;
							$APIBookingData['FairRules']['IscheckinBagInc'] = $value['FairRules']['IscheckinBagInc'];
							$APIBookingData['FairRules']['IscabinbagInc'] = $value['FairRules']['IscabinbagInc'];
							$APIBookingData['FairRules']['CheckinBaggage'] = $value['FairRules']['CheckinBaggage'];
							$APIBookingData['FairRules']['CabinBaggage'] = $value['FairRules']['CabinBaggage'];
							$APIBookingData['FairRules']['IsMealIncludes'] = $value['FairRules']['IsMealIncludes'];
							$APIBookingData['FairRules']['tripbinfo'] = $tripbinfo;

							$FlightBookingDataArr[$keys]['FairRules'] = $APIBookingData['FairRules'];
							$FlightBookingDataArr[$keys]['Segments'] = $SegmentsArray;
						}
					}
					$SSRArr_ = array('Meal' => [$mealArray], 'Baggage' => [$baggageArray], 'SeatPreference' => []);
					$flightSSRDetails = new Zend_Session_Namespace('flightSSRDetails');
					$flightSSRDetails->params = $SSRArr_;
					$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
					$FlightBookingData->params = $FlightBookingDataArr;
					// echo "FlightBookingDataArr<pre>";print_r(json_encode($FlightBookingDataArr));die("SSRArr_");
					$arrUrlData['BookingData'] = $FlightBookingDataArr;
					$arrUrlData['FlightBookingData'] = $FlightBookingDataArr;
					$arrUrlData['SSRArr'] = $SSRArr;
					$arrUrlData['FarequoteData'] = $DataS;
					$arrUrlData['flightSSRDetails'] = isset($SSRArr_) ? $SSRArr_ : [];
					$arrUrlData['FareRuleRequest'] = $FARERULE;
					
					$isHoldAllowed = isset($FlightBookingDataArr[0]['isHoldAllowed']) ? $FlightBookingDataArr[0]['isHoldAllowed'] : false;
					$tempData = array(
						'TraceId' => $SearchTraceId,
						'json_data' => json_encode($arrUrlData),
					);
					$objFlight = new Travel_Model_FlightMaster();

					$objFlight->deleteFlightTempData($SearchTraceId);
					$objFlight->insertFlightTempData($tempData);
					$FareChange = $pricechanged;
					$html = new Zend_View();
					$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
					$html->assign(array('apiResponse' => $FlightBookingDataArr, 'gtxagencysysid' => $this->gtxagencysysid, 'stylecss' => $this->stylecss, 'apiResponseInbound' => [], 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
					$bodyText = $html->render('getflightfarequote.phtml');
					$response = array('success' => true, 'message' => 'Done', 'FareChange' => $FareChange, 'html' => $bodyText, 'intPublishedFare' => number_format(ceil($intPublishedFare * $this->CurrencyRate)), 'SSRArr' => isset($SSRArr_) ? $SSRArr_ : [], 'SSRArrInb' => [], 'apiResponse' => $FlightBookingDataArr);
					echo json_encode($response);
					exit;
				}else {
					$response = array('success' => false, 'message' => 'Session is expired. Please try again with new session', 'FareChange' => false, 'html' => '');
					echo json_encode($response);
					exit;
				}
				// echo '<pre>';print_r(($apiResponse));die;
				
			} elseif($ICSourceSysId == 16) {
				if($route == 2 && $interNationalSearch){
					$ApiResultIndex = isset($arrUrlData['BookingData'][0]['origin']['ApiResultIndex']) ? $arrUrlData['BookingData'][0]['origin']['ApiResultIndex'] : '';
				}

				$request = array(
					'SegmentInfo'=>array(
						'BaseOrigin'=>$sourceCityAirportCode,
						'BaseDestination'=>$destinationCityAirportCode,
						'TripType'=>($route == 2)?'R':'O',
						'AdultCount'=>$adultCount,
						'ChildCount'=>$childCount,
						'InfantCount'=>$infantCount,
					),
					'Trackid'=>$ApiResultIndex,
					'ItineraryInfo'=>$ItineraryInfo,
				);

				$DataS = array(
					'apidata'=>$request,
					'memberCount'=>$intMemberCount,
					'JourneyType'=>$route,
					'interNationalSearch'=>$interNationalSearch,
					'searchID'=>$SearchTraceId,
					'ICSourceSysId'=>$ICSourceSysId,
					'cabinClass'=>$FlightClass,
					'AgentMarkUp'=>$getAgencyMarkups[0]['StdMarkUpPer'],
					'APIMode' => $this->APIMode
				);
				if(!empty($FarequoteData)){
					$DataS = $FarequoteData;
				}
				$getData['BookingData'] = $FlightBookingData;
				$url = $this->GTXAPIDEFAULT.'/flight/v3/farequote';
				$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
				// $apiResponse = json_decode('{"status":true,"message":"SUCCESS","results":[{"Token":"AQAG092312010015996","ApiResultIndex":"AQ125746344531450161257502247306UV8RKAT2BOI","FlightNumber":"SG-8157","SegFlightNumberArr":"SG-8157","AirlineName":"Spicejet","AirlineCode":"SG","IsLCC":true,"IsRefundable":true,"IsRefundableTxt":"Refundable","FromUTCTime":"2024-04-26 06:10","ToUTCTime":"2024-04-26 08:20","DepartureTime":"06:10","ArrivalTime":"08:20","FareClass":"Economy","SourceAirportCode":"DEL","DestAirportCode":"BOM","FlightDuration":"0h 0m","StopCount":"Non-stop","NoOfSeatAvailable":"1","JourneyType":"2","TripType":1,"ICSourceSysId":16,"IsInternational":0,"TotalFlightMembers":1,"SearchTraceId":"8f19e-b6c0f-e8c4a-feb67","logo":"http:\/\/local.gtxapi.com\/public\/AirlineLogo\/SG.gif","PublishedFare":3242,"FairRules":{"Currency":"INR","CurrencyRate":1,"currencySysId":1,"GrossAmount":3242,"APIBaseFare":1999,"BaseFare":1999,"Tax":1243,"intPublishedFare":3242,"OfferedFareAgent":3242,"PublishedFare":3242,"CostToAgent":3242,"PublishedFareAgent":3242,"CostToAgentCustomer":3242,"PublishedFarePerPax":3242,"OfferedFare":3242,"CommissionEarned":0,"CommDiscount":0,"TDS":0,"TDSEarn":0,"Refundable":true,"IsRefundableTxt":"Refundable","PriceID":"2800","FlightId":"SG1","FareClass":"Economy","classOfBooking":"P1","colors":"#000000","fareIdentifier":"N","SeatAvailable":"1","FixedMarkUp":0,"GSTOnMarkUp":0,"CommEarnedAgent":0,"IscheckinBagInc":true,"IscabinbagInc":false,"CheckinBaggage":"15KG","CabinBaggage":"","IsMealIncludes":false,"FareBreakdown":[{"Currency":"INR       ","PassengerType":1,"PaxType":"ADULT","PassengerCount":"1","BaseFare":1999,"Tax":1243,"OfferedFare":3242,"PublishedFare":3242,"CostToAgent":3242,"TDS":"0","TDSEarn":0,"TaxBR":{"MF":0,"YQ":0,"AGST":0,"MFT":0,"OT":1243,"YR":0},"ApiNCM":0,"CommissionEarned":0,"FixedMarkUp":0,"GSTOnMarkUp":0,"intTotalGST":0,"CommDiscount":0,"AgentMarkUp":0,"CostToAgentCustomer":3242,"GrossAmount":3242,"Baggage":"15KG","CabinBaggage":"","arrMarkUps":{"Currency":"INR       ","currencySysId":1,"IntNetCommission":0,"IntCommissionValInPercentage":10,"CommEarned":0,"CommDiscount":0,"FixedMarkUp":0,"GSTOnMarkUp":0,"PublishFare":3242,"CostToCustomer":3242,"CostToAgentCustomer":3242,"TotalEarning":0,"CostToCompany":3242,"CostToAgent":3242,"AgentB2CEarning":0,"intOfferedFare":3242,"intPublishFare":3242,"APIMarkup":0,"AgentMarkUp":0,"TDS":"0","TDSEarn":0,"markup_b2b":0,"AddiMarkup":0,"AddiTaxOnMarkup":0}}],"tripbinfo":{"DEL-BOM":{"ADULT":{"cabin":"","checkin":"15KG"}}}},"Segments":[{"segmentid":"2800","isReturnSegment":"1","arrivingnextday":false,"originAirportName":" Delhi Indira Gandhi Intl (DEL), India","destinationAirportName":" Chhatrapati Shivaji (BOM), India","originCityName":"Delhi","originCountryName":"India","destinationCityName":"Mumbai","destinationCountryName":"India","destinationAirportCode":"BOM","destinationArrTime":"2024-04-26 08:20","SegFlightNumber":"SG-8157","AirlineCode":"SG","AirlineName":"Spicejet","FareClass":"P1","cabinClass":"Economy","originAirportCode":"DEL","originDepTime":"2024-04-26 06:10","TripIndicator":false,"IscheckinBagInc":true,"IscabinbagInc":false,"CheckinBaggage":"15KG","CabinBaggage":"","IsMealIncludes":false,"Duration":"130","GroundTime":0,"NoOfSeatAvailable":"1","strDepartureDtTime":"06:10","strArrivalDtTime":"08:20","FlightDuration":"2h 10m","LAYOVERDuration":null,"LAYOVERCity":"","DepTerminal":"3","ArrTerminal":"1","filePath":"http:\/\/local.gtxapi.com\/public\/AirlineLogo\/SG.gif","Baggage":[{"Code":"2PC|XTB2","Weight":"2 PC","Description":"2 PC","BaggageID":"7619","Destination":"BOM","Orgin":"DEL","Origin":"DEL","Itinref":"0","SegRef":"1","Currency":"INR","Price":"1800.00","cost":"1800.00","key":"2800"},{"Code":"1PC|XTB1","Weight":"1 PC","Description":"1 PC","BaggageID":"7620","Destination":"BOM","Orgin":"DEL","Origin":"DEL","Itinref":"0","SegRef":"1","Currency":"INR","Price":"900.00","cost":"900.00","key":"2800"},{"Code":"INTL ExcessBaggage 30KG|IB30","Weight":"INTL ExcessBaggage 30KG","Description":"INTL ExcessBaggage 30KG","BaggageID":"7621","Destination":"BOM","Orgin":"DEL","Origin":"DEL","Itinref":"0","SegRef":"1","Currency":"INR","Price":"4500.00","cost":"4500.00","key":"2800"},{"Code":"INTL ExcessBaggage 15KG|IB15","Weight":"INTL ExcessBaggage 15KG","Description":"INTL ExcessBaggage 15KG","BaggageID":"7622","Destination":"BOM","Orgin":"DEL","Origin":"DEL","Itinref":"0","SegRef":"1","Currency":"INR","Price":"2250.00","cost":"2250.00","key":"2800"},{"Code":"INTL ExcessBaggage 08KG|IB08","Weight":"INTL ExcessBaggage 08KG","Description":"INTL ExcessBaggage 08KG","BaggageID":"7623","Destination":"BOM","Orgin":"DEL","Origin":"DEL","Itinref":"0","SegRef":"1","Currency":"INR","Price":"1200.00","cost":"1200.00","key":"2800"},{"Code":"ExcessBaggage 30KG|EB30","Weight":"ExcessBaggage 30KG","Description":"ExcessBaggage 30KG","BaggageID":"7624","Destination":"BOM","Orgin":"DEL","Origin":"DEL","Itinref":"0","SegRef":"1","Currency":"INR","Price":"13500.00","cost":"13500.00","key":"2800"},{"Code":"ExcessBaggage 20KG|EB20","Weight":"ExcessBaggage 20KG","Description":"ExcessBaggage 20KG","BaggageID":"7625","Destination":"BOM","Orgin":"DEL","Origin":"DEL","Itinref":"0","SegRef":"1","Currency":"INR","Price":"9000.00","cost":"9000.00","key":"2800"},{"Code":"ExcessBaggage 15KG|EB15","Weight":"ExcessBaggage 15KG","Description":"ExcessBaggage 15KG","BaggageID":"7626","Destination":"BOM","Orgin":"DEL","Origin":"DEL","Itinref":"0","SegRef":"1","Currency":"INR","Price":"6750.00","cost":"6750.00","key":"2800"},{"Code":"ExcessBaggage 10KG|EB10","Weight":"ExcessBaggage 10KG","Description":"ExcessBaggage 10KG","BaggageID":"7627","Destination":"BOM","Orgin":"DEL","Origin":"DEL","Itinref":"0","SegRef":"1","Currency":"INR","Price":"4500.00","cost":"4500.00","key":"2800"},{"Code":"ExcessBaggage 05KG|EB05","Weight":"ExcessBaggage 05KG","Description":"ExcessBaggage 05KG","BaggageID":"7628","Destination":"BOM","Orgin":"DEL","Origin":"DEL","Itinref":"0","SegRef":"1","Currency":"INR","Price":"2250.00","cost":"2250.00","key":"2800"}],"MEAL":[{"Amount":"290.00","Code":"Paneer Masala in Tortilla wrap|VGSW","Description":"Paneer Masala in Tortilla wrap","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6873","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"290.00","cost":"290.00","Origin":"DEL","key":"2800"},{"Amount":"249.00","Code":"Masala Dosa with Tomato onion uttapam and kanjivaram mini idli in sambar along with Coconut Chutney (235 gms)|VGML","Description":"Masala Dosa with Tomato onion uttapam and kanjivaram mini idli in sambar along with Coconut Chutney (235 gms)","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6874","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"249.00","cost":"249.00","Origin":"DEL","key":"2800"},{"Amount":"300.00","Code":"Vegetable Daliya|VCC6","Description":"Vegetable Daliya","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6875","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"300.00","cost":"300.00","Origin":"DEL","key":"2800"},{"Amount":"300.00","Code":"Vegetable Pasta in Neapolitan sauce|VCC5","Description":"Vegetable Pasta in Neapolitan sauce","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6876","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"300.00","cost":"300.00","Origin":"DEL","key":"2800"},{"Amount":"300.00","Code":"Vegtable in Red Thai Curry with Steamed Rice|VCC2","Description":"Vegtable in Red Thai Curry with Steamed Rice","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6877","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"300.00","cost":"300.00","Origin":"DEL","key":"2800"},{"Amount":"434.00","Code":"Chicken masala in tortilla wrap|NVSW","Description":"Chicken masala in tortilla wrap","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6878","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"434.00","cost":"434.00","Origin":"DEL","key":"2800"},{"Amount":"524.00","Code":"Fried egg on buttered bun with cheesy chicken croquette and oven roasted cajun potatoes. (210 gms)|NVML","Description":"Fried egg on buttered bun with cheesy chicken croquette and oven roasted cajun potatoes. (210 gms)","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6879","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"524.00","cost":"524.00","Origin":"DEL","key":"2800"},{"Amount":"300.00","Code":"Chicken schezwan on bed of fried rice|NCC6","Description":"Chicken schezwan on bed of fried rice","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6880","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"300.00","cost":"300.00","Origin":"DEL","key":"2800"},{"Amount":"300.00","Code":"Tawa Fish masala on bed of  Steamed rice with tadka masoor dal|NCC5","Description":"Tawa Fish masala on bed of  Steamed rice with tadka masoor dal","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6881","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"300.00","cost":"300.00","Origin":"DEL","key":"2800"},{"Amount":"300.00","Code":"Tandoori Chicken tangri with chicken haryali tikka and vegetable shami kebab.|NCC4","Description":"Tandoori Chicken tangri with chicken haryali tikka and vegetable shami kebab.","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6882","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"300.00","cost":"300.00","Origin":"DEL","key":"2800"},{"Amount":"300.00","Code":"Chicken in Red Thai Curry with Steamed Rice|NCC2","Description":"Chicken in Red Thai Curry with Steamed Rice","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6883","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"300.00","cost":"300.00","Origin":"DEL","key":"2800"},{"Amount":"300.00","Code":"Grilled Chicken Breast with Mushroom Sauce, Yellow Rice, Saut\u00c3\u00a9ed Carrots and Beans Baton|NCC1","Description":"Grilled Chicken Breast with Mushroom Sauce, Yellow Rice, Saut\u00c3\u00a9ed Carrots and Beans Baton","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6884","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"300.00","cost":"300.00","Origin":"DEL","key":"2800"},{"Amount":"532.00","Code":"Low cal salad Vegetarian|LCVS","Description":"Low cal salad Vegetarian","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6885","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"532.00","cost":"532.00","Origin":"DEL","key":"2800"},{"Amount":"532.00","Code":"Low cal salad Non - Vegetarian|LCNS","Description":"Low cal salad Non - Vegetarian","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6886","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"532.00","cost":"532.00","Origin":"DEL","key":"2800"},{"Amount":"395.00","Code":"Jain Cold Sandwich (current Cucumber and Tomato sandwich)|JNSW","Description":"Jain Cold Sandwich (current Cucumber and Tomato sandwich)","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6887","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"395.00","cost":"395.00","Origin":"DEL","key":"2800"},{"Amount":"0.00","Code":"Jain Hot Meal|JNML","Description":"Jain Hot Meal","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6888","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"0.00","cost":"0.00","Origin":"DEL","key":"2800"},{"Amount":"0.00","Code":"Vegetarian Gluten-free Hot Meal|GFVG","Description":"Vegetarian Gluten-free Hot Meal","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6889","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"0.00","cost":"0.00","Origin":"DEL","key":"2800"},{"Amount":"0.00","Code":"Non - Vegetarian Gluten-free Hot Meal|GFNV","Description":"Non - Vegetarian Gluten-free Hot Meal","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6890","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"0.00","cost":"0.00","Origin":"DEL","key":"2800"},{"Amount":"0.00","Code":"Vegetarian Gluten-free Cold Meal (Dhokla)|GFCM","Description":"Vegetarian Gluten-free Cold Meal (Dhokla)","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6891","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"0.00","cost":"0.00","Origin":"DEL","key":"2800"},{"Amount":"0.00","Code":"Fruit Platter|FPML","Description":"Fruit Platter","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6892","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"0.00","cost":"0.00","Origin":"DEL","key":"2800"},{"Amount":"0.00","Code":"Non - Vegetarian Diabetic Hot Meal|DNVL","Description":"Non - Vegetarian Diabetic Hot Meal","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6893","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"0.00","cost":"0.00","Origin":"DEL","key":"2800"},{"Amount":"0.00","Code":"Vegetarian Diabetic Hot Meal|DBML","Description":"Vegetarian Diabetic Hot Meal","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6894","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"0.00","cost":"0.00","Origin":"DEL","key":"2800"},{"Amount":"0.00","Code":"Kids meal|CHML","Description":"Kids meal","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6895","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"0.00","cost":"0.00","Origin":"DEL","key":"2800"},{"Amount":"678.00","Code":"Cake|CAKE","Description":"Cake","Destination":"BOM","IsBundleServiceMeal":false,"Itinref":"0","MealID":"6896","Orgin":"DEL","SegRef":"1","Url":"","Currency":"INR","Price":"678.00","cost":"678.00","Origin":"DEL","key":"2800"}]}],"Ispassengercity":false,"Ispassengeraddress":false,"isGSTMandatory":false,"IsPassMandatory":false,"IsPassExpiry":false,"IsPassIssue":false,"IsPassDateOfBirth":false,"isAdobrMandatory":true,"isCdobrMandatory":true,"isIdobrMandatory":true,"isSeatApplicable":true,"isHoldAllowed":true,"isSessionTime":"14:00","Baggage":[],"Meal":[]},{"Token":"AQAG092312010015997","ApiResultIndex":"AQ125746344531450161257502247306UV8RKAT2BOI","FlightNumber":"SG-8158","SegFlightNumberArr":"SG-8158","AirlineName":"Spicejet","AirlineCode":"SG","IsLCC":true,"IsRefundable":true,"IsRefundableTxt":"Refundable","FromUTCTime":"2024-04-27 09:05","ToUTCTime":"2024-04-27 11:15","DepartureTime":"09:05","ArrivalTime":"11:15","FareClass":"Economy","SourceAirportCode":"BOM","DestAirportCode":"DEL","FlightDuration":"0h 0m","StopCount":"Non-stop","NoOfSeatAvailable":"1","JourneyType":"2","TripType":1,"ICSourceSysId":16,"IsInternational":0,"TotalFlightMembers":1,"SearchTraceId":"8f19e-b6c0f-e8c4a-feb67","logo":"http:\/\/local.gtxapi.com\/public\/AirlineLogo\/SG.gif","PublishedFare":3323,"FairRules":{"Currency":"INR","CurrencyRate":1,"currencySysId":1,"GrossAmount":3323,"APIBaseFare":1999,"BaseFare":1999,"Tax":1324,"intPublishedFare":3323,"OfferedFareAgent":3323,"PublishedFare":3323,"CostToAgent":3323,"PublishedFareAgent":3323,"CostToAgentCustomer":3323,"PublishedFarePerPax":3323,"OfferedFare":3323,"CommissionEarned":0,"CommDiscount":0,"TDS":0,"TDSEarn":0,"Refundable":true,"IsRefundableTxt":"Refundable","PriceID":"2800-5519","FlightId":"SG1","FareClass":"Economy","classOfBooking":"P1","colors":"#000000","fareIdentifier":"N","SeatAvailable":"1","FixedMarkUp":0,"GSTOnMarkUp":0,"CommEarnedAgent":0,"IscheckinBagInc":true,"IscabinbagInc":false,"CheckinBaggage":"15KG","CabinBaggage":"","IsMealIncludes":false,"FareBreakdown":[{"Currency":"INR       ","PassengerType":1,"PaxType":"ADULT","PassengerCount":"1","BaseFare":1999,"Tax":1324,"OfferedFare":3323,"PublishedFare":3323,"CostToAgent":3323,"TDS":"0","TDSEarn":0,"TaxBR":{"MF":0,"YQ":0,"AGST":0,"MFT":0,"OT":1324,"YR":0},"ApiNCM":0,"CommissionEarned":0,"FixedMarkUp":0,"GSTOnMarkUp":0,"intTotalGST":0,"CommDiscount":0,"AgentMarkUp":0,"CostToAgentCustomer":3323,"GrossAmount":3323,"Baggage":"15KG","CabinBaggage":"","arrMarkUps":{"Currency":"INR       ","currencySysId":1,"IntNetCommission":0,"IntCommissionValInPercentage":10,"CommEarned":0,"CommDiscount":0,"FixedMarkUp":0,"GSTOnMarkUp":0,"PublishFare":3323,"CostToCustomer":3323,"CostToAgentCustomer":3323,"TotalEarning":0,"CostToCompany":3323,"CostToAgent":3323,"AgentB2CEarning":0,"intOfferedFare":3323,"intPublishFare":3323,"APIMarkup":0,"AgentMarkUp":0,"TDS":"0","TDSEarn":0,"markup_b2b":0,"AddiMarkup":0,"AddiTaxOnMarkup":0}}],"tripbinfo":{"BOM-DEL":{"ADULT":{"cabin":"","checkin":"15KG"}}}},"Segments":[{"segmentid":"5519","isReturnSegment":"1","arrivingnextday":false,"originAirportName":" Chhatrapati Shivaji (BOM), India","destinationAirportName":" Delhi Indira Gandhi Intl (DEL), India","originCityName":"Mumbai","originCountryName":"India","destinationCityName":"Delhi","destinationCountryName":"India","destinationAirportCode":"DEL","destinationArrTime":"2024-04-27 11:15","SegFlightNumber":"SG-8158","AirlineCode":"SG","AirlineName":"Spicejet","FareClass":"P1","cabinClass":"Economy","originAirportCode":"BOM","originDepTime":"2024-04-27 09:05","TripIndicator":false,"IscheckinBagInc":true,"IscabinbagInc":false,"CheckinBaggage":"15KG","CabinBaggage":"","IsMealIncludes":false,"Duration":"130","GroundTime":0,"NoOfSeatAvailable":"1","strDepartureDtTime":"09:05","strArrivalDtTime":"11:15","FlightDuration":"2h 10m","LAYOVERDuration":null,"LAYOVERCity":"","DepTerminal":"1","ArrTerminal":"3","filePath":"http:\/\/local.gtxapi.com\/public\/AirlineLogo\/SG.gif","Baggage":[{"Code":"2PC|XTB2","Weight":"2 PC","Description":"2 PC","BaggageID":"1844","Destination":"DEL","Orgin":"BOM","Origin":"BOM","Itinref":"0","SegRef":"1","Currency":"INR","Price":"1844.00","cost":"1844.00","key":"5519"},{"Code":"1PC|XTB1","Weight":"1 PC","Description":"1 PC","BaggageID":"1845","Destination":"DEL","Orgin":"BOM","Origin":"BOM","Itinref":"0","SegRef":"1","Currency":"INR","Price":"922.00","cost":"922.00","key":"5519"},{"Code":"INTL ExcessBaggage 30KG|IB30","Weight":"INTL ExcessBaggage 30KG","Description":"INTL ExcessBaggage 30KG","BaggageID":"1846","Destination":"DEL","Orgin":"BOM","Origin":"BOM","Itinref":"0","SegRef":"1","Currency":"INR","Price":"4500.00","cost":"4500.00","key":"5519"},{"Code":"INTL ExcessBaggage 15KG|IB15","Weight":"INTL ExcessBaggage 15KG","Description":"INTL ExcessBaggage 15KG","BaggageID":"1847","Destination":"DEL","Orgin":"BOM","Origin":"BOM","Itinref":"0","SegRef":"1","Currency":"INR","Price":"2250.00","cost":"2250.00","key":"5519"},{"Code":"INTL ExcessBaggage 08KG|IB08","Weight":"INTL ExcessBaggage 08KG","Description":"INTL ExcessBaggage 08KG","BaggageID":"1848","Destination":"DEL","Orgin":"BOM","Origin":"BOM","Itinref":"0","SegRef":"1","Currency":"INR","Price":"1200.00","cost":"1200.00","key":"5519"},{"Code":"ExcessBaggage 30KG|EB30","Weight":"ExcessBaggage 30KG","Description":"ExcessBaggage 30KG","BaggageID":"1849","Destination":"DEL","Orgin":"BOM","Origin":"BOM","Itinref":"0","SegRef":"1","Currency":"INR","Price":"13500.00","cost":"13500.00","key":"5519"},{"Code":"ExcessBaggage 20KG|EB20","Weight":"ExcessBaggage 20KG","Description":"ExcessBaggage 20KG","BaggageID":"1850","Destination":"DEL","Orgin":"BOM","Origin":"BOM","Itinref":"0","SegRef":"1","Currency":"INR","Price":"9000.00","cost":"9000.00","key":"5519"},{"Code":"ExcessBaggage 15KG|EB15","Weight":"ExcessBaggage 15KG","Description":"ExcessBaggage 15KG","BaggageID":"1851","Destination":"DEL","Orgin":"BOM","Origin":"BOM","Itinref":"0","SegRef":"1","Currency":"INR","Price":"6750.00","cost":"6750.00","key":"5519"},{"Code":"ExcessBaggage 10KG|EB10","Weight":"ExcessBaggage 10KG","Description":"ExcessBaggage 10KG","BaggageID":"1852","Destination":"DEL","Orgin":"BOM","Origin":"BOM","Itinref":"0","SegRef":"1","Currency":"INR","Price":"4500.00","cost":"4500.00","key":"5519"},{"Code":"ExcessBaggage 05KG|EB05","Weight":"ExcessBaggage 05KG","Description":"ExcessBaggage 05KG","BaggageID":"1853","Destination":"DEL","Orgin":"BOM","Origin":"BOM","Itinref":"0","SegRef":"1","Currency":"INR","Price":"2250.00","cost":"2250.00","key":"5519"}],"MEAL":[{"Amount":"290.00","Code":"Paneer Masala in Tortilla wrap|VGSW","Description":"Paneer Masala in Tortilla wrap","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2858","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"290.00","cost":"290.00","Origin":"BOM","key":"5519"},{"Amount":"249.00","Code":"Masala Dosa with Tomato onion uttapam and kanjivaram mini idli in sambar along with Coconut Chutney (235 gms)|VGML","Description":"Masala Dosa with Tomato onion uttapam and kanjivaram mini idli in sambar along with Coconut Chutney (235 gms)","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2859","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"249.00","cost":"249.00","Origin":"BOM","key":"5519"},{"Amount":"300.00","Code":"Vegetable Daliya|VCC6","Description":"Vegetable Daliya","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2860","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"300.00","cost":"300.00","Origin":"BOM","key":"5519"},{"Amount":"300.00","Code":"Vegetable Pasta in Neapolitan sauce|VCC5","Description":"Vegetable Pasta in Neapolitan sauce","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2861","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"300.00","cost":"300.00","Origin":"BOM","key":"5519"},{"Amount":"300.00","Code":"Vegtable in Red Thai Curry with Steamed Rice|VCC2","Description":"Vegtable in Red Thai Curry with Steamed Rice","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2862","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"300.00","cost":"300.00","Origin":"BOM","key":"5519"},{"Amount":"434.00","Code":"Chicken masala in tortilla wrap|NVSW","Description":"Chicken masala in tortilla wrap","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2863","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"434.00","cost":"434.00","Origin":"BOM","key":"5519"},{"Amount":"524.00","Code":"Fried egg on buttered bun with cheesy chicken croquette and oven roasted cajun potatoes. (210 gms)|NVML","Description":"Fried egg on buttered bun with cheesy chicken croquette and oven roasted cajun potatoes. (210 gms)","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2864","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"524.00","cost":"524.00","Origin":"BOM","key":"5519"},{"Amount":"300.00","Code":"Chicken schezwan on bed of fried rice|NCC6","Description":"Chicken schezwan on bed of fried rice","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2865","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"300.00","cost":"300.00","Origin":"BOM","key":"5519"},{"Amount":"300.00","Code":"Tawa Fish masala on bed of  Steamed rice with tadka masoor dal|NCC5","Description":"Tawa Fish masala on bed of  Steamed rice with tadka masoor dal","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2866","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"300.00","cost":"300.00","Origin":"BOM","key":"5519"},{"Amount":"300.00","Code":"Tandoori Chicken tangri with chicken haryali tikka and vegetable shami kebab.|NCC4","Description":"Tandoori Chicken tangri with chicken haryali tikka and vegetable shami kebab.","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2867","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"300.00","cost":"300.00","Origin":"BOM","key":"5519"},{"Amount":"300.00","Code":"Chicken in Red Thai Curry with Steamed Rice|NCC2","Description":"Chicken in Red Thai Curry with Steamed Rice","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2868","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"300.00","cost":"300.00","Origin":"BOM","key":"5519"},{"Amount":"300.00","Code":"Grilled Chicken Breast with Mushroom Sauce, Yellow Rice, Saut\u00c3\u00a9ed Carrots and Beans Baton|NCC1","Description":"Grilled Chicken Breast with Mushroom Sauce, Yellow Rice, Saut\u00c3\u00a9ed Carrots and Beans Baton","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2869","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"300.00","cost":"300.00","Origin":"BOM","key":"5519"},{"Amount":"532.00","Code":"Low cal salad Vegetarian|LCVS","Description":"Low cal salad Vegetarian","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2870","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"532.00","cost":"532.00","Origin":"BOM","key":"5519"},{"Amount":"532.00","Code":"Low cal salad Non - Vegetarian|LCNS","Description":"Low cal salad Non - Vegetarian","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2871","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"532.00","cost":"532.00","Origin":"BOM","key":"5519"},{"Amount":"405.00","Code":"Jain Cold Sandwich (current Cucumber and Tomato sandwich)|JNSW","Description":"Jain Cold Sandwich (current Cucumber and Tomato sandwich)","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2872","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"405.00","cost":"405.00","Origin":"BOM","key":"5519"},{"Amount":"0.00","Code":"Jain Hot Meal|JNML","Description":"Jain Hot Meal","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2873","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"0.00","cost":"0.00","Origin":"BOM","key":"5519"},{"Amount":"0.00","Code":"Vegetarian Gluten-free Hot Meal|GFVG","Description":"Vegetarian Gluten-free Hot Meal","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2874","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"0.00","cost":"0.00","Origin":"BOM","key":"5519"},{"Amount":"0.00","Code":"Non - Vegetarian Gluten-free Hot Meal|GFNV","Description":"Non - Vegetarian Gluten-free Hot Meal","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2875","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"0.00","cost":"0.00","Origin":"BOM","key":"5519"},{"Amount":"0.00","Code":"Vegetarian Gluten-free Cold Meal (Dhokla)|GFCM","Description":"Vegetarian Gluten-free Cold Meal (Dhokla)","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2876","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"0.00","cost":"0.00","Origin":"BOM","key":"5519"},{"Amount":"0.00","Code":"Fruit Platter|FPML","Description":"Fruit Platter","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2877","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"0.00","cost":"0.00","Origin":"BOM","key":"5519"},{"Amount":"0.00","Code":"Non - Vegetarian Diabetic Hot Meal|DNVL","Description":"Non - Vegetarian Diabetic Hot Meal","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2878","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"0.00","cost":"0.00","Origin":"BOM","key":"5519"},{"Amount":"0.00","Code":"Vegetarian Diabetic Hot Meal|DBML","Description":"Vegetarian Diabetic Hot Meal","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2879","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"0.00","cost":"0.00","Origin":"BOM","key":"5519"},{"Amount":"0.00","Code":"Kids meal|CHML","Description":"Kids meal","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2880","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"0.00","cost":"0.00","Origin":"BOM","key":"5519"},{"Amount":"678.00","Code":"Cake|CAKE","Description":"Cake","Destination":"DEL","IsBundleServiceMeal":false,"Itinref":"0","MealID":"2881","Orgin":"BOM","SegRef":"1","Url":"","Currency":"INR","Price":"678.00","cost":"678.00","Origin":"BOM","key":"5519"}]}],"Ispassengercity":false,"Ispassengeraddress":false,"isGSTMandatory":false,"IsPassMandatory":false,"IsPassExpiry":false,"IsPassIssue":false,"IsPassDateOfBirth":false,"isAdobrMandatory":true,"isCdobrMandatory":true,"isIdobrMandatory":true,"isSeatApplicable":true,"isHoldAllowed":true,"isSessionTime":"14:00","Baggage":[],"Meal":[]}],"FareChange":null,"FARERULE":null,"SSRData":[]}',true);
				// echo "apiResponse<pre>";print_r(json_encode($apiResponse));
				$ResponseStatus = $apiResponse['status'];
				$ErrorMessage = isset($apiResponse['message']) ? $apiResponse['message'] : '';
				if ($ResponseStatus == 1) {
					$FlightBookingData = isset($apiResponse['results']) ? $apiResponse['results'] : '';

					$PublishedFare = 0;
					$intPublishedFare = 0;
					$Baggage = [];
					$Meal = [];
					$SSRArr = [];
					$SSRMeal = [];
					$SSRBaggage = [];
					$FlightBookingDataArr = [];
					if ($FlightBookingData) {
						foreach ($FlightBookingData as $keys=>$value) {
							if($value['Segments']){
								foreach($value['Segments'] as $kkkk => $val){
									$mealArray = isset($val['MEAL'])?array_values($val['MEAL']):[];
									$baggageArray = [];
									if(isset($val['Baggage']) && !empty($val['Baggage'])){
										$baggageArray = array_values($val['Baggage']);
									}
									foreach($baggageArray as $keydd => $csm){
										$baggageArray[$keydd]['segmentid'] = $val['segmentid'];
										$baggageArray[$keydd]['amount'] = $csm['Price'];
									}
									foreach($mealArray as $keysdd => $csm){
										$mealArray[$keysdd]['segmentid'] = $val['segmentid'];
										$mealArray[$keysdd]['amount'] = $csm['Price'];
									}
								}
								$SSRMeal[] = isset($mealArray) ? $mealArray : [];
								$SSRBaggage[] = isset($baggageArray) ? $baggageArray : [];
							}

							$AirlineCode = $value['AirlineCode'];
							$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
							$FlightBookingDataArr[$keys] = $value;
							$FlightBookingDataArr[$keys]['isSeatAppli'] = $value['isSeatApplicable'];
							$FlightBookingDataArr[$keys]['AirlineSysId'] = $airlineSysId;
							$FlightBookingDataArr[$keys]['SearchFlightTraceId'] = $value['SearchTraceId'];
							$FlightBookingDataArr[$keys]['CurrencyType'] = $this->CurrencyId;
							$FlightBookingDataArr[$keys]['SourcePlaceSysId'] = $intSourceCityId;
							$FlightBookingDataArr[$keys]['DestPlaceSysId'] = $intDestinationCityId;
							$FlightBookingDataArr[$keys]['isDobAdult'] = $value['isAdobrMandatory'];
							$FlightBookingDataArr[$keys]['isDobChild'] = $value['isCdobrMandatory'];
							$FlightBookingDataArr[$keys]['isDobInfant'] = $value['isIdobrMandatory'];
							$FlightBookingDataArr[$keys]['TravelDate'] = date('Y-m-d', strtotime($value['FromUTCTime']));
							$intPublishedFare += $value['FairRules']['PublishedFareAgent'];
							$Baggage[] = $value['Baggage'];
							$Meal[] = $value['Meal'];
						}
					}
					$SSRArr_ = array('Meal' => $SSRMeal, 'Baggage' => $SSRBaggage, 'SeatPreference' => []);
				
					$flightSSRDetails = new Zend_Session_Namespace('flightSSRDetails');
					$flightSSRDetails->params = $SSRArr_;
					// echo "SSRArr_<pre>";print_r($SSRArr_);die("SSRArr_");
					$arrUrlData['BookingData'] = $FlightBookingDataArr;
					$arrUrlData['FlightBookingData'] = $FlightBookingDataArr;
					$arrUrlData['SSRArr'] = $SSRArr;
					$arrUrlData['FarequoteData'] = $DataS;
					$arrUrlData['flightSSRDetails'] = isset($SSRArr_) ? $SSRArr_ : [];
					$arrUrlData['FareRuleRequest'] = $FARERULE;
					
					$isHoldAllowed = isset($FlightBookingDataArr[0]['isHoldAllowed']) ? $FlightBookingDataArr[0]['isHoldAllowed'] : false;
					$tempData = array(
						'TraceId' => $SearchTraceId,
						'json_data' => json_encode($arrUrlData),
					);
					$objFlight = new Travel_Model_FlightMaster();

					$objFlight->deleteFlightTempData($SearchTraceId);
					$objFlight->insertFlightTempData($tempData);
					$FareChange = $pricechanged;
					$html = new Zend_View();
					$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
					$html->assign(array('apiResponse' => $FlightBookingDataArr, 'gtxagencysysid' => $this->gtxagencysysid, 'stylecss' => $this->stylecss, 'apiResponseInbound' => [], 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
					$bodyText = $html->render('getflightfarequote.phtml');
					$response = array('success' => true, 'message' => 'Done', 'FareChange' => $FareChange, 'html' => $bodyText, 'intPublishedFare' => number_format(ceil($intPublishedFare * $this->CurrencyRate)), 'SSRArr' => isset($SSRArr_) ? $SSRArr_ : [], 'SSRArrInb' => [], 'apiResponse' => $FlightBookingDataArr);
					echo json_encode($response);
					exit;
				} else {
					$response = array('success' => false, 'message' => 'Session is expired. Please try again with new session', 'FareChange' => false, 'html' => '');
					echo json_encode($response);
					exit;
				}

			} elseif($ICSourceSysId == 11){
				$SearchTraceId = isset($arrUrlData['BookingData'][0]['SearchTraceId']) ? $arrUrlData['BookingData'][0]['SearchTraceId'] : '';
				
				$getAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->gtxagencysysid);
				$this->siteName = (isset($getAgencyData['DisplayName']) && !empty($getAgencyData['DisplayName']))?$getAgencyData['DisplayName']: $this->siteName;
				
				$Contacts = !empty($getAgencyData['PrimaryMobileNo'])?$getAgencyData['PrimaryMobileNo']:'';
				
				
				// $Search_Key = $getData['ApiResultIndex'];
				// if($getData['ApiResultIndexInb']){
				// 	$Search_Key = $getData['ApiResultIndex'].','.$getData['ApiResultIndexInb'];
				// }
				
				$request = array(
					'Auth_Header'=>array(
						"IP_Address" => $_SERVER['REMOTE_ADDR'],
						"Request_Id" => $getData['TraceId'],
						"IMEI_Number" => "3434334343111"
					),
					'Search_Key'=>$Search_Key,
					'AirRepriceRequests'=>$AirRepriceRequests,
					'Customer_Mobile'=>$Contacts,
					'GST_Input'=>false,//$isGSTMandatory,
					'SinglePricing'=>true,
				);
				$requestSSR = array(
					'Auth_Header'=>array(
						"IP_Address" => $_SERVER['REMOTE_ADDR'],
						"Request_Id" => $getData['TraceId'],
						"IMEI_Number" => "3434334343111"
					),
					'Search_Key'=>$Search_Key,
					'AirSSRRequestDetails'=>$AirSSRRequestDetails,
				);
				$DataS = array(
					'apidata'=>$request,
					'requestSSR'=>$requestSSR,
					'memberCount'=>$intMemberCount,
					'JourneyType'=>$route,
					'interNationalSearch'=>$interNationalSearch,
					'searchID'=>$SearchTraceId,
					'ICSourceSysId'=>$ICSourceSysId,
					'cabinClass'=>$FlightClass,
					'AgentMarkUp'=>0,
					'AdultCount'=>$adultCount,
					'ChildCount'=>$childCount,
					'InfantCount'=>$infantCount,
					'APIMode' => $this->APIMode
				);
				// echo "DataS<pre>"; print_r(json_encode($DataS));
				// echo "<pre>"; print_r($getAgencyUserData);
				// die;
				
				
				$getData['BookingData'] = $arrUrlData['BookingData'][0];
				$url = $this->GTXAPIDEFAULT.'/flight/v3/farequote';
				$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
				// $apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
				// $apiResponse = json_decode('{"status":true,"message":"SUCCESS","results":[{"ApiResultIndex":"5714158298515041488","Flight_Key":"KEYAkci00wU1C5k7Q7/yByeNg89mGPnJYs475qpzJttVdPlG4FLfRtjfhMKzTdy2StOy23CJJwLFfmvKHd7Nt67UgI7z+u7BxRCZi2gXt+4A5Old8TvOAncUx6W1R6RxUC5gNtTk5q1yYnqbBTyzWhjAIL8g/Q4/6xY601WSzfRUuvMZN19nIwSTZv7VFtUYPqyOxkmikVRMKVZn8OJ1IYkvrhbDP1az2nnjTSVCB5GLZhSjWQuspn7W5cotGUcjC/e/oDbKJA0fNqqaVRiz8rs+kBX3xelCfMKRX3cQgJVpCsn4+KKA072P0J59a1/Z5NfWvRUmvHolamyW3SoQpxd21dx06XuE3VOaZFyBw+7TsXbWf/H1UAKQJPlFHzG8+UM+5rvY0g97q1qdWoPgcmM7xUR10nwYUMULunX5YAB3vgTz8WwGJ8gsdx/+DntfC022hGHt65jGVkdqWm5AvpnkWgK0vT7j5GeXTqt71z81Zz4B3B6LWp0Fb+Jre/4KhO1M+QH92TOuodGCslSPqLqyvPvpZKGaPUKgWhwSsZzP7VoqPWb7pWm3Bjak032E0pUUGDh9Vv5l5C4lfLGjp6LreF8BkYc+O03ateafdytRTpqWeUsnJosSTlIbEtQIAd3d5PhFRtdcsNGj4wcSKdSDJoM81eCvKY/Dm9IMpd1eJfr/0uvhFzoB9rO9tLeQOZf6SSgTGusmJrVWmM1fbvqiLZ6qc6ukAQpGUhpzNgojkLMMUD0IvCzsbtReAadRSI/FZVKF8Q4Ep9ugbRNFoYLlBU/FF79qCCMFnyU45bxcQ6e6lTSFpMkb5rBYMh/bq/ap0OonqaYtGJZGOvOYqw9gRUoMocd787enRXuhxmlYxW5GN9eNPhNOG4c9s9Yb1fAki6NtSGKO3pW1G0e7qDfLJpjOejWizJQF0Di1prQv3yVCubsyCVaz9c1nguTgXkRj2rHw40Asv1WY5peVXN3VBcw8UPb5VR2nLrBm4YPtE9FoJ8Q0QJFcEN4h5MuL1WEYoHWk/0bK+JaIaDE4vrJTxeulmHz0+IiBi8A4HkTvHNzLl/J68wesk9n1PY8fL5FT5shAavDgdQyHmPOZpW5BHROjuOHlBmb88cMJ/nC0gDz1sH4wN3WjvmdseJ1Wpdh0Q35X6+CH0p4XGR4Cj+MtVAsK2ygn1HwC5JuIR082F7pR5u92tZExNgn/wTK4Pa2dkXyccGbt2cH6h0atMjl6yeWq68qfkSAFuCr57uzIxrA9XqXjBNrvylID9FNH3OXhtTycP2Ut/+cuWoxHyWZYStRwqOaXrGFdScUNroJxXAIDj1hfKk6ZXfrBL8hVh6QEKFrZ/Rf8OT2amvssf72UMCdimzHpsE67Rdp2gFf3wMTY4bhBxI/OoXFRP1C6cxv3FiCjO4F8xpwCdp63rS/fqqakrrv04Lf20XU/Ff7wY6xh3Z18Jl71GngTeZWtCYiEaUqqUh9pBnNmrKSgy9+gLDGFW7P8KGrlkvTWpZVV9O3r3C1QhkiVysgAKcqou9R5+9jFiUau7LrtDy5T11nFz3VM5WYv8h4qmmJfoa7mwKe8GqdBo+2IFbAkaG8i7EjqRsH1XhmfSMpy/UlrMiNApCsmwaqY1nbyVFx5PnQyG3+SDED5gcoHe3wc8XeZgC2aM718epIXInZWUo0D5dp6yilWcgjRh2Ei1BmAynN4HxDdvNU2eJ07bx/z3eH8Hq6+Bb19KLdVAuteNhmscul25ExRUSapnFc6jeFsRrYBQWK0Nz96R+pFTMVq7rMVCfAxe2A8VoD4S4qKUM+hJmi/Sa8JvZPRTRI21ffYHzspmTnE/O88SJkhV+6wbOQTd3aA1XkBEjyRbsAqzojYcrkZ887bW9M/UZ9eKJuDCE6ElXuiNtwJlKIWNhVzx/2q/vhYljuTlyGZ3++8WhQl8wl8SO5AKMjBeGlz7c4uusCjO1U33gFMb6NxX0eFhqMIr6OoLRQL+XFDF+aEMWGzes0QdS6Dzf++omKcoVELdb1mx4kNS5MdafnbTAlp/9jTTMfTnHeekcqvAw9eMmsKlO29wp3Jnd4JJH+BdOoyz6fsPIjpA1wJp97NmDD4B4U8WJaSX2VA2+GllNJJsy0/MYdqHBNbLS2OtgpsKSPiWOp1iw=","FlightNumber":"6E- 449","SegFlightNumberArr":"6E- 449","AirlineName":"Indigo","AirlineCode":"6E","IsLCC":true,"IsRefundable":true,"IsRefundableTxt":"Refundable","FromUTCTime":"2024-11-18 05:00","ToUTCTime":"2024-11-18 07:20","DepartureTime":"05:00","ArrivalTime":"07:20","FareClass":"Economy","SourceAirportCode":"DEL","DestAirportCode":"BOM","FlightDuration":"2h 20m","StopCount":"Non-stop","NoOfSeatAvailable":"5","JourneyType":1,"TripType":1,"ICSourceSysId":11,"IsInternational":0,"TotalFlightMembers":5,"SearchTraceId":"08e64-4a6be-95b8c-46ec3","logo":"http://local.gtxapi.com/public/AirlineLogo/6E.png","PublishedFare":27883,"isGSTMandatory":0,"FairRules":{"Currency":"INR","CurrencyRate":1,"currencySysId":1,"BaseFare":19078,"Tax":2865,"intPublishedFare":27883,"OfferedFareAgent":27883,"PublishedFare":27883,"CostToAgent":27883,"PublishedFareAgent":27883,"CostToAgentCustomer":27883,"PublishedFarePerPax":27883,"OfferedFare":21983,"CommissionEarned":0,"CommDiscount":0,"TDS":0,"TDSEarn":0,"Refundable":true,"IsRefundableTxt":"Refundable","PriceID":"R4840103164931654160","Fare_Key":null,"colors":"#000000","FareClass":"Economy","classOfBooking":"Q0IP","GSTMandatory":false,"fareIdentifier":"R","SeatAvailable":"5","FixedMarkUp":5000,"GSTOnMarkUp":900,"CommEarnedAgent":0,"IscheckinBagInc":true,"IscabinbagInc":true,"CheckinBaggage":"15 Kg","CabinBaggage":"7 Kg","IsMealIncludes":false,"FareBreakdown":[{"Currency":"INR","PassengerType":1,"PaxType":"ADULT","PassengerCount":"2","Net_Commission":0,"NetCommission":0,"BaseFare":8664,"Tax":1440,"OfferedFare":10104,"PublishedFare":12464,"CostToAgent":12464,"TDS":"0","TDSEarn":0,"TaxBR":{"MF":0,"YQ":0,"AGST":0,"MFT":0,"OT":1440,"YR":0},"ApiNCM":0,"CommissionEarned":0,"FixedMarkUp":2000,"GSTOnMarkUp":360,"intTotalGST":360,"CommDiscount":0,"AgentMarkUp":0,"CostToAgentCustomer":12464,"Baggage":"15 Kg","CabinBaggage":"7 Kg","markUpArr":{"Currency":"INR","currencySysId":1,"IntNetCommission":0,"IntCommissionValInPercentage":0,"CommEarned":0,"CommDiscount":0,"FixedMarkUp":2000,"GSTOnMarkUp":360,"PublishFare":12464,"CostToCustomer":12464,"CostToAgentCustomer":12464,"TotalEarning":2000,"CostToCompany":10104,"CostToAgent":10104,"AgentB2CEarning":0,"intOfferedFare":10104,"intPublishFare":10104,"APIMarkup":0,"AgentMarkUp":0,"TDS":"0","TDSEarn":0,"markup_b2b":0,"AddiMarkup":0,"AddiTaxOnMarkup":0}},{"Currency":"INR","PassengerType":2,"PaxType":"CHILD","PassengerCount":"2","Net_Commission":0,"NetCommission":0,"BaseFare":8664,"Tax":1440,"OfferedFare":10104,"PublishedFare":12464,"CostToAgent":12464,"TDS":"0","TDSEarn":0,"TaxBR":{"MF":0,"YQ":0,"AGST":0,"MFT":0,"OT":1440,"YR":0},"ApiNCM":0,"CommissionEarned":0,"FixedMarkUp":2000,"GSTOnMarkUp":360,"intTotalGST":360,"CommDiscount":0,"AgentMarkUp":0,"CostToAgentCustomer":12464,"Baggage":"15 Kg","CabinBaggage":"7 Kg","markUpArr":{"Currency":"INR","currencySysId":1,"IntNetCommission":0,"IntCommissionValInPercentage":0,"CommEarned":0,"CommDiscount":0,"FixedMarkUp":2000,"GSTOnMarkUp":360,"PublishFare":12464,"CostToCustomer":12464,"CostToAgentCustomer":12464,"TotalEarning":2000,"CostToCompany":10104,"CostToAgent":10104,"AgentB2CEarning":0,"intOfferedFare":10104,"intPublishFare":10104,"APIMarkup":0,"AgentMarkUp":0,"TDS":"0","TDSEarn":0,"markup_b2b":0,"AddiMarkup":0,"AddiTaxOnMarkup":0}},{"Currency":"INR","PassengerType":3,"PaxType":"INFANT","PassengerCount":"1","Net_Commission":0,"NetCommission":0,"BaseFare":1750,"Tax":25,"OfferedFare":1775,"PublishedFare":2955,"CostToAgent":2955,"TDS":"0","TDSEarn":0,"TaxBR":{"MF":0,"YQ":0,"AGST":0,"MFT":0,"OT":25,"YR":0},"ApiNCM":0,"CommissionEarned":0,"FixedMarkUp":1000,"GSTOnMarkUp":180,"intTotalGST":180,"CommDiscount":0,"AgentMarkUp":0,"CostToAgentCustomer":2955,"Baggage":"10","CabinBaggage":"10","markUpArr":{"Currency":"INR","currencySysId":1,"IntNetCommission":0,"IntCommissionValInPercentage":0,"CommEarned":0,"CommDiscount":0,"FixedMarkUp":1000,"GSTOnMarkUp":180,"PublishFare":2955,"CostToCustomer":2955,"CostToAgentCustomer":2955,"TotalEarning":1000,"CostToCompany":1775,"CostToAgent":1775,"AgentB2CEarning":0,"intOfferedFare":1775,"intPublishFare":1775,"APIMarkup":0,"AgentMarkUp":0,"TDS":"0","TDSEarn":0,"markup_b2b":0,"AddiMarkup":0,"AddiTaxOnMarkup":0}}],"tripbinfo":{"DEL-BOM":{"ADULT":{"cabin":"7 Kg","checkin":"15 Kg"},"CHILD":{"cabin":"7 Kg","checkin":"15 Kg"},"INFANT":{"cabin":"10","checkin":"10"}}}},"Segments":[{"segmentid":1,"segmentids":0,"isReturnSegment":false,"arrivingnextday":false,"originAirportName":false,"destinationAirportName":false,"originCityName":null,"originCountryName":null,"destinationCityName":null,"destinationCountryName":null,"destinationAirportCode":"BOM","destinationArrTime":"2024-11-18 07:20","SegFlightNumber":"6E- 449","AirlineCode":"6E","AirlineName":"IndiGo","FareClass":"","cabinClass":"Economy","originAirportCode":"DEL","originDepTime":"2024-11-18 05:00","TripIndicator":false,"IscheckinBagInc":false,"IscabinbagInc":false,"CheckinBaggage":"","CabinBaggage":"","IsMealIncludes":false,"Duration":140,"GroundTime":0,"NoOfSeatAvailable":"5","strDepartureDtTime":"05:00","strArrivalDtTime":"07:20","FlightDuration":"2h 20m","LAYOVERDuration":null,"LAYOVERCity":"","DepTerminal":"1D","ArrTerminal":"2","filePath":"http://local.gtxapi.com/public/AirlineLogo/6E.png","Baggage":[{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"XBPE","SSR_Key":"A4RgDsqln8cEQOizJrPA+8a2Ta2Obk4PsUVVB19YOd+C9V40oDUq8AIDNvuLQ2rXYeVnfzOebT8TmBGcwcPsumRT0ouff1y9SQkzpyOPvhO1VBpOaQDjhZ2YKhK7JKDWNRuL49YMOAG8omLka8tS2PwUKm2SYuaSUPaNKPLnFZkGMgZrHVz12Ujke6QFad3OvnUEfS1PRYxpBlNmmM0EyxaTmOzzYeQtgeQw+pTh3mIIIr/iGzahrj90My3CTwlHVgO1dw2fX5FgpG3JuGgOGyKEeuzdY3OpzWOLaqYpg15aCQs8Pu/qQlesqRJCzXsydkho7x/FD3mLQCIgL2bXso2l2Qw995b0cKfVoK7kY091pgMMthcyREszbSlq2cHIfyRyHaC6UUFmmcNge8TssZ94EJa13ie62KIxJ4OIGDD0EhCQ28N0NU7yOAHJdwNWsPc3pOLpDsuv6IixKY2xdt4ggKijxlhcZ6oUXQ55hvCkbUNyaw8wYHQ5qodEsBFQ8N/Vtw7ZuFs1oJx8xKH6+wF8uFzmAALUS18fud+PnUEOsJgDn71VGZDqk9D1oAtrFCbAishk7MyJIxqcxjHw1F3/pADXlvkEK2xzXvT825jQ4EvQCgt6icuRjJ1ZYLh3EeVZVDG1YjQZO6aliLG51UFj6+MB3tJ1X7VoFRMJCVU2vLZDa3XVKBPyJYNausaD/mfZT+sMDVnUYOQHvGatZ5/yI6CKYwLCAhnAmGY4K8cA+T6k+yL65oOTdf4Ltnon","SSR_Status":0,"SSR_Type":0,"SSR_TypeDesc":"Prepaid Excess Baggage 3kg","SSR_TypeName":"BAGGAGE","Segment_Id":0,"Segment_Wise":false,"Total_Amount":1515,"Currency":"INR","Code":"XBPE","Price":1515,"cost":1515,"Weight":"Prepaid Excess Baggage 3kg","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"IXBA","SSR_Key":"hEKvFnFpjSS/2lfVk9ww/IS7Rj9AIedtRhMFLvTfPLqvf5RwLxlWYkAUjpasvw6wgUBc6rTOzJY5DhuqnZcdLd2zGZL1umxR4FoLUTaYthKg3+lEPCKOigQ0RXDenm5BMrCJg0vL3Gjm3l9ZCku7auwYuyjS805AbER+MYQDzOrTGNF5SZ50nvRTnXE+4MSNMcLxJfyXvwMfmhlZWkBHx3ObmEhPu/lf33TAoJ/VzAfx78VroANY2ra6sQx+V+TT96q1SFzrl8JTPGGQR6Kw+mZoXJ15cyapfX8ShHWFr+xInzSQpLbnJcJ5462ej4ipuJPvehxlHT2w1hyxg2ujnOYiruEQmJhl4J2EKi7brBXEqT7BQVBDb1iDAh3sDxJ5nugJQsC+rlFg9+BkY+/8XsRDYDxMeMHvQ7QFTZN3bl17vCHVZRdojN+IQwJnmH4LdaGgnFA4CZeNPAjZkKFos1T+pxemupr+7JXs6WRsupc4ILPnNLG0z53PliqomrfBEE8690RX94rcBczsxPTPirU1fwqf+yivxntK9Wj/o22BoUdIw/hWIjCSeOgw+cVmcfelpsYGAKotUGVMnXpejVH3b+/qkQu7keb/bIvNTbxbaW0z0WxO8TkJbDJzspO/LP6QvKvAW+NE3hU6SL3UEixOoxqxrK/N6GC/pzfdz0ajn5ySvR1xei4rHeSl4wjW8lfTVpDar7x43wFMG2WrqdUqbjDXrlumEE8a9qBz5P9Tb5c89aJdNz18NDmkTFpl2i4mkJWA3qXol6k04QChNo/5Hctsr8RMrkE7p7bjCQs=","SSR_Status":0,"SSR_Type":0,"SSR_TypeDesc":"International Prepaid excess baggage 8kg","SSR_TypeName":"BAGGAGE","Segment_Id":0,"Segment_Wise":false,"Total_Amount":1600,"Currency":"INR","Code":"IXBA","Price":1600,"cost":1600,"Weight":"International Prepaid excess baggage 8kg","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"XBPA","SSR_Key":"PayT0VbasdMBryNS21BrE2wL4erFNDKMgE3Ukp2Cwa1jfuZVwuc82dFSi+yK/YbIg8OJcYIX4ph5CBQtEKahatAk8hj48H25gEUdVSETlyGJiQKFDYEMPLNFmGFMBdbh8csiM7ZsY3LuHO6w/18pX9b6/msHQUTO6VOryNMH+FBYf263GZo5VulaSMZe4Kza+6ZB1B7XtEV4OZlHm/2+eyNMG6T7eXksA6PsVbkEgx55+MOX2xZFwnXQdhnK/9VaUq3lnykVqqU8q3yumbASqnmxSTu/jVuLmo+0oQBwwZel4EDW8Uo0/O2FhfilOPJOA4EWJdr0ARcTxUn5KEPC715cLQG0pAyn4z2M0Fd6zvHDzMWX+VpY4wx9Ja8uxEbb04ELGmZN22oco9ICDb0+qC4fXVwaWHqJJSSkIO0qPvoTmYpF5EqkEixA812vfK72yv6Lq8coiiFtzvBLBOHOIxF6S1b6RDecO7MQiIp4RF4986cqkfTjUcghLdOUbDAQGNG/8FxlMAm8Ncz8Mn/GeljX75RHqS0Jx7fqvDBd9ooKuuaLJwWSe1qgVHf7QlTzCyxGrQRhHcJxzq5hLGf5CWijf9Oq8Gp4dKUxYyX5NhfiHSfKh3fdY7hOTj9RnI3voEN2bFSxxcOUS1wBpv0pkbD+X7Gh7oXvSCy1UIu7OYTQQAQ0iYQpGfgX78g4zVxRKpQYgWrfUfR++kHSJoP/ON1JVTsoBb4S1fcsKFAsqDql76FLtN5k62FDPGvdpOA8","SSR_Status":0,"SSR_Type":0,"SSR_TypeDesc":"Prepaid Excess Baggage 5kg","SSR_TypeName":"BAGGAGE","Segment_Id":0,"Segment_Wise":false,"Total_Amount":2525,"Currency":"INR","Code":"XBPA","Price":2525,"cost":2525,"Weight":"Prepaid Excess Baggage 5kg","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"IXBB","SSR_Key":"Q7KW/igCnX55MtcAwM/pdKKZblEtK/QD+d0e/hcMGFuGzpCwJ2DnqacXu76YeWuV4hw1h83AHowiWl1b9txNWjjK637sorgkRxqWpCsF1dwR0aY2VZETCeenwRz0qSTlxLuHnphfMwiYwmHMJY1fkUYus0BksVWc7+v6zEUNy61SC+gss7WzNMZNQ95FM86PVNXNOCLZxp4LdL9u6KoC14c+5optx3MMK/k5CAAYaaQxWpDW5XdCkI1DzRSsCHJF6ZUhSX0bmTvQQ7NtuCdWAueoqyWEaIG+lay8osF8elyr2oNDHTNAxJlNlMDnYVij4JSQ6gC3Y4B3mje22TfkZJTOXRdZWW+8FgzHVw9h3P/cCGkdJAtyoj77j9wpZg8t5PGBFagIO9ul4FLwd2rsf7LlziUu1dnNt1gH8xJWK811AezR0cxWoljJtwdj+HOHnq8JVtJ1X11fGOfvk0cY3APuNwZsvs6sEzaa474gVfRNXoUYTFM8k5TCLRx3lwPB12gr9biZpbmyIAnTApj+yM0A9UTpKFI/HuFiVzCkZwE17FwweaZ4tV18kIk8iNBjKdxMTcxDi3DSwHBuyyw1fmNbcug+MCsBLFeqwwmfaSP1cBOT6zHQX5q2fYho47uS1aLaVTexqbZKPOPloboQ52pNyohmZUwKtEkSe4vrJYsA+go1xvYj/jF7dALk4/r5mvrHPpI5I5YXFdBrLRQ0JkRd1HNS5YVV9uGpSE/n03c0bovbOlSQEUPp0vvc4ZELLt3T2Nt9M8NZENPN5CIJkAQnTwt0/j9fllw212Ta/S4=","SSR_Status":0,"SSR_Type":0,"SSR_TypeDesc":"International Prepaid excess baggage 15kg","SSR_TypeName":"BAGGAGE","Segment_Id":0,"Segment_Wise":false,"Total_Amount":3000,"Currency":"INR","Code":"IXBB","Price":3000,"cost":3000,"Weight":"International Prepaid excess baggage 15kg","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"XBPB","SSR_Key":"X9ewnva9Iv7a4+W9SmpfuLNT9nvslw7pzoKuFiJ7pTOWwPMuy7M8SMQexueF+DLpuMb80ZGAkbw+jaub5jit1M6nWLXgCeFp5cNGj0g7kJOibRsIaDqTF3kbkarw1KKJJv4dpAp8s66EahsUln3fmoXq4JMmIqSiEHju/TKisVjenlv5gnmZgRFIItXFIm8FAeXxpMCbQ+wsWob+zZVTSLQLemEn17bW/5lXBV3wCAI1qY71chhNH5e8O5YS5p80wOJjtHCEjnGJ0w1kO7rIV0vOHAnuTAFgyaZnnEXci+HGy2o3YTMzAjRA7Czmaal1dEiQSFnURmXZthe8CPI7p3AH5D+uikpaQt+shB6MkzVQyrkvstgyQl1E2g31Of1jqTXuRC5sqeM/XMyT98eNbru9AAEipmx2e1kwtumwjBRaBfSFBAV0jrm0jMfX7XZ1xL2XS6aw+ySlejSpisNR5ttcc3QVKR2UtQJ53i62IROhFDX2kp1MktoiSnMxeNIzRWnUt03kXCC8/e4HjkNxjv1/pQnI6VOOY7XyK/LOd4OE+/M39kR2DX4oVm8Ex72v54wvHYG8TmPYNYIQdZpIf7ub+SfkzMF7xZBtJHc/dvBQQrcvVVS9RX12DDqTxF/k8STcQ23zbN6lB784QLPLowa2DhzlVSd3qDmOvoVIXNvliNfj4QWWKL21IPAB95eAChkdF7YPsDmzQsh9sRkYVh6ILDcijQqKXx2zOpvQk0xKGRBUC+3YSfDKfXKkHYje","SSR_Status":0,"SSR_Type":0,"SSR_TypeDesc":"Prepaid Excess Baggage 10kg","SSR_TypeName":"BAGGAGE","Segment_Id":0,"Segment_Wise":false,"Total_Amount":4950,"Currency":"INR","Code":"XBPB","Price":4950,"cost":4950,"Weight":"Prepaid Excess Baggage 10kg","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"IXBC","SSR_Key":"hEKvFnFpjSS/2lfVk9ww/My4SNduWmZWyBF/tMV576WD9ieIlTshrchQF6g5zUT8UxyKfXm5OuJuCB8zm6qdQZLyTXLDZbuXaWzTR2jZtYUhewdO/fCyd5vorhwbAy2GjQQFnwyuSidfNILH2PwanXN2rCwQNIhE15UDy9sOj/D7wjCtnmwmOXTCz6lbFE2PQfUICjGbhe0v5Rgn3F+6DmiCIZlndLWkNV2jwhqFLuy2bZ+IwroPE+q1lP61fcfQ5IjiEntfpHr10uVIudxRkXKO51ZJEbl57vAKn7ziT8a8KwctwWtaIIe1iSRdVEYLFe1zEBXgVSiGpruPRb6Eu15aQdAS4Pp/CNHQuF7WO3T/5MXUvWE2otwYyMeZy9/jkIb9Wb1imZRNLgpM+c/gvgRcavIqWgATko+sssBDi+UqT0uUT2QaDN2h434ITuxDLPi4JMqZ1+COAdswEvzSh6lahvH3UHO3k81fHaPPqKyc5YbOk9Xk7H+5IaI3wmcEYCsfpvSbYxfR1c3bbtLV0zGNnlEyp9/TIxULyQde53XVAxfLWMZ6dtUH1zm0zCD129kw9fmrJcwO+vzg25XMIG328Zl32kfxEuSwG0TlesJ/AF6h7x5YD+BOxzPD+2BU6TKSl8WvsPGSWoavwepFV1XixtfR23fK+pvlrK1ruIjYjDEZuGHVs/B7YXWkSYPj5k0ARsYQTDjUIHnI1UaIEfU/l6Buj7iI08+4OAThZ68Xh89/tDCJcgy5EFui9SA5m4Rd0aYIEVHdcTJOlqY7EuvvLkjAGp7NDczpjPV4iRk=","SSR_Status":0,"SSR_Type":0,"SSR_TypeDesc":"International Prepaid excess baggage 30kg","SSR_TypeName":"BAGGAGE","Segment_Id":0,"Segment_Wise":false,"Total_Amount":6000,"Currency":"INR","Code":"IXBC","Price":6000,"cost":6000,"Weight":"International Prepaid excess baggage 30kg","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"XBPC","SSR_Key":"oljfC88HGyuwMqQtQXXZU3vYZlH/1nDsp+tIdvzJOJ/34H+7Ty+ljpnDbc67wog2rIegVBNBDEt1W2zI7ubVlUv9GTf5WBOu09H0T3ZVhArg3T2BMn9avCjUPIkeYsMXsUmLr83GD9MddC+tIHNmwheFuraekiPSi2aTIInfuzndOLXo2AD67ehVI69rqEIglxBOQM29JIXVZrv5j7FrbtQsGhPyHFAjDQ0E/jAV6n1yCzeUNtc4914bR6Ktv6G3u1UCqf7Opq/CN7s67kg1d1f5UufZrNW/NeBfCZrS2vtyVIONDOM41APTOfDGPJz1FDl7DxCdgY98LHVZuftXdf1vYYx7gGdRALP8/D5j9OAtTikCbFDkg44j7vHVgimDBJxNgONZzVfyspVmvINBphpcIAhXt2JJtGL3kOZi11UU26MwFKwktzawOelht4aqO+QwjEPS/riyJPZ9fAfUuEBSTcQV8L6K18lLCK1FaOOVLZMK+42mDWHEKglb+uD2tM/JWlfbUmF0JA6El7FAe4gegbju5danJ4Ma0gnTFqJcG6yE2XOW5bKg32+chYviAxG1Ay4rcPw/YCJRnVnxkGsdz1faQ5ifWw9IbDfX0lBHnAFS5BYUIKrHp7/9KRwPtWEFb34OH5YAnzeCVP+GrHOfhX96kOHexnb96OKEBJA0Mi1tEB0y4xMh4k5bIwQTXtMpyDRyUXyYCtiIPN+27tkkah5MLqkNiOsZhg6ItDN3VkzkwD/1HVeE0UFtuiJ7","SSR_Status":0,"SSR_Type":0,"SSR_TypeDesc":"Prepaid Excess Baggage 15kg","SSR_TypeName":"BAGGAGE","Segment_Id":0,"Segment_Wise":false,"Total_Amount":7260,"Currency":"INR","Code":"XBPC","Price":7260,"cost":7260,"Weight":"Prepaid Excess Baggage 15kg","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"XBPJ","SSR_Key":"Q8YZYG+qYOXILA9et9ZkNJGU1noEo2ob3ZgexOkVQ3dXiru9U2W2XR+F/23m2g4UoSGvm3j960GfJWUfQXJFsEIO7sxwvbGYxsb0n9OGoHT6BMUjqNMmbe5K6DQ4hP2OCt/txmZ7HRBaGmUJCbu7TyUhT7buFunqLNKw4j9KBPNk+7VqrsGyBOAuamIbK7YuBkOBLNTI4aKSJPGVQiABZwGE4jB5eqy0NbByx1h/DkOJTdod55WYF2SINqNu6ulJZjZV6lYUlIpB9Oqf4dvQdByd1a5ka3a5E28w9WuH5Lvje4IPfVjpdZyZhaQJo8kvB0lCpjlCxL+mkRcjJZ5EckpcuwIneFHdS4Dy4nTVaR0aEqklS8R3cEbPuHvJDTfr6C2oOjZWfZ+pBP3MZL8pYKgAY598xoQ4HwfxMUj7UuO76w490SpLDCnFR00AWQpZw34LwZ0Or53lYczH1VpDX40yRwGUrhJijCH5rcegXTCHPm0YIG/khjdYtMjx/7K1urN8FZeIkSypm4u09ALay14q/pMNzryx5NfAITcFgQZvnxaIdf4WVAK3sPzY0ndz6/O6hWJbB+w53zaIGCfVJwohmkmPxt8yvI5uFlEuw92En8ZJ7Bbf1OTj/tNat6Wj82X+G43xu12TJMq84gt3gQpRBuMNxANI0lHJVsGrtdtjWsDnj9pr6vg9By+V8wH7w/rneto8b0VHHH5rcB1RJ9c/KnmvmqJInCAioibt1LRar7ulJ5/7jQc1h3LFzSQCaJj42FP/INh7MlKNSpNvIg==","SSR_Status":0,"SSR_Type":0,"SSR_TypeDesc":"Prepaid Excess Baggage 20 Kg","SSR_TypeName":"BAGGAGE","Segment_Id":0,"Segment_Wise":false,"Total_Amount":9000,"Currency":"INR","Code":"XBPJ","Price":9000,"cost":9000,"Weight":"Prepaid Excess Baggage 20 Kg","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"XBPD","SSR_Key":"oljfC88HGyuwMqQtQXXZU7Ynpd1OdvzAo3LcbvteQNKSn9qlksU5YTYMCWULfHpA7oWlDN9v0FHkxkvpy7qof/5wP9NDVTtLOGO1e3EHezBjt1xuaqJbEMuaQ2Of1vqh6/PIsn1vQK7uXr/Mi+J57uRZd3w2JEcSlMprGHnt+QqpQx5BuM4SHPZbOxgydMbESn8noVGxcb1t6yYiaNI6bxM1KxwYRnyEmfSIvFb3eMP0RUBL3k+WOjw6w4CSrk+voflwS4lHL1FFYJUHMpOJprnWCnL6oHlpKP/6irNM/znKW6KDlukWah63fg4/SOe8wKm0U5GagSJdHTF1mQnSgH/htwNBWvJ+MMumQ3MY73nesWid5v5oTO3VTkCSNf3/o7/AVz01zD95KWfn0byzB0jxI3WveU0D8ydkrm5Tv7UXYRdu1zbdsmqTnu5JcaIUcTKZ5MAJgaPJpkMHjIxZltM/UGK+ea8zVnMi/oheSz3uXhtLfO/mNfrmZia/72AgnuNImE4hTUAUnKdLhfAjAoe8FSVMuyX3T4QiIM6HZTsHr2yVF5uW6YoMPjQKxIxk8F91T8wafFNrClSomWQ5kwTLeljV3+tbq2LjHrUnrfFQq7BNIkfvNDwVX/sDeYuD7H6C8uT6QilrtKYg57H6IJOU5pEJyUU+bjWl4SMUUnzRqqzH7yMZ5BOHAmm9R8GRiMbiTLdmZEiWCKwdFFXxfsdoXnedTdrsF0cPBNfwNSaM33z7yeRZN5oiQxdK6dAoz4eEQy4d++EM7/q4rIVTZg==","SSR_Status":0,"SSR_Type":0,"SSR_TypeDesc":"Prepaid Excess Baggage 30kg","SSR_TypeName":"BAGGAGE","Segment_Id":0,"Segment_Wise":false,"Total_Amount":13500,"Currency":"INR","Code":"XBPD","Price":13500,"cost":13500,"Weight":"Prepaid Excess Baggage 30kg","segmentid":1,"key":1}],"MEAL":[{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"VLML","SSR_Key":"w27iStZF0gUa8tIbCkJxBMyWfMIEuW8lAvep9OUz2DBCnr1jD/9CIfLb04SedWyoqhR0ZYVQ4rIw0LDnsdfs7JiMgxeXMCxS4bh5qQ4Fp+vc0TiWhxrqepucvc1BHNDFTllFLmRPra/FjJBofy9p9zKj8NDISvhArpbtpoahGqT3kEnwI2LlTWWjHfOpHiiXdyM/RVWGLNwVom4Iu89NnmHK8xUkIb8wy2dxmzVsFS5eoLK7jMktbcysRO/ELkmsdC7Zqpz3Ik6k/PA4t95ZjJUqEwNCr+ovFY0b+axVvloMLAM4TOCSmbeT7oY/8JQfYYg7gGn/4s7l4QyC32CUvtfN33Zf+SiADWaFk40Z0QKDPx7vaoH5BZXs6wn5uBaemIH61geSxMwLFrhKXII620+PEPldDiBC6pb/ND+hLSPWLkqAiGggAJvcg01o/DXa9KMBgkX1Xs87gbi0Oex8R/SIJyHtC/swfXMol/G/XheySv7k3xLmVzCPJ/aTdb4z4a/0bhBgjkd9hsw5qUtNVsHEb3K15KDbDlKB/h8C/iz/QPba+P8dVGfSveBfvxpmvvm1yMOkV5j/Li3hbezr8WlN8nJLzRhK8yMxwaGAbZLR6cvZhMSJRECKmIcjYjLnQq0vV/W1E5zrI6gVWYziyQSzUEDOn3r9kaZhMenbmQAJHE9h3GibKuRj9Juab9XyoJId2wUMOiYV2wUJ8DlJ1A==","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Veg Lactos","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":400,"Currency":"INR","Code":"VLML","Price":400,"cost":400,"Description":"Veg Lactos","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"VGML","SSR_Key":"1wyz1ipMkzNlnYh0cVrhtXBkteDOWBpN2e9jjyvj1Ws1i5sQFBZ+HG6zaMPF+gYpdYJtIIrQhgQmPW/RFqswY/QNG+SgDiZnJQ2vVnp0HQATqPXqhyF55LqJBeCCDfHIWUrNoMHEp6TNyQ62aqw5HtG+AX0RE+0FTsdzk1MIYkcurBEMYu6cF7s34T+Y0AerM8C07Lk7WsEuJB7/55MDco3dMmBzWRmAyj7IYtxFkauphbpQRFoCi8NE/IzjVFP9dc4sfSJfJpEy3oOsrGk3mkmnD0vC4piLdPq7N2AzIrBvDMbmurdYgdFd9gRobcpY4wN4U/2j9hM+tB/9FMI7LJigqYFJojPDxZBPp/AsTeVYjnlEldH8+Pie0M8ktPtbuugqyUxeBnxBvYY+2VmGNid1iOT4J/vYWbOv2pN31jU6etEBpy8SXMtGVMwNsiBsFxViAf6FuY7owCQo3urNxwuglkRffV/An33S5tAU0kzJq9rtqas2woUvwW2liv0g+/fJg7bB2fHyd/K7V7Rjkm++p8I5kP/T1CYWG5sXWqLbr3DQduVbG3CY1bA4CGdd839tZZAuUXSSe+hgNj2KytTQecIkWthb2OSpup18kYgt1Ll/D70qh0Q4DUV869xHOaVKzOBm7cQAjI8MuZyIqQIHzUqYTlQAe4D5vqrkiXm1lTMJ6i3+j1VLZUcNF+EXALpEjJprpLLdAxIlgWDqYQ==","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Veg-Meal ","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":400,"Currency":"INR","Code":"VGML","Price":400,"cost":400,"Description":"Veg-Meal ","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"VGAN","SSR_Key":"FwYawVXx3IRdQrQ8Luw5L5c+wX+PDFuyGUjq1Ciswz/ZpH6mffvE3vybWCPf57PSEUD1/Ev7fkJ+HBxGRSRESH3gCF/KKY/C3RKDvyknEU+w0gilVM7Yz2/FLlL4+pbroDnN15jGKGtTw9+nN02DSPegJ01kjzBaKyVnTa4uypFvyRQq1ZUWjh/s67w+97JrIq7APZHLHrDXUdY725RQJz2BoKOnoNPKnDr7zPXAnEW1+hXyjrYfVnxhEonAVfwhDQld9UMUmVfZ8bKR36Tr722sXuEQOwlqINJK7rEk+ZbipId2GsMDf8SUXsqIUm+urPfxqL3onJRa9W1WbGwZXJ/0/eUp9PvZX7Zllj9/4is4g4T8HGUO8evvh5DVBrcQ9clUrVXGL5muLpz7jGcF6SG7oi0k588KJMM6D3mEe/NrfA98ItRa/m7/QLDnSe7VZe76gG6bdlM6Uycyi7q+Rl2bb94FpYbky+g2PJuHxwiBl4/FjvJCzk0TIWJ0f83knYJzKSjApoID9cdjR8FCsllxoTpdxH3f5jdW59obpivhql0UfZW1K+xdHbYHCLdNUkhtlq6NYXUuotc7xHkCaRD6WKbXh0NSXlj5pSugXAzEa+3v/ctbs/wPWLuiLUH8mYPQFDLZkdnCDJ7LIrjgURl4A3suZMLPM6fQ7U8lKmbcgWLZUq0TU/+reAsZxE0tFIWpTeo2UFHYAMCI6iTAJ21xoD04XAerowyYMHIHOCUUalz9SydNzkxyIuMUAtGG","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Vegan Special + beverage","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":400,"Currency":"INR","Code":"VGAN","Price":400,"cost":400,"Description":"Vegan Special + beverage","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"VCSW","SSR_Key":"6LPVyGyClLgPVxgLMym/zztZwqPON9LQ8PfQE+L18PtMMrlnDW9CZWGTg4NA5P4SUdmU4qxwUartleo8P0wr74XYiPn1by38dQkPyErUYcIR9eNMHwh6+wHrQaXvNBqduxasbr0r9bOoWWDJB3W/MUuubUjjZrgsVpt4dmlep6UwVb/ItIS7Ef7WJqzKaoFj/R9uHH2LlrnMaKheTWDqwhgFZMdLTwzQG4SOxXIlAAbwpk7wcfpK6AodfclGsBzaFYuu/3yzo4OOGCwEyKdYahg+92L4mdvUPGQiNpt90+5pkIWc2dEqvVkvqY20PQTw04C8sey5xDY4ZlPNMBxdlMUO4GvdnRA9RIo1wZsc82VWgFFO1VhEXGZDUMvJj9bWVjcBgu2+ccXD713xvm7piwZK8NcHYhXecVmXzXP5M4kfawOXb77pPfLeFLcxGgDBHTem0gzrqxVWYq1yVn/E3X76zXbOyPlluWBNAVDYHJHWcPdwFTlWvYbi7VzPbIxHToW0xzUYtDQ+Hdea5wraM7MoJVmfv6p0kqS4fcX7AVYUc4xJd7b2vSBhxfUC8/0yMdk/IKaAXuNGXhh44947K7b8TQ5xa4SLsK82G4+4apct4BtznScGdsv1frB/QOUbKD2AL1qJMXiKiktMGEVTbiWagImrbyq8aQT/IkhiU5RRKm5nk4qwYmeQnzJqL5/1ipMD/qc7gLFEp/sJVhxteubgWTvYul3oKxnLG54epXLO4Xr99d35AMN+Ox/RbHBr07OGECuN7jMv8Q0Oz1lBpPV6EU3Uum49ZTae2vWHtBg=","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"6E Eats choice of the day (veg) + beverage","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":400,"Currency":"INR","Code":"VCSW","Price":400,"cost":400,"Description":"6E Eats choice of the day (veg) + beverage","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"TCSW","SSR_Key":"VnD0Xnru++xKMxi5u0iaLYysxqg3+C2T5mpOW2VAdaeHOKVLhmwUYVDmK4fIrumMrqzoiIXWqvOZwOYZJ5KAeTdm97pj4qcoqnadsHdAT6Sc1r0uCRcGcPFmzNnwe1p62pNijvy3amltRxNWf2inOt6snxrq1DwqtmrVVFpQ6S+XdgFpE201UQPiPRINTTlu++PYGijAyOHHvZTAZO+7fitDeahz4woTuR2OxieWfAgaTn1m/yzFRwV6OWFnLIKFdFWODrEJtFonf0RKuB/pA2OXuX8o3SGoq3vZLpkKlAwhiiqJdxZeD8n677OTt/owzI6YLyufnKDPHvLeMc6HLzrv3/ELWWy1SinYjiDGYJh48hX+mJ+7eEcuQlE+IdQKk+HJqwSTB7lSeuOvHpB3K4OycGiz/HmS2aHh0AUtuuSWN9t9N64AfCJKoPLHeeJWDTMJLs3c/wtRzrLI/uYEndx4TkLNvoSI4ycJN3UqHkXaqwSVb9byo/Jnwd5alCt4wRzb0X0tVWYAFx5dpb7h2mpNy6pfNQJnABtU7oL7xHsB7G+QVXOrBriFzedy/Wd/i8fiulV+n0XhmdodTXhO4TLmSKUt1VHVKjSIdNAqAxRDCAc7PGOt4PTE9lvj2+iiaeeLt3xmT312KN2mpSeUxCV+g1s+geT8pbEnR9kN5/eGsQmh19LGyN8cQrDTPlUN1wNaKNwYiiv8j7GX/Cbj5Vy16Qcmtug/3lUuR1mQuzsiZd/BKDuarVxsGryoyohvuDxhsBWCs2DarwGsCDA7xA==","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Tomato Cucumber Cheese Lettuce Sandwich","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":400,"Currency":"INR","Code":"TCSW","Price":400,"cost":400,"Description":"Tomato Cucumber Cheese Lettuce Sandwich","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"LCVG","SSR_Key":"ifF5WoCjVCpb81AD4YMU7PYoZe4oaHCfCDlS+m2pSZDdNfUslv4HfoZ/BYkHYaXMXJWhO2Dpa6PrLStKVf9C1u4zbhF4nolIxXdydHnpm4utV2rwuoy2sQowUUMG00NmurHZhitsd8OMx7tAIuDBxjayhBN6xkMZ2DgdbOpMjcZ9VEvKSR1PkHSQuoe4CcEjuO+UMHb8l0MuCLuNkeREFiBbByuYgCxSrjYc1vpl34EPGs1WaLheULI0HL2zeTEhUuckMI2/O9bPUB34MUvUrDeMfzIhu6fMIAFwXWpXCouRbd2aoCGVnDjRzNjNQpNrkWVmydn323j+B5Qw650/E8/VsoSP70odKWCh2v9M54vFq5b0XmBDVCow9rtkVB+oAqURzbImQQynIZssw4YLhuAQgjfCpX66OET1KvzIpHgNFc8z67kb6DSfebIJdvIK/Gj3Ct7k5/jBThQibkrats8o4SE2k5ke2gGjkceylV5I+QpIgqS/1Gm5ZHSZebo+cxYZInUvcG6ClVgy54S4LPW95v09TLZpBqRYoVpmvQLwzkjP/n6id0OlRhRwfYlaAAjSSlAv12sMdf82NuxiFZXaq0/rKmG08L78rlqehk6NChSy5Nc5Jkn3kJsEduNONjv79RZUNJtPonqd+hUYcxVc5bqkY5eI6jnTpu1KOgu2/6/KoDanTgZUFiZ0YKIxi3zMlQR/7dnHDtveqykJr9PzRLdwLXVYLPdLdrBVQgCfO+xQt1rwkLYg7xrVRffLaLtRS+duFGBY55KMH9IC9A==","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Low calorie veg Special + beverage","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":400,"Currency":"INR","Code":"LCVG","Price":400,"cost":400,"Description":"Low calorie veg Special + beverage","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"JNML","SSR_Key":"1wyz1ipMkzNlnYh0cVrhtUbT8JimiujCCTD4r2RgWoEGXEoBQsWq3ho/jGuSjoL2WZ12haH8mYj4YV/Gu69ZafSVWR2kA4P+C6h1qECY3obqY6PdYlUhXJ5QySgeCU0WMaO1g3wJmJoEvnBqJg9IBo3jbUIYPx5Cr44ygtN/FA7/aJvwf3kGkF5gqUhXf3N6GUPeBAUDa81UPDa8FNtWCDFalZUdeg2Eb7jkbxqZTwJGwTaN15t0Uzr64aPFOxDpnF7tCCeUmparygYz/IZNEc+g3xeaWqouJHB501Dt8jCFjz5rLvoumEQHD5WSjx1eR5TV6nCd3ob/238yl3Pdk1ZTbWH3clTV0Neg5UtUKZU4B5fOOPPNrJwmIT0mS5VDVHLdROjVMqv35bGBDhF/9Mnx6KODr7/TicoT9t33VHZ3vNP4dOJ/4FR5dIPOb24gcOGkkFpYf9OjYYCwkKekntO/W4mjB4WuGvXVFxXc/MFIbYnK1XrJcwL91CiQJUtuLPaK/2cfAhXMUMRvDp3+Pkb0QBcMHvsC6k8up5T1sHjmyDa28116tC45gSuCCfQoVPaOJLbjIDz4D2OBsfoS2OiFL/WAyPFeg64ZxRq14Wus/2ucOtDLdL4mR0eGoIFn21zYizc9RHHwQJuO+WxReQuyK019s8tZCLmsVjSZG3UUfd+/5qFeqa807zfVW4y2GK1WZX8N65yff78BBXhqqw==","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Jain meal","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":400,"Currency":"INR","Code":"JNML","Price":400,"cost":400,"Description":"Jain meal","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"DBVG","SSR_Key":"wCFnVH+cU2xiOn76LA9WQqo7QsdbetIGRmOTAHERl1TVfC+QczQO4db7HNHJ3/Z5ul8lEvEMZ0wiqstdC4eu2go8jI2M/fhkafhXt5N9mnYuNbjw368gfonAFVo4yIcY1TN6ZodvJf1bV5IRTKNtPdev2KeDHQEkSqSM9vSGjGjzOk1kVyx4tbxgub12Ir0wNP/8w/K9CB2jrrTaPWY7mRD99/XdNl9U4MgYPVCNJOBWkrnZbBRaHYHZTbr223nlQ30bapSEUWXc4X1L/XxLJUP/7hdz1uONvZQmwKVJZFm6CaKaZkNlxbdbrxKvmmT6QH/slJjOj4NYgzx1u4P5uOTO/Te9psPTKXkUQyv+gTqb5sAitgo4h0AF/3AYAu4JlO/AXSc2gK11bpq1mj3EZdToOM195nzY5Qf0gVgPJMUqJhQZeLcBxa5GibwGuNseE0svyix8s6Tvl6v3VTdIjjXyUFnAviD2hM66+RK6xi/+DIr9IkcEcDtwT5EBG+Z4OiKRND9eZu3oddxdlue8hD0ebeacvKhzkfEtd5gwC3ozjjSsSBsdCLJj6DrH2/jR9VGUSZZf8rt/S7EykFm6vY9jzrBCk8c+0Vm0wi5fIImYaiVfeBFT33ROzLDSTGaoyEHXGzIqVO69rp4E537vff75bGYoP001QgOZDSUpm9eEQSvQwzqh3tIzrtNd2BCFWdhSIkepP/hMnXp388FhhuFM3QiPEMYW4Y2gI/pMmUXAvSYGC6hWq3UtD5ZTGcKv2HpAyBnQrE21GECf03S81w==","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Diabetic veg Special + beverage","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":400,"Currency":"INR","Code":"DBVG","Price":400,"cost":400,"Description":"Diabetic veg Special + beverage","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"AGSW","SSR_Key":"d8fHcaBhYnxIP3yika6H/wbHhx7jH2ag1qF5mWatvIT9u5BXu3lyN24bRMVN8/WLH4l/s3QU2rPm9iK3ZY8jvXxN1W0CudNLfheR7Ia2Nor6qhAT99ef3oPLLD739DwfXC/4w7TcsrunMowPP8Ch6fqRy2+8vkZXxljP7G1Bhlo/LmyP+TV33veYHpDH1/MQfxlbUjxcqfRkdFfg0QzZyVqEG5nwm5MazCj7WhGAsdt5RAQbSiIb8Dr1P8Blxh6WkAjkG0h1FX0hAS4JyERAAajUlTmuD/dLsGBtAc75egb/Sa7Ax6JGpc2XprvLvsS5/zpy5QJS+4Znhqh6EKIVblPLZU+vsNY7DSDTlt2cSkWUAkWIh7WBcg4tRGKtp59yzsxkadH3sPwUnINhovPk89uJ7f8r1cyxwt8zFmWiBVRjQEbI4Qwyzpcqv/4jTIsoldpaF360nzo6J2Nx/d7XnQoIDjW7DOOVhjFmHl/9a09Dp78w6NygY2HOK2xdpfmu/gHQH0Szy8FACm3TdOwqbqTH2DnD3B6XvGvyKJpyU3eTvnltfT2ie2dx59msb1JZf9JsOHlWZ8Jf+bBlgCtZloUpYgooVI6LpvZenZShSHM+PQas0x8C0wB5J/Y2dRA1cvm7mLiohy3bKZFZH+L6SrFvN0i8KAAWv2+UK1XHXjf6l8gyxb+yv4NpAtW9UvGECHW+4yVV6h/W7NlXDmaYj0U/wMtV1REjcrthdjoyEIYUVnFcqAxEhSPOvHr5j6ASpkn788OuOr8xr45ZVCTz2u0caB50xMyLyreKhrGgmGc=","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"IndiaByIndigo regional favourite (veg) + beverage","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":400,"Currency":"INR","Code":"AGSW","Price":400,"cost":400,"Description":"IndiaByIndigo regional favourite (veg) + beverage","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"PTSW","SSR_Key":"bP9NbAxeQ58BzldziaSYIHhFVYVom+IBFHTkJ4xVlSJNglGrFO66pQpfsyTRx/9IsR10zeLjZf1XAr5VxifbuwJC0XMQ0CbgIHyuEurl3uKtvsYxOWFO3jx9mzlnJ0R+nuhC0jmJljlyyt4pOdAxsdM3QzBCGScyr1aNfVPrMmaOfCyvdC/nzk29bH2wUH0/FxHScVVHHbxrEKuq8nDLLlvmw8iGi2d3C2WCaFR6KaAxM9Wet1D/5Kz9bBMDSvEUHi1/3WK3LST8fFqs23YOe+NxSm7Hs4uM6z8SyUjaFvcsYbABRGIkU5Xdaa/2vN2rMOZ0vcLmxfpYJXPGE9RQxqaCMczgwF2xPuKb0zsARDDVgcKWQ3Lzx7v/Fl/PIH51PQfD4qTdc15ReROiloICav9q4BWSfLMfZdrJuPgq9tNvTY821mk8/TN+ehlM5S5rWwpqb7c7B1A/zHbDSkhu43ZPmzIB5UWac5Gp/Z0ANjJUsAKqXsMA5CIvefuotOZECoa9MKSEv9Cq7etuN4TIJtB1E9X2hET/S3kWeMmVhAER0X861HV3FAnC0k52bKxYxv5WXZfFno/EM7p+E/ZWlA81+aFzn7WmneB3ThjGHkpW2HyLjcsVOFNEp7s3LbuJ79RE5TVf1Y2eHq1zmOZZP4Ik5GuNKdykJi7aSV+oXSihbruf0YE7wm5/AuROi0TKs9xQxS5k1GrZ+vYZ5vTXVw9cJQC4kOpyVVWqf0AsXNA+136kZW53SNF/wbi/WoX+","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Paneer Tikka Sandwich ","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":500,"Currency":"INR","Code":"PTSW","Price":500,"cost":500,"Description":"Paneer Tikka Sandwich ","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"NUSW","SSR_Key":"Ls0zfoZFxKFaAY++5sxU3MYI6AFHDGtEa0WUYwOjcROWk7qeFlvSK9zTrauVOJI8Y014F1EoJ8jiySP9Ui1OqRlIn7RC9snQo0tzpfaQLhWU5zaqSW35LTyfM4o4afo9N/8RV/RkQAtn1uxYAJDUNX0nBazgRBgv2hKC6HYkXyNvqNNaRPTmuPY9Mlb4Vvvv9Jg9ilFLyNGT33JPYJfgE8tSuIm564f9VdFKh5lkjMq825b9OGbbbXzeQrgfo6Vv+RLAtlB9w4T05lfSeNIiXXcrIChXuAqn40MD4qXpDxBISv5FOrWc2yWRGpX+xHuKm3tl9AtTur6+eztg6F//IjfV3wM1FSLaKhSNRvzPfPRB7ON6owApzO6rqe9BSeQb9O9w9kwteZrYgKpq9Hl3q5sWkdHVNiWWTZozHV9ZQrGq3w13PDvfiv2F/tbpKzLfUnA+OruwuutSRW/noeg7UopnRcwZl+IuOcUtDDSwKFC2Tt33IGk/IDbeYnZyCrWB+3TwjkYspg+iJP55IB3LadXv+6zZyVIYqmNq0pTPZxjE+0CzA/1iMDI0eRjvYFhvfSgFabJzrZlIJdOFDjG8v3FJ3BLxF+vtfHd3ylqzzXt0oehl+FD367q1h+ZVbeJG/GeK+asW1T+s+H60EECu/dhDJjMYy116oOG2+7F481AN56LHu+tH7vN4hY/QYRIc2WDgRGylUWLqvRG/iiqMNL/U6d4WiE8hKH5id3z0uUNgxaAND1il0inVa95DMNz7EModvMurxzxK59otWFO5qAilbybbPZgcmK5W1zK/sP3FH3o4uZWyz5Ebl0GTJpKl","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"6E Eats choice of the day (non-veg) + beverage","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":500,"Currency":"INR","Code":"NUSW","Price":500,"cost":500,"Description":"6E Eats choice of the day (non-veg) + beverage","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"GFNV","SSR_Key":"IYaqSyi+y/ouyPOl/hqn5+ZHIvEvzEIRFeJJBUQnvCPzb+Rdd/IHnVCg43GXzSBVER61y2oa+Kc2T/8UX9uI36awSeOPglunCnL3PaNi5O7gttMvulM+bEuhHUTXvzGWxJaOdt0HULJsThnHqCF097Z923Vq5USkNPspjmKaYLNlZUFwHEltP+dqs2EVCOLWI1UgNECF4DvMuhYEOpmI/dlzW8k/lAi4TiPNhiu9uJieEYIqtXteyzqX+4eHXk/VdnQvGHI9kJj3FVNS+b3vgeTqkqS4GcbjJ9KP1tnhGHY2l/dcGSTYpX35529tNSwSsfuyQagIrgvTmX9gywpXuNS4HwDK6G5bOQmAqEEr08B0WxI8L3VblfzmZ894hH6JVFTqgu7K5lHMk+PmSYAkISOeQwpMmtvGs71UlXzNtMWn+9TKELH+0g/S5ERed1gXztqjkKGgN3UGIfJMUn5NR7PIALCUcN6LCU6OJ4Hb8RUW6ZGMGFTECOkC/jfYrcMZusGNzo8bHNPt6+A7ASPjlnURKG9n6gxwqhDjIXbwMTDD/f2Edn1DFEevkidaFMk7tMnjCdG6C7VIM2iwvae2vyz6soTiUJHZhRIKx9K55uOa24qaaleTO/JyxaS/GDNEl1wE90kNc2f96aA5eVcy84w70RWy9r6pWow6u/dX0KCkvH6b0KoYkmZn2Yo4uVIubj5kTTKvwXPKudZUW3bycctefeEAKuYVvkPFuZq6uDvi8yk4FawXNupP8sgDljAL","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Glutten free Non veg","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":500,"Currency":"INR","Code":"GFNV","Price":500,"cost":500,"Description":"Glutten free Non veg","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"DBNV","SSR_Key":"xSQlYx4unCKBvYKdF+L7fT2T/8RTeYAlq1SwDNvEOUTjrQxKYYaBNtneBN7FA2Tu1JLs10Z0+Xfym6EziRf+EcCBr14Q0dQ+PkGobQSd3oDaeHjv7Xzcr5LMbVzbYkNNR39+M/+rFYuz61v9CQxH38673wns6lJvLFoFaV0WjYeKT46S4PrL4HPgEnSpN7aZP86A1UjkclkLlFMzVK6D7N6H64+djxn+jiQ5XgqpAcHkHDvtygcM2tisBfFyMr5ZiNq6rKyRvqxSzEKtMaVNpD3Haxn8jvmgEjaIrWhGdOpB8OsyuQS5eZyn8D4bSGA946PLJ7OAko6lChu+NDfDzmw0fyG9JvZv2cHN4rlFVJfvmjgVDzn7tjsDmovc3/OzcPU8Z3GA59xtkvNuCNfaPKo0+PZeMq/xeBU0fB7D+pj1pKWIgdjEL/yQCNSmoq0PlFNtdLRGFN+aCCwa1k4nG1/gyxU6wfScZEQgB9FAv3Mj6vKEJJg/ezPTg0rCixL9hZrXliVsjwW4545+Vyk2URjhgBPEo4vunUukfq72I00AxFUujc+DE6zjJq/qZFODhjjOQfFM5XCyFPtPQg+r0Ge77C62v+4vRMNuxul6hvau8SwnqBodJNpRulI8lKuy7M5eI0Yk7gi3EanORuYMEz6Qd6OXV5R4n/E9xNLHFOpt9QIYPrLRsrCzZAed/ZnZ6p3Co7MPdG5ErHaewtksfY3r2HRDKefMeNkfHyXtXiecVfCoyt6GTMLVjgc3KgNy","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Diabetic Non  Veg","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":500,"Currency":"INR","Code":"DBNV","Price":500,"cost":500,"Description":"Diabetic Non  Veg","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"CJSW","SSR_Key":"9L/2SiBYcBk2VB2LAtX0lHenmdtEdvOUbppuXQJdqiat9JHYY0oPxXjfvk/X1fqKi10NkwqdAqlD82rDE15aB2aBS06Y/nRzxKtO89h756RtUj9iJ8WN1+YmC73KqsT03ZzeUOQX9piQMBycZeYo1J5iB+4REmmkvjUYzKtT5Bwp+98MMmeONpqX0Mn6MRRdfDUgWmtJVJg8RGx2WTMCl8cSczAXzd1Y7lNQsUSh5YJm5RIS/88Lm/ebuvFkNYGqFmeY98mdc68GECZ0kO8cgayNoSl8EdTMy57y2rACYvLFP0mmlcCUTlEVyfBwZsaD1KgoDaU1FrgBromg1RadQoFqpFSOCLi5Y5U+tDzorU1N0wbsABin6/OGu+vpFuHWMTb35N0LS0hOU+K1RDVGAiYHCnSYJlbBr7IyA0LVD/p4wOrSVayVXvmjNgl/9ujA4usgtDfWRdfXtm4ZOEOgWUNoZsJg+nKkLifvRfQuAZKNKXDUIEY9fVjNxsmSDZbl0a2C9QZG+S4tG9OwTKhDjQcb+Texse5VKWFsliDujFXehG3uo0v+utLlmBR5nJpJtY35KSMlyjQkBH7Os7sdpaWg1f1abhZlVc/X849cvpfq9RmMlxZv/MmvBd9uwEeNAZYav4iGpX5DEwm3klsDx5k2KATvfxTdj79ChNU+4wbFA2flWG/OWc6PMEfgd6K/wuj9xI4jwvMN9HKVdTFywnh9ZTHn9wFtbc/E/VVBtdozwamCKywzGQDZw9VsvrR1vLoM0Qr9tZJ5v13SxbNzyw==","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Chicken Junglee Sandwich + beverage","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":500,"Currency":"INR","Code":"CJSW","Price":500,"cost":500,"Description":"Chicken Junglee Sandwich + beverage","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"CHVM","SSR_Key":"YWUemoB/fBvnYaFothIVUP7+5Rsnjxa8LrrgSSnk8ieHSTkQvPQmZMvDd7mK67JLR2AN3js3Wgun/5L2aqBOCPqm1QxsjNUNVAsYgV8TptQ4vvJTNzND/SH+5Sa0ZOUkQrB7dUEARWj4QE+Ds48hFFiJiRO6kFzg7xdzsoqRZuc3uS+6LmyRlcd8eAiyr3bx83nF8K/D6hjJ7TGquMNh7hJGQ0lNJspcuB6O2lqxGEUbeB/2zQT2oHz/R5/4rp2QqowoT9mfkQYN87G6lw/V+ZQAw2+HHBp9CmULnddXQe+nyFoUA922uJ/L303obKacDoaNYmEFgPuTC0aUc6+H6By84iu5XmKAKqShhlZ5m97+MuFn2jHYAwGRg0rcKbc2OnPXpafoyeBTYZrA+nQF95XTaRzv/XcZv+62+iIIXk3X+SiS2A6x9h8bcyrprlXKKNsDswenLRvZzvf1KWcTSiooeZu+cvFit5rAkhVA+/SScxEuRcNAxYFaVENIfayLiOR3QKPFUF7hu27Lcui3l+t18wQX3Ax3f7znDzvxsLtk44GKCs4fzEVVvr0B2QUJNhsZm7KfOjlvR7dQkTwwpKuF0tHKkan0QHRcyJZdrFiT//qDIxQIHqZ6WguZRHW/rP3n7IDFRC51HXHv7fciVnN/no5aG3opqB3XawmJb24s8Uh+eGlP/JHdsooze0Z2Nozzz0JSveBDxcg3RANWqdiWoq9FnfyEkRT28di9k5SheYRwX7TRaogTd7atgque","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Child meal  Veg","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":500,"Currency":"INR","Code":"CHVM","Price":500,"cost":500,"Description":"Child meal  Veg","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"CHNM","SSR_Key":"PIq4OwPFI6P3zCj6xFoN6FI7RhxXgWN1e/Zy3VwnbGnXH3Jb94Nw8yNuR0if/9ykyW/gpbtocteKXcP8enZF10BYO2LDRcbin1SLNLWD1kncQYdZFYHViG8uOK9TlwaZOtkVrUPOjghI7D6oKYu5sTC9jsghSd+FGTt+ZvzdPhTT/J4Zok+8eNXX0CTuf0gjK4kXiRW8oNQOH6bb1oXCWAEWSMqCWlo4GXP7+ZJ6lvIsCNEnfPGvBplJJe1h/yX5gK27Kadq8++6kTvau0cEIKMpeoM2QMwtPAtEZI1KOGCcTh1OwIu6j0aOczqqk81crxcPBz+gSMBHNFMbsCK1Unce9e+ZbJFgdPW31gw5qOBPqcQKHjL+0Bqo19u/Iu77GSU6bryyfz+UyyRIhEsKkOqHfK+QzOREtr9/g3uWLVlYuN2K5PN3Rj0fHLHpOdqApnf2M8YJgYqZWcSm1lqQy5l8W1iKnDuP4ZpGfsAhFFE/c17jPccZT/izp0+QnJ/ZBHGzw4eM8K4gGS/uIgYO8bl35ZhKjIeOvZjklR/23RdTpMsxIMxzWHCAPTr3XHheVlqna2cb0Ur99a+P+oUj7oyxxsSranvNU4HOE636Kho7cVr9zRknNIH5NDWOoYj9N30dOOZuld2qDUXHG6+3Qg54M/rySMdewb3aX0bpSHqjb0vC9F5Redbm4rqeMvjHUC4eHowOq/4lZ2qKWf6dL8Bqeb3RL+M0nozQFbL5NVQ=","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Child Meal Non Veg","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":500,"Currency":"INR","Code":"CHNM","Price":500,"cost":500,"Description":"Child Meal Non Veg","segmentid":1,"key":1},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"5714158298515041488","Leg_Index":0,"SSR_Code":"CPML","SSR_Key":"VwMi1LZrpDMJBHPjJD6Jxa9evuwW/q8FfAvj55T/TATQKVa9KoU0z42kUOYVcIZkii/14I3mNC4AErfh09NoImemuL2Nawrt9AyZZEMRc0romvxTzMZTjl9x6bo4CvCjVlZdKFRufzMTL4zb+uoIMkKgNXX0YYcJqcYnd+Le2Wcpz2fiaNFjoJ1l6bH/anq3dZlV1nXCfgLaQ01UhpFxoqCabHwXj97jE2JtHH2fGy5vrbiEAnddfc67BmKeCupkirnxMbqa5aaypnoby6XbOaqoKKVCl6cxVdfXm/po75e4Fe5v+TnSOR9iBe2uT7GiA2U13dj2ZyAVxh23EGrRVDUCu44o3bcmQbyklXQ/aDzjC0ayzeedeHHSCgyVLptxK1/gg3A0y+eJM5+qpGt06VVkqe4I++xhO3Evz54yi1IqsD2CrTyq0SCit3iUGMWiepYNDDdDcxN3ws28XiUMRSxVQz4q+HYNmo1nYnw1UVrJYFXXyA7XcrG6XFs/+c4gPEZfeq9GGhwZMdChkIQcQDyxQVoFb4kQXRJ81DcPBN6OfQ+ZJuOYE54/OFljrRfF9ehBhoAYHXAsJ90+3uZpk+bh+QYIVopZFXPzbi927qrtDxyOY5ec3AVuSHuRtWt9Gee7NTcQCBG1gCSGoGjOFGPX3uZEufvRlcGBhnZhapYtVEgBiIB0kMjWk1NMoSkbBvt6Y1tisYXNS96V8Io0ICq6VSiNNkD8fbnFGW3iZuI=","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Corporate Meal","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":650,"Currency":"INR","Code":"CPML","Price":650,"cost":650,"Description":"Corporate Meal","segmentid":1,"key":1}]}],"Ispassengercity":false,"Ispassengeraddress":false,"IsPassMandatory":false,"IsPassExpiry":false,"IsPassIssue":false,"IsPassDateOfBirth":false,"isAdobrMandatory":false,"isCdobrMandatory":true,"isIdobrMandatory":true,"isSeatApplicable":false,"isHoldAllowed":true,"IsSeatRequired":false,"IsMealRequired":false,"isSessionTime":"14:00","Baggage":[],"Meal":[]},{"ApiResultIndex":"4626401097524949696","Flight_Key":"KEYyILKt4yNzVBF2CGWqEdp40yFRCLRnydkfL1WmgiSC1fEtH+5Nz4pU3NO/zduQbNH7Ez4TAYnUsnusbNXZnlepQNSHDjtpd6FeamQaoaAjBMcPwcfF/kL4Ep+x6Kjszjd/db/3noqOR2P7ZWZIBP0QyzKC/oTvr23dIs48PeEapuuKrvvE++i5+LR2/anAmE4kiB5KQ649l4SbT38RIgQAhD+D6k18oPebjV0jCYmorSIne1/hOt8qR5isv6FuTKd9LLbA9YWZr8pQOOfEpLItlv9BXSstgT1vRki/Oo7DpxkWhu51qeWWbPdFcj8qfcuHgR80MGUuHMIUjLfG2TpeaRobMFUFzlujumnt3lT/uFT/AY6HzBEC2yxc4KzK207osx44/dfClm8WHACZVekfDAwc6Wxq7DUGV5YKx9wya3KIHSXolE6Gw5VohnE4dAf1ygr4nBILKJTuVunakNXBPMEn8XHOkm4RVvORDy7MPsJaa/eKZhFz9CkJRnxi/FBQkBbUzSm58q7kx1AAkaMzPkIf/vQfRcmAZtwvy7c9G+MSBYbowerppgjA+ufr0zNFgvhJn32vwoLqSPjqUqG4d3k86/vifKZZE3WOfzQ3xjcAxq4msuutzgo6XlIzCBnuw2HRoAl5AUtAHjUPFQmH1JqCCBJO/E/u4cgMDc7AkNIdMzm2Fnm4dq43CGtQvn+0LWvAsAehUuZtCrdO40xJyv5vG5t5x5eZlS3HJeNrM6zlKliBmXacJqp7gbD8xWUdwQq1Vpbac5zDt1iLxKItCTq0PigAEhveTwtSoX1QmY+NFF3tWJQ49e4QLwMR6jm1EoxeQNPiULKFXwZu7licvOcpl3xVr1OAgGEsQ17BPBqV/YSQJe0pOiE260dp7RjjK9puaMVT4FTAVkTGVAYPNHpB+8pQPdFhK8tueR53jukq2QezKUzmloLIq3BGmPqQ6N6mxcjmK6u6gHz3F3b/ytJppxtOGwriyeEaeFeW6KzvWjOx3mQ7C+6XPXwGrulakYZT10hjHI4fnfyc9wBilvsH0jhtPh2m0ctA5JiCt/5eHmaFaAZ8mZ7oU6rAA9zRx4uQ9/SDEawdU0V50mm/MEjWRX8fxtU7Zk7++T1FdtDRbnDryJ+i4LMQqx3+HGD0ih/UBlS8UtkJNoJMFpYuuGiAffxBE802FUIKRSHWBOXIKR5oPGfM1rS4Szbv92gdq34rL/RFVKaVQhS/kMHyqTW/z/sNsWoffcxu6nwf4fs+jkpDfPZ+EtiUAJmIRJOG3uxm+VrVFs3Dg+xjALOc0Bm2dEaGZQDaGsUzlqRMe9KFtUX0mB8nFuNSfqdesrPhGqTsYhaQk652+ay/P5TvYzpfOnypwWCd7aScQ7koiDHzqwpnZvep0r+8VCg3Zhs+zHebDGYul6nZiGQJV9VVbeji0XrDWfVSc624NfJbXfWNmPnrLKN+vfOa1EgpDWwxunu6CZT+YIa/iXAklLr2yNHRdzlIKBPqeEb3W7bjIBnHiIX0fPLobn9maHPBe3spTcM94NX0uqHsuFHYXbVHzRJJfr/h4kZHBRFyRrUz65sSCCMwXNfVOkI2zhCxcghwQ0Ngqg+InUtppUCR2igbWIdmNjBGVeLOHUfPBg8x2EEeekxYPDTjgvMrU5OoMJiLSpc5KOuCDeI9/Tn1nNw0XKuWe7X1I28zes9iVOBvQzTqCvXWMW4UN8W+BzxF6c/+I6otKSpPrRpo3PqhiSTMC5eiHv9Z+Id7jRJPFTiUEuq2+6PfvWzI+ZsbbFOflKRxkBrhKTPvK8b3FTb6kN3HJEGc99b7g1q+1n8Xcmr6YX6s/Xe7jSYOMEafI54Bv09cR4T45TIpbyaRMsLU3+pJDYHWYE+7wnlDhT0rT8CnDE1Jo58+1U2w9QDIGK9dljdGeptwj6U939E02NepLL7kMXFk/qcVYI+yDh1TCnSwUopBtSinpsNLG7yinpmdMwQfVXwHQ4cvpO8Cbk09HXrMc5WNIWcrZsYHFEhPlZ7DgM5fx1fSbDNki0b6rBSFkgpU23bs6+FcnYRlFOtjcz+DqMpHcyWvhgm/FStG2xx1pW+Y721xGU6fzGHJYHMUTVDanRWxrEOMYMfT/4vEm+jSg==","FlightNumber":"6E-6045","SegFlightNumberArr":"6E-6045","AirlineName":"Indigo","AirlineCode":"6E","IsLCC":true,"IsRefundable":true,"IsRefundableTxt":"Refundable","FromUTCTime":"2024-11-19 02:30","ToUTCTime":"2024-11-19 04:35","DepartureTime":"02:30","ArrivalTime":"04:35","FareClass":"Economy","SourceAirportCode":"BOM","DestAirportCode":"DEL","FlightDuration":"2h 5m","StopCount":"Non-stop","NoOfSeatAvailable":"4","JourneyType":2,"TripType":1,"ICSourceSysId":11,"IsInternational":0,"TotalFlightMembers":5,"SearchTraceId":"08e64-4a6be-95b8c-46ec3","logo":"http://local.gtxapi.com/public/AirlineLogo/6E.png","PublishedFare":27275,"isGSTMandatory":0,"FairRules":{"Currency":"INR","CurrencyRate":1,"currencySysId":1,"BaseFare":19078,"Tax":2257,"intPublishedFare":27275,"OfferedFareAgent":27275,"PublishedFare":27275,"CostToAgent":27275,"PublishedFareAgent":27275,"CostToAgentCustomer":27275,"PublishedFarePerPax":27275,"OfferedFare":21375,"CommissionEarned":0,"CommDiscount":0,"TDS":0,"TDSEarn":0,"Refundable":true,"IsRefundableTxt":"Refundable","PriceID":"R5422932566942023869","Fare_Key":null,"colors":"#000000","FareClass":"Economy","classOfBooking":"Q0IP","GSTMandatory":false,"fareIdentifier":"R","SeatAvailable":"4","FixedMarkUp":5000,"GSTOnMarkUp":900,"CommEarnedAgent":0,"IscheckinBagInc":true,"IscabinbagInc":true,"CheckinBaggage":"15 Kg","CabinBaggage":"7 Kg","IsMealIncludes":false,"FareBreakdown":[{"Currency":"INR","PassengerType":1,"PaxType":"ADULT","PassengerCount":"2","Net_Commission":0,"NetCommission":0,"BaseFare":8664,"Tax":1136,"OfferedFare":9800,"PublishedFare":12160,"CostToAgent":12160,"TDS":"0","TDSEarn":0,"TaxBR":{"MF":0,"YQ":0,"AGST":0,"MFT":0,"OT":1136,"YR":0},"ApiNCM":0,"CommissionEarned":0,"FixedMarkUp":2000,"GSTOnMarkUp":360,"intTotalGST":360,"CommDiscount":0,"AgentMarkUp":0,"CostToAgentCustomer":12160,"Baggage":"15 Kg","CabinBaggage":"7 Kg","markUpArr":{"Currency":"INR","currencySysId":1,"IntNetCommission":0,"IntCommissionValInPercentage":0,"CommEarned":0,"CommDiscount":0,"FixedMarkUp":2000,"GSTOnMarkUp":360,"PublishFare":12160,"CostToCustomer":12160,"CostToAgentCustomer":12160,"TotalEarning":2000,"CostToCompany":9800,"CostToAgent":9800,"AgentB2CEarning":0,"intOfferedFare":9800,"intPublishFare":9800,"APIMarkup":0,"AgentMarkUp":0,"TDS":"0","TDSEarn":0,"markup_b2b":0,"AddiMarkup":0,"AddiTaxOnMarkup":0}},{"Currency":"INR","PassengerType":2,"PaxType":"CHILD","PassengerCount":"2","Net_Commission":0,"NetCommission":0,"BaseFare":8664,"Tax":1136,"OfferedFare":9800,"PublishedFare":12160,"CostToAgent":12160,"TDS":"0","TDSEarn":0,"TaxBR":{"MF":0,"YQ":0,"AGST":0,"MFT":0,"OT":1136,"YR":0},"ApiNCM":0,"CommissionEarned":0,"FixedMarkUp":2000,"GSTOnMarkUp":360,"intTotalGST":360,"CommDiscount":0,"AgentMarkUp":0,"CostToAgentCustomer":12160,"Baggage":"15 Kg","CabinBaggage":"7 Kg","markUpArr":{"Currency":"INR","currencySysId":1,"IntNetCommission":0,"IntCommissionValInPercentage":0,"CommEarned":0,"CommDiscount":0,"FixedMarkUp":2000,"GSTOnMarkUp":360,"PublishFare":12160,"CostToCustomer":12160,"CostToAgentCustomer":12160,"TotalEarning":2000,"CostToCompany":9800,"CostToAgent":9800,"AgentB2CEarning":0,"intOfferedFare":9800,"intPublishFare":9800,"APIMarkup":0,"AgentMarkUp":0,"TDS":"0","TDSEarn":0,"markup_b2b":0,"AddiMarkup":0,"AddiTaxOnMarkup":0}},{"Currency":"INR","PassengerType":3,"PaxType":"INFANT","PassengerCount":"1","Net_Commission":0,"NetCommission":0,"BaseFare":1750,"Tax":25,"OfferedFare":1775,"PublishedFare":2955,"CostToAgent":2955,"TDS":"0","TDSEarn":0,"TaxBR":{"MF":0,"YQ":0,"AGST":0,"MFT":0,"OT":25,"YR":0},"ApiNCM":0,"CommissionEarned":0,"FixedMarkUp":1000,"GSTOnMarkUp":180,"intTotalGST":180,"CommDiscount":0,"AgentMarkUp":0,"CostToAgentCustomer":2955,"Baggage":"10","CabinBaggage":"10","markUpArr":{"Currency":"INR","currencySysId":1,"IntNetCommission":0,"IntCommissionValInPercentage":0,"CommEarned":0,"CommDiscount":0,"FixedMarkUp":1000,"GSTOnMarkUp":180,"PublishFare":2955,"CostToCustomer":2955,"CostToAgentCustomer":2955,"TotalEarning":1000,"CostToCompany":1775,"CostToAgent":1775,"AgentB2CEarning":0,"intOfferedFare":1775,"intPublishFare":1775,"APIMarkup":0,"AgentMarkUp":0,"TDS":"0","TDSEarn":0,"markup_b2b":0,"AddiMarkup":0,"AddiTaxOnMarkup":0}}],"tripbinfo":{"BOM-DEL":{"ADULT":{"cabin":"7 Kg","checkin":"15 Kg"},"CHILD":{"cabin":"7 Kg","checkin":"15 Kg"},"INFANT":{"cabin":"10","checkin":"10"}}}},"Segments":[{"segmentid":2,"segmentids":0,"isReturnSegment":true,"arrivingnextday":false,"originAirportName":false,"destinationAirportName":false,"originCityName":null,"originCountryName":null,"destinationCityName":null,"destinationCountryName":null,"destinationAirportCode":"DEL","destinationArrTime":"2024-11-19 04:35","SegFlightNumber":"6E-6045","AirlineCode":"6E","AirlineName":"IndiGo","FareClass":"","cabinClass":"Economy","originAirportCode":"BOM","originDepTime":"2024-11-19 02:30","TripIndicator":false,"IscheckinBagInc":false,"IscabinbagInc":false,"CheckinBaggage":"","CabinBaggage":"","IsMealIncludes":false,"Duration":125,"GroundTime":0,"NoOfSeatAvailable":"4","strDepartureDtTime":"02:30","strArrivalDtTime":"04:35","FlightDuration":"2h 5m","LAYOVERDuration":null,"LAYOVERCity":"","DepTerminal":"2","ArrTerminal":"1","filePath":"http://local.gtxapi.com/public/AirlineLogo/6E.png","Baggage":[{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"XBPE","SSR_Key":"6dESfDY3QDU+tMBDW/1EVD7FCKnSRPfBIUIJuPLd9hhSgGaXf/Lf5v07vVJS4KwsM43RKZCr3Ok7gvjH5KmdKYysdYM8gf8VOtIOph5fuw481SqmxsMPs5zLCOm3kgLPQOaDIH+rsU0C2vCNhoAtKulkIf5ojmfTy6UwQmxG6MjtpWofKgEIKghKvBHY86dShD7AkHUtLzHwYyla2ACIrmZ2OscbQ5r016AjOPhGCAcZRDck37PSbugerVHOn8iEKOiJ7gO0bdKe7mD74DPxM06CTsQIwiPydc+RtYKFB5v6OY+8BHGehjtZp4rIXQetKT6BIFb5u3EOcOXeeQDxw5m1fUpBAob203BLGlvFx4PPgo+5QjcnR7OYU9OBNA+aG4tlcuUzBhsgYBoFn+nIOBL188a9zN0pBN4ZHGIi8ZPdbvMc72PDh8ZtwVolfyo+VIoH3mCSPKiAEsHHrVv91wI2Zj14u/0yq4kwUVT6vQNfOsO9HPm4cy8gDyQASn62vr62ClvyV26L5krP66n1S68/O1jOfWx4JfOmKHDhrbIPDFICOeDqXviW7b04GRp4lgAqGFRXQaC+4Wzvp1n2Oq5H+AL36MSqFFxgb7C9lhEWR0vzU8mH2tx51hM7Q4iYPowSqQlgoeio9Mjbbz/uPVfoKlNrMC7oae5PdCepWERTmvRnysy4aBFoiRev3lJ9Pss6JRcbWZsJ7ufqnCx24gdgZYp6X5THNOVmEfuadT8cIziFXci/LEPnO6xhSuIWNEg+/3acS12BVgKU7GYYYw==","SSR_Status":0,"SSR_Type":0,"SSR_TypeDesc":"Prepaid Excess Baggage 3kg","SSR_TypeName":"BAGGAGE","Segment_Id":0,"Segment_Wise":false,"Total_Amount":1515,"Currency":"INR","Code":"XBPE","Price":1515,"cost":1515,"Weight":"Prepaid Excess Baggage 3kg","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"IXBA","SSR_Key":"hEKvFnFpjSS/2lfVk9ww/GAf5LdWDDXYy1fuB01NOEn7u/9vacUXGTsJLwQHX0ODbqHYNLshO0yZRblMiezWqNdsox7ahRECXdy8F+Z/gR51xu7Gsp2Yd/0eZm8t/JaOi/kv7UTwLxXr6DbCgzpOHJw4HkPLrJxI2M7ZGx/lLmXPcb+R583IaYuv9gQjjMnFZApN/jtPBdw4zso4tDa488Yv9WX0RZZy5pobxOdy78Gaz0nKbWCSJg5ytBdetcRcOZ3TDmPMSE5gZdr4jzK/R75N+/5TOWZJhACXnWd/cRqIzVy7KUMfbjEvq6zGN3oMfx1+bVRx0LKHibZl7AGkWcMU3XJ0AU/RvzX/fA4jHXzilTL1K2oO13w2vp6aY8ep9kBPy/ZPWWXkMOGSEJp3/2Ga35NwZqz96HPwQJnFWOUtotce6sTuntQswYogrn+HGVBq48umGw/hBz3XR06cKuDJrldV3p+Jz5srqXcIHXb4oDkJ18+8iNOo/J4RF49Pr9bVx3EfJuW2fTjGhsmxul3zBZyH4wXzlIAnSttpne3D63P4bHBJ2AV7C0RU/Ah1YBgAGMnr6zDlO3lQp8ANRwC94gHp94kSLtU+CjCQCaxMboJH5LYPxRektlhGymjjMwVz0s2dRN+9cj69s6GhwRTevoy7orfNwvpp/2E4MGSyoHknTCGYnRni+JO8X+AgUJiIIgQOSgPqMI9YB2lPRYW2eHg2q/Dq8FGwoZOJ4ikaeNRZKnVSc24mboagG3cY+JFzMBarMK1PLyQG8t8mAsU+G3nvftygny/p2cKABtM=","SSR_Status":0,"SSR_Type":0,"SSR_TypeDesc":"International Prepaid excess baggage 8kg","SSR_TypeName":"BAGGAGE","Segment_Id":0,"Segment_Wise":false,"Total_Amount":1600,"Currency":"INR","Code":"IXBA","Price":1600,"cost":1600,"Weight":"International Prepaid excess baggage 8kg","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"XBPA","SSR_Key":"0gd2ZKomJC1IH1PWp3IYhc3oFimhMhD5dlZ9QOmzadS8Gnl4OPl77IFg+9UulkPf90FRJwNNizBnrKSkAUJ33MwsYX4ZJvQz0YGhnqtZxKbv/ZlSSr0L/rgkxTe3Lc9PO6OCacXiPkVdphCPexPlz2Vg/Lyx5yyG5Hq6XRYaybBCrcyut/tadW10+32GWk536PbXgNHqK34NP+7XledvHloFqAej/k1zHy5rASiFbF+VXQxRrQLvlLukZS33Yg/VYZD4MxyEGyqs0IO5whVLldlorggKEUrP6oc7NDd4rJYfMBN3sKvazlN21zZP1sNTKrbUgjfjtMRai2u9XYPqs4t98bDtC5lurUerVjxyqd3pMUldQy2d1fpdtScsC/GsDCMDWLD/ULurTmTLkP4Ubo+zLgKe35sUqG80a7pXWVTMXybROwknCKrIGsn8dYLF9sUnH0i838l7RQSeHqhPjANv+GQMukCj+mgKRGFaSLt/8jGmq8isyAI4Uq7TuGjzQlNNL3UJQxQseiJur1f/YrTYemM4n4+S371JWnljv1FCUSigS6teOTjSQ8RueVdURsIqc/xteTMYwRWd0goGV/wRy6AwJrgT5xGkT2MWiBJGHIjlt1WzIy78kDPlhoB99qFKVg5OHV7C05vgMjzDDxO2N9FwStuiInmpKG4P+tPt96t7n5Z2mYuIkFa2V6lepsPaSCpsxFXaiIgfxbwds0GhEjIbeNlqExhJDFMKzI4LpDoNc72QZ27ea0y61tpFbNu96CzHrQXtRbHYvv6NGw==","SSR_Status":0,"SSR_Type":0,"SSR_TypeDesc":"Prepaid Excess Baggage 5kg","SSR_TypeName":"BAGGAGE","Segment_Id":0,"Segment_Wise":false,"Total_Amount":2525,"Currency":"INR","Code":"XBPA","Price":2525,"cost":2525,"Weight":"Prepaid Excess Baggage 5kg","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"IXBB","SSR_Key":"1VVHVxBtVNtEYyqhjNnEmPbOC1C7Sjs5jLdcAE6KQgMntoV5gS2bRbCg0U96wK9ALiqFtCtQwZWDVctIKWsU7huytNw+i7SvBG7j9RXmGJGVUzQgHfvK5MGrSNHoWPpO8MbiZfQisjFG7U4VlJYE9fCywNQeaAxYMkoDRZdQ6b65ICUtdRhv8fx7f7Vbfn+ijmLONvZ8mE2ff/WiqwrotfrTJCT10ZnOHn2y3zZPGttDdktEim6K+b8mSqXTvPVisbSz3BkYZ+GdYly09Yws/yppfliEoCoMJHMz13VBCeQ8wcYuUaDcm7ID7i/k2gcGx2AA3jLMwQzpVEmADYOCGip+0EmrjohILipUXYPichQOBs0pLPHX6IlkSn6nyb/+MiUh54U6uKkk4Uh2ogbMQuj1PiHl2eL74EA7P2juxjJgQ8vxoDBTrt5AkczI3XVF0Eb1Y0mn2We0FxRczEqbHB7SV2JW7afh/7hkPdpWXn2EV+ZnBAcLXS9Wvhd2yx8JadopgX31A2bdZ7r2pWFbYlhJLWavKIM7Mh7A3YtZgOIW0zdwOu/ntParhmuYQSigqp2prhDpMD+KZvI+KSRd/8FBE1lfin/KbnXk5EjMZ4DOQLSJrZr9p36n1Pb6LpAf0fyyLn8gDO8cBWqFt0GN2XYbkvmfdTbsKFqeU1tTkrp8mHS01JRn/iXYJvAwCQPkiQbekP9gWY4kAnk+jwMXONpUuBjNb8HSBAkhP05p0aeDv5RcfgGJIxnACGRyYIZNKuqHDXQcGZnaPP+LDvgdd93FF5vQavGEcNmGbLJhfZI=","SSR_Status":0,"SSR_Type":0,"SSR_TypeDesc":"International Prepaid excess baggage 15kg","SSR_TypeName":"BAGGAGE","Segment_Id":0,"Segment_Wise":false,"Total_Amount":3000,"Currency":"INR","Code":"IXBB","Price":3000,"cost":3000,"Weight":"International Prepaid excess baggage 15kg","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"XBPB","SSR_Key":"oljfC88HGyuwMqQtQXXZU0Gzc2ktuYiFwQS/jJsGWbbK4UI6ooTUGa/z2UJeDHH3grkzGHPVHvRH+hX5NednAbpUcNpb2AUaRt1D4loSfW5ZAFbU73lTlij+v2jukVcUaUKL2sFXy50NNf8naUygLrySYivEnyQgy2wo2n26PmIy/QJMOMslc5LkVXUH4CqGX9RVqMAv39rU08o2ndYGNHKN3yYa5IekUN5F1gLLvPYuvIVin0t8S+kJiOqfMPYiArribyxGOgZRJ9/D1Lz69PH2NCtx1lPUR9LLcNNr1uRFE07l4WUE/DCleY8msaSTxnDKd43XOXUMUpbZ2+0P9lPRNXafsFq2G/rBI51EMtiEh0Oszodit3GPdis7HmXMGTHih2TCrsi/BnUKfX/RSfBAswjowPFWXF1Ri+ih61uw4R2jfEKhp1rGRRcjHPqkBdNTG85DWw0jjrzn/TaRVBnAUqAAqeMV23ibDFl/0equ4uT6F6RpNgobDz15YQV5CPDrSRXZ+oM14Yvi3/Qlq+JQRPZagIoH1Pll+LfeVNCSCFgELmNIcgdqiQg/kmZb7jQwU7kwPQVdFakdl4GtY9S2ljjnccEQX265jubXfGLBoMqB+lXHB4gm+9Cwp/4Pnbr+IlezVmhnvK+ylYaYPnBi9PdbOgASG3om1tu4bix0LdT98pfPKGffvQurzAxKbSA97QQbuhgJqU64nJUp84KuaGbqMaSlBv8VQeFCKBHvOFQEJ+bBAA4Ev32hvixX891uSh4/cmVhi7uOUuKYYA==","SSR_Status":0,"SSR_Type":0,"SSR_TypeDesc":"Prepaid Excess Baggage 10kg","SSR_TypeName":"BAGGAGE","Segment_Id":0,"Segment_Wise":false,"Total_Amount":4950,"Currency":"INR","Code":"XBPB","Price":4950,"cost":4950,"Weight":"Prepaid Excess Baggage 10kg","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"IXBC","SSR_Key":"tXyIRAnW3sQQMZXf1j4qAO5Yq0YGc5WbeTr5pw5ExQjABlhT4tF6X5z+rGNEufO1UQQajgJvF8tVVVkDYULC7j2PMskNgjVxErZXNv+IO4T8plburKEeUvip8DK8gqVb/LiJwbpZX+xKhYD9QF5u9at1Vhcq0MqPLdb+C/vXUMUEE8KwOGaP3rV2glINh+Hised5KlZ/T/Zy8Ig2s/4cNL+xoQRzxGyJYMNtOrc8+hAUZUURmWp1+eQEWKwZiuQYevWdJVl5D1O9zVfrYRi+zdoTEhPesQHiW8wU+QiXnjZMCQqVJ+P2L44SR7TKWk7pUmtJ27i8EDbtW/vWBCRKu6a2ZPXDWuRZ3PW9kARuDdA2LCQpgQbQzXfWIecHedu4OCRkeZs86KsgqMwwljPinJonK9/qjT+Fb3/PZVDA76lD9RGpsOVaEmfMqogE6SINmzewoORG4nEdgX/dTiK6YdYQkM+wePeWxrNNQ0aR86PVD94xdqksBsbZ5NtVeaU+jyEhTIxeIWW33f2jbSaNR6qA64jH2fWfW6S6x/iikpH+2X9SWLywpmSSo5Z3qeGVB/vkWqKmyZPEAeWlXc/+MDNvTIwbaaa9ciRRLRGJAXybJWZ5lbE+hq+WFc7NtLZrjU2Pqd/rS6xmmJDRmV/sCuuC+KuxXNp7oEaDQzutAekHpU+LyttM4mkfzpmDXesaAZbILKj+JNeN38cTNUU/uideaDEflca2CbssK8rJZ5FbuVT4mo34En6NPo7RoDjEyuKYT6okJfa9gNdzZ+HQAf56R//hPnAsUWhwUMcODUE=","SSR_Status":0,"SSR_Type":0,"SSR_TypeDesc":"International Prepaid excess baggage 30kg","SSR_TypeName":"BAGGAGE","Segment_Id":0,"Segment_Wise":false,"Total_Amount":6000,"Currency":"INR","Code":"IXBC","Price":6000,"cost":6000,"Weight":"International Prepaid excess baggage 30kg","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"XBPC","SSR_Key":"0gd2ZKomJC1IH1PWp3IYhSzbccYW05sLQ3zawtmfOPsjaLN67b+N/WTHdA1lU41U9p/lcT6FzZEbHX1NKUrqgd5b6tHN+yICeAv+RYX4aBHZF/veCCfb5jm2fvHvVvSi/l7WoQw2CWcj7V+rpz2PrzvjtmWYNCLuD9p8ngG/WHme5Croc0Gc24Fus5+oWOFZ8Yz0/BmW5SZpYn5RgG+HDmHFke3cynjy/IVoAQDYVeXWPDLFQPnU30ikqnsDYuOulsz07qhcpJFgoIb28/twh2epVF083e4yfqUVGRU4F8abxQkRvjQjBIFEwyThY6XHLWeWuL6ykCfHHkkq9xjLmFOpwp5H9bby5didYzDbJ0m9MorACa+aI+M/G59MHSrFqz1dNF/JUst5z39Rp+R4J4sDXAHNZvCHRkfT3vVzXpewVRs01L6kZeWtkHoO/rrQ64bLxuDcdR0cjSCXx1Ne5mMAWsSz86c5cijC4EwneZKKMoQWfqBF6Wg52jJaV0j7UFBHclqt/LtNXrOb7BXzAV/EYeZElLRvGwxOl2q/nhZJVy0+yRow7FwQS06Md+NtdhKvvSgZd3RitNpThtgNXsrovQvXrwhljp3Lr+3PjwbYfcSzNbQYJyKuo0WTYDuKQi3KRq2KKkpMk90WGMreiN5DBjpLnBq7tDVgzODhiBuhtVC+GtuGBECLVrSSagtn0PYguu/ncfyzuf6YwRoZ/GSBFbQ6FgWDjon/xb0HwkEG1SKqOP+AoZucmAij2T9sBQGmFw0nytI3EFz2YgPUAA==","SSR_Status":0,"SSR_Type":0,"SSR_TypeDesc":"Prepaid Excess Baggage 15kg","SSR_TypeName":"BAGGAGE","Segment_Id":0,"Segment_Wise":false,"Total_Amount":7260,"Currency":"INR","Code":"XBPC","Price":7260,"cost":7260,"Weight":"Prepaid Excess Baggage 15kg","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"XBPJ","SSR_Key":"H34cg6twRW5dxI8xDuffS0LXpE9VXNZ4EP1sJKTFFSu2521DMci5zM9h8djB1ZHFsfkhu+u5/OpYTc7adTMkcRCbnJ3VAGqhcYpXQ91OHJzKtmMIXnLnvLxEaMDRL63VhllXy8PIHsNWY79V5nJTBRqR86xmh/2PfZBaTgvKc6pKD9GHQNvq/gSJSwvqL0XzFrQkQtjhTwEoZbfK6rkE+LEkpSBIMQgjtJbDg2EgKuHDLHWU4fBDFLQg0MyN+y8ePgkOjN7iPdt3CDjTK9AJ+40RUbfgb5dxjAJd4FaMxV4E9YP+F+H9IZBAyo9Ci6DhfR+i/IkqqRem2260BkjCNAMB7efOM/8E6oRrwAbUn22jaE0e0Pm0mF0LNfk/cTIIoiUyB9ZZ42JbJFtvyFYt9/DRoDVL5oKo9loeZAhDdXzyA9SNgBmUlJm+/laCLfijF2SoWk5y4SzK2U0xlZ9rnULNxMErXq3vtqeDDaJnseOA4lxpGnfntbdvr5rdmjboaDs3cttzFLz2jDEDR1w5ql0EvTJVA5Bf2cltpIKoouWzptya7ZmnoahsBwViqmehk7IXqmORAvLl4gBOBt+iVkFCGrNXrgBQLpp+Gt48Ksx5viy3Zn3HFW8U8rjFh832DOjKZn4LmjC0A1ImW+lVJn6jdraj2wZI5g2VzZk4AzoKHI6goEzZdSQbgG1FGBHkYPYYZz1lVRqHd+X9SmuCyXTM4vFfSXk9/Zz9VMy+g+DsaIlb2kFiWIfdzw6bkKUuT4DNhqsElv4SbqLBonIhDQ==","SSR_Status":0,"SSR_Type":0,"SSR_TypeDesc":"Prepaid Excess Baggage 20 Kg","SSR_TypeName":"BAGGAGE","Segment_Id":0,"Segment_Wise":false,"Total_Amount":9000,"Currency":"INR","Code":"XBPJ","Price":9000,"cost":9000,"Weight":"Prepaid Excess Baggage 20 Kg","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"XBPD","SSR_Key":"XSJB8qIikrRVLBkXxjOey4xIk/A5aipxcgAS0lncHSr3xMk9+fJ1K3kgVU5pEJiRYSP1gdMpy/Wj9z8GdbaLp0X2TqjfAmzWue3IH+Ys4qDdsveRwsjFr7JWsJUEjcwaLwr18C/dnuQkNnBmQe8cQnckXrNGmSY4GZ4I7OV7K82ol1tbpMDsNe5ha05TDE+/EDXT126ZAFTdvl6ncB3UcvQ/vn9WSdeFBQIwSz6Ae+EQlEvUk+ecdlgr1V7eQ12Bb6+oCP8FUCVH+I2bQ+995NCnDHCbbRWbJKdmLLHiA11tGsna8cvXlGdVxXpjV9Kl5FvewTXEZDVroH3FRfSds2cDLiS22mb7UF8lYTn2y9ZOk3GDIz/5OdCEa53Pd7RczHKl7gEwCPXgbx7PFzt6Xiy2gyZ5qEnbaMmOgZAPdoFA5c6EPPQPWvL3HTpqz654gdEmCl2UAXEjEmjVJ4FKy5FqT3jCeOC59B7adT1ChM5xFz0cF+7Xe2dsJew9CEUylTpGPvMUJDKLwc6BVJND5KD+0jhJMJ5HJW3rrrwYgC5CFrK1r4+tp5cyejv8cSA5o1cnxaCoCozqC2prwShAMaK/8HnwF2eEaZbbuhZP1N1+5t+LAHUCWI7rPuuRtpCApFSLu+HA4JKRdcAMYEBg9C+18qX7fCB1xYu9IZ73OnYzNW2ufecE44DEb8fE6+E1A98KKoY5ARU7cD7j5xvxoxB1T4B7xoM1t11pBJ9PCXFJMM4+s28gJ33NFtfGUiYHKAiGHHa94fBkApwCNULkJw==","SSR_Status":0,"SSR_Type":0,"SSR_TypeDesc":"Prepaid Excess Baggage 30kg","SSR_TypeName":"BAGGAGE","Segment_Id":0,"Segment_Wise":false,"Total_Amount":13500,"Currency":"INR","Code":"XBPD","Price":13500,"cost":13500,"Weight":"Prepaid Excess Baggage 30kg","segmentid":2,"key":2}],"MEAL":[{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"VLML","SSR_Key":"ANXExc5goBdNsvbOotb8qvMMlKUxrkrIyjeG2DnCc0HsFb0y/kCBdwQ2TABCwqpx+l4tXXqmLfFdSa7nU1LWXAdiesKZ1FkQ7ewm9x359MDZxa1lecGXMY1fY4vZEmMpv7tV1qGX04XxgXyQm74eOnZwwsNhruemGYZ7A9fjjIdTL0kGCWOPY24/KpSdNo9S6bo6TFtAVSWYhqWIQ16HDEGVXiR5NzWe6u+tZHoJM1h+dtZy/DBMe+pgGWEhXBLX9FxgDK38no5nTq9ow5Y0SEWOI85Q2XlY8HITr8C0fOl8nkND21tLLE4rgswi50g10YY3UUhS76SK46nHMpC7QJGBajtYtrK/7wnv5N1EFWZWx2RwUl/Al21/heCOLMjVq1NxJTBFd+EM6TVIcJnREjbRbg0yEBxlvlBXY43EQSswraYgovw+9Q2aiw2DXXRDqMq83PRjXLqC+sw+ZoLMVx0qaaKq7cCoLZtsMbONX/CKmEwijc33fCoWcANhKGqcuxH3i5JBeU7gTAehSJD4Gaq0vpshkkpclBqL+QJR8Nh1Q351ctouO2xschYs64QLjuxiKBMBf+XJHK2CMgrec64Q2kihoemD2np22rMhWNxLQS1UvUoqbE8zOllIrG2HcWqtMQeKovn+J9YfjjOI20XFi9CU1D3/heTs2yb/9LkXUX97PPjcXikDvxOiG35XqQIyEyYPGID1wNKWTjwX9DyRaPup3HOIagYzRBoSEOk=","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Veg Lactos","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":400,"Currency":"INR","Code":"VLML","Price":400,"cost":400,"Description":"Veg Lactos","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"VGML","SSR_Key":"m4oIcXBoX5c2U/O8xzynWvlRi2YmW6raxh3rJEiXsyLmW11fzUHCgXEfS6P4cvsclRv21m+7omNO6H8kPugKca/9VRHMkAS6MRSyJ1w9L2Ry3OMD14r2QNS8lVF5CHdH6GpCTp4Gh8RhrIQZBJXyUtfNCo0q+vl/jdaUrhCGWUI9knErco+9x0VJ+PStmTqEefmYReFMKhRYQsPoJnOJ3EiTUT/REluYeehoX6X6Mh4gKb4TQrHssLR0QdxWjeh3t1j8IaoPKwHeQ5fnV0il6sptvw0KkQpPkhI0Ik/dDYSSDGWMj1QA6SDibm3ZESkx+hnYOtzPYeZTZjHU+jCXxil/3S9p5SE274Ox7lenqhhOyTzwrPT1gEHJrOS/nj/DecXlRUGpIkOH7JrZJ7SpDch4BBKvztjECc5Q5ILfySz0MYjVMJ9/+QmJqWURTJqC4oN5uYZnkuxeb0spdRAApJDwBVVlFHno6mstpjHuTbvNtGqnX5mmRKiBL+0Xxg991AXuCKhBsak7x9YcfV7LEewksqGDCH/irwlar/HAc2wJYQ3qTLOdqWTAog9SRPScibWzt8ywP8ujeuxud+XlYn1NXusGkXUA8yzhVGTKO0mzOMOUd6VBeipYwBpIq1MlRoy4Q4AjXAjzxBQQq2obwJFw31pPMdWiwEWdykmbMzOtxKNEqk2AbQAq6VYkSWJYcg3rHcGgRXj2Rx2jvQakPzD63CvP9ybPQLJ/kvEl+Yg=","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Veg-Meal ","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":400,"Currency":"INR","Code":"VGML","Price":400,"cost":400,"Description":"Veg-Meal ","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"VGAN","SSR_Key":"oljfC88HGyuwMqQtQXXZU+zy4yxdAwwmmH1HeYfrySS+RgDmHiZUfrSHIJmBSmu7vqzq8NG3QbD06OQaajLQC76zdpwnKiLEWkZ51spwEJrEwsen6Rt1bc42vOzX2T0wLsBVZXH7b7pAG7LrqqWbziEu2TpJaMKw54//DU9seNaNyi16ymbJpMYOYDEylFGZo1wrAshx17vHsi/pX+UP0WiHBQYG7QZQJmnzG7MkLCptxh0Xtuobj5vcvkf78Qc7sTMB727nfmRH7b/1tZ5yBcoX1e8HeSSwVWWj/qtfNqtbRMuE7gh0uib/ruQH6JkODh31EVhWRWbYJOUPrzPMMejcXfeyHSgRUL4BzClyhWtYlaiky8UYEEkraDuVyoV122UOpcgK0SfUBCD3TddQFj0wlfdfPe+bUDxLj/Y2bE32e9i8W/td1keqZUF51RI9UziWkLp6W4WURGyU8f+3UGLlypZm8fmyy7SuiAmTfvZ4so23nmJnOic6FxVgzHeCvQ6LGRxu5xGnLw84qewRhgrzLJG4t20SCC94SVZV/4nu5mRXkzb3BnjExtU2/cfF+bcAntAs5iALHBFWfYBWNZ+cw6HCjTrVlMny+41SnJqW/FzFU/RKo5ZJIX1tbdaQEi9brXLMONiz6xdtnlHhZdiDfKg2/3lR2st/3jGHkssbltLi7S4s6WnPukRkRBBWE6Zl9W0ey3vl903LHEXMPEOHOT45PfeAMNVZKJwyWIAtegeMqIvK2U0K96cttnge","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Vegan Special + beverage","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":400,"Currency":"INR","Code":"VGAN","Price":400,"cost":400,"Description":"Vegan Special + beverage","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"VCSW","SSR_Key":"Q7KW/igCnX55MtcAwM/pdLwI9LNHaMLIKIpZNYEG3RvnSE+v7aTM35eWgnmBJjhOQxPoVM1lY+g7l3zNJTml4MRY190tu/Fo1dfztHBXCSTj+KuEd4JXdoueeaGClDQqDr73/5ar8WJXnkFH0IiNP3pmlGelxHfzqFSBPrxF3/SY/u14/DMpME5b3jB2vCCp5yCLd2L2NLfZUlgmEPLOJlqds+94EWKzPzFgIX6mprgAea3OoAo3oQOyXfYHA+a0BHOM3hpBSaO3jpo62Npb/rwlOnekYmikidcndComkza7tIfEHXFp4xz5DRRMRzIWUjAnSghNubax+932hZkSuLS+aEhwrrjcI+Gk9QoNBv3sKc9gkgULO09GOKPmSZ3ZQWTTC8vGQCcpg47ZQu0eZqMThJMGh/mkYwzhNhRNNKTuctDh+Owk2StUjgpdD22bnJEOKVqG//P6wUlm7HFUFSC7DBKvGBmT6tu07HJ3jpmPwgzCNRfzosYf3g2wUSbgqNs52Iwc/m4GatcIQqlhRKoM6eI7TJgQyNrFndnxxsXoxi+ecNg2atVcuD5aZvU07w6gKFq+eoKtDeBc3Ef0dnCP7ZHVwdB+k3NZLwWPqMI1RGDfEh0uVybrHxqRsEejHQkpKC+jhtt1BhULazzyenc7AG6oC+Gxc1vY48Vw/KL+iKrtbA/+WCrVDROcG2Trj0OBRvsHVpuv5nBPvfaJ43KH1DwBF8hJu6IT8GdhBEQ0QW9tlsfO2qnNYJvbuSRMYuJECZgitPmja1aEiey3dvT57YtCuhMaDWN8bLHLYz8=","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"6E Eats choice of the day (veg) + beverage","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":400,"Currency":"INR","Code":"VCSW","Price":400,"cost":400,"Description":"6E Eats choice of the day (veg) + beverage","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"TCSW","SSR_Key":"bvEsGWLt2HOUJtyWYB72JQplkmvWsBwbOUVDdChJsQmCqUyL8MhIYDIuNKz+14eJ1z/DQ+/do8FsgoPMesV/sZr6ipGTAHMN9tJihNMLOeRSPj+qclIjrVc/n5TABx4o7fM9IEbICP+CgpVjfWAkohiy/M5MPINa0sekqxIw+VGkYXgmRz3JONa/UyWpzQ1ToyvVHohwWdz8RI92l/kRxf2MMSHiN5BsQKIuRooJiM5mMhHQw/6PvZJbckEBw8yP2r1IG3rcNDF5U66/kHc0rRj08cPEmbcgZnNVVZgCWj9vHd/XACrTQMUAgAeZX4dbazM0mvQKW54xFwiJEk9+wOLhDsLqWqBCp29MATMk5vDs9juo8bVGJvCdJ3csc3inB559b/7dXjOV/E3x6s3Q0qGzQjt8TIp6ACt7RD47dKf5VMYh1iWA6b8qgATCwA6tKfznCC7rDWU2qyzfDB6LOZzErKTeqXwYa177EnYNV1N43Ktz2I5iDllqb2OToJ6FXw7T+XBNPz4lfbjD+fKHkmoUggjaopix/9S+jL2N3Js9Mt+1wuhHnDpnNKug2aSxiLi2hZndUwqMgB9BtdMz38xjT5Lv+roRgJAkxKWU2tAg80tAUn0cHVP/5kEgKItHj9/Qx4cPnYFTl2Gol1DHelNyfuKL+v4mIerF3pHzI+c8wgcU1T9fFUxq7GeDL53SPU3D+flkCQEBbD1SqoAvpGGVqQEXNhAgpeWKQrzF/gIMoslVBd9aZFXtGnOzk+aaugk8iYvH4JImW0HBghVjpA==","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Tomato Cucumber Cheese Lettuce Sandwich","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":400,"Currency":"INR","Code":"TCSW","Price":400,"cost":400,"Description":"Tomato Cucumber Cheese Lettuce Sandwich","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"LCVG","SSR_Key":"uJuPjlSIR7MPWUXQ4oUhfxH3NJL1DuenXPAnh7+Rg9dJuNFBasz5122AQPazist6HsXgerLwYkucx+TJZe4bF4yX7DjUbxGqNXvcG7ipPtcYkzUKd1g2cIiUZX6s/bVfLce9McObE75igoOplgSBAcSihlTrTOw69bH/+oIK3oWJz8zq26QcxHT2jSnJS6GEZ9nGzwTOnVeCWXCpur192u3diLXI//yfku+7vBzlgaz5hjb5Cln/jEtCHcgWIJmR9iDe3NsKeNo9L9lh23v1odKDZg7CFZkWwa2CzHA4hw7G2a82Lvaa/uMpeo1pbpQ1kTddSmi+O71VVmdT8vhj4DSNMr9lpDZ0H4uPdnDfV8PnImDejAHldK4r/JeEzzbV4Wpi3mQWHqFwtVdtvcXbwAQ37T0F8cuvXTTIwsf2iq0PI+5F3dZjipepTrXHla8MdfnBNMqovVKaS7E27rZljSk5u8J3YHXHWhNp2iWVfxUP6QlBJ9q0bacXpCKcpGy/OuKQSAuL2KpG4/eWcxSa1meb/vieWn/J8dghZJBXfmaozJgTWVHiqoAfAIo0s4RYafDELty6rEaclEn7R0XfX/K5mgOP1MgAqqVf43hzoxTCEcoZBBjHBnZEvqJxgTGBIxeBQKlWBqlFoyzbNCJG+JzaAyYA3wNnBrUOlOd2qJQ5SiZC3CJdcqoimenRWEStSdwxmnlFsWdQbFLDnc+b/uZMnQCTbK0uEiX5lx/bFtde2fPU4phk2xVc1Tv5Da1CG1eRjGiADev0BJrbws63nw==","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Low calorie veg Special + beverage","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":400,"Currency":"INR","Code":"LCVG","Price":400,"cost":400,"Description":"Low calorie veg Special + beverage","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"JNML","SSR_Key":"1wyz1ipMkzNlnYh0cVrhtYdIzBmo+2Os4w5MYHW9pAdyvp1mINWedjXQDx84D6mDCGX8yBAVmoFH/1p2+NLL2795yZC68bTd93qFsdENBeJwmCNmBMTGOkLigfTU+fCAew7ZGZZKgQ5hoozbj0X/IJZ8CqAaEmzY17ite+K85d3aOR1E6OHSOeWZkUjkxS/GuYpD7QZbyyCGRdGrlX+uS7YytgoifC/kV3oyYmJQtsDezOaTvwsiFVI8JS281ZqNcBfHAlHG4WtItIMTG7LnSVV4LZ+5QdWqXydRevBlc20bjmQALK4lioLguoaFsGUyIzxUStlmuoKnnNTH3jXyzbzCeooZvIlQAHugOSKVkoFGfvjL9v14HFNL0Bt4DfjRdhEltYVjzMuQijXrSdk8w4I/Ym0JsA0U+7sKAoXAuH4DoGdQ7VRezuky4a9PWMjtWsO+jv8F9SKmxZUi9W6o2Pg8CCV4wcKIYWJkbSA2W8fHFjfgnJuVYkZR6TJUaOPby21FsR4vehyzpu/oQR7DVcmsmBvjyqwfZtt48z09XAaVgyiZgPheV8q+K/ceV0AcjuWlALy0czIz3fYlGykgTXg81aREblHyZrx7+2PWrix/I+GSoyEF0NGXnzlu5WLL2rYJ/ZNODmRlvUP/MIxzYLOR5sWjtuRYQ6o3osJKrFLUoMaGAKYiuvST+8ekP2c4IYnaHDiVVOmDLZ3RWixHdRuID27Z786LB9nV/ijezc0=","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Jain meal","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":400,"Currency":"INR","Code":"JNML","Price":400,"cost":400,"Description":"Jain meal","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"DBVG","SSR_Key":"wgO1g54MK4DN7pvoEQKhb1vZ62jKWtiAcoxfnQWfGFzE1+Z+CXpe/kqE/ju2pWFBA9I90zL7YFGfJT3+ecCJhQIgFzpeiG7gQHTTgK9OTOsGlDmW01LF/2zPO7kZKOuGFSFdU08O6TjqeYm3InkDBfksydyaUY2EOwwKY/RTgU4+OEXEtJxE9/h/GcGwlJvKOuSjqUEGv+O1XPu3q6pNzJqtEylg19Nb2bInKfqSJgPigY68AweKW+LkeO8pRsAmHc15lKXN145ibHn5+DDMdzJo/erEEaygcw6SjSBWDlZynC/KpKMcFUh4Vf8jv8zuZEwyxPu81liGRT5ZVqNRdvzr2WwZj7APAA9JzO1bQ8Iwo2Zyly7ypbNQQes+IlLfrRyOblyhBIow4CloSujziaQ0KXGXPsv0FrwNwnErJ6TktBUCidkYH8dEoiq/6R0Uhn4sO6VqMZHa7lUB6eWMOx8QIMH1jBQh0W2ViwnttWtMC1KRSzIxvSdL+71hujAtBoXbE6ViSZ73kUXLFMHdGaEB9J0n0b2B3FUZ7PCwbeYpum9HD9FLvuW9aTZ+mjDQHyPCMGX+xM+HqMquRAXNa/4eb+/mW4nfzioLQVR+Nnio96Jzpw6cq3j3y9S/NtPZWuZOrkKBtJIoxLeGSxBXsl/SqjJZ4fAtzD0ikjmxc7KjhfeRyu0g9wonHnrC6bNfKlTQvYyZKD928MLWJDHuqJe+cNpUahXJV0fCssSTbfXRkof3DyqWl0kH6eg9zhV8woadcueKxn/IN0HN8dglPQ==","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Diabetic veg Special + beverage","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":400,"Currency":"INR","Code":"DBVG","Price":400,"cost":400,"Description":"Diabetic veg Special + beverage","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"AGSW","SSR_Key":"ZGJ+va7hFPXFkwYwn9CJEG8dSaQBmB8w3cUwcryDM5GZpR5uqcEMis/qCWimNvoAmGp2rTG9HD0dy41axCyQZcQqLbxOL4ndayFFLI6XzmfGndW6E18zU9gCnuS0abLh1YhswCpyHXOIqGHkJuhvfwmMtc5rwICOdjKesL4OACYRTBcUvUVRXwt7sVLNhFYHO3W1Fz+VTrx/uPI6J/WHmbkaxdtHs0mG8APlp2vXGITrIxVutYF+9mY5FR4kqcaCkmr1CL3+qbVgB0O034tBXdSPbOOTE74Vcjz3BIIylVamMcGDix3F6pEYNvm4E3tqR+AeY9e0m5tWrnnypxY81m1BW//aw8MD+VdT4iZgqWSa5M3xpIu+GhJox4OJAbfld5978g22ap7DqhcqjeK3ndVViz10qnMr08wVOyEK0SdLmxv8Mbq2BOo/Y8cCsBUeQO+Q4NnPEWyLAfc9ACpvXXgkH3Jl0bmEbtwzJELSB4XwCTtEw7HRguQJWTY9Y0YbVEetL22omGUKJlN/4j1DrSb+DfGxQ3abQbRBZ9Gd2tYzGMPEMlNpGomCT6W+pn8uq0usm7IG8WhDg+s4SAMWixYnL1p9bMM/GuQtE/YwLk82g33bYSTaSJds4qcs8BObVgV9CZEo/SDIPCsdKbpC6cRl94Z54xz6lTEpzEEF3n9RE0nsaPDvW6YadtosMY/H4e1kESj4sJ5go1+RrSDs+YV72WxX82Kxa86aFXV+B6npDe2dZpy++v3uXWGcqWpX+I0vkj37RQ7aoSMcfAx9cq1g4PJ/dDinzGnf+WYJAjXq7qEaF/wbIR09Ud2MCn9C","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"IndiaByIndigo regional favourite (veg) + beverage","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":400,"Currency":"INR","Code":"AGSW","Price":400,"cost":400,"Description":"IndiaByIndigo regional favourite (veg) + beverage","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"PTSW","SSR_Key":"37BZP/yQIe5X9wNzC1TWjZyCjskPjQKeu/5lzvyJE8QyUx5AIZI8gXsD4kcbLgsq46vwiT09ngnxXKxkDFZ7nf8x6+qW4cCAZ9YD+rqPqDaLZN0D84Q6zaOZeoLNQMoa5SiKYvyWBoJFSSvxdXtkTFyQsh9+FEAmRRDghYLRzHzHA1H1fgkndUoTAwsHBY1YRglmySo9jhF3jAlxEQt19YegNPxmgZkAjk+H00bIYzj3gyXGWKbdTz4GIzxlX9Ijquw9qA2kysUy7bEO1Q5riUZwCl+SNolp+EPfhcM1OFXb5I8g6FeU7BwbSpnJ6eQx2KxU+tb+a51J5hZyDg6L0QU2qhRrGUZdchF0XMcOp7SBZEXBDu0BGplbve4GqTTIwrfyVJNqw0epnCdtl+WJ7qFmmiMDmZddtOMsSZ/euD1khZYWHxhnyw5NKhkUrohRiNBB37ZhYqqYHa+REzEqB59wGIAOhars5xPpqeY/i0lZ/cav7wCkmzox4KUCSLA/Y5+STT7rwi2ePhglHsFTCyfXwoO2w9RrytA8zVs0i+vh1dII8uS1MHyJhLyxemvuYvmjk4qkQf85CLvpIZ5W5B42eOtDkaiXbVVwXvfUlRiBnK3SuzQIKMeljrl0+UTMbTCdVqj5RGRwWNuY8EM5lPdkbhtpEEFq33HxfITKQJaLZlfXwyTzu8DJhFmYMpGVp8/dPdLrs5khWUeeM4RJuYHL4N616Y4QPBUVysoJdor0Ct/SBjWP4iH9DUdsYxCc","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Paneer Tikka Sandwich ","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":500,"Currency":"INR","Code":"PTSW","Price":500,"cost":500,"Description":"Paneer Tikka Sandwich ","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"NUSW","SSR_Key":"vY2rRRhAAlYbRvnWrXX4KIQK7NM9kVUIrqV4+CNC5wGKh2yOOE+4ys73TUygocfocF1rBGUJfBAoiy0+ojDu1xMW4PG7iT9DN/qTmh/RC7HkEE49KCae2FqUWXJYyPxNdkr9We1wcYBUHd9KSyH/c0RwI0QTzNKrQ/mW3kE8MbjGnK4TU41tRgxD6KmFktLRA1MQUEEC53VWRrAr+mSwiK1jFogxusk8FD4wox0hMBYERNyiRkUw7BjkhTYninZ8fzAitI5yB0Wy6k2IVc+1C6KZe+yGRn19zvToSUCeuIx+yzAEmwQ9DMx4MUb93qSRCBBh1OG+Rk82TZuznQR9LK+R+KFPr+OvX4QsklfbV3hLm+BbD/EEkErQXXaq2xyrdqDKkA+XURLxpRfGpmy5ocExdpqZSImf3pmkc874lslyD1aSawyxTPFGOfIZWf2pU7dJJAOkcfR+XL2J4Jj//CapGtrBV5NBQRstbZN1FguLiC4e9Dfn1Zqn9eynTY891SOeTYWXjdhdassdE72XyCewfjg6dG+4CGDnC4NHYtEMNl1A1fximut2+4J7ryIrt567tmV14s4eoGfMEIcHea5JOV9HrKr6gtY2X3jTJQqfvHheNA+n0fwsdwZEpHgmJeZeLCdLtyIC2kjl1162tBElPOrg3/KWrjnU7KnEY2N9E0HzzmIPXGL7lzTtu3ab1gBx7e4451oYQzXqKTfEkV7EMMpKf9MbYTSjOgx20Ybs35BsAPviTmuthjXDyUsZQbmH9y04gkziF8vv2wtXy1xbEVMaDqd3ncbiFrCke3F8pHM36El5L/6GsP1jvoP+","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"6E Eats choice of the day (non-veg) + beverage","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":500,"Currency":"INR","Code":"NUSW","Price":500,"cost":500,"Description":"6E Eats choice of the day (non-veg) + beverage","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"GFNV","SSR_Key":"0vtE1AAY73/gPydIIu/eS/By0bVyyWv7f9Ge43lQIiUbVcd0x7xz12KfdBO3QWi+JGOI9APllkBwOwyscG2iEuktB3GwBxS438d0TGiqARQdWHklII1jH6YL+wFGcFpfF5fvhiDGPRPf8KKjFFqXEDvE5TN2LQhnktuK0mnemZbHCM/rhKsgIVCcQ1sfqo+7fEd3nNno2SHEMFZKhfRQnpvv8AEY/1RxMeFfCnj+8R8JkSv+ubFRUjlWfM3m0NnNCTvuB+HzGF6VZsiqA7dCByMweL1Yi4EwESWC6fkWT+BR/HvU+FWoepeaFJ95F3MFW0p0Jp1xXiL48LvjTIhTzpmJDaYzx6JsfmW8iR3YzoIcj1EQ4cO6Er6Xp0PR0P75IUBGHEhkytlKo+5NWjwg2VydxtIZ8GKxHTWEDPLo7h/Ixc8s02yq/9g/qtATVocPKBXP+jUnqJ18pk5EWRwXls2IOE36Tla3sQvUgqH7IjUasecc3tTCTgJtq6D8he2OpDbu5VAK/R/YMTXXHMVYgc8RyyCEVl/qUoOAiw++1TeWGpJGZzFR/YWUActvIE5vqFMpByCSZoDCny21e9kWf7/bi2Dsf1bYeide16vcCmiz6kuX7kbeGj+rbk6cGuPxhWtSHcUu/PLRe6S7hn9KhkIlNw0CKmiWHlz38wQrmVSkDzRXiSj11T1GZevmfPPtE6OIpz0kS9bTgcnh5wpVgDHsnwK/2BrKqode8cxADDWYnbY6Fk1s6LCyvGIJyun3","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Glutten free Non veg","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":500,"Currency":"INR","Code":"GFNV","Price":500,"cost":500,"Description":"Glutten free Non veg","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"DBNV","SSR_Key":"YWUemoB/fBvnYaFothIVUM72cQbbL72JAb+VBY8JUbk1JAwxE4N3h4CjGikZ8/g7R4WpDHzp1uypKCWGqPpn+FCIsXuVRTgkMGr00poYp3nd4SQTMbPnmdSqkIqPNJgAywHz5NrxlqmWaotxqyD+vSTr6Ez6aQ0/CVWGPmKGbzLYQOyNu8i/7LnC4TcfckVA8MdJjG7fN1YA6n7mU/Cd0LaGLiP5qvtkTBWaFdxBgQS72eWkWyJUQ2xi6zGPV4NG/xYbthBcH/yRg44S96i4D0hqJx7JFRcBrXQieDHzgDdKVZ0dIJ0f/gsp0DUIfnwXiEw0Hy+6gYZvYWnNxx5rG/LrmsJM9Imcsw6Wmlf8SSkyxo9IXDkV/8z4N4wT2PixqU19iVhD5iuHnty3G9RPWUr8az/4ZW8Xmv5SlH7nodJhPIgRd4uTuqghZtcYhC9ttFDzIrK84R4kzIJkmRq7G9EIKNk2eWiB1NsbkmwB0j0c0nW7RNy5RoCUmgIsjVXa7jlscnn+mtNaxWsIylrqZMvDQa2O0+2I10N/lSMh8UUcftWrsGSfZvJOcs8+D7n3evLt4KkT0MQkr+NkkE/1u9xQbDfMCYrv0VI7n4NMs9JE1yHV5BHZBmF7JOjVBvb3TflhYVs9PvGuYvTDlVm+87KPo0fLPdGr7dsA9/+R1cQdTfPnDOo+N9HH1r78R3ZDJuZ73yrEwW/bRxJ1hUsYdCIhHdqEv7VE0oQ/OaOiNrAPtIxXiYWbZ0IcawozXqds","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Diabetic Non  Veg","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":500,"Currency":"INR","Code":"DBNV","Price":500,"cost":500,"Description":"Diabetic Non  Veg","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"CJSW","SSR_Key":"17AiGVLO1aN13qLHHc0jdNDvaRkKGsBIIUVJ5Wkcnvt4m6BEtAdE3SrO1QtNHiNoAgbwBpJimUqtAbbPLFxZ4y0F5fS+kiSvtIu0eOBeqVFtmAi/hAYHOFsxaafEMr+DHorc1wvfvn+OxhcOT8OQbWjSlFpLA6rgjDNxeMupYM8EGxl3JGHrQ1Km9WCdZDgoXMDgGirOa+UmM7/K42DbugeajK1fseLnlZ1I8lH9mZnzWKDN2SIP70DqKhrKgAyFYvqr6+XYlsn5LcC5bgRxcINqRHhBeLpDtCIJMl1XdqnhiUPxOHZSf1a9J1rQlK8qc5pSOPdNcpJ1zpmT2sN02KKmTtjSf2a2b++8FFCJ+ZdqW4/zzInc+ZbjW/QY+0Lh2baavSWaH0uz8KjU295aMTDzg2h9UTaAxxI07yZcyUaH3gCyCFvADF8QB6hMI+X77u1S5ExUkg+HayhSPMsyrqd3S/5J2JrXgJubXd/xzUH1ke6R3Y0KcKG1eOgmQUJ3ezfhLmYqSVsLz0yYR7g7VtZ9azhOXLNzjyQ/GoUqYcEzHMjdG6Gy/C1WoLKBsJs959YI/0TrOr5FNmXqUZl8yDuTZEE5KlVbn7HcX4zNyY3s3bsiXzJyXSBAEXDm03fHABP0d+8dLOElmRnQ0R5RTdjhCIbbGLB8fYKk8ZzFinixZqaGknEYsr76dOg//DUQ6pkso68HUvQL/ifUktrNVm5jiUXUmmi9gOrsZzX6I+OG29lYsDx0SpIvMXoRCIhjcSz3KvXlKrBTm6WV15Xy+w==","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Chicken Junglee Sandwich + beverage","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":500,"Currency":"INR","Code":"CJSW","Price":500,"cost":500,"Description":"Chicken Junglee Sandwich + beverage","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"CHVM","SSR_Key":"YWUemoB/fBvnYaFothIVUDNkHm2yuN3897oQlcPpa1ozSJ6+RnWFTi7Ueb0bkhLBSAYN4a8vmTMn9dSmR+s2kHspSv22plIsQPTMHTS/1qYJ6PNCsUOJkBY7gJBtSw/HkZzHWEGDmE8OuP8TEXuzRm46WjW5yQXC7ofxkgRiU3yVsKjvKP/34rG/+SGLLbxlBBU5MtBH2UTFqXfo/U9Mk02kCcSa/US8qH8vPRXSmsPL8YkEKqSedAJ1sEWf+zkC3w3ZULpiEz3Ltf9QzsAf7IDpzIxqk9P5MfG55iq2txagtLpbnC8hpMVAFZ432GPBwiCWJkmFbU9qxbiIEMFD6sUm7kpLsNjOB3odtCAg3h5h3rQIjVVr95sjJUpoyw83Foc9AUJHF7796IAxtxzgNOOJxkCCzV3I4/AhLeaX50/RPa0bD/2HiuzbGI6/9VMBROOwJ/6O7rEZs4UjTJ44rVga0/1B0wNPtH15zDENa15LgOxY8+O+fTgZxI6Cm8CbW5iAQw6TdknpeGKu0Zw7zY+Gpk2Nc6IcTt97P4Ogc+C3EoUAAQtVklIW9LNO+mZWKHLM84ydIN6JDEFMjlHnkAlGCf9PUJ2OOiwG7qVGCbVmChH0QoO7thbVjy6mlPCy9GhbszVyPbQRmc3UgEuevVgzly+2NNK4Uh2BvV8DdEYJmo+62VlyPRMmDfZY8XeTkDiMDgNsW9ZpNNRgmr71/58eLMWUdKjGO14nrAvnzxnC/PQSkWdX+97FcbT14gLV","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Child meal  Veg","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":500,"Currency":"INR","Code":"CHVM","Price":500,"cost":500,"Description":"Child meal  Veg","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"CHNM","SSR_Key":"YWUemoB/fBvnYaFothIVUIBhtvkUnS4XZmrv3UCnezGtbHQHnELZ4zBSHGjV4b07cOzOTTsV8qRjrJuaTxcwGwiLCbU9pM7k4C0eGou45lvuqPwBEXaKer6GGcfHPc/BfV3045fXW/9HTI5SSxg2zfoWXl0SbpDiEQJsYvgfCXINbmyWMkAqyF5VWvl+fdgWNer9Hysy9O6SyD1GG3sV9MdmAqQlfUi0QLnCkj++ObuLCm5rVKiZjsewm3otTr1JlwUL/JouzNicBj6GAy7xYW5zGcNWy1Uhyoe8HRxwaoUE9R4Wgv9NjF6JgacUVBD5A6mYFZ0w2Dh8JKr2YGX5vTO2zJzUMEQSS2h0wEQtKnvCxfTtlXblqYJPawYoPGSqaHoofTLkT12fJi+QlGZz1JD+uKkSSW8ci8givmr8pShG3kzQsRjpigTbuvcHQUD0QHxzJKETiZQDr6d+r+bhdqmPX5qbmOizuaYFDYpcLurIOCC/CRWTT+lOROPWZzZHN5zz9znZ6tG2qdxAnvi1uWadkW4ghYPQfXZlsxknFjDY02cPJJTXBJS86X3O2Q1VeIHa+UDXBxhCmSvTYs47Kxv88e8L+Bqo5lMvgc963fClcjsdNKH1da+9WxiTEn/bPxLT2ZE2gJo8ysN0Kh6vpwjAKGEImZK+Jf7uKdyv5fFgEvx0L7csFrJVu0oxJbt1s19uO7SSh+cCbZQjzxF/rDssTqM1xgLxQG74rrzeGtvARw5Q7S8YCi7zp+PNuLAf","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Child Meal Non Veg","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":500,"Currency":"INR","Code":"CHNM","Price":500,"cost":500,"Description":"Child Meal Non Veg","segmentid":2,"key":2},{"ApplicablePaxTypes":[0,1],"Currency_Code":"INR","Flight_ID":"4626401097524949696","Leg_Index":1,"SSR_Code":"CPML","SSR_Key":"nM2LuOioE8d7xXyU7txePwVjQRD5KevMPxwOhum/tth+1O3cWt2EtppEzxnIB2Bt29FTuow+Uwn2ZXgz5y03m34JmExG4oqQWQsNFjTxU0SgLbJLe6TxTqALUippYA/EmW7gDm0bPy+uzeGj4J6Nl/1O+II6Zo2fdUHmiiCffghDyJisPCc0+ku6OPNFz75s3YxvZJUP2pdzzTo9XT/pRVbg9o6M366Z+lFpkDshPRCTRce1EO8hmzM8g0BerV9Rz7bMAkbBkLwbK8+G6QmQioLHQKdC3esn86wbLJxh/0x8f0wRqpBquSCN+Yal6KSZqNmjG1sXYb70VAvFzmss0TXC2BBMX1+XP5j9wWVrgUWZDkW6lV/ZCpOEbhqSVzA0xo5zXw8Mh8Go6igU8r0uwGH9avynDPc0UZNO4vFmk8IcEjk7ex2vip9qWXw7znSPUFpN4SQEd1qDxR8O2A7hUY1Bmf2LE0IXWqins7IGOusrP7ZP8c6kKBKCbik/wxbCu4qxnxUCFgQZ0l7FPMHHxqqrhKWS+0copXDrh13Z6vk05Nn/jx3FNmNE2RPzgPLjq1keHHYn2Zxz6+wdXhTdfnXs8zmJzIcnERCzTgRW2KJfJhhEXOk8t/qAKkIaKjNRXCdSbIgpeFJrqNE7Wp3BVWYdI0393o/fIeonw9zf1KjpPPLqRrsFG9gxKzeVOEp5Srv9ECufJF/bfgPTH2yC78eVp+dL85B4P/3+L/RE6+w=","SSR_Status":0,"SSR_Type":1,"SSR_TypeDesc":"Corporate Meal","SSR_TypeName":"MEALS","Segment_Id":0,"Segment_Wise":true,"Total_Amount":650,"Currency":"INR","Code":"CPML","Price":650,"cost":650,"Description":"Corporate Meal","segmentid":2,"key":2}]}],"Ispassengercity":false,"Ispassengeraddress":false,"IsPassMandatory":false,"IsPassExpiry":false,"IsPassIssue":false,"IsPassDateOfBirth":false,"isAdobrMandatory":false,"isCdobrMandatory":true,"isIdobrMandatory":true,"isSeatApplicable":false,"isHoldAllowed":true,"IsSeatRequired":false,"IsMealRequired":false,"isSessionTime":"14:00","Baggage":[],"Meal":[]}],"FareChange":null,"FARERULE":null,"SSRData":[],"tripSeatMap":[]}',1);

				// echo "apiResponse<pre>";print_r(json_encode($apiResponse));die;
				$ResponseStatus = $apiResponse['status'];
				$ErrorMessage = isset($apiResponse['message']) ? $apiResponse['message'] : '';
				if ($ResponseStatus == 1) {
					$FlightBookingData = isset($apiResponse['results']) ? $apiResponse['results'] : '';

					$PublishedFare = 0;
					$intPublishedFare = 0;
					$Baggage = [];
					$Meal = [];
					$SSRArr = [];
					$FlightBookingDataArr = [];

					if ($FlightBookingData) {
						foreach ($FlightBookingData as $keys=>$value) {
							$AirlineCode = $value['AirlineCode'];
							$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
							$FlightBookingDataArr[$keys] = $value;
							$FlightBookingDataArr[$keys]['Search_Key'] = $Search_Key;
							$FlightBookingDataArr[$keys]['AirlineSysId'] = $airlineSysId;
							$FlightBookingDataArr[$keys]['CurrencyType'] = $this->CurrencyId;
							$FlightBookingDataArr[$keys]['SourcePlaceSysId'] = $intSourceCityId;
							$FlightBookingDataArr[$keys]['DestPlaceSysId'] = $intDestinationCityId;
							$FlightBookingDataArr[$keys]['SearchFlightTraceId'] = $value['SearchTraceId'];
							$FlightBookingDataArr[$keys]['TravelDate'] = date('Y-m-d', strtotime($value['FromUTCTime']));
							$intPublishedFare += $value['FairRules']['PublishedFareAgent'];
							$PublishedFare += $value['FairRules']['PublishedFare'];
							$FlightBookingDataArr[$keys]['isDobAdult'] = $value['isAdobrMandatory'];
							$FlightBookingDataArr[$keys]['isDobChild'] = $value['isCdobrMandatory'];
							$FlightBookingDataArr[$keys]['isDobInfant'] = $value['isIdobrMandatory'];
							$Baggage[] = $value['Baggage'];
							$Meal[] = $value['Meal'];
						}
					}
					
					$arrUrlData['BookingData'] = $FlightBookingDataArr;
					$arrUrlData['FlightBookingData'] = $FlightBookingDataArr;
					$arrUrlData['SSRArr'] = $SSRArr;
					$arrUrlData['FarequoteData'] = $DataS;
					$arrUrlData['FareRuleRequest'] = [];
					$isHoldAllowed = isset($FlightBookingDataArr[0]['isHoldAllowed']) ? $FlightBookingDataArr[0]['isHoldAllowed'] : false;
					$tempData = array(
						'TraceId' => $SearchTraceId,
						'json_data' => json_encode($arrUrlData),
					);
					// echo "tempData<pre>";print_r($tempData);die;
					$objFlight = new Travel_Model_FlightMaster();

					$objFlight->deleteFlightTempData($SearchTraceId);
					$objFlight->insertFlightTempData($tempData);
					$FareChange = false;
					if($PublishedFareFareCheck != $PublishedFare){
						$FareChange = true;
					}
					$html = new Zend_View();
					$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
					$html->assign(array('apiResponse' => $FlightBookingDataArr, 'gtxagencysysid' => $this->gtxagencysysid, 'stylecss' => $this->stylecss, 'apiResponseInbound' => [], 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
					$bodyText = $html->render('getflightfarequote.phtml');
					$response = array('success' => true, 'message' => 'Done', 'FareChange' => $FareChange, 'html' => $bodyText, 'intPublishedFare' => number_format(ceil($intPublishedFare * $this->CurrencyRate)), 'SSRArr' => isset($SSRArr_) ? $SSRArr_ : [], 'SSRArrInb' => [], 'apiResponse' => $FlightBookingDataArr);
					echo json_encode($response);
					exit;
				} else {
					$response = array('success' => false, 'message' => 'Session is expired. Please try again with new session', 'FareChange' => false, 'html' => '');
					echo json_encode($response);
					exit;
				}

			} else {
				$response = array('success' => false, 'message' => 'Bad request', 'FareChange' => false, 'html' => '');
				echo json_encode($response);
				exit;
			}
		} else {
			die('Page not found!');
		}
	}

	public function continueAcceptAction()
	{
		if ($this->getRequest()->isPost()) {
			$response = array('success' => true, 'message' => 'Done');
			echo json_encode($response);
			exit;
			$FlightFareQuoteSession = new Zend_Session_Namespace('FlightFareQuoteSession');
			$FlightFareQuoteSessionInb = new Zend_Session_Namespace('FlightFareQuoteSessionInb');
			$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
			$FlightBookingDataInbound = new Zend_Session_Namespace('FlightBookingDataInbound');
			$BookingData = $FlightBookingData->params;
			$BookingDataInb = !empty($FlightBookingDataInbound->params) ? $FlightBookingDataInbound->params : [];
			//            echo '<pre>';print_r($FlightFareQuoteSession->params);
			//            echo '<pre>';print_r($FlightFareQuoteSessionInb->params);
			//            die;
			$arrCurrencyList = $this->getCurrencyIdsAndSymbolList();
			if ($FlightFareQuoteSession->params) {
				$apiResponse = $FlightFareQuoteSession->params;
				$result = $apiRData = $apiResponse['Response']['Results'];
				$Currency = $result['Fare']['Currency'];
				$currencySysId = !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
				$BaseFare = $result['Fare']['BaseFare'];
				$Tax = $result['Fare']['Tax'];

				$YQTax = $result['Fare']['YQTax'];
				$AdditionalTxnFeeOfrd = $result['Fare']['AdditionalTxnFeeOfrd'];
				$AdditionalTxnFeePub = $result['Fare']['AdditionalTxnFeePub'];
				$OtherCharges = $result['Fare']['OtherCharges'];
				$Discount = $result['Fare']['Discount'];
				$PublishedFare = $result['Fare']['PublishedFare'];
				$CommissionEarned = $result['Fare']['CommissionEarned'];
				$PLBEarned = $result['Fare']['PLBEarned'];
				$IncentiveEarned = $result['Fare']['IncentiveEarned'];
				$OfferedFare = $result['Fare']['OfferedFare'];
				$TdsOnCommission = $result['Fare']['TdsOnCommission'];
				$TdsOnPLB = $result['Fare']['TdsOnPLB'];
				$TdsOnIncentive = $result['Fare']['TdsOnIncentive'];
				$ServiceFee = $result['Fare']['ServiceFee'];
				$FareBreakdown = $result['FareBreakdown'];

				$arrFairRules = array(
					"Currency" => $Currency,
					"currencySysId" => $currencySysId,
					"BaseFare" => $BaseFare,
					"Tax" => $Tax,
					"YQTax" => $YQTax,
					"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
					"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
					"OtherCharges" => $OtherCharges,
					"Discount" => $Discount,
					"ServiceFee" => $ServiceFee,
					"PublishedFare" => $PublishedFare,
					"CommissionEarned" => $CommissionEarned,
					"PLBEarned" => $PLBEarned,
					"IncentiveEarned" => $IncentiveEarned,
					"OfferedFare" => $OfferedFare,
					"TdsOnCommission" => $TdsOnCommission,
					"TdsOnPLB" => $TdsOnPLB,
					"TdsOnIncentive" => $TdsOnIncentive,
					"FareBreakdown" => $FareBreakdown,
				);
				$BookingData['PublishedFare'] = $PublishedFare; // As Discussed with GG
				$BookingData['PublishedFareTxt'] = number_format($PublishedFare); // As Discussed with GG
				$BookingData['CommissionEarned'] = $CommissionEarned;
				$BookingData['FairRules'] = $arrFairRules;
				$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
				$FlightBookingData->params = $BookingData;

				if ($FlightFareQuoteSessionInb->params) {
					//for return
					$apiResponseInb = $FlightFareQuoteSessionInb->params;
					$resultInb = $apiResponseInb['Response']['Results'];
					$Currency = $resultInb['Fare']['Currency'];
					$currencySysId = !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
					$BaseFare = $resultInb['Fare']['BaseFare'];
					$Tax = $resultInb['Fare']['Tax'];

					$YQTax = $resultInb['Fare']['YQTax'];
					$AdditionalTxnFeeOfrd = $resultInb['Fare']['AdditionalTxnFeeOfrd'];
					$AdditionalTxnFeePub = $resultInb['Fare']['AdditionalTxnFeePub'];
					$OtherCharges = $resultInb['Fare']['OtherCharges'];
					$Discount = $resultInb['Fare']['Discount'];
					$PublishedFare = $resultInb['Fare']['PublishedFare'];
					$CommissionEarned = $resultInb['Fare']['CommissionEarned'];
					$PLBEarned = $resultInb['Fare']['PLBEarned'];
					$IncentiveEarned = $resultInb['Fare']['IncentiveEarned'];
					$OfferedFare = $resultInb['Fare']['OfferedFare'];
					$TdsOnCommission = $resultInb['Fare']['TdsOnCommission'];
					$TdsOnPLB = $resultInb['Fare']['TdsOnPLB'];
					$TdsOnIncentive = $resultInb['Fare']['TdsOnIncentive'];
					$ServiceFee = $resultInb['Fare']['ServiceFee'];
					$FareBreakdown = $resultInb['FareBreakdown'];

					$arrFairRulesInb = array(
						"Currency" => $Currency,
						"currencySysId" => $currencySysId,
						"BaseFare" => $BaseFare,
						"Tax" => $Tax,
						"YQTax" => $YQTax,
						"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
						"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
						"OtherCharges" => $OtherCharges,
						"Discount" => $Discount,
						"ServiceFee" => $ServiceFee,
						"PublishedFare" => $PublishedFare,
						"CommissionEarned" => $CommissionEarned,
						"PLBEarned" => $PLBEarned,
						"IncentiveEarned" => $IncentiveEarned,
						"OfferedFare" => $OfferedFare,
						"TdsOnCommission" => $TdsOnCommission,
						"TdsOnPLB" => $TdsOnPLB,
						"TdsOnIncentive" => $TdsOnIncentive,
						"FareBreakdown" => $FareBreakdown,
					);
					$BookingDataInb['PublishedFare'] = $PublishedFare; // As Discussed with GG
					$BookingDataInb['PublishedFareTxt'] = number_format($PublishedFare); // As Discussed with GG
					$BookingDataInb['CommissionEarned'] = $CommissionEarned;
					$BookingDataInb['FairRules'] = $arrFairRulesInb;
					$FlightBookingDataInbound = new Zend_Session_Namespace('FlightBookingDataInbound');
					$FlightBookingDataInbound->params = $BookingDataInb;
				}
				$response = array('success' => true, 'message' => 'Done');
				echo json_encode($response);
				exit;
			} else {
				$response = array('success' => false, 'message' => 'oops somehting went wrond');
				echo json_encode($response);
				exit;
			}
		}
	}
	public function validateFlight()
	{
		$validation = array(
			'OV'=> ['dob'=>true,'passport'=>false],
			'J9'=> ['dob'=>true,'passport'=>false],
			'OG'=> ['dob'=>false,'passport'=>false],
			'S9'=> ['dob'=>false,'passport'=>false],
			'3L'=> ['dob'=>false,'passport'=>false],
			'9I'=> ['dob'=>false,'passport'=>false],
			'I5'=> ['dob'=>true,'passport'=>false],
			'FD'=> ['dob'=>true,'passport'=>false],
			'D7'=> ['dob'=>true,'passport'=>false],
			'AK'=> ['dob'=>true,'passport'=>true],
			'2T'=> ['dob'=>false,'passport'=>false],
			'XJ'=> ['dob'=>true,'passport'=>false],
			'TR'=> ['dob'=>true,'passport'=>true],
			'TZ'=> ['dob'=>true,'passport'=>true],
			'QZ'=> ['dob'=>true,'passport'=>false],
			'XY'=> ['dob'=>true,'passport'=>true],
			'FZ'=> ['dob'=>true,'passport'=>true],
			'IX'=> ['dob'=>true,'passport'=>true],
			'G9'=> ['dob'=>false,'passport'=>false],
		);
		return $validation;
	}
	public function TBOPrice($flightjourneys, $AdditionalMarkup, $getMarkup, $sessionFlightSearchParams, $tripbinfoBreack, $tripbinfo, $MiniFR)
	{

		$interNationalSearch = $sessionFlightSearchParams['interNationalSearch'];
		$adultCount = $sessionFlightSearchParams['adults'];
		$ResultFareType__ = $sessionFlightSearchParams['FareTypes'];
		$childCount = $sessionFlightSearchParams['child'];
		$infantCount = $sessionFlightSearchParams['infant'];
		$SearchFlightTraceId = $sessionFlightSearchParams['SearchFlightTraceId'];
		$intMemberCount = $adultCount + $childCount + $infantCount;
		$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
		$strFlightRoute = $JourneyType = trim($sessionFlightSearchParams['route']);
		$ConvertionRate = $this->CurrencyRate;
		$Source = $flightjourneys['Source'];
            $IsLCC = isset($flightjourneys['IsLCC']) ? $flightjourneys['IsLCC'] : false;
            $strTraceId = !empty($response['Response']['TraceId']) ? $response['Response']['TraceId'] : '';
            $IsRefundable = ($flightjourneys['IsRefundable']) ? 1 : 0;
            if ($IsRefundable == 0) {
                $Refundable = 'Non Refundable';
            } elseif ($IsRefundable == 1) {
                $Refundable = 'Refundable';
            } else {
                $Refundable = 'Partial Refundable';
            }
            $AirlineRemark = $flightjourneys['AirlineRemark'];

            $LastTicketDate = $flightjourneys['LastTicketDate'];
            $TicketAdvisory = $flightjourneys['TicketAdvisory'];
            $AirlineCode = $flightjourneys['AirlineCode'];
            $ValidatingAirline = $flightjourneys['ValidatingAirline'];

            $Currency = $flightjourneys['Fare']['Currency'];
            $currencySysId = $this->CurrencyId;
            $BaseFare = $flightjourneys['Fare']['BaseFare'];
            $Tax = $flightjourneys['Fare']['Tax'];

            $YQTax = $flightjourneys['Fare']['YQTax'];
            $AdditionalTxnFeeOfrd = $flightjourneys['Fare']['AdditionalTxnFeeOfrd'];
            $AdditionalTxnFeePub = $flightjourneys['Fare']['AdditionalTxnFeePub'];
			$TransactionFee = isset($flightjourneys['Fare']['TransactionFee'])?$flightjourneys['Fare']['TransactionFee']:0;
            $OtherCharges = $flightjourneys['Fare']['OtherCharges'] + $TransactionFee;
            $Discount = $flightjourneys['Fare']['Discount'];
            $PublishedFare = $flightjourneys['Fare']['PublishedFare'];
            $CommissionEarned = $flightjourneys['Fare']['CommissionEarned'];
            $PLBEarned = $flightjourneys['Fare']['PLBEarned'];
            $IncentiveEarned = $flightjourneys['Fare']['IncentiveEarned'];
            $OfferedFare = $flightjourneys['Fare']['OfferedFare'];
            $TdsOnCommission = $flightjourneys['Fare']['TdsOnCommission'];
            $TdsOnPLB = $flightjourneys['Fare']['TdsOnPLB'];
            $TdsOnIncentive = $flightjourneys['Fare']['TdsOnIncentive'];
            $ServiceFee = $flightjourneys['Fare']['ServiceFee'];
            $ResultFareType = $flightjourneys['ResultFareType'];
            $FareBreakdown = $flightjourneys['FareBreakdown'];
            $totalCommissions = $flightjourneys['Fare']['CommissionEarned'] + $flightjourneys['Fare']['PLBEarned'] + $flightjourneys['Fare']['IncentiveEarned'];
            $totalCommissionsOnTds = $flightjourneys['Fare']['TdsOnCommission'] + $flightjourneys['Fare']['TdsOnIncentive'] + $flightjourneys['Fare']['TdsOnPLB'];
            $TotalPassengerCountForDiscount = $adultCount + $childCount;
            $MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'])?$AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']:0;
            $AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2b'] + $MarkUpValue);

            $markUpArr = array(
                'AgentMarkUp' => 0,
                'getMarkup' => $getMarkup,
                'PublishedFare' => $PublishedFare,
                'OfferedFare' => $OfferedFare,
                'Commission' => $totalCommissions,
                'TDS' => $totalCommissionsOnTds,
                'MUFee' => $ServiceFee,
                'intMemberCount' => $intMemberCount,
                'intFlightRoute' => $JourneyType,
                'interNationalSearch' => $interNationalSearch,
                'AddMarkup' => $AddMarkup,
            );

            // $arrMarkUps = $this->calculateMarkup($markUpArr);
			$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupNewAPI($markUpArr,'farequote');
            // echo '<pre>';print_r(($arrMarkUps));echo '</pre>';
			$intPublishedFare = $arrMarkUps['PublishFare'];
            $PassengerType = [];
            foreach ($FareBreakdown as $pk => $pax) {
                if($pax['PassengerType'] != 3){
                    $PassengerType[] = $pax['PassengerType'];
                }
            }
            if($interNationalSearch == 1 && $JourneyType == 2){
                $divideTripBy = 1;//(int)$JourneyType;
            }else{
                $divideTripBy = 1;
            }

            $countBreakUp = count($FareBreakdown);
            $countBreakUpOther = count($PassengerType);
			$NetFareBR = ($OfferedFare / $countBreakUp / $divideTripBy);
            $OtherChargesBR = ($OtherCharges / $countBreakUp / $divideTripBy);
            $YQTaxBR = 0;//($YQTax / $countBreakUp);
            // $NetFareBR = ($OfferedFare / $countBreakUp / $divideTripBy);
            // $OtherChargesBR = ($OtherCharges / $countBreakUp / $divideTripBy);

            if($interNationalSearch == 1 && $JourneyType == 2){
                $breackFareCount = $JourneyType;
            }else{
                $breackFareCount = 1;
            }
			// echo '<pre>';print_r($flightjourneys['Fare']);
            $tripbinfoBreack = array_values($tripbinfoBreack);

            foreach ($FareBreakdown as $pk => $pax) {
                $Breackbagg = isset($tripbinfoBreack[0][$pax['PassengerType']]) ? $tripbinfoBreack[0][$pax['PassengerType']] : '';
                $intPassengerCount = isset($pax['PassengerCount']) ? $pax['PassengerCount'] : 0;

                if($pax['PassengerType'] == 1){
                    $PassengerTypeName = 'ADULT';
                }elseif($pax['PassengerType'] == 2){
                    $PassengerTypeName = 'CHILD';
                }else{
                    $PassengerTypeName = 'INFANT';
                }
                $arrFareBreakdown[$pk]['Currency'] = $arrMarkUps['Currency'];
                $arrFareBreakdown[$pk]['PassengerType'] = $pax['PassengerType'];
                $arrFareBreakdown[$pk]['PaxType'] = $PassengerTypeName;
                $arrFareBreakdown[$pk]['PassengerCount'] = $pax['PassengerCount'];
                $arrFareBreakdown[$pk]['intBaseFare'] =  ($pax['BaseFare']);
                $arrFareBreakdown[$pk]['intTax'] =  ($pax['Tax']);
                $arrFareBreakdown[$pk]['BaseFare'] =  round(($pax['BaseFare'] / $divideTripBy * $ConvertionRate),2);
				$YQTaxInt = round($pax['YQTax'] / $divideTripBy * $ConvertionRate,2);
                if($pax['PassengerType'] == 3){
                    $arrFareBreakdown[$pk]['Tax'] =  round((($pax['Tax'] + $OtherChargesBR + $pax['AdditionalTxnFeePub'] + $pax['AdditionalTxnFeeOfrd']) / $divideTripBy * $ConvertionRate),2);
                    $arrFareBreakdown[$pk]['TaxBR']['OT'] =  round((($pax['Tax'] + $OtherChargesBR + $pax['AdditionalTxnFeePub'] + $pax['AdditionalTxnFeeOfrd']) / $divideTripBy * $ConvertionRate),2);
                }else{
                    $arrFareBreakdown[$pk]['Tax'] =  round(((($pax['Tax'] + $OtherChargesBR + $pax['AdditionalTxnFeePub'] + $pax['AdditionalTxnFeeOfrd']) / $divideTripBy - ($totalCommissions / $countBreakUpOther)) * $ConvertionRate),2);
                    $arrFareBreakdown[$pk]['TaxBR']['OT'] =  round((((($pax['Tax'] - $YQTaxInt)+ $OtherChargesBR + $pax['AdditionalTxnFeePub'] + $pax['AdditionalTxnFeeOfrd']) / $divideTripBy - ($totalCommissions / $countBreakUpOther)) * $ConvertionRate),2);
                }

                $arrFareBreakdown[$pk]['OfferedFare'] =  round(($NetFareBR * $ConvertionRate),2);
                $arrFareBreakdown[$pk]['PublishedFare'] = round((($arrMarkUps['CostToCustomer'] / $countBreakUp / $divideTripBy) * $ConvertionRate),2);
                $arrFareBreakdown[$pk]['TDS'] = ($pax['PassengerType'] != 3)?round((($arrMarkUps['TDS'] / $countBreakUpOther / $divideTripBy) * $ConvertionRate),2):0;
                $arrFareBreakdown[$pk]['TDSEarn'] = ($pax['PassengerType'] != 3)?round((($arrMarkUps['TDSEarn'] / $countBreakUpOther / $divideTripBy) * $ConvertionRate),2):0;
                $arrFareBreakdown[$pk]['TaxBR']['MF'] = 0;
                $arrFareBreakdown[$pk]['TaxBR']['YQ'] = round($pax['YQTax'] / $divideTripBy * $ConvertionRate,2);
                $arrFareBreakdown[$pk]['TaxBR']['intYQ'] = ($pax['YQTax']);
                $arrFareBreakdown[$pk]['TaxBR']['AGST'] = 0;
                $arrFareBreakdown[$pk]['TaxBR']['MFT'] = 0;
                $arrFareBreakdown[$pk]['TaxBR']['AdditionalTxnFeeOfrd'] = $pax['AdditionalTxnFeeOfrd'];
                $arrFareBreakdown[$pk]['TaxBR']['AdditionalTxnFeePub'] = $pax['AdditionalTxnFeePub'];

                $arrFareBreakdown[$pk]['TaxBR']['YR'] = 0;
                $arrFareBreakdown[$pk]['ApiNCM'] = ($pax['PassengerType'] != 3)?round((($arrMarkUps['IntNetCommission'] / $countBreakUpOther) * $ConvertionRate),2):0;
                $arrFareBreakdown[$pk]['CommissionEarned'] = ($pax['PassengerType'] != 3)?round((($arrMarkUps['CommEarned'] / $countBreakUpOther) * $ConvertionRate),2):0;
                $arrFareBreakdown[$pk]['FixedMarkUp'] = round((($arrMarkUps['FixedMarkUp'] / $countBreakUp / $divideTripBy) * $ConvertionRate),2);
                $arrFareBreakdown[$pk]['GSTOnMarkUp'] = round((($arrMarkUps['GSTOnMarkUp'] / $countBreakUp / $divideTripBy) * $ConvertionRate),2);
                $arrFareBreakdown[$pk]['CommDiscount'] = round((($arrMarkUps['CommDiscount'] / $countBreakUp / $divideTripBy) * $ConvertionRate),2);

                $arrFareBreakdown[$pk]['AgentMarkUp'] = round((($arrMarkUps['AgentMarkUp'] / $countBreakUp / $divideTripBy) * $ConvertionRate),2);
                $arrFareBreakdown[$pk]['CostToAgentCustomer'] = round((($arrMarkUps['CostToAgentCustomer'] / $countBreakUp / $divideTripBy) * $ConvertionRate),2);

                $arrFareBreakdown[$pk]['Baggage'] = isset($Breackbagg['checkin'])?$Breackbagg['checkin']:''; //Check In Baggage;
                $arrFareBreakdown[$pk]['CabinBaggage'] = isset($Breackbagg['cabin'])?$Breackbagg['cabin']:''; //Cabin Baggage ;

                $PublishedFarePerPax += ((($arrMarkUps['CostToCustomer'] / $countBreakUp) * $ConvertionRate) / $intMemberCount);
            }

            $Breackbagg = isset($tripbinfoBreack[0][1]) ? $tripbinfoBreack[0][1] : '';
            $IsMealIncludes = false;
            $strBaggage = isset($Breackbagg['checkin'])?$Breackbagg['checkin']:''; ///Checking Baggage
            $strCabinBaggage =  isset($Breackbagg['cabin'])?$Breackbagg['cabin']:''; ////Cabin Baggage
            if (!empty($strCabinBaggage)) {
                $IscabinbagInc = true;
            } else {
                $IscabinbagInc = false;
            }
            if (!empty($strBaggage)) {
                $IscheckinBagInc = true;
            } else {
                $IscheckinBagInc = false;
            }
            $arrFairRules = array(
                "Currency" => $arrMarkUps['Currency'], //$Currency,
                "CurrencyRate" => $ConvertionRate, //$Currency,
                "currencySysId" => $arrMarkUps['currencySysId'],
                "BaseFare" => ($BaseFare / $divideTripBy) * $ConvertionRate,
                "Tax" => round(((($Tax + $OtherCharges + $AdditionalTxnFeeOfrd + $AdditionalTxnFeePub) - $totalCommissions) / $divideTripBy * $ConvertionRate),2),
                "intPublishedFare" => $PublishedFare,
                "PublishedFare" => round(($arrMarkUps['CostToCustomer'] / $divideTripBy * $ConvertionRate),2),
                "PublishedFareAgent" => round(($arrMarkUps['CostToCustomer'] / $divideTripBy * $ConvertionRate),2),
                "PublishedFarePerPax" => round((($arrMarkUps['CostToCustomer'] / $divideTripBy * $ConvertionRate) / $intMemberCount),2),
                "OfferedFare" => round($OfferedFare * $ConvertionRate,2),
                "CommissionEarned" => round($arrMarkUps['CommEarned'] / $divideTripBy * $ConvertionRate,2),
                "CommDiscount" => round($arrMarkUps['CommDiscount'] / $divideTripBy * $ConvertionRate2),
                "TDS" => round((float)$arrMarkUps['TDS'] / $divideTripBy * $ConvertionRate,2),
                "TDSEarn" => round($arrMarkUps['TDSEarn'] / $divideTripBy * $ConvertionRate,2),
                "Refundable" => $IsRefundable,
                "IsRefundableTxt" => $IsRefundable,
                "PriceID" => $ResultIndex,
                // "ApiResultIndex" => $ResultIndex,
                "classOfBooking" => '',
                "FareClass" => $cabinClass,
                "fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
                "IsSpecialReturn" => false,
                "colors" => $fareIdcolor,
                "FixedMarkUp" => round($arrMarkUps['FixedMarkUp'] / $divideTripBy * $ConvertionRate,2),
                "GSTOnMarkUp" => round($arrMarkUps['GSTOnMarkUp'] / $divideTripBy * $ConvertionRate,2),
                "IscheckinBagInc" => $IscheckinBagInc,
                "IscabinbagInc" => $IscabinbagInc,
                "CheckinBaggage" => $strBaggage,
                "CabinBaggage" => $strCabinBaggage,
                "IsMealIncludes" => $IsMealIncludes,
                "IsGSTRequired" => $result['IsGSTMandatory'],
                "FareBreakdown" => array_values($arrFareBreakdown),
                "tripbinfo" => $tripbinfo,
                "MiniFR" => $MiniFR,
            );
			
			return $arrFairRules;
	}
	public function UpdateFlightBookingDataTBO($apiResponse, $arrSSR, $vl)
	{
		// echo '<pre>';
		// print_r($arrSSR);die;
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$route = $sessionFlightSearchParams->params['route'];
		$interNationalSearch = $sessionFlightSearchParams->params['interNationalSearch'];
		$adultCount = $sessionFlightSearchParams->params['adults'];
		$ResultFareType__ = $sessionFlightSearchParams->params['FareTypes'];
		$childCount = $sessionFlightSearchParams->params['child'];
		$infantCount = $sessionFlightSearchParams->params['infant'];
		$SearchFlightTraceId = $sessionFlightSearchParams->params['SearchFlightTraceId'];
		$intMemberCount = $adultCount + $childCount + $infantCount;
		$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
		$strFlightRoute = trim($sessionFlightSearchParams->params['route']);

		$intSourceCityId = trim($sessionFlightSearchParams->params['sourceCityId']);
		$intDestinationCityId = trim($sessionFlightSearchParams->params['destinationCityId']);

		$strFlightRoute = trim($sessionFlightSearchParams->params['route']);
		$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';
		$flight_class = $FlightClasses[$sessionFlightSearchParams->params['flight_class']];
		$strDepatureDate = $sessionFlightSearchParams->params['departure_dates'];
		$strReturnDate = !empty($sessionFlightSearchParams->params['return_dates']) ? $sessionFlightSearchParams->params['return_dates'] : '';
		$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);
		$strSourceAirportCode = $sessionFlightSearchParams->params['from'];
		$strDestinationAirportCode = $sessionFlightSearchParams->params['to'];
		$adultCount = $sessionFlightSearchParams->params['adults'];
		$childCount = $sessionFlightSearchParams->params['child'];
		$infantCount = $sessionFlightSearchParams->params['infant'];
		$SearchFlightTraceId = $sessionFlightSearchParams->params['SearchFlightTraceId'];

		$intMemberCount = $adultCount + $childCount + $infantCount;

		$intSourceCityId = trim($sessionFlightSearchParams->params['sourceCityId']);
		$intDestinationCityId = trim($sessionFlightSearchParams->params['destinationCityId']);

		$arrDepatureDate = explode("/", $strDepatureDate);
		if (count($arrDepatureDate) > 0) {
			$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
		}

		if (!empty($strReturnDate)) {
			$arrReturnDepatureDate = explode("/", $strReturnDate);
			if (count($arrReturnDepatureDate) > 0) {
				$strReturnDate = $arrReturnDepatureDate[2] . "-" . $arrReturnDepatureDate[1] . "-" . $arrReturnDepatureDate[0];
			}
		}

		$localFromDateTime = date("Y-m-d h:i", strtotime($strDepatureDate));
		$localToDateTime = date("Y-m-d h:i", strtotime($strReturnDate));
		$arrCommonInsVariables = array(
			'strTraceId' => $strTraceId,
			'localFromDateTime' => $localFromDateTime,
			'localToDateTime' => $localToDateTime,
			'strSourceAirportCode' => $strSourceAirportCode,
			'strDestinationAirportCode' => $strDestinationAirportCode,
			'intMemberCount' => $intMemberCount,
			'intSourceCityId' => $intSourceCityId,
			'intDestinationCityId' => $intDestinationCityId,
			'JourneyType' => 2, // For Round Trips API Search
			'TripType' => 2,
			'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0,
		);
		//$getMarkup = $this->getMarkup($intCountryCode);
		$getMarkup = $this->getMarkupNew($intCountryCode, 1);
		if (empty($getMarkup['arrAgencyMarkups'])) {
			$getMarkup = $this->getMarkup($intCountryCode);
		}
		$TaxSettingDetail = $this->getTaxSettingDetail($getMarkup['TaxSetting'], 1);
		$getMarkup['TaxSettingDetail'] = $TaxSettingDetail;
		$MarketPlaceSysId = isset($getMarkup['arrAgencyMarkups'][0]['MarketPlaceSysId']) ? $getMarkup['arrAgencyMarkups'][0]['MarketPlaceSysId'] : 0;
		$MasterId = isset($getMarkup['arrAgencyMarkups'][0]['MasterId']) ? $getMarkup['arrAgencyMarkups'][0]['MasterId'] : 0;
		if(empty($MasterId) || $MasterId == 0){
			$MarketPlaceSysId = $MarketPlaceSysId;
		}else{
			$MarketPlaceSysId = $MasterId;
		}
		$SupplierType = 1;
		$getCancelCharge = $this->getCancelCharge($intCountryCode, $SupplierType);
		//$AdditionalMarkup = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAdditionalMarkup();
		$filterData = ['ApiSourceSysId' => 1];
		$AdditionalMarkup = $this->getMarketPlace($filterData, $MarketPlaceSysId);
		$IsLCC = $vl['IsLCC'];
		$FairRules = $vl['FairRules'];
		$Segments = $vl['Segments'];
		$ResponseStatus = $apiResponse['Response']['ResponseStatus'];
		if ($ResponseStatus == 1) {
			$FlightNumber = explode('-', $vl['FlightNumber']);
			$AirlineCode = $vl['AirlineCode'];
			if ($IsLCC) {
				$BaggageArr = isset($arrSSR['Response']['Baggage']) ? $arrSSR['Response']['Baggage'] : [];
				$MealDynamic = isset($arrSSR['Response']['MealDynamic']) ? $arrSSR['Response']['MealDynamic'] : [];
				$SeatDynamic = isset($arrSSR['Response']['SeatDynamic']) ? $arrSSR['Response']['SeatDynamic'] : [];

				if ($SeatDynamic) {
					foreach ($SeatDynamic as $stSeg) {
						$SegmentSeat = $stSeg['SegmentSeat'];
						if ($SegmentSeat) {
							foreach ($SegmentSeat as $KSG => $SG) {
								$RowSeats = $SG['RowSeats'];
								$segmentid = isset($Segments[$KSG]['segmentid']) ? $Segments[$KSG]['segmentid'] : '';

								$sInfo = [];
								$R = 1;
								if ($RowSeats) {
									foreach ($RowSeats as $RK => $RS) {
										$Seats = $RS['Seats'];
										$C = 1;
										if ($Seats) {
											foreach ($Seats as $SK => $ST) {
												$sInfo[] = array(
													'AirlineCode' => $ST['AirlineCode'],
													'FlightNumber' => $ST['FlightNumber'],
													'CraftType' => $ST['CraftType'],
													'Origin' => $ST['Origin'],
													'Destination' => $ST['Destination'],
													'AvailablityType' => $ST['AvailablityType'],
													'isBooked' => ($ST['AvailablityType'] == 3) ? true : false,
													'Description' => $ST['Description'],
													'Code' => $ST['Code'],
													'code' => $ST['Code'],
													'RowNo' => $ST['RowNo'],
													'SeatNo' => $ST['SeatNo'],
													'seatNo' => ($ST['Code'] == 'NoSeat') ? '' : $ST['Code'],
													'SeatType' => $ST['SeatType'],
													'SeatWayType' => $ST['SeatWayType'],
													'Compartment' => $ST['Compartment'],
													'Deck' => $ST['Deck'],
													'Currency' => $ST['Currency'],
													'Price' => $ST['Price'],
													'amount' => $ST['Price'],
													'Text' => $ST['Text'],
													'seatPosition' => ['row' => $R, 'column' => $C],
												);
												$C++;
											}
										}
										$R++;
									}
								}
								$tripSeatMapArr[$segmentid]['sData'] = array('row' => count($RowSeats), 'column' => 7);
								$tripSeatMapArr[$segmentid]['sInfo'] = $sInfo;
							}
						}
					}
				}
				$BaggageArr__ = [];
				if ($BaggageArr) {
					foreach ($BaggageArr as $k => $values) {
						foreach ($values as $kk => $val) {
							$BaggageArr__[$k][$kk] = $val;
							$BaggageArr__[$k][$kk]['amount'] = (isset($val['Price']) && !empty($val['Price'])) ? round($val['Price'] * $this->CurrencyRate, 2) : 0;
						}
					}
				}
				$MealDynamic__ = [];
				if ($MealDynamic) {
					foreach ($MealDynamic as $k => $values) {
						foreach ($values as $kk => $val) {
							$MealDynamic__[$k][$kk] = $val;
							$MealDynamic__[$k][$kk]['amount'] = (isset($val['Price']) && !empty($val['Price'])) ? round($val['Price'] * $this->CurrencyRate, 2) : 0;
						}
					}
				}
				$SSRArr = array('Meal' => $MealDynamic__, 'Baggage' => $BaggageArr__, 'SeatPreference' => $tripSeatMapArr);
			} else {
				$MealDynamic = isset($arrSSR['Response']['Meal']) ? [$arrSSR['Response']['Meal']] : [];
				$BaggageArr = isset($arrSSR['Response']['Baggage']) ? [$arrSSR['Response']['Baggage']] : [[['Code' => 'NoBaggage', 'Description' => '']]];
				$SeatPreference = isset($arrSSR['Response']['SeatPreference']) ? $arrSSR['Response']['SeatPreference'] : [];;
				$SSRArr = array('Meal' => $MealDynamic, 'Baggage' => $BaggageArr, 'SeatPreference' => $SeatPreference);
			}


			$arrCurrencyList = $this->getCurrencyIdsAndSymbolList();
			$result = $apiRData = $apiResponse['Response']['Results'];
			$AirlineRemark = $result['AirlineRemark'];

			// $fareIdentifier = $fareIdentifier__ = !empty($result['FareClassification']['Type']) ? str_replace('.', '_', strtoupper($result['FareClassification']['Type'])) : $result['ResultFareType'];
			$fareIdentifier = $fareIdentifier__ = !empty($result['FareClassification']['Type']) ? str_replace('.', '_', strtoupper($result['FareClassification']['Type'])) : strtoupper(trim($result['ResultFareType']));
			$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];

			$Currency = $result['Fare']['Currency'];
			$currencySysId = !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
			$BaseFare = $result['Fare']['BaseFare'];
			$isGSTMandatory = $result['IsGSTMandatory'];
			$IsPassportFullDetailRequiredAtBook = isset($result['IsPassportFullDetailRequiredAtBook']) ? $result['IsPassportFullDetailRequiredAtBook'] : false;

			if ($result['IsLCC'] == 1) {
				$IsPassExpiry = $result['IsPassportRequiredAtTicket'];
			} else {
				$IsPassExpiry = $result['IsPassportRequiredAtBook'];
			}
			$Baggage = $result['Segments'][0][0]['Baggage'];
			if ($result['IsLCC']) {
				$CabinBaggage = !empty($result['Segments'][0][0]['CabinBaggage']) ? $result['Segments'][0][0]['CabinBaggage'] : '';
			} else {
				$CabinBaggage = !empty($result['Segments'][0][0]['CabinBaggage']) ? $result['Segments'][0][0]['CabinBaggage'] : '7 KG';
			}

			$MiniFareRules = (isset($result['MiniFareRules']) && !empty($result['MiniFareRules'])) ? $result['MiniFareRules'] : [];
			$MiniFR = [];
			if ($MiniFareRules) {
				foreach ($MiniFareRules as $Minivalue) {
					if ($Minivalue) {
						foreach ($Minivalue as $kk => $Mini) {
							$Type = !empty($Mini['Type']) ? strtoupper($Mini['Type']) : 'NA';
							if (empty($Mini['To'])) {
								$TimeFrame = 'from ' . $Mini['From'] . ' ' . $Mini['Unit'] . ' & above before dept';
							} else {
								$TimeFrame = 'from ' . $Mini['From'] . ' To ' . $Mini['To'] . ' ' . $Mini['Unit'] . ' before dept';
							}
							//$MiniFR[$Type][$kk] = $Mini;
							$MiniFR[$Type][$kk]['sector'] = $Mini['JourneyPoints'];
							$MiniFR[$Type][$kk]['amount'] = $Mini['Details'];
							$MiniFR[$Type][$kk]['additionalFee'] = $getCancelCharge;
							$MiniFR[$Type][$kk]['TimeFrame'] = $TimeFrame;
							$MiniFR[$Type][$kk]['policyInfo'] = [];
						}
					}
				}
			}
			$tripbinfo = [];
            $tripbinfoBreack = [];
            if($result['Segments']){
                foreach($result['Segments'] as $value){
                    if($value){
                        foreach($value as $kk=>$vals){
                            $Baggage = $vals['Baggage'];
                            $CabinBaggage = $vals['CabinBaggage'];
                            $SectorsCode = $vals['Origin']['Airport']['AirportCode'].'-'.$vals['Destination']['Airport']['AirportCode'];
                            $tripbinfo[$SectorsCode]['ADULT'] = ['cabin'=>$CabinBaggage,'checkin'=>$Baggage];
                            $tripbinfoBreack[$SectorsCode]['1'] = ['cabin'=>$CabinBaggage,'checkin'=>$Baggage];
                            if(!empty($childCount)){
                                $tripbinfo[$SectorsCode]['CHILD'] = ['cabin'=>$CabinBaggage,'checkin'=>$Baggage];
                                $tripbinfoBreack[$SectorsCode]['2'] = ['cabin'=>$CabinBaggage,'checkin'=>$Baggage];
                            }
                            if(!empty($infantCount)){
                                $tripbinfo[$SectorsCode]['INFANT'] = ['cabin'=>$CabinBaggage,'checkin'=>'NA'];
                                $tripbinfoBreack[$SectorsCode]['3'] = ['cabin'=>$CabinBaggage,'checkin'=>'NA'];
                            }
                        }
                    }
                }
            }
			$NewPrice = $this->TBOPrice($result, $AdditionalMarkup, $getMarkup, $sessionFlightSearchParams->params, $tripbinfoBreack, $tripbinfo, $MiniFR);
			// echo '<pre>';
			// print_r($NewPrice);
			// die;
			$Tax = $result['Fare']['Tax'];

			$YQTax = $result['Fare']['YQTax'];
			$AdditionalTxnFeeOfrd = $result['Fare']['AdditionalTxnFeeOfrd'];
			$AdditionalTxnFeePub = $result['Fare']['AdditionalTxnFeePub'];
			$OtherCharges = $result['Fare']['OtherCharges'];
			$Discount = $result['Fare']['Discount'];
			$PublishedFare = $result['Fare']['PublishedFare'];
			$CommissionEarned = $result['Fare']['CommissionEarned'];
			$PLBEarned = $result['Fare']['PLBEarned'];
			$IncentiveEarned = $result['Fare']['IncentiveEarned'];
			$OfferedFare = $result['Fare']['OfferedFare'];
			$TdsOnCommission = $result['Fare']['TdsOnCommission'];
			$TdsOnPLB = $result['Fare']['TdsOnPLB'];
			$TdsOnIncentive = $result['Fare']['TdsOnIncentive'];
			$ServiceFee = $result['Fare']['ServiceFee'];
			$FareBreakdown = $result['FareBreakdown'];
			$totalCommissions = $result['Fare']['CommissionEarned'] + $result['Fare']['PLBEarned'] + $result['Fare']['IncentiveEarned'];
			$TotalPassengerCountForDiscount = $adultCount + $childCount;
			$intDiscountPerHead = $totalCommissions;

			$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']) ? $AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'] : 0;
			$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);
			$totalCommissionsOnTds = $result['Fare']['TdsOnCommission'] + $result['Fare']['TdsOnIncentive'] + $result['Fare']['TdsOnPLB'];
			$markUpArr = array(
				'getMarkup' => $getMarkup,
				'PublishedFare' => $PublishedFare,
				'OfferedFare' => $OfferedFare,
				'intCommissionEarned' => $totalCommissions,
				'TdsOnPLB' => $totalCommissionsOnTds,
				'intPLBEarned' => 0, //$PLBEarned,
				'intIncentiveEarned' => 0, //$IncentiveEarned,
				'intMemberCount' => $intMemberCount,
				'intFlightRoute' => $strFlightRoute,
				'interNationalSearch' => $interNationalSearch,
				'AddMarkup' => $AddMarkup,
			);

			$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTBO($markUpArr);
			if ($this->gtxagencysysid == '10672') {
				// echo '<pre>';
				// print_r($arrMarkUps);
				// echo '<pre>';
				// print_r($markUpArr);
			}
			$AgencyMarkUp      = $arrMarkUps['intAgencyFixMarkUp'];
			$intGTXMarkUp      = $arrMarkUps['intGTXMarkUp'];
			$intFareWithGTXMarkUp = $arrMarkUps['intFareWithGTXMarkUp'];

			$intOfferedFare = $arrMarkUps['intOfferedFare'];
			if ($interNationalSearch == 1) {
				$intGTXMarkUp = (($arrMarkUps['intGTXMarkUp'] * $intMemberCount) * $strFlightRoute);
				$intSTaxOnGTXMarkUp = (($arrMarkUps['intSTaxOnGTXMarkUp'] * $intMemberCount) * $strFlightRoute);
				$intAgencyFixMarkUp = (($arrMarkUps['intAgencyFixMarkUp'] * $intMemberCount) * $strFlightRoute);
				$intSTaxOnAgencyFixMarkUp = (($arrMarkUps['intSTaxOnAgencyFixMarkUp'] * $intMemberCount) * $strFlightRoute);
			} else {
				$intGTXMarkUp = ($arrMarkUps['intGTXMarkUp'] * $intMemberCount);
				$intSTaxOnGTXMarkUp = ($arrMarkUps['intSTaxOnGTXMarkUp'] * $intMemberCount);
				$intAgencyFixMarkUp = ($arrMarkUps['intAgencyFixMarkUp'] * $intMemberCount);
				$intSTaxOnAgencyFixMarkUp = ($arrMarkUps['intSTaxOnAgencyFixMarkUp'] * $intMemberCount);
			}

			$CommisionPass = $arrMarkUps['CommisionPass'];
			$intCommisionEarnedForAgency = $arrMarkUps['intCommisionEarnedForAgency'];
			$intPLBEarnedForAgency = $arrMarkUps['intPLBEarnedForAgency'];
			$intIncentiveEarnedForAgency = $arrMarkUps['intIncentiveEarnedForAgency'];
			$intTotalEarningsForAgency = $arrMarkUps['intTotalEarningsForAgency'] + $intAgencyFixMarkUp;

			$intGSTOnAgencyCommisionEarned = $arrMarkUps['intGSTOnAgencyCommisionEarned'];
			$intGSTOnAgencyPLBEarned = $arrMarkUps['intGSTOnAgencyPLBEarned'];
			$intGSTOnAgencyIncentiveEarned = $arrMarkUps['intGSTOnAgencyIncentiveEarned'];
			//$intTotalGSTAgencyEarnings = $intSTaxOnAgencyFixMarkUp + $intGSTOnAgencyCommisionEarned + $intGSTOnAgencyPLBEarned + $intGSTOnAgencyIncentiveEarned;
			$intTotalGSTAgencyEarnings = $intSTaxOnAgencyFixMarkUp;

			$intPublishedFare = 0; // CommisionPass $intOfferedFare+ $ServiceFee + $intGTXMarkUp + $intAgencyFixMarkUp + $intCommisionEarnedForAgency + $intPLBEarnedForAgency + $intIncentiveEarnedForAgency + $intTotalGSTAgencyEarnings;
			$intTotalOfferedForAllPax = 0;
			$intTotalCommissionEarned = 0;
			$countBreakUp = count($FareBreakdown);
			foreach ($FareBreakdown as $pk => $pax) {
				$intPassengerType       = $pax['PassengerType'];
				$intPassengerCount = isset($pax['PassengerCount']) ? $pax['PassengerCount'] : 0;
				$intBaseFare       = $pax['BaseFare'];
				$intTax            = $pax['Tax'];
				$OtherCharges_         = ($OtherCharges / $countBreakUp);
				$intDiscountPerHead_         = ($intDiscountPerHead / $countBreakUp);
				$intBaseFareCal             = $intBaseFare - $intDiscountPerHead_;
				$intFareOfferedToPax       = $intBaseFareCal + $intTax;
				//echo '<pre>';print_r($intBaseFareCal);
				$arrFareBreakdown[$pk] = [
					'intDiscountPerHead'      => $intDiscountPerHead_,
					'Currency'      => $pax['Currency'],
					'APIBaseFare'      => $pax['BaseFare'],
					'BaseFare'      => $pax['BaseFare'], //$intBaseFareCal,
					'Tax'           => $pax['Tax'],
					'YQTax'         => $pax['YQTax'],
					'OtherCharges'         => $OtherCharges_,
					'PassengerType' => $pax['PassengerType'],
					'PassengerCount' => $pax['PassengerCount'],
					'PGCharge'      => $pax['PGCharge'],
					'AdditionalTxnFeePub'   => $pax['AdditionalTxnFeePub'],
					'AdditionalTxnFeeOfrd'  => $pax['AdditionalTxnFeeOfrd'],
					'AgencyMarkUp'  => $AgencyMarkUp,
					'GTXMarkUp'  => $intGTXMarkUp,
					'FareOfferedToPax'  => $intFareOfferedToPax,
					'FixedMarkUp'  => ($intAgencyFixMarkUp / $countBreakUp),
					'GSTOnMarkUp'  => ($intSTaxOnAgencyFixMarkUp / $countBreakUp),
					'intTotalGST'  => ($intSTaxOnAgencyFixMarkUp / $countBreakUp),
					'ServiceFee'  => ($ServiceFee / $countBreakUp),
					'CommisionPass'  => ($CommisionPass / $countBreakUp),
					'intGTXMarkUp'  => $intGTXMarkUp,
					'GTXMarkUpGST'  => $intSTaxOnGTXMarkUp,
					'CommissionEarned'  => ($intCommisionEarnedForAgency / $countBreakUp),
					'IntCommission'  => $arrMarkUps['intCommissionEarned'],
				];
				$arrFareBreakdown[$pk]['TDS'] = ($totalCommissionsOnTds / $countBreakUp);
				$arrFareBreakdown[$pk]['MF'] = 0;
				$arrFareBreakdown[$pk]['YQ'] = $pax['YQTax'];
				$arrFareBreakdown[$pk]['AGST'] = 0;
				$arrFareBreakdown[$pk]['MFT'] = 0;
				$arrFareBreakdown[$pk]['OT'] = ($pax['Tax'] + $OtherCharges_);
				$arrFareBreakdown[$pk]['MU'] = 0;
				$arrFareBreakdown[$pk]['YR'] = 0;
				$arrFareBreakdown[$pk]['intCommisionEarnedForAgency'] = ($intCommisionEarnedForAgency / $countBreakUp);
				$arrFareBreakdown[$pk]['intPLBEarnedForAgency'] = ($intPLBEarnedForAgency / $countBreakUp);
				$arrFareBreakdown[$pk]['intIncentiveEarnedForAgency'] = ($intIncentiveEarnedForAgency / $countBreakUp);
				$arrFareBreakdown[$pk]['Baggage'] = ($Baggage);
				$arrFareBreakdown[$pk]['CabinBaggage'] = ($CabinBaggage);

				$intTotalOfferedForAllPax += $intFareOfferedToPax;
				$intTotalCommissionEarned += $intCommisionEarnedForAgency;

				$intPublishedFare += $intBaseFare + $OtherCharges_ + $intTax + ($totalCommissionsOnTds / $countBreakUp) + ($intAgencyFixMarkUp / $countBreakUp) + ($intSTaxOnAgencyFixMarkUp / $countBreakUp) + ($ServiceFee / $countBreakUp) - ($CommisionPass / $countBreakUp);
			}

			$arrFairRules = array(
				"Currency" => $this->CurrencyTitle, //$Currency,
				"CurrencyRate" => $this->CurrencyRate, //$Currency,
				"currencySysId" => $this->CurrencyId,
				"BaseFare" => $BaseFare,
				"Tax" => $Tax,
				"YQTax" => $YQTax,
				"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
				"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
				"OtherCharges" => $OtherCharges,
				"Discount" => $Discount,
				"ServiceFee" => $ServiceFee,
				"PublishedFare" => $intPublishedFare,
				"CommissionEarned" => $intTotalCommissionEarned,
				"PLBEarned" => $PLBEarned,
				"IncentiveEarned" => $IncentiveEarned,
				"OfferedFare" => $OfferedFare,
				"TdsOnCommission" => $TdsOnCommission,
				"TdsOnPLB" => $TdsOnPLB,
				"TdsOnIncentive" => $TdsOnIncentive,
				//"FareBreakdown" => $FareBreakdown,
				"fareIdentifier" => $FairRules['fareIdentifier'],
				"Refundable" => $FairRules['Refundable'],
				"IsRefundableTxt" => $FairRules['IsRefundableTxt'],
				"AirlineRemark" => $FairRules['AirlineRemark'],
				"fareremarks" => $FairRules['AirlineRemark'],
				"CommEarned" => $arrMarkUps['intCommissionEarned'],
				"CommisionPass" => $CommisionPass,
				"PriceID" => $FairRules['PriceID'],
				"FixedMarkUp" => $AgencyMarkUp,
				"GSTOnMarkUp" => $intSTaxOnAgencyFixMarkUp,
				"Baggage" => $Baggage,
				"CabinBaggage" => $CabinBaggage,
				"FareBreakdown" => $arrFareBreakdown,
				"arrMarkUps" => $arrMarkUps,
				"TaxSettingDetail" => $arrMarkUps['TaxSettingDetail'],
				"CancelCharge" => $getCancelCharge,
				"tripbinfo" => $tripbinfo,
				"MiniFR" => $MiniFR,
			);
			if ($interNationalSearch == 1 && $strFlightRoute == 2) {
				$vl['AirlineName']  = $vl['origin']['AirlineName'];
				$vl['FlightNumber']  = $vl['origin']['FlightNumber'];
				$vl['AirlineCode']  = $vl['origin']['AirlineCode'];
				$vl['SourcePlaceSysId'] = $arrCommonInsVariables['intSourceCityId'];
				$vl['DestPlaceSysId'] = $arrCommonInsVariables['intDestinationCityId'];
				$vl['SourceAirportCode'] = $arrCommonInsVariables['strSourceAirportCode'];
				$vl['DestAirportCode']   = $arrCommonInsVariables['strDestinationAirportCode'];
				$vl['IsLCC'] = $vl['origin']['IsLCC'];
				$vl['LocalFromTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? $arrCommonInsVariables['localFromDateTime'] : '';
				$vl['FromUTCTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? $arrCommonInsVariables['localFromDateTime'] : '';
				$vl['LocalToTime'] = isset($arrCommonInsVariables['localToDateTime']) ? $arrCommonInsVariables['localToDateTime'] : '';
				$vl['ToUTCTime'] = isset($arrCommonInsVariables['localToDateTime']) ? $arrCommonInsVariables['localToDateTime'] : '';
				
				$vl['StopCount'] = $OrStopCountTxt;
				$vl['AirlineName'] = $strAirlineName;
				$vl['IsRefundable'] = $vl['origin']['IsRefundable'];
				$vl['IsRefundableTxt'] = $vl['origin']['IsRefundableTxt'];
				$vl['IsInternational'] = $interNationalSearch;
				$vl['SearchFlightTraceId'] = $SearchFlightTraceId;
				$vl['DepartureTime'] = $vl['origin']['DepartureTime'];
				$vl['ArrivalTime'] = $vl['origin']['ArrivalTime'];
			}

			$vl['SourcePlaceSysId'] = $intSourceCityId;
			$vl['DestPlaceSysId'] = $intDestinationCityId;
			$vl['FairRules'] = $arrFairRules;
			$vl['NewPrice'] = $NewPrice;
			$vl['IsPassExpiry'] = $IsPassExpiry;
			$vl['IsPassIssue'] = false;
			$vl['isGSTMandatory'] = $isGSTMandatory;
			$validation = $this->validateFlight();
			if ($interNationalSearch == 1) {
				$vl['isDobAdult'] = true;
			}elseif($AirlineCode == 'I5') {
				$vl['isDobAdult'] = true;
			}else{
				$vl['isDobAdult'] =  isset($validation[$AirlineCode]['dob'])?$validation[$AirlineCode]['dob']:false;
			}
			$vl['isDobChild'] = true;
			$vl['isDobInfant'] = true;
			if($ResultFareType__ == "SENIOR_CITIZEN" && $AirlineCode == '6E'){
				$vl['isDocIdAllowedMandatory'] = true;
				$vl['isDobAdult'] = true;
			}
			if($ResultFareType__ == "STUDENT" && ($AirlineCode == '6E' || $AirlineCode == 'SG')){
				$vl['isDocIdAllowedMandatory'] = true;
			}
			if($IsPassportFullDetailRequiredAtBook){
				$vl['IsPassMandatory'] =  true;
				$vl['IsPassExpiry'] = true;
				$vl['IsPassIssue'] = true;
				$vl['isDobAdult'] = true;
			}
			$vl['isSeatAppli'] = true;
			return ['BookingData' => $vl, 'SSRArr' => $SSRArr];
		}
	}
	
	public function TJPrice($result, $AdditionalMarkup, $getMarkup, $sessionFlightSearchParams, $AirlineCode)
	{

		$adultCount = $sessionFlightSearchParams['adults'];
		$childCount = $sessionFlightSearchParams['child'];
		$infantCount = $sessionFlightSearchParams['infant'];
		$intMemberCount = $adultCount + $childCount + $infantCount;
		$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
		$SegmentCount = 1;
		$ConvertionRate = $this->CurrencyRate;
		$strFlightRoute = $JourneyType = trim($sessionFlightSearchParams['route']);
		if ($result['totalPriceList']) {
			foreach ($result['totalPriceList'] as $kp => $price) {
				$fareDetail = $price['fd'];
				if($price['tai']['tbi']){
					foreach ($price['tai']['tbi'] as $keyss => $tbi) {
						$segc = isset($segmentSector[$keyss])?$segmentSector[$keyss]:'';
						$sectorKey = $segc['origin'].'-'.$segc['destination'];
						if($tbi){
							foreach($tbi as $kgk=>$pbi){
								if($pbi){
									foreach($pbi as $gk=>$vll){
										$tripbaggageinfo[$sectorKey][$gk] = ['cabin'=>isset($vll['cB'])?$vll['cB']:'NA','checkin'=>isset($vll['iB'])?$vll['iB']:'NA'];
									}
								}
							}
						}
					}
				}
				$IsRefundable = isset($fareDetail['ADULT']['rT']) ? $fareDetail['ADULT']['rT'] : 0;
				$PriceID = $price['id'];
				$fareIdentifier = $price['fareIdentifier'];
				$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
				$colors = !empty($AddMarkup['color']) ? $AddMarkup['color'] : '#000000';
				
				$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'])?$AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']:0;
				$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);
				// echo '<pre>===============';
				// print_r($AddMarkup);
				// die;
				$IsMealIncludes = $fareDetail['ADULT']['mI'];
				$strBaggage = ucfirst(strtolower(str_replace(" ", "",$price['fd']['ADULT']['bI']['iB']))); ///Checking Baggage
				$strCabinBaggage = ucfirst(strtolower(str_replace(" ", "",$price['fd']['ADULT']['bI']['cB']))); ////Cabin Baggage
				if (!empty($strCabinBaggage)) {
					$IscabinbagInc = true;
				} else {
					$IscabinbagInc = false;
				}
				if (!empty($strBaggage)) {
					$IscheckinBagInc = true;
				} else {
					$IscheckinBagInc = false;
				}
				if ($IsRefundable == 0) {
					$Refundable = 'Non Refundable';
				} elseif ($IsRefundable == 1) {
					$Refundable = 'Refundable';
				} else {
					$Refundable = 'Partial Refundable';
				}
				$fareIdentifier = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['faretype_rename']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['faretype_rename'] : $fareIdentifier;
				// echo '<pre>';
				// print_r($fareIdentifier);
				// echo '<pre>';
				// print_r($AdditionalMarkup['finalArr']);
				// die;
				$classOfBooking = $fareDetail['ADULT']['cB'];
				$ADULT = $fareDetail['ADULT']['fC']; //fare Components
				$CHILD = isset($fareDetail['CHILD']['fC']) ? $fareDetail['CHILD']['fC'] : []; //fare Components
				$INFANT = isset($fareDetail['INFANT']['fC']) ? $fareDetail['INFANT']['fC'] : []; //fare Components

				$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
				$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
				$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents

				$ADULTNCMTDS = isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
				$CHILDNCMTDS = isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
				$INFANTNCMTDS = isset($fareDetail['INFANT']['afC']['NCM']['TDS']) ? $fareDetail['INFANT']['afC']['NCM']['TDS'] : 0; //TDS

				$ADULTNCMTOT = isset($fareDetail['ADULT']['afC']['NCM']['OT']) ? $fareDetail['ADULT']['afC']['NCM']['OT'] : 0; //- Gross Commission
				$CHILDNCMTOT = isset($fareDetail['CHILD']['afC']['NCM']['OT']) ? $fareDetail['CHILD']['afC']['NCM']['OT'] : 0; //- Gross Commission
				$INFANTNCMTOT = isset($fareDetail['INFANT']['afC']['NCM']['OT']) ? $fareDetail['INFANT']['afC']['NCM']['OT'] : 0; //- Gross Commission
				$GrossCommission = ((($ADULTNCMTOT * $adultCount) + ($CHILDNCMTOT * $childCount) + ($INFANTNCMTOT * $infantCount)));
				$PublishedFare = (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
				$BaseFare = (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
				$TaxIN = (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
				$NetFare = (($ADULT['NF'] * $adultCount) + ($CHILD['NF'] * $childCount) + ($INFANT['NF'] * $infantCount)); //Taxes and Fees
				$NetCommission = (($ADULT['NCM'] * $adultCount) + ($CHILD['NCM'] * $childCount) + ($INFANT['NCM'] * $infantCount)); //Taxes and Fees
				$TDS = str_replace('-', '', (($ADULTNCMTDS * $adultCount) + ($CHILDNCMTDS * $childCount) + ($INFANTNCMTDS * $infantCount)));

				$PublishedFareIN = (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount));

				$AD_MF = isset($ADULTafC['MF']) ? $ADULTafC['MF'] : 0; //Management Fee
				$AD_YQ = isset($ADULTafC['YQ']) ? $ADULTafC['YQ'] : 0; //Fuel Surcharge
				$AD_AGST = isset($ADULTafC['AGST']) ? $ADULTafC['AGST'] : 0; //Airline GST Component
				$AD_MFT = isset($ADULTafC['MFT']) ? $ADULTafC['MFT'] : 0; //Management Fee Tax
				$AD_OT = isset($ADULTafC['OT']) ? $ADULTafC['OT'] : 0; //Other Charges
				$AD_MU = isset($ADULTafC['MU']) ? $ADULTafC['MU'] : 0; //markup
				$AD_YR = isset($ADULTafC['YR']) ? $ADULTafC['YR'] : 0; //Carrier Misc Fee

				$CH_MF = isset($CHILDafC['MF']) ? $CHILDafC['MF'] : 0; //Management Fee
				$CH_YQ = isset($CHILDafC['YQ']) ? $CHILDafC['YQ'] : 0; //Fuel Surcharge
				$CH_AGST = isset($CHILDafC['AGST']) ? $CHILDafC['AGST'] : 0; //Airline GST Component
				$CH_MFT = isset($CHILDafC['MFT']) ? $CHILDafC['MFT'] : 0; //Management Fee Tax
				$CH_OT = isset($CHILDafC['OT']) ? $CHILDafC['OT'] : 0; //Other Charges
				$CH_MU = isset($CHILDafC['MU']) ? $CHILDafC['MU'] : 0; //markup
				$CH_YR = isset($CHILDafC['YR']) ? $CHILDafC['YR'] : 0; //Carrier Misc Fee

				$IN_MF = isset($INFANTafC['MF']) ? $INFANTafC['MF'] : 0; //Management Fee
				$IN_YQ = isset($INFANTafC['YQ']) ? $INFANTafC['YQ'] : 0; //Fuel Surcharge
				$IN_AGST = isset($INFANTafC['AGST']) ? $INFANTafC['AGST'] : 0; //Airline GST Component
				$IN_MFT = isset($INFANTafC['MFT']) ? $INFANTafC['MFT'] : 0; //Management Fee Tax
				$IN_OT = isset($INFANTafC['OT']) ? $INFANTafC['OT'] : 0; //Other Charges
				$IN_MU = isset($INFANTafC['MU']) ? $INFANTafC['MU'] : 0; //markup
				$IN_YR = isset($INFANTafC['YR']) ? $INFANTafC['YR'] : 0; //Carrier Misc Fee

				$MUFee = (($AD_MU * $adultCount) + ($CH_MU * $childCount) + ($IN_MU * $infantCount));
				$TaxIN = ($TaxIN - $GrossCommission - $MUFee);
				$NetFare = ($NetFare - $TDS);
				$markUpArr = array(
					'AgentMarkUp' => 0,
					'getMarkup' => $getMarkup,
					'PublishedFare' => $PublishedFare,
					'OfferedFare' => ($NetFare),
					'Commission' => $NetCommission,
					'TDS' => $TDS,
					'MUFee' => $MUFee,
					'intMemberCount' => $intMemberCount,
					'intFlightRoute' => ($JourneyType == 3)?$SegmentCount:$JourneyType,
					'interNationalSearch' => $interNationalSearch,
					'AddMarkup' => $AddMarkup,
				);
				$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupNewAPI($markUpArr,'farequote');
				///$arrMarkUps = $this->calculateMarkup($markUpArr,'farequote');
				// echo '<pre>===============';
				// print_r($arrMarkUps);AddiMarkup
				// echo '<pre>===============';
				// print_r($markUpArr);
				// die;
				$MUFeeBR = (($AD_MU * $adultCount));
				$TaxINBR = (($ADULT['TAF'] - $ADULTNCMTOT) * $adultCount - $MUFeeBR);
				$TDSBR = str_replace('-', '', (($ADULTNCMTDS * $adultCount)));
				$NetFareBR = (($ADULT['NF'] * $adultCount) - $TDSBR);
				$markUpArrBR = array(
					'getMarkup' => $getMarkup,
					'PublishedFare' => ($ADULT['TF'] * $adultCount),
					'OfferedFare' => ($NetFareBR),
					'Commission' => ($ADULT['NCM'] * $adultCount),
					'TDS' => $TDSBR,
					'MUFee' => $MUFeeBR,
					'intMemberCount' => $adultCount,
					'intFlightRoute' => ($JourneyType == 3)?$SegmentCount:$JourneyType,
					'interNationalSearch' => $interNationalSearch,
					'AddMarkup' => $AddMarkup,
				);
				$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupNewAPI($markUpArrBR,'farequote');
				
				$FareBreakdown[0]['Currency'] = $arrMarkUpsBR['Currency'];
				$FareBreakdown[0]['PassengerType'] = 1;
				$FareBreakdown[0]['PaxType'] = 'ADULT';
				$FareBreakdown[0]['PassengerCount'] = $adultCount;
				$FareBreakdown[0]['BaseFare'] = round(($ADULT['BF'] * $adultCount) * $ConvertionRate,2);
				$FareBreakdown[0]['Tax'] = round($TaxINBR * $ConvertionRate,2);
				$FareBreakdown[0]['OfferedFare'] = round($NetFareBR * $ConvertionRate,2);
				$FareBreakdown[0]['PublishedFare'] = round($arrMarkUpsBR['CostToCustomer'] * $ConvertionRate,2);
				$FareBreakdown[0]['TDS'] = round($arrMarkUpsBR['TDS'] * $ConvertionRate,2);
				$FareBreakdown[0]['TDSEarn'] = round($arrMarkUpsBR['TDSEarn'] * $ConvertionRate,2);
				$FareBreakdown[0]['TaxBR']['MF'] = round(($AD_MF * $adultCount) * $ConvertionRate,2);
				$FareBreakdown[0]['TaxBR']['YQ'] = round(($AD_YQ * $adultCount) * $ConvertionRate,2);
				$FareBreakdown[0]['TaxBR']['AGST'] = round(($AD_AGST * $adultCount) * $ConvertionRate,2);
				$FareBreakdown[0]['TaxBR']['MFT'] = round(($AD_MFT * $adultCount) * $ConvertionRate,2);
				$FareBreakdown[0]['TaxBR']['OT'] = round((($AD_OT - $ADULTNCMTOT) * $adultCount) * $ConvertionRate,2);
				$FareBreakdown[0]['TaxBR']['YR'] = round(($AD_YR * $adultCount) * $ConvertionRate,2);
				$FareBreakdown[0]['ApiNCM'] = round($arrMarkUpsBR['IntNetCommission'] * $ConvertionRate,2);
				$FareBreakdown[0]['CommissionEarned'] = round($arrMarkUpsBR['CommEarned'] * $ConvertionRate,2);
				$FareBreakdown[0]['FixedMarkUp'] = round($arrMarkUpsBR['FixedMarkUp'] * $ConvertionRate,2);
				$FareBreakdown[0]['GSTOnMarkUp'] = round($arrMarkUpsBR['GSTOnMarkUp'] * $ConvertionRate,2);
				$FareBreakdown[0]['CommDiscount'] = round($arrMarkUpsBR['CommDiscount'] * $ConvertionRate,2);
				$FareBreakdown[0]['Baggage'] = isset($fareDetail['ADULT']['bI']['iB']) ? $fareDetail['ADULT']['bI']['iB'] : ''; //Check In Baggage;
				$FareBreakdown[0]['CabinBaggage'] = isset($fareDetail['ADULT']['bI']['cB']) ? $fareDetail['ADULT']['bI']['cB'] : ''; //Cabin Baggage ;
				if (isset($fareDetail['CHILD']) && $childCount > 0) {
					$MUFeeBR = (($CH_MU * $childCount));
					$TaxINBR = (($CHILD['TAF'] - $CHILDNCMTOT) * $childCount - $MUFeeBR);
					$TDSBR = str_replace('-', '', (($CHILDNCMTDS * $childCount)));
					$NetFareBR = (($CHILD['NF'] * $childCount) - $TDSBR);
					$markUpArrBR = array(
						'getMarkup' => $getMarkup,
						'PublishedFare' => ($CHILD['TF'] * $childCount),
						'OfferedFare' => ($NetFareBR),
						'Commission' => ($CHILD['NCM'] * $childCount),
						'TDS' => $TDSBR,
						'MUFee' => $MUFeeBR,
						'intMemberCount' => $childCount,
						'intFlightRoute' => ($JourneyType == 3)?$SegmentCount:$JourneyType,
						'interNationalSearch' => $interNationalSearch,
						'AddMarkup' => $AddMarkup,
					);
					$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupNewAPI($markUpArrBR,'farequote');
					$FareBreakdown[1]['Currency'] = $arrMarkUpsBR['Currency'];
					$FareBreakdown[1]['PassengerType'] = 2;
					$FareBreakdown[1]['PaxType'] = 'CHILD';
					$FareBreakdown[1]['PassengerCount'] = $childCount;
					$FareBreakdown[1]['BaseFare'] = round(($CHILD['BF'] * $childCount) * $ConvertionRate,2);
					$FareBreakdown[1]['Tax'] = round($TaxINBR * $ConvertionRate,2);
					$FareBreakdown[1]['OfferedFare'] = round(($NetFareBR * $ConvertionRate),2);
					$FareBreakdown[1]['PublishedFare'] = round($arrMarkUpsBR['CostToCustomer'] * $ConvertionRate,2);
					$FareBreakdown[1]['TDS'] = round($arrMarkUpsBR['TDS'] * $ConvertionRate,2);
					$FareBreakdown[1]['TDSEarn'] = round($arrMarkUpsBR['TDSEarn'] * $ConvertionRate,2);
					$FareBreakdown[1]['TaxBR']['MF'] = round(($CH_MF * $childCount) * $ConvertionRate,2);
					$FareBreakdown[1]['TaxBR']['YQ'] = round(($CH_YQ * $childCount) * $ConvertionRate,2);
					$FareBreakdown[1]['TaxBR']['AGST'] = round(($CH_AGST * $childCount) * $ConvertionRate,2);
					$FareBreakdown[1]['TaxBR']['MFT'] = round(($CH_MFT * $childCount) * $ConvertionRate,2);
					$FareBreakdown[1]['TaxBR']['OT'] = round((($CH_OT - $CHILDNCMTOT) * $childCount) * $ConvertionRate,2);
					$FareBreakdown[1]['TaxBR']['YR'] = round(($CH_YR * $childCount) * $ConvertionRate,2);
					$FareBreakdown[1]['ApiNCM'] = round($arrMarkUpsBR['IntNetCommission'] * $ConvertionRate,2);
					$FareBreakdown[1]['CommissionEarned'] = round($arrMarkUpsBR['CommEarned'] * $ConvertionRate,2);
					$FareBreakdown[1]['FixedMarkUp'] = round($arrMarkUpsBR['FixedMarkUp'] * $ConvertionRate,2);
					$FareBreakdown[1]['GSTOnMarkUp'] = round($arrMarkUpsBR['GSTOnMarkUp'] * $ConvertionRate,2);
					$FareBreakdown[1]['CommDiscount'] = round($arrMarkUpsBR['CommDiscount'] * $ConvertionRate,2);
					$FareBreakdown[1]['Baggage'] = isset($fareDetail['CHILD']['bI']['iB']) ? $fareDetail['CHILD']['bI']['iB'] : ''; //Check In Baggage;
					$FareBreakdown[1]['CabinBaggage'] = isset($fareDetail['CHILD']['bI']['cB']) ? $fareDetail['CHILD']['bI']['cB'] : ''; //Cabin Baggage ;
				}
				if (isset($fareDetail['INFANT']) && $infantCount > 0) {
					$MUFeeBR = (($IN_MU * $infantCount));
					$TaxINBR = (($INFANT['TAF'] - $INFANTNCMTOT) * $infantCount - $MUFeeBR);
					$TDSBR = str_replace('-', '', (($INFANTNCMTDS * $infantCount)));
					$NetFareBR = (($INFANT['NF'] * $infantCount) - $TDSBR);
					$markUpArrBR = array(
						'getMarkup' => $getMarkup,
						'PublishedFare' => ($INFANT['TF'] * $infantCount),
						'OfferedFare' => ($NetFareBR),
						'Commission' => ($INFANT['NCM'] * $infantCount),
						'TDS' => $TDSBR,
						'MUFee' => $MUFeeBR,
						'intMemberCount' => $infantCount,
						'intFlightRoute' => ($JourneyType == 3)?$SegmentCount:$JourneyType,
						'interNationalSearch' => $interNationalSearch,
						'AddMarkup' => $AddMarkup,
					);
					$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupNewAPI($markUpArrBR,'farequote');
					$FareBreakdown[2]['Currency'] = $arrMarkUpsBR['Currency'];
					$FareBreakdown[2]['PassengerType'] = 3;
					$FareBreakdown[2]['PaxType'] = 'INFANT';
					$FareBreakdown[2]['PassengerCount'] = $infantCount;
					$FareBreakdown[2]['BaseFare'] = round(($INFANT['BF'] * $infantCount) * $ConvertionRate,2);
					$FareBreakdown[2]['Tax'] = round($TaxINBR * $ConvertionRate,2);
					$FareBreakdown[2]['OfferedFare'] = round($NetFareBR * $ConvertionRate,2);
					$FareBreakdown[2]['PublishedFare'] = round($arrMarkUpsBR['CostToCustomer'] * $ConvertionRate,2);
					$FareBreakdown[2]['TDS'] = round($arrMarkUpsBR['TDS'] * $ConvertionRate,2);
					$FareBreakdown[2]['TDSEarn'] = round($arrMarkUpsBR['TDSEarn'] * $ConvertionRate,2);
					$FareBreakdown[2]['TaxBR']['MF'] = round(($IN_MF * $infantCount) * $ConvertionRate,2);
					$FareBreakdown[2]['TaxBR']['YQ'] = round(($IN_YQ * $infantCount) * $ConvertionRate,2);
					$FareBreakdown[2]['TaxBR']['AGST'] = round(($IN_AGST * $infantCount) * $ConvertionRate,2);
					$FareBreakdown[2]['TaxBR']['MFT'] = round(($IN_MFT * $infantCount) * $ConvertionRate,2);
					$FareBreakdown[2]['TaxBR']['OT'] = round((($IN_OT - $INFANTNCMTOT) * $infantCount) * $ConvertionRate,2);
					$FareBreakdown[2]['TaxBR']['YR'] = round(($IN_YR * $infantCount) * $ConvertionRate,2);
					$FareBreakdown[2]['ApiNCM'] = round($arrMarkUpsBR['IntNetCommission'] * $ConvertionRate,2);
					$FareBreakdown[2]['CommissionEarned'] = round($arrMarkUpsBR['CommEarned'] * $ConvertionRate,2);
					$FareBreakdown[2]['FixedMarkUp'] = round($arrMarkUpsBR['FixedMarkUp'] * $ConvertionRate,2);
					$FareBreakdown[2]['GSTOnMarkUp'] = round($arrMarkUpsBR['GSTOnMarkUp'] * $ConvertionRate,2);
					$FareBreakdown[2]['CommDiscount'] = round($arrMarkUpsBR['CommDiscount'] * $ConvertionRate,2);
					$FareBreakdown[2]['Baggage'] = isset($fareDetail['INFANT']['bI']['iB']) ? $fareDetail['INFANT']['bI']['iB'] : ''; //Check In Baggage;
					$FareBreakdown[2]['CabinBaggage'] = isset($fareDetail['INFANT']['bI']['cB']) ? $fareDetail['INFANT']['bI']['cB'] : ''; //Cabin Baggage ;
				}

				$FairRules = array(
					"Currency" => $arrMarkUps['Currency'], //$Currency,
					"CurrencyRate" => $ConvertionRate, //$Currency,
					"currencySysId" => $arrMarkUps['currencySysId'],
					"BaseFare" => round($BaseFare ,2),
					"Tax" => round($TaxIN ,2),
					"intPublishedFare" => $PublishedFareIN,
					"PublishedFare" => ceil($arrMarkUps['CostToCustomer'] * $ConvertionRate),
					"PublishedFareAgent" => ($arrMarkUps['Currency'] == 'INR')?ceil($arrMarkUps['CostToCustomer'] * $ConvertionRate):round($arrMarkUps['CostToCustomer'] * $ConvertionRate,2),
					"PublishedFarePerPax" => ceil(($arrMarkUps['CostToCustomer'] * $ConvertionRate) / $intMemberCount),
					"OfferedFare" => round($NetFare * $ConvertionRate,2),
					"CommissionEarned" => round($arrMarkUps['CommEarned'] * $ConvertionRate,2),
					"CommDiscount" => round($arrMarkUps['CommDiscount'] * $ConvertionRate,2),
					"TDS" => round((float)$arrMarkUps['TDS'] * $ConvertionRate,2),
					"TDSEarn" => round($arrMarkUps['TDSEarn'] * $ConvertionRate,2),
					"Refundable" => $IsRefundable,
					"IsRefundableTxt" => $Refundable,
					"PriceID" => $PriceID,
					"classOfBooking" => $classOfBooking,
					"FareClass" => $fareDetail['ADULT']['cc'],
					"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
					"IsSpecialReturn" => ($price['fareIdentifier'] == 'SPECIAL_RETURN')?true:false,
					"colors" => $colors,
					"SeatAvailable" => $fareDetail['ADULT']['sR'],
					"FixedMarkUp" => round($arrMarkUps['FixedMarkUp'] * $ConvertionRate,2),
					"GSTOnMarkUp" => round($arrMarkUps['GSTOnMarkUp'] * $ConvertionRate,2),
					"IscheckinBagInc" => $IscheckinBagInc,
					"IscabinbagInc" => $IscabinbagInc,
					"CheckinBaggage" => $strBaggage,
					"CabinBaggage" => $strCabinBaggage,
					"IsMealIncludes" => $IsMealIncludes,
					"FareBreakdown" => array_values($FareBreakdown),					
				);
			}
			return $FairRules;
		}
	}
	public function UpdateFlightBookingData($data, $alerts, $FareRuleDetails)
	{
		// ini_set('display_errors', 1);
		// ini_set('display_startup_errors', 1);
		// error_reporting(E_ALL);
		$arrAirlineList = $this->getAirlineIdsAndCodeList();
		$apiResponse = $data;
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
		$FlightSearchGuard = new Zend_Session_Namespace('FlightSearchGuard');
		$CurrentFlightSearchGuard = new Zend_Session_Namespace('CurrentFlightSearchGuard');
		$FlightSearchResults = new Zend_Session_Namespace('FlightSearchResults');
		$intSourceCityId = ($sessionFlightSearchParams->params['sourceCityId']);
		$intDestinationCityId = ($sessionFlightSearchParams->params['destinationCityId']);
		$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);
		$strDepatureDate = $sessionFlightSearchParams->params['strDepatureDate'];
		$strReturnDate = !empty($sessionFlightSearchParams->params['strReturnDate']) ? $sessionFlightSearchParams->params['strReturnDate'] : '';
		$strSourceAirportCode = $sessionFlightSearchParams->params['from'];
		$strDestinationAirportCode = $sessionFlightSearchParams->params['to'];
		$adultCount = $sessionFlightSearchParams->params['adults'];
		$childCount = $sessionFlightSearchParams->params['child'];
		$infantCount = $sessionFlightSearchParams->params['infant'];
		$intMemberCount = $adultCount + $childCount + $infantCount;
		$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
		$strFlightRoute = trim($sessionFlightSearchParams->params['route']);
		$SearchFlightTraceId = ($sessionFlightSearchParams->params['SearchFlightTraceId']);
		$intTatalPaxCT = $adultCount + $childCount;
		//$getMarkup = $this->getMarkup($intCountryCode);
		$getMarkup = $this->getMarkupNew($intCountryCode, 1);
		if (empty($getMarkup['arrAgencyMarkups'])) {
			$getMarkup = $this->getMarkup($intCountryCode);
		}
		$TaxSettingDetail = $this->getTaxSettingDetail($getMarkup['TaxSetting'], 1);
		$getMarkup['TaxSettingDetail'] = $TaxSettingDetail;
		$SupplierType = 2;
		$getCancelCharge = $this->getCancelCharge($intCountryCode, $SupplierType);
		
		
		
		//$AdditionalMarkup = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAdditionalMarkup();

		$MarketPlaceSysId = isset($getMarkup['arrAgencyMarkups'][0]['MarketPlaceSysId']) ? $getMarkup['arrAgencyMarkups'][0]['MarketPlaceSysId'] : 0;
		$MasterId = isset($getMarkup['arrAgencyMarkups'][0]['MasterId']) ? $getMarkup['arrAgencyMarkups'][0]['MasterId'] : 0;
		if(empty($MasterId) || $MasterId == 0){
			$MarketPlaceSysId = $MarketPlaceSysId;
		}else{
			$MarketPlaceSysId = $MasterId;
		}
		$filterData = ['ApiSourceSysId' => 3];
		$AdditionalMarkup = $this->getMarketPlace($filterData, $MarketPlaceSysId);
		
		// $faretypeArr = $AdditionalMarkup['faretypeArr'];
		// echo '<pre>';print_r($AdditionalMarkup);
		// die;
		$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';
		if ($interNationalSearch == 1 && $strFlightRoute == 2) {
			$localFromDateTime = date("Y-m-d h:i", strtotime($strDepatureDate));
			$localToDateTime = date("Y-m-d h:i", strtotime($strReturnDate));
			$arrCommonInsVariables = array(
				'strTraceId' => $strTraceId,
				'localFromDateTime' => $localFromDateTime,
				'localToDateTime' => $localToDateTime,
				'strSourceAirportCode' => $strSourceAirportCode,
				'strDestinationAirportCode' => $strDestinationAirportCode,
				'intMemberCount' => $intMemberCount,
				'intSourceCityId' => $intSourceCityId,
				'intDestinationCityId' => $intDestinationCityId,
				'JourneyType' => 2, // For Round Trips API Search
				'TripType' => $strFlightRoute,
				'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0
			);
			$strTraceId         = $arrCommonInsVariables['strTraceId'];
			$localFromDateTime  = $arrCommonInsVariables['localFromDateTime'];
			$localToDateTime    = $arrCommonInsVariables['localToDateTime'];

			$strSourceAirportCode    = $arrCommonInsVariables['strSourceAirportCode'];
			$strDestinationAirportCode    = $arrCommonInsVariables['strDestinationAirportCode'];
			$intMemberCount    = $arrCommonInsVariables['intMemberCount'];
			$intSourceCityId    = $arrCommonInsVariables['intSourceCityId'];
			$intDestinationCityId    = $arrCommonInsVariables['intDestinationCityId'];
			$intJourneyType    = $arrCommonInsVariables['JourneyType'];
			$intTripType    = $arrCommonInsVariables['TripType'];
			$interNationalSearch    = isset($arrCommonInsVariables['interNationalSearch']) ? $arrCommonInsVariables['interNationalSearch'] : '0';

			$isGSTMandatory = isset($data['conditions']['gst']['igm']) ? $data['conditions']['gst']['igm'] : false;
			$isDobAdult = isset($data['conditions']['dob']['adobr']) ? $data['conditions']['dob']['adobr'] : false;
			$isDobChild = isset($data['conditions']['dob']['cdobr']) ? $data['conditions']['dob']['cdobr'] : false;
			$isDobInfant = isset($data['conditions']['dob']['idobr']) ? $data['conditions']['dob']['idobr'] : false;
			$isSeatAppli = isset($data['conditions']['isa']) ? $data['conditions']['isa'] : false;
			$estimetedTime = isset($data['conditions']['st']) ? ($data['conditions']['st']) : 0;
			$estimetedTime = floor(($estimetedTime / 60) % 60);
			$estimetedDateTime = isset($data['conditions']['sct']) ? $data['conditions']['sct'] : false;

			//$bookingId = $data['bookingId'];
			$bookingId_TJ = $data['bookingId'];
			$bookingId = str_replace('TJ', BKR, $data['bookingId']);
			if ($data['tripInfos']) {
				$alerts = isset($data['alerts']) ? $data['alerts'] : [];
				$IsPassMandatory = isset($data['conditions']['pcs']['pm']) ? $data['conditions']['pcs']['pm'] : false;
				$IsPassExpiry = isset($data['conditions']['pcs']['pped']) ? $data['conditions']['pcs']['pped'] : false;
				$IsPassIssue = isset($data['conditions']['pcs']['pid']) ? $data['conditions']['pcs']['pid'] : false;
				$IsPassDateOfBirth = isset($data['conditions']['pcs']['dobe']) ? $data['conditions']['pcs']['dobe'] : false;
				$isGSTMandatory = isset($data['conditions']['gst']['igm']) ? $data['conditions']['gst']['igm'] : false;
				$isDobAdult = isset($data['conditions']['dob']['adobr']) ? $data['conditions']['dob']['adobr'] : false;
				$isDobChild = isset($data['conditions']['dob']['cdobr']) ? $data['conditions']['dob']['cdobr'] : false;
				$isDobInfant = isset($data['conditions']['dob']['idobr']) ? $data['conditions']['dob']['idobr'] : false;

				if ($interNationalSearch == 1) {
					$isDobAdult = true;
					$isDobChild = true;
					$isDobInfant = true;
				}

				$TempArr['onward'] = $data['tripInfos'][0];
				$TempArr['return'] = $data['tripInfos'][1];
				$totalPriceListArr = array_merge($TempArr['onward']['totalPriceList'], $TempArr['return']['totalPriceList']);
				$SegmentInformation = array_merge($TempArr['onward']['sI'], $TempArr['return']['sI']);
				$totalPriceList = current($totalPriceListArr);
				$IsRefundable = isset($totalPriceList['fd']['ADULT']['rT']) ? $totalPriceList['fd']['ADULT']['rT'] : 0;
				$NoOfSeatAvailable = $totalPriceList['fd']['ADULT']['sR'];
				$strFareClass = $totalPriceList['fd']['ADULT']['cB']; //Cabin Baggage
				$IsMealIncludes = $totalPriceList['fd']['ADULT']['mI'];
				$bagInfo = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Check In Baggage
				$strTraceId = $totalPriceList['id'];
				$ResultIndex = $totalPriceList['id'];
				if (!empty($bagInfo)) {
					$IsBagIncludes = true;
				} else {
					$IsBagIncludes = false;
				}
				if ($IsRefundable == 0) {
					$IsRefundableTxt = 'Non Refundable';
				} elseif ($IsRefundable == 1) {
					$IsRefundableTxt = 'Refundable';
				} else {
					$IsRefundableTxt = 'Partial Refundable';
				}
				$arrSegments = [];
				$FlyingMinutes = 0;
				$TotalLAYOVERMinutes = 0;
				$LAYOVERCityArr = [];
				$PublishedFare = 0;
				$OfferedFare = 0;
				$PublishedFareINT = 0;
				$intTotalGST = 0;
				$apiMarkup = 0;
				$IntCommission = 0;
				$CommisionPass = 0;
				$apiTaxOnMarkup = 0;
				$IntAgencyFixMarkUp = 0;
				$IntTaxOnAgencyFixMarkUp = 0;
				$intCommisionEarnedForAgency = 0;
				$intGTXMarkUp = 0;
				$intSTaxOnGTXMarkUp = 0;
				$intTdsOnPLB = 0;
				$intCommissionEarned = 0;
				$intPublishedFare = 0;
				$intMUFee = 0;
				$intCarrierMiscFee = 0;
				$intAirlineGSTComponent = 0;
				$intManagementFeeTax = 0;
				$intServiceFee = 0;
				$intOtherCharges = 0;
				$intYQTax = 0;
				$intTaxIN = 0;
				$intBaseFareIN = 0;
				$intnewFare = 0;
				$intoldFare = 0;
				$BaseFare = 0;
				$Tax = 0;
				$YQTax = 0;
				$OtherCharges = 0;
				$ServiceFee = 0;
				$AddiTaxOnMarkup = 0;
				$AddiMarkup = 0;
				$FareBreakdown = [];
				$FairRulesArr = [];
				$arrMarkUpsArray = [];

				foreach ($data['tripInfos'] as $key => $result) {
					
					if ($key == 0) {
						$intJourneyType = 1;
					} else {
						$intJourneyType = 2;
					}
					$BookingData = $FlightBookingData->params[$key];
					$alertsFare = isset($alerts[$key]) ? $alerts[$key] : [];
					$newFare = isset($alertsFare['newFare']) ? $alertsFare['newFare'] : 0;
					$oldFare = isset($alertsFare['oldFare']) ? $alertsFare['oldFare'] : 0;
					$SegmentInformation = $result['sI'];
					$totalPriceList = current($result['totalPriceList']);
					$IsRefundable = isset($totalPriceList['fd']['ADULT']['rT']) ? $totalPriceList['fd']['ADULT']['rT'] : 0;
					$NoOfSeatAvailable = $totalPriceList['fd']['ADULT']['sR'];
					$strFareClass = $totalPriceList['fd']['ADULT']['cB'];
					$IsMealIncludes = $totalPriceList['fd']['ADULT']['mI'];
					$bagInfo = $totalPriceList['fd']['ADULT']['bI']['iB'];
					$strTraceId = $BookingData['FairRules']['PriceID'];
					$ResultIndex = $BookingData['FairRules']['PriceID'];
					if (!empty($bagInfo)) {
						$IsBagIncludes = true;
					} else {
						$IsBagIncludes = false;
					}
					if ($IsRefundable == 0) {
						$IsRefundableTxt = 'Non Refundable';
					} elseif ($IsRefundable == 1) {
						$IsRefundableTxt = 'Refundable';
					} else {
						$IsRefundableTxt = 'Partial Refundable';
					}
					$OriginSegments = current($SegmentInformation);
					$DestinationSegments = end($SegmentInformation);
					$arrSegments = [];
					$FlyingMinutes = 0;
					$TotalLAYOVERMinutes = 0;
					$LAYOVERCityArr = [];
					$PublishedFare = 0;
					$BaseFare = 0;
					$Tax = 0;
					$YQTax = 0;
					$OtherCharges = 0;
					$ServiceFee = 0;

					$FareBreakdown = [];

					$BAGGAGE = isset($OriginSegments['ssrInfo']['BAGGAGE']) ? $OriginSegments['ssrInfo']['BAGGAGE'] : '';
					$MEAL = isset($OriginSegments['ssrInfo']['MEAL']) ? $OriginSegments['ssrInfo']['MEAL'] : '';
					$strSourceAirportCodeSSR = $OriginSegments['da']['code'];
					$strDestinationAirportCodeSSR = $OriginSegments['aa']['code'];
					if ($BAGGAGE) {
						foreach ($BAGGAGE as $b => $bag) {
							$Weight = str_replace('Excess Baggage - ', '', $bag['desc']);
							$BaggageArr[$b]['Currency'] = $this->CurrencyTitle;
							$BaggageArr[$b]['key'] = $OriginSegments['id'];
							$BaggageArr[$b]['Code'] = $bag['code'];
							$BaggageArr[$b]['Price'] = isset($bag['amount']) ? $bag['amount'] : 0;
							$BaggageArr[$b]['amount'] = isset($bag['amount']) ? round(($bag['amount'] * $this->CurrencyRate), 2) : 0;
							$BaggageArr[$b]['Weight'] = $Weight;
							$BaggageArr[$b]['origin'] = $strSourceAirportCodeSSR;
							$BaggageArr[$b]['destination'] = $strDestinationAirportCodeSSR;
						}
					}
					if ($MEAL) {
						foreach ($MEAL as $m => $meals) {
							$MealArr[$m]['Currency'] = $this->CurrencyTitle;
							$MealArr[$m]['key'] = $OriginSegments['id'];
							$MealArr[$m]['Code'] = $meals['code'];
							$MealArr[$m]['Price'] = isset($meals['amount']) ? $meals['amount'] : 0;
							$MealArr[$m]['amount'] = isset($meals['amount']) ? round(($meals['amount'] * $this->CurrencyRate), 2) : 0;
							$MealArr[$m]['Description'] = $meals['desc'];
							$MealArr[$m]['origin'] = $strSourceAirportCodeSSR;
							$MealArr[$m]['destination'] = $strDestinationAirportCodeSSR;
						}
					}

					if ($SegmentInformation) {
						foreach ($SegmentInformation as $segments) {
							//echo '<pre>';print_r($segments);
							$duration = $segments['duration'];
							$LAYOVERMinutes = $GroundTime = isset($segments['cT']) ? $segments['cT'] : 0;
							$LAYOVERCity = $LAYOVERCityArr[] = isset($segments['cT']) ? $segments['aa']['city'] : '';
							$FlyingMinutes += ($duration + $LAYOVERMinutes);
							$TotalLAYOVERMinutes += $LAYOVERMinutes;

							$FareClass = $totalPriceList['fd']['ADULT']['cB'];
							$strBaggage = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Checking Baggage
							$strCabinBaggage = $totalPriceList['fd']['ADULT']['bI']['cB']; ////Cabin Baggage
							if (!empty($strCabinBaggage)) {
								$IsBaggage = true;
							} else {
								$IsBaggage = false;
							}

							$AirlineCode = $segments['fD']['aI']['code'];
							$AirlineName = $segments['fD']['aI']['name'];
							$FlightNumber = $segments['fD']['fN'];
							$SegFlightNumber = $AirlineCode . "-" . $FlightNumber;

							$originAirportName = $segments['da']['name'];
							$originAirportCode = $segments['da']['code'];
							$originCityName = $segments['da']['city'];
							$originCountryName = $segments['da']['country'];
							$originDepTime = $segments['dt'];

							$destinationAirportName = $segments['aa']['name'];
							$destinationAirportCode = $segments['aa']['code'];
							$destinationCityName = $segments['aa']['city'];
							$destinationCountryName = $segments['aa']['country'];
							$destinationArrTime = $segments['at'];

							$DepTerminal = isset($segments['da']['terminal']) ? $segments['da']['terminal'] : '';
							$ArrTerminal = isset($segments['aa']['terminal']) ? $segments['aa']['terminal'] : '';

							$filePath = $this->getflightlogo($AirlineCode);

							$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->MinutesToHours($LAYOVERMinutes);

							$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($destinationArrTime);
							$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($originDepTime);
							$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($duration);
							$arrSegments[] = array(
								"segmentid" => $segments['id'],
								"originAirportName" => $originAirportName,
								"destinationAirportName" => $destinationAirportName,
								"originCityName" => $originCityName,
								"originCountryName" => $originCountryName,
								"destinationCityName" => $destinationCityName,
								"destinationCountryName" => $destinationCountryName,
								"destinationAirportCode" => $destinationAirportCode,
								"destinationAirportCode" => $destinationAirportCode,
								"destinationArrTime" => $destinationArrTime,
								"SegFlightNumber" => $SegFlightNumber,
								"AirlineCode" => $AirlineCode,
								"AirlineName" => $AirlineName,
								"FareClass" => $FareClass,
								"originAirportCode" => $originAirportCode,
								"originDepTime" => $originDepTime,
								"TripIndicator" => '', //$TripIndicator,
								"Baggage" => $strBaggage,
								"CabinBaggage" => $strCabinBaggage,
								"IsBaggage" => $IsBaggage,
								"IsMealIncludes" => $IsMealIncludes,
								//"SegmentIndicator" => $SegmentIndicator,
								"Duration" => $duration,
								"GroundTime" => $GroundTime,
								"NoOfSeatAvailable" => $NoOfSeatAvailable,
								"strDepartureDtTime" => $strDepartureDtTime,
								"strArrivalDtTime" => $strArrivalDtTime,
								"FlightDuration" => $strDuration,
								"LAYOVERDuration" => $LAYOVERDuration,
								"LAYOVERCity" => $LAYOVERCity,
								"DepTerminal" => $DepTerminal,
								"ArrTerminal" => $ArrTerminal,
								"filePath" => $filePath,
							);
							//echo '<pre>';print_r($arrSegments);
						}
					}
					$flightSSRDetails = new Zend_Session_Namespace('flightSSRDetails');
					$flightSSRDetails->params['Baggage'] = $BaggageArr;
					$flightSSRDetails->params['Meal'] = $MealArr;
					
					$LAYOVERTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->MinutesToHours($TotalLAYOVERMinutes);

					$AirlineCode = $OriginSegments['fD']['aI']['code'];
					$FlightNumber = $OriginSegments['fD']['fN'];
					$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
					$strAirlineName = $OriginSegments['fD']['aI']['name'];
					$IsLCC = $OriginSegments['fD']['aI']['isLcc'];
					$strSourceAirportCode = $OriginSegments['da']['code'];
					$strDestinationAirportCode = $DestinationSegments['aa']['code'];

					$NewPrice = $this->TJPrice($result, $AdditionalMarkup, $getMarkup, $sessionFlightSearchParams->params, $AirlineCode);
					$Stops = $DestinationSegments['sN'];
					if ($Stops == 0) {
						$StopCountTxt = "Non-stop";
					} else {
						$StopCountTxt = $Stops . " Stop(s)";
					}
					$filePath = $this->getflightlogo($AirlineCode);
					$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->CalculateHoursMinutes($OriginSegments['dt'], $DestinationSegments['at']);
					$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($DestinationSegments['at']);
					$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($OriginSegments['dt']);
					$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
					$arrInsertFlightData[$key]['bookingId'] = $bookingId;
					$arrInsertFlightData[$key]['bookingId_TJ'] = $bookingId_TJ;
					$arrInsertFlightData[$key]['FlightNumber'] = $strFlightNumber;
					$arrInsertFlightData[$key]['AirlineName'] = $strAirlineName;
					$arrInsertFlightData[$key]['AirlineCode'] = $AirlineCode;
					$arrInsertFlightData[$key]['AirInvenSysId'] = 0;
					$arrInsertFlightData[$key]['IsLCC'] = $IsLCC;
					$arrInsertFlightData[$key]['IsMealIncludes'] = $IsMealIncludes;
					$arrInsertFlightData[$key]['IsBagIncludes'] = $IsBagIncludes;
					$arrInsertFlightData[$key]['IsRefundable'] = $IsRefundable;
					$arrInsertFlightData[$key]['IsRefundableTxt'] = $IsRefundableTxt;
					$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
					$arrInsertFlightData[$key]['AirlineSysId'] = $airlineSysId;
					$arrInsertFlightData[$key]['DepartureTime'] = $strDepartureDtTime;
					$arrInsertFlightData[$key]['ArrivalTime'] = $strArrivalDtTime;
					$arrInsertFlightData[$key]['TravelDate'] = $OriginSegments['dt'];
					$arrInsertFlightData[$key]['LocalFromTime'] = str_replace('T', ' ', $OriginSegments['dt']);
					$arrInsertFlightData[$key]['FromUTCTime'] = $OriginSegments['dt'];
					$arrInsertFlightData[$key]['LocalToTime'] = str_replace('T', ' ', $DestinationSegments['at']);
					$arrInsertFlightData[$key]['ToUTCTime'] = $DestinationSegments['at'];
					$arrInsertFlightData[$key]['IsDirect'] = 0;
					$arrInsertFlightData[$key]['FareClass'] = $strFareClass;
					$arrInsertFlightData[$key]['LAYOVERCity'] = isset($LAYOVERCityArr[0]) ? $LAYOVERCityArr[0] : '';
					$arrInsertFlightData[$key]['GroundTime'] = $TotalLAYOVERMinutes;
					$arrInsertFlightData[$key]['LAYOVERDuration'] = $LAYOVERTime;
					$arrInsertFlightData[$key]['FlyingMinutes'] = $FlyingMinutes;
					$arrInsertFlightData[$key]['DepartureDateTxt'] = date('D, d M', strtotime($OriginSegments['dt']));
					$arrInsertFlightData[$key]['ArrivalDateTxt'] = date('D, d M', strtotime($DestinationSegments['at']));
					$arrInsertFlightData[$key]['FlightDuration'] = $FlightDuration;
					$arrInsertFlightData[$key]['SourcePlaceSysId'] = $intSourceCityId;
					$arrInsertFlightData[$key]['DestPlaceSysId'] = $intDestinationCityId;
					$arrInsertFlightData[$key]['SourceAirportCode'] = $strSourceAirportCode;
					$arrInsertFlightData[$key]['DestAirportCode'] = $strDestinationAirportCode;
					//                $arrInsertFlightData[$key]['AirportHaultMinutes'] = $AirportHaultMinutes;
					$arrInsertFlightData[$key]['StopCount'] = $StopCountTxt;
					$arrInsertFlightData[$key]['Stops'] = $Stops;
					$arrInsertFlightData[$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
					$arrInsertFlightData[$key]['TotalFlightMembers'] = $intMemberCount;
					$arrInsertFlightData[$key]['CurrencyType'] = $this->CurrencyId;
					$arrInsertFlightData[$key]['PublishedFare'] = $PublishedFare; // As Discussed with GG
					$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format($PublishedFare); // As Discussed with GG
					//                $arrInsertFlightData[$key]['CommissionEarned'] = $CommissionEarned;
					$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
					$arrInsertFlightData[$key]['JourneyType'] = $intJourneyType;
					$arrInsertFlightData[$key]['TripType'] = $intTripType;
					$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
					$arrInsertFlightData[$key]['logo'] = $filePath;
					$arrInsertFlightData[$key]['FareRuleDetails'] = $FareRuleDetails;
					$arrInsertFlightData[$key]['FairRules'] = $FairRulesArr;
					$arrInsertFlightData[$key]['NewPrice'] = $NewPrice;
					$arrInsertFlightData[$key]['Segments'] = $arrSegments;
					$arrInsertFlightData[$key]['Baggage'] = $BaggageArr;
					$arrInsertFlightData[$key]['Meal'] = $MealArr;
					$arrInsertFlightData[$key]['isGSTMandatory'] = $isGSTMandatory;
					$arrInsertFlightData[$key]['SearchFlightTraceId'] = $SearchFlightTraceId;
					$arrInsertFlightData[$key]['ICSourceSysId'] = 7;
					$arrInsertFlightData[$key]['IsPassMandatory'] = $IsPassMandatory;
					$arrInsertFlightData[$key]['IsPassExpiry'] = $IsPassExpiry;
					$arrInsertFlightData[$key]['IsPassIssue'] = $IsPassIssue;
					$arrInsertFlightData[$key]['IsPassDateOfBirth'] = $IsPassDateOfBirth;
					$arrInsertFlightData[$key]['isGSTMandatory'] = $isGSTMandatory;
					$arrInsertFlightData[$key]['estimetedTime'] = $estimetedTime;
					$arrInsertFlightData[$key]['isDobAdult'] = $isDobAdult;
					$arrInsertFlightData[$key]['isDobChild'] = $isDobChild;
					$arrInsertFlightData[$key]['isDobInfant'] = $isDobInfant;
					$arrInsertFlightData[$key]['isSeatAppli'] = $isSeatAppli;
					$arrInsertFlightData[$key]['strTraceId'] = $strTraceId;


					$arrInsertFlightData[$key]['arrCommonInsVariables'] = $arrCommonInsVariables;
					$arrAirlineName[] = $AirlineCode . '-' . $strAirlineName;
					$AttPriceRange[] = $PublishedFare;
					$FiltStopCount[] = $StopCountTxt;
					$arrInsertFlightData[$key]['FilterPrice'] = ''; //$FilterPrice;
				}
				$Segments = [];
				if ($totalPriceListArr) {
					foreach ($totalPriceListArr as $kp => $price) {
						//echo"<pre>";print_r($price);die;
						$fareDetail = $price['fd'];
						$alertsFare = isset($alerts[$kp]) ? $alerts[$kp] : [];
						$newFare = isset($alertsFare['newFare']) ? $alertsFare['newFare'] : 0;
						$oldFare = isset($alertsFare['oldFare']) ? $alertsFare['oldFare'] : 0;
						//echo '<pre>';print_r(($fareDetail));echo '</pre>';
						$Refundable = $fareDetail['ADULT']['rT'];
						$PriceID = $price['id'];
						$fareIdentifier = $price['fareIdentifier'];
						$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
						$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']) ? $AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'] : 0;
						$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);
						if ($fareIdentifier == 'SME') {
							$IsGSTRequired = true;
						} else {
							$IsGSTRequired = false;
						}
						if ($Refundable == 0) {
							$IsRefundableTxt = 'Non Refundable';
						} elseif ($Refundable == 1) {
							$IsRefundableTxt = 'Refundable';
						} else {
							$IsRefundableTxt = 'Partial Refundable';
						}
						$ADULT = $fareDetail['ADULT']['fC']; //fare Components
						$CHILD = isset($fareDetail['CHILD']['fC']) ? $fareDetail['CHILD']['fC'] : []; //fare Components
						$INFANT = isset($fareDetail['INFANT']['fC']) ? $fareDetail['INFANT']['fC'] : []; //fare Components
						if (!empty($ADULT)) {
							$PaxTypeCount = 1;
						}
						if (!empty($CHILD)) {
							$PaxTypeCount = 2;
						}
						if (!empty($INFANT)) {
							$PaxTypeCount = 3;
						}
						$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
						$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
						$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents

						$ADULTNCMTDS = isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
						$CHILDNCMTDS = isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
						$INFANTNCMTDS = isset($fareDetail['INFANT']['afC']['NCM']['TDS']) ? $fareDetail['INFANT']['afC']['NCM']['TDS'] : 0; //TDS

						$ADULTNCMTOT = isset($fareDetail['ADULT']['afC']['NCM']['OT']) ? $fareDetail['ADULT']['afC']['NCM']['OT'] : 0; //- Gross Commission
						$CHILDNCMTOT = isset($fareDetail['CHILD']['afC']['NCM']['OT']) ? $fareDetail['CHILD']['afC']['NCM']['OT'] : 0; //- Gross Commission
						$INFANTNCMTOT = isset($fareDetail['INFANT']['afC']['NCM']['OT']) ? $fareDetail['INFANT']['afC']['NCM']['OT'] : 0; //- Gross Commission

						$AD_MF = isset($ADULTafC['MF']) ? $ADULTafC['MF'] : 0; //Management Fee
						$AD_YQ = isset($ADULTafC['YQ']) ? $ADULTafC['YQ'] : 0; //Fuel Surcharge
						$AD_AGST = isset($ADULTafC['AGST']) ? $ADULTafC['AGST'] : 0; //Airline GST Component
						$AD_MFT = isset($ADULTafC['MFT']) ? $ADULTafC['MFT'] : 0; //Management Fee Tax
						$AD_OT = isset($ADULTafC['OT']) ? $ADULTafC['OT'] : 0; //Other Charges
						$AD_MU = isset($ADULTafC['MU']) ? $ADULTafC['MU'] : 0; //markup
						$AD_YR = isset($ADULTafC['YR']) ? $ADULTafC['YR'] : 0; //Carrier Misc Fee

						$CH_MF = isset($CHILDafC['MF']) ? $CHILDafC['MF'] : 0; //Management Fee
						$CH_YQ = isset($CHILDafC['YQ']) ? $CHILDafC['YQ'] : 0; //Fuel Surcharge
						$CH_AGST = isset($CHILDafC['AGST']) ? $CHILDafC['AGST'] : 0; //Airline GST Component
						$CH_MFT = isset($CHILDafC['MFT']) ? $CHILDafC['MFT'] : 0; //Management Fee Tax
						$CH_OT = isset($CHILDafC['OT']) ? $CHILDafC['OT'] : 0; //Other Charges
						$CH_MU = isset($CHILDafC['MU']) ? $CHILDafC['MU'] : 0; //markup
						$CH_YR = isset($CHILDafC['YR']) ? $CHILDafC['YR'] : 0; //Carrier Misc Fee

						$IN_MF = isset($INFANTafC['MF']) ? $INFANTafC['MF'] : 0; //Management Fee
						$IN_YQ = isset($INFANTafC['YQ']) ? $INFANTafC['YQ'] : 0; //Fuel Surcharge
						$IN_AGST = isset($INFANTafC['AGST']) ? $INFANTafC['AGST'] : 0; //Airline GST Component
						$IN_MFT = isset($INFANTafC['MFT']) ? $INFANTafC['MFT'] : 0; //Management Fee Tax
						$IN_OT = isset($INFANTafC['OT']) ? $INFANTafC['OT'] : 0; //Other Charges
						$IN_MU = isset($INFANTafC['MU']) ? $INFANTafC['MU'] : 0; //markup
						$IN_YR = isset($INFANTafC['YR']) ? $INFANTafC['YR'] : 0; //Carrier Misc Fee

						if ($kp == 0) {
							$PublishedFare += (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
							$BaseFare += (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
							$Tax += (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
						}

						$PublishedFareIN = (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
						$BaseFareIN = (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
						$TaxIN = (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
						$NetFare = (($ADULT['NF'] * $adultCount) + ($CHILD['NF'] * $childCount) + ($INFANT['NF'] * $infantCount)); //Taxes and Fees
						$NetCommission = (($ADULT['NCM'] * $adultCount) + ($CHILD['NCM'] * $childCount) + ($INFANT['NCM'] * $infantCount)); //Taxes and Fees
						//echo '<pre>';print_r(($ADULTafC));echo '</pre>';
						$YQTax = (($AD_YQ * $adultCount) + ($CH_YQ * $childCount) + ($IN_YQ * $infantCount));
						$OtherCharges = (($AD_OT * $adultCount) + ($CH_OT * $childCount) + ($IN_OT * $infantCount));
						$ServiceFee = (($AD_MF * $adultCount) + ($CH_MF * $childCount) + ($IN_MF * $infantCount));
						$ManagementFeeTax = (($AD_MFT * $adultCount) + ($CH_MFT * $childCount) + ($IN_MFT * $infantCount));
						$AirlineGSTComponent = (($AD_AGST * $adultCount) + ($CH_AGST * $childCount) + ($IN_AGST * $infantCount));
						$CarrierMiscFee = (($AD_YR * $adultCount) + ($CH_YR * $childCount) + ($IN_YR * $infantCount));
						$MUFee = (($AD_MU * $adultCount) + ($CH_MU * $childCount) + ($IN_MU * $infantCount));
						$TdsOnPLB = (($ADULTNCMTDS * $adultCount) + ($CHILDNCMTDS * $childCount) + ($INFANTNCMTDS * $infantCount));
						//$NetCommission = (($ADULTNCMTOT * $adultCount) + ($CHILDNCMTOT * $childCount) + ($INFANTNCMTOT * $infantCount));

						//$PublishedFareIN = $NetFare;
						$PublishedFare = $PublishedFareIN;
						$CommissionEarned = $NetCommission;
						$PLBEarned = 0; //$result['Fare']['PLBEarned'];
						$IncentiveEarned = 0; //$result['Fare']['IncentiveEarned'];
						$OfferedFare = $PublishedFareIN;
						$markUpArr = array(
							'getMarkup' => $getMarkup,
							'PublishedFare' => $PublishedFare,
							'OfferedFare' => $NetFare,
							'intCommissionEarned' => $CommissionEarned,
							'TdsOnPLB' => $TdsOnPLB,
							'MUFee' => $MUFee,
							'intPLBEarned' => $PLBEarned,
							'intIncentiveEarned' => $IncentiveEarned,
							'intMemberCount' => $intMemberCount,
							'intFlightRoute' => $strFlightRoute,
							'interNationalSearch' => $interNationalSearch,
							'AddMarkup' => $AddMarkup,
						);

						$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr, 1);
						$arrMarkUpsArray[] = $arrMarkUps;
						// if ($this->gtxagencysysid == '2656') {
						// 	echo '<pre>';print_r(($arrMarkUps));echo '</pre>';
						// }
						$markUpArrBR = array(
							'getMarkup' => $getMarkup,
							'PublishedFare' => ($ADULT['TF'] * $adultCount),
							'OfferedFare' => ($ADULT['NF'] * $adultCount),
							'intCommissionEarned' => ($ADULT['NCM'] * $adultCount),
							'TdsOnPLB' => ($ADULTNCMTDS * $adultCount),
							'MUFee' => ($AD_MU * $adultCount),
							'intPLBEarned' => $PLBEarned,
							'intIncentiveEarned' => $IncentiveEarned,
							'intMemberCount' => $adultCount,
							'intFlightRoute' => $strFlightRoute,
							'interNationalSearch' => $interNationalSearch,
							'AddMarkup' => $AddMarkup,
						);
						$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR, 1);

						$FareBreakdown[0]['Currency'] = $this->CurrencyTitle;
						$FareBreakdown[0]['PassengerType'] = 1;
						$FareBreakdown[0]['PassengerCount'] = $adultCount;
						$FareBreakdown[0]['TaxIN'] += ($ADULT['TAF'] * $adultCount);
						$FareBreakdown[0]['BaseFareCal'] += ($arrMarkUpsBR['BaseFareCal']);
						$FareBreakdown[0]['BaseFare'] += ($ADULT['BF'] * $adultCount);
						$FareBreakdown[0]['CommissionEarned'] += ($ADULT['NCM'] * $adultCount);
						$FareBreakdown[0]['TDS'] += ($ADULTNCMTDS * $adultCount);
						$FareBreakdown[0]['MF'] += ($AD_MF * $adultCount);
						$FareBreakdown[0]['YQ'] += ($AD_YQ * $adultCount);
						$FareBreakdown[0]['AGST'] += ($AD_AGST * $adultCount);
						$FareBreakdown[0]['MFT'] += ($AD_MFT * $adultCount);
						$FareBreakdown[0]['OT'] += ($AD_OT * $adultCount);
						$FareBreakdown[0]['MU'] += ($AD_MU * $adultCount);
						$FareBreakdown[0]['YR'] += ($AD_YR * $adultCount);
						$FareBreakdown[0]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
						$FareBreakdown[0]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
						$FareBreakdown[0]['intTotalGST'] += $arrMarkUpsBR['intTotalGST'];
						$FareBreakdown[0]['apiMarkup'] += $arrMarkUpsBR['apiMarkup'];
						$FareBreakdown[0]['IntCommission'] += $arrMarkUpsBR['IntCommission'];
						$FareBreakdown[0]['apiTaxOnMarkup'] += $arrMarkUpsBR['apiTaxOnMarkup'];
						$FareBreakdown[0]['FixedMarkUp'] += $arrMarkUpsBR['IntAgencyFixMarkUp'];
						$FareBreakdown[0]['GSTOnMarkUp'] += $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
						$FareBreakdown[0]['CommEarned'] += $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
						$FareBreakdown[0]['GSTonComm'] += 0;
						$FareBreakdown[0]['intGTXMarkUp'] += $arrMarkUpsBR['intGTXMarkUp'];
						$FareBreakdown[0]['GTXMarkUpGST'] += $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
						$FareBreakdown[0]['AdditionalTxnFeeOfrd'] = 0;
						$FareBreakdown[0]['AdditionalTxnFeePub'] = 0;
						$FareBreakdown[0]['PGCharge'] = 0;
						$FareBreakdown[0]['Baggage'] = isset($fareDetail['ADULT']['bI']['iB']) ? $fareDetail['ADULT']['bI']['iB'] : []; //Check In Baggage;
						$FareBreakdown[0]['CabinBaggage'] = isset($fareDetail['ADULT']['bI']['cB']) ? $fareDetail['ADULT']['bI']['cB'] : []; //Cabin Baggage ;
						if (isset($fareDetail['CHILD'])) {
							$markUpArrBR = array(
								'getMarkup' => $getMarkup,
								'PublishedFare' => ($CHILD['TF'] * $childCount),
								'OfferedFare' => ($CHILD['NF'] * $childCount),
								'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
								'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
								'MUFee' => ($CH_MU * $childCount),
								'intPLBEarned' => $PLBEarned,
								'intIncentiveEarned' => $IncentiveEarned,
								'intMemberCount' => $childCount,
								'intFlightRoute' => $strFlightRoute,
								'interNationalSearch' => $interNationalSearch,
								'AddMarkup' => $AddMarkup,
							);
							$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR, 1);
							$FareBreakdown[1]['Currency'] = $this->CurrencyTitle;
							$FareBreakdown[1]['PassengerType'] = 2;
							$FareBreakdown[1]['PassengerCount'] = $childCount;
							$FareBreakdown[1]['TaxIN'] += ($CHILD['TAF'] * $childCount);
							$FareBreakdown[1]['BaseFareCal'] += ($arrMarkUpsBR['BaseFareCal']);
							$FareBreakdown[1]['BaseFare'] += ($CHILD['BF'] * $childCount);
							$FareBreakdown[1]['CommissionEarned'] += ($CHILD['NCM'] * $childCount);
							$FareBreakdown[1]['TDS'] += ($CHILDNCMTDS * $childCount);
							$FareBreakdown[1]['MF'] += ($CH_MF * $childCount);
							$FareBreakdown[1]['YQ'] += ($CH_YQ * $childCount);
							$FareBreakdown[1]['AGST'] += ($CH_AGST * $childCount);
							$FareBreakdown[1]['MFT'] += ($CH_MFT * $childCount);
							$FareBreakdown[1]['OT'] += ($CH_OT * $childCount);
							$FareBreakdown[1]['MU'] += ($CH_MU * $childCount);
							$FareBreakdown[1]['YR'] += ($CH_YR * $childCount);
							$FareBreakdown[1]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
							$FareBreakdown[1]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
							$FareBreakdown[1]['intTotalGST'] += $arrMarkUpsBR['intTotalGST'];
							$FareBreakdown[1]['apiMarkup'] += $arrMarkUpsBR['apiMarkup'];
							$FareBreakdown[1]['IntCommission'] += $arrMarkUpsBR['IntCommission'];
							$FareBreakdown[1]['apiTaxOnMarkup'] += $arrMarkUpsBR['apiTaxOnMarkup'];
							$FareBreakdown[1]['FixedMarkUp'] += $arrMarkUpsBR['IntAgencyFixMarkUp'];
							$FareBreakdown[1]['GSTOnMarkUp'] += $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
							$FareBreakdown[1]['CommEarned'] += $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
							$FareBreakdown[1]['GSTonComm'] += 0;
							$FareBreakdown[1]['intGTXMarkUp'] += $arrMarkUpsBR['intGTXMarkUp'];
							$FareBreakdown[1]['GTXMarkUpGST'] += $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
							$FareBreakdown[1]['AdditionalTxnFeeOfrd'] = 0;
							$FareBreakdown[1]['AdditionalTxnFeePub'] = 0;
							$FareBreakdown[1]['PGCharge'] = 0;
							$FareBreakdown[1]['Baggage'] = isset($fareDetail['CHILD']['bI']['iB']) ? $fareDetail['CHILD']['bI']['iB'] : []; //Check In Baggage;
							$FareBreakdown[1]['CabinBaggage'] = isset($fareDetail['CHILD']['bI']['cB']) ? $fareDetail['CHILD']['bI']['cB'] : []; //Cabin Baggage ;
						}
						if (isset($fareDetail['INFANT'])) {
							$markUpArrBR = array(
								'getMarkup' => $getMarkup,
								'PublishedFare' => ($INFANT['TF'] * $infantCount),
								'OfferedFare' => ($INFANT['NF'] * $infantCount),
								'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
								'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
								'MUFee' => ($IN_MU * $infantCount),
								'intPLBEarned' => $PLBEarned,
								'intIncentiveEarned' => $IncentiveEarned,
								'intMemberCount' => $infantCount,
								'intFlightRoute' => $strFlightRoute,
								'interNationalSearch' => $interNationalSearch,
								'AddMarkup' => $AddMarkup,
							);
							$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR, 1);
							$FareBreakdown[2]['Currency'] = $this->CurrencyTitle;
							$FareBreakdown[2]['PassengerType'] = 3;
							$FareBreakdown[2]['PassengerCount'] = $infantCount;
							$FareBreakdown[2]['TaxIN'] += ($INFANT['TAF'] * $infantCount);
							$FareBreakdown[2]['BaseFareCal'] += ($arrMarkUpsBR['BaseFareCal']);
							$FareBreakdown[2]['BaseFare'] += ($INFANT['BF'] * $infantCount);
							$FareBreakdown[2]['CommissionEarned'] += ($INFANT['NCM'] * $infantCount);
							$FareBreakdown[2]['TDS'] += ($INFANTNCMTDS * $infantCount);
							$FareBreakdown[2]['MF'] += ($IN_MF * $infantCount);
							$FareBreakdown[2]['YQ'] += ($IN_YQ * $infantCount);
							$FareBreakdown[2]['AGST'] += ($IN_AGST * $infantCount);
							$FareBreakdown[2]['OT'] += ($IN_OT * $infantCount);
							$FareBreakdown[2]['MFT'] += ($IN_MFT * $infantCount);
							$FareBreakdown[2]['MU'] += ($IN_MU * $infantCount);
							$FareBreakdown[2]['YR'] += ($IN_YR * $infantCount);
							$FareBreakdown[2]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
							$FareBreakdown[2]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
							$FareBreakdown[2]['intTotalGST'] += $arrMarkUpsBR['intTotalGST'];
							$FareBreakdown[2]['apiMarkup'] += $arrMarkUpsBR['apiMarkup'];
							$FareBreakdown[2]['IntCommission'] += $arrMarkUpsBR['IntCommission'];
							$FareBreakdown[2]['apiTaxOnMarkup'] += $arrMarkUpsBR['apiTaxOnMarkup'];
							$FareBreakdown[2]['FixedMarkUp'] += $arrMarkUpsBR['IntAgencyFixMarkUp'];
							$FareBreakdown[2]['GSTOnMarkUp'] += $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
							$FareBreakdown[2]['CommEarned'] += $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
							$FareBreakdown[2]['GSTonComm'] += 0;
							$FareBreakdown[2]['intGTXMarkUp'] += $arrMarkUpsBR['intGTXMarkUp'];
							$FareBreakdown[2]['GTXMarkUpGST'] += $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
							$FareBreakdown[2]['AdditionalTxnFeeOfrd'] += 0;
							$FareBreakdown[2]['AdditionalTxnFeePub'] += 0;
							$FareBreakdown[2]['PGCharge'] += 0;
							$FareBreakdown[2]['Baggage'] = isset($fareDetail['INFANT']['bI']['iB']) ? $fareDetail['INFANT']['bI']['iB'] : []; //Check In Baggage;
							$FareBreakdown[2]['CabinBaggage'] = isset($fareDetail['INFANT']['bI']['cB']) ? $fareDetail['INFANT']['bI']['cB'] : []; //Cabin Baggage ;
						}

						$PublishedFareINT += ($arrMarkUps['PublishFare'] * $this->CurrencyRate);
						$OfferedFare += $arrMarkUps['intOfferedFare'];
						$intTotalGST += $arrMarkUps['intTotalGST'];
						$apiMarkup += $arrMarkUps['apiMarkup'];
						$IntCommission += $arrMarkUps['IntCommission'];
						$CommisionPass += $arrMarkUps['CommisionPass'];
						$apiTaxOnMarkup += $arrMarkUps['apiTaxOnMarkup'];
						$IntAgencyFixMarkUp += $arrMarkUps['IntAgencyFixMarkUp'];
						$IntTaxOnAgencyFixMarkUp += $arrMarkUps['IntTaxOnAgencyFixMarkUp'];
						$intCommisionEarnedForAgency += $arrMarkUps['intCommisionEarnedForAgency'];
						$intGTXMarkUp += $arrMarkUps['intGTXMarkUp'];
						$intSTaxOnGTXMarkUp += $arrMarkUps['intSTaxOnGTXMarkUp'];
						$AddiTaxOnMarkup += $arrMarkUps['AddiTaxOnMarkup'];
						$AddiMarkup += $arrMarkUps['AddiMarkup'];
						$intTdsOnPLB += $TdsOnPLB;
						$intCommissionEarned += $CommissionEarned;
						$intPublishedFare += $PublishedFareIN;
						$intMUFee += $MUFee;
						$intCarrierMiscFee += $CarrierMiscFee;
						$intAirlineGSTComponent += $AirlineGSTComponent;
						$intManagementFeeTax += $ManagementFeeTax;
						$intServiceFee += $ServiceFee;
						$intOtherCharges += $OtherCharges;
						$intYQTax += $YQTax;
						$intTaxIN += $TaxIN;
						$intBaseFareIN += $BaseFareIN;
						$intnewFare += $newFare;
						$intoldFare += $oldFare;
						$seg = $arrInsertFlightData[$kp]['Segments'];
						//echo '<pre>';print_r($seg);echo '</pre>';
						$Segments[] = $seg;
					}

					$FairRulesArr = array(
						"Currency" => $this->CurrencyTitle, //$Currency,
						"CurrencyRate" => $this->CurrencyRate, //$Currency,
						"currencySysId" => $this->CurrencyId,
						"BaseFare" => $intBaseFareIN,
						"Tax" => $intTaxIN,
						"YQTax" => $intYQTax,
						"OtherCharges" => $intOtherCharges,
						"Discount" => 0, //$Discount,
						"ServiceFee" => $intServiceFee,
						"ManagementFeeTax" => $intManagementFeeTax,
						"AirlineGSTComponent" => $intAirlineGSTComponent,
						"CarrierMiscFee" => $intCarrierMiscFee,
						"MUFee" => $intMUFee,
						"intPublishedFare" => $intPublishedFare,
						"PublishedFare" => ($PublishedFareINT),
						"OfferedFare" => $OfferedFare,
						"CommissionEarned" => $intCommissionEarned,
						"CommisionPass" => $CommisionPass,
						"PLBEarned" => $PLBEarned,
						"IncentiveEarned" => $IncentiveEarned,
						"TdsOnPLB" => $intTdsOnPLB,
						"TdsOnIncentive" => 0,
						"AdditionalTxnFeeOfrd" => 0,
						"AdditionalTxnFeePub" => 0,
						"Refundable" => $Refundable,
						"IsRefundableTxt" => $IsRefundableTxt,
						"PriceID" => $PriceID,
						"IsGSTRequired" => $IsGSTRequired,
						"isDobAdult" => $isDobAdult,
						"isDobChild" => $isDobChild,
						"isDobInfant" => $isDobInfant,
						"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
						"FareClass" => $fareDetail['ADULT']['cc'],
						"AddiMarkup" => $AddiMarkup,
						"AddiTaxOnMarkup" => $AddiTaxOnMarkup,
						"intTotalGST" => $intTotalGST,
						"apiMarkup" => $apiMarkup,
						"IntCommission" => $IntCommission,
						"apiTaxOnMarkup" => $apiTaxOnMarkup,
						"FixedMarkUp" => $IntAgencyFixMarkUp,
						"GSTOnMarkUp" => $IntTaxOnAgencyFixMarkUp,
						"CommEarned" => $IntCommission, //$intCommisionEarnedForAgency,
						"GSTonComm" => 0,
						"intGTXMarkUp" => $intGTXMarkUp,
						"GTXMarkUpGST" => $intSTaxOnGTXMarkUp,
						"CancelCharge" => $getCancelCharge,
						"newFare" => $intnewFare,
						"oldFare" => $intoldFare,
						"Baggage" => isset($fareDetail['ADULT']['bI']['iB']) ? $fareDetail['ADULT']['bI']['iB'] : [],
						"CabinBaggage" => isset($fareDetail['ADULT']['bI']['cB']) ? $fareDetail['ADULT']['bI']['cB'] : [],
						"FareBreakdown" => $FareBreakdown,
						"TaxSettingDetail" => $arrMarkUps['TaxSettingDetail'],
					);
				}
			}


			$arrInsertFlightData[0]['FairRules'] = $FairRulesArr;
			$arrInsertFlightDataInt['bookingId'] = $arrInsertFlightData[0]['bookingId'];
			$arrInsertFlightDataInt['bookingId_TJ'] = $arrInsertFlightData[0]['bookingId_TJ'];
			$arrInsertFlightDataInt['FlightNumber'] = $arrInsertFlightData[0]['FlightNumber'];
			$arrInsertFlightDataInt['AirlineName'] = $arrInsertFlightData[0]['AirlineName'];
			$arrInsertFlightDataInt['AirlineCode'] = $arrInsertFlightData[0]['AirlineCode'];
			$arrInsertFlightDataInt['AirInvenSysId'] = $arrInsertFlightData[0]['AirInvenSysId'];
			$arrInsertFlightDataInt['IsLCC'] = $arrInsertFlightData[0]['IsLCC'];
			$arrInsertFlightDataInt['IsMealIncludes'] = $arrInsertFlightData[0]['IsMealIncludes'];
			$arrInsertFlightDataInt['IsBagIncludes'] = $arrInsertFlightData[0]['IsBagIncludes'];
			$arrInsertFlightDataInt['IsRefundable'] = $arrInsertFlightData[0]['IsRefundable'];
			$arrInsertFlightDataInt['IsRefundableTxt'] = $arrInsertFlightData[0]['IsRefundableTxt'];
			$arrInsertFlightDataInt['apiTraceId'] = $arrInsertFlightData[0]['apiTraceId'];
			$arrInsertFlightDataInt['strTraceId'] = $arrInsertFlightData[0]['apiTraceId'];
			$arrInsertFlightDataInt['AirlineSysId'] = $arrInsertFlightData[0]['AirlineSysId'];
			$arrInsertFlightDataInt['DepartureTime'] = $arrInsertFlightData[0]['DepartureTime'];
			$arrInsertFlightDataInt['ArrivalTime'] = $arrInsertFlightData[0]['ArrivalTime'];
			$arrInsertFlightDataInt['TravelDate'] = $arrInsertFlightData[0]['TravelDate'];
			$arrInsertFlightDataInt['LocalFromTime'] = $arrInsertFlightData[0]['LocalFromTime'];
			$arrInsertFlightDataInt['FromUTCTime'] = $arrInsertFlightData[0]['FromUTCTime'];
			$arrInsertFlightDataInt['LocalToTime'] = $arrInsertFlightData[0]['LocalToTime'];
			$arrInsertFlightDataInt['ToUTCTime'] = $arrInsertFlightData[0]['ToUTCTime'];
			$arrInsertFlightDataInt['IsDirect'] = $arrInsertFlightData[0]['IsDirect'];
			$arrInsertFlightDataInt['FareClass'] = $arrInsertFlightData[0]['FareClass'];
			$arrInsertFlightDataInt['LAYOVERCity'] = $arrInsertFlightData[0]['LAYOVERCity'];
			$arrInsertFlightDataInt['GroundTime'] = $arrInsertFlightData[0]['GroundTime'];
			$arrInsertFlightDataInt['LAYOVERDuration'] = $arrInsertFlightData[0]['LAYOVERDuration'];
			$arrInsertFlightDataInt['FlyingMinutes'] = $arrInsertFlightData[0]['FlyingMinutes'];
			$arrInsertFlightDataInt['DepartureDateTxt'] = $arrInsertFlightData[0]['DepartureDateTxt'];
			$arrInsertFlightDataInt['ArrivalDateTxt'] = $arrInsertFlightData[0]['ArrivalDateTxt'];
			$arrInsertFlightDataInt['FlightDuration'] = $arrInsertFlightData[0]['FlightDuration'];
			$arrInsertFlightDataInt['SourcePlaceSysId'] = $arrInsertFlightData[0]['SourcePlaceSysId'];
			$arrInsertFlightDataInt['DestPlaceSysId'] = $arrInsertFlightData[0]['DestPlaceSysId'];
			$arrInsertFlightDataInt['SourceAirportCode'] = $arrInsertFlightData[0]['SourceAirportCode'];
			$arrInsertFlightDataInt['DestAirportCode'] = $arrInsertFlightData[0]['DestAirportCode'];
			$arrInsertFlightDataInt['StopCount'] = $arrInsertFlightData[0]['StopCount'];
			$arrInsertFlightDataInt['Stops'] = $arrInsertFlightData[0]['Stops'];
			$arrInsertFlightDataInt['NoOfSeatAvailable'] = $arrInsertFlightData[0]['NoOfSeatAvailable'];
			$arrInsertFlightDataInt['TotalFlightMembers'] = $arrInsertFlightData[0]['TotalFlightMembers'];
			$arrInsertFlightDataInt['CurrencyType'] = $arrInsertFlightData[0]['CurrencyType'];
			$arrInsertFlightDataInt['PublishedFare'] = $FairRulesArr['PublishedFare'];
			$arrInsertFlightDataInt['ApiResultIndex'] = $arrInsertFlightData[0]['ApiResultIndex'];
			$arrInsertFlightDataInt['JourneyType'] = $arrInsertFlightData[0]['JourneyType'];
			$arrInsertFlightDataInt['TripType'] = $arrInsertFlightData[0]['TripType'];
			$arrInsertFlightDataInt['SearchFlightTraceId'] = $arrInsertFlightData[0]['SearchFlightTraceId'];
			$arrInsertFlightDataInt['ICSourceSysId'] = $arrInsertFlightData[0]['ICSourceSysId'];
			$arrInsertFlightDataInt['IsInternational'] = $arrInsertFlightData[0]['IsInternational'];
			$arrInsertFlightDataInt['logo'] = $arrInsertFlightData[0]['logo'];
			$arrInsertFlightDataInt['FareRuleDetails'] = $FareRuleDetails;
			$arrInsertFlightDataInt['Fare'] = $FairRulesArr;
			$arrInsertFlightDataInt['Segments'] = $Segments;
			$arrCommonInsVariables = array(
				'strTraceId' => $arrInsertFlightData[0]['apiTraceId'],
				'localFromDateTime' => $arrInsertFlightData[0]['LocalFromTime'],
				'localToDateTime' => $arrInsertFlightData[0]['LocalToTime'],
				'strSourceAirportCode' => $strSourceAirportCode,
				'strDestinationAirportCode' => $strDestinationAirportCode,
				'intMemberCount' => $intMemberCount,
				'intSourceCityId' => $intSourceCityId,
				'intDestinationCityId' => $intDestinationCityId,
				'JourneyType' => 2, // For Round Trips API Search
				'TripType' => 1,
				'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0
			);
			$arrInsertFlightDataInt[0]['arrCommonInsVariables'] = $arrCommonInsVariables;
			$arrInsertFlightData[0]['InternationalData'] = $arrInsertFlightDataInt;
			//echo '<pre>';print_r($arrInsertFlightData);
			$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
			$FlightBookingData->params = $arrInsertFlightData;

			return $arrInsertFlightData;
		} else {
			$localFromDateTime = date("Y-m-d h:i", strtotime($strDepatureDate));
			$localToDateTime = date("Y-m-d h:i", strtotime($strReturnDate));
			$arrCommonInsVariables = array(
				'strTraceId' => $strTraceId,
				'localFromDateTime' => $localFromDateTime,
				'localToDateTime' => $localToDateTime,
				'strSourceAirportCode' => $strSourceAirportCode,
				'strDestinationAirportCode' => $strDestinationAirportCode,
				'intMemberCount' => $intMemberCount,
				'intSourceCityId' => $intSourceCityId,
				'intDestinationCityId' => $intDestinationCityId,
				'JourneyType' => 2, // For Round Trips API Search
				'TripType' => $strFlightRoute,
				'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0
			);
			$strTraceId         = $arrCommonInsVariables['strTraceId'];
			$localFromDateTime  = $arrCommonInsVariables['localFromDateTime'];
			$localToDateTime    = $arrCommonInsVariables['localToDateTime'];

			$strSourceAirportCode    = $arrCommonInsVariables['strSourceAirportCode'];
			$strDestinationAirportCode    = $arrCommonInsVariables['strDestinationAirportCode'];
			$intMemberCount    = $arrCommonInsVariables['intMemberCount'];
			$intSourceCityId    = $arrCommonInsVariables['intSourceCityId'];
			$intDestinationCityId    = $arrCommonInsVariables['intDestinationCityId'];
			$intJourneyType    = $arrCommonInsVariables['JourneyType'];
			$intTripType    = $arrCommonInsVariables['TripType'];
			$interNationalSearch    = isset($arrCommonInsVariables['interNationalSearch']) ? $arrCommonInsVariables['interNationalSearch'] : '0';
			$intTripType = $strFlightRoute;
			$arrInsertFlightData = [];
			$BaggageArr = [];
			$MealArr = [];
			///$bookingId = $data['bookingId'];
			$bookingId_TJ = $data['bookingId'];
			$bookingId = str_replace('TJ', 'BKR', $data['bookingId']);
			$alerts = isset($data['alerts']) ? $data['alerts'] : [];
			$isGSTMandatory = isset($data['conditions']['gst']['igm']) ? $data['conditions']['gst']['igm'] : false;
			$IsPassDateOfBirth = isset($data['conditions']['pcs']['dobe']) ? $data['conditions']['pcs']['dobe'] : false;
			if ($IsPassDateOfBirth && $interNationalSearch) {
				$isDobAdult = true;
				$isDobChild = true;
				$isDobInfant = true;
			} else {
				$isDobAdult = isset($data['conditions']['dob']['adobr']) ? $data['conditions']['dob']['adobr'] : false;
				$isDobChild = isset($data['conditions']['dob']['cdobr']) ? $data['conditions']['dob']['cdobr'] : false;
				$isDobInfant = isset($data['conditions']['dob']['idobr']) ? $data['conditions']['dob']['idobr'] : false;
			}
			$isSeatAppli = isset($data['conditions']['isa']) ? $data['conditions']['isa'] : false;
			$estimetedTime = isset($data['conditions']['st']) ? ($data['conditions']['st']) : 0;
			$estimetedTime = floor(($estimetedTime / 60) % 60);
			$estimetedDateTime = isset($data['conditions']['sct']) ? $data['conditions']['sct'] : false;
			$arrInsertFlightBookingData = [];


			if ($data['tripInfos']) {
				foreach ($data['tripInfos'] as $key => $result) {
					if ($key == 0) {
						$intJourneyType = 1;
					} else {
						$intJourneyType = 2;
					}
					$BookingData = $FlightBookingData->params[$key];
					$alertsFare = isset($alerts[$key]) ? $alerts[$key] : [];
					$newFare = isset($alertsFare['newFare']) ? $alertsFare['newFare'] : 0;
					$oldFare = isset($alertsFare['oldFare']) ? $alertsFare['oldFare'] : 0;
					$SegmentInformation = $result['sI'];
					$totalPriceList = current($result['totalPriceList']);
					$IsRefundable = $totalPriceList['fd']['ADULT']['rT'];
					$NoOfSeatAvailable = $totalPriceList['fd']['ADULT']['sR'];
					$strFareClass = $totalPriceList['fd']['ADULT']['cB'];
					$IsMealIncludes = $totalPriceList['fd']['ADULT']['mI'];
					$bagInfo = $totalPriceList['fd']['ADULT']['bI']['iB'];
					$strTraceId = $BookingData['FairRules']['PriceID'];
					$ResultIndex = $BookingData['FairRules']['PriceID'];
					if (!empty($bagInfo)) {
						$IsBagIncludes = true;
					} else {
						$IsBagIncludes = false;
					}
					if ($IsRefundable == 0) {
						$IsRefundableTxt = 'Non Refundable';
					} elseif ($IsRefundable == 1) {
						$IsRefundableTxt = 'Refundable';
					} else {
						$IsRefundableTxt = 'Partial Refundable';
					}
					$OriginSegments = current($SegmentInformation);
					$DestinationSegments = end($SegmentInformation);
					$AirlineCode = $OriginSegments['fD']['aI']['code'];
					$NewPrice = $this->TJPrice($result, $AdditionalMarkup, $getMarkup, $sessionFlightSearchParams->params, $AirlineCode);
					// echo '<pre>';print_r(($NewPrice));echo '</pre>';
					// die;
					$arrSegments = [];
					$FlyingMinutes = 0;
					$TotalLAYOVERMinutes = 0;
					$LAYOVERCityArr = [];
					$PublishedFare = 0;
					$BaseFare = 0;
					$Tax = 0;
					$YQTax = 0;
					$OtherCharges = 0;
					$ServiceFee = 0;

					$FareBreakdown = [];
					$FairRulesArr = [];
					$AirlineCode = $OriginSegments['fD']['aI']['code'];
					array_multisort($result['totalPriceList']);
					if ($result['totalPriceList']) {
						foreach ($result['totalPriceList'] as $kp => $price) {
							$fareDetail = $price['fd'];

							//echo '<pre>';print_r(($fareDetail));echo '</pre>';
							$Refundable = $fareDetail['ADULT']['rT'];
							$PriceID = $price['id'];
							$fareIdentifier = $price['fareIdentifier'];
							$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
							$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']) ? $AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'] : 0;
							//$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);

							// echo "ssss====== <pre>";
							// print_r($fareIdentifier);
							// echo "ssss====== <pre>";
							// print_r($AirlineCode);
							// echo "ssss====== <pre>";
							// print_r($MarkUpValue);
							
							$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);
							// echo "ssss====== <pre>";
							// print_r($AddMarkup);
							// die;
							if ($fareIdentifier == 'SME') {
								$IsGSTRequired = true;
							} else {
								$IsGSTRequired = false;
							}
							if ($Refundable == 0) {
								$IsRefundableTxt = 'Non Refundable';
							} elseif ($Refundable == 1) {
								$IsRefundableTxt = 'Refundable';
							} else {
								$IsRefundableTxt = 'Partial Refundable';
							}
							$ADULT = $fareDetail['ADULT']['fC']; //fare Components
							$CHILD = isset($fareDetail['CHILD']['fC']) ? $fareDetail['CHILD']['fC'] : []; //fare Components
							$INFANT = isset($fareDetail['INFANT']['fC']) ? $fareDetail['INFANT']['fC'] : []; //fare Components
							if (!empty($ADULT)) {
								$PaxTypeCount = 1;
							}
							if (!empty($CHILD)) {
								$PaxTypeCount = 2;
							}
							if (!empty($INFANT)) {
								$PaxTypeCount = 3;
							}
							$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
							$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
							$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents

							$ADULTNCMTDS = isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
							$CHILDNCMTDS = isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
							$INFANTNCMTDS = isset($fareDetail['INFANT']['afC']['NCM']['TDS']) ? $fareDetail['INFANT']['afC']['NCM']['TDS'] : 0; //TDS

							$ADULTNCMTOT = isset($fareDetail['ADULT']['afC']['NCM']['OT']) ? $fareDetail['ADULT']['afC']['NCM']['OT'] : 0; //- Gross Commission
							$CHILDNCMTOT = isset($fareDetail['CHILD']['afC']['NCM']['OT']) ? $fareDetail['CHILD']['afC']['NCM']['OT'] : 0; //- Gross Commission
							$INFANTNCMTOT = isset($fareDetail['INFANT']['afC']['NCM']['OT']) ? $fareDetail['INFANT']['afC']['NCM']['OT'] : 0; //- Gross Commission

							$AD_MF = isset($ADULTafC['MF']) ? $ADULTafC['MF'] : 0; //Management Fee
							$AD_YQ = isset($ADULTafC['YQ']) ? $ADULTafC['YQ'] : 0; //Fuel Surcharge
							$AD_AGST = isset($ADULTafC['AGST']) ? $ADULTafC['AGST'] : 0; //Airline GST Component
							$AD_MFT = isset($ADULTafC['MFT']) ? $ADULTafC['MFT'] : 0; //Management Fee Tax
							$AD_OT = isset($ADULTafC['OT']) ? $ADULTafC['OT'] : 0; //Other Charges
							$AD_MU = isset($ADULTafC['MU']) ? $ADULTafC['MU'] : 0; //markup
							$AD_YR = isset($ADULTafC['YR']) ? $ADULTafC['YR'] : 0; //Carrier Misc Fee

							$CH_MF = isset($CHILDafC['MF']) ? $CHILDafC['MF'] : 0; //Management Fee
							$CH_YQ = isset($CHILDafC['YQ']) ? $CHILDafC['YQ'] : 0; //Fuel Surcharge
							$CH_AGST = isset($CHILDafC['AGST']) ? $CHILDafC['AGST'] : 0; //Airline GST Component
							$CH_MFT = isset($CHILDafC['MFT']) ? $CHILDafC['MFT'] : 0; //Management Fee Tax
							$CH_OT = isset($CHILDafC['OT']) ? $CHILDafC['OT'] : 0; //Other Charges
							$CH_MU = isset($CHILDafC['MU']) ? $CHILDafC['MU'] : 0; //markup
							$CH_YR = isset($CHILDafC['YR']) ? $CHILDafC['YR'] : 0; //Carrier Misc Fee

							$IN_MF = isset($INFANTafC['MF']) ? $INFANTafC['MF'] : 0; //Management Fee
							$IN_YQ = isset($INFANTafC['YQ']) ? $INFANTafC['YQ'] : 0; //Fuel Surcharge
							$IN_AGST = isset($INFANTafC['AGST']) ? $INFANTafC['AGST'] : 0; //Airline GST Component
							$IN_MFT = isset($INFANTafC['MFT']) ? $INFANTafC['MFT'] : 0; //Management Fee Tax
							$IN_OT = isset($INFANTafC['OT']) ? $INFANTafC['OT'] : 0; //Other Charges
							$IN_MU = isset($INFANTafC['MU']) ? $INFANTafC['MU'] : 0; //markup
							$IN_YR = isset($INFANTafC['YR']) ? $INFANTafC['YR'] : 0; //Carrier Misc Fee

							if ($kp == 0) {
								$PublishedFare += (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
								$BaseFare += (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
								$Tax += (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
							}

							$PublishedFareIN = (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
							$BaseFareIN = (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
							$TaxIN = (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
							$NetFare = (($ADULT['NF'] * $adultCount) + ($CHILD['NF'] * $childCount) + ($INFANT['NF'] * $infantCount)); //Taxes and Fees
							$NetCommission = (($ADULT['NCM'] * $adultCount) + ($CHILD['NCM'] * $childCount) + ($INFANT['NCM'] * $infantCount)); //Taxes and Fees
							//echo '<pre>';print_r(($ADULTafC));echo '</pre>';
							$YQTax = (($AD_YQ * $adultCount) + ($CH_YQ * $childCount) + ($IN_YQ * $infantCount));
							$OtherCharges = (($AD_OT * $adultCount) + ($CH_OT * $childCount) + ($IN_OT * $infantCount));
							$ServiceFee = (($AD_MF * $adultCount) + ($CH_MF * $childCount) + ($IN_MF * $infantCount));
							$ManagementFeeTax = (($AD_MFT * $adultCount) + ($CH_MFT * $childCount) + ($IN_MFT * $infantCount));
							$AirlineGSTComponent = (($AD_AGST * $adultCount) + ($CH_AGST * $childCount) + ($IN_AGST * $infantCount));
							$CarrierMiscFee = (($AD_YR * $adultCount) + ($CH_YR * $childCount) + ($IN_YR * $infantCount));
							$MUFee = (($AD_MU * $adultCount) + ($CH_MU * $childCount) + ($IN_MU * $infantCount));
							$TdsOnPLB = (($ADULTNCMTDS * $adultCount) + ($CHILDNCMTDS * $childCount) + ($INFANTNCMTDS * $infantCount));
							//$NetCommission = (($ADULTNCMTOT * $adultCount) + ($CHILDNCMTOT * $childCount) + ($INFANTNCMTOT * $infantCount));

							//$PublishedFareIN = $NetFare;
							$PublishedFare = $PublishedFareIN;
							$CommissionEarned = $NetCommission;
							$PLBEarned = 0; //$result['Fare']['PLBEarned'];
							$IncentiveEarned = 0; //$result['Fare']['IncentiveEarned'];
							$OfferedFare = $PublishedFareIN;
							$markUpArr = array(
								'getMarkup' => $getMarkup,
								'PublishedFare' => $PublishedFare,
								'OfferedFare' => $NetFare,
								'intCommissionEarned' => $CommissionEarned,
								'TdsOnPLB' => $TdsOnPLB,
								'MUFee' => $MUFee,
								'intPLBEarned' => $PLBEarned,
								'intIncentiveEarned' => $IncentiveEarned,
								'intMemberCount' => $intMemberCount,
								'intFlightRoute' => $strFlightRoute,
								'interNationalSearch' => $interNationalSearch,
								'AddMarkup' => $AddMarkup,
							);

							$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr);
							if ($this->gtxagencysysid == '10672') {
								// echo '<pre>';
								// print_r(($arrMarkUps));
								// echo '</pre>';
								// echo '<pre>';
								// print_r(($markUpArr));
								// echo '</pre>';
							}
							$markUpArrBR = array(
								'getMarkup' => $getMarkup,
								'PublishedFare' => ($ADULT['TF'] * $adultCount),
								'OfferedFare' => ($ADULT['NF'] * $adultCount),
								'intCommissionEarned' => ($ADULT['NCM'] * $adultCount),
								'TdsOnPLB' => ($ADULTNCMTDS * $adultCount),
								'MUFee' => ($AD_MU * $adultCount),
								'intPLBEarned' => $PLBEarned,
								'intIncentiveEarned' => $IncentiveEarned,
								'intMemberCount' => $adultCount,
								'intFlightRoute' => $strFlightRoute,
								'interNationalSearch' => $interNationalSearch,
								'AddMarkup' => $AddMarkup,
							);
							$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);

							// echo '<pre>';print_r($arrMarkUpsBR);
							// echo '<pre>';print_r($markUpArrBR);
							// die;
							$FareBreakdown[0]['Currency'] = $this->CurrencyTitle;
							$FareBreakdown[0]['PassengerType'] = 1;
							$FareBreakdown[0]['PassengerCount'] = $adultCount;
							$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $adultCount);
							$FareBreakdown[0]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
							$FareBreakdown[0]['BaseFare'] = ($ADULT['BF'] * $adultCount);
							$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $adultCount);
							$FareBreakdown[0]['TDS'] = ($ADULTNCMTDS * $adultCount);
							$FareBreakdown[0]['MF'] = ($AD_MF * $adultCount);
							$FareBreakdown[0]['YQ'] = ($AD_YQ * $adultCount);
							$FareBreakdown[0]['AGST'] = ($AD_AGST * $adultCount);
							$FareBreakdown[0]['MFT'] = ($AD_MFT * $adultCount);
							$FareBreakdown[0]['OT'] = ($AD_OT * $adultCount);
							$FareBreakdown[0]['MU'] = ($AD_MU * $adultCount);
							$FareBreakdown[0]['YR'] = ($AD_YR * $adultCount);
							$FareBreakdown[0]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
							$FareBreakdown[0]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
							$FareBreakdown[0]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
							$FareBreakdown[0]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
							$FareBreakdown[0]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
							$FareBreakdown[0]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
							$FareBreakdown[0]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
							$FareBreakdown[0]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
							$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
							$FareBreakdown[0]['GSTonComm'] = 0;
							$FareBreakdown[0]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
							$FareBreakdown[0]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
							$FareBreakdown[0]['AdditionalTxnFeeOfrd'] = 0;
							$FareBreakdown[0]['AdditionalTxnFeePub'] = 0;
							$FareBreakdown[0]['PGCharge'] = 0;
							$FareBreakdown[0]['Baggage'] = isset($fareDetail['ADULT']['bI']['iB']) ? $fareDetail['ADULT']['bI']['iB'] : []; //Check In Baggage;
							$FareBreakdown[0]['CabinBaggage'] = isset($fareDetail['ADULT']['bI']['cB']) ? $fareDetail['ADULT']['bI']['cB'] : []; //Cabin Baggage ;
							if (isset($fareDetail['CHILD'])) {
								$markUpArrBR = array(
									'getMarkup' => $getMarkup,
									'PublishedFare' => ($CHILD['TF'] * $childCount),
									'OfferedFare' => ($CHILD['NF'] * $childCount),
									'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
									'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
									'MUFee' => ($CH_MU * $childCount),
									'intPLBEarned' => $PLBEarned,
									'intIncentiveEarned' => $IncentiveEarned,
									'intMemberCount' => $childCount,
									'intFlightRoute' => $strFlightRoute,
									'interNationalSearch' => $interNationalSearch,
									'AddMarkup' => $AddMarkup,
								);
								$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
								$FareBreakdown[1]['Currency'] = $this->CurrencyTitle;
								$FareBreakdown[1]['PassengerType'] = 2;
								$FareBreakdown[1]['PassengerCount'] = $childCount;
								$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
								$FareBreakdown[1]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
								$FareBreakdown[1]['BaseFare'] = ($CHILD['BF'] * $childCount);
								$FareBreakdown[1]['CommissionEarned'] = ($CHILD['NCM'] * $childCount);
								$FareBreakdown[1]['TDS'] = ($CHILDNCMTDS * $childCount);
								$FareBreakdown[1]['MF'] = ($CH_MF * $childCount);
								$FareBreakdown[1]['YQ'] = ($CH_YQ * $childCount);
								$FareBreakdown[1]['AGST'] = ($CH_AGST * $childCount);
								$FareBreakdown[1]['MFT'] = ($CH_MFT * $childCount);
								$FareBreakdown[1]['OT'] = ($CH_OT * $childCount);
								$FareBreakdown[1]['MU'] = ($CH_MU * $childCount);
								$FareBreakdown[1]['YR'] = ($CH_YR * $childCount);
								$FareBreakdown[1]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
								$FareBreakdown[1]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
								$FareBreakdown[1]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
								$FareBreakdown[1]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
								$FareBreakdown[1]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
								$FareBreakdown[1]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
								$FareBreakdown[1]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
								$FareBreakdown[1]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
								$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
								$FareBreakdown[1]['GSTonComm'] = 0;
								$FareBreakdown[1]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
								$FareBreakdown[1]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
								$FareBreakdown[1]['AdditionalTxnFeeOfrd'] = 0;
								$FareBreakdown[1]['AdditionalTxnFeePub'] = 0;
								$FareBreakdown[1]['PGCharge'] = 0;
								$FareBreakdown[1]['Baggage'] = isset($fareDetail['CHILD']['bI']['iB']) ? $fareDetail['CHILD']['bI']['iB'] : []; //Check In Baggage;
								$FareBreakdown[1]['CabinBaggage'] = isset($fareDetail['CHILD']['bI']['cB']) ? $fareDetail['CHILD']['bI']['cB'] : []; //Cabin Baggage ;
							}
							if (isset($fareDetail['INFANT'])) {
								$markUpArrBR = array(
									'getMarkup' => $getMarkup,
									'PublishedFare' => ($INFANT['TF'] * $infantCount),
									'OfferedFare' => ($INFANT['NF'] * $infantCount),
									'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
									'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
									'MUFee' => ($IN_MU * $infantCount),
									'intPLBEarned' => $PLBEarned,
									'intIncentiveEarned' => $IncentiveEarned,
									'intMemberCount' => $infantCount,
									'intFlightRoute' => $strFlightRoute,
									'interNationalSearch' => $interNationalSearch,
									'AddMarkup' => $AddMarkup,
								);
								$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
								$FareBreakdown[2]['Currency'] = $this->CurrencyTitle;
								$FareBreakdown[2]['PassengerType'] = 3;
								$FareBreakdown[2]['PassengerCount'] = $infantCount;
								$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
								$FareBreakdown[2]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
								$FareBreakdown[2]['BaseFare'] = ($INFANT['BF'] * $infantCount);
								$FareBreakdown[2]['CommissionEarned'] = ($INFANT['NCM'] * $infantCount);
								$FareBreakdown[2]['TDS'] = ($INFANTNCMTDS * $infantCount);
								$FareBreakdown[2]['MF'] = ($IN_MF * $infantCount);
								$FareBreakdown[2]['YQ'] = ($IN_YQ * $infantCount);
								$FareBreakdown[2]['AGST'] = ($IN_AGST * $infantCount);
								$FareBreakdown[2]['OT'] = ($IN_OT * $infantCount);
								$FareBreakdown[2]['MFT'] = ($IN_MFT * $infantCount);
								$FareBreakdown[2]['MU'] = ($IN_MU * $infantCount);
								$FareBreakdown[2]['YR'] = ($IN_YR * $infantCount);
								$FareBreakdown[2]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
								$FareBreakdown[2]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
								$FareBreakdown[2]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
								$FareBreakdown[2]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
								$FareBreakdown[2]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
								$FareBreakdown[2]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
								$FareBreakdown[2]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
								$FareBreakdown[2]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
								$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
								$FareBreakdown[2]['GSTonComm'] = 0;
								$FareBreakdown[2]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
								$FareBreakdown[2]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
								$FareBreakdown[2]['AdditionalTxnFeeOfrd'] = 0;
								$FareBreakdown[2]['AdditionalTxnFeePub'] = 0;
								$FareBreakdown[2]['PGCharge'] = 0;
								$FareBreakdown[2]['Baggage'] = isset($fareDetail['INFANT']['bI']['iB']) ? $fareDetail['INFANT']['bI']['iB'] : []; //Check In Baggage;
								$FareBreakdown[2]['CabinBaggage'] = isset($fareDetail['INFANT']['bI']['cB']) ? $fareDetail['INFANT']['bI']['cB'] : []; //Cabin Baggage ;
							}
							//echo '<pre>';print_r($price);
							$FairRulesArr = array(
								"Currency" => $this->CurrencyTitle, //$Currency,
								"CurrencyRate" => $this->CurrencyRate, //$Currency,
								"currencySysId" => $this->CurrencyId,
								"BaseFare" => $BaseFareIN,
								"Tax" => $TaxIN,
								"YQTax" => $YQTax,
								"OtherCharges" => $OtherCharges,
								"Discount" => 0, //$Discount,
								"ServiceFee" => $ServiceFee,
								"ManagementFeeTax" => $ManagementFeeTax,
								"AirlineGSTComponent" => $AirlineGSTComponent,
								"CarrierMiscFee" => $CarrierMiscFee,
								"MUFee" => $MUFee,
								"intPublishedFare" => $PublishedFareIN,
								"PublishedFare" => ($arrMarkUps['PublishFare'] * $this->CurrencyRate),
								"OfferedFare" => $arrMarkUps['intOfferedFare'],
								"CommissionEarned" => $CommissionEarned,
								"PLBEarned" => $PLBEarned,
								"IncentiveEarned" => $IncentiveEarned,
								"TdsOnPLB" => $TdsOnPLB,
								"TdsOnIncentive" => 0,
								"AdditionalTxnFeeOfrd" => 0,
								"AdditionalTxnFeePub" => 0,
								"Refundable" => $Refundable,
								"IsRefundableTxt" => $IsRefundableTxt,
								"PriceID" => $PriceID,
								"IsGSTRequired" => $IsGSTRequired,
								"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
								"FareClass" => $fareDetail['ADULT']['cc'],
								"intTotalGST" => $arrMarkUps['intTotalGST'],
								"apiMarkup" => $arrMarkUps['apiMarkup'],
								"IntCommission" => $arrMarkUps['IntCommission'],
								"CommisionPass" => $arrMarkUps['CommisionPass'],
								"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
								"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
								"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
								"CommEarned" => $arrMarkUps['IntCommission'], //$arrMarkUps['intCommisionEarnedForAgency'],
								"GSTonComm" => 0,
								"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
								"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
								"AddiMarkup" => $arrMarkUps['AddiMarkup'],
								"AddiTaxOnMarkup" => $arrMarkUps['AddiTaxOnMarkup'],
								"newFare" => $newFare,
								"oldFare" => $oldFare,
								"Baggage" => isset($fareDetail['ADULT']['bI']['iB']) ? $fareDetail['ADULT']['bI']['iB'] : [],
								"CabinBaggage" => isset($fareDetail['ADULT']['bI']['cB']) ? $fareDetail['ADULT']['bI']['cB'] : [],
								"FareBreakdown" => $FareBreakdown,
								"CancelCharge" => $getCancelCharge,
								"arrMarkUps" => $arrMarkUps,
								"TaxSettingDetail" => $arrMarkUps['TaxSettingDetail'],
							);
						}
					}
					
					$BAGGAGE = isset($OriginSegments['ssrInfo']['BAGGAGE']) ? $OriginSegments['ssrInfo']['BAGGAGE'] : '';
					$MEAL = isset($OriginSegments['ssrInfo']['MEAL']) ? $OriginSegments['ssrInfo']['MEAL'] : '';
					$strSourceAirportCode = $OriginSegments['da']['code'];
					$strDestinationAirportCode = $DestinationSegments['aa']['code'];
					if ($BAGGAGE) {
						foreach ($BAGGAGE as $b => $bag) {
							$Weight = str_replace('Excess Baggage - ', '', $bag['desc']);
							$BaggageArr[$b]['Currency'] = $this->CurrencyTitle;
							$BaggageArr[$b]['key'] = $OriginSegments['id'];
							$BaggageArr[$b]['Code'] = $bag['code'];
							$BaggageArr[$b]['Price'] = isset($bag['amount']) ? $bag['amount'] : 0;
							$BaggageArr[$b]['amount'] = isset($bag['amount']) ? round(($bag['amount'] * $this->CurrencyRate), 2) : 0;
							$BaggageArr[$b]['Weight'] = $Weight;
							$BaggageArr[$b]['origin'] = $strSourceAirportCode;
							$BaggageArr[$b]['destination'] = $strDestinationAirportCode;
						}
					}
					if ($MEAL) {
						foreach ($MEAL as $m => $meals) {
							$MealArr[$m]['Currency'] = $this->CurrencyTitle;
							$MealArr[$m]['key'] = $OriginSegments['id'];
							$MealArr[$m]['Code'] = $meals['code'];
							$MealArr[$m]['Price'] = isset($meals['amount']) ? $meals['amount'] : 0;
							$MealArr[$m]['amount'] = isset($meals['amount']) ? round(($meals['amount'] * $this->CurrencyRate), 2) : 0;
							$MealArr[$m]['Description'] = $meals['desc'];
							$MealArr[$m]['origin'] = $strSourceAirportCode;
							$MealArr[$m]['destination'] = $strDestinationAirportCode;
						}
					}

					if ($SegmentInformation) {
						foreach ($SegmentInformation as $segments) {
							//echo '<pre>';print_r($segments);
							$duration = $segments['duration'];
							$LAYOVERMinutes = $GroundTime = isset($segments['cT']) ? $segments['cT'] : 0;
							$LAYOVERCity = $LAYOVERCityArr[] = isset($segments['cT']) ? $segments['aa']['city'] : '';
							$FlyingMinutes += ($duration + $LAYOVERMinutes);
							$TotalLAYOVERMinutes += $LAYOVERMinutes;

							$FareClass = $totalPriceList['fd']['ADULT']['cB'];
							$strBaggage = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Checking Baggage
							$strCabinBaggage = $totalPriceList['fd']['ADULT']['bI']['cB']; ////Cabin Baggage
							if (!empty($strCabinBaggage)) {
								$IsBaggage = true;
							} else {
								$IsBaggage = false;
							}

							$AirlineCode = $segments['fD']['aI']['code'];
							$AirlineName = $segments['fD']['aI']['name'];
							$FlightNumber = $segments['fD']['fN'];
							$SegFlightNumber = $AirlineCode . "-" . $FlightNumber;

							$originAirportName = $segments['da']['name'];
							$originAirportCode = $segments['da']['code'];
							$originCityName = $segments['da']['city'];
							$originCountryName = $segments['da']['country'];
							$originDepTime = $segments['dt'];

							$destinationAirportName = $segments['aa']['name'];
							$destinationAirportCode = $segments['aa']['code'];
							$destinationCityName = $segments['aa']['city'];
							$destinationCountryName = $segments['aa']['country'];
							$destinationArrTime = $segments['at'];

							$DepTerminal = isset($segments['da']['terminal']) ? $segments['da']['terminal'] : '';
							$ArrTerminal = isset($segments['aa']['terminal']) ? $segments['aa']['terminal'] : '';

							$filePath = $this->getflightlogo($AirlineCode);

							$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->MinutesToHours($LAYOVERMinutes);

							$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($destinationArrTime);
							$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($originDepTime);
							$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($duration);
							$arrSegments[] = array(
								"segmentid" => $segments['id'],
								"originAirportName" => $originAirportName,
								"destinationAirportName" => $destinationAirportName,
								"originCityName" => $originCityName,
								"originCountryName" => $originCountryName,
								"destinationCityName" => $destinationCityName,
								"destinationCountryName" => $destinationCountryName,
								"destinationAirportCode" => $destinationAirportCode,
								"destinationAirportCode" => $destinationAirportCode,
								"destinationArrTime" => $destinationArrTime,
								"SegFlightNumber" => $SegFlightNumber,
								"AirlineCode" => $AirlineCode,
								"AirlineName" => $AirlineName,
								"FareClass" => $FareClass,
								"originAirportCode" => $originAirportCode,
								"originDepTime" => $originDepTime,
								"TripIndicator" => '', //$TripIndicator,
								"Baggage" => $strBaggage,
								"CabinBaggage" => $strCabinBaggage,
								"IsBaggage" => $IsBaggage,
								"IsMealIncludes" => $IsMealIncludes,
								//"SegmentIndicator" => $SegmentIndicator,
								"Duration" => $duration,
								"GroundTime" => $GroundTime,
								"NoOfSeatAvailable" => $NoOfSeatAvailable,
								"strDepartureDtTime" => $strDepartureDtTime,
								"strArrivalDtTime" => $strArrivalDtTime,
								"FlightDuration" => $strDuration,
								"LAYOVERDuration" => $LAYOVERDuration,
								"LAYOVERCity" => $LAYOVERCity,
								"DepTerminal" => $DepTerminal,
								"ArrTerminal" => $ArrTerminal,
								"filePath" => $filePath,
							);
							//echo '<pre>';print_r($arrSegments);
						}
					}
					$flightSSRDetails = new Zend_Session_Namespace('flightSSRDetails');
					$flightSSRDetails->params['Baggage'] = $BaggageArr;
					$flightSSRDetails->params['Meal'] = $MealArr;

					$LAYOVERTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->MinutesToHours($TotalLAYOVERMinutes);

					$AirlineCode = $OriginSegments['fD']['aI']['code'];
					$FlightNumber = $OriginSegments['fD']['fN'];
					$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
					$strAirlineName = $OriginSegments['fD']['aI']['name'];
					$IsLCC = $OriginSegments['fD']['aI']['isLcc'];
					$strSourceAirportCode = $OriginSegments['da']['code'];
					$strDestinationAirportCode = $DestinationSegments['aa']['code'];

					$Stops = $DestinationSegments['sN'];
					if ($Stops == 0) {
						$StopCountTxt = "Non-stop";
					} else {
						$StopCountTxt = $Stops . " Stop(s)";
					}
					$filePath = $this->getflightlogo($AirlineCode);
					$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->CalculateHoursMinutes($OriginSegments['dt'], $DestinationSegments['at']);
					$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($DestinationSegments['at']);
					$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($OriginSegments['dt']);
					$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
					$arrInsertFlightData[$key]['bookingId'] = $bookingId;
					$arrInsertFlightData[$key]['bookingId_TJ'] = $bookingId_TJ;
					$arrInsertFlightData[$key]['FlightNumber'] = $strFlightNumber;
					$arrInsertFlightData[$key]['AirlineName'] = $strAirlineName;
					$arrInsertFlightData[$key]['AirlineCode'] = $AirlineCode;
					$arrInsertFlightData[$key]['AirInvenSysId'] = 0;
					$arrInsertFlightData[$key]['IsLCC'] = $IsLCC;
					$arrInsertFlightData[$key]['IsMealIncludes'] = $IsMealIncludes;
					$arrInsertFlightData[$key]['IsBagIncludes'] = $IsBagIncludes;
					$arrInsertFlightData[$key]['IsRefundable'] = $IsRefundable;
					$arrInsertFlightData[$key]['IsRefundableTxt'] = $IsRefundableTxt;
					$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
					$arrInsertFlightData[$key]['AirlineSysId'] = $airlineSysId;
					$arrInsertFlightData[$key]['DepartureTime'] = $strDepartureDtTime;
					$arrInsertFlightData[$key]['ArrivalTime'] = $strArrivalDtTime;
					$arrInsertFlightData[$key]['TravelDate'] = $OriginSegments['dt'];
					$arrInsertFlightData[$key]['LocalFromTime'] = str_replace('T', ' ', $OriginSegments['dt']);
					$arrInsertFlightData[$key]['FromUTCTime'] = $OriginSegments['dt'];
					$arrInsertFlightData[$key]['LocalToTime'] = str_replace('T', ' ', $DestinationSegments['at']);
					$arrInsertFlightData[$key]['ToUTCTime'] = $DestinationSegments['at'];
					$arrInsertFlightData[$key]['IsDirect'] = 0;
					$arrInsertFlightData[$key]['FareClass'] = $strFareClass;
					$arrInsertFlightData[$key]['LAYOVERCity'] = isset($LAYOVERCityArr[0]) ? $LAYOVERCityArr[0] : '';
					$arrInsertFlightData[$key]['GroundTime'] = $TotalLAYOVERMinutes;
					$arrInsertFlightData[$key]['LAYOVERDuration'] = $LAYOVERTime;
					$arrInsertFlightData[$key]['FlyingMinutes'] = $FlyingMinutes;
					$arrInsertFlightData[$key]['DepartureDateTxt'] = date('D, d M', strtotime($OriginSegments['dt']));
					$arrInsertFlightData[$key]['ArrivalDateTxt'] = date('D, d M', strtotime($DestinationSegments['at']));
					$arrInsertFlightData[$key]['FlightDuration'] = $FlightDuration;
					if ($strFlightRoute == 3) {
						$arrInsertFlightData[$key]['SourcePlaceSysId'] = $intSourceCityId[$key];
						$arrInsertFlightData[$key]['DestPlaceSysId'] = $intDestinationCityId[$key];
					} else {
						$arrInsertFlightData[$key]['SourcePlaceSysId'] = $intSourceCityId;
						$arrInsertFlightData[$key]['DestPlaceSysId'] = $intDestinationCityId;
					}
					$arrInsertFlightData[$key]['SourceAirportCode'] = $strSourceAirportCode;
					$arrInsertFlightData[$key]['DestAirportCode'] = $strDestinationAirportCode;
					//                $arrInsertFlightData[$key]['AirportHaultMinutes'] = $AirportHaultMinutes;
					$arrInsertFlightData[$key]['StopCount'] = $StopCountTxt;
					$arrInsertFlightData[$key]['Stops'] = $Stops;
					$arrInsertFlightData[$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
					$arrInsertFlightData[$key]['TotalFlightMembers'] = $intMemberCount;
					$arrInsertFlightData[$key]['CurrencyType'] = $this->CurrencyId;
					$arrInsertFlightData[$key]['PublishedFare'] = $PublishedFare; // As Discussed with GG
					$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format($PublishedFare); // As Discussed with GG
					//                $arrInsertFlightData[$key]['CommissionEarned'] = $CommissionEarned;
					$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
					$arrInsertFlightData[$key]['JourneyType'] = $intJourneyType;
					$arrInsertFlightData[$key]['TripType'] = $intTripType;
					$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
					$arrInsertFlightData[$key]['logo'] = $filePath;
					$arrInsertFlightData[$key]['FareRuleDetails'] = $FareRuleDetails;
					$arrInsertFlightData[$key]['FairRules'] = $FairRulesArr;
					$arrInsertFlightData[$key]['NewPrice'] = $NewPrice;
					$arrInsertFlightData[$key]['Segments'] = $arrSegments;
					$arrInsertFlightData[$key]['Baggage'] = $BaggageArr;
					$arrInsertFlightData[$key]['Meal'] = $MealArr;
					$arrInsertFlightData[$key]['isGSTMandatory'] = $isGSTMandatory;
					$arrInsertFlightData[$key]['SearchFlightTraceId'] = $SearchFlightTraceId;
					$arrInsertFlightData[$key]['ICSourceSysId'] = 7;
					$arrInsertFlightData[$key]['isDobAdult'] = $isDobAdult;
					$arrInsertFlightData[$key]['isDobChild'] = $isDobChild;
					$arrInsertFlightData[$key]['isDobInfant'] = $isDobInfant;
					$arrInsertFlightData[$key]['isSeatAppli'] = $isSeatAppli;
					$arrInsertFlightData[$key]['estimetedTime'] = $estimetedTime;
					$arrInsertFlightData[$key]['estimetedDateTime'] = $estimetedDateTime;
					$arrInsertFlightData[$key]['strTraceId'] = $strTraceId;

					$arrInsertFlightData[$key]['arrCommonInsVariables'] = $arrCommonInsVariables;
					$arrAirlineName[] = $AirlineCode . '-' . $strAirlineName;
					$AttPriceRange[] = $PublishedFare;
					$FiltStopCount[] = $StopCountTxt;
					$arrInsertFlightData[$key]['FilterPrice'] = ''; //$FilterPrice;

				}
			}
			$BaseFare = 0;
			$Tax = 0;
			$YQTax = 0;
			$OtherCharges = 0;
			$Discount = 0;
			$ServiceFee = 0;
			$ManagementFeeTax = 0;
			$AirlineGSTComponent = 0;
			$CarrierMiscFee = 0;
			$MUFee = 0;
			$intPublishedFare = 0;
			$PublishedFare = 0;
			$OfferedFare = 0;
			$AdditionalTxnFeeOfrd = 0;
			$AdditionalTxnFeePub = 0;
			$FixedMarkUp = 0;
			$GSTOnMarkUp = 0;
			$CommEarned = 0;
			$GSTonComm = 0;
			$intGTXMarkUp = 0;
			$GTXMarkUpGST = 0;
			$AddiMarkup = 0;
			$AddiTaxOnMarkup = 0;
			$FareBreakdown = [];
			$Segments = array();
			$PublishedFareIntRound = 0;
			if ($arrInsertFlightData) {
				foreach ($arrInsertFlightData as $k => $result) {
					$PublishedFareIntRound += $result['PublishedFare'];
					$BaseFare += $result['FairRules']['BaseFare'];
					$Tax += $result['FairRules']['Tax'];
					$YQTax += $result['FairRules']['YQTax'];
					$OtherCharges += $result['FairRules']['OtherCharges'];
					$Discount += $result['FairRules']['Discount'];
					$ServiceFee += $result['FairRules']['ServiceFee'];
					$ManagementFeeTax += $result['FairRules']['ManagementFeeTax'];
					$AirlineGSTComponent += $result['FairRules']['AirlineGSTComponent'];
					$CarrierMiscFee += $result['FairRules']['CarrierMiscFee'];
					$MUFee += $result['FairRules']['MUFee'];
					$intPublishedFare += $result['FairRules']['intPublishedFare'];
					$PublishedFare += $result['FairRules']['PublishedFare'];
					$OfferedFare += $result['FairRules']['OfferedFare'];
					$AdditionalTxnFeeOfrd += $result['FairRules']['AdditionalTxnFeeOfrd'];
					$AdditionalTxnFeePub += $result['FairRules']['AdditionalTxnFeePub'];
					$FixedMarkUp += $result['FairRules']['FixedMarkUp'];
					$GSTOnMarkUp += $result['FairRules']['GSTOnMarkUp'];
					$CommEarned += $result['FairRules']['CommEarned'];
					$GSTonComm += $result['FairRules']['GSTonComm'];
					$intGTXMarkUp += $result['FairRules']['intGTXMarkUp'];
					$GTXMarkUpGST += $result['FairRules']['GTXMarkUpGST'];
					$AddiMarkup += $result['FairRules']['AddiMarkup'];
					$AddiTaxOnMarkup += $result['FairRules']['AddiTaxOnMarkup'];

					foreach ($result['FairRules']['FareBreakdown'] as $id => $value) {
						$FareBreakdown[$id]['Currency'] = $value['Currency'];
						$FareBreakdown[$id]['PassengerType'] = $value['PassengerType'];
						$FareBreakdown[$id]['PassengerCount'] = $value['PassengerCount'];
						$FareBreakdown[$id]['TaxIN'] += $value['TaxIN'];
						$FareBreakdown[$id]['BaseFareCal'] += $value['BaseFareCal'];
						$FareBreakdown[$id]['BaseFare'] += $value['BaseFare'];
						$FareBreakdown[$id]['CommissionEarned'] += $value['CommissionEarned'];
						$FareBreakdown[$id]['TDS'] += $value['TDS'];
						$FareBreakdown[$id]['MF'] += $value['MF'];
						$FareBreakdown[$id]['YQ'] += $value['YQ'];
						$FareBreakdown[$id]['AGST'] += $value['AGST'];
						$FareBreakdown[$id]['MFT'] += $value['MFT'];
						$FareBreakdown[$id]['OT'] += $value['OT'];
						$FareBreakdown[$id]['MU'] += $value['MU'];
						$FareBreakdown[$id]['YR'] += $value['YR'];
						$FareBreakdown[$id]['AddiTaxOnMarkup'] += $value['AddiTaxOnMarkup'];
						$FareBreakdown[$id]['AddiMarkup'] += $value['AddiMarkup'];
						$FareBreakdown[$id]['FixedMarkUp'] += $value['FixedMarkUp'];
						$FareBreakdown[$id]['GSTOnMarkUp'] += $value['GSTOnMarkUp'];
						$FareBreakdown[$id]['CommEarned'] += $value['CommEarned'];
						$FareBreakdown[$id]['GSTonComm'] += $value['GSTonComm'];
						$FareBreakdown[$id]['intGTXMarkUp'] += $value['intGTXMarkUp'];
						$FareBreakdown[$id]['GTXMarkUpGST'] += $value['GTXMarkUpGST'];
						$FareBreakdown[$id]['AdditionalTxnFeeOfrd'] += $value['AdditionalTxnFeeOfrd'];
						$FareBreakdown[$id]['AdditionalTxnFeePub'] += $value['AdditionalTxnFeePub'];
						$FareBreakdown[$id]['PGCharge'] += $value['PGCharge'];
					}
					$Segments[] = $result['Segments'];

					//echo '<pre>';print_r($result['Segments']);echo '</pre>';
				}
			}
			//echo '<pre>';print_r($FareBreakdown);echo '</pre>';
			$FareRulesArr = array(
				//'FareRules'=>array(
				'Currency' => $arrInsertFlightData[0]['FairRules']['Currency'],
				'CurrencyRate' => $arrInsertFlightData[0]['FairRules']['CurrencyRate'],
				'currencySysId' => $arrInsertFlightData[0]['FairRules']['currencySysId'],
				'BaseFare' => $BaseFare,
				'Tax' => $Tax,
				'YQTax' => $YQTax,
				'OtherCharges' => $OtherCharges,
				'Discount' => $Discount,
				'ServiceFee' => $ServiceFee,
				'ManagementFeeTax' => $ManagementFeeTax,
				'AirlineGSTComponent' => $AirlineGSTComponent,
				'CarrierMiscFee' => $CarrierMiscFee,
				'MUFee' => $MUFee,
				'intPublishedFare' => $intPublishedFare,
				'PublishedFare' => $PublishedFare,
				'OfferedFare' => $OfferedFare,
				'AdditionalTxnFeeOfrd' => $AdditionalTxnFeeOfrd,
				'AdditionalTxnFeePub' => $AdditionalTxnFeePub,
				'FixedMarkUp' => $FixedMarkUp,
				'GSTOnMarkUp' => $GSTOnMarkUp,
				'CommEarned' => $CommEarned,
				'GSTonComm' => $GSTonComm,
				'intGTXMarkUp' => $intGTXMarkUp,
				'GTXMarkUpGST' => $GTXMarkUpGST,
				'AddiMarkup' => $AddiMarkup,
				'AddiTaxOnMarkup' => $AddiTaxOnMarkup,
				'FareBreakdown' => $FareBreakdown,
				//)
			);
			$arrInsertFlightDataInt['bookingId'] = $arrInsertFlightData[0]['bookingId'];
			$arrInsertFlightDataInt['bookingId_TJ'] = $arrInsertFlightData[0]['bookingId_TJ'];
			$arrInsertFlightDataInt['FlightNumber'] = $arrInsertFlightData[0]['FlightNumber'];
			$arrInsertFlightDataInt['AirlineName'] = $arrInsertFlightData[0]['AirlineName'];
			$arrInsertFlightDataInt['AirlineCode'] = $arrInsertFlightData[0]['AirlineCode'];
			$arrInsertFlightDataInt['AirInvenSysId'] = $arrInsertFlightData[0]['AirInvenSysId'];
			$arrInsertFlightDataInt['IsLCC'] = $arrInsertFlightData[0]['IsLCC'];
			$arrInsertFlightDataInt['IsMealIncludes'] = $arrInsertFlightData[0]['IsMealIncludes'];
			$arrInsertFlightDataInt['IsBagIncludes'] = $arrInsertFlightData[0]['IsBagIncludes'];
			$arrInsertFlightDataInt['IsRefundable'] = $arrInsertFlightData[0]['IsRefundable'];
			$arrInsertFlightDataInt['IsRefundableTxt'] = $arrInsertFlightData[0]['IsRefundableTxt'];
			$arrInsertFlightDataInt['apiTraceId'] = $arrInsertFlightData[0]['apiTraceId'];
			$arrInsertFlightDataInt['strTraceId'] = $arrInsertFlightData[0]['apiTraceId'];
			$arrInsertFlightDataInt['AirlineSysId'] = $arrInsertFlightData[0]['AirlineSysId'];
			$arrInsertFlightDataInt['DepartureTime'] = $arrInsertFlightData[0]['DepartureTime'];
			$arrInsertFlightDataInt['ArrivalTime'] = $arrInsertFlightData[0]['ArrivalTime'];
			$arrInsertFlightDataInt['TravelDate'] = $arrInsertFlightData[0]['TravelDate'];
			$arrInsertFlightDataInt['LocalFromTime'] = $arrInsertFlightData[0]['LocalFromTime'];
			$arrInsertFlightDataInt['FromUTCTime'] = $arrInsertFlightData[0]['FromUTCTime'];
			$arrInsertFlightDataInt['LocalToTime'] = $arrInsertFlightData[0]['LocalToTime'];
			$arrInsertFlightDataInt['ToUTCTime'] = $arrInsertFlightData[0]['ToUTCTime'];
			$arrInsertFlightDataInt['IsDirect'] = $arrInsertFlightData[0]['IsDirect'];
			$arrInsertFlightDataInt['FareClass'] = $arrInsertFlightData[0]['FareClass'];
			$arrInsertFlightDataInt['LAYOVERCity'] = $arrInsertFlightData[0]['LAYOVERCity'];
			$arrInsertFlightDataInt['GroundTime'] = $arrInsertFlightData[0]['GroundTime'];
			$arrInsertFlightDataInt['LAYOVERDuration'] = $arrInsertFlightData[0]['LAYOVERDuration'];
			$arrInsertFlightDataInt['FlyingMinutes'] = $arrInsertFlightData[0]['FlyingMinutes'];
			$arrInsertFlightDataInt['DepartureDateTxt'] = $arrInsertFlightData[0]['DepartureDateTxt'];
			$arrInsertFlightDataInt['ArrivalDateTxt'] = $arrInsertFlightData[0]['ArrivalDateTxt'];
			$arrInsertFlightDataInt['FlightDuration'] = $arrInsertFlightData[0]['FlightDuration'];
			$arrInsertFlightDataInt['SourcePlaceSysId'] = $arrInsertFlightData[0]['SourcePlaceSysId'];
			$arrInsertFlightDataInt['DestPlaceSysId'] = $arrInsertFlightData[0]['DestPlaceSysId'];
			$arrInsertFlightDataInt['SourceAirportCode'] = $arrInsertFlightData[0]['SourceAirportCode'];
			$arrInsertFlightDataInt['DestAirportCode'] = $arrInsertFlightData[0]['DestAirportCode'];
			$arrInsertFlightDataInt['StopCount'] = $arrInsertFlightData[0]['StopCount'];
			$arrInsertFlightDataInt['Stops'] = $arrInsertFlightData[0]['Stops'];
			$arrInsertFlightDataInt['NoOfSeatAvailable'] = $arrInsertFlightData[0]['NoOfSeatAvailable'];
			$arrInsertFlightDataInt['TotalFlightMembers'] = $arrInsertFlightData[0]['TotalFlightMembers'];
			$arrInsertFlightDataInt['CurrencyType'] = $arrInsertFlightData[0]['CurrencyType'];
			$arrInsertFlightDataInt['PublishedFare'] = $PublishedFareIntRound;
			$arrInsertFlightDataInt['ApiResultIndex'] = $arrInsertFlightData[0]['ApiResultIndex'];
			$arrInsertFlightDataInt['JourneyType'] = $arrInsertFlightData[0]['JourneyType'];
			$arrInsertFlightDataInt['TripType'] = $arrInsertFlightData[0]['TripType'];
			$arrInsertFlightDataInt['IsInternational'] = $arrInsertFlightData[0]['IsInternational'];
			$arrInsertFlightDataInt['logo'] = $arrInsertFlightData[0]['logo'];
			$arrInsertFlightDataInt['SearchFlightTraceId'] = $arrInsertFlightData[0]['SearchFlightTraceId'];
			$arrInsertFlightDataInt['ICSourceSysId'] = $arrInsertFlightData[0]['ICSourceSysId'];
			$arrInsertFlightDataInt['estimetedTime'] = $estimetedTime;
			$arrInsertFlightDataInt['estimetedDateTime'] = $estimetedDateTime;
			$arrInsertFlightDataInt['Fare'] = $FareRulesArr;
			$arrInsertFlightDataInt['Segments'] = $Segments;
			$arrCommonInsVariables = array(
				'strTraceId' => $arrInsertFlightData[0]['apiTraceId'],
				'localFromDateTime' => $arrInsertFlightData[0]['LocalFromTime'],
				'localToDateTime' => $arrInsertFlightData[0]['LocalToTime'],
				'strSourceAirportCode' => $strSourceAirportCode,
				'strDestinationAirportCode' => $strDestinationAirportCode,
				'intMemberCount' => $intMemberCount,
				'intSourceCityId' => $intSourceCityId,
				'intDestinationCityId' => $intDestinationCityId,
				'JourneyType' => 2, // For Round Trips API Search
				'TripType' => 1,
				'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0
			);
			$arrInsertFlightDataInt[0]['arrCommonInsVariables'] = $arrCommonInsVariables;
			$arrInsertFlightData[0]['InternationalData'] = $arrInsertFlightDataInt;

			$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
			$FlightBookingData->params = $arrInsertFlightData;
			return $arrInsertFlightData;
		}
	}

	public function UpdateFlightBookingDataSFInter($FlightBookingData, $SearchTraceId, $sessionFlightSearchParams)
	{
		//echo '<pre>';print_r($FlightBookingData);echo '</pre>';
		//echo '<pre>';print_r($sessionFlightSearchParams);echo '</pre>';
		$strSourceAirportCode = $sessionFlightSearchParams['from'];
		$strDestinationAirportCode = $sessionFlightSearchParams['to'];
		$adultCount = $sessionFlightSearchParams['adults'];
		$childCount = $sessionFlightSearchParams['child'];
		$infantCount = $sessionFlightSearchParams['infant'];
		$intMemberCount = $adultCount + $childCount + $infantCount;
		$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
		$strFlightRoute = trim($sessionFlightSearchParams['route']);
		$intTatalPaxCT = $adultCount + $childCount;
		$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId']);
		$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId']);
		$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
		$departureDates     = $sessionFlightSearchParams['departure_dates'];
		$return_dates     = $sessionFlightSearchParams['return_dates'];
		$arrDepartureDates  = explode("/", $departureDates);
		$this->view->departureDates = $strDepatureDate  = $arrDepartureDates[2] . "/" . $arrDepartureDates[1] . "/" . ($arrDepartureDates[0] - 1);

		$arrreturn_dates  = explode("/", $return_dates);
		$this->view->departureDates = $strReturnDate  = $arrreturn_dates[2] . "/" . $arrreturn_dates[1] . "/" . ($arrreturn_dates[0] - 1);

		$FairRules = $FlightBookingData[0]['FairRules'];
		$Segments = $FlightBookingData[0]['Segments'];
		$arrInsertFlightData = $FlightBookingData;
		$arrInsertFlightDataInt['bookingId'] = $arrInsertFlightData[0]['bookingId'];
		$arrInsertFlightDataInt['FlightNumber'] = $arrInsertFlightData[0]['FlightNumber'];
		$arrInsertFlightDataInt['AirlineName'] = $arrInsertFlightData[0]['AirlineName'];
		$arrInsertFlightDataInt['AirlineCode'] = $arrInsertFlightData[0]['AirlineCode'];
		$arrInsertFlightDataInt['AirInvenSysId'] = $arrInsertFlightData[0]['AirInvenSysId'];
		$arrInsertFlightDataInt['IsLCC'] = $arrInsertFlightData[0]['IsLCC'];
		$arrInsertFlightDataInt['IsMealIncludes'] = $arrInsertFlightData[0]['IsMealIncludes'];
		$arrInsertFlightDataInt['IsBagIncludes'] = $arrInsertFlightData[0]['IsBagIncludes'];
		$arrInsertFlightDataInt['IsRefundable'] = $arrInsertFlightData[0]['IsRefundable'];
		$arrInsertFlightDataInt['IsRefundableTxt'] = $arrInsertFlightData[0]['IsRefundableTxt'];
		$arrInsertFlightDataInt['apiTraceId'] = $arrInsertFlightData[0]['apiTraceId'];
		$arrInsertFlightDataInt['strTraceId'] = $arrInsertFlightData[0]['apiTraceId'];
		$arrInsertFlightDataInt['AirlineSysId'] = $arrInsertFlightData[0]['AirlineSysId'];
		$arrInsertFlightDataInt['DepartureTime'] = $arrInsertFlightData[0]['DepartureTime'];
		$arrInsertFlightDataInt['ArrivalTime'] = $arrInsertFlightData[0]['ArrivalTime'];
		$arrInsertFlightDataInt['TravelDate'] = $arrInsertFlightData[0]['TravelDate'];
		$arrInsertFlightDataInt['LocalFromTime'] = $arrInsertFlightData[0]['LocalFromTime'];
		$arrInsertFlightDataInt['FromUTCTime'] = $arrInsertFlightData[0]['FromUTCTime'];
		$arrInsertFlightDataInt['LocalToTime'] = $arrInsertFlightData[0]['LocalToTime'];
		$arrInsertFlightDataInt['ToUTCTime'] = $arrInsertFlightData[0]['ToUTCTime'];
		$arrInsertFlightDataInt['IsDirect'] = $arrInsertFlightData[0]['IsDirect'];
		$arrInsertFlightDataInt['FareClass'] = $arrInsertFlightData[0]['FareClass'];
		$arrInsertFlightDataInt['LAYOVERCity'] = $arrInsertFlightData[0]['LAYOVERCity'];
		$arrInsertFlightDataInt['GroundTime'] = $arrInsertFlightData[0]['GroundTime'];
		$arrInsertFlightDataInt['LAYOVERDuration'] = $arrInsertFlightData[0]['LAYOVERDuration'];
		$arrInsertFlightDataInt['FlyingMinutes'] = $arrInsertFlightData[0]['FlyingMinutes'];
		$arrInsertFlightDataInt['DepartureDateTxt'] = $arrInsertFlightData[0]['DepartureDateTxt'];
		$arrInsertFlightDataInt['ArrivalDateTxt'] = $arrInsertFlightData[0]['ArrivalDateTxt'];
		$arrInsertFlightDataInt['FlightDuration'] = $arrInsertFlightData[0]['FlightDuration'];
		$arrInsertFlightDataInt['SourcePlaceSysId'] = $arrInsertFlightData[0]['SourcePlaceSysId'];
		$arrInsertFlightDataInt['DestPlaceSysId'] = $arrInsertFlightData[0]['DestPlaceSysId'];
		$arrInsertFlightDataInt['SourceAirportCode'] = $arrInsertFlightData[0]['SourceAirportCode'];
		$arrInsertFlightDataInt['DestAirportCode'] = $arrInsertFlightData[0]['DestAirportCode'];
		$arrInsertFlightDataInt['StopCount'] = $arrInsertFlightData[0]['StopCount'];
		$arrInsertFlightDataInt['Stops'] = $arrInsertFlightData[0]['Stops'];
		$arrInsertFlightDataInt['NoOfSeatAvailable'] = $arrInsertFlightData[0]['NoOfSeatAvailable'];
		$arrInsertFlightDataInt['TotalFlightMembers'] = $arrInsertFlightData[0]['TotalFlightMembers'];
		$arrInsertFlightDataInt['CurrencyType'] = $arrInsertFlightData[0]['CurrencyType'];
		$arrInsertFlightDataInt['PublishedFare'] = $FairRulesArr['PublishedFare'];
		$arrInsertFlightDataInt['ApiResultIndex'] = $arrInsertFlightData[0]['ApiResultIndex'];
		$arrInsertFlightDataInt['JourneyType'] = $arrInsertFlightData[0]['JourneyType'];
		$arrInsertFlightDataInt['TripType'] = $arrInsertFlightData[0]['TripType'];
		$arrInsertFlightDataInt['IsInternational'] = $arrInsertFlightData[0]['IsInternational'];
		$arrInsertFlightDataInt['ICSourceSysId'] = 7;
		$arrInsertFlightDataInt['logo'] = $arrInsertFlightData[0]['logo'];
		$arrInsertFlightDataInt['Fare'] = $FairRules;
		$arrInsertFlightDataInt['Segments'] = $Segments;
		$arrCommonInsVariables = array(
			'strTraceId' => $arrInsertFlightData[0]['apiTraceId'],
			'localFromDateTime' => $arrInsertFlightData[0]['LocalFromTime'],
			'localToDateTime' => $arrInsertFlightData[0]['LocalToTime'],
			'strSourceAirportCode' => $strSourceAirportCode,
			'strDestinationAirportCode' => $strDestinationAirportCode,
			'intMemberCount' => $intMemberCount,
			'intSourceCityId' => $intSourceCityId,
			'intDestinationCityId' => $intDestinationCityId,
			'JourneyType' => 2, // For Round Trips API Search
			'TripType' => 1,
			'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0
		);
		if ($interNationalSearch == 1 && $strFlightRoute == 2) {
			$arrInsertFlightData[0]['arrCommonInsVariables'] = $arrCommonInsVariables;
			$arrInsertFlightData[0]['InternationalData'] = $arrInsertFlightDataInt;
		}
		//echo "apiResponse<pre>";print_r($arrInsertFlightData);die;
		$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
		$FlightBookingData->params = $arrInsertFlightData;
		return $arrInsertFlightData;
		//
	}

	public function getseatpageAction()
	{
		$getData = $this->getRequest()->getParams();		
		$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $getData['TraceId']], ['id' => 'ASC']);

		$arrUrlData = json_decode($temp_data['json_data'], true);
		$BookingData = ($arrUrlData['BookingData']) ? $arrUrlData['BookingData'] :[];
		// echo '<pre>';print_r($arrUrlData);die;
		$html = new Zend_View();
		$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
		$html->assign(array('FlightBookingData' => $BookingData, 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
		$bodyText = $html->render('getseatpage.phtml');
		$response = array('success' => true, 'message' => 'Done', 'html' => $bodyText);
		echo json_encode($response);
		exit;
		//
	}

	public function seatmapAction()
	{
		// ini_set('display_errors', 1);
		//     ini_set('display_startup_errors', 1);
		//     error_reporting(E_ALL);
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$getData = $this->getRequest()->getParams();
			$segmentid = $getData['segmentid'];
			$SecKey = isset($getData['SecKey'])?$getData['SecKey']:'';
			$journey = isset($getData['journey'])?$getData['journey']:0;
			$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
			$CustomerSession = new Zend_Session_Namespace('CustomerSession');	
			$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
			$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $getData['TraceId']], ['id' => 'ASC']);
			$arrUrlData = json_decode($temp_data['json_data'], true);
			$FlightBookingData->params = ($arrUrlData['BookingData']) ? $arrUrlData['BookingData'] :[];
			$sessionFlightSearchParams->params = ($arrUrlData['sessionFlightSearchParams']) ? $arrUrlData['sessionFlightSearchParams'] :[];
			$CustomerSession->params = ($arrUrlData['CustomerSession']) ? $arrUrlData['CustomerSession'] :[];
			$tripSeatMap = ($arrUrlData['tripSeatMap']) ? $arrUrlData['tripSeatMap'][0] :[];
			
			$bookingId = $FlightBookingData->params[0]['bookingId_TJ'];
			$ICSourceSysId = $FlightBookingData->params[0]['ICSourceSysId'];
			
			$data = ['bookingId' => $bookingId];
			
			$adultCount = isset($sessionFlightSearchParams->params['adults']) ? $sessionFlightSearchParams->params['adults'] : 1;
			$childCount = isset($sessionFlightSearchParams->params['childs']) ? $sessionFlightSearchParams->params['childs'] : 0;
			$infantCount = isset($sessionFlightSearchParams->params['infants']) ? $sessionFlightSearchParams->params['infants'] : 0;
			$TrackId = isset($FlightBookingData->params[0]['ApiResultIndex']) ? $FlightBookingData->params[0]['ApiResultIndex'] : 0;
			$SearchTraceId = isset($FlightBookingData->params[0]['SearchTraceId']) ? $FlightBookingData->params[0]['SearchTraceId'] : 0;
			$route = isset($sessionFlightSearchParams->params['route']) ? $sessionFlightSearchParams->params['route'] : '';
			$interNationalSearch = isset($sessionFlightSearchParams->params['interNationalSearch']) ? $sessionFlightSearchParams->params['interNationalSearch'] : 0;
			
			$intPaxCount = 1;
			for ($i = 1; $i <= $adultCount; $i++) {
				$roomjson[$i]['Title'] = 'Adult';
				$roomjson[$i]['paxType'] = 1;
				$roomjson[$i]['CustomerSysId'] = $i;
				$roomjson[$i]['CustomerMemberSysId'] = $i;
				$roomjson[$i]['intPaxCount'] = $intPaxCount;
				$intPaxCount++;
			}
			if (!empty($childCount)) {
				$intPaxCount = 1;
				for ($j = $i; $j <= ($adultCount + $childCount); $j++) {
					$roomjson[$j]['Title'] = 'Child';
					$roomjson[$j]['paxType'] = 2;
					$roomjson[$j]['CustomerSysId'] = $j;
					$roomjson[$j]['CustomerMemberSysId'] = $j;
					$roomjson[$j]['intPaxCount'] = $intPaxCount;
					$intPaxCount++;
				}
			}

			$FlightSeatSession = new Zend_Session_Namespace('FlightSeatSession');
			
			if ($ICSourceSysId == 3) {
				$apiResponse = $tripSeatMap;
				$FlightSeatSession->params = $apiResponse;
			} elseif($ICSourceSysId == 16){
				$FlightDetails = [];
				$SegmentInfo = [];
				$Flight_Keys = [];
				if ($FlightBookingData->params) {
					foreach ($FlightBookingData->params as $kk => $value) {
						if ($value['Segments']) {
							foreach ($value['Segments'] as $i => $vl) {
								if($segmentid == $vl['segmentid']){

									$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'])),
									);
								}
							}
						}
						$Flight_Keys[$kk] = isset($value['Flight_Key'])?$value['Flight_Key']:'';
					}
				}
				$sourceCityAirportCode = trim($sessionFlightSearchParams->params['sourceCityAirportCode']);
				$destinationCityAirportCode = trim($sessionFlightSearchParams->params['destinationCityAirportCode']);
				$interNationalSearch = $sessionFlightSearchParams->params['interNationalSearch'];
				$ARR_SALUTION = unserialize(ARR_SALUTION);
				$ARR_SALUTION_CHILD = unserialize(ARR_SALUTION_CHILD);
				$APIPaxDetails = [];
				$PAX_Details = [];
				$post = $getData['passengerdata'];
				$totalPassengers = $intMemberCount = $adultCount + $childCount + $infantCount;
				for ($i = 1; $i <= $totalPassengers; $i++) {
					$countryCode      = $post['countryCode'];
					$paxTypes      = $post['paxType-' . $i];
					$firstName    = trim($post['passenger-firstname-' . $i]);
					$lastName     = trim($post['passenger-lastname-' . $i]);
					$salutation   = $post['salution-' . $i];
					$PassportNo   = isset($post['passenger-PassportNo-' . $i])?$post['passenger-PassportNo-' . $i]:null;
					$nationality   = isset($post['passenger-nationality-' . $i])?$post['passenger-nationality-' . $i]:null;
					$PassportExpiry   = isset($post['passenger-PassportExpiry-' . $i])?$post['passenger-PassportExpiry-' . $i]:null;
					$DOB   = isset($post['passenger-dob-' . $i])?$post['passenger-dob-' . $i]:null;
					if (empty($salutation)) {
						$response = array('success' => false, 'message' => 'Please select salutation.', '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($paxTypes == 1){
						$PaxType = 'ADT';
						$Pax_type = 0;
						$InfantRef = false;
						$paxTitle = ($ARR_SALUTION[$salutation]);
						if($ICSourceSysId == 11 || $ICSourceSysId == 13 || $ICSourceSysId == 14){
							$paxTitle = ($paxTitle == 'Ms')?'Miss':$paxTitle;
						}
						
					}elseif($paxTypes == 2){
						$PaxType = 'CHD';
						$InfantRef = false;
						$Pax_type = 1;
						$paxTitle = ($ARR_SALUTION_CHILD[$salutation]);
						$paxTitle = ($paxTitle == 'Master')?'Mstr':$paxTitle;
					}else{
						$PaxType = 'INF';
						$InfantRef = true;
						$Pax_type = 2;
						$paxTitle = ($ARR_SALUTION_CHILD[$salutation]);
						$paxTitle = ($paxTitle == 'Master')?'Mstr':$paxTitle;
					}

					$SalutationTitle = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getSalutationByid(null, $paxTitle);
					$intGender = ($SalutationTitle['Gender'] == 'Male') ? 0 : 1;
					$Age = null;
					if($DOB){
						$Age = date_diff(date_create($DOB), date_create('today'))->y;
					}
					if($paxTypes != 3){
						$APIPaxDetails[] = array(
							'PaxRefNumber' => $i,
							'PaxType' => $PaxType,
							'Title' => $paxTitle,
							'FirstName' => $firstName,
							'LastName' => $lastName,

						);
					}
				}
				
				$SeatmapRequest = array(
					'AgentInfo'=>array(
						'AppType'=>'API',
					),
					'SegmentInfo'=>array(
						'BaseOrigin'=>$sourceCityAirportCode,
						'BaseDestination'=>$destinationCityAirportCode,
						'TripType'=>($route == 1)?'O':'R',
					),
					'FlightsInfo'=>array_values($FlightDetails),
					'APIPaxDetails'=>array_values($APIPaxDetails),
					'TrackId'=>$TrackId,
				);

				$DataS = array(
					'apidata'=> $SeatmapRequest,
					'memberCount'=> $intMemberCount,
					'JourneyType'=>$route,
					'interNationalSearch'=>$interNationalSearch,
					'searchID'=>$SearchTraceId,
					'ICSourceSysId'=>$ICSourceSysId,
					'segmentid'=>$segmentid,
					'SecKey'=>$SecKey,
					'journey'=>$journey,
				);
				// echo 'apiResponse<pre>';print_r(json_encode($DataS));
				// die;
				$url = $this->GTXAPIDEFAULT.'/flight/v3/getseatmap';
				$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
				
				
				$status = isset($apiResponse['status']) ? $apiResponse['status'] : false;
				$tripSeatMapAPI = isset($apiResponse['tripSeatMap']) ? $apiResponse['tripSeatMap'] : [];
				// echo '<pre>';print_r(($tripSeatMapAPI));
				// die;
				
					$tripSeat = [];
					foreach($tripSeatMapAPI as $key=>$val){
						$sData = $val['sData'];
						if($val['sInfo']){
							foreach($val['sInfo'] as $keys=>$value){
								$Origin = $value['Origin'];
								$Destination = $value['Destination'];
								$secKeys = $Origin.'-'.$Destination;
								if($secKeys == $SecKey){
									$tripSeat[$segmentid]['sData'] = $sData;
									$tripSeat[$segmentid]['sInfo'][] = $value;
								}
							}
						}
					}
					$tripSeatMap = array(
						'tripSeatMap'=>['tripSeat'=>$tripSeat],
						'status'=>['success'=>$status,'httpStatus'=>200],
					);
					$apiResponse = $tripSeatMap;
					$FlightSeatSession->params = $apiResponse;
			} else {
				$requestAPI = array(
					'bookingId' => $FlightBookingData->params[0]['APIBookingId'],
				);
				$DataS = array(
					'apidata' => $requestAPI,
					'memberCount' => ($adultCount + $childCount + $infantCount),
					'JourneyType' => $route,
					'interNationalSearch' => $interNationalSearch,
					'searchID' => $SearchTraceId,
					'ICSourceSysId' => $ICSourceSysId,
					'cabinClass' => '',
					'ADULT' => $adultCount,
					'CHILD' => $childCount,
					'INFANT' => $infantCount,
					'AgentMarkUp' => 0,
					'segmentid' => $segmentid,
					'SecKey' => $SecKey,
					'APIMode' => $this->APIMode,
				);
				$url = $this->GTXAPIDEFAULT.'/flight/v3/getseatmap';
				// $apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, null, $url);
				// $FlightSeatSession->params = $apiResponse;
				// echo '<pre>';print_r(($DataS));
				// echo '<pre>';print_r(($apiResponse));
				// die;
				///Zend_Session::namespaceUnset('FlightSeatSession');
				if (empty($FlightSeatSession->params)) {
					$apiResponseAPI = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, null, $url);
					$apiResponse = $apiResponseAPI['tripSeatMap'];
					$FlightSeatSession->params = $apiResponse;
				} else {
					$apiResponse = $FlightSeatSession->params;
				}
			}
			// if ($this->gtxagencysysid == '12208') {
				 
				
			// }
			
			$SegmentsArr = [];
			if ($FlightBookingData->params) {
				foreach ($FlightBookingData->params as $Datass) {
					if ($Datass['Segments']) {
						foreach ($Datass['Segments'] as $keys => $value) {
							$SegmentsArr[$value['segmentid']] = $value;
						}
					}
				}
			}
			
			$this->view->ICSourceSysId = $ICSourceSysId;
			$this->view->apiResponse = $apiResponse;
			$this->view->segmentid = $segmentid;
			$this->view->SegmentsArr = $SegmentsArr;
			$this->view->baseUrl = $this->baseUrl;
			$this->view->CustomerSession = array_values($roomjson); //$CustomerSession->params;
			$this->view->CurrencyTitle = $this->CurrencyTitle;
			$this->view->CurrencyRate = $this->CurrencyRate;
		} else {
			die('Page not found!');
		}
	}

	public function continuewithseatmapAction()
	{
		header('Access-Control-Allow-Origin: ' . $this->baseUrl . '');
		if ($this->getRequest()->isXmlHttpRequest() && $this->getRequest()->getPost()) {
			$this->_helper->layout->disableLayout();
			$getData = $this->getRequest()->getParams();
			
			//Zend_Session::namespaceUnset('selectedSeatSession');die;
			$segmentid = $getData['segmentid'];
			$seatArray = $getData['seatArray'];
			$paxTypeArr = $getData['paxTypeArr'];
			$actiontype = isset($getData['actiontype']) ? $getData['actiontype'] : 0;
			$CustomerSysIdArray = $getData['CustomerSysIdArray'];
			$FlightBookingDataInbound = new Zend_Session_Namespace('FlightBookingDataInbound');
			$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');

			$SelectedMealSessionNew = new Zend_Session_Namespace('SelectedMealSessionNew');
			$SelectedBaggSessionNew = new Zend_Session_Namespace('SelectedBaggSessionNew');

			$SelectedMealSessionNewInb = new Zend_Session_Namespace('SelectedMealSessionNewInb');
			$SelectedBaggSessionNewInb = new Zend_Session_Namespace('SelectedBaggSessionNewInb');

			$CustomerSession = new Zend_Session_Namespace('CustomerSession');
			$selectedSeatSession = new Zend_Session_Namespace('selectedSeatSession');
			$FlightSeatSession = new Zend_Session_Namespace('FlightSeatSession');

			$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $getData['TraceId']], ['id' => 'ASC']);
			$arrUrlData = json_decode($temp_data['json_data'], true);
			$FlightBookingData->params = ($arrUrlData['BookingData']) ? $arrUrlData['BookingData'] :[];
			$CustomerSession->params = ($arrUrlData['CustomerSession']) ? $arrUrlData['CustomerSession'] :[];
			if(!empty($arrUrlData['tripSeatMap'])){
				$FlightSeatSession->params = ($arrUrlData['tripSeatMap']) ? $arrUrlData['tripSeatMap'][0] :[];
			}
			
			// echo"<pre>";print_r($SelectedMealSessionNew->params);
			// echo"<pre>";print_r($SelectedBaggSessionNew->params);
			// echo"<pre>";print_r($arrUrlData);
			// die;
			$bookingId = $FlightBookingData->params[0]['bookingId'];
			$data = ['bookingId' => $bookingId];
			
			$tripSeat = $FlightSeatSession->params['tripSeatMap']['tripSeat'];

			$value = $tripSeat[$segmentid];
			$sInfo = $value['sInfo'];
			$items = [];
			foreach ($sInfo as $k => $val) {
				$items[$val['seatNo']] = array(
					'seatNo' => $val['seatNo'],
					'amount' => $val['amount'],
					'isBooked' => $val['isBooked'],
					'isLegroom' => isset($val['isLegroom']) ? $val['isLegroom'] : 0,
					'code' => $val['code'],
					'isAisle' => isset($val['isAisle']) ? $val['isAisle'] : 0,
				);
			}
			$selectedSeat = [];
			$SelectedSegment = [];
			if ($CustomerSysIdArray) {
				foreach ($CustomerSysIdArray as $keys => $CustomerSysId) {
					$seatNo = $seatArray[$keys];
					$paxType = $paxTypeArr[$keys];
					$SelectedSegment[] = $paxType . ': ' . $seatNo;
					foreach ($sInfo as $k => $val) {
						if ($val['seatNo'] == $seatNo) {
							$selectedSeat[$segmentid][$CustomerSysId] = $val;
						}
					}
				}
			}


			if (!empty($selectedSeatSession->params)) {
				foreach ($selectedSeatSession->params as $segid => $value) {
					$index = 0;
					if ($segid == $segmentid) {
						foreach ($value as $CustomerId => $val) {
							$seatNo = $seatArray[$index];
							$itemsdata = $items[$seatNo];
							if (trim($val['seatNo']) == trim($seatNo)) {
								$selectedSeatSession->params[$segmentid][$CustomerId] = $val;
							} else {
								$selectedSeatSession->params[$segmentid][$CustomerId] = $itemsdata;
							}
							$index++;
						}
					} else {
						if ($CustomerSysIdArray) {
							foreach ($CustomerSysIdArray as $keys => $CustomerSysId) {
								$seatNo = $seatArray[$keys];
								foreach ($sInfo as $k => $val) {
									if ($val['seatNo'] == $seatNo) {
										$selectedSeatSession->params[$segmentid][$CustomerSysId] = $val;
									}
								}
							}
						}
					}
				}
			} else {
				$selectedSeatSession->params = $selectedSeat;
			}

			$BagPrice = 0;
			$InbBagPrice = 0;
			$MealPrice = 0;
			$InbMealPrice = 0;
			$SeatPrice = 0;
			$BagPrice = !empty($SelectedBaggSessionNew->params['Price'])?$SelectedBaggSessionNew->params['Price']:0;
			$MealPrice = !empty($SelectedMealSessionNew->params['Price'])?$SelectedMealSessionNew->params['Price']:0;

			if ($SelectedMealSessionNewInb->params) {
				foreach ($SelectedMealSessionNewInb->params as $val) {
					$InbMealPrice += $val['Price'];
				}
			}
			if ($SelectedBaggSessionNewInb->params) {
				foreach ($SelectedBaggSessionNewInb->params as $val) {
					$InbBagPrice += $val['Price'];
				}
			}
			if ($selectedSeatSession->params) {
				foreach ($selectedSeatSession->params as $values) {
					foreach ($values as $val) {
						$SeatPrice += $val['amount'];
					}
				}
			}
			if ($actiontype == '2') {
				$SelectedSegment = [];
				Zend_Session::namespaceUnset('selectedSeatSession');
			}

			// echo 'selectedSeatSession<pre>';print_r($selectedSeatSession->params);die;
			//echo"<pre>";print_r($SeatPrice);die;
			$MealFare = ($MealPrice + $InbMealPrice);
			$BaggFare = ($BagPrice + $InbBagPrice);

			$intNetPublishedFare = 0;
			if ($FlightBookingData) {
				foreach ($FlightBookingData->params as $value) {
					$intNetPublishedFare += $value['FairRules']['PublishedFare'];
				}
			}

			$apiResponse = ($FlightBookingData->params);
			$apiResponseInbound = ($FlightBookingDataInbound->params);
			$Data = $apiResponse;
			$DataInb = $apiResponseInbound;
			$intPublishedFare = $Data['FairRules']['PublishedFare'];
			$intPublishedFareInb = !empty($DataInb['FairRules']['PublishedFare']) ? $DataInb['Fare']['PublishedFare'] : 0;
			$MobilePublishedFare = ($intNetPublishedFare + $MealFare + $BaggFare + $SeatPrice);
			//echo"<pre>";print_r($MobilePublishedFare);die;
			$html = new Zend_View();
			$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
			$html->assign(array('apiResponse' => $FlightBookingData->params, 'stylecss' => $this->stylecss, 'apiResponseInbound' => $FlightBookingDataInbound->params, 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
			$bodyText = $html->render('getflightfarequote.phtml');
			$response = array('success' => true, 'message' => 'Done', 'SelectedSegment' => implode(', ', $SelectedSegment), 'MobilePublishedFare' => number_format(ceil($MobilePublishedFare), 2), 'html' => $bodyText);
			echo json_encode($response);
			exit;
		} else {
			die('Page not found!');
		}
	}
	public function migratebookflightAction()
	{
		$param = $this->getRequest()->getParams();
		$traceId = $param['id'];
		if ($traceId) {
			$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $traceId], ['id' => 'ASC']);
			$response = $arrUrlData = json_decode($temp_data['json_data'], true);

			$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
			$FlightBookingData->params = $response['BookingData'];

			$Invoicedata = new Zend_Session_Namespace('Invoicedata');
			$Invoicedata->params = $response['Invoicedata'];

			$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
			$sessionFlightSearchParams->params = $response['sessionFlightSearchParams'];
			$FlightSearchUrl = new Zend_Session_Namespace('FlightSearchUrl');
			$FlightSearchUrl->params = $response['FlightSearchUrl'];
			$CustomerSession = new Zend_Session_Namespace('CustomerSession');
			$CustomerSession->params = $response['CustomerSession'];

			$BookingData = $response['BookingData'];
			$booking_customer_id = $response['flight_booking_customer_id'];
			$flight_booking_id = $response['CustomerMemberSysIds']['flight_booking_id'];
			$sessionFlightSearchParams = $response['sessionFlightSearchParams'];
			$selectedSeatSession = $response['selectedSeatSession'];
			$SelectedMealSessionNew = $response['SelectedMealSessionNew'];
			$SelectedBaggSessionNew = $response['SelectedBaggSessionNew'];
			$CustomerSession = $response['CustomerSession'];
			$ResponseFlightQuery = new Zend_Session_Namespace('ResponseFlightQuery');
			$ResponseFlightQuery->params = $response['ResponseFlightQuery'];


			$encryptedData = new Travel_Model_AtomAES();

			$CancellationProtectionData = isset($response['CancellationProtectionData']) ? $response['CancellationProtectionData'] : '';
			$CancellationProtectionPrice = isset($CancellationProtectionData['CancellationProtectionPrice']) ? $CancellationProtectionData['CancellationProtectionPrice'] : 0;
			$CancellationProtectionDataE = json_encode($CancellationProtectionData);
			$CancellationProtectionDataCode = $encryptedData->encrypt($CancellationProtectionDataE, SECURITYKEY, SECURITYKEY);

			
			$objFlight = new Travel_Model_FlightMaster();
			$flightdata = $objFlight->CheckPaymentSTatus('tbl_flight_booking', $traceId);
			$API_Response_Ticket = json_decode($flightdata['API_Response_Ticket'], true);
			$FlightQueryids = $ResponseFlightQuery->params; //json_decode($flightdata['FlightQueryids'], true); Temp


			$MasterTPSysId = $FlightQueryids['arrIds']['MasterTPSysId'];
			$TPSysId = $FlightQueryids['arrIds']['TPSysId'];
			$TrxId = $FlightQueryids['arrIds']['TrxId'];
			$VersionId = $FlightQueryids['arrIds']['VersionId'];
			$FareBreakdownid = $FlightQueryids['arrIds']['FareBreakdownid'];
			$CustomerSysIdGTX = $FlightQueryids['arrIds']['CustomerSysId'];
			$paymentStatus = ($flightdata['paymentStatus']);

			$IsCancellationProtection = isset($flightdata['IsCancellationProtection']) ? $flightdata['IsCancellationProtection'] : 0;

			$ICSourceSysId = isset($BookingData[0]['ICSourceSysId']) ? $BookingData[0]['ICSourceSysId'] :'';

			if ($paymentStatus == 1 && $temp_data) {
				$apiResponse = json_decode('');
				// echo json_encode($apiResponse);
				// echo "<pre>";print_r($apiResponse);die("apiResponse");
				$ResponseStatus = isset($apiResponse['status']) ? $apiResponse['status'] : false;
				$TransactionStatus = isset($apiResponse['TransactionStatus']) ? $apiResponse['TransactionStatus'] : '';
				$BookingId = isset($apiResponse['BookingId']) ? $apiResponse['BookingId'] : '';
				if($ResponseStatus == 1){
					$Bookres = [
						'status' => array('success' => true,'apiResponse'=>$apiResponse,'BookingId'=>$BookingId, 'TransactionStatus'=>$TransactionStatus,'SearchTraceId' => $traceId),
					];
				}else{
					$Bookres = [
						'status' => array('success' => false,'SearchTraceId' => $traceId),
					];
				}

				$apiResponse = isset($Bookres['status']['apiResponse'])?$Bookres['status']['apiResponse']:[];
				$TransactionStatus = isset($Bookres['status']['TransactionStatus'])?$Bookres['status']['TransactionStatus']:'';
				$BookingId = isset($Bookres['status']['BookingId'])?$Bookres['status']['BookingId']:'';
				$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->SetbookingDetailsNextraTemp($BookingData, $CustomerSession, $apiResponse, $DataS);
				$OrderBookingStatus = isset($response['order']['status']) ? $response['order']['status'] : '';
				if ($OrderBookingStatus != 'ABORTED') {
					$ResponseStatus = isset($response['status']['success']) ? $response['status']['success'] : '0';
					$strTicketPNRLCC = isset($response['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails']) ? $response['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails'] : '';
					$strgdsPnrs = isset($response['itemInfos']['AIR']['travellerInfos'][0]['gdsPnrs']) ? $response['itemInfos']['AIR']['travellerInfos'][0]['gdsPnrs'] : '';
					$Passenger = isset($response['itemInfos']['AIR']['travellerInfos']) ? $response['itemInfos']['AIR']['travellerInfos'] : '';
					$strBookingIdLCC = isset($response['order']['bookingId']) ? $response['order']['bookingId'] : '0';
					$ErrorMessage = isset($response['errors'][0]['message']) ? $response['errors'][0]['message'] : '';
				}
				echo "where<pre>";print_r($strgdsPnrs);
				echo "where<pre>";print_r($response);
				die;
				$segArray = [];
				if ($BookingData) {
					foreach ($BookingData as $k => $valueNew) {
						if ($valueNew['Segments']) {
							foreach ($valueNew['Segments'] as $seg_) {
								$segArray[$seg_['segmentid']]  = $seg_;
							}
						}
					}
				}
				if ($BookingData) {
					foreach ($BookingData as $k => $value) {
						if($ICSourceSysId == 16 && $route == 2){
							$response = $responseApiResponse[$k];
							$ResponseStatus = isset($response['status']['success']) ? $response['status']['success'] : '0';
							$strTicketPNRLCC = isset($response['order']['customerpnr']['PNR_Number']) ? $response['order']['customerpnr']['PNR_Number'] : '';
							$Passenger = isset($response['itemInfos']['AIR']['travellerInfos']) ? $response['itemInfos']['AIR']['travellerInfos'] : '';
							$strBookingIdLCC = isset($response['order']['BookingTrackId']) ? $response['order']['BookingTrackId'] : '0';
							$bookingId = isset($response['order']['bookingId']) ? $response['order']['bookingId'] : '0';
							$ErrorMessage = isset($response['errors'][0]['message']) ? $response['errors'][0]['message'] : '';
						}
						$finalFareSummary = $value['FairRules'];
						//echo '<pre>';print_r($finalFareSummary);
						$couponApply = isset($value['FairRules']['couponApply']) ? $value['FairRules']['couponApply'] : 0;
						if ($couponApply == 1 || $couponApply == '1') {
							$couponVal = isset($value['FairRules']['couponVal']) ? $value['FairRules']['couponVal'] : 0;
						} else {
							$couponVal = 0;
						}
						$PublishedFareNewPrice = 0;
						if($ICSourceSysId == 7){
							$PublishedFareNewPrice += isset($value['NewPrice']['PublishedFare']) ? $value['NewPrice']['PublishedFare'] :0;
						}
					
						$AdditionalTxnFeePub = 0;
						$TotalBaseFare = 0;
						$TotalTaxsandFees = 0;
						if ($value['FairRules']['FareBreakdown']) {
							foreach ($value['FairRules']['FareBreakdown'] as $FareBreakdown) {
								$MF = isset($FareBreakdown['MF']) ? $FareBreakdown['MF'] :0; //Management Fee
								$TDS = isset($FareBreakdown['TDS']) ? $FareBreakdown['TDS']:0; //Management Fee
								$YQ = isset($FareBreakdown['YQ']) ? $FareBreakdown['YQ']:0; //Fuel Surcharge
								$AGST = isset($FareBreakdown['AGST']) ? $FareBreakdown['AGST']:0; //Airline GST Component
								$MFT = isset($FareBreakdown['MFT']) ? $FareBreakdown['MFT']:0; //Management Fee Tax
								$OT = isset($FareBreakdown['OT']) ? $FareBreakdown['OT']:0; //Other Charges
								$MU = isset($FareBreakdown['MU']) ? $FareBreakdown['MU']:0; //Markup
								$YR = isset($FareBreakdown['YR']) ? $FareBreakdown['YR']:0; //Carrier Misc Fee
								$other = $MF + $YQ + $AGST + $MFT + $OT + $YR;
								if ($ICSourceSysId == 3) {
									$other =  $MF + $AGST + $MFT + $OT + $YR;
								}
								$PBaseFare = isset($FareBreakdown['BaseFare']) ? $FareBreakdown['BaseFare']:0;
								$intTotalGST = isset($FareBreakdown['intTotalGST']) ? $FareBreakdown['intTotalGST']:0;
								$FixedMarkUp = isset($FareBreakdown['FixedMarkUp']) ? $FareBreakdown['FixedMarkUp']:0;
								$apiMarkup = isset($FareBreakdown['apiMarkup']) ? $FareBreakdown['apiMarkup']:0;
								$IntCommission = isset($FareBreakdown['IntCommission']) ? $FareBreakdown['IntCommission']:0;
								$CommissionEarned = isset($FareBreakdown['CommissionEarned']) ? $FareBreakdown['CommissionEarned']:0;
								$CommisionPass = isset($FareBreakdown['CommisionPass']) ? $FareBreakdown['CommisionPass']:0;
								$ServiceFee = isset($FareBreakdown['ServiceFee']) ? $FareBreakdown['ServiceFee']:0;

								$paxPublishedFare = ($PBaseFare);
								$PassengerType = isset($FareBreakdown['PassengerType']) ? $FareBreakdown['PassengerType'] :0;
								$PassengerCount = isset($FareBreakdown['PassengerCount']) ? $FareBreakdown['PassengerCount']:0;
								$AdditionalTxnFeePub += isset($FareBreakdown['AdditionalTxnFeePub']) ? $FareBreakdown['AdditionalTxnFeePub']:0;

								$TaxesFees = ($other + $intTotalGST + $FixedMarkUp + $apiMarkup + $IntCommission - $CommissionEarned);
								if ($ICSourceSysId == 3) {
									$TaxesFees = ($other + $intTotalGST + $FixedMarkUp + $apiMarkup + $ServiceFee - $CommisionPass);
								}
								$TotalBaseFare += ($paxPublishedFare);
								$TotalTaxsandFees += ($TaxesFees);
							}
						}
						if($ICSourceSysId == 7 || $ICSourceSysId == 3){
							$PublishedFareINT = ($PublishedFareNewPrice);
						}elseif($ICSourceSysId == 11){
							$PublishedFareINT = isset($value['FairRules']['PublishedFare']) ? ($value['FairRules']['PublishedFare'] - $couponVal) :0;
						}else{
							$PublishedFareINT = (($TotalBaseFare + $TotalTaxsandFees) - $couponVal) * $this->CurrencyRate;
							
						}
						//$PublishedFareINT = ($value['FairRules']['PublishedFare'] - $couponVal);
						if ($k == 0) {
							$MealFare = $MealPrice * $this->CurrencyRate;
							$BaggFare = $BagPrice * $this->CurrencyRate;
						} else {
							$MealFare = $InbMealPrice * $this->CurrencyRate;
							$BaggFare = $InbBagPrice * $this->CurrencyRate;
						}
						$SeatPrice = 0;
						if ($value['Segments']) {
							foreach ($value['Segments'] as $seg) {
								if (!empty($selectedSeatSession->params) && isset($selectedSeatSession->params[$seg['segmentid']]) && !empty($selectedSeatSession->params[$seg['segmentid']])) {
									$selectedSeat = $selectedSeatSession->params[$seg['segmentid']];
									foreach ($selectedSeat as $val) {
										$SeatPrice += $val['amount'];
									}
								}
							}
						}
						$SeatFare = $SeatPrice * $this->CurrencyRate;
						$AgentCommisionEarnedINT = isset($finalFareSummary['GSTonComm']) ? ($finalFareSummary['CommEarned'] + $finalFareSummary['PLBEarned']) * $this->CurrencyRate :0;
						$AgentCommisionEarnedGSTINT = isset($finalFareSummary['GSTonComm']) ? ($finalFareSummary['GSTonComm'] + isset($finalFareSummary['GSTonPLB']) ? $finalFareSummary['GSTonPLB'] : 0) * $this->CurrencyRate :0;
						$AgencyMarkUpINT = isset($finalFareSummary['FixedMarkUp']) ? $finalFareSummary['FixedMarkUp'] * $this->CurrencyRate :0;
						$AgencyMarkUpGSTINT = isset($finalFareSummary['GSTOnMarkUp']) ? $finalFareSummary['GSTOnMarkUp'] * $this->CurrencyRate:0;
						$GTXMarkUpINT = isset($finalFareSummary['intGTXMarkUp']) ? $finalFareSummary['intGTXMarkUp'] * $this->CurrencyRate :0;
						// $BaseAmountINT = ($PublishedFareINT - ($AgentCommisionEarnedGSTINT + $AgencyMarkUpGSTINT + $AgentCommisionEarnedINT + $AgencyMarkUpINT + $GTXMarkUpINT));
						$BaseAmountINT = ($PublishedFareINT - $AgentCommisionEarnedINT - $AgencyMarkUpINT - $AgencyMarkUpGSTINT);
						if ($interNationalSearch == 1 && $route == 2 && $IsSeriesFareData != 1) {
							$FareSummary = $FareSummaryInt;
						} else {
							$FareSummary = array(
								'PublishedFare' => ($PublishedFareINT + $BaggFare + $MealFare + $SeatFare),
								'AgentCommisionEarned' => $AgentCommisionEarnedINT,
								'AgentCommisionEarnedGST' => $AgentCommisionEarnedGSTINT,
								'AgencyMarkUp' => $AgencyMarkUpINT,
								'AgencyMarkUpGST' => $AgencyMarkUpGSTINT,
								'GTXMarkUp' => $GTXMarkUpINT,
								'BaseAmount' => ($BaseAmountINT + $BaggFare + $MealFare + $SeatFare),
							);
						}


						$UpdateFare[$k] = array(
							'Price' => $BaseAmountINT,
							'NetPrice' => $PublishedFareINT,
							'AgencyMarkUp' => $AgencyMarkUpINT,
							'AgentServiceTaxAmount' => $AgencyMarkUpGSTINT,
							'MarkUp' => $AgentCommisionEarnedINT,
							'AgentsCustomServiceTaxAmount' => $AgentCommisionEarnedGSTINT,
							'GTXMarkup' => $GTXMarkUpINT,
							'GTXServiceTaxAmount' => 0,
							'TotalCost' => $PublishedFareINT,
							'MealFare' => $MealFare,
							'BaggFare' => $BaggFare,
							'SeatFare' => $SeatFare,
						);
						$FlightBookingTicketArr[] = $response;
						$ResponseStatus = isset($response['status']['success']) ? $response['status']['success'] : '0';
						if($ICSourceSysId != 16){
							$strTicketPNRLCC = isset($response['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails']) ? $response['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails'] : '';
						}
						$Passenger = isset($response['itemInfos']['AIR']['travellerInfos']) ? $response['itemInfos']['AIR']['travellerInfos'] : '';
						$strBookingIdLCC = isset($response['order']['bookingId']) ? $response['order']['bookingId'] : '0';
						if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
							$strBookingIdLCC = isset($response['order']['bookingId'][$k]) ? $response['order']['bookingId'][$k] : '0';
						}
						$bookingId = str_replace('TJ', 'BKR', $strBookingIdLCC);
						$segment = [];
						$segmentArray = [];
						$finalpnr = [];
						$finalgdspnr = [];
						
						if ($value['Segments']) {
							foreach ($value['Segments'] as $seg) {
								$originAirportCode = $seg['originAirportCode'];
								$destinationAirportCode = $seg['destinationAirportCode'];
								$segment[] = $originAirportCode . '-' . $destinationAirportCode;
								$segmentArray[] = $originAirportCode . '-' . $destinationAirportCode;
								$AirportCode = $originAirportCode . '-' . $destinationAirportCode;
								$finalpnr[] = isset($strTicketPNRLCC[$AirportCode]) ? $strTicketPNRLCC[$AirportCode] : '';
								$finalgdspnr[] = isset($strgdsPnrs[$AirportCode]) ? $strgdsPnrs[$AirportCode] : '';
							}
						}
						
						$finalpnr = $this->checkArrayKeyExist($finalpnr);
						$finalgdspnr = $this->checkArrayKeyExist($finalgdspnr);
						
						$customerpnr = [];
						if ($Passenger) {
							foreach ($Passenger as $pk => $pax) {
								$SelectedMeal = [];
								$SelectedSeat = [];
								$SelectedBag = [];
								$SelectedMeal__ = [];
								$SelectedSeat__ = [];
								$SelectedBag__ = [];
								$pnrDetails = isset($pax['pnrDetails']) ? $pax['pnrDetails'] :[];
								$ticketNumberDetails = isset($pax['ticketNumberDetails']) ? $pax['ticketNumberDetails'] :'';
								$SelectedBag_ = isset($pax['ssrBaggageInfos']) ? $pax['ssrBaggageInfos'] :[];
								$SelectedMeal_ = isset($pax['ssrMealInfos']) ? $pax['ssrMealInfos'] :[];
								$SelectedSeat_ = isset($pax['ssrSeatInfos']) ? $pax['ssrSeatInfos'] :[];
								$TicketNumber = [];
								$TicketId = [];
								$BagPrice_c = 0;
								$MealPrice_c = 0;
								$SeatPrice_c = 0;
								if($ICSourceSysId == 16 && $route == 2){
									$TicketNumber = array_values($pnrDetails);
									$TicketId = array_values($ticketNumberDetails);
									if($segmentArray){
										foreach($segmentArray as $sgvl){
											$BagPrice_c += isset($SelectedBag_[$sgvl]['amount']) ? $SelectedBag_[$sgvl]['amount'] : '';
											$MealPrice_c += isset($SelectedMeal_[$sgvl]['amount']) ? $SelectedMeal_[$sgvl]['amount'] : '';
											$SeatPrice_c += isset($SelectedSeat_[$sgvl]['amount']) ? $SelectedSeat_[$sgvl]['amount'] : '';
										}
									}
								}else{
									// echo "segmentArray<pre>";print_r($segmentArray);
									if($segmentArray){
										foreach($segmentArray as $sgvl){
											if($sgvl){
												// echo "pnrDetails<pre>";print_r($pnrDetails[$sgvl]);
												$TicketNumber[] = (isset($pnrDetails[$sgvl]) && !empty($pnrDetails[$sgvl])) ? $pnrDetails[$sgvl]:'';
												$TicketId[] = (isset($ticketNumberDetails[$sgvl]) && !empty($ticketNumberDetails[$sgvl])) ? $ticketNumberDetails[$sgvl]:'';
												if($SelectedBag_){
													$BagPrice_c += (isset($SelectedBag_[$sgvl]['amount']) && !empty($SelectedBag_[$sgvl]['amount'])) ? $SelectedBag_[$sgvl]['amount'] : 0;
													$MealPrice_c += (isset($SelectedMeal_[$sgvl]['amount']) && !empty($SelectedMeal_[$sgvl]['amount'])) ? $SelectedMeal_[$sgvl]['amount'] : 0;
													$SeatPrice_c += (isset($SelectedSeat_[$sgvl]['amount']) && !empty($SelectedSeat_[$sgvl]['amount'])) ? $SelectedSeat_[$sgvl]['amount'] : 0;
												}
											}
										}
									}
								}
								// die("kfhshfkshf");
								if($ICSourceSysId == 17 || $ICSourceSysId == 16 || $ICSourceSysId == 7 || $ICSourceSysId == 11) {
									
									if($SelectedBaggSessionNew->params && ($CustomerSession->params[$pk]['paxType'] == 1 || $CustomerSession->params[$pk]['paxType'] == 2)){
										foreach ($SelectedBaggSessionNew->params as $valueBag) {
											if($ICSourceSysId == 16) {
												foreach ($valueBag as $valB) {
													$Orgin = $valB['Origin'];
													$Destination = $valB['Destination'];
													$SelectedBag[$Orgin.'-'.$Destination][] = $valB;
												}
											}else{
												$Orgin = $valueBag['origin'];
												$Destination = $valueBag['destination'];
												$SelectedBag[$Orgin.'-'.$Destination][] = $valueBag;
											}
										}
									}
									if($SelectedMealSessionNew->params && ($CustomerSession->params[$pk]['paxType'] == 1 || $CustomerSession->params[$pk]['paxType'] == 2)){
										foreach ($SelectedMealSessionNew->params as $valueMeal) {
											if($ICSourceSysId == 16) {
												foreach ($valueMeal as $valM) {
													$Orgin = $valM['Origin'];
													$Destination = $valM['Destination'];
													$SelectedMeal[$Orgin.'-'.$Destination][] = $valM;
												}
											}else{
												$Orgin = $valueMeal['origin'];
												$Destination = $valueMeal['destination'];
												$SelectedMeal[$Orgin.'-'.$Destination][] = $valueMeal;
											}
										}
									}
									if($SelectedBaggSessionNewInb->params && ($CustomerSession->params[$pk]['paxType'] == 1 || $CustomerSession->params[$pk]['paxType'] == 2)){
										foreach ($SelectedBaggSessionNewInb->params as $valueBag) {
											if($ICSourceSysId == 16) {
												foreach ($valueBag as $valB) {
													$Orgin = $valB['Origin'];
													$Destination = $valB['Destination'];
													$SelectedBag[$Orgin.'-'.$Destination][] = $valB;
												}
											}else{
												$Orgin = $valueBag['origin'];
												$Destination = $valueBag['destination'];
												$SelectedBag[$Orgin.'-'.$Destination][] = $valueBag;
											}
										}
									}
									if($SelectedMealSessionNewInb->params && ($CustomerSession->params[$pk]['paxType'] == 1 || $CustomerSession->params[$pk]['paxType'] == 2)){
										foreach ($SelectedMealSessionNewInb->params as $valueMeal) {
											if($ICSourceSysId == 16) {
												foreach ($valueMeal as $valM) {
													$Orgin = $valM['Origin'];
													$Destination = $valM['Destination'];
													$SelectedMeal[$Orgin.'-'.$Destination][] = $valM;
												}
											}else{
												$Orgin = $valueMeal['origin'];
												$Destination = $valueMeal['destination'];
												$SelectedMeal[$Orgin.'-'.$Destination][] = $valueMeal;
											}
										}
									}
									
									if($selectedSeatSession->params && ($CustomerSession->params[$pk]['paxType'] == 1 || $CustomerSession->params[$pk]['paxType'] == 2)){
											foreach ($selectedSeatSession->params as $keySeg => $valueSeat) {
												if($ICSourceSysId == 7){
													$segmentData = isset($segArray[$keySeg]) ? $segArray[$keySeg] : [];
													$Orgin = $segmentData['originAirportCode'];
													$Destination = $segmentData['destinationAirportCode'];
												}
												foreach ($valueSeat as $ValSeat) {
													if($ICSourceSysId != 7){
														$Orgin = $ValSeat['Origin'];
														$Destination = $ValSeat['Destination'];
													}

													if(!empty($Orgin) && !empty($Destination)){
														$SelectedSeat[$Orgin.'-'.$Destination][] = $ValSeat;
													}
												}
										}
									}
									
									// data not insert proper in case of round trips i need to talk to sabir sir
									
									$customerpnr[$pk]['PNR_Number'] = implode('-', $pnrDetails);
									$customerpnr[$pk]['TicketId'] = implode('-', $TicketNumber);
									$customerpnr[$pk]['TicketNumber'] = implode('-', $TicketId);
									$customerpnr[$pk]['sectors'] = implode('@@', $segmentArray);
									
									if($isgstapply == 1){
										$customerpnr[$pk]['isgstapply'] = !empty($isgstapply) ? ($isgstapply) :0;
									}
									
								}
							}
						}
						
						$objFlight = new Travel_Model_FlightMaster();
						// echo "ResponseStatus ($response)";die;
						if ($ResponseStatus == 1) {
							if (!empty($Invoicedata)) {
								// Create GTX Invoice
								$Invoiceresponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->InvoiceCreate($Invoicedata, $BookingData);
							}
							$update = array(
								'API_Response' => json_encode($value),
								'API_Response_Ticket' => json_encode($response),
								'FlightQueryids' => json_encode($FlightQueryids),
								'PNR_Number' => implode('-', $finalpnr),
								'BookingId' => $bookingId,
								'InvoiceNo' => isset($Invoiceresponse['InvoiceNumber']) ? $Invoiceresponse['InvoiceNumber'] : '',
								'status' => 1,
								'TPSysId' => $TPSysId,
							);
							
							try {

								$update['PublishedFare'] = isset($value['FairRules']['PublishedFare']) ? $value['FairRules']['PublishedFare'] : 0;
								$update['BaseFare'] = isset($value['FairRules']['BaseFare']) ? $value['FairRules']['BaseFare'] : 0;
								$update['Tax'] = !empty($value['FairRules']['Tax']) ? $value['FairRules']['Tax'] : 0;
								$update['YQTax'] = !empty($value['FairRules']['YQTax']) ? $value['FairRules']['YQTax'] : 0;
								$update['OtherCharges'] = !empty($value['FairRules']['OtherCharges']) ? $value['FairRules']['OtherCharges'] : 0;
								$update['Discount'] = !empty($value['FairRules']['Discount']) ? $value['FairRules']['Discount'] : 0;
								$update['ServiceFee'] = !empty($value['FairRules']['ServiceFee']) ? $value['FairRules']['ServiceFee'] : 0;
								$update['OfferedFare'] = isset($value['FairRules']['PublishedFare']) ? $value['FairRules']['PublishedFare'] : 0;
								if($ICSourceSysId == 16){
									$strBookingIdLCC = isset($response['order']['BookingTrackId']) ? $response['order']['BookingTrackId'] : '0';

									$update['APIBookingId'] = $strBookingIdLCC;
									$update['PNR_Number'] = $finalpnr;
								}
								$where = "id = " . $flight_booking_id[$k]; //exit;
								
								// echo "where<pre>";print_r($update);
								// echo "where<pre>";print_r($finalpnr);
								// die;
								$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
								// if ($interNationalSearch == 1 && $route == 2 && $IsSeriesFareData==1) {
								// 	$where1 = "id = " . $flight_booking_id[1]; //exit;
								// 	$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where1);
								// }
								if ($OrderBookingStatus == 'PENDING') {
									$value['OnwardAutoTicket'] = 0;
								}
								$responseArray = array(
									'value' => $value,
									'response' => $response
								);
								if($ICSourceSysId == 17 || $ICSourceSysId == 16 || $ICSourceSysId == 7 || $ICSourceSysId == 3 || $ICSourceSysId == 11){
									if($ICSourceSysId == 16 && $interNationalSearch == 1 && $route == 2){
										$finalpnr = [$strTicketPNRLCC];
									}
									$postFieldArray = array(
										'PublishedFare' => ($PublishedFareINT + $BaggFare + $MealFare + $SeatFare),
										'Cost' => ($BaseAmountINT), /// without Markup,gst. with ssr
										'MasterTPSysId' => $MasterTPSysId,
										'TPSysId' => $TPSysId,
										'TrxId' => $TrxId,
										'VersionId' => $VersionId[$k],
										'PNRNumber' => !empty($finalpnr) ? implode('-', $finalpnr) : '',
										'GDSPNRNumber' => !empty($finalgdspnr) ? implode('-', $finalgdspnr) : '',
										'customerpnr' => $customerpnr,
										'Keys' => $k,
										'ErrorCode' => 0,
										'IsBookingStatus' => 1,
										'OnwardAutoTicket' => ($OrderBookingStatus == 'PENDING')?0:1,
										'sectorTitle' => $value['SourceAirportCode'] . '-' . $value['DestAirportCode'],
										'BookingId' => $bookingId,
										'APIBookingId' => $strBookingIdLCC,
										'IsWebsite' => 0,
									);
									if ($isgstapply == 1) {
										$postFieldArray['gstData'] = json_encode($gstData);
									}
								}else{
									$postFieldArray = array(
										'MasterTPSysId' => $MasterTPSysId,
										'TPSysId' => $TPSysId,
										'TrxId' => $TrxId,
										'VersionId' => $VersionId[$k],
										'XRefBookingId' => $bookingId,
										'APIBookingRes' => json_encode($responseArray),
										'FareSummaryAir' => json_encode($FareSummary),
										'UpdateFare' => json_encode([$UpdateFare[$k]]),
										'Keys' => $k,
										'Passenger' => json_encode($Passenger),
										'gstData' => json_encode($gstData),
										'ErrorCode' => 0,
										'IsBookingStatus' => 1,
									);
								}
								if ($k == 0 && $IsCancellationProtection == 1) {
									$postFieldArray['CancellationProtectionData'] = $CancellationProtectionDataCode;
								}
								
								
								$strFilePath = "flight/updateFlightBookingDetails/" . time() . "_update_request.json";
								Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $postFieldArray);
								// echo "postFieldArray<pre>";print_r(json_encode($postFieldArray));die;
								$model = new Gtxwebservices_Model_Webservices();

								if($ICSourceSysId == 17 || $ICSourceSysId == 16 || $ICSourceSysId == 7 || $ICSourceSysId == 3 || $ICSourceSysId == 11) {
									$result = json_decode($model->UPDATE_FLIGHT_BOOKING($postFieldArray),true);
								
								}else{
									$result = json_decode($model->updateFlightBookingDetails($postFieldArray), true);
								}
								echo '<pre>';print_r($result);
								echo '<pre>';print_r($postFieldArray);
								//
								$AirlineName = $value['AirlineName'];
								$TotalFlightMembers = $value['TotalFlightMembers'];
								$JourneyType = $value['JourneyType'];
								$SourceAirportCode = $value['SourceAirportCode'];
								$DestAirportCode = $value['DestAirportCode'];
								$ResponseStatusPush = isset($result['apistatus']) ? $result['apistatus'] : 0;
								$ErrorMessage = isset($result['message']) ? $result['message'] : '';
								$logParams = [
									"user_id"      => 1,
									"AgencySysId"      => $this->gtxagencysysid,
									"custom_error" => ($ResponseStatusPush == 1) ? "Flight GTX Update Success" : "Flight GTX Update Failed",
									'error'        => $ErrorMessage,
									"text_udf"     => ['response' => $result], // Response
									"char_udf"     => ['request' => $postFieldArray], // Request
									"udf1"         => $SearchFlightTraceId,
									"udf5"                         => 'ticket',
									"from_destination"             => $SourceAirportCode,
									"to_destination"               => $DestAirportCode,
									"flight_type"                  => (int)$JourneyType,
									"source"                       => 1,
									"Pax"                          => ($TotalFlightMembers),
									"Supplier"                     => 'TRIPJACK',
									"Airline"                      => $AirlineName,
									"status"       => ($ResponseStatusPush == 1) ? 2 : 1,
								];
								Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
							} catch (Exception $error) {
								print_r($error->getMessage());die;
							}
							if (!empty($booking_customer_id) && $ICSourceSysId == 16 && $route == 2) {
								foreach ($booking_customer_id[$k] as  $keyCust => $customerId) {
									if($k == 0){
										$customerKey = $keyCust;
									}
									if($k == 1){
										$customerKey = $keyCust + (count($booking_customer_id[0]));
									}
									$TicketId = implode('-', $Passenger[$customerKey]['pnrDetails']);
									$TicketNumber = isset($Passenger[$customerKey]['ticketNumberDetails']) ? implode('-', $Passenger[$customerKey]['ticketNumberDetails']) : '';
									$gdsPnrs = (isset($Passenger[$customerKey]['gdsPnrs']) && !empty($Passenger[$customerKey]['gdsPnrs'])) ? implode('-', $Passenger[$customerKey]['gdsPnrs']) : '';
									$updatep = array(
										'PNR_Number' => !empty($gdsPnrs) ? $gdsPnrs : $TicketId,
										'TicketId' => $TicketId,
										'TicketNumber' => $TicketNumber,
										'sectors' => implode('-', $segment),
										'BookingId' => $bookingId,
									);
									$updatep['APIBookingId'] = $strBookingIdLCC;
									$wherep = "id = " . $customerId;
									$objFlight->UpdateFlightData('tbl_flight_booking_customer', $updatep, $wherep);
								}
							}else{
								if ($Passenger) {
									foreach ($Passenger as $pk => $pax) {
										$TicketId = implode('-', $pax['pnrDetails']);
										$TicketNumber = isset($pax['ticketNumberDetails']) ? implode('-', $pax['ticketNumberDetails']) : '';
										$gdsPnrs = (isset($pax['gdsPnrs']) && !empty($pax['gdsPnrs'])) ? implode('-', $pax['gdsPnrs']) : '';
										$updatep = array(
											'PNR_Number' => !empty($gdsPnrs) ? $gdsPnrs : $TicketId,
											'TicketId' => $TicketId,
											'TicketNumber' => $TicketNumber,
											'sectors' => implode('-', $segment),
											'BookingId' => $bookingId,
										);
										if($ICSourceSysId == 16){
											$updatep['APIBookingId'] = $strBookingIdLCC;
										}
										
										// if($ICSourceSysId == 16 && $route == 2) {
										// 	echo "updatep<pre>";print_r($updatep);
										// 	$booking_customer_id__ = array_merge($booking_customer_id[0],$booking_customer_id[1]);
										// 	$wherep = "id = " . $booking_customer_id__[$pk];
										// 	$objFlight->UpdateFlightData('tbl_flight_booking_customer', $updatep, $wherep);
										// }else{
											$wherep = "id = " . $booking_customer_id[0][$pk];
											$objFlight->UpdateFlightData('tbl_flight_booking_customer', $updatep, $wherep);
										// }
									}
								}
							}
							
							if ($updated) {
								$responseReturn[] = array('success' => true, 'message' => $ErrorMessage, 'IsLCC' => $value['IsLCC']);
							}
						} else {
							$update = array(
								'API_Response' => json_encode($response),
								'API_Response_Ticket' => '',
							);
							$where = "id = " . $flight_booking_id[$k]; //exit;
							$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
							$responseReturn[] = array('success' => false, 'message' => $ErrorMessage, 'IsLCC' => $value['IsLCC']);
						}
					}
					// echo "responseReturn<pre>";print_r($responseReturn);
					// echo "ResponseStatus<pre>";print_r($ResponseStatus);
					
					// die;
					die("end");
					if ($responseReturn && $ResponseStatus == 1) {
						$arrUrlData['FlightBookingTicketArr'] = $FlightBookingTicketArr;
						$insertArr = array(
							'TraceId' => $traceId,
							'json_data' => json_encode($arrUrlData),
							'created_at' => date('Y-m-d H:i:s'),
						);
						$this->objMdl->rv_delete('tbl_temp_data', array('TraceId = ?' => $traceId));
						$objFlight = new Travel_Model_FlightMaster();
						$objFlight->InsertFlightData('tbl_temp_data', $insertArr);
						//                Zend_Session::namespaceUnset('FlightBookingTicketSession');
						$FlightBookingTicketSession = new Zend_Session_Namespace('FlightBookingTicketSession');
						$FlightBookingTicketSession->params = $FlightBookingTicketArr;
						$Return = array('success' => true, 'message' => 'done', 'IsLCC' => $IsLCC,'ICSourceSysId'=>$ICSourceSysId,'TPSysId'=>$TPSysId);
						echo json_encode($Return);
						exit;
					} else {
						$Return = array('success' => false, 'message' => 'failed', 'IsLCC' => $IsLCC,'ICSourceSysId'=>$ICSourceSysId,'TPSysId'=>$TPSysId);
						echo json_encode($Return);
						exit;
					}
				}
				echo "<pre>";print_r($ResponseStatus);
				echo "<pre>";print_r($response);
				die('d');
			}
			
			$class = $sessionFlightSearchParams['class'];
			$route = $sessionFlightSearchParams['route'];
			$interNationalSearch = $sessionFlightSearchParams['interNationalSearch'];
			$this->view->traceId = $param['traceId'];
			$this->view->departure_date = $sessionFlightSearchParams['strDepatureDate'];
			$this->view->return_dates = $sessionFlightSearchParams['strReturnDate'];
			$SearchFlightTraceId = !empty($sessionFlightSearchParams['SearchFlightTraceId']) ? $sessionFlightSearchParams['SearchFlightTraceId'] : $traceId;
			$ICSourceSysId = !empty($BookingData[0]['ICSourceSysId']) ? $BookingData[0]['ICSourceSysId'] : 7;

			$ResponseStatus = isset($API_Response_Ticket['status']['success']) ? $API_Response_Ticket['status']['success'] : '0';

			$status = ($flightdata['status']);
			if ($status == 1 && $paymentStatus == 1 && $ResponseStatus == 1 && $temp_data) {
				$PublishedFare = 0;
				$agencyMarkUp = 0;
				$gtxMarkup = 0;
				$offerFare = 0;
				$gtxMarkupGST = 0;
				$agencyMarkUpGST = 0;
				$TotalDiscount = 0;
				$misxItems_name = [];
				if ($BookingData) {
					foreach ($BookingData as $amount) {
						$AdditionalTxnFeePub = 0;
						$TotalBaseFare = 0;
						$TotalTaxsandFees = 0;
						if ($amount['FairRules']['FareBreakdown']) {
							foreach ($amount['FairRules']['FareBreakdown'] as $value) {

								$MF = $value['MF']; //Management Fee
								$TDS = $value['TDS']; //Management Fee
								$YQ = $value['YQ']; //Fuel Surcharge
								$AGST = $value['AGST']; //Airline GST Component
								$MFT = $value['MFT']; //Management Fee Tax
								// $OT = $value['OT']; //Other Charges
								$OT = isset($value['OT'])?$value['OT']:$value['TaxBR']['OT']; //Other Charges
								$MU = $value['MU']; //Markup
								$YR = $value['YR']; //Carrier Misc Fee
								$other = $MF + $YQ + $AGST + $MFT + $OT + $YR;
								if ($ICSourceSysId == 3) {
									$other =  $MF + $AGST + $MFT + $OT + $YR;
								}
								$PBaseFare = $value['BaseFare'];
								$intTotalGST = $value['intTotalGST'];
								$FixedMarkUp = $value['FixedMarkUp'];
								$apiMarkup = $value['apiMarkup'];
								$IntCommission = $value['IntCommission'];
								$CommissionEarned = $value['CommissionEarned'];
								$CommisionPass = $value['CommisionPass'];
								$ServiceFee = $value['ServiceFee'];

								$paxPublishedFare = ($PBaseFare);
								$PassengerType = $value['PassengerType'];
								$PassengerCount = $value['PassengerCount'];
								$AdditionalTxnFeePub += $value['AdditionalTxnFeePub'];

								$TaxesFees = ($other + $intTotalGST + $FixedMarkUp + $apiMarkup + $IntCommission - $CommissionEarned);
								if ($ICSourceSysId == 3) {
									$TaxesFees = ($other + $intTotalGST + $FixedMarkUp + $apiMarkup + $ServiceFee - $CommisionPass);
								}
								$TotalBaseFare += ($paxPublishedFare);
								$TotalTaxsandFees += ($TaxesFees);
							}
						}
						$PublishedFare += $PublishedFare__ = ($TotalBaseFare + $TotalTaxsandFees);



						//echo "<pre>";print_r($amount['FairRules']);
						$AddiMarkup__ = isset($amount['FairRules']['AddiMarkup']) ? $amount['FairRules']['AddiMarkup'] : 0;
						$AddiTaxOnMarkup__ = isset($amount['FairRules']['AddiTaxOnMarkup']) ? $amount['FairRules']['AddiTaxOnMarkup'] : 0;

						//$PublishedFare += ($amount['FairRules']['PublishedFare'] + $AddiMarkup__ + $AddiTaxOnMarkup__);
						$agencyMarkUp += $amount['FairRules']['FixedMarkUp'] + $AddiMarkup__;
						$gtxMarkup += $amount['FairRules']['intGTXMarkUp'];
						$offerFare += $amount['FairRules']['OfferedFare'];
						$gtxMarkupGST += $amount['FairRules']['GTXMarkUpGST'];
						$agencyMarkUpGST += $amount['FairRules']['GSTOnMarkUp'] + $AddiTaxOnMarkup__;
						$SourceAirportCode = $amount['SourceAirportCode'];
						$DestAirportCode = $amount['DestAirportCode'];
						$FlightNumber = $amount['FlightNumber'];
						$AirlineName = $amount['AirlineName'];

						$Description = $SourceAirportCode . '-' . $DestAirportCode . '-' . $AirlineName . ' ' . $FlightNumber;
						$couponVal = isset($amount['FairRules']['couponVal']) ? $amount['FairRules']['couponVal'] : 0;
						$TotalDiscount += $couponVal;
						//$PublishedFare__ = isset($amount['FairRules']['PublishedFare'])?$amount['FairRules']['PublishedFare'] + $AddiMarkup__ + $AddiTaxOnMarkup__:0;
						$FixedMarkUp__ = isset($amount['FairRules']['FixedMarkUp']) ? $amount['FairRules']['FixedMarkUp'] + $AddiMarkup__ : 0;
						$GSTOnMarkUp__ = isset($amount['FairRules']['GSTOnMarkUp']) ? $amount['FairRules']['GSTOnMarkUp'] + $AddiTaxOnMarkup__ : 0;
						$PublishedFare__ = $PublishedFare__;
						//echo "<pre>";print_r($amount['FairRules']);
						// echo "<pre>";print_r($FixedMarkUp__);
						// echo "<pre>";print_r($GSTOnMarkUp__);
						$TotalFare = ($PublishedFare__ - $FixedMarkUp__ - $GSTOnMarkUp__);
						$TotalAmount = $PublishedFare__;
						$SubTotal = ($PublishedFare__ - $GSTOnMarkUp__);
						$TotalGST = ($GSTOnMarkUp__);
						$TotalFixedMarkUp = $FixedMarkUp__;
						$TotalcouponVal = $couponVal;


						$misxItems_name[] = [
							'AgencySysId' => $this->gtxagencysysid,
							'AgentSysId' => $this->gtxagentsysid,
							'MisxItems_name' => 'Flight',
							'Description' => $Description,
							'ItemQty' => 1,
							'ItemRates' => ($TotalFare),
							'Total' => $TotalFare,
							'DiscountType' => $TotalcouponVal,
							'Discount' => 1,
							'TotalDiscount' => $TotalcouponVal,
							'TotalAmount' => $TotalAmount,
							'MarkupType' => '',
							'Markup' => $TotalFixedMarkUp,
							'TotalMarkup' => $TotalFixedMarkUp,
							'SubTotal' => $SubTotal,
							'ServiceFeeTotal' => $TotalGST,
							'GSTPercentage' => '18',
							'TotalGST' => $TotalGST,
							'SGST' => ($TotalGST / 2),
							'CGST' => ($TotalGST / 2),
							'IGST' => $TotalGST,
							'ItemsSACCode' => '',
						];
					}
				}

				if ($BookingData) {
					$BagPrice = 0;
					$InbBagPrice = 0;
					$MealPrice = 0;
					$InbMealPrice = 0;
					$SeatPrice = 0;
					if ($SelectedBaggSessionNew) {
						foreach ($SelectedBaggSessionNew as $values) {
							$BagPrice += $values['Price'];
						}
					}
					if ($SelectedMealSessionNew) {
						foreach ($SelectedMealSessionNew as $values) {
							$MealPrice += $values['Price'];
						}
					}
					$SeatPrice = 0;
					if ($selectedSeatSession->params) {
						foreach ($selectedSeatSession->params as $values) {
							foreach ($values as $val) {
								$SeatPrice += $val['amount'];
							}
						}
					}

					$PublishedFare = $ProtectionOnPublished = ($PublishedFare + $BagPrice + $MealPrice + $SeatPrice);
					$TotalInvoiceValue = ($PublishedFare - $agencyMarkUpGST);

					$CPAmountWithTax = $CancellationProtectionPrice;
					//echo $PublishedFare.'='.$BaggFare.'='.$MealFare.'='.$SeatPrice.'===='.$TotalDiscount.'==='.$CPAmountWithTax;
					$CPAmount = 0;
					// if ($IsCancellationProtection == 1) {
					// 	$totalPayableAmount = ($PublishedFare);
					// 	if ($CencelattionData == 1 && !empty($CPPercentVal)) {
					// 		$CPAmount = ($totalPayableAmount * $CPPercentVal) / 100;
					// 		$CPAmountWithTax = $CPAmount + ($CPAmount * 18 / 100);
					// 	}

					// }
					$PublishedFare = ($PublishedFare + $CPAmountWithTax);
					$PublishedFare = ($PublishedFare - $TotalDiscount);

					$TotalInvoiceValue = ($TotalInvoiceValue + $CPAmountWithTax);

					$isgstapply = isset($BookingData[0]['FairRules']['IsGSTRequired']) ? $BookingData[0]['FairRules']['IsGSTRequired'] : 0;
					$Currency = isset($BookingData[0]['FairRules']['Currency']) ? $BookingData[0]['FairRules']['Currency'] : 0;
					$itemCount = count($misxItems_name);
					if ($IsCancellationProtection == 1) {
						$misxItems_name[$itemCount] = array(
							'MisxItems_name' => 'Cancellation Protection',
							'Description' => 'Refund Upgrade',
							'ItemQty' => 1,
							'ItemRates' => ($CPAmountWithTax),
							'Total' => $CPAmountWithTax,
							'DiscountType' => 0,
							'Discount' => 0,
							'TotalDiscount' => 0,
							'TotalAmount' => 0,
							'MarkupType' => '',
							'Markup' => 0,
							'TotalMarkup' => 0,
							'SubTotal' => $CPAmountWithTax,
							'ServiceFeeTotal' => 0,
							'GSTPercentage' => 0,
							'TotalGST' => 0,
							'SGST' => 0,
							'CGST' => 0,
							'IGST' => 0,
							'ItemsSACCode' => '',
						);
					}
					$itemCount = count($misxItems_name);
					if (!empty($BaggFare) && $BaggFare > 0) {
						$misxItems_name[$itemCount] = array(
							'MisxItems_name' => 'Add ons',
							'Description' => 'Baggage',
							'ItemQty' => 1,
							'ItemRates' => ($BaggFare),
							'Total' => $BaggFare,
							'DiscountType' => 0,
							'Discount' => 0,
							'TotalDiscount' => 0,
							'TotalAmount' => 0,
							'MarkupType' => '',
							'Markup' => 0,
							'TotalMarkup' => 0,
							'SubTotal' => $BaggFare,
							'ServiceFeeTotal' => 0,
							'GSTPercentage' => 0,
							'TotalGST' => 0,
							'SGST' => 0,
							'CGST' => 0,
							'IGST' => 0,
							'ItemsSACCode' => '',
						);
					}
					$itemCount = count($misxItems_name);
					if (!empty($MealFare) && $MealFare > 0) {
						$misxItems_name[$itemCount] = array(
							'MisxItems_name' => 'Add ons',
							'Description' => 'Meal',
							'ItemQty' => 1,
							'ItemRates' => ($MealFare),
							'Total' => $MealFare,
							'DiscountType' => 0,
							'Discount' => 0,
							'TotalDiscount' => 0,
							'TotalAmount' => 0,
							'MarkupType' => '',
							'Markup' => 0,
							'TotalMarkup' => 0,
							'SubTotal' => $MealFare,
							'ServiceFeeTotal' => 0,
							'GSTPercentage' => 0,
							'TotalGST' => 0,
							'SGST' => 0,
							'CGST' => 0,
							'IGST' => 0,
							'ItemsSACCode' => '',
						);
					}
					$itemCount = count($misxItems_name);
					if (!empty($SeatPrice) && $SeatPrice > 0) {
						$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' => '',
						);
					}
					$Invoicedata = [
						'AgentSysId' => $this->gtxagencysysid,
						'CustomerSysId' => $CustomerSysIdGTX,
						'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' => '',
						'Currency' => 1,
						'TotalInvoiceValue' => $TotalInvoiceValue,
						'InvoiceStatus' => true,
						'TotalCGST' => ($agencyMarkUpGST / 2),
						'TotalSGST' => ($agencyMarkUpGST / 2),
						'TotalIGST' => $agencyMarkUpGST,
						'SumdiscountItem' => 0,
						'OtherDiscount' => $TotalDiscount,
						'otherDiscountVal' => $TotalDiscount,
						'TotalAdvance' => $PublishedFare,
						'TotalDueAmount' => 0,
						'InvoiceValue' => $PublishedFare,
						'notes' => 'Flight Ticket',
						'termsandcondition' => '',
						'client_state' => '',
						'Advance' => 0,
						'PaymentType' => 4,
						'paymentNote' => 'Online',
						'misxItems_name' => $misxItems_name,

					];
					$Invoicedata = isset($response['Invoicedata']) ? $response['Invoicedata'] : $Invoicedata;
					// echo "<pre>";
					// print_r($Invoicedata);
					// echo "<pre>";
					// echo "<pre>";
					// print_r($CancellationProtectionData);
					// echo "<pre>";
					// print_r($CustomerSysIdGTX);
					//die('sssss');
					$ErrorMessage = isset($API_Response_Ticket['errors'][0]['message']) ? $API_Response_Ticket['errors'][0]['message'] : '';
					if ($interNationalSearch == 1 && $route == 2) {
						$MealFare_Int = ($MealPrice + $InbMealPrice);
						$BaggFare_Int = ($BagPrice + $InbBagPrice);
						$SeatPriceInt = 0;
						if ($selectedSeatSession->params) {
							foreach ($selectedSeatSession->params as $values) {
								foreach ($values as $val) {
									$SeatPriceInt += $val['amount'];
								}
							}
						}
						$SeatFare_Int = ($SeatPriceInt);
						$BookingDatadd = $BookingData[0]['InternationalData'];
						$finalFareSummary = $BookingDatadd['Fare'];
						$PublishedFareINT = $BookingDatadd['Fare']['PublishedFare'];
						$AgentCommisionEarnedINT = ($finalFareSummary['CommEarned'] + $finalFareSummary['PLBEarned']);
						$AgentCommisionEarnedGSTINT = ($finalFareSummary['GSTonComm'] + isset($finalFareSummary['GSTonPLB']) ? $finalFareSummary['GSTonPLB'] : 0);
						$AgencyMarkUpINT = $finalFareSummary['FixedMarkUp'];
						$AgencyMarkUpGSTINT = $finalFareSummary['GSTOnMarkUp'];
						$GTXMarkUpINT = $finalFareSummary['intGTXMarkUp'];
						$BaseAmountINT = ($PublishedFareINT - $AgentCommisionEarnedINT);
						$FareSummaryInt = array(
							'PublishedFare' => ($PublishedFareINT + $BaggFare_Int + $MealFare_Int + $SeatFare_Int),
							'AgentCommisionEarned' => $AgentCommisionEarnedINT,
							'AgentCommisionEarnedGST' => $AgentCommisionEarnedGSTINT,
							'AgencyMarkUp' => $AgencyMarkUpINT,
							'AgencyMarkUpGST' => $AgencyMarkUpGSTINT,
							'GTXMarkUp' => $GTXMarkUpINT,
							'BaseAmount' => ($BaseAmountINT + $BaggFare_Int + $MealFare_Int + $SeatFare_Int),
						);
					}

					$MealFare = ($MealPrice + $InbMealPrice);
					$BaggFare = ($BagPrice + $InbBagPrice);

					$gstData = array(
						'GstNumber' => (isset($CustomerSession->params[0]['gstnnumber']) && !empty($CustomerSession->params[0]['gstnnumber'])) ? $CustomerSession->params[0]['gstnnumber'] : '',
						'GstCompany' => (isset($CustomerSession->params[0]['companyname']) && !empty($CustomerSession->params[0]['companyname'])) ? $CustomerSession->params[0]['companyname'] : '',
						'GstEmail' => (isset($CustomerSession->params[0]['gstemail']) && !empty($CustomerSession->params[0]['gstemail'])) ? $CustomerSession->params[0]['gstemail'] : '',
						'GstPhone' => (isset($CustomerSession->params[0]['gstphone']) && !empty($CustomerSession->params[0]['gstphone'])) ? $CustomerSession->params[0]['gstphone'] : '',
						'GstAddress' => (isset($CustomerSession->params[0]['gstaddress']) && !empty($CustomerSession->params[0]['gstaddress'])) ? $CustomerSession->params[0]['gstaddress'] : '',
						'GstState' => (isset($CustomerSession->params[0]['gststate']) && !empty($CustomerSession->params[0]['gststate'])) ? $CustomerSession->params[0]['gststate'] : '',
					);
					$FlightBookingTicketArr = [];
					$responseReturn = [];
					foreach ($BookingData as $k => $value) {
						$finalFareSummary = $value['FairRules'];
						//echo '<pre>';print_r($finalFareSummary);
						$couponApply = isset($value['FairRules']['couponApply']) ? $value['FairRules']['couponApply'] : 0;
						if ($couponApply == 1 || $couponApply == '1') {
							$couponVal = isset($value['FairRules']['couponVal']) ? $value['FairRules']['couponVal'] : 0;
						} else {
							$couponVal = 0;
						}
						$AdditionalTxnFeePub = 0;
						$TotalBaseFare = 0;
						$TotalTaxsandFees = 0;
						if ($value['FairRules']['FareBreakdown']) {
							foreach ($value['FairRules']['FareBreakdown'] as $FareBreakdown) {

								$MF = $FareBreakdown['MF']; //Management Fee
								$TDS = $FareBreakdown['TDS']; //Management Fee
								$YQ = $FareBreakdown['YQ']; //Fuel Surcharge
								$AGST = $FareBreakdown['AGST']; //Airline GST Component
								$MFT = $FareBreakdown['MFT']; //Management Fee Tax
								$OT = $FareBreakdown['OT']; //Other Charges
								$MU = $FareBreakdown['MU']; //Markup
								$YR = $FareBreakdown['YR']; //Carrier Misc Fee
								$other = $MF + $YQ + $AGST + $MFT + $OT + $YR;
								if ($ICSourceSysId == 3) {
									$other =  $MF + $AGST + $MFT + $OT + $YR;
								}
								$PBaseFare = $FareBreakdown['BaseFare'];
								$intTotalGST = $FareBreakdown['intTotalGST'];
								$FixedMarkUp = $FareBreakdown['FixedMarkUp'];
								$apiMarkup = $FareBreakdown['apiMarkup'];
								$IntCommission = $FareBreakdown['IntCommission'];
								$CommissionEarned = $FareBreakdown['CommissionEarned'];
								$CommisionPass = $FareBreakdown['CommisionPass'];
								$ServiceFee = $FareBreakdown['ServiceFee'];

								$paxPublishedFare = ($PBaseFare);
								$PassengerType = $FareBreakdown['PassengerType'];
								$PassengerCount = $FareBreakdown['PassengerCount'];
								$AdditionalTxnFeePub += $FareBreakdown['AdditionalTxnFeePub'];

								$TaxesFees = ($other + $intTotalGST + $FixedMarkUp + $apiMarkup + $IntCommission - $CommissionEarned);
								if ($ICSourceSysId == 3) {
									$TaxesFees = ($other + $intTotalGST + $FixedMarkUp + $apiMarkup + $ServiceFee - $CommisionPass);
								}
								$TotalBaseFare += ($paxPublishedFare);
								$TotalTaxsandFees += ($TaxesFees);
							}
						}
						$PublishedFareINT = (($TotalBaseFare + $TotalTaxsandFees) - $couponVal);

						//$PublishedFareINT = ($value['FairRules']['PublishedFare'] - $couponVal);
						if ($k == 0) {
							$MealFare = $MealPrice;
							$BaggFare = $BagPrice;
						} else {
							$MealFare = $InbMealPrice;
							$BaggFare = $InbBagPrice;
						}
						$SeatPrice = 0;
						if ($value['Segments']) {
							foreach ($value['Segments'] as $seg) {
								if (!empty($selectedSeatSession) && isset($selectedSeatSession[$seg['segmentid']]) && !empty($selectedSeatSession[$seg['segmentid']])) {
									$selectedSeat = $selectedSeatSession[$seg['segmentid']];
									foreach ($selectedSeat as $val) {
										$SeatPrice += $val['amount'];
									}
								}
							}
						}
						$SeatFare = $SeatPrice;
						$AgentCommisionEarnedINT = ($finalFareSummary['CommEarned'] + $finalFareSummary['PLBEarned']);
						$AgentCommisionEarnedGSTINT = ($finalFareSummary['GSTonComm'] + isset($finalFareSummary['GSTonPLB']) ? $finalFareSummary['GSTonPLB'] : 0);
						$AgencyMarkUpINT = $finalFareSummary['FixedMarkUp'];
						$AgencyMarkUpGSTINT = $finalFareSummary['GSTOnMarkUp'];
						$GTXMarkUpINT = $finalFareSummary['intGTXMarkUp'];
						// $BaseAmountINT = ($PublishedFareINT - ($AgentCommisionEarnedGSTINT + $AgencyMarkUpGSTINT + $AgentCommisionEarnedINT + $AgencyMarkUpINT + $GTXMarkUpINT));
						$BaseAmountINT = ($PublishedFareINT - $AgentCommisionEarnedINT);
						if ($interNationalSearch == 1 && $route == 2) {
							$FareSummary = $FareSummaryInt;
						} else {
							$FareSummary = array(
								'PublishedFare' => ($PublishedFareINT + $BaggFare + $MealFare + $SeatFare),
								'AgentCommisionEarned' => $AgentCommisionEarnedINT,
								'AgentCommisionEarnedGST' => $AgentCommisionEarnedGSTINT,
								'AgencyMarkUp' => $AgencyMarkUpINT,
								'AgencyMarkUpGST' => $AgencyMarkUpGSTINT,
								'GTXMarkUp' => $GTXMarkUpINT,
								'BaseAmount' => ($BaseAmountINT + $BaggFare + $MealFare + $SeatFare),
							);
						}


						$UpdateFare[$k] = array(
							'Price' => $BaseAmountINT,
							'NetPrice' => $PublishedFareINT,
							'AgencyMarkUp' => $AgencyMarkUpINT,
							'AgentServiceTaxAmount' => $AgencyMarkUpGSTINT,
							'MarkUp' => $AgentCommisionEarnedINT,
							'AgentsCustomServiceTaxAmount' => $AgentCommisionEarnedGSTINT,
							'GTXMarkup' => $GTXMarkUpINT,
							'GTXServiceTaxAmount' => 0,
							'TotalCost' => $PublishedFareINT,
							'MealFare' => $MealFare,
							'BaggFare' => $BaggFare,
							'SeatFare' => $SeatFare,
						);
						//echo '<pre>';print_r([$UpdateFare[$k]]);
						//$segment = $value['Segments']['originAirportCode'] . '-' . $value['Segments']['destinationAirportCode'];
						$FlightBookingTicketArr[] = $API_Response_Ticket;
						$ResponseStatus = isset($API_Response_Ticket['status']['success']) ? $API_Response_Ticket['status']['success'] : '0';
						$strTicketPNRLCC = isset($API_Response_Ticket['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails']) ? $API_Response_Ticket['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails'] : '';
						$Passenger = isset($API_Response_Ticket['itemInfos']['AIR']['travellerInfos']) ? $API_Response_Ticket['itemInfos']['AIR']['travellerInfos'] : '';
						$strBookingIdLCC = isset($API_Response_Ticket['order']['bookingId']) ? $API_Response_Ticket['order']['bookingId'] : '0';
						if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
							$strBookingIdLCC = isset($API_Response_Ticket['order']['bookingId'][$k]) ? $API_Response_Ticket['order']['bookingId'][$k] : '0';
						}
						$segment = [];
						if ($value['Segments']) {
							foreach ($value['Segments'] as $seg) {
								$originAirportCode = $seg['originAirportCode'];
								$destinationAirportCode = $seg['destinationAirportCode'];
								$segment[] = $originAirportCode . '-' . $destinationAirportCode;
							}
						}
						$objFlight = new Travel_Model_FlightMaster();
						if ($ResponseStatus == 1) {
							if (!empty($Invoicedata)) {
								// Create GTX Invoice
								$Invoiceresponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->InvoiceCreate($Invoicedata, $BookingData);
							}

							$update = array(
								'API_Response' => json_encode($value),
								'API_Response_Ticket' => json_encode($API_Response_Ticket),
								'FlightQueryids' => json_encode($FlightQueryids),
								'PNR_Number' => implode('-', $strTicketPNRLCC),
								'BookingId' => $strBookingIdLCC,
								'InvoiceNo' => isset($Invoiceresponse['InvoiceNumber']) ? $Invoiceresponse['InvoiceNumber'] : '',
								'status' => 1,
								'TPSysId' => $TPSysId,
							);
							$update['PublishedFare'] = $value['FairRules']['PublishedFare'];
							$update['BaseFare'] = $value['FairRules']['BaseFare'];
							$update['Tax'] = $value['FairRules']['Tax'];
							$update['YQTax'] = $value['FairRules']['YQTax'];
							$update['OtherCharges'] = $value['FairRules']['OtherCharges'];
							$update['Discount'] = $value['FairRules']['Discount'];
							$update['ServiceFee'] = $value['FairRules']['ServiceFee'];
							$update['OfferedFare'] = $value['FairRules']['PublishedFare'];
							//echo '<pre>';print_r($update);die;
							$where = "id = " . $flight_booking_id[$k]; //exit;
							$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);

							try {
								$responseArray = array(
									'value' => $value,
									'response' => $API_Response_Ticket
								);
								$postFieldArray = array(
									'MasterTPSysId' => $MasterTPSysId,
									'TPSysId' => $TPSysId,
									'TrxId' => $TrxId,
									'VersionId' => $VersionId[$k],
									'XRefBookingId' => $strBookingIdLCC,
									'APIBookingRes' => json_encode($responseArray),
									'FareSummaryAir' => json_encode($FareSummary),
									'UpdateFare' => json_encode([$UpdateFare[$k]]),
									'Keys' => $k,
									'Passenger' => json_encode($Passenger),
									'gstData' => json_encode($gstData),
									'ErrorCode' => 0,
									'IsBookingStatus' => 1,
								);
								if ($k == 0) {
									//$postFieldArray['CancellationProtectionData'] = $CancellationProtectionDataCode;
								}

								echo '<pre>';
								print_r($postFieldArray);
								$strFilePath = "flight/updateFlightBookingDetails/" . time() . "_update_request.json";
								Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $postFieldArray);

								$model = new Gtxwebservices_Model_Webservices();
								$result = $model->updateFlightBookingDetails($postFieldArray);
								echo '<pre>GTX=';
								print_r($result);

								$AirlineName = $value['AirlineName'];
								$TotalFlightMembers = $value['TotalFlightMembers'];
								$JourneyType = $value['JourneyType'];
								$SourceAirportCode = $value['SourceAirportCode'];
								$DestAirportCode = $value['DestAirportCode'];
								$ResponseStatusPush = $result['apistatus'];
								$ErrorMessage = $result['message'];
								$logParams = [
									"user_id"      => 1,
									"AgencySysId"      => $this->gtxagencysysid,
									"custom_error" => ($ResponseStatusPush == 1) ? "Flight GTX Update Success" : "Flight GTX Update Failed",
									'error'        => $ErrorMessage,
									"text_udf"     => ['response' => $result], // Response
									"char_udf"     => ['request' => $postFieldArray], // Request
									"udf1"         => $SearchFlightTraceId,
									"udf5"                         => 'ticket',
									"from_destination"             => $SourceAirportCode,
									"to_destination"               => $DestAirportCode,
									"flight_type"                  => (int)$JourneyType,
									"source"                       => 1,
									"Pax"                          => ($TotalFlightMembers),
									"Supplier"                     => 'TRIPJACK',
									"Airline"                      => $AirlineName,
									"status"       => ($ResponseStatusPush == 1) ? 2 : 1,
								];
								Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
							} catch (Exception $error) {
							}
							if ($Passenger) {
								foreach ($Passenger as $pk => $pax) {
									$TicketId = implode('-', $pax['pnrDetails']);
									$TicketNumber = isset($pax['ticketNumberDetails']) ? implode('-', $pax['ticketNumberDetails']) : '';

									$updatep = array(
										'PNR_Number' => $TicketId,
										'TicketId' => $TicketId,
										'TicketNumber' => $TicketNumber,
										'sectors' => implode('-', $segment),
										'BookingId' => $strBookingIdLCC,
									);
									//echo '<pre>';print_r($updatep);
									$wherep = "id = " . $booking_customer_id[0][$pk];
									$objFlight->UpdateFlightData('tbl_flight_booking_customer', $updatep, $wherep);
								}
							}
							//if ($updated) {
							$responseReturn[] = array('success' => true, 'message' => $ErrorMessage, 'IsLCC' => $value['IsLCC']);
							//}
						} else {
							$update = array(
								'API_Response' => json_encode($response),
								'API_Response_Ticket' => '',
							);
							$where = "id = " . $flight_booking_id[$k]; //exit;
							$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
							$responseReturn[] = array('success' => false, 'message' => $ErrorMessage, 'IsLCC' => $value['IsLCC']);
						}
					}


					if ($responseReturn) {

						$arrUrlData['responseReturn'] = $responseReturn;
						$arrUrlData['FlightBookingTicketArr'] = $FlightBookingTicketArr;
						$arrUrlData['FlightQueryids'] = json_encode($FlightQueryids);
						$insertArr = array(
							'TraceId' => $traceId,
							'json_data' => json_encode($arrUrlData),
							'created_at' => date('Y-m-d H:i:s'),
						);
						$this->objMdl->rv_delete('tbl_temp_data', array('TraceId = ?' => $traceId));
						$objFlight = new Travel_Model_FlightMaster();
						$objFlight->InsertFlightData('tbl_temp_data', $insertArr);

						$FlightBookingTicketSession = new Zend_Session_Namespace('FlightBookingTicketSession');
						$FlightBookingTicketSession->params = $FlightBookingTicketArr;
						$Return = array('success' => true, 'message' => 'done', 'IsLCC' => '');
						echo json_encode($Return);
						exit;
					} else {
						$Return = array('success' => false, 'message' => 'failed', 'IsLCC' => '');
						echo json_encode($Return);
						exit;
					}
				}
			} else {
				die('Data not found. or booking not completed yet.');
			}
		} else {
			die('invalid request');
		}
	}
	public function Pushinvoice($BookingdataAPI, $FlightQueryids, $_sessiondata = null)
	{

		$gstvalidate = $BookingdataAPI['gstvalidate'];
		$gstnnumber = $BookingdataAPI['gstnnumber'];
		$FlightBookingData = $BookingdataAPI['FlightBookingData'];
		$selectedSeatSession = $BookingdataAPI['selectedSeatSession'];
		$SelectedMealSessionNew = $BookingdataAPI['SelectedMealSessionNew'];
		$SelectedBaggSessionNew = $BookingdataAPI['SelectedBaggSessionNew'];
		$CPAmountWithTax = $BookingdataAPI['CPAmountWithTax'];
		$IsCancellationProtection = $BookingdataAPI['IsCancellationProtection'];
		$MasterTPSysId = $FlightQueryids['arrIds']['MasterTPSysId'];
		$TPSysId = $FlightQueryids['arrIds']['TPSysId'];
		$CustomerSysIdGTX = $FlightQueryids['arrIds']['CustomerSysId'];
		$isgstapply = isset($FlightBookingData[0]['FairRules']['IsGSTRequired']) ? $FlightBookingData[0]['FairRules']['IsGSTRequired'] : 0;
		$TotalPublishedFare = 0;
		$TotalagencyMarkUpGST = 0;

		$TotalSeatPrice = 0;
		$TotalBagPrice = 0;
		$TotalMealPrice = 0;
		if ($FlightBookingData) {
			foreach ($FlightBookingData as $k => $value) {
				$finalFareSummary = $value['FairRules'];
				$segggg = $value['SourceAirportCode'] . '-' . $value['DestAirportCode'];
				//echo "<pre>";print_r($finalFareSummary);
				$SeatPrice = 0;
				$BagPrice = 0;
				$MealPrice = 0;
				if ($value['Segments']) {
					foreach ($value['Segments'] as $seg) {
						if (!empty($selectedSeatSession) && isset($selectedSeatSession[$seg['segmentid']]) && !empty($selectedSeatSession[$seg['segmentid']])) {
							$selectedSeat = $selectedSeatSession[$seg['segmentid']];
							foreach ($selectedSeat as $val) {
								$SeatPrice += ($val['amount'] * $this->CurrencyRate);
							}
						}
						if (!empty($SelectedBaggSessionNew) && isset($SelectedBaggSessionNew[$seg['segmentid']]) && !empty($SelectedBaggSessionNew[$seg['segmentid']])) {
							$selectedBag = $SelectedBaggSessionNew[$seg['segmentid']];
							foreach ($selectedBag as $val) {
								$BagPrice += ($val['Price'] * $this->CurrencyRate);
							}
						}
						if (!empty($SelectedMealSessionNew) && isset($SelectedMealSessionNew[$seg['segmentid']]) && !empty($SelectedMealSessionNew[$seg['segmentid']])) {
							$selectedMeal = $SelectedMealSessionNew[$seg['segmentid']];
							foreach ($selectedMeal as $val) {
								$MealPrice += ($val['Price'] * $this->CurrencyRate);
							}
						}
					}
				}
				$SeatFare = $SeatPrice;
				$PublishedFareINT = $PublishedFare__ = ($value['FairRules']['PublishedFare']);
				$AgentCommisionEarnedINT = (($finalFareSummary['CommEarned'] + $finalFareSummary['PLBEarned']));
				$AgentCommisionEarnedGSTINT = ($finalFareSummary['GSTonComm'] + isset($finalFareSummary['GSTonPLB']) ? $finalFareSummary['GSTonPLB'] : 0);
				$AgencyMarkUpINT = $FixedMarkUp__ = $finalFareSummary['FixedMarkUp'];
				$AgencyMarkUpGSTINT = $GSTOnMarkUp__ = $finalFareSummary['GSTOnMarkUp'];
				$GTXMarkUpINT = $finalFareSummary['intGTXMarkUp'];
				$AllAddOns = ($MealPrice + $BagPrice + $SeatFare);
				$TotalPublishedFare += ($PublishedFareINT + $MealPrice + $BagPrice + $SeatFare);
				$TotalagencyMarkUpGST += $AgencyMarkUpGSTINT;

				$TotalMealPrice += $MealPrice;
				$TotalBagPrice += $BagPrice;
				$TotalSeatPrice += $SeatFare;

				$TotalFare = ($PublishedFare__ - $FixedMarkUp__ - $GSTOnMarkUp__);
				$TotalAmount = $PublishedFare__;
				$SubTotal = ($PublishedFare__ - $GSTOnMarkUp__);
				$TotalGST = ($GSTOnMarkUp__);
				$TotalFixedMarkUp = $FixedMarkUp__;
				$TotalcouponVal = 0;
				$SourceAirportCode = $value['SourceAirportCode'];
				$DestAirportCode = $value['DestAirportCode'];
				$FlightNumber = $value['FlightNumber'];
				$AirlineName = $value['AirlineName'];
				$Description = $SourceAirportCode . '-' . $DestAirportCode . '-' . $AirlineName . ' ' . $FlightNumber;
				$misxItems_name[] = [
					'AgencySysId' => (isset($_sessiondata['AgencySysId']) && !empty($_sessiondata))?$_sessiondata['AgencySysId']:$this->gtxagencysysid,
					'AgentSysId' => (isset($_sessiondata['UserSysId']) && !empty($_sessiondata))?$_sessiondata['UserSysId']:$this->_session->data['UserSysId'],
					'MisxItems_name' => 'Flight',
					'Description' => $Description,
					'ItemQty' => 1,
					'ItemRates' => ($TotalFare),
					'Total' => $TotalFare,
					'DiscountType' => $TotalcouponVal,
					'Discount' => 1,
					'TotalDiscount' => $TotalcouponVal,
					'TotalAmount' => $TotalAmount,
					'MarkupType' => '',
					'Markup' => $TotalFixedMarkUp,
					'TotalMarkup' => $TotalFixedMarkUp,
					'SubTotal' => $SubTotal,
					'ServiceFeeTotal' => $TotalGST,
					'GSTPercentage' => '18',
					'TotalGST' => $TotalGST,
					'SGST' => ($gstvalidate['SGST'] == 1) ? ($TotalGST / 2) : 0,
					'CGST' => ($gstvalidate['CGST'] == 1) ? ($TotalGST / 2) : 0,
					'IGST' => ($gstvalidate['IGST'] == 1) ? $TotalGST : 0,
					'ItemsSACCode' => '',
				];
			}
		}
		$TotalPublishedFare = ($TotalPublishedFare + $CPAmountWithTax);
		$TotalInvoiceValue = ($TotalPublishedFare - $TotalagencyMarkUpGST);
		$TotalDiscount = 0;
		$itemCount = count($misxItems_name);
		if ($IsCancellationProtection == 1) {
			$misxItems_name[$itemCount] = array(
				'MisxItems_name' => 'Cancellation Protection',
				'Description' => 'Refund Upgrade',
				'ItemQty' => 1,
				'ItemRates' => ($CPAmountWithTax),
				'Total' => $CPAmountWithTax,
				'DiscountType' => 0,
				'Discount' => 0,
				'TotalDiscount' => 0,
				'TotalAmount' => 0,
				'MarkupType' => '',
				'Markup' => 0,
				'TotalMarkup' => 0,
				'SubTotal' => $CPAmountWithTax,
				'ServiceFeeTotal' => 0,
				'GSTPercentage' => 0,
				'TotalGST' => 0,
				'SGST' => 0,
				'CGST' => 0,
				'IGST' => 0,
				'ItemsSACCode' => '',
			);
		}
		$itemCount = count($misxItems_name);
		if (!empty($TotalBagPrice) && $TotalBagPrice > 0) {
			$misxItems_name[$itemCount] = array(
				'MisxItems_name' => 'Add ons',
				'Description' => 'Baggage',
				'ItemQty' => 1,
				'ItemRates' => ($TotalBagPrice),
				'Total' => $TotalBagPrice,
				'DiscountType' => 0,
				'Discount' => 0,
				'TotalDiscount' => 0,
				'TotalAmount' => 0,
				'MarkupType' => '',
				'Markup' => 0,
				'TotalMarkup' => 0,
				'SubTotal' => $TotalBagPrice,
				'ServiceFeeTotal' => 0,
				'GSTPercentage' => 0,
				'TotalGST' => 0,
				'SGST' => 0,
				'CGST' => 0,
				'IGST' => 0,
				'ItemsSACCode' => '',
			);
		}
		$itemCount = count($misxItems_name);
		if (!empty($TotalMealPrice) && $TotalMealPrice > 0) {
			$misxItems_name[$itemCount] = array(
				'MisxItems_name' => 'Add ons',
				'Description' => 'Meal',
				'ItemQty' => 1,
				'ItemRates' => ($TotalMealPrice),
				'Total' => $TotalMealPrice,
				'DiscountType' => 0,
				'Discount' => 0,
				'TotalDiscount' => 0,
				'TotalAmount' => 0,
				'MarkupType' => '',
				'Markup' => 0,
				'TotalMarkup' => 0,
				'SubTotal' => $TotalMealPrice,
				'ServiceFeeTotal' => 0,
				'GSTPercentage' => 0,
				'TotalGST' => 0,
				'SGST' => 0,
				'CGST' => 0,
				'IGST' => 0,
				'ItemsSACCode' => '',
			);
		}
		$itemCount = count($misxItems_name);
		if (!empty($TotalSeatPrice) && $TotalSeatPrice > 0) {
			$misxItems_name[$itemCount] = array(
				'MisxItems_name' => 'Add ons',
				'Description' => 'Seat',
				'ItemQty' => 1,
				'ItemRates' => ($TotalSeatPrice),
				'Total' => $TotalSeatPrice,
				'DiscountType' => 0,
				'Discount' => 0,
				'TotalDiscount' => 0,
				'TotalAmount' => 0,
				'MarkupType' => '',
				'Markup' => 0,
				'TotalMarkup' => 0,
				'SubTotal' => $TotalSeatPrice,
				'ServiceFeeTotal' => 0,
				'GSTPercentage' => 0,
				'TotalGST' => 0,
				'SGST' => 0,
				'CGST' => 0,
				'IGST' => 0,
				'ItemsSACCode' => '',
			);
		}
		$Invoicedata = [
			'AgentSysId' => 0,//(isset($_sessiondata['UserSysId']) && !empty($_sessiondata))?$_sessiondata['UserSysId']:$this->_session->data['UserSysId'],
			'CustomerSysId' => $CustomerSysIdGTX,
			'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' => $gstnnumber,
			'Currency' => $this->CurrencyId,
			'TotalInvoiceValue' => $TotalInvoiceValue,
			'InvoiceStatus' => true,
			'TotalSGST' => ($gstvalidate['SGST'] == 1) ? ($TotalagencyMarkUpGST / 2) : 0,
			'TotalCGST' => ($gstvalidate['CGST'] == 1) ? ($TotalagencyMarkUpGST / 2) : 0,
			'TotalIGST' => ($gstvalidate['IGST'] == 1) ? $TotalagencyMarkUpGST : 0,
			'SumdiscountItem' => 0,
			'OtherDiscount' => $TotalDiscount,
			'otherDiscountVal' => $TotalDiscount,
			'TotalAdvance' => $TotalPublishedFare,
			'TotalDueAmount' => 0,
			'InvoiceValue' => $TotalPublishedFare,
			'notes' => 'Flight Ticket',
			'termsandcondition' => '',
			'client_state' => '',
			'Advance' => 0,
			'PaymentType' => 4,
			'paymentNote' => 'Online',
			'misxItems_name' => $misxItems_name,

		];
		
		$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->InvoiceCreate($Invoicedata, $FlightBookingData);
		return $response;
	}

	public function checkArrayKeyExist($arr)
	{
		$newArr = [];
		foreach ($arr as $key => $value) {
			if (strlen($arr[$key])) {
				$newArr[$key] = $value;
			}
		}
		return array_values(array_unique($newArr));
	}
	private function fareCalculatection($arrUrlData, $index = 'NA')
	{
		$FlightBooking = $arrUrlData['BookingData'];
		if($index === 0 || $index === 1){
			$FlightBooking = isset($FlightBooking[$index])?[$FlightBooking[$index]]:[];
		}
		$customer = $arrUrlData['FlightBookingDataRiya']['customer'];
		$bookingId = isset($FlightBooking[0]['bookingId']) ? $FlightBooking[0]['bookingId'] : 0;
	
		$BaseFare = 0;
		$Taxesfee = 0;
		$CommDiscount = 0;
		$TotalPay = 0;
		$ServiceFee__ = 0;
		$AirlineTax = 0;
		$FuelSurcharge = 0;
		$GSTOnMarkUp_ = 0;
		$FixedMarkUp_ = 0;
		$AgentMarkUp_ = 0;
		$CommissionEarned_ = 0;
		$TDSEarn_ = 0;
		$BookableAmount = 0;
		$totalPayableAmount = 0;
		$sectors = [];
		if ($FlightBooking) {
			foreach ($FlightBooking as $key => $value) {
				$BookableAmount += isset($value['FairRules']['BookableAmount']) ? $value['FairRules']['BookableAmount'] : 0;
				
				foreach ($value['FairRules']['FareBreakdown'] as $FareBreakdown) {
					// 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']) : 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);
					$totalPayableAmount += ($BaseFare_ + $FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
					$ServiceFee__ += ($FixedMarkUp + $GSTOnMarkUp);
					$AirlineTax += ($Tax);
					$FuelSurcharge += ($YQ);
					$GSTOnMarkUp_ += ($GSTOnMarkUp);
					$FixedMarkUp_ += ($FixedMarkUp);
					$CommissionEarned_ += ($CommissionEarned);
					$TDSEarn_ += ($TDSEarn);
				}

				if ($value['Segments']) {
					foreach ($value['Segments'] as $seg) {
						$sectors[] = $seg['originAirportCode'] . '-' . $seg['destinationAirportCode'];
					}
				}
			}
		}

		$BagPrice = 0;
		$MealPrice = 0;
		$SeatPrice = 0;
		$customerNew = [];
		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;

			$customerNew[$kkkk] = $ValCustomer;
			$customerNew[$kkkk]['Sectors'] = $sectors;
			$customerNew[$kkkk]['SelectedBag'] = !empty($ValCustomer['SelectedBag']) ? json_decode($ValCustomer['SelectedBag'], 1) : [];
			$customerNew[$kkkk]['SelectedMeal'] = !empty($ValCustomer['SelectedMeal']) ? json_decode($ValCustomer['SelectedMeal'], 1) : [];
			$customerNew[$kkkk]['SelectedSeat'] = !empty($ValCustomer['SelectedSeat']) ? json_decode($ValCustomer['SelectedSeat'], 1) : [];
		}
		$num = round((($TotalPay)), 2);
		$whole = (int) $num;
		$frac  = ($num - $whole);
		$fare = [
			'Currency' => isset($FlightBooking[0]['FairRules']['Currency']) ? trim($FlightBooking[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),
			'Rounding' => number_format($frac, 2),
			'MealPrice' => $MealPrice,
			'BagPrice' => $BagPrice,
			'SeatPrice' => $SeatPrice,
			'TotalSSR' => ($MealPrice + $BagPrice + $SeatPrice),
			'totalPayableAmount' => ($totalPayableAmount + $MealPrice + $BagPrice + $SeatPrice),
			'BookingId' => $bookingId,

		];

		return $fare;
	}
	public function bookFlightAction()
	{
			// 		ini_set('display_errors', 1);
		    // ini_set('display_startup_errors', 1);
		    // error_reporting(E_ALL);
		$param = $this->getRequest()->getParams();
		if ($param) {
			// die('...testing....');
			$code = $this->getRequest()->getParam('code', NULL);
			$traceId = $this->getRequest()->getParam('traceId', NULL);
			if ($code != NULL && $traceId != NULL) {
				$PGType = (isset($param['type']) && !empty($param['type'])) ? $param['type'] : '';
				$transactionResponse = new Travel_Model_TransactionResponse();
				$transactionResponse->setRespHashKey($this->respHashKey);
				$transactionResponse->setResponseEncypritonKey($this->aesResponseKey);
				$transactionResponse->setSalt($this->aesResponseIv);
				if ($PGType == 'easebuzz') {
					$transactionResponse->setRespHashKey($this->respHashKey);
					$transactionResponse->setResponseEncypritonKey($this->aesRequestKey);
					$transactionResponse->setSalt($this->aesRequestKey);
					$returnPerameter = $transactionResponse->decryptResponseInEasebuzz($code);
					$returnPerameter = json_decode($returnPerameter, 1);
					$returnPerameter['f_code'] = ($returnPerameter['status'] == 'success') ? 'Ok' : '';
				} elseif ($param['type'] == 'CCAVENUE') {
					$workingKey = $this->CCAVENUEWorkingKey; //$checkPaymentSetting['PaymentSecretPwd'];
					$encResponse = $code;
					$rcvdString = $transactionResponse->decrypt_cc($encResponse, $workingKey);
					$decryptValues = explode('&', $rcvdString);
					$dataSize = sizeof($decryptValues);
					$bank_ref_no = $order_id = $tracking_id = $status_message = $merchant_param5 = $order_status = '';
					for ($i = 0; $i < $dataSize; $i++) {
						$information = explode('=', $decryptValues[$i]);
						if (isset($information[0])) {
							if ($information[0] == 'order_status') {
								$order_status = $information[1];
							}
							if ($information[0] == 'merchant_param5') {
								$merchant_param5 = $information[1];
							}
							if ($information[0] == 'status_message') {
								$status_message = $information[1];
							}
							if ($information[0] == 'tracking_id') {
								$tracking_id = $information[1];
							}
							if ($information[0] == 'order_id') {
								$order_id = $information[1];
							}
							if ($information[0] == 'bank_ref_no') {
								$bank_ref_no = $information[1];
							}
						}
					}
					$returnPerameter['f_code'] = ($order_status == 'Success') ? 'Ok' : '';
					$returnPerameter['bank_txn'] = $tracking_id;
					$returnPerameter['mer_txn'] = $order_id;
					$returnPerameter['ipg_txn_id'] = $bank_ref_no;
					$returnPerameter['mmp_txn'] = $tracking_id;
					$returnPerameter['desc'] = $status_message;
					$returnPerameter['error'] = $order_status;
					$returnPerameter['udf9'] = $merchant_param5;
				} else {
					$returnPerameter = $transactionResponse->decryptResponseIntoArray($code);
				}

				$checkVal = $transactionResponse->validateResponse($returnPerameter, $PGType);
				$mmp_txn = isset($returnPerameter['mmp_txn']) ? $returnPerameter['mmp_txn'] : '';
				$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $traceId], ['id' => 'ASC']);
				$response = $arrUrlData = json_decode($temp_data['json_data'], true);
				$paymentMode = isset($response['paymentMode']) ? $response['paymentMode'] : 0;
				$usewallet = (isset($response['usewallet']) && !empty($response['usewallet'])) ? $response['usewallet'] : 0;
				$Remark = (isset($response['Remark']) && !empty($response['Remark'])) ? $response['Remark'] : '';
				if ($paymentMode == 1) {
					$checkVal = true;
				}

				if ($checkVal == true) {

					$encryptedData = new Travel_Model_AtomAES();
					if ($paymentMode == 1) {
						$idEncypted = $code;
						$status = 'Ok';
					} else {
						$status = $returnPerameter["f_code"];
						$decodePerameter = Zend_Json::decode(base64_decode($returnPerameter["udf9"]), true);
						$idEncypted = $decodePerameter[5];
					}
					$id = $encryptedData->decrypt($idEncypted, SECURITYKEY, SECURITYKEY);

					if ($status == 'Ok' && $id == trim($traceId)) {
						$UserWalletStatus = (isset($this->_session->wallet['WalletStatus']) && !empty($this->_session->wallet['WalletStatus'])) ? $this->_session->wallet['WalletStatus'] : 0;

						$traceId = $id;
						// $temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $traceId], ['id' => 'ASC']);
						// $response = $arrUrlData = json_decode($temp_data['json_data'], true);
						$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
						$FlightBookingDataInbound = new Zend_Session_Namespace('FlightBookingDataInbound');
						$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
						$FlightSearchUrl = new Zend_Session_Namespace('FlightSearchUrl');
						$CustomerSession = new Zend_Session_Namespace('CustomerSession');
						$this->view->CustomerSession = isset($CustomerSession->params) ? $CustomerSession->params:[];
						$this->view->FlightSearchUrl = isset($FlightSearchUrl->params) ? $FlightSearchUrl->params:[];
						$class = isset($sessionFlightSearchParams->params['class']) ? $sessionFlightSearchParams->params['class']:'';
						$route = isset($sessionFlightSearchParams->params['route']) ? $sessionFlightSearchParams->params['route']:'';
						$interNationalSearch = isset($sessionFlightSearchParams->params['interNationalSearch']) ? $sessionFlightSearchParams->params['interNationalSearch']:'';
						$this->view->traceId = isset($param['traceId']) ? $param['traceId']:'';
						$this->view->departure_date = isset($sessionFlightSearchParams->params['strDepatureDate']) ? $sessionFlightSearchParams->params['strDepatureDate']:'';
						$this->view->return_dates = isset($sessionFlightSearchParams->params['strReturnDate']) ? $sessionFlightSearchParams->params['strReturnDate']:'';
						$SearchFlightTraceId = isset($sessionFlightSearchParams->params['SearchFlightTraceId']) ? $sessionFlightSearchParams->params['SearchFlightTraceId']:'';
						$this->view->class = $class;
						$this->view->code = $code;
						$this->view->PGType = $PGType;
						$this->view->sessionFlightSearchParams = isset($sessionFlightSearchParams->params) ? $sessionFlightSearchParams->params:[];
						$this->view->FlightBookingData = isset($FlightBookingData->params) ? $FlightBookingData->params :[];
						$couponApply = (isset($FlightBookingData->params[0]['FairRules']['couponApply']) && !empty($FlightBookingData->params[0]['FairRules']['couponApply'])) ? $FlightBookingData->params[0]['FairRules']['couponApply'] : 0;
						$ICSourceSysId = isset($FlightBookingData->params[0]['ICSourceSysId']) ? $FlightBookingData->params[0]['ICSourceSysId'] :'';
						$this->view->FlightBookingDataInbound = isset($FlightBookingDataInbound->params) ? $FlightBookingDataInbound->params:[];
						$flight_booking_customer_id = new Zend_Session_Namespace('flight_booking_customer_id');
						$booking_customer_id = isset($flight_booking_customer_id->params) ? $flight_booking_customer_id->params :[];
						$objFlight = new Travel_Model_FlightMaster();
						$CustomerMemberSysIds = new Zend_Session_Namespace('CustomerMemberSysIds');
						$flight_booking_id = isset($CustomerMemberSysIds->params['flight_booking_id']) ? $CustomerMemberSysIds->params['flight_booking_id'] : 0;
						
						// if ($this->gtxagencysysid == '2656') {
						// echo"<pre>";print_r($FlightBookingData->params);
						// 	die('...testing....');
						// }
						$gstData = array(
							'GstNumber' => (isset($CustomerSession->params[0]['gstnnumber']) && !empty($CustomerSession->params[0]['gstnnumber'])) ? $CustomerSession->params[0]['gstnnumber'] : '',
							'GstCompany' => (isset($CustomerSession->params[0]['companyname']) && !empty($CustomerSession->params[0]['companyname'])) ? $CustomerSession->params[0]['companyname'] : '',
							'GstEmail' => (isset($CustomerSession->params[0]['gstemail']) && !empty($CustomerSession->params[0]['gstemail'])) ? $CustomerSession->params[0]['gstemail'] : '',
							'GstPhone' => (isset($CustomerSession->params[0]['gstphone']) && !empty($CustomerSession->params[0]['gstphone'])) ? $CustomerSession->params[0]['gstphone'] : '',
							'GstAddress' => (isset($CustomerSession->params[0]['gstaddress']) && !empty($CustomerSession->params[0]['gstaddress'])) ? $CustomerSession->params[0]['gstaddress'] : '',
							'GstState' => (isset($CustomerSession->params[0]['gststate']) && !empty($CustomerSession->params[0]['gststate'])) ? $CustomerSession->params[0]['gststate'] : '',
						);
						$isgstapply = (isset($CustomerSession->params[0]['isgstapply']) && !empty($CustomerSession->params[0]['isgstapply'])) ? $CustomerSession->params[0]['isgstapply'] : 0;
						$CheckPaymentSTatus = $objFlight->CheckPaymentSTatus('tbl_flight_booking', $param['traceId']);
						$paymentStatus = isset($CheckPaymentSTatus['paymentStatus']) ? $CheckPaymentSTatus['paymentStatus'] : 0;

						$Invoicedata = isset($response['Invoicedata']) ? $response['Invoicedata'] : '';
						$IsCancellationProtection = isset($response['CancellationProtectionData']['IsCancellationProtection']) ? $response['CancellationProtectionData']['IsCancellationProtection'] : '';
						$CancellationProtectionData = isset($response['CancellationProtectionData']) ? $response['CancellationProtectionData'] : '';
						$CancellationProtectionDataE = json_encode($CancellationProtectionData);
						$CancellationProtectionDataCode = $encryptedData->encrypt($CancellationProtectionDataE, SECURITYKEY, SECURITYKEY);
						//echo"<pre>";print_r($Invoicedata);die();
						if (empty($flight_booking_id)) {
							$this->_redirect('flight/travellers/' . $param['traceId']);
						}
						if ($paymentStatus != 1) {
							$this->_redirect('flight/add-onn-service/' . $param['traceId']);
						}


						$FlightBookingTicketArr = [];
						$responseReturn = [];
						$BookingData = [];
						$FlightBookingData->params = isset($response['BookingData']) ? $response['BookingData']:[];
						$BookingData = isset($FlightBookingData->params) ? $FlightBookingData->params:[];

						$ResponseFlightQuery = new Zend_Session_Namespace('ResponseFlightQuery');
						$FlightQueryids = isset($ResponseFlightQuery->params) ? $ResponseFlightQuery->params :[];
						$MasterTPSysId = isset($FlightQueryids['arrIds']['MasterTPSysId']) ? $FlightQueryids['arrIds']['MasterTPSysId']:'';
						$TPSysId = isset($FlightQueryids['arrIds']['TPSysId']) ? $FlightQueryids['arrIds']['TPSysId']:'';
						$TrxId = isset($FlightQueryids['arrIds']['TrxId']) ? $FlightQueryids['arrIds']['TrxId']:'';
						$VersionId = isset($FlightQueryids['arrIds']['VersionId']) ? $FlightQueryids['arrIds']['VersionId']:'';

						$PostData = ['TPSysId' => $TPSysId, 'version' => null,'IsApproved'=>0];
						$bookingdetailsapi = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingdetailsapi($PostData);
						$customer = $bookingdetailsapi['customer'];
						
						$PaymentStatus = isset($bookingdetailsapi['FlightBookingData'][0]['PaymentStatus']) ? $bookingdetailsapi['FlightBookingData'][0]['PaymentStatus'] : '0';
						$CurrentStatus = isset($bookingdetailsapi['FlightBookingData'][0]['CurrentStatus']) ? $bookingdetailsapi['FlightBookingData'][0]['CurrentStatus'] : '0';
						if ($PaymentStatus == 130 && ($CurrentStatus == 142 || $CurrentStatus == 141)) {
							$strReturnURL = $this->baseUrl . "flight/booking-confirmed-new/".$TPSysId;
							$this->_redirect($strReturnURL);
						}
						$FareBreakdownid = $FlightQueryids['arrIds']['FareBreakdownid'];
						$SelectedMealSessionNew = new Zend_Session_Namespace('SelectedMealSessionNew');
						$SelectedMealSessionNew->params = $response['SelectedMealSessionNew'];
						$SelectedBaggSessionNew = new Zend_Session_Namespace('SelectedBaggSessionNew');
						$SelectedBaggSessionNew->params = $response['SelectedBaggSessionNew'];

						$SelectedMealSessionNewInb = new Zend_Session_Namespace('SelectedMealSessionNewInb');
						$SelectedBaggSessionNewInb = new Zend_Session_Namespace('SelectedBaggSessionNewInb');
						$selectedSeatSession = new Zend_Session_Namespace('selectedSeatSession');
						$selectedSeatSession->params = $response['selectedSeatSession'];
						$validateCoupon = isset($arrUrlData['validateCoupon']) ? $arrUrlData['validateCoupon'] : '';
						$applyData = array(
							'AgencySysId' => $this->gtxagencysysid,
							'TPSysId' => $TPSysId,
							'SecurityKey' => SECURITYKEY,
							'CouponCodeEnc' => isset($validateCoupon['code']) ? $validateCoupon['code'] : ''
						);
						$TotalBagPrice = 0;
						$TotalMealPrice = 0;
						$TotalSeatPrice = 0;
						if ($customer) {
							foreach ($customer as $val) {
								$TotalBagPrice += $val['BagPrice'];
								$TotalMealPrice += $val['MealPrice'];
								$TotalSeatPrice += $val['SeatPrice'];
							}
						}
						$PublishedFareWallet = 0;
						$ItineraryFlightsInfo = [];
						if ($BookingData) {
							foreach ($BookingData as $k => $value) {
								$couponApply = isset($value['FairRules']['couponApply']) ? $value['FairRules']['couponApply'] : 0;
								if ($couponApply == 1 || $couponApply == '1') {
									$couponVal = isset($value['FairRules']['couponVal']) ? $value['FairRules']['couponVal'] : 0;
								} else {
									$couponVal = 0;
								}
								$ICSourceSysId = $value['ICSourceSysId'];
								$AdditionalTxnFeePub = 0;
								$FlighstInfo = [];
								$TotalBaseFare = 0;
								$TotalTaxsandFees = 0;
								$GrossAmount = 0;
								$TotalAmount_ = 0;
								$BaggSSRInfo = [];
								$MealsSSRInfo = [];
								$SeatsSSRInfo = [];
								$segment_ = [];
								$SeatPrice = 0;
								$BagPrice = 0;
								$MealPrice = 0;
						
								if ($value['FairRules']['FareBreakdown']) {
									foreach ($value['FairRules']['FareBreakdown'] as $FareBreakdown) {

										$MF = isset($FareBreakdown['MF']) ? $FareBreakdown['MF'] :0; //Management Fee
										$TDS = isset($FareBreakdown['TDS']) ? $FareBreakdown['TDS'] :0; //Management Fee
										$YQ = isset($FareBreakdown['YQ']) ? $FareBreakdown['YQ'] :0; //Fuel Surcharge
										$AGST = isset($FareBreakdown['AGST']) ? $FareBreakdown['AGST'] :0; //Airline GST Component
										$MFT = isset($FareBreakdown['MFT']) ? $FareBreakdown['MFT'] :0; //Management Fee Tax
										$OT = isset($FareBreakdown['OT']) ? $FareBreakdown['OT']:0; //Other Charges
										$MU = isset($FareBreakdown['MU']) ? $FareBreakdown['MU']:0; //Markup
										$YR = isset($FareBreakdown['YR']) ? $FareBreakdown['YR'] :0; //Carrier Misc Fee
										$other = $MF + $YQ + $AGST + $MFT + $OT + $YR;
										if ($ICSourceSysId == 3) {
											$other =  $MF + $AGST + $MFT + $OT + $YR;
										}
										$Tax = isset($FareBreakdown['Tax']) ? $FareBreakdown['Tax']:0;
										$TDSEarn = isset($FareBreakdown['TDSEarn']) ? $FareBreakdown['TDSEarn']:0;
										$PBaseFare = isset($FareBreakdown['BaseFare']) ? $FareBreakdown['BaseFare']:0;
										$intTotalGST = isset($FareBreakdown['intTotalGST']) ? $FareBreakdown['intTotalGST']:0;
										$FixedMarkUp = isset($FareBreakdown['FixedMarkUp']) ? $FareBreakdown['FixedMarkUp'] :0;
										$GSTOnMarkUp = isset($FareBreakdown['GSTOnMarkUp']) ? $FareBreakdown['GSTOnMarkUp']:0;
										$apiMarkup = isset($FareBreakdown['apiMarkup']) ? $FareBreakdown['apiMarkup']:0;
										$IntCommission = isset($FareBreakdown['IntCommission']) ? $FareBreakdown['IntCommission']:0;
										$CommissionEarned = isset($FareBreakdown['CommissionEarned']) ? $FareBreakdown['CommissionEarned']:0;
										$CommisionPass = isset($FareBreakdown['CommisionPass']) ? $FareBreakdown['CommisionPass']:0;
										$ServiceFee = isset($FareBreakdown['ServiceFee']) ? $FareBreakdown['ServiceFee']:0;
										$GrossAmount += (isset($FareBreakdown['GrossAmount'])) ? $FareBreakdown['GrossAmount'] : 0;

										$paxPublishedFare = ($PBaseFare);
										$PassengerType = isset($FareBreakdown['PassengerType']) ? $FareBreakdown['PassengerType']:0;
										$PassengerCount = isset($FareBreakdown['PassengerCount']) ? $FareBreakdown['PassengerCount']:0;
										$AdditionalTxnFeePub += isset($FareBreakdown['AdditionalTxnFeePub']) ? $FareBreakdown['AdditionalTxnFeePub']:0;

										$TaxesFees = ($other + $intTotalGST + $FixedMarkUp + $apiMarkup + $IntCommission - $CommissionEarned);
										if ($ICSourceSysId == 3 || $ICSourceSysId == 7) {
											$TaxesFees = ($Tax + $FixedMarkUp + $GSTOnMarkUp + $ServiceFee + $TDSEarn + $CommissionEarned);
										}
										$TotalBaseFare += ($paxPublishedFare);
										$TotalTaxsandFees += ($TaxesFees);
									}
								}
								$PublishedFareWallet += (($TotalBaseFare + $TotalTaxsandFees) - $couponVal) * $this->CurrencyRate;
								if($ICSourceSysId == 16){
									$SeatPrice = 0;
									$BagPrice = 0;
									$MealPrice = 0;
									$FlighstInfo= [];
									
									if ($value['Segments']) {
										foreach ($value['Segments'] as $seg) {
											
											if (!empty($selectedSeatSession->params) && isset($selectedSeatSession->params[$seg['segmentid']]) && !empty($selectedSeatSession->params[$seg['segmentid']])) {
												$selectedSeat = $selectedSeatSession->params[$seg['segmentid']];
												foreach ($selectedSeat as $ck=>$val) {
													$SeatPrice_ += $val['amount'];
													$SeatPrice += $val['amount'];
													$SeatsSSRInfo[] = ['SeatID'=>$val['SeatID'],'PaxRefNumber'=>$ck];
												}
											}
											if($k == 0){
												if (!empty($SelectedBaggSessionNew->params) && isset($SelectedBaggSessionNew->params[$seg['segmentid']]) && !empty($SelectedBaggSessionNew->params[$seg['segmentid']])) {
													$selectedBag = $SelectedBaggSessionNew->params[$seg['segmentid']];
													// echo "SelectedBaggSessionNew<pre>";print_r($SelectedBaggSessionNew->params);
													// echo "selectedSeat<pre>";print_r($selectedSeat);
													// die;
													foreach ($selectedBag as $ck=>$val) {
														$BagPrice_ += $val['Price'];
														$BagPrice += $val['Price'];
														if($CustomerSession->params){
															foreach($CustomerSession->params as $pk=>$val_){
																$BaggSSRInfo[] = ['BaggageID'=>$val['BaggageID'],'PaxRefNumber'=>(string)($pk+1)];
															}
														}
													}
												}
												if (!empty($SelectedMealSessionNew->params) && isset($SelectedMealSessionNew->params[$seg['segmentid']]) && !empty($SelectedMealSessionNew->params[$seg['segmentid']])) {
													$selectedMeal = $SelectedMealSessionNew->params[$seg['segmentid']];
													foreach ($selectedMeal as $ck=>$val) {
														$MealPrice_ += $val['Price'];
														$MealPrice += $val['Price'];
														if($CustomerSession->params){
															foreach($CustomerSession->params as $pk=>$val_){
																$MealsSSRInfo[] = ['MealID'=>$val['MealID'],'PaxRefNumber'=>(string)($pk+1)];
															}}
													}
												}
											}else{
												if (!empty($SelectedBaggSessionNewInb->params) && isset($SelectedBaggSessionNewInb->params[$seg['segmentid']]) && !empty($SelectedBaggSessionNewInb->params[$seg['segmentid']])) {
													$selectedBag = $SelectedBaggSessionNewInb->params[$seg['segmentid']];
													// echo "SelectedBaggSessionNew<pre>";print_r($SelectedBaggSessionNew->params);
													// echo "selectedSeat<pre>";print_r($selectedSeat);
													// die;SelectedBaggSessionNewInb
													foreach ($selectedBag as $ck=>$val) {
														$BagPrice_ += $val['Price'];
														$BagPrice += $val['Price'];
														if($CustomerSession->params){
															foreach($CustomerSession->params as $pk=>$val_){
																$BaggSSRInfo[] = ['BaggageID'=>$val['BaggageID'],'PaxRefNumber'=>(string)($pk+1)];
															}
														}
													}
												}
												if (!empty($SelectedMealSessionNewInb->params) && isset($SelectedMealSessionNewInb->params[$seg['segmentid']]) && !empty($SelectedMealSessionNewInb->params[$seg['segmentid']])) {
													$selectedMeal = $SelectedMealSessionNewInb->params[$seg['segmentid']];
													foreach ($selectedMeal as $ck=>$val) {
														$MealPrice_ += $val['Price'];
														$MealPrice += $val['Price'];
														if($CustomerSession->params){
															foreach($CustomerSession->params as $pk=>$val_){
																$MealsSSRInfo[] = ['MealID'=>$val['MealID'],'PaxRefNumber'=>(string)($pk+1)];
															}}
													}
												}
											}
											$FlighstInfo[] = array(
												'FlightID'=>$seg['segmentid'],
												'FlightNumber'=>str_replace('-',' ',$seg['SegFlightNumber']),
												'Origin'=>$seg['originAirportCode'],
												'Destination'=>$seg['destinationAirportCode'],
												'DepartureDateTime'=>date('d M Y H:i', strtotime($seg['originDepTime'])),
												'ArrivalDateTime'=>date('d M Y H:i', strtotime($seg['destinationArrTime'])),
											);
										}
									}
									$TotalAmount_ = $GrossAmount + $SeatPrice + $BagPrice + $MealPrice;
									$ItineraryFlightsInfo[$k]['Token'] = $value['Token'];
									$ItineraryFlightsInfo[$k]['FlighstInfo'] = $FlighstInfo;
									$ItineraryFlightsInfo[$k]['PaymentMode'] = 'T';
									$ItineraryFlightsInfo[$k]['PaymentInfo'] = [['TotalAmount'=>$TotalAmount_]];
									if(!empty($BaggSSRInfo)){
										$ItineraryFlightsInfo[$k]['BaggSSRInfo'] = $BaggSSRInfo;
									}
									if(!empty($MealsSSRInfo)){
										$ItineraryFlightsInfo[$k]['MealsSSRInfo'] = $MealsSSRInfo;
									}
									if(!empty($SeatsSSRInfo)){
										$ItineraryFlightsInfo[$k]['SeatsSSRInfo'] = $SeatsSSRInfo;
									}
								}
							}
						}
						if ($this->getRequest()->isXmlHttpRequest() && $FlightBookingData->params) {
							$PublishedFareWallet = $PublishedFareWallet + $TotalBagPrice + $TotalMealPrice + $TotalSeatPrice;
							$this->_helper->layout->disableLayout();
							$this->_helper->viewRenderer->setNoRender(true);
							
							if ($usewallet == 1 && $UserWalletStatus == 1) {

								if ($paymentMode == 2 && $this->_session->session['CustomerSysId'] && $UserWalletStatus == 1) {
									$WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CustomerWallaetBalance($this->_session->session['CustomerSysId']);
									$currentcreditBalance = (isset($WallaetBalance['WalletBalance'][0]['BalanceAmount']) && !empty($WallaetBalance['WalletBalance'][0]['BalanceAmount'])) ? $WallaetBalance['WalletBalance'][0]['BalanceAmount'] : 0;
									$PublishedFareWalletAdd = 0;
									if ($PublishedFareWallet > $currentcreditBalance && $paymentMode == 2) {
										$PublishedFareWalletAdd = ($PublishedFareWallet - $currentcreditBalance);
									}
									$DebitFromWallet = array(
										'Remark' => 'Wallet Recharge - ' . $mmp_txn,
										'Amount' => $PublishedFareWalletAdd,
										'CustomerSysId' => $this->_session->session['CustomerSysId'],
										'CurrencyType' => 1,
										'PlanType' => 1,
										'PaymentMode' => 'Wallet Recharge',
										'ReferenceNo' => $TPSysId,
									);
									$Url = $this->gtxBtoBsite . 'gtxwebservices/customer-wallet/add-b2c-wallet-balance/';
									$addfund = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->DebitFromWallet($DebitFromWallet, $Url);

									$addfundstatus = isset($addfund['status']) ? $addfund['status'] : 0;
									$WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CustomerWallaetBalance($this->_session->session['CustomerSysId']);
									$currentcreditBalance = (isset($WallaetBalance['WalletBalance'][0]['BalanceAmount']) && !empty($WallaetBalance['WalletBalance'][0]['BalanceAmount'])) ? $WallaetBalance['WalletBalance'][0]['BalanceAmount'] : 0;

									if ($addfundstatus == 1 && $paymentMode == 2 && $currentcreditBalance >= $PublishedFareWallet && $this->_session->session && $UserWalletStatus == 1) {
										$rem = 'Flight Booking';
										$DebitFromWallet = array(
											'Remark' => $rem . ' ' . $Remark,
											'Amount' => $PublishedFareWallet,
											'CustomerSysId' => $this->_session->session['CustomerSysId'],
											'CurrencyType' => 1,
											'PlanType' => 1,
											'PaymentMode' => 'Online Wallet',
											'ReferenceNo' => $TPSysId,
										);

										$Url = $this->gtxBtoBsite . 'gtxwebservices/customer-wallet/update-b2c-wallet-balance/';
										$updateBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->DebitFromWallet($DebitFromWallet, $Url);
										$Walletstatus = $updateBalance['status'];
										$TransactionId = $updateBalance['TransactionId'];
										if ($Walletstatus == 1) {
											$checkwalletbalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CustomerWallaetBalance($this->_session->session['CustomerSysId']);
											$checkwalletbalance['WalletStatus'] = $checkwalletbalance['status'];
											$this->_session->wallet = (isset($checkwalletbalance['status']) && $checkwalletbalance['status'] == 1) ? $checkwalletbalance : '';
										} else {
											$Return = array('success' => false, 'message' => 'Oops Unbale to debit amount from your wallet. Please contact with our support team.', 'IsLCC' => $IsLCC);
											echo json_encode($Return);
											exit;
										}
									} else {
										$Return = array('success' => false, 'message' => 'Oops Unbale to recharge your wallet. Please contact with our support team.', 'IsLCC' => $IsLCC);
										echo json_encode($Return);
										exit;
									}
								}
							}

							// start new update booking jyt

							if ($ICSourceSysId == 7 || $ICSourceSysId == 3){
								// echo "arrUrlData<pre>";print_r(json_encode($arrUrlData));die;

								$FlightBooking = isset($arrUrlData['BookingData']) ? $arrUrlData['BookingData'] :[];
								$SourceAirportCode = isset($FlightBooking[0]['SourceAirportCode']) ? $FlightBooking[0]['SourceAirportCode'] :'';
								$DestAirportCode = isset($FlightBooking[0]['DestAirportCode']) ? $FlightBooking[0]['DestAirportCode'] :'';
								$FlightQueryids = isset($arrUrlData['genrateFlightQuery']) ? $arrUrlData['genrateFlightQuery'] :[];
								$customer = isset($arrUrlData['FlightBookingDataRiya']['customer']) ? $arrUrlData['FlightBookingDataRiya']['customer']:[];
								$strUrlData = $traceId;
								$flight_booking_id_Arr = $arrUrlData['flight_booking_id_Arr'];
								$paymentMode = isset($arrUrlData['paymentMode']) ? $arrUrlData['paymentMode'] : 0;
								$bookingHold = isset($arrUrlData['bookingHold']) ? $arrUrlData['bookingHold'] : 0;
								$flexiPayment = isset($arrUrlData['flexiPayment']) ? $arrUrlData['flexiPayment'] : 0;
								$IsCancellationProtection = isset($arrUrlData['IsCancellationProtection']) ? $arrUrlData['IsCancellationProtection'] : 0;
								$sessionFlightSearchParams = isset($arrUrlData['sessionFlightSearchParams']) ? $arrUrlData['sessionFlightSearchParams'] : [];

								$MasterTPSysId = $FlightQueryids['arrIds']['MasterTPSysId'];
								$CustomerSysIdGTX = $FlightQueryids['arrIds']['CustomerSysId'];
								$TPSysId = $FlightQueryids['arrIds']['TPSysId'];
								$VersionId = $FlightQueryids['arrIds']['VersionId'];
								$TrxId = $FlightQueryids['arrIds']['TrxId'];
								$GTXpushstatus = isset($FlightQueryids['status']) ? $FlightQueryids['status'] : 0;
						
					
								$route = $JourneyType = isset($sessionFlightSearchParams['route']) ? $sessionFlightSearchParams['route'] : 0;
								$interNationalSearch = isset($sessionFlightSearchParams['interNationalSearch']) ? $sessionFlightSearchParams['interNationalSearch'] : 0;
								$adultCount   = isset($sessionFlightSearchParams['adults']) ? $sessionFlightSearchParams['adults'] : 0;
								$childCount   = isset($sessionFlightSearchParams['child']) ? $sessionFlightSearchParams['child'] : 0;
								$infantCount   = isset($sessionFlightSearchParams['infant']) ? $sessionFlightSearchParams['infant'] : 0;
								$oneway_origin_text = isset($sessionFlightSearchParams['source_city'][0]) ? $sessionFlightSearchParams['source_city'][0] : $sessionFlightSearchParams['sourceCityAirportCode'][0];
								$oneway_destination_text = isset($sessionFlightSearchParams['destination_city'][0]) ? $sessionFlightSearchParams['destination_city'][0] : $sessionFlightSearchParams['destinationCityAirportCode'][0];

								$intMemberCount = ($adultCount + $childCount + $infantCount);

								$intNetPublishedFare = 0;
								if ($FlightBooking) {
									foreach ($FlightBooking as $value_) {
										$intNetPublishedFare += $value['FairRules']['PublishedFare'];
									}
								}
								
								$DataS = array(
									'apidata' => [],
									'BookingData' => $FlightBooking,
									'customer' => $customer,
									'bookingHold' => isset($bookingHold) ? $bookingHold : 0,
									'memberCount' => $intMemberCount,
									'JourneyType' => $JourneyType,
									'interNationalSearch' => $interNationalSearch,
									'searchID' => $traceId,
									'ICSourceSysId' => $ICSourceSysId,
									'AgentMarkUp' => 0,
									'gstData' => [],
									'APIMode' => $this->APIMode,
								);
								// echo "DataS<pre>";print_r(json_encode($DataS));die;
								$url = $this->GTXAPIDEFAULT . '/flight/v3/book';
								$apiResponse = $bookAPIResponse =  Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
								// echo "DataS<pre>";print_r(json_encode($apiResponse));die;
								// $apiResponse = $bookAPIResponse = json_decode('{"status":false,"message":"Session is already expired. Please try again with new session","results":{"status":{"success":false,"httpStatus":400},"errors":[{"errCode":"2024","message":"Session is already expired. Please try again with new session","details":"Session is already expired. Please try again with new session"}]}}',true);
								// $apiResponse = $bookAPIResponse = json_decode('{"status":true,"message":"SUCCESS","results":{"bookingId":"TJS104201447058","status":{"success":true,"httpStatus":200}},"TransactionStatus":"","BookingId":"","Invoicedata":{"AgentSysId":0,"CustomerSysId":0,"TPSysId":0,"MasterTPSysId":0,"ProposalID":"0/V1","InvoiceDate":"2025-05-12","isDisplayMarkup":true,"PaymentDueDate":"2025-05-12","PaymentDate":"2025-05-12","ClientGST":0,"ClientGSTNumber":"","Currency":1,"TotalInvoiceValue":15981.96,"InvoiceStatus":1,"TotalSGST":0,"TotalCGST":0,"TotalIGST":0,"SumdiscountItem":0,"OtherDiscount":0,"otherDiscountVal":0,"TotalAdvance":15981.96,"TotalDueAmount":15981.96,"InvoiceValue":15981.96,"notes":"Flight Ticket","termsandcondition":"","client_state":"","Advance":0,"PaymentType":4,"paymentNote":"Online","misxItems_name":[{"AgencySysId":2656,"AgentSysId":0,"MisxItems_name":"Flight","Description":"DEL-BOM-Indigo 6E-395","ItemQty":1,"ItemRates":8076.98,"Total":8076.98,"DiscountType":1,"Discount":1,"TotalDiscount":0,"TotalAmount":8076.98,"MarkupType":"","Markup":0,"TotalMarkup":0,"SubTotal":8076.98,"ServiceFeeTotal":0,"GSTPercentage":"18","TotalGST":0,"SGST":0,"CGST":0,"IGST":0,"ItemsSACCode":""},{"AgencySysId":2656,"AgentSysId":0,"MisxItems_name":"Flight","Description":"BOM-DEL-Indigo 6E-2775","ItemQty":1,"ItemRates":7904.98,"Total":7904.98,"DiscountType":1,"Discount":1,"TotalDiscount":0,"TotalAmount":7904.98,"MarkupType":"","Markup":0,"TotalMarkup":0,"SubTotal":7904.98,"ServiceFeeTotal":0,"GSTPercentage":"18","TotalGST":0,"SGST":0,"CGST":0,"IGST":0,"ItemsSACCode":""}]}}',true);
							
								// $apiResponse = $bookAPIResponse = json_decode('{"status":true,"message":"SUCCESS","results":[{"Response":{"Error":{"ErrorCode":0,"ErrorMessage":""},"TraceId":"41ad86e6-6520-47e5-aa5c-eddfd9932fc9","ResponseStatus":1,"Response":{"PNR":"NFQ3GH","BookingId":1979247,"SSRDenied":false,"SSRMessage":null,"Status":1,"IsPriceChanged":false,"IsTimeChanged":false,"FlightItinerary":{"CommentDetails":null,"IsSeatsBooked":false,"JourneyType":1,"SearchCombinationType":2,"TripIndicator":1,"BookingAllowedForRoamer":true,"BookingId":1979247,"IsCouponAppilcable":true,"IsManual":false,"PNR":"NFQ3GH","IsDomestic":true,"ResultFareType":"RegularFare","Source":3,"Origin":"DEL","Destination":"BOM","AirlineCode":"SG","LastTicketDate":"2025-05-07T22:12:04","ValidatingAirlineCode":"SG","AirlineRemark":"SpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet MainSpiceJet Main","AirlineTollFreeNo":"9876543210","IsLCC":true,"NonRefundable":false,"FareType":"PUB","CreditNoteNo":null,"Fare":{"ServiceFeeDisplayType":0,"Currency":"INR","BaseFare":1999,"Tax":1268,"TaxBreakup":[{"key":"K3","value":150},{"key":"PSF","value":91},{"key":"UDF","value":12},{"key":"YR","value":65},{"key":"YQTax","value":900},{"key":"TotalTax","value":1268}],"YQTax":900,"AdditionalTxnFeeOfrd":0,"AdditionalTxnFeePub":0,"PGCharge":0,"OtherCharges":11.8,"ChargeBU":[{"key":"TBOMARKUP","value":0},{"key":"GLOBALPROCUREMENTCHARGE","value":0},{"key":"OTHERCHARGE","value":11.8},{"key":"CONVENIENCECHARGE","value":0}],"Discount":0,"PublishedFare":3578.8,"CommissionEarned":46.77,"PLBEarned":32.62,"IncentiveEarned":33.19,"OfferedFare":3211.26,"TdsOnCommission":18.71,"TdsOnPLB":13.05,"TdsOnIncentive":13.28,"ServiceFee":300,"TotalBaggageCharges":0,"TotalMealCharges":0,"TotalSeatCharges":0,"TotalSpecialServiceCharges":0},"CreditNoteCreatedOn":null,"Passenger":[{"BarcodeDetails":{"Id":0,"Barcode":[{"Index":1,"Format":"PDF417","Content":"M1KHAN/SABIR           NFQ3GH DELBOMSG 8157 142Y00000000 000","BarCodeInBase64":null,"JourneyWayType":3}]},"DocumentDetails":null,"GuardianDetails":null,"PaxId":3217908,"Title":"Mr","FirstName":"sabir","LastName":"khan","PaxType":1,"Gender":1,"IsPANRequired":false,"IsPassportRequired":false,"PAN":"","PassportNo":"","AddressLine1":"delhi","Fare":{"ServiceFeeDisplayType":0,"Currency":"INR","BaseFare":1999,"Tax":1268,"TaxBreakup":[{"key":"K3","value":150},{"key":"PSF","value":91},{"key":"UDF","value":12},{"key":"YR","value":65},{"key":"YQTax","value":900},{"key":"TotalTax","value":1268}],"YQTax":900,"AdditionalTxnFeeOfrd":0,"AdditionalTxnFeePub":0,"PGCharge":0,"OtherCharges":11.8,"ChargeBU":[{"key":"TBOMARKUP","value":0},{"key":"GLOBALPROCUREMENTCHARGE","value":0},{"key":"OTHERCHARGE","value":11.8},{"key":"CONVENIENCECHARGE","value":0}],"Discount":0,"PublishedFare":3578.8,"CommissionEarned":46.77,"PLBEarned":32.62,"IncentiveEarned":33.19,"OfferedFare":3211.26,"TdsOnCommission":18.71,"TdsOnPLB":13.05,"TdsOnIncentive":13.28,"ServiceFee":300,"TotalBaggageCharges":0,"TotalMealCharges":0,"TotalSeatCharges":0,"TotalSpecialServiceCharges":0},"City":"Delhi","CountryCode":"IN","Nationality":"IN","ContactNo":"9671365732","Email":"b.einganuj3010@gmail.com","IsLeadPax":true,"FFAirlineCode":null,"FFNumber":"","Baggage":[{"AirlineCode":"SG","FlightNumber":"8157","WayType":2,"Code":"NoBaggage","Description":2,"Weight":0,"Currency":"INR","Price":0,"Origin":"DEL","Destination":"BOM"}],"Ssr":[]}],"CancellationCharges":null,"Segments":[{"Baggage":"15 KG","CabinBaggage":"7 KG","CabinClass":2,"SupplierFareClass":null,"TripIndicator":1,"SegmentIndicator":1,"Airline":{"AirlineCode":"SG","AirlineName":"SpiceJet","FlightNumber":"8157","FareClass":"P","OperatingCarrier":""},"AirlinePNR":"","Origin":{"Airport":{"AirportCode":"DEL","AirportName":"Indira Gandhi Airport","Terminal":"3","CityCode":"DEL","CityName":"Delhi","CountryCode":"IN","CountryName":"India"},"DepTime":"2025-05-22T06:10:00"},"Destination":{"Airport":{"AirportCode":"BOM","AirportName":"Chhatrapati Shivaji International Airport","Terminal":"1","CityCode":"BOM","CityName":"Mumbai","CountryCode":"IN","CountryName":"India"},"ArrTime":"2025-05-22T08:20:00"},"Duration":130,"GroundTime":0,"Mile":0,"StopOver":false,"FlightInfoIndex":"","StopPoint":"","StopPointArrivalTime":"0001-01-01T00:00:00","StopPointDepartureTime":"0001-01-01T00:00:00","Craft":"737","Remark":null,"IsETicketEligible":true,"FlightStatus":"Confirmed","Status":"HK","FareClassification":null}],"FareRules":[{"Origin":"DEL","Destination":"BOM","Airline":"SG","FareBasisCode":"P1SALE","FareRuleDetail":"The FareBasisCode is: P1SALE<br /> \r\n Domestic:\r\n You have booked a Saver Fare for # and # sector(s). Change and Cancellation fee is applicable on this fare are INR 2500 and INR 3000 respectively. However, in case of changes difference in fare shall be charged if applicable.  Free baggage allowance applicable for domestic sector is 15 k.g\r\n \r\nInternational:\r\n You have booked a saver Fare from  ABC  and  PQR  sector(s). Change and Cancellation fee is applicable on this fare are INR 3500 and INR 4500 respectively. However, in case of changes difference in fare shall be charged if applicable.  Free baggage allowance applicable for International sectors is given below:\r\n \r\nSector Free Bag Allowance\r\nEx India to Male 20 Kgs\r\nEx India to Muscat 30 Kgs\r\nEx India to Bangkok 20 Kgs\r\nEx India to Colombo 30 Kgs\r\nEx India to Dubai 30 Kgs\r\nEx India to Kabul 30 Kgs\r\nEx India to Dhaka 20 Kgs\r\nEx Male 20 Kgs\r\nEx Colombo 30 Kgs\r\nEx Dubai 30 Kgs\r\nEx Kabul 30 Kgs\r\nEx Muscat 30 Kgs\r\nEx Bangkok 20 Kgs\r\nEx Dhaka 20 Kgs\r\n\r <br/> <br/><ul><li>APART FROM AIRLINE CHARGES,GST+RAF+ APPLICABLE CHARGES IF ANY, WILL BE CHARGED.</li><li>MENTIONED FEE ARE INDICATIVE PER PAX AND PER SECTOR.</li><li>FOR DOMESTIC BOOKINGS, PASSENGERS ARE REQUIRED TO SUBMIT THE CANCELLATION OR REISSUE REQUEST AT LEAST 2 HOURS BEFORE THE AIRLINES CANCELLATION AND REISSUE POLICY.</li><li>FOR INTERNATIONAL BOOKINGS, PASSENGERS ARE REQUIRED TO SUBMIT THE CANCELLATION OR REISSUE REQUEST AT LEAST 4 HOURS BEFORE THE AIRLINES CANCELLATION AND REISSUE POLICY.</li></ul>","FareRestriction":null,"FareInclusions":[]}],"MiniFareRules":[{"JourneyPoints":"","Type":"","From":"","To":"","Unit":"","Details":"","OnlineReissueAllowed":false,"OnlineRefundAllowed":false}],"PenaltyCharges":[],"Status":1,"IsWebCheckInAllowed":false}}}}],"TransactionStatus":"","BookingId":"","Invoicedata":{"AgentSysId":0,"CustomerSysId":0,"TPSysId":0,"MasterTPSysId":0,"ProposalID":"0/V1","InvoiceDate":"2025-05-07","isDisplayMarkup":true,"PaymentDueDate":"2025-05-07","PaymentDate":"2025-05-07","ClientGST":0,"ClientGSTNumber":"","Currency":1,"TotalInvoiceValue":3476.75,"InvoiceStatus":1,"TotalSGST":22.88,"TotalCGST":22.88,"TotalIGST":0,"SumdiscountItem":0,"OtherDiscount":0,"otherDiscountVal":0,"TotalAdvance":3522.51,"TotalDueAmount":3522.51,"InvoiceValue":3522.51,"notes":"Flight Ticket","termsandcondition":"","client_state":"","Advance":0,"PaymentType":4,"paymentNote":"Online","misxItems_name":[{"AgencySysId":2656,"AgentSysId":0,"MisxItems_name":"Flight","Description":"DEL-BOM-Spicejet SG-8157","ItemQty":1,"ItemRates":3222.51,"Total":3222.51,"DiscountType":1,"Discount":1,"TotalDiscount":0,"TotalAmount":3522.51,"MarkupType":"","Markup":254.24,"TotalMarkup":254.24,"SubTotal":3476.75,"ServiceFeeTotal":45.76,"GSTPercentage":"18","TotalGST":45.76,"SGST":22.88,"CGST":22.88,"IGST":45.76,"ItemsSACCode":""}]}}',true);
								$ResponseStatus = isset($apiResponse['status']) ? $apiResponse['status'] : false;
								$ErrorMessage = $BookErrorMessage = isset($apiResponse['message']) ? $apiResponse['message'] : '';
								$InvoicedataApi = isset($apiResponse['Invoicedata']) ? $apiResponse['Invoicedata'] : '';
								$BookStatus = isset($apiResponse['results']['status']['success']) ? $apiResponse['results']['status']['success'] : false;
								$bookingId = isset($apiResponse['results']['bookingId']) ? $apiResponse['results']['bookingId'] : '';
								$Bookres = $apiResponse;
								$BookingerrCode = isset($Bookres['errors'][0]['errCode']) ? $Bookres['errors'][0]['errCode'] : 0;
								$model = new Gtxwebservices_Model_Webservices();
								if ($ResponseStatus == 1) {
									if($ICSourceSysId == 3){
										// echo "DataS<pre>";print_r(json_encode($DataS));die;
										$url = $this->GTXAPIDEFAULT . '/flight/v3/ticketing';
										$Bookres = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, [], $url);
										// $Bookres = json_decode('{"status":true,"message":"SUCCESS","results":[{"customerpnr":[{"PNR_Number":"CW824V","TicketId":"708CW824V","TicketNumber":"2260321","sectors":"DEL-BOM"},{"PNR_Number":"CW824V","TicketId":"708CW824V","TicketNumber":"2260322","sectors":"DEL-BOM"},{"PNR_Number":"CW824V","TicketId":"708CW824V","TicketNumber":"2260323","sectors":"DEL-BOM"}],"PNRNumber":"CW824V","GDSPNRNumber":"","ErrorCode":0,"ErrorMessage":"","IsBookingStatus":1,"OnwardAutoTicket":1,"IsPriceChanged":false,"sectorTitle":"DEL-BOM","BookingId":"d364b-cae6c-ad38b-2b8ef","APIBookingId":1980696,"LastTicketDate":"2025-05-12T18:32:35","flexiPayment":0,"bookingHold":0,"FareRules":[{"Origin":"DEL","Destination":"BOM","Airline":"6E","FareBasisCode":"R0IP","FareRuleDetail":"The FareBasisCode is: R0IP<br />Temp Fare Rules GG<br/> <br/><ul><li>APART FROM AIRLINE CHARGES,GST+RAF+ APPLICABLE CHARGES IF ANY, WILL BE CHARGED.</li><li>MENTIONED FEE ARE INDICATIVE PER PAX AND PER SECTOR.</li><li>FOR DOMESTIC BOOKINGS, PASSENGERS ARE REQUIRED TO SUBMIT THE CANCELLATION OR REISSUE REQUEST AT LEAST 2 HOURS BEFORE THE AIRLINES CANCELLATION AND REISSUE POLICY.</li><li>FOR INTERNATIONAL BOOKINGS, PASSENGERS ARE REQUIRED TO SUBMIT THE CANCELLATION OR REISSUE REQUEST AT LEAST 4 HOURS BEFORE THE AIRLINES CANCELLATION AND REISSUE POLICY.</li></ul>","FareRestriction":null,"FareInclusions":["Temp Fare Rules GG"]}],"gstData":"[]"},{"customerpnr":[{"PNR_Number":"QV63RG","TicketId":"708QV63RG","TicketNumber":"2260324","sectors":"BOM-DEL"},{"PNR_Number":"QV63RG","TicketId":"708QV63RG","TicketNumber":"2260325","sectors":"BOM-DEL"},{"PNR_Number":"QV63RG","TicketId":"708QV63RG","TicketNumber":"2260326","sectors":"BOM-DEL"}],"PNRNumber":"QV63RG","GDSPNRNumber":"","ErrorCode":0,"ErrorMessage":"","IsBookingStatus":1,"OnwardAutoTicket":1,"IsPriceChanged":false,"sectorTitle":"BOM-DEL","BookingId":"d364b-cae6c-ad38b-2b8ef","APIBookingId":1980697,"LastTicketDate":"2025-05-12T18:32:46","flexiPayment":0,"bookingHold":0,"FareRules":[{"Origin":"BOM","Destination":"DEL","Airline":"6E","FareBasisCode":"R0IP","FareRuleDetail":"The FareBasisCode is: R0IP<br />Temp Fare Rules GG<br/> <br/><ul><li>APART FROM AIRLINE CHARGES,GST+RAF+ APPLICABLE CHARGES IF ANY, WILL BE CHARGED.</li><li>MENTIONED FEE ARE INDICATIVE PER PAX AND PER SECTOR.</li><li>FOR DOMESTIC BOOKINGS, PASSENGERS ARE REQUIRED TO SUBMIT THE CANCELLATION OR REISSUE REQUEST AT LEAST 2 HOURS BEFORE THE AIRLINES CANCELLATION AND REISSUE POLICY.</li><li>FOR INTERNATIONAL BOOKINGS, PASSENGERS ARE REQUIRED TO SUBMIT THE CANCELLATION OR REISSUE REQUEST AT LEAST 4 HOURS BEFORE THE AIRLINES CANCELLATION AND REISSUE POLICY.</li></ul>","FareRestriction":null,"FareInclusions":["Temp Fare Rules GG"]}],"gstData":"[]"}],"Invoicedata":{"AgentSysId":0,"CustomerSysId":0,"TPSysId":0,"MasterTPSysId":0,"ProposalID":"0/V1","InvoiceDate":"2025-05-12","isDisplayMarkup":true,"PaymentDueDate":"2025-05-12","PaymentDate":"2025-05-12","ClientGST":0,"ClientGSTNumber":"","Currency":1,"TotalInvoiceValue":15981.96,"InvoiceStatus":1,"TotalSGST":0,"TotalCGST":0,"TotalIGST":0,"SumdiscountItem":0,"OtherDiscount":0,"otherDiscountVal":0,"TotalAdvance":15981.96,"TotalDueAmount":15981.96,"InvoiceValue":15981.96,"notes":"Flight Ticket","termsandcondition":"","client_state":"","Advance":0,"PaymentType":4,"paymentNote":"Online","misxItems_name":[{"AgencySysId":2656,"AgentSysId":0,"MisxItems_name":"Flight","Description":"DEL-BOM-Indigo 6E-395","ItemQty":1,"ItemRates":8076.98,"Total":8076.98,"DiscountType":1,"Discount":1,"TotalDiscount":0,"TotalAmount":8076.98,"MarkupType":"","Markup":0,"TotalMarkup":0,"SubTotal":8076.98,"ServiceFeeTotal":0,"GSTPercentage":"18","TotalGST":0,"SGST":0,"CGST":0,"IGST":0,"ItemsSACCode":""},{"AgencySysId":2656,"AgentSysId":0,"MisxItems_name":"Flight","Description":"BOM-DEL-Indigo 6E-2775","ItemQty":1,"ItemRates":7904.98,"Total":7904.98,"DiscountType":1,"Discount":1,"TotalDiscount":0,"TotalAmount":7904.98,"MarkupType":"","Markup":0,"TotalMarkup":0,"SubTotal":7904.98,"ServiceFeeTotal":0,"GSTPercentage":"18","TotalGST":0,"SGST":0,"CGST":0,"IGST":0,"ItemsSACCode":""}]}}',1);
										// echo "Bookres<pre>";print_r(json_encode($Bookres));die;
										$InvoicedataApi = isset($Bookres['Invoicedata']) ? $Bookres['Invoicedata'] : '';
										$ErrorMessage = isset($Bookres['message']) ? $Bookres['message'] : '';
										$ErrorCode = isset($Bookres['ErrorCode']) ? $Bookres['ErrorCode'] : '';
										$ErrorCode = (isset($getErrorCode[$ErrorCode]['gtx_error_code']) && !empty($getErrorCode[$ErrorCode]['gtx_error_code']))?$getErrorCode[$ErrorCode]['gtx_error_code']:$ErrorMessage;
										$ErrorCode = substr($ErrorCode, 0, 249);
										$statusType = 1;
										foreach ($FlightBooking as $k => $value) {
											$NetAmount = ($value['FairRules']['PublishedFare'] + $SeatPrice + $BagPrice + $MealPrice);
											$postField = isset($Bookres['results'][$k]) ? $Bookres['results'][$k] : [];
											$APIBookingresponse[] = $postField;
											$ErrorMessage = isset($postField['ErrorMessage']) ? $postField['ErrorMessage'] : '';
											$ErrorCode = substr($ErrorMessage, 0, 249);
											$IsBookingStatus = isset($postField['IsBookingStatus']) ? $postField['IsBookingStatus'] : 0;
											if ($IsBookingStatus == 1) {
												if ($k == 0) {
													$InvoicedataApi['ProposalID'] = $TPSysId . '/V1';
													$InvoicedataApi['MasterTPSysId'] = $MasterTPSysId;
													$InvoicedataApi['TPSysId'] = $TPSysId;
													$InvoicedataApi['CustomerSysId'] = $CustomerSysIdGTX;
													$invoiceResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->InvoiceCreate($InvoicedataApi, $FlightBooking);
													
													if ($couponApply == 1) {
														$applyCoupon = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->applyCoupon($applyData);
													}
													if ($IsCancellationProtection == 1) {
														$postField['CancellationProtectionData'] = $CancellationProtectionDataCode;
													}
													
												}
												$update = array(
													'FlightQueryids' => json_encode($FlightQueryids),
													'PNR_Number' => $postField['PNRNumber'],
													'BookingId' => $postField['BookingId'],
													'APIBookingId' => $postField['APIBookingId'],
													'MasterTPSysId' => $MasterTPSysId,
													'TPSysId' => $TPSysId,
													'status' =>  $statusType,
													'InvoiceNo' => isset($invoiceResponse['InvoiceNumber']) ? $invoiceResponse['InvoiceNumber'] : '',
												);
			
												if ($paymentMode == 3 || $paymentMode == 2) {
													$update['TransactionId_debit'] = $TransactionId;
												}
												if ($IsCancellationProtection == 1) {
													$update['IsCancellationProtection'] = $IsCancellationProtection;
													$update['CancellationProtectionPrice'] = round($CPAmountWithTax, 2);
												}
			
												$where = "apiTraceId = '$strUrlData'";
												$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);

												
												$postField['PublishedFare'] = $NetAmount;
												$postField['MasterTPSysId'] = $MasterTPSysId;
												$postField['TPSysId'] = $TPSysId;
												$postField['TrxId'] = $TrxId;
												$postField['VersionId'] = $VersionId[$k];
												$result = $model->UPDATE_FLIGHT_BOOKING($postField);
												$GTXUpdateresponse = $result;
												
											}else{
												$fare = $this->fareCalculatection($arrUrlData, $k);
												// echo "fare==== <pre>";print_r($fare);die;
												$DebitFromWallet = array(
													'Remark' => 'Refund',
													'Amount' => $fare['totalPayableAmount'],//($intNetPublishedFare + $MealFare + $BaggFare + $SeatPrice),
													'CustomerSysId' => $this->_session->session['CustomerSysId'],
													'CurrencyType' => 1,
													'PlanType' => 1,
													'PaymentMode' => 'Wallet Refund',
													'ReferenceNo' => $TPSysId,
												);
												if ($paymentMode == 1 && $this->_session->session['CustomerSysId'] && $UserWalletStatus == 1) {
													$Url = $this->gtxBtoBsite . 'gtxwebservices/customer-wallet/add-b2c-wallet-balance/';
													Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->DebitFromWallet($DebitFromWallet, $Url);
												}
												if ($usewallet == 1 && $paymentMode == 2 && $this->_session->session['CustomerSysId'] && $UserWalletStatus == 1) {
													$Url = $this->gtxBtoBsite . 'gtxwebservices/customer-wallet/add-b2c-wallet-balance/';
													Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->DebitFromWallet($DebitFromWallet, $Url);
												}
												$Destination = $SourceAirportCode . '-' . $DestAirportCode;
												$html = new Zend_View();
												$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
												$html->assign(array('ICSourceSysId' => $ICSourceSysId, 'Destination' => $Destination, 'traceId' => $traceId, 'agencyDetails' => $getAgencyData, 'CustomerSession' => $CustomerSession->params[0], 'baseUrl' => $this->baseUrl));
												$bodyText = $html->render('ErrorEmail.phtml');
	
												$subject = 'Booking Failed for ' . $Destination;
												$Caption = 'Booking Failed for ' . $Destination;
												$contactDetail_mail = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getContactDetailForFooter();
												$configs = [
													'to' => trim($CustomerSession->params[0]['EmailId']),
													'fromName' => $this->siteName,
													'fromEmail' => $getAgencyData['PrimaryEmail'],
													'subject' => $subject,
													'bodyHtml' => $bodyText,
												];
												$configsAg = [
													'to' => trim($getAgencyData['PrimaryEmail']),
													'fromName' => $this->siteName,
													'fromEmail' => $getAgencyData['PrimaryEmail'],
													'subject' => $subject,
													'bodyHtml' => $bodyText,
												];
	
												$this->objHelperGeneral->mailSentByElastice($configs, $Caption);
												$this->objHelperGeneral->mailSentByElastice($configsAg, $Caption);
												
											
												$update['status'] = 3;
												$update['TPSysId'] = $TPSysId;
												$where = "apiTraceId = '$traceId'";
												$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);

												$postFieldArray = array(
													'MasterTPSysId' => $MasterTPSysId,
													'TPSysId' => $TPSysId,
													'TrxId' => $TrxId,
													'VersionId' => $VersionId[$k],
													'field' => 'BookingStatus',
													'ErrorCode' => $ErrorCode,
													'StatusCode' => 144,
												);
												$result = $model->updateFlightPaymentFailed($postFieldArray);
											}
										}
										
										$arrUrlData['FlightBookingTicketArr'] = $Bookres;
										$arrUrlData['postField'] = $postField;
										$arrUrlData['GTXUpdateresponse'] = isset($GTXUpdateresponse) ? $GTXUpdateresponse :[];
										$tempData = array(
											'TraceId' => $traceId,
											'json_data' => json_encode($arrUrlData),
										);
										$objFlight->deleteFlightTempData($traceId);
										$objFlight->insertFlightTempData($tempData);
										$Return = array('success' => true, 'Isquery' => false, 'message' => 'done', 'SearchTraceId' => $traceId, 'TPSysId' => $TPSysId);
										echo json_encode($Return);
										exit;
									}
									$DataS = array(
										'apidata' => [],
										'BookingData' => $FlightBooking,
										'customer' => $customer,
										'memberCount' => $intMemberCount,
										'bookingHold' => isset($bookingHold) ? $bookingHold : 0,
										'JourneyType' => $JourneyType,
										'interNationalSearch' => $interNationalSearch,
										'searchID' => $traceId,
										'ICSourceSysId' => $ICSourceSysId,
										'AgentMarkUp' => 0,
										'APIMode' => (int)$this->APIMode,
									);
									// echo "DataS<pre>";print_r(json_encode($DataS));die;
									$url = $this->GTXAPIDEFAULT . '/flight/v3/reprint';
								
									$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
									// echo "apiResponse<pre>";print_r(json_encode($apiResponse));die;
									// $apiResponse = json_decode('{"status":true,"message":"SUCCESS","results":{"order":{"bookingId":"TJS109501436887","amount":2288,"markup":0,"deliveryInfo":{"emails":["jyoti@catpl.co.in"],"contacts":["918287473368"]},"status":"SUCCESS","createdOn":"2025-05-09T17:18:03.720"},"itemInfos":{"AIR":{"tripInfos":[{"sI":[{"id":"274381","fD":{"aI":{"code":"IX","name":"AI Express","isLcc":true},"fN":"1163","eT":"7M8"},"stops":0,"duration":150,"da":{"code":"DEL","name":"Delhi Indira Gandhi Intl","cityCode":"DEL","city":"Delhi","country":"India","countryCode":"IN","terminal":"Terminal 3"},"aa":{"code":"BOM","name":"Chhatrapati Shivaji","cityCode":"BOM","city":"Mumbai","country":"India","countryCode":"IN","terminal":"Terminal 2"},"dt":"2025-06-17T21:10","at":"2025-06-17T23:40","iand":false,"isRs":false,"sN":0,"ifo":false,"isbpo":false,"israa":true,"sid":22}]}],"travellerInfos":[{"pnrDetails":{"DEL-BOM":"WT9E3L"},"checkinStatusMap":{"DEL-BOM":false},"ti":"Ms","pt":"ADULT","fN":"jytjk","lN":"kushawaha"}],"totalPriceInfo":{"totalFareDetail":{"fC":{"TF":2288,"TAF":1389,"IGST":72,"NCM":285,"NF":2003,"BF":899},"afC":{"TAF":{"MFT":72,"AGST":54,"MF":400,"OT":863,"MU":0},"NCM":{"TDS":-15,"OT":300}}}}}},"gstInfo":[],"isSotoBooking":false,"status":{"success":true,"httpStatus":200}},"postField":[{"customerpnr":[{"PNR_Number":"WT9E3L","TicketId":"WT9E3L","TicketNumber":"","sectors":"DEL-BOM"}],"PNRNumber":"WT9E3L","GDSPNRNumber":"","ErrorCode":0,"ErrorMessage":"","IsBookingStatus":true,"OnwardAutoTicket":true,"IsPriceChanged":false,"sectorTitle":"DEL-BOM","BookingId":"d5d04-6a9f4-d880a-ddceb","APIBookingId":"TJS109501436887","LastTicketDate":"","flexiPayment":0,"bookingHold":0,"FareRules":[]}]}',true);
									$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;
									$statusType = 1;
									if ($OrderBookingStatus == 'PENDING') {
										$statusType = 20;
									}
									if ($ICSourceSysId == 8) {
										$statusType = 20;
									}
									if ($status == 1 && $BookStatus == 1 && $OrderBookingStatus != 'ABORTED') {
										$RewardsPoints = isset($FlightBooking[0]['FairRules']['RewardsPoints']) ? $FlightBooking[0]['FairRules']['RewardsPoints'] : 0;
										$RewardsEarn = isset($FlightBooking[0]['FairRules']['RewardsEarn']) ? $FlightBooking[0]['FairRules']['RewardsEarn'] : 0;
										$InvoicedataApi['ProposalID'] = $TPSysId . '/V1';
										$InvoicedataApi['MasterTPSysId'] = $MasterTPSysId;
										$InvoicedataApi['TPSysId'] = $TPSysId;
										$InvoicedataApi['CustomerSysId'] = $CustomerSysIdGTX;
										// echo "InvoicedataApi<pre>";print_r($InvoicedataApi);die;
										$invoiceResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->InvoiceCreate($InvoicedataApi, $FlightBooking);
										foreach ($FlightBooking as $k => $value) {
											$postField = isset($apiResponse['postField'][$k]) ? $apiResponse['postField'][$k] : [];
											$update = array(
												'FlightQueryids' => json_encode($FlightQueryids),
												'PNR_Number' => $postField['PNRNumber'],
												'BookingId' =>  $postField['BookingId'],
												'APIBookingId' => $postField['APIBookingId'],
												'MasterTPSysId' => $MasterTPSysId,
												'TPSysId' => $TPSysId,
												'status' => ($bookingHold == 1) ? 23 : $statusType,
												'InvoiceNo' => isset($invoiceResponse['InvoiceNumber']) ? $invoiceResponse['InvoiceNumber'] : '',
											);
											if ($couponApply == 1) {
												$applyCoupon = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->applyCoupon($applyData);
											}
											if ($paymentMode == 3 || $paymentMode == 2) {
												$update['TransactionId_debit'] = $TransactionId;
											}
											if ($IsCancellationProtection == 1) {
												$update['IsCancellationProtection'] = $IsCancellationProtection;
												$update['CancellationProtectionPrice'] = round($CPAmountWithTax, 2);
											}
											// echo "update<pre>";print_r($update);die;
											$where = "apiTraceId = '$traceId'";
											$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);

											$NetAmount = ($value['FairRules']['PublishedFare'] + $SeatPrice + $BagPrice + $MealPrice);

											$postField['PublishedFare'] = $NetAmount;
											$postField['MasterTPSysId'] = $MasterTPSysId;
											$postField['TPSysId'] = $TPSysId;
											$postField['TrxId'] = $TrxId;
											$postField['VersionId'] = $VersionId[$k];
											$result = $model->UPDATE_FLIGHT_BOOKING($postField);
											$GTXUpdateresponse = $result;
											// echo '<pre>';
											// print_r(($result));
											// $strFilePath = "flight/SearchParam/" . $TPSysId . "/GTX/" . time() . "_update_response.json";
											// Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, ($result));
										}

										if ($BookStatus == 1 && $ResponseStatus == 1) {

											if ($ICSourceSysId != 7) {
												$updateReferenceNumber = '';
												$apiUpdate = array(
													'SecurityKey' => $this->SecurityKey,
													'RefrenceNo' => $strUrlData,
													'TransactionId' => (isset($TransactionId) && !empty($TransactionId)) ? $TransactionId : $TransactionId_debit,
													'FlightTraceId' => $strUrlData,
												);

												$updateReferenceNumber = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->updateReferenceNumber($apiUpdate);

												if (!empty($TransactionId_credit)) {
													$apiUpdateC = array(
														'SecurityKey' => $this->SecurityKey,
														'RefrenceNo' => $strUrlData,
														'TransactionId' => $TransactionId_credit,
														'FlightTraceId' => $strUrlData,
													);
													$updateReferenceNumber = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->updateReferenceNumber($apiUpdateC);
												}
											}

											$arrUrlData['FlightBookingTicketArr'] = $response;
											$arrUrlData['postField'] = $postField;
											$arrUrlData['updateReferenceNumber'] = $updateReferenceNumber;
											$arrUrlData['GTXUpdateresponse'] = $GTXUpdateresponse;
											$tempData = array(
												'TraceId' => $traceId,
												'json_data' => json_encode($arrUrlData),
												'created_at' => date('Y-m-d H:i:s'),
											);
											// echo "arrUrlData<pre>";print_r(json_encode($arrUrlData));die;
											$objFlight->deleteFlightTempData($traceId);
											$objFlight->insertFlightTempData($tempData);
											$this->objMdl->rv_delete('tbl_temp_data', array('TraceId = ?' => $traceId));
												
											$Return = array('success' => true, 'Isquery' => false, 'message' => 'done', 'SearchTraceId' => $traceId,'ICSourceSysId'=>$ICSourceSysId, 'TPSysId' => $TPSysId);
											echo json_encode($Return);
											exit;
										} else {
											$Return = array('success' => false, 'Isquery' => false, 'message' => 'failed', 'SearchTraceId' => $traceId,'ICSourceSysId'=>$ICSourceSysId, 'TPSysId' => $TPSysId);
											echo json_encode($Return);
											exit;
										}
									} else {
										$ErrorCode = (isset($getErrorCode[$BookingerrCode]['gtx_error_code']) && !empty($getErrorCode[$BookingerrCode]['gtx_error_code'])) ? $getErrorCode[$BookingerrCode]['gtx_error_code'] : $BookErrorMessage;
										$ErrorCode = substr($ErrorCode, 0, 249);
										$model = new Gtxwebservices_Model_Webservices();
										if ($FlightBookingData) {
											foreach ($FlightBookingData as $k => $value) {
												$update['TransactionId_debit'] = isset($TransactionId) ? $TransactionId : '';
												$update['status'] = 3;
												$update['TPSysId'] = $TPSysId;
												$where = "apiTraceId = '$strUrlData'";
												$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
												// 'BookingId' => $bookingId,
												// 'APIBookingId' => $strBookingIdLCC,
												// 'XRefBookingId' => $bookingId,
												$Destination = $SourceAirportCode . '-' . $DestAirportCode;
												$html = new Zend_View();
												$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
												$html->assign(array('ICSourceSysId' => $ICSourceSysId, 'Destination' => $Destination, 'traceId' => $traceId, 'agencyDetails' => $getAgencyData, 'CustomerSession' => $CustomerSession->params[0], 'baseUrl' => $this->baseUrl));
												$bodyText = $html->render('ErrorEmail.phtml');
	
												$subject = 'Booking Failed for ' . $Destination;
												$Caption = 'Booking Failed for ' . $Destination;
												$contactDetail_mail = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getContactDetailForFooter();
												$configs = [
													'to' => trim($CustomerSession->params[0]['EmailId']),
													'fromName' => $this->siteName,
													'fromEmail' => $getAgencyData['PrimaryEmail'],
													'subject' => $subject,
													'bodyHtml' => $bodyText,
												];
												$configsAg = [
													'to' => trim($getAgencyData['PrimaryEmail']),
													'fromName' => $this->siteName,
													'fromEmail' => $getAgencyData['PrimaryEmail'],
													'subject' => $subject,
													'bodyHtml' => $bodyText,
												];
	
												$this->objHelperGeneral->mailSentByElastice($configs, $Caption);
												$this->objHelperGeneral->mailSentByElastice($configsAg, $Caption);
												

												$postFieldArray = array(
													'MasterTPSysId' => $MasterTPSysId,
													'TPSysId' => $TPSysId,
													'TrxId' => $TrxId,
													'XRefBookingId' => $bookingId,
													'ErrorCode' => $ErrorCode,
													'VersionId' => isset($VersionId[$k]) ? $VersionId[$k] : 0,
													'IsBookingStatus' => 124,
													'updatePnr' => 1
												);
												if ($OrderBookingStatus == 'ABORTED') {
													$result = $model->updateFlightAbortedgB2B($postFieldArray);
												} else {
													$postFieldArray['field'] = 'BookingStatus';
													$postFieldArray['StatusCode'] = 144;
													$result = $model->updateFlightPaymentFailed($postFieldArray);
												}
											}
										}


										// $WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyWallaetBalance($this->SecurityKey);
										// $sessionWallaetBalance = new Zend_Session_Namespace('sessionWallaetBalance');
										// $sessionWallaetBalance->params = $WallaetBalance;

										$arrUrlData['FlightBookingTicketArr'] = $Bookres;
										$arrUrlData['CreditIntoWallet'] = isset($CreditIntoWallet) ? $CreditIntoWallet : '';
										$tempData = array(
											'TraceId' => $strUrlData,
											'json_data' => json_encode($arrUrlData),
										);
										$objFlight->deleteFlightTempData($strUrlData);
										$objFlight->insertFlightTempData($tempData);
										$Return = array('success' => false, 'Isquery' => false, 'message' => $BookErrorMessage, 'SearchTraceId' => $strUrlData, 'TPSysId' => $TPSysId);
										echo json_encode($Return);
										exit;
									}
								}else{
									$DebitFromWallet = array(
										'Remark' => 'Refund',
										'Amount' => $PublishedFareWallet,
										'CustomerSysId' => $this->_session->session['CustomerSysId'],
										'CurrencyType' => 1,
										'PlanType' => 1,
										'PaymentMode' => 'Wallet Refund',
										'ReferenceNo' => $TPSysId,
									);
									
									if ($paymentMode == 1 && $this->_session->session['CustomerSysId'] && $UserWalletStatus == 1) {
										$Url = $this->gtxBtoBsite . 'gtxwebservices/customer-wallet/add-b2c-wallet-balance/';
										Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->DebitFromWallet($DebitFromWallet, $Url);
									}
									if ($usewallet == 1 && $paymentMode == 2 && $this->_session->session['CustomerSysId'] && $UserWalletStatus == 1) {
										$Url = $this->gtxBtoBsite . 'gtxwebservices/customer-wallet/add-b2c-wallet-balance/';
										Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->DebitFromWallet($DebitFromWallet, $Url);
									}
									
									$model = new Gtxwebservices_Model_Webservices();
									if ($FlightBookingData) {
										foreach ($FlightBookingData as $k => $value) {
											$update['TransactionId_debit'] = isset($TransactionId) ? $TransactionId : '';
											$update['status'] = 3;
											$update['TPSysId'] = $TPSysId;
											$where = "apiTraceId = '$strUrlData'";
											$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);

											$postFieldArray = array(
												'MasterTPSysId' => $MasterTPSysId,
												'TPSysId' => $TPSysId,
												'TrxId' => $TrxId,
												'XRefBookingId' => $bookingId,
												'VersionId' => isset($VersionId[$k]) ? $VersionId[$k] : 0,
												'IsBookingStatus' => 124,
												'updatePnr' => 1
											);
											$postFieldArray['field'] = 'BookingStatus';
											$postFieldArray['StatusCode'] = 144;
											$result = $model->updateFlightPaymentFailed($postFieldArray);
											
										}
									}
									$arrUrlData['bookAPIResponse'] = $bookAPIResponse;
									// $arrUrlData['CreditIntoWallet'] = isset($CreditIntoWallet) ? $CreditIntoWallet : '';
									$tempData = array(
										'TraceId' => $strUrlData,
										'json_data' => json_encode($arrUrlData),
									);
									$objFlight->deleteFlightTempData($strUrlData);
									$objFlight->insertFlightTempData($tempData);
									$Return = array('success' => true, 'Isquery' => false, 'message' => $ErrorMessage, 'SearchTraceId' => $strUrlData, 'TPSysId' => $TPSysId);
									echo json_encode($Return);
									exit;
								}

							}

							// old code below i have only change new update TBO and TJ flight all api as working old process

							$IsSeriesFareData = isset($BookingData[0]['IsSeriesFareData']) ? $BookingData[0]['IsSeriesFareData'] : 0;
							$SourceAirportCode = isset($BookingData[0]['SourceAirportCode']) ? $BookingData[0]['SourceAirportCode'] : '';
							$DestAirportCode = isset($BookingData[0]['DestAirportCode']) ? $BookingData[0]['DestAirportCode'] : '';

							if ($interNationalSearch == 1) {
								$intCountryCode = 'INT';
								$ItemSourceType = 2;
							} else {
								$intCountryCode = 'IN';
								$ItemSourceType = 1;
							}
							$intMarkUp = $this->getMarkup($intCountryCode);
							$arrAgencyUserDetail = isset($intMarkUp['arrAgencyUserDetail']) ? $intMarkUp['arrAgencyUserDetail'] : '';


							$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->getSupportContact(1, 1, $ItemSourceType);
							if (isset($getSupportContact['EmailId']) && !empty($getSupportContact['EmailId']) && $getSupportContact['IsBookingEmail'] == 1) {
								$MasterPrimaryEmailTo = trim($getSupportContact['EmailId']);
							} else {
								$MasterPrimaryEmailTo = $getAgencyData['PrimaryEmail'];
							}
							$getAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->gtxagencysysid);
							$this->siteName = (isset($getAgencyData['DisplayName']) && !empty($getAgencyData['DisplayName']))?$getAgencyData['DisplayName']: $this->siteName;
							// echo"<pre>";print_r($BookingData);die();

							$param = $this->getRequest()->getParams();
							$IsLCC = false;
							if ($ICSourceSysId == 7 || $ICSourceSysId == 8 || $ICSourceSysId == 17 || $ICSourceSysId == 16 || $ICSourceSysId == 11) {
								$adultCount = isset($sessionFlightSearchParams->params['adults']) ? $sessionFlightSearchParams->params['adults'] : 0;
								$childCount = isset($sessionFlightSearchParams->params['child']) ? $sessionFlightSearchParams->params['child'] : 0;
								$infantCount = isset($sessionFlightSearchParams->params['infant']) ? $sessionFlightSearchParams->params['infant'] : 0;
								$intMemberCount = $adultCount + $childCount + $infantCount;
								$IsPassMandatory = isset($FlightBookingData->params[0]['IsPassMandatory']) ? $FlightBookingData->params[0]['IsPassMandatory'] : 0;
								$isDocIdAllowedMandatory = isset($FlightBookingData->params[0]['isDocIdAllowedMandatory']) ? $FlightBookingData->params[0]['isDocIdAllowedMandatory'] : 0;

								$BagPrice = 0;
								$InbBagPrice = 0;
								$MealPrice = 0;
								$InbMealPrice = 0;
								$SeatPrice = 0;
								if ($SelectedBaggSessionNew->params) {
									foreach ($SelectedBaggSessionNew->params as $values) {
										//foreach ($values as $val) {
										$BagPrice += $values['Price'];
										//}
									}
								}
								if ($SelectedMealSessionNew->params) {
									foreach ($SelectedMealSessionNew->params as $values) {
										//foreach ($values as $val) {
										$MealPrice += $values['Price'];
										//}
									}
								}

								$MealFare = ($MealPrice + $InbMealPrice);
								$BaggFare = ($BagPrice + $InbBagPrice);


								$BookingdataAPI = array(
									'getAgencyData' => $getAgencyData,
									'arrAgencyUserDetail' => $arrAgencyUserDetail,
									'FlightBookingData' => $BookingData,
									'customer' => $customer,
									'sessionFlightSearchParams' => $sessionFlightSearchParams->params,
									'CustomerSession' => $CustomerSession->params,
									'flightdetails'   =>   $FlightBookingData->params
								);
								//
								if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
									$Bookres = [
										'status' => array('success' => true),
									];
								} else {
									if($ICSourceSysId == 17){
										
										$itinKey  = isset($BookingData[0]['ApiResultIndex']) ? $BookingData[0]['ApiResultIndex'] : '';
										$CityTitle = isset($CustomerSession->params[0]['CityTitle']) ? $CustomerSession->params[0]['CityTitle'] : '';
										$amountToCharge = isset($BookingData[0]['PublishedFare']) ? $BookingData[0]['PublishedFare'] : 0;
										$ApiResultIndex = isset($BookingData[0]['ApiResultIndex']) ? $BookingData[0]['ApiResultIndex'] : '';
										$ARR_SALUTION = unserialize(ARR_SALUTION);
										$ARR_SALUTION_CHILD = unserialize(ARR_SALUTION_CHILD);
										$PaxData = [];
										$ssrList = [];
										if($CustomerSession->params){
											foreach($CustomerSession->params as $pk=>$val){
												if($val['DOB']){
													$DOB = date('Y-m-d',strtotime($val['DOB']));
													$Age = date_diff(date_create($DOB), date_create('today'))->y;
												}
												if($val['paxType'] == 1){
													$PaxType = 'Adult';
													$paxTitle = ($ARR_SALUTION[$val['Salutation']]);
												}elseif($val['paxType'] == 2){
													$PaxType = 'Child';
													$paxTitle = ($ARR_SALUTION_CHILD[$val['Salutation']]);
												}else{
													$PaxType = 'Infant';
													$paxTitle = ($ARR_SALUTION_CHILD[$val['Salutation']]);
												}
												
												// echo "<pre>";
												// print_r(($val));die;
												$PaxData[$pk] = array(
													"title" => $paxTitle,
													"first_name" => $val['FirstName'],
													"last_name" => $val['LastName'],
													"dob" => $DOB,
													"type" => $PaxType,
													"tour_code" => "",
													"deal_code" => "",
													"frequent_flyer_number" => "",
													"visa" => "",
													"passport_placeofissue" => "",
													"passport" => ($IsPassMandatory) ? $val['PassportNo'] : "",
													"passport_dateofexpiry" => ($IsPassMandatory) ? $val['PassportExpiry'] : "",
													"passport_dateofissue" => ($IsPassMandatory) ? $val['passporIssue'] : "",
													"idproof" => ($isDocIdAllowedMandatory) ? $val['docId'] : "",
													
													"agentid" => "",
													"meal_preference" => "",
													"seat_preference" => "",
													"additional_segmentinfo" => "",
													"profileid" => ($pk + 1),
													"paxssrinfo" => [],
												);
												$baggData = [];
												$mealData = [];
												if($arrUrlData['SelectedBaggSessionNew']){
													foreach($arrUrlData['SelectedBaggSessionNew'] as $baggages){
														$baggseet = isset($baggages)?$baggages:[];
														$baggData[] = [
															"carrier" => $baggseet['carrier'],
															"destination" => $baggseet['destination'],
															"jtype" => "onward",
															"origin" => $baggseet['origin'],
															"passenger_fname" => $val['FirstName'],
															"passenger_lname" => $val['LastName'],
															"passenger_title" => $paxTitle,
															"paxid" => $pk + 1,
															"paxtype" => $PaxType,
															"ssr_chargeableamount" => $baggseet['chargeableamount'],
															"ssrcode" => $baggseet['ssrcode'],
															"ssrname" => $baggseet['ssrname'],
															"ssrtype" => $baggseet['ssrtype']
														];
													}
												}
												if($arrUrlData['SelectedMealSessionNew']){
													foreach($arrUrlData['SelectedMealSessionNew'] as $mealses){
														$mealseet = isset($mealses)?$mealses:[];
														
														$mealData[] = [
															"carrier" => $mealseet['carrier'],
															"destination" => $mealseet['destination'],
															"jtype" => "onward",
															"origin" => $mealseet['origin'],
															"passenger_fname" => $val['FirstName'],
															"passenger_lname" => $val['LastName'],
															"passenger_title" => $paxTitle,
															"paxid" => $pk + 1,
															"paxtype" => $PaxType,
															"ssr_chargeableamount" => $mealseet['chargeableamount'],
															"ssrcode" => $mealseet['ssrcode'],
															"ssrname" => $mealseet['ssrname'],
															"ssrtype" => $mealseet['ssrtype']
														];
													}
												}
												$ssrList[] = array_values(array_merge($baggData,$mealData));
												// $PaxData[$pk]['paxssrinfo'] = array_values(array_merge($baggData,$mealData));
																							
											}
										}
										// echo json_encode($ssrList);
										$ssrListData = [];
										if($ssrList){
											foreach($ssrList as $ssrVal){
												if($ssrVal){
													foreach($ssrVal as $ssrData){
														$ssrListData[] = $ssrData;
													}
												}
											}
										}
										$CityTitle = isset($CustomerSession->params[0]['CityTitle']) && !empty(($CustomerSession->params[0]['CityTitle'])) ? preg_replace("/[^a-zA-Z0-9 ]/", " ", $CustomerSession->params[0]['CityTitle']) :'';
										$request = array(
											"taxInfoStr" => $ApiResultIndex,
											// "leademail" => $CustomerSession->params[0]['EmailId'],
											"leademail" => $getAgencyData['PrimaryEmail'],
											"leadmobile" => $CustomerSession->params[0]['Contacts'],
											"leadcountry" => trim($CustomerSession->params[0]['countryCodeISO']),
											"leadcity" => $CityTitle,
											"leadstate" => $CityTitle,
											"paymentmode" => "cashcard",
											"domint" => ($interNationalSearch)?'international':'domestic',
											"numadults" => $adultCount,
											"numchildren" => $childCount,
											"numinfants" => $infantCount,
											"passengerList" => $PaxData,
											"ssrList" => ['SSRRow'=>$ssrListData],
										);
										if(!empty($gstData)){
											$request['gstdetails'] =  [
												'gstnumber' => $gstData['GstNumber'],
												'gstemail' => $gstData['GstEmail'],
												'gstcompany' => $gstData['GstCompany'],
												'gstaddress' => $gstData['GstAddress'],
												'gstphone' => $gstData['GstPhone'],
											];
										}
										$DataS = array(
											'apidata'=>['bookingrequest'=>$request],
											'memberCount'=> $intMemberCount,
											'JourneyType'=> $route,
											'interNationalSearch'=> $interNationalSearch,
											'searchID'=> $BookingData[0]['SearchTraceId'],
											'ICSourceSysId'=> $ICSourceSysId,
											'APIMode' => $this->APIMode,
											'AgentMarkUp'=> 0,//$getAgencyMarkups[0]['StdMarkUpPer'],
										);
										// echo json_encode($DataS);
										// echo "<pre>";print_r(json_encode($DataS));die("DataS");
										$getData['BookingData'] = $BookingData;
										$url = $this->GTXAPIDEFAULT.'/flight/v3/book';
										
										$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
										// echo "<pre>";print_r(json_encode($apiResponse));die;
										// $apiResponse = json_decode('{"status":true,"message":"SUCCESS","results":{"ApiStatus":{"Status":"OK","StatusCode":"200","Message":"Flight Invoice Details Fetched","Operation":"getETicket","ResultFormat":"JSON","TransactionStatus":"","Result":{"txid":"","flightRecord":{"txid":"FB0603NDLOHT","origin":"DEL","destination":"BOM","total_amount":1653,"fare_quote_amount":1653,"total_base_tax":1653,"multisupplier":"no","payment_status":"paid","booking_status":"pending","payment_mode":"cashcard","bank_id":"NA","bookingdate":"2025-03-06 11:53:58.0","num_sectors":1,"num_adults":1,"num_children":0,"num_infants":0,"num_pax":1,"gds_pnr":"pending","airline_pnr":"pending","fare_breakup":"xxx","booking_type":"online","booking_provider":"OFFLINE","bookedbyname":"Catabatic Test","bookedbyroleid":"3","process_status":"pending","erptxid":"-","ispassthrough":"no","passthroughtype":"-","ssramount":0,"issbill":"false","tripnumber":"","iscloned":"false","travelinsurance_txid":"-","approval_status":"pending","approvaltxid":"","projectcode":"-","ticketing_date":"","passthroughjtype":"","passthroughxml":"","passthroughamount":0,"educess":0,"highereducess":0,"corporatecode":"","isaccountingpushed":"","jn":0,"hiddenmarkup":0,"jtype":"OneWay","agentid":"GWT06185","passengername":"JYOGDHKF","passengerlastname":"FGHFH","passengertitle":"MS","passengeremail":"prashant@catpl.co.in","passengercontact":"8287473368","passengeraddress":"","domint":"domestic","jdate":"2025-03-12","rdate":"2025-03-12","agent_company":"Catabatic","markup":0,"servicetax":0,"tds":0,"commission":0,"handlingcharges":0,"tfeefq":0,"tfeeinv":0,"basefare":512,"tax":1141,"yq":0,"channelinfo":"-","bookingchannel":"api","corporatename":"-","travel_status":"pending","cabinclass":"economy","baggageinfo":"NA","splremarks":"-","costcenter":"-","bookedbyid":"GWT06185","issplrt":"false","travelinsurance_included":"false","travelinsurance_amount":"0.00","inpolicy":"true","policy_reason":"-","additional_basehc":0,"additional_taxhc":0,"additional_feehc":0,"employeeid":"-","apitxid":"-","apidbname":"","promocode":"-","promocode_used":"false","promovalue":0,"corporate_department":"-","apiremarks":"","requestedby":"","carrier":"QPT","invoicenumber":"2158","adminremarks":"-","pgcharges":"0.00","additional":"","flightticketnums":"-","additional_markup":0,"hasssr":"false","hasseatssr":"false","phoneIntlCode":"","phoneAreaCode":"","skipadditionalhc":"","endUserIP":"","endUserBrowser":"","ismultiticketnumber":""},"passengerRecords":[{"txid":"FB0603NDLOHT","paxid":"5093","trip_number":"1","title":"Ms","first_name":"jyogdhkf","last_name":"fghfh","dob":"1998-03-18","type":"adult","email":"","contact_number":"","base_fare":512,"tax":1141,"fuel_surcharge":0,"gds_pnr":"-","airline_pnr":"-","flight_ticket_number":"-","fare_breakup":"XXX","status":"confirmed","tour_code":"","deal_code":"","frequent_flyer_number":"","passport":"","visa":"","passport_dateofissue":"","passport_placeofissue":"","passport_dateofexpiry":"","agentid":"GWT06185","meal_preference":"","seat_preference":"","additional_segmentinfo":"-","paxssrinfo":" <list>     </list>         ","bookingpageparams":"","endorsement_code":"","paxseatinfo":"","paxssrseatinfo":"         <list>             </list>                 ","seatnumber":"","seattypes":"","idproof":"","cost_center":"","grade":"","department":"","designation":"","namechange_allowed":"","liftstatus":"","isnameupdated":"no","tour_code_status":"pending","deal_code_status":"pending","freqfly_status":"pending","passport_status":"pending","ssr_status":"pending","ssr_error":"-","error_details":"-","seat_status":"pending","meal_status":"pending","seat_error":"-","meal_error":"-","specialssr":"-","commission":0,"tds":0,"servicetax":0,"handlingcharges":0,"tfeeinv":0,"tfeefq":0,"promo_discount":0,"discomm":0,"totalinvoice":0,"totalfarequote":0,"markup":0,"canxtxid":"","resctxid":"","refundamount":0,"profileid":"1","additional_basehc":0,"additional_taxhc":0,"additional_feehc":0,"beneficiaryname":"","paxtypechange_allowed":"","osiremarks":"","ssrs":[]}],"passengerFareCollection":[{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"1","amount":512},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"2","amount":1141},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"3","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"4","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"5","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"6","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"7","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"8","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"9","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"10","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"11","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"12","amount":1653},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"13","amount":1653},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"14","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"15","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"18","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"19","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"21","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"41","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"42","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"50","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"51","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"52","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"60","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"64","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"70","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"71","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"72","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"73","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"81","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"82","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"83","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"84","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"85","amount":0},{"txid":"FB0603NDLOHT","paxid":"5093","paxtype":"Adult","fare_componentid":"86","amount":0}],"sectorRecords":[{"txid":"FB0603NDLOHT","origin":"DEL","destination":"BOM","sector_number":"0","jdate":"2025-03-12","departure_time":"1040","arrival_time":"1500","arrdate":"20250312","booking_class":"J","fare_basis":"-","carrier":"QPT","flight_number":"1411","flight_type":"Onward","insert_time":"2025-03-06 11:53:58.0","stop_over":"","airline_pnr":"-","baggageinfo":"-","flight_model":"NA","refundable":false,"refundable_info":"-","airport_terminal":"T2,T1","agentid":"GWT06185","sector_duration":"260","journey_duration":"260","origin_fullname":"Delhi","destination_fullname":"Mumbai","tripnumber":"1","Supplier_id":"","trip_number":"","meal":"","seat":"","baggage":"","specialssr":"","origin_airportfullname":"Indira Gandhi Intl(New Delhi, India)","destination_airportfullname":"Chhatrapati Shivaji(Mumbai, Bombay, India)","base_fare":512,"tax":1141,"total_amount":1653,"faretype":"","carrier_name":"","gds_pnr":"-","supplier":"-","supplier_officeid":"-","supplier_bookingreference":"-","sector_barcode":"","sector_ticketnumber":"","paxid":"","arrival_terminal":"","depart_terminal":"","operatedby":"NA"}],"flightTickets":[{"txid":"FB0603NDLOHT","paxid":"5093","sector_number":"1","trip_number":"1","ticket_number":"pending","airline_pnr":"-","ffnnumber":""}],"flightCommissionCollection":[{"txid":"FB0603NDLOHT","agentid":"GWT06185","type":"FlightsDomestic","carrier":"All","fare_componentid":"4","unit":"percent","value":"0.000","fare_componentid_computed":"1","sign":"+"},{"txid":"FB0603NDLOHT","agentid":"GWT06185","type":"FlightsDomestic","carrier":"All","fare_componentid":"5","unit":"percent","value":"0.000","fare_componentid_computed":"3","sign":"+"},{"txid":"FB0603NDLOHT","agentid":"GWT06185","type":"FlightsDomestic","carrier":"All","fare_componentid":"15","unit":"flat","value":"0.000","fare_componentid_computed":"12","sign":"+"},{"txid":"FB0603NDLOHT","agentid":"GWT06185","type":"FlightsDomestic","carrier":"All","fare_componentid":"3","unit":"percent","value":"0.000","fare_componentid_computed":"1","sign":"+"},{"txid":"FB0603NDLOHT","agentid":"UT12461","type":"FlightsDomestic","carrier":"All","fare_componentid":"4","unit":"percent","value":"0.000","fare_componentid_computed":"1","sign":"+"},{"txid":"FB0603NDLOHT","agentid":"UT12461","type":"FlightsDomestic","carrier":"All","fare_componentid":"5","unit":"percent","value":"0.000","fare_componentid_computed":"3","sign":"+"},{"txid":"FB0603NDLOHT","agentid":"UT12461","type":"FlightsDomestic","carrier":"All","fare_componentid":"15","unit":"flat","value":"0.000","fare_componentid_computed":"12","sign":"+"},{"txid":"FB0603NDLOHT","agentid":"UT12461","type":"FlightsDomestic","carrier":"All","fare_componentid":"3","unit":"percent","value":"0.000","fare_componentid_computed":"1","sign":"+"}],"supplierinfo":"","userinfo":"","additional_markup":0,"accountingXml":"","taxbreakupxml":"","supplierapiname":"","narration1":"","narration2":"","narration3":"","bookingstrlog":"QPT,1411,J,DEL,BOM,1040,1500,20250312,20250312,E,N,0,QP,260,260,N,7MB,N,-,T2,T1,112,saas_gatewaytest_GWT06185_AKASAAIRAPI_0_17412387471397873.8793824381155_0@Student Fares***1,0,0,512.0,0.0,0.0,1141.0,0.0,1750.0,0.0,0.0,0.0,STU$PHF$75.0##STU$RCS$50.0##STU$YQ$550.0##STU$TFE$18.0##STU$ASF$236.0##STU$PSF$91.0##STU$UDF$61.0##STU$GST$60.0@@@@,B0O7RBIX-EC-***512.0:1141.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:1653.0:0.0:1653.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0***-***N***512.0:1141.0:0.0:0.0:0.0:0.0:0.0:0.0:1653.0:0.0:1653.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:eydoY19mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6MX0sJ3NlcnZpY2V0YXhfZmFyZWNvbnMnOnsnZmx0JzowLjAsJ2JmJzowLjAsJ3RheCc6MC4wLCd5cSc6MC4wLCd5cic6MC4wLCdkaXMnOjAuMCwnaGMnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMScsJ3N0YXhfYmZfYW10JzowLjAsJ3N0YXhfeXFfYW10JzowLjAsJ3N0YXhfdGZlZV9hbXQnOjAuMCwnc3RheF9kaXNfYW10JzowLjAsJ3N0YXhfaGNfYW10JzowLjB9LCd0ZmVlX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdtZmVlX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdkaXNjb3VudF9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnLCdkaXNjb21tJzonMC4wLTAuMC0wLjAtMC4wJ30sJ3Rkc19mYXJlY29ucyc6eydmbHQnOjAuMCwnZGlzJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnfSwncGxiY3V0bnBheV9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2hjJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnLCdwbGJfYmZfYW10JzowLjAsJ3BsYl90YXhfYW10JzowLjAsJ3BsYl95cV9hbXQnOjAuMCwncGxiX2hjX2FtdCc6MC4wfSwnaGlkZGVuX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdlZHVjZXNzX2ZhcmVjb25zJzp7J2ZsdCc6MCwnYmYnOjAsJ3RheCc6MCwneXEnOjAsJ3N0YXgnOjAuMCwnaGMnOjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnfSwnaGlnaGVyZWR1Y2Vzc19mYXJlY29ucyc6eydmbHQnOjAsJ2JmJzowLCd0YXgnOjAsJ3lxJzowLCdzdGF4JzowLjAsJ2Rpcyc6MC4wLCdoYyc6MCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdjdXN0b21lcm1hcmt1cF9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6Jyd9LCdkaXNmZWVfZmFyZWNvbnMnOnsnZmx0JzowLjAsJ2JmJzowLjAsJ3lxJzowLjAsJ3RheCc6MC4wfX0=:0.0:0.0:0.0:0.0:0.0:0.0,0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:eydoY19mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6MX0sJ3NlcnZpY2V0YXhfZmFyZWNvbnMnOnsnZmx0JzowLjAsJ2JmJzowLjAsJ3RheCc6MC4wLCd5cSc6MC4wLCd5cic6MC4wLCdkaXMnOjAuMCwnaGMnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMScsJ3N0YXhfYmZfYW10JzowLjAsJ3N0YXhfeXFfYW10JzowLjAsJ3N0YXhfdGZlZV9hbXQnOjAuMCwnc3RheF9kaXNfYW10JzowLjAsJ3N0YXhfaGNfYW10JzowLjB9LCd0ZmVlX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdtZmVlX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdkaXNjb3VudF9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnLCdkaXNjb21tJzonMC4wLTAuMC0wLjAtMC4wJ30sJ3Rkc19mYXJlY29ucyc6eydmbHQnOjAuMCwnZGlzJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnfSwncGxiY3V0bnBheV9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2hjJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnLCdwbGJfYmZfYW10JzowLjAsJ3BsYl90YXhfYW10JzowLjAsJ3BsYl95cV9hbXQnOjAuMCwncGxiX2hjX2FtdCc6MC4wfSwnaGlkZGVuX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdlZHVjZXNzX2ZhcmVjb25zJzp7J2ZsdCc6MCwnYmYnOjAsJ3RheCc6MCwneXEnOjAsJ3N0YXgnOjAuMCwnaGMnOjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnfSwnaGlnaGVyZWR1Y2Vzc19mYXJlY29ucyc6eydmbHQnOjAsJ2JmJzowLCd0YXgnOjAsJ3lxJzowLCdzdGF4JzowLjAsJ2Rpcyc6MC4wLCdoYyc6MCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdjdXN0b21lcm1hcmt1cF9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6Jyd9LCdkaXNmZWVfZmFyZWNvbnMnOnsnZmx0JzowLjAsJ2JmJzowLjAsJ3lxJzowLjAsJ3RheCc6MC4wfX0=:0.0:0.0:0.0:0.0:0.0:0.0,0.0:1750.0:0.0:0.0:0.0:0.0:0.0:0.0:1750.0:0.0:1750.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:eydoY19mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6MX0sJ3NlcnZpY2V0YXhfZmFyZWNvbnMnOnsnZmx0JzowLjAsJ2JmJzowLjAsJ3RheCc6MC4wLCd5cSc6MC4wLCd5cic6MC4wLCdkaXMnOjAuMCwnaGMnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMScsJ3N0YXhfYmZfYW10JzowLjAsJ3N0YXhfeXFfYW10JzowLjAsJ3N0YXhfdGZlZV9hbXQnOjAuMCwnc3RheF9kaXNfYW10JzowLjAsJ3N0YXhfaGNfYW10JzowLjB9LCd0ZmVlX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdtZmVlX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdkaXNjb3VudF9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnLCdkaXNjb21tJzonMC4wLTAuMC0wLjAtMC4wJ30sJ3Rkc19mYXJlY29ucyc6eydmbHQnOjAuMCwnZGlzJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnfSwncGxiY3V0bnBheV9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2hjJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnLCdwbGJfYmZfYW10JzowLjAsJ3BsYl90YXhfYW10JzowLjAsJ3BsYl95cV9hbXQnOjAuMCwncGxiX2hjX2FtdCc6MC4wfSwnaGlkZGVuX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdlZHVjZXNzX2ZhcmVjb25zJzp7J2ZsdCc6MCwnYmYnOjAsJ3RheCc6MCwneXEnOjAsJ3N0YXgnOjAuMCwnaGMnOjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnfSwnaGlnaGVyZWR1Y2Vzc19mYXJlY29ucyc6eydmbHQnOjAsJ2JmJzowLCd0YXgnOjAsJ3lxJzowLCdzdGF4JzowLjAsJ2Rpcyc6MC4wLCdoYyc6MCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdjdXN0b21lcm1hcmt1cF9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6Jyd9LCdkaXNmZWVfZmFyZWNvbnMnOnsnZmx0JzowLjAsJ2JmJzowLjAsJ3lxJzowLjAsJ3RheCc6MC4wfX0=:0.0:0.0:0.0:0.0:0.0:0.0***-***-***512.0-1141.0-0.0-0.0-0.0-1750.0***^@^1.0^@^@@@@@@0@0@0@@domestic@b2b@@@@false@@@INR@@false@^@^512.0,1141.0,0.0,0.0,0.0,0.0,0.0,1750.0,0.0$$$$$$QPT,1411,J,DEL,BOM,1040,1500,20250312,20250312,E,N,0,QP,260,260,N,7MB,N,-,T2,T1,112,saas_gatewaytest_GWT06185_AKASAAIRAPI_0_17412387471397873.8793824381155_0@Student Fares***1,0,0,512.0,0.0,0.0,1141.0,0.0,1750.0,0.0,0.0,0.0,STU$PHF$75.0##STU$RCS$50.0##STU$YQ$550.0##STU$TFE$18.0##STU$ASF$236.0##STU$PSF$91.0##STU$UDF$61.0##STU$GST$60.0@@@@,B0O7RBIX-EC-***-***-***-***N$$$$$$159049542912$$$$$$domestic","paxid":"","booking_class":"","flight_number":"","invoicedate":"","bookingparams":[{"txid":"FB0603NDLOHT","paramname":"originalbookingpageparamlist","paramvalue":"","txdate":"2025-03-06 11:53:58.0","sendtogds":"","domint":""}],"travelinsurance":[],"owfaredetails":"                 <OWFareDetails>                     512.0##1141.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##1653.0##0.0##1653.0##0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0                     </OWFareDetails>                         ","rtfaredetails":"                         <RTFareDetails>                             0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0                             </RTFareDetails>                                 ","officeid":"","passengerssrrecords":[],"pricinglogs":[],"webcheckins":[],"rescmap":""}}},"TransactionStatus":"pending","BookingId":"FB0603NDLOHT","Invoicedata":[]}',true);echo json_encode($apiResponse);
										// $apiResponse = json_decode('{"status":true,"message":"Flight Invoice Details Fetched","results":{"ApiStatus":{"Status":"OK","StatusCode":"200","Message":"Flight Invoice Details Fetched","Operation":"getETicket","ResultFormat":"JSON","TransactionStatus":"","Result":{"txid":"","flightRecord":{"txid":"FB30105SGOMJ","origin":"DEL","destination":"IDR","total_amount":8569,"fare_quote_amount":8569,"total_base_tax":8569,"multisupplier":"no","payment_status":"paid","booking_status":"confirmed","payment_mode":"cashcard","bank_id":"NA","bookingdate":"2025-10-30 15:23:31.0","num_sectors":4,"num_adults":1,"num_children":0,"num_infants":0,"num_pax":1,"gds_pnr":"A3M72R","airline_pnr":"A3M72R","fare_breakup":"xxx","booking_type":"online","booking_provider":"SUP96643","bookedbyname":"Catabatic Test","bookedbyroleid":"3","process_status":"pending","erptxid":"-","ispassthrough":"no","passthroughtype":"-","ssramount":0,"issbill":"false","tripnumber":"","iscloned":"false","travelinsurance_txid":"-","approval_status":"pending","approvaltxid":"","projectcode":"-","ticketing_date":"","passthroughjtype":"","passthroughxml":"","passthroughamount":0,"educess":0,"highereducess":0,"corporatecode":"","isaccountingpushed":"","jn":0,"hiddenmarkup":0,"jtype":"RoundTrip","agentid":"GWT06185","passengername":"JKJKJK","passengerlastname":"HJGJG","passengertitle":"MS","passengeremail":"prashant.gupta.11687@gmail.com","passengercontact":"8287473368","passengeraddress":"","domint":"domestic","jdate":"2025-10-31","rdate":"2025-11-01","agent_company":"Catabatic","markup":0,"servicetax":0,"tds":0,"commission":0,"handlingcharges":0,"tfeefq":0,"tfeeinv":0,"basefare":6474,"tax":2095,"yq":0,"channelinfo":"-","bookingchannel":"api","corporatename":"-","travel_status":"pending","cabinclass":"economy","baggageinfo":"NA","splremarks":"-","costcenter":"-","bookedbyid":"GWT06185","issplrt":"false","travelinsurance_included":"false","travelinsurance_amount":"0.00","markup_included":"false","markup_amount":"0","inpolicy":"true","policy_reason":"-","additional_basehc":0,"additional_taxhc":0,"additional_feehc":0,"employeeid":"-","apitxid":"-","apidbname":"","promocode":"-","promocode_used":"false","promovalue":0,"corporate_department":"-","apiremarks":"indigoapi","requestedby":"","carrier":"6E","invoicenumber":"3838","adminremarks":"-","pgcharges":"0.00","additional":"","flightticketnums":"A3M72R","additional_markup":0,"hasssr":"false","hasseatssr":"false","corporate_code":"","phoneIntlCode":"","phoneAreaCode":"","skipadditionalhc":"","endUserIP":"","endUserBrowser":"","ismultiticketnumber":""},"passengerRecords":[{"txid":"FB30105SGOMJ","paxid":"8973","trip_number":"1","title":"Ms","first_name":"jkjkjk","last_name":"hjgjg","dob":"1998-10-15","type":"adult","email":"","contact_number":"","base_fare":3035,"tax":697,"fuel_surcharge":0,"gds_pnr":"-","airline_pnr":"-","flight_ticket_number":"-","fare_breakup":"XXX","status":"confirmed","tour_code":"","deal_code":"","frequent_flyer_number":"","passport":"","visa":"","passport_dateofissue":"","passport_placeofissue":"","passport_dateofexpiry":"","agentid":"GWT06185","meal_preference":"","seat_preference":"","additional_segmentinfo":"-","paxssrinfo":"<list><\/list>","bookingpageparams":"","endorsement_code":"","paxseatinfo":"","paxssrseatinfo":"<list><\/list>","corporate_code":"","seatnumber":"","seattypes":"","idproof":"","cost_center":"","grade":"","department":"","designation":"","namechange_allowed":"","liftstatus":"","isnameupdated":"no","tour_code_status":"pending","deal_code_status":"pending","freqfly_status":"pending","passport_status":"pending","ssr_status":"pending","ssr_error":"-","error_details":"-","seat_status":"pending","meal_status":"pending","seat_error":"-","meal_error":"-","specialssr":"-","commission":0,"tds":0,"servicetax":0,"handlingcharges":0,"tfeeinv":0,"tfeefq":0,"promo_discount":0,"discomm":0,"totalinvoice":0,"totalfarequote":0,"markup":0,"canxtxid":"","resctxid":"","refundamount":0,"profileid":"1","additional_basehc":0,"additional_taxhc":0,"additional_feehc":0,"additional_rtbasehc":0,"additional_rttaxhc":0,"additional_rtfeehc":0,"beneficiaryname":"","paxtypechange_allowed":"","osiremarks":"","ssrs":[]},{"txid":"FB30105SGOMJ","paxid":"8974","trip_number":"2","title":"Ms","first_name":"jkjkjk","last_name":"hjgjg","dob":"1998-10-15","type":"adult","email":"","contact_number":"","base_fare":3439,"tax":1398,"fuel_surcharge":0,"gds_pnr":"-","airline_pnr":"-","flight_ticket_number":"-","fare_breakup":"XXX","status":"confirmed","tour_code":"","deal_code":"","frequent_flyer_number":"","passport":"","visa":"","passport_dateofissue":"","passport_placeofissue":"","passport_dateofexpiry":"","agentid":"GWT06185","meal_preference":"","seat_preference":"","additional_segmentinfo":"-","paxssrinfo":"<list><\/list>","bookingpageparams":"","endorsement_code":"","paxseatinfo":"","paxssrseatinfo":"<list><\/list>","corporate_code":"","seatnumber":"","seattypes":"","idproof":"","cost_center":"","grade":"","department":"","designation":"","namechange_allowed":"","liftstatus":"","isnameupdated":"no","tour_code_status":"pending","deal_code_status":"pending","freqfly_status":"pending","passport_status":"pending","ssr_status":"pending","ssr_error":"-","error_details":"-","seat_status":"pending","meal_status":"pending","seat_error":"-","meal_error":"-","specialssr":"-","commission":0,"tds":0,"servicetax":0,"handlingcharges":0,"tfeeinv":0,"tfeefq":0,"promo_discount":0,"discomm":0,"totalinvoice":0,"totalfarequote":0,"markup":0,"canxtxid":"","resctxid":"","refundamount":0,"profileid":"1","additional_basehc":0,"additional_taxhc":0,"additional_feehc":0,"additional_rtbasehc":0,"additional_rttaxhc":0,"additional_rtfeehc":0,"beneficiaryname":"","paxtypechange_allowed":"","osiremarks":"","ssrs":[]}],"passengerFareCollection":[{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"1","amount":3035},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"2","amount":697},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"3","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"4","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"5","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"6","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"7","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"8","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"9","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"10","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"11","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"12","amount":3732},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"13","amount":3732},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"14","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"15","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"18","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"19","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"21","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"41","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"42","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"50","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"51","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"52","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"60","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"64","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"70","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"71","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"72","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"73","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"81","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"82","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"83","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"84","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"85","amount":0},{"txid":"FB30105SGOMJ","paxid":"8973","paxtype":"Adult","fare_componentid":"86","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"1","amount":3439},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"2","amount":1398},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"3","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"4","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"5","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"6","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"7","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"8","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"9","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"10","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"11","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"12","amount":4837},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"13","amount":4837},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"14","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"15","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"18","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"19","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"21","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"41","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"42","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"50","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"51","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"52","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"60","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"64","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"70","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"71","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"72","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"73","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"81","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"82","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"83","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"84","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"85","amount":0},{"txid":"FB30105SGOMJ","paxid":"8974","paxtype":"Adult","fare_componentid":"86","amount":0}],"sectorRecords":[{"txid":"FB30105SGOMJ","origin":"DEL","destination":"JAI","sector_number":"0","jdate":"2025-10-31","departure_time":"445","arrival_time":"540","arrdate":"20251031","booking_class":"R","fare_basis":"R0IP","carrier":"6E","flight_number":"5037","flight_type":"Onward","insert_time":"2025-10-30 15:23:31.0","stop_over":"","airline_pnr":"A3M72R","baggageinfo":"15Kg,NA,-","flight_model":"NA","refundable":false,"refundable_info":"-","airport_terminal":"3,2","agentid":"GWT06185","sector_duration":"55","journey_duration":"505","origin_fullname":"Delhi","destination_fullname":"Jaipur","tripnumber":"1","Supplier_id":"","trip_number":"","meal":"","seat":"","baggage":"","specialssr":"","origin_airportfullname":"Indira Gandhi Intl(New Delhi, India)","destination_airportfullname":"Sanganeer(Jaipur, India)","equipment":"323-321","base_fare":3035,"tax":697,"total_amount":3732,"faretype":"","carrier_name":"","gds_pnr":"A3M72R","supplier":"indigoapi","supplier_officeid":"OTI285","supplier_bookingreference":"A3M72R","sector_barcode":"","sector_ticketnumber":"","paxid":"","arrival_terminal":"","depart_terminal":"","operatedby":"Indigo"},{"txid":"FB30105SGOMJ","origin":"JAI","destination":"IDR","sector_number":"1","jdate":"2025-10-31","departure_time":"1145","arrival_time":"1310","arrdate":"20251031","booking_class":"R","fare_basis":"R0IP","carrier":"6E","flight_number":"7154","flight_type":"Onward","insert_time":"2025-10-30 15:23:31.0","stop_over":"","airline_pnr":"A3M72R","baggageinfo":"15Kg,NA,-","flight_model":"NA","refundable":false,"refundable_info":"-","airport_terminal":"2,NA","agentid":"GWT06185","sector_duration":"85","journey_duration":"505","origin_fullname":"Jaipur","destination_fullname":"Indore","tripnumber":"1","Supplier_id":"","trip_number":"","meal":"","seat":"","baggage":"","specialssr":"","origin_airportfullname":"Sanganeer(Jaipur, India)","destination_airportfullname":"Indore(Indore, India)","equipment":"ATR-ATR","base_fare":3035,"tax":697,"total_amount":3732,"faretype":"","carrier_name":"","gds_pnr":"A3M72R","supplier":"indigoapi","supplier_officeid":"OTI285","supplier_bookingreference":"A3M72R","sector_barcode":"","sector_ticketnumber":"","paxid":"","arrival_terminal":"","depart_terminal":"","operatedby":"Indigo"},{"txid":"FB30105SGOMJ","origin":"IDR","destination":"JAI","sector_number":"0","jdate":"2025-11-01","departure_time":"635","arrival_time":"805","arrdate":"20251101","booking_class":"R","fare_basis":"R0IP","carrier":"6E","flight_number":"7274","flight_type":"Return","insert_time":"2025-10-30 15:23:31.0","stop_over":"","airline_pnr":"A3M72R","baggageinfo":"15Kg,NA,-","flight_model":"NA","refundable":false,"refundable_info":"-","airport_terminal":"NA,2","agentid":"GWT06185","sector_duration":"90","journey_duration":"355","origin_fullname":"Indore","destination_fullname":"Jaipur","tripnumber":"2","Supplier_id":"","trip_number":"","meal":"","seat":"","baggage":"","specialssr":"","origin_airportfullname":"Indore(Indore, India)","destination_airportfullname":"Sanganeer(Jaipur, India)","equipment":"ATR-ATR","base_fare":3439,"tax":1398,"total_amount":4837,"faretype":"","carrier_name":"","gds_pnr":"A3M72R","supplier":"indigoapi","supplier_officeid":"OTI285","supplier_bookingreference":"A3M72R","sector_barcode":"","sector_ticketnumber":"","paxid":"","arrival_terminal":"","depart_terminal":"","operatedby":"Indigo"},{"txid":"FB30105SGOMJ","origin":"JAI","destination":"DEL","sector_number":"1","jdate":"2025-11-01","departure_time":"1135","arrival_time":"1230","arrdate":"20251101","booking_class":"R","fare_basis":"R0IP","carrier":"6E","flight_number":"130","flight_type":"Return","insert_time":"2025-10-30 15:23:31.0","stop_over":"","airline_pnr":"A3M72R","baggageinfo":"15Kg,NA,-","flight_model":"NA","refundable":false,"refundable_info":"-","airport_terminal":"2,1","agentid":"GWT06185","sector_duration":"55","journey_duration":"355","origin_fullname":"Jaipur","destination_fullname":"Delhi","tripnumber":"2","Supplier_id":"","trip_number":"","meal":"","seat":"","baggage":"","specialssr":"","origin_airportfullname":"Sanganeer(Jaipur, India)","destination_airportfullname":"Indira Gandhi Intl(New Delhi, India)","equipment":"323-321","base_fare":3439,"tax":1398,"total_amount":4837,"faretype":"","carrier_name":"","gds_pnr":"A3M72R","supplier":"indigoapi","supplier_officeid":"OTI285","supplier_bookingreference":"A3M72R","sector_barcode":"","sector_ticketnumber":"","paxid":"","arrival_terminal":"","depart_terminal":"","operatedby":"Indigo"}],"flightTickets":[{"txid":"FB30105SGOMJ","paxid":"8973","sector_number":"1","trip_number":"1","ticket_number":"A3M72R","airline_pnr":"A3M72R","ffnnumber":""},{"txid":"FB30105SGOMJ","paxid":"8973","sector_number":"2","trip_number":"1","ticket_number":"A3M72R","airline_pnr":"A3M72R","ffnnumber":""},{"txid":"FB30105SGOMJ","paxid":"8974","sector_number":"1","trip_number":"2","ticket_number":"A3M72R","airline_pnr":"A3M72R","ffnnumber":""},{"txid":"FB30105SGOMJ","paxid":"8974","sector_number":"2","trip_number":"2","ticket_number":"A3M72R","airline_pnr":"A3M72R","ffnnumber":""}],"flightCommissionCollection":[{"txid":"FB30105SGOMJ","agentid":"GWT06185","type":"FlightsDomestic","carrier":"All","fare_componentid":"4","unit":"percent","value":"0.000","fare_componentid_computed":"1","sign":"+"},{"txid":"FB30105SGOMJ","agentid":"GWT06185","type":"FlightsDomestic","carrier":"All","fare_componentid":"5","unit":"percent","value":"0.000","fare_componentid_computed":"3","sign":"+"},{"txid":"FB30105SGOMJ","agentid":"GWT06185","type":"FlightsDomestic","carrier":"All","fare_componentid":"15","unit":"flat","value":"0.000","fare_componentid_computed":"12","sign":"+"},{"txid":"FB30105SGOMJ","agentid":"GWT06185","type":"FlightsDomestic","carrier":"All","fare_componentid":"3","unit":"percent","value":"0.000","fare_componentid_computed":"1","sign":"+"},{"txid":"FB30105SGOMJ","agentid":"UT12461","type":"FlightsDomestic","carrier":"All","fare_componentid":"4","unit":"percent","value":"0.000","fare_componentid_computed":"1","sign":"+"},{"txid":"FB30105SGOMJ","agentid":"UT12461","type":"FlightsDomestic","carrier":"All","fare_componentid":"5","unit":"percent","value":"0.000","fare_componentid_computed":"3","sign":"+"},{"txid":"FB30105SGOMJ","agentid":"UT12461","type":"FlightsDomestic","carrier":"All","fare_componentid":"15","unit":"flat","value":"0.000","fare_componentid_computed":"12","sign":"+"},{"txid":"FB30105SGOMJ","agentid":"UT12461","type":"FlightsDomestic","carrier":"All","fare_componentid":"3","unit":"percent","value":"0.000","fare_componentid_computed":"1","sign":"+"}],"supplierinfo":"","userinfo":"","additional_markup":0,"accountingXml":"","taxbreakupxml":"","supplierapiname":"","narration1":"","narration2":"","narration3":"","bookingstrlog":"6E,5037,R,DEL,JAI,0445,0540,20251031,20251031,E,N,0,,0,0,N,323-321,N,-,3,2,35,saas_gatewaytest_INDIGOAPI_GWT06185_1761817491336_0_40_6639.051999769616:6E,7154,R,JAI,IDR,1145,1310,20251031,20251031,E,N,0,,0,0,N,ATR-ATR,N,-,2,-,35,saas_gatewaytest_INDIGOAPI_GWT06185_1761817491336_0_40_6639.051999769616***1,0,0,3035,0,0,697,0,0,0,0,0,ADT$FarePrice-$900.0000##ADT$TravelFee-PHF$50##ADT$TravelFee-RCF$50##ADT$TravelFee-RCF$50##ADT$TravelFee-ASF$236##ADT$TravelFee-UDF$152##ADT$Tax-07GST$159,R0IP,INDIGOTAX_GWT06185_1761817623667_0_1611.5852884868941,159.0,0.0,0.0***3035.0:697.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:3732.0:0.0:3732.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0***R0IP***N***3035.0:697.0:0.0:0.0:0.0:0.0:0.0:0.0:3732.0:0.0:3732.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:eydoY19mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6MX0sJ3NlcnZpY2V0YXhfZmFyZWNvbnMnOnsnZmx0JzowLjAsJ2JmJzowLjAsJ3RheCc6MC4wLCd5cSc6MC4wLCd5cic6MC4wLCdkaXMnOjAuMCwnaGMnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMScsJ3N0YXhfYmZfYW10JzowLjAsJ3N0YXhfeXFfYW10JzowLjAsJ3N0YXhfdGZlZV9hbXQnOjAuMCwnc3RheF9kaXNfYW10JzowLjAsJ3N0YXhfaGNfYW10JzowLjB9LCd0ZmVlX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdtZmVlX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdkaXNjb3VudF9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnLCdkaXNjb21tJzonMC4wLTAuMC0wLjAtMC4wJ30sJ3Rkc19mYXJlY29ucyc6eydmbHQnOjAuMCwnZGlzJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnfSwncGxiY3V0bnBheV9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2hjJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnLCdwbGJfYmZfYW10JzowLjAsJ3BsYl90YXhfYW10JzowLjAsJ3BsYl95cV9hbXQnOjAuMCwncGxiX2hjX2FtdCc6MC4wfSwnaGlkZGVuX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdlZHVjZXNzX2ZhcmVjb25zJzp7J2ZsdCc6MCwnYmYnOjAsJ3RheCc6MCwneXEnOjAsJ3N0YXgnOjAuMCwnaGMnOjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnfSwnaGlnaGVyZWR1Y2Vzc19mYXJlY29ucyc6eydmbHQnOjAsJ2JmJzowLCd0YXgnOjAsJ3lxJzowLCdzdGF4JzowLjAsJ2Rpcyc6MC4wLCdoYyc6MCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdjdXN0b21lcm1hcmt1cF9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6Jyd9LCdkaXNmZWVfZmFyZWNvbnMnOnsnZmx0JzowLjAsJ2JmJzowLjAsJ3lxJzowLjAsJ3RheCc6MC4wfX0=:0.0:0.0:0.0:0.0:0.0:0.0,0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:eydoY19mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6MX0sJ3NlcnZpY2V0YXhfZmFyZWNvbnMnOnsnZmx0JzowLjAsJ2JmJzowLjAsJ3RheCc6MC4wLCd5cSc6MC4wLCd5cic6MC4wLCdkaXMnOjAuMCwnaGMnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMScsJ3N0YXhfYmZfYW10JzowLjAsJ3N0YXhfeXFfYW10JzowLjAsJ3N0YXhfdGZlZV9hbXQnOjAuMCwnc3RheF9kaXNfYW10JzowLjAsJ3N0YXhfaGNfYW10JzowLjB9LCd0ZmVlX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdtZmVlX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdkaXNjb3VudF9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnLCdkaXNjb21tJzonMC4wLTAuMC0wLjAtMC4wJ30sJ3Rkc19mYXJlY29ucyc6eydmbHQnOjAuMCwnZGlzJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnfSwncGxiY3V0bnBheV9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2hjJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnLCdwbGJfYmZfYW10JzowLjAsJ3BsYl90YXhfYW10JzowLjAsJ3BsYl95cV9hbXQnOjAuMCwncGxiX2hjX2FtdCc6MC4wfSwnaGlkZGVuX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdlZHVjZXNzX2ZhcmVjb25zJzp7J2ZsdCc6MCwnYmYnOjAsJ3RheCc6MCwneXEnOjAsJ3N0YXgnOjAuMCwnaGMnOjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnfSwnaGlnaGVyZWR1Y2Vzc19mYXJlY29ucyc6eydmbHQnOjAsJ2JmJzowLCd0YXgnOjAsJ3lxJzowLCdzdGF4JzowLjAsJ2Rpcyc6MC4wLCdoYyc6MCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdjdXN0b21lcm1hcmt1cF9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6Jyd9LCdkaXNmZWVfZmFyZWNvbnMnOnsnZmx0JzowLjAsJ2JmJzowLjAsJ3lxJzowLjAsJ3RheCc6MC4wfX0=:0.0:0.0:0.0:0.0:0.0:0.0,0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:eydoY19mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6MX0sJ3NlcnZpY2V0YXhfZmFyZWNvbnMnOnsnZmx0JzowLjAsJ2JmJzowLjAsJ3RheCc6MC4wLCd5cSc6MC4wLCd5cic6MC4wLCdkaXMnOjAuMCwnaGMnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMScsJ3N0YXhfYmZfYW10JzowLjAsJ3N0YXhfeXFfYW10JzowLjAsJ3N0YXhfdGZlZV9hbXQnOjAuMCwnc3RheF9kaXNfYW10JzowLjAsJ3N0YXhfaGNfYW10JzowLjB9LCd0ZmVlX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdtZmVlX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdkaXNjb3VudF9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnLCdkaXNjb21tJzonMC4wLTAuMC0wLjAtMC4wJ30sJ3Rkc19mYXJlY29ucyc6eydmbHQnOjAuMCwnZGlzJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnfSwncGxiY3V0bnBheV9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2hjJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnLCdwbGJfYmZfYW10JzowLjAsJ3BsYl90YXhfYW10JzowLjAsJ3BsYl95cV9hbXQnOjAuMCwncGxiX2hjX2FtdCc6MC4wfSwnaGlkZGVuX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdlZHVjZXNzX2ZhcmVjb25zJzp7J2ZsdCc6MCwnYmYnOjAsJ3RheCc6MCwneXEnOjAsJ3N0YXgnOjAuMCwnaGMnOjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnfSwnaGlnaGVyZWR1Y2Vzc19mYXJlY29ucyc6eydmbHQnOjAsJ2JmJzowLCd0YXgnOjAsJ3lxJzowLCdzdGF4JzowLjAsJ2Rpcyc6MC4wLCdoYyc6MCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdjdXN0b21lcm1hcmt1cF9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6Jyd9LCdkaXNmZWVfZmFyZWNvbnMnOnsnZmx0JzowLjAsJ2JmJzowLjAsJ3lxJzowLjAsJ3RheCc6MC4wfX0=:0.0:0.0:0.0:0.0:0.0:0.0***R0IP***R0IP***3035.0-697.0-0.0-0.0-0.0-0.0***^@^1.0^@^@@@@@@0@0@0@@domestic@b2b@@@@false@@@INR@@false@^@^3035.0,697.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0######6E,7274,R,IDR,JAI,0635,0805,20251101,20251101,E,N,0,,0,0,N,ATR-ATR,N,-,-,2,1,saas_gatewaytest_INDIGOAPI_GWT06185_1761817491341_0_41_2374.6152340184467:6E,130,R,JAI,DEL,1135,1230,20251101,20251101,E,N,0,,0,0,N,323-321,N,-,2,1,1,saas_gatewaytest_INDIGOAPI_GWT06185_1761817491341_0_41_2374.6152340184467***1,0,0,3439,0,0,1398,0,0,0,0,0,ADT$FarePrice-$2539.0000##ADT$TravelFee-PHF$50##ADT$TravelFee-RCF$50##ADT$TravelFee-RCF$50##ADT$TravelFee-ASF$236##ADT$TravelFee-UDF$767##ADT$TravelFee-UDFA$66##ADT$Tax-23GST$179,R0IP,INDIGOTAX_GWT06185_1761817623667_1_8468.264851879012,179.0,0.0,0.0***3439.0:1398.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:4837.0:0.0:4837.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0***R0IP***N***3439.0:1398.0:0.0:0.0:0.0:0.0:0.0:0.0:4837.0:0.0:4837.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:eydoY19mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6MX0sJ3NlcnZpY2V0YXhfZmFyZWNvbnMnOnsnZmx0JzowLjAsJ2JmJzowLjAsJ3RheCc6MC4wLCd5cSc6MC4wLCd5cic6MC4wLCdkaXMnOjAuMCwnaGMnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMScsJ3N0YXhfYmZfYW10JzowLjAsJ3N0YXhfeXFfYW10JzowLjAsJ3N0YXhfdGZlZV9hbXQnOjAuMCwnc3RheF9kaXNfYW10JzowLjAsJ3N0YXhfaGNfYW10JzowLjB9LCd0ZmVlX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdtZmVlX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdkaXNjb3VudF9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnLCdkaXNjb21tJzonMC4wLTAuMC0wLjAtMC4wJ30sJ3Rkc19mYXJlY29ucyc6eydmbHQnOjAuMCwnZGlzJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnfSwncGxiY3V0bnBheV9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2hjJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnLCdwbGJfYmZfYW10JzowLjAsJ3BsYl90YXhfYW10JzowLjAsJ3BsYl95cV9hbXQnOjAuMCwncGxiX2hjX2FtdCc6MC4wfSwnaGlkZGVuX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdlZHVjZXNzX2ZhcmVjb25zJzp7J2ZsdCc6MCwnYmYnOjAsJ3RheCc6MCwneXEnOjAsJ3N0YXgnOjAuMCwnaGMnOjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnfSwnaGlnaGVyZWR1Y2Vzc19mYXJlY29ucyc6eydmbHQnOjAsJ2JmJzowLCd0YXgnOjAsJ3lxJzowLCdzdGF4JzowLjAsJ2Rpcyc6MC4wLCdoYyc6MCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdjdXN0b21lcm1hcmt1cF9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6Jyd9LCdkaXNmZWVfZmFyZWNvbnMnOnsnZmx0JzowLjAsJ2JmJzowLjAsJ3lxJzowLjAsJ3RheCc6MC4wfX0=:0.0:0.0:0.0:0.0:0.0:0.0,0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:eydoY19mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6MX0sJ3NlcnZpY2V0YXhfZmFyZWNvbnMnOnsnZmx0JzowLjAsJ2JmJzowLjAsJ3RheCc6MC4wLCd5cSc6MC4wLCd5cic6MC4wLCdkaXMnOjAuMCwnaGMnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMScsJ3N0YXhfYmZfYW10JzowLjAsJ3N0YXhfeXFfYW10JzowLjAsJ3N0YXhfdGZlZV9hbXQnOjAuMCwnc3RheF9kaXNfYW10JzowLjAsJ3N0YXhfaGNfYW10JzowLjB9LCd0ZmVlX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdtZmVlX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdkaXNjb3VudF9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnLCdkaXNjb21tJzonMC4wLTAuMC0wLjAtMC4wJ30sJ3Rkc19mYXJlY29ucyc6eydmbHQnOjAuMCwnZGlzJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnfSwncGxiY3V0bnBheV9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2hjJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnLCdwbGJfYmZfYW10JzowLjAsJ3BsYl90YXhfYW10JzowLjAsJ3BsYl95cV9hbXQnOjAuMCwncGxiX2hjX2FtdCc6MC4wfSwnaGlkZGVuX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdlZHVjZXNzX2ZhcmVjb25zJzp7J2ZsdCc6MCwnYmYnOjAsJ3RheCc6MCwneXEnOjAsJ3N0YXgnOjAuMCwnaGMnOjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnfSwnaGlnaGVyZWR1Y2Vzc19mYXJlY29ucyc6eydmbHQnOjAsJ2JmJzowLCd0YXgnOjAsJ3lxJzowLCdzdGF4JzowLjAsJ2Rpcyc6MC4wLCdoYyc6MCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdjdXN0b21lcm1hcmt1cF9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6Jyd9LCdkaXNmZWVfZmFyZWNvbnMnOnsnZmx0JzowLjAsJ2JmJzowLjAsJ3lxJzowLjAsJ3RheCc6MC4wfX0=:0.0:0.0:0.0:0.0:0.0:0.0,0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:eydoY19mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6MX0sJ3NlcnZpY2V0YXhfZmFyZWNvbnMnOnsnZmx0JzowLjAsJ2JmJzowLjAsJ3RheCc6MC4wLCd5cSc6MC4wLCd5cic6MC4wLCdkaXMnOjAuMCwnaGMnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMScsJ3N0YXhfYmZfYW10JzowLjAsJ3N0YXhfeXFfYW10JzowLjAsJ3N0YXhfdGZlZV9hbXQnOjAuMCwnc3RheF9kaXNfYW10JzowLjAsJ3N0YXhfaGNfYW10JzowLjB9LCd0ZmVlX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdtZmVlX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdkaXNjb3VudF9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnLCdkaXNjb21tJzonMC4wLTAuMC0wLjAtMC4wJ30sJ3Rkc19mYXJlY29ucyc6eydmbHQnOjAuMCwnZGlzJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnfSwncGxiY3V0bnBheV9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2hjJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnLCdwbGJfYmZfYW10JzowLjAsJ3BsYl90YXhfYW10JzowLjAsJ3BsYl95cV9hbXQnOjAuMCwncGxiX2hjX2FtdCc6MC4wfSwnaGlkZGVuX2ZhcmVjb25zJzp7J2ZsdCc6MC4wLCdiZic6MC4wLCd0YXgnOjAuMCwneXEnOjAuMCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdlZHVjZXNzX2ZhcmVjb25zJzp7J2ZsdCc6MCwnYmYnOjAsJ3RheCc6MCwneXEnOjAsJ3N0YXgnOjAuMCwnaGMnOjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6JzEnfSwnaGlnaGVyZWR1Y2Vzc19mYXJlY29ucyc6eydmbHQnOjAsJ2JmJzowLCd0YXgnOjAsJ3lxJzowLCdzdGF4JzowLjAsJ2Rpcyc6MC4wLCdoYyc6MCwnaXNtYXN0ZXInOidmYWxzZScsJ21hc3RlcmlkJzonMSd9LCdjdXN0b21lcm1hcmt1cF9mYXJlY29ucyc6eydmbHQnOjAuMCwnYmYnOjAuMCwndGF4JzowLjAsJ3lxJzowLjAsJ2lzbWFzdGVyJzonZmFsc2UnLCdtYXN0ZXJpZCc6Jyd9LCdkaXNmZWVfZmFyZWNvbnMnOnsnZmx0JzowLjAsJ2JmJzowLjAsJ3lxJzowLjAsJ3RheCc6MC4wfX0=:0.0:0.0:0.0:0.0:0.0:0.0***R0IP***R0IP***3439.0-1398.0-0.0-0.0-0.0-0.0***^@^1.0^@^@@@@@@0@0@0@@domestic@b2b@@@@false@@@INR@@false@^@^3439.0,1398.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0$$$$$$6E,5037,R,DEL,JAI,0445,0540,20251031,20251031,E,N,0,,0,0,N,323-321,N,-,3,2,35,saas_gatewaytest_INDIGOAPI_GWT06185_1761817491336_0_40_6639.051999769616:6E,7154,R,JAI,IDR,1145,1310,20251031,20251031,E,N,0,,0,0,N,ATR-ATR,N,-,2,-,35,saas_gatewaytest_INDIGOAPI_GWT06185_1761817491336_0_40_6639.051999769616***1,0,0,3035,0,0,697,0,0,0,0,0,ADT$FarePrice-$900.0000##ADT$TravelFee-PHF$50##ADT$TravelFee-RCF$50##ADT$TravelFee-RCF$50##ADT$TravelFee-ASF$236##ADT$TravelFee-UDF$152##ADT$Tax-07GST$159,R0IP,INDIGOTAX_GWT06185_1761817623667_0_1611.5852884868941,159.0,0.0,0.0***NA***R0IP***NA***N###6E,7274,R,IDR,JAI,0635,0805,20251101,20251101,E,N,0,,0,0,N,ATR-ATR,N,-,-,2,1,saas_gatewaytest_INDIGOAPI_GWT06185_1761817491341_0_41_2374.6152340184467:6E,130,R,JAI,DEL,1135,1230,20251101,20251101,E,N,0,,0,0,N,323-321,N,-,2,1,1,saas_gatewaytest_INDIGOAPI_GWT06185_1761817491341_0_41_2374.6152340184467***1,0,0,3439,0,0,1398,0,0,0,0,0,ADT$FarePrice-$2539.0000##ADT$TravelFee-PHF$50##ADT$TravelFee-RCF$50##ADT$TravelFee-RCF$50##ADT$TravelFee-ASF$236##ADT$TravelFee-UDF$767##ADT$TravelFee-UDFA$66##ADT$Tax-23GST$179,R0IP,INDIGOTAX_GWT06185_1761817623667_1_8468.264851879012,179.0,0.0,0.0***NA***R0IP***NA***N$$$$$$335983174176$$$$$$domestic","paxid":"","booking_class":"","flight_number":"","invoicedate":"","bookingparams":[{"txid":"FB30105SGOMJ","paramname":"originalbookingpageparamlist","paramvalue":"","txdate":"2025-10-30 15:23:31.0","sendtogds":"","domint":""}],"travelinsurance":[],"owfaredetails":"<OWFareDetails>3035.0##697.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##3732.0##0.0##3732.0##0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0<\/OWFareDetails>","rtfaredetails":"<RTFareDetails>3439.0##1398.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##4837.0##0.0##4837.0##0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0##0.0<\/RTFareDetails>","officeid":"dwD\/dA\/bFryff8YS65uIrA==","passengerssrrecords":[],"pricinglogs":[{"txid":"FB30105SGOMJ","pricingtype":"generic","apiname":"indigo","requestxml":"custom","responsexml":"<FullBreakup><AdultBase>3539.0<\/AdultBase><AdultTax>1995.0<\/AdultTax><AdultYq>0.0<\/AdultYq><AdultJn>338.0<\/AdultJn><AdultBreakup><TaxNode><Jtype>onward<\/Jtype><PaxType>ADT<\/PaxType><TaxName><\/TaxName><TaxValue>900.0000<\/TaxValue><\/TaxNode><TaxNode><Jtype>onward<\/Jtype><PaxType>ADT<\/PaxType><TaxName>PHF<\/TaxName><TaxValue>50<\/TaxValue><\/TaxNode><TaxNode><Jtype>onward<\/Jtype><PaxType>ADT<\/PaxType><TaxName>RCF<\/TaxName><TaxValue>50<\/TaxValue><\/TaxNode><TaxNode><Jtype>onward<\/Jtype><PaxType>ADT<\/PaxType><TaxName>RCF<\/TaxName><TaxValue>50<\/TaxValue><\/TaxNode><TaxNode><Jtype>onward<\/Jtype><PaxType>ADT<\/PaxType><TaxName>ASF<\/TaxName><TaxValue>236<\/TaxValue><\/TaxNode><TaxNode><Jtype>onward<\/Jtype><PaxType>ADT<\/PaxType><TaxName>UDF<\/TaxName><TaxValue>152<\/TaxValue><\/TaxNode><TaxNode><Jtype>onward<\/Jtype><PaxType>ADT<\/PaxType><TaxName>07GST<\/TaxName><TaxValue>159<\/TaxValue><\/TaxNode><TaxNode><Jtype>return<\/Jtype><PaxType>ADT<\/PaxType><TaxName><\/TaxName><TaxValue>2539.0000<\/TaxValue><\/TaxNode><TaxNode><Jtype>return<\/Jtype><PaxType>ADT<\/PaxType><TaxName>PHF<\/TaxName><TaxValue>50<\/TaxValue><\/TaxNode><TaxNode><Jtype>return<\/Jtype><PaxType>ADT<\/PaxType><TaxName>RCF<\/TaxName><TaxValue>50<\/TaxValue><\/TaxNode><TaxNode><Jtype>return<\/Jtype><PaxType>ADT<\/PaxType><TaxName>RCF<\/TaxName><TaxValue>50<\/TaxValue><\/TaxNode><TaxNode><Jtype>return<\/Jtype><PaxType>ADT<\/PaxType><TaxName>ASF<\/TaxName><TaxValue>236<\/TaxValue><\/TaxNode><TaxNode><Jtype>return<\/Jtype><PaxType>ADT<\/PaxType><TaxName>UDF<\/TaxName><TaxValue>767<\/TaxValue><\/TaxNode><TaxNode><Jtype>return<\/Jtype><PaxType>ADT<\/PaxType><TaxName>UDFA<\/TaxName><TaxValue>66<\/TaxValue><\/TaxNode><TaxNode><Jtype>return<\/Jtype><PaxType>ADT<\/PaxType><TaxName>23GST<\/TaxName><TaxValue>179<\/TaxValue><\/TaxNode><\/AdultBreakup><ChildBase>0.0<\/ChildBase><ChildTax>0.0<\/ChildTax><ChildYq>0.0<\/ChildYq><ChildJn>0.0<\/ChildJn><ChildBreakup><\/ChildBreakup><InfantBase>0.0<\/InfantBase><InfantTax>1250.0<\/InfantTax><InfantYq>0.0<\/InfantYq><InfantJn>0.0<\/InfantJn><InfantBreakup><\/InfantBreakup><Sector>all<\/Sector><\/FullBreakup>","inserttime":"2025-10-30 15:23:31.0"}],"webcheckins":[],"farerules":{"txid":"FB30105SGOMJ","carrier1":"6E","carrier2":"-","owrules":"<AllFareRules><Rule><![CDATA[<table border=\"1\" cellspacing=\"0\" cellpadding=\"8\" style=\"font-family: arial;font-size: 13px;width:100%\"><tbody><tr><th style=\"text-align: left;\">Fare Description<\/th><td>Best deal from our Regular, Return, Family and Online Group fares (depending on travel conditions).<\/td><\/tr><tr><th style=\"text-align: left;\">6E Tiffin(Snacks\/Meal)<\/th><td>Chargeable<\/td><\/tr><tr><th style=\"text-align: left;\">Standard seat<\/th><td>Chargeable<\/td><\/tr><tr><th style=\"text-align: left;\">Date Changes Fee Per Passenger Per Sector<\/th><td>Up to INR 3250<\/td><\/tr><tr><th style=\"text-align: left;\">Cancellation Charge Per Passenger Per Sector<\/th><td>Up to INR 3500<\/td><\/tr><tr><th style=\"text-align: left;\">XL seat<\/th><td>No discount<\/td><\/tr><tr><th style=\"text-align: left;\">Check-in Baggage<\/th><td>15KG<\/td><\/tr><tr><th style=\"text-align: left;\">Hand Baggage<\/th><td>One hand bag up to 7 kgs and 115 cms (L+W+H), shall be allowed per customer.<\/td><\/tr><tr><td colspan=\"2\" style=\"background:#d9e1f2\">Change & Cancellation are allowed before 3 Hrs of travelling in all Domestic flights<\/td><\/tr><\/tbody><\/table>]]><\/Rule><\/AllFareRules>","twrules":"-","inserttime":"2025-10-30 15:23:33.0"},"rescmap":""}}}}',true);
										// echo "<pre>";print_r($apiResponse);die("apiResponse");
										$ResponseStatus = isset($apiResponse['status']) ? $apiResponse['status'] : false;
										$TransactionStatus = isset($apiResponse['TransactionStatus']) ? $apiResponse['TransactionStatus'] : '';
										$BookingId = isset($apiResponse['BookingId']) ? $apiResponse['BookingId'] : '';
										if($ResponseStatus == 1){
											$Bookres = [
												'status' => array('success' => true,'apiResponse'=>$apiResponse,'BookingId'=>$BookingId, 'TransactionStatus'=>$TransactionStatus,'SearchTraceId' => $arrUrlData['SearchTraceId']),
											];
										}else{
											$Bookres = [
												'status' => array('success' => false,'SearchTraceId' => $arrUrlData['SearchTraceId']),
											];
										}
									} elseif ($ICSourceSysId == 16) {
										$isAdobrMandatory = isset($BookingData[0]['isAdobrMandatory'])?$BookingData[0]['isAdobrMandatory']:false;
										$isCdobrMandatory = isset($BookingData[0]['isCdobrMandatory'])?$BookingData[0]['isCdobrMandatory']:false;
										$isIdobrMandatory = isset($BookingData[0]['isIdobrMandatory'])?$BookingData[0]['isIdobrMandatory']:false;

										$ApiResultIndex = isset($BookingData[0]['ApiResultIndex']) ? $BookingData[0]['ApiResultIndex'] : '';
										if($route == 2 && $interNationalSearch){
											$SourceAirportCode = trim($sessionFlightSearchParams->params['sourceCityAirportCode']);
											$DestAirportCode = trim($sessionFlightSearchParams->params['destinationCityAirportCode']);
										}
										$ARR_SALUTION = unserialize(ARR_SALUTION);
										$ARR_SALUTION_CHILD = unserialize(ARR_SALUTION_CHILD);
										$PaxData = [];
										
										if($CustomerSession->params){
											foreach($CustomerSession->params as $pk=>$val){
												$DOB = date('d/m/Y',strtotime($val['DOB']));
												if($val['paxType'] == 1){
													$PaxType = 'ADT';
													$InfantRef = false;
													$paxTitle = ($ARR_SALUTION[$val['Salutation']]);
													// $paxTitle = ($paxTitle == 'Ms')?'Miss':$paxTitle;
												}elseif($val['paxType'] == 2){
													$PaxType = 'CHD';
													$InfantRef = false;
													$paxTitle = ($ARR_SALUTION_CHILD[$val['Salutation']]);
													$paxTitle = ($paxTitle == 'Ms')?'Miss':$paxTitle;
													$paxTitle = ($paxTitle == 'Master')?'Mstr':$paxTitle;
												}else{
													$PaxType = 'INF';
													$InfantRef = 1;
													$paxTitle = ($ARR_SALUTION_CHILD[$val['Salutation']]);
													$paxTitle = ($paxTitle == 'Ms')?'Miss':$paxTitle;
													$paxTitle = ($paxTitle == 'Master')?'Mstr':$paxTitle;
												}
												$SalutationTitle = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getSalutationByid(null,$paxTitle);
												$intGender = $SalutationTitle['Gender'];
												$PaxData[$pk] = array(
													"PaxRefNumber"=>(string)($pk+1),
													"Title"=>$paxTitle,
													"FirstName"=> $val['FirstName'],
													"LastName"=>$val['LastName'],
													//"DOB"=>$DOB,
													"Gender"=>$intGender,
													"PaxType"=>$PaxType,
													"PassportCountryCode"=>($IsPassMandatory)?$val['PassportNation']:"",
													"PassportNo"=>($IsPassMandatory)?$val['PassportNo']:"",
													"PassportExpiry"=>($IsPassMandatory)?date('d/m/Y',strtotime($val['PassportExpiry'])):"",
													"PassportIssuedDate"=>($IsPassMandatory)?date('d/m/Y',strtotime($val['passporIssue'])):"",
													"InfantRef"=>$InfantRef
												);
												
												if ($isAdobrMandatory == 1 && $val['paxType'] == 1) {
													$PaxData[$pk]['DOB'] = $DOB;
												}
												if ($isCdobrMandatory == 1 && $val['paxType'] == 2) {
													$PaxData[$pk]['DOB'] = $DOB;
												}
												if ($isIdobrMandatory == 1 && $val['paxType'] == 3) {
													$PaxData[$pk]['DOB'] = $DOB;
												}
											}
										}
	
										$request = array(
											'BaseOrigin'=>$SourceAirportCode,
											'BaseDestination'=>$DestAirportCode,
											'TripType'=>($route == 2)?'R':'O',
											'AdultCount'=>$adultCount,
											'ChildCount'=>$childCount,
											'InfantCount'=>$infantCount,
											'TrackId'=>$ApiResultIndex,
											'BlockPNR'=>false,
											'AgentInfo'=>[],
	
											'ItineraryFlightsInfo'=>$ItineraryFlightsInfo,
											'PaxDetailsInfo'=>$PaxData,
											'AddressDetails'=>[
												'CountryCode' => $CustomerSession->params[0]['countryCode'],
												'ContactNumber' =>$CustomerSession->params[0]['Contacts'],
												'EmailID' =>$CustomerSession->params[0]['EmailId']
											],
										);
	
										$DataS = array(
											'apidata'=>$request,
											'memberCount'=>$intMemberCount,
											'JourneyType'=>$route,
											'interNationalSearch'=>$interNationalSearch,
											'searchID'=> $BookingData[0]['SearchTraceId'],
											'ICSourceSysId'=>$ICSourceSysId,
											'AgentMarkUp'=>$getAgencyMarkups[0]['StdMarkUpPer'],
										);
										// echo "DataS<pre>";
										// print_r(json_encode($DataS));die;
										$getData['BookingData'] = $FlightBookingData;
										$url = $this->GTXAPIDEFAULT.'/flight/v3/book';
										$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
										// $apiResponse = json_decode('{"status":true,"message":"SUCCESS","results":{"TrackId":"AQAG09231201115290320241227291696180007442","Bookingresponse":{"ItinearyDetails":[{"AdultCount":"1","ChildCount":"1","InfantCount":"1","IssuedDate":"29\/03\/2024 13:57:30","Item":[{"Resultcode":"1","BookingTrackId":"AQAG09231201115290320241227291696180007442","AirIqPNR":"AF29CB0006","CRSPNR":"N\/A","BaseOrigin":"DEL","BaseDestination":"DXB","GST_Number":"","TicketingTimeLimit":"","PromoCode":"","Class":"S","PrintTicket":"","SegmentType":"I","Special":"N","Stock":"SG","TripType":"R","PaymentDetails":{"Item":[{"Amount":"28654.00","CurrencyCode":"INR"}]},"TourCode":"","TravellerInfo":{"Item":[{"Title":"MS","FirstName":"JYOTIA","LastName":"KUSHAWAHA","DateOfBirth":"26\/03\/1998","PaxType":"Adult","TicketNumber":"AF29CB00061-1","SegmentInformation":{"Item":[{"AirlinePNR":"D8T1TM","TicketNo":"AF29CB00061-1","FlightNumber":"11","Origin":"DEL","Destination":"DXB","DepartureDateTime":"01\/05\/2024 07:45","ArrivalDateTime":"01\/05\/2024 10:10","AirCraftType":"","CarrierCode":"SG","ClassCode":"S","FareBasis":"SSAV","FrequentFlyerNumber":"","SpRequest":"","MealsPreference":"","MealsAmount":"0.00","BaggagePreference":"30KG ","BaggageAmount":"0.00","SeatPreference":"","SeatAmount":"0.00"},{"AirlinePNR":"D8T1TM","TicketNo":"AF29CB00062-1","FlightNumber":"6","Origin":"DXB","Destination":"DEL","DepartureDateTime":"02\/05\/2024 11:10","ArrivalDateTime":"02\/05\/2024 15:55","AirCraftType":"","CarrierCode":"SG","ClassCode":"S","FareBasis":"SSAV","FrequentFlyerNumber":"","SpRequest":"","MealsPreference":"","MealsAmount":"0.00","BaggagePreference":"30KG ","BaggageAmount":"0.00","SeatPreference":"","SeatAmount":"0.00"}],"MonetaryDetail":{"BasicAmount":"7948.00","BasicCurrencyCode":"INR","CurrencyCode":"INR","GrossAmount":"11764.00","PLBAmount":"0.00","ServiceTax":"ServiceTax","ServiceTaxAmount":"0.00","TaxDetails":{"item":[{"Amount":"102.00","CurrencyCode":"INR","TaxCode":"SGST07"},{"Amount":"497.00","CurrencyCode":"INR","TaxCode":"ASF"},{"Amount":"110.00","CurrencyCode":"INR","TaxCode":"AAT"},{"Amount":"102.00","CurrencyCode":"INR","TaxCode":"CGST07"},{"Amount":"110.00","CurrencyCode":"INR","TaxCode":"API"},{"Amount":"164.00","CurrencyCode":"INR","TaxCode":"UDF"},{"Amount":"771.00","CurrencyCode":"INR","TaxCode":"PFC"},{"Amount":"1743.00","CurrencyCode":"INR","TaxCode":"PSF"},{"Amount":"217.00","CurrencyCode":"INR","TaxCode":"TRF"}]},"TransactionFee":"TransactionFee","TransactionFeeAmount":"0.00"}}},{"Title":"MISS","FirstName":"SHIKHACHA","LastName":"KUSHAWAHA","DateOfBirth":"14\/04\/2016","PaxType":"Child","TicketNumber":"AF29CB00061-2","SegmentInformation":{"Item":[{"AirlinePNR":"D8T1TM","TicketNo":"AF29CB00061-2","FlightNumber":"11","Origin":"DEL","Destination":"DXB","DepartureDateTime":"01\/05\/2024 07:45","ArrivalDateTime":"01\/05\/2024 10:10","AirCraftType":"","CarrierCode":"SG","ClassCode":"S","FareBasis":"SSAV","FrequentFlyerNumber":"","SpRequest":"","MealsPreference":"","MealsAmount":"0.00","BaggagePreference":"30KG ","BaggageAmount":"0.00","SeatPreference":"","SeatAmount":"0.00"},{"AirlinePNR":"D8T1TM","TicketNo":"AF29CB00062-2","FlightNumber":"6","Origin":"DXB","Destination":"DEL","DepartureDateTime":"02\/05\/2024 11:10","ArrivalDateTime":"02\/05\/2024 15:55","AirCraftType":"","CarrierCode":"SG","ClassCode":"S","FareBasis":"SSAV","FrequentFlyerNumber":"","SpRequest":"","MealsPreference":"","MealsAmount":"0.00","BaggagePreference":"30KG ","BaggageAmount":"0.00","SeatPreference":"","SeatAmount":"0.00"}],"MonetaryDetail":{"BasicAmount":"7948.00","BasicCurrencyCode":"INR","CurrencyCode":"INR","GrossAmount":"11764.00","PLBAmount":"0.00","ServiceTax":"ServiceTax","ServiceTaxAmount":"0.00","TaxDetails":{"item":[{"Amount":"102.00","CurrencyCode":"INR","TaxCode":"SGST07"},{"Amount":"497.00","CurrencyCode":"INR","TaxCode":"ASF"},{"Amount":"110.00","CurrencyCode":"INR","TaxCode":"AAT"},{"Amount":"102.00","CurrencyCode":"INR","TaxCode":"CGST07"},{"Amount":"110.00","CurrencyCode":"INR","TaxCode":"API"},{"Amount":"164.00","CurrencyCode":"INR","TaxCode":"UDF"},{"Amount":"771.00","CurrencyCode":"INR","TaxCode":"PFC"},{"Amount":"1743.00","CurrencyCode":"INR","TaxCode":"PSF"},{"Amount":"217.00","CurrencyCode":"INR","TaxCode":"TRF"}]},"TransactionFee":"TransactionFee","TransactionFeeAmount":"0.00"}}},{"Title":"MISS","FirstName":"SHIKHAI","LastName":"SINGH","DateOfBirth":"22\/03\/2023","PaxType":"Infant","TicketNumber":"AF29CB00061-3","SegmentInformation":{"Item":[{"AirlinePNR":"D8T1TM","TicketNo":"AF29CB00061-3","FlightNumber":"11","Origin":"DEL","Destination":"DXB","DepartureDateTime":"01\/05\/2024 07:45","ArrivalDateTime":"01\/05\/2024 10:10","AirCraftType":"","CarrierCode":"SG","ClassCode":"S","FareBasis":"SSAV","FrequentFlyerNumber":"","SpRequest":"","MealsPreference":"","MealsAmount":"0.00","BaggagePreference":"","BaggageAmount":"0.00","SeatPreference":"","SeatAmount":"0.00"},{"AirlinePNR":"D8T1TM","TicketNo":"AF29CB00062-3","FlightNumber":"6","Origin":"DXB","Destination":"DEL","DepartureDateTime":"02\/05\/2024 11:10","ArrivalDateTime":"02\/05\/2024 15:55","AirCraftType":"","CarrierCode":"SG","ClassCode":"S","FareBasis":"SSAV","FrequentFlyerNumber":"","SpRequest":"","MealsPreference":"","MealsAmount":"0.00","BaggagePreference":"","BaggageAmount":"0.00","SeatPreference":"","SeatAmount":"0.00"}],"MonetaryDetail":{"BasicAmount":"5126.00","BasicCurrencyCode":"INR","CurrencyCode":"INR","GrossAmount":"5126.00","PLBAmount":"0.00","ServiceTax":"ServiceTax","ServiceTaxAmount":"0.00","TaxDetails":{"item":[{"Amount":"0.00","CurrencyCode":"INR","TaxCode":"Tax"}]},"TransactionFee":"TransactionFee","TransactionFeeAmount":"0.00"}}}]}}],"OtherCharges":"0.00","SegmentType":"I","TerminalContactDetails":{"Address1":"","Address2":"","City":"Chennai","Country":"CX","Email":"gaurav@catpl.co.in","Phone":"9811192312","State":"","TerminalName":"Catabatic Technology Pvt Ltd -API"},"TotalAmount":"28654.00","TotalSegments":"2","TripType":"R"}]},"Status":{"Error":"","ResultCode":"1","SequenceID":"13571771460122540"}},"TransactionStatus":"","BookingId":""}',1);
										// $apiResponse = json_decode('{"status":true,"message":"SUCCESS","results":{"TrackId":"AQAG0923120153290320241019524056910007439","Bookingresponse":{"ItinearyDetails":[{"AdultCount":"1","ChildCount":"0","InfantCount":"0","IssuedDate":"29\/03\/2024 11:49:55","Item":[{"Resultcode":"1","BookingTrackId":"AQAG0923120153290320241019524056910007439","AirIqPNR":"AF29CB0003","CRSPNR":"N\/A","BaseOrigin":"DEL","BaseDestination":"DXB","GST_Number":"","TicketingTimeLimit":"","PromoCode":"","Class":"S","PrintTicket":"","SegmentType":"I","Special":"N","Stock":"SG","TripType":"R","PaymentDetails":{"Item":[{"Amount":"11764.00","CurrencyCode":"INR"}]},"TourCode":"","TravellerInfo":{"Item":[{"Title":"MS","FirstName":"JYOTI","LastName":"KUSHAWAHA","DateOfBirth":"19\/03\/1998","PaxType":"Adult","TicketNumber":"AF29CB00031-1","SegmentInformation":{"Item":[{"AirlinePNR":"MCV9NQ","TicketNo":"AF29CB00031-1","FlightNumber":"11","Origin":"DEL","Destination":"DXB","DepartureDateTime":"09\/05\/2024 07:45","ArrivalDateTime":"09\/05\/2024 10:10","AirCraftType":"","CarrierCode":"SG","ClassCode":"S","FareBasis":"SSAV","FrequentFlyerNumber":"","SpRequest":"","MealsPreference":"","MealsAmount":"0.00","BaggagePreference":"30KG ","BaggageAmount":"0.00","SeatPreference":"","SeatAmount":"0.00"},{"AirlinePNR":"MCV9NQ","TicketNo":"AF29CB00032-1","FlightNumber":"6","Origin":"DXB","Destination":"DEL","DepartureDateTime":"10\/05\/2024 11:10","ArrivalDateTime":"10\/05\/2024 15:55","AirCraftType":"","CarrierCode":"SG","ClassCode":"S","FareBasis":"SSAV","FrequentFlyerNumber":"","SpRequest":"","MealsPreference":"","MealsAmount":"0.00","BaggagePreference":"30KG ","BaggageAmount":"0.00","SeatPreference":"","SeatAmount":"0.00"}],"MonetaryDetail":{"BasicAmount":"7948.00","BasicCurrencyCode":"INR","CurrencyCode":"INR","GrossAmount":"11764.00","PLBAmount":"0.00","ServiceTax":"ServiceTax","ServiceTaxAmount":"0.00","TaxDetails":{"item":[{"Amount":"102.00","CurrencyCode":"INR","TaxCode":"SGST07"},{"Amount":"497.00","CurrencyCode":"INR","TaxCode":"ASF"},{"Amount":"110.00","CurrencyCode":"INR","TaxCode":"AAT"},{"Amount":"102.00","CurrencyCode":"INR","TaxCode":"CGST07"},{"Amount":"110.00","CurrencyCode":"INR","TaxCode":"API"},{"Amount":"164.00","CurrencyCode":"INR","TaxCode":"UDF"},{"Amount":"771.00","CurrencyCode":"INR","TaxCode":"PFC"},{"Amount":"1743.00","CurrencyCode":"INR","TaxCode":"PSF"},{"Amount":"217.00","CurrencyCode":"INR","TaxCode":"TRF"}]},"TransactionFee":"TransactionFee","TransactionFeeAmount":"0.00"}}}]}}],"OtherCharges":"0.00","SegmentType":"I","TerminalContactDetails":{"Address1":"","Address2":"","City":"Chennai","Country":"CX","Email":"gaurav@catpl.co.in","Phone":"9811192312","State":"","TerminalName":"Catabatic Technology Pvt Ltd -API"},"TotalAmount":"11764.00","TotalSegments":"2","TripType":"R"}]},"Status":{"Error":"","ResultCode":"1","SequenceID":"11493887525186780"}},"TransactionStatus":"","BookingId":""}',1);
										// echo "apiResponse<pre>";print_r(json_encode($apiResponse));die;
										$ResponseStatus = isset($apiResponse['results']['Status']['ResultCode']) ? $apiResponse['results']['Status']['ResultCode'] : false;
										$TransactionStatus = isset($apiResponse['TransactionStatus']) ? $apiResponse['TransactionStatus'] : '';
										$BookingId = isset($apiResponse['BookingId']) ? $apiResponse['BookingId'] : '';
										
										if($ResponseStatus == 1){
											$Bookres = [
												'status' => array('success' => true,'apiResponse'=>$apiResponse,'BookingId'=>$BookingId, 'TransactionStatus'=>$TransactionStatus,'SearchTraceId' => $arrUrlData['SearchTraceId']),
											];	
										}				
									}  elseif ($ICSourceSysId == 11) {
										$BookresEtrav = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightTicketEtrav($BookingdataAPI);
										// $BookresEtrav = json_decode('{"status":true,"message":"SUCCESS","results":{"Booking_RefNo":"FBB7B2PF","Response_Header":{"Error_Code":"0000","Error_Desc":"SUCCESS","Error_InnerException":"","Request_Id":"7eab3-4f0b1-d82d5-6e3a9","Status_Id":"11"}},"TransactionStatus":"","BookingId":""}',1);
										// echo "<pre>BookresEtrav";
										// print_r(json_encode($BookresEtrav));die;
										$BookStatus = !empty($BookresEtrav['status'])?$BookresEtrav['status']:false;
										$Booking_RefNo = isset($BookresEtrav['results']['Booking_RefNo'])?$BookresEtrav['results']['Booking_RefNo']:'';
										if($BookStatus == 1){

											$request_ = array(
												'Auth_Header'=>array(
													"IP_Address" => $_SERVER['REMOTE_ADDR'],
													"Request_Id" => $BookingData[0]['SearchTraceId'],
													"IMEI_Number" => "3434334343111"
												),
												'RefNo'=> $Booking_RefNo,
												'ClientRefNo'=> "add payment",
												'TransactionType'=>0,
												'ProductId'=>1,
											);
											$DataS_ = array(
												'apidata'=>$request_,
												'memberCount'=>$intMemberCount,
												'JourneyType'=>$route,
												'interNationalSearch'=>$interNationalSearch,
												'searchID'=>$BookingData[0]['SearchTraceId'],
												'ICSourceSysId'=>$ICSourceSysId,
												'APIMode' => $this->APIMode
											);
											// echo "<pre>addpayment";
											// print_r(json_encode($DataS_));die;
											$getData['BookingData'] = $FlightBookingData;
											$url = $this->GTXAPIDEFAULT.'/flight/v3/addpayment';
											$addpayment = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS_, $getData, $url);
											// $addpayment = json_decode('{"status":true,"message":"SUCCESS","results":{"Amount":3277,"DebitedAmount":3219.94,"PaymentID":"215465","Response_Header":{"Error_Code":"0000","Error_Desc":"SUCCESS","Error_InnerException":"","Request_Id":"7eab3-4f0b1-d82d5-6e3a9","Status_Id":"11"}}}',1);
											$APIPaymentStatus = !empty($addpayment['status'])?$addpayment['status']:false;
											
											if($APIPaymentStatus == 1){

												$request = array(
													'Auth_Header'=>array(
														"IP_Address" => $_SERVER['REMOTE_ADDR'],
														"Request_Id" => $BookingData[0]['SearchTraceId'],
														"IMEI_Number" => "3434334343111"
													),
													'Booking_RefNo'=>$Booking_RefNo,
													'Ticketing_Type'=>1,
												);
												$DataS = array(
													'apidata'=>$request,
													'memberCount'=>$intMemberCount,
													'JourneyType'=>$route,
													'interNationalSearch'=>$interNationalSearch,
													'searchID'=>$BookingData[0]['SearchTraceId'],
													'ICSourceSysId'=>$ICSourceSysId,
													'APIMode' => $this->APIMode
												);
												// echo "<pre>apiResponse";
												// print_r(json_encode($DataS));die;
												$getData['BookingData'] = $FlightBookingData;
												$url = $this->GTXAPIDEFAULT.'/flight/v3/ticketing';
												$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
												// $apiResponse = json_decode('{"status":false,"message":"Your ticket request is on pending \/ unknown status. Please check the status before initiating an another ticket. ","results":{"AirlinePNRDetails":null,"Booking_RefNo":"FBB7B2PF","Response_Header":{"Error_Code":"0008","Error_Desc":"Your ticket request is on pending \/ unknown status. Please check the status before initiating an another ticket. ","Error_InnerException":"Err002 : This transaction is already confirmed, Please check in transaction track","Request_Id":"7eab3-4f0b1-d82d5-6e3a9","Status_Id":"22"}}}',1);
												// echo "<pre>apiResponse";
												// print_r(json_encode($apiResponse));die;
												$Bookres = [
													'status' => array('success' => true,'apiResponse'=>$apiResponse, 'SearchTraceId' => $arrUrlData['SearchTraceId']),
												];
											}else{
												$Bookres = [
													'status' => array('success' => false,'SearchTraceId' => $arrUrlData['SearchTraceId']),
												];
											}
										}else{
											$Bookres = [
												'status' => array('success' => false,'SearchTraceId' => $BookingData[0]['SearchTraceId']),
											];
										}

									}else{
										$Bookres = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightTicketTripJack($BookingdataAPI);
									}
									
								}
								// if($this->gtxagencysysid == '26691'){
								// 	echo "BookingData<pre>";print_r($Bookres);
								// 	die;
								// }
								
								
								$BookStatus = $Bookres['status']['success'];
								$BookErrorMessage = 'Unable to continue booking. please contact with our support team.'; //$Bookres['errors'][0]['message'];
								if ($BookStatus == 1) {
									if ($couponApply == 1) {
										$applyCoupon = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->applyCoupon($applyData);
									}

									$Bookres['SearchFlightTraceId'] = $SearchFlightTraceId;
									if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
										$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingDetailsSeriesFareNew($BookingData, $CustomerSession->params);
									} else {
										if($ICSourceSysId == 17){
											$apiResponse = isset($Bookres['status']['apiResponse'])?$Bookres['status']['apiResponse']:[];
											$TransactionStatus = isset($Bookres['status']['TransactionStatus'])?$Bookres['status']['TransactionStatus']:'';
											$BookingId = isset($Bookres['status']['BookingId'])?$Bookres['status']['BookingId']:'';
											$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->SetbookingDetailsNextra($BookingData, $CustomerSession->params, $apiResponse, $DataS);
											
										} elseif($ICSourceSysId == 16){
											$apiResponse = isset($Bookres['status']['apiResponse'])?$Bookres['status']['apiResponse']:[];
											$TransactionStatus = isset($Bookres['status']['TransactionStatus'])?$Bookres['status']['TransactionStatus']:'';
											$BookingId = isset($Bookres['status']['BookingId'])?$Bookres['status']['BookingId']:'';
											$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->SetbookingDetailsAIRIQ($BookingData, $CustomerSession->params, $apiResponse, $DataS);
											$responseApiResponse = $response;
											
										} elseif($ICSourceSysId == 11){
											$apiResponse = isset($Bookres['status']['apiResponse'])?$Bookres['status']['apiResponse']:[];
											$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->SetbookingDetailsEtrave($BookingData, $CustomerSession->params, $apiResponse, $DataS);
											$responseApiResponse = $response;
											
										}else{
											$Bookres['BookingData'] = $BookingData;
											$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingDetailsTripJack($Bookres);
										}
										
									}
									$OrderBookingStatus = isset($response['order']['status']) ? $response['order']['status'] : '';
									if ($OrderBookingStatus != 'ABORTED') {
										
										if($ICSourceSysId == 16){
											$ResponseStatus = isset($response[0]['status']['success']) ? $response[0]['status']['success'] : '0';
											// $strTicketPNRLCC = isset($response[0]['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails']) ? $response[0]['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails'] : '';
											$strTicketPNRLCC = isset($response[0]['order']['customerpnr']['PNR_Number']) ? $response[0]['order']['customerpnr']['PNR_Number'] : '';
											$strgdsPnrs = isset($response[0]['itemInfos']['AIR']['travellerInfos'][0]['gdsPnrs']) ? $response[0]['itemInfos']['AIR']['travellerInfos'][0]['gdsPnrs'] : '';
											
											$Passenger = isset($response[0]['itemInfos']['AIR']['travellerInfos']) ? $response[0]['itemInfos']['AIR']['travellerInfos'] : '';
											$strBookingIdLCC = isset($response[0]['order']['bookingId']) ? $response[0]['order']['bookingId'] : '0';
											$ErrorMessage = isset($response[0]['errors'][0]['message']) ? $response['errors'][0]['message'] : '';
										}else{
											$ResponseStatus = isset($response['status']['success']) ? $response['status']['success'] : '0';
											$strTicketPNRLCC = isset($response['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails']) ? $response['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails'] : '';
											$strgdsPnrs = isset($response['itemInfos']['AIR']['travellerInfos'][0]['gdsPnrs']) ? $response['itemInfos']['AIR']['travellerInfos'][0]['gdsPnrs'] : '';
											$Passenger = isset($response['itemInfos']['AIR']['travellerInfos']) ? $response['itemInfos']['AIR']['travellerInfos'] : '';
											$strBookingIdLCC = isset($response['order']['bookingId']) ? $response['order']['bookingId'] : '0';
											$ErrorMessage = isset($response['errors'][0]['message']) ? $response['errors'][0]['message'] : '';
										}
										if ($interNationalSearch == 1 && $route == 2) {
											$MealFare_Int = ($MealPrice + $InbMealPrice) * $this->CurrencyRate;
											$BaggFare_Int = ($BagPrice + $InbBagPrice) * $this->CurrencyRate;
											$SeatPriceInt = 0;
											if ($selectedSeatSession->params) {
												foreach ($selectedSeatSession->params as $values) {
													foreach ($values as $val) {
														$SeatPriceInt += $val['amount'];
													}
												}
											}
											$SeatFare_Int = ($SeatPriceInt * $this->CurrencyRate);
											$BookingDatadd = $BookingData[0]['InternationalData'];
											$finalFareSummary = $BookingDatadd['Fare'];
											$PublishedFareINT = $BookingDatadd['Fare']['PublishedFare'];
											$AgentCommisionEarnedINT = ($finalFareSummary['CommEarned'] + $finalFareSummary['PLBEarned']) * $this->CurrencyRate;
											$AgentCommisionEarnedGSTINT = ($finalFareSummary['GSTonComm'] + isset($finalFareSummary['GSTonPLB']) ? $finalFareSummary['GSTonPLB'] : 0) * $this->CurrencyRate;
											$AgencyMarkUpINT = $finalFareSummary['FixedMarkUp'] * $this->CurrencyRate;
											$AgencyMarkUpGSTINT = $finalFareSummary['GSTOnMarkUp'] * $this->CurrencyRate;
											$GTXMarkUpINT = $finalFareSummary['intGTXMarkUp'] * $this->CurrencyRate;
											$BaseAmountINT = ($PublishedFareINT - $AgentCommisionEarnedINT);
											$FareSummaryInt = array(
												'PublishedFare' => ($PublishedFareINT + $BaggFare_Int + $MealFare_Int + $SeatFare_Int),
												'AgentCommisionEarned' => $AgentCommisionEarnedINT,
												'AgentCommisionEarnedGST' => $AgentCommisionEarnedGSTINT,
												'AgencyMarkUp' => $AgencyMarkUpINT,
												'AgencyMarkUpGST' => $AgencyMarkUpGSTINT,
												'GTXMarkUp' => $GTXMarkUpINT,
												'BaseAmount' => ($BaseAmountINT + $BaggFare_Int + $MealFare_Int + $SeatFare_Int),
											);
										}

										$segArray = [];
										if ($BookingData) {
											foreach ($BookingData as $k => $valueNew) {
												if ($valueNew['Segments']) {
													foreach ($valueNew['Segments'] as $seg_) {
														$segArray[$seg_['segmentid']]  = $seg_;
													}
												}
											}
										}
										if ($BookingData) {
											foreach ($BookingData as $k => $value) {
												if($ICSourceSysId == 16 && $route == 2){
													$response = $responseApiResponse[$k];
													$ResponseStatus = isset($response['status']['success']) ? $response['status']['success'] : '0';
													$strTicketPNRLCC = isset($response['order']['customerpnr']['PNR_Number']) ? $response['order']['customerpnr']['PNR_Number'] : '';
													$Passenger = isset($response['itemInfos']['AIR']['travellerInfos']) ? $response['itemInfos']['AIR']['travellerInfos'] : '';
													$strBookingIdLCC = isset($response['order']['BookingTrackId']) ? $response['order']['BookingTrackId'] : '0';
													$bookingId = isset($response['order']['bookingId']) ? $response['order']['bookingId'] : '0';
													$ErrorMessage = isset($response['errors'][0]['message']) ? $response['errors'][0]['message'] : '';
												}
												$finalFareSummary = $value['FairRules'];
												//echo '<pre>';print_r($finalFareSummary);
												$couponApply = isset($value['FairRules']['couponApply']) ? $value['FairRules']['couponApply'] : 0;
												if ($couponApply == 1 || $couponApply == '1') {
													$couponVal = isset($value['FairRules']['couponVal']) ? $value['FairRules']['couponVal'] : 0;
												} else {
													$couponVal = 0;
												}
												$PublishedFareNewPrice = 0;
												if($ICSourceSysId == 7){
													$PublishedFareNewPrice += isset($value['NewPrice']['PublishedFare']) ? $value['NewPrice']['PublishedFare'] :0;
												}
											
												$AdditionalTxnFeePub = 0;
												$TotalBaseFare = 0;
												$TotalTaxsandFees = 0;
												if ($value['FairRules']['FareBreakdown']) {
													foreach ($value['FairRules']['FareBreakdown'] as $FareBreakdown) {
														$MF = isset($FareBreakdown['MF']) ? $FareBreakdown['MF'] :0; //Management Fee
														$TDS = isset($FareBreakdown['TDS']) ? $FareBreakdown['TDS']:0; //Management Fee
														$YQ = isset($FareBreakdown['YQ']) ? $FareBreakdown['YQ']:0; //Fuel Surcharge
														$AGST = isset($FareBreakdown['AGST']) ? $FareBreakdown['AGST']:0; //Airline GST Component
														$MFT = isset($FareBreakdown['MFT']) ? $FareBreakdown['MFT']:0; //Management Fee Tax
														$OT = isset($FareBreakdown['OT']) ? $FareBreakdown['OT']:0; //Other Charges
														$MU = isset($FareBreakdown['MU']) ? $FareBreakdown['MU']:0; //Markup
														$YR = isset($FareBreakdown['YR']) ? $FareBreakdown['YR']:0; //Carrier Misc Fee
														$other = $MF + $YQ + $AGST + $MFT + $OT + $YR;
														if ($ICSourceSysId == 3) {
															$other =  $MF + $AGST + $MFT + $OT + $YR;
														}
														$PBaseFare = isset($FareBreakdown['BaseFare']) ? $FareBreakdown['BaseFare']:0;
														$intTotalGST = isset($FareBreakdown['intTotalGST']) ? $FareBreakdown['intTotalGST']:0;
														$FixedMarkUp = isset($FareBreakdown['FixedMarkUp']) ? $FareBreakdown['FixedMarkUp']:0;
														$apiMarkup = isset($FareBreakdown['apiMarkup']) ? $FareBreakdown['apiMarkup']:0;
														$IntCommission = isset($FareBreakdown['IntCommission']) ? $FareBreakdown['IntCommission']:0;
														$CommissionEarned = isset($FareBreakdown['CommissionEarned']) ? $FareBreakdown['CommissionEarned']:0;
														$CommisionPass = isset($FareBreakdown['CommisionPass']) ? $FareBreakdown['CommisionPass']:0;
														$ServiceFee = isset($FareBreakdown['ServiceFee']) ? $FareBreakdown['ServiceFee']:0;

														$paxPublishedFare = ($PBaseFare);
														$PassengerType = isset($FareBreakdown['PassengerType']) ? $FareBreakdown['PassengerType'] :0;
														$PassengerCount = isset($FareBreakdown['PassengerCount']) ? $FareBreakdown['PassengerCount']:0;
														$AdditionalTxnFeePub += isset($FareBreakdown['AdditionalTxnFeePub']) ? $FareBreakdown['AdditionalTxnFeePub']:0;

														$TaxesFees = ($other + $intTotalGST + $FixedMarkUp + $apiMarkup + $IntCommission - $CommissionEarned);
														if ($ICSourceSysId == 3) {
															$TaxesFees = ($other + $intTotalGST + $FixedMarkUp + $apiMarkup + $ServiceFee - $CommisionPass);
														}
														$TotalBaseFare += ($paxPublishedFare);
														$TotalTaxsandFees += ($TaxesFees);
													}
												}
												if($ICSourceSysId == 7 || $ICSourceSysId == 3){
													$PublishedFareINT = ($PublishedFareNewPrice);
												}elseif($ICSourceSysId == 11){
													$PublishedFareINT = isset($value['FairRules']['PublishedFare']) ? ($value['FairRules']['PublishedFare'] - $couponVal) :0;
												}else{
													$PublishedFareINT = (($TotalBaseFare + $TotalTaxsandFees) - $couponVal) * $this->CurrencyRate;
													
												}
												//$PublishedFareINT = ($value['FairRules']['PublishedFare'] - $couponVal);
												if ($k == 0) {
													$MealFare = $MealPrice * $this->CurrencyRate;
													$BaggFare = $BagPrice * $this->CurrencyRate;
												} else {
													$MealFare = $InbMealPrice * $this->CurrencyRate;
													$BaggFare = $InbBagPrice * $this->CurrencyRate;
												}
												$SeatPrice = 0;
												if ($value['Segments']) {
													foreach ($value['Segments'] as $seg) {
														if (!empty($selectedSeatSession->params) && isset($selectedSeatSession->params[$seg['segmentid']]) && !empty($selectedSeatSession->params[$seg['segmentid']])) {
															$selectedSeat = $selectedSeatSession->params[$seg['segmentid']];
															foreach ($selectedSeat as $val) {
																$SeatPrice += $val['amount'];
															}
														}
													}
												}
												$SeatFare = $SeatPrice * $this->CurrencyRate;
												$AgentCommisionEarnedINT = isset($finalFareSummary['GSTonComm']) ? ($finalFareSummary['CommEarned'] + $finalFareSummary['PLBEarned']) * $this->CurrencyRate :0;
												$AgentCommisionEarnedGSTINT = isset($finalFareSummary['GSTonComm']) ? ($finalFareSummary['GSTonComm'] + isset($finalFareSummary['GSTonPLB']) ? $finalFareSummary['GSTonPLB'] : 0) * $this->CurrencyRate :0;
												$AgencyMarkUpINT = isset($finalFareSummary['FixedMarkUp']) ? $finalFareSummary['FixedMarkUp'] * $this->CurrencyRate :0;
												$AgencyMarkUpGSTINT = isset($finalFareSummary['GSTOnMarkUp']) ? $finalFareSummary['GSTOnMarkUp'] * $this->CurrencyRate:0;
												$GTXMarkUpINT = isset($finalFareSummary['intGTXMarkUp']) ? $finalFareSummary['intGTXMarkUp'] * $this->CurrencyRate :0;
												// $BaseAmountINT = ($PublishedFareINT - ($AgentCommisionEarnedGSTINT + $AgencyMarkUpGSTINT + $AgentCommisionEarnedINT + $AgencyMarkUpINT + $GTXMarkUpINT));
												$BaseAmountINT = ($PublishedFareINT - $AgentCommisionEarnedINT - $AgencyMarkUpINT - $AgencyMarkUpGSTINT);
												if ($interNationalSearch == 1 && $route == 2 && $IsSeriesFareData != 1) {
													$FareSummary = $FareSummaryInt;
												} else {
													$FareSummary = array(
														'PublishedFare' => ($PublishedFareINT + $BaggFare + $MealFare + $SeatFare),
														'AgentCommisionEarned' => $AgentCommisionEarnedINT,
														'AgentCommisionEarnedGST' => $AgentCommisionEarnedGSTINT,
														'AgencyMarkUp' => $AgencyMarkUpINT,
														'AgencyMarkUpGST' => $AgencyMarkUpGSTINT,
														'GTXMarkUp' => $GTXMarkUpINT,
														'BaseAmount' => ($BaseAmountINT + $BaggFare + $MealFare + $SeatFare),
													);
												}


												$UpdateFare[$k] = array(
													'Price' => $BaseAmountINT,
													'NetPrice' => $PublishedFareINT,
													'AgencyMarkUp' => $AgencyMarkUpINT,
													'AgentServiceTaxAmount' => $AgencyMarkUpGSTINT,
													'MarkUp' => $AgentCommisionEarnedINT,
													'AgentsCustomServiceTaxAmount' => $AgentCommisionEarnedGSTINT,
													'GTXMarkup' => $GTXMarkUpINT,
													'GTXServiceTaxAmount' => 0,
													'TotalCost' => $PublishedFareINT,
													'MealFare' => $MealFare,
													'BaggFare' => $BaggFare,
													'SeatFare' => $SeatFare,
												);
												$FlightBookingTicketArr[] = $response;
												$ResponseStatus = isset($response['status']['success']) ? $response['status']['success'] : '0';
												if($ICSourceSysId != 16){
													$strTicketPNRLCC = isset($response['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails']) ? $response['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails'] : '';
												}
												$Passenger = isset($response['itemInfos']['AIR']['travellerInfos']) ? $response['itemInfos']['AIR']['travellerInfos'] : '';
												$strBookingIdLCC = isset($response['order']['bookingId']) ? $response['order']['bookingId'] : '0';
												if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
													$strBookingIdLCC = isset($response['order']['bookingId'][$k]) ? $response['order']['bookingId'][$k] : '0';
												}
												$bookingId = str_replace('TJ', 'BKR', $strBookingIdLCC);
												$segment = [];
												$segmentArray = [];
												$finalpnr = [];
												$finalgdspnr = [];
												
												if ($value['Segments']) {
													foreach ($value['Segments'] as $seg) {
														$originAirportCode = $seg['originAirportCode'];
														$destinationAirportCode = $seg['destinationAirportCode'];
														$segment[] = $originAirportCode . '-' . $destinationAirportCode;
														$segmentArray[] = $originAirportCode . '-' . $destinationAirportCode;
														$AirportCode = $originAirportCode . '-' . $destinationAirportCode;
														$finalgdspnr[] = isset($strgdsPnrs[$AirportCode]) ? $strgdsPnrs[$AirportCode] : '';
														$finalpnr[] = isset($strTicketPNRLCC[$AirportCode]) ? $strTicketPNRLCC[$AirportCode] : '';
													}
												}
												$GDSpnr = !empty($finalgdspnr) ? $this->checkArrayKeyExist($finalgdspnr):[];
												$finalpnr = $this->checkArrayKeyExist($finalpnr);
												
												$customerpnr = [];
												if ($Passenger) {
													foreach ($Passenger as $pk => $pax) {
														$SelectedMeal = [];
														$SelectedSeat = [];
														$SelectedBag = [];
														$SelectedMeal__ = [];
														$SelectedSeat__ = [];
														$SelectedBag__ = [];
														$pnrDetails = isset($pax['pnrDetails']) ? $pax['pnrDetails'] :[];
														$ticketNumberDetails = isset($pax['ticketNumberDetails']) ? $pax['ticketNumberDetails'] :'';
														$SelectedBag_ = isset($pax['ssrBaggageInfos']) ? $pax['ssrBaggageInfos'] :[];
														$SelectedMeal_ = isset($pax['ssrMealInfos']) ? $pax['ssrMealInfos'] :[];
														$SelectedSeat_ = isset($pax['ssrSeatInfos']) ? $pax['ssrSeatInfos'] :[];
														$TicketNumber = [];
														$TicketId = [];
														$BagPrice_c = 0;
														$MealPrice_c = 0;
														$SeatPrice_c = 0;
														if($ICSourceSysId == 16 && $route == 2){
															$TicketNumber = array_values($pnrDetails);
															$TicketId = array_values($ticketNumberDetails);
															if($segmentArray){
																foreach($segmentArray as $sgvl){
																	$BagPrice_c += isset($SelectedBag_[$sgvl]['amount']) ? $SelectedBag_[$sgvl]['amount'] : '';
																	$MealPrice_c += isset($SelectedMeal_[$sgvl]['amount']) ? $SelectedMeal_[$sgvl]['amount'] : '';
																	$SeatPrice_c += isset($SelectedSeat_[$sgvl]['amount']) ? $SelectedSeat_[$sgvl]['amount'] : '';
																}
															}
														}else{
															// echo "segmentArray<pre>";print_r($segmentArray);
															if($segmentArray){
																foreach($segmentArray as $sgvl){
																	if($sgvl){
																		// echo "pnrDetails<pre>";print_r($pnrDetails[$sgvl]);
																		$TicketNumber[] = (isset($pnrDetails[$sgvl]) && !empty($pnrDetails[$sgvl])) ? $pnrDetails[$sgvl]:'';
																		$TicketId[] = (isset($ticketNumberDetails[$sgvl]) && !empty($ticketNumberDetails[$sgvl])) ? $ticketNumberDetails[$sgvl]:'';
																		if($SelectedBag_){
																			$BagPrice_c += (isset($SelectedBag_[$sgvl]['amount']) && !empty($SelectedBag_[$sgvl]['amount'])) ? $SelectedBag_[$sgvl]['amount'] : 0;
																			$MealPrice_c += (isset($SelectedMeal_[$sgvl]['amount']) && !empty($SelectedMeal_[$sgvl]['amount'])) ? $SelectedMeal_[$sgvl]['amount'] : 0;
																			$SeatPrice_c += (isset($SelectedSeat_[$sgvl]['amount']) && !empty($SelectedSeat_[$sgvl]['amount'])) ? $SelectedSeat_[$sgvl]['amount'] : 0;
																		}
																	}
																}
															}
														}
														// die("kfhshfkshf");
														if($ICSourceSysId == 17 || $ICSourceSysId == 16 || $ICSourceSysId == 7 || $ICSourceSysId == 11) {
															
															if($SelectedBaggSessionNew->params && ($CustomerSession->params[$pk]['paxType'] == 1 || $CustomerSession->params[$pk]['paxType'] == 2)){
																foreach ($SelectedBaggSessionNew->params as $valueBag) {
																	if($ICSourceSysId == 16) {
																		foreach ($valueBag as $valB) {
																			$Orgin = $valB['Origin'];
																			$Destination = $valB['Destination'];
																			$SelectedBag[$Orgin.'-'.$Destination][] = $valB;
																		}
																	}else{
																		$Orgin = $valueBag['origin'];
																		$Destination = $valueBag['destination'];
																		$SelectedBag[$Orgin.'-'.$Destination][] = $valueBag;
																	}
																}
															}
															if($SelectedMealSessionNew->params && ($CustomerSession->params[$pk]['paxType'] == 1 || $CustomerSession->params[$pk]['paxType'] == 2)){
																foreach ($SelectedMealSessionNew->params as $valueMeal) {
																	if($ICSourceSysId == 16) {
																		foreach ($valueMeal as $valM) {
																			$Orgin = $valM['Origin'];
																			$Destination = $valM['Destination'];
																			$SelectedMeal[$Orgin.'-'.$Destination][] = $valM;
																		}
																	}else{
																		$Orgin = $valueMeal['origin'];
																		$Destination = $valueMeal['destination'];
																		$SelectedMeal[$Orgin.'-'.$Destination][] = $valueMeal;
																	}
																}
															}
															if($SelectedBaggSessionNewInb->params && ($CustomerSession->params[$pk]['paxType'] == 1 || $CustomerSession->params[$pk]['paxType'] == 2)){
																foreach ($SelectedBaggSessionNewInb->params as $valueBag) {
																	if($ICSourceSysId == 16) {
																		foreach ($valueBag as $valB) {
																			$Orgin = $valB['Origin'];
																			$Destination = $valB['Destination'];
																			$SelectedBag[$Orgin.'-'.$Destination][] = $valB;
																		}
																	}else{
																		$Orgin = $valueBag['origin'];
																		$Destination = $valueBag['destination'];
																		$SelectedBag[$Orgin.'-'.$Destination][] = $valueBag;
																	}
																}
															}
															if($SelectedMealSessionNewInb->params && ($CustomerSession->params[$pk]['paxType'] == 1 || $CustomerSession->params[$pk]['paxType'] == 2)){
																foreach ($SelectedMealSessionNewInb->params as $valueMeal) {
																	if($ICSourceSysId == 16) {
																		foreach ($valueMeal as $valM) {
																			$Orgin = $valM['Origin'];
																			$Destination = $valM['Destination'];
																			$SelectedMeal[$Orgin.'-'.$Destination][] = $valM;
																		}
																	}else{
																		$Orgin = $valueMeal['origin'];
																		$Destination = $valueMeal['destination'];
																		$SelectedMeal[$Orgin.'-'.$Destination][] = $valueMeal;
																	}
																}
															}
															
															if($selectedSeatSession->params && ($CustomerSession->params[$pk]['paxType'] == 1 || $CustomerSession->params[$pk]['paxType'] == 2)){
																	foreach ($selectedSeatSession->params as $keySeg => $valueSeat) {
																		if($ICSourceSysId == 7){
																			$segmentData = isset($segArray[$keySeg]) ? $segArray[$keySeg] : [];
																			$Orgin = $segmentData['originAirportCode'];
																			$Destination = $segmentData['destinationAirportCode'];
																		}
																		foreach ($valueSeat as $ValSeat) {
																			if($ICSourceSysId != 7){
																				$Orgin = $ValSeat['Origin'];
																				$Destination = $ValSeat['Destination'];
																			}

																			if(!empty($Orgin) && !empty($Destination)){
																				$SelectedSeat[$Orgin.'-'.$Destination][] = $ValSeat;
																			}
																		}
																}
															}
															
															// data not insert proper in case of round trips i need to talk to sabir sir
															// foreach($segmentArray as $sgvl){
															// 	$SelectedBag__[$sgvl] = $SelectedBag[$sgvl][$pk];
															// 	$SelectedMeal__[$sgvl] = $SelectedMeal[$sgvl][$pk];
															// 	$SelectedSeat__[$sgvl] = $SelectedSeat[$sgvl][$pk];
															// }
															$customerpnr[$pk]['PNR_Number'] = implode('-', $pnrDetails);
															$customerpnr[$pk]['TicketId'] = implode('-', $TicketNumber);
															$customerpnr[$pk]['TicketNumber'] = implode('-', $TicketId);
															$customerpnr[$pk]['sectors'] = implode('@@', $segmentArray);
															// $customerpnr[$pk]['SelectedBag'] = !empty($SelectedBag) ? json_encode($SelectedBag) :'';
															// $customerpnr[$pk]['SelectedMeal'] = !empty($SelectedMeal) ? json_encode($SelectedMeal) :'';
															// $customerpnr[$pk]['BagPrice'] = !empty($BagPrice_c) ? ($BagPrice_c) :0;
															// $customerpnr[$pk]['MealPrice'] = !empty($MealPrice_c) ? ($MealPrice_c) :0;
															// $customerpnr[$pk]['SelectedSeat'] = !empty($SelectedSeat) ? json_encode($SelectedSeat) :'';
															// $customerpnr[$pk]['SeatPrice'] = !empty($SeatPrice_c) ? ($SeatPrice_c) :0;
															
															if($isgstapply == 1){
																$customerpnr[$pk]['isgstapply'] = !empty($isgstapply) ? ($isgstapply) :0;
															}
															
														}
													}
												}
												
												$objFlight = new Travel_Model_FlightMaster();
												// echo "ResponseStatus ($response)";die;
												if ($ResponseStatus == 1) {
													if (!empty($Invoicedata)) {
														// Create GTX Invoice
														$Invoiceresponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->InvoiceCreate($Invoicedata, $BookingData);
													}
													$update = array(
														'API_Response' => json_encode($value),
														'API_Response_Ticket' => json_encode($response),
														'FlightQueryids' => json_encode($FlightQueryids),
														'PNR_Number' => implode('-', $finalpnr),
														'BookingId' => $bookingId,
														'InvoiceNo' => isset($Invoiceresponse['InvoiceNumber']) ? $Invoiceresponse['InvoiceNumber'] : '',
														'status' => 1,
														'TPSysId' => $TPSysId,
													);
													$update['PublishedFare'] = isset($value['FairRules']['PublishedFare']) ? $value['FairRules']['PublishedFare'] : 0;
													$update['BaseFare'] = isset($value['FairRules']['BaseFare']) ? $value['FairRules']['BaseFare'] : 0;
													$update['Tax'] = !empty($value['FairRules']['Tax']) ? $value['FairRules']['Tax'] : 0;
													$update['YQTax'] = !empty($value['FairRules']['YQTax']) ? $value['FairRules']['YQTax'] : 0;
													$update['OtherCharges'] = !empty($value['FairRules']['OtherCharges']) ? $value['FairRules']['OtherCharges'] : 0;
													$update['Discount'] = !empty($value['FairRules']['Discount']) ? $value['FairRules']['Discount'] : 0;
													$update['ServiceFee'] = !empty($value['FairRules']['ServiceFee']) ? $value['FairRules']['ServiceFee'] : 0;
													$update['OfferedFare'] = isset($value['FairRules']['PublishedFare']) ? $value['FairRules']['PublishedFare'] : 0;
													if($ICSourceSysId == 16){
														$strBookingIdLCC = isset($response['order']['BookingTrackId']) ? $response['order']['BookingTrackId'] : '0';

														$update['APIBookingId'] = $strBookingIdLCC;
														$update['PNR_Number'] = $finalpnr;
													}
													$where = "id = " . $flight_booking_id[$k]; //exit;
													// echo "where<pre>";print_r($where);die;
													$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
													// if ($interNationalSearch == 1 && $route == 2 && $IsSeriesFareData==1) {
													// 	$where1 = "id = " . $flight_booking_id[1]; //exit;
													// 	$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where1);
													// }
													if ($OrderBookingStatus == 'PENDING') {
														$value['OnwardAutoTicket'] = 0;
													}
													try {
														$responseArray = array(
															'value' => $value,
															'response' => $response
														);
														if($ICSourceSysId == 17 || $ICSourceSysId == 16 || $ICSourceSysId == 7 || $ICSourceSysId == 3 || $ICSourceSysId == 11){
															if($ICSourceSysId == 16 && $interNationalSearch == 1 && $route == 2){
																$finalpnr = [$strTicketPNRLCC];
															}
															$postFieldArray = array(
																'PublishedFare' => ($PublishedFareINT + $BaggFare + $MealFare + $SeatFare),
																'Cost' => ($BaseAmountINT), /// without Markup,gst. with ssr
																'MasterTPSysId' => $MasterTPSysId,
																'TPSysId' => $TPSysId,
																'TrxId' => $TrxId,
																'VersionId' => $VersionId[$k],
																'PNRNumber' => !empty($finalpnr) ? implode('-', $finalpnr) : '',
																'GDSPNRNumber' => !empty($GDSpnr) ? implode('-', $GDSpnr) :'',
																'customerpnr' => $customerpnr,
																'Keys' => $k,
																'ErrorCode' => 0,
																'IsBookingStatus' => 1,
																'OnwardAutoTicket' => ($OrderBookingStatus == 'PENDING')?0:1,
																'sectorTitle' => $value['SourceAirportCode'] . '-' . $value['DestAirportCode'],
																'BookingId' => $bookingId,
																'APIBookingId' => $strBookingIdLCC,
																'IsWebsite' => 0,
															);
															if ($isgstapply == 1) {
																$postFieldArray['gstData'] = json_encode($gstData);
															}
														}else{
															$postFieldArray = array(
																'MasterTPSysId' => $MasterTPSysId,
																'TPSysId' => $TPSysId,
																'TrxId' => $TrxId,
																'VersionId' => $VersionId[$k],
																'XRefBookingId' => $bookingId,
																'APIBookingRes' => json_encode($responseArray),
																'FareSummaryAir' => json_encode($FareSummary),
																'UpdateFare' => json_encode([$UpdateFare[$k]]),
																'Keys' => $k,
																'Passenger' => json_encode($Passenger),
																'gstData' => json_encode($gstData),
																'ErrorCode' => 0,
																'IsBookingStatus' => 1,
															);
														}
														if ($k == 0 && $IsCancellationProtection == 1) {
															$postFieldArray['CancellationProtectionData'] = $CancellationProtectionDataCode;
														}
														
														
														$strFilePath = "flight/updateFlightBookingDetails/" . time() . "_update_request.json";
														Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $postFieldArray);
														// echo "postFieldArray<pre>";print_r(json_encode($postFieldArray));die;
														$model = new Gtxwebservices_Model_Webservices();

														if($ICSourceSysId == 17 || $ICSourceSysId == 16 || $ICSourceSysId == 7 || $ICSourceSysId == 3 || $ICSourceSysId == 11) {
															$result = json_decode($model->UPDATE_FLIGHT_BOOKING($postFieldArray),true);
														}else{
															$result = json_decode($model->updateFlightBookingDetails($postFieldArray), true);
														}
														
														//
														$AirlineName = $value['AirlineName'];
														$TotalFlightMembers = $value['TotalFlightMembers'];
														$JourneyType = $value['JourneyType'];
														$SourceAirportCode = $value['SourceAirportCode'];
														$DestAirportCode = $value['DestAirportCode'];
														$ResponseStatusPush = isset($result['apistatus']) ? $result['apistatus'] : 0;
														$ErrorMessage = isset($result['message']) ? $result['message'] : '';
														$logParams = [
															"user_id"      => 1,
															"AgencySysId"      => $this->gtxagencysysid,
															"custom_error" => ($ResponseStatusPush == 1) ? "Flight GTX Update Success" : "Flight GTX Update Failed",
															'error'        => $ErrorMessage,
															"text_udf"     => ['response' => $result], // Response
															"char_udf"     => ['request' => $postFieldArray], // Request
															"udf1"         => $SearchFlightTraceId,
															"udf5"                         => 'ticket',
															"from_destination"             => $SourceAirportCode,
															"to_destination"               => $DestAirportCode,
															"flight_type"                  => (int)$JourneyType,
															"source"                       => 1,
															"Pax"                          => ($TotalFlightMembers),
															"Supplier"                     => 'TRIPJACK',
															"Airline"                      => $AirlineName,
															"status"       => ($ResponseStatusPush == 1) ? 2 : 1,
														];
														Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
													} catch (Exception $error) {
													}
													if (!empty($booking_customer_id) && $ICSourceSysId == 16 && $route == 2) {
														foreach ($booking_customer_id[$k] as  $keyCust => $customerId) {
															if($k == 0){
																$customerKey = $keyCust;
															}
															if($k == 1){
																$customerKey = $keyCust + (count($booking_customer_id[0]));
															}
															$TicketId = implode('-', $Passenger[$customerKey]['pnrDetails']);
															$TicketNumber = isset($Passenger[$customerKey]['ticketNumberDetails']) ? implode('-', $Passenger[$customerKey]['ticketNumberDetails']) : '';
															$gdsPnrs = (isset($Passenger[$customerKey]['gdsPnrs']) && !empty($Passenger[$customerKey]['gdsPnrs'])) ? implode('-', $Passenger[$customerKey]['gdsPnrs']) : '';
															$updatep = array(
																'PNR_Number' => !empty($gdsPnrs) ? $gdsPnrs : $TicketId,
																'TicketId' => $TicketId,
																'TicketNumber' => $TicketNumber,
																'sectors' => implode('-', $segment),
																'BookingId' => $bookingId,
															);
															$updatep['APIBookingId'] = $strBookingIdLCC;
															$wherep = "id = " . $customerId;
															$objFlight->UpdateFlightData('tbl_flight_booking_customer', $updatep, $wherep);
														}
													}else{
														if ($Passenger) {
															foreach ($Passenger as $pk => $pax) {
																$TicketId = implode('-', $pax['pnrDetails']);
																$TicketNumber = isset($pax['ticketNumberDetails']) ? implode('-', $pax['ticketNumberDetails']) : '';
																$gdsPnrs = (isset($pax['gdsPnrs']) && !empty($pax['gdsPnrs'])) ? implode('-', $pax['gdsPnrs']) : '';
																$updatep = array(
																	'PNR_Number' => !empty($gdsPnrs) ? $gdsPnrs : $TicketId,
																	'TicketId' => $TicketId,
																	'TicketNumber' => $TicketNumber,
																	'sectors' => implode('-', $segment),
																	'BookingId' => $bookingId,
																);
																if($ICSourceSysId == 16){
																	$updatep['APIBookingId'] = $strBookingIdLCC;
																}
																
																// if($ICSourceSysId == 16 && $route == 2) {
																// 	echo "updatep<pre>";print_r($updatep);
																// 	$booking_customer_id__ = array_merge($booking_customer_id[0],$booking_customer_id[1]);
																// 	$wherep = "id = " . $booking_customer_id__[$pk];
																// 	$objFlight->UpdateFlightData('tbl_flight_booking_customer', $updatep, $wherep);
																// }else{
																	$wherep = "id = " . $booking_customer_id[0][$pk];
																	$objFlight->UpdateFlightData('tbl_flight_booking_customer', $updatep, $wherep);
																// }
															}
														}
													}
													
													if ($updated) {
														$responseReturn[] = array('success' => true, 'message' => $ErrorMessage, 'IsLCC' => $value['IsLCC']);
													}
												} else {
													$update = array(
														'API_Response' => json_encode($response),
														'API_Response_Ticket' => '',
													);
													$where = "id = " . $flight_booking_id[$k]; //exit;
													$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
													$responseReturn[] = array('success' => false, 'message' => $ErrorMessage, 'IsLCC' => $value['IsLCC']);
												}
											}
											// echo "responseReturn<pre>";print_r($responseReturn);
											// echo "ResponseStatus<pre>";print_r($ResponseStatus);
											
											// die;
											// die("ttttttt");
											if ($responseReturn && $ResponseStatus == 1) {
												$arrUrlData['FlightBookingTicketArr'] = $FlightBookingTicketArr;
												$insertArr = array(
													'TraceId' => $traceId,
													'json_data' => json_encode($arrUrlData),
													'created_at' => date('Y-m-d H:i:s'),
												);
												$this->objMdl->rv_delete('tbl_temp_data', array('TraceId = ?' => $traceId));
												$objFlight = new Travel_Model_FlightMaster();
												$objFlight->InsertFlightData('tbl_temp_data', $insertArr);
												//                Zend_Session::namespaceUnset('FlightBookingTicketSession');
												$FlightBookingTicketSession = new Zend_Session_Namespace('FlightBookingTicketSession');
												$FlightBookingTicketSession->params = $FlightBookingTicketArr;
												$Return = array('success' => true, 'message' => 'done', 'IsLCC' => $IsLCC,'ICSourceSysId'=>$ICSourceSysId,'TPSysId'=>$TPSysId);
												echo json_encode($Return);
												exit;
											} else {
												$Return = array('success' => false, 'message' => 'failed', 'IsLCC' => $IsLCC,'ICSourceSysId'=>$ICSourceSysId,'TPSysId'=>$TPSysId);
												echo json_encode($Return);
												exit;
											}
										}
									} else {
										$Destination = $SourceAirportCode . '-' . $DestAirportCode;
										$html = new Zend_View();
										$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
										$html->assign(array('ICSourceSysId' => $ICSourceSysId, 'Destination' => $Destination, 'traceId' => $traceId, 'agencyDetails' => $getAgencyData, 'CustomerSession' => $CustomerSession->params[0], 'baseUrl' => $this->baseUrl));
										$bodyText = $html->render('ErrorEmail.phtml');

										$subject = 'Booking ABORTED for ' . $Destination;
										$Caption = 'Booking ABORTED for ' . $Destination;
										$contactDetail_mail = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getContactDetailForFooter();
										$configs = [
											'to' => trim($CustomerSession->params[0]['EmailId']),
											'fromName' => $this->siteName,
											'fromEmail' => $getAgencyData['PrimaryEmail'],
											'subject' => $subject,
											'bodyHtml' => $bodyText,
										];
										$configsAg = [
											'to' => trim($getAgencyData['PrimaryEmail']),
											'fromName' => $this->siteName,
											'fromEmail' => $getAgencyData['PrimaryEmail'],
											'subject' => $subject,
											'bodyHtml' => $bodyText,
										];

										$ddd = $this->objHelperGeneral->mailSentByElastice($configs, $Caption);
										$sss = $this->objHelperGeneral->mailSentByElastice($configsAg, $Caption);
										$postFieldArray = array(
											'MasterTPSysId' => $MasterTPSysId,
											'TPSysId' => $TPSysId,
											'TrxId' => $TrxId,
											'ErrorCode' => 0,
											'IsBookingStatus' => 124,
											'updatePnr' => 1
										);
										$model = new Gtxwebservices_Model_Webservices();
										$result = $model->updateFlightAbortedgB2B($postFieldArray);
									}
								} else {
									$DebitFromWallet = array(
										'Remark' => 'Refund',
										'Amount' => $PublishedFareWallet,
										'CustomerSysId' => $this->_session->session['CustomerSysId'],
										'CurrencyType' => 1,
										'PlanType' => 1,
										'PaymentMode' => 'Wallet Refund',
										'ReferenceNo' => $TPSysId,
									);

									if ($paymentMode == 1 && $this->_session->session['CustomerSysId'] && $UserWalletStatus == 1) {
										$Url = $this->gtxBtoBsite . 'gtxwebservices/customer-wallet/add-b2c-wallet-balance/';
										Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->DebitFromWallet($DebitFromWallet, $Url);
									}
									if ($usewallet == 1 && $paymentMode == 2 && $this->_session->session['CustomerSysId'] && $UserWalletStatus == 1) {
										$Url = $this->gtxBtoBsite . 'gtxwebservices/customer-wallet/add-b2c-wallet-balance/';
										Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->DebitFromWallet($DebitFromWallet, $Url);
									}
									$Destination = $SourceAirportCode . '-' . $DestAirportCode;
									$html = new Zend_View();
									$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
									$html->assign(array('ICSourceSysId' => $ICSourceSysId, 'Destination' => $Destination, 'traceId' => $traceId, 'agencyDetails' => $getAgencyData, 'getSupportContact' => $getSupportContact, 'CustomerSession' => $CustomerSession->params[0], 'baseUrl' => $this->baseUrl));
									$bodyText = $html->render('ErrorEmail.phtml');

									$subject = 'Booking Failed for ' . $Destination;
									$Caption = 'Booking Failed for ' . $Destination;

									$configs = [
										'to' => trim($CustomerSession->params[0]['EmailId']),
										'fromName' => $this->siteName,
										'fromEmail' => $getAgencyData['PrimaryEmail'],
										'subject' => $subject,
										'bodyHtml' => $bodyText,
									];
									$configsAg = [
										'to' => trim($MasterPrimaryEmailTo),
										'fromName' => $this->siteName,
										'fromEmail' => $getAgencyData['PrimaryEmail'],
										'subject' => $subject,
										'bodyHtml' => $bodyText,
									];

									$ddd = $this->objHelperGeneral->mailSentByElastice($configs, $Caption);
									$sss = $this->objHelperGeneral->mailSentByElastice($configsAg, $Caption);

									if ($BookingData) {
										foreach ($BookingData as $k => $value) {
											$update = array(
												'status' => 3,
												'TPSysId' => $TPSysId,
												'API_Response_Ticket' => json_encode($Bookres),
											);
											$where = "id = " . $flight_booking_id[$k]; //exit;
											$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);

											try {
												// $postFieldArray = array(
												// 	'MasterTPSysId' => $MasterTPSysId,
												// 	'TPSysId' => $TPSysId,
												// 	'TrxId' => $TrxId,
												// 	'VersionId' => $VersionId[$k],
												// 	'ErrorCode' => 6,
												// 	'field' => 'BookingStatus',
												// 	'StatusCode' => 144,
												// 	'XRefBookingId' => '',
												// 	'APIBookingRes' => '',
												// );

												// $model = new Gtxwebservices_Model_Webservices();
												// $result = $model->updateFlightPaymentFailed($postFieldArray);

												$postFieldArray = array(
													'MasterTPSysId' => $MasterTPSysId,
													'TPSysId' => $TPSysId,
													'TrxId' => $TrxId,
													'ErrorCode' => 0,
													'IsBookingStatus' => 124,
													'updatePnr' => 1
												);
												$postFieldArray['field'] = 'BookingStatus';
												$postFieldArray['StatusCode'] = 144;
												$model = new Gtxwebservices_Model_Webservices();
												$result = $model->updateFlightPaymentFailed($postFieldArray);
												// echo "<pre>";print_r($result);die('ddd');
											} catch (Exception $error) {
											}
										}
									}
									$Return = array('success' => false, 'message' => $BookErrorMessage, 'IsLCC' => $IsLCC,'ICSourceSysId'=>$ICSourceSysId,'TPSysId'=>$TPSysId);
									echo json_encode($Return);
									exit;
								}
							} else { /// TBO booking code
								// jytupdate 8 virsion commect code
								// $sourceCityText = (isset($sessionFlightSearchParams->params['sourceCityText']) && !empty($sessionFlightSearchParams->params['sourceCityText'])) ? explode(',', $sessionFlightSearchParams->params['sourceCityText']) :'';
								// $destinationCityText = (isset($sessionFlightSearchParams->params['destinationCityText']) && !empty($sessionFlightSearchParams->params['destinationCityText'])) ? explode(',', $sessionFlightSearchParams->params['destinationCityText']) :'';
								// $mytrip_city_from = isset($sourceCityText[0]) ? $sourceCityText[0] :'';
								// $mytrip_city_to = isset($destinationCityText[0]) ? $destinationCityText[0] :'';
								// if ($route == 1) {
								// 	$sectorTitle = $mytrip_city_from . '-' . $mytrip_city_to;
								// } else {
								// 	$sectorTitle = $mytrip_city_from . '-' . $mytrip_city_to . '-' . $mytrip_city_from;
								// }

								$param = $this->getRequest()->getParams();
								//$checkBooking = $CheckPaymentSTatus;
								//echo"<pre>";print_r($flight_booking_id);
								

								if ($BookingData) {
									foreach ($BookingData as $k => $value) {
										
										$checkBooking = $objFlight->getbookingbyId('tbl_flight_booking', $flight_booking_id[$k]);
										$Bookingstatus = isset($checkBooking['status']) ? $checkBooking['status'] : 0;
										$BookedStatus = isset($checkBooking['BookedStatus']) ? $checkBooking['BookedStatus'] : 0;
										$API_Response_Ticket = isset($checkBooking['API_Response_Ticket']) ? json_decode($checkBooking['API_Response_Ticket'], true) : 0;
										//
										$selectedSeat = [];
										$segment = [];
										if ($value['Segments']) {
											foreach ($value['Segments'] as $seg) {
												$selectedSeat[$seg['segmentid']] = isset($selectedSeatSession->params[$seg['segmentid']]) ? $selectedSeatSession->params[$seg['segmentid']] : '';
												$originAirportCode = $seg['originAirportCode'];
												$destinationAirportCode = $seg['destinationAirportCode'];
												$segment[] = $originAirportCode . '-' . $destinationAirportCode;
											}
										}

										$BookingdataAPI = array(
											'FlightBookingData' => $value,
											'sessionFlightSearchParams' => $sessionFlightSearchParams->params,
											'CustomerSession' => $CustomerSession->params,
											'customer' => $customer,
											'SelectedMealSessionNew' => $SelectedMealSessionNew->params,
											'SelectedBaggSessionNew' => $SelectedBaggSessionNew->params,
											'SelectedMealSessionNewInb' => $SelectedMealSessionNewInb->params,
											'SelectedBaggSessionNewInb' => $SelectedBaggSessionNewInb->params,
											'selectedSeatSession' => $selectedSeat,
											'selectedSeatSessionInb' => [],
											'flightSSRDetails' => [],
											'flightSSRDetailsInb' => [],
											'getAgencyData' => $getAgencyData,
											'arrAgencyUserDetail' => $arrAgencyUserDetail,
										);
										
										
										$GTXMarkUp = 0;
										$PublishedFare = 0;
										$BaseAmount = 0;
										$intNetPublishedFare = 0;
										$AgencyMarkUp = 0;
										$AgencyMarkUpGST = 0;
										$AgentCommisionEarned = 0;
										$AgentCommisionEarnedGST = 0;
										$intTotalOtherCharge = 0;
										$intTaxAllPax = 0;
										$intBaseFareAllPax = 0;
										$couponApply = isset($value['FairRules']['couponApply']) ? $value['FairRules']['couponApply']:0;
										if ($couponApply == 1 || $couponApply == '1') {
											$couponVal = isset($value['FairRules']['couponVal']) ? $value['FairRules']['couponVal'] : 0;
										} else {
											$couponVal = 0;
										}
										if ($value['FairRules']['FareBreakdown']) {
											foreach ($value['FairRules']['FareBreakdown'] as $valuees) {
												$Tax = isset($valuees['Tax']) ? $valuees['Tax'] :0;
												$TDS = isset($valuees['TDS']) ? $valuees['TDS']:0;
												$FixedMarkUp = isset($valuees['FixedMarkUp']) ? $valuees['FixedMarkUp']:0;
												$GSTOnMarkUp = isset($valuees['GSTOnMarkUp']) ? $valuees['GSTOnMarkUp']:0;
												$OtherCharges = isset($valuees['OtherCharges']) ? $valuees['OtherCharges']:0;
												$CommissionEarned = isset($valuees['CommissionEarned']) ? $valuees['CommissionEarned']:0;
												$intCommisionEarnedForAgency = isset($valuees['intCommisionEarnedForAgency']) ? $valuees['intCommisionEarnedForAgency']:0;
												$intPLBEarnedForAgency = isset($valuees['intPLBEarnedForAgency']) ? $valuees['intPLBEarnedForAgency']:0;
												$intIncentiveEarnedForAgency = isset($valuees['intIncentiveEarnedForAgency']) ? $valuees['intIncentiveEarnedForAgency']:0;

												$BaseFare = isset($valuees['BaseFare']) ? ($valuees['BaseFare'] + $OtherCharges) :0;
												$AgentCommisionEarned += ($intCommisionEarnedForAgency + $intPLBEarnedForAgency + $intIncentiveEarnedForAgency);
												$GTXMarkUp += isset($valuees['intGTXMarkUp']) ? $valuees['intGTXMarkUp']:0;
												$intTotalOtherCharge += isset($valuees['OtherCharges']) ? $valuees['OtherCharges']:0;
												//$BaseAmount += ($BaseFare);
												$intBaseFareAllPax += isset($BaseFare) ? $BaseFare:0;
												$intTaxAllPax += isset($Tax) ? $Tax :0;
												$AgencyMarkUp += isset($FixedMarkUp) ? $FixedMarkUp :0;
												$AgencyMarkUpGST += isset($GSTOnMarkUp) ? $GSTOnMarkUp :0;
												$PublishedFare += ($BaseFare + $FixedMarkUp + $GSTOnMarkUp + $OtherCharges + $Tax + $intCommisionEarnedForAgency + $intPLBEarnedForAgency + $intIncentiveEarnedForAgency);


												$Tax = isset($valuees['Tax']) ? $valuees['Tax']:0;
												$TDS = isset($valuees['TDS']) ? $valuees['TDS']:0;
												$TDSEarn = isset($valuees['TDSEarn']) ? $valuees['TDSEarn']:0;
												$FixedMarkUp = isset($valuees['FixedMarkUp']) ? $valuees['FixedMarkUp']:0;
												$GSTOnMarkUp = isset($valuees['GSTOnMarkUp']) ? $valuees['GSTOnMarkUp']:0;
												$OtherCharges = isset($valuees['OtherCharges']) ? $valuees['OtherCharges']:0;
												$ServiceFee = isset($valuees['ServiceFee']) ? $valuees['ServiceFee']:0;
												$CommisionPass = isset($valuees['CommisionPass'])? $valuees['CommisionPass']:0;
												$CommissionEarned = isset($valuees['CommissionEarned']) ? $valuees['CommissionEarned']:0;
												$intCommisionEarnedForAgency = isset($valuees['intCommisionEarnedForAgency']) ? $valuees['intCommisionEarnedForAgency']:0;
												$intPLBEarnedForAgency = isset($valuees['intPLBEarnedForAgency']) ? $valuees['intPLBEarnedForAgency']:0;
												$intIncentiveEarnedForAgency = isset($valuees['intIncentiveEarnedForAgency']) ? $valuees['intIncentiveEarnedForAgency']:0;
												// $BaseFare_ = ($valuees['BaseFare'] + $OtherCharges + $Tax + $intCommisionEarnedForAgency + $intPLBEarnedForAgency + $intIncentiveEarnedForAgency);
												$BaseFare_ = ($valuees['BaseFare'] + $OtherCharges + $Tax + $ServiceFee);
												$BaseAmount += ($valuees['BaseFare'] + $OtherCharges + $Tax + $ServiceFee - $CommisionPass);

												$intNetPublishedFare += ($valuees['BaseFare'] + $Tax + $FixedMarkUp + $GSTOnMarkUp + $TDSEarn + $CommissionEarned);
											}
										}
										$BaseAmount = ($BaseAmount - $couponVal);
										$intNetPublishedFare = ($intNetPublishedFare - $couponVal);
										
										if ($value['IsLCC'] == 1) {
											if ($BookedStatus == 0) {
												if ($route == 3 && $k == 0) {
													$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightTicket($BookingdataAPI, $k);
												} elseif ($route == 3) {
													$apiFlightTicketTBO = new Zend_Session_Namespace('apiFlightTicketTBO');
													$response = $apiFlightTicketTBO->params;
												}
												if ($route == 1 || $route == 2) {
													$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightTicket($BookingdataAPI, $k);
												}
											} else {
												$response = $API_Response_Ticket;
											}
										} else {
											$apiTraceId = isset($API_Response_Ticket['Response']['TraceId']) ? $API_Response_Ticket['Response']['TraceId'] : '0';
											$strBookingIdLCC = isset($API_Response_Ticket['Response']['Response']['BookingId']) ? $API_Response_Ticket['Response']['Response']['BookingId'] : '';
											$strTicketPNRLCC = isset($API_Response_Ticket['Response']['Response']['PNR']) ? $API_Response_Ticket['Response']['Response']['PNR'] : '';

											
											$dataTicket = [
												"TraceId" => $apiTraceId,
												"PNR" => $strTicketPNRLCC,
												"BookingId" => $strBookingIdLCC,
												"FlightBookingData" => $value,
											];

											if ($route == 3 && $k == 0) {
												$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->generateNonLccTicket($dataTicket);
											} elseif ($route == 3) {
												$FlightBookingTicketSession = new Zend_Session_Namespace('FlightBookingTicketSession');
												$response = $FlightBookingTicketSession->params;
											}
											if ($route == 1 || $route == 2) {
												$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->generateNonLccTicket($dataTicket);
												// $FlightBookingTicketSession = new Zend_Session_Namespace('FlightBookingTicketSession');
												// $response = $FlightBookingTicketSession->params;
											}
											$IsPriceChanged = isset($response['Response']['Response']['IsPriceChanged']) ? $response['Response']['Response']['IsPriceChanged'] : false;
											if($IsPriceChanged == 1){
												$dataTicket = [
													"TraceId" => $apiTraceId,
													"PNR" => $strTicketPNRLCC,
													"BookingId" => $strBookingIdLCC,
													"IsPriceChangeAccepted" => true,
													"FlightBookingData" => $value
												];
												$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->generateNonLccTicket($dataTicket);
											}
											
											//$IsLCC = true;
											//$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightBooking($BookingdataAPI, $k);
										}
										// jyt comment
										
										if ($k == 0) {
											$MealSelected = $SelectedMealSessionNew->params;
											$BaggSelected = $SelectedBaggSessionNew->params;
										} else {
											$MealSelected = $SelectedMealSessionNewInb->params;
											$BaggSelected = $SelectedBaggSessionNewInb->params;
										}

										$BagPrice = 0;
										$InbBagPrice = 0;
										$MealPrice = 0;
										$InbMealPrice = 0;
										$SeatPrice = 0;
										if ($BaggSelected) {
											foreach ($BaggSelected as $values) {
												$BagPrice += $values['Price'];
											}
										}
										if ($MealSelected) {
											foreach ($MealSelected as $values) {
												$MealPrice += $values['Price'];
											}
										}
										if ($selectedSeat) {
											foreach ($selectedSeat as $val) {
												foreach ($val as $values) {
													$SeatPrice += $values['Price'];
												}
											}
										}

										$MealFare = ($MealPrice + $InbMealPrice);
										$BaggFare = ($BagPrice + $InbBagPrice);

										$FlightBookingTicketArr[] = $response;
										$ResponseStatus = isset($response['Response']['ResponseStatus']) ? $response['Response']['ResponseStatus'] : '0';
										$apiTraceId = isset($response['Response']['TraceId']) ? $response['Response']['TraceId'] : '0';
										$ErrorCode = isset($response['Response']['Error']['ErrorCode']) ? $response['Response']['Error']['ErrorCode'] : '0';
										$ErrorMessage = isset($response['Response']['Error']['ErrorMessage']) ? $response['Response']['Error']['ErrorMessage'] : '';
										$strBookingIdLCC = isset($response['Response']['Response']['BookingId']) ? $response['Response']['Response']['BookingId'] : '';
										$strTicketPNRLCC = isset($response['Response']['Response']['PNR']) ? $response['Response']['Response']['PNR'] : '';
										$Passenger = isset($response['Response']['Response']['FlightItinerary']['Passenger']) ? $response['Response']['Response']['FlightItinerary']['Passenger'] : '';
										$SegmentsAPI = isset($response['Response']['Response']['FlightItinerary']['Segments']) ? $response['Response']['Response']['FlightItinerary']['Segments'] : '';
										$GTXMarkUpGST = 0;
										$UpdateFare[$k] = array(
											'Price' => ($BaseAmount * $this->CurrencyRate),
											'NetPrice' => ($intNetPublishedFare * $this->CurrencyRate),
											'AgencyMarkUp' => $AgencyMarkUp,
											'AgentServiceTaxAmount' => $AgencyMarkUpGST,
											'MarkUp' => $AgentCommisionEarned,
											'AgentsCustomServiceTaxAmount' => $AgentCommisionEarnedGST,
											'GTXMarkup' => $GTXMarkUp,
											'GTXServiceTaxAmount' => $GTXMarkUpGST,
											'TotalCost' => $intNetPublishedFare,
											'MealFare' => $MealFare,
											'BaggFare' => $BaggFare,
											'SeatPrice' => $SeatPrice,
										);
										
										$FareSummaryAir = array(
											'PublishedFare' => round(($intNetPublishedFare + $MealFare + $BaggFare + $SeatPrice) * $this->CurrencyRate, 2),
											'AgentCommisionEarned' => round($AgentCommisionEarned * $this->CurrencyRate, 2),
											'AgentCommisionEarnedGST' => round($AgentCommisionEarnedGST * $this->CurrencyRate, 2),
											'AgencyMarkUp' => round($AgencyMarkUp * $this->CurrencyRate, 2),
											'AgencyMarkUpGST' => round($AgencyMarkUpGST * $this->CurrencyRate, 2),
											'GTXMarkUp' => round($GTXMarkUp * $this->CurrencyRate, 2),
											'BaseAmount' => round(($BaseAmount + $MealFare + $BaggFare + $SeatPrice) * $this->CurrencyRate, 2),
										);
										$objFlight = new Travel_Model_FlightMaster();
										if ($ResponseStatus == 1) {
											
											$customerpnr = [];
											$GDSpnr = [];
											if ($Passenger) {
												$PNR_Number = [];
												$kkkk = 0;
												foreach($segment as $sgvl){
													$PNR_Number[] = $strTicketPNRLCC;
													if((isset($SegmentsAPI[$kkkk]['AirlinePNR']) && !empty($SegmentsAPI[$kkkk]['AirlinePNR']))){
														$GDSpnr[] = (isset($SegmentsAPI[$kkkk]['AirlinePNR']) && !empty($SegmentsAPI[$kkkk]['AirlinePNR']))?$SegmentsAPI[$kkkk]['AirlinePNR']:'';
													}
													$kkkk++;
												}
												foreach ($Passenger as $pk => $pax) {
													$PaxType = $pax['PaxType'];
													$TicketId = $pax['Ticket']['TicketId'];
													$TicketNumber = [];
													$TicketId = [];
													$ValidatingAirline = (isset($pax['Ticket']['ValidatingAirline']) && !empty($pax['Ticket']['ValidatingAirline']))?$pax['Ticket']['ValidatingAirline']:'';
													foreach($segment as $sgvl){
														$TicketNumber[] = $pax['Ticket']['TicketNumber'];
														$TicketId[] = $pax['Ticket']['TicketId'];
													}
													$customerpnr[$pk]['PNR_Number'] = implode('-', $PNR_Number);
													$customerpnr[$pk]['TicketId'] = implode('-', $TicketNumber);
													$customerpnr[$pk]['TicketNumber'] = implode('-', $TicketId);
													$customerpnr[$pk]['sectors'] = implode('@@', $segment);
													$SelectedBag_ = [];
													$SelectedMeal_ = [];
													$SelectedSeat_ = [];
													$BagPrice_ = isset($pax['Fare']['TotalBaggageCharges'])?$pax['Fare']['TotalBaggageCharges']:0;
													$MealPrice_ = isset($pax['Fare']['TotalMealCharges'])?$pax['Fare']['TotalMealCharges']:0;
													$SeatPrice_ = isset($pax['Fare']['TotalSeatCharges'])?$pax['Fare']['TotalSeatCharges']:0;
													if(isset($pax['Baggage']) && !empty($pax['Baggage'])){
														foreach($pax['Baggage'] as $vall){
															$scs = $vall['Origin'].'-'.$vall['Destination'];
															$SelectedBag_[$scs][] = !empty($vall)?$vall:[];
														}
													}
													if(isset($pax['MealDynamic']) && !empty($pax['MealDynamic'])){
														foreach($pax['MealDynamic'] as $vall){
															$scs = $vall['Origin'].'-'.$vall['Destination'];
															$SelectedMeal_[$scs][] = !empty($vall)?$vall:[];
														}
													}
													if(isset($pax['SeatDynamic']) && !empty($pax['SeatDynamic'])){
														foreach($pax['SeatDynamic'] as $vall){
															$scs = $vall['Origin'].'-'.$vall['Destination'];
															$SelectedSeat_[$scs][] = !empty($vall)?$vall:[];
														}
													}
													
													// if($PaxType != 3){
													// 	$customerpnr[$pk]['SelectedBag'] = !empty($SelectedBag_) ? json_encode($SelectedBag_) :'';
													// 	$customerpnr[$pk]['SelectedMeal'] = !empty($SelectedMeal_) ? json_encode($SelectedMeal_) :'';
													// 	$customerpnr[$pk]['SelectedSeat'] = !empty($SelectedSeat_) ? json_encode($SelectedSeat_) :'';
													// 	$customerpnr[$pk]['BagPrice'] = !empty($BagPrice_) ? ($BagPrice_) :0;
													// 	$customerpnr[$pk]['MealPrice'] = !empty($MealPrice_) ? ($MealPrice_) :0;
													// 	$customerpnr[$pk]['SeatPrice'] = !empty($SeatPrice_) ? ($SeatPrice_) :0;
													// }
												}
											}
											// echo "<pre>route";print_r($customerpnr);
											// echo "<pre>";print_r($Invoicedata);
											// die();
											if (!empty($Invoicedata)) {
												// Create GTX Invoice
												$Invoiceresponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->InvoiceCreate($Invoicedata, $BookingData);
											}
											$this->genrateinvoice($strBookingIdLCC);
											$updateBB['BookedStatus'] = 1;
											$whereBB = "id = " . $flight_booking_id[$k]; //exit;
											$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $updateBB, $whereBB);
											$BookingId = $strBookingIdLCC . "/" . $strTicketPNRLCC;
											$update = array(
												'API_Response' => json_encode($value),
												'API_Response_Ticket' => json_encode($response),
												'FlightQueryids' => json_encode($FlightQueryids),
												'PNR_Number' => $strTicketPNRLCC,
												'BookingId' => $strBookingIdLCC,
												'InvoiceNo' => isset($Invoiceresponse['InvoiceNumber']) ? $Invoiceresponse['InvoiceNumber'] : '',
												'status' => 1,
												'TPSysId' => $TPSysId,
												'MealPrice' => $MealFare,
												'BagPrice' => $BaggFare,
												'SeatPrice' => $SeatPrice,
											);
											$update['BaseFare'] = $intBaseFareAllPax;
											$update['Tax'] = $intTaxAllPax;
											$update['OtherCharges'] = $intTotalOtherCharge;
											$update['AgentCommisionEarned'] = $AgentCommisionEarned;
											$update['AgentCommisionEarnedGST'] = $AgentCommisionEarnedGST;
											$update['AgencyMarkUp'] = $AgencyMarkUp;
											$update['AgencyMarkUpGST'] = $AgencyMarkUpGST;
											$update['GTXMarkUp'] = $GTXMarkUp;
											$update['GTXMarkUpGST'] = 0;
											$where = "id = " . $flight_booking_id[$k]; //exit;

											$Amount = round((($BaseAmount + $MealFare + $BaggFare + $SeatPrice) * $this->CurrencyRate), 2);
											$NetAmount = round((($intNetPublishedFare + $MealFare + $BaggFare + $SeatPrice) * $this->CurrencyRate), 2);
											$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);

											

											try {
												// $responseArray = array(
												// 	'value' => $value,
												// 	'response' => $response
												// );
												// $postFieldArray = array(
												// 	'MasterTPSysId' => $MasterTPSysId,
												// 	'TPSysId' => $TPSysId,
												// 	'TrxId' => $TrxId,
												// 	'FareBreakdownid' => json_encode($FareBreakdownid),
												// 	'VersionId' => $VersionId[$k],
												// 	'XRefBookingId' => $strBookingIdLCC,
												// 	'APIBookingId' => $strBookingIdLCC,
												// 	'APIBookingRes' => json_encode($responseArray),
												// 	'Passenger' => json_encode($Passenger),
												// 	//'UpdateFare' => json_encode($UpdateFare),
												// 	'UpdateFare' => json_encode([$UpdateFare[$k]]),
												// 	'Keys' => $k,
												// 	'gstData' => json_encode($gstData),
												// 	'ErrorCode' => 0,
												// 	'IsBookingStatus' => 1,
												// 	'sectorTitle' => $sectorTitle,
												// 	'Amount' => $Amount,
												// 	'NetAmount' => $NetAmount,
												// );

												$GDSpnr = array_values(array_unique($GDSpnr));
												
												$postFieldArray = array(
													'PublishedFare' => ($NetAmount),
													'Cost' => ($Amount), /// without Markup,gst. with ssr
													'MasterTPSysId' => $MasterTPSysId,
													'TPSysId' => $TPSysId,
													'TrxId' => $TrxId,
													'VersionId' => $VersionId[$k],
													'PNRNumber' => (!empty($GDSpnr) && $GDSpnr != $strTicketPNRLCC)?$strTicketPNRLCC.'-'.implode('-',$GDSpnr):$strTicketPNRLCC,
													'customerpnr' => $customerpnr,
													'Keys' => $k,
													'ErrorCode' => 0,
													'IsBookingStatus' => 1,
													'OnwardAutoTicket' => 1,
													'sectorTitle' => $value['SourceAirportCode'] . '-' . $value['DestAirportCode'],
													'BookingId' => $strBookingIdLCC,
													'APIBookingId' => $strBookingIdLCC,
													'IsWebsite' => 0,
												);

												if ($isgstapply == 1) {
													$postFieldArray['gstData'] = json_encode($gstData);
												}
												
												if ($k == 0) {
													// if ($couponApply == 1) {
													// 	$applyCoupon = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->applyCoupon($applyData);
													// }
													if ($couponApply == 1) {
														$applyCoupon = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->applyCoupon($applyData);
													}
													if ($IsCancellationProtection == 1) {
														$postFieldArray['CancellationProtectionData'] = $CancellationProtectionDataCode;
													}
												}

												$strFilePath = "flight/updateFlightBookingDetails/" . date('Y-m-d H:s:i') . "_update_request.json";
												Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($postFieldArray));

												$model = new Gtxwebservices_Model_Webservices();
												//$result = $model->updateFlightBookingDetailsTBO($postFieldArray, $this->gtxagencysysid);
												$result = $model->UPDATE_FLIGHT_BOOKING($postFieldArray);
												//
												// if ($this->gtxagencysysid == '31556') {
													// echo '<pre>';print_r($postFieldArray);
													// echo '<pre>';print_r($result);
												// }
												$strFilePath = "flight/updateFlightBookingDetails/" . date('Y-m-d H:s:i') . "_update_response.json";
												Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $result);
												$AirlineName = isset($value['AirlineName']) ? $value['AirlineName']:'';
												$TotalFlightMembers = isset($value['TotalFlightMembers']) ? $value['TotalFlightMembers']:0;
												$JourneyType = isset($value['JourneyType']) ? $value['JourneyType']:'';
												$SourceAirportCode = isset($value['SourceAirportCode']) ? $value['SourceAirportCode']:'';
												$DestAirportCode = isset($value['DestAirportCode']) ? $value['DestAirportCode']:'';
												$ResponseStatusPush = isset($result['status']) ? $result['status']:'';
												$ErrorMessage = isset($result['message']) ? $result['message']:'';
												$logParams = [
													"user_id"      => 1,
													"AgencySysId"      => $this->gtxagencysysid,
													"custom_error" => ($ResponseStatusPush == 1) ? "Flight GTX Update Success" : "Flight GTX Update Failed",
													'error'        => $ErrorMessage,
													"text_udf"     => ['response' => $result], // Response
													"char_udf"     => ['request' => $postFieldArray], // Request
													"udf1"         => $SearchFlightTraceId,
													"udf5"                         => 'ticket',
													"from_destination"             => $SourceAirportCode,
													"to_destination"               => $DestAirportCode,
													"flight_type"                  => (int)$JourneyType,
													"source"                       => 1,
													"Pax"                          => ($TotalFlightMembers),
													"Supplier"                     => 'TBO',
													"Airline"                      => $AirlineName,
													"status"       => ($ResponseStatusPush == 1) ? 2 : 1,
												];
												Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
												//$result = json_decode($result,1);
												//echo '<pre>';print_r($result);status
											} catch (Exception $error) {
												print_r($error->getMessage());
											}
											$PaxCount = count($Passenger);
											if ($Passenger) {
												foreach ($Passenger as $pk => $pax) {
													$customer = $CustomerSession->params[$pk];
													if ($pk == 0) {
														$CustomerSysId = $customer['CustomerSysId'];
													} else {
														$CustomerSysId = $customer['CustomerMemberSysId'];
													}
													$MealPrice = 0;
													$BaggagePrice = 0;
													if (isset($MealSelected[$CustomerSysId]) && !empty($MealSelected[$CustomerSysId])) {
														$MealPrice              = $MealSelected[$CustomerSysId]['Price'];
													}
													if (isset($BaggSelected[$CustomerSysId]) && !empty($BaggSelected[$CustomerSysId])) {
														$BaggagePrice              = $BaggSelected[$CustomerSysId]['Price'];
													}
													$TicketId = $pax['Ticket']['TicketId'];
													$TicketNumber = $pax['Ticket']['TicketNumber'];
													$updatep = array(
														'BookingId' => $strBookingIdLCC,
														'APIBookingId' => $strBookingIdLCC,
														'PNR_Number' => $strTicketPNRLCC,
														'TicketId' => $TicketId,
														'TicketNumber' => $TicketNumber,
														'sectors' => implode('-', $segment),
													);
													$updatep['BaseFare'] = ($intBaseFareAllPax / $PaxCount);
													$updatep['Tax'] = ($intTaxAllPax / $PaxCount);
													$updatep['OtherCharges'] = ($intTotalOtherCharge / $PaxCount);
													$updatep['AgentCommisionEarned'] = ($AgentCommisionEarned / $PaxCount);
													$updatep['AgentCommisionEarnedGST'] = ($AgentCommisionEarnedGST / $PaxCount);
													$updatep['AgencyMarkUp'] = ($AgencyMarkUp / $PaxCount);
													$updatep['AgencyMarkUpGST'] = ($AgencyMarkUpGST / $PaxCount);
													$updatep['GTXMarkUp'] = ($GTXMarkUp / $PaxCount);
													$updatep['GTXMarkUpGST'] = 0;
													$updatep['MealPrice'] = $MealPrice;
													$updatep['BaggagePrice'] = $BaggagePrice;
													if (isset($booking_customer_id[$k][$pk]) && !empty($booking_customer_id[$k][$pk])) {
														$wherep = "id = " . $booking_customer_id[$k][$pk];
														$objFlight->UpdateFlightData('tbl_flight_booking_customer', $updatep, $wherep);
													}
												}
											}
											if ($updated) {
												$responseReturn[] = array('success' => true, 'message' => $ErrorMessage, 'IsLCC' => $value['IsLCC']);
											}
										} else {

											$DebitFromWallet = array(
												'Remark' => 'Refund',
												'Amount' => ($intNetPublishedFare + $MealFare + $BaggFare + $SeatPrice),
												'CustomerSysId' => $this->_session->session['CustomerSysId'],
												'CurrencyType' => 1,
												'PlanType' => 1,
												'PaymentMode' => 'Wallet Refund',
												'ReferenceNo' => $TPSysId,
											);
											if ($paymentMode == 1 && $this->_session->session['CustomerSysId'] && $UserWalletStatus == 1) {
												$Url = $this->gtxBtoBsite . 'gtxwebservices/customer-wallet/add-b2c-wallet-balance/';
												Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->DebitFromWallet($DebitFromWallet, $Url);
											}
											if ($usewallet == 1 && $paymentMode == 2 && $this->_session->session['CustomerSysId'] && $UserWalletStatus == 1) {
												$Url = $this->gtxBtoBsite . 'gtxwebservices/customer-wallet/add-b2c-wallet-balance/';
												Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->DebitFromWallet($DebitFromWallet, $Url);
											}
											$Destination = $SourceAirportCode . '-' . $DestAirportCode;
											$html = new Zend_View();
											$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
											$html->assign(array('ICSourceSysId' => $ICSourceSysId, 'Destination' => $Destination, 'traceId' => $traceId, 'agencyDetails' => $getAgencyData, 'CustomerSession' => $CustomerSession->params[0], 'baseUrl' => $this->baseUrl));
											$bodyText = $html->render('ErrorEmail.phtml');

											$subject = 'Booking Failed for ' . $Destination;
											$Caption = 'Booking Failed for ' . $Destination;
											$contactDetail_mail = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getContactDetailForFooter();
											$configs = [
												'to' => trim($CustomerSession->params[0]['EmailId']),
												'fromName' => $this->siteName,
												'fromEmail' => $getAgencyData['PrimaryEmail'],
												'subject' => $subject,
												'bodyHtml' => $bodyText,
											];
											$configsAg = [
												'to' => trim($getAgencyData['PrimaryEmail']),
												'fromName' => $this->siteName,
												'fromEmail' => $getAgencyData['PrimaryEmail'],
												'subject' => $subject,
												'bodyHtml' => $bodyText,
											];

											$this->objHelperGeneral->mailSentByElastice($configs, $Caption);
											$this->objHelperGeneral->mailSentByElastice($configsAg, $Caption);
											$update = array(
												'API_Response' => json_encode($response),
												'API_Response_Ticket' => json_encode($response),
												'status' => 3,
											);
											$where = "id = " . $flight_booking_id[$k]; //exit;
											$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
											try {
												// $postFieldArray = array(
												// 	'MasterTPSysId' => $MasterTPSysId,
												// 	'TPSysId' => $TPSysId,
												// 	'TrxId' => $TrxId,
												// 	'VersionId' => $VersionId[$k],
												// 	'ErrorCode' => 6,
												// 	'field' => 'BookingStatus',
												// 	'StatusCode' => 141,
												// 	'XRefBookingId' => '',
												// 	'APIBookingRes' => '',
												// );

												// $model = new Gtxwebservices_Model_Webservices();
												// $result = $model->updateFlightPaymentFailed($postFieldArray);


												$postFieldArray = array(
													'MasterTPSysId' => $MasterTPSysId,
													'TPSysId' => $TPSysId,
													'TrxId' => $TrxId,
													'ErrorCode' => 0,
													'IsBookingStatus' => 124,
													'updatePnr' => 1
												);
												$postFieldArray['field'] = 'BookingStatus';
												$postFieldArray['StatusCode'] = 144;
												$model = new Gtxwebservices_Model_Webservices();
												$result = $model->updateFlightPaymentFailed($postFieldArray);
												// echo "<pre>";print_r($result);die('ddd');
											} catch (Exception $error) {
											}
											$responseReturn[] = array('success' => false, 'message' => $ErrorMessage, 'IsLCC' => $value['IsLCC']);
										}
									}
								}
							}
							if ($responseReturn) {

								$arrUrlData['responseReturn'] = $responseReturn;
								$arrUrlData['FlightBookingTicketArr'] = $FlightBookingTicketArr;
								$arrUrlData['applyCoupon'] = $applyCoupon;
								$insertArr = array(
									'TraceId' => $traceId,
									'json_data' => json_encode($arrUrlData),
									'created_at' => date('Y-m-d H:i:s'),
								);
								$this->objMdl->rv_delete('tbl_temp_data', array('TraceId = ?' => $traceId));
								$objFlight = new Travel_Model_FlightMaster();
								$objFlight->InsertFlightData('tbl_temp_data', $insertArr);

								$FlightBookingTicketSession = new Zend_Session_Namespace('FlightBookingTicketSession');
								$FlightBookingTicketSession->params = $FlightBookingTicketArr;
								$Return = array('success' => true, 'message' => 'done', 'IsLCC' => $IsLCC,'ICSourceSysId'=>$ICSourceSysId,'TPSysId'=>$TPSysId);
								echo json_encode($Return);
								exit;
							} else {
								$Return = array('success' => false, 'message' => 'failed', 'IsLCC' => $IsLCC,'ICSourceSysId'=>$ICSourceSysId,'TPSysId'=>$TPSysId);
								echo json_encode($Return);
								exit;
							}
						}
					} else {
						$this->_redirect('flight/add-onn-service/' . $param['traceId']);
					}
				} else {
					die('Please contact to administrator');
				}
			}
		}
	}

	public function bookingConfirmedAction()
	{
		$param = $this->getRequest()->getParams();
		// if($this->gtxagencysysid == '54779'){
		// 	ini_set('display_errors', 1);
		//     ini_set('display_startup_errors', 1);
		//     error_reporting(E_ALL);
		// }

		$FlightBookingTicketSession = new Zend_Session_Namespace('FlightBookingTicketSession');
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$CustomerSysIdSession = new Zend_Session_Namespace('CustomerSysIdSession');
		//$this->view->CustomerSession = $CustomerSession->params;
		$this->view->FlightBookingTicketSession = ($FlightBookingTicketSession->params[0]);
		$this->view->sessionFlightSearchParams = $sessionFlightSearchParams->params;
		$route = $sessionFlightSearchParams->params['route'];
		$interNationalSearch = $sessionFlightSearchParams->params['interNationalSearch'];
		$SearchFlightTraceId = $sessionFlightSearchParams->params['SearchFlightTraceId'];
		$SearchFlightTraceId = $TraceIdParam = (isset($param['TraceId']) && !empty($param['TraceId'])) ? $param['TraceId'] : $SearchFlightTraceId;
		$this->view->SearchFlightTraceId = $SearchFlightTraceId;
		$this->view->gtxagencysysid = $this->gtxagencysysid;
		$this->view->stylecss = $this->stylecss;
		$this->view->IsSeriesFareData = $this->IsSeriesFare;
		$objFlight = new Travel_Model_FlightMaster();
		$FlightBookingInb = [];
		$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $SearchFlightTraceId], ['id' => 'ASC']);
		$arrUrlData = json_decode($temp_data['json_data'], true);
		$ICSourceSysId = $arrUrlData['BookingData'][0]['ICSourceSysId'];
		$FlightBookingTicketArr = $arrUrlData['FlightBookingTicketArr'];
		$FlightBookingTicketSession->params = $FlightBookingTicketArr;
		if ($ICSourceSysId == 3 || $ICSourceSysId == 16) {
			$SearchFlightTraceId = $SearchFlightTraceId;
			if ($interNationalSearch == 1 && $route == 2) {
				$FlightBooking = $objFlight->FlightBookingDataTripJackNew('tbl_flight_booking', $SearchFlightTraceId, 2);
			} else {
				$FlightBooking = $objFlight->FlightBookingDataTripJackNew('tbl_flight_booking', $SearchFlightTraceId, 1);

				$FlightBookingInb = $objFlight->FlightBookingDataTripJackNew('tbl_flight_booking', $SearchFlightTraceId, 2);
			}

			$SearchFlightTraceId = isset($FlightBooking['data']['BookingId']) ? $FlightBooking['data']['BookingId'] : 0;
		} else {
			$SearchFlightTraceId = $FlightBookingTicketSession->params[0]['order']['bookingId'];
			if ($ICSourceSysId == 8) {
				$SearchFlightTraceId = $FlightBookingTicketSession->params[0]['order']['bookingId'][0];
			}
			$SearchFlightTraceId = str_replace('TJ', 'BKR', $SearchFlightTraceId);
			if ($interNationalSearch == 1 && $route == 2) {
				$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $SearchFlightTraceId, 2);
			} else {
				$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $SearchFlightTraceId, 1);

				$FlightBookingInb = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $SearchFlightTraceId, 2);
			}
		}
		$urlStatus = isset($param['status']) ? $param['status'] : false;
		

		$FlightBooking__ = $objFlight->FlightBookingDataNew('tbl_flight_booking', $SearchFlightTraceId);
		// echo '<pre>';print_r($SearchFlightTraceId);
		// echo '<pre>';print_r($param);
		// die;
		$requestPerameter = [];
		if ($FlightBooking__['data']) {
			$ARR_SALUTION = unserialize(ARR_SALUTION);
			$ARR_SALUTION_CHILD = unserialize(ARR_SALUTION_CHILD);
			$pax_full_name = [];
			$whatsappnumber = '';
			if ($FlightBooking__['passenger']) {
				foreach ($FlightBooking__['passenger'] as $passenger) {
					$Salutation = isset($passenger['Salutation']) ? $passenger['Salutation'] : '';
					$paxType = isset($passenger['paxType']) ? $passenger['paxType'] : '';
					if ($paxType == 1) {
						$Salutation_ = $ARR_SALUTION[$Salutation];
					} elseif ($paxType == 2) {
						$Salutation_ = $ARR_SALUTION_CHILD[$Salutation];
					} else {
						$Salutation_ = $ARR_SALUTION_CHILD[$Salutation];
					}
					$FirstName = isset($passenger['FirstName']) ? $passenger['FirstName'] : '';
					$LastName = isset($passenger['LastName']) ? $passenger['LastName'] : '';
					$Contacts = isset($passenger['Contacts']) ? $passenger['Contacts'] : '';
					$countryCode = isset($passenger['countryCode']) ? $passenger['countryCode'] : '';
					$pax_full_name[] = $Salutation_ . '. ' . $FirstName . ' ' . $LastName;
					$whatsappnumber = $countryCode . '' . $Contacts;
				}
			}

			$customer_name = isset($pax_full_name[0]) ? $pax_full_name[0] : '';
			foreach ($FlightBooking__['data'] as $key => $value) {
				$Response = json_decode($value['API_Response'], true);
				$flight_name_number = $Response['AirlineName'] . ' - ' . $Response['FlightNumber'];
				$BookingId = $value['BookingId'];
				$ICSourceSysId = $value['ICSourceSysId'];
				$PNR_Number_ = explode('-', $value['PNR_Number']);
				$PNR_Number_ = array_unique($PNR_Number_);
				$PNR_Number = !empty($PNR_Number_) ? implode('-', $PNR_Number_) . ' / ' . $BookingId : 'PENDING';

				$requestPerameter[$key]['customer_name'] = !empty($customer_name) ? $customer_name : null;
				$requestPerameter[$key]['departure_date'] = !empty($Response['LocalFromTime']) ? date('d-m-Y', strtotime($Response['LocalFromTime'])) : null;
				$requestPerameter[$key]['departure_time'] = !empty($Response['LocalFromTime']) ? date('H:i', strtotime($Response['LocalFromTime'])) : null;
				$requestPerameter[$key]['arrival_date'] = !empty($Response['LocalToTime']) ? date('d-m-Y', strtotime($Response['LocalToTime'])) : null;
				$requestPerameter[$key]['arrival_time'] = !empty($Response['LocalToTime']) ? date('H:i', strtotime($Response['LocalToTime'])) : null;
				$requestPerameter[$key]['flight_name_number'] = !empty($flight_name_number) ? $flight_name_number : null;
				$requestPerameter[$key]['pnr_number'] = !empty($PNR_Number) ? $PNR_Number : null;
				$requestPerameter[$key]['pax_count'] = !empty($Response['TotalFlightMembers']) ? $Response['TotalFlightMembers'] : null;
				$requestPerameter[$key]['pax_full_name'] = !empty($pax_full_name) ? implode(', ', $pax_full_name) : null;
				$requestPerameter[$key]['my_booking_url'] = !empty($this->baseUrl) ? $this->baseUrl . 'customer/myprofile' : null;
				$requestPerameter[$key]['displayname'] = !empty($this->siteName) ? $this->siteName : null;
				$requestPerameter[$key]['ticketdownloadlink'] = !empty($this->baseUrl) ? 'flight/e-ticket/' . $BookingId . '?source=' . $ICSourceSysId . '' : null;
				$requestPerameter[$key]['whatsappnumber'] = !empty($whatsappnumber) ? $whatsappnumber : null;
			}
		}
		
		// echo '<pre>';print_r($FlightBooking__);die;
		//$FlightBookingTicketSession->params[0]['order']['bookingId']
		$ResponseArr = [];
		$ErrorMessageArr = [];
		$getAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getAgencyData($this->gtxagencysysid);
		$this->siteName = (isset($getAgencyData['DisplayName']) && !empty($getAgencyData['DisplayName']))?$getAgencyData['DisplayName']: $this->siteName;
		$contactDetail_mail = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getContactDetailForFooter();
		$ICSourceSysId = isset($FlightBooking['data']['ICSourceSysId']) ? $FlightBooking['data']['ICSourceSysId'] : 0;
		$Bookingstatus = isset($FlightBooking['data']['status']) ? $FlightBooking['data']['status'] : 0;
		$API_Response = json_decode($FlightBooking['data']['API_Response'], true);
		$SupplierSysId = isset($API_Response['SupplierSysId']) ? $API_Response['SupplierSysId'] : 0;
		$apiSupplierData = array(
			"SupplierSysId" => $SupplierSysId,
			"AgencySysId" => $this->gtxagencysysid,
		);
		if ($FlightBooking['data']['IsInternational'] == 1) {
			$ItemSourceType = 2;
		} else {
			$ItemSourceType = 1;
		}
		$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->getSupportContact(1, 1, $ItemSourceType);
		if (isset($getSupportContact['EmailId']) && !empty($getSupportContact['EmailId']) && $getSupportContact['IsBookingEmail'] == 1) {
			$MasterPrimaryEmailTo = trim($getSupportContact['EmailId']);
		} else {
			$MasterPrimaryEmailTo = $getAgencyData['PrimaryEmail'];
		}

		$gstnumber = $FlightBooking['data']['gstnnumber'];
		$GSTINFO = isset($getAgencyData['GSTINFO']) ? $getAgencyData['GSTINFO'] : '';
		$gstvalidate = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->gstvalidate($gstnumber, $GSTINFO);
		$getAgencySupplierUserData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencySupplierUserData($apiSupplierData);
		$getAgencySupplierUserData = isset($getAgencySupplierUserData['data']) ? $getAgencySupplierUserData['data'] : array();
		$html = new Zend_View();
		$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
		$html->assign(array('getSupportContact' => $getSupportContact, 'FlightBooking' => $FlightBooking, 'FlightBooking__' => $FlightBooking__, 'Email' => true, 'getAgencySupplierUserData' => $getAgencySupplierUserData, 'getAgencyData' => $getAgencyData, 'FlightBookingInb' => $FlightBookingInb, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, 'baseUrl' => $this->baseUrl, 'gstvalidate' => $gstvalidate));

		if ($this->gtxagencysysid == '87401') {
			$bodyText = $html->render('e-ticket-new.phtml');
		} else {
			$bodyText = $html->render('e-ticket-mail.phtml');
		}
		$PNR_Number = !empty($FlightBooking['data']['PNR_Number']) ? trim($FlightBooking['data']['PNR_Number']) : 'PENDING';
		$WPNR = array_values(array_unique(explode('-', $PNR_Number)));
		if($WPNR[0] == 'pending' || $WPNR[0] == 'PENDING'){
			$subject = 'Pending Flight Ticket Confirmation';
			$Caption = 'Pending Flight Ticket Confirmation';
		}else{
			$subject = 'Your Ticket Has Been Booked';
			$Caption = 'Your Ticket Has Been Booked';
		}
		$configs = [
			'to' => trim($FlightBooking['passenger'][0]['EmailId']),
			'fromName' => $this->siteName,
			'fromEmail' => $getAgencyData['PrimaryEmail'],
			'subject' => $subject,
			'bodyHtml' => $bodyText,
		];
		$configsAgency = [
			'to' => trim($MasterPrimaryEmailTo),
			'fromName' => $this->siteName,
			'fromEmail' => $getAgencyData['PrimaryEmail'],
			'subject' => $subject,
			'bodyHtml' => $bodyText,
		];
		// if($this->gtxagencysysid == '2656'){
		// 	echo"<pre>";print_r($Bookingstatus);
		// 	echo"<pre>";print_r($configs);
		// 	echo"<pre>";print_r($configsAgency);
		// 	die('hi');
		// }
		// echo "<pre>"; print_r($configsAgency);die;
		if ($ICSourceSysId == 8) {
			$supplierBodyText = $html->render('e-ticket-supplier.phtml');
			$configsSupp = [
				'to' => trim($getAgencySupplierUserData['EmailId']),
				'fromName' => $this->siteName,
				'fromEmail' => $getAgencyData['PrimaryEmail'],
				'subject' => $subject,
				'bodyHtml' => $supplierBodyText,
			];
			$returnmail = $this->objHelperGeneral->mailSentByElastice($configsSupp, $Caption);
		}


		if ($Bookingstatus == 1 && $urlStatus == 'true') {
			$CustomerSession = $FlightBooking['passenger'];
			$SourceAirportCode = $FlightBooking['data']['SourceAirportCode'];
			$DestAirportCode = $FlightBooking['data']['DestAirportCode'];
			$TravelDate = date('d M Y', strtotime($FlightBooking['data']['TravelDate']));
			$sectors = $SourceAirportCode . '-' . $DestAirportCode;
			$apiTraceId = $FlightBooking['data']['apiTraceId'];
			$BookingId = $FlightBooking['data']['BookingId'];
			$AirlineName = $FlightBooking['data']['AirlineName'];
			$PNR_Number = !empty($FlightBooking['data']['PNR_Number']) ? trim($FlightBooking['data']['PNR_Number']) : 'PENDING';
			$ICSourceSysId = $FlightBooking['data']['ICSourceSysId'];
			$countryCode = (isset($CustomerSession[0]['countryCode']) && !empty($CustomerSession[0]['countryCode'])) ? $CustomerSession[0]['countryCode'] : '';
			$FirstName = (isset($CustomerSession[0]['FirstName']) && !empty($CustomerSession[0]['FirstName'])) ? $CustomerSession[0]['FirstName'] : '';
			$MobileNumber = $countryCode . $CustomerSession[0]['Contacts'];

			$departureDataTime = [];
			$arrivalDateTime = [];
			$fromtoDestination = [];
			$airlineNameAirlineNumber = [];
			if ($arrUrlData['BookingData']) {
				foreach ($arrUrlData['BookingData'] as $Data) {
					$LocalFromTime = date('d-M-Y H:i', strtotime($Data['LocalFromTime']));
					$LocalToTime = date('d-M-Y H:i', strtotime($Data['LocalToTime']));
					$departureDataTime[] = $LocalFromTime;
					$arrivalDateTime[] = $LocalToTime;
					$fromtoDestination[] = $Data['SourceAirportCode'] . '-' . $Data['DestAirportCode'];
					$airlineNameAirlineNumber[] = $Data['AirlineName'] . ' ' . $Data['FlightNumber'];
				}
			}

			// ================ For whatsapp==============
			$PaxDetailsW = [];
			if ($CustomerSession) {
				foreach ($CustomerSession as $key => $value) {
					$PaxDetailsW[] = trim($value['FirstName']) . ' ' . trim($value['LastName']);
				}
			}
			$WPNR = array_values(array_unique(explode('-', $PNR_Number)));
			$ddd = $this->baseUrl . 'flight/e-ticket-new/' . $BookingId . '?source=7';
			$whatsappArray = [
				'mobileNoCountryCode' => $MobileNumber,
				'fullName' => $FirstName,
				'ticketStatus' => ($Bookingstatus == 1) ? 'CONFIRMED' : 'PENDING',
				'airlineNameAirlineNumber' => implode(',', $airlineNameAirlineNumber),
				'fromtoDestination' => implode(',', $fromtoDestination),
				'departureDataTime' => implode(',', $departureDataTime),
				'arrivalDateTime' => implode(',', $arrivalDateTime),
				'pnrAndBookingId' => implode('-', $WPNR) . '/' . $BookingId,
				'noOfPax' => count($PaxDetailsW),
				'PaxDetails' => implode(',', $PaxDetailsW),
				'checkurl' => $this->baseUrl,
				'AgencyName' => trim($this->siteName),
				'voucherlink' => 'flight/e-ticket-new/' . $BookingId . '?source=' . $ICSourceSysId,
			];

			$whatsappResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->SendWhatsapp($whatsappArray);

			// if ($this->gtxagencysysid == '2656') {
			// 	echo '<pre>';
			// 	print_r($whatsappArray);
			// 	echo '<pre>';
			// 	print_r($whatsappResponse);
			// 	die;
			// }
			if($PNR_Number == 'PENDING'){
				$ConfirmedMSG = $PNR_Number;
			}else{
				$ConfirmedMSG = 'Confirmed';
			}
			$siteName = trim($this->siteName);
			$message = "Hi $FirstName,\n\nYour Flight Booking of $sectors on $TravelDate is $ConfirmedMSG. Your Confirmation / PNR No. is $PNR_Number.\n\nTeam $siteName\nTRVCRM";


			$this->postFields = "";
			$this->postFields .= "&method=$this->SMSMETHOD";
			$this->postFields .= "&api_key=$this->SMSAPIKEY";
			$this->postFields .= "&sender=$this->SMSSENDER";
			$this->postFields .= "&message=$message";
			$this->postFields .= "&format=$this->SMSFORMAT";
			$this->postFields .= "&to=" . substr($MobileNumber, -10);
			$postURL = $this->SMSURL;
			if ($ICSourceSysId == 8 && $countryCode == '91') {
				$resultVal = $objFlight->sendSmsDetails($postURL, $this->postFields, array('AgencySysId' => 1), $this->IsSMSApi, $apiTraceId);
			}
			// if ($this->gtxagencysysid == '2656') {
			// 	echo '<pre>';print_r($message);
			// 	echo '<pre>';print_r($resultVal);
			// 	echo '<pre>';print_r($this->postFields);
			// 	die('s');
			// }
			// echo 'configs<pre>';print_r($configs);
			// echo 'Caption<pre>';print_r($Caption);
			// echo '<pre>';print_r($FlightBooking);
			// die('s');
			if ($this->WhatsappMsgAllow == 1) {
				$WhatsappMessage = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->WhatsappMessage($requestPerameter, $FlightBooking__['data']);
			}

			$returnmail1 = $this->objHelperGeneral->mailSentByElastice($configs, $Caption);
			$returnmail = $this->objHelperGeneral->mailSentByElastice($configsAgency, $Caption);
			
			$this->_redirect('flight/booking-confirmed?TraceId='.$TraceIdParam);
		} elseif ($urlStatus == 'false') {
			// $configs = [
			// 	'to' => trim($getAgencyData['PrimaryEmail']),
			// 	'fromName' => $this->siteName,
			// 	'fromEmail' => $getAgencyData['PrimaryEmail'],
			// 	'subject' => 'Booking Failed',
			// 	'bodyHtml' => $bodyText,
			// ];
			// echo '<pre>';print_r($configs);
			// die('s');
		}

		//$response = json_decode($returnmail, true);
		$this->view->FlightBooking = $FlightBooking;
		$this->view->FlightBookingInb = $FlightBookingInb;
		$this->view->FlightBooking__ = $FlightBooking__;
		if ($FlightBookingTicketSession->params) {
		} else {
			//$this->_redirect('flight');
		}
	}

	public function bookingConfirmedNewAction()
	{
            // ini_set('display_errors', 1);
            // ini_set('display_startup_errors', 1);
            // error_reporting(E_ALL);
            $post = $param = $this->getRequest()->getParams();

            $status = isset($post['status']) ? $post['status'] : '';
            $TPSysId = isset($post['TPSysId']) ? $post['TPSysId'] : '';
            $PostData = ['TPSysId' => $TPSysId, 'version' => null];
            $apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingdetailsapi($PostData);
            // echo 'apiResponse== <pre>';print_r(json_encode($apiResponse));
            // die;
            $FlightBookingData = isset($apiResponse['FlightBookingData'])?$apiResponse['FlightBookingData']:[];
            $ICSourceSysId = isset($FlightBookingData[0]['ICSourceSysId']) ? $FlightBookingData[0]['ICSourceSysId'] : 0;

            $temp_data = $this->objMdl->selectOne('tbl_flight_booking', ['*'], ['TPSysId' => $TPSysId], ['id' => 'ASC']);
            // echo '<pre>';print_r();
            // die;
            $this->view->apiResponse = $apiResponse;
            $this->view->FlightBookingData = $FlightBookingData;
            $this->view->passengerData = $apiResponse['customer'];
            $this->view->CurrencyRate = $this->CurrencyRate;
            $this->view->CurrencyTitle = $this->CurrencyTitle;
            $this->view->baseUrl = $this->baseUrl;
            $this->view->strUrlData = isset($post['TraceId']) ? $post['TraceId'] :'';

            $SupportContact = isset($apiResponse['SupportContact'])?$apiResponse['SupportContact']:[];
            $CustomerDetails = isset($apiResponse['CustomerDetails'])?$apiResponse['CustomerDetails']:[];

            $XRefBookingId = (isset($FlightBookingData[0]['XRefBookingId']) && !empty($FlightBookingData[0]['XRefBookingId']))?$FlightBookingData[0]['XRefBookingId']:$FlightBookingData[0]['TPSysId'];
            $BookingStatus = isset($FlightBookingData[0]['BookingStatus'])?$FlightBookingData[0]['BookingStatus']:0;
            $success = isset($FlightBookingData[0]['IsBookingStatus'])?$FlightBookingData[0]['IsBookingStatus']:0;
            $CurrentStatus = isset($FlightBookingData[0]['CurrentStatus'])?$FlightBookingData[0]['CurrentStatus']:0;
            $ICSourceSysId = isset($FlightBookingData[0]['ICSourceSysId']) ? $FlightBookingData[0]['ICSourceSysId'] : 0;
            $AirlineRefPNR = (isset($FlightBookingData[0]['AirlineRefPNR']) && !empty($FlightBookingData[0]['AirlineRefPNR'])) ? $FlightBookingData[0]['AirlineRefPNR'] : 'PENDING';
            $AgentAgencyName = isset($FlightBookingData[0]['AgentAgencyName']) ? $FlightBookingData[0]['AgentAgencyName'] : 0;
            $SourceAirportCode = isset($FlightBookingData[0]['SourceAirportCode']) ? $FlightBookingData[0]['SourceAirportCode'] : 0;
            $DestAirportCode = isset($FlightBookingData[0]['DestAirportCode']) ? $FlightBookingData[0]['DestAirportCode'] : 0;
            $sectors = trim($SourceAirportCode).'-'.trim($DestAirportCode);
            $TravelDate = isset($FlightBookingData[0]['LocalFromTime']) ? date('d M Y',strtotime($FlightBookingData[0]['LocalFromTime'])) : 0;
            $MasterPrimaryEmailTo = isset($FlightBookingData[0]['MasterPrimaryEmail']) ? $FlightBookingData[0]['MasterPrimaryEmail'] : '';
            $AgentEmailTo = isset($FlightBookingData[0]['AgentEmailId']) ? $FlightBookingData[0]['AgentEmailId'] : '';
            $mobile = isset($FlightBookingData[0]['mobile']) ? $FlightBookingData[0]['mobile'] : '';
            $emailid = isset($FlightBookingData[0]['emailid']) ? $FlightBookingData[0]['emailid'] : '';
            $CustomerEmailTo = isset($CustomerDetails['EmailId']) ? $CustomerDetails['EmailId'] : '';
            $name = isset($apiResponse['customer'][0]['FirstName']) ? trim($apiResponse['customer'][0]['FirstName']) : '';
            $countryCode = isset($CustomerDetails['countrycode']) ? $CustomerDetails['countrycode'] : '';
            $MobileNumber = isset($CustomerDetails['Contacts']) ? trim($CustomerDetails['Contacts']) : '';


            $sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
            $SearchFlightTraceId = $sessionFlightSearchParams->params['SearchFlightTraceId'];
            $this->view->SearchFlightTraceId = $SearchFlightTraceId;

            $requestPerameter = [];

            $ResponseArr = [];
            $ErrorMessageArr = [];
            $getAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getAgencyData($this->gtxagencysysid);
            $contactDetail_mail = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getContactDetailForFooter();
            $this->siteName = (isset($getAgencyData['DisplayName']) && !empty($getAgencyData['DisplayName']))?$getAgencyData['DisplayName']: $this->siteName;
            if ($FlightBookingData[0]['IsInternational'] == 1) {
                    $ItemSourceType = 2;
            } else {
                    $ItemSourceType = 1;
            }
            $getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->getSupportContact(1, 1, $ItemSourceType);

            $gstnumber = isset($FlightBookingData[0]['gstnnumber']) ? $FlightBookingData[0]['gstnnumber'] :'';
            $GSTINFO = isset($getAgencyData['GSTINFO']) ? $getAgencyData['GSTINFO'] : '';
            $gstvalidate = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->gstvalidate($gstnumber, $GSTINFO);
            // if($apiSupplierData){
            // 	$getAgencySupplierUserData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencySupplierUserData($apiSupplierData);
            // 	$getAgencySupplierUserData = isset($getAgencySupplierUserData['data']) ? $getAgencySupplierUserData['data'] : array();
            // }
            $BaseFare = 0;
            $Taxesfee = 0;
            $CommDiscount = 0;
            $TotalPay = 0;
            $couponVal = 0;
            $departureDataTime = [];
            $arrivalDateTime = [];
            $fromtoDestination = [];
            $airlineNameAirlineNumber = [];

            $BagPrice = 0;
            $MealPrice = 0;
            $SeatPrice = 0;
            $PaxDetailsW = [];
            $customerSegment = [];
            $FlightBookingDataNew = [];
            $TripCount = count($FlightBookingData);
            if ($apiResponse['customer']) {
                    foreach ($apiResponse['customer'] as $paxk => $vals) {
                            $customerSegment[$vals['VersionId']][] = $vals;
                            $PaxDetailsW[] = trim($vals['Title']).'. '.trim($vals['FirstName']) . ' ' . trim($vals['LastName']);
                            $BagPrice += ($vals['BagPrice'] / $TripCount);
                            $MealPrice += ($vals['MealPrice'] / $TripCount);
                            $SeatPrice += ($vals['SeatPrice'] / $TripCount);
                    }
            }

            if ($FlightBookingData) {
                    foreach ($FlightBookingData as $key => $value) {
                            $customerSeg = isset($customerSegment[$value['AirVersionId']])?$customerSegment[$value['AirVersionId']]:[];
                            $FlightBookingDataNew[$key] = $value;
                            $FlightBookingDataNew[$key]['customer'] = $customerSeg;
                            foreach ($value['FareBreakdown'] as $FareBreakdown) {
                                    $BaseFare += isset($FareBreakdown['BaseFare']) ? ($FareBreakdown['BaseFare']) : 0;
                                    $couponVal += isset($FareBreakdown['couponVal']) ? ($FareBreakdown['couponVal']) : 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;
                                    $Taxesfee += ($FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
                                    $TotalPay += ($BaseFare_ + $FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
                            }

                            $LocalFromTime = date('d-M-Y H:i', strtotime($value['LocalFromTime']));
                            $LocalToTime = date('d-M-Y H:i', strtotime($value['LocalToTime']));
                            $departureDataTime[] = $LocalFromTime;
                            $arrivalDateTime[] = $LocalToTime;
                            $fromtoDestination[] = trim($value['SourceAirportCode']) . '-' . trim($value['DestAirportCode']);
                            $airlineNameAirlineNumber[] = trim($value['AirLineTitle']) . ' ' . trim($value['FlightNumber']);
                    }
            }



            $fareData = [
                    'Currency' => isset($FlightBookingData[0]['CurrencySymbol']) ? trim($FlightBookingData[0]['CurrencySymbol']) : 'INR',
                    'BaseFare' => round($BaseFare, 2),
                    'Taxesfee' => round($Taxesfee, 2),
                    'CommDiscount' => round($CommDiscount, 2),
                    'BagPrice' => round($BagPrice, 2),
                    'MealPrice' => round($MealPrice, 2),
                    'SeatPrice' => round($SeatPrice, 2),
                    'couponVal' => round($couponVal, 2),
                    'TotalSSR' => round($BagPrice + $MealPrice + $SeatPrice, 2),
                    'TotalPay' => round((($TotalPay + $BagPrice + $MealPrice + $SeatPrice) - $couponVal), 2),
            ];
			if ($status == true &&  ($CurrentStatus == 142 || $CurrentStatus == 141)) {
				$html = new Zend_View();
				$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
				$html->assign(array('bookingDataByAPI' => $FlightBookingDataNew,'getSupportContact'=>$SupportContact,'arrtravellerList'=>$apiResponse['customer'], 'MasterAgencySysId'=>$this->MasterAgencySysId,'CustomerDetails'=>$CustomerDetails,
				'B2BType' => $this->_session->B2BType, 'stylecss' => $this->stylecss,'BookingID'=> $XRefBookingId,'TPSysId' => $TPSysId, 'apiResponse' => $apiResponse,'fareData'=>$fareData, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle,' siteName' => $this->siteName, 'baseUrl' => $this->baseUrl, 'IsForMail' => 1));

				$bodyText = $html->render('e-ticket-api.phtml');
				$subject = 'Your Ticket Has Been Booked '. ' (Ref: ' . $XRefBookingId . ')';
				$Caption = 'Your Ticket Has Been Booked';
				if($CurrentStatus == 141){
						$subject = 'Booking Status - '.$BookingStatus.' '. ' (Ref: ' . $XRefBookingId . ')';
						$Caption = 'Your Ticket Has Been Booked';
				}

				$configs = [
						'to' => trim($emailid),
						'fromName' => $this->siteName,
						'fromEmail' => $getAgencyData['PrimaryEmail'],
						'subject' => $subject,
						'bodyHtml' => $bodyText,
				];
				$configsAgency = [
						'to' => trim($MasterPrimaryEmailTo),
						'fromName' => $this->siteName,
						'fromEmail' => $getAgencyData['PrimaryEmail'],
						'subject' => $subject,
						'bodyHtml' => $bodyText,
				];

				$PaxDetailsW = array_values(array_unique($PaxDetailsW));
				$WPNR = array_values(array_unique(explode('-', $AirlineRefPNR)));
				$whatsappArray = [
						'mobileNoCountryCode' => $countryCode.$mobile,
						'fullName' => $name,
						'ticketStatus' => $BookingStatus,
						'airlineNameAirlineNumber' => implode(',', $airlineNameAirlineNumber),
						'fromtoDestination' => implode(',', $fromtoDestination),
						'departureDataTime' => implode(',', $departureDataTime),
						'arrivalDateTime' => implode(',', $arrivalDateTime),
						'pnrAndBookingId' => implode('-', $WPNR) . '/' . $XRefBookingId,
						'noOfPax' => count($PaxDetailsW),
						'PaxDetails' => implode(',', $PaxDetailsW),
						'checkurl' => $this->baseUrl,
						'AgencyName' => trim($this->siteName),
						'voucherlink' => 'flight/e-ticket-api/' . $TPSysId,
				];

				if($temp_data['CancelCharge'] == 0){
						$objFlight = new Travel_Model_FlightMaster();
						$whatsappResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->SendWhatsapp($whatsappArray);
						// if($this->gtxagencysysid == '33164'){
						// 	echo '<pre>';print_r($whatsappResponse);
						// 	echo '<pre>';print_r($whatsappArray);
						// 	die;
						// }

						$returnmail1 = json_decode($this->objHelperGeneral->mailSentByElastice($configs, $Caption),1);
						$returnmail = $this->objHelperGeneral->mailSentByElastice($configsAgency, $Caption);
						if($returnmail1['success'] == 1){
								$update['CancelCharge'] = 1;
								$where = "TPSysId = " . $TPSysId;
								$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
						}

						if($temp_data['CustomerSysId']){
							$customerBooking = $this->objMdl->rv_select_row('tbl_flight_booking_customer', ['EmailId','Contacts'], ['CustomerSysId' => $temp_data['CustomerSysId'],'AgencySysId' => $this->gtxagencysysid], ['id' => 'ASC']);
							$tbl_customerD = array();
							if(!empty($customerBooking)){
								$tbl_customerD = $this->objMdl->rv_select_all('tbl_customer', ['EmailId','Contacts'], ['EmailId' => trim($customerBooking['EmailId']), 'AgencySysId' => $this->gtxagencysysid], ['CustomerSysId' => 'ASC']);
							}

							if(!empty($tbl_customerD) && count($tbl_customerD) == 1){

								$datah = array(
									'siteName' => $this->websiteName,
									'baseUrl' => $this->baseUrl,
									'AgencySysId' => $this->gtxagencysysid,
									'TPSysId' => $TPSysId,
									'CustomerSysId' => (int)$FlightBookingData[0]['CustomerSysId'],
								);

								$url = $this->gtxBtoBsite . 'gtxwebservices/customerapi/send-agency-customer-credentials/';
								$data_stringh = json_encode($datah);
								$ch = curl_init();
								curl_setopt($ch, CURLOPT_URL, $url);
								curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
								curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
								curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
								curl_setopt($ch, CURLOPT_POST, true);
								curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
								//                                        curl_setopt($ch, CURLOPT_TIMEOUT_MS, 100); // 100 milliseconds
								//                                        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, 100);
								curl_setopt($ch, CURLOPT_HTTPHEADER, array(
									'Accept: application/json',
									'Content-Type: application/json', 
									'http_deviceid: APPMOBILE1766992320', 
									'SecurityKey: ' . SECURITYKEY,
									'Content-Length: ' . strlen($data_stringh)
								));

								$outputH = curl_exec($ch); 
						//                            echo $outputH;die;
								$response = json_decode($outputH, true);

							}
						}
				}  
				$this->_redirect('flight/booking-confirmed-new/' . $TPSysId);
			}               
	}

	public function eTicketDownloadAction()
	{
		$this->_helper->layout->disableLayout();
		$param = $this->getRequest()->getParams();
		$objFlight = new Travel_Model_FlightMaster();
		$source = isset($param['source']) ? $param['source'] : '';
		$FlightBookingInb = [];
		if ($source == 3 || $source == 16) {
			$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId']);
		} else {
			$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId'], 1);
			if ($source == 8) {
				$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId']);
			}
			$FlightBookingInb = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId'], 2);
		}

		//if($this->gtxagencysysid == '15764'){
		$FlightBooking__ = $objFlight->FlightBookingDataNew('tbl_flight_booking', $param['bookingId']);

		//}

		if ($FlightBooking['data']['IsInternational'] == 1) {
			$intCountryCode = 'INT';
		} else {
			$intCountryCode = 'IN';
		}

		if ($FlightBooking['data']['IsInternational'] == 1) {
			$ItemSourceType = 2;
		} else {
			$ItemSourceType = 1;
		}
		$getAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->gtxagencysysid);
		$this->siteName = (isset($getAgencyData['DisplayName']) && !empty($getAgencyData['DisplayName']))?$getAgencyData['DisplayName']: $this->siteName;
		$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->getSupportContact(1, 1, $ItemSourceType);
		if (isset($getSupportContact['EmailId']) && !empty($getSupportContact['EmailId']) && $getSupportContact['IsBookingEmail'] == 1) {
			$MasterPrimaryEmailTo = trim($getSupportContact['EmailId']);
		} else {
			$MasterPrimaryEmailTo = $getAgencyData['PrimaryEmail'];
		}
		
		$gstnumber = $FlightBooking['data']['gstnnumber'];
		$GSTINFO = isset($getAgencyData['GSTINFO']) ? $getAgencyData['GSTINFO'] : '';
		$gstvalidate = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->gstvalidate($gstnumber, $GSTINFO);

		$intMarkUp = $this->getMarkup($intCountryCode);
		$arrAgencyUserDetail = isset($intMarkUp['arrAgencyUserDetail']) ? $intMarkUp['arrAgencyUserDetail'] : '';
		$this->view->arrAgencyUserDetail = $arrAgencyUserDetail;
		$this->view->getAgencyData = $getAgencyData;
		$this->view->FlightBooking = $FlightBooking;
		$this->view->FlightBookingInb = $FlightBookingInb;

		$this->view->getSupportContact = $getSupportContact;
		$this->view->FlightBooking__ = $FlightBooking__;
		$this->view->baseUrl = $this->baseUrl;
		$this->view->CurrencyRate = $this->CurrencyRate;
		$this->view->gstvalidate = $gstvalidate;
	}
	public function eTicketAction()
	{
		$this->_helper->layout->disableLayout();
		$param = $this->getRequest()->getParams();
		$objFlight = new Travel_Model_FlightMaster();
		$source = isset($param['source']) ? $param['source'] : '';
		$FlightBookingInb = [];
		if ($source == 3 || $source == 16) {
			$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId']);
		} else {
			$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId'], 1);
			if ($source == 8) {
				$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId']);
			}
			$FlightBookingInb = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId'], 2);
		}

		//if($this->gtxagencysysid == '15764'){
		$FlightBooking__ = $objFlight->FlightBookingDataNew('tbl_flight_booking', $param['bookingId']);

		//}

		if ($FlightBooking['data']['IsInternational'] == 1) {
			$intCountryCode = 'INT';
		} else {
			$intCountryCode = 'IN';
		}

		if ($FlightBooking['data']['IsInternational'] == 1) {
			$ItemSourceType = 2;
		} else {
			$ItemSourceType = 1;
		}
		$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->getSupportContact(1, 1, $ItemSourceType);
		if (isset($getSupportContact['EmailId']) && !empty($getSupportContact['EmailId']) && $getSupportContact['IsBookingEmail'] == 1) {
			$MasterPrimaryEmailTo = trim($getSupportContact['EmailId']);
		} else {
			$MasterPrimaryEmailTo = $getAgencyData['PrimaryEmail'];
		}
		$getAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->gtxagencysysid);
		$this->siteName = (isset($getAgencyData['DisplayName']) && !empty($getAgencyData['DisplayName']))?$getAgencyData['DisplayName']: $this->siteName;

		$gstnumber = $FlightBooking['data']['gstnnumber'];
		$GSTINFO = isset($getAgencyData['GSTINFO']) ? $getAgencyData['GSTINFO'] : '';
		$gstvalidate = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->gstvalidate($gstnumber, $GSTINFO);

		$intMarkUp = $this->getMarkup($intCountryCode);
		$arrAgencyUserDetail = isset($intMarkUp['arrAgencyUserDetail']) ? $intMarkUp['arrAgencyUserDetail'] : '';
		$this->view->arrAgencyUserDetail = $arrAgencyUserDetail;
		$this->view->getAgencyData = $getAgencyData;
		$this->view->FlightBooking = $FlightBooking;
		$this->view->FlightBookingInb = $FlightBookingInb;

		$this->view->getSupportContact = $getSupportContact;
		$this->view->FlightBooking__ = $FlightBooking__;
		$this->view->baseUrl = $this->baseUrl;
		$this->view->CurrencyRate = $this->CurrencyRate;
		$this->view->gstvalidate = $gstvalidate;
	}
	public function eTicketNewAction()
	{
		$this->_helper->layout->disableLayout();
		$param = $this->getRequest()->getParams();
		$objFlight = new Travel_Model_FlightMaster();
		$source = isset($param['source']) ? $param['source'] : '';
		
		$FlightBookingInb = [];
		if ($source == 3 || $source == 16 || $source == 17) {
			$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId']);
		} else {
			$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId'], 1);
			if ($source == 8) {
				$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId']);
			}
			$FlightBookingInb = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId'], 2);
		}
		$TPSysId = $FlightBooking['data']['TPSysId'];
		//if($this->gtxagencysysid == '15764'){
		$FlightBooking__ = $objFlight->FlightBookingDataNew('tbl_flight_booking', $param['bookingId']);
		$PostData = ['TPSysId' => $TPSysId, 'version' => null,'SecurityKey'=>SECURITYKEY];
		$getHttpRequest = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingdetailsapi($PostData);
		$bookingDataByAPI = $getHttpRequest['FlightBookingData'];
		
		//}
		
		if ($FlightBooking['data']['IsInternational'] == 1) {
			$intCountryCode = 'INT';
		} else {
			$intCountryCode = 'IN';
		}

		if ($FlightBooking['data']['IsInternational'] == 1) {
			$ItemSourceType = 2;
		} else {
			$ItemSourceType = 1;
		}
		$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->getSupportContact(1, 1, $ItemSourceType);
		if (isset($getSupportContact['EmailId']) && !empty($getSupportContact['EmailId']) && $getSupportContact['IsBookingEmail'] == 1) {
			$MasterPrimaryEmailTo = trim($getSupportContact['EmailId']);
		} else {
			$MasterPrimaryEmailTo = $getAgencyData['PrimaryEmail'];
		}
		$getAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->gtxagencysysid);
		$this->siteName = (isset($getAgencyData['DisplayName']) && !empty($getAgencyData['DisplayName']))?$getAgencyData['DisplayName']: $this->siteName;
		//
		$gstnumber = $FlightBooking['data']['gstnnumber'];
		
		$GSTINFO = isset($getAgencyData['GSTINFO']) ? $getAgencyData['GSTINFO'] : '';
		$gstvalidate = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->gstvalidate($gstnumber, $GSTINFO);

		$intMarkUp = $this->getMarkup($intCountryCode);
		$arrAgencyUserDetail = isset($intMarkUp['arrAgencyUserDetail']) ? $intMarkUp['arrAgencyUserDetail'] : '';

		// if($this->gtxagencysysid == '110804'){
		// 	$PostData = ['TPSysId' => $TPSysId, 'version' => null, 'SecurityKey'=>$this->_session->data['SecurityKey']];
		// 	$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingdetailsapi($PostData);
		// 	$FlightBookingData = isset($apiResponse['FlightBookingData'])?$apiResponse['FlightBookingData']:[];
		// }
		if($this->gtxagencysysid == '87401'){
			// 
		}
		$agencyTermAndCondition = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->agencyTermAndCondition($this->gtxagencysysid);
		// echo '<pre>';print_r($agencyTermAndCondition['TermConditionsInvoice']);
		// echo '<pre>';print_r($getHttpRequest);die;
		$this->view->arrAgencyUserDetail = $arrAgencyUserDetail;
		$this->view->getAgencyData = $getAgencyData;
		$this->view->FlightBooking = $FlightBooking;
		$this->view->FlightBookingInb = $FlightBookingInb;
		$this->view->bookingDataByAPI = $bookingDataByAPI;

		$this->view->FlightBooking__ = $FlightBooking__;
		$this->view->getSupportContact = $getSupportContact;
		$this->view->baseUrl = $this->baseUrl;
		$this->view->gstvalidate = $gstvalidate;
	}
	public function eTicketApiAction()
	{
		$this->_helper->layout->disableLayout();
		$post = $this->getRequest()->getParams();
		$TPSysId = $post['bookingId'];
		$PostData = ['TPSysId' => $TPSysId, 'version' => null,'SecurityKey'=>''];
		$getHttpRequest = $apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingdetailsapi($PostData);
		$url = $this->GTXAPIDEFAULT . '/flight/v3/get-agency-term-and-condtions';
		$TermsAndCondition = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest(['AgencySysId' => $this->gtxagencysysid],null, $url);
		$FlightInvoice = isset($TermsAndCondition['results']['FlightTicket']) ? $TermsAndCondition['results']['FlightTicket'] : '';
		$FlightBookingData = isset($apiResponse['FlightBookingData']) ? $apiResponse['FlightBookingData'] : [];
		$XRefBookingId = isset($FlightBookingData[0]['XRefBookingId']) ? trim($FlightBookingData[0]['XRefBookingId']) : '';
		// echo "where<pre>";print_r($apiResponse);die;
		$BaseFare = 0;
		$Taxesfee = 0;
		$CommDiscount = 0;
		$TotalPay = 0;
		$couponVal = 0;

		$BagPrice = 0;
		$MealPrice = 0;
		$SeatPrice = 0;
		$TripCount = count($FlightBookingData);
		$customerSegment = [];
		if ($apiResponse['customer']) {
			foreach ($apiResponse['customer'] as $paxk => $vals) {
				$customerSegment[$vals['VersionId']][] = $vals;
				$BagPrice += ($vals['BagPrice']);
				$MealPrice += ($vals['MealPrice']);
				$SeatPrice += ($vals['SeatPrice']);
			}
		}
		$FlightBookingDataNew = [];
		if ($FlightBookingData) {
			foreach ($FlightBookingData as $key => $value) {
				$customerSeg = isset($customerSegment[$value['AirVersionId']])?$customerSegment[$value['AirVersionId']]:[];
				$FlightBookingDataNew[$key] = $value;
				$FlightBookingDataNew[$key]['customer'] = $customerSeg;
				foreach ($value['FareBreakdown'] as $FareBreakdown) {
					$BaseFare += isset($FareBreakdown['BaseFare']) ? ($FareBreakdown['BaseFare']) : 0;
					$couponVal += isset($FareBreakdown['couponVal']) ? ($FareBreakdown['couponVal']) : 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;
					$Taxesfee += ($FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
					$TotalPay += ($BaseFare_ + $FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
				}
			}
		}		
		//echo "where<pre>";print_r($FlightBookingDataNew);die;
		$fareData = [
			'Currency' => isset($FlightBookingData[0]['CurrencySymbol']) ? trim($FlightBookingData[0]['CurrencySymbol']) : 'INR',
			'BaseFare' => round($BaseFare, 2),
			'Taxesfee' => round($Taxesfee, 2),
			'CommDiscount' => round($CommDiscount, 2),
			'BagPrice' => round($BagPrice, 2),
			'MealPrice' => round($MealPrice, 2),
			'SeatPrice' => round($SeatPrice, 2),
			'couponVal' => round($couponVal, 2),
			'TotalSSR' => round($BagPrice + $MealPrice + $SeatPrice, 2),
			'TotalPay' => round((($TotalPay + $BagPrice + $MealPrice + $SeatPrice) - $couponVal), 2),
		];
		// echo '<pre>';print_r($apiResponse['customer']);die;
		$this->view->BookingID = $XRefBookingId;
		$this->view->apiResponse = $apiResponse;
		$this->view->fareData = $fareData;
		$this->view->FlightInvoice = $FlightInvoice;


		$bookingDataByAPI = $FlightBookingDataNew;//$getHttpRequest['FlightBookingData'];
		$this->view->arrtravellerList = $getHttpRequest['customer'];
		$this->view->FlightInvoice = $FlightInvoice;
        $this->view->getSupportContact = $getHttpRequest['SupportContact'];
        $this->view->CustomerDetails = $getHttpRequest['CustomerDetails'];
        $this->view->bookingDataByAPI = $bookingDataByAPI;
        $this->view->intTPSysId = $this->getRequest()->getParam("data");
        $this->view->version = $versionId;
        $this->view->withprice = $withprice = isset($post['withprice']) ? $post['withprice'] :0;
		$nobranding = $this->view->nobranding = $nobranding = isset($post['nobranding']) ? $post['nobranding'] : 0;
        $intCustomerSysId = $bookingDataByAPI[0]['CustomerSysId'];
        $ICSourceSysId = $bookingDataByAPI[0]['ICSourceSysId'];
        $XRefBookingId = $bookingDataByAPI[0]['XRefBookingId'];
		
		$this->view->TPSysId = $TPSysId;
		$this->view->baseUrl = $this->baseUrl;
		$logo = $this->gtxBtoBsite . 'public/upload/media/agency/' . trim(@$bookingDataByAPI[0]['AgencySysId']) . '/' . trim(@$bookingDataByAPI[0]['Logo']);
		$this->view->MasterAgencyLogo = $logo;
		$this->view->MasterAgencySysId = $this->MasterAgencySysId;
		
	}
	public function eTicketApiDownloadAction()
	{
		$this->_helper->layout->disableLayout();
		$post = $this->getRequest()->getParams();
		$TPSysId = $post['bookingId'];
		$PostData = ['TPSysId' => $TPSysId, 'version' => null,'SecurityKey'=>''];
		$getHttpRequest = $apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingdetailsapi($PostData);
		$url = $this->GTXAPIDEFAULT . '/flight/v3/get-agency-term-and-condtions';
		$TermsAndCondition = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest(['AgencySysId' => $this->gtxagencysysid],null, $url);
		$FlightInvoice = isset($TermsAndCondition['results']['FlightTicket']) ? $TermsAndCondition['results']['FlightTicket'] : '';
		$FlightBookingData = isset($apiResponse['FlightBookingData']) ? $apiResponse['FlightBookingData'] : [];
		$XRefBookingId = isset($FlightBookingData[0]['XRefBookingId']) ? trim($FlightBookingData[0]['XRefBookingId']) : '';

		$BaseFare = 0;
		$Taxesfee = 0;
		$CommDiscount = 0;
		$TotalPay = 0;
		$couponVal = 0;

		$BagPrice = 0;
		$MealPrice = 0;
		$SeatPrice = 0;
		$customerSegment = [];
		$FlightBookingDataNew = [];
		$TripCount = count($FlightBookingData);
		if ($apiResponse['customer']) {
			foreach ($apiResponse['customer'] as $paxk => $vals) {
				$customerSegment[$vals['VersionId']][] = $vals;
				$BagPrice += ($vals['BagPrice'] / $TripCount);
				$MealPrice += ($vals['MealPrice'] / $TripCount);
				$SeatPrice += ($vals['SeatPrice'] / $TripCount);
			}
		}
		
		if ($FlightBookingData) {
			foreach ($FlightBookingData as $key => $value) {
				$customerSeg = isset($customerSegment[$value['AirVersionId']])?$customerSegment[$value['AirVersionId']]:[];
				$FlightBookingDataNew[$key] = $value;
				$FlightBookingDataNew[$key]['customer'] = $customerSeg;
				foreach ($value['FareBreakdown'] as $FareBreakdown) {
					$BaseFare += isset($FareBreakdown['BaseFare']) ? ($FareBreakdown['BaseFare']) : 0;
					$couponVal += isset($FareBreakdown['couponVal']) ? ($FareBreakdown['couponVal']) : 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;
					$Taxesfee += ($FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
					$TotalPay += ($BaseFare_ + $FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
				}
			}
		}
		

		$fareData = [
			'Currency' => isset($FlightBookingData[0]['CurrencySymbol']) ? trim($FlightBookingData[0]['CurrencySymbol']) : 'INR',
			'BaseFare' => round($BaseFare, 2),
			'Taxesfee' => round($Taxesfee, 2),
			'CommDiscount' => round($CommDiscount, 2),
			'BagPrice' => round($BagPrice, 2),
			'MealPrice' => round($MealPrice, 2),
			'SeatPrice' => round($SeatPrice, 2),
			'couponVal' => round($couponVal, 2),
			'TotalSSR' => round($BagPrice + $MealPrice + $SeatPrice, 2),
			'TotalPay' => round((($TotalPay + $BagPrice + $MealPrice + $SeatPrice) - $couponVal), 2),
		];
		$this->view->BookingID = $XRefBookingId;
		$this->view->apiResponse = $apiResponse;
		$this->view->fareData = $fareData;
		$this->view->FlightInvoice = $FlightInvoice;


		$bookingDataByAPI = $FlightBookingDataNew;//$getHttpRequest['FlightBookingData'];
		$this->view->arrtravellerList = $getHttpRequest['customer'];
		$this->view->FlightInvoice = $FlightInvoice;
        $this->view->getSupportContact = $getHttpRequest['SupportContact'];
        $this->view->CustomerDetails = $getHttpRequest['CustomerDetails'];
        $this->view->bookingDataByAPI = $bookingDataByAPI;
        $this->view->intTPSysId = $this->getRequest()->getParam("data");
        $this->view->version = $versionId;
        $this->view->withprice = $withprice = isset($post['withprice']) ? $post['withprice'] :0;
		$nobranding = $this->view->nobranding = $nobranding = isset($post['nobranding']) ? $post['nobranding'] : 0;
        $intCustomerSysId = $bookingDataByAPI[0]['CustomerSysId'];
        $ICSourceSysId = $bookingDataByAPI[0]['ICSourceSysId'];
        $XRefBookingId = $bookingDataByAPI[0]['XRefBookingId'];
		
		$this->view->TPSysId = $TPSysId;
		$this->view->baseUrl = $this->baseUrl;
		$logo = $this->gtxBtoBsite . 'public/upload/media/agency/' . trim(@$bookingDataByAPI[0]['AgencySysId']) . '/' . trim(@$bookingDataByAPI[0]['Logo']);
		$this->view->MasterAgencyLogo = $logo;
		$this->view->MasterAgencySysId = $this->MasterAgencySysId;


		$params = array(
            'baseUrl' => $this->baseUrl,
            'intTPSysId' => $this->getRequest()->getParam("data"),
            'FlightInvoice' => $FlightInvoice,
            'MasterAgencyLogo' => $logo,
            'MasterAgencySysId' =>  $this->MasterAgencySysId,
            'TPSysId' => $TPSysId,
            'withprice' => $withprice,
            'BookingID' => $XRefBookingId,
			'apiResponse' => $apiResponse,
			'fareData' => $fareData,
			'stylecss' => $this->stylecss,
            'arrtravellerList' => $getHttpRequest['customer'],
            'getSupportContact' => $getHttpRequest['SupportContact'],
            'bookingDataByAPI' => $FlightBookingDataNew,
            'download' => true,
        );

        $html = new Zend_View();
        $html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
        $html->assign($params);
        $Body = $html->render('e-ticket-api.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 invoiceAction()
	{
		$this->_helper->layout->disableLayout();
		$param = $this->getRequest()->getParams();
		$objFlight = new Travel_Model_FlightMaster();
		$source = isset($param['source']) ? $param['source'] : '';
		$getAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->gtxagencysysid);
		$this->siteName = (isset($getAgencyData['DisplayName']) && !empty($getAgencyData['DisplayName']))?$getAgencyData['DisplayName']: $this->siteName;
		//echo '<pre>';print_r($getAgencyData);die;
		$this->view->getAgencyData = $getAgencyData;
		$FlightBookingInb = [];
		if ($source == 3 || $source == 16 || $source == 17) {
			$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId']);
		} else {
			$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId'], 1);
			if ($source == 8) {
				$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId']);
			}
			$FlightBookingInb = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId'], 2);
		}

		$FlightBooking__ = $objFlight->FlightBookingDataNew('tbl_flight_booking', $param['bookingId']);
		$InvoiceNumber = $this->objMdl->rv_select_row('tbl_invoice', ['*'], ['Booking_Id' => $param['bookingId']], []);

		if ($FlightBooking['data']['IsInternational'] == 1) {
			$ItemSourceType = 2;
		} else {
			$ItemSourceType = 1;
		}
		$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->getSupportContact(1, 1, $ItemSourceType);

		$gstnumber = $FlightBooking['data']['gstnnumber'];
		$InvoiceNo = $FlightBooking['data']['InvoiceNo'];
		$GSTINFO = isset($getAgencyData['GSTINFO']) ? $getAgencyData['GSTINFO'] : '';
		$gstvalidate = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->gstvalidate($gstnumber, $GSTINFO);
		// echo '<pre>';print_r($gstvalidate);
		// die('s');
		$sitename = $this->siteName;
		$this->view->gstnumber = $gstnumber;
		$this->view->siteName = $sitename;
		$this->view->InvoiceNumber = $InvoiceNumber;
		$this->view->FlightBooking = $FlightBooking;
		$this->view->getSupportContact = $getSupportContact;
		$this->view->FlightBookingInb = $FlightBookingInb;
		$this->view->FlightBooking__ = $FlightBooking__;
		$this->view->baseUrl = $this->baseUrl;
		$this->view->gstvalidate = $gstvalidate;
	}

	public function invoiceApiAction()
	{
		$this->_helper->layout->disableLayout();
		$post = $this->getRequest()->getParams();
		$TPSysId = $post['bookingId'];
		$PostData = ['TPSysId' => $TPSysId, 'version' => null,'SecurityKey'=>$this->_session->data['SecurityKey']];
		$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingdetailsapi($PostData);
		$url = $this->GTXAPIDEFAULT . '/flight/v3/get-agency-term-and-condtions';
		$TermsAndCondition = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest(['AgencySysId' => $this->gtxagencysysid],null, $url);
	
		$FlightInvoice = isset($TermsAndCondition['results']['FlightInvoice']) ? $TermsAndCondition['results']['FlightInvoice'] : '';
		
		if ($apiResponse && $apiResponse['status'] == 1) {
			$FlightBookingData = isset($apiResponse['FlightBookingData']) ? $apiResponse['FlightBookingData'] : [];
			$XRefBookingId = isset($FlightBookingData[0]['XRefBookingId']) ? trim($FlightBookingData[0]['XRefBookingId']) : '';
			
			if (!empty($apiResponse)) {
			} else {
				return response()->json([
					'status' => [
						'success' => false,
						'httpStatus' => 405,
					],
					'message' => 'Oops API not working please refresh this page',
				]);
			}

			$BaseFare = 0;
			$Taxesfee = 0;
			$CommDiscount = 0;
			$TotalPay = 0;
			$FlightNumber = [];
			if ($FlightBookingData) {
				foreach ($FlightBookingData as $key => $value) {
					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;
						$Taxesfee += ($FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
						$TotalPay += ($BaseFare_ + $FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
						if ($value['Segments']) {
							foreach ($value['Segments'] as $flight) {
								$FlightNumber[$flight['OriginAirportCode'] . '-' . $flight['DestAirportCode']] = $flight['FlightNumber'];
							}
						}
					}
				}
			}
			$BagPrice = 0;
			$MealPrice = 0;
			$SeatPrice = 0;
			$TripCount = count($FlightBookingData);
			if ($apiResponse['customer']) {
				foreach ($apiResponse['customer'] as $paxk => $vals) {
					$BagPrice += ($vals['BagPrice'] / $TripCount);
					$MealPrice += ($vals['MealPrice'] / $TripCount);
					$SeatPrice += ($vals['SeatPrice'] / $TripCount);
				}
			}

			$fareData = [
				'Currency' => isset($FlightBookingData[0]['CurrencySymbol']) ? trim($FlightBookingData[0]['CurrencySymbol']) : 'INR',
				'BaseFare' => round($BaseFare, 2),
				'Taxesfee' => round($Taxesfee, 2),
				'CommDiscount' => round($CommDiscount, 2),
				'BagPrice' => round($BagPrice, 2),
				'MealPrice' => round($MealPrice, 2),
				'SeatPrice' => round($SeatPrice, 2),
				'TotalSSR' => round($BagPrice + $MealPrice + $SeatPrice, 2),
				'TotalPay' => round(($TotalPay + $BagPrice + $MealPrice + $SeatPrice), 2),
			];
		}
		$this->view->BookingID = $XRefBookingId;
		$this->view->apiResponse = $apiResponse;
		$this->view->fareData = $fareData;
		$this->view->FlightNumber = $FlightNumber;
		$this->view->FlightInvoice = $FlightInvoice;




		$this->view->CurrencyRate = $this->CurrencyRate;
		$this->view->CurrencyTitle = $this->CurrencyTitle;
		$this->view->B2BType = $this->_session->B2BType;
		$this->view->baseUrl = $this->baseUrl;
		$this->view->siteName = $this->siteName;
		$this->view->strUrlData = $post['data'];
		$logo = $this->gtxBtoBsite . 'public/upload/media/agency/' . trim(@$bookingDataByAPI[0]['AgencySysId']) . '/' . trim(@$bookingDataByAPI[0]['Logo']);
		$this->view->MasterAgencyLogo = $logo;
		$this->view->MasterAgencySysId = $this->MasterAgencySysId;
		$this->view->FareBreakdownarr = $FareBreakdownarr;
        $this->view->FlightNumber = $FlightNumber;

	
		
	}

	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 hidePhoneNumberDigit($phone, $type = 0)
	{
		$result = substr($phone, 0, 3);
		$result .= "****";
		$result .= substr($phone, 9, 4);
		if ($type == 1) {
			return $result;
		} else {
			return $phone;
		}
	}

	public function makepaymentAction()
	{
		if ($this->getRequest()->isXmlHttpRequest() && $this->getRequest()->getPost()) {
			$this->_helper->viewRenderer->setNoRender(true);
			$param = $this->getRequest()->getPost();
			$IsCancellationProtection = isset($param['IsCancellationProtection']) ? $param['IsCancellationProtection'] : 0;
			$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
			$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
			$apiTraceId = isset($FlightBookingData->params[0]['SearchFlightTraceId']) ? $FlightBookingData->params[0]['SearchFlightTraceId']:($FlightBookingData->params[0]['SearchTraceId'] ?? $param['apiTraceId'] ?? null);
			
			$getAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->gtxagencysysid);
			$this->siteName = (isset($getAgencyData['DisplayName']) && !empty($getAgencyData['DisplayName']))?$getAgencyData['DisplayName']: $this->siteName;

			$data = new Travel_Model_FlightMaster();
			$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $param['apiTraceId']], ['id' => 'ASC']);
			$arrUrlData = json_decode($temp_data['json_data'], true);
			$CustomerSession = $arrUrlData['CustomerSession'];
			$flight_booking_id_Arr = $arrUrlData['flight_booking_id_Arr'];
			$checkFlightOTP = $data->CheckPaymentSTatus('tbl_flight_booking', $apiTraceId);
			$verifying = isset($param['verifying']) ? $param['verifying'] : '';
			$paymentMode = isset($param['paymentMode']) ? $param['paymentMode'] : 0;
			$Remark = isset($param['Remark']) ? $param['Remark'] : 0;
			$usewallet = isset($param['usewallet']) ? $param['usewallet'] : 0;
			$arrUrlData['paymentMode'] = $paymentMode;
			$arrUrlData['Remark'] = $Remark;
			$arrUrlData['usewallet'] = $usewallet;

			$insertArr = array(
				'TraceId' => $param['apiTraceId'],
				'json_data' => json_encode($arrUrlData),
				'created_at' => date('Y-m-d-H-i-s'),
			);
			$this->objMdl->rv_delete('tbl_temp_data', array('TraceId = ?' => $param['apiTraceId']));
			$objFlight = new Travel_Model_FlightMaster();
			$objFlight->InsertFlightData('tbl_temp_data', $insertArr);
			if (!empty($verifying) && $verifying == 'true' && $this->getRequest()->isXmlHttpRequest()) {
				$OTPNumber = isset($param['OTPNumber']) ? $param['OTPNumber'] : '';
			
				if ($this->OTPVerified == 1) {
					$update = array(
						'generateOTP' => 1,
						'IsCancellationProtection' => $IsCancellationProtection,
					);
					if ($flight_booking_id_Arr) {
						foreach ($flight_booking_id_Arr as $valid) {
							$where = "id = '" . $valid . "'";
							$data->UpdateFlightData('tbl_flight_booking', $update, $where);
						}
					}
					$response = array('success' => true, 'paynow' => true);
					echo json_encode($response);
					exit;
				}
				
				if ($checkFlightOTP['generateOTP'] == $OTPNumber) {
					$update = array(
						'generateOTP' => 1,
					);
					if ($flight_booking_id_Arr) {
						foreach ($flight_booking_id_Arr as $valid) {
							$where = "id = '" . $valid . "'";
							$data->UpdateFlightData('tbl_flight_booking', $update, $where);
						}
					}
					$response = array('success' => true, 'paynow' => true);
					echo json_encode($response);
					exit;
				} else {
					$response = array('success' => false, 'message' => 'Invalid otp', 'paynow' => false);
					echo json_encode($response);
					exit;
				}
			}
			$OldOTP = !empty($checkFlightOTP['generateOTP']) ? $checkFlightOTP['generateOTP'] : '';

			if (!empty($OldOTP) && $OldOTP != 1) {
				$generateNumericOTP = $OldOTP;
			} else {
				$generateNumericOTP = $this->generateNumericOTP(6);
			}

			$update = array(
				'generateOTP' => $generateNumericOTP,
				'IsCancellationProtection' => $IsCancellationProtection,
			);
			if ($flight_booking_id_Arr) {
				foreach ($flight_booking_id_Arr as $valid) {
					$where = "id = '" . $valid . "'";
					$data->UpdateFlightData('tbl_flight_booking', $update, $where);
				}
			}

			$MobileNumber = $CustomerSession[0]['countryCode'] . $CustomerSession[0]['Contacts'];
			if ($this->gtxagencysysid == '2596') {
				$this->siteName = 'Sterling';
			} else {
				$this->siteName = (isset($getAgencyData['DisplayName']) && !empty($getAgencyData['DisplayName']))?$getAgencyData['DisplayName']: $this->siteName;
			}
			$message = "Hi,\nUse $generateNumericOTP as OTP (One Time Password) to verify your mobile number. Do not share this OTP with anyone for security reason.\nThanks\n$this->siteName\nTRVCRM";

			if ($MobileNumber) {

				$this->postFields = "";
				$this->postFields .= "&method=$this->SMSMETHOD";
				$this->postFields .= "&api_key=$this->SMSAPIKEY";
				$this->postFields .= "&sender=$this->SMSSENDER";
				$this->postFields .= "&message=$message";
				$this->postFields .= "&format=$this->SMSFORMAT";
				$this->postFields .= "&to=" . substr($MobileNumber, -10);
				$postURL = $this->SMSURL;
				$resultVal = $data->sendSmsDetails($postURL, $this->postFields, array('AgencySysId' => 1), $this->IsSMSApi, $param['TraceId']);

				$html = new Zend_View();
				$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
				$html->assign(array('getBooingOTP' => $generateNumericOTP, 'agencyDetails' => $getAgencyData, 'CustomerSession' => $CustomerSession[0], 'baseUrl' => $this->baseUrl));
				$bodyText = $html->render('OTPEmail.phtml');

				$subject = 'OTP for flight booking';
				$Caption = 'OTP for flight booking ';

				$contactDetail_mail = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getContactDetailForFooter();

				$configs = [
					'to' => trim($CustomerSession[0]['EmailId']),
					'fromName' => $this->siteName,
					'fromEmail' => $contactDetail_mail['email'],
					'subject' => $subject,
					'bodyHtml' => $bodyText,
				];

				$returnmail = $this->objHelperGeneral->mailSentByElastice($configs, $Caption);
				//echo '<pre>';print_r($returnmail);
				$hidePhoneNumberDigit = $this->hidePhoneNumberDigit($MobileNumber, 1);
				$hideEmailid = $this->hidePhoneNumberDigit(trim($CustomerSession[0]['EmailId']), 1);

				echo json_encode(["success" => true, 'message' => 'success', 'hidePhoneNumberDigit' => $hidePhoneNumberDigit, 'hideEmailid' => $hideEmailid]);
				exit;
			} else {
				echo json_encode(["success" => false, 'message' => 'Unbale to pay please contact with our support team.']);
				exit;
			}
		}
	}
	public function payNowAction()
	{
		// die('...testing....');
		// ini_set('display_errors', 1);
		//     ini_set('display_startup_errors', 1);
		//     error_reporting(E_ALL);
		$param = $this->getRequest()->getParams();

		$objFlight = new Travel_Model_FlightMaster();
		$FlightTempData = $objFlight->GetFlightTempData($param['traceId']);
		$arrUrlData = json_decode($FlightTempData['json_data'], true);
		$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
		$FlightBookingDataInbound = new Zend_Session_Namespace('FlightBookingDataInbound');
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$sessionFlightSearchParams->params = $arrUrlData['sessionFlightSearchParams'];
		$FlightSearchUrl = new Zend_Session_Namespace('FlightSearchUrl');
		$CustomerSession = new Zend_Session_Namespace('CustomerSession');
		$selectedSeatSession = new Zend_Session_Namespace('selectedSeatSession');
		$CustomerSession = new Zend_Session_Namespace('CustomerSession');
		$this->view->CustomerSession = $CustomerSession->params;
		$this->view->FlightSearchUrl = $FlightSearchUrl->params;
		$class = $sessionFlightSearchParams->params['class'];
		$route = $sessionFlightSearchParams->params['route'];
		$interNationalSearch = $sessionFlightSearchParams->params['interNationalSearch'];
		$this->view->traceId = $param['traceId'];
		$this->view->departure_date = $sessionFlightSearchParams->params['strDepatureDate'];
		$this->view->return_dates = $sessionFlightSearchParams->params['strReturnDate'];
		$this->view->class = $class;
		$this->view->sessionFlightSearchParams = $sessionFlightSearchParams->params;
		$this->view->FlightBookingData = $FlightBookingData->params = $arrUrlData['BookingData'];
		$this->view->FlightBookingDataInbound = $FlightBookingDataInbound->params;

		$flight_booking_customer_id = new Zend_Session_Namespace('flight_booking_customer_id');
		$booking_customer_id = $flight_booking_customer_id->params;
		$ResponseFlightQuery = new Zend_Session_Namespace('ResponseFlightQuery');
		$FlightQueryids = $ResponseFlightQuery->params = $arrUrlData['genrateFlightQuery'];
		$MasterTPSysId = $FlightQueryids['arrIds']['MasterTPSysId'];
		$TPSysId = $FlightQueryids['arrIds']['TPSysId'];
		$VersionId = $FlightQueryids['arrIds']['VersionId'];

		$PostData = ['TPSysId' => $TPSysId, 'version' => null,'IsApproved'=>0];
		$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingdetailsapi($PostData);
		$customer = $apiResponse['customer'];
		// $FlightBookingData = $apiResponse['FlightBookingData'];
		// echo '<pre>';print_r($arrUrlData);

		$CustomerMemberSysIds = new Zend_Session_Namespace('CustomerMemberSysIds');
		$flight_booking_id = isset($CustomerMemberSysIds->params['flight_booking_id']) ? $CustomerMemberSysIds->params['flight_booking_id'] : 0;
		$getAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->gtxagencysysid);
		$this->siteName = (isset($getAgencyData['DisplayName']) && !empty($getAgencyData['DisplayName']))?$getAgencyData['DisplayName']: $this->siteName;
		$gstnnumber = isset($CustomerSession->params[0]['gstnnumber']) ? $CustomerSession->params[0]['gstnnumber'] : '';
		$GSTINFO = isset($getAgencyData['GSTINFO']) ? $getAgencyData['GSTINFO'] : '';
		$gstvalidate = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->gstvalidate($gstnnumber, $GSTINFO);
		$UserWalletStatus = (isset($this->_session->wallet['WalletStatus']) && !empty($this->_session->wallet['WalletStatus'])) ? $this->_session->wallet['WalletStatus'] : 0;

		$this->siteName = (isset($getAgencyData['DisplayName']) && !empty($getAgencyData['DisplayName']))?$getAgencyData['DisplayName']: $this->siteName;

		$FlightBookingTicketArr = [];
		$responseReturn = [];
		$BookingData = [];
		$BookingDataTemp = [];
		$BookingData = $BookingDataTemp = $FlightBookingData->params;
		$this->view->AgentSysId = $this->gtxagentsysid;
		$this->view->AgencySysId = $this->gtxagencysysid;
		$this->view->DisplayName = $getAgencyData['DisplayName'];
		$ICSourceSysId = $FlightBookingData->params[0]['ICSourceSysId'];

		// if($this->apimulticity == 3 && $ICSourceSysId == 3 && $route == 3){
		// 	$BookingData = [$BookingData[0]];
		// }
		
		if ($this->getRequest()->isXmlHttpRequest() && $FlightBookingData->params) {
			// echo '<pre>';print_r($param);die('ssss');


			
			//$FlightBookingData = $arrUrlData['FlightBookingData'];
			
			$flight_booking_id_Arr = $arrUrlData['flight_booking_id_Arr'];
			$genrateFlightQuery = $arrUrlData['genrateFlightQuery'];
			$paymentMode = isset($arrUrlData['paymentMode']) ? $arrUrlData['paymentMode'] : 0;
			$Remark = isset($arrUrlData['Remark']) ? $arrUrlData['Remark'] : '';
			$usewallet = isset($arrUrlData['usewallet']) ? $arrUrlData['usewallet'] : 0;
			$CustomerSysIdGTX = $genrateFlightQuery['arrIds']['CustomerSysId'];
			$TPSysId = $genrateFlightQuery['arrIds']['TPSysId'];
			$MasterTPSysId = $genrateFlightQuery['arrIds']['MasterTPSysId'];
			$apiTraceId = $param['traceId'];
			
			$PaymentStatus = isset($apiResponse['FlightBookingData'][0]['PaymentStatus']) ? $apiResponse['FlightBookingData'][0]['PaymentStatus'] : '0';
			$CurrentStatus = isset($apiResponse['FlightBookingData'][0]['CurrentStatus']) ? $apiResponse['FlightBookingData'][0]['CurrentStatus'] : '0';
			if ($PaymentStatus == 130 && ($CurrentStatus == 142 || $CurrentStatus == 141)) {
				$strReturnURL = $this->baseUrl . "flight/booking-confirmed-new/".$TPSysId;
				echo json_encode(["success" => false, 'redirect' => true, 'message' => 'Booking already success.','url' => $strReturnURL]);
				exit;
			}
			if ($PaymentStatus == 22) {
				$strReturnURL = $this->baseUrl . "flight/booking-confirmed-new/".$TPSysId;
				echo json_encode(["success" => false, 'redirect' => true, 'message' => 'Payment already success.','url' => $strReturnURL]);
				exit;
			}
			// echo '<pre>';print_r($apiResponse['FlightBookingData']);
			// die('ssss');

			$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
			if($this->IsTJFlightAPI){
				$SupplierType = 2;
			}else{
				$SupplierType = 1;
			}
			// echo '<pre>';print_r($sessionFlightSearchParams->params);die;
			$getMarkup = $this->getCancellationChargeNew($intCountryCode, 1, $SupplierType); ///$this->getMarkup($intCountryCode);
			$CencelattionData = (isset($getMarkup['CencelattionData'][0]['IsCancellationProtection']) && trim($getMarkup['CencelattionData'][0]['IsCancellationProtection']) == 1) ? 1 : 0;
			$CPPercentVal = (isset($getMarkup['CencelattionData'][0]['CPPercentVal']) && !empty($getMarkup['CencelattionData'][0]['CPPercentVal'])) ? (int)$getMarkup['CencelattionData'][0]['CPPercentVal'] : 0;

			$checkFlightOTP = $objFlight->CheckPaymentSTatus('tbl_flight_booking', $apiTraceId);
			
			$couponVal = isset($checkFlightOTP['couponVal']) ? $checkFlightOTP['couponVal'] : 0;
			$couponApply = isset($checkFlightOTP['couponApply']) ? $checkFlightOTP['couponApply'] : 0;
			$generateOTP = isset($checkFlightOTP['generateOTP']) ? $checkFlightOTP['generateOTP'] : 0;
			$IsCancellationProtection = isset($checkFlightOTP['IsCancellationProtection']) ? $checkFlightOTP['IsCancellationProtection'] : 0;


			if ($generateOTP != 1) {
				echo json_encode(["success" => false, 'redirect' => true, 'message' => 'OTP not verified. contact with our support team.']);
				exit;
			}
			$CashBalance = 0;
			$dataArray = array(
				'AgencySysId' => $this->gtxagencysysid,
				'SearchFlightTraceId' => $apiTraceId
			);
			// if ($ICSourceSysId == 3) {
			// 	$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetAgencyBalance($dataArray);
			// 	$CashBalance = (float) isset($response['CashBalance']) ? $response['CashBalance'] : 0;
			// } elseif ($ICSourceSysId == 7) {
			// 	$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetAgencyBalanceTJ($dataArray, $this->gtxagencysysid);
			// 	$CashBalance = isset($response['user']['bs']['totalBalance']) ? (float) $response['user']['bs']['totalBalance'] : 0;
			// }
			$route = $sessionFlightSearchParams->params['route'];
			$interNationalSearch = $sessionFlightSearchParams->params['interNationalSearch'];

			$adultCount = $sessionFlightSearchParams->params['adults'];
			$childCount = $sessionFlightSearchParams->params['child'];
			$infantCount = $sessionFlightSearchParams->params['infant'];
			$intMemberCount = $adultCount + $childCount + $infantCount;
			if ($ICSourceSysId == 11 && $this->IsETRAVFlightAPI) {
				$getAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->gtxagencysysid);
				$this->siteName = (isset($getAgencyData['DisplayName']) && !empty($getAgencyData['DisplayName']))?$getAgencyData['DisplayName']: $this->siteName;
				$Contacts = !empty($getAgencyData['PrimaryMobileNo'])?$getAgencyData['PrimaryMobileNo']:'';
				
				$request = array(
					'Auth_Header'=>array(
						"IP_Address" => $_SERVER['REMOTE_ADDR'],
						"Request_Id" => $apiTraceId,
						"IMEI_Number" => "3434334343111"
					)
				);
			}
				
				$DataS = array(
					'apidata'=>$request,
					'memberCount'=>$intMemberCount,
					'JourneyType'=>$route,
					'interNationalSearch'=>$interNationalSearch,
					'searchID'=>$apiTraceId,
					'ICSourceSysId'=>$ICSourceSysId,
					'APIMode' => $this->APIMode
				);
				
				$getData['BookingData'] = $FlightBookingData;
				$url = $this->GTXAPIDEFAULT.'/flight/v3/getbalnace';
				$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
				// echo "DataS<pre>";print_r($response);die;
				$CashBalance = isset($response['results'])?(float) $response['results']:0;
				
				// if ($CashBalance >= (float) $PublishedFare) {
				// } else {
				// 	$responseS = array('success' => false, 'message' => 'Oops insufficient supplier wallet balance. please contact with agency', 'url' => '');
				// 	echo json_encode($responseS);
				// 	exit;
				// }
			
			
			$BagPrice = 0;
			$InbBagPrice = 0;
			$MealPrice = 0;
			$InbMealPrice = 0;
			$SeatPrice = 0;

			if ($customer) {
				foreach ($customer as $val) {
					$BagPrice += $val['BagPrice'];
					$MealPrice += $val['MealPrice'];
					$SeatPrice += $val['SeatPrice'];
				}
			}
			// if ($SelectedBaggSessionNew->params) {
			// 	foreach ($SelectedBaggSessionNew->params as $val) {
			// 		if($ICSourceSysId == 16){
			// 			foreach ($val as $val_) {
			// 				$BagPrice += $val_['Price'];
			// 			}
			// 		}else{
			// 			$BagPrice += $val['Price'];
			// 		}
			// 	}
			// }
			// if ($SelectedMealSessionNew->params) {
			// 	foreach ($SelectedMealSessionNew->params as $val) {
			// 		if($ICSourceSysId == 16){
			// 			foreach ($val as $val_) {
			// 				$MealPrice += $val_['Price'];
			// 			}
			// 		}else{
			// 			$MealPrice += $val['Price'];
			// 		}
			// 	}
			// }

			// if ($SelectedMealSessionNewInb->params) {
			// 	foreach ($SelectedMealSessionNewInb->params as $val) {
			// 		$InbMealPrice += $val['Price'];
			// 	}
			// }
			// if ($SelectedBaggSessionNewInb->params) {
			// 	foreach ($SelectedBaggSessionNewInb->params as $val) {
			// 		$InbBagPrice += $val['Price'];
			// 	}
			// }
			
			// if ($selectedSeatSession->params) {
			// 	foreach ($selectedSeatSession->params as $values) {
			// 		foreach ($values as $val) {
			// 			$SeatPrice += $val['amount'];
			// 		}
			// 	}
			// }
			$MealFare = ($MealPrice + $InbMealPrice);
			$BaggFare = ($BagPrice + $InbBagPrice);
			//

			$PublishedFare = 0;
			$agencyMarkUp = 0;
			$gtxMarkup = 0;
			$offerFare = 0;
			$gtxMarkupGST = 0;
			$agencyMarkUpGST = 0;
			$TotalDiscount = 0;
			$misxItems_name = [];
			
			if ($BookingData) {
				foreach ($BookingData as $amount) {
					// if($ICSourceSysId == 7 || $ICSourceSysId == 3) {
					// 	$amount['NewPrice']['couponVal'] = $amount['FairRules']['couponVal'];
					// 	$amount['FairRules'] = $amount['NewPrice'];
					// }
					// echo "<pre>";print_r($amount['FairRules']);
					$AdditionalTxnFeePub = 0;
					$TotalBaseFare = 0;
					$TotalTaxsandFees = 0;
					if ($amount['FairRules']['FareBreakdown']) {
						foreach ($amount['FairRules']['FareBreakdown'] as $value) {

							$MF = $value['MF']; //Management Fee
							$TDS = $value['TDS']; //Management Fee
							$YQ = $value['YQ']; //Fuel Surcharge
							$AGST = $value['AGST']; //Airline GST Component
							$MFT = $value['MFT']; //Management Fee Tax
							// $OT = $value['OT']; //Other Charges
						    $OT = isset($value['OT'])?$value['OT']:$value['TaxBR']['OT']; //Other Charges

							$MU = $value['MU']; //Markup
							$YR = $value['YR']; //Carrier Misc Fee
							$other = $MF + $YQ + $AGST + $MFT + $OT + $YR;
							if ($ICSourceSysId == 3) {
								$other =  $MF + $AGST + $MFT + $OT + $YR;
							}
							$PBaseFare = $value['BaseFare'];
							$intTotalGST = $value['intTotalGST'];
							$FixedMarkUp = $value['FixedMarkUp'];
							$apiMarkup = $value['apiMarkup'];
							$IntCommission = $value['IntCommission'];
							$CommissionEarned = $value['CommissionEarned'];
							$CommisionPass = $value['CommisionPass'];
							$ServiceFee = $value['ServiceFee'];

							$paxPublishedFare = ($PBaseFare);
							$PassengerType = $value['PassengerType'];
							$PassengerCount = $value['PassengerCount'];
							$AdditionalTxnFeePub += $value['AdditionalTxnFeePub'];

							$TaxesFees = ($other + $intTotalGST + $FixedMarkUp + $apiMarkup + $IntCommission - $CommissionEarned);
							if ($ICSourceSysId == 3) {
								$TaxesFees = ($other + $intTotalGST + $FixedMarkUp + $apiMarkup + $ServiceFee + $TDS - $CommisionPass);
							}
							$TotalBaseFare += ($paxPublishedFare);
							$TotalTaxsandFees += ($TaxesFees);
						}
					}
					if($ICSourceSysId == 7 || $ICSourceSysId == 3){
						$PublishedFare += $PublishedFare__ = ($amount['FairRules']['PublishedFare']);
					}else{
						$PublishedFare += $PublishedFare__ = ($TotalBaseFare + $TotalTaxsandFees);
					}

					//echo "<pre>";print_r($amount['FairRules']);
					$AddiMarkup__ = isset($amount['FairRules']['AddiMarkup']) ? $amount['FairRules']['AddiMarkup'] : 0;
					$AddiTaxOnMarkup__ = isset($amount['FairRules']['AddiTaxOnMarkup']) ? $amount['FairRules']['AddiTaxOnMarkup'] : 0;

					//$PublishedFare += ($amount['FairRules']['PublishedFare'] + $AddiMarkup__ + $AddiTaxOnMarkup__);
					$agencyMarkUp += $amount['FairRules']['FixedMarkUp'] + $AddiMarkup__;
					$gtxMarkup += $amount['FairRules']['intGTXMarkUp'];
					$offerFare += $amount['FairRules']['OfferedFare'];
					$gtxMarkupGST += $amount['FairRules']['GTXMarkUpGST'];
					$agencyMarkUpGST += $amount['FairRules']['GSTOnMarkUp'] + $AddiTaxOnMarkup__;
					$SourceAirportCode = $amount['SourceAirportCode'];
					$DestAirportCode = $amount['DestAirportCode'];
					$FlightNumber = $amount['FlightNumber'];
					$AirlineName = $amount['AirlineName'];

					$Description = $SourceAirportCode . '-' . $DestAirportCode . '-' . $AirlineName . ' ' . $FlightNumber;
					$couponVal = isset($amount['FairRules']['couponVal']) ? $amount['FairRules']['couponVal'] : 0;
					$TotalDiscount += $couponVal;
					//$PublishedFare__ = isset($amount['FairRules']['PublishedFare'])?$amount['FairRules']['PublishedFare'] + $AddiMarkup__ + $AddiTaxOnMarkup__:0;
					$FixedMarkUp__ = isset($amount['FairRules']['FixedMarkUp']) ? $amount['FairRules']['FixedMarkUp'] + $AddiMarkup__ : 0;
					$GSTOnMarkUp__ = isset($amount['FairRules']['GSTOnMarkUp']) ? $amount['FairRules']['GSTOnMarkUp'] + $AddiTaxOnMarkup__ : 0;
					$PublishedFare__ = $PublishedFare__;
					//echo "<pre>";print_r($amount['FairRules']);
					// echo "<pre>";print_r($FixedMarkUp__);
					// echo "<pre>";print_r($GSTOnMarkUp__);
					$TotalFare = ($PublishedFare__ - $FixedMarkUp__ - $GSTOnMarkUp__);
					$TotalAmount = $PublishedFare__;
					$SubTotal = ($PublishedFare__ - $GSTOnMarkUp__);
					$TotalGST = ($GSTOnMarkUp__);
					$TotalFixedMarkUp = $FixedMarkUp__;
					$TotalcouponVal = $couponVal;

					$misxItems_name[] = [
						'AgencySysId' => $this->gtxagencysysid,
						'AgentSysId' => $this->gtxagentsysid,
						'MisxItems_name' => 'Flight',
						'Description' => $Description,
						'ItemQty' => 1,
						'ItemRates' => ($TotalFare * $this->CurrencyRate),
						'Total' => ($TotalFare * $this->CurrencyRate),
						'DiscountType' => ($TotalcouponVal * $this->CurrencyRate),
						'Discount' => 1,
						'TotalDiscount' => ($TotalcouponVal * $this->CurrencyRate),
						'TotalAmount' => ($TotalAmount * $this->CurrencyRate),
						'MarkupType' => '',
						'Markup' => ($TotalFixedMarkUp * $this->CurrencyRate),
						'TotalMarkup' => ($TotalFixedMarkUp * $this->CurrencyRate),
						'SubTotal' => ($SubTotal * $this->CurrencyRate),
						'ServiceFeeTotal' => ($TotalGST * $this->CurrencyRate),
						'GSTPercentage' => '18',
						'TotalGST' => ($TotalGST * $this->CurrencyRate),
						'SGST' => ($gstvalidate['SGST'] == 1) ? (($TotalGST * $this->CurrencyRate) / 2) : 0,
						'CGST' => ($gstvalidate['CGST'] == 1) ? (($TotalGST * $this->CurrencyRate) / 2) : 0,
						'IGST' => ($gstvalidate['IGST'] == 1) ? ($TotalGST * $this->CurrencyRate) : 0,
						'ItemsSACCode' => '',
					];
				}
			}
			// $PublishedFare = $ProtectionOnPublished = ($PublishedFare + $BaggFare + $MealFare + $SeatPrice - $couponVal);
			$PublishedFare = $ProtectionOnPublished = ($PublishedFare + $BaggFare + $MealFare + $SeatPrice);
			$TotalInvoiceValue = ($PublishedFare - $agencyMarkUpGST);
			$CPAmountWithTax = 0;
			//echo $PublishedFare.'='.$BaggFare.'='.$MealFare.'='.$SeatPrice.'===='.$TotalDiscount.'==='.$CPAmountWithTax;
			$CPAmount = 0;
			if ($IsCancellationProtection == 1) {
				$totalPayableAmount = ($PublishedFare);
				if ($CencelattionData == 1 && !empty($CPPercentVal)) {
					$CPAmount = ($totalPayableAmount * $CPPercentVal) / 100;
					$CPAmountWithTax = $CPAmount + ($CPAmount * 18 / 100);
				}
				$PublishedFare = ($PublishedFare + $CPAmountWithTax);
			}
			$PublishedFare = ($PublishedFare - $TotalDiscount);
			$TotalInvoiceValue = ($TotalInvoiceValue + $CPAmountWithTax);

			$isgstapply = isset($BookingData[0]['FairRules']['IsGSTRequired']) ? $BookingData[0]['FairRules']['IsGSTRequired'] : 0;
			$Currency = isset($BookingData[0]['FairRules']['Currency']) ? $BookingData[0]['FairRules']['Currency'] : 0;
			$itemCount = count($misxItems_name);
			if ($IsCancellationProtection == 1) {
				$misxItems_name[$itemCount] = array(
					'MisxItems_name' => 'Cancellation Protection',
					'Description' => 'Refund Upgrade',
					'ItemQty' => 1,
					'ItemRates' => ($CPAmountWithTax),
					'Total' => $CPAmountWithTax,
					'DiscountType' => 0,
					'Discount' => 0,
					'TotalDiscount' => 0,
					'TotalAmount' => 0,
					'MarkupType' => '',
					'Markup' => 0,
					'TotalMarkup' => 0,
					'SubTotal' => $CPAmountWithTax,
					'ServiceFeeTotal' => 0,
					'GSTPercentage' => 0,
					'TotalGST' => 0,
					'SGST' => 0,
					'CGST' => 0,
					'IGST' => 0,
					'ItemsSACCode' => '',
				);
			}
			$itemCount = count($misxItems_name);
			if (!empty($BaggFare) && $BaggFare > 0) {
				$misxItems_name[$itemCount] = array(
					'MisxItems_name' => 'Add ons',
					'Description' => 'Baggage',
					'ItemQty' => 1,
					'ItemRates' => ($BaggFare * $this->CurrencyRate),
					'Total' => ($BaggFare * $this->CurrencyRate),
					'DiscountType' => 0,
					'Discount' => 0,
					'TotalDiscount' => 0,
					'TotalAmount' => 0,
					'MarkupType' => '',
					'Markup' => 0,
					'TotalMarkup' => 0,
					'SubTotal' => ($BaggFare * $this->CurrencyRate),
					'ServiceFeeTotal' => 0,
					'GSTPercentage' => 0,
					'TotalGST' => 0,
					'SGST' => 0,
					'CGST' => 0,
					'IGST' => 0,
					'ItemsSACCode' => '',
				);
			}
			$itemCount = count($misxItems_name);
			if (!empty($MealFare) && $MealFare > 0) {
				$misxItems_name[$itemCount] = array(
					'MisxItems_name' => 'Add ons',
					'Description' => 'Meal',
					'ItemQty' => 1,
					'ItemRates' => ($MealFare * $this->CurrencyRate),
					'Total' => ($MealFare * $this->CurrencyRate),
					'DiscountType' => 0,
					'Discount' => 0,
					'TotalDiscount' => 0,
					'TotalAmount' => 0,
					'MarkupType' => '',
					'Markup' => 0,
					'TotalMarkup' => 0,
					'SubTotal' => ($MealFare * $this->CurrencyRate),
					'ServiceFeeTotal' => 0,
					'GSTPercentage' => 0,
					'TotalGST' => 0,
					'SGST' => 0,
					'CGST' => 0,
					'IGST' => 0,
					'ItemsSACCode' => '',
				);
			}
			$itemCount = count($misxItems_name);
			if (!empty($SeatPrice) && $SeatPrice > 0) {
				$misxItems_name[$itemCount] = array(
					'MisxItems_name' => 'Add ons',
					'Description' => 'Seat',
					'ItemQty' => 1,
					'ItemRates' => ($SeatPrice * $this->CurrencyRate),
					'Total' => ($SeatPrice * $this->CurrencyRate),
					'DiscountType' => 0,
					'Discount' => 0,
					'TotalDiscount' => 0,
					'TotalAmount' => 0,
					'MarkupType' => '',
					'Markup' => 0,
					'TotalMarkup' => 0,
					'SubTotal' => ($SeatPrice * $this->CurrencyRate),
					'ServiceFeeTotal' => 0,
					'GSTPercentage' => 0,
					'TotalGST' => 0,
					'SGST' => 0,
					'CGST' => 0,
					'IGST' => 0,
					'ItemsSACCode' => '',
				);
			}
			$Invoicedata = [
				'AgentSysId' => 0,
				'CustomerSysId' => $CustomerSysIdGTX,
                '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' => $gstnnumber,
				'Currency' => $this->CurrencyId,
				'TotalInvoiceValue' => ($TotalInvoiceValue * $this->CurrencyRate),
				'InvoiceStatus' => true,
				'TotalSGST' => ($gstvalidate['SGST'] == 1) ? (($agencyMarkUpGST * $this->CurrencyRate) / 2) : 0,
				'TotalCGST' => ($gstvalidate['CGST'] == 1) ? (($agencyMarkUpGST * $this->CurrencyRate) / 2) : 0,
				'TotalIGST' => ($gstvalidate['IGST'] == 1) ? ($agencyMarkUpGST * $this->CurrencyRate) : 0,
				'SumdiscountItem' => 0,
				'OtherDiscount' => ($TotalDiscount * $this->CurrencyRate),
				'otherDiscountVal' => ($TotalDiscount * $this->CurrencyRate),
				'TotalAdvance' => ($PublishedFare * $this->CurrencyRate),
				'TotalDueAmount' => 0,
				'InvoiceValue' => ($PublishedFare * $this->CurrencyRate),
				'notes' => 'Flight Ticket',
				'termsandcondition' => '',
				'client_state' => '',
				'Advance' => 0,
				'PaymentType' => 4,
				'paymentNote' => 'Online',
				'misxItems_name' => $misxItems_name,

			];

			// $response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->InvoiceCreate($Invoicedata, $BookingData);
			//  echo "<pre>";print_r($response);
			// echo "<pre>";print_r($Invoicedata);
			// die;
			// if ($this->gtxagencysysid == '4539') {
			
			// }

			$countTrip = (int) count($flight_booking_id);
			$update = array(
				'CancellationProtectionPrice' => ($CPAmountWithTax / $countTrip),
			);
			if ($flight_booking_id) {
				foreach ($flight_booking_id as $valid) {
					$where = "id = '" . $valid . "'";
					$objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
				}
			}
			$CancellationProtectionData['IsCancellationProtection'] = $IsCancellationProtection;
			$CancellationProtectionData['CancellationProtectionPrice'] = round($CPAmountWithTax, 2);
			$CancellationProtectionData['finalPackageCostWithMarkupnTax'] = $ProtectionOnPublished;
			$CurrencyId = new Zend_Session_Namespace('CurrencyId');

			$TempData = array(
				'BookingData' => $BookingData,
				'sessionFlightSearchParams' => $sessionFlightSearchParams->params,
				'FlightSearchUrl' => $FlightSearchUrl->params,
				'CustomerSession' => $CustomerSession->params,
				'ResponseFlightQuery' => $ResponseFlightQuery->params,
				'SelectedMealSessionNew' => $SelectedMealSessionNew->params,
				'SelectedBaggSessionNew' => $SelectedBaggSessionNew->params,
				'SelectedBaggSessionNewInb' => $SelectedBaggSessionNewInb->params,
				'SelectedMealSessionNewInb' => $SelectedMealSessionNewInb->params,
				'flight_booking_customer_id' => $flight_booking_customer_id->params,
				'CustomerMemberSysIds' => $CustomerMemberSysIds->params,
				'selectedSeatSession' => $selectedSeatSession->params,
				'CurrencyId' => $CurrencyId->params,
				'flight_booking_id_Arr' => $flight_booking_id_Arr,
				'_sessiondata' => $this->_session->session,
				'_wallet' => $this->_session->wallet,
				'CencelattionData' => isset($getMarkup['CencelattionData']) ? $getMarkup['CencelattionData'] : [],
				'CancellationProtectionData' => isset($CancellationProtectionData) ? $CancellationProtectionData : [],
				'Invoicedata' => !empty($Invoicedata) ? $Invoicedata : [],
				'validateCoupon' => $arrUrlData['validateCoupon'],
				'validateData' => $arrUrlData['validateData'],
				'genrateFlightQuery' => $arrUrlData['genrateFlightQuery'],
				'FlightBookingDataRiya' => $arrUrlData['FlightBookingDataRiya'],
				'paymentMode' => $paymentMode,
				'Remark' => $Remark,
				'usewallet' => $usewallet,
			);
			
			$FlightBookingTicketArr = [];
			$checkBooking = $this->objMdl->selectOne('tbl_flight_booking', ['id', 'status'], ['apiTraceId' => $param['traceId']], ['id' => 'ASC']);
			$Bookingstatus = isset($checkBooking['status']) ? $checkBooking['status'] : 0;
			if ($BookingData && $CashBalance >= (float) ceil($PublishedFare) && $Bookingstatus != 21 && $ICSourceSysId == 3) {
				foreach ($BookingData as $k => $values) {
					$AirlineName = $values['AirlineName'];
					$FlightNumber = $values['FlightNumber'];

					$BookingdataAPI = array(
						'FlightBookingData' => $values,
						'sessionFlightSearchParams' => $sessionFlightSearchParams->params,
						'CustomerSession' => $CustomerSession->params,
						'SelectedMealSessionNew' => $SelectedMealSessionNew->params,
						'SelectedBaggSessionNew' => $SelectedBaggSessionNew->params,
						'SelectedMealSessionNewInb' => $SelectedMealSessionNewInb->params,
						'SelectedBaggSessionNewInb' => $SelectedBaggSessionNewInb->params,
						'selectedSeatSession' => $selectedSeatSession->params,
					);
					if ($values['IsLCC'] == 1) {
						/// This action perform on bookflight action
					} else {
						$IsLCC = true;
						if ($route == 3 && $k == 0) {
							$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightBooking($BookingdataAPI, $k);
						} elseif ($route == 3) {
							$apiFlightBooking = new Zend_Session_Namespace('apiFlightBooking');
							$response = $apiFlightBooking->params;
						}
						if ($route == 1 || $route == 2) {
							$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightBooking($BookingdataAPI, $k);
						}

						$FlightBookingTicketArr[] = $response;
						$ResponseStatus = isset($response['Response']['ResponseStatus']) ? $response['Response']['ResponseStatus'] : '0';
						$ErrorMessage = isset($response['Response']['Error']['ErrorMessage']) ? $response['Response']['Error']['ErrorMessage'] : '';
						if ($ResponseStatus == 1) {
							$update = array(
								'API_Response_Ticket' => json_encode($response),
								'status' => 21, // Booking Confirmed Ticket In Process
							);
							$where = "id = " . $flight_booking_id[$k]; //exit;
							$objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
						} else {
							echo json_encode(["success" => false, 'redirect' => true, 'message' => 'Unable to book ' . $AirlineName . ' ' . $FlightNumber . ' please choose another flight.']);
							exit;
						}
					}
				}
			} elseif ($BookingData && $CashBalance < (float) ceil($PublishedFare) && ($ICSourceSysId == 3 || $ICSourceSysId == 7 || $ICSourceSysId == 11)) {
				$Caption = 'Unsaficiant balance';
				$subject = 'Pay Now';
				$getAgencySupplierUserData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencySupplierUserData($apiSupplierData);
				$getAgencySupplierUserData = isset($getAgencySupplierUserData['data']) ? $getAgencySupplierUserData['data'] : array();
				$html = new Zend_View();
				$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
				$html->assign(array('getAgencySupplierUserData' => $getAgencySupplierUserData, 'getAgencyData' => $getAgencyData, 'ICSourceSysId' => $ICSourceSysId, 'FlightBookingInb' => $FlightBookingInb, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, 'baseUrl' => $this->baseUrl));

				$supplierBodyText = $html->render('unsaficiant-balance.phtml');
				$configsSupp = [
					'to' => trim($getAgencyData['PrimaryEmail']),
					'fromName' => $this->siteName,
					'fromEmail' => $getAgencyData['PrimaryEmail'],
					'subject' => $subject,
					'bodyHtml' => $supplierBodyText,
				];
				$returnmail = $this->objHelperGeneral->mailSentByElastice($configsSupp, $Caption);
				echo json_encode(["success" => false, 'redirect' => true, 'message' => 'Sorry we could not process your booking. Please contact our customer support.']);
				exit;
			}
			if ($Bookingstatus != 21) {
				$TempData['FlightBookingTicketArr'] = $FlightBookingTicketArr;
			}
			$TempData['apiFlightBooking'] = $FlightBookingTicketArr;
			//die('s');
			$insertArr = array(
				'TraceId' => $param['traceId'],
				'json_data' => json_encode($TempData),
				'created_at' => date('Y-m-d-H-i-s'),
			);
			
			$this->objMdl->rv_delete('tbl_temp_data', array('TraceId = ?' => $param['traceId']));
			$objFlight = new Travel_Model_FlightMaster();
			$objFlight->InsertFlightData('tbl_temp_data', $insertArr);

			$markuparray['intAgentMarkUpAmount'] = 0;
			$markuparray['intAgencyMarkUpAmount'] = round($agencyMarkUp);
			$markuparray['intGTXMarkUpAmount'] = round($gtxMarkup);
			$markuparray['intTotalAmount'] = round($offerFare);
			$markuparray['intTax'] = 0;
			$markuparray['intTotalGTXTaxAmount'] = 0;
			$markuparray['GTXServiceTaxAmount'] = round($gtxMarkupGST);
			$markuparray['AgentServiceTaxAmount'] = round($agencyMarkUpGST);
			$markuparray['AgentsCustomServiceTaxAmount'] = 0;
			$markuparray['Pax'] = 1;
			$markuparray['TotalDiscount'] = 0;
			$markuparray['CurrencyType'] = $this->CurrencyId; //currency Id
			$markuparray['MarketPlaceId'] = 2; //b2b or b2c


			$currentcreditBalance = 0;
			if ($usewallet == 1 || $paymentMode == 1 && $this->_session->session) {
				$WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CustomerWallaetBalance($this->_session->session['CustomerSysId']);
				$currentcreditBalance = (isset($WallaetBalance['WalletBalance'][0]['BalanceAmount']) && !empty($WallaetBalance['WalletBalance'][0]['BalanceAmount'])) ? $WallaetBalance['WalletBalance'][0]['BalanceAmount'] : 0;

				if ($PublishedFare > $currentcreditBalance && $paymentMode == 2) {
					$PublishedFare = ($PublishedFare - $currentcreditBalance);
				}
			}


			$encryptMarkUpData = base64_encode(json_encode($markuparray));

			$this->_helper->layout->disableLayout();
			$this->_helper->viewRenderer->setNoRender(true);
			$param = $this->getRequest()->getParams();
			$customerData = $CustomerSession->params[0];
			$AgentSysId = $this->gtxagentsysid;
			$AgencySysId = $this->gtxagencysysid;
			$intTPSysId = $TPSysId;
			$intCustSysId = $customerData['CustomerSysId'];
			$firstName = $customerData['FirstName'];
			$emailId = $customerData['EmailId'];
			$mobileNumber = $customerData['Contacts'];
			$lastInsertId = $param['traceId']; //base64_encode(implode(',', $flight_booking_id));

			$encryptedData = new Travel_Model_AtomAES();
			$lastInsertId = $encryptedData->encrypt($lastInsertId, SECURITYKEY, SECURITYKEY);

			$FLBookingID = base64_encode(implode(',', $flight_booking_id)); //$param['traceId']; //$this->GUID();
			$guid = $this->GUID();
			$walletCode = $this->walletCode($AgentSysId, $guid, ceil($PublishedFare), $AgencySysId, $intTPSysId, $intCustSysId, $encryptMarkUpData);

			$strReturnURL = $this->baseUrl . "flight/check-payment";
			$requestLogs = [
				"AgentSysId" => $this->gtxagentsysid,
				"AgencySysId" => $this->gtxagencysysid,
				"guid" => $this->guid,
				"intTPSysId" => json_encode([$TPSysId]),
				"intCustSysId" => $customerData['CustomerSysId'],
				"firstName" => $customerData['FirstName'],
				"emailId" => $customerData['EmailId'],
				"mobileNumber" => $customerData['Contacts'],
				"lastInsertId" => $param['traceId'],
				"PublishedFare" => $PublishedFare,
				"walletCode" => $walletCode,
				"markuparray" => $markuparray,
			];
			if ($ICSourceSysId == 3) {
				$Supplier = 'TBO';
			} elseif ($ICSourceSysId == 7) {
				$Supplier = 'TRIPJACK';
			} else {
				$Supplier = 'SERIESFARE';
			}
			$logParams = [
				"user_id"      => 1,
				"AgencySysId"  => $this->gtxagencysysid,
				"custom_error" => "Payment Request",
				'error'        => '',
				"text_udf"     => ['response' => ''], // Response
				"char_udf"     => ['request' => $requestLogs], // Request
				"udf1"         => $param['traceId'],
				"udf5"                     => 'paymentrequest',
				"from_destination"         => ($strFlightRoute == '3') ? implode(',', $sessionFlightSearchParams->params['from']) : $sessionFlightSearchParams->params['from'],
				"to_destination"           => ($strFlightRoute == '3') ? implode(',', $sessionFlightSearchParams->params['to']) : $sessionFlightSearchParams->params['to'],
				"Pax"                      => (int)($sessionFlightSearchParams->params['adults'] + $sessionFlightSearchParams->params['childs'] + $sessionFlightSearchParams->params['infants']),
				"source"                   => 1,
				"flight_type"              => (int)$strFlightRoute,
				"Supplier"                 => $Supplier,
				"status"       => 1,
			];
			Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);

			if ($paymentMode == 1 && $currentcreditBalance >= $PublishedFare && $this->_session->session && $UserWalletStatus == 1) {
				$rem = 'Flight Booking';
				$DebitFromWallet = array(
					'Remark' => $rem . ' ' . $Remark,
					'Amount' => $PublishedFare,
					'CustomerSysId' => $this->_session->session['CustomerSysId'],
					'CurrencyType' => 1,
					'PlanType' => 1,
					'PaymentMode' => 'Online Wallet',
					'ReferenceNo' => $TPSysId,
				);
				$Url = $this->gtxBtoBsite . 'gtxwebservices/customer-wallet/update-b2c-wallet-balance/';

				$updateBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->DebitFromWallet($DebitFromWallet, $Url);
				$Walletstatus = $updateBalance['status'];
				$TransactionId = $updateBalance['TransactionId'];
				if ($Walletstatus == 1) {
					$checkwalletbalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CustomerWallaetBalance($this->_session->session['CustomerSysId']);
					$checkwalletbalance['WalletStatus'] = $checkwalletbalance['status'];
					$this->_session->wallet = (isset($checkwalletbalance['status']) && $checkwalletbalance['status'] == 1) ? $checkwalletbalance : '';
					foreach ($flight_booking_id as $key => $booking_id) {
						$arrPayment = [
							"error_Message" => 'Wallet Transaction',
							"error" => '',
							"GUID" => $TransactionId,
							"TransactionId_debit" => $TransactionId,
						];
						$arrPayment['paymentStatus'] = 1;
						$where = "id = " . $booking_id; //exit;
						$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $arrPayment, $where);
					}
					$encryptedData = new Travel_Model_AtomAES();
					$lastInsertId = $encryptedData->encrypt($apiTraceId, SECURITYKEY, SECURITYKEY);
					if ($updated) {
						$response = array('success' => true, 'paymentMode' => $paymentMode, 'message' => 'success', 'url' => 'flight/book-flight/' . $apiTraceId . '/' . $lastInsertId);
						echo json_encode($response);
						exit;
					} else {
						$response = array('success' => false, 'paymentMode' => $paymentMode, 'message' => 'Oops something went wrong.', 'url' => '');
						echo json_encode($response);
						exit;
					}
					// if ($this->gtxagencysysid == '2656') {
					// 	echo "<pre>";
					// 	print_r($DebitFromWallet);
					// 	echo "<pre>";
					// 	print_r($updateBalance);
					// 	exit;
					// }
				}
			}
			echo json_encode(["success" => true, 'guid' => $guid, 'paymentMode' => $paymentMode, 'amount' => ceil($PublishedFare), 'walletCode' => $walletCode, 'stringData' => $encryptMarkUpData, 'strReturnURL' => $strReturnURL, 'lastInsertId' => $lastInsertId, 'FLBookingID' => $FLBookingID, 'TPSysId' => $intTPSysId, 'UserData' => ['name' => $firstName, 'email' => $emailId, 'mobile' => $mobileNumber, 'CustomerSysId' => $intCustSysId]]);
			exit;
		}
	}

	public function checkPaymentAction()
	{
		$this->_helper->layout->disableLayout();
		$this->_helper->viewRenderer->setNoRender(true);
		$param = $this->getRequest()->getPost();
		// if ($this->gtxagencysysid == '110804') {
		// $param = json_decode('{"encdata":"1f1f9884cbce1f8a52030264bffe1116b0e67f5354c3effea1f3f21d8bc7e40c3fc3caea53158d7b83cea78e9992ed4af6b12be840f7ebd7f2c632c41a52621f1164878765286f835f9fdb29b9723fccf95f6a3f49f79bf702d87323a49243e57f07aa5de77f72af87010020939e7866604d2dc5d3cdf71ece6f86b03bcb95a9350050c29039a9e245e194340e08de06676152b3cb509a82cad4f4e51bcdfd5b8baa44b3ec6597880bea0ee39d73638a6e6abb5e7b146946b29f1e7a389d07949231410d4fac8e416acaa7f14bd2dbcd9f9050458bf0fc7123571c5dd90113b9687f7d654bca0f3cd23129e9f85cfe44ccd5adad624a7e9613bdfc0b3e0c19bed04bb6845b3d5f099837a456593a16d96ce8809bae3af953e221ffaebbb51709f07f2ed433c8bfe865235aa7628b29a40a6d11d69760f77131e6c92d7bac811ca515deda286e89f105b9b7944a109a2ffecbe944c2a31c9cf36be89a4a0a11e2750fc84a4d42420ebddf8f9eb7ef0a2bb2c8b689b58eff640c4fafbee74d1847e17f80866f0b11f4e542d84bdb066f76dba17c433207fa4d8629a51f6b4c5e1c15441348cea8a9264a7322e783f5a85ca708f6ddfc283325bf972cb4d170ba39b259f3532c87f997b2d46991610534fac57fc83755669f65c29abf592496a06b60d52ba8008428c019d344cae48adf76246bf5a322c2830b115c07bbfd8846c209a553010dbfff7186c5118a18b8713e8cef192ae8bce599ec06e21aff73ae16887dd99b0b7573bee9c8e4043ba8957c5d407b1882acb571443407d3787b668005fda7abf201c3ea8edb1ce7f712f9587ebfd45fe0d6c48d20020fffc4e86572e8f993b171e0a8519f0650e7f732f6debbf37f50235ffde56252c240d89c8628e774421d285a580e5e7753288d95a975191f422ae22b422b8a454c786c0f134c2b13101bcf0ef091b48ba5bd699b4b0ac5577cf8fce2e6bfc0e76f05001d82d1859189d4dab6961f975099d58b7902be74c1e1571d529276341abda4e41d4391964d7713c2dd68146403edc6b715f3ffbbf484082ebb0eded6961edae47bd5c245b0c476de25a188181c9a881350b42212c09e2e6effa12b9613a8726865d2f34134ec2911cf1b540871633c11a18e31a66c74cb19489ab392467afc7a09aa7ee5c9dc8930bcc62fc1c518c3993e9a25d10b8697a4e4d14d21c1933e1c175edb0052bf3ccdb99e5971e11ce2a00b9719715dd33bc942886d51ee033c4b8931273425c0835c421d260323dcbf74cf814bebc142f3593d7e93f85dc71027ee3296d8418ff1a4b9adc6258f5efc181d9779b493745b6cf03e3054859fccb2bb5e147aa3959beee434112316c41d3e6f255b981e2d26a2ee9d06cbf570dc23a4133e","type":"CCAVENUE"}',1);
		// }
		$strFilePath = "payment/log/" . date('Y-m-d-H-i-s') . "_response.json";
		Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($param));
		if ($this->gtxagencysysid == '2656') {
			//echo '<pre>';print_r($param);die;
			// ini_set('display_errors', 1);
			// ini_set('display_startup_errors', 1);
			// error_reporting(E_ALL);
		}


		if (!empty($param)) {
			$PGType = (isset($param['type']) && !empty($param['type'])) ? $param['type'] : '';
			$transactionResponse = new Travel_Model_TransactionResponse();
			$transactionResponse->setRespHashKey($this->respHashKey);
			$transactionResponse->setResponseEncypritonKey($this->aesResponseKey);
			$transactionResponse->setSalt($this->aesResponseIv);
			if ($PGType == 'easebuzz') {
				$transactionResponse->setRespHashKey($this->respHashKey);
				$transactionResponse->setResponseEncypritonKey($this->aesRequestKey);
				$transactionResponse->setSalt($this->aesRequestKey);
				$returnPerameter = $transactionResponse->decryptResponseInEasebuzz($param['encdata']);
				$returnPerameter = json_decode($returnPerameter, 1);
				$returnPerameter['f_code'] = ($returnPerameter['status'] == 'success') ? 'Ok' : '';
				$returnPerameter['bank_txn'] = $returnPerameter['easepayid'];
				$returnPerameter['mer_txn'] = $returnPerameter['txnid'];
				$returnPerameter['ipg_txn_id'] = $returnPerameter['bank_ref_num'];
				$returnPerameter['mmp_txn'] = $returnPerameter['bank_ref_num'];
				$returnPerameter['desc'] = $returnPerameter['error_Message'];
				$returnPerameter['error'] = $returnPerameter['error_Message'];
			} elseif ($param['type'] == 'CCAVENUE') {
				$workingKey = $this->CCAVENUEWorkingKey; //$checkPaymentSetting['PaymentSecretPwd'];
				$encResponse = $param["encdata"];
				$rcvdString = $transactionResponse->decrypt_cc($encResponse, $workingKey);
				$decryptValues = explode('&', $rcvdString);
				$dataSize = sizeof($decryptValues);
				$bank_ref_no = $order_id = $tracking_id = $status_message = $merchant_param5 = $order_status = '';
				for ($i = 0; $i < $dataSize; $i++) {
					$information = explode('=', $decryptValues[$i]);
					if (isset($information[0])) {
						if ($information[0] == 'order_status') {
							$order_status = $information[1];
						}
						if ($information[0] == 'merchant_param5') {
							$merchant_param5 = $information[1];
						}
						if ($information[0] == 'status_message') {
							$status_message = $information[1];
						}
						if ($information[0] == 'tracking_id') {
							$tracking_id = $information[1];
						}
						if ($information[0] == 'order_id') {
							$order_id = $information[1];
						}
						if ($information[0] == 'bank_ref_no') {
							$bank_ref_no = $information[1];
						}
					}
				}
				$returnPerameter['f_code'] = ($order_status == 'Success') ? 'Ok' : '';
				$returnPerameter['bank_txn'] = $tracking_id;
				$returnPerameter['mer_txn'] = $order_id;
				$returnPerameter['ipg_txn_id'] = $bank_ref_no;
				$returnPerameter['mmp_txn'] = $tracking_id;
				$returnPerameter['desc'] = $status_message;
				$returnPerameter['error'] = $order_status;
				$returnPerameter['udf9'] = $merchant_param5;
			} else {
				$returnPerameter = $transactionResponse->decryptResponseIntoArray($param['encdata']);
			}

			$checkVal = $transactionResponse->validateResponse($returnPerameter, $PGType);
			
			
			$strFilePath = "payment/log/" . date('Y-m-d-H-i-s') . "_decode_response.json";
			Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($returnPerameter));
			if ($checkVal == true) {

				$status = $returnPerameter["f_code"];
				$mer_txn = $returnPerameter["mer_txn"];
				$decodePerameter = Zend_Json::decode(base64_decode($returnPerameter["udf9"]), true);
				
				$encypetedId = $decodePerameter[5];
				$TrxId = $decodePerameter[6];
				$TrxId = explode(',', base64_decode($TrxId));
				$GUID = $returnPerameter['mmp_txn'];
				$error = isset($returnPerameter['error']) ? $returnPerameter['error'] : '';
				$error_Message = isset($returnPerameter['desc']) ? $returnPerameter['desc'] : 0;
				$objFlight = new Travel_Model_FlightMaster();
				$arrPayment = [
					"error_Message" => $error_Message,
					"error" => $error,
					"GUID" => $GUID,
				];

				$encryptedData = new Travel_Model_AtomAES();
				$id = $encryptedData->decrypt($encypetedId, SECURITYKEY, SECURITYKEY);
				
				$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $id], ['id' => 'ASC']);
				$response = json_decode($temp_data['json_data'], true);

				// if ($this->gtxagencysysid == '110804') {
				// 	echo "<pre>";
				// 	print_r($decodePerameter);
				// 	echo "<pre>";
				// 	print_r($response);
				// 	die;
				// }
				if (PAYMENT_GATWAY_LOGS) {
					//Write Request Logs starts...
					$logParams = [
						"user_id"      => 1,
						"AgencySysId"  => $this->gtxagencysysid,
						"custom_error" => "Payment Response",
						'error'        => '',
						"text_udf"     => ['response' => $returnPerameter], // Response
						"char_udf"     => ['request' => ''], // Request
						"udf1"         => $id,
						"status"       => 2,
					];
					Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
				}


				//echo "<pre>";print_r($returnPerameter);die;
				$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
				$FlightBookingData->params = $response['BookingData'];

				$Invoicedata = new Zend_Session_Namespace('Invoicedata');
				$Invoicedata->params = $response['Invoicedata'];

				$CurrencyId = new Zend_Session_Namespace('CurrencyId');
				$CurrencyId->params = $response['CurrencyId'];
				Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CurrencyData($this->gtxagencysysid, $response['CurrencyId']);
				$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
				$sessionFlightSearchParams->params = $response['sessionFlightSearchParams'];
				$FlightSearchUrl = new Zend_Session_Namespace('FlightSearchUrl');
				$FlightSearchUrl->params = $response['FlightSearchUrl'];
				$CustomerSession = new Zend_Session_Namespace('CustomerSession');
				$CustomerSession->params = $response['CustomerSession'];
				$ResponseFlightQuery = new Zend_Session_Namespace('ResponseFlightQuery');
				$ResponseFlightQuery->params = $response['ResponseFlightQuery'];
				$SelectedMealSessionNew = new Zend_Session_Namespace('SelectedMealSessionNew');
				$SelectedMealSessionNew->params = $response['SelectedMealSessionNew'];
				$SelectedBaggSessionNew = new Zend_Session_Namespace('SelectedBaggSessionNew');
				$SelectedBaggSessionNew->params = $response['SelectedBaggSessionNew'];
				$SelectedBaggSessionNewInb = new Zend_Session_Namespace('SelectedBaggSessionNewInb');
				$SelectedBaggSessionNewInb->params = $response['SelectedBaggSessionNewInb'];
				$SelectedMealSessionNewInb = new Zend_Session_Namespace('SelectedMealSessionNewInb');
				$SelectedMealSessionNewInb->params = $response['SelectedMealSessionNewInb'];
				$flight_booking_customer_id = new Zend_Session_Namespace('flight_booking_customer_id');
				$flight_booking_customer_id->params = $response['flight_booking_customer_id'];
				$CustomerMemberSysIds = new Zend_Session_Namespace('CustomerMemberSysIds');
				$CustomerMemberSysIds->params = $response['CustomerMemberSysIds'];
				$selectedSeatSession = new Zend_Session_Namespace('selectedSeatSession');
				$selectedSeatSession->params = $response['selectedSeatSession'];
				$user = new Zend_Session_Namespace('User');
				$user->session = $response['_sessiondata'];
				$user->wallet = $response['_wallet'];
				$bookingidd = $response['BookingData'][0]['bookingId'];
				$ICSourceSysId = $response['BookingData'][0]['ICSourceSysId'];
				$ResponseFlightQuery = new Zend_Session_Namespace('ResponseFlightQuery');
				$FlightQueryids = $ResponseFlightQuery->params;
				$MasterTPSysId = $FlightQueryids['arrIds']['MasterTPSysId'];
				$TPSysId = $FlightQueryids['arrIds']['TPSysId'];
				$VersionId = $FlightQueryids['arrIds']['VersionId'];
				///echo "<pre>";print_r($response['_wallet']);die;

				if ($id && $TrxId) {
					if ($status == "Ok") {

						$arrPayment['paymentStatus'] = 1;
						foreach ($TrxId as $key => $flight_booking_id) {
							$where = "id = " . $flight_booking_id; //exit;
							$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $arrPayment, $where);
							try {
								$postFieldArray = array(
									'MasterTPSysId' => $MasterTPSysId,
									'TPSysId' => $TPSysId,
									'TrxId' => $TrxId,
									'VersionId' => $VersionId[$key],
									'ErrorCode' => 6,
									'field' => 'PaymentStatus',
									'StatusCode' => 22,
									'XRefBookingId' => '',
									'APIBookingRes' => '',
								);

								$strFilePath = "flight/payment/" . time() . "_success_payment_request.json";
								Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $postFieldArray);
								$model = new Gtxwebservices_Model_Webservices();
								$result = $model->updateFlightPaymentFailed($postFieldArray);
								//echo "<pre>";print_r($result);die('3');

							} catch (Exception $error) {
							}
						}
						if ($ICSourceSysId == 7) {
							$this->genrateinvoice($bookingidd);
						}

						if (isset($ICSourceSysId) && $ICSourceSysId == 8) {
							$CheckSoldInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckSoldInventory($response['BookingData'][0]['bookingId']);
							if ($sessionFlightSearchParams->params['route'] == 2) {
								$CheckSoldInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckSoldInventory($response['BookingData'][1]['bookingId']);
							}
						}

						if ($updated) {
							if ($PGType == 'easebuzz') {
								$this->_redirect('flight/book-flight/' . $id . '/' . $param['encdata'] . '?type=' . $PGType);
							} else {
								$this->_redirect('flight/book-flight/' . $id . '/' . $param['encdata'] . '?type=' . $PGType);
							}
						}
					} elseif ($status == "C") {
						// cancelled by User
						$arrPayment['paymentStatus'] = 2;
						foreach ($TrxId as $key => $flight_booking_id) {
							$where = "id = " . $flight_booking_id; //exit;
							$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $arrPayment, $where);
							try {
								$postFieldArray = array(
									'MasterTPSysId' => $MasterTPSysId,
									'TPSysId' => $TPSysId,
									'TrxId' => $TrxId,
									'VersionId' => $VersionId[$key],
									'ErrorCode' => 6,
									'field' => 'PaymentStatus',
									'StatusCode' => 20,
									'XRefBookingId' => '',
									'APIBookingRes' => '',
								);

								$strFilePath = "flight/payment/" . time() . "_cancelbyuser_request.json";
								Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $postFieldArray);
								$model = new Gtxwebservices_Model_Webservices();
								$result = $model->updateFlightPaymentFailed($postFieldArray);
							} catch (Exception $error) {
							}
						}
						if (isset($ICSourceSysId) && $ICSourceSysId == 8) {
							$CheckReleaseInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckReleaseInventory($response['BookingData'][0]['bookingId']);
							if ($sessionFlightSearchParams->params['route'] == 2) {
								$CheckReleaseInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckReleaseInventory($response['BookingData'][1]['bookingId']);
							}
						}
						if ($updated) {
							$this->_redirect('flight/payment-failed/' . $id);
						}
					} else {

						// payment failed case...
						$arrPayment['paymentStatus'] = 3;
						foreach ($TrxId as $key => $flight_booking_id) {
							$where = "id = " . $flight_booking_id; //exit;
							$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $arrPayment, $where);
							try {
								$postFieldArray = array(
									'MasterTPSysId' => $MasterTPSysId,
									'TPSysId' => $TPSysId,
									'TrxId' => $TrxId,
									'VersionId' => $VersionId[$key],
									'ErrorCode' => 6,
									'field' => 'PaymentStatus',
									'StatusCode' => 20,
									'XRefBookingId' => '',
									'APIBookingRes' => '',
								);
								$strFilePath = "flight/payment/" . time() . "_cancelbyuser_request.json";
								Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $postFieldArray);
								$model = new Gtxwebservices_Model_Webservices();
								$result = $model->updateFlightPaymentFailed($postFieldArray);
							} catch (Exception $error) {
							}
						}
						if (isset($ICSourceSysId) && $ICSourceSysId == 8) {
							$CheckReleaseInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckReleaseInventory($response['BookingData'][0]['bookingId']);
							if ($sessionFlightSearchParams->params['route'] == 2) {
								$CheckReleaseInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckReleaseInventory($response['BookingData'][1]['bookingId']);
							}
						}
						//if ($updated) {
						$this->_redirect('flight/payment-failed/' . $id);
						//}
					}
				}
			} else {
				echo 'Please contact to administrator';
				exit;
			}
		}
	}

	public function paymentFailedAction()
	{
		$param = $this->getRequest()->getParams();
		//echo"<pre>";print_r($param);die;
		$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
		$FlightBookingDataInbound = new Zend_Session_Namespace('FlightBookingDataInbound');
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$FlightSearchUrl = new Zend_Session_Namespace('FlightSearchUrl');
		$CustomerSession = new Zend_Session_Namespace('CustomerSession');
		$CustomerMemberSysIds = new Zend_Session_Namespace('CustomerMemberSysIds');
		$LeadPaxSession = new Zend_Session_Namespace('LeadPaxSession');
		$CustomerMembersSession = new Zend_Session_Namespace('CustomerMembersSession');
		$this->view->CustomerMemberSysIds = $CustomerMemberSysIds->params;
		$this->view->LeadPaxSession = $LeadPaxSession->params;
		$this->view->CustomerMembersSession = $CustomerMembersSession->params;
		$this->view->CustomerSession = $CustomerSession->params;
		$this->view->FlightSearchUrl = $FlightSearchUrl->params;
		$class = $sessionFlightSearchParams->params['class'];
		//echo"<pre>";print_r($param['id']);die;
		$this->view->traceId = $param['TraceId'];
		$this->view->departure_date = $sessionFlightSearchParams->params['strDepatureDate'];
		$this->view->return_dates = $sessionFlightSearchParams->params['strReturnDate'];
		$this->view->class = $class;
		$this->view->param = $param;
		$this->view->CurrencyRate = $this->CurrencyRate;
		$this->view->CurrencyTitle = $this->CurrencyTitle;
		$this->view->sessionFlightSearchParams = $sessionFlightSearchParams->params;
		$this->view->FlightBookingData = $FlightBookingData->params;
		$this->view->FlightBookingDataInbound = $FlightBookingDataInbound->params;
	}

	public function removebaggageAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$SelectedMealSessionNew = new Zend_Session_Namespace('SelectedMealSessionNew');
			$SelectedBaggSessionNew = new Zend_Session_Namespace('SelectedBaggSessionNew');

			$SelectedMealSessionNewInb = new Zend_Session_Namespace('SelectedMealSessionNewInb');
			$SelectedBaggSessionNewInb = new Zend_Session_Namespace('SelectedBaggSessionNewInb');
			$param = $this->getRequest()->getParams();

			$CustomerSysId = $param['CustomerSysId'];
			if ($param['segment'] == 1 && $param['type'] == 'Baggage') {
				unset($SelectedBaggSessionNew->params[$CustomerSysId]);
			}
			if ($param['segment'] == 2 && $param['type'] == 'BaggageInb') {
				unset($SelectedBaggSessionNewInb->params[$CustomerSysId]);
			}
			if ($param['segment'] == 1 && $param['type'] == 'Meal') {
				unset($SelectedMealSessionNew->params[$CustomerSysId]);
			}
			if ($param['segment'] == 2 && $param['type'] == 'MealInb') {
				unset($SelectedMealSessionNewInb->params[$CustomerSysId]);
			}
			$response = array('success' => true);
			echo json_encode($response);
			exit;
		}
	}

	public function viewDetailsAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$param = $this->getRequest()->getParams();
			//print_r($param);die;
			$this->view->traceId = $param['traceId'];
			$objFlight = new Travel_Model_FlightMaster();
			$searchtrace = array('apiTraceId' => $param['TraceId']);

			$FlightBookingInb = [];
			$FlightBooking = $objFlight->PeningFlightBookingDataTripJack('tbl_flight_booking', $param['TraceId'], 1);
			$FlightBookingInb = $objFlight->PeningFlightBookingDataTripJack('tbl_flight_booking', $param['TraceId'], 2);
			//	echo '<pre>';print_r($FlightBooking);
			//die('s');
			$this->view->FlightBooking = $FlightBooking;
			$this->view->FlightBookingInb = $FlightBookingInb;
			$this->view->baseUrl = $this->baseUrl;
			$this->view->CurrencyRate = $this->CurrencyRate;
			$this->view->CurrencyTitle = $this->CurrencyTitle;
			// echo '<pre>';print_r($FlightBooking);
			// echo '<pre>';print_r($BookingData);
			// die;
		}
	}
	public function bookingstatusAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$param = $this->getRequest()->getParams();
			//print_r($param);die;
			$bookemail = $param['bookemail'];
			$objFlight = new Travel_Model_FlightMaster();
			$FlightBooking__ = $objFlight->bookingstatusNew('tbl_flight_booking', $param['bookingid']);

			if (!empty($FlightBooking__['data'])) {
				$status = $FlightBooking__['data'][0]['status'];
				$BookingId = $FlightBooking__['data'][0]['BookingId'];
                                $TPSysId = $FlightBooking__['data'][0]['TPSysId'];
				$ICSourceSysId = $FlightBooking__['data'][0]['ICSourceSysId'];
				$EmailId = isset($FlightBooking__['passenger'][0]['EmailId']) ? $FlightBooking__['passenger'][0]['EmailId'] : '';

				if (strtolower($bookemail) === $EmailId) {
					if ($status == 1) {
						$response = array('success' => true, 'BookingId' => $BookingId ,'TPSysId' => $TPSysId, 'ICSourceSysId' => $ICSourceSysId, 'message' => 'Booking Confirmed');
						echo json_encode($response);
						exit;
					} else {
						$response = array('success' => false, 'message' => 'Pending Booking');
						echo json_encode($response);
						exit;
					}
				} else {
					$response = array('success' => false, 'message' => 'Email Id not matched11');
					echo json_encode($response);
					exit;
				}
			} else {
				$response = array('success' => false, 'message' => 'Booking not found');
				echo json_encode($response);
				exit;
			}
		}
	}

	public function viewDetailsPendingAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$param = $this->getRequest()->getParams();
			//print_r($param);die;
			$this->view->traceId = $param['traceId'];
			$objFlight = new Travel_Model_FlightMaster();

			$FlightBookingInb = [];
			$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['TraceId'], 1);
			$FlightBookingInb = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['TraceId'], 2);
			//echo '<pre>';print_r($FlightBooking);
			//die('s');
			$this->view->FlightBooking = $FlightBooking;
			$this->view->FlightBookingInb = $FlightBookingInb;
			$this->view->baseUrl = $this->baseUrl;
			$this->view->CurrencyRate = $this->CurrencyRate;
			$this->view->CurrencyTitle = $this->CurrencyTitle;
			// echo '<pre>';print_r($param);
			// echo '<pre>';print_r($BookingData);
			// die;
		}
	}

	public function cancelTicketAction()
	{
		$this->checklogin();
		$this->_helper->layout->disableLayout();
		$param = $this->getRequest()->getParams();
		$objFlight = new Travel_Model_FlightMaster();
		$FlightBookingInb = [];
		$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId'], 1);
		$FlightBookingInb = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId'], 2);
		$ICSourceSysId = $FlightBooking['data']['ICSourceSysId'];
		$API_Response_Ticket = $FlightBooking['data']['API_Response_Ticket'];
		$APIBookingId = !empty($FlightBooking['data']['APIBookingId'])?$FlightBooking['data']['APIBookingId']:$FlightBooking['data']['BookingId'];
		$Source = $API_Response_Ticket['Response']['Response']['FlightItinerary']['Source'];
		$SupplierType = ($ICSourceSysId == 3) ? 1 : 2;
		$apiTraceId = $FlightBooking['data']['apiTraceId'];
		if ($FlightBooking['data']['IsInternational'] == 1) {
			$intCountryCode = 'INT';
		} else {
			$intCountryCode = 'IN';
		}
		if ($this->getRequest()->isPost() && $this->getRequest()->isXmlHttpRequest()) {
			$intMarkUp = $this->getCancelCharge($intCountryCode, $SupplierType);
			// echo '<pre>';
			// print_r($intMarkUp);
			// print_r($FlightBooking['data']);

			// die('dd');
			$sectorsSelectors = $param['sectorsSelectors'];
			$TicketId = $param['TicketId'];
			$PaxDetails = $param['PaxDetails'];
			$requestType = $param['requestType'];
			$cRemarks = $param['cRemarks'];
			$traceId = $param['traceId'];
			$bookingId = $param['bookingId'];
			$sectorsDates = $param['sectorsDates'];
			$trips = [];
			$TicketIdArr = [];
			if ($ICSourceSysId == 3) {
				$API_Response_Ticket = json_decode($FlightBooking['data']['API_Response_Ticket'], true);
				$Source = $API_Response_Ticket['Response']['Response']['FlightItinerary']['Source'];
				if ($sectorsSelectors) {
					foreach ($sectorsSelectors as $sec) {
						$sectorEX = explode('-', $sec);
						$sector[] = array('Origin' => $sectorEX[0], 'Destination' => $sectorEX[1]);
					}
				}
				$data = array(
					"bookingId" => $bookingId,
					"remarks" => $cRemarks,
					"apiTraceId" => $apiTraceId,
					"CancellationType" => 2,
					"sectorsSelectors" => $sector,
					"PaxDetails" => $PaxDetails,
					"TicketId" => $TicketId,
					"requestType" => $requestType,
					"Source" => $Source,
				);
				if ($TicketId) {
					foreach ($TicketId as $tdid) {
						$TicketIdArr[$tdid] = $tdid;
					}
				}
				$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetAmendmentChargesTBO($data);
				$intChangeRequestStatus = $ChangeResponse['Response']['ResponseStatus'];
			} else {
				if ($sectorsSelectors) {
					foreach ($sectorsSelectors as $key => $sec) {
						$sectorEX = explode('-', $sec);

						$dateEX = $sectorsDates[$key];
						$paxArray = [];
						if ($PaxDetails) {
							foreach ($PaxDetails as $pax) {
								$PaxDetailsEX = explode('-', $pax);
								$paxArray[] = array(
									'fn'    =>  $PaxDetailsEX[0],
									'ln'    =>  $PaxDetailsEX[1]
								);
							}
						}
						$trips[] = array(
							'src' => $sectorEX[0],
							'dest' => $sectorEX[1],
							'departureDate' => $dateEX,
							'travellers' => $paxArray,
						);
					}
				}

				$data = array(
					"bookingId" => $APIBookingId,
					"type" => 'CANCELLATION', //$requestType,
					"remarks" => $cRemarks,
					"trips" => $trips,
					"apiTraceId" => $apiTraceId,
				);
				
				$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetAmendmentCharges($data);
				$intChangeRequestStatus = $ChangeResponse['status']['success'];
				$trips = isset($ChangeResponse['trips']) ? $ChangeResponse['trips'] : '';
			}

			// echo '<pre>';print_r($ChangeResponse);
			// die;

			$AmendmentRequestData = new Zend_Session_Namespace('AmendmentRequestData');
			$AmendmentRequestData->params = $data;
			if ($intChangeRequestStatus == 1) {
				$update = array(
					"ChangeRequestRes" => json_encode($ChangeResponse),
					"ChangeRequestStatus" => $intChangeRequestStatus,
					//"status" => ($requestType == 1) ? 6 : 7,
				);
				$this->objMdl->rv_update('tbl_flight_booking', $update, ['BookingId=?' => $bookingId]);
			} else {
				// $data = array(
				// 	"status" => ($requestType == 1) ? 6 : 7,
				// );
				// $this->objMdl->rv_update('tbl_flight_booking', $data, ['BookingId=?' => $bookingId]);
				//$where = "BookingId = " . $bookingId;
				// $where = "BookingId = " . $bookingId; //exit;
				//$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $data, $where);

			}
			$html = new Zend_View();
			$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
			$html->assign(array('FlightBooking' => $FlightBooking, 'FlightBookingInb' => $FlightBookingInb, 'ChangeResponse' => $ChangeResponse, 'baseUrl' => $this->baseUrl, 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate, 'ICSourceSysId' => $ICSourceSysId, 'TicketId' => $TicketIdArr, 'intMarkUp' => $intMarkUp));
			$bodyText = $html->render('getcancelcharge.phtml');
			$response = array('success' => true, 'msg' => 'Done', 'html' => $bodyText);
			echo json_encode($response);
			exit;
		}
		// echo '<pre>';print_r($FlightBooking);
		// die('dd');
		$this->view->FlightBooking = $FlightBooking;
		$this->view->FlightBookingInb = $FlightBookingInb;
		$this->view->ICSourceSysId = $ICSourceSysId;
		$this->view->baseUrl = $this->baseUrl;
		$this->view->CurrencyRate = $this->CurrencyRate;
		$this->view->CurrencyTitle = $this->CurrencyTitle;
		$this->view->bookingId = $param['bookingId'];
	}
	public function cancelTicketApiAction()
	{
		$this->checklogin();
		$this->_helper->layout->disableLayout();
		$param = $post = $this->getRequest()->getParams();
		
		$objFlight = new Travel_Model_FlightMaster();
		if (!empty($param['TPSysId'])) {
			$TPSysId = $param['TPSysId'];
			$PostData = ['TPSysId' => $TPSysId, 'version' => null, 'IsApproved' => 0, 'SecurityKey' => SECURITYKEY];
			$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingdetailsapi($PostData);
			// echo '<pre>';print_r($apiResponse);die;
			if ($apiResponse['status'] == 1 && isset($apiResponse['FlightBookingData'])) {
				$FlightBookingData = isset($apiResponse['FlightBookingData']) ? $apiResponse['FlightBookingData'] : [];
				$XRefBookingId = isset($FlightBookingData[0]['XRefBookingId']) ? trim($FlightBookingData[0]['XRefBookingId']) : '';
				$customer = $apiResponse['customer'];
				
				$customerTripWise = [];
				if ($customer) {
					foreach ($customer as $key => $val) {
						$customerTripWise[$val['VersionId']][] = $val;
					}
				}
				if (!empty($apiResponse)) {
				} else {
					echo json_encode([
						'status' => [
							'success' => false,
							'httpStatus' => 405,
						],
						'message' => 'Oops API not working please refresh this page',
					]);
					exit;
				}

				if ($this->getRequest()->isXmlHttpRequest()) {
					// echo '<pre>';print_r($post);die;
					$APIBookingId = isset($FlightBookingData[0]['APIBookingId']) ? trim($FlightBookingData[0]['APIBookingId']) : '';
					$IsInternational = isset($FlightBookingData[0]['IsInternational']) ? trim($FlightBookingData[0]['IsInternational']) : '';
					$TPSysId = isset($FlightBookingData[0]['TPSysId']) ? trim($FlightBookingData[0]['TPSysId']) : '';
					$ICSourceSysId = isset($FlightBookingData[0]['ICSourceSysId']) ? trim($FlightBookingData[0]['ICSourceSysId']) : '';
					$cType = isset($post['cType']) ? $post['cType'] : '';
					$requestTypeValue = isset($post['requestTypeValue']) ? $post['requestTypeValue'] : '';
					$requestType = isset($post['requestType']) ? $post['requestType'] : '';
					$cRemarks = isset($post['cRemarks']) ? $post['cRemarks'] : '';
					$PaxDetails = isset($post['PaxDetails']) ? $post['PaxDetails'] : [];
					$sectorsSelectors = [];
					// echo '<pre>';print_r($post);die;
					$trips = [];
					if ($PaxDetails) {
						foreach ($PaxDetails as $key=>$value) {
							$secc = $value['sec'];
							$sectorsSelectors[] = $secc['sectorsSelectors'];
							$sectorEX = explode('-',$secc['sectorsSelectors']);
							$Dates = isset($secc['Dates'][0])?$secc['Dates'][0]:'';
							$APIBookingId = isset($secc['APIBookingId'][0])?$secc['APIBookingId'][0]:'';
							$travellers = [];
							if (!empty($secc['PaxDetails'])) {
								foreach ($secc['PaxDetails'] as $val) {
									$expdetails = explode('__',$val);
									$PaxDetailsEX = explode('-',$expdetails[0]);
									$travellers[] = array(
										'fn'    =>  trim($PaxDetailsEX[0]),
										'ln'    =>  trim($PaxDetailsEX[1]),
										'TPPaxSysId'    =>  trim($expdetails[3]),
										'TicketId'    =>  isset($expdetails[4])?$expdetails[4]:0,
									);
									
								}
							}
							$trips[] = array(
								'src' => $sectorEX[0],
								'dest' => $sectorEX[1],
								'departureDate' => $Dates,
								'travellers' => $travellers,
								'BookingId' => $APIBookingId,
							);               
						}
					}

					$dataSH = array(
						"bookingId" => $APIBookingId,
						"type" => ($ICSourceSysId == 7)?'CANCELLATION':$requestTypeValue,
						"remarks" => $cRemarks,
						// "trips" => $trips,
					);
					if(!empty($trips)){
						$dataSH['trips'] = $trips;
					}else{
						$bookingDataByAPI = $apiResponse['FlightBookingData'];
						$customer = $customerTripWise;
						if ($bookingDataByAPI) {
							foreach ($bookingDataByAPI as $value) {
								$APIBookingId = $value['APIBookingId'];
								$SEctors = trim($value['SourceAirportCode']) . '-' . trim($value['DestAirportCode']);
								$departureDate = str_replace('T', ' ', $value['LocalFromTime']);
								$travellers = [];
								if ($customer[$value['AirVersionId']]) {
									foreach ($customer[$value['AirVersionId']] as $key => $valuePax) {
										$FirstName = $valuePax['FirstName'];
										$LastName = $valuePax['LastName'];
										$TPPaxSysId = $valuePax['TPPaxSysId'];
										$TicketNumber = $valuePax['TicketNumber'];
										$travellers[] = array(
											'fn'    =>  trim($FirstName),
											'ln'    =>  trim($LastName),
											'TPPaxSysId'    =>  trim($TPPaxSysId),
											'TicketId'    =>  trim($TicketNumber),
										);
									}
								}
								$trips[] = array(
									'src' => trim($value['SourceAirportCode']),
									'dest' => trim($value['DestAirportCode']),
									'departureDate' => date('Y-m-d', strtotime($departureDate)),
									'travellers' => $travellers,
									'BookingId' => $APIBookingId,
								);
							}
						}
						$dataSH['trips'] = $trips;
					}
					// echo '<pre>';print_r(($dataSH));
					//  die('dddd');
					$DataS = array(
						'apidata' => $dataSH,
						'memberCount' => 0,
						'JourneyType' => 0,
						'interNationalSearch' => $IsInternational,
						'searchID' => $XRefBookingId,
						'BookingId' => $XRefBookingId,
						'TPSysId' => $TPSysId,
						'MasterAgencySysId' => $this->gtxagencysysid,
						'UserSysId' => !empty($this->gtxagentsysid)?$this->gtxagentsysid:0,
						'ICSourceSysId' => $ICSourceSysId,
						'remarks' => $cRemarks,
						'requestTypeValue' => $requestTypeValue,
						'sectors' => !empty($sectorsSelectors)?$sectorsSelectors:['Full Itinerary'],
					);
					// echo '<pre>';print_r(($DataS));
					//  die('dddd');
					if($cType == 1){
						if($this->gtxagencysysid == '1'){
							$url = $this->GTXAPIDEFAULT.'/flight/v3/getamendmentcharge';
						}else{
							$url = 'https://gtxapi.hellogtx.com/flight/v3/getamendmentcharge';
						}
						
						$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, [], $url);
						// echo '<pre>';print_r(($DataS));
						// echo '<pre>';print_r(($ChangeResponse));
						// die;
						// $ResponseStatus = isset($ChangeResponse['status']) ? $ChangeResponse['status'] : false;
						// $ErrorMessage = isset($ChangeResponse['message']) ? $ChangeResponse['message'] : '';
						$html = new Zend_View();
						$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
						$html->assign(array('apiResponse' => $apiResponse,'ChangeResponse'=>$ChangeResponse, 'baseUrl' => $this->baseUrl, 
							'CurrencyTitle' => $this->CurrencyTitle, 
							'CurrencyRate' => $this->CurrencyRate, 'ICSourceSysId' => $ICSourceSysId
						));
						$bodyText = $html->render('getcancelchargeapi.phtml');
						$response = array('success' => true, 'msg' => 'Done', 'html' => $bodyText);
						echo json_encode($response);
						exit;
					}else{
						if($this->gtxagencysysid == '1'){
							$url = $this->GTXAPIDEFAULT.'/flight/v3/submitamendment';
						}else{
							$url = 'https://gtxapi.hellogtx.com/flight/v3/submitamendment';
						}
						// echo '<pre>';print_r(json_encode($DataS));
					 	// die('dddd');
						$SubmitResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, [], $url);
						$ResponseStatus = isset($SubmitResponse['status']) ? $SubmitResponse['status'] : false;
						$ErrorMessage = isset($SubmitResponse['message']) ? $SubmitResponse['message'] : '';
						$message = isset($SubmitResponse['amendmentSubmit']['message']) ? $SubmitResponse['amendmentSubmit']['message'] : '';
						$ChangeRequestId = isset($SubmitResponse['amendmentSubmit']['ChangeRequestId']) ? $SubmitResponse['amendmentSubmit']['ChangeRequestId'] : '';
						// echo '<pre>';print_r(json_encode($DataS));
						// echo '<pre>';print_r(($SubmitResponse));
						// die;
						if($ResponseStatus == 1){
							$response = array('success' => true, 'msg' => 'Request submited sucessfully', 'ChangeRequestId'=>$ChangeRequestId);
							echo json_encode($response);
							exit;
						}else{
							$response = array('success' => true, 'msg' => $ErrorMessage, 'ChangeRequestId'=>'NA');
							echo json_encode($response);
							exit;
						}
						// echo '<pre>';print_r(($SubmitResponse));
						// echo '<pre>';print_r(($DataS));
						// die('dddd');
					}
					
					
				}

				$BaseFare = 0;
				$Taxesfee = 0;
				$CommDiscount = 0;
				$TotalPay = 0;
				$couponVal = 0;
				if ($FlightBookingData) {
					foreach ($FlightBookingData as $key => $value) {
						foreach ($value['FareBreakdown'] as $FareBreakdown) {
							$BaseFare += isset($FareBreakdown['BaseFare']) ? ($FareBreakdown['BaseFare']) : 0;
							$couponVal += isset($FareBreakdown['couponVal']) ? ($FareBreakdown['couponVal']) : 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;
							$Taxesfee += ($FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
							$TotalPay += ($BaseFare_ + $FixedMarkUp + $GSTOnMarkUp + $CommissionEarned + $Tax + $TDSEarn);
						}
					}
				}
				
				// pr($customerTripWise);die;
				$BagPrice = 0;
				$MealPrice = 0;
				$SeatPrice = 0;
				$TripCount = count($FlightBookingData);
				if ($apiResponse['customer']) {
					foreach ($apiResponse['customer'] as $paxk => $vals) {
						$BagPrice += ($vals['BagPrice'] / $TripCount);
						$MealPrice += ($vals['MealPrice'] / $TripCount);
						$SeatPrice += ($vals['SeatPrice'] / $TripCount);
					}
				}

				$fareData = [
					'Currency' => isset($FlightBookingData[0]['CurrencySymbol']) ? trim($FlightBookingData[0]['CurrencySymbol']) : 'INR',
					'BaseFare' => round($BaseFare, 2),
					'Taxesfee' => round($Taxesfee, 2),
					'CommDiscount' => round($CommDiscount, 2),
					'BagPrice' => round($BagPrice, 2),
					'MealPrice' => round($MealPrice, 2),
					'SeatPrice' => round($SeatPrice, 2),
					'couponVal' => round($couponVal, 2),
					'TotalSSR' => round($BagPrice + $MealPrice + $SeatPrice, 2),
					'TotalPay' => round((($TotalPay + $BagPrice + $MealPrice + $SeatPrice) - $couponVal), 2),
				];

				if (!empty($apiResponse)) {

					$UserData = $this->_session->session;
					$this->view->customerTripWise = $customerTripWise;
					$this->view->UserData = $UserData;
					$this->view->apiResponse = $apiResponse;
					$this->view->fareData = $fareData;
					$this->view->baseUrl = $this->baseUrl;
					$this->view->CurrencyRate = $this->CurrencyRate;
					$this->view->CurrencyTitle = $this->CurrencyTitle;
					$this->view->BookingID = $XRefBookingId;

				}
			} else {
				echo json_encode([
					'status' => [
						'success' => false,
						'httpStatus' => 405,
					],
					'message' => 'Data not found',
				]);
				exit;
			}
		}
	}

	public function submitAmendmentAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			// ini_set('display_errors', 1);
			// ini_set('display_startup_errors', 1);
			// error_reporting(E_ALL);
			$this->_helper->layout->disableLayout();
			$param = $this->getRequest()->getParams();

			$objFlight = new Travel_Model_FlightMaster();
			$FlightBookingInb = [];
			$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId'], 1);
			$FlightBookingInb = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['bookingId'], 2);
			$ICSourceSysId = $FlightBooking['data']['ICSourceSysId'];
			$SupplierType = ($ICSourceSysId == 3) ? 1 : 2;
			$apiTraceId = $FlightBooking['data']['apiTraceId'];
			$FlightQueryids = json_decode($FlightBooking['data']['FlightQueryids'], true);
			$MasterTPSysId = $FlightQueryids['arrIds']['MasterTPSysId'];
			$TPSysId = $FlightQueryids['arrIds']['TPSysId'];
			if ($FlightBooking['data']['IsInternational'] == 1) {
				$intCountryCode = 'INT';
			} else {
				$intCountryCode = 'IN';
			}
			$intMarkUp = $this->getCancelCharge($intCountryCode, $SupplierType);

			if ($FlightBooking['data']['IsInternational'] == 1) {
				$ItemSourceType = 2;
			} else {
				$ItemSourceType = 1;
			}
			$getAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getAgencyData($this->gtxagencysysid);
			$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->getSupportContact(96, 1, $ItemSourceType);
			if (isset($getSupportContact['EmailId']) && !empty($getSupportContact['EmailId'])) {
				$MasterPrimaryEmailTo = trim($getSupportContact['EmailId']);
			} else {
				$MasterPrimaryEmailTo = $getAgencyData['PrimaryEmail'];
			}
			$this->siteName = (isset($getAgencyData['DisplayName']) && !empty($getAgencyData['DisplayName']))?$getAgencyData['DisplayName']: $this->siteName;
			// echo '<pre>';
			// print_r($MasterPrimaryEmailTo);
			// echo '<pre>';
			// print_r($getAgencyData);
			// die;
			$AmendmentRequestData = new Zend_Session_Namespace('AmendmentRequestData');
			$data = $AmendmentRequestData->params;

			// echo '<pre>';
			// print_r($data);
			// die;
			$bookingId = $param['bookingId'];
			$requestType = $param['requestType'];
			$PaxDetails = $param['PaxDetails'];
			$cRemarks = $param['cRemarks'];
			$TicketId = $param['TicketId'];
			$sectorsSelectors = $param['sectorsSelectors'];
			if ($requestType == 1) {
				$requestTypeValue = 'Full Cancellation';
				$requestTypeStatus = 6;
			} elseif ($requestType == 2) {
				$requestTypeValue = 'Partial Cancellation';
				$requestTypeStatus = 7;
			} else {
				$requestTypeValue = 'Change Itinerary / Reissue';
				$requestTypeStatus = 14;
			}
			$TotalrefundAmount = 0;
			$Totalamendmentcharges = 0;
			$ResponseStatus = 0;
			$GetAmendmentDetails = [];
			if ($ICSourceSysId == 3) {
				// $AmendmentChargesSession = new Zend_Session_Namespace('AmendmentChargesSession');
				// $AmendmentCharges = $AmendmentChargesSession->params;

				$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->cancelFlightBooking($data);
				// $SubmitAmendment = new Zend_Session_Namespace('SubmitAmendment');
				// $ChangeResponse = $SubmitAmendment->params;

				$intChangeRequestStatus = isset($ChangeResponse['Response']['ResponseStatus']) ? $ChangeResponse['Response']['ResponseStatus'] : '';
				$ChangeRequestId = isset($ChangeResponse['Response']['TicketCRInfo'][0]['ChangeRequestId']) ? $ChangeResponse['Response']['TicketCRInfo'][0]['ChangeRequestId'] : '';
				$intErrorCode = isset($ChangeResponse['Response']['Error']['ErrorCode']) ? $ChangeResponse['Response']['Error']['ErrorCode'] : 0;
				$strErrorMessage = isset($ChangeResponse['Response']['Error']['ErrorMessage']) ? $ChangeResponse['Response']['Error']['ErrorMessage'] : '';
				$amendmentId = $ChangeRequestId;
				if ($intChangeRequestStatus == 1) {
					foreach ($ChangeResponse['Response']['TicketCRInfo'] as $TicketCRInfo) {
						$RequestId = $TicketCRInfo['ChangeRequestId'];
						$TicketId = $TicketCRInfo['TicketId'];
						$Changedata = array(
							"ChangeRequestId" => $RequestId,
							"apiTraceId" => $apiTraceId
						);
						$GetAmendmentDetails[$TicketId] = $GetDetails = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetAmendmentDetailsTBO($Changedata);
						$refundAmount = (isset($GetDetails['RefundedAmount']) && !empty($GetDetails['RefundedAmount'])) ? $GetDetails['RefundedAmount'] : 0;
						$IntamendmentCharges = (isset($GetDetails['CancellationCharge']) && !empty($GetDetails['CancellationCharge'])) ? $GetDetails['CancellationCharge'] : 0;
						$FinalrefundAmount = ($refundAmount - $intMarkUp);
						$TotalrefundAmount += ($FinalrefundAmount > 0) ? $FinalrefundAmount : 0;
						$Totalamendmentcharges += $IntamendmentCharges;
					}
					if ($TotalrefundAmount > 0 || $Totalamendmentcharges > 0) {
						$ResponseStatus = 1;
					}
				}

				$travellers = [];
				$trips = [];
				if ($PaxDetails) {
					foreach ($PaxDetails as $px) {
						$PaxDetailsEXP = explode('-', $px);
						$travellers[] = array(
							'fn' => $PaxDetailsEXP[0],
							'ln' => $PaxDetailsEXP[1],
						);
					}
				}
				if ($sectorsSelectors) {
					foreach ($sectorsSelectors as $sec) {
						$secEXP = explode('-', $sec);
						$trips[] = array(
							'src' => $secEXP[0],
							'dest' => $secEXP[1],
							'travellers' => $travellers,
						);
					}
				}
				$data['trips'] = $trips;
			} else {
				$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetSubmitAmendment($data);
				//$ChangeResponse = json_decode('{"bookingId":"TJS109100423997","amendmentId":"8600891243","status":{"success":true,"httpStatus":200}}',1);
				// $SubmitAmendment = new Zend_Session_Namespace('SubmitAmendment');
				// $ChangeResponse = $SubmitAmendment->params;
				
				$intChangeRequestStatus = $ChangeResponse['status']['success'];
				$strErrorMessage = $ChangeResponse['status']['httpStatus'];
				$amendmentId = $ChangeResponse['amendmentId'];
				$data_details = array(
					"amendmentId" => $amendmentId,
					"apiTraceId" => $apiTraceId,
				);
				$GetAmendmentDetails = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetAmendmentDetails($data_details);
				if (isset($GetAmendmentDetails['trips']) && !empty($GetAmendmentDetails['trips'])) {
					foreach ($GetAmendmentDetails['trips'] as $i => $val) {
						foreach ($val['travellers'] as $ik => $amendmentInfo) {
							$refundAmount = (isset($amendmentInfo['refundableamount']) && !empty($amendmentInfo['refundableamount'])) ? $amendmentInfo['refundableamount'] : '0';
							$IntamendmentCharges = (isset($amendmentInfo['amendmentCharges']) && !empty($amendmentInfo['amendmentCharges'])) ? $amendmentInfo['amendmentCharges'] : '0';
							$FinalrefundAmount = ($refundAmount - $intMarkUp);
							$TotalrefundAmount += ($FinalrefundAmount > 0) ? $FinalrefundAmount : 0;
							$Totalamendmentcharges += $IntamendmentCharges;
						}
					}
					$ResponseStatus = 1;
				}
			}

			// echo '<pre>';
			// print_r($TotalrefundAmount);
			// echo '<pre>';
			// print_r($Totalamendmentcharges);
			// echo '<pre>';
			// print_r($GetAmendmentDetails);
			// echo '<pre>';
			// print_r($ChangeResponse);
			// die('dd');
			if ($intChangeRequestStatus == 1) {
				try {
					$dataModification = array(
						"ChangeRequestId" => $amendmentId,
						"ChangeRequestStatus" => 1,
						"AgencySysId" => $this->gtxagencysysid,
						"MasterTPSysId" => $this->gtxagencysysid,
						"BookingId" => $bookingId,
						"RequestType" => $requestTypeValue,
						"Remarks" => $cRemarks,
						"servicefee" => $intMarkUp,
						"apiTraceId" => $apiTraceId,
						"status" => ($ResponseStatus == 1) ? 1 : 0,
						"nameData" => '',
						"RefundMode" => 'Online',
						"refundedamount" => $TotalrefundAmount,
						"sectors" => implode('<br>', $sectorsSelectors),
						"amendmentcharges" => $Totalamendmentcharges,
						"RequestData" => json_encode($data),
						"APIResponseData" => json_encode($ChangeResponse),
						"created_at" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
						"updated_at" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
					);
					
					$objFlight->InsertFlightData('tb_flight_modification', $dataModification);
					$postFieldArray = array(
						'PaxDetails' => json_encode($PaxDetails),
						'MasterTPSysId' => $MasterTPSysId,
						'TPSysId' => $TPSysId,
						'StatusType' => 120,
						'ChangeRequestId' => $amendmentId,
						'ChangeRequestStatus' => 1,
						'ChangeRequestRes' => json_encode($ChangeResponse),
						'dataModification' => json_encode($dataModification),
						"AgentSysId" => $this->gtxagentsysid,
						"AgencySysId" => $this->gtxagencysysid
					);

					$model = new Gtxwebservices_Model_Webservices();
					$result = $model->updateFlightCancellation($postFieldArray);

					$update = array(
						"ChangeRequestId" => ($amendmentId),
						"ChangeRequestRes" => json_encode($ChangeResponse),
						"ChangeRequestStatus" => $intChangeRequestStatus,
						"status" => ($requestType == 1) ? 6 : 7,
					);
					$this->objMdl->rv_update('tbl_flight_booking', $update, ['BookingId=?' => $bookingId]);

					if ($TicketId && $ICSourceSysId == 3) {
						foreach ($TicketId as $tid) {
							$whereArray = array(
								'TicketId=?'    =>  $tid,
								'BookingId=?'    =>  $bookingId
							);
							$updatePax = array(
								"ChangeRequestId" => $amendmentId,
								"ChangeRequestStatus" => ($requestType == 1) ? 6 : 7,
							);
							$this->objMdl->rv_update('tbl_flight_booking_customer', $updatePax, $whereArray);
						}
					} else {
						foreach ($PaxDetails as $pax) {
							$PaxDetailsEX = explode('-', $pax);
							$whereArray = array(
								'FirstName=?'    =>  $PaxDetailsEX[0],
								'LastName=?'    =>  $PaxDetailsEX[1],
								'BookingId=?'    =>  $bookingId
							);
							$updatePax = array(
								"ChangeRequestId" => $amendmentId,
								"ChangeRequestStatus" => ($requestType == 1) ? 6 : 7,
							);
							$this->objMdl->rv_update('tbl_flight_booking_customer', $updatePax, $whereArray);
						}
					}

					################ when cancellation charges comes start ###################
					if ($ResponseStatus == 1) {
						$Status = 9;
						$dataModification['status'] = $Status;
						$dataModification['RefundMode'] = 'Online Refund';
						$objFlight->InsertFlightData('tb_flight_modification', $dataModification);
						$postFieldArray = array(
							'PaxDetails' => json_encode($PaxDetails),
							'MasterTPSysId' => $MasterTPSysId,
							'TPSysId' => $TPSysId,
							'StatusType' => ($Status == 9) ? 19 : 121,
							'ChangeRequestId' => $amendmentId,
							'ChangeRequestStatus' => 1,
							'ChangeRequestRes' => json_encode($ChangeResponse),
							'dataModification' => json_encode($dataModification),
							"AgentSysId" => $this->gtxagentsysid,
							"AgencySysId" => $this->gtxagencysysid
						);

						$model = new Gtxwebservices_Model_Webservices();
						$result = $model->updateFlightCancellation($postFieldArray);
					}
					################ when cancellation charges comes end ###################

					$FlightBooking = $objFlight->FlightCancelDataTripJack('tbl_flight_booking', $param['bookingId'], $amendmentId);

					if (!empty($FlightBooking['data'])) {
						//$getAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->gtxagencysysid);
						//echo"<pre>";print_r($getAgencyData);die;
						$html = new Zend_View();
						$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
						$html->assign(array('FlightBooking' => $FlightBooking, 'param' => $param, 'bookingId' => $param['bookingId'], 'getAgencyData' => $getAgencyData, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, 'baseUrl' => $this->baseUrl));
						$bodyText = $html->render('cancelmailer.phtml');
						$contactDetail_mail = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getContactDetailForFooter();
						$subject = 'Cancellation request received - ' . $param['bookingId'];
						$Caption = 'Cancellation request received - ' . $param['bookingId'];
						$configs = [
							'to' => trim($FlightBooking['passenger'][0]['EmailId']),
							'fromName' => $this->siteName,
							'fromEmail' => $getAgencyData['PrimaryEmail'],
							'subject' => $subject,
							'bodyHtml' => $bodyText,
						];

						$configsAgency = [
							'to' => trim($MasterPrimaryEmailTo),
							'fromName' => $this->siteName,
							'fromEmail' => $getAgencyData['PrimaryEmail'],
							'subject' => $subject,
							'bodyHtml' => $bodyText,
						];

						$returnmail = $this->objHelperGeneral->mailSentByElastice($configs, $Caption);
						$returnmail = $this->objHelperGeneral->mailSentByElastice($configsAgency, $Caption);
					}
					// echo '<pre>';
					// print_r($configs);
					// echo '<pre>';
					// print_r($param);
					// die('dd');
					$strMsg = "success. Your booking cancellation is Inprocess";
					$redirect = true;
					$response = array('success' => true, 'msg' => $strMsg, 'redirect' => $redirect);
					echo json_encode($response);
					exit;
				} catch (Exception $e) {
					print_r($e->getMessage());
					exit;
				}
			} else {
				$strMsg = "Oops! Your booking Can't be cancel right now please try again latter, Please contact administrator for more details";
				$redirect = false;
				$response = array('success' => true, 'msg' => $strMsg, 'redirect' => $redirect);
				echo json_encode($response);
				exit;
			}
		}
	}

	public function amendmentDetailsAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$param = $this->getRequest()->getParams();
			$this->view->traceId = $param['amendmentId'];
			if($this->IsTJFlightAPI){
				$SupplierType = 2;
			}else{
				$SupplierType = 1;
			}
			$getMarkup = $this->getCancellationChargeNew('IN', 1, $SupplierType); //$this->getMarkup('IN');
			$data = array(
				"amendmentId" => $param['amendmentId'],
			);
			$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetAmendmentDetails($data);
			$this->view->ChangeResponse = $ChangeResponse;
			$intMarkUp = 0;
			if ($getMarkup['status'] == 1) {
				if ($getMarkup['arrAgencyMarkupsCancellation']) {
					foreach ($getMarkup['arrAgencyMarkupsCancellation'] as $value) {
						if ($value['SupplierType'] == 2 && $value['ServiceType'] == 1 && $value['MPType'] == 1 && $value['MPType'] == 1) {
							$intGTXMarkUpType = $value['MarkUpType'];
							$MarkUp = $value['MarkUp'];
							$intGTXMarkUpType = $value['MarkUpType'];
							if ($intGTXMarkUpType == 1) { // For Flat
								$intMarkUp += $MarkUp;
							} else { // For Percentage
								$intMarkUp += $MarkUp; //($intOfferedFare * $MarkUp) / 100;
							}
						}
					}
				}
			}
			$this->view->amendmentId = $param['amendmentId'];
			$this->view->CancelMarkUp = $intMarkUp;
			// $html = new Zend_View();
			// $html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
			// $html->assign(array('ChangeResponse' => $ChangeResponse));
			// $bodyText = $html->render('amendment-details.phtml');
			// $response = array('success' => true, 'message' => 'success', 'html' => $bodyText);
			// echo json_encode($response);
			// exit;
			// echo '<pre>';
			// print_r($ChangeResponse);
			// echo '<pre>';
			// print_r($getMarkup['arrAgencyMarkupsCancellation']);
			// echo '</pre>';
			// die;
		} else {
			die();
		}
	}

	public function updateRefundAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$param = $this->getRequest()->getParams();
			$refundedamount = base64_decode(base64_decode($param['refundedamount']));

			$amendmentId = $param['amendmentId'];
			$data = array(
				"status" => $param['Status'],
				"RefundMode" => $param['RefundMode'],
				"refundremarks" => $param['refundremarks'],
				"refundedamount" => $refundedamount,
			);
			$whereArray = array(
				'ChangeRequestId=?'    =>  $amendmentId,
			);

			$rv_update = $this->objMdl->rv_update('tbl_flight_booking', $data, $whereArray);

			if ($rv_update) {
				$response = array('success' => true, 'msg' => 'Refund Update Successfully');
				echo json_encode($response);
				exit;
			} else {
				$response = array('success' => false, 'msg' => 'Unable to update. try again.');
				echo json_encode($response);
				exit;
			}
		} else {
			die();
		}
	}

	public function getAirlineIdsAndCodeList()
	{
		$url = $this->baseUrl . "public/data/dynamic/AirlineIdsAndCodeList.json";
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		$str = curl_exec($ch);
		//$str = file_get_contents($this->baseUrl.'public/data/dynamic/AirlineIdsAndCodeList.json');
		$response = json_decode($str, true);
		return $response;
	}
	public function getCurrencyIdsAndSymbolList()
	{
		$url = $this->baseUrl . "public/data/dynamic/currency.json";
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		$str = curl_exec($ch);
		//$str = file_get_contents($this->baseUrl.'public/data/dynamic/currency.json');
		$response = json_decode($str, true);
		return $response;
	}
	public function getCityIdsAndAirPortCodeList()
	{
		$url = $this->baseUrl . "public/data/dynamic/AirPortCodeList.json";
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		$str = curl_exec($ch);
		//        $str = file_get_contents($this->baseUrl.'public/data/dynamic/AirPortCodeList.json');
		$response = json_decode($str, true);
		return $response;
	}
	public function customerloginAction()
	{
		$request = Zend_Controller_Front::getInstance()->getRequest();
		if ($this->getRequest()->isPost()) {
			$data = $request->getPost();
			$this->_session->session = $data;
			$this->_redirect('users/index/myprofile');
		}
	}

	public function logoutAction()
	{
		$storage = new Zend_Session_Namespace('User');
		$storage->unsetAll();
		$this->_redirect('index');
	}

	/*
		     *writeSessionPopup is used to show the request a callback popup window after interval on landing page
	*/

	public function writeSessionPopupAction()
	{
		$myNamespace = new Zend_Session_Namespace('MypopSess');
		$myNamespace->setPopup = true;
		$myNamespace->session_time = time();
		exit;
	}

	public function viewmoreAction()
	{
		$post = json_decode(file_get_contents('php://input'), true);
		$sessionFlightSearchParams = new Zend_Session_Namespace('SessionFlightSearchParams');
		$strFlightRoute = trim($sessionFlightSearchParams->params['route']);
		if ($post['item']) {
			$PriceID = $post['PriceID'];
			$FairRules = [];
			if ($post['item']['FairRules']) {
				foreach ($post['item']['FairRules'] as $price) {
					if ($price['PriceID'] == $PriceID) {
						$FairRules = $price;
					}
				}
			}
			$post['item']['FairRules'] = $FairRules;
			$ArrayData[0] = $post['item'];
			//echo '<pre>';print_r($post);die();
			$this->view->CurrencyRate = $this->CurrencyRate;
			$this->view->CurrencyTitle = $this->CurrencyTitle;
			$this->view->ShowPriceNoMarkup = $this->ShowPriceNoMarkup;
			$html = new Zend_View();
			$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
			$html->assign(array('Data' => $ArrayData, 'DataInbound' => [], 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle,'ShowPriceNoMarkup'=>$this->ShowPriceNoMarkup,'strFlightRoute'=>$strFlightRoute));
			$bodyText = $html->render('viewmore.phtml');

			$htmlFlight = new Zend_View();
			$htmlFlight->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
			$htmlFlight->assign(array('Data' => $ArrayData, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle,'ShowPriceNoMarkup'=>$this->ShowPriceNoMarkup,'strFlightRoute'=>$strFlightRoute));
			$viewmoreFlight = $htmlFlight->render('viewmoreFlight.phtml');

			$htmlBaggage = new Zend_View();
			$htmlBaggage->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
			$htmlBaggage->assign(array('Data' => $ArrayData, 'FairRules' => $FairRules, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle,'ShowPriceNoMarkup'=>$this->ShowPriceNoMarkup,'strFlightRoute'=>$strFlightRoute));
			$FlightBaggage = $htmlBaggage->render('viewmoreFlightBaggage.phtml');
			$response = array('success' => true, 'message' => 'success', 'html' => $bodyText,'viewmoreFlight'=>$viewmoreFlight,'FlightBaggage'=> $FlightBaggage);
			echo json_encode($response);
			exit;
		} else {
			$response = array('success' => false, 'message' => 'failed', 'html' => '');
			echo json_encode($response);
			exit;
		}
	}


	public function farebreackupmobileAction()
	{
		$this->_helper->layout->disableLayout();
		$param = $this->getRequest()->getParams();
		$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
		$this->view->CurrencyRate = $this->CurrencyRate;
		$this->view->FlightBookingData = $FlightBookingData->params;
	}

	public function getCountryCodeList()
	{
		$url = $this->baseUrl . "public/data/static/country.json";
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		$str = curl_exec($ch);
		// print_r($str);die;
		//        $str = file_get_contents($this->baseUrl.'public/data/dynamic/AirPortCodeList.json');
		$response = json_decode($str, true);
		return $response;
	}

	public function getsetcityAction()
	{

		header('Access-Control-Allow-Origin: *');
		$this->_helper->layout->disableLayout();
		$this->_helper->viewRenderer->setNoRender(true);
		$flightsourcedestin = $this->objMdl->rv_select_all('tbl_flight', ['*'], ['IsActive' => 1, 'isMarkForDel' => 0], ['order_by' => 'ASC'], 20);
		$array = array();
		$param = $this->getRequest()->getParams();
		// print_r($param);die;
		foreach ($flightsourcedestin as $key => $flightcode) {
			$data = json_decode($flightcode['city_json'], true);
			$explode = explode(',', $data['label']);
			$explodenew = explode('(', $explode[1]);
			$finalair = explode('-', $explodenew[0]);
			if (isset($finalair[1])) {
				$airportsname = $finalair[1];
			} else {
				$airportsname = $finalair[0];
			}

			$dataenc['AirportCode'] = $data['AirportCode'];
			$dataenc['CityID'] = $data['CityID'];
			$dataenc['ContSysId'] = $data['ContSysId'];
			$dataenc['ICAO'] = $data['ICAO'];
			$dataenc['CountryCode'] = $data['CountryCode'];
			$dataenc['DO'] = $data['DO'];
			$dataenc['cn'] = $data['cn'];
			$dataenc['label'] = $data['label'];
			$dataenc['labelWithSynonyms'] = $data['labelWithSynonyms'];

			$array[] = $dataenc;
		}

		$arrContextOptions = array(
			"ssl" => array(
				"verify_peer" => false,
				"verify_peer_name" => false,
			),
		);
		// print_r($param);die;
		if(isset($param['keyword']) && !empty($param['keyword'])){
			$curl = curl_init();
			curl_setopt_array($curl, array(
				CURLOPT_URL => 'https://globaltravelexchange.com/gtxwebservices/airport-code/get-airport-data',
				CURLOPT_RETURNTRANSFER => true,
				CURLOPT_ENCODING => '',
				CURLOPT_MAXREDIRS => 10,
				CURLOPT_TIMEOUT => 0,
				CURLOPT_FOLLOWLOCATION => true,
				CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
				CURLOPT_CUSTOMREQUEST => 'POST',
				CURLOPT_POSTFIELDS => array('term' => $param['keyword']),
			));
	
			$response = curl_exec($curl);
	
			curl_close($curl);
			echo $response;die;
		}else{
			$str = file_get_contents($this->baseUrl . 'public/data/dynamic/flight_destinations.json', false, stream_context_create($arrContextOptions));
			// echo "<pre>";
			// echo ($str);
			// die('gfghf');
			if($str){
				$array2 = json_decode($str, true);
			}else{
				$array2 = [];
			}
			$finalArray = array_merge($array, $array2);
			$input = $this->multi_unique($finalArray);
			$response = json_encode(array_values($input));
			echo $response;
			exit;
		}
	}

	public function multi_unique($array)
	{
		foreach ($array as $k => $na) {
			$new[$na['AirportCode']] = ($na);
		}
		$uniq = ($new);
		$i = 0;
		foreach ($uniq as $k => $ser) {
			$new1[$i] = ($ser);
			// $new1[$i] = unserialize($ser);
			$i++;
		}
		return ($new1);
	}

	public function genrateinvoice($bookingId)
	{
		//$bookingId;
		$objFlight = new Travel_Model_FlightMaster();
		$invoicedata = $objFlight->getInvoice('tbl_invoice');
		$prein = $invoicedata['InvoiceNumber'];
		$array = explode('-', $prein);
		$number = 000000;
		$invnumber = $number + $array[1] + 1;
		$nub = sprintf("%06d", $invnumber);
		$inv = "INV-" . $nub;
		//echo"<pre>";print_r($inv);die;
		$arrinvoice['InvoiceNumber'] = $inv;
		$arrinvoice['Booking_Id'] = $bookingId;
		$response = $objFlight->InsertFlightData('tbl_invoice', $arrinvoice);
		//echo"<pre>";print_r($response);die;
		return $response;
	}

	public function couponApplyAction()
	{
		header('Access-Control-Allow-Origin: ' . $this->baseUrl . '');
		if ($this->getRequest()->isXmlHttpRequest() && $this->getRequest()->getPost()) {
			$data = $this->getRequest()->getPost();
			// echo "data<pre>";print_r($data);
			$objFlight = new Travel_Model_FlightMaster();
			$actions = (isset($data['actions']) && !empty($data['actions'])) ? trim($data['actions']) : '';
			$couponval = (isset($data['couponval']) && !empty($data['couponval'])) ? trim($data['couponval']) : '';
			$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
			// echo "testing<pre>";print_r(json_encode($FlightBookingData->params));die;FromUTCTime
			$ICSourceSysId = $FlightBookingData->params[0]['ICSourceSysId'];
			// $LocalFromTime = date('Y-m-d', strtotime($FlightBookingData->params[0]['LocalFromTime']));
			$LocalFromTime = $FlightBookingData->params[0]['TravelDate'];
			$ServiceFee__ = 0;
			$PublishedFare__ = 0;
			if ($FlightBookingData->params) {
				foreach ($FlightBookingData->params as $value) {
					//$ServiceFee__ += $value['FairRules']['FixedMarkUp'];
					$AdditionalTxnFeePub = 0;
					$TotalBaseFare = 0;
					$TotalTaxsandFees = 0;
					if ($value['FairRules']['FareBreakdown']) {
						foreach ($value['FairRules']['FareBreakdown'] as $value) {

							$MF = $value['MF']; //Management Fee
							$TDS = $value['TDS']; //Management Fee
							$YQ = $value['YQ']; //Fuel Surcharge
							$AGST = $value['AGST']; //Airline GST Component
							$MFT = $value['MFT']; //Management Fee Tax
							// $OT = $value['OT']; //Other Charges
							$OT = isset($value['OT'])?$value['OT']:$value['TaxBR']['OT']; //Other Charges
							$MU = $value['MU']; //Markup
							$YR = $value['YR']; //Carrier Misc Fee
							$other = $MF + $YQ + $AGST + $MFT + $OT + $YR;
							if ($ICSourceSysId == 3) {
								$other =  $MF + $AGST + $MFT + $OT + $YR;
							}
							$PBaseFare = $value['BaseFare'];
							$intTotalGST = $value['intTotalGST'];
							$FixedMarkUp = $value['FixedMarkUp'];
							$apiMarkup = $value['apiMarkup'];
							$IntCommission = $value['IntCommission'];
							$CommissionEarned = $value['CommissionEarned'];
							$CommisionPass = $value['CommisionPass'];
							$ServiceFee = $value['ServiceFee'];
							$ServiceFee__ += $FixedMarkUp;

							$paxPublishedFare = ($PBaseFare);
							$PassengerType = $value['PassengerType'];
							$PassengerCount = $value['PassengerCount'];
							$AdditionalTxnFeePub += $value['AdditionalTxnFeePub'];

							$TaxesFees = ($other + $intTotalGST + $FixedMarkUp + $apiMarkup + $IntCommission - $CommissionEarned);
							if ($ICSourceSysId == 3) {
								$TaxesFees = ($other + $intTotalGST + $FixedMarkUp + $apiMarkup + $ServiceFee - $CommisionPass);
							}
							$TotalBaseFare += ($paxPublishedFare);
							$TotalTaxsandFees += ($TaxesFees);
						}
					}
					$PublishedFare__ += ($TotalBaseFare + $TotalTaxsandFees);
				}
			}
			if($ServiceFee__ < 0){
				$response = array('success' => false, 'message' => 'Sorry, this coupon is not applicable to selected flight');
				echo json_encode($response);
				exit;
			}
			$validate = array(
				'AgencySysId' => $this->gtxagencysysid,
				'ServiceFee' => $ServiceFee__,
				'CriteriaValue' => $PublishedFare__,
				'couponcode' => $couponval,
				'TravelDate' => $LocalFromTime,
				'ProductType' => 1,
			);
			if ($actions == 'add') {
				$validateCoupon = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->validateCoupon($validate);
				$couponStatus = isset($validateCoupon['status']) ? $validateCoupon['status'] : 0;
				$discount = isset($validateCoupon['couponprice']) ? $validateCoupon['couponprice'] : 0;
			} else {
				$couponStatus = 0;
				$discount = 0;
			}


			$temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $data['TraceId']], ['id' => 'ASC']);
			$arrUrlData = json_decode($temp_data['json_data'], true);

			$currentdate = date('Y-m-d');
			$arrFlightData = [];
			$TripCount = count($FlightBookingData->params);


			if ($FlightBookingData->params && $couponStatus == 1 && $actions == 'add') {
				foreach ($FlightBookingData->params as $key => $booking) {
					$arrFlightData[$key] = $booking;
					$arrFlightData[$key]['FairRules']['couponName'] = $couponval;
					$arrFlightData[$key]['FairRules']['couponVal'] = ($discount / $TripCount);
					$arrFlightData[$key]['FairRules']['couponApply'] = 1;
					$arrFlightData[$key]['FairRules']['couponexpiryDate'] = $expiryDate;

					$FareBreakdownArray = [];
					$countBreakUp = count($booking['FairRules']['FareBreakdown']);
					if($booking['FairRules']['FareBreakdown']){
						foreach($booking['FairRules']['FareBreakdown'] as $bk=>$breackdown){
							$CommisionPass = $breackdown['CommisionPass'];
							$FareBreakdownArray[$bk] = $breackdown;
							$FareBreakdownArray[$bk]['couponName'] = $codeName;
							$FareBreakdownArray[$bk]['couponVal'] = (($discount / $TripCount) / $countBreakUp);
							$FareBreakdownArray[$bk]['CommisionPass'] = ($CommisionPass + (($discount / $TripCount) / $countBreakUp));
						}
					}
					$arrFlightData[$key]['FairRules']['FareBreakdown'] = $FareBreakdownArray;
				}
			} elseif ($actions == 'remove') {
				foreach ($FlightBookingData->params as $key => $booking) {
					$couponStatus = 1;
					$arrFlightData[$key] = $booking;
					$arrFlightData[$key]['FairRules']['couponName'] = $codeName;
					$arrFlightData[$key]['FairRules']['couponVal'] = 0;
					$arrFlightData[$key]['FairRules']['couponApply'] = 0;
					$arrFlightData[$key]['FairRules']['couponexpiryDate'] = $expiryDate;
					$FareBreakdownArray = [];
					$countBreakUp = count($booking['FairRules']['FareBreakdown']);
					if($booking['FairRules']['FareBreakdown']){
						foreach($booking['FairRules']['FareBreakdown'] as $bk=>$breackdown){
							$couponVal = $breackdown['couponVal'];
							$CommisionPass = $breackdown['CommisionPass'];
							$FareBreakdownArray[$bk] = $breackdown;
							$FareBreakdownArray[$bk]['couponName'] = $codeName;
							$FareBreakdownArray[$bk]['couponVal'] = 0;
							$FareBreakdownArray[$bk]['CommisionPass'] = ($CommisionPass - $couponVal);
						}
					}
					$arrFlightData[$key]['FairRules']['FareBreakdown'] = $FareBreakdownArray;
				}
			} else {
				$arrFlightData = $FlightBookingData->params;
			}


			$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
			$FlightBookingData->params = $arrFlightData;

			$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
			$PublishedFare = 0;
			$intPublishedFare = 0;
			if ($FlightBookingData->params) {
				foreach ($FlightBookingData->params as $value) {
					$couponVal = (float) isset($value['FairRules']['couponVal']) ? $value['FairRules']['couponVal'] : 0;
					$intPublishedFare += (((float) $value['FairRules']['PublishedFare']) - $couponVal);
				}
			}
			// if($this->gtxagencysysid == '4539'){

			// 	echo "<pre>";
			// 	print_r($FlightBookingData->params);
			// 	echo "<pre>";die;
			// }
			$arrUrlData['BookingData'] = $FlightBookingData->params;
			$arrUrlData['validateCoupon'] = $validateCoupon;
			$arrUrlData['validateData'] = $validate;
			$insertArr = array(
				'TraceId' => $data['TraceId'],
				'json_data' => json_encode($arrUrlData),
				'created_at' => date('Y-m-d H:i:s'),
			);
			$this->objMdl->rv_delete('tbl_temp_data', array('TraceId = ?' => $data['TraceId']));
			$objFlight = new Travel_Model_FlightMaster();
			$objFlight->InsertFlightData('tbl_temp_data', $insertArr);

			$discountMessage = 'Congratulations! Discount of Rs. ' . $discount . ' has been applied successfully.';

			$html = new Zend_View();
			$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
			$html->assign(array('apiResponse' => $FlightBookingData->params, 'stylecss' => $this->stylecss, 'apiResponseInbound' => [], 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
			$bodyText = $html->render('getflightfarequote.phtml');
			if ($couponStatus == 1) {
				$response = array('success' => true, 'message' => 'Done', 'FareChange' => false, 'html' => $bodyText, 'intPublishedFare' => number_format(ceil($intPublishedFare)), 'SSRArr' => [], 'SSRArrInb' => [], 'apiResponse' => $FlightBookingData->params, 'discountMessage' => $discountMessage);
				echo json_encode($response);
				exit;
			} else {
				$response = array('success' => false, 'message' => 'Invalid Coupon code', 'FareChange' => false, 'html' => $bodyText, 'intPublishedFare' => number_format(ceil($intPublishedFare)), 'SSRArr' => [], 'SSRArrInb' => [], 'apiResponse' => $FlightBookingData->params, 'discountMessage' => $discountMessage);
				echo json_encode($response);
				exit;
			}
		} else {
			die('Page not found');
		}
	}

	public function checkPaymentStatusAction()
	{
		$this->_helper->viewRenderer->setNoRender(true);
		$param = $this->getRequest()->getPost();

		$encode = json_decode('{"encdata":"077D6330CFB4D0089835CD70A8188CD0147B2FBEE3B04CC87028964DC1D573D9DC6FB5278D6CDD7404CB0711A5240892DFC71A7B16650536FA8FC1812ECB25DA77AF9998C16DF978C9FB3E96257250CD2C687B436483D17C32B28E855BB68F38F3B4EBAE558C5803AA2266BA00C1758E4E82079CE7165C411C00D34D3DDCDBE2576F27022BBC6AB0D58E3CE282D2B8DC88511B1D6F1E640428F40752C3DAF23253A48BDC545723BC6303CB3E76FAB13B08D4E62865F0647088A4162B656C5A586A69433C1DF57EF93EE9E53E691A27C8C3793D954B09A382653B84AEF61B77C302CF03A3D399DA48090355C33C5ECCF4B98CA5BB3755DC77D59017962095317A1DCF3D40791DC734FCB6BCD8724A267F5968ED46112FBDC49D51098887BA21CEEA20AE51F7603851A33F585FDBFE19C074A3062931C0AFE6D6D93B72608FFD2AB25EC99FA27C164A3E6468C934D56C104867B2E46A31ABA7041E66FC58327F55770734DCD4EED0BDB38B6211B1F422D440A136E8092569A5716FC927286DFFEEF0379B0D4630C94524800AA7C3377B084D4211BE1BB016911E6C180137AF04319E651362BC6110124681CCA7A98277C6B73D88655C813DDFEB658F9DE2963EB12838162F952691923C379F012507A7D0FB126F5AAD0EA7113E3C615403AEE9F62FDEAA856385BA142D9ADB699482EA9865C0FC3F394230EC4776A90EA3D18AEB354A92C7814F4333F87DB258C1E571A3247A4E0D8172BF3A2F81FA2A63970C3B8948B69E74B3823C1C89CEFCE7596587457FA2FFEC00565F56AD98900953AFA218704AAB2FA1D4C589E424722FECE6047D820C19BCF35CB436EFD74AF1598A496E148387E5C7C201279362CF08A8D97B2B485637A2354FE3BD5C2C16E7D1878DA0FC6B809702069B7EDB46AF77C6A15BF803774D8BDABCB33697D19802E149D18DFEC2DD01AFC7B13575CD685845752CC7B9A7EA42A13441144502C5076FB0CD5344B2182275C51B062D20139FF4DABCE71F96C5A29ADE677E644964493C18D7EB6C248597046CA5B5761E3F0954C00374F44AED068F51AA82084C7B3F0C22ACA99D6FEC86325E6630C60E2512D5C16D94750EBDAA3A5CBED73BB582996FCD5398522E5640219E976342D4C99F4280275378F9225AA9CA2D322795CED2610A9E181E7179C659DF88CBFD7A902E74A5A177901816FB56FA9EEA860732A457564E4D477ADC0E6CBF0CC382936E97313320","login":"367703"}', true);
		//Write Request Logs starts...
		//$strFilePath = "payment/log/" . date('Y-m-d-H-i-s') . "_response.json";
		// Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($param));
		$transactionResponse = new Travel_Model_TransactionResponse();
		$transactionResponse->setRespHashKey($this->respHashKey);
		$transactionResponse->setResponseEncypritonKey($this->aesResponseKey);
		$transactionResponse->setSalt($this->aesResponseIv);
		$returnPerameter = $transactionResponse->decryptResponseIntoArray($encode['encdata']);
		$checkVal = $transactionResponse->validateResponse($returnPerameter);
		$decodePerameter = Zend_Json::decode(base64_decode($returnPerameter["udf9"]), true);
		$id = $decodePerameter[5];
		$encryptedData = new Travel_Model_AtomAES();
		$id = $encryptedData->decrypt($id, SECURITYKEY, SECURITYKEY);

		echo "<pre>";
		print_r($returnPerameter);
		die;
	}

	public function checklogin()
	{
		if (!$_SESSION['User']['session']) {
			$this->_redirect('/');
		}
	}
	public function hoursTodays($hours)
	{
		$hid = 24; // Hours in a day - could be 24, 8, etc
		if ($hours > $hid) {
			$days = round($hours / $hid);
		} else {
			$days = -1;
		}
		$Final = '';
		if ($days < 0) {
			$Final = "$hours hrs";
		} else {
			$Final = "$days days";
		}
		return $Final;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit