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/holidays.tripjack.com/application/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/holidays.tripjack.com/application/controllers/FlightControllerbackup.php
<?php

/***************************************************************
 * Catabatic Technology Pvt. Ltd.
 * File Name     : IndexController.php
 * File Desc.    : Index controller for home page front end
 * Created By    : Ranvir Singh <ranvir@catpl.co.in>
 * Created Date  : 25 May 2017
 * Updated Date  : 14 Dec 2017
 ***************************************************************/

class FlightController extends Catabatic_ValidateCustomer
{


	protected $objMdl;
	protected $tablename;
	protected $tablenameDestination;
	protected $baseUrl;
	protected $tollfreenumber;

	protected $objHelperGeneral;
	protected $per_page_record;

	public $_session;
	public $customerbookinglistAPIUrl;

	public $uploadPakcagePath;
	public $uploadDestinationPath;
	public $dummyImagePackage;
	public $dummyImageDestination;

	public $myNamespace;
	public $AgencyId;
	public $gtxagencysysid;


	public function init()
	{

		parent::init();
		$this->_helper->_layout->setLayout('layout-flights')->setLayoutPath(APPLICATION_PATH . '/layouts/scripts');
		$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
		$BootStrap  = $aConfig['bootstrap'];
		$this->_session = new Zend_Session_Namespace('User');
		$this->siteName = $BootStrap['siteName'];
		$this->baseUrl  = $BootStrap['siteUrl'];
		$this->siteImageUrl  = $BootStrap['siteImageUrl'];
		$this->tollfreenumber  = $BootStrap['tollfreenumber'];
		//$this->gtxagencysysid = $this->AgencyId = $BootStrap['gtxagencysysid'];
		$this->gtxagencysysid = $this->_session->data['AgencySysId'];
		$this->MasterAgencySysId = $this->_session->data['MasterAgencySysId'];

		$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->AgencyId = $this->_session->data['AgencySysId'];
		$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->customerbookinglistAPIUrl = API_CUSTOMER_LIST; // from constant file
		$this->customerchangepasswordAPIUrlB2c = API_CUSTOMER_CHANGEPASSWORDB2C;
		$this->myNamespace = new Zend_Session_Namespace('MypopSess'); // get user end infomations

		$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']);
		$this->CurrencyRate = $currency_rate->Rate;
		$this->CurrencyTitle = $currencyType->Title;
		$this->CurrencyId = $currencyType->CurrencyId;
	}

	public function indexAction()
	{
		
		$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
		$recentSearch = new Zend_Session_Namespace('recentSearch');
		$this->view->sessionFlightSearchParams = $sessionFlightSearchParams->params;
		$this->view->recentSearch = $recentSearch->params;

		$this->view->baseUrl    = $this->baseUrl;
		//die('ddcc');
		//echo '<pre>';print_r($this->_session->data);

	}

	public function flightsearchdataAction()
	{
		$getData = $this->getRequest()->getParams();
		$uri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
		$TraceId = implode('-', str_split(substr(strtolower(md5(time() . rand(1000, 9999))), 0, 20), 5));
		$SearchFlightTraceId = new Zend_Session_Namespace('SearchFlightTraceId');
		$SearchFlightTraceId->params = $TraceId;
		$uriExp = explode('?', $uri);
		//Zend_Session::namespaceUnset('sessionFlightSearchParams');

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

		$begin = new DateTime($CreateSessionSearchParams['strDepatureDate'][0]);
		$end = new DateTime($CreateSessionSearchParams['strDepatureDate'][0]);
		$end = $end->modify('+3 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")];
		}

		$FlightSearchUrl = new Zend_Session_Namespace('FlightSearchUrl');
		$FlightSearchUrl->params = ($TraceId);  // Putting all form data to Session
		$data = array('status' => true, 'DepartDateArr' => $DepartDateArr, 'FlightTraceId' => $TraceId, 'sessionFlightSearchParams' => json_encode($CreateSessionSearchParams));
		echo json_encode($data);
		exit;
		// $this->view->getData = $getData;
		// $this->_redirect('flights/index/flight-search/TraceId/' . $TraceId);
		// //$this->_redirect('flight/flight-search?' . $uriExp[1]);
	}
	public function getMarkup($intCountryCode)
	{
		if ($intCountryCode) {
			$this->postFields = "";
			$this->postFields .= "&AgencySysId=$this->MasterAgencySysId";
			$this->postFields .= "&AgentSysId=0";
			$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 getCancelCharge($intCountryCode)
	{
		if ($intCountryCode) {
			$getMarkup = $this->getMarkup($intCountryCode);
			$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;
							}
						}
					}
				}
			}
			return $intMarkUp;
		} else {
			$data = array('status' => false, 'message' => 'Invalid request');
			return ($data);
		}
	}

	public function flightSearchAction()
	{
		$post = json_decode(file_get_contents('php://input'), true);
		$getData = $this->getRequest()->getParams();
		$this->view->getData = $getData;
		$this->view->baseUrl = $this->baseUrl;
		$this->view->CurrencyTitle = $this->CurrencyTitle;
		$sessionFlightSearchParams = json_decode($post['sessionFlightSearchParams'], true);
		$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']);
		$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId'][0]);
		$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId'][0]);

		$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] : '';
		if (!empty(trim($intCountryCode)) && trim($intCountryCode) != "IN") {
			$intAirType = 2;
		} else {
			$intAirType = 1;
		}
		$begin = new DateTime($sessionFlightSearchParams['strDepatureDate'][0]);
		$end = new DateTime($sessionFlightSearchParams['strDepatureDate'][0]);
		if ($strFlightRoute == 2 && $interNationalSearch == '') {
			$end = $end->modify('+5 day');
		} else {
			$end = $end->modify('+5 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")];
		}

		$beginR = new DateTime($sessionFlightSearchParams['strReturnDate'][0]);
		$endR = new DateTime($sessionFlightSearchParams['strReturnDate'][0]);
		if ($strFlightRoute == 2 && $interNationalSearch == '') {
			$endR = $endR->modify('+5 day');
		} else {
			$endR = $endR->modify('+5 day');
		}

		$intervalR = new DateInterval('P1D');
		$daterange = new DatePeriod($beginR, $intervalR, $endR);
		$ReturnDateArr = [];
		foreach ($daterange as $date) {
			$ReturnDateArr[] = ['formatDate' => $date->format("Y-m-d"), 'depDate' => $date->format("d/m/Y")];
		}

		$this->view->intMemberCount = $intMemberCount;
		$arrFlightClass = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getFlightClasses();
		$FlightClass = $arrFlightClass[$flight_class];
		$objFlight = new Travel_Model_FlightMaster();
		$objMarkup = new Travel_Model_Markup();
		$TraceId = $this->getRequest()->getParam('TraceId');
		$this->view->FlightTraceId = $TraceId;
		if ($FlightTraceId != $TraceId) {
			$data = array('outbound' => [], 'inbound' => [], 'ErrorMessage' => 'Invalid request', 'arrAirlineName' => [], 'FiltStopCount' => [], 'ArrPriceUnique' => []);
			echo json_encode($data);
			exit;
		}
		if ($this->getRequest()->isXmlHttpRequest() && $sessionFlightSearchParams) {
			$this->_helper->layout->disableLayout();
			$this->_helper->viewRenderer->setNoRender(true);
			// For getting All Airlines Array
			$arrAirlineList = $this->getAirlineIdsAndCodeList();
			// For getting All Source & Destination CitySysId Array
			$arrCityIds = $this->getCityIdsAndAirPortCodeList();
			$getMarkup = $this->getMarkup($intCountryCode);
			$getAgencyMarkups = $objMarkup->getAgencyMarkups($intAirType, $this->gtxagencysysid);
			//echo '<pre>';print_r($getAgencyMarkups);die;
			$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsTripjack($sessionFlightSearchParams);
			$strFilePath = "flight/FlightSearch/" . time() . "_demo_result_request.json";
			Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($apiResponse));

			// $str = file_get_contents($this->baseUrl . 'public/logs/flight/FlightSearch/demo_result_request.json');
			// $apiResponse = json_decode($str, true);

			$intJourneyType = 1;
			$intTripType = 1;
			$arrInsertFlightData = [];
			$arrAirlineName = [];
			$FiltStopCount = [];
			$FiltPriceRange = [];
			$AttPriceRange = [];
			$dddddddd = [];

			$intResponseStatus = $apiResponse['ResponseStatus'];
			$ONWARD = $apiResponse['OutBoundFlightResults'];
			if ($intResponseStatus == 1) {
				if ($ONWARD) {
					foreach ($ONWARD as $key => $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 = $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';
						}
						$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 = [];
						$intYQTaxToT = 0;
						$intTotalOfferedForAllPax = 0;
						$intBaseFareAllPax = 0;
						$intTaxAllPax = 0;
						array_multisort($result['totalPriceList']);
						if ($result['totalPriceList']) {
							foreach ($result['totalPriceList'] as $kp => $price) {
								$fareDetail = $price['fd'];

								// echo '<pre>';
								// print_r($fareDetail);
								// echo '</pre>';
								$SeatAvailable = $fareDetail['ADULT']['sR'];
								$classOfBooking = $fareDetail['ADULT']['cB'];
								$Refundable = $fareDetail['ADULT']['rT'];
								$PriceID = $price['id'];
								$fareIdentifier = $price['fareIdentifier'];
								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 

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


								$FareBreakdown[0]['Currency'] = 'INR';
								$FareBreakdown[0]['PassengerType'] = 1;
								$FareBreakdown[0]['PassengerCount'] = $adultCount;
								$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $adultCount);
								$FareBreakdown[0]['TotalBaseFare'] = ($ADULT['TF'] * $adultCount);
								$FareBreakdown[0]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
								$FareBreakdown[0]['BaseFare'] = ($ADULT['BF'] * $adultCount);
								$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $adultCount);
								$FareBreakdown[0]['TDS'] = (float)str_replace('-', '', ($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]['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]['AgentMarkUp'] = $arrMarkUpsBR['totalAgentMarkUp'];
								$FareBreakdown[0]['GSTOnAgentMarkUp'] = $arrMarkUpsBR['intGSTOnAgentFixMarkUp'];
								$FareBreakdown[0]['Agencycommission'] = $arrMarkUpsBR['Agencycommission'];
								$FareBreakdown[0]['TotalCommssionVal_ag'] = $arrMarkUpsBR['TotalCommssionVal_ag'];
								$FareBreakdown[0]['AdminComminAmount_ag'] = $arrMarkUpsBR['AdminComminAmount_ag'];
								$FareBreakdown[0]['AgentB2CEarning'] = $arrMarkUpsBR['AgentB2CEarning'];
								$FareBreakdown[0]['CostToAgentCustomer'] = $arrMarkUpsBR['CostToAgentCustomer'];
								$FareBreakdown[0]['CostToAgent'] = $arrMarkUpsBR['CostToAgent'];
								$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'])) {
									$TdsOnPLBCal = isset($CHILDNCMTDS) ? str_replace('-', '', $CHILDNCMTDS) : 0;
									$markUpArrBR = array(
										'getMarkup' => $getMarkup,
										'getAgencyMarkups' => $getAgencyMarkups,
										'PublishedFare' => ($CHILD['TF'] * $childCount),
										'OfferedFare' => (($CHILD['NF'] - $TdsOnPLBCal) * $childCount),
										'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
										'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
										'MUFee' => ($CH_MU * $childCount),
										'intPLBEarned' => $PLBEarned,
										'intIncentiveEarned' => $IncentiveEarned,
										'intMemberCount' => $childCount,
										'intFlightRoute' => $strFlightRoute,
										'interNationalSearch' => $interNationalSearch,
									);
									$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArrBR);
									$FareBreakdown[1]['Currency'] = 'INR';
									$FareBreakdown[1]['PassengerType'] = 2;
									$FareBreakdown[1]['PassengerCount'] = $childCount;
									$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
									$FareBreakdown[1]['TotalBaseFare'] = ($CHILD['TF'] * $childCount);
									$FareBreakdown[1]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
									$FareBreakdown[1]['BaseFare'] = ($CHILD['BF'] * $childCount);
									$FareBreakdown[1]['CommissionEarned'] = ($CHILD['NCM'] * $childCount);
									$FareBreakdown[1]['TDS'] = (float)str_replace('-', '', ($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]['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]['AgentMarkUp'] = $arrMarkUpsBR['totalAgentMarkUp'];
									$FareBreakdown[1]['GSTOnAgentMarkUp'] = $arrMarkUpsBR['intGSTOnAgentFixMarkUp'];
									$FareBreakdown[1]['Agencycommission'] = $arrMarkUpsBR['Agencycommission'];
									$FareBreakdown[1]['TotalCommssionVal_ag'] = $arrMarkUpsBR['TotalCommssionVal_ag'];
									$FareBreakdown[1]['AdminComminAmount_ag'] = $arrMarkUpsBR['AdminComminAmount_ag'];
									$FareBreakdown[1]['AgentB2CEarning'] = $arrMarkUpsBR['AgentB2CEarning'];
									$FareBreakdown[1]['CostToAgentCustomer'] = $arrMarkUpsBR['CostToAgentCustomer'];
									$FareBreakdown[1]['CostToAgent'] = $arrMarkUpsBR['CostToAgent'];
									$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'])) {
									$TdsOnPLBCal = isset($INFANTNCMTDS) ? str_replace('-', '', $INFANTNCMTDS) : 0;
									$markUpArrBR = array(
										'getMarkup' => $getMarkup,
										'getAgencyMarkups' => $getAgencyMarkups,
										'PublishedFare' => ($INFANT['TF'] * $infantCount),
										'OfferedFare' => (($INFANT['NF'] - $TdsOnPLBCal) * $infantCount),
										'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
										'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
										'MUFee' => ($IN_MU * $infantCount),
										'intPLBEarned' => $PLBEarned,
										'intIncentiveEarned' => $IncentiveEarned,
										'intMemberCount' => $infantCount,
										'intFlightRoute' => $strFlightRoute,
										'interNationalSearch' => $interNationalSearch,
									);
									$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArrBR);
									$FareBreakdown[2]['Currency'] = 'INR';
									$FareBreakdown[2]['PassengerType'] = 3;
									$FareBreakdown[2]['PassengerCount'] = $infantCount;
									$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
									$FareBreakdown[2]['TotalBaseFare'] = ($INFANT['TF'] * $infantCount);
									$FareBreakdown[2]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
									$FareBreakdown[2]['BaseFare'] = ($INFANT['BF'] * $infantCount);
									$FareBreakdown[2]['CommissionEarned'] = ($INFANT['NCM'] * $infantCount);
									$FareBreakdown[2]['TDS'] = (float)str_replace('-', '', ($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]['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]['AgentMarkUp'] = $arrMarkUpsBR['totalAgentMarkUp'];
									$FareBreakdown[2]['GSTOnAgentMarkUp'] = $arrMarkUpsBR['intGSTOnAgentFixMarkUp'];
									$FareBreakdown[2]['Agencycommission'] = $arrMarkUpsBR['Agencycommission'];
									$FareBreakdown[2]['TotalCommssionVal_ag'] = $arrMarkUpsBR['TotalCommssionVal_ag'];
									$FareBreakdown[2]['AdminComminAmount_ag'] = $arrMarkUpsBR['AdminComminAmount_ag'];
									$FareBreakdown[2]['AgentB2CEarning'] = $arrMarkUpsBR['AgentB2CEarning'];
									$FareBreakdown[2]['CostToAgentCustomer'] = $arrMarkUpsBR['CostToAgentCustomer'];
									$FareBreakdown[2]['CostToAgent'] = $arrMarkUpsBR['CostToAgent'];
									$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" => ($arrMarkUps['PublishFare'] * $this->CurrencyRate),
									"PublishedFareAgent" => ($arrMarkUps['CostToAgentCustomer'] * $this->CurrencyRate),
									"OfferedFareAgent" => ($arrMarkUps['CostToAgent'] * $this->CurrencyRate),
									"OfferedFare" => $arrMarkUps['intOfferedFare'],
									"PLBEarned" => $PLBEarned,
									"IncentiveEarned" => $IncentiveEarned,
									"TdsOnPLB" => (float)isset($TdsOnPLB) ? str_replace('-', '', $TdsOnPLB) : 0,
									"TdsOnIncentive" => 0,
									"AdditionalTxnFeeOfrd" => 0,
									"AdditionalTxnFeePub" => 0,
									"Refundable" => $Refundable,
									"IsRefundableTxt" => $IsRefundableTxt,
									"PriceID" => $PriceID,
									"IsGSTRequired" => $IsGSTRequired,
									"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
									"SeatAvailable" => $SeatAvailable,
									"classOfBooking" => $classOfBooking,
									"FareClass" => $fareDetail['ADULT']['cc'],
									"intTotalGST" => $arrMarkUps['intTotalGST'],
									"apiMarkup" => $arrMarkUps['apiMarkup'],
									"IntCommission" => $arrMarkUps['IntCommission'],
									"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
									"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
									"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
									"CommEarned" => $arrMarkUps['intCommisionEarnedForAgency'],
									"CommEarnedAgent" => $arrMarkUps['AgentB2CEarning'],
									"GSTonComm" => 0,
									"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
									"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],

									"AgentMarkUp" => $arrMarkUps['totalAgentMarkUp'],
									"GSTOnAgentMarkUp" => $arrMarkUps['intGSTOnAgentFixMarkUp'],
									'Agencycommission' => $arrMarkUps['Agencycommission'],
									'TotalCommssionVal_ag' => $arrMarkUps['TotalCommssionVal_ag'],
									'AdminComminAmount_ag' => $arrMarkUps['AdminComminAmount_ag'],
									'AgentB2CEarning' => $arrMarkUps['AgentB2CEarning'],
									'CostToAgentCustomer' => $arrMarkUps['CostToAgentCustomer'],
									'CostToAgent' => $arrMarkUps['CostToAgent'],
									"FareBreakdown" => $FareBreakdown,
									"arrMarkUps" => $arrMarkUps,
								);
								// echo '<pre>';
								// print_r($FairRulesArr[$kp]);
								// echo '</pre>';
							}
						}

						$TotalLAYOVERMinutes = 0;
						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(
									"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,
									"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);
							}
						}

						$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';
						$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]['SearchTraceId'] = $FlightTraceId;
						$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]['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);
						$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format(($PublishedFareReverse * $this->CurrencyRate));
						$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
						$arrInsertFlightData[$key]['JourneyType'] = $intJourneyType;
						$arrInsertFlightData[$key]['TripType'] = $intTripType;
						$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
						$arrInsertFlightData[$key]['logo'] = $filePath;
						$arrInsertFlightData[$key]['FairRules'] = $FairRulesArr;
						$arrInsertFlightData[$key]['Segments'] = $arrSegments;

						$arrAirlineName[] = $AirlineCode . '-' . $strAirlineName;
						$AttPriceRange[] = $PublishedFareReverse * $this->CurrencyRate;
						$FiltStopCount[] = $StopCountTxt;
						$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
						$arrInsertFlightData[$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
						if ($FairRulesArr) {
							foreach ($FairRulesArr as $Fare) {
								$dddddddd[] = $Fare['PublishedFare'];
							}
						}
					}
				}
				$RoundTrip = $this->FlightDataRoundTripJack($apiResponse, $sessionFlightSearchParams);
				$dddddddd = array_merge($dddddddd, $RoundTrip['dddddddd']);
				sort($dddddddd);
				//echo '<pre>';print_r($dddddddd);die;
				$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, $RoundTrip['arrAirlineName'])));
				$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, $RoundTrip['FiltStopCount'])));
				$MinriceRange = (min(array_merge($AttPriceRange, $RoundTrip['AttPriceRange'])));
				$MaxriceRange = (max(array_merge($AttPriceRange, $RoundTrip['AttPriceRange'])));
				sort($FiltStopCount);
				if ($interNationalSearch == 1 && $strFlightRoute == 2) {

					$RoundInterTrip = $this->FlightDataRoundTripInternational($apiResponse, $sessionFlightSearchParams);
					//echo '<pre>';print_r($RoundInterTrip);die;
					$MinriceRange = (min($RoundInterTrip['AttPriceRange']));
					$MaxriceRange = (max($RoundInterTrip['AttPriceRange']));
					$data = array('outbound' => $RoundInterTrip['outbound'], 'DepartDateArr' => $DepartDateArr, 'source' => $source, 'destination' => $destination, 'source_city' => $source_city, 'destination_city' => $destination_city, 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute, 'CurrencyTitle' => $this->CurrencyTitle, 'inbound' => [], 'arrAirlineName' => $RoundInterTrip['arrAirlineName'], 'FiltStopCount' => $RoundInterTrip['FiltStopCount'], 'ArrPriceUnique' => $RoundInterTrip['ArrPriceUnique'], 'MinriceRange' => round($MinriceRange), 'MaxriceRange' => round($MaxriceRange));
				} else {

					$data = array('outbound' => $arrInsertFlightData, 'inbound' => $RoundTrip['inbound'], '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' => round($MinriceRange), 'MaxriceRange' => round($MaxriceRange));
				}
				echo json_encode($data);
				exit;
			} else {
				$data = array('outbound' => [], 'inbound' => [], '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;
		}
	}

	public function FlightDataRoundTripJack($apiResponse, $sessionFlightSearchParams)
	{
		$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId']);
		$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId']);
		$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
		$adultCount = $sessionFlightSearchParams['adults'];
		$childCount = $sessionFlightSearchParams['child'];
		$infantCount = $sessionFlightSearchParams['infant'];
		$intMemberCount = $adultCount + $childCount + $infantCount;
		$strFlightRoute = trim($sessionFlightSearchParams['route']);
		$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
		$FlightTraceId = trim($sessionFlightSearchParams['FlightTraceId']);
		$intTatalPaxCT = $adultCount + $childCount;
		$getMarkup = $this->getMarkup($intCountryCode);
		$arrAirlineList = $this->getAirlineIdsAndCodeList();
		$intJourneyType = 2;
		$intTripType = 1;
		$arrInsertFlightData = [];
		$arrAirlineName = [];
		$FiltStopCount = [];
		$FiltPriceRange = [];
		$AttPriceRange = [];
		$dddddddd = [];
		$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'];
					$strFareClass = $totalPriceList['fd']['ADULT']['cB'];
					$IsMealIncludes = $totalPriceList['fd']['ADULT']['mI'];
					$bagInfo = $totalPriceList['fd']['ADULT']['bI']['iB'];
					$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';
					}
					$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 = [];

					array_multisort($result['totalPriceList']);
					if ($result['totalPriceList']) {
						foreach ($result['totalPriceList'] as $kp => $price) {
							$fareDetail = $price['fd'];

							// echo '<pre>';
							// print_r($fareDetail);
							// echo '</pre>';
							$SeatAvailable = $fareDetail['ADULT']['sR'];
							$classOfBooking = $fareDetail['ADULT']['cB'];
							$Refundable = $fareDetail['ADULT']['rT'];
							$PriceID = $price['id'];
							$fareIdentifier = $price['fareIdentifier'];
							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 

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


							$FareBreakdown[0]['Currency'] = 'INR';
							$FareBreakdown[0]['PassengerType'] = 1;
							$FareBreakdown[0]['PassengerCount'] = $adultCount;
							$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $adultCount);
							$FareBreakdown[0]['TotalBaseFare'] = ($ADULT['TF'] * $adultCount);
							$FareBreakdown[0]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
							$FareBreakdown[0]['BaseFare'] = ($ADULT['BF'] * $adultCount);
							$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $adultCount);
							$FareBreakdown[0]['TDS'] = (float)str_replace('-', '', ($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]['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'])) {
								$TdsOnPLBCal = isset($CHILDNCMTDS) ? str_replace('-', '', $CHILDNCMTDS) : 0;
								$markUpArrBR = array(
									'getMarkup' => $getMarkup,
									'PublishedFare' => ($CHILD['TF'] * $childCount),
									'OfferedFare' => (($CHILD['NF'] - $TdsOnPLBCal) * $childCount),
									'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
									'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
									'MUFee' => ($CH_MU * $childCount),
									'intPLBEarned' => $PLBEarned,
									'intIncentiveEarned' => $IncentiveEarned,
									'intMemberCount' => $childCount,
									'intFlightRoute' => $strFlightRoute,
									'interNationalSearch' => $interNationalSearch,
								);
								$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArrBR);
								$FareBreakdown[1]['Currency'] = 'INR';
								$FareBreakdown[1]['PassengerType'] = 2;
								$FareBreakdown[1]['PassengerCount'] = $childCount;
								$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
								$FareBreakdown[1]['TotalBaseFare'] = ($CHILD['TF'] * $childCount);
								$FareBreakdown[1]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
								$FareBreakdown[1]['BaseFare'] = ($CHILD['BF'] * $childCount);
								$FareBreakdown[1]['CommissionEarned'] = ($CHILD['NCM'] * $childCount);
								$FareBreakdown[1]['TDS'] = (float)str_replace('-', '', ($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]['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'])) {
								$TdsOnPLBCal = isset($INFANTNCMTDS) ? str_replace('-', '', $INFANTNCMTDS) : 0;
								$markUpArrBR = array(
									'getMarkup' => $getMarkup,
									'PublishedFare' => ($INFANT['TF'] * $infantCount),
									'OfferedFare' => (($INFANT['NF'] - $TdsOnPLBCal) * $infantCount),
									'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
									'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
									'MUFee' => ($IN_MU * $infantCount),
									'intPLBEarned' => $PLBEarned,
									'intIncentiveEarned' => $IncentiveEarned,
									'intMemberCount' => $infantCount,
									'intFlightRoute' => $strFlightRoute,
									'interNationalSearch' => $interNationalSearch,
								);
								$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArrBR);
								$FareBreakdown[2]['Currency'] = 'INR';
								$FareBreakdown[2]['PassengerType'] = 3;
								$FareBreakdown[2]['PassengerCount'] = $infantCount;
								$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
								$FareBreakdown[2]['TotalBaseFare'] = ($INFANT['TF'] * $infantCount);
								$FareBreakdown[2]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
								$FareBreakdown[2]['BaseFare'] = ($INFANT['BF'] * $infantCount);
								$FareBreakdown[2]['CommissionEarned'] = ($INFANT['NCM'] * $infantCount);
								$FareBreakdown[2]['TDS'] = (float)str_replace('-', '', ($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]['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" => ($arrMarkUps['PublishFare'] * $this->CurrencyRate),
								"OfferedFare" => $arrMarkUps['intOfferedFare'],
								"PLBEarned" => $PLBEarned,
								"IncentiveEarned" => $IncentiveEarned,
								"TdsOnPLB" => (float)isset($TdsOnPLB) ? str_replace('-', '', $TdsOnPLB) : 0,
								"TdsOnIncentive" => 0,
								"AdditionalTxnFeeOfrd" => 0,
								"AdditionalTxnFeePub" => 0,
								"Refundable" => $Refundable,
								"IsRefundableTxt" => $IsRefundableTxt,
								"PriceID" => $PriceID,
								"IsGSTRequired" => $IsGSTRequired,
								"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
								"SeatAvailable" => $SeatAvailable,
								"classOfBooking" => $classOfBooking,
								"FareClass" => $fareDetail['ADULT']['cc'],
								"intTotalGST" => $arrMarkUps['intTotalGST'],
								"apiMarkup" => $arrMarkUps['apiMarkup'],
								"IntCommission" => $arrMarkUps['IntCommission'],
								"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
								"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
								"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
								"CommEarned" => $arrMarkUps['intCommisionEarnedForAgency'],
								"GSTonComm" => 0,
								"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
								"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
								"FareBreakdown" => $FareBreakdown,
								"arrMarkUps" => $arrMarkUps,
							);
							// echo '<pre>';
							// print_r($FairRulesArr[$kp]);
							// echo '</pre>';
						}
					}
					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(
								"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,
								"Duration" => $duration,
								"GroundTime" => $GroundTime,
								"NoOfSeatAvailable" => $NoOfSeatAvailable,
								"strDepartureDtTime" => $strDepartureDtTime,
								"strArrivalDtTime" => $strArrivalDtTime,
								"FlightDuration" => $strDuration,
								"LAYOVERDuration" => $LAYOVERDuration,
								"LAYOVERCity" => $LAYOVERCity,
								"DepTerminal" => $DepTerminal,
								"ArrTerminal" => $ArrTerminal,
								"filePath" => $filePath,
							);
						}
					}

					$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';

					$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]['SearchTraceId'] = $FlightTraceId;
					$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]['IsInternational'] = $interNationalSearch;
					$arrInsertFlightData[$key]['logo'] = $filePath;
					$arrInsertFlightData[$key]['FairRules'] = $FairRulesArr;
					$arrInsertFlightData[$key]['Segments'] = $arrSegments;
					$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
					$arrInsertFlightData[$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;

					$arrAirlineName[] = $AirlineCode . '-' . $strAirlineName;
					$AttPriceRange[] = $PublishedFareReverse;
					$FiltStopCount[] = $StopCountTxt;
					if ($FairRulesArr) {
						foreach ($FairRulesArr as $Fare) {
							$dddddddd[] = $Fare['PublishedFare'];
						}
					}
					//$FiltPriceRange[] = $FilterPrice = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_PRICE_RANGE_AED), ($PublishedFare * $this->CurrencyRate));
					//$arrInsertFlightData[$key]['FilterPrice'] = $FilterPrice;
				}
			}
			sort($dddddddd);


			$arrAirlineName = array_unique($arrAirlineName);
			$FiltStopCount = array_unique($FiltStopCount);
			$AttPriceRange = array_unique($AttPriceRange);
			$data = array('inbound' => $arrInsertFlightData, 'dddddddd' => $dddddddd, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'AttPriceRange' => $AttPriceRange);
			return ($data);
		} else {
			return false;
		}
	}

	public function FlightDataRoundTripInternational($apiResponse, $sessionFlightSearchParams)
	{

		$intResponseStatus = !empty($apiResponse['ResponseStatus']) ? $apiResponse['ResponseStatus'] : '0';
		if ($intResponseStatus == 1) {
			$arrAirlineList = $this->getAirlineIdsAndCodeList();
			// For getting All currency Array
			$arrAirlineList = $this->getAirlineIdsAndCodeList();
			//echo '<pre>';print_r($sessionFlightSearchParams);die;
			$strFlightRoute = trim($sessionFlightSearchParams['route']);
			$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';

			$strDepatureDate = $sessionFlightSearchParams['departure_dates'][0];
			$strReturnDate = !empty($sessionFlightSearchParams['return_dates']) ? $sessionFlightSearchParams['return_dates'][0] : '';
			$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
			$strSourceAirportCode = $sessionFlightSearchParams['from'][0];
			$strDestinationAirportCode = $sessionFlightSearchParams['to'][0];
			$adultCount = $sessionFlightSearchParams['adults'];
			$childCount = $sessionFlightSearchParams['child'];
			$infantCount = $sessionFlightSearchParams['infant'];
			$FlightTraceId = trim($sessionFlightSearchParams['FlightTraceId']);

			$intMemberCount = $adultCount + $childCount + $infantCount;
			$strFlightRoute = trim($sessionFlightSearchParams['route']);
			$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
			$intTatalPaxCT = $adultCount + $childCount;
			$getMarkup = $this->getMarkup($intCountryCode);

			$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId'][0]);
			$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId'][0]);

			$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' => $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';
			$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 = $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';
				}
				$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 = [];
				array_multisort($result['totalPriceList']);
				if ($result['totalPriceList']) {
					foreach ($result['totalPriceList'] as $kp => $price) {
						$fareDetail = $price['fd'];

						// echo '<pre>';
						// print_r($fareDetail);
						// echo '</pre>';
						$SeatAvailable = $fareDetail['ADULT']['sR'];
						$classOfBooking = $fareDetail['ADULT']['cB'];
						$Refundable = $fareDetail['ADULT']['rT'];
						$PriceID = $price['id'];
						$fareIdentifier = $price['fareIdentifier'];
						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 

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


						$FareBreakdown[0]['Currency'] = 'INR';
						$FareBreakdown[0]['PassengerType'] = 1;
						$FareBreakdown[0]['PassengerCount'] = $adultCount;
						$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $adultCount);
						$FareBreakdown[0]['TotalBaseFare'] = ($ADULT['TF'] * $adultCount);
						$FareBreakdown[0]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
						$FareBreakdown[0]['BaseFare'] = ($ADULT['BF'] * $adultCount);
						$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $adultCount);
						$FareBreakdown[0]['TDS'] = (float)str_replace('-', '', ($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]['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'])) {
							$TdsOnPLBCal = isset($CHILDNCMTDS) ? str_replace('-', '', $CHILDNCMTDS) : 0;
							$markUpArrBR = array(
								'getMarkup' => $getMarkup,
								'PublishedFare' => ($CHILD['TF'] * $childCount),
								'OfferedFare' => (($CHILD['NF'] - $TdsOnPLBCal) * $childCount),
								'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
								'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
								'MUFee' => ($CH_MU * $childCount),
								'intPLBEarned' => $PLBEarned,
								'intIncentiveEarned' => $IncentiveEarned,
								'intMemberCount' => $childCount,
								'intFlightRoute' => $strFlightRoute,
								'interNationalSearch' => $interNationalSearch,
							);
							$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArrBR);
							$FareBreakdown[1]['Currency'] = 'INR';
							$FareBreakdown[1]['PassengerType'] = 2;
							$FareBreakdown[1]['PassengerCount'] = $childCount;
							$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
							$FareBreakdown[1]['TotalBaseFare'] = ($CHILD['TF'] * $childCount);
							$FareBreakdown[1]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
							$FareBreakdown[1]['BaseFare'] = ($CHILD['BF'] * $childCount);
							$FareBreakdown[1]['CommissionEarned'] = ($CHILD['NCM'] * $childCount);
							$FareBreakdown[1]['TDS'] = (float)str_replace('-', '', ($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]['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'])) {
							$TdsOnPLBCal = isset($INFANTNCMTDS) ? str_replace('-', '', $INFANTNCMTDS) : 0;
							$markUpArrBR = array(
								'getMarkup' => $getMarkup,
								'PublishedFare' => ($INFANT['TF'] * $infantCount),
								'OfferedFare' => (($INFANT['NF'] - $TdsOnPLBCal) * $infantCount),
								'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
								'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
								'MUFee' => ($IN_MU * $infantCount),
								'intPLBEarned' => $PLBEarned,
								'intIncentiveEarned' => $IncentiveEarned,
								'intMemberCount' => $infantCount,
								'intFlightRoute' => $strFlightRoute,
								'interNationalSearch' => $interNationalSearch,
							);
							$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArrBR);
							$FareBreakdown[2]['Currency'] = 'INR';
							$FareBreakdown[2]['PassengerType'] = 3;
							$FareBreakdown[2]['PassengerCount'] = $infantCount;
							$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
							$FareBreakdown[2]['TotalBaseFare'] = ($INFANT['TF'] * $infantCount);
							$FareBreakdown[2]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
							$FareBreakdown[2]['BaseFare'] = ($INFANT['BF'] * $infantCount);
							$FareBreakdown[2]['CommissionEarned'] = ($INFANT['NCM'] * $infantCount);
							$FareBreakdown[2]['TDS'] = (float)str_replace('-', '', ($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]['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" => ($arrMarkUps['PublishFare'] * $this->CurrencyRate),
							"OfferedFare" => $arrMarkUps['intOfferedFare'],
							"PLBEarned" => $PLBEarned,
							"IncentiveEarned" => $IncentiveEarned,
							"TdsOnPLB" => (float)isset($TdsOnPLB) ? str_replace('-', '', $TdsOnPLB) : 0,
							"TdsOnIncentive" => 0,
							"AdditionalTxnFeeOfrd" => 0,
							"AdditionalTxnFeePub" => 0,
							"Refundable" => $Refundable,
							"IsRefundableTxt" => $IsRefundableTxt,
							"PriceID" => $PriceID,
							"IsGSTRequired" => $IsGSTRequired,
							"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
							"SeatAvailable" => $SeatAvailable,
							"classOfBooking" => $classOfBooking,
							"FareClass" => $fareDetail['ADULT']['cc'],
							"intTotalGST" => $arrMarkUps['intTotalGST'],
							"apiMarkup" => $arrMarkUps['apiMarkup'],
							"IntCommission" => $arrMarkUps['IntCommission'],
							"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
							"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
							"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
							"CommEarned" => $arrMarkUps['intCommisionEarnedForAgency'],
							"GSTonComm" => 0,
							"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
							"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
							"FareBreakdown" => $FareBreakdown,
							"arrMarkUps" => $arrMarkUps,
						);
						// echo '<pre>';
						// print_r($FairRulesArr[$kp]);
						// echo '</pre>';
					}
				}
				$TotalDurationReturn = 0;
				$TotalDurationOnward = 0;
				$TotalLAYOVERMinutes = 0;
				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'];
						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,
							"Baggage" => $strBaggage,
							"CabinBaggage" => $strCabinBaggage,
							"IsBaggage" => $IsBaggage,
							"IsMealIncludes" => $IsMealIncludes,
							"Duration" => $duration,
							"GroundTime" => $GroundTime,
							"NoOfSeatAvailable" => $NoOfSeatAvailable,
							"strDepartureDtTime" => $strDepartureDtTime,
							"strArrivalDtTime" => $strArrivalDtTime,
							"FlightDuration" => $strDuration,
							"LAYOVERDuration" => $LAYOVERDuration,
							"LAYOVERCity" => $LAYOVERCity,
							"DepTerminal" => $DepTerminal,
							"ArrTerminal" => $ArrTerminal,
							"filePath" => $filePath,
						);
					}
				}


				$TotalLAYOVERMinutesO = 0;
				$FlyingMinutesO = 0;
				$LAYOVERCityArrO = [];
				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)";
				}


				$arrInsertFlightData[$key]['origin']['FlightNumber'] = $FlightNumber;
				$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']['IsRefundable'] = $IsRefundable;
				$arrInsertFlightData[$key]['origin']['IsRefundableTxt'] = $IsRefundableTxt;
				$arrInsertFlightData[$key]['origin']['SearchTraceId'] = $FlightTraceId;
				$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'] = 1;
				$arrInsertFlightData[$key]['origin']['JourneyType'] = 1;
				$arrInsertFlightData[$key]['origin']['TripType'] = $intTripType;
				$arrInsertFlightData[$key]['origin']['IsInternational'] = $interNationalSearch;
				$arrInsertFlightData[$key]['origin']['logo'] = $filePath;

				//// Rrturn variable

				$TotalLAYOVERMinutesD = 0;
				$FlyingMinutesD = 0;
				$LAYOVERCityArrD = [];
				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;
					}
				}
				$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']['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']['IsRefundable'] = $IsRefundable;
				$arrInsertFlightData[$key]['destination']['IsRefundableTxt'] = $IsRefundableTxt;
				$arrInsertFlightData[$key]['destination']['SearchTraceId'] = $FlightTraceId;
				$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'] = 1;
				$arrInsertFlightData[$key]['destination']['JourneyType'] = $intJourneyType;
				$arrInsertFlightData[$key]['destination']['TripType'] = $intTripType;
				$arrInsertFlightData[$key]['destination']['IsInternational'] = $interNationalSearch;
				$arrInsertFlightData[$key]['destination']['logo'] = $filePath;

				$arrInsertFlightData[$key]['AirlineName'] = $strAirlineName; // As Discussed with GG
				$arrInsertFlightData[$key]['PublishedFare'] = ($PublishedFareReverse * $this->CurrencyRate); // As Discussed with GG
				$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format($PublishedFareReverse);
				$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
				$arrInsertFlightData[$key]['SearchTraceId'] = $FlightTraceId;
				$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
				$arrInsertFlightData[$key]['StopCount'] = $OrStopCountTxt;
				$arrInsertFlightData[$key]['DepartureTime'] = $strDepartureDtTime;
				$arrInsertFlightData[$key]['IsRefundable'] = $IsRefundable;
				$arrInsertFlightData[$key]['IsBagIncludes'] = $IsBagIncludes;

				$arrInsertFlightData[$key]['SourcePlaceSysId'] = $arrCommonInsVariables['intSourceCityId'];
				$arrInsertFlightData[$key]['DestPlaceSysId'] = $arrCommonInsVariables['intDestinationCityId'];
				$arrInsertFlightData[$key]['SourceAirportCode'] = $arrCommonInsVariables['strSourceAirportCode'];
				$arrInsertFlightData[$key]['DestAirportCode']   = $arrCommonInsVariables['strDestinationAirportCode'];
				$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]['FairRules'] = $FairRulesArr;
				$arrInsertFlightData[$key]['Segments'] = $arrSegments;

				$arrInsertFlightData[$key]['arrCommonInsVariables'] = $arrCommonInsVariables;

				if ($FairRulesArr) {
					foreach ($FairRulesArr as $Fare) {
						$dddddddd[] = $Fare['PublishedFare'];
					}
				}
				// $arrInsertFlightData[$key]['fffffffffffff'] = $arrFairRules;
				//$FiltPriceRange[] = $FilterPrice = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_PRICE_RANGE_AED), ($PublishedFare * $this->CurrencyRate));
				$AttPriceRange[] = $PublishedFareReverse;
				$arrAirlineName[] = $AirlineCode . '-' . $strAirlineName;
				$FiltStopCount[] = $OrStopCountTxt;
				$DesFiltStopCount[] = $DeStopCountTxt;

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

				$arrInsertFlightData[$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
			}
			sort($dddddddd);

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

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

			return $data;
		} else {
			return false;
		}
	}

	public function viewmoreAction()
	{
		$post = json_decode(file_get_contents('php://input'), true);
		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($ArrayData);
			$this->view->CurrencyRate = $this->CurrencyRate;
			$this->view->CurrencyTitle = $this->CurrencyTitle;
			$html = new Zend_View();
			$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
			$html->assign(array('Data' => $ArrayData, 'DataInbound' => [], 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle));
			$bodyText = $html->render('viewmore.phtml');
			$response = array('success' => true, 'message' => 'success', 'html' => $bodyText);
			echo json_encode($response);
			exit;
		} else {
			$response = array('success' => false, 'message' => 'failed', 'html' => '');
			echo json_encode($response);
			exit;
		}
	}
	public function getflightfarerulesAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$getData = $this->getRequest()->getParams();
			$sessionFlightSearchParams = json_decode($getData['sessionFlightSearchParams'], true);

			//echo '<pre>';print_r($getData);die;
			$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
			$adultCount = $sessionFlightSearchParams['adults'];
			$childCount = $sessionFlightSearchParams['child'];
			$infantCount = $sessionFlightSearchParams['infant'];
			$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);

			$intMemberCount = $adultCount + $childCount + $infantCount;
			$intMarkUp = $this->getCancelCharge($intCountryCode);


			$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareRulesTripJack($getData);
			$this->view->apiResponse = $apiResponse;
			$this->view->getData = $getData;
			$this->view->intMarkUp = ($intMarkUp * $intMemberCount);
			$this->view->IsLCC = $getData['IsLCC'];
			$this->view->interNationalSearch = $interNationalSearch;
		} else {
			die('Page not found!');
		}
	}

	public function bookNowAction()
	{
		Zend_Session::namespaceUnset('FlightBookingDataRoundInter');
		Zend_Session::namespaceUnset('FlightBookingDataInbound');
		Zend_Session::namespaceUnset('FlightBookingData');
		$post = json_decode(file_get_contents('php://input'), true);
		$roundSelect = isset($post['roundSelect']) ? $post['roundSelect'] : 0;
		$SingleSelect = isset($post['SingleSelect']) ? $post['SingleSelect'] : 0;
		$ProposaltraceID = isset($post['traceID']) ? $post['traceID'] : 0;
		if (isset($post['sessionFlightSearchParams']) && !empty($post['sessionFlightSearchParams'])) {
			$sessionParams = json_decode($post['sessionFlightSearchParams'], true);
		}
		$Outbound = json_decode($post['Outbound'], true);
		$Inbound = json_decode(($post['Inbound']) ? $post['Inbound'] : json_encode([]), true);
		$SearchTraceId = $Outbound['SearchTraceId'];
		// echo '<pre>';
		// print_r($sessionParams);
		// die;
		$FairRules = [];
		if ($Outbound['FairRules']) {
			foreach ($Outbound['FairRules'] as $price) {
				if ($price['PriceID'] == $SingleSelect) {
					$FairRules = $price;
				}
			}
		}

		$Outbound['apiTraceId'] = $SingleSelect;
		$Outbound['FairRules'] = $FairRules;
		$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;
					}
				}
			}
			$Outbound['apiTraceId'] = $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;
		}

		$arrData = array(
			'FlightBookingData' => $FlightBookingData->params,
			'apiTraceId' => $apiTraceId,
			'SearchTraceId' => $SearchTraceId,
		);
		$objFlight = new Travel_Model_FlightMaster();

		if (!empty($sessionParams)) {
			$arrData['sessionFlightSearchParams'] = $sessionParams;
		}

		$tempData = array(
			'TraceId' => $SearchTraceId,
			'json_data' => json_encode($arrData),
		);
		$objFlight->deleteFlightTempData($SearchTraceId);
		$objFlight->insertFlightTempData($tempData);
		if ($FlightBookingData->params) {

			$response = array('success' => true, 'message' => 'Plase wait...', 'url' => $this->baseUrl . '/flight/travellers/data/' . $SearchTraceId);
			echo json_encode($response);
			exit;
		} else {
			$response = array('success' => false, 'message' => 'Oops something went wrong', 'url' => '');
			echo json_encode($response);
			exit;
		}
	}
	public function travellersAction()
	{
		$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
		$objFlight = new Travel_Model_FlightMaster();
		$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
		$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
		$arrUrlData = json_decode($FlightTempData['json_data'], true);
		if (!empty($arrUrlData)) {
			$CountryCode = $this->getCountryCodeList();
			$this->view->CountryCode = $CountryCode;
			// echo '<pre>';
			// print_r($arrUrlData);
			// die('d');
			$FlightBookingData = $arrUrlData['FlightBookingData'];
			$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
			$this->view->FlightBookingData = $FlightBookingData;
			$this->view->SearchTraceId = $arrUrlData['SearchTraceId'];
			$this->view->EditCustomerData = $arrUrlData['ForCustomerSession'];
			$this->view->sessionFlightSearchParams = $sessionFlightSearchParams;
			$this->view->CurrencyRate = $this->CurrencyRate;
			$this->view->CurrencyTitle = $this->CurrencyTitle;
			$this->view->intAdultsCount = $adultCount = isset($sessionFlightSearchParams['adults']) ? $sessionFlightSearchParams['adults'] : 0;
			$this->view->intChildrenCount = $childCount = isset($sessionFlightSearchParams['child']) ? $sessionFlightSearchParams['child'] : 0;
			$this->view->intInfantCount = $infantCount = isset($sessionFlightSearchParams['infant']) ? $sessionFlightSearchParams['infant'] : 0;
			$this->view->totalPaxCount = $adultCount + $childCount + $infantCount;
			$roomjson = array();

			$intPaxCount = 1;
			for ($i = 1; $i <= $adultCount; $i++) {
				$roomjson[$i]['Title'] = 'Adult';
				$roomjson[$i]['paxType'] = 1;
				$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]['intPaxCount'] = $intPaxCount;
					$intPaxCount++;
				}
			}

			$this->view->roomjson = $roomjson;
		} else {
			$this->_redirect('flight');
		}
	}
	public function getflightfarequoteAction()
	{
		$getData = $this->getRequest()->getParams();
		$objFlight = new Travel_Model_FlightMaster();
		$FlightTraceId = $getData['FlightTraceId'];
		$FlightTempData = $objFlight->GetFlightTempData($FlightTraceId);
		$arrUrlData = json_decode($FlightTempData['json_data'], true);
		$FlightBookingData = $arrUrlData['FlightBookingData'];
		$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
		$SearchTraceId = $FlightBookingData[0]['SearchTraceId'];
		$strFlightRoute = trim($sessionFlightSearchParams['route']);
		$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
		Zend_Session::namespaceUnset('FlightSeatSession');
		Zend_Session::namespaceUnset('selectedSeatSession');
		$apiTraceId = [];
		if ($FlightBookingData) {
			foreach ($FlightBookingData as $value) {
				$apiTraceId[] = $value['FairRules']['PriceID'];
			}
		}

		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$this->_helper->viewRenderer->setNoRender(true);

			$getQ = array(
				'TraceId' => $apiTraceId,
				'Inbound' => false,
			);

			//$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareQuoteTripJack($getQ);
			$str = file_get_contents($this->baseUrl . '/public/logs/flight/FlightFareReview/Review_response.json');
			$apiResponse = json_decode($str, true);

			$ResponseStatus = $apiResponse['status']['success'];
			$ErrorMessage = isset($apiResponse['errors'][0]['message']) ? $apiResponse['errors'][0]['message'] : '';
			if ($ResponseStatus == 1) {
				$alerts = isset($apiResponse['alerts']) ? $apiResponse['alerts'] : '';
				$FlightBookingData = $this->UpdateFlightBookingData($apiResponse, $alerts, $SearchTraceId, $sessionFlightSearchParams, $FlightBookingData);
				// echo '<pre>';
				// print_r($FlightBookingData);
				// die('d');
				$newFare = 0;
				$oldFare = 0;
				$PublishedFare = 0;
				$intPublishedFare = 0;
				$Baggage = [];
				$Meal = [];

				if ($FlightBookingData) {
					foreach ($FlightBookingData as $value) {
						$newFare += $value['FairRules']['newFare'];
						$PublishedFare += $value['FairRules']['newFare'];
						$intPublishedFare += $value['FairRules']['PublishedFare'];
						$oldFare += $value['FairRules']['oldFare'];
						$Baggage[] = $value['Baggage'];
						$Meal[] = $value['Meal'];
					}
				}

				$SSRArr = array('Meal' => $Meal, 'Baggage' => $Baggage, 'SeatPreference' => array());
				$FareChange = false;
				if ($newFare != $oldFare) {
					$FareChange = true;
				}
				$html = new Zend_View();
				$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
				$html->assign(array('Data' => $FlightBookingData, 'baseUrl' => $this->baseUrl, 'sessionFlightSearchParams' => $sessionFlightSearchParams, 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
				$bodyText = $html->render('faresummaryright.phtml');
				$response = array('success' => true, 'message' => 'Done', 'FareChange' => $FareChange, 'html' => $bodyText, 'intPublishedFare' => $this->CurrencyTitle . ' ' . number_format(($intPublishedFare), 2), 'SSRArr' => json_encode($SSRArr), 'SSRArrInb' => [], 'apiResponse' => json_encode($FlightBookingData));
				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('ddd');
		} else {
			die('Page not found!');
		}
	}



	public function UpdateFlightBookingData($data, $alerts, $SearchTraceId, $sessionFlightSearchParams, $FlightBookingData)
	{
		$arrAirlineList = $this->getAirlineIdsAndCodeList();;
		$apiResponse = $data;

		$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId'][0]);
		$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId'][0]);
		$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
		$departureDates     = $sessionFlightSearchParams['departure_dates'][0];
		$return_dates     = $sessionFlightSearchParams['return_dates'][0];
		$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);

		$strSourceAirportCode = $sessionFlightSearchParams['from'][0];
		$strDestinationAirportCode = $sessionFlightSearchParams['to'][0];
		$adultCount = $sessionFlightSearchParams['adults'];
		$childCount = $sessionFlightSearchParams['child'];
		$infantCount = $sessionFlightSearchParams['infant'];
		$intMemberCount = $adultCount + $childCount + $infantCount;
		$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
		$strFlightRoute = trim($sessionFlightSearchParams['route']);
		$intTatalPaxCT = $adultCount + $childCount;
		if (!empty(trim($intCountryCode)) && trim($intCountryCode) != "IN") {
			$intAirType = 2;
		} else {
			$intAirType = 1;
		}
		$getMarkup = $this->getMarkup($intCountryCode);
		$objMarkup = new Travel_Model_Markup();
		$getAgencyMarkups = $objMarkup->getAgencyMarkups($intAirType, $this->gtxagencysysid);
		// echo '<pre>';
		// print_r($getAgencyMarkups);
		// die('d');
		$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';
		$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'];
		$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;
		$isSeatApplicable = isset($data['conditions']['isa']) ? $data['conditions']['isa'] : false;
		$isSessionTime = isset($data['conditions']['st']) ? $data['conditions']['st'] : false;
		$isSessionTime = floor(($isSessionTime / 60) % 60);

		$isAdobrMandatory = isset($data['conditions']['dob']['adobr']) ? $data['conditions']['dob']['adobr'] : false;
		$isCdobrMandatory = isset($data['conditions']['dob']['cdobr']) ? $data['conditions']['dob']['cdobr'] : false;
		$isIdobrMandatory = isset($data['conditions']['dob']['idobr']) ? $data['conditions']['dob']['idobr'] : false;

		$arrInsertFlightBookingData = [];

		try {
			if ($data['tripInfos']) {
				foreach ($data['tripInfos'] as $key => $result) {
					if ($key == 0) {
						$intJourneyType = 1;
					} else {
						$intJourneyType = 2;
					}
					if ($interNationalSearch == 1 && $strFlightRoute == 2) {
						$BookingData = $FlightBookingData[0];
					} else {
						$BookingData = $FlightBookingData[$key];
					}

					$alertsFare = isset($alerts[$key]) ? $alerts[$key] : [];

					$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'];
					$ExtraMarkup = $BookingData['FairRules']['ExtraMarkup'];
					$ExtraMarkupOnGST = $BookingData['FairRules']['ExtraMarkupOnGST'];
					$TotalExtraMarkUp = ($ExtraMarkup + $ExtraMarkupOnGST);
					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;
					$$PublishedFareReverse = 0;
					$BaseFare = 0;
					$Tax = 0;
					$YQTax = 0;
					$OtherCharges = 0;
					$ServiceFee = 0;
					$newFare = isset($alertsFare['newFare']) ? $alertsFare['newFare'] : 0;
					$oldFare = isset($alertsFare['oldFare']) ? $alertsFare['oldFare'] : 0;
					$FareBreakdown = [];
					$FairRulesArr = [];
					if ($result['totalPriceList']) {
						foreach ($result['totalPriceList'] as $kp => $price) {
							$fareDetail = $price['fd'];

							// echo '<pre>';
							// print_r($fareDetail);
							// echo '</pre>';
							$SeatAvailable = $fareDetail['ADULT']['sR'];
							$classOfBooking = $fareDetail['ADULT']['cB'];
							$Refundable = $fareDetail['ADULT']['rT'];
							$PriceID = $price['id'];
							$fareIdentifier = $price['fareIdentifier'];
							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 

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


							$FareBreakdown[0]['Currency'] = 'INR';
							$FareBreakdown[0]['PassengerType'] = 1;
							$FareBreakdown[0]['PassengerCount'] = $adultCount;
							$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $adultCount);
							$FareBreakdown[0]['TotalBaseFare'] = ($ADULT['TF'] * $adultCount);
							$FareBreakdown[0]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
							$FareBreakdown[0]['BaseFare'] = ($ADULT['BF'] * $adultCount);
							$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $adultCount);
							$FareBreakdown[0]['TDS'] = (float)str_replace('-', '', ($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]['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]['AgentMarkUp'] = $arrMarkUpsBR['totalAgentMarkUp'];
							$FareBreakdown[0]['GSTOnAgentMarkUp'] = $arrMarkUpsBR['intGSTOnAgentFixMarkUp'];
							$FareBreakdown[0]['Agencycommission'] = $arrMarkUpsBR['Agencycommission'];
							$FareBreakdown[0]['TotalCommssionVal_ag'] = $arrMarkUpsBR['TotalCommssionVal_ag'];
							$FareBreakdown[0]['AdminComminAmount_ag'] = $arrMarkUpsBR['AdminComminAmount_ag'];
							$FareBreakdown[0]['AgentB2CEarning'] = $arrMarkUpsBR['AgentB2CEarning'];
							$FareBreakdown[0]['CostToAgentCustomer'] = $arrMarkUpsBR['CostToAgentCustomer'];
							$FareBreakdown[0]['CostToAgent'] = $arrMarkUpsBR['CostToAgent'];
							$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'])) {
								$TdsOnPLBCal = isset($CHILDNCMTDS) ? str_replace('-', '', $CHILDNCMTDS) : 0;
								$markUpArrBR = array(
									'getMarkup' => $getMarkup,
									'getAgencyMarkups' => $getAgencyMarkups,
									'PublishedFare' => ($CHILD['TF'] * $childCount),
									'OfferedFare' => (($CHILD['NF'] - $TdsOnPLBCal) * $childCount),
									'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
									'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
									'MUFee' => ($CH_MU * $childCount),
									'intPLBEarned' => $PLBEarned,
									'intIncentiveEarned' => $IncentiveEarned,
									'intMemberCount' => $childCount,
									'intFlightRoute' => $strFlightRoute,
									'interNationalSearch' => $interNationalSearch,
								);
								$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArrBR);
								$FareBreakdown[1]['Currency'] = 'INR';
								$FareBreakdown[1]['PassengerType'] = 2;
								$FareBreakdown[1]['PassengerCount'] = $childCount;
								$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
								$FareBreakdown[1]['TotalBaseFare'] = ($CHILD['TF'] * $childCount);
								$FareBreakdown[1]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
								$FareBreakdown[1]['BaseFare'] = ($CHILD['BF'] * $childCount);
								$FareBreakdown[1]['CommissionEarned'] = ($CHILD['NCM'] * $childCount);
								$FareBreakdown[1]['TDS'] = (float)str_replace('-', '', ($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]['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]['AgentMarkUp'] = $arrMarkUpsBR['totalAgentMarkUp'];
								$FareBreakdown[1]['GSTOnAgentMarkUp'] = $arrMarkUpsBR['intGSTOnAgentFixMarkUp'];
								$FareBreakdown[1]['Agencycommission'] = $arrMarkUpsBR['Agencycommission'];
								$FareBreakdown[1]['TotalCommssionVal_ag'] = $arrMarkUpsBR['TotalCommssionVal_ag'];
								$FareBreakdown[1]['AdminComminAmount_ag'] = $arrMarkUpsBR['AdminComminAmount_ag'];
								$FareBreakdown[1]['AgentB2CEarning'] = $arrMarkUpsBR['AgentB2CEarning'];
								$FareBreakdown[1]['CostToAgentCustomer'] = $arrMarkUpsBR['CostToAgentCustomer'];
								$FareBreakdown[1]['CostToAgent'] = $arrMarkUpsBR['CostToAgent'];
								$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'])) {
								$TdsOnPLBCal = isset($INFANTNCMTDS) ? str_replace('-', '', $INFANTNCMTDS) : 0;
								$markUpArrBR = array(
									'getMarkup' => $getMarkup,
									'getAgencyMarkups' => $getAgencyMarkups,
									'PublishedFare' => ($INFANT['TF'] * $infantCount),
									'OfferedFare' => (($INFANT['NF'] - $TdsOnPLBCal) * $infantCount),
									'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
									'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
									'MUFee' => ($IN_MU * $infantCount),
									'intPLBEarned' => $PLBEarned,
									'intIncentiveEarned' => $IncentiveEarned,
									'intMemberCount' => $infantCount,
									'intFlightRoute' => $strFlightRoute,
									'interNationalSearch' => $interNationalSearch,
								);
								$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArrBR);
								$FareBreakdown[2]['Currency'] = 'INR';
								$FareBreakdown[2]['PassengerType'] = 3;
								$FareBreakdown[2]['PassengerCount'] = $infantCount;
								$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
								$FareBreakdown[2]['TotalBaseFare'] = ($INFANT['TF'] * $infantCount);
								$FareBreakdown[2]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
								$FareBreakdown[2]['BaseFare'] = ($INFANT['BF'] * $infantCount);
								$FareBreakdown[2]['CommissionEarned'] = ($INFANT['NCM'] * $infantCount);
								$FareBreakdown[2]['TDS'] = (float)str_replace('-', '', ($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]['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]['AgentMarkUp'] = $arrMarkUpsBR['totalAgentMarkUp'];
								$FareBreakdown[2]['GSTOnAgentMarkUp'] = $arrMarkUpsBR['intGSTOnAgentFixMarkUp'];
								$FareBreakdown[2]['Agencycommission'] = $arrMarkUpsBR['Agencycommission'];
								$FareBreakdown[2]['TotalCommssionVal_ag'] = $arrMarkUpsBR['TotalCommssionVal_ag'];
								$FareBreakdown[2]['AdminComminAmount_ag'] = $arrMarkUpsBR['AdminComminAmount_ag'];
								$FareBreakdown[2]['AgentB2CEarning'] = $arrMarkUpsBR['AgentB2CEarning'];
								$FareBreakdown[2]['CostToAgentCustomer'] = $arrMarkUpsBR['CostToAgentCustomer'];
								$FareBreakdown[2]['CostToAgent'] = $arrMarkUpsBR['CostToAgent'];
								$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),
								"PublishedFareAgent" => ($arrMarkUps['CostToAgentCustomer'] * $this->CurrencyRate),
								"OfferedFareAgent" => ($arrMarkUps['CostToAgent'] * $this->CurrencyRate),
								"OfferedFare" => $arrMarkUps['intOfferedFare'],
								"PLBEarned" => $PLBEarned,
								"IncentiveEarned" => $IncentiveEarned,
								"TdsOnPLB" => (float)isset($TdsOnPLB) ? str_replace('-', '', $TdsOnPLB) : 0,
								"TdsOnIncentive" => 0,
								"AdditionalTxnFeeOfrd" => 0,
								"AdditionalTxnFeePub" => 0,
								"Refundable" => $Refundable,
								"IsRefundableTxt" => $IsRefundableTxt,
								"PriceID" => $PriceID,
								"IsGSTRequired" => $IsGSTRequired,
								"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
								"SeatAvailable" => $SeatAvailable,
								"classOfBooking" => $classOfBooking,
								"FareClass" => $fareDetail['ADULT']['cc'],
								"intTotalGST" => $arrMarkUps['intTotalGST'],
								"apiMarkup" => $arrMarkUps['apiMarkup'],
								"IntCommission" => $arrMarkUps['IntCommission'],
								"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
								"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
								"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
								"CommEarned" => $arrMarkUps['intCommisionEarnedForAgency'],
								"CommEarnedAgent" => $arrMarkUps['AgentB2CEarning'],
								"GSTonComm" => 0,
								"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
								"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],

								"AgentMarkUp" => $arrMarkUps['totalAgentMarkUp'],
								"GSTOnAgentMarkUp" => $arrMarkUps['intGSTOnAgentFixMarkUp'],
								'Agencycommission' => $arrMarkUps['Agencycommission'],
								'TotalCommssionVal_ag' => $arrMarkUps['TotalCommssionVal_ag'],
								'AdminComminAmount_ag' => $arrMarkUps['AdminComminAmount_ag'],
								'AgentB2CEarning' => $arrMarkUps['AgentB2CEarning'],
								'CostToAgentCustomer' => $arrMarkUps['CostToAgentCustomer'],
								'CostToAgent' => $arrMarkUps['CostToAgent'],
								"FareBreakdown" => $FareBreakdown,
								"arrMarkUps" => $arrMarkUps,
							);
							// echo '<pre>';
							// print_r($FairRulesArr[$kp]);
							// echo '</pre>';
						}
					}
					// if ($result['totalPriceList']) {
					// 	foreach ($result['totalPriceList'] as $kp => $price) {
					// 		$fareDetail = $price['fd'];

					// 		$SeatAvailable = $fareDetail['ADULT']['sR'];
					// 		$classOfBooking = $fareDetail['ADULT']['cB'];
					// 		$Refundable = $fareDetail['ADULT']['rT'];
					// 		$PriceID = $price['id'];

					// 		$fareIdentifier = $price['fareIdentifier'];
					// 		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 
					// 		// echo '<pre>';
					// 		// print_r(($fareDetail));
					// 		// echo '</pre>';
					// 		$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));

					// 		$PublishedFare = $PublishedFareIN;
					// 		$CommissionEarned = $NetCommission;
					// 		$PLBEarned = 0; //$result['Fare']['PLBEarned'];
					// 		$IncentiveEarned = 0; //$result['Fare']['IncentiveEarned'];
					// 		$OfferedFare = $NetFare;
					// 		$markUpArr = array(
					// 			'getMarkup' => $getMarkup,
					// 			'PublishedFare' => $PublishedFare,
					// 			'OfferedFare' => $OfferedFare,
					// 			'intCommissionEarned' => $CommissionEarned,
					// 			'TdsOnPLB' => $TdsOnPLB,
					// 			'MUFee' => $MUFee,
					// 			'intPLBEarned' => $PLBEarned,
					// 			'intIncentiveEarned' => $IncentiveEarned,
					// 			'intMemberCount' => $intMemberCount,
					// 			'intFlightRoute' => $strFlightRoute,
					// 			'interNationalSearch' => $interNationalSearch,
					// 		);
					// 		$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArr);
					// 		// echo '<pre>';
					// 		// print_r(($arrMarkUps));
					// 		// echo '</pre>';die('ss');

					// 		$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,
					// 		);
					// 		$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($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]['TotalBaseFare'] = ($ADULT['TF'] * $adultCount);
					// 		$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]['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,
					// 			);
					// 			$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArrBR);
					// 			$FareBreakdown[1]['Currency'] = 'INR';
					// 			$FareBreakdown[1]['PassengerType'] = 2;
					// 			$FareBreakdown[1]['PassengerCount'] = $childCount;
					// 			$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
					// 			$FareBreakdown[1]['TotalBaseFare'] = ($CHILD['TF'] * $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]['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,
					// 			);
					// 			$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArrBR);
					// 			$FareBreakdown[2]['Currency'] = 'INR';
					// 			$FareBreakdown[2]['PassengerType'] = 3;
					// 			$FareBreakdown[2]['PassengerCount'] = $infantCount;
					// 			$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
					// 			$FareBreakdown[2]['TotalBaseFare'] = ($INFANT['TF'] * $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]['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 ;
					// 		}

					// 		$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'] + $TotalExtraMarkUp) * $this->CurrencyRate),
					// 			"OfferedFare" => $arrMarkUps['intOfferedFare'],
					// 			"PLBEarned" => $PLBEarned,
					// 			"IncentiveEarned" => $IncentiveEarned,
					// 			"TdsOnPLB" => $TdsOnPLB,
					// 			"TdsOnIncentive" => 0,
					// 			"AdditionalTxnFeeOfrd" => 0,
					// 			"AdditionalTxnFeePub" => 0,
					// 			"Refundable" => $Refundable,
					// 			"IsRefundableTxt" => $IsRefundableTxt,
					// 			"PriceID" => $PriceID,
					// 			"IsGSTRequired" => $IsGSTRequired,
					// 			"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
					// 			"SeatAvailable" => $SeatAvailable,
					// 			"classOfBooking" => $classOfBooking,
					// 			"newFare" => $newFare,
					// 			"oldFare" => $oldFare,
					// 			"FareClass" => $fareDetail['ADULT']['cc'],
					// 			"intTotalGST" => $arrMarkUps['intTotalGST'],
					// 			"apiMarkup" => $arrMarkUps['apiMarkup'],
					// 			"IntCommission" => $arrMarkUps['IntCommission'],
					// 			"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
					// 			"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
					// 			"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
					// 			"CommEarned" => $arrMarkUps['intCommisionEarnedForAgency'],
					// 			"GSTonComm" => 0,
					// 			"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
					// 			"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
					// 			"ExtraMarkup" => $ExtraMarkup,
					// 			"ExtraMarkupOnGST" => $ExtraMarkupOnGST,
					// 			"FareBreakdown" => $FareBreakdown,
					// 		);
					// 		// echo '<pre>';
					// 		// print_r($FairRulesArr[$kp]);
					// 		// echo '</pre>';
					// 	}
					// }


					$BAGGAGE = isset($OriginSegments['ssrInfo']['BAGGAGE']) ? $OriginSegments['ssrInfo']['BAGGAGE'] : '';
					$MEAL = isset($OriginSegments['ssrInfo']['MEAL']) ? $OriginSegments['ssrInfo']['MEAL'] : '';
					if ($BAGGAGE) {
						foreach ($BAGGAGE as $b => $bag) {
							$Weight = str_replace('Excess Baggage - ', '', $bag['desc']);
							$BaggageArr[$b]['Currency'] = 'INR';
							$BaggageArr[$b]['key'] = $OriginSegments['id'];
							$BaggageArr[$b]['Code'] = $bag['code'];
							$BaggageArr[$b]['Price'] = isset($bag['amount']) ? $bag['amount'] : 0;
							$BaggageArr[$b]['Weight'] = $Weight;
						}
					}
					if ($MEAL) {
						foreach ($MEAL as $m => $meals) {
							$MealArr[$m]['Currency'] = 'INR';
							$MealArr[$m]['key'] = $OriginSegments['id'];
							$MealArr[$m]['Code'] = $meals['code'];
							$MealArr[$m]['Price'] = isset($meals['amount']) ? $meals['amount'] : 0;
							$MealArr[$m]['Description'] = $meals['desc'];
						}
					}

					if ($SegmentInformation) {
						foreach ($SegmentInformation as $k => $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")->getTimeFromApiStringTJ($destinationArrTime);
							$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($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" => ($k + 1),
								"Baggage" => $strBaggage,
								"CabinBaggage" => $strCabinBaggage,
								"IsBaggage" => $IsBaggage,
								"IsMealIncludes" => $IsMealIncludes,
								"SegmentIndicator" => ($k + 1),
								"Duration" => $duration,
								"GroundTime" => $GroundTime,
								"NoOfSeatAvailable" => $NoOfSeatAvailable,
								"strDepartureDtTime" => $strDepartureDtTime,
								"strArrivalDtTime" => $strArrivalDtTime,
								"FlightDuration" => $strDuration,
								"LAYOVERDuration" => $LAYOVERDuration,
								"LAYOVERCity" => $LAYOVERCity,
								"DepTerminal" => $DepTerminal,
								"ArrTerminal" => $ArrTerminal,
								"filePath" => $filePath,
							);
						}
					}
					$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")->getTimeFromApiStringTJ($DestinationSegments['at']);
					$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($OriginSegments['dt']);
					$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
					$arrInsertFlightData[$key]['bookingId'] = $bookingId;
					$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]['SearchTraceId'] = $SearchTraceId;
					$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]['StopCount'] = $StopCountTxt;
					$arrInsertFlightData[$key]['Stops'] = $Stops;
					$arrInsertFlightData[$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
					$arrInsertFlightData[$key]['TotalFlightMembers'] = $intMemberCount;
					$arrInsertFlightData[$key]['CurrencyType'] = 1;
					$arrInsertFlightData[$key]['PublishedFare'] = $$PublishedFareReverse; // As Discussed with GG
					$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format($PublishedFareReverse); // As Discussed with GG
					$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
					$arrInsertFlightData[$key]['JourneyType'] = $intJourneyType;
					$arrInsertFlightData[$key]['TripType'] = $intTripType;
					$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
					$arrInsertFlightData[$key]['logo'] = $filePath;
					$arrInsertFlightData[$key]['FairRules'] = $FairRulesArr;
					$arrInsertFlightData[$key]['Segments'] = $arrSegments;
					$arrInsertFlightData[$key]['Baggage'] = $BaggageArr;
					$arrInsertFlightData[$key]['Meal'] = $MealArr;
					$arrInsertFlightData[$key]['isGSTMandatory'] = $isGSTMandatory;
					$arrInsertFlightData[$key]['IsPassMandatory'] = $IsPassMandatory;
					$arrInsertFlightData[$key]['IsPassExpiry'] = $IsPassExpiry;
					$arrInsertFlightData[$key]['IsPassIssue'] = $IsPassIssue;
					$arrInsertFlightData[$key]['IsPassDateOfBirth'] = $IsPassDateOfBirth;
					$arrInsertFlightData[$key]['isAdobrMandatory'] = $isAdobrMandatory;
					$arrInsertFlightData[$key]['isCdobrMandatory'] = $isCdobrMandatory;
					$arrInsertFlightData[$key]['isIdobrMandatory'] = $isIdobrMandatory;
					$arrInsertFlightData[$key]['isSeatApplicable'] = $isSeatApplicable;
					$arrInsertFlightData[$key]['isSessionTime'] = $isSessionTime . ':00';

					$arrInsertFlightData[$key]['strTraceId'] = $strTraceId;

					// echo '<pre>';
					// print_r($arrInsertFlightData[$key]);
					// echo '</pre>';
					$arrInsertFlightData[$key]['arrCommonInsVariables'] = $arrCommonInsVariables;
				}
			}
		} catch (Zend_Exception $e) {
			print_r($e->getMessage());
			exit;
		}
		return $arrInsertFlightData;
	}
	public function UpdateFlightBookingDataInternational($data, $alerts, $SearchTraceId, $sessionFlightSearchParams, $FlightBookingData)
	{
		$arrAirlineList = $this->getAirlineIdsAndCodeList();;
		$apiResponse = $data;

		$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId'][0]);
		$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId'][0]);
		$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
		$departureDates     = $sessionFlightSearchParams['departure_dates'][0];
		$return_dates     = $sessionFlightSearchParams['return_dates'][0];
		$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);

		$strSourceAirportCode = $sessionFlightSearchParams['from'][0];
		$strDestinationAirportCode = $sessionFlightSearchParams['to'][0];
		$adultCount = $sessionFlightSearchParams['adults'];
		$childCount = $sessionFlightSearchParams['child'];
		$infantCount = $sessionFlightSearchParams['infant'];
		$intMemberCount = $adultCount + $childCount + $infantCount;
		$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
		$strFlightRoute = trim($sessionFlightSearchParams['route']);
		$intTatalPaxCT = $adultCount + $childCount;
		$getMarkup = $this->getMarkup($intCountryCode);

		$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';
		$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'];
		$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;
		$isSeatApplicable = isset($data['conditions']['isa']) ? $data['conditions']['isa'] : false;
		$isSessionTime = isset($data['conditions']['st']) ? $data['conditions']['st'] : false;
		$isSessionTime = floor(($isSessionTime / 60) % 60);

		$isAdobrMandatory = isset($data['conditions']['dob']['adobr']) ? $data['conditions']['dob']['adobr'] : false;
		$isCdobrMandatory = isset($data['conditions']['dob']['cdobr']) ? $data['conditions']['dob']['cdobr'] : false;
		$isIdobrMandatory = isset($data['conditions']['dob']['idobr']) ? $data['conditions']['dob']['idobr'] : false;

		$arrInsertFlightBookingData = [];
		try {
			if ($data['tripInfos']) {
				foreach ($data['tripInfos'] as $key => $result) {
					if ($key == 0) {
						$intJourneyType = 1;
					} else {
						$intJourneyType = 2;
					}
					$BookingData = $FlightBookingData[$key];
					$alertsFare = isset($alerts[$key]) ? $alerts[$key] : [];

					$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'];
					$ExtraMarkup = $BookingData['FairRules']['ExtraMarkup'];
					$ExtraMarkupOnGST = $BookingData['FairRules']['ExtraMarkupOnGST'];
					$TotalExtraMarkUp = ($ExtraMarkup + $ExtraMarkupOnGST);
					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;
					$newFare = isset($alertsFare['newFare']) ? $alertsFare['newFare'] : 0;
					$oldFare = isset($alertsFare['oldFare']) ? $alertsFare['oldFare'] : 0;
					$FareBreakdown = [];
					$FairRulesArr = [];
					if ($result['totalPriceList']) {
						foreach ($result['totalPriceList'] as $kp => $price) {
							$fareDetail = $price['fd'];

							$SeatAvailable = $fareDetail['ADULT']['sR'];
							$classOfBooking = $fareDetail['ADULT']['cB'];
							$Refundable = $fareDetail['ADULT']['rT'];
							$PriceID = $price['id'];
							$fareIdentifier = $price['fareIdentifier'];
							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 
							// echo '<pre>';
							// print_r(($fareDetail));
							// echo '</pre>';
							$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));

							$PublishedFare = $PublishedFareIN;
							$CommissionEarned = $NetCommission;
							$PLBEarned = 0; //$result['Fare']['PLBEarned'];
							$IncentiveEarned = 0; //$result['Fare']['IncentiveEarned'];
							$OfferedFare = $NetFare;
							$markUpArr = array(
								'getMarkup' => $getMarkup,
								'PublishedFare' => $PublishedFare,
								'OfferedFare' => $OfferedFare,
								'intCommissionEarned' => $CommissionEarned,
								'TdsOnPLB' => $TdsOnPLB,
								'MUFee' => $MUFee,
								'intPLBEarned' => $PLBEarned,
								'intIncentiveEarned' => $IncentiveEarned,
								'intMemberCount' => $intMemberCount,
								'intFlightRoute' => $strFlightRoute,
								'interNationalSearch' => $interNationalSearch,
							);
							$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArr);
							// echo '<pre>';
							// print_r(($arrMarkUps));
							// echo '</pre>';die('ss');

							$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,
							);
							$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($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]['TotalBaseFare'] = ($ADULT['TF'] * $adultCount);
							$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]['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,
								);
								$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArrBR);
								$FareBreakdown[1]['Currency'] = 'INR';
								$FareBreakdown[1]['PassengerType'] = 2;
								$FareBreakdown[1]['PassengerCount'] = $childCount;
								$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
								$FareBreakdown[1]['TotalBaseFare'] = ($CHILD['TF'] * $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]['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,
								);
								$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArrBR);
								$FareBreakdown[2]['Currency'] = 'INR';
								$FareBreakdown[2]['PassengerType'] = 3;
								$FareBreakdown[2]['PassengerCount'] = $infantCount;
								$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
								$FareBreakdown[2]['TotalBaseFare'] = ($INFANT['TF'] * $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]['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 ;
							}

							$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'] + $TotalExtraMarkUp) * $this->CurrencyRate),
								"OfferedFare" => $arrMarkUps['intOfferedFare'],
								"PLBEarned" => $PLBEarned,
								"IncentiveEarned" => $IncentiveEarned,
								"TdsOnPLB" => $TdsOnPLB,
								"TdsOnIncentive" => 0,
								"AdditionalTxnFeeOfrd" => 0,
								"AdditionalTxnFeePub" => 0,
								"Refundable" => $Refundable,
								"IsRefundableTxt" => $IsRefundableTxt,
								"PriceID" => $PriceID,
								"IsGSTRequired" => $IsGSTRequired,
								"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
								"SeatAvailable" => $SeatAvailable,
								"classOfBooking" => $classOfBooking,
								"newFare" => $newFare,
								"oldFare" => $oldFare,
								"FareClass" => $fareDetail['ADULT']['cc'],
								"intTotalGST" => $arrMarkUps['intTotalGST'],
								"apiMarkup" => $arrMarkUps['apiMarkup'],
								"IntCommission" => $arrMarkUps['IntCommission'],
								"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
								"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
								"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
								"CommEarned" => $arrMarkUps['intCommisionEarnedForAgency'],
								"GSTonComm" => 0,
								"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
								"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
								"ExtraMarkup" => $ExtraMarkup,
								"ExtraMarkupOnGST" => $ExtraMarkupOnGST,
								"FareBreakdown" => $FareBreakdown,
							);
							// echo '<pre>';
							// print_r($FairRulesArr[$kp]);
							// echo '</pre>';
						}
					}


					$BAGGAGE = isset($OriginSegments['ssrInfo']['BAGGAGE']) ? $OriginSegments['ssrInfo']['BAGGAGE'] : '';
					$MEAL = isset($OriginSegments['ssrInfo']['MEAL']) ? $OriginSegments['ssrInfo']['MEAL'] : '';
					if ($BAGGAGE) {
						foreach ($BAGGAGE as $b => $bag) {
							$Weight = str_replace('Excess Baggage - ', '', $bag['desc']);
							$BaggageArr[$b]['Currency'] = 'INR';
							$BaggageArr[$b]['key'] = $OriginSegments['id'];
							$BaggageArr[$b]['Code'] = $bag['code'];
							$BaggageArr[$b]['Price'] = isset($bag['amount']) ? $bag['amount'] : 0;
							$BaggageArr[$b]['Weight'] = $Weight;
						}
					}
					if ($MEAL) {
						foreach ($MEAL as $m => $meals) {
							$MealArr[$m]['Currency'] = 'INR';
							$MealArr[$m]['key'] = $OriginSegments['id'];
							$MealArr[$m]['Code'] = $meals['code'];
							$MealArr[$m]['Price'] = isset($meals['amount']) ? $meals['amount'] : 0;
							$MealArr[$m]['Description'] = $meals['desc'];
						}
					}

					if ($SegmentInformation) {
						foreach ($SegmentInformation as $k => $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")->getTimeFromApiStringTJ($destinationArrTime);
							$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($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" => ($k + 1),
								"Baggage" => $strBaggage,
								"CabinBaggage" => $strCabinBaggage,
								"IsBaggage" => $IsBaggage,
								"IsMealIncludes" => $IsMealIncludes,
								"SegmentIndicator" => ($k + 1),
								"Duration" => $duration,
								"GroundTime" => $GroundTime,
								"NoOfSeatAvailable" => $NoOfSeatAvailable,
								"strDepartureDtTime" => $strDepartureDtTime,
								"strArrivalDtTime" => $strArrivalDtTime,
								"FlightDuration" => $strDuration,
								"LAYOVERDuration" => $LAYOVERDuration,
								"LAYOVERCity" => $LAYOVERCity,
								"DepTerminal" => $DepTerminal,
								"ArrTerminal" => $ArrTerminal,
								"filePath" => $filePath,
							);
						}
					}
					$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")->getTimeFromApiStringTJ($DestinationSegments['at']);
					$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($OriginSegments['dt']);
					$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
					$arrInsertFlightData[$key]['bookingId'] = $bookingId;
					$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]['SearchTraceId'] = $SearchTraceId;
					$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]['StopCount'] = $StopCountTxt;
					$arrInsertFlightData[$key]['Stops'] = $Stops;
					$arrInsertFlightData[$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
					$arrInsertFlightData[$key]['TotalFlightMembers'] = $intMemberCount;
					$arrInsertFlightData[$key]['CurrencyType'] = 1;
					$arrInsertFlightData[$key]['PublishedFare'] = $PublishedFare; // As Discussed with GG
					$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format($PublishedFare); // As Discussed with GG
					$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
					$arrInsertFlightData[$key]['JourneyType'] = $intJourneyType;
					$arrInsertFlightData[$key]['TripType'] = $intTripType;
					$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
					$arrInsertFlightData[$key]['logo'] = $filePath;
					$arrInsertFlightData[$key]['FairRules'] = $FairRulesArr;
					$arrInsertFlightData[$key]['Segments'] = $arrSegments;
					$arrInsertFlightData[$key]['Baggage'] = $BaggageArr;
					$arrInsertFlightData[$key]['Meal'] = $MealArr;
					$arrInsertFlightData[$key]['isGSTMandatory'] = $isGSTMandatory;
					$arrInsertFlightData[$key]['IsPassMandatory'] = $IsPassMandatory;
					$arrInsertFlightData[$key]['IsPassExpiry'] = $IsPassExpiry;
					$arrInsertFlightData[$key]['IsPassIssue'] = $IsPassIssue;
					$arrInsertFlightData[$key]['IsPassDateOfBirth'] = $IsPassDateOfBirth;
					$arrInsertFlightData[$key]['isAdobrMandatory'] = $isAdobrMandatory;
					$arrInsertFlightData[$key]['isCdobrMandatory'] = $isCdobrMandatory;
					$arrInsertFlightData[$key]['isIdobrMandatory'] = $isIdobrMandatory;
					$arrInsertFlightData[$key]['isSeatApplicable'] = $isSeatApplicable;
					$arrInsertFlightData[$key]['isSessionTime'] = $isSessionTime . ':00';
					$arrInsertFlightData[$key]['strTraceId'] = $strTraceId;
					$arrInsertFlightData[$key]['arrCommonInsVariables'] = $arrCommonInsVariables;
				}
			}
		} catch (Zend_Exception $e) {
			print_r($e->getMessage());
			exit;
		}
		// echo '<pre>';
		// print_r(($arrInsertFlightData));
		// echo '</pre>';die('ss');
		return $arrInsertFlightData;
		//echo '<pre>';print_r($arrInsertFlightData[0]);die;
	}
	public function loadAddOnsAction()
	{
		$getData = $this->getRequest()->getParams();

		$FlightBookingData = json_decode($getData['intOutBoundId'], true);
		$flightSSRDetails = json_decode($getData['SSRArr'], true);
		$TotalTravellers = json_decode($getData['TotalTravellers'], true);
		$Response = $flightSSRDetails;

		$SSRArr = $Response;
		$html = new Zend_View();
		$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
		$html->assign(array('CustomerSession' => $TotalTravellers, 'SSRArr' => $SSRArr, 'SSRArrInb' => [], 'flightSSRDetails' => $flightSSRDetails, 'FlightBookingData' => $FlightBookingData, 'FlightBookingDataInbound' => []));
		$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 getseatpageAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$getData = $this->getRequest()->getParams();
			// echo '<pre>';
			// print_r($getData);
			// die('d');
			$FlightBookingData = json_decode($getData['intOutBoundId'], true);
			$html = new Zend_View();
			$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
			$html->assign(array('FlightBookingData' => $FlightBookingData, 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
			$bodyText = $html->render('getseatpage.phtml');
			$response = array('success' => true, 'message' => 'Done', 'html' => $bodyText);
			echo json_encode($response);
			exit;
		} else {
			die('Page not found!');
		}
		//
	}
	public function seatmapAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$getData = $this->getRequest()->getParams();

			$segmentid = $getData['segmentid'];
			$FlightBookingData = json_decode($getData['intOutBoundId'], true);
			$CustomerSession = json_decode($getData['TotalTravellers'], true);
			$selectedSeatSession = json_decode($getData['selectedSeatSession'], true);
			$FlightSeatSession = json_decode($getData['FlightSeatSession'], true);
			// echo '<pre>';print_r($FlightSeatSession);
			// echo '<pre>';print_r($getData);
			// die;
			$bookingId = $FlightBookingData[0]['bookingId'];
			$data = ['bookingId' => $bookingId];
			if (!empty($FlightSeatSession)) {
				$apiResponse = $FlightSeatSession;
			} else {
				$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetSeatMapFlightsTripJack($data);
			}

			// $str = file_get_contents($this->baseUrl . '/public/logs/flight/FlightSeat/Seat_response.json');
			// $apiResponse = json_decode($str, true);
			$SegmentsArr = [];
			if ($FlightBookingData) {
				foreach ($FlightBookingData as $Datass) {
					if ($Datass['Segments']) {
						foreach ($Datass['Segments'] as $keys => $value) {
							$SegmentsArr[$value['segmentid']] = $value;
						}
					}
				}
			}
			//echo '<pre>';print_r($apiResponse);die;
			$this->view->apiResponse = $apiResponse;
			$this->view->segmentid = $segmentid;
			$this->view->SegmentsArr = $SegmentsArr;
			$this->view->baseUrl = $this->baseUrl;
			$this->view->CustomerSession = $CustomerSession;
			$this->view->selectedSeatSession = $selectedSeatSession;
			$this->view->CurrencyTitle = $this->CurrencyTitle;
			$html = new Zend_View();
			$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
			$html->assign(array(
				'apiResponse' => $apiResponse, 'segmentid' => $segmentid, 'SegmentsArr' => $SegmentsArr, 'baseUrl' => $this->baseUrl,
				'CustomerSession' => $CustomerSession, 'selectedSeatSession' => $selectedSeatSession, 'CurrencyTitle' => $this->CurrencyTitle
			));
			$bodyText = $html->render('seatmap.phtml');
			$response = array('success' => true, 'message' => 'Done', 'html' => $bodyText, 'apiResponse' => json_encode($apiResponse));
			echo json_encode($response);
			exit;
		} else {
			die('Page not found!');
		}
	}

	public function updatefareAction()
	{
		$getData = $this->getRequest()->getParams();
		$FlightBookingData = json_decode($getData['intOutBoundId'], true);
		$CustomerSession = json_decode($getData['TotalTravellers'], true);
		$SSRArr = json_decode($getData['SSRArr'], true);
		$SelectedMeal = json_decode($getData['SelectedMeal'], true);
		$SelectedBagg = json_decode($getData['SelectedBagg'], true);
		$SelectedSeat = json_decode($getData['SelectedSeat'], true);
		$sessionFlightSearchParams = json_decode($getData['sessionFlightSearchParams'], true);
		if (!empty($SelectedMeal)) {
			$SelectedMealSessionNew = $SelectedMeal;
		} else {
			$SelectedMealSessionNew = [];
		}
		if (!empty($SelectedBagg)) {
			$SelectedBaggSessionNew = $SelectedBagg;
		} else {
			$SelectedBaggSessionNew = [];
		}
		// echo '<pre>';
		// print_r($SelectedMealSessionNew);
		// print_r($SelectedBaggSessionNew);
		$BaggageArr = [];
		$MealArr = [];
		if ($SSRArr['Baggage']) {
			foreach ($SSRArr['Baggage'] as $Datass) {
				if ($Datass) {
					foreach ($Datass as $keys => $value) {
						$BaggageArr[$value['key']][] = $value;
					}
				}
			}
		}
		if ($SSRArr['Meal']) {
			foreach ($SSRArr['Meal'] as $Datass) {
				if ($Datass) {
					foreach ($Datass as $keys => $value) {
						$MealArr[$value['key']][] = $value;
					}
				}
			}
		}

		$CustomerSysId = $getData['CustomerSysId'];
		$segmentid = $getData['segmentid'];
		$index = $getData['index'];


		if ($getData['actiontype'] == 'meal') {
			$getData['data'] = $MealArr[$segmentid][$index];
			if (!empty($SelectedMealSessionNew[$segmentid])) {
				foreach ($SelectedMealSessionNew[$segmentid] as $CustomerId => $val) {
					if ($CustomerId == $CustomerSysId) {
						$SelectedMealSessionNew[$segmentid][$CustomerId] = $getData['data'];
					} else {
						$NewArray = true;
						$SelectedMealSessionNew[$segmentid][$CustomerId] = $val;
					}
				}
			} else {
				$SelectedMealSessionNew[$segmentid][$CustomerSysId] = $getData['data'];
			}
			if ($NewArray) {
				$SelectedMealSessionNew[$segmentid][$CustomerSysId] = $getData['data'];
			}
		} else {
			$getData['data'] = $BaggageArr[$segmentid][$index];
			if (!empty($SelectedBaggSessionNew[$segmentid])) {
				foreach ($SelectedBaggSessionNew[$segmentid] as $CustomerId => $val) {
					if ($CustomerId == $CustomerSysId) {
						$SelectedBaggSessionNew[$segmentid][$CustomerId] = $getData['data'];
					} else {
						$NewArray = true;
						$SelectedBaggSessionNew[$segmentid][$CustomerId] = $val;
					}
				}
			} else {
				$SelectedBaggSessionNew[$segmentid][$CustomerSysId] = $getData['data'];
			}
			if ($NewArray) {
				$SelectedBaggSessionNew[$segmentid][$CustomerSysId] = $getData['data'];
			}
		}
		// if ($index == '' && $getData['actiontype'] == 'meal') {
		// 	unset($SelectedMealSessionNew[$segmentid][$CustomerSysId]);
		// }
		// if ($index == '' && $getData['actiontype'] == 'baggage') {
		// 	unset($SelectedBaggSessionNew[$segmentid][$CustomerSysId]);
		// }
		// echo '<pre>';
		// print_r($SelectedMealSessionNew);
		// print_r($SelectedBaggSessionNew);
		// echo '</pre>';
		$BaggFare = 0;
		$MealFare = 0;
		if ($SelectedBaggSessionNew) {
			foreach ($SelectedBaggSessionNew as $values) {
				foreach ($values as $val) {
					$BaggFare += $val['Price'];
				}
			}
		}
		if ($SelectedMealSessionNew) {
			foreach ($SelectedMealSessionNew as $values) {
				foreach ($values as $val) {
					$MealFare += $val['Price'];
				}
			}
		}
		$intNetPublishedFare = 0;
		if ($FlightBookingData) {
			foreach ($FlightBookingData as $value) {
				$intNetPublishedFare += $value['FairRules']['PublishedFare'];
			}
		}
		$apiResponse = ($FlightBookingData);
		$Data = $apiResponse;
		$MobilePublishedFare = ($intNetPublishedFare + $MealFare + $BaggFare);

		$html = new Zend_View();
		$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
		$html->assign(array('Data' => $FlightBookingData, 'baseUrl' => $this->baseUrl, 'sessionFlightSearchParams' => $sessionFlightSearchParams, 'actiontype' => $getData['actiontype'], 'selectedSeatSession' => $SelectedSeat, 'SelectedMealSessionNew' => $SelectedMealSessionNew, 'SelectedBaggSessionNew' => $SelectedBaggSessionNew, 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
		$bodyText = $html->render('faresummaryright.phtml');
		$response = array('success' => true, 'message' => 'Done', 'MobilePublishedFare' => $MobilePublishedFare, 'SelectedMealSessionNew' => json_encode($SelectedMealSessionNew), 'SelectedBaggSessionNew' => json_encode($SelectedBaggSessionNew), 'html' => $bodyText);
		echo json_encode($response);
		exit;
	}
	public function continuewithseatmapAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$getData = $this->getRequest()->getParams();

			$FlightBookingData = json_decode($getData['intOutBoundId'], true);
			$CustomerSession = json_decode($getData['TotalTravellers'], true);
			$SelectedMeal = json_decode($getData['SelectedMeal'], true);
			$SelectedBagg = json_decode($getData['SelectedBagg'], true);
			$apiResponseSeat = json_decode($getData['apiResponseSeat'], true);
			$SelectedSeat = json_decode($getData['SelectedSeat'], true);
			if (isset($getData['sessionFlightSearchParams'])) {
				$sessionFlightSearchParams = json_decode($getData['sessionFlightSearchParams'], true);
			}
			//Zend_Session::namespaceUnset('selectedSeatSession');die;
			$segmentid = $getData['segmentid'];
			$seatArray = $getData['seatArray'];
			$paxTypeArr = $getData['paxTypeArr'];
			$CustomerSysIdArray = $getData['CustomerSysIdArray'];

			$SelectedMealSessionNew = $SelectedMeal;
			$SelectedBaggSessionNew = $SelectedBagg;


			if (!empty($SelectedSeat)) {
				$selectedSeatSession = $SelectedSeat;
			} else {
				$selectedSeatSession = [];
			}


			$bookingId = $FlightBookingData[0]['bookingId'];
			$data = ['bookingId' => $bookingId];
			$tripSeat = $apiResponseSeat['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];
					$checkSeat = str_replace(' ', '', $seatNo);
					if (trim($checkSeat) != 'NA' && !empty($checkSeat)) {
						$SelectedSegment[] = $paxType . ':' . $seatNo;
					} else {
						$SelectedSegment[] = '';
					}

					foreach ($sInfo as $k => $val) {
						if ($val['seatNo'] == $seatNo) {
							$selectedSeat[$segmentid][$CustomerSysId] = $val;
						}
					}
				}
			}
			if (count(array_filter($SelectedSegment)) == count($SelectedSegment)) {
				$SelectedSegmentst = implode(', ', $SelectedSegment);
			} else {
				$SelectedSegmentst = '----';
			}
			//echo '<pre>';print_r($SelectedSegmentst);die;
			//echo '<pre>';print_r(implode(', ',$SelectedSegment));

			if (!empty($selectedSeatSession)) {
				foreach ($selectedSeatSession 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[$segmentid][$CustomerId] = $val;
							} else {
								$selectedSeatSession[$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[$segmentid][$CustomerSysId] = $val;
									}
								}
							}
						}
					}
				}
			} else {
				$selectedSeatSession = $selectedSeat;
			}
			//echo '<pre>';print_r($selectedSeatSession);die;
			$BagPrice = 0;
			$InbBagPrice = 0;
			$MealPrice = 0;
			$InbMealPrice = 0;
			$SeatPrice = 0;
			if ($SelectedBaggSessionNew) {
				foreach ($SelectedBaggSessionNew as $val) {
					$BagPrice += $val['Price'];
				}
			}
			if ($SelectedMealSessionNew) {
				foreach ($SelectedMealSessionNew as $val) {
					$MealPrice += $val['Price'];
				}
			}


			if ($selectedSeatSession) {
				foreach ($selectedSeatSession as $values) {
					foreach ($values as $val) {
						$SeatPrice += $val['amount'];
					}
				}
			}
			$MealFare = ($MealPrice + $InbMealPrice);
			$BaggFare = ($BagPrice + $InbBagPrice);
			$intNetPublishedFare = 0;
			if ($FlightBookingData) {
				foreach ($FlightBookingData as $value) {
					$intNetPublishedFare += $value['FairRules']['PublishedFare'];
				}
			}
			//echo '<pre>';print_r($SelectedMealSessionNewInb);
			//echo '<pre>';print_r($SelectedBaggSessionNewInb);

			$MobilePublishedFare = ($intNetPublishedFare + $MealFare + $BaggFare + $SeatPrice);

			$html = new Zend_View();
			$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
			$html->assign(array('Data' => $FlightBookingData, 'baseUrl' => $this->baseUrl, 'CurrencyTitle' => $this->CurrencyTitle, 'sessionFlightSearchParams' => $sessionFlightSearchParams, 'selectedSeatSession' => $selectedSeatSession, 'SelectedMealSessionNew' => $SelectedMealSessionNew, 'SelectedBaggSessionNew' => $SelectedBaggSessionNew, 'CurrencyRate' => $this->CurrencyRate));
			$bodyText = $html->render('faresummaryright.phtml');
			$response = array('success' => true, 'message' => 'Done', 'SelectedSegment' => $SelectedSegmentst, 'selectedSeatSession' => json_encode($selectedSeatSession), 'MobilePublishedFare' => $MobilePublishedFare, 'html' => $bodyText);
			echo json_encode($response);
			exit;
		} else {
			die('Page not found!');
		}
	}
	public function genrateFlightQuery($post)
	{
		$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
		$class = $sessionFlightSearchParams->params['class'];
		$interNationalSearch = $sessionFlightSearchParams->params['interNationalSearch'];
		$route = $sessionFlightSearchParams->params['route'];
		$departureDates = $sessionFlightSearchParams->params['departure_date'][0];
		$returnDate = $sessionFlightSearchParams->params['return_date'][0];
		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;
		// }
		$Segments_c = current($FlightBookingData->params);
		$Segments_E = end($FlightBookingData->params);
		$arrCurrentSegments1 = current($Segments_c['Segments']);
		$arrEndSegments1 = end($Segments_c['Segments']);
		//echo '<pre>';print_r($Segments_c['Segments']);die;
		$Mobile = $post['leadMobile'];
		$emailId = $post['leadEmail'];
		$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'][0]) ? $sessionFlightSearchParams->params['sourceCityId'][0] : '';
		$DestinationPlacesSysId = isset($sessionFlightSearchParams->params['destinationCityId'][0]) ? $sessionFlightSearchParams->params['destinationCityId'][0] : '';

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

		$departuredate = str_replace('T', ' ', $arrCurrentSegments1['originDepTime']);
		$arrivaldate = str_replace('T', ' ', $arrEndSegments1['destinationArrTime']);
		$FlightNumber = $FlightBookingData->params['FlightNumber'];
		//$PublishedFare = $FlightBookingData->params['PublishedFare'];
		$oneway_origin_text = isset($arrCurrentSegments1['originCityName']) ? $arrCurrentSegments1['originCityName'] : '';
		$oneway_destination_text = isset($arrEndSegments1['destinationCityName']) ? $arrEndSegments1['destinationCityName'] : '';
		$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));

		//echo '<pre>';print_r($BookingData);die;
		if ($BookingData) {
			foreach ($BookingData as $k => $booking) {
				$finalFareSummary = $booking['FairRules'];
				$PublishedFare += $booking['FairRules']['PublishedFare'];
				$PublishedFareINT = $booking['FairRules']['PublishedFare'];
				// $finalFareSummary = $this->getfinalFareSummary($booking);
				$AgentCommisionEarned += ($finalFareSummary['CommEarned'] + $finalFareSummary['PLBEarned']);
				$AgentCommisionEarnedINT = ($finalFareSummary['CommEarned'] + $finalFareSummary['PLBEarned']);
				$AgentCommisionEarnedGST += ($finalFareSummary['GSTonComm'] + isset($finalFareSummary['GSTonPLB']) ? $finalFareSummary['GSTonPLB'] : 0);
				$AgentCommisionEarnedGSTINT = ($finalFareSummary['GSTonComm'] + isset($finalFareSummary['GSTonPLB']) ? $finalFareSummary['GSTonPLB'] : 0);
				$AgencyMarkUp += $finalFareSummary['FixedMarkUp'];
				$AgencyMarkUpINT = $finalFareSummary['FixedMarkUp'];
				$AgencyMarkUpGST += $finalFareSummary['GSTOnMarkUp'];
				$AgencyMarkUpGSTINT = $finalFareSummary['GSTOnMarkUp'];
				$GTXMarkUp += $finalFareSummary['intGTXMarkUp'];
				$GTXMarkUpINT = $finalFareSummary['intGTXMarkUp'];
				$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]['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]['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]['airclass'] = $class;
		// }
		$RoomInfoJson = json_encode($roomjson);
		//echo '<pre>';print_r($roomjson);die;
		$totalPassengers = $adultCount + $childCount + $infantCount;
		$arrPax = [];
		$passengerAddress = isset($post['passenger-address-1']) ? $post['passenger-address-1'] : '';
		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];
			$arrPax[] = [
				"PassengerType" => $paxType,
				"salutation" => $salutation,
				"fname" => $firstName,
				"lname" => $lastName,
				"dob" => $dateofbirth,
				"address" => $passengerAddress,
			];
		}

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

		$sabirArray = array(
			'AgencySysId' => $this->MasterAgencySysId,
			'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' => $OriginCity . '-' . $Destcity,
			'IsHotelFromApi' => 1,
			'ICSourceSysId' => 7,
			'roominfojson' => $RoomInfoJson,
			'AgentCommisionEarned' => $AgentCommisionEarned,
			'AgentCommisionEarnedGST' => $AgentCommisionEarnedGST,
			'AgencyMarkUp' => $AgencyMarkUp,
			'AgencyMarkUpGST' => $AgencyMarkUpGST,
			'GTXMarkUp' => $GTXMarkUp,
			'GTXMarkUpGST' => $GTXMarkUpGST,
			'BaseAmount' => $BaseAmount,
			'PublishedFare' => $PublishedFare,
		);
		//echo '<pre>';print_r($sabirArray);die;
		$model = new Gtxwebservices_Model_Webservices();
		$result = $model->genrateFlightQuery($sabirArray);
		$response = json_decode($result, true);
		//echo '<pre>';print_r($response);die;
		Zend_Session::namespaceUnset('ResponseFlightQuery');
		$ResponseFlightQuery = new Zend_Session_Namespace('ResponseFlightQuery');
		$ResponseFlightQuery->params = $response;

		return $response;
	}
	public function savePassengerDetailsTripjackAction()
	{
		if ($this->_request->isXmlHttpRequest()) {
			try {
				$this->_helper->layout->disableLayout();
				$this->_helper->viewRenderer->setNoRender(true);
				$post = $this->getRequest()->getParams();
				$sessionFlightSearchParams = json_decode($this->getRequest()->getParam('sessionFlightSearchParams'), true);
				$route = isset($sessionFlightSearchParams['route']) ? $sessionFlightSearchParams['route'] : '';
				$interNationalSearch = isset($sessionFlightSearchParams['interNationalSearch']) ? $sessionFlightSearchParams['interNationalSearch'] : '';
				$isgstapply = (trim($this->getRequest()->getParam('isgstapply'))) ? trim($this->getRequest()->getParam('isgstapply')) : 0;
				$gstnnumber = (trim($this->getRequest()->getParam('gstnnumber'))) ? trim($this->getRequest()->getParam('gstnnumber')) : '';
				$companyname = (trim($this->getRequest()->getParam('companyname'))) ? trim($this->getRequest()->getParam('companyname')) : '';
				$gstemail = (trim($this->getRequest()->getParam('gstemail'))) ? trim($this->getRequest()->getParam('gstemail')) : '';
				$gstphone = (trim($this->getRequest()->getParam('gstphone'))) ? trim($this->getRequest()->getParam('gstphone')) : '';
				$gstaddress = (trim($this->getRequest()->getParam('gstaddress'))) ? trim($this->getRequest()->getParam('gstaddress')) : '';
				$gststate = (trim($this->getRequest()->getParam('gststate'))) ? trim($this->getRequest()->getParam('gststate')) : '';
				$intOutBoundId = !empty($this->getRequest()->getParam('intOutBoundId')) ? json_decode($this->getRequest()->getParam('intOutBoundId'), true) : 0;
				$BookingData = $intOutBoundId;
				$SearchTraceId = $BookingData[0]['SearchTraceId'];
				$isAdobrMandatory = $BookingData[0]['isAdobrMandatory'];
				$isCdobrMandatory = $BookingData[0]['isCdobrMandatory'];
				$isIdobrMandatory = $BookingData[0]['isIdobrMandatory'];
				$SelectedBaggSessionNew = json_decode($post['SelectedBaggSessionNew'], true);
				$SelectedMealSessionNew = json_decode($post['SelectedMealSessionNew'], true);
				$selectedSeatSession = json_decode($post['selectedSeatSession'], true);
				$countryCode = isset($post['countryCode']) ? $post['countryCode'] : '';
				$countryCodeISO = isset($post['countryCodeISO']) ? $post['countryCodeISO'] : '';

				$adultCount   = isset($sessionFlightSearchParams['adults']) ? $sessionFlightSearchParams['adults'] : 0;
				$childCount   = isset($sessionFlightSearchParams['child']) ? $sessionFlightSearchParams['child'] : 0;
				$infantCount   = isset($sessionFlightSearchParams['infant']) ? $sessionFlightSearchParams['infant'] : 0;

				$totalPassengers = $adultCount + $childCount + $infantCount;
				// echo '<pre>';
				// print_r($BookingData);
				// die;
				// echo '<pre>';
				// $dffdfdfdf = $this->genrateFlightQuery($post);
				// echo '<pre>';
				// print_r($BookingData);
				// die;
				$departure_dates_string = $sessionFlightSearchParams['departure_dates'][0];
				$explode_date = explode("/", $departure_dates_string);
				$departure_dates = $explode_date[2] . '-' . $explode_date[1] . '-' . $explode_date[0];

				$return_dates_string = $sessionFlightSearchParams['return_dates'][0];
				$explode_return_date = explode("/", $return_dates_string);
				$return_dates =  (isset($sessionFlightSearchParams['return_dates'][0]) && !empty($sessionFlightSearchParams['return_dates'][0])) ? $explode_return_date[2] . '-' . $explode_return_date[1] . '-' . $explode_return_date[0] : '1900-01-01';

				$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];
				$flight_class = $sessionFlightSearchParams['flight_class'];

				$roomjson = array();
				$roomjson[1]['Adult']  = $adultCount;
				$roomjson[1]['Child']  = $childCount;
				$roomjson[1]['bedtype'] = '';
				$roomjson[1]['departuredate'] = $departure_dates_string;
				$roomjson[1]['returndate'] = $return_dates_string;
				$roomjson[1]['fromaircode'] = $oneway_origin_text;
				$roomjson[1]['toaircode'] = $oneway_destination_text;
				$roomjson[1]['airclass'] = $flight_class;
				for ($c = 1; $c <= $childCount; $c++) {
					$childsage = $infantCount;
					$roomjson[$c]['Adult']  = $adultCount;
					$roomjson[$c]['Child']  = $childCount;
					$roomjson[$c]['ChildAge_' . $c]  = $childsage;
					$roomjson[$c]['bedtype'] = '';
					$roomjson[$c]['departuredate'] = $departure_dates_string;
					$roomjson[$c]['returndate'] = $return_dates_string;
					$roomjson[$c]['fromaircode'] = $oneway_origin_text;
					$roomjson[$c]['toaircode'] = $oneway_destination_text;
					$roomjson[$c]['airclass'] = $flight_class;
				}
				$RoomInfoJson = json_encode($roomjson);

				if (empty($adultCount)) {
					throw new Exception("Adult count not found.");
				}
				$ForCustomerSession = array();
				$arrCustomerMembers = array();
				$objFlight = new Travel_Model_FlightMaster();
				$param = array(
					'leadMobile' => $post['leadMobile'],
					'leadEmail' => $post['leadEmail'],
				);

				$this->objMdl->rv_delete('tbl_customer', array('apiTraceId = ?' => $post['FlightTraceId']));
				$this->objMdl->rv_delete('tbl_customer_member', array('apiTraceId = ?' => $post['FlightTraceId']));

				$tbl_customer = $objFlight->SearchFlightCustomer('tbl_customer', $param);
				$key = 0;
				for ($i = 1; $i <= $totalPassengers; $i++) {

					$paxType      = $post['paxType-' . $i];
					$firstName    = $post['passenger-firstname-' . $i];
					$lastName     = $post['passenger-lastname-' . $i];
					$salutation   = $post['passenger-salutation-' . $i];
					$relation   = $post['relation-' . $i];
					$mobileNumber = $post['leadMobile'];
					$email_id     = $post['leadEmail'];
					$passengerDob       = !empty($post['passenger-dob-' . $i]) ? $post['passenger-dob-' . $i] : '01/01/1900';
					$nationality       = isset($post['passenger-nationality-' . $i]) ? $post['passenger-nationality-' . $i] : '';
					$passengerPassportNo       = isset($post['passenger-PassportNo-' . $i]) ? $post['passenger-PassportNo-' . $i] : '';
					$passengerPassportExpiry       = isset($post['passenger-PassportExpiry-' . $i]) ? $post['passenger-PassportExpiry-' . $i] : '01/01/1900';
					$passporIssue       = isset($post['passenger-passporIssue-' . $i]) ? $post['passenger-passporIssue-' . $i] : '01/01/1900';

					if (!empty($passengerDob)) {
						$passengerDob       = explode("/", $passengerDob);
						$passengerDob       = $passengerDob[2] . "-" . $passengerDob[1] . "-" . $passengerDob[0];
					}
					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($mobileNumber)) {
						$response = array('succes' => false, 'msg' => 'Please enter lead pax mobile number.', 'index' => 'leadMobile');
						echo json_encode($response);
						exit;
					}

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

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

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

					if (empty($lastName)) {
						$response = array('succes' => false, 'msg' => 'Please enter last name.', 'index' => 'passenger-lastname-' . $i);
						echo json_encode($response);
						exit;
					}
					if ($paxType == 1 && $isAdobrMandatory) {
						if (empty($passengerDob) && $passengerDob == '1900-01-01') {
							$response = array('succes' => false, 'msg' => 'Please enter adult date of birth.', 'index' => 'passenger-dob-' . $i);
							echo json_encode($response);
							exit;
						}
						$departureDates = $sessionFlightSearchParams['departure_dates'][0];
						if (!empty($departureDates)) {
							$arrDepartureDates = explode("/", $departureDates);
							$departureDatesAD = $arrDepartureDates[2] . "-" . $arrDepartureDates[1] . "-" . $arrDepartureDates[0];
							$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' => 'passenger-dob-' . $i);
								echo json_encode($response);
								exit;
							}
						} else {
							$response = array('succes' => false, 'msg' => "Departure date can not be empty.", 'index' => 'mobile_number');
							echo json_encode($response);
							exit;
						}
					}
					if (!empty($paxType) && $paxType == 2 && $isCdobrMandatory) {
						if (empty($passengerDob) && $passengerDob == '1900-01-01') {
							$response = array('succes' => false, 'msg' => 'Please enter child date of birth.', 'index' => 'passenger-dob-' . $i);
							echo json_encode($response);
							exit;
						}
						$departureDates = $sessionFlightSearchParams['departure_dates'][0];
						if (!empty($departureDates)) {
							$arrDepartureDates       = explode("/", $departureDates);
							$departureDates       = $arrDepartureDates[2] . "-" . $arrDepartureDates[1] . "-" . $arrDepartureDates[0];
							$childAge =  date_diff(date_create($passengerDob), date_create($departureDates))->y;
							if ($childAge < 2 || $childAge >= 12) {
								$response = array('succes' => false, 'msg' => "Child age should be 2 years or less than 12 years. ", 'index' => 'passenger-dob-' . $i);
								echo json_encode($response);
								exit;
							}
						} else {
							$response = array('succes' => false, 'msg' => "Departure date can not be empty.", 'index' => 'mobile_number');
							echo json_encode($response);
							exit;
						}
					}

					if (!empty($paxType) && $paxType == 3 && $isIdobrMandatory) {
						if (empty($passengerDob) && $passengerDob == '1900-01-01') {
							$response = array('succes' => false, 'msg' => 'Please enter infant date of birth.', 'index' => 'passenger-dob-' . $i);
							echo json_encode($response);
							exit;
						}
						$departureDates = $sessionFlightSearchParams['departure_dates'][0];
						if (!empty($departureDates)) {
							$arrDepartureDates       = explode("/", $departureDates);
							$departureDates       = $arrDepartureDates[2] . "-" . $arrDepartureDates[1] . "-" . $arrDepartureDates[0];
							$infantAge =  date_diff(date_create($passengerDob), date_create($departureDates))->y;
							if ($infantAge >= 2) {
								$response = array('succes' => false, 'msg' => "Infant age should be less than 2 years. ", 'index' => 'passenger-dob-' . $i);
								echo json_encode($response);
								exit;
							}
						} else {
							$response = array('succes' => false, 'msg' => "Departure date can not be empty.", 'index' => 'mobile_number');
							echo json_encode($response);
							exit;
						}
					}

					if ($interNationalSearch == 1) {
						if (isset($post['passenger-nationality-' . $i]) && empty($nationality)) {
							$response = array('succes' => false, 'msg' => 'Please select Nationality.', 'index' => 'passenger-nationality-' . $i);
							echo json_encode($response);
							exit;
						}
						if (isset($post['passenger-PassportNo-' . $i]) && empty($passengerPassportNo)) {
							$response = array('succes' => false, 'msg' => 'Please enter passenger passport no.', 'index' => 'passenger-PassportNo-' . $i);
							echo json_encode($response);
							exit;
						}
						if (isset($post['passenger-passporIssue-' . $i]) && empty($passporIssue)) {
							$response = array('succes' => false, 'msg' => 'Please enter passport issue date.', 'index' => 'passenger-passporIssue-' . $i);
							echo json_encode($response);
							exit;
						}
						if (isset($post['passenger-PassportExpiry-' . $i]) && empty($passengerPassportExpiry)) {
							$response = array('succes' => false, 'msg' => 'Please enter passport expiry date.', 'index' => 'passenger-PassportExpiry-' . $i);
							echo json_encode($response);
							exit;
						}
						if (isset($post['passenger-PassportExpiry-' . $i]) && strtotime($departure_dates) > strtotime($passengerPassportExpiry)) {
							$response = array('succes' => false, 'msg' => 'Please enter passport valid expiry date.', 'index' => 'passenger-PassportExpiry-' . $i);
							echo json_encode($response);
							exit;
						}
					}
					$IsExistcustomer = '';
					$CustomerSysIdPost = $post['CustomerSysId-' . $i];
					if (!empty($CustomerSysIdPost) && $CustomerSysIdPost != '0') {
						$IsExistcustomer = $objFlight->CheckCustomer('tbl_customer', array('CustomerSysId' => $CustomerSysIdPost));
					}
					$add_travellerslist = 1;
					if ($i == 1 && $relation == 0) {
						$apiData = array(
							"AgencySysId" => $this->gtxagencysysid,
							"Salutation" => $salutation,
							"EmailId" => $post['leadEmail'],
							"FirstName" => $firstName,
							"LastName" => $lastName,
							"CountryCode" => $countryCode,
							"MobileNo" => $post['leadMobile'],
						);
						$model = new Gtxwebservices_Model_Webservices();
						$result = $model->CreateCustomer($apiData);
						$apiCustomer = json_decode($result, true);
						$arrCustomer = $ForCustomerSession[$key] = array(
							'AgencySysId' => $this->gtxagencysysid,
							'MasterAgencySysId' => $this->MasterAgencySysId,
							'EmailId' => $email_id,
							'Salutation' => $salutation,
							'Relation' => $relation,
							'Contacts' => $mobileNumber,
							'FirstName' => $firstName,
							'LastName' => $lastName,
							'Password' => '',
							'IsPswExpire' => 0,
							'CreatedByUserSysId' => $this->gtxagencysysid,
							//'DOB' => $passengerDob,
							'Address' => '',
							'CityTitle' => '',
							'CitySysId' => 0,
							'paxType' => $paxType,
							'StateOrZoneSysId' => 0,
							'CountrySysId' => 0,
							'countryCode' => $countryCode,
							'RegisterDate' => Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss'),
							'IsApproved' => 0,
							'IsActive' => 1,
							'IsMarkForDel' => '0',
						);
						if ($apiCustomer['status'] == 1) {
							$arrCustomer['GTX_customerSysId'] = $apiCustomer['Message'];
						}
						if ($isAdobrMandatory && $paxType == 1) {
							$arrCustomer['DOB'] = $ForCustomerSession[$key]['DOB'] = $passengerDob;
						}
						if ($isCdobrMandatory && $paxType == 2) {
							$arrCustomer['DOB'] = $ForCustomerSession[$key]['DOB'] = $passengerDob;
						}
						if ($isIdobrMandatory && $paxType == 3) {
							$arrCustomer['DOB'] = $ForCustomerSession[$key]['DOB'] = $passengerDob;
						}
						if ($isgstapply == 1) {
							$arrCustomer['companyname'] = $ForCustomerSession[$key]['companyname'] = $companyname;
							$arrCustomer['gstnnumber'] = $ForCustomerSession[$key]['gstnnumber'] = $gstnnumber;
							$arrCustomer['gstaddress'] = $ForCustomerSession[$key]['gstaddress'] = $gstaddress;
							$arrCustomer['gstemail'] = $ForCustomerSession[$key]['gstemail'] = $gstemail;
							$arrCustomer['gststate'] = $ForCustomerSession[$key]['gststate'] = $gststate;
							$arrCustomer['gstphone'] = $ForCustomerSession[$key]['gstphone'] = $gstphone;
						}
						if ($interNationalSearch == 1) {
							$arrCustomer['PassportNation'] = $ForCustomerSession[$key]['PassportNationality'] = ($interNationalSearch == 1) ? $nationality : '';
							$arrCustomer['PassportNo'] = $ForCustomerSession[$key]['PassportNo'] = ($interNationalSearch == 1) ? $passengerPassportNo : '';
							$arrCustomer['PassportExpiry'] = $ForCustomerSession[$key]['PassportExpiry'] = ($interNationalSearch == 1) ? $passengerPassportExpiry : '';
							$arrCustomer['passporIssue'] = $ForCustomerSession[$key]['passporIssue'] = ($interNationalSearch == 1) ? $passporIssue : '';
						}
						if (!empty($IsExistcustomer)) {
							$arrCustomer['modified'] = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
							$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 (empty($tbl_customer)) {

							$arrCustomer['apiTraceId'] = $post['FlightTraceId'];
							$arrCustomer['modified'] = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
							$arrCustomer['created'] = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');

							$CustomerSysId = $objFlight->InsertFlightData('tbl_customer', $arrCustomer);
						} else {
							$arrCustomer['CustomerSysId'] = $tbl_customer[0]['CustomerSysId'];
							$arrCustomer['apiTraceId'] = $post['FlightTraceId'];
							$arrCustomer['modified'] = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
							$arrCustomer['created'] = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
							$CustomerSysId = $Isadultmem = $objFlight->InsertFlightData('tbl_customer_member', $arrCustomer);
						}

						$arrmembersId[] = $CustomerSysId;

						$ForCustomerSession[$key]['CustomerSysId'] = $CustomerSysId;
						$CustomerSysIdSession = new Zend_Session_Namespace('CustomerSysIdSession');
						$CustomerSysIdSession->params = $CustomerSysId;
						$arrCustomer['CustomerSysId'] = $CustomerSysId;
					} 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,
							'MasterAgencySysId' => $this->MasterAgencySysId,
							'CustomerSysId' => (!empty($CustomerSysId) && $Isadultmem == 0) ? $CustomerSysId : @$tbl_customer[0]['CustomerSysId'],
							'EmailId' => $email_id,
							'Salutation' => $salutation,
							'Relation' => $relation,
							'Contacts' => $mobileNumber,
							'FirstName' => $firstName,
							'LastName' => $lastName,
							'Password' => '',
							'IsPswExpire' => 0,
							'CreatedByUserSysId' => $this->gtxagencysysid,
							//'DOB' => $passengerDob,
							'Address' => '',
							'CityTitle' => '',
							'CitySysId' => 0,
							'paxType' => $paxType,
							'StateOrZoneSysId' => 0,
							'CountrySysId' => 0,
							'countryCode' => $countryCode,
							'RegisterDate' => Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss'),
							'IsApproved' => 0,
							'IsActive' => 1,
							'IsMarkForDel' => '0',
						);
						if ($isAdobrMandatory && $paxType == 1) {
							$arrCustomerMembers['DOB'] = $ForCustomerSession[$key]['DOB'] = $passengerDob;
						}
						if ($isCdobrMandatory && $paxType == 2) {
							$arrCustomerMembers['DOB'] = $ForCustomerSession[$key]['DOB'] = $passengerDob;
						}
						if ($isIdobrMandatory && $paxType == 3) {
							$arrCustomerMembers['DOB'] = $ForCustomerSession[$key]['DOB'] = $passengerDob;
						}
						if ($isgstapply == 1) {
							$arrCustomerMembers['companyname'] = $ForCustomerSession[$key]['companyname'] = $companyname;
							$arrCustomerMembers['gstnnumber'] = $ForCustomerSession[$key]['gstnnumber'] = $gstnnumber;
							$arrCustomerMembers['gstaddress'] = $ForCustomerSession[$key]['gstaddress'] = $gstaddress;
							$arrCustomerMembers['gstemail'] = $ForCustomerSession[$key]['gstemail'] = $gstemail;
							$arrCustomerMembers['gststate'] = $ForCustomerSession[$key]['gststate'] = $gststate;
							$arrCustomerMembers['gstphone'] = $ForCustomerSession[$key]['gstphone'] = $gstphone;
						}
						if ($interNationalSearch == 1) {
							$arrCustomerMembers['PassportNation'] = $ForCustomerSession[$key]['PassportNationality'] = ($interNationalSearch == 1) ? $nationality : '';
							$arrCustomerMembers['PassportNo'] = $ForCustomerSession[$key]['PassportNo'] = ($interNationalSearch == 1) ? $passengerPassportNo : '';
							$arrCustomerMembers['PassportExpiry'] = $ForCustomerSession[$key]['PassportExpiry'] = ($interNationalSearch == 1) ? $passengerPassportExpiry : '';
							$arrCustomerMembers['passporIssue'] = $ForCustomerSession[$key]['passporIssue'] = ($interNationalSearch == 1) ? $passporIssue : '';
						}
						if (!empty($IsExistMember)) {
							$arrCustomerMembers['CustomerSysId'] = $ForCustomerSession[$key]['CustomerSysId'] = $IsExistMember['CustomerSysId'];
							$arrCustomerMembers['modified'] = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
							$where = "CustomerMemberSysId = " . $CustomerSysIdPost; //exit;
							$objFlight->UpdateFlightData('tbl_customer_member', $arrCustomerMembers, $where);
							$CustomerMemberSysId = $CustomerSysIdPost;
							if ($i == 1) {
								$bookCustomerId = $CustomerSysIdPost;
							}
						} elseif ($add_travellerslist == 1) {
							$arrCustomerMembers['apiTraceId'] = $post['FlightTraceId'];
							$arrCustomerMembers['modified'] = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
							$arrCustomerMembers['created'] = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
							$CustomerMemberSysId = $bookCustomerId = $objFlight->InsertFlightData('tbl_customer_member', $arrCustomerMembers);
						} else {
							$CustomerMemberSysId = 0;
						}
						$ForCustomerSession[$key]['CustomerMemberSysId'] = $CustomerMemberSysId;
						$arrCustomerMembers['CustomerMemberSysId'] = $CustomerMemberSysId;
						$CustomerMembersSessionArr[] = $arrCustomerMembers;
						$arrmembersId[] = $CustomerMemberSysId;
					}
					$ForCustomerSession[$key]['isgstapply'] = $isgstapply;
					$ForCustomerSession[$key]['countryCodeISO'] = $countryCodeISO;


					$key++;
				}
				// echo '<pre>';
				// print_r($post);die;
				if ($BookingData && $isgstapply == 0) {
					foreach ($BookingData as $values) {
						if (trim($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 id.', '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.', 'index' => 'gstphone');
						echo json_encode($response);
						exit;
					}
					if (strlen($gstphone) != 10 && strlen($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;
					}
				}

				$this->objMdl->rv_delete('tbl_flight_booking', array('apiTraceId = ?' => $post['FlightTraceId']));
				$this->objMdl->rv_delete('tbl_flight_booking_customer', array('apiTraceId = ?' => $post['FlightTraceId']));
				$flight_booking_customer = [];
				$flight_booking_id_Arr = [];
				if ($BookingData) {
					foreach ($BookingData as $k => $value) {

						$arrPlanAir['AgencySysId'] = $this->gtxagencysysid;
						$arrPlanAir['CustomerSysId'] = !empty($CustomerSysId) ? $CustomerSysId : $bookCustomerId;
						$arrPlanAir['FlightNumber'] = $value['FlightNumber'];
						$arrPlanAir['AirlineName'] = $value['AirlineName'];
						$arrPlanAir['TravelDate'] = $value['TravelDate'];
						$arrPlanAir['IsLCC'] = $value['IsLCC'];
						$arrPlanAir['IsRefundable'] = ($value['IsRefundable']) ? $value['IsRefundable'] : 0;
						$arrPlanAir['apiTraceId'] = $value['SearchTraceId'];
						$arrPlanAir['AirlineSysId'] = $value['AirlineSysId'];
						$arrPlanAir['DepartureTime'] = $value['DepartureTime'];
						$arrPlanAir['ArrivalTime'] = $value['ArrivalTime'];
						$arrPlanAir['IsDirect'] = $value['IsDirect'];
						$arrPlanAir['FareClass'] = $value['FareClass'];
						$arrPlanAir['FlyingMinutes'] = $value['FlyingMinutes'];
						$arrPlanAir['FlightDuration'] = $value['FlightDuration'];
						$arrPlanAir['SourcePlaceSysId'] = $value['SourcePlaceSysId'];
						$arrPlanAir['DestPlaceSysId'] = $value['DestPlaceSysId'];
						$arrPlanAir['SourceAirportCode'] = $value['SourceAirportCode'];
						$arrPlanAir['DestAirportCode'] = $value['DestAirportCode'];
						$arrPlanAir['StopCount'] = $value['StopCount'];
						$arrPlanAir['TotalFlightMembers'] = $value['TotalFlightMembers'];
						$arrPlanAir['CurrencyType'] = $value['CurrencyType'];
						$arrPlanAir['PublishedFare'] = $value['FairRules']['PublishedFare'];
						$arrPlanAir['ApiResultIndex'] = $value['ApiResultIndex'];
						$arrPlanAir['JourneyType'] = $value['JourneyType'];
						$arrPlanAir['TripType'] = $value['TripType'];
						$arrPlanAir['IsInternational'] = ($value['IsInternational']) ? $value['IsInternational'] : 0;
						$arrPlanAir['logo'] = $value['logo'];
						$arrPlanAir['Currency'] = $value['FairRules']['Currency'];
						$arrPlanAir['BaseFare'] = $value['FairRules']['BaseFare'];
						$arrPlanAir['Tax'] = $value['FairRules']['Tax'];
						$arrPlanAir['YQTax'] = $value['FairRules']['YQTax'];
						$arrPlanAir['OtherCharges'] = $value['FairRules']['OtherCharges'];
						$arrPlanAir['Discount'] = $value['FairRules']['Discount'];
						$arrPlanAir['ServiceFee'] = $value['FairRules']['ServiceFee'];
						$arrPlanAir['OfferedFare'] = $value['FairRules']['OfferedFare'];
						$arrPlanAir['AgencyMarkUp'] = $value['FairRules']['FixedMarkUp'];
						$arrPlanAir['AgencyMarkUpGST'] = $value['FairRules']['GSTOnMarkUp'];
						$arrPlanAir['GTXMarkUp'] = $value['FairRules']['intGTXMarkUp'];
						$arrPlanAir['GTXMarkUpGST'] = $value['FairRules']['GTXMarkUpGST'];
						$arrPlanAir['bookingData'] = json_encode($value);
						//$arrPlanAir['SelectedBaggSessionNew'] = json_encode($SelectedBaggSessionNew);
						//$arrPlanAir['SelectedMealSessionNew'] = json_encode($SelectedMealSessionNew);
						//$arrPlanAir['selectedSeatSession'] = json_encode($selectedSeatSession);
						$arrPlanAir['status'] = 0;
						$arrPlanAir['IsMarkForDel'] = 0;
						$arrPlanAir['created_at'] = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
						$arrPlanAir['updated_at'] = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
						//echo '<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);
						}
						$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;
				}
				
				if ($flight_booking_customer && $flight_booking_id_Arr) {
					$genrateFlightQuery = $this->genrateFlightQuery($post);
					$queryStatus = isset($genrateFlightQuery['status']) ? $genrateFlightQuery['status'] : 0;
					$arrData = array(
						'FlightBookingData' => $BookingData,
						'flight_booking_id_Arr' => $flight_booking_id_Arr,
						'ForCustomerSession' => $ForCustomerSession,
						'CustomerMembersSessionArr' => $CustomerMembersSessionArr,
						'CustomerSysId' => $CustomerSysId,
						'CustomerMemSysId' => $arrmembersId,
						'flight_booking_customer' => $flight_booking_customer,
						'SearchTraceId' => $post['FlightTraceId'],
						'sessionFlightSearchParams' => $sessionFlightSearchParams,
						'SelectedBaggSessionNew' => $SelectedBaggSessionNew,
						'SelectedMealSessionNew' => $SelectedMealSessionNew,
						'selectedSeatSession' => $selectedSeatSession,
						'genrateFlightQuery' => $genrateFlightQuery,
					);
	
					$tempData = array(
						'TraceId' => $post['FlightTraceId'],
						'json_data' => json_encode($arrData),
					);
					$objFlight->deleteFlightTempData($SearchTraceId);
					$objFlight->insertFlightTempData($tempData);
					//echo '<pre>';print_r($genrateFlightQuery);echo '</pre>';
					if ($queryStatus == 0) {
						$this->objMdl->rv_delete('tbl_customer', array('apiTraceId = ?' => $post['FlightTraceId']));
						$this->objMdl->rv_delete('tbl_customer_member', array('apiTraceId = ?' => $post['FlightTraceId']));

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

						$response = array('succes' => false, 'msg' => 'This booking is not processed. Please contact to administrator.', 'index' => '');
						echo json_encode($response);
						exit;
					}
					$response = array('success' => true, 'msg' => 'Done', 'apiTraceId' => $post['FlightTraceId']);
					echo json_encode($response);
					exit;
				} else {
					$response = array('success' => false, 'msg' => 'oops somehting went wrong.');
					echo json_encode($response);
					exit;
				}
				print_r($flight_booking_id_Arr);
				print_r($flight_booking_customer);
				die;
				die;
			} catch (Exception $e) {
				echo $e->getMessage();
			}
		}
	}
	public function InsertFlightBookingCustomer($data, $arrmembersId, $arrPlain)
	{
		$objFlight = new Travel_Model_FlightMaster();
		$flight_booking_customer = [];
		$i = 0;
		$FareBreakdownArr = [];
		if ($arrPlain['FairRules']['FareBreakdown']) {
			$ind = 0;
			foreach ($arrPlain['FairRules']['FareBreakdown'] as $FareB) {
				for ($j = 0; $j < $FareB['PassengerCount']; $j++) {
					$ind++;
					$FareBreakdownArr[$ind - 1] = $FareB;
				}
			}
		}

		if ($data) {
			foreach ($data as $k => $value) {
				$baggage = $FareBreakdownArr[$k];
				//$baggage = $arrPlain['FairRules']['FareBreakdown'][$k];
				$arrCustomerMembers = array(
					'AgencySysId' => $this->gtxagencysysid,
					'CustomerSysId' => $arrmembersId[$i],
					'apiTraceId' => $arrPlain['apiTraceId'],
					'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'],
					'PassportExpiry' => $value['PassportExpiry'],
					'Address' => $value['Address'],
					'CityTitle' => $value['CityTitle'],
					'CitySysId' => $value['CitySysId'],
					'paxType' => $value['paxType'],
					'StateOrZoneSysId' => $value['StateOrZoneSysId'],
					'CountrySysId' => $value['CountrySysId'],
					'countryCode' => $value['countryCode'],
					'companyname' => $value['companyname'],
					'gstnnumber' => $value['gstnnumber'],
					'Baggage' => !empty($baggage['Baggage']) ? $baggage['Baggage'] : '',
					'CabinBaggage' => !empty($baggage['CabinBaggage']) ? $baggage['CabinBaggage'] : '',
					'RegisterDate' => Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss'),
					'IsApproved' => 0,
					'IsActive' => 1,
					'IsMarkForDel' => '0',
				);
				//echo '<pre>';print_r($arrCustomerMembers);
				//die;
				$flight_booking_customer[$k] = $objFlight->InsertFlightData('tbl_flight_booking_customer', $arrCustomerMembers);
				$i++;
			}
			return $flight_booking_customer;
		}
	}

	public function reviewPaymentAction()
	{
		$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
		$objFlight = new Travel_Model_FlightMaster();
		$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
		$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
		$arrUrlData = json_decode($FlightTempData['json_data'], true);
		$FlightBookingData = $arrUrlData['FlightBookingData'];
		if (!empty($arrUrlData)) {
			// echo '<pre>';
			// print_r($this->_session->data);
			// die;
			$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
			$this->view->FlightBookingData = $FlightBookingData;
			$this->view->SearchTraceId = $arrUrlData['SearchTraceId'];
			$this->view->SelectedBaggSessionNew = $arrUrlData['SelectedBaggSessionNew'];
			$this->view->SelectedMealSessionNew = $arrUrlData['SelectedMealSessionNew'];
			$this->view->selectedSeatSession = $arrUrlData['selectedSeatSession'];
			$this->view->ForCustomerSession = $arrUrlData['ForCustomerSession'];
			$this->view->sessionFlightSearchParams = $sessionFlightSearchParams;
			$this->view->CurrencyRate = $this->CurrencyRate;
			$this->view->CurrencyTitle = $this->CurrencyTitle;
			$this->view->intAdultsCount = $adultCount = isset($sessionFlightSearchParams['adults']) ? $sessionFlightSearchParams['adults'] : 0;
			$this->view->intChildrenCount = $childCount = isset($sessionFlightSearchParams['child']) ? $sessionFlightSearchParams['child'] : 0;
			$this->view->intInfantCount = $infantCount = isset($sessionFlightSearchParams['infant']) ? $sessionFlightSearchParams['infant'] : 0;
			$this->view->totalPaxCount = $adultCount + $childCount + $infantCount;
			//$Bookres = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyWallaetBalance($BookingdataAPI);
			$this->view->WalletBalance = 10000;
		} else {
			$this->_redirect('flight');
		}
	}
	public function paymentFailedAction()
	{
		$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
		$objFlight = new Travel_Model_FlightMaster();
		$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
		$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
		$arrUrlData = json_decode($FlightTempData['json_data'], true);
		$FlightBookingData = $arrUrlData['FlightBookingData'];
		if (!empty($arrUrlData)) {
			// echo '<pre>';
			// print_r($arrUrlData);
			// die;
			$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
			$this->view->FlightBookingData = $FlightBookingData;
			$this->view->SearchTraceId = $arrUrlData['SearchTraceId'];
			$this->view->SelectedBaggSessionNew = $arrUrlData['SelectedBaggSessionNew'];
			$this->view->SelectedMealSessionNew = $arrUrlData['SelectedMealSessionNew'];
			$this->view->selectedSeatSession = $arrUrlData['selectedSeatSession'];
			$this->view->ForCustomerSession = $arrUrlData['ForCustomerSession'];
			$this->view->sessionFlightSearchParams = $sessionFlightSearchParams;
			$this->view->CurrencyRate = $this->CurrencyRate;
			$this->view->CurrencyTitle = $this->CurrencyTitle;
			$this->view->intAdultsCount = $adultCount = isset($sessionFlightSearchParams['adults']) ? $sessionFlightSearchParams['adults'] : 0;
			$this->view->intChildrenCount = $childCount = isset($sessionFlightSearchParams['child']) ? $sessionFlightSearchParams['child'] : 0;
			$this->view->intInfantCount = $infantCount = isset($sessionFlightSearchParams['infant']) ? $sessionFlightSearchParams['infant'] : 0;
			$this->view->totalPaxCount = $adultCount + $childCount + $infantCount;
			$this->view->WalletBalance = 10000;
		} else {
			$this->_redirect('flight');
		}
	}
	public function payNowAction()
	{
		//die('Temporarily payment disabled');
		if ($this->getRequest()->isXmlHttpRequest() && $this->getRequest()->getPost()) {
			$this->_helper->layout->disableLayout();
			$this->_helper->viewRenderer->setNoRender(true);
			$param = $this->getRequest()->getParams();
			$data = $param['data'];
			$paymentAction = isset($param['paymentAction']) ? $param['paymentAction'] : ''; //PAYNOW
			$FlightTraceId = $param['FlightTraceId'];
			if ($data != $FlightTraceId) {
				$response = array('success' => false, 'message' => 'Oops invalid request', 'url' => '');
				echo json_encode($response);
				exit;
			}

			$paymentMode = $param['paymentMode']; /// 1 for wallet and 2 for online
			$objFlight = new Travel_Model_FlightMaster();
			$FlightTempData = $objFlight->GetFlightTempData($data);
			$arrUrlData = json_decode($FlightTempData['json_data'], true);
			if (!empty($arrUrlData)) {
				$FlightBookingData = $arrUrlData['FlightBookingData'];
				$SearchTraceId = $arrUrlData['SearchTraceId'];
				$SelectedBaggSessionNew = $arrUrlData['SelectedBaggSessionNew'];
				$SelectedMealSessionNew = $arrUrlData['SelectedMealSessionNew'];
				$selectedSeatSession = $arrUrlData['selectedSeatSession'];
				$ForCustomerSession = $arrUrlData['ForCustomerSession'];
				$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
				$flight_booking_id_Arr = $arrUrlData['flight_booking_id_Arr'];
				$BagPrice = 0;
				$MealPrice = 0;
				$SeatPrice = 0;
				if ($SelectedBaggSessionNew) {
					foreach ($SelectedBaggSessionNew as $values) {
						foreach ($values as $val) {
							$BagPrice += $val['Price'];
						}
					}
				}
				if ($SelectedMealSessionNew) {
					foreach ($SelectedMealSessionNew as $values) {
						foreach ($values as $val) {
							$MealPrice += $val['Price'];
						}
					}
				}
				if ($selectedSeatSession) {
					foreach ($selectedSeatSession as $values) {
						foreach ($values as $val) {
							$SeatPrice += $val['amount'];
						}
					}
				}
				$PublishedPrice = 0;
				$agencyMarkUp = 0;
				$gtxMarkup = 0;
				$offerFare = 0;
				$gtxMarkupGST = 0;
				$agencyMarkUpGST = 0;
				if ($FlightBookingData) {
					foreach ($FlightBookingData as $k => $value) {
						$PublishedPrice += $value['FairRules']['PublishedFare'];
						$agencyMarkUp += $value['FairRules']['FixedMarkUp'];
						$gtxMarkup += $value['FairRules']['intGTXMarkUp'];
						$offerFare += $value['FairRules']['offerTotal'];
						$gtxMarkupGST += $value['FairRules']['intGTXMarkUp'];
						$agencyMarkUpGST += $value['FairRules']['GSTOnMarkUp'];
					}
				}
				$PublishedFare = ($PublishedPrice + $BagPrice + $MealPrice + $SeatPrice);
				if ($paymentAction == 'PAYNOW' && $paymentMode == 2) {


					$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'] = 1; //currency Id
					$markuparray['MarketPlaceId'] = 2; //b2b or b2c

					$encryptMarkUpData = base64_encode(json_encode($markuparray));
					$customerData = $ForCustomerSession[0];
					$AgentSysId = '';
					$AgencySysId = $this->gtxagencysysid;
					$TPSysId = 11111;
					$intTPSysId = json_encode([$TPSysId]);

					$intCustSysId = $customerData['CustomerSysId'];
					$firstName = $customerData['FirstName'];
					$emailId = $customerData['EmailId'];
					$mobileNumber = $customerData['Contacts'];
					$lastInsertId = $param['traceId']; //base64_encode(implode(',', $flight_booking_id));
					$guid = base64_encode(implode(',', $flight_booking_id_Arr)); //$param['traceId']; //$this->GUID();
					$walletCode = $this->walletCode($AgentSysId, $guid, ceil($PublishedFare), $AgencySysId, $intTPSysId, $intCustSysId, $encryptMarkUpData);

					$strReturnURL = $this->baseUrl . "flight/check-payment/id/" . ($FlightTraceId);

					$arrUrlData['_sessiondata'] = $this->_session->data;
					$tempData = array(
						'TraceId' => $FlightTraceId,
						'json_data' => json_encode($arrUrlData),
					);
					$objFlight->deleteFlightTempData($SearchTraceId);
					$objFlight->insertFlightTempData($tempData);

					echo json_encode(["success" => true, 'guid' => $guid, 'gtxagentsysid' => $this->gtxagentsysid, 'gtxagencysysid' => $this->gtxagencysysid, 'amount' => ceil($PublishedFare), 'walletCode' => $walletCode, 'stringData' => $encryptMarkUpData, 'strReturnURL' => $strReturnURL, 'TPSysId' => $intTPSysId, 'UserData' => ['name' => $firstName, 'email' => $emailId, 'mobile' => $mobileNumber, 'CustomerSysId' => $intCustSysId]]);
					exit;
				} elseif ($paymentAction == 'PAYNOW' && $paymentMode == 1) {
					$WalletBalance = 10000;
					if ($WalletBalance >= $PublishedFare) {
						foreach ($flight_booking_id_Arr as $key => $flight_booking_id) {
							$arrPayment = [
								"error_Message" => '',
								"error" => '',
								"GUID" => 11122255,
							];
							$arrPayment['paymentStatus'] = 1;
							$where = "id = " . $flight_booking_id; //exit;
							$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $arrPayment, $where);
						}
						if ($updated) {
							$response = array('success' => true, 'message' => 'success', 'url' => 'flight/book-flight/data/' . $FlightTraceId);
							echo json_encode($response);
							exit;
							//$this->_redirect('flight/book-flight/data/' . $FlightTraceId);
						}
					} else {
						$response = array('success' => false, 'message' => 'Oops insufficient wallet balance.', 'url' => '');
						echo json_encode($response);
						exit;
					}
					// echo "<pre>";
					// 	print_r($flight_booking_id_Arr);
					// 	die;
					// $response = array('success' => false, 'message' => 'Wallet payment underprocess now.', 'url' => '');
					// echo json_encode($response);
					// exit;
				}


				$ViewArr = array(
					'AgentSysId' => '',
					'AgencySysId' => $this->gtxagencysysid,
					'baseUrl' => $this->baseUrl,
					'FlightTraceId' => $FlightTraceId
				);
				$html = new Zend_View();
				$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
				$html->assign($ViewArr);
				$bodyText = $html->render('pay-now.phtml');
				$response = array('success' => true, 'message' => 'Done', 'html' => $bodyText);
				echo json_encode($response);
			} else {
				$response = array('success' => false, 'message' => 'Oops somethings went wrong!!', 'url' => '');
				echo json_encode($response);
				exit;
			}
		} else {
			die('bad request');
		}
	}
	public function checkPaymentAction()
	{
		$this->_helper->viewRenderer->setNoRender(true);
		$param = $this->getRequest()->getParams();
		// $ResponseFlightQuery = new Zend_Session_Namespace('ResponseFlightQuery');
		// $FlightQueryids = $ResponseFlightQuery->params;
		// $MasterTPSysId = $FlightQueryids['arrIds']['MasterTPSysId'];
		// $TPSysId = $FlightQueryids['arrIds']['TPSysId'];
		// $VersionId = $FlightQueryids['arrIds']['VersionId'];
		$status = $this->getRequest()->getParam('status');
		$GUID = $this->getRequest()->getParam('GUID');
		$TrxId = $this->getRequest()->getParam('TrxId');
		$error = $this->getRequest()->getParam('error');
		$error_Message = $this->getRequest()->getParam('error_Message');
		$id = $this->getRequest()->getParam('id');
		$TrxId = explode(',', base64_decode($this->getRequest()->getParam('TrxId')));
		$objFlight = new Travel_Model_FlightMaster();
		$FlightTempData = $objFlight->GetFlightTempData($id);
		$response = json_decode($FlightTempData['json_data'], true);
		// echo "<pre>";
		// print_r($TrxId);
		// die;
		$arrPayment = [
			"error_Message" => $error_Message,
			"error" => $error,
			"GUID" => $GUID,
		];
		$traceId = $param['id'];
		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);
				}
				if ($updated) {
					$this->_redirect('flight/book-flight/data/' . $id);
				}
			} else if ($status == "C") {
				// cancelled by User
				$arrPayment['paymentStatus'] = 2;
				$arrPayment['status'] = 4;
				foreach ($TrxId as $key => $flight_booking_id) {
					$where = "id = " . $flight_booking_id; //exit;
					$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $arrPayment, $where);
				}
				//if ($updated) {
				$this->_redirect('flight/payment-failed/data/' . $id);
				//}
			} else {
				// payment failed case...
				$arrPayment['paymentStatus'] = 3;
				$arrPayment['status'] = 4;
				foreach ($TrxId as $key => $flight_booking_id) {
					$where = "id = " . $flight_booking_id; //exit;
					$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $arrPayment, $where);
				}
				if ($updated) {
					$this->_redirect('flight/payment-failed/data/' . $id);
				}
			}
		}
	}
	public function bookFlightAction()
	{
		$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
		$objFlight = new Travel_Model_FlightMaster();
		$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
		$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
		$arrUrlData = json_decode($FlightTempData['json_data'], true);
		$FlightBookingData = $arrUrlData['FlightBookingData'];
		if (!empty($arrUrlData)) {
			$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
			$this->view->FlightBookingData = $FlightBookingData;
			$this->view->SearchTraceId = $arrUrlData['SearchTraceId'];
			$this->view->SelectedBaggSessionNew = $SelectedBaggSessionNew = $arrUrlData['SelectedBaggSessionNew'];
			$this->view->SelectedMealSessionNew = $SelectedMealSessionNew = $arrUrlData['SelectedMealSessionNew'];
			$this->view->selectedSeatSession = $selectedSeatSession = $arrUrlData['selectedSeatSession'];
			$this->view->ForCustomerSession = $ForCustomerSession = $arrUrlData['ForCustomerSession'];
			$this->view->sessionFlightSearchParams = $sessionFlightSearchParams;
			$this->view->CurrencyRate = $this->CurrencyRate;
			$this->view->CurrencyTitle = $this->CurrencyTitle;
			$this->view->intAdultsCount = $adultCount = isset($sessionFlightSearchParams['adults']) ? $sessionFlightSearchParams['adults'] : 0;
			$this->view->intChildrenCount = $childCount = isset($sessionFlightSearchParams['child']) ? $sessionFlightSearchParams['child'] : 0;
			$this->view->intInfantCount = $infantCount = isset($sessionFlightSearchParams['infant']) ? $sessionFlightSearchParams['infant'] : 0;
			$this->view->totalPaxCount = $adultCount + $childCount + $infantCount;
			$flight_booking_id = isset($arrUrlData['flight_booking_id_Arr']) ? $arrUrlData['flight_booking_id_Arr'] : 0;
			$booking_customer_id = isset($arrUrlData['flight_booking_customer']) ? $arrUrlData['flight_booking_customer'] : 0;

			if ($this->getRequest()->isXmlHttpRequest() && $this->getRequest()->getPost()) {
				$this->_helper->layout->disableLayout();
				$this->_helper->viewRenderer->setNoRender(true);
				$BookingdataAPI = array(
					'FlightBookingData' => $FlightBookingData,
					'IsInternational' => $FlightBookingData[0]['IsInternational'],
					'CustomerSession' => $ForCustomerSession,
					'SelectedBaggSessionNew' => $arrUrlData['SelectedBaggSessionNew'],
					'SelectedMealSessionNew' => $arrUrlData['SelectedMealSessionNew'],
					'selectedSeatSession' => $arrUrlData['selectedSeatSession'],
				);
				// echo '<pre>';
				// print_r($booking_customer_id);
				// print_r($flight_booking_id);
				// print_r($arrUrlData);
				// die;
				$Bookres = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightTicketTripJack($BookingdataAPI);
				// $str = file_get_contents($this->baseUrl . '/public/logs/flight/FlightTicket/FlightTicket_response.json');
				// $Bookres = json_decode($str, true);
				$BookStatus = $Bookres['status']['success'];
				$BookErrorMessage = $Bookres['errors'][0]['message'];
				if ($BookStatus == 1) {
					$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingDetailsTripJack($Bookres);
					// $str = file_get_contents($this->baseUrl . 'public/logs/flight/BookingDetails/BookingDetails_response.json');
					// $response = json_decode($str, true);
					$ResponseStatus = isset($response['status']['success']) ? $response['status']['success'] : '0';
					$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';
					$ErrorMessage = isset($response['errors'][0]['message']) ? $response['errors'][0]['message'] : '';
					if ($FlightBookingData) {
						foreach ($FlightBookingData as $k => $value) {
							try {
								$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'];
											}
										}
										if (!empty($SelectedBaggSessionNew) && isset($SelectedBaggSessionNew[$seg['segmentid']]) && !empty($SelectedBaggSessionNew[$seg['segmentid']])) {
											$selectedBag = $SelectedBaggSessionNew[$seg['segmentid']];
											foreach ($selectedBag as $val) {
												$BagPrice += $val['Price'];
											}
										}
										if (!empty($SelectedMealSessionNew) && isset($SelectedMealSessionNew[$seg['segmentid']]) && !empty($SelectedMealSessionNew[$seg['segmentid']])) {
											$selectedMeal = $SelectedMealSessionNew[$seg['segmentid']];
											foreach ($selectedMeal as $val) {
												$MealPrice += $val['Price'];
											}
										}
									}
								}
								$SeatFare = $SeatPrice;

								//$segment = $value['Segments']['originAirportCode'] . '-' . $value['Segments']['destinationAirportCode'];
								$FlightBookingTicketArr[] = $response;
								$ResponseStatus = isset($response['status']['success']) ? $response['status']['success'] : '0';
								$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';
								$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) {
									$FlightQueryids = [];
									$update = array(
										'API_Response' => json_encode($value),
										'API_Response_Ticket' => json_encode($response),
										'FlightQueryids' => json_encode($FlightQueryids),
										'PNR_Number' => implode('-', $strTicketPNRLCC),
										'BookingId' => $strBookingIdLCC,
										'status' => 1,
									);
									$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);
									$where = "id = " . $flight_booking_id[$k]; //exit;
									$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);


									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,
											);

											$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']);
								}
							} catch (Exception $e) {
								echo $e->getMessage();
							}
						}
						// $arrUrlData['FlightBookingTicketArr'] = $FlightBookingTicketArr;
						// echo '<pre>';
						// print_r($arrUrlData);
						// die;
						if ($responseReturn && $ResponseStatus == 1) {
							$arrUrlData['FlightBookingTicketArr'] = $response;
							$tempData = array(
								'TraceId' => $arrUrlData['SearchTraceId'],
								'json_data' => json_encode($arrUrlData),
							);
							$objFlight->deleteFlightTempData($arrUrlData['SearchTraceId']);
							$objFlight->insertFlightTempData($tempData);
							$Return = array('success' => true, 'message' => 'done', 'SearchTraceId' => $arrUrlData['SearchTraceId']);
							echo json_encode($Return);
							exit;
						} else {
							$Return = array('success' => false, 'message' => 'failed');
							echo json_encode($Return);
							exit;
						}
					}
				} else {
					$arrUrlData['FlightBookingTicketArr'] = $Bookres;
					$tempData = array(
						'TraceId' => $arrUrlData['SearchTraceId'],
						'json_data' => json_encode($arrUrlData),
					);
					$objFlight->deleteFlightTempData($arrUrlData['SearchTraceId']);
					$objFlight->insertFlightTempData($tempData);
					$Return = array('success' => false, 'message' => $BookErrorMessage, 'SearchTraceId' => $arrUrlData['SearchTraceId']);
					echo json_encode($Return);
					exit;
				}
				echo '<pre>';
				print_r($Bookres);
				die;
			}
		} else {
			$this->_redirect('flight');
		}
	}

	public function bookingConfirmedAction()
	{
		$post = $this->getRequest()->getParams();
		$status = $post['status'];
		$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
		$objFlight = new Travel_Model_FlightMaster();
		$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
		$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
		$arrUrlData = json_decode($FlightTempData['json_data'], true);
		$FlightBookingData = $arrUrlData['FlightBookingData'];
		if (!empty($arrUrlData)) {
			$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
			$this->view->FlightBookingData = $FlightBookingData;
			$this->view->SearchTraceId = $arrUrlData['SearchTraceId'];
			$this->view->FlightBookingTicketArr = $FlightBookingTicketArr = $arrUrlData['FlightBookingTicketArr'];
			$this->view->SelectedBaggSessionNew = $SelectedBaggSessionNew = $arrUrlData['SelectedBaggSessionNew'];
			$this->view->SelectedMealSessionNew = $SelectedMealSessionNew = $arrUrlData['SelectedMealSessionNew'];
			$this->view->selectedSeatSession = $selectedSeatSession = $arrUrlData['selectedSeatSession'];
			$this->view->ForCustomerSession = $ForCustomerSession = $arrUrlData['ForCustomerSession'];
			$this->view->sessionFlightSearchParams = $sessionFlightSearchParams;
			$this->view->CurrencyRate = $this->CurrencyRate;
			$this->view->CurrencyTitle = $this->CurrencyTitle;
			$this->view->intAdultsCount = $adultCount = isset($sessionFlightSearchParams['adults']) ? $sessionFlightSearchParams['adults'] : 0;
			$this->view->intChildrenCount = $childCount = isset($sessionFlightSearchParams['child']) ? $sessionFlightSearchParams['child'] : 0;
			$this->view->intInfantCount = $infantCount = isset($sessionFlightSearchParams['infant']) ? $sessionFlightSearchParams['infant'] : 0;
			$this->view->totalPaxCount = $adultCount + $childCount + $infantCount;
		} else {
			die('bad request');
		}
		// echo '<pre>';
		// print_r($arrUrlData);
		// die;
	}

	public function eTicketAction()
	{
		$post = $this->getRequest()->getParams();
		$status = $post['status'];
		$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
		$objFlight = new Travel_Model_FlightMaster();
		$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
		$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
		$arrUrlData = json_decode($FlightTempData['json_data'], true);
		$FlightBookingData = $arrUrlData['FlightBookingData'];
		if (!empty($arrUrlData)) {
			$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
			$this->view->FlightBookingData = $FlightBookingData;
			$this->view->SearchTraceId = $arrUrlData['SearchTraceId'];
			$this->view->FlightBookingTicketArr = $FlightBookingTicketArr = $arrUrlData['FlightBookingTicketArr'];
			$this->view->SelectedBaggSessionNew = $SelectedBaggSessionNew = $arrUrlData['SelectedBaggSessionNew'];
			$this->view->SelectedMealSessionNew = $SelectedMealSessionNew = $arrUrlData['SelectedMealSessionNew'];
			$this->view->selectedSeatSession = $selectedSeatSession = $arrUrlData['selectedSeatSession'];
			$this->view->ForCustomerSession = $ForCustomerSession = $arrUrlData['ForCustomerSession'];
			$this->view->sessionFlightSearchParams = $sessionFlightSearchParams;
			$this->view->CurrencyRate = $this->CurrencyRate;
			$this->view->CurrencyTitle = $this->CurrencyTitle;
			$this->view->intAdultsCount = $adultCount = isset($sessionFlightSearchParams['adults']) ? $sessionFlightSearchParams['adults'] : 0;
			$this->view->intChildrenCount = $childCount = isset($sessionFlightSearchParams['child']) ? $sessionFlightSearchParams['child'] : 0;
			$this->view->intInfantCount = $infantCount = isset($sessionFlightSearchParams['infant']) ? $sessionFlightSearchParams['infant'] : 0;
			$this->view->totalPaxCount = $adultCount + $childCount + $infantCount;
		} else {
			die('bad request');
		}
		// echo '<pre>';
		// print_r($arrUrlData);
		// die;
	}
	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);
		$str = curl_exec($ch);
		$response = json_decode($str, true);
		return $response;
	}
	public function searchcustomerAction()
	{
		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_TJ);
			$ARR_SALUTION_CHILD = unserialize(ARR_SALUTION_CHILD);

			//echo '<pre>';print_r($param);die;
			$objFlight = new Travel_Model_FlightMaster();
			$tbl_customer = $objFlight->SearchFlightCustomer('tbl_customer', $param);
			$customerMemberArr = [];
			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']];
								if ($member['Salutation'] == 1) {
									$gender = 'Male';
								} else {
									$gender = 'Female';
								}
							} elseif ($member['paxType'] == 2) {
								$paxtype = 'Child';
								$SalutationTxt = $ARR_SALUTION_CHILD[$member['Salutation']];
								if ($member['Salutation'] == 2) {
									$gender = 'Male';
								} else {
									$gender = 'Female';
								}
							} else {
								$paxtype = 'Infant';
								$SalutationTxt = $ARR_SALUTION_CHILD[$member['Salutation']];
								if ($member['Salutation'] == 2) {
									$gender = 'Male';
								} else {
									$gender = 'Female';
								}
							}


							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 = '';
							}

							$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'],
								'paxType' => $member['paxType'],
								'PassportNation' => $member['PassportNation'],
								'paxTypeName' => $paxtype,
								'gender' => $gender,
								'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 = '';
					}
					//                $PassportExpiry = ($value['PassportExpiry'] != '0000-00-00')?date('d/m/Y',strtotime($value['PassportExpiry'])):'';
					if ($value['paxType'] == 1) {
						$paxtype = 'Adult';
						$SalutationTxt = $ARR_SALUTION[$value['Salutation']];
						if ($value['Salutation'] == 1) {
							$gender = 'Male';
						} else {
							$gender = 'Female';
						}
					} elseif ($value['paxType'] == 2) {
						$paxtype = 'Child';
						$SalutationTxt = $ARR_SALUTION_CHILD[$value['Salutation']];
						if ($value['Salutation'] == 2) {
							$gender = 'Male';
						} else {
							$gender = 'Female';
						}
					} else {
						$paxtype = 'Infant';
						$SalutationTxt = $ARR_SALUTION_CHILD[$value['Salutation']];
						if ($value['Salutation'] == 2) {
							$gender = 'Male';
						} else {
							$gender = 'Female';
						}
					}

					$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'],
						'paxType' => $value['paxType'],
						'paxTypeName' => $paxtype,
						'companyname' => $value['companyname'],
						'gstnnumber' => $value['gstnnumber'],
						'gstaddress' => $value['gstaddress'],
						'gstcity' => $value['gstcity'],
						'gststate' => $value['gststate'],
						'gstpincode' => $value['gstpincode'],
						'PassportNation' => $value['PassportNation'],
						'PassportExpiry' => $PassportExpiry,
						'gender' => $gender,
						'passporIssue' => $passporIssue,
						'dobday' => $DOB[2],
						'dobmonth' => $DOB[1],
						'dobyear' => $DOB[0],
						//'customerMember' => $customerMemberArr
					);
				}
				$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;
						}
					}
				}
				// echo '<pre>';print_r($responseArray);
				// die;
				//ksort($responseArray);
				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;
				}
			} else {
				$response = array(
					'success' => false,
					'msg' => 'no record found',
					'CustomerSysId' => 0,
					'data' => []
				);
				echo json_encode($response);
				exit;
			}
		} else {
			die('Page not found');
		}
		//        echo '<pre>';print_r($response);die;
	}
	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 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);
		$str = curl_exec($ch);
		//        $str = file_get_contents($this->baseUrl.'public/data/dynamic/AirlineIdsAndCodeList.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);
		$str = curl_exec($ch);
		//        $str = file_get_contents($this->baseUrl.'public/data/dynamic/AirPortCodeList.json');
		$response = json_decode($str, true);
		return $response;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit