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/FlightController.php_14_09_2022
<?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 $gtxBtoBsite;
	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;
	private $respHashKey;
	private $aesResponseKey;
	private $aesResponseIv;


	public function init()
	{

		// $this->_session = new Zend_Session_Namespace('User');
		// if(empty($this->_session->data)){
		// 	$data = array('status' => false,'message'=>'Session expired.');
		// 	echo json_encode($data);
		// 	exit;
		// }
		parent::init();
		$this->_helper->_layout->setLayout('layout-flights')->setLayoutPath(APPLICATION_PATH . '/layouts/scripts');
		$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
		$BootStrap  = $aConfig['bootstrap'];

		$this->respHashKey = Catabatic_Helper::getRespHashKey();
		$this->aesResponseKey = Catabatic_Helper::getAesResponseKey();
		$this->aesResponseIv = Catabatic_Helper::getAesResponseIv();

		$this->_session = new Zend_Session_Namespace('User');
		$this->siteName = $BootStrap['siteName'];
		$this->baseUrl  = $BootStrap['siteUrl'];
		$this->IsSeriesFare  = $BootStrap['IsSeriesFare'];
		$this->IsTJFlightAPI  = $BootStrap['IsTJFlightAPI'];
		$this->IsBOTHFlightAPI  = $BootStrap['IsBOTHFlightAPI'];
		$this->gtxBtoBsite  = $BootStrap['gtxBtoBsite'];
		$this->siteImageUrl  = $BootStrap['siteImageUrl'];
		$this->tollfreenumber  = $BootStrap['tollfreenumber'];
		$this->IsAllowFlight = $BootStrap['IsAllowFlight'];
		$this->view->ValidateRemark = $BootStrap['ValidateRemark'];

		//$this->gtxagencysysid = $this->AgencyId = $BootStrap['gtxagencysysid'];
		$this->gtxagencysysid = $this->_session->data['AgencySysId'];
		$this->MasterAgencySysId = $this->view->MasterAgencySysId = $this->_session->data['MasterAgencySysId'];
		$this->SecurityKey = $this->_session->data['SecurityKey'];
		$this->view->B2BType = $this->_session->B2BType;

		$this->objMdl   = new Admin_Model_CRUD();

		$this->tablename    = "tb_tbb2c_packages_master";
		$this->tablenameTes = "tbl_testimonials";
		$this->tablePopularCity = 'tbl_popular_city';
		$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;
		if ($this->IsAllowFlight == 0) {
			$this->_redirect('dashboard');
		}
	}

	public function indexAction()
	{
		$ChangeFLight = $this->view->ChangeFLight = $this->getRequest()->getParam('data');
		//Zend_Session::namespaceUnset('sessionFlightSearchParams');
		// $WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyWallaetBalance($this->SecurityKey);
		// $sessionWallaetBalance = new Zend_Session_Namespace('sessionWallaetBalance');
		// $sessionWallaetBalance->params = $WallaetBalance;
		// echo '<pre>';
		// print_r($this->_session->data);
		// echo '<pre>';

		try {
			$crud = new Admin_Model_CRUD();
			$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
			$recentSearch = new Zend_Session_Namespace('recentSearch');
			$this->view->sessionFlightSearchParams = $sessionFlightSearchParams->params;
			$this->view->recentSearch = $recentSearch->params;

			$this->view->B2BAgentSysId = $this->_session->data['UserSysId'];
			$this->view->B2BAgencySysId = $this->_session->data['AgencySysId'];

			$this->view->baseUrl    = $this->baseUrl;
			$this->view->siteName    = $this->siteName;
			$this->view->IsSeriesFare    = $this->IsSeriesFare;
			$this->view->IsTJFlightAPI    = $this->IsTJFlightAPI;
			$this->view->B2BType    = $this->_session->B2BType;
			$this->view->gtxagencysysid    = $this->gtxagencysysid;
			//echo '<pre>';print_r($this->_session->UserPicPath);die('ddcc');
			$SeriesFareSecotrs = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetAgencyInventorySector(1);
			$this->view->SeriesFareSecotrs    = $SeriesFareSecotrs;
			// $WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyWallaetBalance($this->SecurityKey);
			// echo '<pre>';print_r($WallaetBalance);

			$DomesPopularCity = $crud->rv_select_all($this->tablePopularCity, ['*'], ['popularCityType' => 0, 'IsMarkForDel' => 0, 'isb2b' => 1, 'status' => 1], ['AboutId' => 'DESC']);
			$InterPopularCity = $crud->rv_select_all($this->tablePopularCity, ['*'], ['popularCityType' => 1, 'IsMarkForDel' => 0, 'isb2b' => 1, 'status' => 1], ['AboutId' => 'DESC']);
			$flightsourcedestin = $this->objMdl->rv_select_all('tbl_flight', ['*'], ['IsActive' => 1], [], 20);

			//$resultset = $this->objMdl->rv_select_static('tbl_offers', ['*'], ['isMarkForDel' => 0, 'IsFeatured' => 1, 'isb2b' => 1], ['Id ' => 'DESC']);
			//$importantlink = $crud->rv_select_static('tbl_notification', ['*'], ['isMarkForDel' => 0, 'IsFeatured' => 1, 'isActive' => 1], ['Id ' => 'DESC']);
			$resultset = $crud->getoffers();
			$importantlink = $crud->getnotification();
			$this->view->importantlink = $importantlink;
			$this->view->resultset    = $resultset;
			$this->view->flightsourcedestin = $flightsourcedestin;
			$this->view->DomesPopularCity = $DomesPopularCity;
			$this->view->InterPopularCity = $InterPopularCity;
		} catch (Zend_Exception $e) {
			print_r($e->getMessage());
			exit;
		}
	}

	public function flightsearchdataAction()
	{
		$getData = $this->getRequest()->getParams();
		$uri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();

		$uriExp = explode('?', $uri);
		//Zend_Session::namespaceUnset('sessionFlightSearchParams');

		$PostDataTemp = new Zend_Session_Namespace('PostDataTemp');
		$IsChangeSearch = base64_encode(json_encode($getData));
		// echo"<pre>";print_r($getData);die();
		$TraceId = implode('-', str_split(substr(strtolower(md5(time() . rand(1000, 9999))), 0, 20), 5));
		$SearchFlightTraceId = new Zend_Session_Namespace('SearchFlightTraceId');
		$SearchFlightTraceId->params = $TraceId;
		$CreateSessionSearchParams = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CreateSessionSearchParams($getData, $TraceId);
		if (base64_encode(json_encode($PostDataTemp->params)) == $IsChangeSearch) {
			$CreateSessionSearchParams['IsChangeSearch'] = 0;
		} else {
			$CreateSessionSearchParams['IsChangeSearch'] = 1;
		}

		$PostDataTemp->params = $getData;  // Putting all form data to Session

		$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;
	}
	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 getMarkupNew()
	{
		if ($this->SecurityKey) {
			$dataArray = array(
				'B2BAgencySysIdKey' => $this->SecurityKey,
				'B2CAgencySysIdKey' => SECURITYKEY,
			);
			$model = new Gtxwebservices_Model_Webservices();
			$result = $model->getMarkupAndServiceTaxNew($dataArray);
			$response = json_decode($result, true);
			return $response;
		} else {
			$data = array('status' => false, 'message' => 'Invalid request');
			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 array_searcher($needles, $array)
	{
		$keys = [];
		foreach ($array as $key => $value) {
			if (in_array($value['fareIdentifier'], $needles)) {
				$keys[] = $value;
			}
		}
		return $keys;
	}
	public function FlightDataSeriesFare($response, $sessionFlightSearchParams, $intJourneyType = null)
	{

		$arrAirlineList = $this->getAirlineIdsAndCodeList();
		$objFlight = new Travel_Model_FlightMaster();
		$getAllflightAirportListData = $objFlight->getAllflightAirportListData();
		$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId'][0]);
		$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId'][0]);
		$sourceCityText = explode(',', $sessionFlightSearchParams['sourceCityText'][0]);
		$destinationCityText = explode(',', $sessionFlightSearchParams['destinationCityText'][0]);
		$adultCount = $sessionFlightSearchParams['adults'];
		$childCount = $sessionFlightSearchParams['child'];
		$infantCount = $sessionFlightSearchParams['infant'];
		$intMemberCount = $adultCount + $childCount + $infantCount;
		$strFlightRoute = trim($sessionFlightSearchParams['route']);
		$FlightTraceId = trim($sessionFlightSearchParams['FlightTraceId']);
		$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
		$flight_class = trim($sessionFlightSearchParams['flight_class']);
		$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
		$source_city = isset($sessionFlightSearchParams['source_city']) ? $sessionFlightSearchParams['source_city'][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 ($intJourneyType) {
			$intJourneyType = $intJourneyType;
		} else {
			$intJourneyType = 1;
		}
		if ($infantCount > 0) {
			$isIdobrMandatory = true;
		} else {
			$isIdobrMandatory = false;
		}
		$intTripType = 1;
		$$arrInsertFlightData = [];
		$arrAirlineName = [];
		$FiltStopCount = [];
		$FiltPriceRange = [];
		$AttPriceRange = [];

		if ($response) {
			$key = 0;
			foreach ($response as $result) {
				$strTraceId = $result['id'] . '-' . $FlightTraceId;
				$SupplierSysId = $result['Supplier'];
				$SecurityKey = $result['SecurityKey'];
				$CheckInLuggage = $result['CheckInLuggage'];
				$InCabinLuggage = $result['InCabinLuggage'];
				$FareRules = $result['Fare'];
				$CancellationPolicy = $result['CancellationPolicy'];
				$InternalRemarks = $result['InternalRemarks'];
				$SegmentInformation = $result['airlineinventories'];

				$airlineprices = $result['airlineprices'];
				$CurrentAirlineprices = current($airlineprices);
				$OriginSegments = current($SegmentInformation);
				$DestinationSegments = end($SegmentInformation);
				$FNEX = explode('-', $OriginSegments['FlightNumber']);
				$AirlineCode = $FNEX[0];
				$FlightNumber = $FNEX[1];
				$strFlightNumber = $OriginSegments['FlightNumber'];
				$strAirlineName = $OriginSegments['AirLines'];
				$strDepartureDtTime = date('H:i', strtotime($OriginSegments['DepartureTime']));
				$strArrivalDtTime = $OriginSegments['ArrivalTime'];
				$FlightDuration = $OriginSegments['EstimateHours'];
				$FlightDurationArr = explode(':', $FlightDuration);
				$hours = isset($FlightDurationArr[0]) ? $FlightDurationArr[0] : 0;
				$minutes = isset($FlightDurationArr[1]) ? $FlightDurationArr[1] : 0;
				$strSourceAirportCode = $OriginSegments['FromCityCode'];
				$strDestinationAirportCode = $DestinationSegments['ToCityCode'];
				$Stops = $OriginSegments['Stops'];
				$IsLCC = true;
				$Currency = $result['Markup'];
				$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
				$filePath = $this->getflightlogo($AirlineCode);
				if (!empty($CheckInLuggage)) {
					$IsBaggage = true;
				} else {
					$IsBaggage = false;
				}
				$totalMarkup = 0;
				$arrSegments = [];
				if ($airlineprices) {
					foreach ($airlineprices as $price) {
						$arrSegments = array();
						if ((int)$price['CurrentSeat'] > 0) {
							if ($SegmentInformation) {
								$totalhoures = $totalminutes = $countSegment = $breakTime = $dtime =  0;
								$strDepartureDtTimeFirst =  '';
								foreach ($SegmentInformation as $segments) {
									// echo '<pre>';
									// print_r($segments);
									$FNEX = explode('-', $segments['FlightNumber']);
									$AirlineCode = $FNEX[0];
									$FlightNumber = $FNEX[1];
									$FromTerminal = $segments['FromTerminal'];
									$ToTerminal = $segments['ToTerminal'];
									$SegFlightNumber = $segments['FlightNumber'];
									$AirlineName = $segments['AirLines'];
									$strDepartureDtTime = $segments['DepartureTime'];
									if ($countSegment == 0) {
										$strDepartureDtTimeFirst = $segments['DepartureTime'];
									}
									$strArrivalDtTime = $segments['ArrivalTime'];
									if ($countSegment > 0) {
										$firstTime = $strArrivalDtTimePre;
										$secondTime = $strDepartureDtTime;
										$checkFTime = preg_match("/^(?:2[0-3]|[01][0-9]):[0-5][0-9]$/", $firstTime);
										$checkSTime = preg_match("/^(?:2[0-3]|[01][0-9]):[0-5][0-9]$/", $secondTime);
										$dtime = 0;
										if ($checkFTime == true && $checkSTime == true) {
											$a = new DateTime($firstTime);
											$b = new DateTime($secondTime);
											$interval = $a->diff($b);
											$dtime = (int) $interval->h . ':' . (int) $interval->i;
											if ((int) $interval->invert == 1) {
												$c = new DateTime('24:00');
												$d = new DateTime($dtime);
												$interval1 = $c->diff($d);
												$dtime = (int) $interval1->h * 60 + (int) $interval1->i;
											} else {
												$dtime = (int) $interval->h * 60 + (int) $interval->i;
											}
										}
									}
									$strArrivalDtTimePre = $strArrivalDtTime;
									$strDuration = $segments['EstimateHours'];

									$FlightDurationArr = explode(':', $strDuration);
									$hours = isset($FlightDurationArr[0]) ? (int)$FlightDurationArr[0] : 0;
									$minutes = isset($FlightDurationArr[1]) ? (int)$FlightDurationArr[1] : 0;
									$FlightDurationTxt = $hours . ($hours > 1 ? ' hours' : 'hour') . ' ' . $minutes . ($minutes > 1 ? ' minutes' : ' minute');
									$totalhoures = $totalhoures + $hours;
									$totalminutes = $totalminutes + $minutes;
									$FromDate = date('Y-m-d', strtotime($price['FromDate'])) . ' ' . $strDepartureDtTime;
									$LocalToTime = date('Y-m-d H:i:s', strtotime('+' . $hours . ' hour +' . $minutes . ' minutes', strtotime($FromDate)));
									$destinationArrTime = date('Y-m-d', strtotime('+' . $hours . ' hour +' . $minutes . ' minutes', strtotime($FromDate)));
									//echo "<pre>";print_r($cenvertedTime);die;
									$originAirportCode = $segments['FromCityCode'];
									$destinationAirportCode = $segments['ToCityCode'];
									$Stops = $segments['Stops'];
									$filePathS = $this->getflightlogo($AirlineCode);
									//$originAirportCodeData = $objFlight->getflightAirportData($originAirportCode);
									//$destinationAirportCodeData = $objFlight->getflightAirportData($destinationAirportCode);
									$originAirportCodeData = isset($getAllflightAirportListData[$originAirportCode]) ? $getAllflightAirportListData[$originAirportCode] : array();
									$destinationAirportCodeData = isset($getAllflightAirportListData[$destinationAirportCode]) ? $getAllflightAirportListData[$destinationAirportCode] : array();

									$originCityName = isset($originAirportCodeData[0]['AirportName']) ? explode(',', $originAirportCodeData[0]['AirportName']) : '';
									$destinationCityName = isset($destinationAirportCodeData[0]['AirportName']) ? explode(',', $destinationAirportCodeData[0]['AirportName']) : '';

									$arrSegments[] = array(
										"destinationAirportCode" => $destinationAirportCode,
										"SegFlightNumber" => $SegFlightNumber,
										"AirlineCode" => $AirlineCode,
										"AirlineName" => $AirlineName,
										"originAirportCode" => $originAirportCode,
										"Baggage" => $CheckInLuggage,
										"CabinBaggage" => $InCabinLuggage,
										"IsBaggage" => $IsBaggage,
										"NoOfSeatAvailable" => $NoOfSeatAvailable,
										"strDepartureDtTime" => $strDepartureDtTime,
										"strArrivalDtTime" => $strArrivalDtTime,
										"FlightDuration" => $FlightDurationTxt,
										"filePath" => $filePathS,
										"originAirportName" => isset($originAirportCodeData[0]['AirportName']) ? $originAirportCodeData[0]['AirportName'] : '',
										"destinationAirportName" => isset($destinationAirportCodeData[0]['AirportName']) ? $destinationAirportCodeData[0]['AirportName'] : '',
										"originCityName" => isset($originCityName[0]) ? $originCityName[0] : '',
										"originCountryName" => '',
										"destinationCityName" => isset($destinationCityName[0]) ? $destinationCityName[0] : '',
										"destinationCountryName" => '',
										"destinationArrTime" => $destinationArrTime . 'T' . $strArrivalDtTime,
										"FareClass" => '',
										"originDepTime" => $price['FromDate'] . 'T' . $strDepartureDtTime,
										"TripIndicator" => '', //$TripIndicator,
										"IsMealIncludes" => 0,
										"Duration" => '',
										"GroundTime" => '',
										"LAYOVERDuration" => '',
										"LAYOVERCity" => '',
										"DepTerminal" => $FromTerminal,
										"ArrTerminal" => $ToTerminal,
									);
									$countSegment++;
								}
							}


							$totalhouresminutes = ($totalhoures * 60 + $totalminutes + $dtime);

							$totalhouresminutesH = (intdiv($totalhouresminutes, 60));
							$totalhouresminutesM = $totalhouresminutes % 60;
							$totalhouresminutesHStr = $totalhouresminutesMStr = '';
							if ($totalhouresminutesH > 0) {
								$totalhouresminutesHStr = ($totalhouresminutesH > 1) ? $totalhouresminutesH . ' hours' : $totalhouresminutesH . ' hour';
							}
							if ($totalhouresminutesM > 0) {
								$totalhouresminutesMStr = ($totalhouresminutesM > 1) ? $totalhouresminutesM . ' minutes' : $totalhouresminutesM . ' minute';
							}
							$totalhouresminutesHtml = $totalhouresminutesHStr . ', ' . $totalhouresminutesMStr;

							$BaseFare = $price['Fare'];
							$InfantFare = $price['InfantFare'];
							$Taxes = $price['Taxes'];
							$Markup = $price['Markup'];
							$MarkupType = $price['MarkupType'];
							$InfantMarkup = $price['InfantMarkup'];
							if ($MarkupType == 1) {
								$totalMarkup = $Markup;
							} else {
								$totalMarkup = ((($BaseFare + $Taxes) * $Markup) / 100);
							}
							$PublishedFareReverseAdultChild = ($BaseFare + $Taxes + $totalMarkup) * ($adultCount + $childCount);
							$PublishedFareReverseInfant = ($InfantFare + $InfantMarkup) * $infantCount;
							$PublishedFareReverse = $PublishedFareReverseAdultChild + $PublishedFareReverseInfant;
							$NoOfSeatAvailable = $price['CurrentSeat'];
							$BaseFareIN = ($BaseFare * ($adultCount + $childCount)) + ($InfantFare * $infantCount);
							$PriceID = $result['id'] . '_' . $price['id'];
							$ADULT = array();
							$ADULT = array('TAF' => 0, 'TF' => 0, 'BF' => $BaseFare, 'NCM' => 0);
							$AD_MF = $AD_YQ = $AD_AGST = $AD_MFT = $AD_OT = $AD_MU = $AD_YR = $TdsOnPLBCal = $ADULTNCMTDS = $PLBEarned = $IncentiveEarned = 0;
							$FareBreakdown = $FairRulesArr = [];
							$FareBreakdown[0]['Currency'] = 'INR';
							$FareBreakdown[0]['PassengerType'] = 1;
							$FareBreakdown[0]['PassengerCount'] = $intMemberCount;
							$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $intMemberCount);
							$FareBreakdown[0]['TotalBaseFare'] = ($ADULT['TF'] * $intMemberCount);
							$FareBreakdown[0]['BaseFareCal'] = ($BaseFare * ($adultCount + $childCount)) + ($InfantFare * $infantCount);
							$FareBreakdown[0]['BaseFare'] = ($BaseFare * ($adultCount + $childCount)) + ($InfantFare * $infantCount);
							$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $intMemberCount);
							$FareBreakdown[0]['TDS'] = (float)str_replace('-', '', ($ADULTNCMTDS * $intMemberCount));
							$FareBreakdown[0]['MF'] = ($AD_MF * $intMemberCount);
							$FareBreakdown[0]['YQ'] = ($AD_YQ * $intMemberCount);
							$FareBreakdown[0]['AGST'] = ($AD_AGST * $intMemberCount);
							$FareBreakdown[0]['MFT'] = ($AD_MFT * $intMemberCount);
							$FareBreakdown[0]['OT'] = $Taxes * ($adultCount + $childCount); //($AD_OT * $intMemberCount);
							$FareBreakdown[0]['MU'] = ($AD_MU * $intMemberCount);
							$FareBreakdown[0]['YR'] = ($AD_YR * $intMemberCount);
							$FareBreakdown[0]['intTotalGST'] = 0;
							$FareBreakdown[0]['apiMarkup'] = 0; //$Taxes * ($adultCount + $childCount);
							$FareBreakdown[0]['IntCommission'] = 0;
							$FareBreakdown[0]['apiTaxOnMarkup'] = 0;
							$FareBreakdown[0]['FixedMarkUp'] = ($totalMarkup * ($adultCount + $childCount)) + ($InfantMarkup * $infantCount);
							$FareBreakdown[0]['GSTOnMarkUp'] = 0;
							$FareBreakdown[0]['CommEarned'] = 0;
							$FareBreakdown[0]['GSTonComm'] = 0;
							$FareBreakdown[0]['intGTXMarkUp'] = 0;
							$FareBreakdown[0]['GTXMarkUpGST'] = 0;
							$FareBreakdown[0]['AgentMarkUp'] = 0;
							$FareBreakdown[0]['GSTOnAgentMarkUp'] = 0;
							$FareBreakdown[0]['Agencycommission'] = 0;
							$FareBreakdown[0]['TotalCommssionVal_ag'] = 0;
							$FareBreakdown[0]['AdminComminAmount_ag'] = 0;
							$FareBreakdown[0]['AgentB2CEarning'] = 0;
							$FareBreakdown[0]['CostToAgentCustomer'] = (int)($PublishedFareReverse * $this->CurrencyRate);
							$FareBreakdown[0]['CostToAgent'] = 0;
							$FareBreakdown[0]['AdditionalTxnFeeOfrd'] = 0;
							$FareBreakdown[0]['AdditionalTxnFeePub'] = 0;
							$FareBreakdown[0]['PGCharge'] = 0;
							$FareBreakdown[0]['Baggage'] = $CheckInLuggage; //Check In Baggage;
							$FareBreakdown[0]['CabinBaggage'] = $InCabinLuggage; //Cabin Baggage ;
							$FairRulesArr[] = array(
								"Currency" => $this->CurrencyTitle, //$Currency,
								"CurrencyRate" => $this->CurrencyRate, //$Currency,
								"currencySysId" => $this->CurrencyId,
								"BaseFare" => $BaseFareIN,
								"Tax" => $Taxes * ($adultCount + $childCount),
								"YQTax" => 0,
								"OtherCharges" => 0,
								"Discount" => 0, //$Discount,
								"ServiceFee" => 0,
								"ManagementFeeTax" => 0,
								"AirlineGSTComponent" => 0,
								"CarrierMiscFee" => 0,
								"MUFee" => 0,
								"intPublishedFare" => $PublishedFareReverse,
								"PublishedFare" => ($PublishedFareReverse * $this->CurrencyRate),
								"PublishedFareAgent" => (int)($PublishedFareReverse * $this->CurrencyRate),
								"OfferedFareAgent" => (int)($PublishedFareReverse * $this->CurrencyRate),
								"OfferedFare" => 0,
								"PLBEarned" => 0,
								"IncentiveEarned" => 0,
								"TdsOnPLB" => 0,
								"TdsOnIncentive" => 0,
								"AdditionalTxnFeeOfrd" => 0,
								"AdditionalTxnFeePub" => 0,
								"OnwardAutoTicket" => $price['OnwardAutoTicket'],
								"Refundable" => $price['IsRefundable'],
								"IsRefundableTxt" => ($price['IsRefundable'] == 1) ? 'Refundable' : 'Non-Refundable',
								"PriceID" => $PriceID,
								"ApiResultIndex" => $PriceID,
								"IsGSTRequired" => 0,
								"fareIdentifier" => 'Special Deal',
								"SeatAvailable" => $NoOfSeatAvailable,
								"classOfBooking" => 0,
								"FareClass" => '',
								"intTotalGST" => 0,
								"apiMarkup" => 0,
								"IntCommission" => 0,
								"apiTaxOnMarkup" => 0,
								"FixedMarkUp" => ($totalMarkup * ($adultCount + $childCount)) + ($InfantMarkup * $infantCount),
								"GSTOnMarkUp" => 0,
								"CommEarned" => 0,
								"CommEarnedAgent" => 0,
								"GSTonComm" => 0,
								"intGTXMarkUp" => (int)0,
								"GTXMarkUpGST" => 0,
								"AgentMarkUp" => 0,
								"GSTOnAgentMarkUp" => 0,
								'Agencycommission' => 0,
								'TotalCommssionVal_ag' => 0,
								'AdminComminAmount_ag' => 0,
								'AgentB2CEarning' => 0,
								'CostToAgentCustomer' => (int)($PublishedFareReverse * $this->CurrencyRate),
								'CostToAgent' => 0,
								"FareBreakdown" => $FareBreakdown,
								"newFare" => 0,
								"oldFare" => 0,
								"arrMarkUps" => 0,
							);
							//$SourceAirportCodeData = $objFlight->getflightAirportData($strSourceAirportCode);
							//$destinationAirportCodeData = $objFlight->getflightAirportData($strDestinationAirportCode);

							$SourceAirportCodeData = isset($getAllflightAirportListData[$strSourceAirportCode]) ? $getAllflightAirportListData[$strSourceAirportCode] : array();
							$destinationAirportCodeData = isset($getAllflightAirportListData[$strDestinationAirportCode]) ? $getAllflightAirportListData[$strDestinationAirportCode] : array();

							$SourcePlaceName = isset($SourceAirportCodeData[0]['AirportName']) ? explode(',', $SourceAirportCodeData[0]['AirportName']) : '';
							$DestPlaceName = isset($destinationAirportCodeData[0]['AirportName']) ? explode(',', $destinationAirportCodeData[0]['AirportName']) : '';

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

		$arrAirlineList = $this->getAirlineIdsAndCodeList();
		$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]);
		$sourceCityText = explode(',', $sessionFlightSearchParams['sourceCityText'][0]);
		$destinationCityText = explode(',', $sessionFlightSearchParams['destinationCityText'][0]);
		// echo '<pre>';
		// print_r($sessionFlightSearchParams);die;
		$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($interNationalSearch)) && trim($interNationalSearch) == 1) {
			$this->FlightDataMultiCityInterNational($apiResponse, $sessionFlightSearchParams, $getMarkupNew, $getAgencyMarkups);
			$intAirType = 2;
		} else {
			$intAirType = 1;
		}

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

		$intResponseStatus = $apiResponse['ResponseStatus'];
		$ONWARD = $apiResponse['OutBoundFlightResults'];
		// echo '<pre>';
		// print_r($MultiHead);
		// print_r($sessionFlightSearchParams);
		// die;
		if ($intResponseStatus == 1) {
			if ($ONWARD) {
				foreach ($ONWARD as $keys => $tripInfos) {
					foreach ($tripInfos 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(
									'getMarkupNew' => $getMarkupNew,
									'getAgencyMarkups' => $getAgencyMarkups,
									'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);die;
								if ($kp == 0) {
									$PublishedFareReverse += ($arrMarkUps['PublishFare']);
								}
								$TdsOnPLBCal = isset($ADULTNCMTDS) ? str_replace('-', '', $ADULTNCMTDS) : 0;
								$markUpArrBR = array(
									'getMarkupNew' => $getMarkupNew,
									'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(
										'getMarkupNew' => $getMarkupNew,
										'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(
										'getMarkupNew' => $getMarkupNew,
										'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,
									"ApiResultIndex" => $PriceID,
									"IsGSTRequired" => $IsGSTRequired,
									"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
									"fareIdentifierSP" => $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;
						$SegFlightNumberArr = [];
						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,
								);
								$SegFlightNumberArr[] = $SegFlightNumber;
								//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[$keys][$key]['FlightNumber'] = $strFlightNumber;
						$arrInsertFlightData[$keys][$key]['SegFlightNumberArr'] = implode(', ', $SegFlightNumberArr);
						$arrInsertFlightData[$keys][$key]['AirlineName'] = $strAirlineName;
						$arrInsertFlightData[$keys][$key]['AirlineCode'] = $AirlineCode;
						$arrInsertFlightData[$keys][$key]['IsTJFlightAPI'] = $this->IsTJFlightAPI;
						$arrInsertFlightData[$keys][$key]['AirInvenSysId'] = 0;
						$arrInsertFlightData[$keys][$key]['IsLCC'] = $IsLCC;
						$arrInsertFlightData[$keys][$key]['IsMealIncludes'] = $IsMealIncludes;
						$arrInsertFlightData[$keys][$key]['IsBagIncludes'] = $IsBagIncludes;
						$arrInsertFlightData[$keys][$key]['IsRefundable'] = $IsRefundable;
						$arrInsertFlightData[$keys][$key]['IsRefundableTxt'] = $IsRefundableTxt;
						$arrInsertFlightData[$keys][$key]['SearchTraceId'] = $FlightTraceId;
						$arrInsertFlightData[$keys][$key]['apiTraceId'] = $strTraceId;
						$arrInsertFlightData[$keys][$key]['AirlineSysId'] = $airlineSysId;
						$arrInsertFlightData[$keys][$key]['DepartureTime'] = $strDepartureDtTime;
						$arrInsertFlightData[$keys][$key]['ArrivalTime'] = $strArrivalDtTime;
						$arrInsertFlightData[$keys][$key]['TravelDate'] = $OriginSegments['dt'];
						$arrInsertFlightData[$keys][$key]['LocalFromTime'] = str_replace('T', ' ', $OriginSegments['dt']);
						$arrInsertFlightData[$keys][$key]['FromUTCTime'] = $OriginSegments['dt'];
						$arrInsertFlightData[$keys][$key]['LocalToTime'] = str_replace('T', ' ', $DestinationSegments['at']);
						$arrInsertFlightData[$keys][$key]['ToUTCTime'] = $DestinationSegments['at'];
						$arrInsertFlightData[$keys][$key]['IsDirect'] = 0;
						$arrInsertFlightData[$keys][$key]['FareClass'] = $strFareClass;
						$arrInsertFlightData[$keys][$key]['LAYOVERCity'] = isset($LAYOVERCityArr[0]) ? $LAYOVERCityArr[0] : '';
						$arrInsertFlightData[$keys][$key]['GroundTime'] = $TotalLAYOVERMinutes;
						$arrInsertFlightData[$keys][$key]['LAYOVERDuration'] = $LAYOVERTime;
						$arrInsertFlightData[$keys][$key]['FlyingMinutes'] = $FlyingMinutes;
						$arrInsertFlightData[$keys][$key]['DepartureDateTxt'] = date('D, d M', strtotime($OriginSegments['dt']));
						$arrInsertFlightData[$keys][$key]['ArrivalDateTxt'] = date('D, d M', strtotime($DestinationSegments['at']));
						$arrInsertFlightData[$keys][$key]['FlightDuration'] = $FlightDuration;
						$arrInsertFlightData[$keys][$key]['SourcePlaceSysId'] = $intSourceCityId;
						$arrInsertFlightData[$keys][$key]['DestPlaceSysId'] = $intDestinationCityId;
						$arrInsertFlightData[$keys][$key]['SourceAirportCode'] = $strSourceAirportCode;
						$arrInsertFlightData[$keys][$key]['DestAirportCode'] = $strDestinationAirportCode;
						$arrInsertFlightData[$keys][$key]['SourcePlaceName'] = $sourceCityText[0];
						$arrInsertFlightData[$keys][$key]['DestPlaceName'] = $destinationCityText[0];
						$arrInsertFlightData[$keys][$key]['StopCount'] = $StopCountTxt;
						$arrInsertFlightData[$keys][$key]['Stops'] = $Stops;
						$arrInsertFlightData[$keys][$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
						$arrInsertFlightData[$keys][$key]['TotalFlightMembers'] = $intMemberCount;
						$arrInsertFlightData[$keys][$key]['CurrencyType'] = $this->CurrencyId;
						$arrInsertFlightData[$keys][$key]['PublishedFare'] = ($PublishedFareReverse * $this->CurrencyRate);
						$arrInsertFlightData[$keys][$key]['PublishedFareTxt'] = number_format(($PublishedFareReverse * $this->CurrencyRate));
						$arrInsertFlightData[$keys][$key]['ApiResultIndex'] = $ResultIndex;
						$arrInsertFlightData[$keys][$key]['JourneyType'] = $intJourneyType;
						$arrInsertFlightData[$keys][$key]['TripType'] = $intTripType;
						$arrInsertFlightData[$keys][$key]['IsInternational'] = $interNationalSearch;
						$arrInsertFlightData[$keys][$key]['ICSourceSysId'] = 7;
						$arrInsertFlightData[$keys][$key]['strFlightRoute'] = $strFlightRoute;
						$arrInsertFlightData[$keys][$key]['logo'] = $filePath;
						$arrInsertFlightData[$keys][$key]['FairRules'] = $FairRulesArr;
						$arrInsertFlightData[$keys][$key]['RouteKey'] = $keys;
						$arrInsertFlightData[$keys][$key]['Segments'] = $arrSegments;

						$arrAirlineName[$keys][] = $strAirlineName;
						$AttPriceRange[$keys][] = $PublishedFareReverse * $this->CurrencyRate;
						$FiltStopCount[$keys][] = $StopCountTxt;
						$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
						$arrInsertFlightData[$keys][$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
						if ($FairRulesArr) {
							foreach ($FairRulesArr as $Fare) {
								$dddddddd[] = $Fare['PublishedFare'];
							}
						}
					}
				}
			}
			$arrAirlineName__ = [];
			if ($arrAirlineName) {
				foreach ($arrAirlineName as $key => $value) {
					$arrAirlineName__[] = array_values(array_unique($value));
				}
			}
			$FiltStopCount__ = [];
			if ($FiltStopCount) {
				foreach ($FiltStopCount as $key => $value) {
					$FiltStopCount__[] = array_values(array_unique($value));
				}
			}
			$AttPriceRange__ = [];
			if ($AttPriceRange) {
				foreach ($AttPriceRange as $key => $value) {
					$MinriceRange = (min(array_values(array_unique($value))));
					$MaxriceRange = (max(array_values(array_unique($value))));
					$AttPriceRange__[] = ['MinriceRange' => floor($MinriceRange), 'MaxriceRange' => floor($MaxriceRange)];
				}
			}
			$MinriceRange = (min($AttPriceRange));
			$MaxriceRange = (max($AttPriceRange));

			$MultiHead = [];
			$outboundArray = [];
			if ($sessionFlightSearchParams['source']) {
				foreach ($sessionFlightSearchParams['source'] as $sk => $source_) {
					$destination_ = isset($sessionFlightSearchParams['destination'][$sk]) ? explode(',', $sessionFlightSearchParams['destination'][$sk]) : '';
					$source_ = isset($source_) ? explode(',', $source_) : '';
					$departure_date_ = isset($sessionFlightSearchParams['departure_date'][$sk]) ? $sessionFlightSearchParams['departure_date'][$sk] : '';
					$MultiHead[] = array(
						'source' => $source_[0],
						'destination' => $destination_[0],
						'departure_date' => $departure_date_,
					);
					// $outboundArray[$sk] = array(
					// 	'source' => $source_[0],
					// 	'destination' => $destination_[0],
					// 	'departure_date' => $departure_date_,
					// );
					// $outboundArray[$sk]['FlightData'][$sk] = $arrInsertFlightData[$sk];
				}
			}
			//echo '<pre>';print_r(($outboundArray));
			//die;
			sort($FiltStopCount__);
			$data = array('outbound' => $arrInsertFlightData, 'inbound' => [], 'MultiHead' => $MultiHead, 'ReturnDateArr' => '', 'DepartDateArr' => '', 'source' => $source, 'destination' => $destination, 'source_city' => $source_city, 'destination_city' => $destination_city, 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute, 'CurrencyTitle' => $this->CurrencyTitle, 'arrAirlineName' => $arrAirlineName__, 'FiltStopCount' => $FiltStopCount__, 'ArrPriceUnique' => $AttPriceRange__, 'MinriceRange' => (ceil($MinriceRange) - 100), 'MaxriceRange' => (ceil($MaxriceRange) + 100));
			echo json_encode($data);
			exit;
		} else {
			$data = array('outbound' => [], 'inbound' => [], 'MultiHead' => [], 'source' => $source, 'destination' => $destination, 'source_city' => $source_city, 'destination_city' => $destination_city, 'route' => $strFlightRoute, 'interNationalSearch' => $interNationalSearch, 'arrAirlineName' => [], 'FiltStopCount' => [], 'ArrPriceUnique' => []);
			echo json_encode($data);
			exit;
		}
	}
	public function FlightDataMultiCityInterNational($apiResponse, $sessionFlightSearchParams, $getMarkupNew, $getAgencyMarkups)
	{

		$arrAirlineList = $this->getAirlineIdsAndCodeList();
		$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]);
		$sourceCityText = explode(',', $sessionFlightSearchParams['sourceCityText'][0]);
		$destinationCityText = explode(',', $sessionFlightSearchParams['destinationCityText'][0]);
		$AdditionalMarkup = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAdditionalMarkup();
		$faretypeArr = $AdditionalMarkup['faretypeArr'];
		// echo '<pre>';
		// print_r($sessionFlightSearchParams);die;
		$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($interNationalSearch)) && trim($interNationalSearch) == 1) {
			$intAirType = 2;
		} else {
			$intAirType = 1;
		}
		$MultiHead = [];
		if ($sessionFlightSearchParams['source']) {
			foreach ($sessionFlightSearchParams['source'] as $sk => $source_) {
				$sourceCityAirportCode = isset($sessionFlightSearchParams['sourceCityAirportCode'][$sk]) ? $sessionFlightSearchParams['sourceCityAirportCode'][$sk] : '';
				$destinationCityAirportCode = isset($sessionFlightSearchParams['destinationCityAirportCode'][$sk]) ? $sessionFlightSearchParams['destinationCityAirportCode'][$sk] : '';
				$destination_ = isset($sessionFlightSearchParams['destination'][$sk]) ? explode(',', $sessionFlightSearchParams['destination'][$sk]) : '';
				$source_ = isset($source_) ? explode(',', $source_) : '';
				$departure_date_ = isset($sessionFlightSearchParams['departure_date'][$sk]) ? $sessionFlightSearchParams['departure_date'][$sk] : '';
				$MultiHead[] = array(
					'source' => $source_[0],
					'destination' => $destination_[0],
					'soCode' => $sourceCityAirportCode,
					'deCode' => $destinationCityAirportCode,
					'departure_date' => $departure_date_,
				);
			}
		}
		$intJourneyType = 1;
		$intTripType = 3;
		$arrInsertFlightData = [];
		$arrAirlineName = [];
		$FiltStopCount = [];
		$FiltPriceRange = [];
		$AttPriceRange = [];
		$dddddddd = [];
		$FilterData = [];
		$arrAirlineName = [];
		$FiltStopCount = [];
		$intResponseStatus = $apiResponse['ResponseStatus'];
		$ONWARD = $apiResponse['OutBoundFlightResults'];

		// print_r($sessionFlightSearchParams);
		// die;
		if ($intResponseStatus == 1) {
			if ($ONWARD) {
				foreach ($ONWARD as $keys => $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'];
					$ApiResultIndex = $totalPriceList['id'];
					$Refundable = $totalPriceList['ADULT']['rT'];
					if ($Refundable == 0) {
						$IsRefundableTxt = 'Non Refundable';
					} elseif ($Refundable == 1) {
						$IsRefundableTxt = 'Refundable';
					} else {
						$IsRefundableTxt = 'Partial Refundable';
					}
					$ArrivalArr = [];
					$departureArr = [];
					$arrSegments = [];
					if ($SegmentInformation) {
						$tp = 0;
						foreach ($SegmentInformation as $k => $Segmentsss) {
							$segments = $Segmentsss;
							$duration = $segments['duration'];
							$LAYOVERMinutes = $GroundTime = isset($segments['cT']) ? $segments['cT'] : 0;
							$LAYOVERCity = $LAYOVERCityArr[] = isset($segments['cT']) ? $segments['aa']['city'] : '';

							$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;
							}
							$Stops = $segments['sN'];
							if ($Stops == 0) {
								$OrStopCountTxt = "Non-stop";
							} else {
								$OrStopCountTxt = $Stops . " Stop(s)";
							}

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

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

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

							$isReturnSegment = false;

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

							$ConectingTime = isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0;
							$SegmentNumber = isset($Segmentsss['sN']) ? $Segmentsss['sN'] : false;

							$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[$k] = 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,
								"IsRefundableTxt" => $IsRefundableTxt,
								"StopCountTxt" => $OrStopCountTxt,
								"SegmentNumber" => $SegmentNumber,
								"ConectingTime" => $ConectingTime,
								"filePath" => $filePath,
							);

							if ($ConectingTime == 0 && $SegmentNumber == 1) {
								$ArrivalArr[$k] = array(
									'fD' => $Segmentsss['fD'],
									'oB' => $Segmentsss['oB'],
									'stops' => $Segmentsss['stops'],
									'so' => $Segmentsss['so'],
									'duration' => $Segmentsss['duration'],
									//'da' => $Segmentsss['da'],
									'aa' => $Segmentsss['aa'],
									//'dt' => $Segmentsss['dt'],
									'at' => $Segmentsss['at'],
									'iand' => $Segmentsss['iand'],
									'cT' => isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0,
									'sN' => $Segmentsss['sN'],
								);
							} elseif ($ConectingTime == 0 && $SegmentNumber == 2) {
								$ArrivalArr[$k] = array(
									'fD' => $Segmentsss['fD'],
									'oB' => $Segmentsss['oB'],
									'stops' => $Segmentsss['stops'],
									'so' => $Segmentsss['so'],
									'duration' => $Segmentsss['duration'],
									//'da' => $Segmentsss['da'],
									'aa' => $Segmentsss['aa'],
									//'dt' => $Segmentsss['dt'],
									'at' => $Segmentsss['at'],
									'iand' => $Segmentsss['iand'],
									'cT' => isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0,
									'sN' => $Segmentsss['sN'],
								);
							} elseif ($ConectingTime == 0 && $SegmentNumber == 3) {
								$ArrivalArr[$k] = array(
									'fD' => $Segmentsss['fD'],
									'oB' => $Segmentsss['oB'],
									'stops' => $Segmentsss['stops'],
									'so' => $Segmentsss['so'],
									'duration' => $Segmentsss['duration'],
									//'da' => $Segmentsss['da'],
									'aa' => $Segmentsss['aa'],
									//'dt' => $Segmentsss['dt'],
									'at' => $Segmentsss['at'],
									'iand' => $Segmentsss['iand'],
									'cT' => isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0,
									'sN' => $Segmentsss['sN'],
								);
							} elseif ($ConectingTime == 0 && $SegmentNumber == 4) {
								$ArrivalArr[$k] = array(
									'fD' => $Segmentsss['fD'],
									'oB' => $Segmentsss['oB'],
									'stops' => $Segmentsss['stops'],
									'so' => $Segmentsss['so'],
									'duration' => $Segmentsss['duration'],
									//'da' => $Segmentsss['da'],
									'aa' => $Segmentsss['aa'],
									//'dt' => $Segmentsss['dt'],
									'at' => $Segmentsss['at'],
									'iand' => $Segmentsss['iand'],
									'cT' => isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0,
									'sN' => $Segmentsss['sN'],
								);
							} elseif ($ConectingTime == 0 && $SegmentNumber == 0) {
								$ArrivalArr[$k] = array(
									'fD' => $Segmentsss['fD'],
									'oB' => $Segmentsss['oB'],
									'stops' => $Segmentsss['stops'],
									'so' => $Segmentsss['so'],
									'duration' => $Segmentsss['duration'],
									//'da' => $Segmentsss['da'],
									'aa' => $Segmentsss['aa'],
									//'dt' => $Segmentsss['dt'],
									'at' => $Segmentsss['at'],
									'iand' => $Segmentsss['iand'],
									'cT' => isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0,
									'sN' => $Segmentsss['sN'],
								);
							}
							if ($SegmentNumber == 0) { // departure
								$departureArr[$k] = array(
									'fD' => $Segmentsss['fD'],
									'oB' => $Segmentsss['oB'],
									'stops' => $Segmentsss['stops'],
									'so' => $Segmentsss['so'],
									'duration' => $Segmentsss['duration'],
									'da' => $Segmentsss['da'],
									//'aa' => $Segmentsss['aa'],
									'dt' => $Segmentsss['dt'],
									//'at' => $Segmentsss['at'],
									'iand' => $Segmentsss['iand'],
									'cT' => isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0,
									'sN' => $Segmentsss['sN'],
								);
							}
						}
					}

					if (!empty($bagInfo)) {
						$IsBagIncludes = true;
					} else {
						$IsBagIncludes = false;
					}
					if ($IsRefundable == 0) {
						$IsRefundableTxt = 'Non Refundable';
					} elseif ($IsRefundable == 1) {
						$IsRefundableTxt = 'Refundable';
					} else {
						$IsRefundableTxt = 'Partial Refundable';
					}
					$arrv = array_values($ArrivalArr);
					$depa = array_values($departureArr);
					$FlightData = [];


					if ($depa) {
						foreach ($depa as $sk => $depval) {
							$arrival = isset($arrv[$sk]) ? $arrv[$sk] : '';
							// echo '<pre>';
							// print_r([$depval,$arrival]);
							// echo '</pre>';
							$LAYOVERMinutes = $GroundTime = isset($arrival['cT']) ? $depval['cT'] : 0;
							$LAYOVERTimeO = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($LAYOVERMinutes);
							if ($depval['cT']) {
								$TotalDurationOnward = $FlyingMinutesO = ($depval['cT'] + $arrival['cT'] + $depval['duration'] + $arrival['duration']);
							} else {
								$TotalDurationOnward = $FlyingMinutesO = ($depval['duration']);
							}
							$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($TotalDurationOnward);
							$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($arrival['at']);
							$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($depval['dt']);
							$Stops = $arrival['sN'];
							if ($Stops == 0) {
								$OrStopCountTxt = "Non-stop";
							} else {
								$OrStopCountTxt = $Stops . " Stop(s)";
							}
							$AirlineCode = $depval['fD']['aI']['code'];
							$FlightNumber = $depval['fD']['fN'];
							$strAirlineName = $depval['fD']['aI']['name'];
							$OrFlightNumber = $AirlineCode . '-' . $FlightNumber;
							$IsLCC = $depval['fD']['aI']['isLcc'];
							$strSourceAirportCode = $depval['da']['code'];
							$strDestinationAirportCode = $arrival['aa']['code'];
							$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
							$filePath = $this->getflightlogo($AirlineCode);
							$deFlightNumber = $arrival['fD']['aI']['code'] . '-' . $arrival['fD']['fN'];
							if ($depval['cT']) {
								$SegFlightNumberArr = [$OrFlightNumber, $deFlightNumber];
							} else {
								$SegFlightNumberArr = [$OrFlightNumber];
							}

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


							$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
							$FilterArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strArrivalDtTime);
							$FlightData[$sk]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
							$FlightData[$sk]['FilterArrivalDtTime'] = $FilterArrivalDtTime;
							// $FilterData[$sk]['SourceAirportCode'] = $strSourceAirportCode;
							// $FilterData[$sk]['DestAirportCode'] = $strDestinationAirportCode;
							// $FilterData[$sk]['strAirlineName'] = $AirlineCode . '-' . $strAirlineName;
							// $FilterData[$sk]['strStopCountTxt'] = $OrStopCountTxt;
							// $FilterData[] = array(
							// 	'SourceAirportCode' => $strSourceAirportCode,
							// 	'DestAirportCode' => $strDestinationAirportCode,
							// 	'strAirlineName' => $AirlineCode . '-' . $strAirlineName,
							// 	'FilterDepartureDtTime' => $FilterDepartureDtTime,
							// 	'FilterArrivalDtTime' => $FilterArrivalDtTime,
							// 	'strStopCountTxt' => $OrStopCountTxt,
							// );

							$arrAirlineName[] = $AirlineCode . '-' . $strAirlineName;
							$FiltStopCount[] = $OrStopCountTxt;
						}
					}
					$PublishedFare = 0;
					$PublishedFareReverse = 0;
					$BaseFare = 0;
					$Tax = 0;
					$YQTax = 0;
					$OtherCharges = 0;
					$ServiceFee = 0;
					$FareBreakdown = [];
					$FairRulesArr = [];
					$array_searcher = $this->array_searcher($faretypeArr, $result['totalPriceList']);
					array_multisort($array_searcher);
					if ($array_searcher) {
						foreach ($array_searcher 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'];
							$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$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
							if (!empty($ADULT)) {
								$PaxTypeCount = 1;
							}
							if (!empty($CHILD)) {
								$PaxTypeCount = 2;
							}
							if (!empty($INFANT)) {
								$PaxTypeCount = 3;
							}
							$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
							$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
							$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents

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

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

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

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

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

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

							$PublishedFareIN = (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
							$BaseFareIN = (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
							$TaxIN = (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
							$NetFare = (($ADULT['NF'] * $adultCount) + ($CHILD['NF'] * $childCount) + ($INFANT['NF'] * $infantCount)); //Taxes and Fees
							$NetCommission = (($ADULT['NCM'] * $adultCount) + ($CHILD['NCM'] * $childCount) + ($INFANT['NCM'] * $infantCount)); //Taxes and Fees
							//echo '<pre>';print_r(($ADULTafC));echo '</pre>';
							$YQTax = (($AD_YQ * $adultCount) + ($CH_YQ * $childCount) + ($IN_YQ * $infantCount));
							$OtherCharges = (($AD_OT * $adultCount) + ($CH_OT * $childCount) + ($IN_OT * $infantCount));
							$ServiceFee = (($AD_MF * $adultCount) + ($CH_MF * $childCount) + ($IN_MF * $infantCount));
							$ManagementFeeTax = (($AD_MFT * $adultCount) + ($CH_MFT * $childCount) + ($IN_MFT * $infantCount));
							$AirlineGSTComponent = (($AD_AGST * $adultCount) + ($CH_AGST * $childCount) + ($IN_AGST * $infantCount));
							$CarrierMiscFee = (($AD_YR * $adultCount) + ($CH_YR * $childCount) + ($IN_YR * $infantCount));
							$MUFee = (($AD_MU * $adultCount) + ($CH_MU * $childCount) + ($IN_MU * $infantCount));
							$TdsOnPLB = (($ADULTNCMTDS * $adultCount) + ($CHILDNCMTDS * $childCount) + ($INFANTNCMTDS * $infantCount));
							//$NetCommission = (($ADULTNCMTOT * $adultCount) + ($CHILDNCMTOT * $childCount) + ($INFANTNCMTOT * $infantCount));
							$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(
								'getMarkupNew' => $getMarkupNew,
								'getAgencyMarkups' => $getAgencyMarkups,
								'PublishedFare' => $PublishedFare,
								'OfferedFare' => $OfferedFare,
								'intCommissionEarned' => $CommissionEarned,
								'TdsOnPLB' => $TdsOnPLB,
								'MUFee' => $MUFee,
								'intPLBEarned' => $PLBEarned,
								'intIncentiveEarned' => $IncentiveEarned,
								'intMemberCount' => $intMemberCount,
								'intFlightRoute' => $strFlightRoute,
								'interNationalSearch' => $interNationalSearch,
								'AddMarkup' => $AddMarkup,
							);
							//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(
								'getMarkupNew' => $getMarkupNew,
								'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,
								'AddMarkup' => $AddMarkup,
							);
							$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) + ($arrMarkUpsBR['IntAdddimarkup'] / $PaxTypeCount));
							$FareBreakdown[0]['MU'] = ($AD_MU * $adultCount);
							$FareBreakdown[0]['YR'] = ($AD_YR * $adultCount);
							$FareBreakdown[0]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
							$FareBreakdown[0]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
							$FareBreakdown[0]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
							$FareBreakdown[0]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
							$FareBreakdown[0]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
							$FareBreakdown[0]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
							$FareBreakdown[0]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
							$FareBreakdown[0]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
							$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
							$FareBreakdown[0]['GSTonComm'] = 0;
							$FareBreakdown[0]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
							$FareBreakdown[0]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
							$FareBreakdown[0]['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(
									'getMarkupNew' => $getMarkupNew,
									'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,
									'AddMarkup' => $AddMarkup,
								);
								$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) + ($arrMarkUpsBR['IntAdddimarkup'] / $PaxTypeCount));
								$FareBreakdown[1]['MU'] = ($CH_MU * $childCount);
								$FareBreakdown[1]['YR'] = ($CH_YR * $childCount);
								$FareBreakdown[1]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
								$FareBreakdown[1]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
								$FareBreakdown[1]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
								$FareBreakdown[1]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
								$FareBreakdown[1]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
								$FareBreakdown[1]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
								$FareBreakdown[1]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
								$FareBreakdown[1]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
								$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
								$FareBreakdown[1]['GSTonComm'] = 0;
								$FareBreakdown[1]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
								$FareBreakdown[1]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
								$FareBreakdown[1]['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(
									'getMarkupNew' => $getMarkupNew,
									'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,
									'AddMarkup' => $AddMarkup,
								);
								$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) + ($arrMarkUpsBR['IntAdddimarkup'] / $PaxTypeCount));
								$FareBreakdown[2]['MFT'] = ($IN_MFT * $infantCount);
								$FareBreakdown[2]['MU'] = ($IN_MU * $infantCount);
								$FareBreakdown[2]['YR'] = ($IN_YR * $infantCount);
								$FareBreakdown[2]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
								$FareBreakdown[2]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
								$FareBreakdown[2]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
								$FareBreakdown[2]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
								$FareBreakdown[2]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
								$FareBreakdown[2]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
								$FareBreakdown[2]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
								$FareBreakdown[2]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
								$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
								$FareBreakdown[2]['GSTonComm'] = 0;
								$FareBreakdown[2]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
								$FareBreakdown[2]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
								$FareBreakdown[2]['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,
								"ApiResultIndex" => $PriceID,
								"IsGSTRequired" => $IsGSTRequired,
								"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
								"fareIdentifierSP" => $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'],
								"AddiTaxOnMarkup" => $arrMarkUps['AddiTaxOnMarkup'],
								"AddiMarkup" => $arrMarkUps['AddiMarkup'],

								"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,
							);
						}
					}
					if ($SegmentInformation) {
						foreach ($SegmentInformation as $segments) {
						}
					}
					$arrInsertFlightData[$keys]['PublishedFare'] = ($PublishedFareReverse * $this->CurrencyRate);
					$arrInsertFlightData[$keys]['AirlineName'] = $strAirlineName;
					$arrInsertFlightData[$keys]['DepartureTime'] = $strDepartureDtTime;
					$arrInsertFlightData[$keys]['FlyingMinutes'] = $FlightDuration;
					$arrInsertFlightData[$keys]['ArrivalTime'] = $strArrivalDtTime;
					$arrInsertFlightData[$keys]['JourneyType'] = $intJourneyType;
					$arrInsertFlightData[$keys]['TripType'] = $intTripType;
					$arrInsertFlightData[$keys]['IsInternational'] = $interNationalSearch;
					$arrInsertFlightData[$keys]['ICSourceSysId'] = 7;
					$arrInsertFlightData[$keys]['ApiResultIndex'] = $ApiResultIndex;
					$arrInsertFlightData[$keys]['SearchTraceId'] = $FlightTraceId;
					$arrInsertFlightData[$keys]['FairRules'] = $FairRulesArr;
					$arrInsertFlightData[$keys]['Segments'] = $arrSegments;
					$arrInsertFlightData[$keys]['FlightData'] = $FlightData;
					$arrInsertFlightData[$keys]['MultiHead'] = $MultiHead;
					if ($FairRulesArr) {
						foreach ($FairRulesArr as $Fare) {
							$dddddddd[] = $Fare['PublishedFareAgent'];
						}
					}
				}
			}
			$FiltStopCount = array_values(array_unique($FiltStopCount));
			$arrAirlineName = array_values(array_unique($arrAirlineName));
			//echo '<pre>';
			//print_r((($arrAirlineName)));
			//print_r(json_encode(array_values($arrInsertFlightData)));
			//echo '</pre>';
			//die;

			$AttPriceRange__ = [];

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

			sort($FiltStopCount);
			$data = array('outbound' => $arrInsertFlightData, 'inbound' => [], 'MultiHead' => $MultiHead, 'ReturnDateArr' => '', 'DepartDateArr' => '', 'source' => $source, 'destination' => $destination, 'source_city' => $source_city, 'destination_city' => $destination_city, 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute, 'CurrencyTitle' => $this->CurrencyTitle, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'ArrPriceUnique' => $AttPriceRange__, 'MinriceRange' => (ceil($MinriceRange) - 100), 'MaxriceRange' => (ceil($MaxriceRange) + 100));
			echo json_encode($data);
			exit;
		} else {
			$data = array('outbound' => [], 'inbound' => [], 'MultiHead' => [], 'source' => $source, 'destination' => $destination, 'source_city' => $source_city, 'destination_city' => $destination_city, 'route' => $strFlightRoute, 'interNationalSearch' => $interNationalSearch, 'arrAirlineName' => [], 'FiltStopCount' => [], 'ArrPriceUnique' => []);
			echo json_encode($data);
			exit;
		}
	}
	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]);
		$sourceCityText = explode(',', $sessionFlightSearchParams['sourceCityText'][0]);
		$destinationCityText = explode(',', $sessionFlightSearchParams['destinationCityText'][0]);
		$travelDates = $sessionFlightSearchParams['strDepatureDate'][0];
		$IsChangeSearch = $sessionFlightSearchParams['IsChangeSearch'];


		$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 ($strFlightRoute == 1 && $strFlightRoute != 4) {
			$sessionFlightSearchParams['from_city_'][0] = '1__' . $source_city . '-' . $destination_city;
		} elseif ($strFlightRoute == 2 && $strFlightRoute != 4) {
			$sessionFlightSearchParams['from_city_'][0] = '2__' . $source_city . '-' . $destination_city . '-' . $source_city;
		}
		$SearchTime = $sessionFlightSearchParams['SearchTime'];
		$CurrentTime = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
		$SearchInterval = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->SearchInterval($SearchTime, $CurrentTime);

		// echo '<pre>';
		// print_r(($SearchInterval));die;
		if (!empty(trim($interNationalSearch)) && trim($interNationalSearch) == 1) {
			$intAirType = 2;
		} else {
			$intAirType = 1;
		}
		$begin = new DateTime($sessionFlightSearchParams['strDepatureDate'][0]);
		//$begin = new DateTime(date('Y-m-d'));
		$end = new DateTime($sessionFlightSearchParams['strDepatureDate'][0]);
		if ($strFlightRoute == 2 && $interNationalSearch == '') {
			$end = $end->modify('+30 day');
		} else {
			$end = $end->modify('+30 day');
		}

		$interval = new DateInterval('P1D');
		$daterange = new DatePeriod($begin, $interval, $end);
		$DepartDateArr = [];
		foreach ($daterange as $date) {
			$DepartDateArr[] = ['formatDate' => $date->format("Y-m-d"), 'depDate' => $date->format("d/m/Y")];
		}

		$beginR = new DateTime($sessionFlightSearchParams['strReturnDate'][0]);
		$endR = new DateTime($sessionFlightSearchParams['strReturnDate'][0]);
		if ($strFlightRoute == 2 && $interNationalSearch == '') {
			$endR = $endR->modify('+30 day');
		} else {
			$endR = $endR->modify('+30 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();
			$getMarkupNew = $this->getMarkupNew();
			$AdditionalMarkup = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAdditionalMarkup();
			$faretypeArr = $AdditionalMarkup['faretypeArr'];
			$all_data = $AdditionalMarkup['finalArr'];
			$get_column_value = array_column($all_data, 'ApiRoundTrip');
			$ApiRoundTrip = $get_column_value[0];

			$getAgencyMarkups = $objMarkup->getAgencyMarkups($intAirType, $this->gtxagencysysid);
			$FlightDataSeriesFare = [];
			if ($strFlightRoute == 4) {
				$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsSeriesFare($sessionFlightSearchParams);

				$FlightDataSeriesFare = $this->FlightDataSeriesFare($apiResponse, $sessionFlightSearchParams);
				echo json_encode($FlightDataSeriesFare);
				exit;
			}


			if ($this->IsBOTHFlightAPI) {
				$apiResponseTBO = [];
				$apiResponse = [];
				if ($strFlightRoute == 2) {
					if ($ApiRoundTrip == 3) {

						$apiResponseTBO = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlights($sessionFlightSearchParams, $this->gtxagencysysid);
					} else {
						$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsTripjack($sessionFlightSearchParams);
					}
				} else {
					$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsTripjack($sessionFlightSearchParams);
					$apiResponseTBO = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlights($sessionFlightSearchParams, $this->gtxagencysysid);
				}

				$MergeRequest = (array_merge($apiResponse, $apiResponseTBO));
				$MergeRequest['sessionFlightSearchParams'] = $sessionFlightSearchParams;
				// echo '<pre>';
				// print_r(($MergeRequest));
				// echo '<pre>';
				// print_r(($sessionFlightSearchParams));
				// die;
				$multiRequest = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->multiRequest($MergeRequest);

				$apiResponse = (isset($multiRequest['TPJ']) && !empty($multiRequest['TPJ'])) ? $multiRequest['TPJ'] : [];
				$apiResponseTBO = (isset($multiRequest['TBO']) && !empty($multiRequest['TBO'])) ? $multiRequest['TBO'] : [];
				$FlightDataTBO = $this->FlightDataTBO($apiResponseTBO, $sessionFlightSearchParams, []);
			} elseif ($this->IsTJFlightAPI) {
				$apiResponseSF = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsSeriesFare($sessionFlightSearchParams);
				if (!empty($apiResponseSF)) {
					$FlightDataSeriesFare = $this->FlightDataSeriesFare($apiResponseSF, $sessionFlightSearchParams, 1);
				}
				if (($SearchInterval['h'] == 0 && $SearchInterval['m'] >= 13) || $IsChangeSearch == 1) {
					$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsTripjack($sessionFlightSearchParams);
				} else {
					$FlightSearchResultsTJ = new Zend_Session_Namespace('FlightSearchResultsTJ');
					$apiResponse = $FlightSearchResultsTJ->params;
					//echo"<pre>";print_r($apiResponse);die();
					$intResponseStatusTJ = !empty($apiResponse['ResponseStatus']) ? $apiResponse['ResponseStatus'] : 0;
					if ($intResponseStatusTJ == 1) {
						$FlightSearchResultsTJ = new Zend_Session_Namespace('FlightSearchResultsTJ');
						$apiResponse = $FlightSearchResultsTJ->params;
					} else {
						$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsTripjack($sessionFlightSearchParams);
					}
				}
			} else { /// For TBO Search

				$apiResponseSF = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsSeriesFare($sessionFlightSearchParams);

				if (!empty($apiResponseSF)) {
					$FlightDataSeriesFare = $this->FlightDataSeriesFare($apiResponseSF, $sessionFlightSearchParams, 1);
				}

				if (($SearchInterval['h'] == 0 && $SearchInterval['m'] >= 13) || $IsChangeSearch == 1) {
					$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlights($sessionFlightSearchParams, $this->gtxagencysysid);
				} else {
					$FlightSearchResults = new Zend_Session_Namespace('FlightSearchResults');
					$apiResponse = $FlightSearchResults->params;
					$intResponseStatus = !empty($apiResponse['ResponseStatus']) ? $apiResponse['ResponseStatus'] : 0;
					if ($intResponseStatus == 1) {
						$FlightSearchResults = new Zend_Session_Namespace('FlightSearchResults');
						$apiResponse = $FlightSearchResults->params;
					} else {
						$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlights($sessionFlightSearchParams, $this->gtxagencysysid);
					}
				}

				$FlightDataTBO = $this->FlightDataTBO($apiResponse, $sessionFlightSearchParams, $FlightDataSeriesFare);
				echo json_encode($FlightDataTBO);
				exit;
			}
			if ($strFlightRoute == 3) {
				$FlightDataMultiCity = $this->FlightDataMultiCity($apiResponse, $sessionFlightSearchParams, $getMarkupNew, $getAgencyMarkups);
			}
			$intJourneyType = 1;
			$intTripType = 1;
			$arrInsertFlightData = [];
			$arrAirlineName = [];
			$FiltStopCount = [];
			$FiltPriceRange = [];
			$AttPriceRange = [];
			$dddddddd = [];
			$intResponseStatus = !empty($apiResponse['ResponseStatus']) ? $apiResponse['ResponseStatus'] : $apiResponseTBO['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_searcher = $this->array_searcher($faretypeArr, $result['totalPriceList']);
						array_multisort($array_searcher);
						if ($array_searcher) {
							foreach ($array_searcher 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'];
								$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$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

								if (!empty($ADULT)) {
									$PaxTypeCount = 1;
								}
								if (!empty($CHILD)) {
									$PaxTypeCount = 2;
								}
								if (!empty($INFANT)) {
									$PaxTypeCount = 3;
								}

								$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
								$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
								$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents

								$ADULTNCMTDS = 0; //isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
								$CHILDNCMTDS = 0; //isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
								$INFANTNCMTDS = 0; //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(
									'getMarkupNew' => $getMarkupNew,
									'getAgencyMarkups' => $getAgencyMarkups,
									'PublishedFare' => $PublishedFare,
									'OfferedFare' => $OfferedFare,
									'intCommissionEarned' => $CommissionEarned,
									'TdsOnPLB' => $TdsOnPLB,
									'MUFee' => $MUFee,
									'intPLBEarned' => $PLBEarned,
									'intIncentiveEarned' => $IncentiveEarned,
									'intMemberCount' => $intMemberCount,
									'intFlightRoute' => $strFlightRoute,
									'interNationalSearch' => $interNationalSearch,
									'AddMarkup' => $AddMarkup,
								);

								$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArr);
								//echo '<pre>';print_r($arrMarkUps);die;
								if ($kp == 0) {
									$PublishedFareReverse += ($arrMarkUps['PublishFare']);
								}
								$TdsOnPLBCal = isset($ADULTNCMTDS) ? str_replace('-', '', $ADULTNCMTDS) : 0;
								$markUpArrBR = array(
									'getMarkupNew' => $getMarkupNew,
									'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,
									'AddMarkup' => $AddMarkup,
								);
								$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]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
								$FareBreakdown[0]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
								$FareBreakdown[0]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
								$FareBreakdown[0]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
								$FareBreakdown[0]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
								$FareBreakdown[0]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
								$FareBreakdown[0]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
								$FareBreakdown[0]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
								//$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
								$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['IntCommission'];
								$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(
										'getMarkupNew' => $getMarkupNew,
										'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,
										'AddMarkup' => $AddMarkup,
									);
									$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]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
									$FareBreakdown[1]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
									$FareBreakdown[1]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
									$FareBreakdown[1]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
									$FareBreakdown[1]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
									$FareBreakdown[1]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
									$FareBreakdown[1]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
									$FareBreakdown[1]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
									//$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
									$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['IntCommission'];
									$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(
										'getMarkupNew' => $getMarkupNew,
										'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,
										'AddMarkup' => $AddMarkup,
									);
									$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]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
									$FareBreakdown[2]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
									$FareBreakdown[2]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
									$FareBreakdown[2]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
									$FareBreakdown[2]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
									$FareBreakdown[2]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
									$FareBreakdown[2]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
									$FareBreakdown[2]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
									//$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
									$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['IntCommission'];
									$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,
									"ApiResultIndex" => $PriceID,
									"IsGSTRequired" => $IsGSTRequired,
									"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
									"fareIdentifierSP" => $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'],
									"CommEarned" => $arrMarkUps['IntCommission'],
									"CommEarnedAgent" => $arrMarkUps['AgentB2CEarning'],
									"GSTonComm" => 0,
									"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
									"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
									"AddiTaxOnMarkup" => $arrMarkUps['AddiTaxOnMarkup'],
									"AddiMarkup" => $arrMarkUps['AddiMarkup'],

									"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;
						$SegFlightNumberArr = [];
						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,
								);
								$SegFlightNumberArr[] = $SegFlightNumber;
								//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';
						if (!empty($FairRulesArr)) {
							$arrInsertFlightData[$key]['FlightNumber'] = $strFlightNumber;
							$arrInsertFlightData[$key]['SegFlightNumberArr'] = implode(', ', $SegFlightNumberArr);
							$arrInsertFlightData[$key]['AirlineName'] = $strAirlineName;
							$arrInsertFlightData[$key]['AirlineCode'] = $AirlineCode;
							$arrInsertFlightData[$key]['IsTJFlightAPI'] = $this->IsTJFlightAPI;
							$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]['SourcePlaceName'] = $sourceCityText[0];
							$arrInsertFlightData[$key]['DestPlaceName'] = $destinationCityText[0];
							$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]['ICSourceSysId'] = 7;
							$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);
							$FilterArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strArrivalDtTime);
							$arrInsertFlightData[$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
							$arrInsertFlightData[$key]['FilterArrivalDtTime'] = $FilterArrivalDtTime;
							$arrInsertFlightData[$key]['IsSeriesFareData'] = false;
							if ($FairRulesArr) {
								foreach ($FairRulesArr as $Fare) {
									$dddddddd[] = $Fare['PublishedFare'];
								}
							}
						}
					}
				}

				$RoundTrip = $this->FlightDataRoundTripJack($apiResponse, $sessionFlightSearchParams);
				$dddddddd = array_merge($dddddddd, $RoundTrip['dddddddd']);

				sort($dddddddd);
				if (isset($FlightDataSeriesFare['arrAirlineName']) && !empty($FlightDataSeriesFare['arrAirlineName'])) {
					$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, $RoundTrip['arrAirlineName'], $FlightDataSeriesFare['arrAirlineName'])));
				} else {
					$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, $RoundTrip['arrAirlineName'])));
				}
				if (isset($FlightDataTBO['arrAirlineName']) && !empty($FlightDataTBO['arrAirlineName']) && $ApiRoundTrip == 3 && $strFlightRoute == 2) {
					$arrAirlineName = array_values(array_unique($FlightDataTBO['arrAirlineName']));
				} elseif (isset($FlightDataTBO['arrAirlineName']) && !empty($FlightDataTBO['arrAirlineName'])){
					$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, $RoundTrip['arrAirlineName'], $FlightDataTBO['arrAirlineName'])));
				}else{
					$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, $RoundTrip['arrAirlineName'])));
				}

				if (isset($FlightDataSeriesFare['FiltStopCount']) && !empty($FlightDataSeriesFare['FiltStopCount'])) {
					$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, $RoundTrip['FiltStopCount'], $FlightDataSeriesFare['FiltStopCount'])));
				} else {
					$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, $RoundTrip['FiltStopCount'])));
				}
				if (isset($FlightDataTBO['FiltStopCount']) && !empty($FlightDataTBO['FiltStopCount']) && $ApiRoundTrip == 3) {
					$FiltStopCount = array_values(array_unique($FlightDataTBO['FiltStopCount']));
				} elseif (isset($FlightDataTBO['FiltStopCount']) && !empty($FlightDataTBO['FiltStopCount'])) {
					$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, $RoundTrip['FiltStopCount'], $FlightDataTBO['FiltStopCount'])));
				}else{
					$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, $RoundTrip['FiltStopCount'])));
				}
				
				if (isset($FlightDataSeriesFare['AttPriceRange']) && !empty($FlightDataSeriesFare['AttPriceRange'])) {
					$MinriceRange = (min(array_merge($AttPriceRange, $RoundTrip['AttPriceRange'], $FlightDataSeriesFare['AttPriceRange'])));
					$MaxriceRange = (max(array_merge($AttPriceRange, $RoundTrip['AttPriceRange'], $FlightDataSeriesFare['AttPriceRange'])));
				} elseif (isset($FlightDataTBO['inbound']) && !empty($FlightDataTBO['inbound']) && $ApiRoundTrip == 3 && $strFlightRoute == 2) {
					$MinriceRange = (($FlightDataTBO['MinriceRange']));
					$MaxriceRange = (($FlightDataTBO['MaxriceRange']));
				} else {
					$MinriceRange = (min(array_merge($AttPriceRange, $RoundTrip['AttPriceRange'])));
					$MaxriceRange = (max(array_merge($AttPriceRange, $RoundTrip['AttPriceRange'])));
				}
				// echo '<pre>';
				// print_r($FlightDataTBO);die;
				// sort($FiltStopCount);

				if (!empty($FlightDataSeriesFare['outbound'])) {
					$arrInsertFlightData = array_values(array_merge($arrInsertFlightData, $FlightDataSeriesFare['outbound']));
				}
				if (isset($FlightDataTBO['outbound']) && !empty($FlightDataTBO['outbound'])) {
					$arrInsertFlightData = array_values(array_merge($arrInsertFlightData, $FlightDataTBO['outbound']));
				}
				if (isset($FlightDataTBO['inbound']) && !empty($FlightDataTBO['inbound']) && $ApiRoundTrip == 3 && $strFlightRoute == 2) {
					$RoundTripinbound = array_values($FlightDataTBO['inbound']);
					//$RoundTrip['inbound'] =  $FlightDataTBO['inbound'];	
				} else {
					$RoundTripinbound = array_values($RoundTrip['inbound']);
				}


				if ($interNationalSearch == 1 && $strFlightRoute == 2) {

					$RoundInterTrip = $this->FlightDataRoundTripInternational($apiResponse, $sessionFlightSearchParams);
					//echo '<pre>';print_r($RoundInterTrip);die;
					$MinriceRange = (min($RoundInterTrip['AttPriceRange']) - 200);
					$MaxriceRange = (max($RoundInterTrip['AttPriceRange']));
					$data = array('outbound' => $RoundInterTrip['outbound'], 'DepartDateArr' => $DepartDateArr, 'travelDates' => $travelDates, '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' => (ceil($MinriceRange) - 100), 'MaxriceRange' => (ceil($MaxriceRange) + 100));
				} else {

					$data = array('outbound' => array_values($arrInsertFlightData), 'travelDates' => $travelDates, 'inbound' => $RoundTripinbound, 'ReturnDateArr' => $ReturnDateArr, 'DepartDateArr' => $DepartDateArr, 'source' => $source, 'destination' => $destination, 'source_city' => $source_city, 'destination_city' => $destination_city, 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute, 'CurrencyTitle' => $this->CurrencyTitle, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'MinriceRange' => (ceil($MinriceRange) - 100), 'MaxriceRange' => (ceil($MaxriceRange) + 100));
				}
				echo json_encode($data);
				exit;
			} else {
				$data = array('outbound' => [], 'inbound' => [], 'travelDates' => $travelDates, 'source' => $source, 'destination' => $destination, 'source_city' => $source_city, 'destination_city' => $destination_city, 'route' => $strFlightRoute, 'interNationalSearch' => $interNationalSearch, 'arrAirlineName' => [], 'FiltStopCount' => [], 'ArrPriceUnique' => [], 'CurrencyTitle' => $this->CurrencyTitle, 'MinriceRange' => 0, 'MaxriceRange' => 0);
				echo json_encode($data);
				exit;
			}
			///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']);
		$sourceCityText = explode(',', $sessionFlightSearchParams['sourceCityText'][0]);
		$destinationCityText = explode(',', $sessionFlightSearchParams['destinationCityText'][0]);
		$intTatalPaxCT = $adultCount + $childCount;
		//$getMarkup = $this->getMarkup($intCountryCode);
		$getMarkupNew = $this->getMarkupNew();
		$AdditionalMarkup = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAdditionalMarkup();
		$faretypeArr = $AdditionalMarkup['faretypeArr'];
		if (!empty(trim($interNationalSearch)) && trim($interNationalSearch) == 1) {
			$intAirType = 2;
		} else {
			$intAirType = 1;
		}
		$objMarkup = new Travel_Model_Markup();
		$getAgencyMarkups = $objMarkup->getAgencyMarkups($intAirType, $this->gtxagencysysid);
		$arrAirlineList = $this->getAirlineIdsAndCodeList();
		$apiResponseSF = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsSeriesFare($sessionFlightSearchParams, 'roundtrip');
		if (!empty($apiResponseSF)) {
			$FlightDataSeriesFare = $this->FlightDataSeriesFare($apiResponseSF, $sessionFlightSearchParams, 2);
		}
		$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_searcher = $this->array_searcher($faretypeArr, $result['totalPriceList']);
					array_multisort($array_searcher);
					if ($array_searcher) {
						foreach ($array_searcher 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'];
							$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$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

							if (!empty($ADULT)) {
								$PaxTypeCount = 1;
							}
							if (!empty($CHILD)) {
								$PaxTypeCount = 2;
							}
							if (!empty($INFANT)) {
								$PaxTypeCount = 3;
							}
							$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
							$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
							$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents

							$ADULTNCMTDS = 0; //isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
							$CHILDNCMTDS = 0; //isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
							$INFANTNCMTDS = 0; //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(
								'getMarkupNew' => $getMarkupNew,
								'getAgencyMarkups' => $getAgencyMarkups,
								'PublishedFare' => $PublishedFare,
								'OfferedFare' => $OfferedFare,
								'intCommissionEarned' => $CommissionEarned,
								'TdsOnPLB' => $TdsOnPLB,
								'MUFee' => $MUFee,
								'intPLBEarned' => $PLBEarned,
								'intIncentiveEarned' => $IncentiveEarned,
								'intMemberCount' => $intMemberCount,
								'intFlightRoute' => $strFlightRoute,
								'interNationalSearch' => $interNationalSearch,
								'AddMarkup' => $AddMarkup,
							);
							//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(
								'getMarkupNew' => $getMarkupNew,
								'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,
								'AddMarkup' => $AddMarkup,
							);
							$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]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
							$FareBreakdown[0]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
							$FareBreakdown[0]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
							$FareBreakdown[0]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
							$FareBreakdown[0]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
							$FareBreakdown[0]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
							$FareBreakdown[0]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
							$FareBreakdown[0]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
							$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
							$FareBreakdown[0]['GSTonComm'] = 0;
							$FareBreakdown[0]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
							$FareBreakdown[0]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
							$FareBreakdown[0]['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(
									'getMarkupNew' => $getMarkupNew,
									'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,
									'AddMarkup' => $AddMarkup,
								);
								$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]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
								$FareBreakdown[1]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
								$FareBreakdown[1]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
								$FareBreakdown[1]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
								$FareBreakdown[1]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
								$FareBreakdown[1]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
								$FareBreakdown[1]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
								$FareBreakdown[1]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
								$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
								$FareBreakdown[1]['GSTonComm'] = 0;
								$FareBreakdown[1]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
								$FareBreakdown[1]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
								$FareBreakdown[1]['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(
									'getMarkupNew' => $getMarkupNew,
									'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,
									'AddMarkup' => $AddMarkup,
								);
								$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]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
								$FareBreakdown[2]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
								$FareBreakdown[2]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
								$FareBreakdown[2]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
								$FareBreakdown[2]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
								$FareBreakdown[2]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
								$FareBreakdown[2]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
								$FareBreakdown[2]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
								$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
								$FareBreakdown[2]['GSTonComm'] = 0;
								$FareBreakdown[2]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
								$FareBreakdown[2]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
								$FareBreakdown[2]['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,
								"ApiResultIndex" => $PriceID,
								"IsGSTRequired" => $IsGSTRequired,
								"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
								"fareIdentifierSP" => $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'],
								"AddiTaxOnMarkup" => $arrMarkUps['AddiTaxOnMarkup'],
								"AddiMarkup" => $arrMarkUps['AddiMarkup'],

								"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;
					$SegFlightNumberArr = [];
					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,
							);
							$SegFlightNumberArr[] = $SegFlightNumber;
						}
					}

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

					if (!empty($FairRulesArr)) {
						$arrInsertFlightData[$key]['FlightNumber'] = $strFlightNumber;
						$arrInsertFlightData[$key]['SegFlightNumberArr'] = implode(', ', $SegFlightNumberArr);
						$arrInsertFlightData[$key]['AirlineName'] = $strAirlineName;
						$arrInsertFlightData[$key]['AirlineCode'] = $AirlineCode;
						$arrInsertFlightData[$key]['IsTJFlightAPI'] = $this->IsTJFlightAPI;
						//                $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]['SourcePlaceName'] = $destinationCityText[0];
						$arrInsertFlightData[$key]['DestPlaceName'] = $sourceCityText[0];
						//                $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]['ICSourceSysId'] = 7;
						$arrInsertFlightData[$key]['logo'] = $filePath;
						$arrInsertFlightData[$key]['FairRules'] = $FairRulesArr;
						$arrInsertFlightData[$key]['Segments'] = $arrSegments;
						$arrInsertFlightData[$key]['IsSeriesFareData'] = false;

						$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
						$FilterArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strArrivalDtTime);
						$arrInsertFlightData[$key]['ReturnFilterDepartureDtTime'] = $FilterDepartureDtTime;
						$arrInsertFlightData[$key]['ReturnFilterArrivalDtTime'] = $FilterArrivalDtTime;

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

			if (!empty($FlightDataSeriesFare['outbound'])) {
				$arrInsertFlightData = array_values(array_merge($arrInsertFlightData, $FlightDataSeriesFare['outbound']));
			}

			$data = array('inbound' => array_values($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']);
			$sourceCityText = explode(',', $sessionFlightSearchParams['sourceCityText'][0]);
			$destinationCityText = explode(',', $sessionFlightSearchParams['destinationCityText'][0]);
			$intMemberCount = $adultCount + $childCount + $infantCount;
			$strFlightRoute = trim($sessionFlightSearchParams['route']);
			$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
			$intTatalPaxCT = $adultCount + $childCount;
			if (!empty(trim($interNationalSearch)) && trim($interNationalSearch) == 1) {
				$intAirType = 2;
			} else {
				$intAirType = 1;
			}
			//$getMarkup = $this->getMarkup($intCountryCode);
			$AdditionalMarkup = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAdditionalMarkup();
			$faretypeArr = $AdditionalMarkup['faretypeArr'];
			$getMarkupNew = $this->getMarkupNew();
			$objMarkup = new Travel_Model_Markup();
			$getAgencyMarkups = $objMarkup->getAgencyMarkups($intAirType, $this->gtxagencysysid);

			$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_searcher = $this->array_searcher($faretypeArr, $result['totalPriceList']);
				array_multisort($array_searcher);
				if ($array_searcher) {
					foreach ($array_searcher 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'];
						$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$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
						if (!empty($ADULT)) {
							$PaxTypeCount = 1;
						}
						if (!empty($CHILD)) {
							$PaxTypeCount = 2;
						}
						if (!empty($INFANT)) {
							$PaxTypeCount = 3;
						}
						$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
						$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
						$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents

						$ADULTNCMTDS = 0; //isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
						$CHILDNCMTDS = 0; //isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
						$INFANTNCMTDS = 0; //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(
							'getMarkupNew' => $getMarkupNew,
							'getAgencyMarkups' => $getAgencyMarkups,
							'PublishedFare' => $PublishedFare,
							'OfferedFare' => $OfferedFare,
							'intCommissionEarned' => $CommissionEarned,
							'TdsOnPLB' => $TdsOnPLB,
							'MUFee' => $MUFee,
							'intPLBEarned' => $PLBEarned,
							'intIncentiveEarned' => $IncentiveEarned,
							'intMemberCount' => $intMemberCount,
							'intFlightRoute' => $strFlightRoute,
							'interNationalSearch' => $interNationalSearch,
							'AddMarkup' => $AddMarkup,
						);
						//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(
							'getMarkupNew' => $getMarkupNew,
							'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,
							'AddMarkup' => $AddMarkup,
						);
						$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) + ($arrMarkUpsBR['IntAdddimarkup'] / $PaxTypeCount));
						$FareBreakdown[0]['MU'] = ($AD_MU * $adultCount);
						$FareBreakdown[0]['YR'] = ($AD_YR * $adultCount);
						$FareBreakdown[0]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
						$FareBreakdown[0]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
						$FareBreakdown[0]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
						$FareBreakdown[0]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
						$FareBreakdown[0]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
						$FareBreakdown[0]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
						$FareBreakdown[0]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
						$FareBreakdown[0]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
						$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
						$FareBreakdown[0]['GSTonComm'] = 0;
						$FareBreakdown[0]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
						$FareBreakdown[0]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
						$FareBreakdown[0]['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(
								'getMarkupNew' => $getMarkupNew,
								'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,
								'AddMarkup' => $AddMarkup,
							);
							$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) + ($arrMarkUpsBR['IntAdddimarkup'] / $PaxTypeCount));
							$FareBreakdown[1]['MU'] = ($CH_MU * $childCount);
							$FareBreakdown[1]['YR'] = ($CH_YR * $childCount);
							$FareBreakdown[1]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
							$FareBreakdown[1]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
							$FareBreakdown[1]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
							$FareBreakdown[1]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
							$FareBreakdown[1]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
							$FareBreakdown[1]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
							$FareBreakdown[1]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
							$FareBreakdown[1]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
							$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
							$FareBreakdown[1]['GSTonComm'] = 0;
							$FareBreakdown[1]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
							$FareBreakdown[1]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
							$FareBreakdown[1]['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(
								'getMarkupNew' => $getMarkupNew,
								'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,
								'AddMarkup' => $AddMarkup,
							);
							$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) + ($arrMarkUpsBR['IntAdddimarkup'] / $PaxTypeCount));
							$FareBreakdown[2]['MFT'] = ($IN_MFT * $infantCount);
							$FareBreakdown[2]['MU'] = ($IN_MU * $infantCount);
							$FareBreakdown[2]['YR'] = ($IN_YR * $infantCount);
							$FareBreakdown[2]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
							$FareBreakdown[2]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
							$FareBreakdown[2]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
							$FareBreakdown[2]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
							$FareBreakdown[2]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
							$FareBreakdown[2]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
							$FareBreakdown[2]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
							$FareBreakdown[2]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
							$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
							$FareBreakdown[2]['GSTonComm'] = 0;
							$FareBreakdown[2]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
							$FareBreakdown[2]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
							$FareBreakdown[2]['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,
							"ApiResultIndex" => $PriceID,
							"IsGSTRequired" => $IsGSTRequired,
							"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
							"fareIdentifierSP" => $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'],
							"AddiTaxOnMarkup" => $arrMarkUps['AddiTaxOnMarkup'],
							"AddiMarkup" => $arrMarkUps['AddiMarkup'],

							"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'];

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

				if (!empty($FairRulesArr)) {
					$arrInsertFlightData[$key]['origin']['FlightNumber'] = $FlightNumber;
					$arrInsertFlightData[$key]['origin']['SegFlightNumberArr'] = implode(', ', $SegFlightNumberArr);
					$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']['SourcePlaceName'] = $sourceCityText[0];
					$arrInsertFlightData[$key]['origin']['DestPlaceName'] = $destinationCityText[0];
					$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']['ICSourceSysId'] = 7;
					$arrInsertFlightData[$key]['origin']['logo'] = $filePath;

					//// Rrturn variable

					$TotalLAYOVERMinutesD = 0;
					$FlyingMinutesD = 0;
					$LAYOVERCityArrD = [];
					$SegFlightNumberArr = [];
					if ($TempArr['return']) {
						foreach ($TempArr['return'] as $onwd) {
							$duration = $segments['duration'];
							$LAYOVERMinutes = $GroundTime = isset($onwd['cT']) ? $onwd['cT'] : 0;
							$LAYOVERCity = $LAYOVERCityArrD[] = isset($onwd['cT']) ? $onwd['aa']['city'] : '';
							$FlyingMinutesD += ($duration + $LAYOVERMinutes);
							$TotalLAYOVERMinutesD += $LAYOVERMinutes;
							$AirlineCode = $onwd['fD']['aI']['code'];
							$FlightNumber = $onwd['fD']['fN'];
							$SegFlightNumber = $AirlineCode . "-" . $FlightNumber;
							$SegFlightNumberArr[] = $SegFlightNumber;
						}
					}
					//echo '<pre>';print_r($SegFlightNumberArr);echo '</pre>';
					$OriginReturn = current($TempArr['return']);
					$DestinationReturn = end($TempArr['return']);

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

					$Stops = $DestinationReturn['sN'];
					if ($Stops == 0) {
						$DeStopCountTxt = "Non-stop";
					} else {
						$DeStopCountTxt = $Stops . " Stop(s)";
					}
					$arrInsertFlightData[$key]['destination']['FlightNumber'] = $FlightNumber;
					$arrInsertFlightData[$key]['destination']['SegFlightNumberArr'] = implode(', ', $SegFlightNumberArr);
					$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']['SourcePlaceName'] = $destinationCityText[0];
					$arrInsertFlightData[$key]['destination']['DestPlaceName'] = $sourceCityText[0];
					$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']['ICSourceSysId'] = 7;
					$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]['ArrivalTime'] = $strArrivalDtTime;
					$arrInsertFlightData[$key]['IsRefundable'] = $IsRefundable;
					$arrInsertFlightData[$key]['IsBagIncludes'] = $IsBagIncludes;
					$arrInsertFlightData[$key]['IsTJFlightAPI'] = $this->IsTJFlightAPI;
					$arrInsertFlightData[$key]['ICSourceSysId'] = 7;

					$arrInsertFlightData[$key]['SourcePlaceSysId'] = $arrCommonInsVariables['intSourceCityId'];
					$arrInsertFlightData[$key]['DestPlaceSysId'] = $arrCommonInsVariables['intDestinationCityId'];
					$arrInsertFlightData[$key]['SourceAirportCode'] = $arrCommonInsVariables['strSourceAirportCode'];
					$arrInsertFlightData[$key]['DestAirportCode']   = $arrCommonInsVariables['strDestinationAirportCode'];
					$arrInsertFlightData[$key]['SourcePlaceName'] = $sourceCityText[0];
					$arrInsertFlightData[$key]['DestPlaceName'] = $destinationCityText[0];
					$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' => array_values($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;
			$this->view->IsTJFlightAPI = $this->IsTJFlightAPI;
			$html = new Zend_View();
			$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
			$html->assign(array('Data' => $ArrayData, 'DataInbound' => [], 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, 'IsTJFlightAPI' => $this->IsTJFlightAPI, 'B2BType' => $this->_session->B2BType));
			$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);
			$intOutBoundId = json_decode($getData['intOutBoundId'], true);
			$icsourcesysid = isset($getData['icsourcesysid']) ? $getData['icsourcesysid'] : 0;

			try {
				$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
				$adultCount = $sessionFlightSearchParams['adults'];
				$childCount = $sessionFlightSearchParams['child'];
				$infantCount = $sessionFlightSearchParams['infant'];
				$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
				//echo '<pre>';print_r($getData);die;
				// ICSourceSysId
				$intMemberCount = $adultCount + $childCount + $infantCount;
				$intMarkUp = $this->getCancelCharge($intCountryCode);

				if ($icsourcesysid == 7) {
					$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareRulesTripJack($getData);
				} else {
					$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareRules($getData, $this->gtxagencysysid);
				}


				$this->view->apiResponse = $apiResponse;
				$this->view->IsTJFlightAPI = $this->IsTJFlightAPI;
				$this->view->icsourcesysid = $icsourcesysid;
				$this->view->getData = $getData;
				$this->view->intMarkUp = ($intMarkUp * $intMemberCount);

				$this->view->IsLCC = $getData['IsLCC'];
				$this->view->interNationalSearch = $interNationalSearch;
				$this->view->intOutBoundId = $intOutBoundId;
			} catch (Zend_Exception $e) {
				print_r($e->getMessage());
				exit;
			}
		} 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'];

		$IsSeriesFareData = isset($Outbound['IsSeriesFareData']) ? $Outbound['IsSeriesFareData'] : 0;
		if ($IsSeriesFareData == 1) {
			$sessionParams['departure_date'][0] = $Outbound['FromDate'];
			$sessionParams['departure_dates'][0] = $Outbound['FromDate'];
			$sessionParams['strDepatureDate'][0] = $Outbound['FromDate'];
			//$sessionParams['route'] = 4;
		}
		$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;
		}
		//echo "<pre>";print_r($FlightBookingData->params);die;
		$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 bookNowMultiAction()
	{
		Zend_Session::namespaceUnset('FlightBookingDataRoundInter');
		Zend_Session::namespaceUnset('FlightBookingDataInbound');
		Zend_Session::namespaceUnset('FlightBookingData');
		$post = json_decode(file_get_contents('php://input'), true);

		$sessionParams = json_decode($post['sessionFlightSearchParams'], true);
		$Outbound = json_decode($post['Outbound'], true);
		$FareArr = json_decode(($post['FareArr']) ? $post['FareArr'] : json_encode([]), true);
		$SearchTraceId = $sessionParams['FlightTraceId'];
		$FlightBookingData = [];
		$apiTraceId = [];
		if ($Outbound) {
			foreach ($Outbound as $key => $item) {
				$FairRules = isset($FareArr[$key]) ? $FareArr[$key] : [];
				$apiTraceId[$key] = $FairRules['PriceID'];
				$FlightBookingData[$key] = $item;
				$FlightBookingData[$key]['FairRules'] = $FairRules;
			}
		}

		$arrData = array(
			'apiTraceId' => implode(',', $apiTraceId),
			'FlightBookingData' => $FlightBookingData,
			'SearchTraceId' => $SearchTraceId,
			'sessionFlightSearchParams' => $sessionParams,
		);

		$objFlight = new Travel_Model_FlightMaster();

		//echo "<pre>";print_r($arrData);
		//die;
		$tempData = array(
			'TraceId' => $SearchTraceId,
			'json_data' => json_encode($arrData),
		);
		$objFlight->deleteFlightTempData($SearchTraceId);
		$objFlight->insertFlightTempData($tempData);

		if ($FlightBookingData) {

			$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);
		//echo  $this->_session->B2BType;die;
		if (!empty($arrUrlData)) {
			$CountryCode = $this->getCountryCodeList();
			$this->view->CountryCode = $CountryCode;
			$this->view->B2BType    = $this->_session->B2BType;

			$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->IsTJFlightAPI    = $this->IsTJFlightAPI;
			$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();
			$apiData = array(
				"CustomerSysId" => $this->_session->data['CustomerSysId'],
				"UserSysId" => $this->_session->data['UserSysId'],
				"AgencySysId" => $this->_session->data['AgencySysId']
			);
			$getAgencyUserData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyUserData($apiData);
			$this->view->getAgencyUserData = $getAgencyUserData['profile'];
			// echo '<pre>';getAgencyUserData
			// print_r($getAgencyUserData);
			// die('d');
			$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 addextramarkupAction()
	{
		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);
			$sessionFlightSearchParams = json_decode($getData['sessionFlightSearchParams'], true);

			$showintax = isset($getData['showintax']) ? $getData['showintax'] : 0;
			$ExtraMarkup = isset($getData['ExtraMarkup']) ? $getData['ExtraMarkup'] : 0;
			$Reverse = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->calculateReverse($ExtraMarkup, 18);
			$MarkupArrayServiceTax = $Reverse['TaxAmount'];
			$MarkupArr['showintax'] = $showintax;
			$MarkupArr['intExtraMarkup'] = $ExtraMarkup;
			$MarkupArr['ExtraMarkup'] = $Reverse['NetPrice'];
			$MarkupArr['ExtraMarkupOnGST'] = $Reverse['TaxAmount'];
			$ExtraMarkup = $Reverse['NetPrice'];

			$strFlightRoute = ($sessionFlightSearchParams['route'] != 4) ? trim($sessionFlightSearchParams['route']) : 1;
			if ($sessionFlightSearchParams['route'] == 4) {
				$this->IsTJFlightAPI = 1;
			}
			$SelectedMealSessionNew = $SelectedMeal;
			$SelectedBaggSessionNew = $SelectedBagg;
			$selectedSeatSession = $SelectedSeat;
			$FlightBookingArr = [];
			if ($FlightBookingData) {
				$IntExtraMarkup = ($ExtraMarkup / $strFlightRoute);
				$IntExtraMarkupOnGST = ($MarkupArrayServiceTax / $strFlightRoute);

				foreach ($FlightBookingData as $key => $outb) {

					$FlightBookingArr[$key] = $outb;
					$FlightBookingArr[$key]['FairRules']['showintax'] = ($showintax);
					$FlightBookingArr[$key]['FairRules']['ExtraMarkup'] = ($IntExtraMarkup);
					$FlightBookingArr[$key]['FairRules']['ExtraMarkupOnGST'] = ($IntExtraMarkupOnGST);
					$FareBreakdown = [];
					$FareBreakCount = count($outb['FairRules']['FareBreakdown']);
					if ($outb['FairRules']['FareBreakdown']) {
						foreach ($outb['FairRules']['FareBreakdown'] as $k => $FareBreak) {
							$FareBreakdown[$k] = $FareBreak;
							$FareBreakdown[$k]['showintax'] = $showintax;
							$FareBreakdown[$k]['ExtraMarkup'] = ($IntExtraMarkup / $FareBreakCount);
							$FareBreakdown[$k]['ExtraMarkupOnGST'] = ($IntExtraMarkupOnGST / $FareBreakCount);
						}
					}
					$FlightBookingArr[$key]['FairRules']['FareBreakdown'] = $FareBreakdown;
				}
			}

			$BagPrice = 0;
			$InbBagPrice = 0;
			$MealPrice = 0;
			$InbMealPrice = 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'];
					}
				}
			}
			$MealFare = ($MealPrice + $InbMealPrice);
			$BaggFare = ($BagPrice + $InbBagPrice);
			$intNetPublishedFare = 0;
			if ($FlightBookingData) {
				foreach ($FlightBookingData as $value) {
					$intNetPublishedFare += $value['FairRules']['PublishedFareAgent'];
				}
			}
			$MobilePublishedFare = ($intNetPublishedFare + $MealFare + $BaggFare + $SeatPrice + $ExtraMarkup + $MarkupArrayServiceTax);
			// echo '<pre>';
			// print_r($MobilePublishedFare);die;
			$html = new Zend_View();
			$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
			$html->assign(array('Data' => $FlightBookingArr, 'IsTJFlightAPI' => $this->IsTJFlightAPI, 'MarkupArr' => $MarkupArr, 'baseUrl' => $this->baseUrl, 'sessionFlightSearchParams' => $sessionFlightSearchParams, 'CurrencyTitle' => $this->CurrencyTitle, 'selectedSeatSession' => $selectedSeatSession, 'SelectedMealSessionNew' => $SelectedMealSessionNew, 'SelectedBaggSessionNew' => $SelectedBaggSessionNew, 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
			$bodyText = $html->render('faresummaryright.phtml');
			$response = array('success' => true, 'message' => 'Done', 'FlightBookingArr' => json_encode($FlightBookingArr), 'MarkupArr' => json_encode($MarkupArr), 'MobilePublishedFare' => $this->CurrencyTitle . ' ' . $MobilePublishedFare, 'html' => $bodyText);
			echo json_encode($response);
			exit;
		}
	}
	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 = [];
		$arrData = [];
		if ($FlightBookingData) {
			foreach ($FlightBookingData as $kk => $value) {
				$apiTraceId[] = $value['FairRules']['PriceID'];
				$arrData[$kk]['TraceId'] = $value['FairRules']['PriceID'];
				$arrData[$kk]['ResultIndex'] = $value['FairRules']['ApiResultIndex'];
			}
		}

		if ($this->getRequest()->isXmlHttpRequest() && $this->getRequest()->getPost()) {
			$this->_helper->layout->disableLayout();
			$this->_helper->viewRenderer->setNoRender(true);
			$IsSeriesFareData = isset($FlightBookingData[0]['IsSeriesFareData']) ? $FlightBookingData[0]['IsSeriesFareData'] : 0;
			$ICSourceSysId = isset($FlightBookingData[0]['ICSourceSysId']) ? $FlightBookingData[0]['ICSourceSysId'] : 0;
			$getQ = array(
				'TraceId' => $apiTraceId,
				'Inbound' => false,
				'SearchTraceId' => $SearchTraceId,
				'BookingData' => $FlightBookingData[0]
			);
			//echo "<pre>";print_r($FlightBookingData);die;
			// if ($strFlightRoute == 4) {
			// 	$this->IsTJFlightAPI = 1;
			// }
			if ($ICSourceSysId == 7 || $ICSourceSysId == 8) {
				if ($apiTraceId) {
					foreach ($apiTraceId as $i => $vl) {
						$requestData = array(
							'TraceId' => $vl,
							'flowType' => 'REVIEW',
							'FlightTraceId' => $SearchTraceId,
							'BookingData' => $FlightBookingData[0]
						);
						$apiResponsefr = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareRulesTripJack($requestData);
						$FareRuleRequest[$i] = $apiResponsefr;
					}
				}
				if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
					$apiResponse = array('status' => array('success' => 1), 'bookingId' => $FlightBookingData[0]['bookingId']);
				} else {
					$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareQuoteTripJack($getQ);
				}

				$ResponseStatus = $apiResponse['status']['success'];
				$ErrorMessage = isset($apiResponse['errors'][0]['message']) ? $apiResponse['errors'][0]['message'] : '';
				if ($ResponseStatus == 1) {
					$alerts = isset($apiResponse['alerts']) ? $apiResponse['alerts'] : '';
					if ($IsSeriesFareData == 0) {
						$FlightBookingData = $this->UpdateFlightBookingData($apiResponse, $alerts, $SearchTraceId, $sessionFlightSearchParams, $FlightBookingData, $FareRuleRequest);
					}
					$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']['PublishedFareAgent'];
							$oldFare += $value['FairRules']['oldFare'];
							$Baggage[] = $value['Baggage'];
							$Meal[] = $value['Meal'];
						}
					}

					$SSRArr = array('Meal' => $Meal, 'Baggage' => $Baggage, 'SeatPreference' => array());
					$arrUrlData['FlightBookingData'] = $FlightBookingData;
					$arrUrlData['SSRArr'] = $SSRArr;
					$tempData = array(
						'TraceId' => $FlightTraceId,
						'json_data' => json_encode($arrUrlData),
					);
					$objFlight->deleteFlightTempData($FlightTraceId);
					$objFlight->insertFlightTempData($tempData);
					$FareChange = false;
					if ($newFare != $oldFare) {
						$FareChange = true;
					}
					$html = new Zend_View();
					$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
					//echo "<pre>";print_r($FlightBookingData);die;
					$html->assign(array('Data' => $FlightBookingData, 'IsTJFlightAPI' => $this->IsTJFlightAPI, 'B2BType' => $this->_session->B2BType, '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;
				}
			} else {
				$adultCount = $sessionFlightSearchParams['adults'];
				$childCount = $sessionFlightSearchParams['child'];
				$infantCount = $sessionFlightSearchParams['infant'];
				$flight_class = $sessionFlightSearchParams['flight_class'];
				$intMemberCount = $adultCount + $childCount + $infantCount;
				$arrFlightClass = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getFlightClasses();
				$FlightClass = $arrFlightClass[$flight_class];
				if (!empty(trim($interNationalSearch)) && trim($interNationalSearch) == 1) {
					$intAirType = 2;
				} else {
					$intAirType = 1;
				}
				$objMarkup = new Travel_Model_Markup();
				$getAgencyMarkups = $objMarkup->getAgencyMarkups($intAirType, $this->gtxagencysysid);
				$getMarkupNew = $this->getMarkupNew();
				$FlightBookingDataArr = [];
				$newFare = 0;
				$oldFare = 0;
				$tripSeatMapArr = [];
				$BaggageAr = [];
				$Meal = [];
				$IsSeriesFareData = isset($FlightBookingData[0]['IsSeriesFareData']) ? $FlightBookingData[0]['IsSeriesFareData'] : 0;

				if ($FlightBookingData && $IsSeriesFareData == 0) {
					foreach ($FlightBookingData as $key => $vl) {
						$arrData['TraceId'] = $vl['FairRules']['PriceID'];
						$arrData['ResultIndex'] = $vl['FairRules']['ApiResultIndex'];
						$arrData['BookingData'] = $vl;
						$IsLCC = $vl['IsLCC'];
						$strAirlineCode = $vl['AirlineCode'];
						$FlightBookingDataArr[$key] = $vl;
						$oldFare += $vl['FairRules']['CostToAgentCustomer'];

						$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareQuote($arrData, $this->gtxagencysysid);
						$arrSSR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->flightSSRDetails($arrData, $this->gtxagencysysid);
						// echo '<pre>';
						// print_r($apiResponse);
						// echo '</pre>';
						$FlightNumber = explode('-', $vl['FlightNumber']);

						if ($IsLCC) {
							$Baggage = isset($arrSSR['Response']['Baggage']) ? $arrSSR['Response']['Baggage'] : [];
							$MealDynamic = isset($arrSSR['Response']['MealDynamic']) ? $arrSSR['Response']['MealDynamic'] : [];
							$SeatDynamic = isset($arrSSR['Response']['SeatDynamic']) ? $arrSSR['Response']['SeatDynamic'] : [];
							if ($Baggage) {
								foreach ($Baggage as $b => $bgg) {
									//$Baggage[] = $bgg;isReturnSegment
									if ($bgg) {
										foreach ($bgg as $bg) {
											$BaggageAr[$b][] = array(
												'AirlineCode' => $bg['AirlineCode'],
												'FlightNumber' => $bg['FlightNumber'],
												'key' => $bg['FlightNumber'],
												'WayType' => $bg['WayType'],
												'Code' => $bg['Code'],
												'Description' => $bg['Description'],
												'Weight' => $bg['Weight'],
												'Currency' => $bg['Currency'],
												'Price' => $bg['Price'],
												'Origin' => $bg['Origin'],
												'Destination' => $bg['Destination'],
											);
										}
									}
								}
							}
							if ($MealDynamic) {
								foreach ($MealDynamic as $b => $mell) {
									if ($mell) {
										foreach ($mell as $ml) {
											$Meal[$b][] = array(
												'AirlineCode' => $ml['AirlineCode'],
												'FlightNumber' => $ml['FlightNumber'],
												'key' => $ml['FlightNumber'],
												'WayType' => $ml['WayType'],
												'Code' => $ml['Code'],
												'Description' => $ml['Description'],
												'AirlineDescription' => $ml['AirlineDescription'],
												'Quantity' => $ml['Quantity'],
												'Currency' => $ml['Currency'],
												'Price' => $ml['Price'],
												'Origin' => $ml['Origin'],
												'Destination' => $ml['Destination'],
											);
										}
									}
								}
							}
							if ($SeatDynamic) {
								foreach ($SeatDynamic as $stSeg) {
									$SegmentSeat = $stSeg['SegmentSeat'];
									if ($SegmentSeat) {
										foreach ($SegmentSeat as $SG) {
											$RowSeats = $SG['RowSeats'];
											$sInfo = [];
											$R = 1;
											if ($RowSeats) {
												foreach ($RowSeats as $RK => $RS) {
													$Seats = $RS['Seats'];
													$C = 1;
													if ($Seats) {
														foreach ($Seats as $SK => $ST) {
															$sInfo[] = array(
																'AirlineCode' => $ST['AirlineCode'],
																'FlightNumber' => $ST['FlightNumber'],
																'CraftType' => $ST['CraftType'],
																'Origin' => $ST['Origin'],
																'Destination' => $ST['Destination'],
																'AvailablityType' => $ST['AvailablityType'],
																'isBooked' => ($ST['AvailablityType'] == 3) ? true : false,
																'Description' => $ST['Description'],
																'Code' => $ST['Code'],
																'code' => $ST['Code'],
																'RowNo' => $ST['RowNo'],
																'SeatNo' => $ST['SeatNo'],
																'seatNo' => ($ST['Code'] == 'NoSeat') ? '' : $ST['Code'],
																'SeatType' => $ST['SeatType'],
																'SeatWayType' => $ST['SeatWayType'],
																'Compartment' => $ST['Compartment'],
																'Deck' => $ST['Deck'],
																'Currency' => $ST['Currency'],
																'Price' => $ST['Price'],
																'amount' => $ST['Price'],
																'Text' => $ST['Text'],
																'seatPosition' => ['row' => $R, 'column' => $C],
															);
															$C++;
														}
													}
													$R++;
												}
											}
											$tripSeatMapArr[$FlightNumber[1]]['sData'] = array('row' => count($RowSeats), 'column' => 7);
											$tripSeatMapArr[$FlightNumber[1]]['sInfo'] = $sInfo;
										}
									}
								}
							}
						} else {
							$MealDynamic = isset($arrSSR['Response']['Meal']) ? $arrSSR['Response']['Meal'] : [];
							if ($MealDynamic) {
								foreach ($MealDynamic as $k => $ml) {
									$Meal[] = array(
										'Code' => $ml['Code'],
										'Description' => $ml['Description'],
										'AirlineDescription' => $ml['Description'],
										'Currency' => $this->CurrencyTitle,
										'amount' => 0,
										'Price' => 0,
										'key' => $FlightNumber[1],
									);
								}
							}
						}

						//echo "<pre>";print_r($Meal);echo "</pre>";
						$ResponseStatus = $apiResponse['Response']['ResponseStatus'];
						$ErrorMessage = $apiResponse['Response']['Error']['ErrorMessage'];
						$data = $apiResponse['Response']['Results'];
						$SegmentsArrary = $data['Segments'];
						$AccumulatedDuration = 0;
						$arrSegments = [];
						if (count($SegmentsArrary) > 0) {
							$FlyingMinutes = 0;
							$countSeg = count($SegmentsArrary);
							foreach ($SegmentsArrary as $kk => $SegResult) {
								foreach ($SegResult as $kkk => $segmentsResult) {
									if ($countSeg >= 2) {
										$AccumulatedDuration += isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : (0);
									} else {
										$AccumulatedDuration += ($segmentsResult['Duration'] + $segmentsResult['GroundTime']);
									}
									//echo "<pre>";print_r($segmentsResult);die;
									$FlyingMinutes = $FlyingMinutes + (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : ($segmentsResult['Duration'] + $segmentsResult['GroundTime']));
									$LAYOVERMinutes = ((isset($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : 0));
									$DepTime = $segmentsResult['Origin']['DepTime'];
									$ArrTime = $segmentsResult['Destination']['ArrTime'];
									$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($LAYOVERMinutes);
									// FOR FLIGHT SEGMENTS.....
									$strBaggage = $segmentsResult['Baggage'];
									$strCabinBaggage = $segmentsResult['CabinBaggage'];
									if (!empty($strBaggage)) {
										$IsBaggage = 1;
										$IsBagIncludes = true;
									} else {
										$IsBaggage = 0;
										$IsBagIncludes = false;
									}
									if (!empty($strCabinBaggage)) {
										$strCabinBaggage = $strCabinBaggage;
									} else {
										$strCabinBaggage = '0 KG';
									}
									$TripIndicator = $segmentsResult['TripIndicator'];
									$SegmentIndicator = $segmentsResult['SegmentIndicator'];

									$strAirlineCode = $segmentsResult['Airline']['AirlineCode'];
									$AirlineName = $segmentsResult['Airline']['AirlineName'];
									$FlightNumber = $segmentsResult['Airline']['FlightNumber'];
									$FareClass = $segmentsResult['Airline']['FareClass'];
									$FareClassArr[] = $FareClass;
									$SegFlightNumber = $strAirlineCode . "-" . $FlightNumber;

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

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

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

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

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

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

									$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($ArrTime);
									$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($DepTime);
									$BaggageArrNew = isset($Baggage[$kk]) ? $Baggage[$kk] : [];
									if ($IsLCC) {
										$MealArrNew = isset($MealDynamic[$kk]) ? $MealDynamic[$kk] : [];
									} else {
										$MealArrNew = isset($Meal) ? $Meal : [];
									}

									$arrSegments[] = array(
										"segmentid" => $FlightNumber,
										"originAirportName" => $originAirportName,
										"destinationAirportName" => $destinationAirportName,
										"originCityName" => $originCityName,
										"originCountryName" => $originCountryName,
										"destinationCityName" => $destinationCityName,
										"destinationCountryName" => $destinationCountryName,
										"originAirportCode" => $originAirportCode,
										"destinationAirportCode" => $destinationAirportCode,
										"originDepTime" => $originDepTime,
										"destinationArrTime" => $destinationArrTime,
										"SegFlightNumber" => $SegFlightNumber,
										"AirlineCode" => $strAirlineCode,
										"AirlineName" => $AirlineName,
										"FareClass" => $FareClass,
										"TripIndicator" => $TripIndicator,
										"isReturnSegment" => ($TripIndicator == 1) ? false : true,
										"Baggage" => $strBaggage,
										"CabinBaggage" => $strCabinBaggage,
										"IsBaggage" => $IsBaggage,
										"SegmentIndicator" => $SegmentIndicator,
										"Duration" => $Duration,
										"GroundTime" => $GroundTime,
										"Mile" => $Mile,
										"StopOver" => $StopOver,
										"StopPoint" => $StopPoint,
										"StopPointArrivalTime" => $StopPointArrivalTime,
										"StopPointDepartureTime" => $StopPointDepartureTime,
										"Craft" => $Craft,
										"Remark" => $Remark,
										"IsETicketEligible" => $IsETicketEligible,
										"FlightStatus" => $FlightStatus,
										"Status" => $Status,
										"NoOfSeatAvailable" => $NoOfSeatAvailable,
										"strDepartureDtTime" => $strDepartureDtTime,
										"strArrivalDtTime" => $strArrivalDtTime,
										"FlightDuration" => $strDuration,
										"LAYOVERDuration" => $LAYOVERDuration,
										"DepTerminal" => $DepTerminal,
										"ArrTerminal" => $ArrTerminal,
										"filePath" => $filePath,
										"BAGGAGEARRAY" => $BaggageArrNew,
										"MEALARRAY" => $MealArrNew,
									);
								}
							}
						}
						// echo '<pre>';
						// print_r($arrSegments);
						// echo '</pre>';
						//die;
						$IsLCC = isset($data['IsLCC']) ? $data['IsLCC'] : false;
						$ResultIndex = $data['ResultIndex'];
						$Source = $data['Source'];
						$IsLCC = $data['IsLCC'];
						$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';

						$BaseFare = $data['Fare']['BaseFare'];
						$Tax = $data['Fare']['Tax'];
						$YQTax = $data['Fare']['YQTax'];
						$AdditionalTxnFeeOfrd = $data['Fare']['AdditionalTxnFeeOfrd'];
						$AdditionalTxnFeePub = $data['Fare']['AdditionalTxnFeePub'];
						$OtherCharges = $data['Fare']['OtherCharges'];
						$Discount = $data['Fare']['Discount'];
						$PublishedFare = $data['Fare']['PublishedFare'];
						$CommissionEarned = $data['Fare']['CommissionEarned'];
						$PLBEarned = $data['Fare']['PLBEarned'];
						$IncentiveEarned = $data['Fare']['IncentiveEarned'];
						$OfferedFare = $data['Fare']['OfferedFare'];
						$TdsOnCommission = $data['Fare']['TdsOnCommission'];
						$TdsOnPLB = $data['Fare']['TdsOnPLB'];
						$TdsOnIncentive = $data['Fare']['TdsOnIncentive'];
						$ServiceFee = $data['Fare']['ServiceFee'];
						$ResultFareType = $data['ResultFareType'];
						$FareBreakdown = $data['FareBreakdown'];
						$totalCommissions = $data['Fare']['CommissionEarned'] + $data['Fare']['PLBEarned'] + $data['Fare']['IncentiveEarned'];
						$totalCommissionsOnTds = $data['Fare']['TdsOnCommission'] + $data['Fare']['TdsOnIncentive'] + $data['Fare']['TdsOnPLB'];
						$IsPassportRequiredAtBook = isset($data['IsPassportRequiredAtBook']) ? $data['IsPassportRequiredAtBook'] : false;
						$IsPassportRequiredAtTicket = isset($data['IsPassportRequiredAtTicket']) ? $data['IsPassportRequiredAtTicket'] : false;
						if ($IsLCC) {
							if ($IsPassportRequiredAtTicket) {
								$IsPassMandatory =  true;
								$IsPassExpiry =  true;
								$IsPassIssue =  false;
							} else {
								$IsPassMandatory =  false;
								$IsPassExpiry =  false;
								$IsPassIssue =  false;
							}
						} else {
							if ($IsPassportRequiredAtBook) {
								$IsPassMandatory =  true;
								$IsPassExpiry =  true;
								$IsPassIssue =  false;
							} else {
								$IsPassMandatory =  false;
								$IsPassExpiry =  false;
								$IsPassIssue =  false;
							}
						}


						$IsPassDateOfBirth =  false;
						$isGSTMandatory = isset($data['IsGSTMandatory']) ? $data['IsGSTMandatory'] : false;
						$IsPanRequiredAtBook = isset($data['IsPanRequiredAtBook']) ? $data['IsPanRequiredAtBook'] : false;
						$IsPanRequiredAtTicket = isset($data['IsPanRequiredAtTicket']) ? $data['IsPanRequiredAtTicket'] : false;
						$isSeatApplicable =  false;
						$isSessionTime =  false;
						$isSessionTime = 0;
						//'I5';

						if ($interNationalSearch == 1) {
							$isAdobrMandatory =  true;
							$isCdobrMandatory =  true;
							$isIdobrMandatory = true;
						} else if ($strAirlineCode == 'I5') {
							$isAdobrMandatory =  true;
							$isCdobrMandatory =  true;
							$isIdobrMandatory = true;
						} else {
							$isAdobrMandatory =  false;
							$isCdobrMandatory =  true;
							$isIdobrMandatory = true;
						}
						$FlightBookingDataArr[$key]['ICSourceSysId'] = 3;
						$FlightBookingDataArr[$key]['Ispassengercity'] = true;
						$FlightBookingDataArr[$key]['Ispassengeraddress'] = true;
						$FlightBookingDataArr[$key]['isGSTMandatory'] = $isGSTMandatory;
						$FlightBookingDataArr[$key]['IsPassMandatory'] = $IsPassMandatory;
						$FlightBookingDataArr[$key]['IsPassExpiry'] = $IsPassExpiry;
						$FlightBookingDataArr[$key]['IsPassIssue'] = $IsPassIssue;
						$FlightBookingDataArr[$key]['IsPassDateOfBirth'] = $IsPassDateOfBirth;
						$FlightBookingDataArr[$key]['isAdobrMandatory'] = $isAdobrMandatory;
						$FlightBookingDataArr[$key]['isCdobrMandatory'] = $isCdobrMandatory;
						$FlightBookingDataArr[$key]['isIdobrMandatory'] = $isIdobrMandatory;
						$FlightBookingDataArr[$key]['isSeatApplicable'] = $isSeatApplicable;
						$FlightBookingDataArr[$key]['IsPanRequiredAtTicket'] = $IsPanRequiredAtTicket;
						$FlightBookingDataArr[$key]['IsPanRequiredAtBook'] = $IsPanRequiredAtBook;
						$FlightBookingDataArr[$key]['isSessionTime'] = $isSessionTime . ':00';



						$markUpArr = array(
							'getMarkupNew' => $getMarkupNew,
							'getAgencyMarkups' => $getAgencyMarkups,
							'PublishedFare' => $PublishedFare,
							'OfferedFare' => $OfferedFare,
							'intCommissionEarned' => $totalCommissions,
							'TdsOnCommission' => $totalCommissionsOnTds,
							'MUFee' => $ServiceFee,
							'intPLBEarned' => $PLBEarned,
							'intIncentiveEarned' => $IncentiveEarned,
							'intMemberCount' => $intMemberCount,
							'intFlightRoute' => $strFlightRoute,
							'interNationalSearch' => $interNationalSearch,
						);

						$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTBO($markUpArr);
						$intPublishedFare = $arrMarkUps['PublishFare'];
						$newFare += $arrMarkUps['CostToAgentCustomer'];
						$countBreakUp = count($FareBreakdown);
						foreach ($FareBreakdown as $pk => $pax) {
							$intPassengerCount = isset($pax['PassengerCount']) ? $pax['PassengerCount'] : 0;

							$arrFareBreakdown[$pk]['Currency'] = $pax['Currency'];
							$arrFareBreakdown[$pk]['PassengerType'] = $pax['PassengerType'];
							$arrFareBreakdown[$pk]['PassengerCount'] = $pax['PassengerCount'];
							$arrFareBreakdown[$pk]['TaxIN'] = ($pax['Tax']);
							$arrFareBreakdown[$pk]['TotalBaseFare'] = 0;
							$arrFareBreakdown[$pk]['BaseFareCal'] = ($arrMarkUps['BaseFareCal'] / $countBreakUp);
							$arrFareBreakdown[$pk]['BaseFare'] = ($pax['BaseFare']);
							$arrFareBreakdown[$pk]['CommissionEarned'] = ($totalCommissions / $countBreakUp);
							$arrFareBreakdown[$pk]['OtherCharges'] = ($OtherCharges / $countBreakUp);
							$arrFareBreakdown[$pk]['TDS'] = ($totalCommissionsOnTds / $countBreakUp);
							$arrFareBreakdown[$pk]['MF'] = 0;
							$arrFareBreakdown[$pk]['YQ'] = $pax['YQTax'];
							$arrFareBreakdown[$pk]['AGST'] = 0;
							$arrFareBreakdown[$pk]['MFT'] = 0;
							$arrFareBreakdown[$pk]['OT'] = $pax['Tax'];
							$arrFareBreakdown[$pk]['MU'] = 0;
							$arrFareBreakdown[$pk]['YR'] = 0;
							$arrFareBreakdown[$pk]['intTotalGST'] = ($arrMarkUps['intTotalGST'] / $countBreakUp);
							$arrFareBreakdown[$pk]['apiMarkup'] = ($arrMarkUps['apiMarkup'] / $countBreakUp);
							$arrFareBreakdown[$pk]['IntCommission'] = ($arrMarkUps['IntCommission'] / $countBreakUp);
							$arrFareBreakdown[$pk]['apiTaxOnMarkup'] = ($arrMarkUps['apiTaxOnMarkup'] / $countBreakUp);
							$arrFareBreakdown[$pk]['FixedMarkUp'] = ($arrMarkUps['IntAgencyFixMarkUp'] / $countBreakUp);
							$arrFareBreakdown[$pk]['GSTOnMarkUp'] = ($arrMarkUps['IntTaxOnAgencyFixMarkUp'] / $countBreakUp);
							$arrFareBreakdown[$pk]['CommEarned'] = ($arrMarkUps['IntCommission'] / $countBreakUp);
							$arrFareBreakdown[$pk]['GSTonComm'] = 0;
							$arrFareBreakdown[$pk]['intGTXMarkUp'] = ($arrMarkUps['intGTXMarkUp'] / $countBreakUp);
							$arrFareBreakdown[$pk]['GTXMarkUpGST'] = ($arrMarkUps['intSTaxOnGTXMarkUp'] / $countBreakUp);
							$arrFareBreakdown[$pk]['AgentMarkUp'] = ($arrMarkUps['totalAgentMarkUp'] / $countBreakUp);
							$arrFareBreakdown[$pk]['GSTOnAgentMarkUp'] = ($arrMarkUps['intGSTOnAgentFixMarkUp'] / $countBreakUp);
							$arrFareBreakdown[$pk]['Agencycommission'] = ($arrMarkUps['Agencycommission'] / $countBreakUp);
							$arrFareBreakdown[$pk]['TotalCommssionVal_ag'] = ($arrMarkUps['TotalCommssionVal_ag'] / $countBreakUp);
							$arrFareBreakdown[$pk]['AdminComminAmount_ag'] = ($arrMarkUps['AdminComminAmount_ag'] / $countBreakUp);
							$arrFareBreakdown[$pk]['AgentB2CEarning'] = ($arrMarkUps['AgentB2CEarning'] / $countBreakUp);
							$arrFareBreakdown[$pk]['CostToAgentCustomer'] = ($arrMarkUps['CostToAgentCustomer'] / $countBreakUp);
							$arrFareBreakdown[$pk]['CostToAgent'] = ($arrMarkUps['CostToAgent'] / $countBreakUp);
							$arrFareBreakdown[$pk]['AdditionalTxnFeeOfrd'] = $pax['AdditionalTxnFeeOfrd'];
							$arrFareBreakdown[$pk]['AdditionalTxnFeePub'] = $pax['AdditionalTxnFeePub'];
							$arrFareBreakdown[$pk]['PGCharge'] = 0;
							$arrFareBreakdown[$pk]['Baggage'] = ''; //Check In Baggage;
							$arrFareBreakdown[$pk]['CabinBaggage'] = ''; //Cabin Baggage ;

						}

						$arrFairRules = array(
							"Currency" => $this->CurrencyTitle, //$Currency,
							"CurrencyRate" => $this->CurrencyRate, //$Currency,
							"currencySysId" => $this->CurrencyId,
							"BaseFare" => $BaseFare,
							"Tax" => $Tax,
							"YQTax" => $YQTax,
							"OtherCharges" => $OtherCharges,
							"Discount" => $Discount,
							"ServiceFee" => $ServiceFee,
							"ManagementFeeTax" => 0,
							"AirlineGSTComponent" => 0,
							"CarrierMiscFee" => 0,
							"MUFee" => 0,
							"intPublishedFare" => $PublishedFare,
							"PublishedFare" => ($arrMarkUps['PublishFare'] * $this->CurrencyRate),
							"PublishedFareAgent" => ($arrMarkUps['CostToAgentCustomer'] * $this->CurrencyRate),
							"OfferedFareAgent" => ($arrMarkUps['CostToAgent'] * $this->CurrencyRate),
							"OfferedFare" => $arrMarkUps['intOfferedFare'],
							"CommissionEarned" => $CommissionEarned,
							"PLBEarned" => $PLBEarned,
							"IncentiveEarned" => $IncentiveEarned,
							"TdsOnCommission" => $TdsOnCommission,
							"TdsOnPLB" => $TdsOnPLB,
							"TdsOnIncentive" => $TdsOnIncentive,
							"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
							"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
							"PriceID" => $strTraceId,
							"ApiResultIndex" => $ResultIndex,
							"IsGSTRequired" => $isGSTMandatory,
							"fareIdentifier" => $ResultFareType,
							"FareClass" => $FlightClass,
							"intTotalGST" => $arrMarkUps['intTotalGST'],
							"apiMarkup" => $arrMarkUps['apiMarkup'],
							"IntCommission" => $arrMarkUps['IntCommission'],
							"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
							"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
							"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
							"CommEarned" => $arrMarkUps['IntCommission'],
							"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" => $arrFareBreakdown,
							"arrMarkUps" => $arrMarkUps,
						);
						$FlightBookingDataArr[$key]['FairRules'] = $arrFairRules;
						$FlightBookingDataArr[$key]['Segments'] = $arrSegments;
						// echo "<pre>";
						// print_r($arrFairRules);
						// echo "<pre>";
						//print_r($arrSSR);
					}
				}
				if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
					//$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareQuoteSeriesFare($getQ);
					$apiResponse = array('status' => array('success' => 1), 'bookingId' => $FlightBookingData[0]['bookingId']);
					$ResponseStatus = $apiResponse['status']['success'];
					$FlightBookingDataArr = $FlightBookingData;
				}
				//echo "<pre>";print_r($ResponseStatus);echo "</pre>";die;
				if (!empty($tripSeatMapArr)) {
					$tripSeatMap['tripSeatMap']['tripSeat'] = $tripSeatMapArr;
					$tripSeatMap['status'] = ['success' => true, 'httpStatus' => 200];
				} else {
					$tripSeatMap['tripSeatMap']['tripSeat'] = [];
					$tripSeatMap['status'] = ['success' => false, 'httpStatus' => 400];
				}
				if ($IsLCC) {
					$SSRArr = array('Meal' => $Meal, 'Baggage' => $BaggageAr, 'SeatPreference' => array());
				} else {
					$Mealwwww[0] = $Meal;
					$SSRArr = array('Meal' => $Mealwwww, 'Baggage' => $BaggageAr, 'SeatPreference' => array());
				}

				//
				// die;
				if ($ResponseStatus == 1) {
					$FareChange = false;
					if ($newFare != $oldFare) {
						$FareChange = true;
					}
					//$SSRArr = [];
					$html = new Zend_View();
					$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
					//echo "<pre>";print_r($FlightBookingData);die;
					$html->assign(array('Data' => $FlightBookingDataArr, 'IsTJFlightAPI' => $this->IsTJFlightAPI, 'B2BType' => $this->_session->B2BType, '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(($newFare), 2), 'SSRArr' => json_encode($SSRArr), 'tripSeatMap' => json_encode($tripSeatMap), 'SeatDynamic' => json_encode($SeatDynamic), 'SSRArrInb' => [], 'apiResponse' => json_encode($FlightBookingDataArr));
					echo json_encode($response);
					exit;
				} else {
					$response = array('success' => false, 'message' => 'Session is expired. Please try again with new session', 'FareChange' => false, 'html' => '');
					echo json_encode($response);
					exit;
				}
			}

			$FareRuleRequest = [];
		} else {
			die('Page not found!');
		}
	}



	public function UpdateFlightBookingData($data, $alerts, $SearchTraceId, $sessionFlightSearchParams, $FlightBookingData, $FareRuleRequest = null)
	{
		$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($interNationalSearch)) && trim($interNationalSearch) == 1) {
			$intAirType = 2;
		} else {
			$intAirType = 1;
		}
		//$getMarkup = $this->getMarkup($intCountryCode);
		$AdditionalMarkup = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAdditionalMarkup();
		$faretypeArr = $AdditionalMarkup['faretypeArr'];
		$getMarkupNew = $this->getMarkupNew();
		$objMarkup = new Travel_Model_Markup();
		$getAgencyMarkups = $objMarkup->getAgencyMarkups($intAirType, $this->gtxagencysysid);
		// echo '<pre>';
		// print_r($getAgencyMarkups);
		// die('d');
		if ($interNationalSearch == 1 && $strFlightRoute == 2) {
		} else {
		}
		$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_TJ = $data['bookingId'];
		$bookingId = str_replace('TJ', BOOKINGREF, $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);
		if ($IsPassDateOfBirth && $interNationalSearch) {
			$isAdobrMandatory = true;
			$isCdobrMandatory = true;
			$isIdobrMandatory = true;
		} else {
			$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']) {
				$TempArr['onward'] = $data['tripInfos'][0];
				$TempArr['return'] = $data['tripInfos'][1];
				$totalPriceListArr = array_merge($TempArr['onward']['totalPriceList'], $TempArr['return']['totalPriceList']);
				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];
					}

					$SegmentInformation = $result['sI'];
					//echo '<pre>';print_r($SegmentInformation);
					$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;
					$alertsFare = isset($alerts[$key]) ? $alerts[$key] : [];
					$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($price);
							// echo '</pre>';
							$SeatAvailable = $fareDetail['ADULT']['sR'];
							$classOfBooking = $fareDetail['ADULT']['cB'];
							$Refundable = $fareDetail['ADULT']['rT'];
							$PriceID = $price['id'];
							$fareIdentifier = $price['fareIdentifier'];
							$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$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
							if (!empty($ADULT)) {
								$PaxTypeCount = 1;
							}
							if (!empty($CHILD)) {
								$PaxTypeCount = 2;
							}
							if (!empty($INFANT)) {
								$PaxTypeCount = 3;
							}
							$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
							$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
							$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents

							$ADULTNCMTDS = 0; //isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
							$CHILDNCMTDS = 0; //isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
							$INFANTNCMTDS = 0; //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(
								'getMarkupNew' => $getMarkupNew,
								'getAgencyMarkups' => $getAgencyMarkups,
								'PublishedFare' => $PublishedFare,
								'OfferedFare' => $OfferedFare,
								'intCommissionEarned' => $CommissionEarned,
								'TdsOnPLB' => $TdsOnPLB,
								'MUFee' => $MUFee,
								'intPLBEarned' => $PLBEarned,
								'intIncentiveEarned' => $IncentiveEarned,
								'intMemberCount' => $intMemberCount,
								'intFlightRoute' => $strFlightRoute,
								'interNationalSearch' => $interNationalSearch,
								'AddMarkup' => $AddMarkup,
							);
							//echo '<pre>';print_r($markUpArr);
							$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArr, 'Review');
							if ($kp == 0) {
								$PublishedFareReverse += ($arrMarkUps['PublishFare']);
							}
							$TdsOnPLBCal = isset($ADULTNCMTDS) ? str_replace('-', '', $ADULTNCMTDS) : 0;
							$markUpArrBR = array(
								'getMarkupNew' => $getMarkupNew,
								'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,
								'AddMarkup' => $AddMarkup,
							);
							$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArrBR, 'Review');


							$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]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
							$FareBreakdown[0]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
							$FareBreakdown[0]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
							$FareBreakdown[0]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
							$FareBreakdown[0]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
							$FareBreakdown[0]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
							$FareBreakdown[0]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
							$FareBreakdown[0]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
							//$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
							$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['IntCommission'];
							$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(
									'getMarkupNew' => $getMarkupNew,
									'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,
									'AddMarkup' => $AddMarkup,
								);
								$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArrBR, 'Review');
								$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]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
								$FareBreakdown[1]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
								$FareBreakdown[1]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
								$FareBreakdown[1]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
								$FareBreakdown[1]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
								$FareBreakdown[1]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
								$FareBreakdown[1]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
								$FareBreakdown[1]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
								//$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
								$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['IntCommission'];
								$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(
									'getMarkupNew' => $getMarkupNew,
									'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,
									'AddMarkup' => $AddMarkup,
								);
								$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArrBR, 'Review');
								$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]['AddiTaxOnMarkup'] = ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
								$FareBreakdown[2]['AddiMarkup'] = ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
								$FareBreakdown[2]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
								$FareBreakdown[2]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
								$FareBreakdown[2]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
								$FareBreakdown[2]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
								$FareBreakdown[2]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
								$FareBreakdown[2]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
								//$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['intCommisionEarnedForAgency'];
								$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['IntCommission'];
								$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),
								"fareIdentifierSP" => $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'],
								"CommEarned" => $arrMarkUps['IntCommission'],
								"CommEarnedAgent" => $arrMarkUps['AgentB2CEarning'],
								"GSTonComm" => 0,
								"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
								"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
								"AddiTaxOnMarkup" => $arrMarkUps['AddiTaxOnMarkup'],
								"AddiMarkup" => $arrMarkUps['AddiMarkup'],

								"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,
								"newFare" => $newFare,
								"oldFare" => $oldFare,
								"arrMarkUps" => $arrMarkUps,
							);
							// echo '<pre>';
							// print_r($FairRulesArr[$kp]);
							// echo '</pre>';
						}
					}



					$BAGGAGE = isset($OriginSegments['ssrInfo']['BAGGAGE']) ? $OriginSegments['ssrInfo']['BAGGAGE'] : '';
					$MEAL = isset($OriginSegments['ssrInfo']['MEAL']) ? $OriginSegments['ssrInfo']['MEAL'] : '';
					// echo '<pre>';print_r($MEAL);echo '</pre>';
					// echo '<pre>';print_r($MEALINB);echo '</pre>';
					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) {
							$BAGGAGEARRAY = isset($segments['ssrInfo']['BAGGAGE']) ? $segments['ssrInfo']['BAGGAGE'] : '';
							$MEALARRAY = isset($segments['ssrInfo']['MEAL']) ? $segments['ssrInfo']['MEAL'] : '';
							$MealArrNew = [];
							$BaggageArrNew = [];
							if ($MEALARRAY) {
								foreach ($MEALARRAY as $m => $meals) {
									$MealArrNew[$m]['Currency'] = $this->CurrencyTitle;
									$MealArrNew[$m]['key'] = $segments['id'];
									$MealArrNew[$m]['Code'] = $meals['code'];
									$MealArrNew[$m]['Price'] = isset($meals['amount']) ? $meals['amount'] : 0;
									$MealArrNew[$m]['Description'] = $meals['desc'];
								}
							}
							if ($BAGGAGEARRAY) {
								foreach ($BAGGAGEARRAY as $b => $bag) {
									$Weight = str_replace('Excess Baggage - ', '', $bag['desc']);
									$BaggageArrNew[$b]['Currency'] = $this->CurrencyTitle;
									$BaggageArrNew[$b]['key'] = $segments['id'];
									$BaggageArrNew[$b]['Code'] = $bag['code'];
									$BaggageArrNew[$b]['Price'] = isset($bag['amount']) ? $bag['amount'] : 0;
									$BaggageArrNew[$b]['Weight'] = $Weight;
								}
							}

							$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,
								"BAGGAGEARRAY" => $BaggageArrNew,
								"MEALARRAY" => $MealArrNew,
								"SegmentNumber" => $segments['sN'],
								"isReturnSegment" => $segments['isRs'],
							);
						}
					}
					// if ($MEALARRAY) {
					// 	foreach ($MEALARRAY as $mkey => $datas) {
					// 		if ($datas) {
					// 			foreach ($datas as $m => $meals) {
					// 				$MealArr[$m]['Currency'] = 'INR';
					// 				$MealArr[$m]['key'] = $mkey;
					// 				$MealArr[$m]['Code'] = $meals['code'];
					// 				$MealArr[$m]['Price'] = isset($meals['amount']) ? $meals['amount'] : 0;
					// 				$MealArr[$m]['Description'] = $meals['desc'];
					// 			}
					// 		}
					// 	}
					// }
					// echo '<pre>';
					// print_r($MEALARRAY);
					$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';
					$FareRuleData = isset($FareRuleRequest[$key]) ? $FareRuleRequest[$key] : [];
					$arrInsertFlightData[$key]['bookingId'] = $bookingId;
					$arrInsertFlightData[$key]['bookingId_TJ'] = $bookingId_TJ;
					$arrInsertFlightData[$key]['FlightNumber'] = $strFlightNumber;
					$arrInsertFlightData[$key]['AirlineName'] = $strAirlineName;
					$arrInsertFlightData[$key]['AirlineCode'] = $AirlineCode;
					$arrInsertFlightData[$key]['AirInvenSysId'] = 0;
					$arrInsertFlightData[$key]['IsLCC'] = $IsLCC;
					$arrInsertFlightData[$key]['IsMealIncludes'] = $IsMealIncludes;
					$arrInsertFlightData[$key]['IsBagIncludes'] = $IsBagIncludes;
					$arrInsertFlightData[$key]['IsRefundable'] = $IsRefundable;
					$arrInsertFlightData[$key]['IsRefundableTxt'] = $IsRefundableTxt;
					$arrInsertFlightData[$key]['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]['ICSourceSysId'] = 7;
					$arrInsertFlightData[$key]['logo'] = $filePath;
					$arrInsertFlightData[$key]['FairRules'] = $FairRulesArr;
					$arrInsertFlightData[$key]['Segments'] = $arrSegments;
					$arrInsertFlightData[$key]['Baggage'] = $BaggageArr;
					$arrInsertFlightData[$key]['Meal'] = $MealArr;
					$arrInsertFlightData[$key]['Ispassengercity'] = false;
					$arrInsertFlightData[$key]['Ispassengeraddress'] = false;
					$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]['FareRuleData'] = $FareRuleData;

					// echo '<pre>';
					// print_r($arrInsertFlightData[$key]);
					// echo '</pre>';
					$arrInsertFlightData[$key]['arrCommonInsVariables'] = $arrCommonInsVariables;
				}
				$BaseFare = 0;
				$Tax = 0;
				$YQTax = 0;
				$OtherCharges = 0;
				$Discount = 0;
				$ServiceFee = 0;
				$ManagementFeeTax = 0;
				$AirlineGSTComponent = 0;
				$CarrierMiscFee = 0;
				$MUFee = 0;
				$intPublishedFare = 0;
				$PublishedFare_Int = 0;
				$PublishedFareAgent = 0;
				$OfferedFareAgent = 0;
				$OfferedFare = 0;
				$PLBEarned = 0;
				$IncentiveEarned = 0;
				$TdsOnPLB = 0;
				$TdsOnIncentive = 0;
				$AdditionalTxnFeeOfrd = 0;
				$AdditionalTxnFeePub = 0;
				$IsGSTRequired = 0;
				$fareIdentifier = '';
				$SeatAvailable = 0;
				$classOfBooking = 0;
				$FareClass = 0;
				$intTotalGST = 0;
				$AddiMarkup = 0;
				$AddiTaxOnMarkup = 0;
				$apiMarkup = 0;
				$IntCommission = 0;
				$apiTaxOnMarkup = 0;
				$FixedMarkUp = 0;
				$GSTOnMarkUp = 0;
				$CommEarned = 0;
				$CommEarnedAgent = 0;
				$GSTonComm = 0;
				0;
				$intGTXMarkUp = 0;
				$GTXMarkUpGST = 0;

				$AgentMarkUp = 0;
				$GSTOnAgentMarkUp = 0;
				$Agencycommission = 0;
				$TotalCommssionVal_ag = 0;
				$AdminComminAmount_ag = 0;
				$AgentB2CEarning = 0;
				$CostToAgentCustomer = 0;
				$CostToAgent = 0;
				$newFare = 0;
				$oldFare = 0;
				$FairRulesArr = [];
				$FareBreakdown = [];
				$Segments = [];
				if ($totalPriceListArr) {
					foreach ($totalPriceListArr as $kp => $price) {
						$fareDetail = $price['fd'];
						$alertsFare = isset($alerts[$kp]) ? $alerts[$kp] : [];
						$newFare = isset($alertsFare['newFare']) ? $alertsFare['newFare'] : 0;
						$oldFare = isset($alertsFare['oldFare']) ? $alertsFare['oldFare'] : 0;
						// echo '<pre>';
						// print_r($price);
						// echo '</pre>';
						$SeatAvailable = $fareDetail['ADULT']['sR'];
						$classOfBooking = $fareDetail['ADULT']['cB'];
						$Refundable = $fareDetail['ADULT']['rT'];
						$PriceID = $price['id'];
						$fareIdentifier = $price['fareIdentifier'];
						$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$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
						if (!empty($ADULT)) {
							$PaxTypeCount = 1;
						}
						if (!empty($CHILD)) {
							$PaxTypeCount = 2;
						}
						if (!empty($INFANT)) {
							$PaxTypeCount = 3;
						}
						$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
						$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
						$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents

						$ADULTNCMTDS = 0; //isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
						$CHILDNCMTDS = 0; //isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
						$INFANTNCMTDS = 0; //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(
							'getMarkupNew' => $getMarkupNew,
							'getAgencyMarkups' => $getAgencyMarkups,
							'PublishedFare' => $PublishedFare,
							'OfferedFare' => $OfferedFare,
							'intCommissionEarned' => $CommissionEarned,
							'TdsOnPLB' => $TdsOnPLB,
							'MUFee' => $MUFee,
							'intPLBEarned' => $PLBEarned,
							'intIncentiveEarned' => $IncentiveEarned,
							'intMemberCount' => $intMemberCount,
							'intFlightRoute' => $strFlightRoute,
							'interNationalSearch' => $interNationalSearch,
							'AddMarkup' => $AddMarkup,
						);
						//echo '<pre>';print_r($markUpArr);
						$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArr, 'Review');
						if ($kp == 0) {
							$PublishedFareReverse += ($arrMarkUps['PublishFare']);
						}
						$TdsOnPLBCal = isset($ADULTNCMTDS) ? str_replace('-', '', $ADULTNCMTDS) : 0;
						$markUpArrBR = array(
							'getMarkupNew' => $getMarkupNew,
							'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,
							'AddMarkup' => $AddMarkup,
						);
						$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArrBR, 'Review');


						$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]['AddiTaxOnMarkup'] += ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
						$FareBreakdown[0]['AddiMarkup'] += ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
						$FareBreakdown[0]['intTotalGST'] += $arrMarkUpsBR['intTotalGST'];
						$FareBreakdown[0]['apiMarkup'] += $arrMarkUpsBR['apiMarkup'];
						$FareBreakdown[0]['IntCommission'] += $arrMarkUpsBR['IntCommission'];
						$FareBreakdown[0]['apiTaxOnMarkup'] += $arrMarkUpsBR['apiTaxOnMarkup'];
						$FareBreakdown[0]['FixedMarkUp'] += $arrMarkUpsBR['IntAgencyFixMarkUp'];
						$FareBreakdown[0]['GSTOnMarkUp'] += $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
						$FareBreakdown[0]['CommEarned'] += $arrMarkUpsBR['intCommisionEarnedForAgency'];
						$FareBreakdown[0]['GSTonComm'] += 0;
						$FareBreakdown[0]['intGTXMarkUp'] += $arrMarkUpsBR['intGTXMarkUp'];
						$FareBreakdown[0]['GTXMarkUpGST'] += $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
						$FareBreakdown[0]['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(
								'getMarkupNew' => $getMarkupNew,
								'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,
								'AddMarkup' => $AddMarkup,
							);
							$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArrBR, 'Review');
							$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]['AddiTaxOnMarkup'] += ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
							$FareBreakdown[1]['AddiMarkup'] += ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
							$FareBreakdown[1]['intTotalGST'] += $arrMarkUpsBR['intTotalGST'];
							$FareBreakdown[1]['apiMarkup'] += $arrMarkUpsBR['apiMarkup'];
							$FareBreakdown[1]['IntCommission'] += $arrMarkUpsBR['IntCommission'];
							$FareBreakdown[1]['apiTaxOnMarkup'] += $arrMarkUpsBR['apiTaxOnMarkup'];
							$FareBreakdown[1]['FixedMarkUp'] += $arrMarkUpsBR['IntAgencyFixMarkUp'];
							$FareBreakdown[1]['GSTOnMarkUp'] += $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
							$FareBreakdown[1]['CommEarned'] += $arrMarkUpsBR['intCommisionEarnedForAgency'];
							$FareBreakdown[1]['GSTonComm'] += 0;
							$FareBreakdown[1]['intGTXMarkUp'] += $arrMarkUpsBR['intGTXMarkUp'];
							$FareBreakdown[1]['GTXMarkUpGST'] += $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
							$FareBreakdown[1]['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(
								'getMarkupNew' => $getMarkupNew,
								'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,
								'AddMarkup' => $AddMarkup,
							);
							$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTripJack($markUpArrBR, 'Review');
							$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]['AddiTaxOnMarkup'] += ($arrMarkUpsBR['AddiTaxOnMarkup'] / $PaxTypeCount);
							$FareBreakdown[2]['AddiMarkup'] += ($arrMarkUpsBR['AddiMarkup'] / $PaxTypeCount);
							$FareBreakdown[2]['intTotalGST'] += $arrMarkUpsBR['intTotalGST'];
							$FareBreakdown[2]['apiMarkup'] += $arrMarkUpsBR['apiMarkup'];
							$FareBreakdown[2]['IntCommission'] += $arrMarkUpsBR['IntCommission'];
							$FareBreakdown[2]['apiTaxOnMarkup'] += $arrMarkUpsBR['apiTaxOnMarkup'];
							$FareBreakdown[2]['FixedMarkUp'] += $arrMarkUpsBR['IntAgencyFixMarkUp'];
							$FareBreakdown[2]['GSTOnMarkUp'] += $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
							$FareBreakdown[2]['CommEarned'] += $arrMarkUpsBR['intCommisionEarnedForAgency'];
							$FareBreakdown[2]['GSTonComm'] += 0;
							$FareBreakdown[2]['intGTXMarkUp'] += $arrMarkUpsBR['intGTXMarkUp'];
							$FareBreakdown[2]['GTXMarkUpGST'] += $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
							$FareBreakdown[2]['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($arrMarkUps['PublishFare']);
						$Currency += $this->CurrencyTitle;
						$CurrencyRate += $this->CurrencyRate;
						$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_Int += ($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'];
						$AddiMarkup += $arrMarkUps['AddiMarkup'];
						$AddiTaxOnMarkup += $arrMarkUps['AddiTaxOnMarkup'];
						$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'];
						$newFare += $newFare;
						$oldFare += $oldFare;

						$seg = $arrInsertFlightData[$kp]['Segments'];
						//echo '<pre>';print_r($seg);echo '</pre>';
						$Segments[] = $seg;
					}
				}
				$FairRulesArr = array(
					"Currency" => $Currency, //$Currency,
					"CurrencyRate" => $CurrencyRate, //$Currency,
					"currencySysId" => $currencySysId,
					"BaseFare" => $BaseFare,
					"Tax" => $Tax,
					"YQTax" => $YQTax,
					"OtherCharges" => $OtherCharges,
					"Discount" => 0, //$Discount,
					"ServiceFee" => $ServiceFee,
					"ManagementFeeTax" => $ManagementFeeTax,
					"AirlineGSTComponent" => $AirlineGSTComponent,
					"CarrierMiscFee" => $CarrierMiscFee,
					"MUFee" => $MUFee,
					"intPublishedFare" => $intPublishedFare,
					"PublishedFare" => ($PublishedFare_Int),
					"PublishedFareAgent" => ($PublishedFareAgent),
					"OfferedFareAgent" => ($OfferedFareAgent),
					"OfferedFare" => $OfferedFare,
					"PLBEarned" => $PLBEarned,
					"IncentiveEarned" => $IncentiveEarned,
					"TdsOnPLB" => ($TdsOnPLB),
					"TdsOnIncentive" => 0,
					"AdditionalTxnFeeOfrd" => 0,
					"AdditionalTxnFeePub" => 0,
					"Refundable" => $Refundable,
					"IsRefundableTxt" => $IsRefundableTxt,
					"PriceID" => $PriceID,
					"IsGSTRequired" => $IsGSTRequired,
					"fareIdentifier" => $fareIdentifier,
					"SeatAvailable" => $SeatAvailable,
					"classOfBooking" => $classOfBooking,
					"FareClass" => $FareClass,
					"AddiTaxOnMarkup" => $AddiTaxOnMarkup,
					"AddiMarkup" => $AddiMarkup,
					"intTotalGST" => $intTotalGST,
					"apiMarkup" => $apiMarkup,
					"IntCommission" => $IntCommission,
					"apiTaxOnMarkup" => $apiTaxOnMarkup,
					"FixedMarkUp" => $FixedMarkUp,
					"GSTOnMarkUp" => $GSTOnMarkUp,
					"CommEarned" => $CommEarned,
					"CommEarnedAgent" => $CommEarnedAgent,
					"GSTonComm" => 0,
					"intGTXMarkUp" => $intGTXMarkUp,
					"GTXMarkUpGST" => $GTXMarkUpGST,

					"AgentMarkUp" => $AgentMarkUp,
					"GSTOnAgentMarkUp" => $GSTOnAgentMarkUp,
					'Agencycommission' => $Agencycommission,
					'TotalCommssionVal_ag' => $TotalCommssionVal_ag,
					'AdminComminAmount_ag' => $AdminComminAmount_ag,
					'AgentB2CEarning' => $AgentB2CEarning,
					'CostToAgentCustomer' => $CostToAgentCustomer,
					'CostToAgent' => $CostToAgent,
					"newFare" => $newFare,
					"oldFare" => $oldFare,
					"FareBreakdown" => $FareBreakdown,

				);
				$arrInsertFlightDataInt['bookingId'] = $arrInsertFlightData[0]['bookingId'];
				$arrInsertFlightDataInt['FlightNumber'] = $arrInsertFlightData[0]['FlightNumber'];
				$arrInsertFlightDataInt['AirlineName'] = $arrInsertFlightData[0]['AirlineName'];
				$arrInsertFlightDataInt['AirlineCode'] = $arrInsertFlightData[0]['AirlineCode'];
				$arrInsertFlightDataInt['AirInvenSysId'] = $arrInsertFlightData[0]['AirInvenSysId'];
				$arrInsertFlightDataInt['IsLCC'] = $arrInsertFlightData[0]['IsLCC'];
				$arrInsertFlightDataInt['IsMealIncludes'] = $arrInsertFlightData[0]['IsMealIncludes'];
				$arrInsertFlightDataInt['IsBagIncludes'] = $arrInsertFlightData[0]['IsBagIncludes'];
				$arrInsertFlightDataInt['IsRefundable'] = $arrInsertFlightData[0]['IsRefundable'];
				$arrInsertFlightDataInt['IsRefundableTxt'] = $arrInsertFlightData[0]['IsRefundableTxt'];
				$arrInsertFlightDataInt['apiTraceId'] = $arrInsertFlightData[0]['apiTraceId'];
				$arrInsertFlightDataInt['strTraceId'] = $arrInsertFlightData[0]['apiTraceId'];
				$arrInsertFlightDataInt['AirlineSysId'] = $arrInsertFlightData[0]['AirlineSysId'];
				$arrInsertFlightDataInt['DepartureTime'] = $arrInsertFlightData[0]['DepartureTime'];
				$arrInsertFlightDataInt['ArrivalTime'] = $arrInsertFlightData[0]['ArrivalTime'];
				$arrInsertFlightDataInt['TravelDate'] = $arrInsertFlightData[0]['TravelDate'];
				$arrInsertFlightDataInt['LocalFromTime'] = $arrInsertFlightData[0]['LocalFromTime'];
				$arrInsertFlightDataInt['FromUTCTime'] = $arrInsertFlightData[0]['FromUTCTime'];
				$arrInsertFlightDataInt['LocalToTime'] = $arrInsertFlightData[0]['LocalToTime'];
				$arrInsertFlightDataInt['ToUTCTime'] = $arrInsertFlightData[0]['ToUTCTime'];
				$arrInsertFlightDataInt['IsDirect'] = $arrInsertFlightData[0]['IsDirect'];
				$arrInsertFlightDataInt['FareClass'] = $arrInsertFlightData[0]['FareClass'];
				$arrInsertFlightDataInt['LAYOVERCity'] = $arrInsertFlightData[0]['LAYOVERCity'];
				$arrInsertFlightDataInt['GroundTime'] = $arrInsertFlightData[0]['GroundTime'];
				$arrInsertFlightDataInt['LAYOVERDuration'] = $arrInsertFlightData[0]['LAYOVERDuration'];
				$arrInsertFlightDataInt['FlyingMinutes'] = $arrInsertFlightData[0]['FlyingMinutes'];
				$arrInsertFlightDataInt['DepartureDateTxt'] = $arrInsertFlightData[0]['DepartureDateTxt'];
				$arrInsertFlightDataInt['ArrivalDateTxt'] = $arrInsertFlightData[0]['ArrivalDateTxt'];
				$arrInsertFlightDataInt['FlightDuration'] = $arrInsertFlightData[0]['FlightDuration'];
				$arrInsertFlightDataInt['SourcePlaceSysId'] = $arrInsertFlightData[0]['SourcePlaceSysId'];
				$arrInsertFlightDataInt['DestPlaceSysId'] = $arrInsertFlightData[0]['DestPlaceSysId'];
				$arrInsertFlightDataInt['SourceAirportCode'] = $arrInsertFlightData[0]['SourceAirportCode'];
				$arrInsertFlightDataInt['DestAirportCode'] = $arrInsertFlightData[0]['DestAirportCode'];
				$arrInsertFlightDataInt['StopCount'] = $arrInsertFlightData[0]['StopCount'];
				$arrInsertFlightDataInt['Stops'] = $arrInsertFlightData[0]['Stops'];
				$arrInsertFlightDataInt['NoOfSeatAvailable'] = $arrInsertFlightData[0]['NoOfSeatAvailable'];
				$arrInsertFlightDataInt['TotalFlightMembers'] = $arrInsertFlightData[0]['TotalFlightMembers'];
				$arrInsertFlightDataInt['CurrencyType'] = $arrInsertFlightData[0]['CurrencyType'];
				$arrInsertFlightDataInt['PublishedFare'] = $FairRulesArr['PublishedFare'];
				$arrInsertFlightDataInt['ApiResultIndex'] = $arrInsertFlightData[0]['ApiResultIndex'];
				$arrInsertFlightDataInt['JourneyType'] = $arrInsertFlightData[0]['JourneyType'];
				$arrInsertFlightDataInt['TripType'] = $arrInsertFlightData[0]['TripType'];
				$arrInsertFlightDataInt['IsInternational'] = $arrInsertFlightData[0]['IsInternational'];
				$arrInsertFlightDataInt['ICSourceSysId'] = 7;
				$arrInsertFlightDataInt['logo'] = $arrInsertFlightData[0]['logo'];
				$arrInsertFlightDataInt['Fare'] = $FairRulesArr;
				$arrInsertFlightDataInt['Segments'] = $Segments;
				$arrCommonInsVariables = array(
					'strTraceId' => $arrInsertFlightData[0]['apiTraceId'],
					'localFromDateTime' => $arrInsertFlightData[0]['LocalFromTime'],
					'localToDateTime' => $arrInsertFlightData[0]['LocalToTime'],
					'strSourceAirportCode' => $strSourceAirportCode,
					'strDestinationAirportCode' => $strDestinationAirportCode,
					'intMemberCount' => $intMemberCount,
					'intSourceCityId' => $intSourceCityId,
					'intDestinationCityId' => $intDestinationCityId,
					'JourneyType' => 2, // For Round Trips API Search
					'TripType' => 1,
					'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0
				);
				if ($interNationalSearch == 1 && $strFlightRoute == 2) {
					$arrInsertFlightDataInt[0]['arrCommonInsVariables'] = $arrCommonInsVariables;
					$arrInsertFlightData[0]['InternationalData'] = $arrInsertFlightDataInt;
				}
				// echo '<pre>';
				// print_r(($arrInsertFlightData));
				// echo '</pre>';
				// echo '<pre>';
				// print_r(($FareBreakdown));
				// echo '</pre>';
			}
		} 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 = 0; //isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
							$CHILDNCMTDS = 0; //isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
							$INFANTNCMTDS = 0; //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]['ICSourceSysId'] = 7;
					$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' => [], 'IsTJFlightAPI' => $this->IsTJFlightAPI));
		$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, 'IsTJFlightAPI' => $this->IsTJFlightAPI));
			$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);
			$tripSeatMap = json_decode($getData['tripSeatMap'], true);
			$CustomerSession = json_decode($getData['TotalTravellers'], true);
			$selectedSeatSession = json_decode($getData['selectedSeatSession'], true);
			$FlightSeatSession = json_decode($getData['FlightSeatSession'], true);
			$ICSourceSysId = isset($FlightBookingData[0]['ICSourceSysId']) ? $FlightBookingData[0]['ICSourceSysId'] : 0;
			// echo '<pre>';print_r($FlightSeatSession);
			//echo '<pre>';print_r($FlightBookingData);
			//die;
			$bookingId = $FlightBookingData[0]['bookingId_TJ'];
			$data = ['bookingId' => $bookingId];
			if ($ICSourceSysId == 7) {
				if (!empty($FlightSeatSession)) {
					$apiResponse = $FlightSeatSession;
				} else {
					$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetSeatMapFlightsTripJack($data);
				}
			} else {
				$apiResponse = $tripSeatMap;
			}


			// $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, 'IsTJFlightAPI' => $this->IsTJFlightAPI, '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 = [];
		}


		$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;
					}
				}
			}
		}
		// echo '<pre>'; print_r($BaggageArr);
		// echo '<pre>'; print_r($MealArr);
		// die;
		$SeatPrice = 0;
		if ($SelectedSeat) {
			foreach ($SelectedSeat as $values) {
				foreach ($values as $val) {
					$SeatPrice += $val['amount'];
				}
			}
		}

		$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']['PublishedFareAgent'];
			}
		}
		$apiResponse = ($FlightBookingData);
		$Data = $apiResponse;
		$MobilePublishedFare = ($intNetPublishedFare + $MealFare + $BaggFare + $SeatPrice);

		$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' => $this->CurrencyTitle . ' ' . number_format($MobilePublishedFare, 2), '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 $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'];
					}
				}
			}
			$MealFare = ($MealPrice + $InbMealPrice);
			$BaggFare = ($BagPrice + $InbBagPrice);
			$intNetPublishedFare = 0;
			if ($FlightBookingData) {
				foreach ($FlightBookingData as $value) {
					$intNetPublishedFare += $value['FairRules']['PublishedFareAgent'];
				}
			}
			//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' => $this->CurrencyTitle . ' ' . number_format($MobilePublishedFare, 2), 'html' => $bodyText);
			echo json_encode($response);
			exit;
		} else {
			die('Page not found!');
		}
	}
	public function farebreackupmobileAction()
	{
		$this->_helper->layout->disableLayout();
		$param = $this->getRequest()->getParams();
		$sessionFlightSearchParams = json_decode($param['sessionFlightSearchParams'], true);
		$SelectedMeal = json_decode($param['SelectedMeal'], true);
		$SelectedBagg = json_decode($param['SelectedBagg'], true);
		$SelectedSeat = json_decode($param['SelectedSeat'], true);
		$FlightBookingData = json_decode($param['intOutBoundId'], true);

		$this->view->CurrencyRate = $this->CurrencyRate;
		$this->view->CurrencyRate = $this->CurrencyRate;
		$this->view->baseUrl = $this->baseUrl;
		$this->view->IsTJFlightAPI = $this->IsTJFlightAPI;
		$this->view->Data = $FlightBookingData;
		$this->view->SelectedMealSessionNew = $SelectedMeal;
		$this->view->SelectedBaggSessionNew = $SelectedBagg;
		$this->view->selectedSeatSession = $SelectedSeat;
		$this->view->sessionFlightSearchParams = $sessionFlightSearchParams;
	}
	public function genrateFlightQuery($post)
	{

		$BookingData = !empty($post['intOutBoundId']) ? json_decode($post['intOutBoundId'], true) : 0;
		$sessionFlightSearchParams = !empty($post['sessionFlightSearchParams']) ? json_decode($post['sessionFlightSearchParams'], true) : 0;
		$SelectedBaggSessionNew = !empty($post['SelectedBaggSessionNew']) ? json_decode($post['SelectedBaggSessionNew'], true) : 0;
		$SelectedMealSessionNew = !empty($post['SelectedMealSessionNew']) ? json_decode($post['SelectedMealSessionNew'], true) : 0;
		$selectedSeatSession = !empty($post['selectedSeatSession']) ? json_decode($post['selectedSeatSession'], true) : 0;
		$FlightTraceId = $post['FlightTraceId'];
		$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'];
				}
			}
		}
		$MealFare = ($MealPrice);
		$BaggFare = ($BagPrice);
		$SeatFare = ($SeatPrice);
		// echo '<pre>';
		// print_r($MealFare);
		// echo '<pre>';
		// print_r($BaggFare);
		// echo '<pre>';
		// print_r($SeatPrice);
		// die;
		$class = $sessionFlightSearchParams['class'];
		$interNationalSearch = $sessionFlightSearchParams['interNationalSearch'];
		$route = $sessionFlightSearchParams['route'];
		$departureDates = $sessionFlightSearchParams['departure_date'][0];
		$returnDate = $sessionFlightSearchParams['return_date'][0];
		if (!empty($departureDates)) {
			$arrDepartureDates = explode("/", $departureDates);
			$departureDatesAD = $arrDepartureDates[2] . "-" . $arrDepartureDates[1] . "-" . $arrDepartureDates[0];
		}

		$Segments_c = current($BookingData);
		$Segments_E = end($BookingData);
		$arrCurrentSegments1 = current($Segments_c['Segments']);
		$arrEndSegments1 = end($Segments_c['Segments']);

		$Mobile = $post['leadMobile'];
		$emailId = $post['leadEmail'];
		$adultCount = isset($sessionFlightSearchParams['adults']) ? $sessionFlightSearchParams['adults'] : 0;
		$childCount = isset($sessionFlightSearchParams['childs']) ? $sessionFlightSearchParams['childs'] : 0;
		$infantCount = isset($sessionFlightSearchParams['infants']) ? $sessionFlightSearchParams['infants'] : 0;

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

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

		$departuredate = str_replace('T', ' ', $arrCurrentSegments1['originDepTime']);
		$arrivaldate = str_replace('T', ' ', $arrEndSegments1['destinationArrTime']);
		$FlightNumber = $BookingData[0]['FlightNumber'];
		$IsSeriesFareData = isset($BookingData[0]['IsSeriesFareData']) ? $BookingData[0]['IsSeriesFareData'] : 0;
		$ICSourceSysId = isset($BookingData[0]['ICSourceSysId']) ? $BookingData[0]['ICSourceSysId'] : 0;
		//$PublishedFare = $FlightBookingData['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'];
				//echo '<pre>';print_r($booking);echo '</pre>';
				// $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));
				$SeatPrice = 0;
				$BagPrice = 0;
				$MealPrice = 0;
				if ($booking['Segments']) {
					foreach ($booking['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'];
							}
						}
					}
				}
				$FareSummary[$k] = array(
					'PublishedFare' => ($PublishedFareINT + $BagPrice + $MealPrice + $SeatPrice),
					'AgentCommisionEarned' => $AgentCommisionEarnedINT,
					'AgentCommisionEarnedGST' => $AgentCommisionEarnedGSTINT,
					'AgencyMarkUp' => $AgencyMarkUpINT,
					'AgencyMarkUpGST' => $AgencyMarkUpGSTINT,
					'GTXMarkUp' => $GTXMarkUpINT,
					'BaseAmount' => ($BaseAmountINT + $BagPrice + $MealPrice + $SeatPrice),
					'MealPrice' => $MealPrice,
					'BagPrice' => $BagPrice,
					'SeatPrice' => $SeatPrice,
				);
			}
		}
		//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'] = (isset($departureDates) && $departureDates != '') ? $departureDates : date('d/m/Y', strtotime($departuredate));
		$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' => $ICSourceSysId,
			'roominfojson' => $RoomInfoJson,
			'AgentCommisionEarned' => $AgentCommisionEarned,
			'AgentCommisionEarnedGST' => $AgentCommisionEarnedGST,
			'AgencyMarkUp' => $AgencyMarkUp,
			'AgencyMarkUpGST' => $AgencyMarkUpGST,
			'GTXMarkUp' => $GTXMarkUp,
			'GTXMarkUpGST' => $GTXMarkUpGST,
			'BaseAmount' => ($BaseAmount + $BaggFare + $MealFare + $SeatFare),
			'PublishedFare' => ($PublishedFare + $BaggFare + $MealFare + $SeatFare),
			'MealFare' => $MealFare,
			'BaggFare' => $BaggFare,
			'SeatFare' => $SeatFare,
			'IsB2BQuery' => true,
			'B2BAgentSysId' => $this->_session->data['UserSysId'],
			'B2BAgencySysId' => $this->_session->data['AgencySysId'],
			'leadsource' => 'Website B2B',
			'IsB2BProposal' => 1
		);
		if ($route == 4) {
			$this->IsTJFlightAPI = 1;
		}
		if ($ICSourceSysId == 3) {
			//$sabirArray['ICSourceSysId'] = ($IsSeriesFareData == 1) ? 8 : 3;
		}
		// echo '<pre>';
		// print_r($sabirArray);
		// die;
		$model = new Gtxwebservices_Model_Webservices();
		$result = $model->genrateFlightQuery($sabirArray);
		$strFilePath = "flight/SearchParam/" . $FlightTraceId . "/FlightQueryids/" . time() . "_error.json";
		Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, ($result));
		$response = json_decode($result, true);

		$ResponseStatus = isset($response['status']) ? $response['status'] : 0;
		$ErrorMessage = isset($response['message']) ? $response['message'] : '';
		$logParams = [
			"user_id"      => 1,
			"custom_error" => ($ResponseStatus == 1) ? "GTX Query Create Success" : "GTX Query Create Failed",
			'error'        => $ErrorMessage,
			"text_udf"     => ['response' => $response], // Response
			"char_udf"     => ['request' => $sabirArray], // Request
			"udf1"         => $FlightTraceId,
			"status"       => ($ResponseStatus == 1) ? 2 : 1,
		];
		Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);

		Zend_Session::namespaceUnset('ResponseFlightQuery');
		$ResponseFlightQuery = new Zend_Session_Namespace('ResponseFlightQuery');
		$ResponseFlightQuery->params = $response;

		return $response;
	}

	public function getsetcityAction()
	{

		$this->_helper->layout->disableLayout();
		$this->_helper->viewRenderer->setNoRender(true);

		$flightsourcedestin = $this->objMdl->rv_select_all('tbl_flight', ['*'], ['IsActive' => 1, 'isMarkForDel' => 0], ['order_by' => 'ASC'], 20);
		//	echo "<pre>"; print_r($flightsourcedestin); die('test');
		$array = array();


		foreach ($flightsourcedestin as $key => $flightcode) {
			$data = json_decode($flightcode['city_json'], true);
			$explode = explode(',', $data['label']);
			$explodenew = explode('(', $explode[1]);
			$finalair = explode('-', $explodenew[0]);
			if (isset($finalair[1])) {
				$airportsname = $finalair[1];
			} else {
				$airportsname = $finalair[0];
			}

			$dataenc['AirportCode'] = $data['AirportCode'];
			$dataenc['CityID'] = $data['CityID'];
			$dataenc['ContSysId'] = $data['ContSysId'];
			$dataenc['ICAO'] = $data['ICAO'];
			$dataenc['CountryCode'] = $data['CountryCode'];
			$dataenc['DO'] = $data['DO'];
			$dataenc['cn'] = $data['cn'];
			$dataenc['label'] = $data['label'];

			$array[] = $dataenc;
			//echo "<pre>"; print_r($array); die('testwww');

		}

		$arrContextOptions = array(
			"ssl" => array(
				"verify_peer" => false,
				"verify_peer_name" => false,
			),
		);
		// echo "<pre>"; print_r($arrContextOptions); die('test43543www');

		$str = file_get_contents($this->baseUrl . 'public/data/dynamic/flight_destinations.json', false, stream_context_create($arrContextOptions));
		//   echo "<pre>";
		//   echo ($str);
		//   die('test');
		$array2 = json_decode($str, true);

		$finalArray = array_merge($array, $array2);

		$input = $this->multi_unique($finalArray);
		//	echo "<pre>"; print_r($input); die('test43543www');
		$response = json_encode(array_values($input));
		echo $response;
		//echo "<pre>"; print_r($response); die('test43543www');

		exit;
	}
	public function multi_unique($array)
	{
		foreach ($array as $k => $na) {
			$new[$k] = serialize($na);
		}

		$uniq = array_unique($new);
		foreach ($uniq as $k => $ser) {
			$new1[$k] = unserialize($ser);
		}

		return ($new1);
	}

	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;
				$SeatDynamic = !empty($this->getRequest()->getParam('SeatDynamic')) ? json_decode($this->getRequest()->getParam('SeatDynamic'), true) : 0;
				$checkEditCustomerData = ($post['checkEditCustomerData']) ? ($post['checkEditCustomerData']) : 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;

				//  $dffdfdfdf = $this->genrateFlightQuery($post);
				// echo '<pre>';
				// print_r($dffdfdfdf);
				// echo '<pre>';
				// print_r($BookingData);
				// print_r($SeatDynamic);
				// 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'],
				);
				$param['AgencySysId'] = $this->gtxagencysysid;

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

				$paxArray = [];
				for ($ii = 1; $ii <= $totalPassengers; $ii++) {
					$firstName = $post['passenger-firstname-' . $ii];
					$lastName = $post['passenger-lastname-' . $ii];
					$paxArray[] = ucfirst(trim($firstName)) . ' ' . ucfirst(trim($lastName));
				}
				if (array_diff_assoc($paxArray, array_unique($paxArray))) {
					$response = array('succes' => false, 'msg' => " Any two passengers can't have same name.", 'index' => '');
					echo json_encode($response);
					exit;
				}


				$key = 0;
				$CityTitle = isset($post['passenger-city-name-1']) ? $post['passenger-city-name-1'] : '';
				$passengerCity = isset($post['passenger-city-1']) ? $post['passenger-city-1'] : '';
				$CountrySysId = isset($post['passenger-country-1']) ? $post['passenger-country-1'] : '';
				$passengerAddress = isset($post['passenger-address-1']) ? $post['passenger-address-1'] : '';
				$passengercountryName = isset($post['passenger-countryName-1']) ? $post['passenger-countryName-1'] : '';
				$IsSeriesFareData = isset($BookingData[0]['IsSeriesFareData']) ? $BookingData[0]['IsSeriesFareData'] : 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 (strlen(trim($firstName)) < 2) {
						$response = array('succes' => false, 'msg' => 'Length of the First Name should be minimum 2 characters.', '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 (strlen(trim($lastName)) < 2) {
						$response = array('succes' => false, 'msg' => 'Length of the Last Name should be minimum 2 characters.', 'index' => 'passenger-lastname-' . $i);
						echo json_encode($response);
						exit;
					}


					if ($paxType == 1 && $isAdobrMandatory) {
						if (empty($passengerDob) && ($passengerDob == '1900-01-01' || $passengerDob == '00/00/0000' || $passengerDob == '____-__-__')) {
							$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' || $passengerDob == '00/00/0000' || $passengerDob == '____-__-__')) {
							$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) {
						//print_r($passengerDob);
						if (empty($passengerDob) || ($passengerDob == '1900-01-01' || $passengerDob == '00/00/0000' || $passengerDob == '____-__-__')) {
							$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;
						}
						$expiry_date = $this->calculateDiff($departure_dates, $passengerPassportExpiry);
						//$passportmonth = (int)date_diff(date_create($passengerPassportExpiry), date_create($departure_dates))->m;

						if ($expiry_date < '6') {
							$response = array('succes' => false, 'msg' => 'Passport Expiry Date cannot be less than 6 months from last travel 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;
						}
					}
					if ($route == 4) {
						$this->IsTJFlightAPI = 1;
					}
					$ICSourceSysId = isset($BookingData[0]['ICSourceSysId']) ? $BookingData[0]['ICSourceSysId'] : 0;
					if ($ICSourceSysId == 3 && $IsSeriesFareData == 0) {
						if (empty(trim($CityTitle))) {
							$response = array('succes' => false, 'msg' => 'Please enter City.', 'index' => 'passenger-city-1');
							echo json_encode($response);
							exit;
						}
						if (empty(trim($passengerCity))) {
							$response = array('succes' => false, 'msg' => 'Please enter valid City.', 'index' => 'passenger-city-1');
							echo json_encode($response);
							exit;
						}

						if (empty(trim($passengerAddress))) {
							$response = array('succes' => false, 'msg' => 'Please enter Address.', 'index' => 'passenger-address-1');
							echo json_encode($response);
							exit;
						}
					}
					$IsExistcustomer = '';
					$CustomerSysIdPost = $post['CustomerSysId-' . $i];
					if (!empty($CustomerSysIdPost) && $CustomerSysIdPost != '0') {
						$IsExistcustomer = $objFlight->CheckCustomer('tbl_customer', array('CustomerSysId' => $CustomerSysIdPost, 'AgencySysId' => $this->gtxagencysysid));
					}

					$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 ($ICSourceSysId == 3) {
							$arrCustomer['Address'] = $ForCustomerSession[$key]['Address'] = $passengerAddress;
							$arrCustomer['CityTitle'] = $ForCustomerSession[$key]['CityTitle'] = $CityTitle;
							$arrCustomer['CitySysId'] = $ForCustomerSession[$key]['CitySysId'] = $passengerCity;
							$arrCustomer['CountrySysId'] = $ForCustomerSession[$key]['CountrySysId'] = $CountrySysId;
							$arrCustomer['countryName'] = $ForCustomerSession[$key]['countryName'] = $passengercountryName;
						}
						// if ($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, 'AgencySysId' => $this->gtxagencysysid));
						}
						$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 ($ICSourceSysId == 3) {
							$arrCustomerMembers['Address'] = $ForCustomerSession[$key]['Address'] = $passengerAddress;
							$arrCustomerMembers['CityTitle'] = $ForCustomerSession[$key]['CityTitle'] = $CityTitle;
							$arrCustomerMembers['CitySysId'] = $ForCustomerSession[$key]['CitySysId'] = $passengerCity;
							$arrCustomerMembers['CountrySysId'] = $ForCustomerSession[$key]['CountrySysId'] = $CountrySysId;
							$arrCustomerMembers['countryName'] = $ForCustomerSession[$key]['countryName'] = $passengercountryName;
						}
						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($CustomerSysId);
				// die;
				// 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 ($interNationalSearch == 1 && $route == 2 && $this->IsTJFlightAPI == 0) {
					$dataArrInter = $this->CreateInternationDataArr($BookingData, $sessionFlightSearchParams, !empty($CustomerSysId) ? $CustomerSysId : $bookCustomerId);
					// echo '<pre>';print_r($dataArrInter);
					// die;
					$dataArrInter['origin']['bookedby'] = ($this->_session->data['FirstName']) . ' ' . trim($this->_session->data['LastName']);
					if (count($ForCustomerSession) > 1) {
						$dataArrInter['origin']['CustomerDetails'] = $ForCustomerSession[0]['FirstName'] . ' ' . $ForCustomerSession[0]['LastName'] . ' (+' . (count($ForCustomerSession)) . ')';
					} else {
						$dataArrInter['origin']['CustomerDetails'] = $ForCustomerSession[0]['FirstName'] . ' ' . $ForCustomerSession[0]['LastName'];
					}
					$flight_booking_id = $flight_booking_id_Arr[] = $objFlight->InsertFlightData('tbl_flight_booking', $dataArrInter['origin']);
					// $dataArrInter['destination']['parent_id'] = $flight_booking_id;
					// $flight_booking_id = $flight_booking_id_Arr[] = $objFlight->InsertFlightData('tbl_flight_booking', $dataArrInter['destination']);
					$flight_booking_customer[0] = $this->InsertFlightBookingCustomer($ForCustomerSession, $arrmembersId, $dataArrInter['origin'], $flight_booking_id);

					// echo '<pre>';print_r($flight_booking_id_Arr);
					// echo '<pre>';print_r($flight_booking_customer);

				} else {
					$IsSeriesFareData = isset($BookingData[0]['IsSeriesFareData']) ? $BookingData[0]['IsSeriesFareData'] : 0;

					if ($BookingData) {
						foreach ($BookingData as $k => $value) {
							$TotalBaseFare = 0;
							$TotalTaxsandFees = 0;
							$CostToAgent = 0;
							$CostToAgentCustomer = 0;
							$CommRetained = 0;
							$TotalAgentMarkUp = 0;
							$TotalGSTOnAgentMarkUp = 0;
							if ($value['FairRules']['FareBreakdown']) {
								foreach ($value['FairRules']['FareBreakdown'] as $FareBreakdown) {
									$PBaseFare = $FareBreakdown['BaseFare'];
									$intGTXMarkUp = $FareBreakdown['intGTXMarkUp'];
									$GTXMarkUpGST = $FareBreakdown['GTXMarkUpGST'];
									$intTotalGST = $FareBreakdown['intTotalGST'];
									$FixedMarkUp = $FareBreakdown['FixedMarkUp'];
									$apiMarkup = $FareBreakdown['apiMarkup'];
									$AgentMarkUp = $FareBreakdown['AgentMarkUp'];
									$GSTOnAgentMarkUp = $FareBreakdown['GSTOnAgentMarkUp'];
									$IntCommission = $FareBreakdown['IntCommission'];
									$TotalBaseFare += $PBaseFare;
									$TDS = $FareBreakdown['TDS']; //TDS Fee
									$MF = $FareBreakdown['MF']; //Management Fee
									$YQ = $FareBreakdown['YQ']; //Fuel Surcharge
									$AGST = $FareBreakdown['AGST']; //Airline GST Component
									$MFT = $FareBreakdown['MFT']; //Management Fee Tax
									$OT = $FareBreakdown['OT']; //Other Charges
									$MU = $FareBreakdown['MU']; //Markup
									$YR = $FareBreakdown['YR']; //Carrier Misc Fee
									if ($this->IsTJFlightAPI) {
										$otherCharge = ($YQ + $AGST + $MFT + $MF + $OT + $YR + $intGTXMarkUp + $GTXMarkUpGST);
									} else {
										$otherCharge = ($YQ + $AGST + $MFT + $MF + $OT + $YR + $intGTXMarkUp + $GTXMarkUpGST + $TDS);
									}

									$TaxesFees = ($otherCharge + $intTotalGST + $FixedMarkUp + $apiMarkup + $AgentMarkUp + $GSTOnAgentMarkUp - $IntCommission);
									$TotalTaxsandFees += $TaxesFees;
									$CostToAgent += $FareBreakdown['CostToAgent'];
									$CostToAgentCustomer += $FareBreakdown['CostToAgentCustomer'];
									$CommRetained += $FareBreakdown['AdminComminAmount_ag'];
									$TotalAgentMarkUp += $AgentMarkUp;
									$TotalGSTOnAgentMarkUp += $GSTOnAgentMarkUp;
								}
							}
							$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'];
										}
									}
								}
							}
							try {
								$ExtraMarkup = ($value['FairRules']['ExtraMarkup']) ? $value['FairRules']['ExtraMarkup'] : 0;
								$ExtraMarkupOnGST = ($value['FairRules']['ExtraMarkupOnGST']) ? $value['FairRules']['ExtraMarkupOnGST'] : 0;
								$arrPlanAir['AgencySysId'] = $this->gtxagencysysid;
								$arrPlanAir['CustomerSysId'] = !empty($CustomerSysId) ? $CustomerSysId : $bookCustomerId;
								$arrPlanAir['FlightNumber'] = $value['FlightNumber'];
								$arrPlanAir['AirlineName'] = $value['AirlineName'];
								$arrPlanAir['ICSourceSysId'] = $value['ICSourceSysId'];
								$arrPlanAir['BookingId'] = $value['bookingId'];
								$arrPlanAir['APIBookingId'] = $value['bookingId_TJ'];
								$arrPlanAir['TravelDate'] = ($value['TravelDate'] != '') ? $value['TravelDate'] : '1900-01-01';
								$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'] = isset($value['IsDirect']) ? $value['IsDirect'] : 0;
								$arrPlanAir['FareClass'] = $value['FareClass'];
								$arrPlanAir['FlyingMinutes'] = isset($value['FlyingMinutes']) ? $value['FlyingMinutes'] : 0;
								$arrPlanAir['FlightDuration'] = $value['FlightDuration'];
								$arrPlanAir['SourcePlaceSysId'] = (int)$value['SourcePlaceSysId'];
								$arrPlanAir['DestPlaceSysId'] = (int)$value['DestPlaceSysId'];
								$arrPlanAir['SourceAirportCode'] = $value['SourceAirportCode'];
								$arrPlanAir['DestAirportCode'] = $value['DestAirportCode'];
								$arrPlanAir['StopCount'] = $value['StopCount'];
								$arrPlanAir['TotalFlightMembers'] = $value['TotalFlightMembers'];
								$arrPlanAir['CurrencyType'] = $value['CurrencyType'];
								$arrPlanAir['PublishedFare'] = ($value['FairRules']['CostToAgentCustomer']) ? $value['FairRules']['CostToAgentCustomer'] : 0;
								$arrPlanAir['ApiResultIndex'] = isset($value['ApiResultIndex']) ? $value['ApiResultIndex'] : $value['SearchTraceId'];
								$arrPlanAir['JourneyType'] = $value['JourneyType'];
								$arrPlanAir['TripType'] = $value['TripType'];
								$arrPlanAir['IsInternational'] = ($value['IsInternational']) ? $value['IsInternational'] : 0;
								$arrPlanAir['logo'] = $value['logo'];
								$arrPlanAir['Currency'] = ($value['FairRules']['Currency']) ? $value['FairRules']['Currency'] : 'INR';
								$arrPlanAir['BaseFare'] = $TotalBaseFare;
								$arrPlanAir['Tax'] = $TotalTaxsandFees;
								$arrPlanAir['YQTax'] = (isset($value['FairRules']['YQTax']) && trim($value['FairRules']['YQTax']) != '') ? (float)trim($value['FairRules']['YQTax']) : '0';
								$arrPlanAir['OtherCharges'] = ($value['FairRules']['OtherCharges']) ? $value['FairRules']['OtherCharges'] : 0;
								$arrPlanAir['Discount'] = ($value['FairRules']['Discount']) ? $value['FairRules']['Discount'] : 0;
								$arrPlanAir['ServiceFee'] = ($value['FairRules']['ServiceFee']) ? $value['FairRules']['ServiceFee'] : 0;
								$arrPlanAir['OfferedFare'] = ($value['FairRules']['CostToAgent']) ? $value['FairRules']['CostToAgent'] : 0;
								$arrPlanAir['AgencyMarkUp'] = ($value['FairRules']['FixedMarkUp']) ? $value['FairRules']['FixedMarkUp'] : 0;
								$arrPlanAir['AgencyMarkUpGST'] = ($value['FairRules']['GSTOnMarkUp']) ? $value['FairRules']['GSTOnMarkUp'] : 0;
								$arrPlanAir['GTXMarkUp'] = ($value['FairRules']['intGTXMarkUp']) ? $value['FairRules']['intGTXMarkUp'] : 0;
								$arrPlanAir['GTXMarkUpGST'] = ($value['FairRules']['GTXMarkUpGST']) ? $value['FairRules']['GTXMarkUpGST'] : 0;
								$arrPlanAir['fareIdentifierSP'] = ($value['FairRules']['fareIdentifierSP']) ? $value['FairRules']['fareIdentifierSP'] : '';
								$arrPlanAir['BagPrice'] = $BagPrice;
								$arrPlanAir['MealPrice'] = $MealPrice;
								$arrPlanAir['SeatPrice'] = $SeatPrice;
								$arrPlanAir['ExtraMarkup']     = $ExtraMarkup;
								$arrPlanAir['ExtraMarkupOnGST']     = $ExtraMarkupOnGST;
								$arrPlanAir['AgentCommisionEarned'] = ($CommRetained + $TotalAgentMarkUp + $TotalGSTOnAgentMarkUp);
								$arrPlanAir['bookingData'] = json_encode($value);
								$arrPlanAir['bookedby'] = ($this->_session->data['FirstName']) . ' ' . trim($this->_session->data['LastName']);
								if (count($ForCustomerSession) > 1) {
									$arrPlanAir['CustomerDetails'] = $ForCustomerSession[0]['FirstName'] . ' ' . $ForCustomerSession[0]['LastName'] . ' (+' . (count($ForCustomerSession) - 1) . ')';
								} else {
									$arrPlanAir['CustomerDetails'] = $ForCustomerSession[0]['FirstName'] . ' ' . $ForCustomerSession[0]['LastName'];
								}

								//$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_id);
							} catch (Exception $e) {
								echo $e->getMessage();
								exit;
							}
						}
						$flight_booking_customer_id = new Zend_Session_Namespace('flight_booking_customer_id');
						$flight_booking_customer_id->params = $flight_booking_customer;
					}
				}
				// echo '<pre>';
				// print_r($flight_booking_customer);
				// echo '<pre>';
				// print_r($flight_booking_id_Arr);
				// die;
				if ($flight_booking_customer && $flight_booking_id_Arr) {
					if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
						$checkInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckInventorycheckRetriveUpdateNew($BookingData, $sessionFlightSearchParams);
						if ($checkInventory[0]['Status'] == 1) {
							$BookingData[0]['bookingId'] = isset($checkInventory[0]['data']['RefNo']) ? $checkInventory[0]['data']['RefNo'] : 0;
							$intOutBoundId = json_decode($post['intOutBoundId'], 1);
							$intOutBoundId[0]['bookingId'] = isset($checkInventory[0]['data']['RefNo']) ? $checkInventory[0]['data']['RefNo'] : 0;
							$intOutBoundIdJson = json_encode($intOutBoundId);
							$post['intOutBoundId'] = $intOutBoundIdJson;
						} else {
							$checkInventoryResponse = array('success' => $checkInventory[0]['Status'], 'status' => $checkInventory[0]['Status'], 'msg' => ($checkInventory[0]['message'] != '') ? $checkInventory[0]['message'] : 'Seats are no available.');
							echo json_encode($checkInventoryResponse);
							exit;
						}
						if (isset($checkInventory[1]['Status']) && !empty($checkInventory[1]) && $route == 2) {
							if ($checkInventory[1]['Status'] == 1) {
								$BookingData[1]['bookingId'] = isset($checkInventory[1]['data']['RefNo']) ? $checkInventory[1]['data']['RefNo'] : 0;
								$intOutBoundId = json_decode($post['intOutBoundId'], 1);
								$intOutBoundId[1]['bookingId'] = isset($checkInventory[1]['data']['RefNo']) ? $checkInventory[1]['data']['RefNo'] : 0;
								$intOutBoundIdJson = json_encode($intOutBoundId);
								$post['intOutBoundId'] = $intOutBoundIdJson;
							} else {
								$checkInventoryResponse = array('success' => $checkInventory[1]['Status'], 'status' => $checkInventory[1]['Status'], 'msg' => ($checkInventory[1]['message'] != '') ? $checkInventory[1]['message'] : 'Seats are no available.');
								echo json_encode($checkInventoryResponse);
								exit;
							}
						}
					}
					// echo '<pre>';print_r($BookingData);
					// die;

					//$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,
						'SeatDynamic' => $SeatDynamic,
						'genrateFlightQuery' => [], //$genrateFlightQuery,
						'post' => $post,
						'apiData' => $apiData,
					);

					$tempData = array(
						'TraceId' => $post['FlightTraceId'],
						'json_data' => json_encode($arrData),
					);
					$objFlight->deleteFlightTempData($SearchTraceId);
					$objFlight->insertFlightTempData($tempData);

					// 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 calculateDiff($departureDate, $ExpirtyDate)
	{
		$date1 = strtotime($departureDate);
		$date2 = strtotime($ExpirtyDate);
		// Formulate the Difference between two dates
		$diff = abs($date2 - $date1);
		$years = floor($diff / (365 * 60 * 60 * 24));
		$months = floor(($diff - $years * 365 * 60 * 60 * 24) / (30 * 60 * 60 * 24));
		$days = floor(($diff - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 * 24) / (60 * 60 * 24));
		return abs((date('Y', $date2) - date('Y', $date1)) * 12 + (date('m', $date2) - date('m', $date1)));
		//return ['years' => $years, 'months' => $months, 'days' => $days];
	}
	public function InsertFlightBookingCustomer($data, $arrmembersId, $arrPlain, $flight_booking_id)
	{
		$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,
					'flight_booking_id' => $flight_booking_id,
					'CustomerSysId' => $arrmembersId[$i],
					'apiTraceId' => ($arrPlain['SearchTraceId']) ? $arrPlain['SearchTraceId'] : $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 CreateInternationDataArr($BookingData, $sessionFlightSearchParams, $CustomerSysId)
	{
		$arrPlanAir = [];
		$arrPlanAirDes = [];
		$url = $this->baseUrl . "public/data/dynamic/flight_destinations.json";
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
		$str = curl_exec($ch);
		//        $str = file_get_contents($this->baseUrl . 'public/data/dynamic/flight_destinations.json');
		$Destinationjson = json_decode($str, true);
		//$arrCurrencyList = $this->getCurrencyIdsAndSymbolList();
		$arrAirlineList = $this->getAirlineIdsAndCodeList();

		$strDepatureDate = $sessionFlightSearchParams['strDepatureDate'][0];
		$strReturnDate = $sessionFlightSearchParams['strReturnDate'][0];
		//echo '<pre>';print_r($BookingData);die;
		if ($BookingData) {
			foreach ($BookingData as $k => $val) {
				$value = $val['origin'];
				$TotalBaseFare = 0;
				$TotalTaxsandFees = 0;
				$CostToAgent = 0;
				$CostToAgentCustomer = 0;
				$CommRetained = 0;
				$TotalAgentMarkUp = 0;
				$TotalGSTOnAgentMarkUp = 0;
				if ($val['FairRules']['FareBreakdown']) {
					foreach ($val['FairRules']['FareBreakdown'] as $FareBreakdown) {
						$PBaseFare = $FareBreakdown['BaseFare'];
						$intGTXMarkUp = $FareBreakdown['intGTXMarkUp'];
						$GTXMarkUpGST = $FareBreakdown['GTXMarkUpGST'];
						$intTotalGST = $FareBreakdown['intTotalGST'];
						$FixedMarkUp = $FareBreakdown['FixedMarkUp'];
						$apiMarkup = $FareBreakdown['apiMarkup'];
						$AgentMarkUp = $FareBreakdown['AgentMarkUp'];
						$GSTOnAgentMarkUp = $FareBreakdown['GSTOnAgentMarkUp'];
						$IntCommission = $FareBreakdown['IntCommission'];
						$TotalBaseFare += $PBaseFare;
						$TDS = $FareBreakdown['TDS']; //TDS Fee
						$MF = $FareBreakdown['MF']; //Management Fee
						$YQ = $FareBreakdown['YQ']; //Fuel Surcharge
						$AGST = $FareBreakdown['AGST']; //Airline GST Component
						$MFT = $FareBreakdown['MFT']; //Management Fee Tax
						$OT = $FareBreakdown['OT']; //Other Charges
						$MU = $FareBreakdown['MU']; //Markup
						$YR = $FareBreakdown['YR']; //Carrier Misc Fee
						$otherCharge = ($YQ + $AGST + $MFT + $MF + $OT + $YR + $intGTXMarkUp + $GTXMarkUpGST);
						$TaxesFees = ($otherCharge + $intTotalGST + $FixedMarkUp + $apiMarkup + $AgentMarkUp + $GSTOnAgentMarkUp - $IntCommission);
						$TotalTaxsandFees += $TaxesFees;
						$CostToAgent += $FareBreakdown['CostToAgent'];
						$CostToAgentCustomer += $FareBreakdown['CostToAgentCustomer'];
						$CommRetained += $FareBreakdown['AdminComminAmount_ag'];
						$TotalAgentMarkUp += $AgentMarkUp;
						$TotalGSTOnAgentMarkUp += $GSTOnAgentMarkUp;
					}
				}
				$ExtraMarkup = ($val['FairRules']['ExtraMarkup']) ? $val['FairRules']['ExtraMarkup'] : 0;
				$ExtraMarkupOnGST = ($val['FairRules']['ExtraMarkupOnGST']) ? $val['FairRules']['ExtraMarkupOnGST'] : 0;
				$SeatPrice = 0;
				$BagPrice = 0;
				$MealPrice = 0;
				//echo '<pre>';print_r($val);die;
				$filterByFrom = $value['SourceAirportCode'];
				$filterByTo = $value['DestAirportCode'];
				$arrSourceCityId_ = array_filter($Destinationjson, function ($var) use ($filterByFrom) {
					return ($var['AirportCode'] == $filterByFrom);
				});

				$arrdestinationCityId_ = array_filter($Destinationjson, function ($var) use ($filterByTo) {
					return ($var['AirportCode'] == $filterByTo);
				});
				$Currency = $value['FairRules']['Currency'];
				$currencySysId = $this->CurrencyId;
				$arrSourceCityId = array_values($arrSourceCityId_);
				$arrdestinationCityId = array_values($arrdestinationCityId_);
				if (count($value['Segments']) > 1) {
					$IsDirect = '1';
				} else {
					$IsDirect = '0';
				}
				$FlyingMinutes = 0;
				if (count($value['Segments']) > 0) {
					foreach ($value['Segments'] as $segmentsResult) {
						$FlyingMinutes = $FlyingMinutes + ((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0) + (!empty($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : 0)));
					}
				}
				$airlineSysId = !empty($arrAirlineList[$value['Segments'][0]['AirlineCode']]) ? $arrAirlineList[$value['Segments'][0]['AirlineCode']] : '0';
				$arrPlanAir['AgencySysId'] = $this->gtxagencysysid;
				$arrPlanAir['CustomerSysId'] = $CustomerSysId;
				$arrPlanAir['FlightNumber'] = $value['OrFlightNumber'];
				$arrPlanAir['AirlineName'] = $value['AirlineName'];
				$arrPlanAir['ICSourceSysId'] = $value['ICSourceSysId'];
				$arrPlanAir['IsLCC'] = $value['IsLCC'];
				$arrPlanAir['IsRefundable'] = !empty($value['IsRefundable']) ? $value['IsRefundable'] : 0;
				$arrPlanAir['apiTraceId'] = $val['SearchTraceId'];
				$arrPlanAir['AirlineSysId'] = $airlineSysId;
				$arrPlanAir['TravelDate'] = $strDepatureDate;
				$arrPlanAir['DepartureTime'] = $value['DepartureTime'];
				$arrPlanAir['ArrivalTime'] = $value['ArrivalTime'];
				$arrPlanAir['IsDirect'] = $IsDirect;
				$arrPlanAir['FareClass'] = $value['Segments'][0]['FareClass'];
				$arrPlanAir['FlyingMinutes'] = $FlyingMinutes;
				$arrPlanAir['FlightDuration'] = $value['FlightDuration'];
				$arrPlanAir['SourcePlaceSysId'] = $arrSourceCityId[0]['CityID'];
				$arrPlanAir['DestPlaceSysId'] = $arrdestinationCityId[0]['CityID'];
				$arrPlanAir['SourceAirportCode'] = $value['SourceAirportCode'];
				$arrPlanAir['DestAirportCode'] = $value['DestAirportCode'];
				$arrPlanAir['StopCount'] = $value['StopCount'];
				$arrPlanAir['TotalFlightMembers'] = $value['TotalFlightMembers'];
				$arrPlanAir['CurrencyType'] = $currencySysId;
				$arrPlanAir['PublishedFare'] = $val['PublishedFare'];
				$arrPlanAir['ApiResultIndex'] = $val['ApiResultIndex'];
				$arrPlanAir['JourneyType'] = $value['JourneyType'];
				$arrPlanAir['TripType'] = $value['TripType'];
				$arrPlanAir['IsInternational'] = ($value['IsInternational']) ? $value['IsInternational'] : 0;
				$arrPlanAir['logo'] = $value['logo'];
				$arrPlanAir['Currency'] = $val['FairRules']['Currency'];
				$arrPlanAir['BaseFare'] = $TotalBaseFare;
				$arrPlanAir['Tax'] = $TotalTaxsandFees;
				$arrPlanAir['YQTax'] = (isset($value['FairRules']['YQTax']) && trim($value['FairRules']['YQTax']) != '') ? (float)trim($value['FairRules']['YQTax']) : '0';
				$arrPlanAir['OtherCharges'] = ($value['FairRules']['OtherCharges']) ? $value['FairRules']['OtherCharges'] : 0;
				$arrPlanAir['Discount'] = ($value['FairRules']['Discount']) ? $value['FairRules']['Discount'] : 0;
				$arrPlanAir['ServiceFee'] = ($value['FairRules']['ServiceFee']) ? $value['FairRules']['ServiceFee'] : 0;
				$arrPlanAir['OfferedFare'] = ($value['FairRules']['CostToAgent']) ? $value['FairRules']['CostToAgent'] : 0;
				$arrPlanAir['AgencyMarkUp'] = ($value['FairRules']['FixedMarkUp']) ? $value['FairRules']['FixedMarkUp'] : 0;
				$arrPlanAir['AgencyMarkUpGST'] = ($value['FairRules']['GSTOnMarkUp']) ? $value['FairRules']['GSTOnMarkUp'] : 0;
				$arrPlanAir['GTXMarkUp'] = ($value['FairRules']['intGTXMarkUp']) ? $value['FairRules']['intGTXMarkUp'] : 0;
				$arrPlanAir['GTXMarkUpGST'] = ($value['FairRules']['GTXMarkUpGST']) ? $value['FairRules']['GTXMarkUpGST'] : 0;
				$arrPlanAir['BagPrice'] = $BagPrice;
				$arrPlanAir['MealPrice'] = $MealPrice;
				$arrPlanAir['SeatPrice'] = $SeatPrice;
				$arrPlanAir['ExtraMarkup']     = $ExtraMarkup;
				$arrPlanAir['ExtraMarkupOnGST']     = $ExtraMarkupOnGST;
				$arrPlanAir['AgentCommisionEarned'] = ($CommRetained + $TotalAgentMarkUp + $TotalGSTOnAgentMarkUp);
				$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');

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

				$arrdestinationCityId_ = array_filter($Destinationjson, function ($var) use ($filterByTo) {
					return ($var['AirportCode'] == $filterByTo);
				});
				$Currency = $values['FairRules']['Currency'];
				$currencySysId = !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
				$arrSourceCityId = array_values($arrSourceCityId_);
				$arrdestinationCityId = array_values($arrdestinationCityId_);
				if (count($values['Segments']) > 1) {
					$IsDirect = '1';
				} else {
					$IsDirect = '0';
				}
				$FlyingMinutes = 0;
				if (count($values['Segments']) > 0) {
					foreach ($values['Segments'] as $segmentsResult) {
						$FlyingMinutes = $FlyingMinutes + ((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0) + (!empty($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : 0)));
					}
				}
				$airlineSysId = !empty($arrAirlineList[$values['Segments'][0]['AirlineCode']]) ? $arrAirlineList[$values['Segments'][0]['AirlineCode']] : '0';
				$arrPlanAirDes['AgencySysId'] = $this->gtxagencysysid;
				$arrPlanAirDes['CustomerSysId'] = $CustomerSysId;
				$arrPlanAirDes['FlightNumber'] = $values['DeFlightNumber'];
				$arrPlanAirDes['AirlineName'] = $values['AirlineName'];
				$arrPlanAirDes['ICSourceSysId'] = $values['ICSourceSysId'];
				$arrPlanAirDes['IsLCC'] = $values['IsLCC'];
				$arrPlanAirDes['IsRefundable'] = !empty($values['IsRefundable']) ? $values['IsRefundable'] : 0;
				$arrPlanAirDes['apiTraceId'] = $val['SearchTraceId'];
				$arrPlanAirDes['AirlineSysId'] = $airlineSysId;
				$arrPlanAirDes['TravelDate'] = $strReturnDate;
				$arrPlanAirDes['DepartureTime'] = $values['DepartureTime'];
				$arrPlanAirDes['ArrivalTime'] = $values['ArrivalTime'];
				$arrPlanAirDes['IsDirect'] = $IsDirect;
				$arrPlanAirDes['FareClass'] = $values['Segments'][0]['FareClass'];
				$arrPlanAirDes['FlyingMinutes'] = $FlyingMinutes;
				$arrPlanAirDes['FlightDuration'] = $values['FlightDuration'];
				$arrPlanAirDes['SourcePlaceSysId'] = $arrSourceCityId[0]['CityID'];
				$arrPlanAirDes['DestPlaceSysId'] = $arrdestinationCityId[0]['CityID'];
				$arrPlanAirDes['SourceAirportCode'] = $values['SourceAirportCode'];
				$arrPlanAirDes['DestAirportCode'] = $values['DestAirportCode'];
				$arrPlanAirDes['StopCount'] = $values['StopCount'];
				$arrPlanAirDes['TotalFlightMembers'] = $values['TotalFlightMembers'];
				$arrPlanAirDes['CurrencyType'] = $currencySysId;
				$arrPlanAirDes['PublishedFare'] = $val['PublishedFare'];
				$arrPlanAirDes['ApiResultIndex'] = $val['ApiResultIndex'];
				$arrPlanAirDes['JourneyType'] = $values['JourneyType'];
				$arrPlanAirDes['TripType'] = $values['TripType'];
				$arrPlanAirDes['IsInternational'] = ($values['IsInternational']) ? $values['IsInternational'] : 0;
				$arrPlanAirDes['logo'] = $values['logo'];
				$arrPlanAirDes['Currency'] = $val['FairRules']['Currency'];
				$arrPlanAirDes['BaseFare'] = $TotalBaseFare;
				$arrPlanAirDes['Tax'] = $TotalTaxsandFees;
				$arrPlanAirDes['YQTax'] = (isset($value['FairRules']['YQTax']) && trim($value['FairRules']['YQTax']) != '') ? (float)trim($value['FairRules']['YQTax']) : '0';
				$arrPlanAirDes['OtherCharges'] = ($value['FairRules']['OtherCharges']) ? $value['FairRules']['OtherCharges'] : 0;
				$arrPlanAirDes['Discount'] = ($value['FairRules']['Discount']) ? $value['FairRules']['Discount'] : 0;
				$arrPlanAirDes['ServiceFee'] = ($value['FairRules']['ServiceFee']) ? $value['FairRules']['ServiceFee'] : 0;
				$arrPlanAirDes['OfferedFare'] = ($value['FairRules']['CostToAgent']) ? $value['FairRules']['CostToAgent'] : 0;
				$arrPlanAirDes['AgencyMarkUp'] = ($value['FairRules']['FixedMarkUp']) ? $value['FairRules']['FixedMarkUp'] : 0;
				$arrPlanAirDes['AgencyMarkUpGST'] = ($value['FairRules']['GSTOnMarkUp']) ? $value['FairRules']['GSTOnMarkUp'] : 0;
				$arrPlanAirDes['GTXMarkUp'] = ($value['FairRules']['intGTXMarkUp']) ? $value['FairRules']['intGTXMarkUp'] : 0;
				$arrPlanAirDes['GTXMarkUpGST'] = ($value['FairRules']['GTXMarkUpGST']) ? $value['FairRules']['GTXMarkUpGST'] : 0;
				$arrPlanAirDes['BagPrice'] = $BagPrice;
				$arrPlanAirDes['MealPrice'] = $MealPrice;
				$arrPlanAirDes['SeatPrice'] = $SeatPrice;
				$arrPlanAirDes['ExtraMarkup']     = $ExtraMarkup;
				$arrPlanAirDes['ExtraMarkupOnGST']     = $ExtraMarkupOnGST;
				$arrPlanAirDes['AgentCommisionEarned'] = ($CommRetained + $TotalAgentMarkUp + $TotalGSTOnAgentMarkUp);
				$arrPlanAirDes['status'] = 0;
				$arrPlanAirDes['IsMarkForDel'] = 0;
				$arrPlanAirDes['created_at'] = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
				$arrPlanAirDes['updated_at'] = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');

				return array('origin' => $arrPlanAir, 'destination' => $arrPlanAirDes);
			}
		}
	}

	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)) {

			$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
			if ($sessionFlightSearchParams['route'] == 4) {
				$this->IsTJFlightAPI = 1;
			}
			$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->IsTJFlightAPI = $this->IsTJFlightAPI;
			$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;
			$WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyWallaetBalance($this->SecurityKey);
			$this->view->WalletBalance = ($WallaetBalance['status'] == 1) ? $WallaetBalance['creditBalance'] : 0;
			$this->view->B2BType = $this->_session->B2BType;
			// echo '<pre>';
			// print_r($arrUrlData);
			// die;
		} 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;
			$WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyWallaetBalance($this->SecurityKey);
			$this->view->WalletBalance = ($WallaetBalance['status'] == 1) ? $WallaetBalance['creditBalance'] : 0;
		} else {
			$this->_redirect('flight');
		}
	}
	public function payNowAction()
	{
		//die($this->_session->UserPicPath);
		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;
			}
			$strFilePath = "flight/payment/" . $data . date('Y-m-d-H-i-s') . "_payment_request.json";
			Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($param));

			$paymentMode = $param['paymentMode']; /// 1 for wallet and 2 for online
			$IsCancellationProtection = isset($param['IsCancellationProtection']) ? (int)$param['IsCancellationProtection'] : 0;
			$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'];
				$bookingId = $FlightBookingData[0]['bookingId'];
				$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;
				$PublishedPriceWallet = 0;
				$agencyMarkUp = 0;
				$gtxMarkup = 0;
				$offerFare = 0;
				$gtxMarkupGST = 0;
				$agencyMarkUpGST = 0;
				if ($FlightBookingData) {
					foreach ($FlightBookingData as $k => $value) {
						$ExtraMarkup = $value['FairRules']['ExtraMarkup'];
						$ExtraMarkupOnGST = $value['FairRules']['ExtraMarkupOnGST'];

						$PublishedPrice += ($value['FairRules']['CostToAgentCustomer'] + $ExtraMarkup + $ExtraMarkupOnGST);
						$PublishedPriceWallet += $value['FairRules']['PublishedFare'];
						$agencyMarkUp += $value['FairRules']['FixedMarkUp'];
						$gtxMarkup += $value['FairRules']['intGTXMarkUp'];
						$offerFare += $value['FairRules']['offerTotal'];
						$gtxMarkupGST += $value['FairRules']['intGTXMarkUp'];
						$agencyMarkUpGST += $value['FairRules']['GSTOnMarkUp'];
					}
				}
				if ($paymentMode == 3) {
					$PublishedFare = ($PublishedPrice + $BagPrice + $MealPrice + $SeatPrice);
				} elseif ($paymentMode == 2) {
					$PublishedFare = ($PublishedPriceWallet + $BagPrice + $MealPrice + $SeatPrice);
				}

				$arrUrlData['_sessiondata'] = $this->_session->data;
				$arrUrlData['_B2BType'] = $this->_session->B2BType;
				$arrUrlData['_getAgencyRolePermission'] = $this->_session->getAgencyRolePermission;
				$arrUrlData['_UserPicPath'] = $this->_session->UserPicPath;
				$arrUrlData['paymentMode'] = $paymentMode;
				$arrUrlData['IsCancellationProtection'] = $IsCancellationProtection;
				$arrUrlData['CencelattionData'] = $this->_session->CencelattionData;
				$PublishedFareCheck = ($PublishedPrice + $BagPrice + $MealPrice + $SeatPrice);
				$CPAmountWithTax = 0;
				$CPPercentVal = isset($this->_session->CencelattionData[0]['CPPercentVal']) ? $this->_session->CencelattionData[0]['CPPercentVal'] : 0;
				if ($IsCancellationProtection == 1 && !empty($CPPercentVal)) {
					$CPAmount = ($PublishedFareCheck * $CPPercentVal) / 100;
					$CPAmountWithTax = $CPAmount + ($CPAmount * 18 / 100);
					$PublishedFare = $PublishedFare + $CPAmountWithTax;
				}
				$arrUrlData['CPAmountWithTax'] = $CPAmountWithTax;
				$tempData = array(
					'TraceId' => $FlightTraceId,
					'json_data' => json_encode($arrUrlData),
				);
				$objFlight->deleteFlightTempData($SearchTraceId);
				$objFlight->insertFlightTempData($tempData);
				$arrData = array(
					'FlightTraceId' => $FlightTraceId
				);



				$IsSeriesFareData = isset($FlightBookingData[0]['IsSeriesFareData']) ? $FlightBookingData[0]['IsSeriesFareData'] : 0;
				if ($this->IsTJFlightAPI == 0 && $IsSeriesFareData == 0) {
					$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetAgencyBalance($arrData, $this->gtxagencysysid);
					$CreditBalance = (float) isset($response['CreditBalance']) ? $response['CreditBalance'] : 0;
					$CashBalance = (float) isset($response['CashBalance']) ? ($response['CashBalance'] + $CreditBalance) : 0;
					if ($CashBalance >= (float) $PublishedFareCheck) {
					} else {
						$responseS = array('success' => false, 'message' => 'Oops insufficient supplier wallet balance. please contact with agency', 'url' => '');
						echo json_encode($responseS);
						exit;
					}
				}

				if ($paymentAction == 'PAYNOW' && ($paymentMode == 2 || $paymentMode == 3)) {
					try {
						$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));
						$encryptedData = new Travel_Model_AtomAES();
						$lastInsertId = $encryptedData->encrypt($FlightTraceId, SECURITYKEY, SECURITYKEY);
						$FLBookingID = base64_encode(implode(',', $flight_booking_id_Arr)); //$param['traceId']; //$this->GUID();
						$guid = $this->GUID();
						$walletCode = $this->walletCode($AgentSysId, $guid, ceil($PublishedFare), $AgencySysId, $intTPSysId, $intCustSysId, $encryptMarkUpData);

						//$strReturnURL = $this->baseUrl . "flight/check-payment/id/" . ($FlightTraceId);
						$strReturnURL = $this->baseUrl . "index/check-payment";
						echo json_encode(["success" => true, 'guid' => $guid, 'gtxagentsysid' => $this->gtxagentsysid, 'gtxagencysysid' => $this->gtxagencysysid, 'amount' => ceil($PublishedFare), 'lastInsertId' => $lastInsertId, 'FLBookingID' => $FLBookingID, 'walletCode' => $walletCode, 'stringData' => $encryptMarkUpData, 'strReturnURL' => $strReturnURL, 'TPSysId' => $intTPSysId, 'UserData' => ['name' => $firstName, 'email' => $emailId, 'mobile' => $mobileNumber, 'CustomerSysId' => $intCustSysId]]);
						exit;
					} catch (Exception $e) {
						echo $e->getMessage();
						exit;
					}
				} elseif ($paymentAction == 'PAYNOW' && $paymentMode == 1) {
					$PublishedFare = ($PublishedPriceWallet + $BagPrice + $MealPrice + $SeatPrice);
					$PublishedFare = $PublishedFare + $CPAmountWithTax;
					$WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyWallaetBalance($this->SecurityKey);
					$WalletBalance = ($WallaetBalance['status'] == 1) ? $WallaetBalance['creditBalance'] : 0;
					if ($WalletBalance >= $PublishedFare) {
						$remarks = (isset($param['remarks']) && !empty($param['remarks'])) ? '- ' . $param['remarks'] : '';
						$rem = (isset($IsCancellationProtection) && $IsCancellationProtection == 2) ? 'Flight Booking with Refund' : 'Flight Booking';
						$updateCreditBalance = array(
							'SecurityKey' => $this->SecurityKey,
							'Remark' => $rem . ' ' . $remarks,
							'Amount' => $PublishedFare,
							'PlanType' => 1, // for flight
							'UserSysId' => $this->_session->data['UserSysId'],
							'PaymentMode' => 'Wallet',
							'RefrenceNo' => $bookingId,
							'CurrencyType' => $this->CurrencyId,
							'FlightTraceId' => $FlightTraceId,
						);

						$updateBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyupdateCreditBalance($updateCreditBalance);
						$Walletstatus = $updateBalance['status'];

						if ($Walletstatus == 1) {
							$WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyWallaetBalance($this->SecurityKey);
							$sessionWallaetBalance = new Zend_Session_Namespace('sessionWallaetBalance');
							$sessionWallaetBalance->params = $WallaetBalance;
							$TransactionId = $updateBalance['TransactionId'];
							foreach ($flight_booking_id_Arr as $key => $flight_booking_id) {
								$arrPayment = [
									"error_Message" => '',
									"error" => '',
									"GUID" => $TransactionId,
									"TransactionId_debit" => $TransactionId,
								];
								$arrPayment['paymentStatus'] = 1;
								$where = "id = " . $flight_booking_id; //exit;
								$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $arrPayment, $where);
							}
							$encryptedData = new Travel_Model_AtomAES();
							$lastInsertId = $encryptedData->encrypt($FlightTraceId, SECURITYKEY, SECURITYKEY);
							if ($updated) {
								$response = array('success' => true, 'message' => 'success', 'url' => 'flight/book-flight/data/' . $FlightTraceId . '/code/' . $lastInsertId);
								echo json_encode($response);
								exit;
								//$this->_redirect('flight/book-flight/data/' . $FlightTraceId);
							}
						} else {
							$response = array('success' => false, 'message' => $updateBalance['message'], 'url' => '');
							echo json_encode($response);
							exit;
						}
					} 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;
				}

				$encryptedData = new Travel_Model_AtomAES();
				$lastInsertId = $encryptedData->encrypt($FlightTraceId, SECURITYKEY, SECURITYKEY);
				$ViewArr = array(
					'AgentSysId' => '',
					'AgencySysId' => $this->gtxagencysysid,
					'baseUrl' => $this->baseUrl,
					'FlightTraceId' => $FlightTraceId,
					'lastInsertId' => $lastInsertId
				);
				$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()->getPost();
		echo "<pre>";
		die;
		// $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);
		$WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyWallaetBalance($this->SecurityKey);
		$sessionWallaetBalance = new Zend_Session_Namespace('sessionWallaetBalance');
		$sessionWallaetBalance->params = $WallaetBalance;
		$objFlight = new Travel_Model_FlightMaster();
		$FlightTempData = $objFlight->GetFlightTempData($id);
		$arrUrlData = json_decode($FlightTempData['json_data'], true);
		$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'];
		$paymentMode = $arrUrlData['paymentMode'];
		$bookingId = $FlightBookingData[0]['bookingId'];
		$IsSeriesFareData = isset($FlightBookingData[0]['IsSeriesFareData']) ? $FlightBookingData[0]['IsSeriesFareData'] : 0;
		$FlightQueryids = $arrUrlData['FlightQueryids'];
		$strFilePath = "flight/payment/" . $id . date('Y-m-d-H-i-s') . "_Atompayment_response.json";
		Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($param));

		$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;
		$PublishedPriceWallet = 0;
		$agencyMarkUp = 0;
		$gtxMarkup = 0;
		$offerFare = 0;
		$gtxMarkupGST = 0;
		$agencyMarkUpGST = 0;
		$TotalExtraMArkup = 0;
		if ($FlightBookingData) {
			foreach ($FlightBookingData as $k => $value) {
				$PublishedPrice += $value['FairRules']['CostToAgentCustomer'];
				$PublishedPriceWallet += $value['FairRules']['PublishedFare'];
				$agencyMarkUp += $value['FairRules']['FixedMarkUp'];
				$gtxMarkup += $value['FairRules']['intGTXMarkUp'];
				$offerFare += $value['FairRules']['offerTotal'];
				$gtxMarkupGST += $value['FairRules']['intGTXMarkUp'];
				$agencyMarkUpGST += $value['FairRules']['GSTOnMarkUp'];
				$ExtraMarkup = isset($value['FairRules']['ExtraMarkup']) ? $value['FairRules']['ExtraMarkup'] : 0;
				$ExtraMarkupOnGST = isset($value['FairRules']['ExtraMarkupOnGST']) ? $value['FairRules']['ExtraMarkupOnGST'] : 0;
				$TotalExtraMArkup += ($ExtraMarkup + $ExtraMarkupOnGST);
			}
		}
		if ($paymentMode == 3) {
			$PublishedFare = ($PublishedPrice + $BagPrice + $MealPrice + $SeatPrice + $TotalExtraMArkup);
		} elseif ($paymentMode == 2) {
			$PublishedFare = ($PublishedPriceWallet + $BagPrice + $MealPrice + $SeatPrice);
		}

		$strCreditDate = date('Y-m-d');
		$dataArray = array(
			'B2BAgencySysIdKey' => $this->_session->data['SecurityKey'],
			'B2CAgencySysIdKey' => SECURITYKEY,
			'PaymentMode' => ($paymentMode == 2) ? 'Self Card' : 'Customer Card',
			'Amount' => $PublishedFare,
			'RefrenceNo' => $bookingId,
			'CreditDate' => $strCreditDate,
			'Remark' => 'Add Fund',
			'PlanType' => 7,
			'CurrencyType' => 1,
			'UserSysId' => $this->_session->data['UserSysId'],
		);

		$arrPayment = [
			"error_Message" => $error_Message,
			"error" => $error,
			"GUID" => $GUID,
		];
		$traceId = $param['id'];
		if ($id && $TrxId) {
			if ($status == "Ok") {
				try {
					$curl_p = curl_init(API_DIRECT_CREDIT);
					curl_setopt($curl_p, CURLOPT_POST, true);
					curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($dataArray));
					curl_setopt($curl_p, CURLOPT_RETURNTRANSFER, true);
					curl_setopt($curl_p, CURLOPT_SSL_VERIFYPEER, false);
					curl_setopt($curl_p, CURLOPT_TIMEOUT, 300);
					$response = curl_exec($curl_p);
					//echo "<pre>";print_r(API_DIRECT_CREDIT);
					//echo "<pre>";print_r($dataArray);
					//echo "<pre>";print_r($response);
					//die('s');
					curl_close($curl_p);
				} catch (Exception $error) {
					print_r($error->getMessage());
					die;
				}
				$responseData = json_decode($response, true);
				if ($responseData['status'] == 1) {
					$arrPayment['paymentStatus'] = 1;
					$arrPayment['TransactionId_credit'] = $responseData['TransactionId'];
					foreach ($TrxId as $key => $flight_booking_id) {
						$where = "id = " . $flight_booking_id; //exit;
						try {
							$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $arrPayment, $where);
						} catch (Exception $e) {
							echo $e->getMessage();
							die;
						}
					}
					if ($IsSeriesFareData == 1) {
						$CheckSoldInventory1 = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckSoldInventory($FlightBookingData[0]['bookingId']);
						if ($CheckSoldInventory1['Status'] == false) {
							if ($sessionFlightSearchParams['route'] == 2 && isset($FlightBookingData[1]['bookingId'])) {
								$CheckReleaseInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckReleaseInventory($FlightBookingData[1]['bookingId']);
							}
							$this->_redirect('flight/booking-confirmed/data/' . $arrUrlData['SearchTraceId'] . '?status=true');
							die;
						}
						if ($sessionFlightSearchParams['route'] == 2 && isset($FlightBookingData[1]['bookingId'])) {
							$CheckSoldInventory2 = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckSoldInventory($FlightBookingData[1]['bookingId']);
							if ($CheckSoldInventory2['Status'] == false) {
								$CheckReleaseInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckReleaseInventory($FlightBookingData[0]['bookingId']);
								$this->_redirect('flight/booking-confirmed/data/' . $arrUrlData['SearchTraceId'] . '?status=true');
								die;
							}
						}
					}

					//echo "<pre>";print_r($CheckSoldInventory);die;
					if ($updated) {
						$this->_redirect('flight/book-flight/data/' . $id);
					}
				} else {
					die('Oops transaction failed. Reference number for your support:-' . $bookingId);
				}
			} 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 ($IsSeriesFareData == 1) {
					$CheckReleaseInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckReleaseInventory($FlightBookingData[0]['bookingId']);
					if ($sessionFlightSearchParams['route'] == 2 && isset($FlightBookingData[1]['bookingId'])) {
						$CheckReleaseInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckReleaseInventory($FlightBookingData[1]['bookingId']);
					}
				}
				//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 ($IsSeriesFareData == 1) {
					$CheckReleaseInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckReleaseInventory($FlightBookingData[0]['bookingId']);
					if ($sessionFlightSearchParams['route'] == 2 && isset($FlightBookingData[1]['bookingId'])) {
						$CheckReleaseInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckReleaseInventory($FlightBookingData[1]['bookingId']);
					}
				}
				if ($updated) {
					$this->_redirect('flight/payment-failed/data/' . $id);
				}
			}
		} else {
			die('Oops transaction failed. Reference number for your support:-' . $bookingId);
		}
	}
	public function DebitFromWallet($arrUrlData)
	{

		$FlightBookingData = $arrUrlData['FlightBookingData'];
		$SelectedBaggSessionNew = $arrUrlData['SelectedBaggSessionNew'];
		$SelectedMealSessionNew = $arrUrlData['SelectedMealSessionNew'];
		$selectedSeatSession = $arrUrlData['selectedSeatSession'];
		$paymentMode = $arrUrlData['paymentMode'];
		$bookingId = $FlightBookingData[0]['bookingId'];
		$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;
		$PublishedPriceWallet = 0;
		if ($FlightBookingData) {
			foreach ($FlightBookingData as $k => $value) {
				$PublishedPrice += $value['FairRules']['CostToAgentCustomer'];
				$PublishedPriceWallet += $value['FairRules']['PublishedFare'];
			}
		}
		if ($paymentMode == 3) {
			$PublishedFare = ($PublishedPriceWallet + $BagPrice + $MealPrice + $SeatPrice);
		} elseif ($paymentMode == 2) {
			$PublishedFare = ($PublishedPriceWallet + $BagPrice + $MealPrice + $SeatPrice);
		}
		$IsCancellationProtection = (isset($arrUrlData['IsCancellationProtection'])) ? $arrUrlData['IsCancellationProtection'] : 0;
		$CPAmountWithTax = (isset($arrUrlData['CPAmountWithTax'])) ? $arrUrlData['CPAmountWithTax'] : 0;
		if ($IsCancellationProtection == 1 && !empty($CPAmountWithTax)) {
			$PublishedFare  = $PublishedFare + $CPAmountWithTax;
		}
		$WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyWallaetBalance($this->SecurityKey);
		$WalletBalance = ($WallaetBalance['status'] == 1) ? $WallaetBalance['creditBalance'] : 0;
		// if($this->MasterAgencySysId == 35){
		// 	echo "<pre>";
		// 	print_r($WallaetBalance);
		// 	echo "<pre>";
		// 	print_r($PublishedFare);
		// 	die;
		// }
		if ($WalletBalance >= $PublishedFare) {
			$remarks = '';
			$updateCreditBalance = array(
				'SecurityKey' => $this->SecurityKey,
				'Remark' => 'Flight Booking ' . $remarks,
				'Amount' => $PublishedFare,
				'PlanType' => 1, // for flight
				'UserSysId' => $this->_session->data['UserSysId'],
				'PaymentMode' => 'Online Wallet',
				'RefrenceNo' => $bookingId,
				'CurrencyType' => $this->CurrencyId,
				'FlightTraceId' => $arrUrlData['SearchTraceId'],
			);
			// echo "<pre>";
			// print_r($updateCreditBalance);
			//die;

			$updateBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyupdateCreditBalance($updateCreditBalance);
			$Walletstatus = $updateBalance['status'];
			$TransactionId = $updateBalance['TransactionId'];
			return $updateBalance;
		} else {
			$Return = array('success' => false, 'message' => 'Oops insufficient wallet balance.', 'SearchTraceId' => $arrUrlData['SearchTraceId']);
			echo json_encode($Return);
			exit;
		}
	}

	public function CreditIntoWallet($arrUrlData)
	{
		$FlightBookingData = $arrUrlData['FlightBookingData'];
		$SelectedBaggSessionNew = $arrUrlData['SelectedBaggSessionNew'];
		$SelectedMealSessionNew = $arrUrlData['SelectedMealSessionNew'];
		$selectedSeatSession = $arrUrlData['selectedSeatSession'];
		$paymentMode = $arrUrlData['paymentMode'];
		$bookingId = $FlightBookingData[0]['bookingId'];
		$SearchTraceId = $FlightBookingData[0]['SearchTraceId'];
		$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;
		$PublishedPriceWallet = 0;
		if ($FlightBookingData) {
			foreach ($FlightBookingData as $k => $value) {
				$PublishedPrice += $value['FairRules']['CostToAgentCustomer'];
				$PublishedPriceWallet += $value['FairRules']['PublishedFare'];
			}
		}
		$PublishedFare = ($PublishedPriceWallet + $BagPrice + $MealPrice + $SeatPrice);
		$strCreditDate = date('Y-m-d');
		$dataArray = array(
			'B2BAgencySysIdKey' => $this->_session->data['SecurityKey'],
			'B2CAgencySysIdKey' => SECURITYKEY,
			'PaymentMode' => 'Wallet Refund',
			'Amount' => $PublishedFare,
			'RefrenceNo' => $bookingId,
			'CreditDate' => $strCreditDate,
			'Remark' => 'Refund',
			'PlanType' => 7,
			'CurrencyType' => 1,
			'UserSysId' => $this->_session->data['UserSysId'],
		);

		try {
			$curl_p = curl_init(API_DIRECT_CREDIT);
			curl_setopt($curl_p, CURLOPT_POST, true);
			curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($dataArray));
			curl_setopt($curl_p, CURLOPT_RETURNTRANSFER, true);
			curl_setopt($curl_p, CURLOPT_SSL_VERIFYPEER, false);
			curl_setopt($curl_p, CURLOPT_TIMEOUT, 300);
			$response = curl_exec($curl_p);
			//echo "<pre>";print_r($response);die;
			curl_close($curl_p);
		} catch (Exception $error) {
			print_r($error->getMessage());
			die;
		}
		$responseData = json_decode($response, true);
		$Walletstatus  = $responseData['status'];
		$Walletmessage = $responseData['message'];
		$logParams = [
			"user_id"      => 1,
			"custom_error" => ($Walletstatus == 1) ? "Wallet Credit success" : "Wallet Credit failed",
			'error'        => $Walletmessage,
			"text_udf"     => ['response' => $responseData], // Response
			"char_udf"     => ['request' => $dataArray], // Request
			"udf1"         => $SearchTraceId,
			"status"       => ($Walletstatus == 1) ? 2 : 1,
		];
		Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);

		return $responseData;
	}

	public function bookFlightAction()
	{
		//error_reporting(1);
		//die('booking disabled. live api running now.');
		$param = $this->getRequest()->getParams();

		if ($param) {
			$code = $this->getRequest()->getParam('code', NULL);
			$traceId = $this->getRequest()->getParam('data', NULL);
			if ($code != NULL && $traceId != NULL) {
				$encryptedData = new Travel_Model_AtomAES();
				$code = $param['code'];
				$encryptCode = $encryptedData->encrypt($param['data'], SECURITYKEY, SECURITYKEY);
				if ($encryptCode == $code) {
					$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->arrUrlData = $arrUrlData;
						$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->genrateFlightQuery = $FlightQueryids = $arrUrlData['genrateFlightQuery'];
						$this->view->sessionFlightSearchParams = $sessionFlightSearchParams;
						$this->view->code = $code;
						$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->route = $route = isset($sessionFlightSearchParams['route']) ? $sessionFlightSearchParams['route'] : 0;
						$this->view->totalPaxCount = $adultCount + $childCount + $infantCount;
						$WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyWallaetBalance($this->SecurityKey);
						$this->view->WalletBalance = ($WallaetBalance['status'] == 1) ? $WallaetBalance['creditBalance'] : 0;
						$this->view->B2BType = $this->_session->B2BType;
						$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;
						$paymentMode = isset($arrUrlData['paymentMode']) ? $arrUrlData['paymentMode'] : 0;
						$IsCancellationProtection = isset($arrUrlData['IsCancellationProtection']) ? $arrUrlData['IsCancellationProtection'] : 0;
						$post = isset($arrUrlData['post']) ? $arrUrlData['post'] : '';
						$apiData = isset($arrUrlData['apiData']) ? $arrUrlData['apiData'] : '';
						$CustomerSysId = isset($arrUrlData['CustomerSysId']) ? $arrUrlData['CustomerSysId'] : 0;

						$CheckPaymentSTatus = $objFlight->CheckPaymentSTatus('tbl_flight_booking', $strUrlData);
						$paymentStatus = isset($CheckPaymentSTatus['paymentStatus']) ? $CheckPaymentSTatus['paymentStatus'] : 0;
						$currentBookingStatus = isset($CheckPaymentSTatus['status']) ? $CheckPaymentSTatus['status'] : 0;
						if ($currentBookingStatus == 3) {
							$this->_redirect('flight/booking-confirmed/data/' . $strUrlData);
						}

						if (empty($flight_booking_id)) {
							$this->_redirect('flight/travellers/data/' . $strUrlData);
						}
						if ($paymentStatus != 1) {
							$this->_redirect('flight/review-payment/data/' . $strUrlData);
						}

						$mytrip_city_from = $sessionFlightSearchParams['from_city'][0];
						$mytrip_city_to = $sessionFlightSearchParams['to_city'][0];
						if ($route == 1) {
							$sectorTitle = $mytrip_city_from . '-' . $mytrip_city_to;
						} else {
							$sectorTitle = $mytrip_city_from . '-' . $mytrip_city_to . '-' . $mytrip_city_from;
						}
						if ($this->getRequest()->isXmlHttpRequest() && $this->getRequest()->getPost()) {
							// echo "<pre>";
							// print_r($SelectedMealSessionNew);
							// die;
							$this->_helper->layout->disableLayout();
							$this->_helper->viewRenderer->setNoRender(true);
							$ICSourceSysId = isset($FlightBookingData[0]['ICSourceSysId']) ? $FlightBookingData[0]['ICSourceSysId'] : 0;
							$IsSeriesFareData = isset($FlightBookingData[0]['IsSeriesFareData']) ? $FlightBookingData[0]['IsSeriesFareData'] : 0;
							$OnwardAutoTicket = isset($FlightBookingData[0]['OnwardAutoTicket']) ? $FlightBookingData[0]['OnwardAutoTicket'] : 1;
							$BookingdataAPI = array(
								'FlightBookingData' => $FlightBookingData,
								'IsInternational' => $FlightBookingData[0]['IsInternational'],
								'CustomerSession' => $ForCustomerSession,
								'SelectedBaggSessionNew' => $arrUrlData['SelectedBaggSessionNew'],
								'SelectedMealSessionNew' => $arrUrlData['SelectedMealSessionNew'],
								'selectedSeatSession' => $arrUrlData['selectedSeatSession'],
								'SearchTraceId' => $arrUrlData['SearchTraceId'],
							);
							/// For refund upgrade
							$PublishedFareAgentFinalRF = 0;
							if ($FlightBookingData) {
								foreach ($FlightBookingData as $k => $value) {
									$Amount = $value['FairRules']['BaseFare'];
									$NetAmount = $value['FairRules']['PublishedFare'];
									$PublishedFareAgent = (isset($value['FairRules']['PublishedFareAgent'])) ? $value['FairRules']['PublishedFareAgent'] : 0;
									$ExtraMarkup = (isset($value['FairRules']['ExtraMarkup'])) ? $value['FairRules']['ExtraMarkup'] : 0;
									$ExtraMarkupOnGST = (isset($value['FairRules']['ExtraMarkupOnGST'])) ? $value['FairRules']['ExtraMarkupOnGST'] : 0;
									$PublishedFareAgentFinalRF += round(($PublishedFareAgent + $ExtraMarkup + $ExtraMarkupOnGST), 2);
								}
							}
							$CPPercentVal = (isset($arrUrlData['CencelattionData'][0]['CPPercentVal']) && !empty($arrUrlData['CencelattionData'][0]['CPPercentVal'])) ? (int)$arrUrlData['CencelattionData'][0]['CPPercentVal'] : 0;
							$CPAmountWithTax = 0;
							if ($IsCancellationProtection == 1 && !empty($CPPercentVal)) {
								$CPAmount = ($PublishedFareAgentFinalRF * $CPPercentVal) / 100;
								$CPAmountWithTax = $CPAmount + ($CPAmount * 18 / 100);
							}
							$CancellationProtectionData['IsCancellationProtection'] = $IsCancellationProtection;
							$CancellationProtectionData['CancellationProtectionPrice'] = round($CPAmountWithTax, 2);
							$CancellationProtectionData['finalPackageCostWithMarkupnTax'] = $PublishedFareAgentFinalRF;
							$CancellationProtectionDataE = json_encode($CancellationProtectionData);
							$CancellationProtectionDataCode = $encryptedData->encrypt($CancellationProtectionDataE, SECURITYKEY, SECURITYKEY);


							// echo "<pre>";
							// print_r($FlightBookingData);
							// echo "<pre>";
							// print_r($SelectedMealSessionNew);
							// die;
							if ($paymentMode == 3 || $paymentMode == 2) {
								$DebitFromWallet = $this->DebitFromWallet($arrUrlData);
								$TransactionId = isset($DebitFromWallet['TransactionId']) ? $DebitFromWallet['TransactionId'] : '';
							}
							if ($ICSourceSysId == 8) {
								$Bookres = [
									'status' => array('success' => true),
								];
							} else {
								if ($ICSourceSysId == 7) {
									$Bookres = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightTicketTripJack($BookingdataAPI);
								} elseif ($ICSourceSysId == 3) { //// TBO booking condition by sabir noor
									try {
										$IsLCC = false;

										// GTX Data pushing
										$model = new Gtxwebservices_Model_Webservices();
										$result = $model->CreateCustomer($apiData);
										$apiCustomer = json_decode($result, true);
										if ($apiCustomer['status'] == 1) {
											$arrCustomer['GTX_customerSysId'] = $apiCustomer['Message'];
											$where = "CustomerSysId = " . $CustomerSysId;
											$objFlight->UpdateFlightData('tbl_customer', $arrCustomer, $where);
										}
										$FlightQueryids = $this->genrateFlightQuery($post);
										$ResponseStatusGTX = isset($FlightQueryids['status']) ? $FlightQueryids['status'] : 0;
										$ErrorMessageGTX = isset($FlightQueryids['message']) ? $FlightQueryids['message'] : 'Unable to create query. please contact administrator.';
										if ($ResponseStatusGTX == 0) {
											$Return = array('success' => false, 'message' => $ErrorMessageGTX, 'SearchTraceId' => $arrUrlData['SearchTraceId']);
											echo json_encode($Return);
											exit;
										}


										$strFilePath = "flight/FlightQueryids/" . time() . "_response.json";
										Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($FlightQueryids));
										$queryStatus = isset($FlightQueryids['status']) ? $FlightQueryids['status'] : 0;
										$MasterTPSysId = $FlightQueryids['arrIds']['MasterTPSysId'];
										$TPSysId = $FlightQueryids['arrIds']['TPSysId'];
										$VersionId = $FlightQueryids['arrIds']['VersionId'];
										$TrxId = $FlightQueryids['arrIds']['TrxId'];

										if ($FlightBookingData) {
											$FlightBookingTicketArr = [];
											foreach ($FlightBookingData as $k => $value) {
												$finalFareSummary = $value['FairRules'];
												$BookingdataAPI = array(
													'FlightBookingData' => $value,
													'sessionFlightSearchParams' => $sessionFlightSearchParams,
													'CustomerSession' => $ForCustomerSession,
													'SelectedBaggSessionNew' => $arrUrlData['SelectedBaggSessionNew'],
													'SelectedMealSessionNew' => $arrUrlData['SelectedMealSessionNew'],
													'selectedSeatSession' => $arrUrlData['selectedSeatSession'],
												);
												if ($value['IsLCC'] == 1) {
													$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightTicket($BookingdataAPI, $this->gtxagencysysid);
												} else {
													$IsLCC = true;
													$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightBooking($BookingdataAPI, $this->gtxagencysysid);
												}


												$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'];
															}
														}
													}
												}
												$PublishedFareINT = ($value['FairRules']['PublishedFare']);
												$AgentCommisionEarnedINT = ($finalFareSummary['CommEarned'] + $finalFareSummary['PLBEarned']);
												$AgentCommisionEarnedGSTINT = ($finalFareSummary['GSTonComm'] + isset($finalFareSummary['GSTonPLB']) ? $finalFareSummary['GSTonPLB'] : 0);
												$AgencyMarkUpINT = $finalFareSummary['FixedMarkUp'];
												$AgencyMarkUpGSTINT = $finalFareSummary['GSTOnMarkUp'];
												$GTXMarkUpINT = $finalFareSummary['intGTXMarkUp'];

												$BaseAmountINT = ($PublishedFareINT - $AgentCommisionEarnedINT);
												$UpdateFare[$k] = array(
													'Price' => $BaseAmountINT,
													'NetPrice' => $PublishedFareINT,
													'AgencyMarkUp' => $AgencyMarkUpINT,
													'AgentServiceTaxAmount' => $AgencyMarkUpGSTINT,
													'MarkUp' => $AgentCommisionEarnedINT,
													'AgentsCustomServiceTaxAmount' => $AgentCommisionEarnedGSTINT,
													'GTXMarkup' => $GTXMarkUpINT,
													'GTXServiceTaxAmount' => 0,
													'TotalCost' => $PublishedFareINT,
													'MealFare' => $MealPrice,
													'BaggFare' => $BagPrice,
													'SeatFare' => $SeatFare,
												);
												$FlightBookingTicketArr[] = $response;
												$ResponseStatus = isset($response['Response']['ResponseStatus']) ? $response['Response']['ResponseStatus'] : '0';
												$apiTraceId = isset($response['Response']['TraceId']) ? $response['Response']['TraceId'] : '0';
												$ErrorCode = isset($response['Response']['Error']['ErrorCode']) ? $response['Response']['Error']['ErrorCode'] : '0';
												$ErrorMessage = isset($response['Response']['Error']['ErrorMessage']) ? $response['Response']['Error']['ErrorMessage'] : '';
												$strBookingIdLCC = isset($response['Response']['Response']['BookingId']) ? $response['Response']['Response']['BookingId'] : '';
												$strTicketPNRLCC = isset($response['Response']['Response']['PNR']) ? $response['Response']['Response']['PNR'] : '';
												$Passenger = isset($response['Response']['Response']['FlightItinerary']['Passenger']) ? $response['Response']['Response']['FlightItinerary']['Passenger'] : '';
												$statusType = 1;
												if ($OnwardAutoTicket == 0 && $IsSeriesFareData == 1) {
													$statusType = 20;
												}

												if ($ResponseStatus == 1) {
													$update = array(
														'API_Response' => json_encode($value),
														'API_Response_Ticket' => json_encode($response),
														'FlightQueryids' => json_encode($FlightQueryids),
														'PNR_Number' => $strTicketPNRLCC,
														'BookingId' => $strBookingIdLCC,
														'APIBookingId' => $strBookingIdLCC,
														'MasterTPSysId' => $MasterTPSysId,
														'TPSysId' => $TPSysId,
														'status' => $statusType,
													);

													if ($paymentMode == 3 || $paymentMode == 2) {
														$update['TransactionId_debit'] = $TransactionId;
													}
													if ($IsCancellationProtection == 1) {
														$update['IsCancellationProtection'] = $IsCancellationProtection;
														$update['CancellationProtectionPrice'] = round($CPAmountWithTax, 2);
													}

													$Amount = $value['FairRules']['OfferedFare'];
													$NetAmount = $value['FairRules']['PublishedFare'];

													$where = "id = " . $flight_booking_id[$k]; //exit;
													$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
													$responseArray = array(
														'value' => $value,
														'response' => $response
													);
													$postFieldArray = array(
														'MasterTPSysId' => $MasterTPSysId,
														'TPSysId' => $TPSysId,
														'TrxId' => $TrxId,
														'VersionId' => $VersionId[$k],
														'XRefBookingId' => $strBookingIdLCC,
														'APIBookingRes' => json_encode($responseArray),
														'Passenger' => json_encode($Passenger),
														'UpdateFare' => json_encode([$UpdateFare[$k]]),
														'Keys' => $k,
														'ErrorCode' => 0,
														'IsBookingStatus' => 1,
														'sectorTitle' => $sectorTitle,
														'Amount' => $Amount,
														'NetAmount' => $NetAmount,
													);
													if ($k == 0) {
														$postFieldArray['CancellationProtectionData'] = $CancellationProtectionDataCode;
													}
													// $strFilePath = "flight/updateFlightBookingDetails/" . time() . "_update_request.json";
													// Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($postFieldArray));

													// $model = new Gtxwebservices_Model_Webservices();
													// $result = $model->updateFlightBookingB2B($postFieldArray);

													$strFilePath = "flight/SearchParam/" . $strUrlData . "/GTX/" . $k . "_update_request.json";
													Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($postFieldArray));

													$model = new Gtxwebservices_Model_Webservices();
													$result = $model->updateFlightBookingB2B($postFieldArray);

													$strFilePath = "flight/SearchParam/" . $strUrlData . "/GTX/" . time() . "_update_response.json";
													Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, ($result));

													$segment = [];
													if ($value['Segments']) {
														foreach ($value['Segments'] as $seg) {
															$originAirportCode = $seg['originAirportCode'];
															$destinationAirportCode = $seg['destinationAirportCode'];
															$segment[] = $originAirportCode . '-' . $destinationAirportCode;
														}
													}
													if ($Passenger) {
														foreach ($Passenger as $pk => $pax) {

															$TicketId = $pax['Ticket']['TicketId'];
															$TicketNumber = $pax['Ticket']['TicketNumber'];

															$updatep = array(
																'PNR_Number' => $strTicketPNRLCC,
																'TicketId' => $TicketId,
																'TicketNumber' => $TicketNumber,
																'sectors' => implode('-', $segment),
																'BookingId' => $strBookingIdLCC,
																'APIBookingId' => $strBookingIdLCC,
															);

															$wherep = "id = " . $booking_customer_id[$k][$pk];
															$objFlight->UpdateFlightData('tbl_flight_booking_customer', $updatep, $wherep);
														}
													}
													//if ($updated) {
													$responseReturn[$k] = array('success' => true, 'message' => $ErrorMessage, 'IsLCC' => $value['IsLCC']);
													//}
												} else {
													$update = array(
														'API_Response' => json_encode($response),
														'API_Response_Ticket' => '',
													);
													$where = "id = " . $flight_booking_id[$k]; //exit;
													$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
													$responseReturn[] = array('success' => false, 'message' => $ErrorMessage, 'IsLCC' => $value['IsLCC']);
												}
												// echo "<pre>";
												// print_r($response);
											}
											// echo "<pre>";
											// print_r($FlightBookingData);
											// die('ddddddd');
											if ($responseReturn && $ResponseStatus == 1) {
												$arrUrlData['FlightBookingTicketArr'] = $FlightBookingTicketArr;
												$arrUrlData['FlightQueryids'] = $FlightQueryids;
												$tempData = array(
													'TraceId' => $arrUrlData['SearchTraceId'],
													'json_data' => json_encode($arrUrlData),
												);
												$objFlight->deleteFlightTempData($arrUrlData['SearchTraceId']);
												$objFlight->insertFlightTempData($tempData);
												$Return = array('success' => true, 'message' => 'done', 'IsLCC' => $IsLCC, 'SearchTraceId' => $arrUrlData['SearchTraceId'], 'responseReturn' => $responseReturn);
												echo json_encode($Return);
												exit;
											} else {
												if ($paymentMode != 2 || $paymentMode != 3) {
													$CreditIntoWallet = $this->CreditIntoWallet($arrUrlData);
													$TransactionId = isset($CreditIntoWallet['TransactionId']) ? $CreditIntoWallet['TransactionId'] : '';
												}
												if ($FlightBookingData) {
													foreach ($FlightBookingData as $k => $value) {
														$update['TransactionId_debit'] = isset($TransactionId) ? $TransactionId : '';
														$update['status'] = 3;
														$where = "id = " . $flight_booking_id[$k]; //exit;
														$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
													}
												}
												$arrUrlData['FlightBookingTicketArr'] = $FlightBookingTicketArr;
												$arrUrlData['FlightQueryids'] = $FlightQueryids;
												$arrUrlData['CreditIntoWallet'] = $CreditIntoWallet;
												$tempData = array(
													'TraceId' => $arrUrlData['SearchTraceId'],
													'json_data' => json_encode($arrUrlData),
												);
												$objFlight->deleteFlightTempData($arrUrlData['SearchTraceId']);
												$objFlight->insertFlightTempData($tempData);
												$Return = array('success' => false, 'message' => 'failed', 'IsLCC' => $IsLCC, 'SearchTraceId' => $arrUrlData['SearchTraceId']);
												echo json_encode($Return);
												exit;
											}
										}
									} catch (Exception $e) {
										echo $e->getMessage();
										exit;
									}
								}
							}

							// $apiFlightTicketTripJack = new Zend_Session_Namespace('apiFlightTicketTripJack');
							// $Bookres = $apiFlightTicketTripJack->params;

							$BookingerrCode = isset($Bookres['errors'][0]['errCode']) ? $Bookres['errors'][0]['errCode'] : 0;
							$BookId = isset($Bookres['errors'][0]['details']) ? $Bookres['errors'][0]['details'] : '';

							if ($BookingerrCode == '2502') {
								$checkExistBooking = $objFlight->checkExistBooking($BookId);
								if (!empty($checkExistBooking)) {
									$Bookres = [
										'bookingId' => $BookId,
										'status' => array('success' => true, 'httpStatus' => 200),
									];
								}
							}


							if ($ICSourceSysId == 8 && $IsSeriesFareData == 1) {
								$OrderBookingStatus = 'SUCCESS';
							} elseif ($ICSourceSysId == 7) {
								$Bookres['SearchTraceId'] = $arrUrlData['SearchTraceId'];
								$Bookres['FlightBookingData'] = $FlightBookingData;
								$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingDetailsTripJack($Bookres);
								$OrderBookingStatus = isset($response['order']['status']) ? $response['order']['status'] : '';
							}
							$BookStatus = $Bookres['status']['success'];
							$BookErrorMessage = $Bookres['errors'][0]['message'];
							if ($BookStatus == 1 && $OrderBookingStatus != 'ABORTED') {
								// GTX Data pushing
								$model = new Gtxwebservices_Model_Webservices();
								$result = $model->CreateCustomer($apiData);
								$apiCustomer = json_decode($result, true);
								if ($apiCustomer['status'] == 1) {
									$arrCustomer['GTX_customerSysId'] = $apiCustomer['Message'];
									$where = "CustomerSysId = " . $CustomerSysId;
									$objFlight->UpdateFlightData('tbl_customer', $arrCustomer, $where);
								}
								$FlightQueryids = $this->genrateFlightQuery($post);
								$ResponseStatusGTX = isset($FlightQueryids['status']) ? $FlightQueryids['status'] : 0;
								$ErrorMessageGTX = isset($FlightQueryids['message']) ? $FlightQueryids['message'] : 'Unable to create query. please contact administrator.';
								if ($ResponseStatusGTX == 0) {
									//$CreditIntoWallet = $this->CreditIntoWallet($arrUrlData);
									//$TransactionId = isset($CreditIntoWallet['TransactionId']) ? $CreditIntoWallet['TransactionId'] : '';
									$Return = array('success' => false, 'message' => $ErrorMessageGTX, 'SearchTraceId' => $arrUrlData['SearchTraceId']);
									echo json_encode($Return);
									exit;
								}

								$strFilePath = "flight/SearchParam/" . $strUrlData . "/FlightQueryids/" . time() . "_request.json";
								Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($post));
								$strFilePath = "flight/SearchParam/" . $strUrlData . "/FlightQueryids/" . time() . "_response.json";
								Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($FlightQueryids));
								$queryStatus = isset($FlightQueryids['status']) ? $FlightQueryids['status'] : 0;
								$MasterTPSysId = $FlightQueryids['arrIds']['MasterTPSysId'];
								$TPSysId = $FlightQueryids['arrIds']['TPSysId'];
								$VersionId = $FlightQueryids['arrIds']['VersionId'];
								$TrxId = $FlightQueryids['arrIds']['TrxId'];

								// GTX Data pushing end.
								if ($ICSourceSysId == 8 && $IsSeriesFareData == 1) {
									$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingDetailsSeriesFareNew($FlightBookingData, $ForCustomerSession);
								} else {
									$Bookres['SearchTraceId'] = $arrUrlData['SearchTraceId'];
									$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingDetailsTripJack($Bookres);
								}

								// $str = file_get_contents($this->baseUrl . 'public/logs/flight/BookingDetails/1636723577_Series_BookingDetails_response.json');
								// $response = json_decode($str, true);

								if ($paymentMode == 3 || $paymentMode == 2) {
									// $DebitFromWallet = $this->DebitFromWallet($arrUrlData); Old likha tha pahle. prashant sir ke kehne pe humne isko api se pahle laga diya - 08-02-2022
									// $TransactionId = isset($DebitFromWallet['TransactionId']) ? $DebitFromWallet['TransactionId'] : '';
								} else {
									if ($ICSourceSysId == 8 && $IsSeriesFareData == 1) {
										$checkExistBooking1 = $objFlight->checkExistBooking($FlightBookingData[0]['bookingId']);
										if (empty($checkExistBooking1)) {
											$CheckSoldInventory1 = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckSoldInventory($FlightBookingData[0]['bookingId']);
											if ($CheckSoldInventory1['Status'] == false) {
												$CreditIntoWallet = $this->CreditIntoWalletForFailSoldInventory($arrUrlData, $flight_booking_id[0], $FlightQueryids);
												if ($route == 2 && isset($FlightBookingData[1]['bookingId'])) {
													$CheckReleaseInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckReleaseInventory($FlightBookingData[1]['bookingId']);
												}

												$return = array('success' => false, 'message' => 'Please contact administrator. Please note down reference number " ' . $FlightBookingData[0]['bookingId'] . ' " for future use.', 'SearchTraceId' => $arrUrlData['SearchTraceId']);
												echo json_encode($return);
												exit;
											}
										}

										if ($route == 2 && isset($FlightBookingData[1]['bookingId'])) {
											$checkExistBooking2 = $objFlight->checkExistBooking($FlightBookingData[1]['bookingId']);
											if (empty($checkExistBooking2)) {
												$CheckSoldInventory2 = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckSoldInventory($FlightBookingData[1]['bookingId']);
												if ($CheckSoldInventory2['Status'] == false) {
													$CheckReleaseInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckReleaseInventory($FlightBookingData[0]['bookingId']);
													$CreditIntoWallet = $this->CreditIntoWalletForFailSoldInventory($arrUrlData, $flight_booking_id[1], $FlightQueryids);
													$return = array('success' => false, 'message' => 'Please contact administrator. Please note down reference number " ' . $FlightBookingData[1]['bookingId'] . ' " for future use.', 'SearchTraceId' => $arrUrlData['SearchTraceId']);
													echo json_encode($return);
													exit;
												}
											}
										}
									}
								}

								$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) {
										$finalFareSummary = $value['FairRules'];
										$segggg = $value['SourceAirportCode'] . '-' . $value['DestAirportCode'];

										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;
											$PublishedFareINT = ($value['FairRules']['PublishedFare']);
											$AgentCommisionEarnedINT = ($finalFareSummary['CommEarned'] + $finalFareSummary['PLBEarned']);
											$AgentCommisionEarnedGSTINT = ($finalFareSummary['GSTonComm'] + isset($finalFareSummary['GSTonPLB']) ? $finalFareSummary['GSTonPLB'] : 0);
											$AgencyMarkUpINT = $finalFareSummary['FixedMarkUp'];
											$AgencyMarkUpGSTINT = $finalFareSummary['GSTOnMarkUp'];
											$GTXMarkUpINT = $finalFareSummary['intGTXMarkUp'];
											$AllAddOns = ($MealPrice + $BagPrice + $SeatFare);

											$BaseAmountINT = ($PublishedFareINT - $AgentCommisionEarnedINT);
											$UpdateFare[$k] = array(
												'Price' => $BaseAmountINT,
												'NetPrice' => $PublishedFareINT,
												'AgencyMarkUp' => $AgencyMarkUpINT,
												'AgentServiceTaxAmount' => $AgencyMarkUpGSTINT,
												'MarkUp' => $AgentCommisionEarnedINT,
												'AgentsCustomServiceTaxAmount' => $AgentCommisionEarnedGSTINT,
												'GTXMarkup' => $GTXMarkUpINT,
												'GTXServiceTaxAmount' => 0,
												'TotalCost' => $PublishedFareINT,
												'MealFare' => $MealPrice,
												'BaggFare' => $BagPrice,
												'SeatFare' => $SeatFare,
											);
											//$segment = $value['Segments']['originAirportCode'] . '-' . $value['Segments']['destinationAirportCode'];
											$FlightBookingTicketArr[] = $response;
											$OrderStatus = isset($response['order']['status']) ? $response['order']['status'] : '';
											$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';

											if ($ICSourceSysId == 8 &&  isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
												$strBookingIdLCC = isset($response['order']['bookingId'][$k]) ? $response['order']['bookingId'][$k] : '0';
											} else {
												$strBookingIdLCC = isset($response['order']['bookingId']) ? $response['order']['bookingId'] : '0';
											}
											$bookingId = str_replace('TJ', BOOKINGREF, $strBookingIdLCC);
											//$PNRNew = $strTicketPNRLCC[$segggg];
											$segment = [];
											$finalpnr = [];
											if ($value['Segments']) {
												foreach ($value['Segments'] as $seg) {
													$originAirportCode = $seg['originAirportCode'];
													$destinationAirportCode = $seg['destinationAirportCode'];
													$segment[] = $originAirportCode . '-' . $destinationAirportCode;
													$segment_t = $originAirportCode . '-' . $destinationAirportCode;
													//$PNRNew[] = $strTicketPNRLCC[$segment_t];
													$AirportCode = $originAirportCode . '-' . $destinationAirportCode;
													$finalpnr[] = isset($strTicketPNRLCC[$AirportCode]) ? $strTicketPNRLCC[$AirportCode] : '';
												}
											}
											$finalpnr = $this->checkArrayKeyExist($finalpnr);
											$objFlight = new Travel_Model_FlightMaster();
											$statusType = 1;
											if ($OnwardAutoTicket == 0 && $ICSourceSysId == 8 &&  $IsSeriesFareData == 1) {
												$statusType = 20;
											}
											if ($ResponseStatus == 1) {
												$PNRNew = !empty($finalpnr) ? implode(',', $finalpnr) : '';
												try {
													$update = array(
														'API_Response' => json_encode($value),
														'API_Response_Ticket' => json_encode($response),
														'FlightQueryids' => json_encode($FlightQueryids),
														'PNR_Number' => $PNRNew,
														//'PNR_Number' => implode('-', $strTicketPNRLCC),
														'BookingId' => $bookingId,
														'APIBookingId' => $strBookingIdLCC,
														'MasterTPSysId' => $MasterTPSysId,
														'TPSysId' => $TPSysId,
														'status' => $statusType,
														//'OrderStatus' => $OrderStatus,
													);

													if ($paymentMode == 3 || $paymentMode == 2) {
														$update['TransactionId_debit'] = $TransactionId;
													}


													$Amount = ($value['FairRules']['BaseFare'] + $AllAddOns);
													$NetAmount = ($value['FairRules']['PublishedFare'] + $AllAddOns);
													$PublishedFareAgent = (isset($value['FairRules']['PublishedFareAgent'])) ? $value['FairRules']['PublishedFareAgent'] : 0;
													$ExtraMarkup = (isset($value['FairRules']['ExtraMarkup'])) ? $value['FairRules']['ExtraMarkup'] : 0;
													$ExtraMarkupOnGST = (isset($value['FairRules']['ExtraMarkupOnGST'])) ? $value['FairRules']['ExtraMarkupOnGST'] : 0;
													$PublishedFareAgentFinal = round(($PublishedFareAgent + $ExtraMarkup + $ExtraMarkupOnGST), 2);

													// $CPPercentVal = (isset($arrUrlData['CencelattionData'][0]['CPPercentVal']) && !empty($arrUrlData['CencelattionData'][0]['CPPercentVal'])) ? (int)$arrUrlData['CencelattionData'][0]['CPPercentVal'] : 0;

													// $CPAmountWithTax = 0;
													// if ($IsCancellationProtection == 1 && !empty($CPPercentVal)) {
													// 	$CPAmount = ($PublishedFareAgentFinal * $CPPercentVal) / 100;
													// 	$CPAmountWithTax = $CPAmount + ($CPAmount * 18 / 100);
													// }
													// $CancellationProtectionData['IsCancellationProtection'] = $IsCancellationProtection;
													// $CancellationProtectionData['CancellationProtectionPrice'] = round($CPAmountWithTax, 2);
													// $CancellationProtectionData['finalPackageCostWithMarkupnTax'] = $PublishedFareAgentFinal;
													// $CancellationProtectionDataE = json_encode($CancellationProtectionData);
													// $CancellationProtectionDataCode = $encryptedData->encrypt($CancellationProtectionDataE, SECURITYKEY, SECURITYKEY);

													if ($IsCancellationProtection == 1) {
														$update['IsCancellationProtection'] = $IsCancellationProtection;
														$update['CancellationProtectionPrice'] = round($CPAmountWithTax, 2);
													}

													//echo '<pre>';print_r($CancellationProtectionData);
													$where = "id = " . $flight_booking_id[$k]; //exit;
													$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);

													$responseArray = array(
														'value' => $value,
														'response' => $response
													);
													$postFieldArray = array(
														'MasterTPSysId' => $MasterTPSysId,
														'TPSysId' => $TPSysId,
														'TrxId' => $TrxId,
														'VersionId' => $VersionId[$k],
														'XRefBookingId' => $bookingId,
														'APIBookingRes' => json_encode($responseArray),
														'Passenger' => json_encode($Passenger),
														'UpdateFare' => json_encode([$UpdateFare[$k]]),
														'Keys' => $k,
														'ErrorCode' => 0,
														'IsBookingStatus' => 1,
														'sectorTitle' => $sectorTitle,
														'Amount' => $Amount,
														'NetAmount' => $NetAmount,
														//'CancellationProtectionData' => $CancellationProtectionDataCode,
													);
													if ($k == 0) {
														$postFieldArray['CancellationProtectionData'] = $CancellationProtectionDataCode;
													}
													// $strFilePath = "flight/updateFlightBookingDetails/" . time() . "_update_request.json";
													// Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($postFieldArray));

													$strFilePath = "flight/SearchParam/" . $strUrlData . "/GTX/" . $k . "_update_request.json";
													Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($postFieldArray));

													$model = new Gtxwebservices_Model_Webservices();
													$result = $model->updateFlightBookingB2B($postFieldArray);

													$strFilePath = "flight/SearchParam/" . $strUrlData . "/GTX/" . time() . "_update_response.json";
													Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, ($result));
												} catch (Exception $error) {
													//echo $error->getMessage();
													$strFilePath = "flight/SearchParam/" . $strUrlData . "/errors/" . time() . "_request.json";
													Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($error->getMessage()));
													$Return = array('success' => false, 'message' => 'Sorry some errors has occured our end. Please note down reference number " ' . $bookingId . ' " for future use. we will contact you soon.');
													echo json_encode($Return);
													exit;
												}

												//die('dd');
												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' => $bookingId,
															'APIBookingId' => $strBookingIdLCC,
														);

														$wherep = "id = " . $booking_customer_id[$k][$pk];
														$objFlight->UpdateFlightData('tbl_flight_booking_customer', $updatep, $wherep);
													}
												}
												if ($updated) {
													$responseReturn[] = array('success' => true, 'message' => $ErrorMessage, 'IsLCC' => $value['IsLCC']);
												}
											} else {
												$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();
											$strFilePath = "flight/SearchParam/" . $strUrlData . "/errors/" . time() . "_request.json";
											Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($e->getMessage()));
											$Return = array('success' => false, 'message' => 'Sorry some errors has occured our end. Please note down reference number " ' . $bookingId . ' " for future use. for future use. we will contact you soon.');
											echo json_encode($Return);
											exit;
										}
									}

									// echo '<pre>';print_r($responseReturn);
									// echo '<pre>';print_r($ResponseStatus);
									// 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 {

								//echo $paymentMode;die('qq');
								if ($paymentMode == 3 || $paymentMode == 2) {
								} else {
									$CreditIntoWallet = $this->CreditIntoWallet($arrUrlData);
									$TransactionId = isset($CreditIntoWallet['TransactionId']) ? $CreditIntoWallet['TransactionId'] : '';
								}
								if ($FlightBookingData) {
									foreach ($FlightBookingData as $k => $value) {
										$update['TransactionId_debit'] = isset($TransactionId) ? $TransactionId : '';
										$update['status'] = 3;
										$where = "id = " . $flight_booking_id[$k]; //exit;
										$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
									}
								}
								if ($OrderBookingStatus == 'ABORTED') {
									$postFieldArray = array(
										'MasterTPSysId' => $MasterTPSysId,
										'TPSysId' => $TPSysId,
										'TrxId' => $TrxId,
										'XRefBookingId' => $bookingId,
										'ErrorCode' => 0,
										'IsBookingStatus' => 124,
										'updatePnr' => 1
									);
									$model = new Gtxwebservices_Model_Webservices();
									$result = $model->updateFlightAbortedgB2B($postFieldArray);
								}
								$WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyWallaetBalance($this->SecurityKey);
								$sessionWallaetBalance = new Zend_Session_Namespace('sessionWallaetBalance');
								$sessionWallaetBalance->params = $WallaetBalance;
								//die('ss');
								$arrUrlData['FlightBookingTicketArr'] = $Bookres;
								$arrUrlData['CreditIntoWallet'] = $CreditIntoWallet;
								$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;
							}
						}
					} else {
						$this->_redirect('flight');
					}
				}
			}
		}
	}
	public function generatenonlccticketAction()
	{
		$post = $this->getRequest()->getParams();
		$status = isset($post['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'];
		$FlightBookingTicketArr = $arrUrlData['FlightBookingTicketArr'];
		$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;
		$paymentMode = isset($arrUrlData['paymentMode']) ? $arrUrlData['paymentMode'] : 0;
		$post = isset($arrUrlData['post']) ? $arrUrlData['post'] : '';
		$apiData = isset($arrUrlData['apiData']) ? $arrUrlData['apiData'] : '';
		$FlightQueryids = isset($arrUrlData['FlightQueryids']) ? $arrUrlData['FlightQueryids'] : '';
		$CustomerSysId = isset($arrUrlData['CustomerSysId']) ? $arrUrlData['CustomerSysId'] : 0;
		$MasterTPSysId = $FlightQueryids['arrIds']['MasterTPSysId'];
		$TPSysId = $FlightQueryids['arrIds']['TPSysId'];
		$VersionId = $FlightQueryids['arrIds']['VersionId'];
		$TrxId = $FlightQueryids['arrIds']['TrxId'];

		if ($FlightBookingTicketArr) {
			foreach ($FlightBookingTicketArr as $key => $response) {

				$ResponseStatus = isset($response['Response']['ResponseStatus']) ? $response['Response']['ResponseStatus'] : '0';
				$apiTraceId = isset($response['Response']['TraceId']) ? $response['Response']['TraceId'] : '0';
				$ErrorCode = isset($response['Response']['Error']['ErrorCode']) ? $response['Response']['Error']['ErrorCode'] : '0';
				$ErrorMessage = isset($response['Response']['Error']['ErrorMessage']) ? $response['Response']['Error']['ErrorMessage'] : '';
				$strBookingIdLCC = isset($response['Response']['Response']['BookingId']) ? $response['Response']['Response']['BookingId'] : '';
				$strTicketPNRLCC = isset($response['Response']['Response']['PNR']) ? $response['Response']['Response']['PNR'] : '';
				$IsLCC = isset($response['Response']['Response']['FlightItinerary']['IsLCC']) ? $response['Response']['Response']['FlightItinerary']['IsLCC'] : '';

				if ($ResponseStatus == 1 && $IsLCC != 1) {
					$data = [
						"TraceId" => $apiTraceId,
						"PNR" => $strTicketPNRLCC,
						"BookingId" => $strBookingIdLCC,
						"FlightTraceId" => $strUrlData
					];

					// echo '<pre>';
					// print_r($data);
					$strJsonResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->generateNonLccTicket($data, $this->gtxagencysysid);
					// $str = file_get_contents($this->baseUrl . '/public/logs/flight/generateNonLccTicket/FlightTicket_response.json');
					// $strJsonResponse = json_decode($str, true);

					$responseNLCC = ($strJsonResponse);
					$FlightBookingTicketArr[$key] = $responseNLCC;
					$ResponseStatusNLCC = isset($responseNLCC['Response']['ResponseStatus']) ? $responseNLCC['Response']['ResponseStatus'] : '0';
					$ErrorMessageNLCC = isset($responseNLCC['Response']['Error']['ErrorMessage']) ? $responseNLCC['Response']['Error']['ErrorMessage'] : '';
					$Passenger = isset($responseNLCC['Response']['Response']['FlightItinerary']['Passenger']) ? $responseNLCC['Response']['Response']['FlightItinerary']['Passenger'] : '';
					if ($ResponseStatusNLCC == 1) {
						$update = array(
							'API_Response_Ticket' => json_encode($responseNLCC),
							'PNR_Number' => $strTicketPNRLCC,
							'BookingId' => $strBookingIdLCC,
							'status' => 1,
						);
						// echo '<pre>';
						// print_r($update);
						$where = "id = " . $flight_booking_id[$key]; //exit;
						$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
						$BookingId = $strBookingIdLCC . "/" . $strTicketPNRLCC;
						$postFieldArray = array(
							'MasterTPSysId' => $MasterTPSysId,
							'TPSysId' => $TPSysId,
							'TrxId' => $TrxId,
							'VersionId' => $VersionId[$key],
							'XRefBookingId' => $strTicketPNRLCC . '/' . $strBookingIdLCC,
							'APIBookingRes' => json_encode($responseNLCC),
							'Passenger' => json_encode($Passenger),
							'ErrorCode' => 0,
							'IsBookingStatus' => 1,

						);
						$strFilePath = "flight/updateFlightBookingDetailsNonLcc/" . time() . "_update_request.json";
						Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $postFieldArray);

						$model = new Gtxwebservices_Model_Webservices();
						$result = $model->updateFlightBookingB2B($postFieldArray);

						if ($Passenger) {
							foreach ($Passenger as $pk => $pax) {
								$TicketId = $pax['Ticket']['TicketId'];
								$TicketNumber = $pax['Ticket']['TicketNumber'];
								$updatep = array(
									'TicketId' => $TicketId,
									'TicketNumber' => $TicketNumber,
								);
								$wherep = "id = " . $booking_customer_id[$key][$pk];
								$objFlight->UpdateFlightData('tbl_flight_booking_customer', $updatep, $wherep);
							}
						}
						$responseReturn[] = array('success' => true, 'message' => 'Done');
					} else {
						$update = array(
							'API_Response_Ticket' => '',
							'status' => 5,
						);
						$where = "id = " . $flight_booking_id[$key]; //exit;
						$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
						$responseReturn[] = array('success' => false, 'message' => $ErrorMessageNLCC);
					}
				} else {
					$FlightBookingTicketArr[$key] = $response;
				}
			}
		}
		if ($FlightBookingTicketArr) {

			$arrUrlData['FlightBookingTicketArr'] = $FlightBookingTicketArr;
			$tempData = array(
				'TraceId' => $arrUrlData['SearchTraceId'],
				'json_data' => json_encode($arrUrlData),
			);
			$objFlight->deleteFlightTempData($arrUrlData['SearchTraceId']);
			$objFlight->insertFlightTempData($tempData);
			$Return = array('success' => true, 'message' => 'done', 'IsLCC' => $IsLCC, 'SearchTraceId' => $arrUrlData['SearchTraceId']);
			echo json_encode($Return);
			exit;
		}
	}

	public function bookingConfirmedAction()
	{
		$post = $param = $this->getRequest()->getParams();
		try {
			$status = isset($post['status']) ? $post['status'] : '';
			$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
			$bookingid = $this->view->bookingid = $this->getRequest()->getParam('bookingid');
			$objFlight = new Travel_Model_FlightMaster();
			$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
			$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
			$FlightBooking = $objFlight->FlightCancelDataTripJack('tbl_flight_booking', $post['bookingid'], null, $strUrlData);

			$arrUrlData = json_decode($FlightTempData['json_data'], true);
			$FlightBookingData = $arrUrlData['FlightBookingData'];

			if (isset($post['bookingid']) && !empty($post['bookingid'])) {
				$API_Response[0] = json_decode($FlightBooking['data']['API_Response'], 1);
				$API_Response_Ticket[0] = json_decode($FlightBooking['data']['API_Response_Ticket'], 1);
				$FlightBookingData = $API_Response;
			}


			if (!empty($arrUrlData)) {
				$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
				if ($sessionFlightSearchParams['route'] == 4) {
					$this->IsTJFlightAPI = 1;
				}
				$ICSourceSysId = isset($FlightBooking['data']['ICSourceSysId']) ? $FlightBooking['data']['ICSourceSysId'] : 0;

				$this->view->B2BType = $this->_session->B2BType;
				$this->view->ICSourceSysId = $ICSourceSysId;
				$this->view->FlightBookingData = $FlightBookingData;
				$this->view->FlightBooking = $FlightBooking;
				$this->view->passengerData = $FlightBooking['passenger'];
				$this->view->SearchTraceId = $TraceId = $arrUrlData['SearchTraceId'];
				$this->view->FlightBookingTicketArr = $FlightBookingTicketArr = $arrUrlData['FlightBookingTicketArr'];
				if (isset($post['bookingid']) && !empty($post['bookingid'])) {
					$this->view->FlightBookingTicketArr = $FlightBookingTicketArr = $API_Response_Ticket;
					if ($ICSourceSysId == 7 || $ICSourceSysId == 8) {
						$this->view->FlightBookingTicketArr = $FlightBookingTicketArr = $API_Response_Ticket[0];
					}
				}
				$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->IsTJFlightAPI = $this->IsTJFlightAPI;
				$this->view->IsBOTHFlightAPI = $this->IsBOTHFlightAPI;
				$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;
				$BookingData = $objFlight->FlightBookingData('tbl_flight_booking', $TraceId);
				$this->view->BookingData = $BookingData;

				$IsSeriesFareData = isset($FlightBookingData[0]['IsSeriesFareData']) ? $FlightBookingData[0]['IsSeriesFareData'] : 0;
				$ICSourceSysId = isset($BookingData['onward']['ICSourceSysId']) ? $BookingData['onward']['ICSourceSysId'] : 0;
				$SegmentsArr = [];
				if ($FlightBookingData) {
					foreach ($FlightBookingData as $Data) {
						foreach ($Data['Segments'] as $seg) {
							$SegmentsArr[] = $seg;
						}
					}
				}
				$AirlineCodeArr = [];
				if ($SegmentsArr) {
					foreach ($SegmentsArr as $key => $value) {
						$AirlineCodeArr[] = $value['AirlineCode'];
					}
				}
				$getAirlinesSupport = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAirlinesSupport(array_values(array_unique($AirlineCodeArr)));
				$this->view->getAirlinesSupport = $getAirlinesSupport;
				if ($ICSourceSysId == 7 || $ICSourceSysId == 8) {
					$success = $FlightBookingTicketArr['status']['success'];
				} else {
					$Response['onward'] = $FlightBookingTicketArr[0];
					if (isset($FlightBookingTicketArr[1])) {
						$Response['return'] = $FlightBookingTicketArr[1];
					}
					$success = $Response['onward']['Response']['ResponseStatus'];
					if ($IsSeriesFareData == 1) {
						$success = $FlightBookingTicketArr['status']['success'];
					}
				}
				// if (trim($this->MasterAgencySysId) == '5310') {
				// 	echo '<pre>';print_r($status); 
				// 	echo '<pre>';print_r($success); 
				// echo '<pre>';print_r($FlightBookingTicketArr); 

				// echo '<pre>';print_r($FlightBookingData); 
				// die;
				// }
				// if($this->gtxagencysysid == '6230'){
				// 	echo '<pre>';print_r($ICSourceSysId); 
				// 	echo '<pre>';print_r($success); 
				// 	echo '<pre>';print_r($BookingData);die;
				// }
				$getAgencySupplierUserData = array();
				$IsSupplierInv = isset($FlightBookingData[0]['IsSupplierInv']) ? $FlightBookingData[0]['IsSupplierInv'] : 0;

				if ($status == 'true' && $success == 1) {
					if ($IsSeriesFareData == 1 && ($IsSupplierInv == 1 || $IsSupplierInv == 0)) {
						$SupplierSysId = isset($FlightBookingData[0]['SupplierSysId']) ? $FlightBookingData[0]['SupplierSysId'] : 0;
						$apiSupplierData = array(
							"SupplierSysId" => $SupplierSysId,
							"AgencySysId" => $this->_session->data['AgencySysId'],
						);
						$getAgencySupplierUserData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencySupplierUserData($apiSupplierData);
						$getAgencySupplierUserData = isset($getAgencySupplierUserData['data']) ? $getAgencySupplierUserData['data'] : array();
					}
					$apiData = array(
						"CustomerSysId" => $this->_session->data['CustomerSysId'],
						"UserSysId" => $this->_session->data['UserSysId'],
						"AgencySysId" => $this->_session->data['AgencySysId']
					);
					$created_at = isset($FlightTempData['created_at']) ? $FlightTempData['created_at'] : date('d-m-Y');
					$getAgencyUserData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyUserData($apiData);
					$MasterAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->MasterAgencySysId);
					$getAgencyData = $getAgencyUserData['profile'];
					$AgentAddress = $getAgencyUserData['AddressByAgency'];
					$this->view->getAgencyData = $getAgencyData;
					$this->view->B2BType = $this->_session->B2BType;
					$logo = $this->gtxBtoBsite . 'public/upload/media/agency/' . trim(@$MasterAgencyData['AgencySysId']) . '/' . trim(@$MasterAgencyData['logo']);
					$this->view->MasterAgencyLogo = $logo;
					$getSupportContactData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getSupportContactData(1, 2, 1);
					$html = new Zend_View();
					$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
					$html->assign(array('FlightBookingData' => $FlightBookingData, 'Email' => true, 'MasterAgencyData' => $MasterAgencyData, 'ForCustomerSession' => $ForCustomerSession, 'selectedSeatSession' => $selectedSeatSession, 'SelectedMealSessionNew' => $SelectedMealSessionNew, 'SelectedBaggSessionNew' => $SelectedBaggSessionNew, 'FlightBookingTicketArr' => $FlightBookingTicketArr, 'B2BType' => $this->_session->B2BType, 'MasterAgencyLogo' => $logo, 'sessionFlightSearchParams' => $sessionFlightSearchParams, 'getAgencyData' => $getAgencyData, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, ' siteName' => $this->siteName, 'baseUrl' => $this->baseUrl, 'IsTJFlightAPI' => $this->IsTJFlightAPI, 'created_at' => $created_at, 'getSupportContactData' => $getSupportContactData, 'siteName' => $this->siteName, 'passengerData' => $FlightBooking['passenger'], 'BookingData' => $FlightBooking['data'], 'AgentAddress' => $AgentAddress, 'getAirlinesSupport' => $getAirlinesSupport, 'MasterAgencySysId' => $this->MasterAgencySysId, 'getAgencySupplierUserData' => $getAgencySupplierUserData));
					//$paramssss = array('FlightBookingData' => $FlightBookingData, 'Email' => true, 'ForCustomerSession' => $ForCustomerSession, 'selectedSeatSession' => $selectedSeatSession, 'SelectedMealSessionNew' => $SelectedMealSessionNew, 'SelectedBaggSessionNew' => $SelectedBaggSessionNew, 'FlightBookingTicketArr' => $FlightBookingTicketArr, 'B2BType' => $this->_session->B2BType, 'MasterAgencyLogo' => $logo, 'sessionFlightSearchParams' => $sessionFlightSearchParams, 'getAgencyData' => $getAgencyData, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, ' siteName' => $this->siteName, 'baseUrl' => $this->baseUrl,'IsTJFlightAPI'=>$this->IsTJFlightAPI,'created_at'=>$created_at,'getSupportContactData'=>$getSupportContactData,'siteName' => $this->siteName);

					$OnwardAutoTicket = isset($FlightBookingData[0]['OnwardAutoTicket']) ? $FlightBookingData[0]['OnwardAutoTicket'] : 1;
					$MasterPrimaryEmailTo = $MasterAgencyData['PrimaryEmail'];
					$AgentEmailTo = $getAgencyData['EmailId'];
					$sendersEmailId = (isset($getSupportContactData['EmailId'])) ? trim($getSupportContactData['EmailId']) : $MasterPrimaryEmailTo;
					if ($OnwardAutoTicket == 1) {
						$bodyText = $html->render('e-ticket.phtml');
						$bodyTextMaster = $html->render('e-ticket-masteragency.phtml');
						$bodyTextAgent = $html->render('e-ticket-agent.phtml');
						$subject1 = $subject = 'Your Ticket Has Been Booked';
						$Caption = 'Your Ticket Has Been Booked';
						if (trim($this->MasterAgencySysId) == '5310') {
							$sendersEmailId = $MasterPrimaryEmailTo = "sales.auxotrip@gmail.com";
							$subject1 = 'Your Ticket Has Been Booked ' . $FlightBookingData[0]['SourceAirportCode'] . ' - ' . $FlightBookingData[0]['DestAirportCode'] . ' (Ref: ' . $FlightBookingData[0]['bookingId'] . ')';
						}
						$configs = [
							'to' => trim($ForCustomerSession[0]['EmailId']),
							'fromName' => $this->siteName,
							'fromEmail' => $getAgencyData['EmailId'],
							'subject' => $subject,
							'bodyHtml' => $bodyText,
						];
						$configsMaster = [
							'to' => trim($MasterPrimaryEmailTo),
							'fromName' => $this->siteName,
							'fromEmail' => $sendersEmailId,
							'subject' => $subject1,
							'bodyHtml' => $bodyTextMaster,
						];
						$configsAgent = [
							'to' => trim($AgentEmailTo),
							'fromName' => $this->siteName,
							'fromEmail' => $sendersEmailId,
							'subject' => $subject,
							'bodyHtml' => $bodyTextAgent,
						];


						$returnmail = $this->objHelperGeneral->mailSentByElastice($configs, $Caption);
						$returnmail2 = $this->objHelperGeneral->mailSentByElastice($configsMaster, $Caption);
						$returnmail3 = $this->objHelperGeneral->mailSentByElastice($configsAgent, $Caption);
						$logParams = [
							"user_id"      => 1,
							"custom_error" => "Booking Confirm Mail",
							"text_udf"     => ['ForCustomer' => $returnmail, 'ForMasterAgency' => $returnmail2, 'ForAgent' => $returnmail3], // Response
							"char_udf"     => ['ForCustomer' => $configs, 'ForMasterAgency' => $configsMaster, 'ForAgent' => $configsAgent], // Request
							"udf1"         => $TraceId,
							"status"       => 2,
						];
						Zend_Controller_Action_HelperBroker::getStaticHelper("General")->CreateLogs($logParams);
						// echo "<pre>";
						// print_r($returnmail);
						// echo "</pre>";
						// echo "<pre>";
						// echo ($returnmail2);
						// echo "</pre>";
						// echo "<pre>";
						// echo ($returnmail3);
						// echo "</pre>";
						// die('qqq');
					} else {
						$bodyText_custom = $html->render('e-ticket.phtml');
						$bodyTextAgent = $html->render('e-ticket-agent.phtml');

						$bodyText = $html->render('send_updateticket_to_booking_agent.phtml');
						$subject = 'Booking Status – Pending - ' . $FlightBookingData[0]['SourceAirportCode'] . ' - ' . $FlightBookingData[0]['DestAirportCode'] . ' (Ref: ' . $FlightBookingData[0]['bookingId'] . ')';
						$Caption = 'Your Ticket Has Been Booked';

						$AgentEmailId = trim($getAgencyData['EmailId']);
						//echo "<pre>";print_r($AgentEmailId);die;
						$emailData = array('fromEmail' => $getSupportContactData['EmailId'], 'fromName' => $this->siteName, 'subject' => $subject, 'to' => array(trim($AgentEmailId)), 'bodyHtml' => $bodyText, 'bodyText' => '');
						$otherEmailid = array();
						if (trim($this->MasterAgencySysId) == '5310') {
							$otherEmailid[] = "sales.auxotrip@gmail.com";
						}
						$emailData_sender = array('fromEmail' => $getSupportContactData['EmailId'], 'fromName' => $this->siteName, 'subject' => $subject, 'to' => array_merge($otherEmailid, array($sendersEmailId)), 'bodyHtml' => $bodyText, 'bodyText' => '');

						$arrEmailStatistics = array();
						$emailstatus = Catabatic_ValidateCustomer::mailSentByElastice($emailData, $arrEmailStatistics, 0, 0, array($sendersEmailId));
						$emailstatus1 =  Catabatic_ValidateCustomer::mailSentByElastice($emailData_sender, $arrEmailStatistics, 0, 0, array($sendersEmailId), array(trim($AgentEmailId)));
						$configs = [
							'to' => trim($ForCustomerSession[0]['EmailId']),
							'fromName' => $this->siteName,
							'fromEmail' => $getAgencyData['EmailId'],
							'subject' => $subject,
							'bodyHtml' => $bodyText_custom,
						];

						$configsAgent = [
							'to' => trim($AgentEmailTo),
							'fromName' => $this->siteName,
							'fromEmail' => $sendersEmailId,
							'subject' => $subject,
							'bodyHtml' => $bodyTextAgent,
						];
						$this->objHelperGeneral->mailSentByElastice($configs, $Caption);
						$this->objHelperGeneral->mailSentByElastice($configsAgent, $Caption);
					}

					if ($IsSeriesFareData == 1 && !empty($getAgencySupplierUserData) && ($IsSupplierInv == 1 || $IsSupplierInv == 0)) {
						$Caption = $subject;

						$supplierBodyText = $html->render('e-ticket-supplier.phtml');
						$configsSupp = [
							'to' => trim($getAgencySupplierUserData['EmailId']),
							'fromName' => $this->siteName,
							'fromEmail' => $sendersEmailId,
							'subject' => $subject,
							'bodyHtml' => $supplierBodyText,
						];
						$returnmail = $this->objHelperGeneral->mailSentByElastice($configsSupp, $Caption);
						$configsSuppMaster = [
							'to' => trim($MasterPrimaryEmailTo),
							'fromName' => $this->siteName,
							'fromEmail' => $sendersEmailId,
							'subject' => $subject,
							'bodyHtml' => $supplierBodyText,
						];
						$returnmail = $this->objHelperGeneral->mailSentByElastice($configsSuppMaster, $Caption);
					}

					$this->_redirect('flight/booking-confirmed/data/' . $strUrlData);
				}
				// else{
				// 	$this->_redirect('flight/booking-confirmed/data/' . $strUrlData);
				// }
			} else {
				die('bad request');
			}
		} catch (Zend_Exception $e) {
			print_r($e->getMessage());
			exit;
		}
	}

	public function updateholdticketAction()
	{
		$post = $this->getRequest()->getParams();
		$status = isset($post['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'];
			if ($sessionFlightSearchParams['route'] == 4) {
				$this->IsTJFlightAPI = 1;
			}
			$this->view->B2BType = $this->_session->B2BType;
			$this->view->FlightBookingData = $FlightBookingData;
			$this->view->SearchTraceId = $TraceId = $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->IsTJFlightAPI = $this->IsTJFlightAPI;
			$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;
			$BookingData = $objFlight->FlightBookingData('tbl_flight_booking', $TraceId);
			$this->view->BookingData = $BookingData;
			// echo '<pre>';FlightBookingTicketArr
			// print_r($BookingData);
			// die;
			if ($this->IsTJFlightAPI) {
				$success = $FlightBookingTicketArr['status']['success'];
			} else {
				$Response['onward'] = $FlightBookingTicketArr[0];
				if (isset($FlightBookingTicketArr[1])) {
					$Response['return'] = $FlightBookingTicketArr[1];
				}
				$success = $Response['onward']['Response']['ResponseStatus'];
			}
			// print_r($success);
			// die;
			if ($status == 'true' && $success == 1) {
				$apiData = array(
					"CustomerSysId" => $this->_session->data['CustomerSysId'],
					"UserSysId" => $this->_session->data['UserSysId'],
					"AgencySysId" => $this->_session->data['AgencySysId']
				);
				$created_at = isset($FlightTempData['created_at']) ? $FlightTempData['created_at'] : date('d-m-Y');
				$getAgencyUserData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyUserData($apiData);
				$MasterAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->MasterAgencySysId);
				$getAgencyData = $getAgencyUserData['profile'];
				$this->view->getAgencyData = $getAgencyData;
				$this->view->B2BType = $this->_session->B2BType;
				$logo = $this->gtxBtoBsite . 'public/upload/media/agency/' . trim(@$MasterAgencyData['AgencySysId']) . '/' . trim(@$MasterAgencyData['logo']);
				$this->view->MasterAgencyLogo = $logo;
				$getSupportContactData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getSupportContactData(1, 2, 1);
				$html = new Zend_View();
				$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
				$html->assign(array('FlightBookingData' => $FlightBookingData, 'Email' => true, 'ForCustomerSession' => $ForCustomerSession, 'selectedSeatSession' => $selectedSeatSession, 'SelectedMealSessionNew' => $SelectedMealSessionNew, 'SelectedBaggSessionNew' => $SelectedBaggSessionNew, 'FlightBookingTicketArr' => $FlightBookingTicketArr, 'B2BType' => $this->_session->B2BType, 'MasterAgencyLogo' => $logo, 'sessionFlightSearchParams' => $sessionFlightSearchParams, 'getAgencyData' => $getAgencyData, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, ' siteName' => $this->siteName, 'baseUrl' => $this->baseUrl, 'IsTJFlightAPI' => $this->IsTJFlightAPI, 'created_at' => $created_at, 'getSupportContactData' => $getSupportContactData, 'siteName' => $this->siteName));
				//$paramssss = array('FlightBookingData' => $FlightBookingData, 'Email' => true, 'ForCustomerSession' => $ForCustomerSession, 'selectedSeatSession' => $selectedSeatSession, 'SelectedMealSessionNew' => $SelectedMealSessionNew, 'SelectedBaggSessionNew' => $SelectedBaggSessionNew, 'FlightBookingTicketArr' => $FlightBookingTicketArr, 'B2BType' => $this->_session->B2BType, 'MasterAgencyLogo' => $logo, 'sessionFlightSearchParams' => $sessionFlightSearchParams, 'getAgencyData' => $getAgencyData, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, ' siteName' => $this->siteName, 'baseUrl' => $this->baseUrl,'IsTJFlightAPI'=>$this->IsTJFlightAPI,'created_at'=>$created_at,'getSupportContactData'=>$getSupportContactData,'siteName' => $this->siteName);

				$OnwardAutoTicket = isset($FlightBookingData[0]['OnwardAutoTicket']) ? $FlightBookingData[0]['OnwardAutoTicket'] : 1;
				if ($OnwardAutoTicket == 1) {
					$bodyText = $html->render('e-ticket.phtml');
					$subject = 'Your Ticket Has Been Booked';
					$Caption = 'Your Ticket Has Been Booked';
					$configs = [
						'to' => trim($ForCustomerSession[0]['EmailId']),
						'fromName' => $this->siteName,
						'fromEmail' => $getAgencyData['EmailId'],
						'subject' => $subject,
						'bodyHtml' => $bodyText,
					];
					$returnmail = $this->objHelperGeneral->mailSentByElastice($configs, $Caption);
				} else {

					$bodyText = $html->render('send_updateticket_to_booking_agent.phtml');
					$subject = 'Booking Status – Pending - ' . $FlightBookingData[0]['SourceAirportCode'] . ' - ' . $FlightBookingData[0]['DestAirportCode'] . ' (Ref: ' . $FlightBookingData[0]['bookingId'] . ')';
					$Caption = 'Your Ticket Has Been Booked';
					$sendersEmailId = trim($getSupportContactData['EmailId']);
					$AgentEmailId = trim($getAgencyData['EmailId']);
					//echo "<pre>";print_r($AgentEmailId);die;
					$emailData = array('fromEmail' => $getSupportContactData['EmailId'], 'fromName' => $this->siteName, 'subject' => $subject, 'to' => array(trim($AgentEmailId)), 'bodyHtml' => $bodyText, 'bodyText' => '');
					$emailData_sender = array('fromEmail' => $getSupportContactData['EmailId'], 'fromName' => $this->siteName, 'subject' => $subject, 'to' => array($sendersEmailId), 'bodyHtml' => $bodyText, 'bodyText' => '');

					$arrEmailStatistics = array();
					$emailstatus = Catabatic_ValidateCustomer::mailSentByElastice($emailData, $arrEmailStatistics, 0, 0, array($sendersEmailId));
					$emailstatus1 =  Catabatic_ValidateCustomer::mailSentByElastice($emailData_sender, $arrEmailStatistics, 0, 0, array($sendersEmailId), array(trim($AgentEmailId)));
				}
				$this->_redirect('flight/booking-confirmed/data/' . $strUrlData);
			}
			// else{
			// 	$this->_redirect('flight/booking-confirmed/data/' . $strUrlData);
			// }
		} else {
			die('bad request');
		}
		// echo '<pre>';
		// print_r($arrUrlData);
		// die;
	}

	public function downloadTicketAction()
	{

		$this->_helper->layout->disableLayout();
		$post = $this->getRequest()->getParams();
		$status = $post['status'];


		//echo '<pre>';print_r($post);die;
		$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
		$objFlight = new Travel_Model_FlightMaster();
		$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
		$withprice = $this->view->withprice = $this->getRequest()->getParam('withprice');
		$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
		$FlightBookingDataFinal = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $strUrlData);
		$arrUrlData = json_decode($FlightTempData['json_data'], true);
		$FlightBookingData = $arrUrlData['FlightBookingData'];
		if (!empty($arrUrlData)) {
			$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
			$this->view->created_at = $FlightTempData['created_at'];
			$this->view->FlightBookingData = $FlightBookingData;
			$this->view->passengerData = $FlightBookingDataFinal['passenger'];
			$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->baseUrl = $this->baseUrl;
			$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;
			$apiData = array(
				"CustomerSysId" => $this->_session->data['CustomerSysId'],
				"UserSysId" => $this->_session->data['UserSysId'],
				"AgencySysId" => $this->_session->data['AgencySysId']
			);
			$getAgencyUserData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyUserData($apiData);
			$MasterAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->MasterAgencySysId);
			$getAgencyData = $getAgencyUserData['profile'];
			$this->view->getAgencyData = $getAgencyData;
			$this->view->B2BType = $this->_session->B2BType;
			$logo = $this->gtxBtoBsite . 'public/upload/media/agency/' . trim(@$MasterAgencyData['AgencySysId']) . '/' . trim(@$MasterAgencyData['logo']);
			$this->view->MasterAgencyLogo = $logo;
		} else {
			die('bad request');
		}
	}

	public function downloadTicketnewAction()
	{
		$this->_helper->layout->disableLayout();
		$post = $this->getRequest()->getParams();
		$status = $post['status'];
		$checkaction = isset($post['checkaction']) ? $post['checkaction'] : '';

		//echo '<pre>';print_r($FlightBookingDataFinal);die;FlightBookingData
		$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
		$objFlight = new Travel_Model_FlightMaster();
		$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
		$withprice = $this->view->withprice = isset($post['withprice']) ? $post['withprice'] : 0;
		$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
		$FlightBookingDataFinal = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $strUrlData);
		$arrUrlData = json_decode($FlightTempData['json_data'], true);
		$FlightBookingData = $arrUrlData['FlightBookingData'];
		$ICSourceSysId = isset($FlightBookingDataFinal['data']['ICSourceSysId']) ? $FlightBookingDataFinal['data']['ICSourceSysId'] : 0;
		//                echo '<pre>';print_r($FlightBookingDataFinal);die;
		if (!empty($arrUrlData)) {
			$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
			if ($sessionFlightSearchParams['route'] == 4) {
				$this->IsTJFlightAPI = 1;
			}
			$this->view->created_at = $FlightTempData['created_at'];
			$this->view->ICSourceSysId = $ICSourceSysId;
			$this->view->FlightBookingData = $FlightBookingData;
			$this->view->passengerData = $FlightBookingDataFinal['passenger'];
			$this->view->BookingData = $FlightBookingDataFinal['data'];
			$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->baseUrl = $this->baseUrl;
			$this->view->IsTJFlightAPI = $this->IsTJFlightAPI;
			$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;
			$apiData = array(
				"CustomerSysId" => $this->_session->data['CustomerSysId'],
				"UserSysId" => $this->_session->data['UserSysId'],
				"AgencySysId" => $this->_session->data['AgencySysId']
			);
			$getAgencyUserData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyUserData($apiData);
			$MasterAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->MasterAgencySysId);
			$AgentAddress = $getAgencyUserData['AddressByAgency'];
			$this->view->AgentAddress = $AgentAddress;
			$getAgencyData = $getAgencyUserData['profile'];
			$this->view->getAgencyData = $getAgencyData;
			$this->view->MasterAgencySysId = $this->MasterAgencySysId;

			//echo '<pre>';print_r($AgentAddress);die; passengerData
			$this->view->B2BType = $this->_session->B2BType;
			$logo = $this->gtxBtoBsite . 'public/upload/media/agency/' . trim(@$MasterAgencyData['AgencySysId']) . '/' . trim(@$MasterAgencyData['logo']);
			$this->view->MasterAgencyLogo = $logo;
			$SegmentsArr = [];
			if ($FlightBookingData) {
				foreach ($FlightBookingData as $Data) {
					foreach ($Data['Segments'] as $seg) {
						$SegmentsArr[] = $seg;
					}
				}
			}
			$AirlineCodeArr = [];
			if ($SegmentsArr) {
				foreach ($SegmentsArr as $key => $value) {
					$AirlineCodeArr[] = $value['AirlineCode'];
				}
			}
			$getAirlinesSupport = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAirlinesSupport(array_values(array_unique($AirlineCodeArr)));
			$this->view->getAirlinesSupport = $getAirlinesSupport;
			//echo '<pre>';print_r($MasterAgencyData);die;




			//echo '<pre>';print_r($FlightBookingData);
			//die;
		} else {
			die('bad request');
		}
		// echo '<pre>';
		// print_r($arrUrlData);
		// die;
	}
	public function eTicketAction()
	{
		// ini_set('display_errors', 1);
		// ini_set('display_startup_errors', 1);
		// error_reporting(E_ALL);
		$this->_helper->layout->disableLayout();
		$post = $this->getRequest()->getParams();
		$status = $post['status'];
		$checkaction = isset($post['checkaction']) ? $post['checkaction'] : '';

		//echo '<pre>';print_r($FlightBookingDataFinal);die;FlightBookingData
		$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
		$objFlight = new Travel_Model_FlightMaster();
		$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
		$withprice = $this->view->withprice = isset($post['withprice']) ? $post['withprice'] : 0;
		$bookingid = $this->view->bookingid = (isset($post['bookingid']) && !empty($post['bookingid'])) ? $post['bookingid'] : 0;
		$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
		$FlightBookingDataFinal = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $strUrlData, null, $bookingid);
		$arrUrlData = json_decode($FlightTempData['json_data'], true);
		$FlightBookingData = $arrUrlData['FlightBookingData'];
		if (isset($post['bookingid']) && !empty($post['bookingid'])) {
			$API_Response[0] = json_decode($FlightBookingDataFinal['data']['API_Response'], 1);
			$API_Response_Ticket[0] = json_decode($FlightBookingDataFinal['data']['API_Response_Ticket'], 1);
			$FlightBookingData = $API_Response;
		}
		// if($this->gtxagencysysid == '6230'){
		// 	echo '<pre>';print_r($FlightBookingDataFinal);die;
		// }
		$ICSourceSysId = isset($FlightBookingDataFinal['data']['ICSourceSysId']) ? $FlightBookingDataFinal['data']['ICSourceSysId'] : 0;
		// echo '<pre>';print_r($FlightBookingDataFinal);die;
		if (!empty($arrUrlData)) {
			$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
			if ($sessionFlightSearchParams['route'] == 4) {
				$this->IsTJFlightAPI = 1;
			}
			$this->view->created_at = $FlightTempData['created_at'];
			$this->view->ICSourceSysId = $ICSourceSysId;
			$this->view->gtxagencysysid = $this->gtxagencysysid;
			$this->view->FlightBookingData = $FlightBookingData;
			$this->view->passengerData = $FlightBookingDataFinal['passenger'];
			$this->view->BookingData = $FlightBookingDataFinal['data'];
			$this->view->SearchTraceId = $arrUrlData['SearchTraceId'];
			$this->view->FlightBookingTicketArr = $FlightBookingTicketArr = $arrUrlData['FlightBookingTicketArr'];
			if (isset($post['bookingid']) && !empty($post['bookingid'])) {
				$this->view->FlightBookingTicketArr = $FlightBookingTicketArr = $API_Response_Ticket;
				if ($ICSourceSysId == 7 || $ICSourceSysId == 8) {
					$this->view->FlightBookingTicketArr = $FlightBookingTicketArr = $API_Response_Ticket[0];
				}
			}
			$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->baseUrl = $this->baseUrl;
			$this->view->IsTJFlightAPI = $this->IsTJFlightAPI;
			$this->view->MasterAgencySysId = $this->MasterAgencySysId;
			$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;
			$apiData = array(
				"CustomerSysId" => $this->_session->data['CustomerSysId'],
				"UserSysId" => $this->_session->data['UserSysId'],
				"AgencySysId" => $this->_session->data['AgencySysId']
			);
			$getAgencyUserData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyUserData($apiData);
			$MasterAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->MasterAgencySysId);
			$AgentAddress = $getAgencyUserData['AddressByAgency'];
			$this->view->AgentAddress = $AgentAddress;
			$getAgencyData = $getAgencyUserData['profile'];
			$this->view->getAgencyData = $getAgencyData;

			//echo '<pre>';print_r($AgentAddress);die; passengerData
			$this->view->B2BType = $this->_session->B2BType;
			$logo = $this->gtxBtoBsite . 'public/upload/media/agency/' . trim(@$MasterAgencyData['AgencySysId']) . '/' . trim(@$MasterAgencyData['logo']);
			$this->view->MasterAgencyLogo = $logo;
			$SegmentsArr = [];
			if ($FlightBookingData) {
				foreach ($FlightBookingData as $Data) {
					foreach ($Data['Segments'] as $seg) {
						$SegmentsArr[] = $seg;
					}
				}
			}
			$AirlineCodeArr = [];
			if ($SegmentsArr) {
				foreach ($SegmentsArr as $key => $value) {
					$AirlineCodeArr[] = $value['AirlineCode'];
				}
			}

			$getAirlinesSupport = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAirlinesSupport(array_values(array_unique($AirlineCodeArr)));
			$this->view->getAirlinesSupport = $getAirlinesSupport;

			//
			if ($this->getRequest()->isPost() && $this->getRequest()->isXmlHttpRequest() && $checkaction == 'ExtraMarkup') {
				$ExtraMarkup = isset($post['ExtraMarkup']) ? $post['ExtraMarkup'] : 0;
				if ($ExtraMarkup >= 0) {
					$Reverse = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->calculateReverse($ExtraMarkup, 18);
					$MarkupArrayServiceTax = $Reverse['TaxAmount'];
					$MarkupArr['intExtraMarkup'] = $ExtraMarkup;
					$MarkupArr['ExtraMarkup'] = $Reverse['NetPrice'];
					$MarkupArr['ExtraMarkupOnGST'] = $Reverse['TaxAmount'];
					$ExtraMarkup = $Reverse['NetPrice'];
					$FlightBookingArr = [];
					$strFlightRoute = count($FlightBookingData);
					if ($FlightBookingData) {
						$IntExtraMarkup = ($ExtraMarkup / $strFlightRoute);
						$IntExtraMarkupOnGST = ($MarkupArrayServiceTax / $strFlightRoute);
						foreach ($FlightBookingData as $key => $outb) {
							$FlightBookingArr[$key] = $outb;
							$FlightBookingArr[$key]['FairRules']['showintax'] = 0;
							$FlightBookingArr[$key]['FairRules']['ExtraMarkup'] = ($IntExtraMarkup);
							$FlightBookingArr[$key]['FairRules']['ExtraMarkupOnGST'] = ($IntExtraMarkupOnGST);
							$FareBreakdown = [];
							$FareBreakCount = count($outb['FairRules']['FareBreakdown']);
							if ($outb['FairRules']['FareBreakdown']) {
								foreach ($outb['FairRules']['FareBreakdown'] as $k => $FareBreak) {
									$FareBreakdown[$k] = $FareBreak;
									$FareBreakdown[$k]['showintax'] = 0;
									$FareBreakdown[$k]['ExtraMarkup'] = ($IntExtraMarkup / $FareBreakCount);
									$FareBreakdown[$k]['ExtraMarkupOnGST'] = ($IntExtraMarkupOnGST / $FareBreakCount);
								}
							}
							$FlightBookingArr[$key]['FairRules']['FareBreakdown'] = $FareBreakdown;
						}
						try {
							$update['ExtraMarkup'] = $IntExtraMarkup;
							$update['ExtraMarkupOnGST'] = $IntExtraMarkupOnGST;
							$where = "apiTraceId = '" . $strUrlData . "'"; //exit;
							$objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
						} catch (Zend_Exception $e) {
							print_r($e->getMessage());
							exit;
						}
					}
					$arrUrlData['FlightBookingData'] = $FlightBookingArr;
					$tempData = array(
						'TraceId' => $strUrlData,
						'json_data' => json_encode($arrUrlData),
					);
					$objFlight->deleteFlightTempData($strUrlData);
					$objFlight->insertFlightTempData($tempData);
					$response = array('success' => true);
					echo json_encode($response);
					exit;
				} else {
					$response = array('success' => false);
					echo json_encode($response);
					exit;
				}
			}
			if ($this->getRequest()->isPost() && $this->getRequest()->isXmlHttpRequest()) {
				$post = $this->getRequest()->getParams();
				$EticketEmail = isset($post['EticketEmail']) ? $post['EticketEmail'] : '';
				$html = new Zend_View();
				$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
				$html->assign(array('FlightBookingData' => $FlightBookingData, 'created_at' => $FlightTempData['created_at'], 'withprice' => $withprice, 'Email' => true, 'ForCustomerSession' => $ForCustomerSession, 'selectedSeatSession' => $selectedSeatSession, 'SelectedMealSessionNew' => $SelectedMealSessionNew, 'SelectedBaggSessionNew' => $SelectedBaggSessionNew, 'FlightBookingTicketArr' => $FlightBookingTicketArr, 'B2BType' => $this->_session->B2BType, 'MasterAgencyLogo' => $logo, 'sessionFlightSearchParams' => $sessionFlightSearchParams, 'getAgencyData' => $getAgencyData, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, ' siteName' => $this->siteName, 'baseUrl' => $this->baseUrl, 'IsTJFlightAPI' => $this->IsTJFlightAPI, 'passengerData' => $FlightBookingDataFinal['passenger'], 'BookingData' => $FlightBookingDataFinal['data'], 'AgentAddress' => $AgentAddress));

				$bodyText = $html->render('e-ticket.phtml');
				$subject = 'Your Ticket Has Been Booked';
				$Caption = 'Your Ticket Has Been Booked';

				$configs = [
					'to' => trim($EticketEmail),
					'fromName' => $this->siteName,
					'fromEmail' => $getAgencyData['EmailId'],
					'subject' => $subject,
					'bodyHtml' => $bodyText,
				];
				$returnmail = $this->objHelperGeneral->mailSentByElastice($configs, $Caption);
				$returnmail = json_decode($returnmail, true);
				if ($returnmail['success']) {
					$response = array('success' => true);
					echo json_encode($response);
					exit;
				}
			}


			//echo '<pre>';print_r($FlightBookingData);
			//die;
		} else {
			die('bad request');
		}
		// echo '<pre>';
		// print_r($arrUrlData);
		// die;
	}

	public function invoiceAction()
	{
		$this->_helper->layout->disableLayout();
		$post = $this->getRequest()->getParams();
		$status = $post['status'];
		$this->view->baseUrl = $this->baseUrl;
		$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'];
		$this->view->IsTJFlightAPI = $this->IsTJFlightAPI;
		//echo "<pre>";print_r($arrUrlData['sessionFlightSearchParams']);die;
		if (!empty($arrUrlData)) {
			$this->view->sessionFlightSearchParams = $sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
			$this->view->created_at = $FlightTempData['created_at'];
			$this->view->FlightBookingData = $FlightBookingData;
			$this->view->SearchTraceId = $arrUrlData['SearchTraceId'];
			$this->view->FlightBookingTicketArr = $arrUrlData['FlightBookingTicketArr'];

			$apiData = array(
				"CustomerSysId" => $this->_session->data['CustomerSysId'],
				"UserSysId" => $this->_session->data['UserSysId'],
				"AgencySysId" => $this->_session->data['AgencySysId']
			);
			$getAgencyUserData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyUserData($apiData);
			$MasterAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->MasterAgencySysId);
			$getAgencyData = $getAgencyUserData['profile'];
			$AgentAddress = $getAgencyUserData['AddressByAgency'];
			$this->view->AgentAddress = $AgentAddress;
			$this->view->getAgencyData = $getAgencyData;
			$this->view->MasterAgencyData = $MasterAgencyData;
			$logo = $this->gtxBtoBsite . 'public/upload/media/agency/' . trim(@$MasterAgencyData['AgencySysId']) . '/' . trim(@$MasterAgencyData['logo']);
			$this->view->MasterAgencyLogo = $logo;
			$this->view->B2BType = $this->_session->B2BType;
			$this->view->MasterAgencySysId = $this->MasterAgencySysId;

			$FlightBookingInb = [];
			$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $strUrlData, 1);
			$FlightBookingInb = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $strUrlData, 2);
			$this->view->FlightBooking = $FlightBooking;
			$this->view->FlightBookingInb = $FlightBookingInb;

			if ($this->getRequest()->isPost() && $this->getRequest()->isXmlHttpRequest()) {
				$post = $this->getRequest()->getParams();
				$InvoiceEmail = isset($post['InvoiceEmail']) ? $post['InvoiceEmail'] : '';

				$html = new Zend_View();
				$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
				$html->assign(array('FlightBookingData' => $FlightBookingData, 'FlightBooking' => $FlightBooking, 'FlightBookingInb' => $FlightBookingInb, 'Email' => true, 'B2BType' => $this->_session->B2BType, 'MasterAgencyLogo' => $logo, 'sessionFlightSearchParams' => $sessionFlightSearchParams, 'getAgencyData' => $getAgencyData, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, ' siteName' => $this->siteName, 'baseUrl' => $this->baseUrl));

				$bodyText = $html->render('invoice.phtml');
				$subject = 'Invoice';
				$Caption = 'Invoice';

				$configs = [
					'to' => trim($InvoiceEmail),
					'fromName' => $this->siteName,
					'fromEmail' => $getAgencyData['EmailId'],
					'subject' => $subject,
					'bodyHtml' => $bodyText,
				];
				$returnmail = $this->objHelperGeneral->mailSentByElastice($configs, $Caption);
				$returnmail = json_decode($returnmail, true);
				if ($returnmail['success']) {
					$response = array('success' => true);
					echo json_encode($response);
					exit;
				}
			}

			// echo "<pre>";print_r($MasterAgencyData);
			// die;
		} else {
			die('bad request');
		}
		// echo '<pre>';
		// print_r($arrUrlData);
		// die;
	}
	public function getticketdataAction()
	{
		$this->_helper->layout->disableLayout();
		$post = $this->getRequest()->getParams();
		$objFlight = new Travel_Model_FlightMaster();
		$FlightBookingData = $objFlight->FlightBookingDataAll('tbl_flight_booking', $post['data']);
		if ($FlightBookingData) {
			$TotalExtraMarkup = 0;
			foreach ($FlightBookingData as $val) {
				$ExtraMarkup = $val['ExtraMarkup'];
				$ExtraMarkupOnGST = $val['ExtraMarkupOnGST'];
				$TotalExtraMarkup += ($ExtraMarkup + $ExtraMarkupOnGST);
			}
			$response = array('success' => true, 'TotalExtraMarkup' => round($TotalExtraMarkup));
			echo json_encode($response);
			exit;
		}
		//echo '<pre>';print_r($FlightBookingData);die;
	}
	public function customerInvoiceAction()
	{
		$this->_helper->layout->disableLayout();
		$post = $this->getRequest()->getParams();
		$status = $post['status'];
		$this->view->baseUrl = $this->baseUrl;
		$this->view->siteName = $this->siteName;
		$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'];
			if ($sessionFlightSearchParams['route'] == 4) {
				$this->IsTJFlightAPI = 1;
			}
			$this->view->created_at = $FlightTempData['created_at'];
			$this->view->FlightBookingData = $FlightBookingData;
			$this->view->IsTJFlightAPI = $this->IsTJFlightAPI;
			$this->view->SearchTraceId = $arrUrlData['SearchTraceId'];
			$this->view->FlightBookingTicketArr = $arrUrlData['FlightBookingTicketArr'];

			$apiData = array(
				"CustomerSysId" => $this->_session->data['CustomerSysId'],
				"UserSysId" => $this->_session->data['UserSysId'],
				"AgencySysId" => $this->_session->data['AgencySysId']
			);
			$getAgencyUserData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyUserData($apiData);
			$getAgencyData = $getAgencyUserData['profile'];
			$AgentAddress = $getAgencyUserData['AddressByAgency'];
			$this->view->AgentAddress = $AgentAddress;
			$this->view->getAgencyData = $getAgencyData;
			$this->view->MasterAgencySysId = $this->MasterAgencySysId;

			$FlightBookingInb = [];
			$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $strUrlData, 1);
			$FlightBookingInb = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $strUrlData, 2);
			$this->view->FlightBooking = $FlightBooking;
			$this->view->FlightBookingInb = $FlightBookingInb;

			if ($this->getRequest()->isPost() && $this->getRequest()->isXmlHttpRequest()) {
				$post = $this->getRequest()->getParams();
				$SaveAction = isset($post['SaveAction']) ? $post['SaveAction'] : '';
				if ($SaveAction == 'save') {
					$ids = isset($post['ids']) ? $post['ids'] : '';
					$email = isset($post['email']) ? $post['email'] : '';
					$CustInvoiceEmail = isset($post['CustInvoiceEmail']) ? $post['CustInvoiceEmail'] : '';
					$InvoiceNo = isset($post['InvoiceNo']) ? $post['InvoiceNo'] : '';
					$address = isset($post['address']) ? $post['address'] : '';
					$cname = isset($post['cname']) ? $post['cname'] : '';
					$InvoiceDate = isset($post['InvoiceDate']) ? explode('/', $post['InvoiceDate']) : '';
					$InvoiceDates = $InvoiceDate[2] . '-' . $InvoiceDate[1] . '-' . $InvoiceDate[0];
					$update = array(
						"InvoiceNo" => $InvoiceNo,
						"address" => $address,
						"InvoiceDate" => $InvoiceDates,
						"InvoiceName" => $cname,
					);
					$this->objMdl->rv_update('tbl_flight_booking', $update, ['id=?' => $ids]);
					if ($email == 'email') {
						$apiData = array(
							"CustomerSysId" => $this->_session->data['CustomerSysId'],
							"UserSysId" => $this->_session->data['UserSysId'],
							"AgencySysId" => $this->_session->data['AgencySysId']
						);
						$getAgencyUserData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyUserData($apiData);
						$MasterAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->MasterAgencySysId);
						$FlightBookingInb = [];
						$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $strUrlData, 1);
						$FlightBookingInb = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $strUrlData, 2);
						$getAgencyData = $getAgencyUserData['profile'];
						$this->view->getAgencyData = $getAgencyData;
						$this->view->B2BType = $this->_session->B2BType;
						$logo = $this->gtxBtoBsite . 'public/upload/media/agency/' . trim(@$MasterAgencyData['AgencySysId']) . '/' . trim(@$MasterAgencyData['logo']);
						$this->view->MasterAgencyLogo = $logo;
						$html = new Zend_View();
						$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
						$html->assign(array('FlightBookingData' => $FlightBookingData, 'FlightBooking' => $FlightBooking, 'FlightBookingInb' => $FlightBookingInb, 'Email' => true, 'B2BType' => $this->_session->B2BType, 'MasterAgencyLogo' => $logo, 'sessionFlightSearchParams' => $sessionFlightSearchParams, 'getAgencyData' => $getAgencyData, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, ' siteName' => $this->siteName, 'baseUrl' => $this->baseUrl));

						$bodyText = $html->render('customer-invoice.phtml');
						$subject = 'Invoice';
						$Caption = 'Invoice';

						$configs = [
							'to' => trim($CustInvoiceEmail),
							'fromName' => $this->siteName,
							'fromEmail' => $getAgencyData['EmailId'],
							'subject' => $subject,
							'bodyHtml' => $bodyText,
						];
						$returnmail = $this->objHelperGeneral->mailSentByElastice($configs, $Caption);
					}
					$response = array('success' => true);
					echo json_encode($response);
					exit;
					// echo "<pre>";
					// print_r($post);
					// die;
				} else {
					$response = array('success' => true, 'FlightBooking' => $FlightBooking, 'FlightBookingInb' => $FlightBookingInb);
					echo json_encode($response);
					exit;
				}
			}
		} else {
			die('bad request');
		}
		// echo '<pre>';
		// print_r($FlightBooking);
		// die;
	}
	public function amendmentItineraryAction()
	{
		$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'];
		$bookingId_TJ = $this->view->bookingId_TJ = $FlightBookingData[0]['bookingId_TJ'];
		$bookingId = $this->view->bookingId = $FlightBookingData[0]['bookingId'];

		$FlightBooking = $objFlight->FlightCancelDataTripJack('tbl_flight_booking', $bookingId_TJ, null, $strUrlData);
		// $API_Response[0] = json_decode($FlightBooking['data']['API_Response'], 1);
		// $FlightBookingData = $API_Response;

		if (isset($post['bookingid']) && !empty($post['bookingid'])) {
			$API_Response[0] = json_decode($FlightBooking['data']['API_Response'], 1);
			$FlightBookingData = $API_Response;
		}
		// echo '<pre>';
		// print_r($FlightBooking);
		// die;
		if (!empty($arrUrlData)) {
			$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
			$this->view->created_at = $FlightTempData['created_at'];
			$this->view->FlightBookingData = $FlightBookingData;
			$this->view->passengerData = $FlightBooking['passenger'];
			$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->IsTJFlightAPI = $this->IsTJFlightAPI;
			$this->view->baseUrl = $this->baseUrl;
			$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;
			$apiData = array(
				"CustomerSysId" => $this->_session->data['CustomerSysId'],
				"UserSysId" => $this->_session->data['UserSysId'],
				"AgencySysId" => $this->_session->data['AgencySysId']
			);
			$getAgencyUserData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyUserData($apiData);
			$getAgencyData = $getAgencyUserData['profile'];
			$this->view->getAgencyData = $getAgencyData;
			// print_r($FlightTempData);
			// die;
		} else {
			die('bad request');
		}
		if ($this->getRequest()->isPost() && $this->getRequest()->isXmlHttpRequest()) {
			$post = $this->getRequest()->getParams();
			$sectorsSelectors = $post['sectorsSelectors'];
			$PaxDetails = isset($post['PaxDetails']) ? $post['PaxDetails'] : array();
			$requestType = $post['requestType'];
			$cRemarks = $post['cRemarks'];
			$bookingId = $post['bookingId'];
			$bookingId_TJ = $post['bookingId_TJ'];
			$TPPaxSysId = $post['TPPaxSysId'];
			$PaxType = $post['PaxType'];
			$IsSeriesFareData = $post['IsSeriesFareData'];
			if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
				$bookingId_TJ = $bookingId;
				$passenger = $FlightBooking['passenger'];
				$selectedpassangerTypecount = array_count_values($PaxType);
				$selectedtotalAdults = $selectedpassangerTypecount['ADULT'];

				$passpaxType = array_column($passenger, 'paxType');
				$passangerTypecount = array_count_values($passpaxType);
				$totalAdults = $passangerTypecount['1'];
				$ChangeRequestStatus = array_column($passenger, 'ChangeRequestStatus');
				$totalcancelled = (!empty($ChangeRequestStatus)) ?  array_sum($ChangeRequestStatus) : 0;
				$isCancelType = (!empty($PaxDetails) && (count($passenger) > (count($PaxDetails) + $totalcancelled))) ? 2 : 1;

				if ((count($PaxDetails) != count($passenger)) && $totalAdults == $selectedtotalAdults && !empty($PaxDetails)) {
					$response = array('success' => false, 'msg' => 'Can not select all adults.');
					echo json_encode($response);
					exit;
				}
			}
			$bookingId_TJ = $FlightBooking['data']['APIBookingId'];
			$Source = $post['TBOSource'];
			$TBOtraceId = $post['TBOtraceId'];

			$sectorsDates = array_unique($post['sectorsDates']);
			$requestTypeValue = $post['requestTypeValue'];
			$trips = [];

			if (array_unique($sectorsSelectors)) {
				foreach (array_unique($sectorsSelectors) as $key => $sec) {
					$sectorEX = explode('-', $sec);

					$dateEX = $sectorsDates[$key];
					$paxArray = [];
					$paxDetailArray = [];
					if ($PaxDetails) {
						foreach ($PaxDetails as $pax) {
							$PaxDetailsEX = explode('-', $pax);
							$paxArray[] = array(
								'fn'    =>  $PaxDetailsEX[0],
								'ln'    =>  $PaxDetailsEX[1]
							);
							$paxDetailArray[trim($PaxDetailsEX[0]) . '-' . trim($PaxDetailsEX[1])] = 1;
						}
					}
					$trips[$key] = array(
						'src' => $sectorEX[0],
						'dest' => $sectorEX[1],
						'departureDate' => $dateEX,
						//'travellers' => $paxArray,
						//'nextTravelDate' => '2021-02-02',
					);
					if (!empty($paxArray)) {
						$trips[$key]['travellers'] = $paxArray;
					}
				}
			}
			$tripsPost = $trips;
			if ($this->IsTJFlightAPI == 1) {
				$data = array(
					"bookingId" => $bookingId_TJ,
					"type" => $requestTypeValue,
					"remarks" => $cRemarks,
					"isCancelType" => $isCancelType,
				);
				if (!empty($trips)) {
					$data['trips'] = $trips;
				}
				if (!empty($paxDetailArray)) {
					$data['paxDetailArray'] = $paxDetailArray;
				}
				$AmendmentRequestData = new Zend_Session_Namespace('AmendmentRequestData');
				$AmendmentRequestData->params = $data;

				if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
					//echo "<pre>";print_r($FlightBooking);die;
					$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetAmendmentChargesSeriesFare($data, $FlightBooking);
				} else {
					$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetAmendmentCharges($data);
				}
				// echo '<pre>';
				// print_r($ChangeResponse);
				// print_r($bookingId_TJ);
				// die;

				$intChangeRequestStatus = $ChangeResponse['status']['success'];
				$trips = isset($ChangeResponse['trips']) ? $ChangeResponse['trips'] : '';
			} else {
				if ($sectorsSelectors) {
					foreach ($sectorsSelectors as $sec) {
						$sectorEX = explode('-', $sec);
						$sector[] = array('Origin' => $sectorEX[0], 'Destination' => $sectorEX[1]);
					}
				}
				$data = array(
					"BookingId" => $bookingId,
					"source" => $Source,
					"remarks" => $cRemarks,
					"intIsLCC" => $TBOtraceId,
					"CancellationType" => 2,
					"sectorsSelectors" => $sector,
					"TicketId" => $PaxDetails,
					"requestType" => $requestType,
					"FlightTraceId" => $strUrlData,
				);
				$AmendmentRequestData = new Zend_Session_Namespace('AmendmentRequestData');
				$AmendmentRequestData->params = $data;
				$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CancellationChargesRequest($data, $this->gtxagencysysid);
				$intChangeRequestStatus = $ChangeResponse['Response']['ResponseStatus'];
				$requestType = $requestTypeValue;
				// echo '<pre>';
				// print_r($ChangeResponse);
				// print_r($data);
				// die;
			}
			if ($intChangeRequestStatus == 1) {
				$update = array(
					"ChangeRequestRes" => json_encode($ChangeResponse),
					"ChangeRequestStatus" => $intChangeRequestStatus,
					//"status" => $requestType,
				);
				$this->objMdl->rv_update('tbl_flight_booking', $update, ['APIBookingId=?' => $bookingId_TJ]);
			}
			if ($FlightBookingData[0]['IsInternational'] == 1) {
				$intCountryCode = 'INT';
			} else {
				$intCountryCode = 'IN';
			}
			if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
				$intMarkUp = 0;
			} else {
				$intMarkUp = $this->getCancelCharge($intCountryCode);
			}
			$html = new Zend_View();
			$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
			$html->assign(array('FlightBooking' => $FlightBooking, 'post' => $post, 'tripsPost' => $tripsPost, 'FlightBookingInb' => [], 'intMarkUp' => $intMarkUp, 'ChangeResponse' => $ChangeResponse, 'baseUrl' => $this->baseUrl, 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
			$bodyText = $html->render('getcancelcharge.phtml');
			$response = array('success' => true, 'msg' => 'Done', 'html' => $bodyText);
			echo json_encode($response);
			exit;
		}
		// echo '<pre>';
		// print_r($arrUrlData);
		// die;
	}
	public function submitAmendmentAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$param = $this->getRequest()->getParams();

			$AmendmentRequestData = new Zend_Session_Namespace('AmendmentRequestData');
			$data = $AmendmentRequestData->params;
			$bookingId_TJ = $param['bookingId_TJ'];
			$bookingId = $param['bookingId'];
			$IsSeriesFareData = $param['IsSeriesFareData'];
			$requestType = $param['requestType'];
			$requestTypeValue = $param['requestTypeValue'];
			$PaxDetails = $param['PaxDetails'];
			$TPPaxSysId = $param['TPPaxSysId'];
			$strUrlData = $param['strUrlData'];
			$cRemarks = $param['cRemarks'];
			$sectorsSelectors = array_unique($param['sectorsSelectors']);
			$sectorsDates = ($param['sectorsDates']);
			$nameData = implode('<br>', $param['nameData']);
			$sectors = implode('<br>', $param['sectorsSelectors']);
			$objFlight = new Travel_Model_FlightMaster();
			$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['strUrlData'], 1);
			$FlightQueryids = json_decode($FlightBooking['data']['FlightQueryids'], true);
			$MasterTPSysId = $FlightQueryids['arrIds']['MasterTPSysId'];
			$TPSysId = $FlightQueryids['arrIds']['TPSysId'];
			$VersionId = $FlightQueryids['arrIds']['VersionId'];
			$apiData = array(
				"CustomerSysId" => $this->_session->data['CustomerSysId'],
				"UserSysId" => $this->_session->data['UserSysId'],
				"AgencySysId" => $this->_session->data['AgencySysId']
			);
			if ($FlightBooking['data']['IsInternational'] == 1) {
				$intCountryCode = 'INT';
			} else {
				$intCountryCode = 'IN';
			}
			$intMarkUp = $this->getCancelCharge($intCountryCode);
			$intMarkUp = !empty($intMarkUp) ? $intMarkUp : '0';

			$intIsLCC = $FlightBooking['data']['IsLCC'];
			$getAgencyUserData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyUserData($apiData);
			$MasterAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->_session->data['MasterAgencySysId']);
			$getAgencyData = $getAgencyUserData['profile'];
			// echo '<pre>';
			// print_r($MasterAgencyData['PrimaryEmail']);
			// echo '<pre>';
			// print_r($getAgencyData['EmailId']);
			// die;
			if ($this->IsTJFlightAPI == 0) {
				$BOOKINGSTATUS = unserialize(BOOKINGSTATUS);
				$cancellationResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->cancelFlightBooking($data, $this->gtxagencysysid);
				// $str = file_get_contents($this->baseUrl . 'public/logs/flight/2021-08-03-15-29-31_SendChange_response.json');
				// $cancellationResponse = json_decode($str, true);

				$intChangeRequestStatus = isset($cancellationResponse['Response']['ResponseStatus']) ? $cancellationResponse['Response']['ResponseStatus'] : '';
				$ChangeRequestId = isset($cancellationResponse['Response']['TicketCRInfo'][0]['ChangeRequestId']) ? $cancellationResponse['Response']['TicketCRInfo'][0]['ChangeRequestId'] : '';
				$intErrorCode = isset($cancellationResponse['Response']['Error']['ErrorCode']) ? $cancellationResponse['Response']['Error']['ErrorCode'] : 0;
				$strErrorMessage = isset($cancellationResponse['Response']['Error']['ErrorMessage']) ? $cancellationResponse['Response']['Error']['ErrorMessage'] : '';
				if ($intChangeRequestStatus == 1) {
					$dataModification = array(
						"ChangeRequestId" => $ChangeRequestId,
						"ChangeRequestStatus" => 1,
						"AgencySysId" => $this->gtxagencysysid,
						"MasterTPSysId" => $this->MasterAgencySysId,
						"BookingId" => $bookingId,
						"RequestType" => $BOOKINGSTATUS[$requestTypeValue],
						"Remarks" => $cRemarks,
						"apiTraceId" => $strUrlData,
						"nameData" => $nameData,
						"sectors" => $sectors,
						"RequestData" => json_encode($data),
						"APIResponseData" => json_encode($cancellationResponse),
						"created_at" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
						"updated_at" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
					);
					$ModificationId  = $objFlight->InsertFlightData('tb_flight_modification', $dataModification);
					$update = array(
						"ChangeRequestId" => $ChangeRequestId,
						"ChangeRequestRes" => json_encode($cancellationResponse),
						"ChangeRequestStatus" => $intChangeRequestStatus,
						"status" => ($requestTypeValue)
					);
					$where = "BookingId = " . $bookingId; //exit;
					$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
					$strMsg = ($intIsLCC == 1) ? "Your booking has been cancelled." : "Booking PNR has been released successfully.";
					$redirect = true;
				} else if ($intChangeRequestStatus == 2) {
					$data = array(
						"status" => ($requestTypeValue)
					);
					$where = "BookingId = " . $bookingId; //exit;
					$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $data, $where);
					$strMsg = ($intIsLCC == 1) ? "Your booking cancellation is Inprocess" : $strErrorMessage;
					$redirect = false;
				} else {
					$strMsg = "Oops! Your booking Can'nt be cancelled right now please try again latter, Please contact administrator for more details";
					$redirect = false;
				}
				$FlightBooking = $objFlight->FlightCancelDataTripJack('tbl_flight_booking', $bookingId, null);


				if ($intChangeRequestStatus == 1 && $intErrorCode == 0) {
					if (!empty($FlightBooking['data'])) {
						$html = new Zend_View();
						$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
						$html->assign(array('FlightBooking' => $FlightBooking, 'param' => $param, 'bookingId' => $param['bookingId'], 'getAgencyData' => $getAgencyData, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, 'baseUrl' => $this->baseUrl));

						$bodyText = $html->render('cancelmailer.phtml');
						$subject = 'Modification request received - ' . $param['bookingId'];
						$Caption = 'Modification request received - ' . $param['bookingId'];
						// to customer
						$configs = [
							'to' => trim($FlightBooking['passenger'][0]['EmailId']),
							'fromName' => $this->siteName,
							'fromEmail' => $getAgencyData['EmailId'],
							'subject' => $subject,
							'bodyHtml' => $bodyText,
						];
						$this->objHelperGeneral->mailSentByElastice($configs, $Caption);
						// To agent
						$configsAg = [
							'to' => trim($getAgencyData['EmailId']),
							'fromName' => $this->siteName,
							'fromEmail' => $getAgencyData['EmailId'],
							'subject' => $subject,
							'bodyHtml' => $bodyText,
						];
						$this->objHelperGeneral->mailSentByElastice($configsAg, $Caption);
						// To Agency , Main comany
						$configsAgc = [
							'to' => trim($MasterAgencyData['PrimaryEmail']),
							'fromName' => $this->siteName,
							'fromEmail' => $getAgencyData['EmailId'],
							'subject' => $subject,
							'bodyHtml' => $bodyText,
						];
						$this->objHelperGeneral->mailSentByElastice($configsAgc, $Caption);
					}

					try {

						$postFieldArray = array(
							'PaxDetails' => json_encode($PaxDetails),
							'MasterTPSysId' => $MasterTPSysId,
							'TPSysId' => $TPSysId,
							'StatusType' => 10,
							'ChangeRequestId' => $ChangeRequestId,
							'ChangeRequestStatus' => 1,
							'ChangeRequestRes' => json_encode($cancellationResponse)
						);

						$model = new Gtxwebservices_Model_Webservices();
						$result = $model->updateFlightCancellation($postFieldArray);
					} catch (Exception $error) {
					}
					$response = array('success' => true, 'msg' => $strMsg, 'apiResponse' => $cancellationResponse, 'redirect' => $redirect);
					echo json_encode($response);
					exit;
				} else {
					$response = array('success' => true, 'msg' => $strErrorMessage, 'apiResponse' => $cancellationResponse, 'redirect' => $redirect);
					echo json_encode($response);
					exit;
				}
			}
			if ($requestTypeValue == 'CANCELLATION') {
				if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
					$bookingId_TJ = $bookingId;
					$this->GetSubmitAmendmentSeriesFare($param);
				} else {
					$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetSubmitAmendment($data);
				}

				// $SubmitAmendment = new Zend_Session_Namespace('SubmitAmendment');
				// $ChangeResponse = $SubmitAmendment->params;



				$intChangeRequestStatus = $ChangeResponse['status']['success'];
				$strErrorMessage = $ChangeResponse['errors'][0]['message'];
				if ($intChangeRequestStatus == 1) {
					try {
						$dataModification = array(
							"ChangeRequestId" => $ChangeResponse['amendmentId'],
							"ChangeRequestStatus" => 1,
							"AgencySysId" => $this->gtxagencysysid,
							"MasterTPSysId" => $this->MasterAgencySysId,
							"BookingId" => $bookingId_TJ,
							"RequestType" => $requestTypeValue,
							"Remarks" => $cRemarks,
							"servicefee" => $intMarkUp,
							"apiTraceId" => $strUrlData,
							"nameData" => '',
							"RefundMode" => '',
							"refundedamount" => 0,
							"sectors" => $sectorsSelectors,
							"amendmentcharges" => 0,
							"RequestData" => json_encode($data),
							"APIResponseData" => json_encode($ChangeResponse),
							"created_at" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
							"updated_at" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
						);
						$ModificationId  = $objFlight->InsertFlightData('tb_flight_modification', $dataModification);
						// $update = array(
						// 	"ChangeRequestId" => ($ChangeResponse['amendmentId']),
						// 	"status" => $requestType,
						// 	"ChangeRequestStatus" => $requestType,
						// );
						// $this->objMdl->rv_update('tbl_flight_booking', $update, ['apiTraceId=?' => $strUrlData]);
						if ($sectorsSelectors) {
							foreach ($sectorsSelectors as $sc) {
								$sec = explode('-', $sc);
								$whereArrayflight = array(
									'SourceAirportCode=?' => $sec[0],
									'DestAirportCode=?' => $sec[1],
									'apiTraceId=?' => $strUrlData
								);
								$update = array(
									"ChangeRequestId" => ($ChangeResponse['amendmentId']),
									"status" => $requestType,
									"ChangeRequestStatus" => $requestType,
								);
								$this->objMdl->rv_update('tbl_flight_booking', $update, $whereArrayflight);
							}
						}

						if ($PaxDetails) {
							foreach ($PaxDetails as $pax) {
								$PaxDetailsEX = explode('-', $pax);
								$whereArray = array(
									'FirstName=?'    =>  $PaxDetailsEX[0],
									'LastName=?'    =>  $PaxDetailsEX[1],
									'apiTraceId=?'    =>  $strUrlData
								);
								$updatePax = array(
									"ChangeRequestId" => $ChangeResponse['amendmentId'],
									"ChangeRequestStatus" => $requestType,
								);
								$this->objMdl->rv_update('tbl_flight_booking_customer', $updatePax, $whereArray);
							}
						}


						$postFieldArray = array(
							'PaxDetails' => json_encode($PaxDetails),
							'MasterTPSysId' => $MasterTPSysId,
							'TPSysId' => $TPSysId,
							'StatusType' => 120,
							'ChangeRequestId' => $ChangeResponse['amendmentId'],
							'ChangeRequestStatus' => 1,
							'ChangeRequestRes' => json_encode($ChangeResponse),
							'dataModification' => json_encode($dataModification),
							"AgentSysId" => $this->_session->data['UserSysId'],
							"AgencySysId" => $this->_session->data['MasterAgencySysId']
						);

						$model = new Gtxwebservices_Model_Webservices();
						$result = $model->updateFlightCancellation($postFieldArray);
					} catch (Exception $error) {
						print_r($error->getMessage());
						exit;
					}
					$FlightBooking = $objFlight->FlightCancelDataTripJack('tbl_flight_booking', $bookingId_TJ, $ChangeResponse['amendmentId']);
					if (!empty($FlightBooking['data'])) {
						$html = new Zend_View();
						$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
						$html->assign(array('FlightBooking' => $FlightBooking, 'param' => $param, 'bookingId' => $param['bookingId'], 'getAgencyData' => $getAgencyData, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, 'baseUrl' => $this->baseUrl));

						$bodyText = $html->render('cancelmailer.phtml');
						$subject = 'Cancellation request received - ' . $param['bookingId'];
						$Caption = 'Cancellation request received - ' . $param['bookingId'];
						$configs = [
							'to' => trim($FlightBooking['passenger'][0]['EmailId']),
							'fromName' => $this->siteName,
							'fromEmail' => $getAgencyData['EmailId'],
							'subject' => $subject,
							'bodyHtml' => $bodyText,
						];
						$returnmail = $this->objHelperGeneral->mailSentByElastice($configs, $Caption);

						// To agent
						$configsAg = [
							'to' => trim($getAgencyData['EmailId']),
							'fromName' => $this->siteName,
							'fromEmail' => $getAgencyData['EmailId'],
							'subject' => $subject,
							'bodyHtml' => $bodyText,
						];
						$this->objHelperGeneral->mailSentByElastice($configsAg, $Caption);
						// To Agency , Main comany
						$configsAgc = [
							'to' => trim($MasterAgencyData['PrimaryEmail']),
							'fromName' => $this->siteName,
							'fromEmail' => $getAgencyData['EmailId'],
							'subject' => $subject,
							'bodyHtml' => $bodyText,
						];
						$this->objHelperGeneral->mailSentByElastice($configsAgc, $Caption);
					}
					$strMsg = "success. Your booking cancellation is Inprocess";
					$redirect = true;
					$response = array('success' => true, 'msg' => $strMsg, 'redirect' => $redirect);
					echo json_encode($response);
					exit;
				} else {
					$strMsg = "Oops! Your booking Can'nt be cancel right now please try again latter, Please contact administrator for more details";
					$redirect = false;
					$response = array('success' => true, 'msg' => $strMsg, 'redirect' => $redirect);
					echo json_encode($response);
					exit;
				}
			} else {
				$trips = [];

				if (array_unique($sectorsSelectors)) {
					foreach (array_unique($sectorsSelectors) as $key => $sec) {
						$sectorEX = explode('-', $sec);

						$dateEX = $sectorsDates[$key];
						$paxArray = [];
						if ($PaxDetails) {
							foreach ($PaxDetails as $pax) {
								$PaxDetailsEX = explode('-', $pax);
								$paxArray[] = array(
									'fn'    =>  $PaxDetailsEX[0],
									'ln'    =>  $PaxDetailsEX[1]
								);
							}
						}
						$trips[] = array(
							'src' => $sectorEX[0],
							'dest' => $sectorEX[1],
							'departureDate' => $dateEX,
							'travellers' => $paxArray,
							//'nextTravelDate' => '2021-02-02',
						);
					}
				}

				$data = array(
					"bookingId" => $bookingId_TJ,
					"type" => $requestTypeValue,
					"remarks" => $cRemarks,
					"trips" => $trips,
				);

				$ChangeResponse = [];
				$dataModification = array(
					"ChangeRequestId" => 0,
					"ChangeRequestStatus" => 1,
					"AgencySysId" => $this->gtxagencysysid,
					"MasterTPSysId" => $this->MasterAgencySysId,
					"BookingId" => $bookingId_TJ,
					"RequestType" => $requestTypeValue,
					"servicefee" => $intMarkUp,
					"Remarks" => $cRemarks,
					"apiTraceId" => $strUrlData,
					"RequestData" => json_encode($data),
					"APIResponseData" => json_encode($ChangeResponse),
					"created_at" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
					"updated_at" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
				);
				$amendmentId  = $objFlight->InsertFlightData('tb_flight_modification', $dataModification);
				$updateTPMOD['ChangeRequestId'] = $amendmentId;
				$objFlight->updateModification($updateTPMOD, $amendmentId);

				$update = array(
					"ChangeRequestId" => ($amendmentId),
					"status" => $requestType,
					"ChangeRequestStatus" => $requestType,
				);
				$this->objMdl->rv_update('tbl_flight_booking', $update, ['apiTraceId=?' => $strUrlData]);

				if ($PaxDetails) {
					foreach ($PaxDetails as $pax) {
						$PaxDetailsEX = explode('-', $pax);
						$whereArray = array(
							'FirstName=?'    =>  $PaxDetailsEX[0],
							'LastName=?'    =>  $PaxDetailsEX[1],
							'apiTraceId=?'    =>  $strUrlData
						);
						$updatePax = array(
							"ChangeRequestId" => $amendmentId,
							"ChangeRequestStatus" => $requestType,
						);
						$this->objMdl->rv_update('tbl_flight_booking_customer', $updatePax, $whereArray);
					}
				}
				try {

					$postFieldArray = array(
						'PaxDetails' => json_encode($PaxDetails),
						'MasterTPSysId' => $MasterTPSysId,
						'TPSysId' => $TPSysId,
						'StatusType' => 120,
						'ChangeRequestId' => $amendmentId,
						'ChangeRequestStatus' => 1,
						'ChangeRequestRes' => json_encode($ChangeResponse),
						'dataModification' => json_encode($dataModification),
						"AgentSysId" => $this->_session->data['UserSysId'],
						"AgencySysId" => $this->_session->data['MasterAgencySysId']
					);

					$model = new Gtxwebservices_Model_Webservices();
					$result = $model->updateFlightCancellation($postFieldArray);
					// echo '<pre>';
					// print_r($result);
				} catch (Exception $error) {
				}
				$FlightBooking = $objFlight->FlightCancelDataTripJack('tbl_flight_booking', $bookingId_TJ, $amendmentId);
				if (!empty($FlightBooking['data'])) {
					$html = new Zend_View();
					$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
					$html->assign(array('FlightBooking' => $FlightBooking, 'param' => $param, 'bookingId' => $param['bookingId'], 'getAgencyData' => $getAgencyData, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, 'baseUrl' => $this->baseUrl));

					$bodyText = $html->render('cancelmailer.phtml');
					$subject = 'Modification request received - ' . $param['bookingId'];
					$Caption = 'Modification request received - ' . $param['bookingId'];
					$configs = [
						'to' => trim($FlightBooking['passenger'][0]['EmailId']),
						'fromName' => $this->siteName,
						'fromEmail' => $getAgencyData['EmailId'],
						'subject' => $subject,
						'bodyHtml' => $bodyText,
					];
					$returnmail = $this->objHelperGeneral->mailSentByElastice($configs, $Caption);
					// To agent
					$configsAg = [
						'to' => trim($getAgencyData['EmailId']),
						'fromName' => $this->siteName,
						'fromEmail' => $getAgencyData['EmailId'],
						'subject' => $subject,
						'bodyHtml' => $bodyText,
					];
					$this->objHelperGeneral->mailSentByElastice($configsAg, $Caption);
					// To Agency , Main comany
					$configsAgc = [
						'to' => trim($MasterAgencyData['PrimaryEmail']),
						'fromName' => $this->siteName,
						'fromEmail' => $getAgencyData['EmailId'],
						'subject' => $subject,
						'bodyHtml' => $bodyText,
					];
					$this->objHelperGeneral->mailSentByElastice($configsAgc, $Caption);
					// echo '<pre>';
					// print_r($returnmail);die;
				}
				$strMsg = "success. Your booking modification is Inprocess";
				$redirect = true;
				$response = array('success' => true, 'msg' => $strMsg, 'redirect' => $redirect);
				echo json_encode($response);
				exit;
			}
		}
	}
	public function amendmentDetailsAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$param = $this->getRequest()->getParams();
			$this->view->traceId = $param['amendmentId'];
			$refundSubmit = isset($param['refundSubmit']) ? $param['refundSubmit'] : 0;
			// echo '<pre>';
			// print_r($param);
			// die;
			$objMarkup = new Travel_Model_Markup();
			$intCountryCode = isset($param['countryCode']) ? $param['countryCode'] : '';
			if (!empty(trim($intCountryCode)) && trim($intCountryCode) == "INT") {
				$ItemSourceType = 2;
			} else {
				$ItemSourceType = 1;
			}
			$intMarkUp = $this->getCancelCharge($intCountryCode);
			$getAgencyMarkups = $objMarkup->getAgencyCancellation($ItemSourceType, $this->gtxagencysysid);
			try {
				if ($refundSubmit == 1) {
					$objFlight = new Travel_Model_FlightMaster();
					$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['data'], 1);
					$FlightQueryids = json_decode($FlightBooking['data']['FlightQueryids'], true);
					$MasterTPSysId = $FlightQueryids['arrIds']['MasterTPSysId'];
					$TPSysId = $FlightQueryids['arrIds']['TPSysId'];
					$VersionId = $FlightQueryids['arrIds']['VersionId'];

					$Status = isset($param['Status']) ? $param['Status'] : 0;
					$RefundMode = isset($param['RefundMode']) ? $param['RefundMode'] : '';
					$refundremarks = isset($param['refundremarks']) ? $param['refundremarks'] : '';
					$amendmentId = isset($param['amendmentId']) ? $param['amendmentId'] : '';
					$refundedamount = isset($param['refundedamount']) ? $param['refundedamount'] : '';
					$GeModificationData = $objFlight->GeModificationDataAmendmentId($amendmentId);

					$GetAmendmentDetails = new Zend_Session_Namespace('GetAmendmentDetails');
					$AmendmentDetails = $GetAmendmentDetails->params;
					if ($refundedamount >= 0) {
						$update['status'] = $Status;
						$where = "ChangeRequestId = " . $amendmentId; //exit;
						$objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
						$dataModification = array(
							"ChangeRequestId" => $amendmentId,
							"ChangeRequestStatus" => 1,
							"AgencySysId" => $this->gtxagencysysid,
							"MasterTPSysId" => $this->MasterAgencySysId,
							"BookingId" => $GeModificationData[0]['BookingId'],
							"RequestType" => $GeModificationData[0]['RequestType'],
							"apiTraceId" => $GeModificationData[0]['apiTraceId'],
							"Remarks" => $refundremarks,
							"RequestData" => json_encode($AmendmentDetails),
							"APIResponseData" => ($GeModificationData[0]['APIResponseData']),

							"RefundMode" => $RefundMode,
							"status" => $Status,
							"refundedamount" => $refundedamount,
							"servicefee" => ($GeModificationData[0]['servicefee']),

							"created_at" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
							"updated_at" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
						);
						$postFieldArray = array(
							'MasterTPSysId' => $MasterTPSysId,
							'TPSysId' => $TPSysId,
							'StatusType' => ($Status == 9) ? 19 : 121,
							'ChangeRequestId' => $amendmentId,
							'ChangeRequestStatus' => 1,
							'dataModification' => json_encode($dataModification),
							"AgentSysId" => $this->_session->data['UserSysId'],
							"AgencySysId" => $this->_session->data['MasterAgencySysId'],
							'B2BAgencySysIdKey' => $this->_session->data['SecurityKey'],
							'B2CAgencySysIdKey' => SECURITYKEY,
						);

						$model = new Gtxwebservices_Model_Webservices();
						$result = $model->updateFlightCancelRefund($postFieldArray);
						// echo '<pre>';
						// print_r($result);
						// print_r($dataModification);

						$amendmentId = $objFlight->InsertFlightData('tb_flight_modification', $dataModification);
						// echo '<pre>';
						// print_r($dataModification);
						// die;
						if ($amendmentId) {
							$response = array('success' => true, 'refundid' => $amendmentId, 'message' => 'Refund submit successfully');
							echo json_encode($response);
							exit;
						} else {
							$response = array('success' => false, 'message' => 'Unable to submit refund. please try again.');
							echo json_encode($response);
							exit;
						}
					} else {
						$response = array('success' => false, 'message' => 'Negative amount not allowed.');
						echo json_encode($response);
						exit;
					}
				}
			} catch (Exception $e) {
				print_r($e->getMessage());
				exit;
			}
			if ($this->IsTJFlightAPI == 1) {
				$data = array(
					"amendmentId" => $param['amendmentId'],
				);
				$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetAmendmentDetails($data);
			} else {
				$data = array(
					"amendmentId" => $param['amendmentId'],
				);
				$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetAmendmentDetailsTBO($data, $this->gtxagencysysid);
			}
			// echo '<pre>';
			// print_r($ChangeResponse);
			// die;
			Zend_Session::namespaceUnset('GetAmendmentDetails');
			$GetAmendmentDetails = new Zend_Session_Namespace('GetAmendmentDetails');
			$GetAmendmentDetails->params = $ChangeResponse;
			$this->view->ChangeResponse = $ChangeResponse;

			$this->view->amendmentId = $param['amendmentId'];
			$this->view->CancelMarkUp = ($intMarkUp + $getAgencyMarkups);
			$this->view->UserType = 'admin';
			$this->view->getAgencyMarkups = $getAgencyMarkups;
		} else {
			die();
		}
	}

	public function modificationdataAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$this->_helper->viewRenderer->setNoRender(true);
			$param = $this->getRequest()->getParams();
			$TraceId = base64_decode($this->getRequest()->getParam("TraceId"));
			$objFlight = new Travel_Model_FlightMaster();

			$GeModificationData = $objFlight->GeModificationData($TraceId);
			// echo '<pre>';
			// print_r($GeModificationData);
			// die;
			$BookingData = $objFlight->FlightBookingData('tbl_flight_booking', $TraceId);
			$IsInternational = $BookingData['onward']['IsInternational'];
			if ($IsInternational) {
				$intCountryCode = 'INT';
			} else {
				$intCountryCode = 'IN';
			}

			$intMarkUp = $this->getCancelCharge($intCountryCode);
			$this->view->amendmentId = $param['amendmentId'];
			$this->view->CancelMarkUp = $intMarkUp;
			$this->view->IsTJFlightAPI = $this->IsTJFlightAPI;
			$html = new Zend_View();
			$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
			$html->assign(array('GeModificationData' => $GeModificationData, 'IsTJFlightAPI' => $this->IsTJFlightAPI, 'amendmentId' => $param['amendmentId'], 'CancelMarkUp' => $intMarkUp, 'param' => $param, 'UserType' => 'admin', 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, 'baseUrl' => $this->baseUrl));
			$htmlPage = $html->render('modification-data.phtml');
			$response = array('success' => true, 'htmlPage' => $htmlPage);
			echo json_encode($response);
			exit;
		} else {
			die('bad request');
		}
	}

	public function updatepnrAction()
	{
		if ($this->getRequest()->isXmlHttpRequest()) {
			$this->_helper->layout->disableLayout();
			$this->_helper->viewRenderer->setNoRender(true);
			$param = $this->getRequest()->getParams();
			$TraceId = base64_decode($this->getRequest()->getParam("TraceId"));
			$objFlight = new Travel_Model_FlightMaster();

			$FlightTempData = $objFlight->GetFlightTempData($TraceId);
			$arrUrlData = json_decode($FlightTempData['json_data'], true);
			$FlightBookingData = $arrUrlData['FlightBookingData'];
			$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;
			$ForCustomerSession = $arrUrlData['ForCustomerSession'];
			$FlightBookingTicketArr = $arrUrlData['FlightBookingTicketArr'];
			$paymentMode = isset($arrUrlData['paymentMode']) ? $arrUrlData['paymentMode'] : 0;
			$this->view->SelectedBaggSessionNew = $SelectedBaggSessionNew = $arrUrlData['SelectedBaggSessionNew'];
			$this->view->SelectedMealSessionNew = $SelectedMealSessionNew = $arrUrlData['SelectedMealSessionNew'];
			$this->view->selectedSeatSession = $selectedSeatSession = $arrUrlData['selectedSeatSession'];
			$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
			//$arrUrlData['FlightBookingTicketArr'] = array('dddd');

			$BookingData = $objFlight->FlightBookingData('tbl_flight_booking', $TraceId);
			$FlightQueryids = json_decode($BookingData['onward']['FlightQueryids'], true);
			$MasterTPSysId = $FlightQueryids['arrIds']['MasterTPSysId'];
			$TPSysId = $FlightQueryids['arrIds']['TPSysId'];
			$VersionId = $FlightQueryids['arrIds']['VersionId'];
			$TrxId = $FlightQueryids['arrIds']['TrxId'];


			$apiData = array(
				"CustomerSysId" => $this->_session->data['CustomerSysId'],
				"UserSysId" => $this->_session->data['UserSysId'],
				"AgencySysId" => $this->_session->data['AgencySysId']
			);
			$created_at = isset($FlightTempData['created_at']) ? $FlightTempData['created_at'] : date('d-m-Y');
			$getAgencyUserData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyUserData($apiData);
			$MasterAgencyData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyData($this->MasterAgencySysId);
			$getAgencyData = $getAgencyUserData['profile'];
			$this->view->getAgencyData = $getAgencyData;
			$this->view->B2BType = $this->_session->B2BType;
			$logo = $this->gtxBtoBsite . 'public/upload/media/agency/' . trim(@$MasterAgencyData['AgencySysId']) . '/' . trim(@$MasterAgencyData['logo']);
			$this->view->MasterAgencyLogo = $logo;
			$getSupportContactData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getSupportContactData(1, 2, 1);


			$Bookres = array(
				'bookingId' => $param['APIBookingId'],
				'status' => array(
					'success' => true,
					'httpStatus' => 200
				),
			);
			$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingDetailsTripJack($Bookres);
			// echo '<pre>';
			// print_r($response);
			// die;
			try {
				$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'] : '';
				$OrderBookingStatus = isset($response['order']['status']) ? $response['order']['status'] : '';
				$bookingId = str_replace('TJ', BOOKINGREF, $strBookingIdLCC);
				$FlightBookingTicketArr = [];
				$CostToAgent = 0;
				$baggageAmount = 0;
				$mealAmount = 0;
				$SeatAmount = 0;
				if ($FlightBookingData) {
					foreach ($FlightBookingData as $k => $value) {
						$CostToAgent += $value['FairRules']['CostToAgent'];
						$segggg = $value['SourceAirportCode'] . '-' . $value['DestAirportCode'];
						$segment = [];
						$finalpnr = [];
						if ($value['Segments']) {
							foreach ($value['Segments'] as $seg) {
								$originAirportCode = $seg['originAirportCode'];
								$destinationAirportCode = $seg['destinationAirportCode'];
								$segment[] = $originAirportCode . '-' . $destinationAirportCode;
								$AirportCode = $originAirportCode . '-' . $destinationAirportCode;
								$finalpnr[] = isset($strTicketPNRLCC[$AirportCode]) ? $strTicketPNRLCC[$AirportCode] : '';
							}
						}
						$finalpnr = $this->checkArrayKeyExist($finalpnr);
						// echo '<pre>';
						// print_r($PNRNew);
						// echo '<pre>';
						// print_r($strTicketPNRLCC);
						$FlightBookingTicketArr[] = $response;
						if ($ResponseStatus == 1) {
							$PNRNew = !empty($finalpnr) ? implode(',', $finalpnr) : '';
							$update = array(
								'API_Response_Ticket' => json_encode($response),
								'PNR_Number' => $PNRNew,
								'APIBookingId' => $strBookingIdLCC,
								'fareIdentifierSP' => 1,
							);

							$where = "id = " . $flight_booking_id[$k]; //exit;
							$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);

							$responseArray = array(
								'value' => $value,
								'response' => $response
							);

							$postFieldArray = array(
								'MasterTPSysId' => $MasterTPSysId,
								'TPSysId' => $TPSysId,
								'TrxId' => $TrxId,
								'VersionId' => $VersionId[$k],
								'XRefBookingId' => $bookingId,
								'APIBookingRes' => json_encode($responseArray),
								'Passenger' => json_encode($Passenger),
								'ErrorCode' => 0,
								'IsBookingStatus' => 1,
								'updatePnr' => 1
							);

							$model = new Gtxwebservices_Model_Webservices();
							$result = $model->updateFlightBookingB2B($postFieldArray);

							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' => !empty($TicketNumber) ? $TicketNumber : 0,
										'sectors' => implode('-', $segment),
										'BookingId' => $bookingId,
										'APIBookingId' => $strBookingIdLCC,
									);

									$wherep = "id = " . $booking_customer_id[0][$pk];
									$ddd = $objFlight->UpdateFlightData('tbl_flight_booking_customer', $updatep, $wherep);
								}
							}
						}
					}

					if ($ResponseStatus == 1 && $OrderBookingStatus != 'ABORTED') {
						$arrUrlData['FlightBookingTicketArr'] = $response;
						$tempData = array(
							'TraceId' => $TraceId,
							'json_data' => json_encode($arrUrlData),
						);

						$objFlight->deleteFlightTempData($TraceId);
						$ifff = $objFlight->insertFlightTempData($tempData);


						$html = new Zend_View();
						$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
						$html->assign(array('FlightBookingData' => $FlightBookingData, 'Email' => true, 'ForCustomerSession' => $ForCustomerSession, 'selectedSeatSession' => $selectedSeatSession, 'SelectedMealSessionNew' => $SelectedMealSessionNew, 'SelectedBaggSessionNew' => $SelectedBaggSessionNew, 'FlightBookingTicketArr' => $response, 'B2BType' => $this->_session->B2BType, 'MasterAgencyLogo' => $logo, 'sessionFlightSearchParams' => $sessionFlightSearchParams, 'getAgencyData' => $getAgencyData, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, ' siteName' => $this->siteName, 'baseUrl' => $this->baseUrl, 'IsTJFlightAPI' => $this->IsTJFlightAPI, 'created_at' => $created_at, 'getSupportContactData' => $getSupportContactData, 'siteName' => $this->siteName));
						$bodyText = $html->render('e-ticket.phtml');
						$subject = 'Your Ticket Has Been Booked';
						$Caption = 'Your Ticket Has Been Booked';
						$configs = [
							'to' => trim($ForCustomerSession[0]['EmailId']),
							'fromName' => $this->siteName,
							'fromEmail' => $getAgencyData['EmailId'],
							'subject' => $subject,
							'bodyHtml' => $bodyText,
						];
						$returnmail = $this->objHelperGeneral->mailSentByElastice($configs, $Caption);

						$Return = array('success' => true, 'message' => 'Update PNR successfully done', 'SearchTraceId' => $TraceId);
						echo json_encode($Return);
						exit;
					} else {
						//if ($paymentMode == 0) {
						$CreditIntoWallet = $this->CreditIntoWallet($arrUrlData);
						$TransactionId = isset($CreditIntoWallet['TransactionId']) ? $CreditIntoWallet['TransactionId'] : '';
						if ($FlightBookingData) {
							foreach ($FlightBookingData as $k => $value) {
								if ($OrderBookingStatus == 'ABORTED') {
									$update['status'] = 21;
								}
								$update['TransactionId_debit'] = $TransactionId;
								$where = "id = " . $flight_booking_id[$k]; //exit;
								$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
							}
						}
						if ($OrderBookingStatus == 'ABORTED') {
							$postFieldArray = array(
								'MasterTPSysId' => $MasterTPSysId,
								'TPSysId' => $TPSysId,
								'TrxId' => $TrxId,
								'XRefBookingId' => $bookingId,
								'ErrorCode' => 0,
								'IsBookingStatus' => 124,
								'updatePnr' => 1
							);
							$model = new Gtxwebservices_Model_Webservices();
							$result = $model->updateFlightAbortedgB2B($postFieldArray);
						}
						//}
						$WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyWallaetBalance($this->SecurityKey);
						$sessionWallaetBalance = new Zend_Session_Namespace('sessionWallaetBalance');
						$sessionWallaetBalance->params = $WallaetBalance;
						//die('ss');
						$arrUrlData['FlightBookingTicketArr'] = $response;
						$arrUrlData['CreditIntoWallet'] = $CreditIntoWallet;
						$tempData = array(
							'TraceId' => $TraceId,
							'json_data' => json_encode($arrUrlData),
						);

						$objFlight->deleteFlightTempData($TraceId);
						$objFlight->insertFlightTempData($tempData);
						$Return = array('success' => false, 'message' => 'failed to update. Current booking status is: - ' . $OrderBookingStatus);
						echo json_encode($Return);
						exit;
					}
				}
			} catch (Zend_Exception $e) {
				print_r($e->getMessage());
				exit;
			}
		} else {
			die('bad request');
		}
	}

	public function getCountryCodeList()
	{
		$url = $this->baseUrl . "public/data/static/country.json";
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
		$str = curl_exec($ch);
		$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();
			//$param = json_decode(file_get_contents('php://input'), true);
			$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
			$ARR_SALUTION = unserialize(ARR_SALUTION_TJ);
			$ARR_SALUTION_CHILD = unserialize(ARR_SALUTION_CHILD);
			$param['AgencySysId'] = $this->gtxagencysysid;
			//echo '<pre>';print_r($param);die;
			$objFlight = new Travel_Model_FlightMaster();
			$tbl_customer = $objFlight->SearchFlightCustomer('tbl_customer', $param);
			//echo '<pre>';print_r($tbl_customer);die;
			$customerMemberArr = [];
			if ($tbl_customer) {
				foreach ($tbl_customer as $value) {
					$DOB = explode('-', $value['DOB']);
					$customerMember = $objFlight->GetFlightCustomerMember('tbl_customer_member', array('CustomerSysId' => $value['CustomerSysId'], 'AgencySysId' => $this->gtxagencysysid));
					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'],
								'countryName' => $member['countryName'],
								'countryCode' => $member['countryCode'],
								'PassportNo' => $member['PassportNo'],
								'paxType' => $member['paxType'],
								'PassportNation' => $member['PassportNation'],
								'paxTypeName' => $paxtype,
								'gender' => $gender,
								'PassportExpiry' => $PassportExpirym,
								'passporIssue' => $passporIssuem,
								'dobday' => (isset($DOBm[2]) && !empty($DOBm[2])) ? $DOBm[2] : '__',
								'dobmonth' => (isset($DOBm[1]) && !empty($DOBm[1])) ? $DOBm[1] : '__',
								'dobyear' => (isset($DOBm[0]) && !empty($DOBm[0])) ? $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'],
						'countryName' => $value['countryName'],
						'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' => (isset($DOB[2]) && !empty($DOB[2])) ? $DOB[2] : '__',
						'dobmonth' => (isset($DOB[1]) && !empty($DOB[1])) ? $DOB[1] : '__',
						'dobyear' => (isset($DOB[0]) && !empty($DOB[0])) ? $DOB[0] : '____',
						//'customerMember' => $customerMemberArr
					);
				}
				$responseArray = [];
				$responseArray_ng = [];
				$array_merge = array_merge($response, $customerMemberArr);
				if ($array_merge) {
					foreach ($array_merge as $key => $val) {
						if ($key == 0) {
							$responseArray['_' . $val['CustomerSysId']] = $val;
							$responseArray_ng[$key] = $val;
						} else {
							$responseArray['_' . $val['CustomerMemberSysId']] = $val;
							$responseArray_ng[$key] = $val;
						}
					}
				}
				// echo '<pre>';print_r($responseArray);
				// die;
				//ksort($responseArray);
				if (!empty($responseArray)) {
					$array = array();
					$array = array('success' => true, 'leadPax' => $leadPax, 'msg' => 'success', 'data' => $responseArray, 'responseArray_ng' => $responseArray_ng, 'totalpax' => count($responseArray));
					echo json_encode($array);
					exit;
				} else {
					echo json_encode(array('success' => false, 'msg' => 'no record found', 'data' => $responseArray, 'responseArray_ng' => $responseArray_ng, 'totalpax' => count($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 selectedformailAction()
	{
		$this->_helper->layout->disableLayout();
		$post = json_decode(file_get_contents('php://input'), true);
		$PriceID = $post['PriceID'];
		$Outbound = ($post['item']);
		$Inbound = (isset($post['Inbound']) && $post['Inbound'] != '') ? $post['Inbound'] : array();
		$PriceArr = ($post['PriceArr']);
		$SingleSelect = $PriceArr['PriceID'];
		$PriceIdArr = ($post['PriceIdArr']);
		$JourneyType = ($post['JourneyType']);
		$FinalArray = [];
		$IsInternational = ($post['IsInternational']);
		$strFlightRoute = ($post['strFlightRoute']);
		if ($strFlightRoute == 3 && $IsInternational == '') {
			foreach ($Outbound as $PrId => $valuse) {
				foreach ($valuse as $key => $value) {
					foreach ($value['FairRules'] as $fare) {
						if (in_array($fare['PriceID'], $PriceIdArr)) {
							$FinalArray[$fare['PriceID']] = $value;
							$FinalArray[$fare['PriceID']]['FairRules'] = [$fare];
						}
					}
				}
			}
			$response = array('success' => true, 'Outbound' => json_encode($FinalArray));
			echo json_encode($response);
			exit;
		}
		//echo '<pre>';print_r($post);echo '</pre>';
		$array_merge = array_merge($Outbound, $Inbound);
		//echo '<pre>';print_r($PriceIdArr);echo '</pre>';
		//echo '<pre>';print_r($array_merge);echo '</pre>';die;

		$Outbound['apiTraceId'] = $SingleSelect;
		$Outbound['ApiResultIndex'] = $SingleSelect;
		foreach ($array_merge as $PrId => $valuse) {
			foreach ($valuse['FairRules'] as $fare) {
				if (in_array($fare['ApiResultIndex'], $PriceIdArr)) {
					$FinalArray[$fare['ApiResultIndex']] = $valuse;
					$FinalArray[$fare['ApiResultIndex']]['FairRules'] = [$fare];
				}
			}
		}
		// echo '<pre>';print_r($FinalArray);echo '</pre>';
		// die;
		$response = array('success' => true, 'Outbound' => json_encode($FinalArray));
		echo json_encode($response);
		exit;
	}
	public function shareonwhatsappAction()
	{
		$this->_helper->layout->disableLayout();
		$post = json_decode(file_get_contents('php://input'), true);
		$Outbound = ($post['item']);
		$addMarkup = ($post['addMarkup']);
		$mobilenumber = ($post['mobilenumber']);
		$countrycode = ($post['countrycode']);
		$sessionFlightSearchParams = json_decode($post['sessionFlightSearchParams'], true);
		$emailId = $customeremail = ($post['emailId']);
		$ccemail = (isset($post['ccemail']) && !empty($post['ccemail'])) ? $post['ccemail'] : '';
		$customername = ($post['customername']);
		$shareOnly = isset($post['shareOnly']) ? $post['shareOnly'] : false;


		$apiData = array(
			"CustomerSysId" => $this->_session->data['CustomerSysId'],
			"UserSysId" => $this->_session->data['UserSysId'],
			"AgencySysId" => $this->_session->data['AgencySysId']
		);
		$getAgencyUserData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyUserData($apiData);
		$getAgencyDetail = $getAgencyUserData['profile'];
		$agencySysID = $this->gtxagencysysid;
		if ($sessionFlightSearchParams['route'] == 4) {
			$from_city = (isset($sessionFlightSearchParams['from_city'][0])) ? explode('-', $sessionFlightSearchParams['from_city'][0]) : '';
			$Origincity = $from_city[0];
			$DestinationCity = $from_city[1];
		} else {
			$Origincity = $sessionFlightSearchParams['from'][0];
			$DestinationCity = $sessionFlightSearchParams['to'][0];
		}
		$route = $sessionFlightSearchParams['route'];
		$interNationalSearch = $sessionFlightSearchParams['interNationalSearch'];

		$fromName = (isset($getAgencyDetail['DisplayName']) && !empty($getAgencyDetail['DisplayName'])) ? trim($getAgencyDetail['DisplayName']) : trim(trim($getAgencyDetail['Title']));
		$emailId = trim($emailId);
		$mailCustmail = array(trim($emailId));
		$emailSendId = $sendersEmailId = (isset($sendersEmailId) && $sendersEmailId != '') ? $sendersEmailId : trim($getAgencyDetail['EmailId']);

		$mailToCC = explode(',', $ccemail);
		$getflightData = [];
		$getMarkupArr = [];
		$index = 0;

		$MultiHead = [];
		if ($Outbound) {
			foreach ($Outbound as $key => $values) {
				$val = json_decode($values, true);

				$markup = $addMarkup[$index];
				$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->calculateServiceTax($markup, 18);
				$MarkupArrayServiceTax = !empty($arrServiceTaxOnNetPayable['serviceTaxAmount']) ? $arrServiceTaxOnNetPayable['serviceTaxAmount'] : 0;
				$val['ExtraMarkup'] = $markup;
				$val['ExtraMarkupOnGST'] = $MarkupArrayServiceTax;

				if ($route == 3 && $interNationalSearch == 1) { ////// for multicity international
					$MultiHead[] = $val['MultiHead'];
					$FlightData = isset($val['FlightData']) ? $val['FlightData'] : '';
					if ($FlightData) {
						foreach ($FlightData as $fk => $flight) {
							$flight['ExtraMarkup'] = $markup;
							$flight['ExtraMarkupOnGST'] = $MarkupArrayServiceTax;
							$flight['FairRules'] = $val['FairRules'];
							$flight['MultiHead'] = $val['MultiHead'];
							$getflightData[$key][$fk] = $flight;
						}
					}
				} else {
					$getflightData[] = $val;
				}
				$index++;
			}
		}
		$post['item'] = $getflightData;
		$FlightData = [];
		$index = 0;
		try {
			if ($getflightData) {
				foreach ($getflightData as $keys => $val) {
					if ($route == 3 && $interNationalSearch == 1) { ////// for multicity international
						foreach ($val as $fk => $vals) {
							$FlightData[$keys][$fk] = $vals;
							$index++;
						}
					} else {
						$FlightData[$val['JourneyType']][] = $val;
						$index++;
					}
				}
			}
		} catch (Zend_Exception $e) {
			print_r($e->getMessage());
			exit;
		}
		$route = $sessionFlightSearchParams['route'];
		$interNationalSearch = $sessionFlightSearchParams['interNationalSearch'];
		$tripType = ($route == 4) ? 1 : $route;
		$adultDetails = ($sessionFlightSearchParams['adults']) ? $sessionFlightSearchParams['adults'] : '';
		$childDetails = ($sessionFlightSearchParams['child'] > 0) ? ', ' . $sessionFlightSearchParams['child'] . ' Child(s)' : '';
		$InfantDetails = ($sessionFlightSearchParams['infant'] > 0) ? ', ' . $sessionFlightSearchParams['infant'] . ' Infant(s)' : '';
		$departure_dates_string = $sessionFlightSearchParams['departure_dates'][0];
		$return_dates_string = $sessionFlightSearchParams['return_dates'][0];

		$explode_date = explode("/", $departure_dates_string);
		$departure_dates = $explode_date[2] . '-' . $explode_date[1] . '-' . $explode_date[0];
		$explode_dateR = explode("/", $return_dates_string);
		$return_dates = $explode_dateR[2] . '-' . $explode_dateR[1] . '-' . $explode_dateR[0];

		$NoofPax = '*No. of Pax:* ' . $adultDetails . ' Adult(s)' . $childDetails . $InfantDetails;
		$TravelDate = ($departure_dates) ? '\n *Travel Date:* ' . $departure_dates : '';
		$whatsappmessageFlight = '';
		$navarrow = ($tripType == 1) ? "→" : "⇄";
		$navarrowM = "→";
		//$navarrow = ($tripType == 1) ? "→" : "→";
		//$demoArray = [];
		if ($route == 3 && $interNationalSearch == 1) {
			$MultiHeadArr = isset($MultiHead[0]) ? $MultiHead[0] : '';
			$OrigDestCodearr = [];
			if ($MultiHeadArr) {
				foreach ($MultiHeadArr as $value) {
					$OrigDestCodearr[] = $value['soCode'] . '→' . $value['deCode'];
				}
			}
			$OrigDestCode = implode(' | ', $OrigDestCodearr);

			$NoofPax = '*No. of Pax:* ' . $adultDetails . ' Adult(s)' . $childDetails . $InfantDetails;
			$TravelDate = ($departure_dates) ? '\n *Travel Date:* ' . $departure_dates : '';
			foreach ($FlightData as $Key => $flightDatas) {
				$finalHtml = '';
				$Option = '*Option ' . ($Key + 1) . '*';
				$HrLine = "__________________\n";
				foreach ($flightDatas as $dKey => $Data) {
					$duration = $Data['FlightDuration'];
					$ExtraMarkup__ = $Data['ExtraMarkup'];
					$ExtraMarkupOnGST__ = $Data['ExtraMarkupOnGST'];

					if ($dKey == 0) {
						$totalCost = "*Total Cost: *" . trim($Data['FairRules'][0]['Currency']) . " " . number_format(round($Data['FairRules'][0]['PublishedFareAgent'] + $ExtraMarkup__ + $ExtraMarkupOnGST__), 2) . "\n";
					} else {
						$totalCost = '';
					}

					$routeDetail = '' . $Data['DepartureDateTxt'] . ' - ' . $Data['DepartureTime'] . ' - ' . $Data['ArrivalDateTxt'] . ' - ' . $Data['ArrivalTime'] . "\n*Duration:* " . $duration;
					//$finalHtml .= $totalCost . '\n*' . trim($Data['SourceAirportCode']) . ' - ' . trim($Data['DestAirportCode']) . ' - ' . trim($Data['AirlineName']) . ' (' . trim($Data['SegFlightNumberArr']) . ')* ' . $routeDetail;
					$SourceAirportCode = trim($Data['SourceAirportCode']);
					$DestAirportCode = trim($Data['DestAirportCode']);
					$AirlineName = trim($Data['AirlineName']);
					$SegFlightNumberArr = trim($Data['SegFlightNumberArr']);
					$finalHtml .= "\n$totalCost\n*$SourceAirportCode - $DestAirportCode - $AirlineName ($SegFlightNumberArr)* \n" . $routeDetail;

					//$whatsappmessageFlight .= "%0a%0a*------* *$AirlineName* *$SegFlightNumberArr*  *$SourceAirportCode* *$navarrowM* *$DestAirportCode* *------*%0a ";
					//echo '</pre>'; print_r($Data);
				}
				$whatsappmessageFlight .= $Option . '' . $finalHtml . "\n" . $HrLine;
			}
			$firstname = trim($getAgencyDetail['FirstName']) ? trim($getAgencyDetail['FirstName']) . ' ' . trim($getAgencyDetail['LastName']) : 'Agent';
			$primarycontact = trim($getAgencyDetail['Contacts']) ? trim($getAgencyDetail['Contacts']) : 'N/A';
			$agencyDisplayName = trim($getAgencyDetail['Title']) ? trim($getAgencyDetail['Title']) : 'N/A';
			$whatsappmessage = "Thanks for your Flight query for *$OrigDestCode* \n.$whatsappmessageFlight" . "Kindly check and reply.";
		} else {

			foreach ($FlightData as $getflightKey => $flightDatas) {
				$finalHtml = '';
				$kk = 0;
				if ($getflightKey == 1) {
					$TravelDate = ($departure_dates_string) ? '*Travel Date:* ' . $departure_dates_string . '' : '';
				} else {
					$TravelDate = ($return_dates_string) ? '*Travel Date:* ' . $return_dates_string . '' : '';
				}

				foreach ($flightDatas as $dKey => $fVal) {
					if (count($flightDatas) > 1) {
						$finalHtml .= '*' . ($dKey + 1) . '.* ';
					} else {
						$finalHtml .= '';
					}
					//echo '</pre>'; print_r($fVal);
					$ExtraMarkup__ = $fVal['ExtraMarkup'];
					$ExtraMarkupOnGST__ = $fVal['ExtraMarkupOnGST'];
					$duration = '*Duration:* ' . $fVal['FlightDuration'];
					$routeDetail = '' . trim($fVal['SourceAirportCode']) . ' (' . $fVal['DepartureTime'] . ') - ' . trim($fVal['DestAirportCode']) . '(' . $fVal['ArrivalTime'] . ')';
					//$finalHtml .= '*' .  . ' (' . trim($fVal['FlightNumber']) . ') :* ' . $routeDetail . ' ' . $duration . ' \n *Total Cost:*  ' . trim($fVal['FairRules'][0]['Currency']) . ' ' . round($fVal['FairRules'][0]['PublishedFareAgent'] + $ExtraMarkup__ + $ExtraMarkupOnGST__) . '/-\n';
					$AirlineName = trim($fVal['AirlineName']);
					$FlightNumber = trim($fVal['FlightNumber']);
					$AirlineName = trim($fVal['AirlineName']);
					$finalHtml .= "*$AirlineName ($FlightNumber) :*\n$routeDetail \n$duration\n*Total Cost:* " . trim($fVal['FairRules'][0]['Currency']) . " " . round($fVal['FairRules'][0]['PublishedFareAgent'] + $ExtraMarkup__ + $ExtraMarkupOnGST__) . "/-\n\n";
					$kk++;
				}

				$SourcePlaceName = $flightDatas[0]['SourcePlaceName'];
				$DestPlaceName = $flightDatas[0]['DestPlaceName'];
				$OrigincityTitle = $SourcePlaceName . ' (' . trim($flightDatas[0]['SourceAirportCode']) . ')';
				$DestinationCityTitle = $DestPlaceName . ' (' . trim($flightDatas[0]['DestAirportCode']) . ')';
				if ($route == 4) {
					$SourcePlaceName = $flightDatas[0]['Segments'][0]['originCityName'];
					$DestPlaceName = $flightDatas[0]['Segments'][0]['destinationCityName'];
				}

				$whatsappmessageFlight .= "\n*------* *$SourcePlaceName* *$navarrow* *$DestPlaceName* *------*\n\n$NoofPax\n$TravelDate\n\n$finalHtml";
			}
			$firstname = trim($getAgencyDetail['FirstName']) ? trim($getAgencyDetail['FirstName']) . ' ' . trim($getAgencyDetail['LastName']) : 'Agent';
			$primarycontact = trim($getAgencyDetail['Contacts']) ? trim($getAgencyDetail['Contacts']) : 'N/A';
			$agencyDisplayName = trim($getAgencyDetail['Title']) ? trim($getAgencyDetail['Title']) : 'N/A';
			$roundToOrigin = ($tripType == 2) ? 'to ' . $Origincity : '';
			$whatsappmessage = "Thanks for your Flight query for $Origincity to $DestinationCity $roundToOrigin.$whatsappmessageFlight" . "Kindly check and reply.";
		}

		$whatsappmessage = $whatsappmessage;
		$response = array('success' => true, 'message' => 'Proposal sent successfully', 'whatsapp' => $whatsappmessage);
		echo json_encode($response);
		exit;
	}
	public function shareonmailAction()
	{
		$this->_helper->layout->disableLayout();
		$post = json_decode(file_get_contents('php://input'), true);
		$Outbound = ($post['item']);
		$addMarkup = ($post['addMarkup']);
		$mobilenumber = ($post['mobilenumber']);
		$countrycode = ($post['countrycode']);
		$sessionFlightSearchParams = json_decode($post['sessionFlightSearchParams'], true);
		$emailId = $customeremail = ($post['emailId']);
		$ccemail = (isset($post['ccemail']) && !empty($post['ccemail'])) ? $post['ccemail'] : '';
		$customername = ($post['customername']);
		$shareOnly = isset($post['shareOnly']) ? $post['shareOnly'] : false;

		if (empty(trim($emailId)) && !$shareOnly) {
			$response = array('success' => false, 'message' => 'Please enter customer mail id.', 'whatsapp' => '', 'contactno' => '');
			echo json_encode($response);
			exit;
		}
		if (!filter_var($emailId, FILTER_VALIDATE_EMAIL) && !$shareOnly) {
			$msg = "Email address is not valid.";
			$response = array('success' => false, 'message' => $msg, 'index' => 'leadEmail');
			echo json_encode($response);
			exit;
		}
		if (empty(trim($customername))) {
			$response = array('success' => false, 'message' => 'Please enter customer name.', 'whatsapp' => '', 'contactno' => '');
			echo json_encode($response);
			exit;
		}
		if (empty(trim($mobilenumber))) {
			$response = array('success' => false, 'message' => 'Please enter customer mobile no.', 'whatsapp' => '', 'contactno' => '');
			echo json_encode($response);
			exit;
		}
		if (strlen($mobilenumber) != 10 && strlen($mobilenumber) != 11) {
			$response = array('succes' => false, 'message' => 'Please enter a valid mobile number.');
			echo json_encode($response);
			exit;
		}
		$apiData = array(
			"CustomerSysId" => $this->_session->data['CustomerSysId'],
			"UserSysId" => $this->_session->data['UserSysId'],
			"AgencySysId" => $this->_session->data['AgencySysId']
		);
		$getAgencyUserData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getAgencyUserData($apiData);
		$getAgencyDetail = $getAgencyUserData['profile'];
		$agencySysID = $this->gtxagencysysid;
		if ($sessionFlightSearchParams['route'] == 4) {
			$from_city = (isset($sessionFlightSearchParams['from_city'][0])) ? explode('-', $sessionFlightSearchParams['from_city'][0]) : '';
			$Origincity = $from_city[0];
			$DestinationCity = $from_city[1];
		} else {
			//$Origincity = $sessionFlightSearchParams['from'][0];
			//$DestinationCity = $sessionFlightSearchParams['to'][0];

			$Origincity = $sessionFlightSearchParams['from_city'][0];
			$DestinationCity = $sessionFlightSearchParams['to_city'][0];
		}
		$route = $sessionFlightSearchParams['route'];
		$interNationalSearch = $sessionFlightSearchParams['interNationalSearch'];

		$fromName = (isset($getAgencyDetail['DisplayName']) && !empty($getAgencyDetail['DisplayName'])) ? trim($getAgencyDetail['DisplayName']) : trim(trim($getAgencyDetail['Title']));
		$emailId = trim($emailId);
		$mailCustmail = array(trim($emailId));
		$emailSendId = $sendersEmailId = (isset($sendersEmailId) && $sendersEmailId != '') ? $sendersEmailId : trim($getAgencyDetail['EmailId']);

		$mailToCC = explode(',', $ccemail);
		$getflightData = [];
		$getMarkupArr = [];
		$index = 0;

		$MultiHead = [];
		if ($Outbound) {
			foreach ($Outbound as $key => $values) {
				$val = json_decode($values, true);

				$markup = $addMarkup[$index];
				$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->calculateServiceTax($markup, 18);
				$MarkupArrayServiceTax = !empty($arrServiceTaxOnNetPayable['serviceTaxAmount']) ? $arrServiceTaxOnNetPayable['serviceTaxAmount'] : 0;
				$val['ExtraMarkup'] = $markup;
				$val['ExtraMarkupOnGST'] = $MarkupArrayServiceTax;

				if ($route == 3 && $interNationalSearch == 1) { ////// for multicity international
					$MultiHead[] = $val['MultiHead'];
					$FlightData = isset($val['FlightData']) ? $val['FlightData'] : '';
					if ($FlightData) {
						foreach ($FlightData as $fk => $flight) {
							$flight['ExtraMarkup'] = $markup;
							$flight['ExtraMarkupOnGST'] = $MarkupArrayServiceTax;
							$flight['FairRules'] = $val['FairRules'];
							$flight['MultiHead'] = $val['MultiHead'];
							$getflightData[$key][$fk] = $flight;
						}
					}
				} else {
					$getflightData[] = $val;
				}
				$index++;
			}
		}
		$post['item'] = $getflightData;
		$FlightData = [];
		$index = 0;
		try {
			if ($getflightData) {
				foreach ($getflightData as $keys => $val) {
					if ($route == 3 && $interNationalSearch == 1) { ////// for multicity international
						foreach ($val as $fk => $vals) {
							$FlightData[$keys][$fk] = $vals;
							$index++;
							$ExtraMarkup = $vals['ExtraMarkup'];
							$ExtraMarkupOnGST = $vals['ExtraMarkupOnGST'];
							$proposalData = array(
								'AgencySysId' => $this->_session->data['AgencySysId'],
								'MasterAgencySysId' => $this->_session->data['MasterAgencySysId'],
								'UserSysId' => $this->_session->data['UserSysId'],
								'FlightNumber' => ($vals['SegFlightNumberArr']),
								'AirlineName' => ($vals['AirlineName']),
								'TravelDate' => str_replace('T', ' ', $vals['TravelDate']),
								'SearchTraceId' => ($vals['SearchTraceId']),
								'NetFare' => ($vals['FairRules'][0]['OfferedFareAgent'] + $vals['FairRules'][0]['intGTXMarkUp'] + $vals['FairRules'][0]['GTXMarkUpGST']),
								'Commission' => ($vals['FairRules'][0]['AgentB2CEarning'] + $vals['FairRules'][0]['GSTOnAgentMarkUp']),
								'NetPrice' => ($vals['FairRules'][0]['PublishedFareAgent']),
								'FinalPrice' => ($vals['FairRules'][0]['PublishedFareAgent'] + $ExtraMarkup + $ExtraMarkupOnGST),
								'ExtraMarkup' => ($ExtraMarkup),
								'ExtraMarkupOnGST' => ($ExtraMarkupOnGST),
								'CustEmail' => ($post['emailId']),
								'CustName' => ($post['customername']),
								'CustMobile' => ($post['mobilenumber']),
								'flightData' => json_encode($vals),
							);
							$proposalData['updated_at'] = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
							$objFlight = new Travel_Model_FlightMaster();
							$objFlight->InsertFlightData('tb_shared_proposal', $proposalData);
						}
					} else {
						$FlightData[$val['JourneyType']][] = $val;
						$index++;
						$ExtraMarkup = $val['ExtraMarkup'];
						$ExtraMarkupOnGST = $val['ExtraMarkupOnGST'];
						$proposalData = array(
							'AgencySysId' => $this->_session->data['AgencySysId'],
							'MasterAgencySysId' => $this->_session->data['MasterAgencySysId'],
							'UserSysId' => $this->_session->data['UserSysId'],
							'FlightNumber' => ($val['FlightNumber']),
							'AirlineName' => ($val['AirlineName']),
							'TravelDate' => str_replace('T', ' ', $val['TravelDate']),
							'SearchTraceId' => ($val['SearchTraceId']),
							'NetFare' => ($val['FairRules'][0]['OfferedFareAgent'] + $val['FairRules'][0]['intGTXMarkUp'] + $val['FairRules'][0]['GTXMarkUpGST']),
							'Commission' => ($val['FairRules'][0]['AgentB2CEarning'] + $val['FairRules'][0]['GSTOnAgentMarkUp']),
							'NetPrice' => ($val['FairRules'][0]['PublishedFareAgent']),
							'FinalPrice' => ($val['FairRules'][0]['PublishedFareAgent'] + $ExtraMarkup + $ExtraMarkupOnGST),
							'ExtraMarkup' => ($ExtraMarkup),
							'ExtraMarkupOnGST' => ($ExtraMarkupOnGST),
							'CustEmail' => ($post['emailId']),
							'CustName' => ($post['customername']),
							'CustMobile' => ($post['mobilenumber']),
							'flightData' => json_encode($val),
						);
						$proposalData['updated_at'] = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
						$objFlight = new Travel_Model_FlightMaster();
						$objFlight->InsertFlightData('tb_shared_proposal', $proposalData);
					}
				}
			}
		} catch (Zend_Exception $e) {
			print_r($e->getMessage());
			exit;
		}

		$route = $sessionFlightSearchParams['route'];
		$interNationalSearch = $sessionFlightSearchParams['interNationalSearch'];
		$tripType = ($route == 4) ? 1 : $route;
		$adultDetails = ($sessionFlightSearchParams['adults']) ? $sessionFlightSearchParams['adults'] : '';
		$childDetails = ($sessionFlightSearchParams['child'] > 0) ? ', ' . $sessionFlightSearchParams['child'] . ' Child(s)' : '';
		$InfantDetails = ($sessionFlightSearchParams['infant'] > 0) ? ', ' . $sessionFlightSearchParams['infant'] . ' Infant(s)' : '';
		$departure_dates_string = $sessionFlightSearchParams['departure_dates'][0];
		$return_dates_string = $sessionFlightSearchParams['return_dates'][0];

		$explode_date = explode("/", $departure_dates_string);
		$departure_dates = $explode_date[2] . '-' . $explode_date[1] . '-' . $explode_date[0];
		$explode_dateR = explode("/", $return_dates_string);
		$return_dates = $explode_dateR[2] . '-' . $explode_dateR[1] . '-' . $explode_dateR[0];

		$NoofPax = '%0a*No. of Pax:* ' . $adultDetails . ' Adult(s)' . $childDetails . $InfantDetails;
		$TravelDate = ($departure_dates) ? '%0a%0a*Travel Date:* ' . $departure_dates : '';
		$whatsappmessageFlight = '';
		$navarrow = ($tripType == 1) ? "→" : "⇄";
		$navarrowM = "→";
		//$navarrow = ($tripType == 1) ? "→" : "→";
		//$demoArray = [];
		if ($route == 3 && $interNationalSearch == 1) {
			$MultiHeadArr = isset($MultiHead[0]) ? $MultiHead[0] : '';
			$OrigDestCodearr = [];
			if ($MultiHeadArr) {
				foreach ($MultiHeadArr as $value) {
					$OrigDestCodearr[] = $value['soCode'] . '→' . $value['deCode'];
				}
			}
			$OrigDestCode = implode(' | ', $OrigDestCodearr);

			$NoofPax = '%0a*No. of Pax:* ' . $adultDetails . ' Adult(s)' . $childDetails . $InfantDetails;
			$TravelDate = ($departure_dates) ? '%0a*Travel Date:* ' . $departure_dates : '';
			foreach ($FlightData as $Key => $flightDatas) {
				$finalHtml = '';
				$Option = '%0a%0a*Option ' . ($Key + 1) . '*%0a';
				$HrLine = '__________________%0a';
				foreach ($flightDatas as $dKey => $Data) {
					$duration = $Data['FlightDuration'];
					$ExtraMarkup__ = $Data['ExtraMarkup'];
					$ExtraMarkupOnGST__ = $Data['ExtraMarkupOnGST'];

					if ($dKey == 0) {
						$totalCost = 'Total Cost: *' . trim($Data['FairRules'][0]['Currency']) . ' ' . number_format(round($Data['FairRules'][0]['PublishedFareAgent'] + $ExtraMarkup__ + $ExtraMarkupOnGST__), 2) . '*%0a';
					} else {
						$totalCost = '';
					}

					$routeDetail = '%0a' . $Data['DepartureDateTxt'] . ' - ' . $Data['DepartureTime'] . '%0a' . $Data['ArrivalDateTxt'] . ' - ' . $Data['ArrivalTime'] . '%0a*Duration:* ' . $duration . '%0a';
					$finalHtml .= $totalCost . '%0a*' . trim($Data['SourceAirportCode']) . ' - ' . trim($Data['DestAirportCode']) . ' - ' . trim($Data['AirlineName']) . ' (' . trim($Data['SegFlightNumberArr']) . ')* ' . $routeDetail;
					//$whatsappmessageFlight .= "%0a%0a*------* *$AirlineName* *$SegFlightNumberArr*  *$SourceAirportCode* *$navarrowM* *$DestAirportCode* *------*%0a ";
					//echo '</pre>'; print_r($Data);
				}
				$whatsappmessageFlight .= $Option . '' . $finalHtml . '%0a' . $HrLine;
			}
			$firstname = trim($getAgencyDetail['FirstName']) ? trim($getAgencyDetail['FirstName']) . ' ' . trim($getAgencyDetail['LastName']) : 'Agent';
			$primarycontact = trim($getAgencyDetail['Contacts']) ? trim($getAgencyDetail['Contacts']) : 'N/A';
			$agencyDisplayName = trim($getAgencyDetail['Title']) ? trim($getAgencyDetail['Title']) : 'N/A';
			$whatsappmessage = "*Dear $customername*,%0a%0aThanks for your Flight query for *$OrigDestCode* %0a.$whatsappmessageFlight  %0a%0aYou can also call $firstname at $primarycontact or email at $emailSendId or whatsapp me here.%0a%0aRegards %0a%0a$firstname, %0a$agencyDisplayName";
		} else {
			foreach ($FlightData as $getflightKey => $flightDatas) {
				$finalHtml = '';
				$kk = 0;
				if ($getflightKey == 1) {
					$TravelDate = ($departure_dates_string) ? '%0a*Travel Date:* ' . $departure_dates_string . '%0a' : '';
				} else {
					$TravelDate = ($return_dates_string) ? '%0a*Travel Date:* ' . $return_dates_string . '%0a' : '';
				}

				foreach ($flightDatas as $dKey => $fVal) {
					if (count($flightDatas) > 1) {
						$finalHtml .= '%0a*' . ($dKey + 1) . '.* ';
					} else {
						$finalHtml .= '%0a';
					}
					//echo '</pre>'; print_r($fVal);
					$ExtraMarkup__ = $fVal['ExtraMarkup'];
					$ExtraMarkupOnGST__ = $fVal['ExtraMarkupOnGST'];
					$duration = $fVal['FlightDuration'];
					$routeDetail = '%0a' . trim($fVal['SourceAirportCode']) . ' - ' . trim($fVal['DestAirportCode']) . ' on ' . $fVal['DepartureTime'] . ' - ' . $fVal['ArrivalTime'];
					$finalHtml .= '*' . trim($fVal['AirlineName']) . ' (' . trim($fVal['FlightNumber']) . ') :*' . $routeDetail . ' ' . $duration . '%0a*Total Cost:*  ' . trim($fVal['FairRules'][0]['Currency']) . ' ' . round($fVal['FairRules'][0]['PublishedFareAgent'] + $ExtraMarkup__ + $ExtraMarkupOnGST__) . '/-%0a';
					$kk++;
				}

				$SourcePlaceName = $flightDatas[0]['SourcePlaceName'];
				$DestPlaceName = $flightDatas[0]['DestPlaceName'];
				$OrigincityTitle = $SourcePlaceName . ' (' . trim($flightDatas[0]['SourceAirportCode']) . ')';
				$DestinationCityTitle = $DestPlaceName . ' (' . trim($flightDatas[0]['DestAirportCode']) . ')';
				if ($route == 4) {
					$SourcePlaceName = $flightDatas[0]['Segments'][0]['originCityName'];
					$DestPlaceName = $flightDatas[0]['Segments'][0]['destinationCityName'];
				}

				$whatsappmessageFlight .= "%0a%0a*------* *$SourcePlaceName* *$navarrow* *$DestPlaceName* *------*%0a $NoofPax $TravelDate $finalHtml ";
			}
			$firstname = trim($getAgencyDetail['FirstName']) ? trim($getAgencyDetail['FirstName']) . ' ' . trim($getAgencyDetail['LastName']) : 'Agent';
			$primarycontact = trim($getAgencyDetail['Contacts']) ? trim($getAgencyDetail['Contacts']) : 'N/A';
			$agencyDisplayName = trim($getAgencyDetail['Title']) ? trim($getAgencyDetail['Title']) : 'N/A';
			$roundToOrigin = ($tripType == 2) ? 'to ' . $Origincity : '';
			$whatsappmessage = "*Dear $customername*,%0a%0aThanks for your Flight query for $Origincity to $DestinationCity $roundToOrigin.$whatsappmessageFlight  %0a%0aYou can also call $firstname at $primarycontact or email at $emailSendId or whatsapp me here.%0a%0aRegards %0a%0a$firstname, %0a$agencyDisplayName";
		}

		if ($shareOnly) {
			$response = array('success' => true, 'message' => 'Proposal sent successfully', 'whatsapp' => $whatsappmessage, 'contactno' => $countrycode . $mobilenumber);
			echo json_encode($response);
			exit;
		}

		$MultiHeadArr = isset($MultiHead[0]) ? $MultiHead[0] : '';
		$html = new Zend_View();
		$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
		$html->assign(array('FlightBooking' => $getflightData, 'FlightData' => $FlightData, 'MultiHead' => $MultiHeadArr, 'addMarkup' => $addMarkup, 'sessionFlightSearchParams' => $sessionFlightSearchParams, 'customername' => $customername, 'getAgencyData' => $getAgencyDetail, 'agencySysID' => $this->gtxagencysysid, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, 'baseUrl' => $this->baseUrl));
		if ($route == 3 && $interNationalSearch == 1) {
			$bodyText = $html->render('shareonmailMultiInt.phtml');
		} else {
			$bodyText = $html->render('shareonmail.phtml');
		}

		$subject = ucfirst(trim($getAgencyDetail['FirstName'])) . " your " . $Origincity . " to " . $DestinationCity . " Flight details from  " . trim($getAgencyDetail['Title']);

		$configs = [
			'fromEmail' => trim($emailSendId),
			'fromName' => trim($fromName),
			'subject' => $subject,
			'to' => trim($emailId),
			'bodyHtml' => $bodyText, 'bodyText' => ''
		];
		//echo '<pre>'; print_r($configs);echo '</pre>';die;
		$returnmail = $this->objHelperGeneral->mailSentByElastice($configs);
		$mailResponse = json_decode($returnmail, true);
		if ($mailResponse['success']) {
			$response = array('success' => true, 'message' => 'Proposal sent successfully', 'whatsapp' => $whatsappmessage, 'contactno' => $countrycode . $mobilenumber);
			echo json_encode($response);
			exit;
		} else {
			$response = array('success' => false, 'message' => 'Unable to send. please retry again.', 'whatsapp' => '', 'contactno' => '');
			echo json_encode($response);
			exit;
		}
	}
	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);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
		$str = curl_exec($ch);
		//        $str = file_get_contents($this->baseUrl.'public/data/dynamic/AirlineIdsAndCodeList.json');
		$response = json_decode($str, true);
		return $response;
	}

	public function getCityIdsAndAirPortCodeList()
	{
		$url = $this->baseUrl . "public/data/dynamic/AirPortCodeList.json";
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
		$str = curl_exec($ch);
		//        $str = file_get_contents($this->baseUrl.'public/data/dynamic/AirPortCodeList.json');
		$response = json_decode($str, true);
		return $response;
	}


	//// TBO data manage
	public function FlightDataTBO($apiResponse, $sessionFlightSearchParams, $FlightDataSeriesFare)
	{
		//echo '<pre>'; print_r($FlightDataSeriesFare);
		$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]);
		$this->view->intMemberCount = $intMemberCount;
		$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] : '';
		$arrFlightClass = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getFlightClasses();
		$FlightClass = $arrFlightClass[$flight_class];
		$currentDate = date('Y-m-d');
		$travelDates = $sessionFlightSearchParams['strDepatureDate'][0];
		//$begin = new DateTime($sessionFlightSearchParams['strDepatureDate'][0]);
		$begin = new DateTime($currentDate);
		$end = new DateTime($sessionFlightSearchParams['strDepatureDate'][0]);
		$sourceCityText = explode(',', $sessionFlightSearchParams['sourceCityText'][0]);
		$destinationCityText = explode(',', $sessionFlightSearchParams['destinationCityText'][0]);
		if ($strFlightRoute == 2 && $interNationalSearch == '') {
			$end = $end->modify('+30 day');
		} else {
			$end = $end->modify('+30 day');
		}

		$interval = new DateInterval('P1D');
		$daterange = new DatePeriod($begin, $interval, $end);
		$DepartDateArr = [];
		foreach ($daterange as $date) {
			$DepartDateArr[] = ['formatDate' => $date->format("Y-m-d"), 'depDate' => $date->format("d/m/Y")];
		}

		//$beginR = new DateTime($sessionFlightSearchParams['strReturnDate'][0]);
		$beginR = new DateTime($currentDate);
		$endR = new DateTime($sessionFlightSearchParams['strReturnDate'][0]);
		if ($strFlightRoute == 2 && $interNationalSearch == '') {
			$endR = $endR->modify('+30 day');
		} else {
			$endR = $endR->modify('+30 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")];
		}
		// For getting All Airlines Array
		$arrAirlineList = $this->getAirlineIdsAndCodeList();
		// For getting All Source & Destination CitySysId Array
		$arrCityIds = $this->getCityIdsAndAirPortCodeList();
		$getMarkup = $this->getMarkup($intCountryCode);

		if (!empty(trim($interNationalSearch)) && trim($interNationalSearch) == 1) {
			$intAirType = 2;
		} else {
			$intAirType = 1;
		}
		$objMarkup = new Travel_Model_Markup();
		$getAgencyMarkups = $objMarkup->getAgencyMarkups($intAirType, $this->gtxagencysysid);
		$getMarkupNew = $this->getMarkupNew();
		$intResponseStatus = !empty($apiResponse['ResponseStatus']) ? $apiResponse['ResponseStatus'] : '0';
		if ($intResponseStatus == 1) {
			$DayLightSavingDiff = 0;
			$AirportHaultMinutes = 0;
			$arrInsertFlightData = [];
			$arrAirlineName = [];
			$FiltStopCount = [];
			$FiltPriceRange = [];
			$AttPriceRange = [];
			foreach ($apiResponse['OutBoundFlightResults'] as $key => $result) {
				$IsGSTMandatory = isset($result['IsGSTMandatory']) ? $result['IsGSTMandatory'] : 0;
				$ResultIndex = $result['ResultIndex'];
				$Source = $result['Source'];
				$IsLCC = $result['IsLCC'];
				$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';
				$IsRefundable = ($result['IsRefundable']) ? 1 : 0;
				$AirlineRemark = $result['AirlineRemark'];

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

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

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

				$markUpArr = array(
					'getMarkupNew' => $getMarkupNew,
					'getAgencyMarkups' => $getAgencyMarkups,
					'PublishedFare' => $PublishedFare,
					'OfferedFare' => $OfferedFare,
					'intCommissionEarned' => $totalCommissions,
					'TdsOnCommission' => $totalCommissionsOnTds,
					'MUFee' => $ServiceFee,
					'intPLBEarned' => $PLBEarned,
					'intIncentiveEarned' => $IncentiveEarned,
					'intMemberCount' => $intMemberCount,
					'intFlightRoute' => $strFlightRoute,
					'interNationalSearch' => $interNationalSearch,
				);
				//echo '<pre>';print_r($markUpArr);
				$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTBO($markUpArr);
				//echo '<pre>';print_r($arrMarkUps);
				$intPublishedFare = $arrMarkUps['PublishFare'];

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

					$arrFareBreakdown[$pk]['Currency'] = $pax['Currency'];
					$arrFareBreakdown[$pk]['PassengerType'] = $pax['PassengerType'];
					$arrFareBreakdown[$pk]['PassengerCount'] = $pax['PassengerCount'];
					$arrFareBreakdown[$pk]['TaxIN'] = ($pax['Tax']);
					$arrFareBreakdown[$pk]['TotalBaseFare'] = 0;
					$arrFareBreakdown[$pk]['BaseFareCal'] = ($arrMarkUps['BaseFareCal'] / $countBreakUp);
					$arrFareBreakdown[$pk]['BaseFare'] = ($pax['BaseFare']);
					$arrFareBreakdown[$pk]['CommissionEarned'] = ($totalCommissions / $countBreakUp);
					$arrFareBreakdown[$pk]['OtherCharges'] = ($OtherCharges / $countBreakUp);
					$arrFareBreakdown[$pk]['TDS'] = ($totalCommissionsOnTds / $countBreakUp);
					$arrFareBreakdown[$pk]['MF'] = 0;
					$arrFareBreakdown[$pk]['YQ'] = $pax['YQTax'];
					$arrFareBreakdown[$pk]['AGST'] = 0;
					$arrFareBreakdown[$pk]['MFT'] = 0;
					$arrFareBreakdown[$pk]['OT'] = $pax['Tax'];
					$arrFareBreakdown[$pk]['MU'] = 0;
					$arrFareBreakdown[$pk]['YR'] = 0;
					$arrFareBreakdown[$pk]['intTotalGST'] = ($arrMarkUps['intTotalGST'] / $countBreakUp);
					$arrFareBreakdown[$pk]['apiMarkup'] = ($arrMarkUps['apiMarkup'] / $countBreakUp);
					$arrFareBreakdown[$pk]['IntCommission'] = ($arrMarkUps['IntCommission'] / $countBreakUp);
					$arrFareBreakdown[$pk]['apiTaxOnMarkup'] = ($arrMarkUps['apiTaxOnMarkup'] / $countBreakUp);
					$arrFareBreakdown[$pk]['FixedMarkUp'] = ($arrMarkUps['IntAgencyFixMarkUp'] / $countBreakUp);
					$arrFareBreakdown[$pk]['GSTOnMarkUp'] = ($arrMarkUps['IntTaxOnAgencyFixMarkUp'] / $countBreakUp);
					$arrFareBreakdown[$pk]['CommEarned'] = ($arrMarkUps['intCommisionEarnedForAgency'] / $countBreakUp);
					$arrFareBreakdown[$pk]['GSTonComm'] = 0;
					$arrFareBreakdown[$pk]['intGTXMarkUp'] = ($arrMarkUps['intGTXMarkUp'] / $countBreakUp);
					$arrFareBreakdown[$pk]['GTXMarkUpGST'] = ($arrMarkUps['intSTaxOnGTXMarkUp'] / $countBreakUp);
					$arrFareBreakdown[$pk]['AgentMarkUp'] = ($arrMarkUps['totalAgentMarkUp'] / $countBreakUp);
					$arrFareBreakdown[$pk]['GSTOnAgentMarkUp'] = ($arrMarkUps['intGSTOnAgentFixMarkUp'] / $countBreakUp);
					$arrFareBreakdown[$pk]['Agencycommission'] = ($arrMarkUps['Agencycommission'] / $countBreakUp);
					$arrFareBreakdown[$pk]['TotalCommssionVal_ag'] = ($arrMarkUps['TotalCommssionVal_ag'] / $countBreakUp);
					$arrFareBreakdown[$pk]['AdminComminAmount_ag'] = ($arrMarkUps['AdminComminAmount_ag'] / $countBreakUp);
					$arrFareBreakdown[$pk]['AgentB2CEarning'] = ($arrMarkUps['AgentB2CEarning'] / $countBreakUp);
					$arrFareBreakdown[$pk]['CostToAgentCustomer'] = ($arrMarkUps['CostToAgentCustomer'] / $countBreakUp);
					$arrFareBreakdown[$pk]['CostToAgent'] = ($arrMarkUps['CostToAgent'] / $countBreakUp);
					$arrFareBreakdown[$pk]['AdditionalTxnFeeOfrd'] = $pax['AdditionalTxnFeeOfrd'];
					$arrFareBreakdown[$pk]['AdditionalTxnFeePub'] = $pax['AdditionalTxnFeePub'];
					$arrFareBreakdown[$pk]['PGCharge'] = 0;
					$arrFareBreakdown[$pk]['Baggage'] = ''; //Check In Baggage;
					$arrFareBreakdown[$pk]['CabinBaggage'] = ''; //Cabin Baggage ;

				}

				$arrFairRules[0] = array(
					"Currency" => $this->CurrencyTitle, //$Currency,
					"CurrencyRate" => $this->CurrencyRate, //$Currency,
					"currencySysId" => $this->CurrencyId,
					"BaseFare" => $BaseFare,
					"Tax" => $Tax,
					"YQTax" => $YQTax,
					"OtherCharges" => $OtherCharges,
					"Discount" => $Discount,
					"ServiceFee" => $ServiceFee,
					"ManagementFeeTax" => 0,
					"AirlineGSTComponent" => 0,
					"CarrierMiscFee" => 0,
					"MUFee" => 0,
					"intPublishedFare" => $PublishedFare,
					"PublishedFare" => ($arrMarkUps['PublishFare'] * $this->CurrencyRate),
					"PublishedFareAgent" => ($arrMarkUps['CostToAgentCustomer'] * $this->CurrencyRate),
					"OfferedFareAgent" => ($arrMarkUps['CostToAgent'] * $this->CurrencyRate),
					"OfferedFare" => $arrMarkUps['intOfferedFare'],
					"CommissionEarned" => $CommissionEarned,
					"PLBEarned" => $PLBEarned,
					"IncentiveEarned" => $IncentiveEarned,
					"TdsOnCommission" => $TdsOnCommission,
					"TdsOnPLB" => $TdsOnPLB,
					"TdsOnIncentive" => $TdsOnIncentive,
					"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
					"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
					"PriceID" => $strTraceId,
					"ApiResultIndex" => $ResultIndex,
					"IsGSTRequired" => $IsGSTMandatory,
					"fareIdentifier" => $ResultFareType,
					"FareClass" => $FlightClass,
					"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" => $arrFareBreakdown,
					"arrMarkUps" => $arrMarkUps,
				);
				//echo '<pre>';print_r($arrFareBreakdown);
				$arrFairRules___pppppp[0] = array(
					"Currency" => $this->CurrencyTitle, //$Currency,
					"CurrencyRate" => $this->CurrencyRate, //$Currency,
					"currencySysId" => $this->CurrencyId,
					"fareIdentifier" => $ResultFareType,
					"BaseFare" => $BaseFare,
					"Tax" => $Tax,
					"YQTax" => $YQTax,
					"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
					"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
					"OtherCharges" => $OtherCharges,
					"Discount" => $Discount,
					"ServiceFee" => $ServiceFee,
					"PublishedFare" => $PublishedFare,

					"PublishedFareAgent" => $PublishedFare,
					"CommEarnedAgent" => $CommissionEarned,
					"OfferedFareAgent" => $OfferedFare,

					"CommissionEarned" => $CommissionEarned,
					"PLBEarned" => $PLBEarned,
					"IncentiveEarned" => $IncentiveEarned,
					"OfferedFare" => $OfferedFare,
					"TdsOnCommission" => $TdsOnCommission,
					"TdsOnPLB" => $TdsOnPLB,
					"TdsOnIncentive" => $TdsOnIncentive,
					"PriceID" => $strTraceId,
					"ApiResultIndex" => $ResultIndex,
					"FareBreakdown" => $FareBreakdown,
				);
				$originCity = $result['Segments'][0][0]['Origin']['Airport']['CityName'];
				$DestinationCity = $result['Segments'][0][0]['Destination']['Airport']['CityName'];
				$AirlineCode = $result['Segments'][0][0]['Airline']['AirlineCode'];
				$FlightNumber = $result['Segments'][0][0]['Airline']['FlightNumber'];
				$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
				$strAirlineName = $result['Segments'][0][0]['Airline']['AirlineName'];
				$strFareClass = $result['Segments'][0][0]['Airline']['FareClass'];
				$AccumulatedDuration = 0;
				$arrSegments = [];
				$FareClassArr = [];
				if (count($result['Segments'][0]) > 0) {
					$FlyingMinutes = 0;

					$countSeg = count($result['Segments'][0]);
					foreach ($result['Segments'][0] as $segmentsResult) {
						$Duration = $segmentsResult['Duration'];
						if ($countSeg >= 2) {
							$AccumulatedDuration += isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : (0);
						} else {
							$AccumulatedDuration += ($segmentsResult['Duration'] + $segmentsResult['GroundTime']);
						}

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

						$strAirlineCode = $segmentsResult['Airline']['AirlineCode'];
						$AirlineName = $segmentsResult['Airline']['AirlineName'];
						$FlightNumber = $segmentsResult['Airline']['FlightNumber'];
						$FareClass = $segmentsResult['Airline']['FareClass'];
						$FareClassArr[] = $FareClass;
						$SegFlightNumber = $strAirlineCode . "-" . $FlightNumber;

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

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

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

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

						$strAirlineCodeLogo = $strAirlineCode;

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

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

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

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

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

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

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

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

				$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($initialOriginArrTime);
				$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($initialOriginDepTime);
				$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
				if ($StopCount == 0) {
					$StopCountTxt = "Non-stop";
				} else {
					$StopCountTxt = $StopCount . " Stop(s)";
				}
				if ($IsRefundable) {
					$IsRefundableTxt = 'Refundable';
				} else {
					$IsRefundableTxt = 'Non Refundable';
				}
				$classOfBooking = implode(',', $FareClassArr);
				$arrFairRules[0]['classOfBooking'] = $classOfBooking;
				$arrFairRules[0]['FareClass'] = $FlightClass;
				$arrFairRules[0]['IsRefundableTxt'] = $IsRefundableTxt;
				$arrFairRules[0]['SeatAvailable'] = $NoOfSeatAvailable;
				$intJourneyType = 1;
				$intTripType = 1;
				$localFromDateTime = str_replace(' ', 'T', $initialOriginDepTime); //date("Y-m-d h:i", strtotime($strDepatureDate));
				$localToDateTime = str_replace(' ', 'T', $initialOriginArrTime); //date("Y-m-d h:i", strtotime($strReturnDate));
				//echo '<pre>';print_r($initialOriginDepTime);
				//echo '<pre>';print_r($localFromDateTime);
				$arrInsertFlightData[$key]['FlightNumber'] = $strFlightNumber;
				$arrInsertFlightData[$key]['AirlineName'] = $strAirlineName;
				$arrInsertFlightData[$key]['AirlineCode'] = $AirlineCode;
				$arrInsertFlightData[$key]['AirInvenSysId'] = 0;
				$arrInsertFlightData[$key]['IsLCC'] = $IsLCC;
				$arrInsertFlightData[$key]['IsTJFlightAPI'] = $this->IsTJFlightAPI;
				$arrInsertFlightData[$key]['IsGSTMandatory'] = $IsGSTMandatory;
				$arrInsertFlightData[$key]['IsRefundable'] = $IsRefundable;
				$arrInsertFlightData[$key]['IsRefundableTxt'] = $IsRefundableTxt;
				$arrInsertFlightData[$key]['IsBagIncludes'] = $IsBagIncludes;
				$arrInsertFlightData[$key]['SearchTraceId'] = $FlightTraceId;
				$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
				$arrInsertFlightData[$key]['AirlineSysId'] = $airlineSysId;
				$arrInsertFlightData[$key]['TravelDate'] = $localFromDateTime;
				$arrInsertFlightData[$key]['LocalFromTime'] = $localFromDateTime;
				$arrInsertFlightData[$key]['FromUTCTime'] = $initialOriginDepTime;
				$arrInsertFlightData[$key]['LocalToTime'] = $localToDateTime;
				$arrInsertFlightData[$key]['ToUTCTime'] = $initialOriginArrTime;
				$arrInsertFlightData[$key]['DepartureTime'] = $strDepartureDtTime;
				$arrInsertFlightData[$key]['DepartureDateTxt'] = date('D, d M', strtotime($localFromDateTime));
				$arrInsertFlightData[$key]['ArrivalTime'] = $strArrivalDtTime;
				$arrInsertFlightData[$key]['IsDirect'] = $IsDirect;
				$arrInsertFlightData[$key]['FareClass'] = $strFareClass;
				$arrInsertFlightData[$key]['FlightClass'] = $FlightClass;
				$arrInsertFlightData[$key]['DayLightSavingDiff'] = $DayLightSavingDiff;
				$arrInsertFlightData[$key]['FlyingMinutes'] = $FlyingMinutes;
				$arrInsertFlightData[$key]['FlightDuration'] = $FlightDuration;
				$arrInsertFlightData[$key]['SourcePlaceSysId'] = $intSourceCityId;
				$arrInsertFlightData[$key]['DestPlaceSysId'] = $intDestinationCityId;
				$arrInsertFlightData[$key]['SourceAirportCode'] = $strSourceAirportCode;
				$arrInsertFlightData[$key]['DestAirportCode'] = $strDestinationAirportCode;
				$arrInsertFlightData[$key]['SourcePlaceName'] = $sourceCityText[0];
				$arrInsertFlightData[$key]['DestPlaceName'] = $destinationCityText[0];
				$arrInsertFlightData[$key]['AirportHaultMinutes'] = $AirportHaultMinutes;
				$arrInsertFlightData[$key]['StopCount'] = $StopCountTxt;
				$arrInsertFlightData[$key]['Stops'] = '';
				$arrInsertFlightData[$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
				$arrInsertFlightData[$key]['TotalFlightMembers'] = $intMemberCount;
				$arrInsertFlightData[$key]['CurrencyType'] = $currencySysId;
				$arrInsertFlightData[$key]['Currency'] = $this->CurrencyTitle;
				$arrInsertFlightData[$key]['PublishedFare'] = $intPublishedFare; // As Discussed with GG
				$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format($intPublishedFare); // As Discussed with GG
				$arrInsertFlightData[$key]['CommissionEarned'] = $CommissionEarned;
				$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
				$arrInsertFlightData[$key]['JourneyType'] = $intJourneyType;
				$arrInsertFlightData[$key]['TripType'] = $intTripType;
				$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
				$arrInsertFlightData[$key]['ICSourceSysId'] = 3;
				$arrInsertFlightData[$key]['logo'] = $filePath;
				$arrInsertFlightData[$key]['FairRules'] = $arrFairRules;
				$arrInsertFlightData[$key]['Segments'] = $arrSegments;

				$arrAirlineName[] = $AirlineCode . '-' . $strAirlineName;
				$AttPriceRange[] = $intPublishedFare * $this->CurrencyRate;
				$FiltStopCount[] = $StopCountTxt;
				$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
				$arrInsertFlightData[$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
			}
			$RoundTrip = $this->FlightDataRoundTripTBO($apiResponse, $sessionFlightSearchParams);
			//$MinriceRange = (min($AttPriceRange));
			//$MaxriceRange = (max($AttPriceRange));AttPriceRange
			if (!empty($FlightDataSeriesFare['outbound'])) {
				$arrInsertFlightData = array_values(array_merge($arrInsertFlightData, $FlightDataSeriesFare['outbound']));
			}

			if (isset($FlightDataSeriesFare['AttPriceRange']) && !empty($FlightDataSeriesFare['AttPriceRange'])) {
				$MinriceRange = (min(array_merge($AttPriceRange, $RoundTrip['AttPriceRange'], $FlightDataSeriesFare['AttPriceRange'])));
				$MaxriceRange = (max(array_merge($AttPriceRange, $RoundTrip['AttPriceRange'], $FlightDataSeriesFare['AttPriceRange'])));
			} else {
				$MinriceRange = (min(array_merge($AttPriceRange, $RoundTrip['AttPriceRange'])));
				$MaxriceRange = (max(array_merge($AttPriceRange, $RoundTrip['AttPriceRange'])));
			}
			//$MinriceRange = min(array_values(array_unique(array_merge($AttPriceRange, $RoundTrip['AttPriceRange']))));
			//$MaxriceRange = max(array_values(array_unique(array_merge($AttPriceRange, $RoundTrip['AttPriceRange']))));

			//$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, $RoundTrip['arrAirlineName'])));
			//$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, $RoundTrip['FiltStopCount'])));

			if (isset($FlightDataSeriesFare['arrAirlineName']) && !empty($FlightDataSeriesFare['arrAirlineName'])) {
				$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, $RoundTrip['arrAirlineName'], $FlightDataSeriesFare['arrAirlineName'])));
			} else {
				$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, $RoundTrip['arrAirlineName'])));
			}
			if (isset($FlightDataSeriesFare['FiltStopCount']) && !empty($FlightDataSeriesFare['FiltStopCount'])) {
				$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, $RoundTrip['FiltStopCount'], $FlightDataSeriesFare['FiltStopCount'])));
			} else {
				$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, $RoundTrip['FiltStopCount'])));
			}

			if ($interNationalSearch == 1 && $strFlightRoute == 2) {
				$RoundInterTrip = $this->FlightDataRoundTripInternationalTBO($apiResponse, $sessionFlightSearchParams);
				$MinriceRange = (min(array_values(array_unique($RoundInterTrip['AttPriceRange']))) - 200);
				$MaxriceRange = (max(array_values(array_unique($RoundInterTrip['AttPriceRange']))));
				$arrAirlineName = array_values(array_unique($RoundInterTrip['arrAirlineName']));
				$FiltStopCount = array_values(array_unique($RoundInterTrip['FiltStopCount']));
				$data = array('outbound' => $RoundInterTrip['outbound'], 'inbound' => [], 'ReturnDateArr' => $ReturnDateArr, 'DepartDateArr' => $DepartDateArr, 'travelDates' => $travelDates, 'source' => $source, 'destination' => $destination, 'source_city' => $source_city, 'destination_city' => $destination_city, 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute, 'CurrencyTitle' => $this->CurrencyTitle, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'MinriceRange' => (ceil($MinriceRange) - 100), 'MaxriceRange' => (ceil($MaxriceRange) + 100));
				return $data;
			} else {
				$data = array('outbound' => $arrInsertFlightData, 'inbound' => $RoundTrip['inbound'], 'ReturnDateArr' => $ReturnDateArr, 'DepartDateArr' => $DepartDateArr, 'travelDates' => $travelDates, 'source' => $source, 'destination' => $destination, 'source_city' => $source_city, 'destination_city' => $destination_city, 'interNationalSearch' => $interNationalSearch, 'route' => $strFlightRoute, 'CurrencyTitle' => $this->CurrencyTitle, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'MinriceRange' => (ceil($MinriceRange) - 100), 'MaxriceRange' => (ceil($MaxriceRange) + 100));
				return $data;
			}
		} else {
			$data = array('outbound' => [], 'inbound' => [], 'arrAirlineName' => [], 'FiltStopCount' => [], 'ArrPriceUnique' => []);
			return $data; //echo json_encode($data);
		}
	}

	public function FlightDataRoundTripTBO($apiResponse, $sessionFlightSearchParams)
	{
		$adultCount = $sessionFlightSearchParams['adults'];
		$childCount = $sessionFlightSearchParams['child'];
		$infantCount = $sessionFlightSearchParams['infant'];
		$intMemberCount = $adultCount + $childCount + $infantCount;
		$strFlightRoute = trim($sessionFlightSearchParams['route']);
		$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
		$flight_class = trim($sessionFlightSearchParams['flight_class']);
		$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
		$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId'][0]);
		$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId'][0]);
		$FlightTraceId = trim($sessionFlightSearchParams['FlightTraceId']);
		$this->view->intMemberCount = $intMemberCount;
		$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] : '';
		$arrFlightClass = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getFlightClasses();
		$FlightClass = $arrFlightClass[$flight_class];
		$begin = new DateTime($sessionFlightSearchParams['strDepatureDate'][0]);
		$end = new DateTime($sessionFlightSearchParams['strDepatureDate'][0]);
		$sourceCityText = explode(',', $sessionFlightSearchParams['sourceCityText'][0]);
		$destinationCityText = explode(',', $sessionFlightSearchParams['destinationCityText'][0]);
		if ($strFlightRoute == 2 && $interNationalSearch == '') {
			$end = $end->modify('+30 day');
		} else {
			$end = $end->modify('+30 day');
		}

		$interval = new DateInterval('P1D');
		$daterange = new DatePeriod($begin, $interval, $end);
		$DepartDateArr = [];
		foreach ($daterange as $date) {
			$DepartDateArr[] = ['formatDate' => $date->format("Y-m-d"), 'depDate' => $date->format("d/m/Y")];
		}

		$beginR = new DateTime($sessionFlightSearchParams['strReturnDate'][0]);
		$endR = new DateTime($sessionFlightSearchParams['strReturnDate'][0]);
		if ($strFlightRoute == 2 && $interNationalSearch == '') {
			$endR = $endR->modify('+30 day');
		} else {
			$endR = $endR->modify('+30 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")];
		}
		// For getting All Airlines Array
		$arrAirlineList = $this->getAirlineIdsAndCodeList();
		// For getting All Source & Destination CitySysId Array
		$arrCityIds = $this->getCityIdsAndAirPortCodeList();
		$getMarkup = $this->getMarkup($intCountryCode);

		if (!empty(trim($interNationalSearch)) && trim($interNationalSearch) == 1) {
			$intAirType = 2;
		} else {
			$intAirType = 1;
		}
		$objMarkup = new Travel_Model_Markup();
		$getAgencyMarkups = $objMarkup->getAgencyMarkups($intAirType, $this->gtxagencysysid);
		$getMarkupNew = $this->getMarkupNew();
		$intResponseStatus = !empty($apiResponse['ResponseStatus']) ? $apiResponse['ResponseStatus'] : '0';
		if ($intResponseStatus == 1) {
			$DayLightSavingDiff = 0;
			$AirportHaultMinutes = 0;
			$arrInsertFlightData = [];
			$arrAirlineName = [];
			$FiltStopCount = [];
			$FiltPriceRange = [];
			$AttPriceRange = [];
			foreach ($apiResponse['InBoundFlightResults'] as $key => $result) {
				$IsGSTMandatory = isset($result['IsGSTMandatory']) ? $result['IsGSTMandatory'] : 0;
				$ResultIndex = $result['ResultIndex'];
				$Source = $result['Source'];
				$IsLCC = $result['IsLCC'];
				$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';
				$IsRefundable = ($result['IsRefundable']) ? 1 : 0;
				$AirlineRemark = $result['AirlineRemark'];

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

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

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

				$markUpArr = array(
					'getMarkupNew' => $getMarkupNew,
					'getAgencyMarkups' => $getAgencyMarkups,
					'PublishedFare' => $PublishedFare,
					'OfferedFare' => $OfferedFare,
					'intCommissionEarned' => $totalCommissions,
					'TdsOnCommission' => $totalCommissionsOnTds,
					'MUFee' => $ServiceFee,
					'intPLBEarned' => $PLBEarned,
					'intIncentiveEarned' => $IncentiveEarned,
					'intMemberCount' => $intMemberCount,
					'intFlightRoute' => $strFlightRoute,
					'interNationalSearch' => $interNationalSearch,
				);

				$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTBO($markUpArr);
				$intPublishedFare = $arrMarkUps['PublishFare'];

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

					$arrFareBreakdown[$pk]['Currency'] = $pax['Currency'];
					$arrFareBreakdown[$pk]['PassengerType'] = $pax['PassengerType'];
					$arrFareBreakdown[$pk]['PassengerCount'] = $pax['PassengerCount'];
					$arrFareBreakdown[$pk]['TaxIN'] = ($pax['Tax']);
					$arrFareBreakdown[$pk]['TotalBaseFare'] = 0;
					$arrFareBreakdown[$pk]['BaseFareCal'] = ($arrMarkUps['BaseFareCal'] / $countBreakUp);
					$arrFareBreakdown[$pk]['BaseFare'] = ($pax['BaseFare']);
					$arrFareBreakdown[$pk]['CommissionEarned'] = ($totalCommissions / $countBreakUp);
					$arrFareBreakdown[$pk]['OtherCharges'] = ($OtherCharges / $countBreakUp);
					$arrFareBreakdown[$pk]['TDS'] = ($totalCommissionsOnTds / $countBreakUp);
					$arrFareBreakdown[$pk]['MF'] = 0;
					$arrFareBreakdown[$pk]['YQ'] = $pax['YQTax'];
					$arrFareBreakdown[$pk]['AGST'] = 0;
					$arrFareBreakdown[$pk]['MFT'] = 0;
					$arrFareBreakdown[$pk]['OT'] = $pax['Tax'];
					$arrFareBreakdown[$pk]['MU'] = 0;
					$arrFareBreakdown[$pk]['YR'] = 0;
					$arrFareBreakdown[$pk]['intTotalGST'] = ($arrMarkUps['intTotalGST'] / $countBreakUp);
					$arrFareBreakdown[$pk]['apiMarkup'] = ($arrMarkUps['apiMarkup'] / $countBreakUp);
					$arrFareBreakdown[$pk]['IntCommission'] = ($arrMarkUps['IntCommission'] / $countBreakUp);
					$arrFareBreakdown[$pk]['apiTaxOnMarkup'] = ($arrMarkUps['apiTaxOnMarkup'] / $countBreakUp);
					$arrFareBreakdown[$pk]['FixedMarkUp'] = ($arrMarkUps['IntAgencyFixMarkUp'] / $countBreakUp);
					$arrFareBreakdown[$pk]['GSTOnMarkUp'] = ($arrMarkUps['IntTaxOnAgencyFixMarkUp'] / $countBreakUp);
					$arrFareBreakdown[$pk]['CommEarned'] = ($arrMarkUps['intCommisionEarnedForAgency'] / $countBreakUp);
					$arrFareBreakdown[$pk]['GSTonComm'] = 0;
					$arrFareBreakdown[$pk]['intGTXMarkUp'] = ($arrMarkUps['intGTXMarkUp'] / $countBreakUp);
					$arrFareBreakdown[$pk]['GTXMarkUpGST'] = ($arrMarkUps['intSTaxOnGTXMarkUp'] / $countBreakUp);
					$arrFareBreakdown[$pk]['AgentMarkUp'] = ($arrMarkUps['totalAgentMarkUp'] / $countBreakUp);
					$arrFareBreakdown[$pk]['GSTOnAgentMarkUp'] = ($arrMarkUps['intGSTOnAgentFixMarkUp'] / $countBreakUp);
					$arrFareBreakdown[$pk]['Agencycommission'] = ($arrMarkUps['Agencycommission'] / $countBreakUp);
					$arrFareBreakdown[$pk]['TotalCommssionVal_ag'] = ($arrMarkUps['TotalCommssionVal_ag'] / $countBreakUp);
					$arrFareBreakdown[$pk]['AdminComminAmount_ag'] = ($arrMarkUps['AdminComminAmount_ag'] / $countBreakUp);
					$arrFareBreakdown[$pk]['AgentB2CEarning'] = ($arrMarkUps['AgentB2CEarning'] / $countBreakUp);
					$arrFareBreakdown[$pk]['CostToAgentCustomer'] = ($arrMarkUps['CostToAgentCustomer'] / $countBreakUp);
					$arrFareBreakdown[$pk]['CostToAgent'] = ($arrMarkUps['CostToAgent'] / $countBreakUp);
					$arrFareBreakdown[$pk]['AdditionalTxnFeeOfrd'] = $pax['AdditionalTxnFeeOfrd'];
					$arrFareBreakdown[$pk]['AdditionalTxnFeePub'] = $pax['AdditionalTxnFeePub'];
					$arrFareBreakdown[$pk]['PGCharge'] = 0;
					$arrFareBreakdown[$pk]['Baggage'] = ''; //Check In Baggage;
					$arrFareBreakdown[$pk]['CabinBaggage'] = ''; //Cabin Baggage ;

				}

				$arrFairRules[0] = array(
					"Currency" => $this->CurrencyTitle, //$Currency,
					"CurrencyRate" => $this->CurrencyRate, //$Currency,
					"currencySysId" => $this->CurrencyId,
					"BaseFare" => $BaseFare,
					"Tax" => $Tax,
					"YQTax" => $YQTax,
					"OtherCharges" => $OtherCharges,
					"Discount" => $Discount,
					"ServiceFee" => $ServiceFee,
					"ManagementFeeTax" => 0,
					"AirlineGSTComponent" => 0,
					"CarrierMiscFee" => 0,
					"MUFee" => 0,
					"intPublishedFare" => $PublishedFare,
					"PublishedFare" => ($arrMarkUps['PublishFare'] * $this->CurrencyRate),
					"PublishedFareAgent" => ($arrMarkUps['CostToAgentCustomer'] * $this->CurrencyRate),
					"OfferedFareAgent" => ($arrMarkUps['CostToAgent'] * $this->CurrencyRate),
					"OfferedFare" => $arrMarkUps['intOfferedFare'],
					"CommissionEarned" => $CommissionEarned,
					"PLBEarned" => $PLBEarned,
					"IncentiveEarned" => $IncentiveEarned,
					"TdsOnCommission" => $TdsOnCommission,
					"TdsOnPLB" => $TdsOnPLB,
					"TdsOnIncentive" => $TdsOnIncentive,
					"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
					"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
					"PriceID" => $strTraceId,
					"ApiResultIndex" => $ResultIndex,
					"IsGSTRequired" => $IsGSTMandatory,
					"fareIdentifier" => $ResultFareType,
					"FareClass" => $FlightClass,
					"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" => $arrFareBreakdown,
					"arrMarkUps" => $arrMarkUps,
				);

				$originCity = $result['Segments'][0][0]['Origin']['Airport']['CityName'];
				$DestinationCity = $result['Segments'][0][0]['Destination']['Airport']['CityName'];
				$AirlineCode = $result['Segments'][0][0]['Airline']['AirlineCode'];
				$FlightNumber = $result['Segments'][0][0]['Airline']['FlightNumber'];
				$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
				$strAirlineName = $result['Segments'][0][0]['Airline']['AirlineName'];
				$strFareClass = $result['Segments'][0][0]['Airline']['FareClass'];
				$AccumulatedDuration = 0;
				$arrSegments = [];
				$FareClassArr = [];
				if (count($result['Segments'][0]) > 0) {
					$FlyingMinutes = 0;

					$countSeg = count($result['Segments'][0]);
					foreach ($result['Segments'][0] as $segmentsResult) {
						$Duration = $segmentsResult['Duration'];
						if ($countSeg >= 2) {
							$AccumulatedDuration += isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : (0);
						} else {
							$AccumulatedDuration += ($segmentsResult['Duration'] + $segmentsResult['GroundTime']);
						}

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

						$strAirlineCode = $segmentsResult['Airline']['AirlineCode'];
						$AirlineName = $segmentsResult['Airline']['AirlineName'];
						$FlightNumber = $segmentsResult['Airline']['FlightNumber'];
						$FareClass = $segmentsResult['Airline']['FareClass'];
						$FareClassArr[] = $FareClass;
						$SegFlightNumber = $strAirlineCode . "-" . $FlightNumber;

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

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

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

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

						$strAirlineCodeLogo = $strAirlineCode;

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

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

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

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

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

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

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

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

				$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($initialOriginArrTime);
				$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($initialOriginDepTime);
				$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
				if ($StopCount == 0) {
					$StopCountTxt = "Non-stop";
				} else {
					$StopCountTxt = $StopCount . " Stop(s)";
				}
				if ($IsRefundable) {
					$IsRefundableTxt = 'Refundable';
				} else {
					$IsRefundableTxt = 'Non Refundable';
				}
				$classOfBooking = implode(',', $FareClassArr);
				$arrFairRules[0]['classOfBooking'] = $classOfBooking;
				$arrFairRules[0]['FareClass'] = $FlightClass;
				$arrFairRules[0]['IsRefundableTxt'] = $IsRefundableTxt;
				$arrFairRules[0]['SeatAvailable'] = $NoOfSeatAvailable;
				$intJourneyType = 2;
				$intTripType = 1;
				$localFromDateTime = str_replace(' ', 'T', $initialOriginDepTime); //date("Y-m-d h:i", strtotime($strDepatureDate));
				$localToDateTime = str_replace(' ', 'T', $initialOriginArrTime); //date("Y-m-d h:i", strtotime($strReturnDate));
				$arrInsertFlightData[$key]['FlightNumber'] = $strFlightNumber;
				$arrInsertFlightData[$key]['AirlineName'] = $strAirlineName;
				$arrInsertFlightData[$key]['AirlineCode'] = $AirlineCode;
				$arrInsertFlightData[$key]['AirInvenSysId'] = 0;
				$arrInsertFlightData[$key]['IsLCC'] = $IsLCC;
				$arrInsertFlightData[$key]['IsTJFlightAPI'] = $this->IsTJFlightAPI;
				$arrInsertFlightData[$key]['IsGSTMandatory'] = $IsGSTMandatory;
				$arrInsertFlightData[$key]['IsRefundable'] = $IsRefundable;
				$arrInsertFlightData[$key]['IsRefundableTxt'] = $IsRefundableTxt;
				$arrInsertFlightData[$key]['IsBagIncludes'] = $IsBagIncludes;
				$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
				$arrInsertFlightData[$key]['SearchTraceId'] = $FlightTraceId;
				$arrInsertFlightData[$key]['AirlineSysId'] = $airlineSysId;
				$arrInsertFlightData[$key]['TravelDate'] = $localFromDateTime;
				$arrInsertFlightData[$key]['LocalFromTime'] = $localFromDateTime;
				$arrInsertFlightData[$key]['FromUTCTime'] = $initialOriginDepTime;
				$arrInsertFlightData[$key]['LocalToTime'] = $localToDateTime;
				$arrInsertFlightData[$key]['ToUTCTime'] = $initialOriginArrTime;
				$arrInsertFlightData[$key]['DepartureTime'] = $strDepartureDtTime;
				$arrInsertFlightData[$key]['DepartureDateTxt'] = date('D, d M', strtotime($localFromDateTime));
				$arrInsertFlightData[$key]['ArrivalTime'] = $strArrivalDtTime;
				$arrInsertFlightData[$key]['IsDirect'] = $IsDirect;
				$arrInsertFlightData[$key]['FareClass'] = $strFareClass;
				$arrInsertFlightData[$key]['FlightClass'] = $FlightClass;
				$arrInsertFlightData[$key]['DayLightSavingDiff'] = $DayLightSavingDiff;
				$arrInsertFlightData[$key]['FlyingMinutes'] = $FlyingMinutes;
				$arrInsertFlightData[$key]['FlightDuration'] = $FlightDuration;
				$arrInsertFlightData[$key]['SourcePlaceSysId'] = $intSourceCityId;
				$arrInsertFlightData[$key]['DestPlaceSysId'] = $intDestinationCityId;
				$arrInsertFlightData[$key]['SourceAirportCode'] = $strSourceAirportCode;
				$arrInsertFlightData[$key]['DestAirportCode'] = $strDestinationAirportCode;
				$arrInsertFlightData[$key]['SourcePlaceName'] = $sourceCityText[0];
				$arrInsertFlightData[$key]['DestPlaceName'] = $destinationCityText[0];
				$arrInsertFlightData[$key]['AirportHaultMinutes'] = $AirportHaultMinutes;
				$arrInsertFlightData[$key]['StopCount'] = $StopCountTxt;
				$arrInsertFlightData[$key]['Stops'] = '';
				$arrInsertFlightData[$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
				$arrInsertFlightData[$key]['TotalFlightMembers'] = $intMemberCount;
				$arrInsertFlightData[$key]['CurrencyType'] = $currencySysId;
				$arrInsertFlightData[$key]['Currency'] = $this->CurrencyTitle;
				$arrInsertFlightData[$key]['PublishedFare'] = $intPublishedFare; // As Discussed with GG
				$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format($intPublishedFare); // As Discussed with GG
				$arrInsertFlightData[$key]['CommissionEarned'] = $CommissionEarned;
				$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
				$arrInsertFlightData[$key]['JourneyType'] = $intJourneyType;
				$arrInsertFlightData[$key]['TripType'] = $intTripType;
				$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
				$arrInsertFlightData[$key]['ICSourceSysId'] = 3;
				$arrInsertFlightData[$key]['logo'] = $filePath;
				$arrInsertFlightData[$key]['FairRules'] = $arrFairRules;
				$arrInsertFlightData[$key]['Segments'] = $arrSegments;

				$arrAirlineName[] = $AirlineCode . '-' . $strAirlineName;
				$AttPriceRange[] = $intPublishedFare * $this->CurrencyRate;
				$FiltStopCount[] = $StopCountTxt;
				$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
				$arrInsertFlightData[$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
			}
			$arrAirlineName = array_unique($arrAirlineName);
			$FiltStopCount = array_unique($FiltStopCount);
			$AttPriceRange = array_unique($AttPriceRange);
			//echo '<pre>';print_r($AttPriceRange);echo '<pre>';
			$data = array('inbound' => $arrInsertFlightData, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'AttPriceRange' => $AttPriceRange);
			return $data;
		} else {
			return false;
		}
	}

	public function FlightDataRoundTripInternationalTBO($apiResponse, $sessionFlightSearchParams)
	{
		$adultCount = $sessionFlightSearchParams['adults'];
		$childCount = $sessionFlightSearchParams['child'];
		$infantCount = $sessionFlightSearchParams['infant'];
		$intMemberCount = $adultCount + $childCount + $infantCount;
		$strFlightRoute = trim($sessionFlightSearchParams['route']);
		$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
		$flight_class = trim($sessionFlightSearchParams['flight_class']);
		$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
		$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId'][0]);
		$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId'][0]);
		$FlightTraceId = trim($sessionFlightSearchParams['FlightTraceId']);
		$this->view->intMemberCount = $intMemberCount;
		$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] : '';
		$arrFlightClass = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getFlightClasses();
		$FlightClass = $arrFlightClass[$flight_class];
		$begin = new DateTime($sessionFlightSearchParams['strDepatureDate'][0]);
		$end = new DateTime($sessionFlightSearchParams['strDepatureDate'][0]);
		$sourceCityText = explode(',', $sessionFlightSearchParams['sourceCityText'][0]);
		$destinationCityText = explode(',', $sessionFlightSearchParams['destinationCityText'][0]);
		if ($strFlightRoute == 2 && $interNationalSearch == '') {
			$end = $end->modify('+30 day');
		} else {
			$end = $end->modify('+30 day');
		}

		$interval = new DateInterval('P1D');
		$daterange = new DatePeriod($begin, $interval, $end);
		$DepartDateArr = [];
		foreach ($daterange as $date) {
			$DepartDateArr[] = ['formatDate' => $date->format("Y-m-d"), 'depDate' => $date->format("d/m/Y")];
		}

		$beginR = new DateTime($sessionFlightSearchParams['strReturnDate'][0]);
		$endR = new DateTime($sessionFlightSearchParams['strReturnDate'][0]);
		if ($strFlightRoute == 2 && $interNationalSearch == '') {
			$endR = $endR->modify('+30 day');
		} else {
			$endR = $endR->modify('+30 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")];
		}
		// For getting All Airlines Array
		$arrAirlineList = $this->getAirlineIdsAndCodeList();
		// For getting All Source & Destination CitySysId Array
		$arrCityIds = $this->getCityIdsAndAirPortCodeList();
		$getMarkup = $this->getMarkup($intCountryCode);

		if (!empty(trim($interNationalSearch)) && trim($interNationalSearch) == 1) {
			$intAirType = 2;
		} else {
			$intAirType = 1;
		}
		$objMarkup = new Travel_Model_Markup();
		$getAgencyMarkups = $objMarkup->getAgencyMarkups($intAirType, $this->gtxagencysysid);
		$getMarkupNew = $this->getMarkupNew();
		$strDepatureDate = $sessionFlightSearchParams['departure_dates'][0];
		$strReturnDate = !empty($sessionFlightSearchParams['return_dates']) ? $sessionFlightSearchParams['return_dates'][0] : '';
		$strSourceAirportCode = $sessionFlightSearchParams['from'][0];
		$strDestinationAirportCode = $sessionFlightSearchParams['to'][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];
			}
		}
		$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' => 2,
			'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0,
		);
		// echo '<pre>';
		// print_r($arrCommonInsVariables);
		// die;
		$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 = [];
		$intResponseStatus = !empty($apiResponse['ResponseStatus']) ? $apiResponse['ResponseStatus'] : '0';
		if ($intResponseStatus == 1) {
			$DayLightSavingDiff = 0;
			$AirportHaultMinutes = 0;
			$arrInsertFlightData = [];
			$arrAirlineName = [];
			$FiltStopCount = [];
			$DesFiltStopCount = [];
			$AttPriceRange = [];
			$FiltPriceRange = [];

			foreach ($apiResponse['InterNationalFlightResults'] as $key => $result) {
				$IsGSTMandatory = isset($result['IsGSTMandatory']) ? $result['IsGSTMandatory'] : 0;
				$ResultIndex = $result['ResultIndex'];

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

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

				$Currency = $result['Fare']['Currency'];
				//                echo '<pre>';print_r($arrSegments);echo '</pre>';
				$currencySysId = $this->CurrencyId;
				$BaseFare = $result['Fare']['BaseFare'];
				$Tax = $result['Fare']['Tax'];

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

				$markUpArr = array(
					'getMarkupNew' => $getMarkupNew,
					'getAgencyMarkups' => $getAgencyMarkups,
					'PublishedFare' => $PublishedFare,
					'OfferedFare' => $OfferedFare,
					'intCommissionEarned' => $totalCommissions,
					'TdsOnCommission' => $totalCommissionsOnTds,
					'MUFee' => $ServiceFee,
					'intPLBEarned' => $PLBEarned,
					'intIncentiveEarned' => $IncentiveEarned,
					'intMemberCount' => $intMemberCount,
					'intFlightRoute' => $strFlightRoute,
					'interNationalSearch' => $interNationalSearch,
				);

				$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkupTBO($markUpArr);
				$intPublishedFare = $arrMarkUps['PublishFare'];

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

					$arrFareBreakdown[$pk]['Currency'] = $pax['Currency'];
					$arrFareBreakdown[$pk]['PassengerType'] = $pax['PassengerType'];
					$arrFareBreakdown[$pk]['PassengerCount'] = $pax['PassengerCount'];
					$arrFareBreakdown[$pk]['TaxIN'] = ($pax['Tax']);
					$arrFareBreakdown[$pk]['TotalBaseFare'] = 0;
					$arrFareBreakdown[$pk]['BaseFareCal'] = ($arrMarkUps['BaseFareCal'] / $countBreakUp);
					$arrFareBreakdown[$pk]['BaseFare'] = ($pax['BaseFare']);
					$arrFareBreakdown[$pk]['CommissionEarned'] = ($totalCommissions / $countBreakUp);
					$arrFareBreakdown[$pk]['OtherCharges'] = ($OtherCharges / $countBreakUp);
					$arrFareBreakdown[$pk]['TDS'] = ($totalCommissionsOnTds / $countBreakUp);
					$arrFareBreakdown[$pk]['MF'] = 0;
					$arrFareBreakdown[$pk]['YQ'] = $pax['YQTax'];
					$arrFareBreakdown[$pk]['AGST'] = 0;
					$arrFareBreakdown[$pk]['MFT'] = 0;
					$arrFareBreakdown[$pk]['OT'] = $pax['Tax'];
					$arrFareBreakdown[$pk]['MU'] = 0;
					$arrFareBreakdown[$pk]['YR'] = 0;
					$arrFareBreakdown[$pk]['intTotalGST'] = ($arrMarkUps['intTotalGST'] / $countBreakUp);
					$arrFareBreakdown[$pk]['apiMarkup'] = ($arrMarkUps['apiMarkup'] / $countBreakUp);
					$arrFareBreakdown[$pk]['IntCommission'] = ($arrMarkUps['IntCommission'] / $countBreakUp);
					$arrFareBreakdown[$pk]['apiTaxOnMarkup'] = ($arrMarkUps['apiTaxOnMarkup'] / $countBreakUp);
					$arrFareBreakdown[$pk]['FixedMarkUp'] = ($arrMarkUps['IntAgencyFixMarkUp'] / $countBreakUp);
					$arrFareBreakdown[$pk]['GSTOnMarkUp'] = ($arrMarkUps['IntTaxOnAgencyFixMarkUp'] / $countBreakUp);
					$arrFareBreakdown[$pk]['CommEarned'] = ($arrMarkUps['intCommisionEarnedForAgency'] / $countBreakUp);
					$arrFareBreakdown[$pk]['GSTonComm'] = 0;
					$arrFareBreakdown[$pk]['intGTXMarkUp'] = ($arrMarkUps['intGTXMarkUp'] / $countBreakUp);
					$arrFareBreakdown[$pk]['GTXMarkUpGST'] = ($arrMarkUps['intSTaxOnGTXMarkUp'] / $countBreakUp);
					$arrFareBreakdown[$pk]['AgentMarkUp'] = ($arrMarkUps['totalAgentMarkUp'] / $countBreakUp);
					$arrFareBreakdown[$pk]['GSTOnAgentMarkUp'] = ($arrMarkUps['intGSTOnAgentFixMarkUp'] / $countBreakUp);
					$arrFareBreakdown[$pk]['Agencycommission'] = ($arrMarkUps['Agencycommission'] / $countBreakUp);
					$arrFareBreakdown[$pk]['TotalCommssionVal_ag'] = ($arrMarkUps['TotalCommssionVal_ag'] / $countBreakUp);
					$arrFareBreakdown[$pk]['AdminComminAmount_ag'] = ($arrMarkUps['AdminComminAmount_ag'] / $countBreakUp);
					$arrFareBreakdown[$pk]['AgentB2CEarning'] = ($arrMarkUps['AgentB2CEarning'] / $countBreakUp);
					$arrFareBreakdown[$pk]['CostToAgentCustomer'] = ($arrMarkUps['CostToAgentCustomer'] / $countBreakUp);
					$arrFareBreakdown[$pk]['CostToAgent'] = ($arrMarkUps['CostToAgent'] / $countBreakUp);
					$arrFareBreakdown[$pk]['AdditionalTxnFeeOfrd'] = $pax['AdditionalTxnFeeOfrd'];
					$arrFareBreakdown[$pk]['AdditionalTxnFeePub'] = $pax['AdditionalTxnFeePub'];
					$arrFareBreakdown[$pk]['PGCharge'] = 0;
					$arrFareBreakdown[$pk]['Baggage'] = ''; //Check In Baggage;
					$arrFareBreakdown[$pk]['CabinBaggage'] = ''; //Cabin Baggage ;

				}

				$arrFairRules[0] = array(
					"Currency" => $this->CurrencyTitle, //$Currency,
					"CurrencyRate" => $this->CurrencyRate, //$Currency,
					"currencySysId" => $this->CurrencyId,
					"BaseFare" => $BaseFare,
					"Tax" => $Tax,
					"YQTax" => $YQTax,
					"OtherCharges" => $OtherCharges,
					"Discount" => $Discount,
					"ServiceFee" => $ServiceFee,
					"ManagementFeeTax" => 0,
					"AirlineGSTComponent" => 0,
					"CarrierMiscFee" => 0,
					"MUFee" => 0,
					"intPublishedFare" => $PublishedFare,
					"PublishedFare" => ($arrMarkUps['PublishFare'] * $this->CurrencyRate),
					"PublishedFareAgent" => ($arrMarkUps['CostToAgentCustomer'] * $this->CurrencyRate),
					"OfferedFareAgent" => ($arrMarkUps['CostToAgent'] * $this->CurrencyRate),
					"OfferedFare" => $arrMarkUps['intOfferedFare'],
					"CommissionEarned" => $CommissionEarned,
					"PLBEarned" => $PLBEarned,
					"IncentiveEarned" => $IncentiveEarned,
					"TdsOnCommission" => $TdsOnCommission,
					"TdsOnPLB" => $TdsOnPLB,
					"TdsOnIncentive" => $TdsOnIncentive,
					"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
					"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
					"PriceID" => $strTraceId,
					"ApiResultIndex" => $ResultIndex,
					"IsGSTRequired" => $IsGSTMandatory,
					"fareIdentifier" => $ResultFareType,
					"FareClass" => $FlightClass,
					"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" => $arrFareBreakdown,
					"arrMarkUps" => $arrMarkUps,
				);
				if (count($result['Segments'][0]) > 1) {
					$SegmentsCount = count($result['Segments'][0]);
					$OriginStopCount = $SegmentsCount - 1;
				} else {
					$OriginStopCount = '0';
				}
				if (count($result['Segments'][1]) > 1) {
					$SegmentsCountDe = count($result['Segments'][1]);
					$DestinationStopCount = $SegmentsCountDe - 1;
				} else {
					$DestinationStopCount = '0';
				}
				if ($OriginStopCount == 0) {
					$OrStopCountTxt = "Non-stop";
				} else {
					$OrStopCountTxt = $OriginStopCount . " Stop(s)";
				}
				if ($DestinationStopCount == 0) {
					$DeStopCountTxt = "Non-stop";
				} else {
					$DeStopCountTxt = $DestinationStopCount . " Stop(s)";
				}
				//                echo $DestinationStopCount;
				if ($result['IsRefundable']) {
					$IsRefundableTxt = 'Refundable';
				} else {
					$IsRefundableTxt = 'Non Refundable';
				}
				$Refundable = ($result['IsRefundable']) ? 1 : 0;

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

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


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

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

						$strAirlineCode = $segmentsResult['Airline']['AirlineCode'];
						$AirlineName = $segmentsResult['Airline']['AirlineName'];
						$FlightNumber = $segmentsResult['Airline']['FlightNumber'];
						$FareClass = $segmentsResult['Airline']['FareClass'];
						$FareClassArr[] = $FareClass;
						$SegFlightNumber = $strAirlineCode . "-" . $FlightNumber;

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

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

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

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

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

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

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

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

						);
					}
				}

				$classOfBooking = implode(',', $FareClassArr);
				$arrFairRules[0]['classOfBooking'] = $classOfBooking;
				$arrFairRules[0]['FareClass'] = $FlightClass;
				$arrFairRules[0]['IsRefundableTxt'] = $IsRefundableTxt;
				$arrFairRules[0]['SeatAvailable'] = $NoOfSeatAvailable;
				$OriFlyingMinutes = ($AccumulatedDuration);

				$OriFlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($OriFlyingMinutes);
				// FOR RETURN TRIP SEGMENT
				$AccumulatedDurationD = 0;
				$arrDestinationSegments = [];
				$DestSegFlightNumberArr = [];
				if (count($result['Segments'][1]) > 0) {
					$FlyingMinutes = 0;
					$countSeg = count($result['Segments'][1]);
					foreach ($result['Segments'][1] as $kkk => $segmentsResult1) {
						if ($countSeg >= 2) {
							$AccumulatedDurationD += isset($segmentsResult1['AccumulatedDuration']) ? $segmentsResult1['AccumulatedDuration'] : (0);
						} else {
							$AccumulatedDurationD += ($segmentsResult1['Duration'] + $segmentsResult1['GroundTime']);
						}
						$FlyingMinutes = $FlyingMinutes + (isset($segmentsResult1['AccumulatedDuration']) ? $segmentsResult1['AccumulatedDuration'] : ($segmentsResult1['Duration'] + $segmentsResult1['GroundTime']));
						$LAYOVERMinutes = ((isset($segmentsResult1['GroundTime']) ? $segmentsResult1['GroundTime'] : 0));
						$DepTime = $segmentsResult1['Origin']['DepTime'];
						$ArrTime = $segmentsResult1['Destination']['ArrTime'];
						$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($LAYOVERMinutes);
						// FOR FLIGHT SEGMENTS.....
						//                        echo '<pre>';print_r($LAYOVERMinutes.'=='.$key.'=='.$DepData['Airline']['AirlineName']);echo '</pre>';
						$strBaggage = $segmentsResult1['Baggage'];
						$strCabinBaggage = $segmentsResult1['CabinBaggage'];
						if (!empty($strBaggage)) {
							$IsBaggage = 1;
						} else {
							$IsBaggage = 0;
						}
						if (!empty($strCabinBaggage)) {
							$strCabinBaggage = $strCabinBaggage;
						} else {
							$strCabinBaggage = '0 KG';
						}
						$TripIndicator = $segmentsResult1['TripIndicator'];
						$SegmentIndicator = $segmentsResult1['SegmentIndicator'];

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

						$SegFlightNumber = $strAirlineCode . "-" . $FlightNumber;
						$DestSegFlightNumberArr[] = $SegFlightNumber;
						$DepTerminal = $segmentsResult1['Origin']['Airport']['Terminal'];
						if (!empty($DepTerminal)) {
							$DepTerminal = $DepTerminal;
						} else {
							$DepTerminal = 0;
						}
						$ArrTerminal = $segmentsResult1['Destination']['Airport']['Terminal'];
						if (!empty($ArrTerminal)) {
							$ArrTerminal = $ArrTerminal;
						} else {
							$ArrTerminal = 0;
						}

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

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

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

						$strAirlineCodeLogo = $strAirlineCode;

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

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

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

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

				$airlineSysId = !empty($arrAirlineList[$DepData['Airline']['AirlineCode']]) ? $arrAirlineList[$DepData['Airline']['AirlineCode']] : '0';
				$DeFlyingMinutes = ($AccumulatedDurationD);
				$DesFlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($DeFlyingMinutes);

				//                echo '<pre>';print_r(count($arrDestinationSegments).'=='.$key.'=='.$DepData['Airline']['AirlineName']);echo '</pre>';
				//                echo '<pre>';print_r(count($arrDestinationSegments).'=='.$key);echo '</pre>'; FlightDuration
				$arrInsertFlightData[$key]['origin']['FlightNumber'] = $DepData['Airline']['FlightNumber'];
				$arrInsertFlightData[$key]['origin']['AirlineName'] = $strAirlineName = $DepData['Airline']['AirlineName'];
				$arrInsertFlightData[$key]['origin']['AirlineCode'] = $AirlineCode = $DepData['Airline']['AirlineCode'];
				$arrInsertFlightData[$key]['origin']['FareClass'] = $AirlineCode = $DepData['Airline']['FareClass'];
				$arrInsertFlightData[$key]['origin']['OrFlightNumber'] = $OrFlightNumber;
				$arrInsertFlightData[$key]['origin']['SegFlightNumberArr'] = implode(', ', $SegFlightNumberArr);
				$arrInsertFlightData[$key]['origin']['Currency'] = $Currency;
				$arrInsertFlightData[$key]['origin']['ResultIndex'] = $ResultIndex;
				$arrInsertFlightData[$key]['origin']['IsLCC'] = $result['IsLCC'];
				$arrInsertFlightData[$key]['origin']['IsGSTMandatory'] = $IsGSTMandatory;
				$arrInsertFlightData[$key]['origin']['IsRefundable'] = $result['IsRefundable'];
				$arrInsertFlightData[$key]['origin']['IsRefundableTxt'] = $IsRefundableTxt;
				$arrInsertFlightData[$key]['origin']['AirlineSysId'] = $airlineSysId;
				$arrInsertFlightData[$key]['origin']['DepatureDate'] = date('d M Y', strtotime($strDepatureDate));
				$arrInsertFlightData[$key]['origin']['DepartureDateTxt'] = date('D, d M', strtotime($strDepatureDate));
				$arrInsertFlightData[$key]['origin']['DepartureTime'] = $OrDepTime;
				$arrInsertFlightData[$key]['origin']['ArrivalTime'] = $OrArrTime;
				$arrInsertFlightData[$key]['origin']['SourceAirportCode'] = $DepOrigin['Airport']['AirportCode'];
				$arrInsertFlightData[$key]['origin']['SourceCityName'] = $DepOrigin['Airport']['CityName'];
				$arrInsertFlightData[$key]['origin']['DestAirportCode'] = $DepDestination['Airport']['AirportCode'];
				$arrInsertFlightData[$key]['origin']['DestCityName'] = $DepDestination['Airport']['CityName'];
				$arrInsertFlightData[$key]['origin']['StopCount'] = $OrStopCountTxt;
				$arrInsertFlightData[$key]['origin']['NoOfSeatAvailable'] = $DepData['NoOfSeatAvailable'];
				$arrInsertFlightData[$key]['origin']['TotalFlightMembers'] = $intMemberCount;
				$arrInsertFlightData[$key]['origin']['FlyingMinutes'] = $OriFlyingMinutes;
				$arrInsertFlightData[$key]['origin']['FlightDuration'] = $OriFlightDuration;
				$arrInsertFlightData[$key]['origin']['JourneyType'] = $intJourneyType;
				$arrInsertFlightData[$key]['origin']['TripType'] = $intTripType;
				$arrInsertFlightData[$key]['origin']['IsInternational'] = $interNationalSearch;
				$arrInsertFlightData[$key]['origin']['ICSourceSysId'] = 3;
				$arrInsertFlightData[$key]['origin']['logo'] = $OrifilePath;
				$arrInsertFlightData[$key]['origin']['Segments'] = $arroOriginSegments;

				$airlineSysId = !empty($arrAirlineList[$ArrData['Airline']['AirlineCode']]) ? $arrAirlineList[$ArrData['Airline']['AirlineCode']] : '0';
				$arrInsertFlightData[$key]['destination']['FlightNumber'] = $ArrData['Airline']['FlightNumber'];
				$arrInsertFlightData[$key]['destination']['AirlineName'] = $ArrData['Airline']['AirlineName'];
				$arrInsertFlightData[$key]['destination']['SegFlightNumberArr'] = implode(', ', $DestSegFlightNumberArr);
				$arrInsertFlightData[$key]['destination']['DeFlightNumber'] = $DeFlightNumber;
				$arrInsertFlightData[$key]['destination']['Currency'] = $Currency;
				$arrInsertFlightData[$key]['destination']['ResultIndex'] = $ResultIndex;
				$arrInsertFlightData[$key]['destination']['IsLCC'] = $result['IsLCC'];
				$arrInsertFlightData[$key]['destination']['IsGSTMandatory'] = $IsGSTMandatory;
				$arrInsertFlightData[$key]['destination']['IsRefundable'] = $result['IsRefundable'];
				$arrInsertFlightData[$key]['destination']['IsRefundableTxt'] = $IsRefundableTxt;
				$arrInsertFlightData[$key]['destination']['AirlineSysId'] = $airlineSysId;
				$arrInsertFlightData[$key]['destination']['ReturnDate'] = date('d M Y', strtotime($strReturnDate));
				$arrInsertFlightData[$key]['destination']['DepartureDateTxt'] = date('D, d M', strtotime($strReturnDate));
				$arrInsertFlightData[$key]['destination']['DepartureTime'] = $DeDepTime;
				$arrInsertFlightData[$key]['destination']['ArrivalTime'] = $DeArrTime;
				$arrInsertFlightData[$key]['destination']['SourceAirportCode'] = $ArrOrigin['Airport']['AirportCode'];
				$arrInsertFlightData[$key]['destination']['SourceCityName'] = $ArrOrigin['Airport']['CityName'];
				$arrInsertFlightData[$key]['destination']['DestAirportCode'] = $ArrDestination['Airport']['AirportCode'];
				$arrInsertFlightData[$key]['destination']['DestCityName'] = $ArrDestination['Airport']['CityName'];
				$arrInsertFlightData[$key]['destination']['StopCount'] = $DeStopCountTxt;
				$arrInsertFlightData[$key]['destination']['NoOfSeatAvailable'] = $ArrData['NoOfSeatAvailable'];
				$arrInsertFlightData[$key]['destination']['TotalFlightMembers'] = $intMemberCount;
				$arrInsertFlightData[$key]['destination']['FlyingMinutes'] = $DeFlyingMinutes;
				$arrInsertFlightData[$key]['destination']['FlightDuration'] = $DesFlightDuration;
				$arrInsertFlightData[$key]['destination']['JourneyType'] = $intJourneyType;
				$arrInsertFlightData[$key]['destination']['TripType'] = $intTripType;
				$arrInsertFlightData[$key]['destination']['IsInternational'] = $interNationalSearch;
				$arrInsertFlightData[$key]['destination']['ICSourceSysId'] = 3;
				$arrInsertFlightData[$key]['destination']['logo'] = $DesfilePath;
				$arrInsertFlightData[$key]['destination']['Segments'] = $arrDestinationSegments;

				$arrInsertFlightData[$key]['FlightNumber']  = $DepData['Airline']['FlightNumber'];
				$arrInsertFlightData[$key]['AirlineCode']  = $DepData['Airline']['AirlineCode'];
				$arrInsertFlightData[$key]['AirlineSysId'] = $airlineSysId;
				$arrInsertFlightData[$key]['SourcePlaceSysId'] = $arrCommonInsVariables['intSourceCityId'];
				$arrInsertFlightData[$key]['DestPlaceSysId'] = $arrCommonInsVariables['intDestinationCityId'];
				$arrInsertFlightData[$key]['SourceAirportCode'] = $arrCommonInsVariables['strSourceAirportCode'];
				$arrInsertFlightData[$key]['DestAirportCode']   = $arrCommonInsVariables['strDestinationAirportCode'];
				$arrInsertFlightData[$key]['SourcePlaceName'] = $sourceCityText[0];
				$arrInsertFlightData[$key]['DestPlaceName'] = $destinationCityText[0];
				$arrInsertFlightData[$key]['PublishedFare'] = $intPublishedFare; // As Discussed with GG
				$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format($intPublishedFare);
				$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
				$arrInsertFlightData[$key]['IsTJFlightAPI'] = $this->IsTJFlightAPI;
				$arrInsertFlightData[$key]['strFlightRoute'] = $strFlightRoute;
				$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
				$arrInsertFlightData[$key]['IsLCC'] = $result['IsLCC'];
				$arrInsertFlightData[$key]['LocalFromTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? $arrCommonInsVariables['localFromDateTime'] : '';
				$arrInsertFlightData[$key]['FromUTCTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? $arrCommonInsVariables['localFromDateTime'] : '';
				$arrInsertFlightData[$key]['LocalToTime'] = isset($arrCommonInsVariables['localToDateTime']) ? $arrCommonInsVariables['localToDateTime'] : '';
				$arrInsertFlightData[$key]['ToUTCTime'] = isset($arrCommonInsVariables['localToDateTime']) ? $arrCommonInsVariables['localToDateTime'] : '';
				$arrInsertFlightData[$key]['IsGSTMandatory'] = $IsGSTMandatory;
				$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
				$arrInsertFlightData[$key]['SearchTraceId'] = $FlightTraceId;
				$arrInsertFlightData[$key]['FlightClass'] = $FlightClass;
				$arrInsertFlightData[$key]['FairRules'] = $arrFairRules;
				$arrInsertFlightData[$key]['StopCount'] = $OrStopCountTxt;
				$arrInsertFlightData[$key]['AirlineName'] = $strAirlineName;
				$arrInsertFlightData[$key]['IsRefundable'] = $Refundable;
				$arrInsertFlightData[$key]['IsBagIncludes'] = $IsBagIncludes;
				$arrInsertFlightData[$key]['IsRefundableTxt'] = $IsRefundableTxt;
				$arrInsertFlightData[$key]['FlyingMinutes'] = ($OriFlyingMinutes + $DeFlyingMinutes);
				$arrInsertFlightData[$key]['DepartureTime'] = $OrDepTime;
				$arrInsertFlightData[$key]['ArrivalTime'] = $OrArrTime;
				$arrInsertFlightData[$key]['ICSourceSysId'] = 3;
				$arrInsertFlightData[$key]['Segments'] = $arrSegments;

				///$InternationalData['FairRules'] = $arrFairRules;

				$arrInsertFlightData[$key]['InternationalData'] = $apiResponse['InterNationalFlightResults'][$key];
				$arrInsertFlightData[$key]['arrCommonInsVariables'] = $arrCommonInsVariables;


				$AttPriceRange[] = $intPublishedFare;
				$arrAirlineName[] = $AirlineCode . '-' . $strAirlineName;
				$FiltStopCount[] = $OrStopCountTxt;
				$DesFiltStopCount[] = $DeStopCountTxt;
				$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $OrDepTime);
				// echo '<pre>';print_r($DeDepTime);echo '<br>';
				// echo '<pre>';print_r($FilterDepartureDtTime);
				$arrInsertFlightData[$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
				//                $arrInsertFlightData[$key] = $result;

			}

			$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 getlogsAction()
	{
		$this->_helper->layout->disableLayout();
		$this->_helper->viewRenderer->setNoRender(true);
		$param = $this->getRequest()->getParams();
		$folder = isset($param['folder']) ? $param['folder'] : '';

		if (!empty($folder)) {
			$file_folder = $_SERVER["DOCUMENT_ROOT"] . "/public/logs/flight/" . $folder . '/';
		} else {
			$file_folder = $_SERVER["DOCUMENT_ROOT"] . "/public/logs/flight/";
		}
		$file_folder_2 = scandir($file_folder, 1);
		//echo '<pre>';print_r($file_folder_2);echo '</pre>';
		//$file_folder = $_SERVER["DOCUMENT_ROOT"] . "/public/logs/flight/FlightSearch/"; // folder to load files
		if (is_dir($file_folder)) {
			if ($file_folder_2) {
				foreach ($file_folder_2 as $file) {
					if (!empty($folder)) {
						echo "file name:<a target='_blank' href='" . $this->baseUrl . "/public/logs/flight/" . $folder . "/" . $file . "'>" . $file . "</a><br>";
					} else {
						echo "Folder name:<a href='" . $this->baseUrl . "/flight/getlogs/folder/" . $file . "/'>" . $file . "</a><br>";
					}
				}
			}
		}
	}
	public function GetSubmitAmendmentSeriesFare($param)
	{
		$AmendmentRequestData = new Zend_Session_Namespace('AmendmentRequestData');
		$data = $AmendmentRequestData->params;
		$isCancelType = (isset($data['isCancelType']) && $data['isCancelType'] != '') ? $data['isCancelType'] : 1;
		$bookingId_TJ = $param['bookingId'];
		$bookingId = $param['bookingId'];
		$IsSeriesFareData = $param['IsSeriesFareData'];
		$requestType = $param['requestType'];
		$requestTypeValue = $param['requestTypeValue'];
		$PaxDetails = $param['PaxDetails'];
		$TPPaxSysId = $param['TPPaxSysId'];
		$strUrlData = $param['strUrlData'];
		$cRemarks = $param['cRemarks'];
		$sectorsSelectors = array_unique($param['sectorsSelectors']);
		$sectorsDates = ($param['sectorsDates']);
		$nameData = implode('<br>', $param['nameData']);
		$sectors = implode('<br>', $param['sectorsSelectors']);
		$objFlight = new Travel_Model_FlightMaster();
		$FlightBooking = $objFlight->FlightBookingDataTripJack('tbl_flight_booking', $param['strUrlData'], 1);
		$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetSubmitAmendmentSeriesFare($data, $FlightBooking);
		$intChangeRequestStatus = $ChangeResponse['status']['success'];
		$strErrorMessage = $ChangeResponse['errors'][0]['message'];

		$FlightQueryids = json_decode($FlightBooking['data']['FlightQueryids'], true);
		$MasterTPSysId = $FlightQueryids['arrIds']['MasterTPSysId'];
		$TPSysId = $FlightQueryids['arrIds']['TPSysId'];
		$VersionId = $FlightQueryids['arrIds']['VersionId'];
		$passenger = $FlightBooking['passenger'];

		if (empty($PaxDetails)) {
			foreach ($passenger as $key => $val) {
				$PaxDetails[] = trim($val['FirstName']) . '-' . trim($val['LastName']);
			}
		}

		if ($intChangeRequestStatus == 1) {
			try {
				$dataModification = array(
					"ChangeRequestId" => $ChangeResponse['amendmentId'],
					"ChangeRequestStatus" => 1,
					"AgencySysId" => $this->gtxagencysysid,
					"MasterTPSysId" => $this->MasterAgencySysId,
					"BookingId" => $bookingId_TJ,
					"RequestType" => $requestTypeValue,
					"Remarks" => $cRemarks,
					"servicefee" => 0,
					"RefundMode" => 'Cash',
					"status" => 19,
					"refundedamount" => $ChangeResponse['RefundAmount'],
					"apiTraceId" => $strUrlData,
					"RequestData" => json_encode($data),
					"APIResponseData" => json_encode($ChangeResponse),
					"created_at" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
					"updated_at" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
				);
				$ModificationId  = $objFlight->InsertFlightData('tb_flight_modification', $dataModification);
				if ($sectorsSelectors) {
					foreach ($sectorsSelectors as $sc) {
						$sec = explode('-', $sc);
						$whereArrayflight = array(
							'SourceAirportCode=?' => $sec[0],
							'DestAirportCode=?' => $sec[1],
							'apiTraceId=?' => $strUrlData
						);
						$update = array(
							"ChangeRequestId" => ($ChangeResponse['amendmentId']),
							"status" => ($isCancelType == 2) ? 22 : 9,
							"ChangeRequestStatus" => $requestType,
							"ChangeRequestRes" => json_encode($ChangeResponse),
						);
						$this->objMdl->rv_update('tbl_flight_booking', $update, $whereArrayflight);
					}
				}

				if ($PaxDetails) {
					foreach ($PaxDetails as $pax) {
						$PaxDetailsEX = explode('-', $pax);
						$whereArray = array(
							'FirstName=?'    =>  $PaxDetailsEX[0],
							'LastName=?'    =>  $PaxDetailsEX[1],
							'apiTraceId=?'    =>  $strUrlData
						);
						$updatePax = array(
							"ChangeRequestId" => $ChangeResponse['amendmentId'],
							"ChangeRequestRes" => json_encode($ChangeResponse),
							"ChangeRequestStatus" => 1,
						);
						$this->objMdl->rv_update('tbl_flight_booking_customer', $updatePax, $whereArray);
					}
				}

				$postFieldArray = array(
					'PaxDetails' => json_encode($PaxDetails),
					'MasterTPSysId' => $MasterTPSysId,
					'TPSysId' => $TPSysId,
					'StatusType' => ($isCancelType == 2) ? 71 : 19,
					'ChangeRequestId' => $ChangeResponse['amendmentId'],
					'ChangeRequestStatus' => 1,
					'ChangeRequestRes' => json_encode($ChangeResponse),
					'dataModification' => json_encode($dataModification),
					"AgentSysId" => $this->_session->data['UserSysId'],
					"AgencySysId" => $this->_session->data['MasterAgencySysId'],
					'B2BAgencySysIdKey' => $this->_session->data['SecurityKey'],
					'B2CAgencySysIdKey' => SECURITYKEY,
				);
				//echo "<pre>";print_r($postFieldArray);die;
				$model = new Gtxwebservices_Model_Webservices();
				$result = $model->updateFlightCancellationRefund($postFieldArray);
				$response = json_decode($result, 1);
				$status = $response['status'];
				$TransactionId = $response['TransactionId'];
				if ($status == true) {
					$response = array('success' => true, 'refundid' => $TransactionId, 'msg' => 'Refund submit successfully', 'redirect' => true);
					echo json_encode($response);
					exit;
				} else {
					$response = array('success' => false, 'message' => 'Unable to submit refund. please try again.');
					echo json_encode($response);
					exit;
				}
			} catch (Exception $error) {
				print_r($error->getMessage());
				exit;
			}
		} else {
			$strMsg = "Oops! Your booking Can'nt be cancel right now please try again latter, Please contact administrator for more details";
			$redirect = false;
			$response = array('success' => true, 'msg' => $strMsg, 'redirect' => $redirect);
			echo json_encode($response);
			exit;
		}
	}



	public function migratebookflightAction()
	{
		//error_reporting(1);
		//die('booking disabled. live api running now.');
		$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);
		//echo '<pre>';print_r($arrUrlData);die;
		$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->genrateFlightQuery = $FlightQueryids = $arrUrlData['genrateFlightQuery'];
			$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->route = $route = isset($sessionFlightSearchParams['route']) ? $sessionFlightSearchParams['route'] : 0;
			$this->view->totalPaxCount = $adultCount + $childCount + $infantCount;
			$WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyWallaetBalance($this->SecurityKey);
			$this->view->WalletBalance = ($WallaetBalance['status'] == 1) ? $WallaetBalance['creditBalance'] : 0;
			$this->view->B2BType = $this->_session->B2BType;
			$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;
			$paymentMode = isset($arrUrlData['paymentMode']) ? $arrUrlData['paymentMode'] : 0;
			$post = isset($arrUrlData['post']) ? $arrUrlData['post'] : '';
			$apiData = isset($arrUrlData['apiData']) ? $arrUrlData['apiData'] : '';
			$CustomerSysId = isset($arrUrlData['CustomerSysId']) ? $arrUrlData['CustomerSysId'] : 0;
			$_sessiondata = isset($arrUrlData['_sessiondata']) ? $arrUrlData['_sessiondata'] : 0;
			$UserSysId = $_sessiondata['UserSysId'];
			$AgencySysId = $_sessiondata['AgencySysId'];
			$MasterAgencySysId = $_sessiondata['MasterAgencySysId'];

			$CheckPaymentSTatus = $objFlight->CheckPaymentSTatus('tbl_flight_booking', $strUrlData);
			$paymentStatus = isset($CheckPaymentSTatus['paymentStatus']) ? $CheckPaymentSTatus['paymentStatus'] : 0;
			$status = isset($CheckPaymentSTatus['status']) ? $CheckPaymentSTatus['status'] : 0;
			$bookingId_check = isset($FlightBookingData[0]['bookingId']) ? $FlightBookingData[0]['bookingId'] : 0;
			// echo "<pre>";
			// print_r($arrUrlData);
			if (empty($flight_booking_id)) {
				die('flight_booking_id not available.');
			}
			if ($paymentStatus == 1 && $status == 1) {
				die('Booking already success');
			}

			if ($bookingId_check == '0') {
				die('Booking id not available');
			}
			// echo "<pre>";
			// print_r($FlightBookingData);die('w');
			$mytrip_city_from = $sessionFlightSearchParams['from_city'][0];
			$mytrip_city_to = $sessionFlightSearchParams['to_city'][0];
			if ($route == 1) {
				$sectorTitle = $mytrip_city_from . '-' . $mytrip_city_to;
			} else {
				$sectorTitle = $mytrip_city_from . '-' . $mytrip_city_to . '-' . $mytrip_city_from;
			}
			if ($FlightBookingData) {

				$this->_helper->layout->disableLayout();
				$this->_helper->viewRenderer->setNoRender(true);

				$IsSeriesFareData = isset($FlightBookingData[0]['IsSeriesFareData']) ? $FlightBookingData[0]['IsSeriesFareData'] : 0;
				$OnwardAutoTicket = isset($FlightBookingData[0]['OnwardAutoTicket']) ? $FlightBookingData[0]['OnwardAutoTicket'] : 1;
				$BookingdataAPI = array(
					'FlightBookingData' => $FlightBookingData,
					'IsInternational' => $FlightBookingData[0]['IsInternational'],
					'CustomerSession' => $ForCustomerSession,
					'SelectedBaggSessionNew' => $arrUrlData['SelectedBaggSessionNew'],
					'SelectedMealSessionNew' => $arrUrlData['SelectedMealSessionNew'],
					'selectedSeatSession' => $arrUrlData['selectedSeatSession'],
					'SearchTraceId' => $arrUrlData['SearchTraceId'],
				);
				if ($IsSeriesFareData == 1) {
					$Bookres = [
						'status' => array('success' => true),
					];
				} else {
					if ($this->IsTJFlightAPI) {
						$Bookres = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightTicketTripJack($BookingdataAPI);
					} elseif ($IsSeriesFareData == 0) { //// TBO booking condition by sabir noor
						try {
							$IsLCC = false;
							// if ($paymentMode == 3 || $paymentMode == 2) {
							// 	$DebitFromWallet = $this->DebitFromWallet($arrUrlData);
							// 	$TransactionId = isset($DebitFromWallet['TransactionId']) ? $DebitFromWallet['TransactionId'] : '';
							// }
							// GTX Data pushing
							$model = new Gtxwebservices_Model_Webservices();
							$result = $model->CreateCustomer($apiData);
							$apiCustomer = json_decode($result, true);
							if ($apiCustomer['status'] == 1) {
								$arrCustomer['GTX_customerSysId'] = $apiCustomer['Message'];
								$where = "CustomerSysId = " . $CustomerSysId;
								$objFlight->UpdateFlightData('tbl_customer', $arrCustomer, $where);
							}
							$FlightQueryids = $this->genrateFlightQuery($post);

							// echo "<pre>";
							// print_r($FlightQueryids);
							// die;
							$strFilePath = "flight/FlightQueryids/" . time() . "_response.json";
							Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($FlightQueryids));
							$queryStatus = isset($FlightQueryids['status']) ? $FlightQueryids['status'] : 0;
							$MasterTPSysId = $FlightQueryids['arrIds']['MasterTPSysId'];
							$TPSysId = $FlightQueryids['arrIds']['TPSysId'];
							$VersionId = $FlightQueryids['arrIds']['VersionId'];
							$TrxId = $FlightQueryids['arrIds']['TrxId'];

							if ($FlightBookingData) {
								$FlightBookingTicketArr = [];
								foreach ($FlightBookingData as $k => $value) {
									$BookingdataAPI = array(
										'FlightBookingData' => $value,
										'sessionFlightSearchParams' => $sessionFlightSearchParams,
										'CustomerSession' => $ForCustomerSession,
										'SelectedBaggSessionNew' => $arrUrlData['SelectedBaggSessionNew'],
										'SelectedMealSessionNew' => $arrUrlData['SelectedMealSessionNew'],
										'selectedSeatSession' => $arrUrlData['selectedSeatSession'],
									);
									if ($value['IsLCC'] == 1) {
										$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightTicket($BookingdataAPI);
									} else {
										$IsLCC = true;
										$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightBooking($BookingdataAPI);
									}

									// $str = file_get_contents($this->baseUrl . '/public/logs/flight/BookingDetails/FlightBooking_response.json');
									// $response = json_decode($str, true);
									// echo "<pre>";
									// print_r($response);
									// die;
									$FlightBookingTicketArr[] = $response;
									$ResponseStatus = isset($response['Response']['ResponseStatus']) ? $response['Response']['ResponseStatus'] : '0';
									$apiTraceId = isset($response['Response']['TraceId']) ? $response['Response']['TraceId'] : '0';
									$ErrorCode = isset($response['Response']['Error']['ErrorCode']) ? $response['Response']['Error']['ErrorCode'] : '0';
									$ErrorMessage = isset($response['Response']['Error']['ErrorMessage']) ? $response['Response']['Error']['ErrorMessage'] : '';
									$strBookingIdLCC = isset($response['Response']['Response']['BookingId']) ? $response['Response']['Response']['BookingId'] : '';
									$strTicketPNRLCC = isset($response['Response']['Response']['PNR']) ? $response['Response']['Response']['PNR'] : '';
									$Passenger = isset($response['Response']['Response']['FlightItinerary']['Passenger']) ? $response['Response']['Response']['FlightItinerary']['Passenger'] : '';
									$statusType = 1;
									if ($OnwardAutoTicket == 0 && $IsSeriesFareData == 1) {
										$statusType = 20;
									}

									if ($ResponseStatus == 1) {
										$update = array(
											'API_Response' => json_encode($value),
											'API_Response_Ticket' => json_encode($response),
											'FlightQueryids' => json_encode($FlightQueryids),
											'PNR_Number' => $strTicketPNRLCC,
											'BookingId' => $strBookingIdLCC,
											'APIBookingId' => $strBookingIdLCC,
											'MasterTPSysId' => $MasterTPSysId,
											'TPSysId' => $TPSysId,
											'status' => $statusType,
										);

										if ($paymentMode == 3 || $paymentMode == 2) {
											$update['TransactionId_debit'] = $TransactionId;
										}

										$Amount = $value['FairRules']['OfferedFare'];
										$NetAmount = $value['FairRules']['PublishedFare'];

										$where = "id = " . $flight_booking_id[$k]; //exit;
										$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
										$responseArray = array(
											'value' => $value,
											'response' => $response
										);
										$postFieldArray = array(
											'MasterTPSysId' => $MasterTPSysId,
											'TPSysId' => $TPSysId,
											'TrxId' => $TrxId,
											'VersionId' => $VersionId[$k],
											'XRefBookingId' => $strBookingIdLCC . '/' . $strTicketPNRLCC,
											'APIBookingRes' => json_encode($responseArray),
											'Passenger' => json_encode($Passenger),
											'ErrorCode' => 0,
											'IsBookingStatus' => 1,
											'sectorTitle' => $sectorTitle,
											'Amount' => $Amount,
											'NetAmount' => $NetAmount,
										);
										$strFilePath = "flight/updateFlightBookingDetails/" . time() . "_update_request.json";
										Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($postFieldArray));

										$model = new Gtxwebservices_Model_Webservices();
										$result = $model->updateFlightBookingB2B($postFieldArray);

										$segment = [];
										if ($value['Segments']) {
											foreach ($value['Segments'] as $seg) {
												$originAirportCode = $seg['originAirportCode'];
												$destinationAirportCode = $seg['destinationAirportCode'];
												$segment[] = $originAirportCode . '-' . $destinationAirportCode;
											}
										}
										if ($Passenger) {
											foreach ($Passenger as $pk => $pax) {

												$TicketId = $pax['Ticket']['TicketId'];
												$TicketNumber = $pax['Ticket']['TicketNumber'];

												$updatep = array(
													'PNR_Number' => $strTicketPNRLCC,
													'TicketId' => $TicketId,
													'TicketNumber' => $TicketNumber,
													'sectors' => implode('-', $segment),
													'BookingId' => $strBookingIdLCC,
													'APIBookingId' => $strBookingIdLCC,
												);

												$wherep = "id = " . $booking_customer_id[$k][$pk];
												$objFlight->UpdateFlightData('tbl_flight_booking_customer', $updatep, $wherep);
											}
										}
										//if ($updated) {
										$responseReturn[$k] = array('success' => true, 'message' => $ErrorMessage, 'IsLCC' => $value['IsLCC']);
										//}
									} else {
										$update = array(
											'API_Response' => json_encode($response),
											'API_Response_Ticket' => '',
										);
										$where = "id = " . $flight_booking_id[$k]; //exit;
										$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
										$responseReturn[] = array('success' => false, 'message' => $ErrorMessage, 'IsLCC' => $value['IsLCC']);
									}
									// echo "<pre>";
									// print_r($response);
								}
								// echo "<pre>";
								// print_r($FlightBookingData);
								// die('ddddddd');
								if ($responseReturn && $ResponseStatus == 1) {
									$arrUrlData['FlightBookingTicketArr'] = $FlightBookingTicketArr;
									$arrUrlData['FlightQueryids'] = $FlightQueryids;
									$tempData = array(
										'TraceId' => $arrUrlData['SearchTraceId'],
										'json_data' => json_encode($arrUrlData),
									);
									$objFlight->deleteFlightTempData($arrUrlData['SearchTraceId']);
									$objFlight->insertFlightTempData($tempData);
									$Return = array('success' => true, 'message' => 'done', 'IsLCC' => $IsLCC, 'SearchTraceId' => $arrUrlData['SearchTraceId'], 'responseReturn' => $responseReturn);
									echo json_encode($Return);
									exit;
								} else {
									if ($paymentMode != 2 || $paymentMode != 3) {
										$CreditIntoWallet = $this->CreditIntoWallet($arrUrlData);
										$TransactionId = isset($CreditIntoWallet['TransactionId']) ? $CreditIntoWallet['TransactionId'] : '';
										if ($FlightBookingData) {
											foreach ($FlightBookingData as $k => $value) {
												$update['TransactionId_debit'] = $TransactionId;
												$where = "id = " . $flight_booking_id[$k]; //exit;
												$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
											}
										}
									}
									$arrUrlData['FlightBookingTicketArr'] = $FlightBookingTicketArr;
									$arrUrlData['FlightQueryids'] = $FlightQueryids;
									$arrUrlData['CreditIntoWallet'] = $CreditIntoWallet;
									$tempData = array(
										'TraceId' => $arrUrlData['SearchTraceId'],
										'json_data' => json_encode($arrUrlData),
									);
									$objFlight->deleteFlightTempData($arrUrlData['SearchTraceId']);
									$objFlight->insertFlightTempData($tempData);
									$Return = array('success' => false, 'message' => 'failed', 'IsLCC' => $IsLCC, 'SearchTraceId' => $arrUrlData['SearchTraceId']);
									echo json_encode($Return);
									exit;
								}
							}
						} catch (Exception $e) {
							echo $e->getMessage();
							exit;
						}
					}
				}

				$BookingerrCode = isset($Bookres['errors'][0]['errCode']) ? $Bookres['errors'][0]['errCode'] : 0;
				$BookId = isset($Bookres['errors'][0]['details']) ? $Bookres['errors'][0]['details'] : '';

				if ($BookingerrCode == '2502') {
					$checkExistBooking = $objFlight->checkExistBooking($BookId);
					if (!empty($checkExistBooking)) {
						$Bookres = [
							'bookingId' => $BookId,
							'status' => array('success' => true, 'httpStatus' => 200),
						];
					}
				}

				$Bookres['SearchTraceId'] = $arrUrlData['SearchTraceId'];
				$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingDetailsTripJack($Bookres);
				$OrderBookingStatus = isset($response['order']['status']) ? $response['order']['status'] : '';
				if ($IsSeriesFareData == 1) {
					$OrderBookingStatus = isset($response['order']['status']) ? $response['order']['status'] : 'SUCCESS';
				}
				// echo "<pre>";
				// print_r($OrderBookingStatus);
				// print_r($Bookres);

				$BookStatus = $Bookres['status']['success'];
				$BookErrorMessage = $Bookres['errors'][0]['message'];
				if ($BookStatus == 1 && $OrderBookingStatus != 'ABORTED') {
					// GTX Data pushing
					$model = new Gtxwebservices_Model_Webservices();
					$result = $model->CreateCustomer($apiData);
					$apiCustomer = json_decode($result, true);
					if ($apiCustomer['status'] == 1) {
						$arrCustomer['GTX_customerSysId'] = $apiCustomer['Message'];
						$where = "CustomerSysId = " . $CustomerSysId;
						$objFlight->UpdateFlightData('tbl_customer', $arrCustomer, $where);
					}
					$FlightQueryids = $this->genrateFlightQueryMigrate($post, $UserSysId, $AgencySysId, $MasterAgencySysId);

					// $genrateFlightQueryMigrate = new Zend_Session_Namespace('genrateFlightQueryMigrate');
					// $FlightQueryids = $genrateFlightQueryMigrate->params;
					// echo "<pre>";
					// print_r($FlightQueryids);

					$strFilePath = "flight/SearchParam/" . $strUrlData . "/FlightQueryids/" . time() . "_request.json";
					Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($post));
					$strFilePath = "flight/SearchParam/" . $strUrlData . "/FlightQueryids/" . time() . "_response.json";
					Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($FlightQueryids));
					$queryStatus = isset($FlightQueryids['status']) ? $FlightQueryids['status'] : 0;
					$MasterTPSysId = $FlightQueryids['arrIds']['MasterTPSysId'];
					$TPSysId = $FlightQueryids['arrIds']['TPSysId'];
					$VersionId = $FlightQueryids['arrIds']['VersionId'];
					$TrxId = $FlightQueryids['arrIds']['TrxId'];

					// GTX Data pushing end.
					if ($IsSeriesFareData == 1) {
						$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingDetailsSeriesFareNew($FlightBookingData, $ForCustomerSession);
						//echo '<pre>';print_r($response);die;
						// if ($paymentMode != 2 || $paymentMode != 3) {
						// 	$CheckSoldInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckSoldInventory($FlightBookingData[0]['bookingId']);
						// 	if ($route == 2 && isset($FlightBookingData[1]['bookingId'])) {
						// 		$CheckSoldInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckSoldInventory($FlightBookingData[1]['bookingId']);
						// 	}
						// }
					} else {
						$Bookres['SearchTraceId'] = $arrUrlData['SearchTraceId'];
						$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingDetailsTripJack($Bookres);
					}


					// if ($paymentMode == 3 || $paymentMode == 2) {
					// 	$DebitFromWallet = $this->DebitFromWallet($arrUrlData);
					// 	$TransactionId = isset($DebitFromWallet['TransactionId']) ? $DebitFromWallet['TransactionId'] : '';
					// }

					$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'] : '';
					// echo "<pre>";
					// print_r($response);

					if ($FlightBookingData) {
						foreach ($FlightBookingData as $k => $value) {
							$segggg = $value['SourceAirportCode'] . '-' . $value['DestAirportCode'];

							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;
								$OrderStatus = isset($response['order']['status']) ? $response['order']['status'] : '';
								$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';

								if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
									$strBookingIdLCC = isset($response['order']['bookingId'][$k]) ? $response['order']['bookingId'][$k] : '0';
								} else {
									$strBookingIdLCC = isset($response['order']['bookingId']) ? $response['order']['bookingId'] : '0';
								}
								$bookingId = str_replace('TJ', BOOKINGREF, $strBookingIdLCC);
								//$PNRNew = $strTicketPNRLCC[$segggg];
								$segment = [];
								$finalpnr = [];
								if ($value['Segments']) {
									foreach ($value['Segments'] as $seg) {
										$originAirportCode = $seg['originAirportCode'];
										$destinationAirportCode = $seg['destinationAirportCode'];
										$segment[] = $originAirportCode . '-' . $destinationAirportCode;
										$segment_t = $originAirportCode . '-' . $destinationAirportCode;
										//$PNRNew[] = $strTicketPNRLCC[$segment_t];
										$AirportCode = $originAirportCode . '-' . $destinationAirportCode;
										$finalpnr[] = isset($strTicketPNRLCC[$AirportCode]) ? $strTicketPNRLCC[$AirportCode] : '';
									}
								}
								$objFlight = new Travel_Model_FlightMaster();
								$statusType = 1;
								if ($OnwardAutoTicket == 0 && $IsSeriesFareData == 1) {
									$statusType = 20;
								}
								if ($ResponseStatus == 1) {
									$PNRNew = !empty($finalpnr) ? implode(',', $finalpnr) : '';
									try {
										$update = array(
											'API_Response' => json_encode($value),
											'API_Response_Ticket' => json_encode($response),
											'FlightQueryids' => json_encode($FlightQueryids),
											'PNR_Number' => $PNRNew,
											//'PNR_Number' => implode('-', $strTicketPNRLCC),
											'BookingId' => $bookingId,
											'APIBookingId' => $strBookingIdLCC,
											'MasterTPSysId' => $MasterTPSysId,
											'TPSysId' => $TPSysId,
											'status' => $statusType,
											//'OrderStatus' => $OrderStatus,
										);

										// if ($paymentMode == 3 || $paymentMode == 2) {
										// 	$update['TransactionId_debit'] = $TransactionId;
										// }


										$Amount = $value['FairRules']['BaseFare'];
										$NetAmount = $value['FairRules']['PublishedFare'];

										$where = "id = " . $flight_booking_id[$k]; //exit;
										$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);

										$responseArray = array(
											'value' => $value,
											'response' => $response
										);
										$postFieldArray = array(
											'MasterTPSysId' => $MasterTPSysId,
											'TPSysId' => $TPSysId,
											'TrxId' => $TrxId,
											'VersionId' => $VersionId[$k],
											'XRefBookingId' => $bookingId,
											'APIBookingRes' => json_encode($responseArray),
											'Passenger' => json_encode($Passenger),
											'ErrorCode' => 0,
											'IsBookingStatus' => 1,
											'sectorTitle' => $sectorTitle,
											'Amount' => $Amount,
											'NetAmount' => $NetAmount,
										);
										// $strFilePath = "flight/updateFlightBookingDetails/" . time() . "_update_request.json";
										// Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($postFieldArray));

										$strFilePath = "flight/SearchParam/" . $strUrlData . "/GTX/" . time() . "_update_request.json";
										Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($postFieldArray));

										$model = new Gtxwebservices_Model_Webservices();
										$result = $model->updateFlightBookingB2B($postFieldArray);

										$strFilePath = "flight/SearchParam/" . $strUrlData . "/GTX/" . time() . "_update_response.json";
										Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, ($result));
									} catch (Exception $error) {
										//echo $error->getMessage();
										$strFilePath = "flight/SearchParam/" . $strUrlData . "/errors/" . time() . "_request.json";
										Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($error->getMessage()));
										$Return = array('success' => false, 'message' => 'Sorry some errors has occured our end. Please note down reference number " ' . $bookingId . ' " for future use. we will contact you soon.');
										echo json_encode($Return);
										exit;
									}

									//die('dd');
									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' => $bookingId,
												'APIBookingId' => $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();
								$strFilePath = "flight/SearchParam/" . $strUrlData . "/errors/" . time() . "_request.json";
								Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($e->getMessage()));
								$Return = array('success' => false, 'message' => 'Sorry some errors has occured our end. Please note down reference number " ' . $bookingId . ' " for future use. for future use. we will contact you soon.');
								echo json_encode($Return);
								exit;
							}
						}

						// echo '<pre>';print_r($responseReturn);
						// echo '<pre>';print_r($ResponseStatus);
						// 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 {

					die('ABORTED');
					if ($paymentMode == 0) {
						$CreditIntoWallet = $this->CreditIntoWallet($arrUrlData);
						$TransactionId = isset($CreditIntoWallet['TransactionId']) ? $CreditIntoWallet['TransactionId'] : '';
						if ($FlightBookingData) {
							foreach ($FlightBookingData as $k => $value) {
								$update['TransactionId_debit'] = $TransactionId;
								$where = "id = " . $flight_booking_id[$k]; //exit;
								$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $update, $where);
							}
						}
					}
					$WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyWallaetBalance($this->SecurityKey);
					$sessionWallaetBalance = new Zend_Session_Namespace('sessionWallaetBalance');
					$sessionWallaetBalance->params = $WallaetBalance;
					//die('ss');
					$arrUrlData['FlightBookingTicketArr'] = $Bookres;
					$arrUrlData['CreditIntoWallet'] = $CreditIntoWallet;
					$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;
				}
			} else {
				die('Method Issue');
			}
		} else {
			$this->_redirect('flight');
		}
	}

	public function genrateFlightQueryMigrate($post, $UserSysId, $AgencySysId, $MasterAgencySysId)
	{

		$BookingData = !empty($post['intOutBoundId']) ? json_decode($post['intOutBoundId'], true) : 0;
		$sessionFlightSearchParams = !empty($post['sessionFlightSearchParams']) ? json_decode($post['sessionFlightSearchParams'], true) : 0;
		$SelectedBaggSessionNew = !empty($post['SelectedBaggSessionNew']) ? json_decode($post['SelectedBaggSessionNew'], true) : 0;
		$SelectedMealSessionNew = !empty($post['SelectedMealSessionNew']) ? json_decode($post['SelectedMealSessionNew'], true) : 0;
		$selectedSeatSession = !empty($post['selectedSeatSession']) ? json_decode($post['selectedSeatSession'], true) : 0;
		$FlightTraceId = $post['FlightTraceId'];
		$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'];
				}
			}
		}
		$MealFare = ($MealPrice);
		$BaggFare = ($BagPrice);
		$SeatFare = ($SeatPrice);

		$class = $sessionFlightSearchParams['class'];
		$interNationalSearch = $sessionFlightSearchParams['interNationalSearch'];
		$route = $sessionFlightSearchParams['route'];
		$departureDates = $sessionFlightSearchParams['departure_date'][0];
		$returnDate = $sessionFlightSearchParams['return_date'][0];
		if (!empty($departureDates)) {
			$arrDepartureDates = explode("/", $departureDates);
			$departureDatesAD = $arrDepartureDates[2] . "-" . $arrDepartureDates[1] . "-" . $arrDepartureDates[0];
		}

		$Segments_c = current($BookingData);
		$Segments_E = end($BookingData);
		$arrCurrentSegments1 = current($Segments_c['Segments']);
		$arrEndSegments1 = end($Segments_c['Segments']);

		$Mobile = $post['leadMobile'];
		$emailId = $post['leadEmail'];
		$adultCount = isset($sessionFlightSearchParams['adults']) ? $sessionFlightSearchParams['adults'] : 0;
		$childCount = isset($sessionFlightSearchParams['childs']) ? $sessionFlightSearchParams['childs'] : 0;
		$infantCount = isset($sessionFlightSearchParams['infants']) ? $sessionFlightSearchParams['infants'] : 0;

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

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

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

		//echo '<pre>';print_r($BookingData);die;
		if ($BookingData) {
			foreach ($BookingData as $k => $booking) {
				$finalFareSummary = $booking['FairRules'];
				$PublishedFare += $booking['FairRules']['PublishedFare'];
				$PublishedFareINT = $booking['FairRules']['PublishedFare'];
				//echo '<pre>';print_r($booking);echo '</pre>';
				// $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));
				$SeatPrice = 0;
				$BagPrice = 0;
				$MealPrice = 0;
				if ($booking['Segments']) {
					foreach ($booking['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'];
							}
						}
					}
				}
				$FareSummary[$k] = array(
					'PublishedFare' => ($PublishedFareINT + $BagPrice + $MealPrice + $SeatPrice),
					'AgentCommisionEarned' => $AgentCommisionEarnedINT,
					'AgentCommisionEarnedGST' => $AgentCommisionEarnedGSTINT,
					'AgencyMarkUp' => $AgencyMarkUpINT,
					'AgencyMarkUpGST' => $AgencyMarkUpGSTINT,
					'GTXMarkUp' => $GTXMarkUpINT,
					'BaseAmount' => ($BaseAmountINT + $BagPrice + $MealPrice + $SeatPrice),
					'MealPrice' => $MealPrice,
					'BagPrice' => $BagPrice,
					'SeatPrice' => $SeatPrice,
				);
			}
		}
		//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'] = (isset($departureDates) && $departureDates != '') ? $departureDates : date('d/m/Y', strtotime($departuredate));
		$roomjson[1]['returndate'] = $returnDate;
		$roomjson[1]['fromaircode'] = $oneway_origin_text;
		$roomjson[1]['toaircode'] = $oneway_destination_text;
		$roomjson[1]['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' => $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' => ($IsSeriesFareData == 1) ? 8 : 7,
			'roominfojson' => $RoomInfoJson,
			'AgentCommisionEarned' => $AgentCommisionEarned,
			'AgentCommisionEarnedGST' => $AgentCommisionEarnedGST,
			'AgencyMarkUp' => $AgencyMarkUp,
			'AgencyMarkUpGST' => $AgencyMarkUpGST,
			'GTXMarkUp' => $GTXMarkUp,
			'GTXMarkUpGST' => $GTXMarkUpGST,
			'BaseAmount' => ($BaseAmount + $BaggFare + $MealFare + $SeatFare),
			'PublishedFare' => ($PublishedFare + $BaggFare + $MealFare + $SeatFare),
			'MealFare' => $MealFare,
			'BaggFare' => $BaggFare,
			'SeatFare' => $SeatFare,
			'IsB2BQuery' => true,
			'B2BAgentSysId' => $UserSysId, //$this->_session->data['UserSysId'],
			'B2BAgencySysId' => $AgencySysId, //$this->_session->data['AgencySysId'],
			'leadsource' => 'Website B2B',
			'IsB2BProposal' => 1
		);
		if ($route == 4) {
			$this->IsTJFlightAPI = 1;
		}
		if ($this->IsTJFlightAPI == 0) {
			$sabirArray['ICSourceSysId'] = ($IsSeriesFareData == 1) ? 8 : 3;
		}
		// echo '<pre>';
		// print_r($sabirArray);
		// die;
		$model = new Gtxwebservices_Model_Webservices();
		$result = $model->genrateFlightQuery($sabirArray);
		$strFilePath = "flight/SearchParam/" . $FlightTraceId . "/FlightQueryids/" . time() . "_error.json";
		Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, ($result));
		$response = json_decode($result, true);
		print_r($result);
		Zend_Session::namespaceUnset('genrateFlightQueryMigrate');
		$genrateFlightQueryMigrate = new Zend_Session_Namespace('genrateFlightQueryMigrate');
		$genrateFlightQueryMigrate->params = $response;

		return $response;
	}
	public function CreditIntoWalletForFailSoldInventory($arrUrlData, $flight_booking_id, $FlightQueryids)
	{
		$objFlight = new Travel_Model_FlightMaster();
		$CreditIntoWallet = $this->CreditIntoWallet($arrUrlData);
		$TransactionId = isset($CreditIntoWallet['TransactionId']) ? $CreditIntoWallet['TransactionId'] : '';
		$updateB['TransactionId_debit'] = $TransactionId;
		$whereB = "id = " . $flight_booking_id; //exit;
		$updated = $objFlight->UpdateFlightData('tbl_flight_booking', $updateB, $whereB);
		$WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyWallaetBalance($this->SecurityKey);
		$sessionWallaetBalance = new Zend_Session_Namespace('sessionWallaetBalance');
		$sessionWallaetBalance->params = $WallaetBalance;
		$arrUrlData['FlightQueryids'] = $FlightQueryids;
		$arrUrlData['CreditIntoWallet'] = $CreditIntoWallet;
		$tempData = array(
			'TraceId' => $arrUrlData['SearchTraceId'],
			'json_data' => json_encode($arrUrlData),
		);
		$objFlight->deleteFlightTempData($arrUrlData['SearchTraceId']);
		$return = $objFlight->insertFlightTempData($tempData);
		return $return;
	}

	public function checkArrayKeyExist($arr)
	{
		$newArr = [];
		foreach ($arr as $key => $value) {
			if (strlen($arr[$key])) {
				$newArr[$key] = $value;
			}
		}
		return array_values(array_unique($newArr));
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit