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/modules/gtxwebservices/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/b2bzend/application/modules/gtxwebservices/models/Dynaminpackagexml.php
<?php

/* Zend Framework
 * @category   Zend
 * @package    Zend_Controller_Action
 * @copyright  Copyright (c) 2008-2014 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    1.0
 * @author     Ranvir singh <ranvir@catpl.co.in>
 * Create Date 06-09-2016
 * Update Date 06-09-2016
 * ************************************************************* */

class Gtxwebservices_Model_Dynaminpackagexml extends Zend_Db_Table_Abstract {

    function __construct() {
        $this->db = Zend_Db_Table::getDefaultAdapter();
    }

    public function __destruct() {
        $this->db->closeConnection();
    }

    public function getTC($SecurityKey) {
        $select = $this->db->select()->from(array("T1" => "TB_Agency"), array(""))
                ->joinLeft(array('T2' => "TB_Agency_Terms_Conditions"), "T1.AgencySysId = T2.AgencySysId")
                ->where("T1.SecurityKey =?", $SecurityKey);
        $result = $this->db->fetchAll($select);
        return $result;
    }

    public function createxml($packageId, $PackageCostCalType, $sCode) {
        $catTypeMaster = Catabatic_Helper::getPackCatType();
        $statusArray = array(1 => TRUE, 0 => FALSE);
        $OstatusArray = array(1 => FALSE, 0 => TRUE);
        $mealPlanType = array(1 => "HB", 2 => "FB", 3 => "AI", 4 => "RO", 5 => "BB", 6 => "CP", 7 => "MAP", 9 => "EP", 8 => "AP");
        $currentDate = date("Y-m-d");
        $finalResultSet = array();
        if ($PackageCostCalType == 1) {
            $statement = $this->db->query("GET_BYO_READYMADEPACKAGE_LOWESTCOST_FULLINFO $packageId");
        } else {
            $statement = $this->db->query("GET_BYO_READYMADEPACKAGE_LOWESTCOST_FULLINFO $packageId");
        }

        // Result set 1
        $resultSet1 = $statement->fetchAll();
        foreach ($resultSet1 as $row) {
            $finalResultSet['Result1'][] = $row;
        }
        // Result set 2
        $statement->nextRowSet(); // Advance to the second result set
        $resultSet2 = $statement->fetchAll();
        foreach ($resultSet2 as $row) {
            $finalResultSet['Result2'][] = $row;
        }
        // Result set 3
        $statement->nextRowSet(); // Advance to the third result set
        $resultSet3 = $statement->fetchAll();
        foreach ($resultSet3 as $row) {
            $finalResultSet['Result3'][] = $row;
        }
        // Result set 4
        $statement->nextRowSet(); // Advance to the third result set
        $resultSet4 = $statement->fetchAll();
        foreach ($resultSet4 as $row) {
            $finalResultSet['Result4'][] = $row;
        }
        // Result set 5
        $statement->nextRowSet(); // Advance to the third result set
        $resultSet5 = $statement->fetchAll();
        $finalResultSet['Result5'] = array();
        foreach ($resultSet5 as $row) {
            $finalResultSet['Result5'][] = $row;
        }
        // Result set 6
        $statement->nextRowSet(); // Advance to the third result set
        $resultSet6 = $statement->fetchAll();
        $finalResultSet['Result6'] = array();
        foreach ($resultSet6 as $row) {
            $finalResultSet['Result6'][] = $row;
        }
        // Result set 7
        $statement->nextRowSet(); // Advance to the third result set
        $resultSet7 = $statement->fetchAll();
        $finalResultSet['Result7'] = array();
        foreach ($resultSet7 as $row) {
            $finalResultSet['Result7'][] = $row;
        }
        // Result set 8
        $statement->nextRowSet(); // Advance to the third result set
        $resultSet8 = $statement->fetchAll();
        $finalResultSet['Result8'] = array();
        foreach ($resultSet8 as $row) {
            $finalResultSet['Result8'][] = $row;
        }
        // Result set 9
        $statement->nextRowSet(); // Advance to the third result set
        $resultSet9 = $statement->fetchAll();
        foreach ($resultSet9 as $row) {
            $finalResultSet['Result9'][] = $row;
        }
        // Result set 10
        $statement->nextRowSet(); // Advance to the third result set
        $resultSet10 = $statement->fetchAll();
        foreach ($resultSet10 as $row) {
            $finalResultSet['Result10'][] = $row;
        }
        // Result set 11
        $statement->nextRowSet(); // Advance to the third result set
        $resultSet11 = $statement->fetchAll();
        foreach ($resultSet11 as $row) {
            $finalResultSet['Result11'][] = $row;
        }
        // Result set 12
        $statement->nextRowSet(); // Advance to the third result set
        $resultSet12 = $statement->fetchAll();
        foreach ($resultSet12 as $row) {
            $finalResultSet['Result12'][] = $row;
        }
        $statement->nextRowSet(); // Advance to the third result set
        $finalResultSet['Result13'] = array();
        $resultSet13 = $statement->fetchAll();
        foreach ($resultSet13 as $row) {
            $finalResultSet['Result13'][] = $row;
        }
        $statement->nextRowSet(); // Advance to the third result set
        $resultSet14 = $statement->fetchAll();
        foreach ($resultSet14 as $row) {
            $finalResultSet['Result14'][] = $row;
        }

        $statement->nextRowSet(); // Advance to the third result set
        $resultSet15 = $statement->fetchAll();
        foreach ($resultSet15 as $row) {
            $finalResultSet['Result15'][] = $row;
        }

        $statement->nextRowSet(); // Advance to the third result set
        $resultSet16 = $statement->fetchAll();
        foreach ($resultSet16 as $row) {
            $finalResultSet['Result16'][] = $row;
        }

        $statement->nextRowSet(); // Advance to the third result set
        $resultSet17 = $statement->fetchAll();
        foreach ($resultSet17 as $row) {
            $finalResultSet['Result17'][] = $row;
        }
        
//        $statement->nextRowSet(); // Advance to the third result set
//        $resultSet18 = $statement->fetchAll();
//        foreach ($resultSet18 as $row) {
//            $finalResultSet['Result18'][] = $row;
//        }

        /*  start Itineraries code */
        $subItem = array(0 => "CITY", 1 => "HOTEL", 2 => "ACTIVITY", 3 => "SIGHTSEEING", 4 => "TRANSFERS");
        $catagoryArray = array();
        if (!empty($finalResultSet['Result7'])) {
            foreach ($finalResultSet['Result7'] as $ItinerariesF) {
                if ($PackageCostCalType == 1) {
                    $catagoryArray[$ItinerariesF['MARKETPLACEID']][$ItinerariesF['TOURTYPE']][$ItinerariesF['PACKCATEGORYID']][$ItinerariesF['MealPlanType']][] = $ItinerariesF;
                } else {
                    $catagoryArray[$ItinerariesF['MARKETPLACEID']][$ItinerariesF['TOURTYPE']][$ItinerariesF['PACKCATEGORYID']][1][] = $ItinerariesF;
                }
            }
        }
        $ItinerarieItem = array();
        $i = 0;
        $totalDay = 0;
        foreach ($finalResultSet['Result1'] as $Itineraries) {
            if ($Itineraries['MASTERREFID'] == 0) {
                $totalDay = $Itineraries['INTSEQUENCE'];
                $ItinerarieItem[$i]['ItineraryId'] = (int) $Itineraries['TPINTSYSID'];
                $ItinerarieItem[$i]['Title'] = $Itineraries['INTTITLE'];
                $ItinerarieItem[$i]['Day'] = $Itineraries['INTSEQUENCE'];
                $ItinerarieItem[$i]['Program'] = $Itineraries['INTDETAILS'];
                $arrayINCLMASK = str_split($Itineraries['INCLMASK']);
                $arrayPACKTYPEMASK = str_split($Itineraries['PACKTYPEMASK']);
                $subItinerariesItem = array();
                $subItems = array();
                foreach ($subItem as $key => $val) {
                    $subItemId = 0;
                    if ($val == "CITY") {
                        foreach ($finalResultSet['Result2'] as $ItinerariesCity) {
                            if ($ItinerariesCity["TPINTSYSID"] == $Itineraries['TPINTSYSID']) {
                                $subItemId = (int) $ItinerariesCity["PLACESYSID"];
                            }
                        }
                    } else if ($val == "HOTEL") {
                        $hotelArray = array();

                        //echo "<pre>";print_r($finalResultSet['Result3']);exit;

                        foreach ($catagoryArray as $catVal) {
                            foreach ($catVal as $valB) {
                                $r = 0;
                                foreach ($valB as $keyH => $valH) {
                                    $h = 0;
                                    foreach ($finalResultSet['Result3'] as $ItinerariesHOTEL) {
                                        if (($ItinerariesHOTEL["TPINTSYSID"] == $Itineraries['TPINTSYSID']) && ($ItinerariesHOTEL["BYOPACKTYPE"] == $keyH)) {
                                            $hotelArray[$r]['Item'][$h]['IsIncluded'] = $statusArray[$ItinerariesHOTEL["ISSELECTEDONPKG"]];
                                            $hotelArray[$r]['Item'][$h]['Id'] = (int) $ItinerariesHOTEL["INVNITEMSYSID"];
                                            $hotelArray[$r]['Item'][$h]['MasterIntSysId'] = (int) $ItinerariesHOTEL["MASTERINTSYSID"];
                                            $hotelArray[$r]['Item'][$h]['ACCOMSYSID'] = (int) $ItinerariesHOTEL["ACCOMSYSID"];
                                            $hotelArray[$r]['Item'][$h]['MEALPLANTYPE'] = (int) $ItinerariesHOTEL["MealPlanType"];
                                            $hotelArray[$r]['Item'][$h]['ROOMTYPE'] = (int) $ItinerariesHOTEL["ROOMTYPE"];
                                            if ($PackageCostCalType == 1) {
                                                $hotelArray[$r]['Item'][$h]['MealPlanId'] = (int) $ItinerariesHOTEL["MealPlanType"];
                                            } else {
                                                $hotelArray[$r]['Item'][$h]['MealPlanId'] = NULL;
                                            }


                                            $h++;
                                        }
                                    }
                                    $hotelArray[$r]['Type'] = $catTypeMaster[$keyH];
                                    $hotelArray[$r]['Id'] = $keyH;
                                    $r++;
                                }
                            }
                            //$catTypeMaster
                        }
                        $subItems = $hotelArray;
                    } else if ($val == "ACTIVITY") {
                        $activityArray = array();
                        $a = 0;
                        $activityArray[0]['Item'] = array();
                        foreach ($finalResultSet['Result5'] as $ItinerariesACTIVITY) {
                            if ($ItinerariesACTIVITY["TPIntSysId"] == $Itineraries['TPINTSYSID']) {
                                $activityArray[0]['Item'][$a]['IsIncluded'] = $OstatusArray[$ItinerariesACTIVITY["ISOPTIONALACTIVITY"]];
                                $activityArray[0]['Item'][$a]['Id'] = (int) $ItinerariesACTIVITY["INVNITEMSYSID"];
                                $activityArray[0]['Item'][$a]['MasterIntSysId'] = 0;
                                $a++;
                            }
                        }
                        $activityArray[0]['Type'] = NULL;
                        $activityArray[0]['Id'] = 0;
                        $subItems = $activityArray;
                    } else if ($val == "SIGHTSEEING") {
                        $sightseeingArray = array();
                        $s = 0;
                        $sightseeingArray[0]['Item'] = array();
                        foreach ($finalResultSet['Result6'] as $ItinerariesSIGHTSEEING) {
                            if ($ItinerariesSIGHTSEEING["TPIntSysId"] == $Itineraries['TPINTSYSID']) {
                                $sightseeingArray[0]['Item'][$s]['IsIncluded'] = $OstatusArray[$ItinerariesSIGHTSEEING["ISOPTIONALSIGHTSEEING"]];
                                if ($ItinerariesSIGHTSEEING["INVNITEMSYSID"] == 0) {
                                    $sightseeingArray[0]['Item'][$s]['TYPE'] = $ItinerariesSIGHTSEEING["TYPE"];
                                    $sightseeingArray[0]['Item'][$s]['Id'] = (int) $ItinerariesSIGHTSEEING["VersionId"];
                                    $sightseeingArray[0]['Item'][$s]['SSSysId'] = (int) $ItinerariesSIGHTSEEING["SSSYSID"];
                                    $sightseeingArray[0]['Item'][$s]['PriceType'] = (int) $ItinerariesSIGHTSEEING["PriceType"];
                                } else {
                                    $sightseeingArray[0]['Item'][$s]['TYPE'] = $ItinerariesSIGHTSEEING["TYPE"];
                                    $sightseeingArray[0]['Item'][$s]['Id'] = (int) $ItinerariesSIGHTSEEING["VersionId"];
                                    $sightseeingArray[0]['Item'][$s]['SSSysId'] = (int) $ItinerariesSIGHTSEEING["SSSYSID"];
                                    $sightseeingArray[0]['Item'][$s]['PriceType'] = (int) $ItinerariesSIGHTSEEING["PriceType"];
                                }

                                $sightseeingArray[0]['Item'][$s]['MasterIntSysId'] = 0;
                                $s++;
                            }
                        }
                        $sightseeingArray[0]['Type'] = NULL;
                        $sightseeingArray[0]['Id'] = 0;
                        $subItems = $sightseeingArray;
                        
                    } else if ($val == "TRANSFERS") {
                        $transfersArray = array();
                        $tr = 0;
                        $s = 0;
                        $transfersArray[$tr]['Item'] = array();
                        foreach ($finalResultSet['Result13'] as $ItinerariesTRANSFERS) { 
                            if ($ItinerariesTRANSFERS["TPINTSYSID"] == $Itineraries['TPINTSYSID']) {
                                $transfersArray[$tr]['Item'][$s]['IsIncluded'] = $statusArray[$ItinerariesTRANSFERS["ISINCLUDED"]];
                                $transfersArray[$tr]['Item'][$s]['TYPE'] = $ItinerariesTRANSFERS["TYPE"];
                                $transfersArray[$tr]['Item'][$s]['Id'] = (int) $ItinerariesTRANSFERS["FIXTRANSSYSID"];
                                $transfersArray[$tr]['Item'][$s]['RouteSysId'] = (int) $ItinerariesTRANSFERS["ROUTESYSID"];
                                $transfersArray[$tr]['Item'][$s]['RouteVechSysId'] = (int) $ItinerariesTRANSFERS["ROUTEVECHSYSID"];
                                $transfersArray[$tr]['Item'][$s]['MasterIntSysId'] = 0;
                                $transfersArray[$tr]['Type'] = $ItinerariesTRANSFERS["TRANSTYPE"];
                                $transfersArray[$tr]['Id'] = 0;
                                $tr++;
                            }
                        }

                        $subItems = $transfersArray;
                    }
                     
                    $subItinerariesItem[$key]["Type"] = $val;
                    $subItinerariesItem[$key]["Id"] = $subItemId; //static
                    $subItinerariesItem[$key]["Items"] = $subItems;
                   
                }
                $ItinerarieItem[$i]['ItineraryItem'] = $subItinerariesItem;
                $i++;
            }
        }
        
        $Itineraries = array("Itinerary" => $ItinerarieItem);
        $Cities = array();
        $Cities["desc"] = NULL;
        $c = 0;
        $checkCity = array();
        $getCityName = array();
        $getCountryName = array();
        foreach ($finalResultSet['Result2'] as $ItinerariesCity) {
            if (!in_array($ItinerariesCity['PLACESYSID'], $checkCity)) {
                $checkCity[] = $ItinerariesCity['PLACESYSID'];
                $Cities["City"][$c]["CityId"] = (int) $ItinerariesCity['PLACESYSID'];
                $Cities["City"][$c]["Title"] = $ItinerariesCity['CITYNAME'];
                $getCityName[$ItinerariesCity['PLACESYSID']] = $ItinerariesCity['CITYNAME'];
                $getCountryName[$ItinerariesCity['COUNTRYID']] = $ItinerariesCity['COUNTRYNAME'];
                $Cities["City"][$c]["Hotels"] = array();
                $cH = 0;
                $checkHotelId = array();
                foreach ($finalResultSet['Result3'] as $ItinerariesCityHOTEL) {
                    if ($ItinerariesCity['PLACESYSID'] == $ItinerariesCityHOTEL['CITYID']) {
                        if (!in_array($ItinerariesCityHOTEL['INVNITEMSYSID'], $checkHotelId)) {
                            $checkHotelId[] = (int) $ItinerariesCityHOTEL['INVNITEMSYSID'];
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["RefHotelId"] = (int) $ItinerariesCityHOTEL['INVNITEMSYSID'];
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["Name"] = $ItinerariesCityHOTEL['HOTELNAME'];
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["Star"] = $ItinerariesCityHOTEL['STARRATING'];
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["Rating"] = $ItinerariesCityHOTEL['REVIEWRATING'];
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["IsIncluded"] = $statusArray[$ItinerariesCityHOTEL['ISSELECTEDONPKG']];
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["Location"] = array("Lat" => $ItinerariesCityHOTEL['GEOLAT'], "Long" => $ItinerariesCityHOTEL['GEOLONG'], "Address" => $ItinerariesCityHOTEL['ADDRESS']);
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["Images"] = array();
                            $aI = 0;
                            if (!empty($finalResultSet['Result4'])) {
                                foreach ($finalResultSet['Result4'] as $imagesData) {
                                    if ($ItinerariesCityHOTEL['ACCOMSYSID'] == $imagesData['ACCOMSYSID']) {
                                        $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["Images"]["Image"][$aI]['ImagId'] = (int) $imagesData['IMAGEID'];
                                        $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["Images"]["Image"][$aI]['Type'] = $imagesData['IMAGETYPE'];
                                        $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["Images"]["Image"][$aI]['Order'] = $imagesData['SEQ'];
                                        $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["Images"]["Image"][$aI]['ShortDesc'] = NULL;
                                        $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["Images"]["Image"][$aI]['URL'] = $imagesData['URL'];
                                        $aI++;
                                    }
                                }
                            }
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["CityId"] = (int) $ItinerariesCityHOTEL['CITYID'];
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["Brief"] = htmlentities($ItinerariesCityHOTEL['BRIEF'], ENT_QUOTES);
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["MainImg"] = $ItinerariesCityHOTEL['DETAILIMG'];
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["AccoAminitiesMask"] = $ItinerariesCityHOTEL['ACCOAMINITIESMASK'];
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["AccoAminities"] = array();
                            $ACCOAMINITIES = $this->maskArray(str_split($ItinerariesCityHOTEL['ACCOAMINITIESMASK']), $finalResultSet['Result10']);
                            if (!empty($ACCOAMINITIES)) {
                                $am = 0;
                                foreach ($ACCOAMINITIES as $valACCOAMINITIES) {
                                    $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["AccoAminities"][$am]["AminityId"] = $valACCOAMINITIES['AminityId'];
                                    $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["AccoAminities"][$am]["Title"] = $valACCOAMINITIES['Title'];
                                    $am++;
                                }
                            }
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["IsfromAPI"] = false; //Need Help
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["SupplierSysId"] = (int) $ItinerariesCityHOTEL['SUPPLIERSYSID'];
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["SupplierName"] = $ItinerariesCityHOTEL['SUPPLIERNAME'];

                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["priceaditionals"]["currencyType"] = (float) $ItinerariesCityHOTEL['CURRENCYTYPE'];
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["priceaditionals"]["costTripleOcc"] = (float) $ItinerariesCityHOTEL['COSTPPTO'];
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["priceaditionals"]["costDoubleOcc"] = (float) $ItinerariesCityHOTEL['COSTPPDO'];
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["priceaditionals"]["costSingleOcc"] = (float) $ItinerariesCityHOTEL['COSTPPSO'];
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["priceaditionals"]["costExtraBed"] = (float) $ItinerariesCityHOTEL['COSTEXTRABED'];
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["priceaditionals"]["costWithoutBed"] = (float) $ItinerariesCityHOTEL['COSTCHILDWITHOUTBED'];
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["priceaditionals"]["netCost"] = (float) $ItinerariesCityHOTEL['NETCOST'];
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["priceaditionals"]["adultCost"] = 0; //need discussion
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["priceaditionals"]["kidsCost"] = 0; //need discussion

                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["RoomTypeName"] = $ItinerariesCityHOTEL['ROOMNAME'];
                            $Cities["City"][$c]["Hotels"]["Hotel"][$cH]["MealTypeName"] = $mealPlanType[$ItinerariesCityHOTEL['MealPlanType']];
                            $cH++;
                        }
                    }
                }
                $Cities["City"][$c]["Activities"] = array();
                $cA = 0;
                $checkActivityId = array();
                foreach ($finalResultSet['Result5'] as $ItinerariesCityActivity) {
                    if ($ItinerariesCity['PLACESYSID'] == $ItinerariesCityActivity['CITYID']) {
                        if (!in_array($ItinerariesCityActivity['INVNITEMSYSID'], $checkActivityId)) {
                            $checkActivityId[] = (int) $ItinerariesCityActivity['INVNITEMSYSID'];
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["RefActivityId"] = (int) $ItinerariesCityActivity['INVNITEMSYSID'];
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["Title"] = $ItinerariesCityActivity['TITLE'];
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["Description"] = $ItinerariesCityActivity['WRITEUP'];
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["CurrencyType"] = "0"; //Need Help
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["CityId"] = (int) $ItinerariesCityActivity['CITYID'];
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["CityName"] = $ItinerariesCityActivity['CITYNAME'];
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["Lat"] = $ItinerariesCityActivity['LATITUDE'];
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["Long"] = $ItinerariesCityActivity['LONGITUDE'];
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["Image"] = $ItinerariesCityActivity['THUMNAILIMG'];
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["SupplierSysId"] = (int) $ItinerariesCityActivity['SUPPLIERSYSID'];
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["SupplierName"] = $ItinerariesCityActivity['SUPPLIERNAME'];
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["priceaditionals"]["currencyType"] = $ItinerariesCityActivity['CURRENCYTYPE'];
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["priceaditionals"]["costTripleOcc"] = 0;
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["priceaditionals"]["costDoubleOcc"] = 0;
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["priceaditionals"]["costSingleOcc"] = 0;
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["priceaditionals"]["costExtraBed"] = 0;
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["priceaditionals"]["costWithoutBed"] = 0;
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["priceaditionals"]["netCost"] = (float) $ItinerariesCityActivity['NETCOST'];
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["priceaditionals"]["adultCost"] = (float) $ItinerariesCityActivity['ADULTCOST'];
                            $Cities["City"][$c]["Activities"]["Activity"][$cA]["priceaditionals"]["kidsCost"] = (float) $ItinerariesCityActivity['KIDSCOST'];
                            $cA++;
                        }
                    }
                }
//                echo "<pre>";print_r($finalResultSet['Result6']);die;
                $Cities["City"][$c]["SightSeeings"] = array();
                $cS = 0;
                $checkSightSeeingId = array();
                foreach ($finalResultSet['Result6'] as $ItinerariesCitySightSeeing) {
                    if ($ItinerariesCity['PLACESYSID'] == $ItinerariesCitySightSeeing['CITYID']) {
                        if (!in_array($ItinerariesCitySightSeeing['VersionId'], $checkSightSeeingId)) {


                            if ($ItinerariesCitySightSeeing['INVNITEMSYSID'] == 0) {
                                $checkSightSeeingId[] = (int) $ItinerariesCitySightSeeing['VersionId'];
                                $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["RefSSId"] = (int) $ItinerariesCitySightSeeing['VersionId'];
                                $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["SSSysId"] = (int) $ItinerariesCitySightSeeing['SSSYSID'];
                                $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["TYPE"] = $ItinerariesCitySightSeeing["TYPE"];
                            } else {
                                $checkSightSeeingId[] = (int) $ItinerariesCitySightSeeing['VersionId'];
                                $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["RefSSId"] = (int) $ItinerariesCitySightSeeing['VersionId'];
                                $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["SSSysId"] = (int) $ItinerariesCitySightSeeing['SSSYSID'];
                                $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["TYPE"] = $ItinerariesCitySightSeeing["TYPE"];
                            }
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["Title"] = $ItinerariesCitySightSeeing['SSTITLE'];
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["Description"] = $ItinerariesCitySightSeeing['WRITEUP'];
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["CurrencyType"] = 0; //Need Help
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["CityId"] = (int) $ItinerariesCitySightSeeing['CITYID'];
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["CityName"] = $ItinerariesCitySightSeeing['CITYNAME'];
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["Lat"] = $ItinerariesCitySightSeeing['LATITUDE'];
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["Long"] = $ItinerariesCitySightSeeing['LONGITUDE'];
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["Image"] = $ItinerariesCitySightSeeing['THUMNAILIMG'];
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["SupplierSysId"] = (int) $ItinerariesCitySightSeeing['SUPPLIERSYSID'];
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["SupplierName"] = $ItinerariesCitySightSeeing['SUPPLIERNAME'];
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["priceaditionals"]["currencyType"] = $ItinerariesCitySightSeeing['CURRENCYTYPE'];
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["priceaditionals"]["TransCurrencyType"] = (int)$ItinerariesCitySightSeeing['TransCurrencyType'];
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["priceaditionals"]["costTripleOcc"] = 0;
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["priceaditionals"]["costDoubleOcc"] = 0;
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["priceaditionals"]["costSingleOcc"] = 0;
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["priceaditionals"]["costExtraBed"] = 0;
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["priceaditionals"]["costWithoutBed"] = 0;
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["priceaditionals"]["PriceType"] = (int)$ItinerariesCitySightSeeing['PriceType'];
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["priceaditionals"]["Capacity"] = (int)$ItinerariesCitySightSeeing['Capacity'];
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["priceaditionals"]["RouteVechSysId"] = (int)$ItinerariesCitySightSeeing['RouteVechSysId'];
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["priceaditionals"]["netCost"] = ((int)$ItinerariesCitySightSeeing['RouteVechSysId'] > 0) ? (float) $ItinerariesCitySightSeeing['TotalPrice'] :  (float) $ItinerariesCitySightSeeing['NETCOST'];
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["priceaditionals"]["adultCost"] = (float) $ItinerariesCitySightSeeing['ADULTCOST'];
                            $Cities["City"][$c]["SightSeeings"]["SightSeeing"][$cS]["priceaditionals"]["kidsCost"] = (float) $ItinerariesCitySightSeeing['KIDSCOST'];

                            $cS++;
                        }
                    }
                }
                $c++;
            }
        }
        $tourTypesC = array();
        $minPrice = array();
        if (!empty($finalResultSet['Result7'])) {
            foreach ($finalResultSet['Result7'] as $tourTypesVal) {
                $minPrice[] = $tourTypesVal['PRICEPERPERSON'];
            }
        }
        $tourTypes = array();
        $tp = 0;
        $p = 0;
        // echo "<pre>";print_r($catagoryArray);exit;
        foreach ($catagoryArray as $keyValP => $tourTypeP) {
            $tourTypes['MarketType'][$p]['MarketTypeId'] = (int) $keyValP;
            $tourTypes['MarketType'][$p]['MarketTypeTitle'] = ($keyValP == 2) ? 'B2B' : 'B2C';
            $tourTypes['MarketType'][$p]['TourType'] = array();
            $tp = 0;
            foreach ($tourTypeP as $keyValP => $keyVal) {
                $tourTypes['MarketType'][$p]['TourType'][$tp]['TourType'] = $keyValP;
                $tourTypes['MarketType'][$p]['TourType'][$tp]['TourTypeTitle'] = ($keyValP == 1) ? 'Private' : 'Group';
                $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories'] = array();
                $pt = 0;
                foreach ($keyVal as $key => $valP) {
                    if ($pt == 0) {
                        $SeletedForPackage = TRUE;
                    } else {
                        $SeletedForPackage = FALSE;
                    }
                    $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["CategoryId"] = $key;
                    $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["Type"] = $catTypeMaster[$key];
                    $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["TPSysId"] = $key;
                    $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MasterTPId"] = '';
                    $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["SeletedForPackage"] = $SeletedForPackage;
                    $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["Price"] = '';

                    $pJ = 0;
                    foreach ($valP as $keyM => $valM) {
                        if ($PackageCostCalType == 1) {
                            $MPTypeId = $keyM;
                            $MPTypeText = $mealPlanType[$keyM];
                        } else {
                            $MPTypeId = 1;
                            $MPTypeText = 'LowestCost';
                        }
                        $SeletedForPackage = FALSE;
                        if ($pJ == 0) {
                            $SeletedForPackage = TRUE;
                        }
                        $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]['MPTypeId'] = (int) $MPTypeId;
                        $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]['MPTypeText'] = $MPTypeText;
                        $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]['SeletedForPackage'] = $SeletedForPackage;
                        $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"] = array();
                        $pA = 0;
                        foreach ($valM as $val) {
                            $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"][$pA]['From'] = $val['FROMDATE']->format('Y-m-d');
                            $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"][$pA]['To'] = $val['TODATE']->format('Y-m-d');
                            $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"][$pA]['Currency'] = $val['CURRENCYTYPE'];
                            $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"][$pA]['priceTripleOcc'] = $val['COSTPPTO'];
                            $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"][$pA]['priceDoubleOcc'] = $val['PRICEPERPERSON'];
                            $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"][$pA]['priceSingleOcc'] = $val['COSTPPSO'];
                            $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"][$pA]['priceExtraBed'] = $val['COSTEXTRABED'];
                            $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"][$pA]['priceWithoutBed'] = $val['COSTCHILDWITHOUTBED'];
                            $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"][$pA]['Tax'] = $val['TAX'];
                            $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"][$pA]['MarkType'] = $val['MARKTYPE'];
                            $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"][$pA]['MarkValue'] = $val['MARKVALUE'];
                            $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"][$pA]['ExcludedPercent'] = $val['EXCLUDEDPERCENT'];
                            $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"][$pA]['PricePerPerson'] = $val['PRICEPERPERSON'];
                            $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"][$pA]['TourType'] = (int) $val['TOURTYPE'];
                            $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"][$pA]['TourTypeTitle'] = $val['TOURTYPETITLE'];
                            $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"][$pA]['DiscountType'] = 0; //Need Help
                            $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"][$pA]['DiscountVal'] = 0; //Need Help
                            $tourTypes['MarketType'][$p]['TourType'][$tp]['Categories']["Category"][$pt]["MPType"][$pJ]["PriceAdditional"][$pA]['DestinationSysId'] = (int)$val['DestinationSysId'];
                            $pA++;
                        }
                        $pJ++;
                    }
                    $pt++;
                }
                $tp++;
            }
            $p++;
        }
        $Inclusions = $this->maskString($finalResultSet['Result12'], $arrayINCLMASK);
        $PackageType = $this->maskString($finalResultSet['Result11'], $arrayPACKTYPEMASK);
        $CancellationRules = array();
        $cl = 0;
        if (!empty($finalResultSet['Result15'])) {
            foreach ($finalResultSet['Result15'] as $CancellationRulesData) {
                $CancellationRules[$cl]["DaysBefore"] = $CancellationRulesData['DAYSBEFORE'];
                $CancellationRules[$cl]["ExtraValue"] = $CancellationRulesData['EXTRAVALUE'];
                $CancellationRules[$cl]["IsPercentage"] = $statusArray[$CancellationRulesData['ISPERCENTAGE']];
                $CancellationRules[$cl]["Title"] = $CancellationRulesData['TITLE'];
                $CancellationRules[$cl]["TPRulesSysId"] = $CancellationRulesData['TPRULESSYSID'];
                $CancellationRules[$cl]["Value"] = $CancellationRulesData['VALUE'];
                $cl++;
            }
        }

        /* Start Transfer */



        $TRANSPORT_CATEGORY = unserialize(TRANSPORT_CATEGORY);
        $transfers = array();
        if (!empty($finalResultSet['Result13'])) {
            foreach ($finalResultSet['Result13'] as $tranferKey => $transfersData) {
                $transfers[$tranferKey]["isIncluded"] = $statusArray[$transfersData["ISINCLUDED"]];
                $transfers[$tranferKey]["type"] = $transfersData["TYPE"];
                $transfers[$tranferKey]["fixTransSysId"] = $transfersData["FIXTRANSSYSID"];
                $transfers[$tranferKey]["supplierSysId"] = $transfersData["SUPPLIERSYSID"];
                $transfers[$tranferKey]["supplierName"] = $transfersData["SUPPLIERNAME"];
                $transfers[$tranferKey]["cityCovered"] = $transfersData["CITYCOVERED"];
                $transfers[$tranferKey]["routeName"] = isset($transfersData["ROUTENAME"]) ? $transfersData["ROUTENAME"] : '';
                $transfers[$tranferKey]["vehSysId"] = $transfersData["VEHSYSID"];
                $transfers[$tranferKey]["vehicleName"] = $transfersData["VehName"];
                $transfers[$tranferKey]["transType"] = $transfersData["TRANSTYPE"];
                $transfers[$tranferKey]["transTypeCat"] = $transfersData["TRANSTYPECAT"];
                $transfers[$tranferKey]["fromPlace"] = $transfersData["FROMPLACE"];
                $transfers[$tranferKey]["sourceCityId"] = $transfersData["SOURCECITYID"];
                $transfers[$tranferKey]["toPlace"] = $transfersData["TOPLACE"];
                $transfers[$tranferKey]["destCityId"] = $transfersData["DESTCITYID"];
                $transfers[$tranferKey]["currencyType"] = $transfersData["CURRENCYTYPE"];
                $transfers[$tranferKey]["currencySymbol"] = $transfersData["SYMBOL"];
                $transfers[$tranferKey]["costPerson"] = $transfersData["COSTPERSON"];
                $transfers[$tranferKey]["totalCost"] = $transfersData["TOTALPRICE"];
                $transfers[$tranferKey]["isGroup"] = $transfersData["ISGROUP"];
                $transfers[$tranferKey]["capacity"] = $transfersData["CAPACITY"];
                $transfers[$tranferKey]["Description"] = $transfersData["DESCRIPTION"];
                $transfers[$tranferKey]["NoofDays"] = $transfersData["NOOFDAYS"];
                $transfers[$tranferKey]["transTypeTitle"] = ($transfersData["TRANSTYPE"] == 2) ? $TRANSPORT_CATEGORY[$transfersData["TRANSTYPECAT"]] : $TRANSPORT_CATEGORY[$transfersData["TRANSTYPE"]] ;
            }
        }
        /* End Transfer */
//        echo "<pre>";print_r($transfers);exit;

        $OtherServices = array();
        if (!empty($finalResultSet['Result14'])) {
            foreach ($finalResultSet['Result14'] as $OtherServicesKey => $OtherServicesData) {
                $OtherServices[$OtherServicesKey]["otherSrvSysId"] = $OtherServicesData["OTHERSRVSYSID"];
                $OtherServices[$OtherServicesKey]["tpIntSysId"] = $OtherServicesData["TPINTSYSID"];
                $OtherServices[$OtherServicesKey]["serviceTitle"] = $OtherServicesData["SERVICETITLE"];
                $OtherServices[$OtherServicesKey]["comment"] = $OtherServicesData["COMMENT"];
                $OtherServices[$OtherServicesKey]["currencyType"] = $OtherServicesData["CURRENCYTYPE"];
                $OtherServices[$OtherServicesKey]["paxCount"] = $OtherServicesData["PAXCOUNT"];
                $OtherServices[$OtherServicesKey]["cost"] = $OtherServicesData["COST"];
                $OtherServices[$OtherServicesKey]["isCostInclInTP"] = $OtherServicesData["ISCOSTINCLINTP"];
                $OtherServices[$OtherServicesKey]["supplierSysId"] = $OtherServicesData["SUPPLIERSYSID"];
                $OtherServices[$OtherServicesKey]["supplierName"] = $OtherServicesData["SUPPLIERNAME"];
                $OtherServices[$OtherServicesKey]["serviceTypeId"] = $OtherServicesData["SERVICETYPEID"];
                $OtherServices[$OtherServicesKey]["serviceType"] = $OtherServicesData["SERVICETYPE"];
                $OtherServices[$OtherServicesKey]["rateTypeId"] = $OtherServicesData["RATETYPEID"];
                $OtherServices[$OtherServicesKey]["rateType"] = $OtherServicesData["RATETYPE"];
            }
        }
        $k=1;
        $fixedInventoryArrayList = array();
        if (!empty($finalResultSet['Result16'])) {
            foreach ($finalResultSet['Result16'] as $fixedInventoryArray) {
                $fixedInventoryArrayList[$fixedInventoryArray['DestinationSysId']]["CityName"] = $fixedInventoryArray['Title'];
                //$fixedInventoryArrayList[$fixedInventoryArray['DestinationSysId']]["FlightDetail"] = array();
                
                if (!empty($finalResultSet['Result17'])) {
                    foreach ($finalResultSet['Result17'] as $fixedInventoryFlightDetailArray) {
                        if ($fixedInventoryFlightDetailArray['DestinationSysId'] == $fixedInventoryArray['DestinationSysId']) {
                            if ($fixedInventoryFlightDetailArray['InvnAirlineSysId'] != null) {
                                $fixedInventoryArrayList[$fixedInventoryFlightDetailArray['DestinationSysId']]['FlightInv'][$fixedInventoryFlightDetailArray['FlightType']][$fixedInventoryFlightDetailArray['InvnAirlineSysId']]["FlightType"] = $fixedInventoryFlightDetailArray['FlightType'];
                                $fixedInventoryArrayList[$fixedInventoryFlightDetailArray['DestinationSysId']]['FlightInv'][$fixedInventoryFlightDetailArray['FlightType']][$fixedInventoryFlightDetailArray['InvnAirlineSysId']]["AirlineName"] = $fixedInventoryFlightDetailArray['AirlineName'];
                                $fixedInventoryArrayList[$fixedInventoryFlightDetailArray['DestinationSysId']]['FlightInv'][$fixedInventoryFlightDetailArray['FlightType']][$fixedInventoryFlightDetailArray['InvnAirlineSysId']]["AirlineCode"] = $fixedInventoryFlightDetailArray['AirlineCode'];
                                $fixedInventoryArrayList[$fixedInventoryFlightDetailArray['DestinationSysId']]['FlightInv'][$fixedInventoryFlightDetailArray['FlightType']][$fixedInventoryFlightDetailArray['InvnAirlineSysId']]["DepartureAirportCode"] = $fixedInventoryFlightDetailArray['DepartureAirportCode'];
                                $fixedInventoryArrayList[$fixedInventoryFlightDetailArray['DestinationSysId']]['FlightInv'][$fixedInventoryFlightDetailArray['FlightType']][$fixedInventoryFlightDetailArray['InvnAirlineSysId']]["DepartureAirportName"] = $fixedInventoryFlightDetailArray['DepartureAirportName'];
                                $fixedInventoryArrayList[$fixedInventoryFlightDetailArray['DestinationSysId']]['FlightInv'][$fixedInventoryFlightDetailArray['FlightType']][$fixedInventoryFlightDetailArray['InvnAirlineSysId']]["DepartureTime"] = $fixedInventoryFlightDetailArray['DepartureTime']->format("H:i:s");
                                $fixedInventoryArrayList[$fixedInventoryFlightDetailArray['DestinationSysId']]['FlightInv'][$fixedInventoryFlightDetailArray['FlightType']][$fixedInventoryFlightDetailArray['InvnAirlineSysId']]["FromTerminal"] = $fixedInventoryFlightDetailArray['FromTerminal'];
                                $fixedInventoryArrayList[$fixedInventoryFlightDetailArray['DestinationSysId']]['FlightInv'][$fixedInventoryFlightDetailArray['FlightType']][$fixedInventoryFlightDetailArray['InvnAirlineSysId']]["ArrivalAirportCode"] = $fixedInventoryFlightDetailArray['ArrivalAirportCode'];
                                $fixedInventoryArrayList[$fixedInventoryFlightDetailArray['DestinationSysId']]['FlightInv'][$fixedInventoryFlightDetailArray['FlightType']][$fixedInventoryFlightDetailArray['InvnAirlineSysId']]["ArrivalAirportName"] = $fixedInventoryFlightDetailArray['ArrivalAirportName'];
                                $fixedInventoryArrayList[$fixedInventoryFlightDetailArray['DestinationSysId']]['FlightInv'][$fixedInventoryFlightDetailArray['FlightType']][$fixedInventoryFlightDetailArray['InvnAirlineSysId']]["ArrivalTime"] = $fixedInventoryFlightDetailArray['ArrivalTime']->format("H:i:s");
                                $fixedInventoryArrayList[$fixedInventoryFlightDetailArray['DestinationSysId']]['FlightInv'][$fixedInventoryFlightDetailArray['FlightType']][$fixedInventoryFlightDetailArray['InvnAirlineSysId']]["ToTerminal"] = $fixedInventoryFlightDetailArray['ToTerminal'];
                                $fixedInventoryArrayList[$fixedInventoryFlightDetailArray['DestinationSysId']]['FlightInv'][$fixedInventoryFlightDetailArray['FlightType']][$fixedInventoryFlightDetailArray['InvnAirlineSysId']]["EstimateHours"] = $fixedInventoryFlightDetailArray['EstimateHours'];
                            }
                        }
                    }
                }


                $fromDate = $fixedInventoryArray['FromDate']->format('Ymd');
                $fixedInventoryArrayList[$fixedInventoryArray['DestinationSysId']]["FromDate"][$fromDate]["FromDate"] = $fixedInventoryArray['FromDate']->format('Y-m-d');
                $fixedInventoryArrayList[$fixedInventoryArray['DestinationSysId']]["FromDate"][$fromDate]["FromDateDMY"] = $fixedInventoryArray['FromDate']->format('d/m/Y');
                $fixedInventoryArrayList[$fixedInventoryArray['DestinationSysId']]["FromDate"][$fromDate]["AdultCost"] = (float) $fixedInventoryArray['AdultCost'];
                $fixedInventoryArrayList[$fixedInventoryArray['DestinationSysId']]["FromDate"][$fromDate]["InfantCost"] = (float) $fixedInventoryArray['InfantCost'];
               // $fixedInventoryArrayList[$fixedInventoryArray['DestinationSysId']]["FromDate"][$fromDate]["MarkupType"] = (int) $fixedInventoryArray['MarkupType'];
                if ($fixedInventoryArray['MarkupType'] == 2) {
                    $fixedInventoryArrayList[$fixedInventoryArray['DestinationSysId']]["FromDate"][$fromDate]["B2BAdultMarkup"] = ((float) $fixedInventoryArray['AdultCost'] * (float) $fixedInventoryArray['B2BAdultMarkup']/100);
                    $fixedInventoryArrayList[$fixedInventoryArray['DestinationSysId']]["FromDate"][$fromDate]["B2BInfantMarkup"] = ((float) $fixedInventoryArray['B2BInfantMarkup'] * (float) $fixedInventoryArray['InfantCost']/100);
                    $fixedInventoryArrayList[$fixedInventoryArray['DestinationSysId']]["FromDate"][$fromDate]["B2CAdultMarkup"] = ((float) $fixedInventoryArray['AdultCost'] *(float) $fixedInventoryArray['B2CAdultMarkup']/100);
                    $fixedInventoryArrayList[$fixedInventoryArray['DestinationSysId']]["FromDate"][$fromDate]["B2CInfantMarkup"] = ((float) $fixedInventoryArray['B2CInfantMarkup'] * (float) $fixedInventoryArray['InfantCost']/100);
                } else {
                    $fixedInventoryArrayList[$fixedInventoryArray['DestinationSysId']]["FromDate"][$fromDate]["B2BAdultMarkup"] = (float) $fixedInventoryArray['B2BAdultMarkup'];
                    $fixedInventoryArrayList[$fixedInventoryArray['DestinationSysId']]["FromDate"][$fromDate]["B2BInfantMarkup"] = (float) $fixedInventoryArray['B2BInfantMarkup'];
                    $fixedInventoryArrayList[$fixedInventoryArray['DestinationSysId']]["FromDate"][$fromDate]["B2CAdultMarkup"] = (float) $fixedInventoryArray['B2CAdultMarkup'];
                    $fixedInventoryArrayList[$fixedInventoryArray['DestinationSysId']]["FromDate"][$fromDate]["B2CInfantMarkup"] = (float) $fixedInventoryArray['B2CInfantMarkup'];
                }
                $fixedInventoryArrayList[$fixedInventoryArray['DestinationSysId']]["FromDate"][$fromDate]["CurrencySysId"] = (int) $fixedInventoryArray['CurrencySysId'];
                $fixedInventoryArrayList[$fixedInventoryArray['DestinationSysId']]["FromDate"][$fromDate]["Symbol"] = trim($fixedInventoryArray['Symbol']);
            }
        }

        $PKGSELLVALIDTILL = $finalResultSet['Result1'][0]['PKGSELLVALIDTILL']->format('Y-m-d');
        $AgencyId = (int) $finalResultSet['Result1'][0]['AGENCYSYSID'];
        $IsTG = (int) $finalResultSet['Result1'][0]['IsTG'];
        $IsGTXNetworkWeb = (int) $finalResultSet['Result1'][0]['IsGTXNetworkWeb'];
        if ($IsTG == 1 && $sCode == "ewr53bg") {
            $TGAgencySysId = "1903";
        } else if ($IsGTXNetworkWeb == 1 && $sCode != '') {
            $termsandCondition = $this->getTC($sCode);
            //echo "<pre>";print_r($termsandCondition);exit;
            if (!empty($termsandCondition)) {
                $TGAgencySysId = $termsandCondition[0]['AgencySysId'];
                $finalResultSet['Result8'][0]['RefundPolicy'] = $termsandCondition[0]['REFUNDPOLICY'];
                $finalResultSet['Result8'][0]['BOOKINGTERMS'] = $termsandCondition[0]['BookingTerms'];
                $finalResultSet['Result8'][0]['CANCELLATIONPOLICY'] = $termsandCondition[0]['CancellationPolicy'];
                $finalResultSet['Result8'][0]['TERMSANDCONDITIONS'] = $termsandCondition[0]['TermsAndConditions'];
                $finalResultSet['Result8'][0]['TRAVELBASICS'] = $termsandCondition[0]['TravelBasics'];
                $finalResultSet['Result8'][0]['WHYUSEUS'] = $termsandCondition[0]['WhyUseUs'];
            }
        } else {
            $TGAgencySysId = $AgencyId;
        }

        $gtxPkgSourceId = (int) $finalResultSet['Result1'][0]['PACKSOURCEID'];
        $TPSYSID = (int) $finalResultSet['Result1'][0]['TPSYSID'];
        $AllowMinPax = $finalResultSet['Result1'][0]['MINPAX'];
        $dataArray = array("package" => array(
                "TPId" => $TPSYSID,
                "IsFixedDeparturePackage" => (int) $finalResultSet['Result1'][0]['IsFixedDeparturePackage'],
                "ImgHeader" => $finalResultSet['Result1'][0]['IMGHEADER'], //need discussion
                "ImgThumbnail" => trim($finalResultSet['Result1'][0]['IMGTHUMBNAIL']), //need discussion
                "BookingValidUntill" => $PKGSELLVALIDTILL,
                "AdvBookingDays" => (int) $finalResultSet['Result1'][0]['ADVBOOKINGDAYS'],
                "AdvBookingPercent" => (int) $finalResultSet['Result1'][0]['ADVBOOKINGPERCENT'],
                "MarkUpOnGTXNetworkPackage" => (float) $finalResultSet['Result1'][0]['MarkUpOnGTXNetworkPackage'],
                "AgencyId" => (int) $AgencyId,
                "AgencyIdB2C" => (int) $TGAgencySysId,
                "AgencyIdB2B" => (int) $AgencyId,
                "AgencyName" => $finalResultSet['Result1'][0]['AGENCYDISPLAYNAME'],
                "Name" => $finalResultSet['Result1'][0]['TITLE'],
                "TagLine1" => NULL, //need discussion
                "TagLine2" => NULL, //need discussion
                "AllowMinPax" => $AllowMinPax,
                "DestinationPlaces" => trim($finalResultSet['Result1'][0]['DestinationPlaces']),
                "DestinationPlacesSysId" => (int) trim($finalResultSet['Result1'][0]['DestinationPlacesSysId']),
                "SourcePlaces" => trim($finalResultSet['Result1'][0]['SourcePlaces']),
                "SourcePlaceSysId" => (int) trim($finalResultSet['Result1'][0]['SourcePlaceSysId']),
                "GroupSize" => $finalResultSet['Result1'][0]['GROUPSIZE'],
                "Source" => array("SourceId" => $gtxPkgSourceId, "Value" => $finalResultSet['Result1'][0]['PACKSOURCETITLE']),
                "Type" => array("TypeId" => isset($finalResultSet['Result1'][0]['PackRangeTypeID']) ? $finalResultSet['Result1'][0]['PackRangeTypeID'] : 0, "Value" => $finalResultSet['Result1'][0]['PACKRANGETYPETITLE']),
                "Supplier" => array("SupplierId" => $finalResultSet['Result1'][0]['SUPPLIERSYSID'], "SupplierName" => $finalResultSet['Result1'][0]['SUPPLIERNAME']),
                "PackageSpec" => array("Specification" => $finalResultSet['Result1'][0]['PACKAGESPECTITLE'], "SpecificationId" => $finalResultSet['Result1'][0]['PackSpecTypeID']),
                "Inclusions" => $Inclusions,
                "PackageType" => $PackageType,
                "Validity" => array("From" => $currentDate, "To" => $PKGSELLVALIDTILL), //need help
                "Cities" => $Cities,
                "Transfers" => $transfers, //need discussion
                "OtherServices" => $OtherServices, //need discussion
                "Itineraries" => $Itineraries,
                "TourTypes" => $tourTypes,
                "Terms" => array("RefundPolicy" => htmlentities($finalResultSet['Result8'][0]['RefundPolicy'], ENT_QUOTES), "BookingTerms" => htmlentities(@$finalResultSet['Result8'][0]['BOOKINGTERMS'], ENT_QUOTES), "CancellationPolicy" => htmlentities(@$finalResultSet['Result8'][0]['CANCELLATIONPOLICY'], ENT_QUOTES), "Conditions" => htmlentities(@$finalResultSet['Result8'][0]['TERMSANDCONDITIONS'], ENT_QUOTES), "Exclusions" => htmlentities(@$finalResultSet['Result8'][0]['EXCLUSIONS'], ENT_QUOTES), "Inclusion" => htmlentities(@$finalResultSet['Result8'][0]['INCLUSIONS'], ENT_QUOTES), "TravelBasics" => htmlentities(@$finalResultSet['Result8'][0]['TRAVELBASICS'], ENT_QUOTES), "WhyUseUs" => htmlentities(@$finalResultSet['Result8'][0]['WHYUSEUS'], ENT_QUOTES)),
                "PackTypeMask" => 0, //need discussion
                "InclMask" => NULL, //need discussion
                "DiscountType" => 0, //need discussion
                "DiscountVal" => 0, //need discussion
                "CancellationRules" => $CancellationRules,
                "AllowBookingType" => (int) $finalResultSet['Result1'][0]['BookingType'],
                "fixedInventory" => $fixedInventoryArrayList
        ));

        $Fcountries = "";
        $KcountryIds = "";
        $countries = array_values($getCountryName);
        if (!empty($countries)) {
            $Fcountries = implode(",", $countries);
            $KcountryIds = implode(",", array_keys($getCountryName));
        }


        $Fdestinations = "";
        $Kdestinations = "";
        $destinations = array_values($getCityName);
        if (!empty($destinations)) {
            $Fdestinations = implode(",", $destinations);
            $Kdestinations = implode(",", array_keys($getCityName));
        }
        $nights = (int) $totalDay - 1;
        $PackageSearchString = $finalResultSet['Result1'][0]['SearchString'];
        if ($PackageSearchString != "") {
            $PackageSearchString = $finalResultSet['Result1'][0]['SearchString'];
        } else {
            $PackageSearchString = $Fdestinations;
        }
        $finalDataArray = array(
            "gtxPkgId" => $TPSYSID,
            "gtxPkgSourceId" => $gtxPkgSourceId,
            "agencyId" => $AgencyId,
            "isFeatured" => True,
            "displayIndex" => 0,
            "shortJsonInfo" => $PackageType,
            "longJsonInfo" => $dataArray,
            "PackageSearchString" => $PackageSearchString,
            "destinations" => $Fdestinations,
            "destinationIds" => $Kdestinations,
            "countries" => $Fcountries,
            "countryIds" => $KcountryIds,
            "minPrice" => min($minPrice),
            "maxPrice" => max($minPrice),
            "nights" => $nights,
            "minPax" => $AllowMinPax,
            "pkgValidFrom" => $currentDate,
            "pkgValidTo" => $PKGSELLVALIDTILL,
            "bookingValidUntil" => $PKGSELLVALIDTILL,
            "isPublished" => FALSE,
            "isActive" => TRUE,
            "isMarkForDel" => FALSE
        );
        $insertData = array(
            "GTXPkgId" => $TPSYSID,
            "GTXPkgSourceId" => $gtxPkgSourceId,
            "AgencySysId" => $TGAgencySysId,
            "IsFeatured" => True,
            "DisplayIndex" => False,
            "ItemType" => 1,
            "PackageType" => $gtxPkgSourceId,
            "PackageSearchString" => $PackageSearchString,
            "PackageSubType" => $PackageCostCalType,
            "ShortJsonInfo" => json_encode($PackageType),
            "LongJsonInfo" => json_encode($dataArray),
            "Destinations" => $Fdestinations,
            "DestinationsId" => $Kdestinations,
            "Countries" => $Fcountries,
            "CountryIds" => $KcountryIds,
            "MinPrice" => (float) min($minPrice),
            "MaxPrice" => (float) max($minPrice),
            "Nights" => $nights,
            "MinPax" => $AllowMinPax,
            "PackTypeMask" => "",
            "PackRangeType" => "",
            "PkgValidFrom" => $currentDate,
            "PkgValidUntil" => $PKGSELLVALIDTILL,
            "BookingValidUntil" => $PKGSELLVALIDTILL,
            "StarRating" => 3,
            "UpdateDate" => date("Y-m-d H:i:s"),
            "CreateDate" => date("Y-m-d H:i:s"),
            "PublishedOn" => date("Y-m-d H:i:s"),
            "CreatedBy" => isset(Travel_Model_AgencyAuth::getIdentity()->UserSysId) ? Travel_Model_AgencyAuth::getIdentity()->UserSysId : '1',
            "UpdatedBy" => isset(Travel_Model_AgencyAuth::getIdentity()->UserSysId) ? Travel_Model_AgencyAuth::getIdentity()->UserSysId : '1',
            "IsPublish" => false,
            "IsActive" => true,
            "IsMarkForDel" => false,
        );
        try {
            $dbtable = new Zend_Db_Table("TB_TBB2C_Packages_Master");
            $updateData = array(
                "UpdateDate" => date("Y-m-d H:i:s"),
                "UpdatedBy" => isset(Travel_Model_AgencyAuth::getIdentity()->UserSysId) ? Travel_Model_AgencyAuth::getIdentity()->UserSysId : '1',
                "IsMarkForDel" => true
            );
            $where = array("GTXPkgId=?" => $TPSYSID, "AgencySysId=?" => $TGAgencySysId);
            $dbtable->update($updateData, $where);
            $returnVal = $dbtable->insert($insertData);
        } catch (Zend_Exception $e) {
            echo $returnVal = $e->getMessage();
        }
        //exit;
        //        file_put_contents("data/" . time() . 'prasant.txt', $returnVal);
        header('Content-type: text/javascript');
        echo $ResultSet = $this->prettyPrint(Zend_Json::Encode($finalDataArray));

        return $returnVal;
    }

    function prettyPrint($json) {
        $result = '';
        $level = 0;
        $in_quotes = false;
        $in_escape = false;
        $ends_line_level = NULL;
        $json_length = strlen($json);

        for ($i = 0; $i < $json_length; $i++) {
            $char = $json[$i];
            $new_line_level = NULL;
            $post = "";
            if ($ends_line_level !== NULL) {
                $new_line_level = $ends_line_level;
                $ends_line_level = NULL;
            }
            if ($in_escape) {
                $in_escape = false;
            } else if ($char === '"') {
                $in_quotes = !$in_quotes;
            } else if (!$in_quotes) {
                switch ($char) {
                    case '}':
                    case ']':
                        $level--;
                        $ends_line_level = NULL;
                        $new_line_level = $level;
                        break;

                    case '{':
                    case '[':
                        $level++;
                    case ',':
                        $ends_line_level = $level;
                        break;

                    case ':':
                        $post = " ";
                        break;

                    case " ":
                    case "\t":
                    case "\n":
                    case "\r":
                        $char = "";
                        $ends_line_level = $new_line_level;
                        $new_line_level = NULL;
                        break;
                }
            } else if ($char === '\\') {
                $in_escape = true;
            }
            if ($new_line_level !== NULL) {
                $result .= "\n" . str_repeat("\t", $new_line_level);
            }
            $result .= $char . $post;
        }

        return $result;
    }

    public function maskString($dataArray, $maskArray) {
        $string = array();
        $h = 0;
        for ($i = 1; $i < count($maskArray); $i++) {
            if ($maskArray[$i] == 1) {
                $string[] = @$dataArray[$h]['TITLE'];
            }
            $h++;
        }
        $stringSET = "";
        $string = array_values($string);
        if (!empty($string)) {
            $stringSET = implode(',', $string);
        }
        return $stringSET;
    }

    public function maskArray($maskArray, $dataArray) {
        $string = array();
        $h = 0;
        for ($i = 1; $i < count($maskArray); $i++) {
            if ($maskArray[$i] == 1) {
                $string[$h]['AminityId'] = @$dataArray[$h]['AMINITYID'];
                $string[$h]['Title'] = @$dataArray[$h]['TITLE'];
            }
            $h++;
        }
        return $string;
    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit