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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

/* * *************************************************************
 * Catabatic Technology Pvt. Ltd.
 * File Name     : IndexController.php
 * File Desc.    : Index controller for home page front end
 * Created By    : Piyush Tiwari <piyush@catpl.co.in>
 * Created Date  : 27 June 2018
 * Updated Date  : ------------
 * ************************************************************* */

class IndexController extends Catabatic_CheckSession
{

    protected $objMdl;
    protected $tablename;
    protected $tablenameDestination;
    protected $baseUrl;
    protected $tollfreenumber;
    protected $objHelperGeneral;
    protected $per_page_record;
    public $_session;
    public $customerbookinglistAPIUrl;
    public $uploadPakcagePath;
    public $uploadDestinationPath;
    public $dummyImagePackage;
    public $dummyImageDestination;
    public $myNamespace;
    public $siteName;
    public $gtxBtoBsite;
    public $tablenameTes;
    public $tablePopularCity;
    public $hotelTypeArr;
    public $enableCache;
    public $packageTypeStatic;
    public $CurrencyRate;
    public $CurrencyTitle;
    public $configuration;
    public $amazonaws;
    public $stylecss;
    public $gtxagencysysid;
    private $respHashKey;
    private $aesResponseKey;
    private $aesResponseIv;
    private $aesRequestKey;
    private $CCAVENUEWorkingKey;
    private $SMSURL;
    private $SMSMETHOD;
    private $SMSAPIKEY;
    private $SMSSENDER;
    private $SMSFORMAT;
    public $API_GET_LANDING_PAGE_DATA;
    public  $API_LANDING_PAGE_LEAD;
    public $API_LANDING_PAGE_VISA;
    public $API_LANDING_PAGE_QUERY_PROPOSAL;
    public $API_LANDING_PAGE_DYNAMIC_QUERY;
    public $API_LANDING_PAGE_LEAD_UPDATE;
    public $API_LANDING_Master_DESTINATION;


    public function init()
    {
        parent::init();
        $aConfig = $this->getInvokeArg('bootstrap')->getOptions();
        $BootStrap = $aConfig['bootstrap'];
        $this->gtxagentsysid = $BootStrap['gtxagentsysid'];
        $this->siteName = $BootStrap['siteName'];

        $this->view->baseUrl = $this->baseUrl = $BootStrap['siteUrl'];
        $this->view->stylecss = $this->stylecss = $BootStrap['stylecss'];
        $this->tollfreenumber = $BootStrap['tollfreenumber'];
        $this->gtxagencysysid = $BootStrap['gtxagencysysid'];
        $this->gtxBtoBsite = $BootStrap['gtxBtoBsite'];
        $this->gtxwebserviceurl = $BootStrap['gtxwebserviceurl'];
        $this->objMdl = new Admin_Model_CRUD();

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

        $this->SMSURL = Catabatic_Helper::getSMSURL();
        $this->SMSMETHOD = Catabatic_Helper::getSMSMETHOD();
        $this->SMSAPIKEY = Catabatic_Helper::getSMSAPIKEY();
        $this->SMSSENDER = Catabatic_Helper::getSMSSENDER();
        $this->SMSFORMAT = Catabatic_Helper::getSMSFORMAT();

        $this->tablename = "tb_tbb2c_packages_master";
        $this->tablenameTes = "tbl_testimonials";
        $this->tablenameDestination = "tb_tbb2c_destinations";
        $this->tablePopularCity = 'tbl_popular_city';
        $this->hotelTypeArr = ['Standard', 'Deluxe', 'Luxury'];

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

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

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

        $this->enableCache = $BootStrap['enableCache'];
        $this->packageTypeStatic = $BootStrap['packageTypeDynamic'];

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

        $this->myNamespace = new Zend_Session_Namespace('MypopSess'); // get user end infomations
        $currencyType = $this->objMdl->selectOne('tbl_currency', ['*'], ['isActive' => 1, 'Title' => 'INR'], ['id' => 'ASC']);
        $currency_rate = $this->objMdl->selectOne('tbl_currency_rate', ['*'], ['FCurrencyType' => 1, 'TCurrencyType' => $currencyType->CurrencyId, 'isActive' => 1], ['cid' => 'ASC']);
        $this->CurrencyRate = $currency_rate->Rate;
        $this->CurrencyTitle = $currencyType->Title;
        $this->configuration = $BootStrap;
        $this->view->check_hotel_enable = $this->check_enabled_hotel_api();
        $this->view->amazonaws = $this->amazonaws = 'https://b2bzend.s3.ap-south-1.amazonaws.com/';
        //landing Page api
        $this->API_GET_LANDING_PAGE_DATA  =  $this->gtxBtoBsite . 'gtxwebservices/agency/get-landingpage-data';
        $this->API_LANDING_PAGE_LEAD = $this->gtxBtoBsite . 'gtxwebservices/lead';
        $this->API_LANDING_PAGE_VISA =  $this->gtxBtoBsite . 'gtxwebservices/visa';
        $this->API_LANDING_PAGE_QUERY_PROPOSAL = $this->gtxBtoBsite . 'gtxwebservices/query-proposal';
        $this->API_LANDING_PAGE_DYNAMIC_QUERY = $this->gtxBtoBsite . 'gtxwebservices/dynamic-query';
        $this->API_LANDING_PAGE_LEAD_UPDATE =  $this->gtxBtoBsite . 'gtxwebservices/lead-update';
        $this->API_LANDING_Master_DESTINATION = $this->gtxBtoBsite . 'webservice/master-data/destination';
        //        echo"<pre>";print_r($API_GET_LANDING_PAGE_DATA);die('ff');

    }

    public function riyatravelAction()
    {

        echo 'My IP Address: - ' . $_SERVER['REMOTE_ADDR'];
        echo 'Server IP Address: - ' . $_SERVER['SERVER_ADDR'];
        echo '<br>';
        $Authorization = base64_encode('RAIDR030010101*drea01:Riya@12');
        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_URL => 'http://testrws.mywebcheck.in/travelapi.svc/Login',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_POSTFIELDS => array('TerminalID' => 'RAIDR030010101', 'Username' => 'drea01', 'Password' => 'Riya@12'),
            CURLOPT_HTTPHEADER => array(
                'Authorization: Base64 UkFJRFIwMzAwMTAxMDEqZHJlYTAxOlJpeWFAMTI='
            ),
        ));

        $response = curl_exec($curl);

        curl_close($curl);
        echo $response;
        die('API');
    }

    public function webcheckinAction() {}

    //  ----------------- Function : Travelgpt Page View And OTP Verification   ------------------------------------
    public function travelgptAction()
    {
        $objFlight = new Travel_Model_FlightMaster();
        header('Access-Control-Allow-Origin: *');
        if ($this->getRequest()->isPost()) {
            $data = $this->getRequest()->getParams();
            $Leadsession = new Zend_Session_Namespace('leadSession');
            $LeadSessionArray = $Leadsession->LeadSession;
            $leadDetails = $objFlight->getLeadDeailsByLeadID($LeadSessionArray['LastInsertId']);
            $otp = $leadDetails['otp'];
            $votpArray = array();
            $votpArray[0] = $data['otp1'];
            $votpArray[1] = $data['otp2'];
            $votpArray[2] = $data['otp3'];
            $votpArray[3] = $data['otp4'];
            $votpString = implode('', $votpArray);
            if ($votpString == $otp) {
                $response = array('status' => true, 'message' => "Your OTP has been successfully verified. Kindly wait momentarily while we prepare your itinerary.");
                echo json_encode($response);
                exit;
            } else {
                $response = array('status' => false, 'message' => "Wrong OTP entered. Please input the correct OTP.");
                echo json_encode($response);
                exit;
            }
        }
    }

    public function travelgptgetapiAction()
    {
        header('Access-Control-Allow-Origin: *');
        if ($this->getRequest()->isPost()) {
            $data = $this->getRequest()->getParams();
            // Start a session
            $session = new Zend_Session_Namespace('TravelSession');

            $clientData = [
                'location' => $data['chat_location'],
                'travel_date' => date('d/m/Y', strtotime($data['chat_date'])),
                'no_of_nights' => $data['chat_night'],
                'vacation_purpose' => $data['chat_vacation_purpose'],
                'vacation_type' => $data['chat_vacation_type']
            ];
            // Save data to session
            $session->clientData = $clientData;
            if (!empty($session->clientData)) {
                $response = array('status' => true, 'location' => $clientData['location']);
                echo json_encode($response);
                exit;
            } else {
                $response = array('status' => false, 'message' => "session not created");
                echo json_encode($response);
                exit;
            }
        }
    }

    //  ----------------- Function : Send OTP   ------------------------------------
    public function sendotpAction()
    {
        header('Access-Control-Allow-Origin: *');
        $objFlight = new Travel_Model_FlightMaster();
        $session = new Zend_Session_Namespace('TravelSession');
        $clientdata = $session->clientData;
        if ($this->getRequest()->isPost()) {
            $data = $this->getRequest()->getParams();
            $randomString = $this->randomString();
            $MobileNumber = $data['chat_mobile'];

            $chatrequest = "Build a day wise travel itinerary for " . $clientdata['location'] . " for " . $clientdata['travel_date'] . " for " . $clientdata['no_of_nights'] . " Nights For " . $clientdata['vacation_purpose'] . " For " . $clientdata['vacation_type'] . "";

            $clientdata2 = [
                'salutation' => $data['salutation'],
                'fname' => $data['chat_fname'],
                'lname' => $data['chat_lname'],
                'email' => $data['chat_email'],
                'mobile' => $data['chat_mobile'],
                'countryCode' => $data['chat_countrycode'],
                'otp' => $randomString,
                'location' => $clientdata['location'],
                'travel_date' => $clientdata['travel_date'],
                'no_of_nights' => $clientdata['no_of_nights'],
                'vacation_purpose' => $clientdata['vacation_purpose'],
                'vacation_type' => $clientdata['vacation_type'],
                'lead_request' => $chatrequest,
                'create_date' => date('Y-m-d-H-i-s'),
            ];

            $LastInsertId = $objFlight->InsertChatgptEnqueryData($clientdata2);
            $Leadsession = new Zend_Session_Namespace('leadSession');
            $LeadSessionarray = ['LastInsertId' => $LastInsertId, 'LeadRequest' => $chatrequest];
            $Leadsession->LeadSession = $LeadSessionarray;
            $message = "Hi,\nUse $randomString as OTP (One Time Password) to verify your mobile number. Do not share this OTP with anyone for security reason.\nThanks\n$this->siteName\nTRVCRM";
            $this->postFields = "";
            $this->postFields .= "&method=$this->SMSMETHOD";
            $this->postFields .= "&api_key=$this->SMSAPIKEY";
            $this->postFields .= "&sender=$this->SMSSENDER";
            $this->postFields .= "&message=$message";
            $this->postFields .= "&format=$this->SMSFORMAT";
            $this->postFields .= "&to=" . substr($MobileNumber, -10);
            $postURL = $this->SMSURL;

            if ($data['chat_mobile']) {
                $resultVal = $objFlight->sendSmsDetails($postURL, $this->postFields, array('AgencySysId' => $this->gtxagencysysid), $this->IsSMSApi, 0);
            }
            if ($resultVal['response']['status'] == 'OK') {
                $response = array('status' => true, 'phone' => $data['chat_mobile'], 'countryCode' => $data['chat_countrycode']);
                echo json_encode($response);
                exit;
            } else {
                $response = array('status' => false, 'message' => "Otp Not Send");
                echo json_encode($response);
                exit;
            }
        }
    }

    //  ----------------- Function : Resend OTP   ------------------------------------
    public function resendotpAction()
    {
        header('Access-Control-Allow-Origin: *');
        $objFlight = new Travel_Model_FlightMaster();
        $Leadsession = new Zend_Session_Namespace('leadSession');
        $LeadSessionData = $Leadsession->LeadSession;
        if ($this->getRequest()->isPost()) {
            $leadid = $LeadSessionData['LastInsertId'];
            $leadDetails = $objFlight->getLeadDeailsByLeadID($leadid);
            $randomString = $this->randomString();
            $MobileNumber = $leadDetails['mobile'];

            $updateData = ['otp' => $randomString];
            $where = "lead_id = " . $leadDetails['lead_id'];
            $objFlight->updateLeadResponse($updateData, $where);
            $message = "Hi,\nUse $randomString as OTP (One Time Password) to verify your mobile number. Do not share this OTP with anyone for security reason.\nThanks\n$this->siteName\nTRVCRM";
            $this->postFields = "";
            $this->postFields .= "&method=$this->SMSMETHOD";
            $this->postFields .= "&api_key=$this->SMSAPIKEY";
            $this->postFields .= "&sender=$this->SMSSENDER";
            $this->postFields .= "&message=$message";
            $this->postFields .= "&format=$this->SMSFORMAT";
            $this->postFields .= "&to=" . substr($MobileNumber, -10);
            $postURL = $this->SMSURL;

            if ($MobileNumber) {
                $resultVal = $objFlight->sendSmsDetails($postURL, $this->postFields, array('AgencySysId' => $this->gtxagencysysid), $this->IsSMSApi, 0);
            }
            if ($resultVal['response']['status'] == 'OK') {
                $response = array('status' => true);
                echo json_encode($response);
                exit;
            } else {
                $response = array('status' => false);
                echo json_encode($response);
                exit;
            }
        }
    }

    //  ----------------- Function : Travelgpt Details   ------------------------------------  
    public function travelgptdetailsAction()
    {
        $objFlight = new Travel_Model_FlightMaster();
        $Leadsession = new Zend_Session_Namespace('leadSession');
        $LeadSessionArray = $Leadsession->LeadSession;
        if (isset($LeadSessionArray)) {
            $leadDetails = $objFlight->getLeadDeailsByLeadID($LeadSessionArray['LastInsertId']);
            if (!empty($leadDetails)) {
                if ($leadDetails['lead_response'] == '') {

                    //  ----------------- Create GTX Lead  ------------------------------------
                    $days = (int) ($leadDetails['no_of_nights'] + 1);
                    $queryArr = [
                        'AgencySysId' => $this->gtxagencysysid,
                        'AgentSysId' => $this->gtxagencysysid,
                        'leadsend' => '',
                        'ToDestination' => $leadDetails['location'],
                        'PlanType' => 0,
                        'leadID' => 0,
                        'Email' => trim($leadDetails['email']),
                        'CountryCode' => trim($leadDetails['countryCode']),
                        'MobileNumber' => (int) ($leadDetails['mobile']),
                        'Salutation' => (int) ($leadDetails['salutation']),
                        'FirstName' => trim($leadDetails['fname']),
                        'LastName' => trim($leadDetails['lname']),
                        'traveldate' => trim($leadDetails['travel_date']),
                        'Noofdays' => $days,
                    ];

                    $GtxLeadid = $this->CreateGtxLead($queryArr);
                    //  ----------------- Create GTX Lead  ------------------------------------
                    //  ----------------- Chatgpt Response  ------------------------------------
                    $TravelgptResponseContent = $this->ChatgptResponse($LeadSessionArray['LeadRequest']);
                    //  ----------------- Chatgpt Response  ------------------------------------
                    $updateData = ['lead_response' => $TravelgptResponseContent, 'gtxLeadId' => $GtxLeadid];
                    $where = "lead_id = " . $leadDetails['lead_id'];
                    $objFlight->updateLeadResponse($updateData, $where);
                } else {
                    $GtxLeadid = $leadDetails['gtxLeadId'];
                    $TravelgptResponseContent = $leadDetails['lead_response'];
                }

                //  ----------------- Recommended Tours Packages   ------------------------------------     
                if ((isset($leadDetails['location']) && !empty($leadDetails['location']))) {
                    $temp = explode(",", $leadDetails['location']);
                    $str = $operator = '';
                    foreach ($temp as $k => $val) {
                        $operator = ($k != 0) ? ' OR ' : '';
                        if ($val) {
                            $str .= " $operator Destinations LIKE ('%" . $val . "%') OR Countries LIKE ('%" . $val . "%') ";
                        }
                    }
                    if ($str) {
                        $whereDestination .= ' (' . $str . ') ';
                    }
                }
                $currentTime = date('Y-m-d 00:00:00');
                $whereCustom = " (1=1) ";
                $whereCustom .= ($whereDestination) ? " AND $whereDestination " : "";
                $whereCustom .= "AND MinPrice !=0";
                $whereCustom .= " AND ( (`PkgValidFrom` <= '$currentTime') AND (`PkgValidUntil` >= '$currentTime') ) ";
                $whereCustom .= " AND ( `BookingValidUntil` >= '$currentTime')  ";

                $packagesTours = $this->objMdl->rv_select_all_custom_query('tb_tbb2c_packages_master', ['PkgSysId', 'Image', 'GTXPkgId', 'Destinations', 'DestinationsId', 'Countries', 'BookingValidUntil', 'LongJsonInfo', 'Nights', 'StarRating', 'PackageType', 'PackageSubType', 'MinPrice'], ['IsActive' => 1, 'IsPublish' => 1, 'IsMarkForDel' => 0, 'AgencySysId' => $this->gtxagencysysid], $whereCustom, ['MinPrice' => 'ASC'], 20);

                foreach ($packagesTours as $key => $value) {

                    $destinationArr = explode(',', $value['Destinations']); // get the first destination only by extracting array
                    if ($value['Destinations'] != "") {
                        $destinationArr = explode(',', $value['Destinations']);
                        $checkdata = $this->objMdl->selectOne('tb_tbb2c_destinations', ['DesId'], ['Title' => $destinationArr[0]]);
                    }

                    $LongJsonInfo = Zend_Json::decode($value['LongJsonInfo']);

                    if (isset($_SESSION['TravelAgent']['session']) && !empty($_SESSION['TravelAgent']['session'])) {
                        $categoryDetails = $this->objHelperGeneral->getCategoryAndPriceArray($LongJsonInfo['package']['TourTypes']['MarketType'], 'B2B', $value['PackageType'], $value['PackageSubType']); // get default category
                    } else {
                        $categoryDetails = $this->objHelperGeneral->getCategoryAndPriceArray($LongJsonInfo['package']['TourTypes']['MarketType'], 'B2C', $value['PackageType'], $value['PackageSubType']); // get default category
                    }
                    if (isset($value['Image']) && ($value['Image'] != '')) {

                        $tourImage1 = explode(',', $value['Image']);
                        if ($tourImage1[0] != '') {
                            $tourImage = $this->baseUrl . 'public/upload/' . $this->stylecss . '/tours/' . $value['PkgSysId'] . '/{size}/' . $tourImage1[0];
                        } else if ($tourImage1[1] != '') {
                            $tourImage = $this->baseUrl . 'public/upload/' . $this->stylecss . '/tours/' . $value['PkgSysId'] . '/{size}/' . $tourImage1[1];
                        }
                    } else {
                        $tourImage = $LongJsonInfo['package']['ImgThumbnail'];
                    }
                    $defaultCategoryId = $categoryDetails['defaultCategoryId'];
                    $defaultCategory = $categoryDetails['defaultCategory'];
                    $defaultTourType = $categoryDetails['defaultTourType'];
                    $TPId = ($value['PackageType'] == $this->packageTypeStatic) ? $LongJsonInfo['package']['TPId'] : $categoryDetails['TPId'];
                    $MPType = (!empty($categoryDetails['MPType']) && ($categoryDetails['MPType'] != 'LowestCost')) ? array_search($categoryDetails['MPType'], unserialize(CONST_MEAL_PLAN_ARR)) : 0;
                    $tourTypeChar = ($defaultTourType == 1) ? 'P' : 'G'; // if private than P else G for Group tour type
                    $priceArrJson = $categoryDetails['priceArrJson'];
                    $displayFinalPrice = $this->objHelperGeneral->getPackagePrice($defaultCategoryId, $tourTypeChar, $priceArrJson, true);  // Param 4: true ( if calculate discounted price )
                    $getCurrencyType = $priceArrJson[$tourTypeChar][$defaultCategoryId]['price'][0]['Currency'];
                    $defaultCategoryIdm = isset($LongJsonInfo['package']['Itineraries']['Itinerary'][0]['ItineraryItem'][1]['Items'][0]['Id']) ? $LongJsonInfo['package']['Itineraries']['Itinerary'][0]['ItineraryItem'][1]['Items'][0]['Id'] : 0;

                    $toursFinal[] = [
                        'name' => $this->objHelperGeneral->trimContent($LongJsonInfo['package']['Name'], 20),
                        'nameF' => trim($LongJsonInfo['package']['Name']), // full name of package name
                        'img' => $tourImage,
                        'night' => $value['Nights'],
                        'price' => $this->objHelperGeneral->moneyFormatINR(round($displayFinalPrice)),
                        'currencyType' => $currencyTypeArray[$getCurrencyType],
                        'star' => $value['StarRating'],
                        'QuadPrice' => ($LongJsonInfo['QuadPrice'] != '') ? $LongJsonInfo['QuadPrice'] : 0,
                        'Destination' => $value['Destinations'],
                        'DestinationsId' => $value['DestinationsId'],
                        'PkgSysId' => $value['PkgSysId'],
                        'GTXPkgId' => $value['GTXPkgId'],
                        'defaultCategoryId' => ($defaultCategoryId != '') ? $defaultCategoryId : $defaultCategoryIdm,
                        'defaultCategory' => $defaultCategory,
                        'tourtype' => ($defaultTourType != '') ? $defaultTourType : 1,
                        'TPId' => $TPId,
                        'PackageType' => $value['PackageType'],
                        'mp' => $MPType,
                        'Countries' => $value['Countries'],
                        'isFixedDeparturesPackage' => $LongJsonInfo['package']['IsFixedDeparturePackage'],
                        'BookingValidUntil' => $value['BookingValidUntil'],
                        'oldPrice' => $value['oldPrice'],
                    ];
                }

                //  ----------------- Recommended Tours Packages   ------------------------------------   

                $this->view->Leadid = $leadDetails['lead_id'];
                $this->view->gtxLeadId = $GtxLeadid;
                $this->view->TravelgptRequest = $leadDetails['no_of_nights'] . " nights travel itinerary for " . ucwords($leadDetails['location']) . " for a " . strtolower($leadDetails['vacation_purpose']) . " trip";
                $this->view->TravelgptResponse = $TravelgptResponseContent;
                $this->view->packagesTours = $toursFinal;
            } else {
                $this->_redirect("travelgpt");
            }
        } else {
            $this->_redirect("travelgpt");
        }
    }

    //  ----------------- Function : Create GTX Lead   ------------------------------------     
    public function CreateGtxLead($queryArr)
    {
        try {
            $curl = curl_init($this->gtxBtoBsite . "gtxwebservices/lead"); // b2c site url
            curl_setopt($curl, CURLOPT_POST, true);
            curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($queryArr));
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            $response = json_decode(curl_exec($curl));
            curl_close($curl);
            $responseData = $response->leadID;
            return $responseData;
        } catch (Exception $ex) {
            $message = $this->view->error_msg = $ex->getMessage();
            $status = false;
        }
    }

    //  ----------------- Function : Update Remark   ------------------------------------     
    public function updateRemarkAction()
    {
        header('Access-Control-Allow-Origin: *');
        if ($this->getRequest()->isPost()) {
            $objFlight = new Travel_Model_FlightMaster();
            $data = $this->getRequest()->getParams();
            $leadId = $data['leadId'];
            $gtxleadId = $data['gtxid'];
            $remark = $data['remark'];
            $updateData = array('remark' => $remark);
            $where = "lead_id = " . $leadId;
            $objFlight->updateLeadResponse($updateData, $where);
            $leadDetails = $objFlight->getLeadDeailsByLeadID($leadId);
            $queryUpdateArr = [
                'AgencySysId' => $this->gtxagencysysid,
                'leadID' => (int) $gtxleadId,
                'PlanType' => 0,
                'PKGCheckInDate' => $leadDetails['travel_date'],
                'Noofdays' => ($leadDetails['no_of_nights'] + 1),
                'Destination' => '',
                'FromDestinationId' => '',
                'ToDestination' => $leadDetails['location'],
                'ToDestinationId' => '',
                'message' => $remark,
            ];

            try {
                $curl = curl_init($this->gtxBtoBsite . "gtxwebservices/lead-update"); // b2c site url
                curl_setopt($curl, CURLOPT_POST, true);
                curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($queryUpdateArr));
                curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
                $responseArr = json_decode(curl_exec($curl), 1);
                $status = true;
                curl_close($curl);
                if ($responseArr['status'] == 'success') {
                    echo json_encode(array('status' => true, 'message' => "Remark Successfully Submited"));
                    exit;
                } else {
                    echo json_encode(array('status' => false, 'message' => "Remark Not Submit"));
                    exit;
                }
            } catch (Exception $ex) {
                $message = $this->view->error_msg = $ex->getMessage();
                $status = false;
                echo json_encode(array('status' => $status, 'message' => "Remark Not Submit"));
                exit;
            }
        }
    }

    //  ----------------- Function : Chatgpt Api   ------------------------------------     
    public function ChatgptResponse($chat_request)
    {
        $openaiApiKey = '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'; // API Key
        $apiEndpoint = 'https://api.openai.com/v1/chat/completions'; // API Url
        $requestData = json_encode([
            'model' => 'gpt-3.5-turbo',
            'messages' => [
                ['role' => 'system', 'content' => 'You are a helpful assistant.'],
                ['role' => 'user', 'content' => $chat_request],
            ],
        ]);
        $ch = curl_init($apiEndpoint);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $requestData);
        curl_setopt($ch, CURLOPT_HTTPHEADER, [
            'Content-Type: application/json',
            'Authorization: Bearer ' . $openaiApiKey,
        ]);

        $response = curl_exec($ch);
        if (curl_errno($ch)) {
            echo 'Curl error: ' . curl_error($ch);
        }
        curl_close($ch);
        $responseData = json_decode($response, true);

        if ($responseData['choices'][0]['message']['content']) {
            $responseData = $responseData['choices'][0]['message']['content'];
            return $responseData;
        } else {
            $errorMessage = '';
            return $errorMessage;
        }
    }

    public function randomString()
    {
        $length = 4;
        $chars = "0123456789";
        $str = "";
        for ($i = 0; $i < $length; $i++) {
            $str .= $chars[mt_rand(0, strlen($chars) - 1)];
        }
        return $str;
    }

    public function indexAction()
    {
        // Zend_Session::namespaceUnset('CurrencyId');
        $CurrencyId = new Zend_Session_Namespace('CurrencyId');
        if ($this->gtxagencysysid == '41279') {
            $DCurrencyId = (isset($CurrencyId->params) && !empty($CurrencyId->params)) ? trim($CurrencyId->params) : '1';
        } else {
            $DCurrencyId = (isset($CurrencyId->params) && !empty($CurrencyId->params)) ? trim($CurrencyId->params) : '1';
        }
        $apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CurrencyData($this->gtxagencysysid, $DCurrencyId);
        //$sdsd = json_decode('',1);
        // $appSiteMapService = new Travel_Model_AppSiteMapService($sitemapPageLink);
        // $siteMapResult = $appSiteMapService->generateSiteMap($sitemapPageLink);
        // if ($this->gtxagencysysid == '36328') {
        // echo "<pre>";print_r($DCurrencyId);
        // echo "<pre>";print_r($apiResponse);
        // echo "<pre>";print_r($this->_session->session);
        // die('dd');
        // }
		
		$crud = new Admin_Model_CRUD();
	$crud->checkTblregions();
	$crud->checkTblCountries();
	$crud->checkTblStates();
	$crud->checkTblDestinations();
	$crud->checkTblPacktype();
	$crud->checkTblTravelogues();
	$crud->checkTblOurServices();
	$crud->checkTblStaticPages();
	$crud->checkTblPackMaster();
	$crud->checkTblcommonBox();

        if ($this->gtxagencysysid == '1111sd') {
            echo $baseUrl = 'https://www.travelidea.in/';
            $sitemapPageLink = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->sitemapPageLink($baseUrl);
            $appSiteMapService = new Travel_Model_AppSiteMapService($sitemapPageLink);
            $siteMapResult = $appSiteMapService->generateSiteMap($sitemapPageLink);
            echo "<pre>";
            print_r($siteMapResult);
            echo "<pre>";
            print_r($sitemapPageLink);
            die('s');
            $html = new Zend_View();
            $html->setScriptPath(APPLICATION_PATH . '/views/scripts/index/');
            $bodyText = $html->render('comingsoon.phtml');
            echo $bodyText;
            die;
            // die('We are preparing for going to live ...');
            // ini_set('display_errors', 1);
            // ini_set('display_startup_errors', 1);
            // error_reporting(E_ALL);
        }
        if ($this->gtxagencysysid == '4539') {
            $data = array(
                'AgencySysId' => $this->gtxagencysysid,
                'ServiceFee' => 0,
                'CriteriaValue' => 0,
                'ProductType' => 1,
                'TravelDate' => date('Y-m-d'),
            );

            $availableCoupon = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->availableCoupon($data);
            $availableCouponList = isset($availableCoupon['data']) ? $availableCoupon['data'] : [];
            $this->view->availableCouponList = $availableCouponList;
        }
        Zend_Session::namespaceUnset('sessionFlightSearchParams');
        Zend_Session::namespaceUnset('FlightBookingTicketSession');
        Zend_Session::namespaceUnset('FlightBookingData');
        Zend_Session::namespaceUnset('FlightBookingDataInbound');
        Zend_Session::namespaceUnset('SelectedMealSessionNew');
        Zend_Session::namespaceUnset('SelectedBaggSessionNew');
        Zend_Session::namespaceUnset('SelectedMealSessionNewInb');
        Zend_Session::namespaceUnset('SelectedBaggSessionNewInb');
        Zend_Session::namespaceUnset('flightSSRDetailsInb');
        Zend_Session::namespaceUnset('flightSSRDetails');

        $currencyTypeArray = $this->objHelperGeneral->getCurrencyData();
        $decodedPackageDestinationArray = array();
        $geoCityData = $this->objMdl->getAllCountyDetailForHomePage();
        $arrContextOptions = array(
            "ssl" => array(
                "verify_peer" => false,
                "verify_peer_name" => false,
            ),
        );
        $param = $this->getRequest()->getParams();
        $this->view->getParams = $param;
        $this->view->CurrencyTitle = $this->CurrencyTitle;
        $result = $this->objMdl->getCmsdata('tbl_home_common_box', ['*'], ['home_common_id' => 1], ['home_common_id' => 'DESC']);
        $popularTourContent = json_decode($result->popularTourContent, 1);
        $destinationContent = json_decode($result->destinationContent, 1);
        $perfectTourContent = json_decode($result->perfectTourContent, 1);
        $blogContent = json_decode($result->blogContent, 1);
        $offersContent = json_decode($result->offersContent, 1);
        $statesContent = isset($result->statesContent) ? json_decode($result->statesContent, 1) : array();
        $countriesContent = isset($result->countriesContent) ? json_decode($result->countriesContent, 1) : array();
        $whychooseusContent = isset($result->whychooseusContent) ? json_decode($result->whychooseusContent, 1) : array();
        $happycustomerContent = isset($result->happycustomerContent) ? json_decode($result->happycustomerContent, 1) : array();
        $otherUsefulContent = isset($result->otherUsefulContent) ? json_decode($result->otherUsefulContent, 1) : array();
        $interestingFactsContent = isset($result->interestingFactsContent) ? json_decode($result->interestingFactsContent, 1) : array();
		
		 $detailLayout['FAQschema'] = isset($result->FAQschema) ? $result->FAQschema : '';
		 $detailLayout['HTagDescription'] = isset($result->HTagDescription) ? $result->HTagDescription : '';
		 $detailLayout['FAQ'] = isset($result->FAQ) ? $result->FAQ : '';		
		 $this->view->detailLayout = $detailLayout;
 
        $url = $this->baseUrl . 'public/data/dynamic/car_station.json';
        $carstationArray = file_get_contents($url, false, stream_context_create($arrContextOptions));

        $nationalityArray = $this->hotel_nationality_list();
        if (!empty($carstationArray)) {
            $decodedcarstationArray = Zend_Json::decode($carstationArray);
        }

        $destinatonTop = $destinationJsonArray = array();
        if ($destinationContent['destinations_check'] == 1) {
            //echo "<pre>";print_r($this->stylecss );die;
            if ($this->stylecss == 'lts' || $this->stylecss == 'uamongus' || $this->stylecss == 'bigvalue' || $this->stylecss == 'ushaholidays' || $this->stylecss == 'goflysmart' || $this->stylecss == 'unitedtoursandtravels' || $this->stylecss == 'flywelltours' || $this->stylecss == 'bookmytournow' || $this->stylecss == 'ktas' || $this->stylecss == 'crossworld' || $this->stylecss == 'incredible' || $this->stylecss == 'flightguruonline' || $this->stylecss == 'sterling' || $this->stylecss == 'thekrishnatravels' || $this->stylecss == 'rahattravels') {
                $urlDes = $this->baseUrl . 'public/upload/' . $this->stylecss . '/data/package_destinations.json';
                $destinationJson = file_get_contents($urlDes, false, stream_context_create($arrContextOptions));
                //echo"<pre>";print_r($destinationJson);die;
                $destinationJsonArray = !empty($destinationJson) ? json_decode($destinationJson, 1) : array();
                // echo "<pre>";print_r($destinationJsonArray);die;
            } //else {
            $destinatonTop = $this->objMdl->rv_select_all($this->tablenameDestination, ['DesSysId', 'Title', 'Activities', 'Hotels', 'Tours', 'Image', 'DestDescription'], ['IsActive' => 1, 'IsFeatured' => 1, 'IsMarkForDel' => 0], ['tbl.DesSysId' => 'ASC'], 8);
            // }
        }

        $destinatonSerach = $this->objMdl->rv_select_all($this->tablenameDestination, ['DesSysId', 'Title', 'Activities', 'Hotels', 'Tours', 'Image', 'DestDescription'], ['IsActive' => 1, 'IsMarkForDel' => 0, 'DisplayOnHeader' => 1], ['tbl.DesSysId' => 'ASC'], 8);
        // echo "<pre>";print_r($destinatonSerach);die;
        $destinatonTopArr = array();
        foreach ($destinatonTop as $topdesKey => $topdesValue) {
            $desTitleValue = $topdesValue['Title'];
            $whereCustom = ($desTitleValue) ? " ( Destinations LIKE '%{$desTitleValue}%' )" : "";
            $tourResult = $this->objMdl->rv_select_row_where_custom($this->tablename, ['count(*) as totalCount'], ['IsMarkForDel' => 0, 'IsActive' => 1, 'IsPublish' => 1, 'ItemType' => 1], $whereCustom, [], '');
            $destinatonTopArr[] = [
                'DesSysId' => $topdesValue['DesSysId'],
                'Title' => $topdesValue['Title'],
                'Activities' => $topdesValue['Activities'],
                'Hotels' => $topdesValue['Hotels'],
                'Tours' => $topdesValue['Tours'],
                'Image' => $topdesValue['Image'],
                'DestDescription' => $topdesValue['DestDescription'],
                'totalCount' => $tourResult['totalCount']
            ];
        }

        $this->view->destinatonSerach = $destinatonSerach;
        $this->view->destinations = $destinatonTopArr;
        $this->view->baseUrl = $this->baseUrl;
        $this->view->tollfreenumber = $this->tollfreenumber;
        $this->view->siteName = $this->siteName;

        $trendingTours = array();
        if ($perfectTourContent['domestic_check'] == 1) {
            $trendingTours = $this->objMdl->rv_select_all('tb_tbb2c_packages_master', ['PkgSysId', 'Image', 'MainImage', 'GTXPkgId', 'Destinations', 'Countries', 'BookingValidUntil', 'LongJsonInfo', 'Nights', 'StarRating', 'PackageType', 'PackageSubType', 'oldPrice'], ['IsActive' => 1, 'IsPublish' => 1, 'IsMarkForDel' => 0, 'ItemType' => 1, 'IsFeatured' => 1, 'countryIds' => 101], ['PkgSysId' => 'DESC'], 20);
        }

        $trendingToursinter = array();
        if ($popularTourContent['international_check'] == 1) {
            $trendingToursinter = $this->objMdl->rv_select_all('tb_tbb2c_packages_master', ['PkgSysId', 'Image', 'MainImage', 'GTXPkgId', 'Destinations', 'Countries', 'BookingValidUntil', 'LongJsonInfo', 'Nights', 'StarRating', 'PackageType', 'PackageSubType', 'oldPrice'], ['IsActive' => 1, 'IsPublish' => 1, 'IsMarkForDel' => 0, 'ItemType' => 1, 'IsFeatured' => 1, 'countryIds!' => 101], ['PkgSysId' => 'DESC'], 20);
        }

        $trendingActivities = $this->objMdl->rv_select_all('tb_tbb2c_packages_master', ['PkgSysId', 'Image', 'GTXPkgId', 'Destinations', 'Countries', 'BookingValidUntil', 'LongJsonInfo', 'Nights', 'StarRating', 'PackageType', 'PackageSubType', 'oldPrice'], ['IsActive' => 1, 'IsPublish' => 1, 'IsMarkForDel' => 0, 'ItemType' => 3, 'IsFeatured' => 1], ['PkgSysId' => 'DESC'], 12);
        $whyChooses = $this->objMdl->rv_select_all('tbl_ourpartner', ['id', 'title', 'icon', 'url', 'tab', 'description'], ['isb2b' => 0, 'status' => 1, 'IsMarkForDel' => 0], ['id' => 'DESC'], 50);
        $this->view->whyChooses = $whyChooses;
        //domestic  
        foreach ($trendingTours as $key => $value) {
            $destinationArr = explode(',', $value['Destinations']); // get the first destination only by extracting array
            $LongJsonInfo = Zend_Json::decode($value['LongJsonInfo']);
            if (isset($_SESSION['TravelAgent']['session']) && !empty($_SESSION['TravelAgent']['session'])) {
                $categoryDetails = $this->objHelperGeneral->getCategoryAndPriceArray($LongJsonInfo['package']['TourTypes']['MarketType'], 'B2B', $value['PackageType'], $value['PackageSubType']); // get default category
            } else {
                $categoryDetails = $this->objHelperGeneral->getCategoryAndPriceArray($LongJsonInfo['package']['TourTypes']['MarketType'], 'B2C', $value['PackageType'], $value['PackageSubType']); // get default category
            }
            if (isset($value['MainImage']) && ($value['MainImage'] != '')) {
                //die($LongJsonInfo['package']['ImgThumbnail']);
                $tourImage1 = explode(',', $value['MainImage']);
                if ($tourImage1[0] != '') {
                    $tourImage = $this->baseUrl . 'public/upload/' . $this->stylecss . '/tours/' . $value['PkgSysId'] . '/{size}/' . $tourImage1[0];
                } else if ($tourImage1[1] != '') {
                    $tourImage = $this->baseUrl . 'public/upload/' . $this->stylecss . '/tours/' . $value['PkgSysId'] . '/{size}/' . $tourImage1[1];
                }
            } else if (isset($value['Image']) && ($value['Image'] != '')) {
                //die($LongJsonInfo['package']['ImgThumbnail']);
                $tourImage1 = explode(',', $value['Image']);
                if ($tourImage1[0] != '') {
                    $tourImage = $this->baseUrl . 'public/upload/' . $this->stylecss . '/tours/' . $value['PkgSysId'] . '/{size}/' . $tourImage1[0];
                } else if ($tourImage1[1] != '') {
                    $tourImage = $this->baseUrl . 'public/upload/' . $this->stylecss . '/tours/' . $value['PkgSysId'] . '/{size}/' . $tourImage1[1];
                }
            } else {
                $tourImage = $LongJsonInfo['package']['ImgThumbnail'];
            }
            $defaultCategoryId = $categoryDetails['defaultCategoryId'];
            $defaultCategory = $categoryDetails['defaultCategory'];
            $defaultTourType = $categoryDetails['defaultTourType'];
            $TPId = ($value['PackageType'] == $this->packageTypeStatic) ? $LongJsonInfo['package']['TPId'] : $categoryDetails['TPId'];
            $MPType = (!empty($categoryDetails['MPType']) && ($categoryDetails['MPType'] != 'LowestCost')) ? array_search($categoryDetails['MPType'], unserialize(CONST_MEAL_PLAN_ARR)) : 0;
            $tourTypeChar = ($defaultTourType == 1) ? 'P' : 'G'; // if private than P else G for Group tour type
            $priceArrJson = $categoryDetails['priceArrJson'];
            $displayFinalPrice = $this->objHelperGeneral->getPackagePrice($defaultCategoryId, $tourTypeChar, $priceArrJson, true);  // Param 4: true ( if calculate discounted price )
            $getCurrencyType = $priceArrJson[$tourTypeChar][$defaultCategoryId]['price'][0]['Currency'];
            $defaultCategoryIdm = isset($LongJsonInfo['package']['Itineraries']['Itinerary'][0]['ItineraryItem'][1]['Items'][0]['Id']) ? $LongJsonInfo['package']['Itineraries']['Itinerary'][0]['ItineraryItem'][1]['Items'][0]['Id'] : 0;
            $currencyType = $currencyTypeArray[$getCurrencyType];
            $exchangeRate = 1;
            if ($this->gtxagencysysid == 98196 && $getCurrencyType == 93) {
                $exchangeRate = $this->objHelperGeneral->currencyExchangeRate($getCurrencyType, 2, 0);
                $displayFinalPrice = (int) ($displayFinalPrice * $exchangeRate);
                $currencyType = 'USD';
            }
            $toursFinal[] = [
                'name' => $this->objHelperGeneral->trimContent($LongJsonInfo['package']['Name'], 24),
                'nameF' => trim($LongJsonInfo['package']['Name']), // full name of package name
                'img' => $tourImage,
                'night' => $value['Nights'],
                'price' => $this->objHelperGeneral->moneyFormatINR(round($displayFinalPrice)),
                'currencyType' => $currencyType,
                'star' => $value['StarRating'],
                'Destination' => $value['Destinations'],
                'PkgSysId' => $value['PkgSysId'],
                'GTXPkgId' => $value['GTXPkgId'],
                'defaultCategoryId' => ($defaultCategoryId != '') ? $defaultCategoryId : $defaultCategoryIdm,
                'defaultCategory' => $defaultCategory,
                'tourtype' => ($defaultTourType != '') ? $defaultTourType : 1,
                'TPId' => $TPId,
                'PackageType' => $value['PackageType'],
                'mp' => $MPType,
                'Countries' => $value['Countries'],
                'isFixedDeparturesPackage' => $LongJsonInfo['package']['IsFixedDeparturePackage'],
                'BookingValidUntil' => $value['BookingValidUntil'],
                'oldPrice' => $value['oldPrice'],
            ];
            // print_r($toursFinal);
            // die;
        }



        //  echo "umrahPackage<pre>"; print_r( $this->view->umrahPackageTour);die;
        foreach ($trendingToursinter as $key => $value) {

            $destinationArr = explode(',', $value['Destinations']); // get the first destination only by extracting array
            $LongJsonInfo = Zend_Json::decode($value['LongJsonInfo']);

            if (isset($_SESSION['TravelAgent']['session']) && !empty($_SESSION['TravelAgent']['session'])) {
                $categoryDetails = $this->objHelperGeneral->getCategoryAndPriceArray($LongJsonInfo['package']['TourTypes']['MarketType'], 'B2B', $value['PackageType'], $value['PackageSubType']); // get default category
            } else {
                $categoryDetails = $this->objHelperGeneral->getCategoryAndPriceArray($LongJsonInfo['package']['TourTypes']['MarketType'], 'B2C', $value['PackageType'], $value['PackageSubType']); // get default category
            }
            if (isset($value['MainImage']) && ($value['MainImage'] != '')) {
                //die($LongJsonInfo['package']['ImgThumbnail']);
                $tourImage1 = explode(',', $value['MainImage']);
                if ($tourImage1[0] != '') {
                    $tourImage = $this->baseUrl . 'public/upload/' . $this->stylecss . '/tours/' . $value['PkgSysId'] . '/{size}/' . $tourImage1[0];
                } else if ($tourImage1[1] != '') {
                    $tourImage = $this->baseUrl . 'public/upload/' . $this->stylecss . '/tours/' . $value['PkgSysId'] . '/{size}/' . $tourImage1[1];
                }
            } else if (isset($value['Image']) && $value['Image'] != '') {
                //die($LongJsonInfo['package']['ImgThumbnail']);
                $tourImage1 = explode(',', $value['Image']);
                if ($tourImage1[0] != '') {
                    $tourImage = $this->baseUrl . 'public/upload/' . $this->stylecss . '/tours/' . $value['PkgSysId'] . '/{size}/' . $tourImage1[0];
                } else if ($tourImage1[1] != '') {
                    $tourImage = $this->baseUrl . 'public/upload/' . $this->stylecss . '/tours/' . $value['PkgSysId'] . '/{size}/' . $tourImage1[1];
                }
            } else {
                $tourImage = $LongJsonInfo['package']['ImgThumbnail'];
            }
            $defaultCategoryId = $categoryDetails['defaultCategoryId'];
            $defaultCategory = $categoryDetails['defaultCategory'];
            $defaultTourType = $categoryDetails['defaultTourType'];
            $TPId = ($value['PackageType'] == $this->packageTypeStatic) ? $LongJsonInfo['package']['TPId'] : $categoryDetails['TPId'];
            $MPType = (!empty($categoryDetails['MPType']) && ($categoryDetails['MPType'] != 'LowestCost')) ? array_search($categoryDetails['MPType'], unserialize(CONST_MEAL_PLAN_ARR)) : 0;
            $tourTypeChar = ($defaultTourType == 1) ? 'P' : 'G'; // if private than P else G for Group tour type
            $priceArrJson = $categoryDetails['priceArrJson'];
            $displayFinalPrice = $this->objHelperGeneral->getPackagePrice($defaultCategoryId, $tourTypeChar, $priceArrJson, true);  // Param 4: true ( if calculate discounted price )
            $getCurrencyType = $priceArrJson[$tourTypeChar][$defaultCategoryId]['price'][0]['Currency'];

            $toursFinalinter[] = [
                'name' => $this->objHelperGeneral->trimContent($LongJsonInfo['package']['Name'], 24),
                'nameF' => $LongJsonInfo['package']['Name'], // full name of package name
                'img' => $tourImage,
                'night' => $value['Nights'],
                'price' => $this->objHelperGeneral->moneyFormatINR(round($displayFinalPrice)),
                'currencyType' => $currencyTypeArray[$getCurrencyType],
                'star' => $value['StarRating'],
                'Destination' => $value['Destinations'],
                'PkgSysId' => $value['PkgSysId'],
                'GTXPkgId' => $value['GTXPkgId'],
                'defaultCategoryId' => $defaultCategoryId,
                'defaultCategory' => $defaultCategory,
                'tourtype' => $defaultTourType,
                'TPId' => $TPId,
                'PackageType' => $value['PackageType'],
                'mp' => $MPType,
                'Countries' => $value['Countries'],
                'isFixedDeparturesPackage' => $LongJsonInfo['package']['IsFixedDeparturePackage'],
                'BookingValidUntil' => $value['BookingValidUntil'],
                'oldPrice' => $value['oldPrice'],
            ];
        }
        $activityFinal = array();
        foreach ($trendingActivities as $tKey => $tVal) {

            $LongJsonInfo = json_decode($tVal['LongJsonInfo'], 1);

            if (isset($LongJsonInfo['ThumnailImg']) && trim($LongJsonInfo['ThumnailImg']) != '') {
                $imagename = $LongJsonInfo['ThumnailImg'];
            } else {
                $imagename1 = explode(',', $tVal['Image']);
                $imagename = $this->baseUrl . 'public/upload/' . $this->stylecss . '/activities/' . $tVal['PkgSysId'] . '/images/medium/' . $imagename1[0];
            }
            $rate = 1;

            $netPrice = 0;
            if (!empty($LongJsonInfo['SICCost'])) {
                $netPrice = (int) ($LongJsonInfo['SICCost'][0]['NetAdultCost'] + $LongJsonInfo['AdultEntryFee']);
            } else if (!empty($LongJsonInfo['PvtCost'])) {
                $netPrice = (int) ($LongJsonInfo['PvtCost'][0]['NetAdultCost'] + $LongJsonInfo['AdultEntryFee']);
            } else {
                $netPrice = (int) $LongJsonInfo['AdultEntryFee'];
            }

            //echo "<pre>";print_r($LongJsonInfo);die;
            $activityFinal[] = [
                'PkgSysId' => $tVal['PkgSysId'],
                'Title' => $LongJsonInfo['Title'],
                'destination' => $tVal['Destinations'],
                'oldPrice' => (isset($tVal['oldPrice']) && $tVal['oldPrice'] != 0 && $tVal['oldPrice'] != '') ? $tVal['oldPrice'] : '',
                'Image' => $imagename,
                'Duration' => $LongJsonInfo['Duration'],
                'DurationInMin' => $LongJsonInfo['DurationInMin'],
                'DurationStr' => $LongJsonInfo['DurationStr'],
                'PriceAdditional' => isset($netPrice) ? round($netPrice) : 0,
                'CurrencySymbol' => isset($LongJsonInfo['CurrencySymbol']) ? $LongJsonInfo['CurrencySymbol'] : 'INR',
                //                'CurrencySymbol' => ($currencyType) ? $currencyType : 'INR',
            ];
        }

        $testimonials = array();
        if ($interestingFactsContent['testmonial_check'] == 1) {
            $testimonials = $this->objMdl->rv_select_all('tbl_feedback', ['*'], ['IsActive' => 1, 'displayOnHome' => 1], ['FeedbackId' => 'DESC'], 10);
        }
        $bannerDetail = $this->objMdl->rv_select_all('tb_homebanner_detail', ['banner_id', 'image', 'heading', 'description', 'url', 'opt'], ['status' => 1, 'isDisplayOnHome' => 1, 'isMarkForDel' => 0, 'isb2b' => 0], ['banner_id' => 'DESC'], 10);
        if ($this->stylecss == 'walsonstravels') {
            $bannerDetailll = $this->objMdl->rv_select_all('tb_homebanner_detail', ['banner_id', 'image', 'heading', 'description', 'videolink', 'url', 'opt'], ['status' => 1, 'isDisplayOnHome' => 1, 'isMarkForDel' => 0, 'isb2b' => 0], ['banner_id' => 'DESC'], 10);
        }



        $homePromotionTypeOne = $this->objMdl->rv_select_all('tbl_home_promotion', ['*'], ['IsmarkForDel' => 0, 'IsFeatured' => 1, 'templatetype' => 1], ['promotionId' => 'DESC'], 10);
        $homePromotionTypeTwo = $this->objMdl->rv_select_all('tbl_home_promotion', ['*'], ['IsmarkForDel' => 0, 'IsFeatured' => 1, 'templatetype' => 2], ['promotionId' => 'DESC'], 1);
        $homePromotionTypeThree = $this->objMdl->rv_select_all('tbl_home_promotion', ['*'], ['IsmarkForDel' => 0, 'IsFeatured' => 1, 'templatetype' => 3], ['promotionId' => 'DESC'], 1);

        // // echo "<pre>"; print_r($homePromotionTypeTwo); die('here1111');
        if ($homePromotionTypeTwo) {
            $tagName = json_decode($homePromotionTypeTwo[0]['promotion_name']);
        }
        if ($homePromotionTypeTwo) {
            $promotionUrl = json_decode($homePromotionTypeTwo[0]['promotion_url']);
        }
        if ($homePromotionTypeTwo) {
            $tabType = json_decode($homePromotionTypeTwo[0]['tab_type']);
        }

        $tagName = '';
        $finalArrayTwo = array();

        if (!empty($tagNAme)) {
            $finalArrayTwo[0] = ['tagNAme' => $tagName->promotion_tag1, 'promotionUrl' => $promotionUrl->promotion_tag_url1, 'tabType' => $tabType->tagopt1];
            $finalArrayTwo[1] = ['tagNAme' => $tagName->promotion_tag2, 'promotionUrl' => $promotionUrl->promotion_tag_url2, 'tabType' => $tabType->tagopt2];
            $finalArrayTwo[2] = ['tagNAme' => $tagName->promotion_tag3, 'promotionUrl' => $promotionUrl->promotion_tag_url3, 'tabType' => $tabType->tagopt3];
            $finalArrayTwo[3] = ['tagNAme' => $tagName->promotion_tag4, 'promotionUrl' => $promotionUrl->promotion_tag_url4, 'tabType' => $tabType->tagopt4];
        }
        // $finalArrayTwo[0] = ['tagNAme' => $tagName->promotion_tag1, 'promotionUrl' => $promotionUrl->promotion_tag_url1, 'tabType' => $tabType->tagopt1];
        // $finalArrayTwo[1] = ['tagNAme' => $tagName->promotion_tag2, 'promotionUrl' => $promotionUrl->promotion_tag_url2, 'tabType' => $tabType->tagopt2];
        // $finalArrayTwo[2] = ['tagNAme' => $tagName->promotion_tag3, 'promotionUrl' => $promotionUrl->promotion_tag_url3, 'tabType' => $tabType->tagopt3];
        // $finalArrayTwo[3] = ['tagNAme' => $tagName->promotion_tag4, 'promotionUrl' => $promotionUrl->promotion_tag_url4, 'tabType' => $tabType->tagopt4];

        $homePromotionTypeTwoArr = array();

        // if($homePromotionTypeTwo){
        //   if($homePromotionTypeTwo[0]['promotionId']) {
        //     $homePromotionTypeTwoArr = [
        //       'promotionId' => $homePromotionTypeTwo[0]['promotionId'],
        //       'templatetype' => $homePromotionTypeTwo[0]['templatetype'],
        //       'promotion_image' => $homePromotionTypeTwo[0]['promotion_image'],
        //       'finalArrayTwo' => $finalArrayTwo,
        //     ];
        //   }
        // }

        if ($homePromotionTypeTwo[0]['promotionId']) {
            $homePromotionTypeTwoArr = [
                'promotionId' => $homePromotionTypeTwo[0]['promotionId'],
                'templatetype' => $homePromotionTypeTwo[0]['templatetype'],
                'promotion_image' => $homePromotionTypeTwo[0]['promotion_image'],
                'finalArrayTwo' => $finalArrayTwo,
            ];
        }


        $resultPromotionCategory = $this->objMdl->getCmsdata('tbl_promotion_category', ['*'], ['prom_cat_id'], ['prom_cat_id' => 'DESC']);
        $getCmsPageDetail = $this->objMdl->rv_select_row('tbl_static_pages', ['page_description'], ['identifier' => 'about-us', 'status' => 'Activate'], ['sid' => 'desc']);
        $getOfferDetail = $this->objMdl->rv_select_row('tbl_offers', ['*'], ['status' => 1, 'id' => 1], ['id' => 'desc']);

        $travelogues = array();
        if ($blogContent['blog_check'] == 1) {
            $travelogues = $this->objMdl->rv_select_all('tbl_travelogues', ['*'], ['isMarkForDel' => 0, 'status' => 1, 'displayOnBanner' => 1], ['TravId' => 'DESC'], 10);
        }

        $offeronhome = array();
        if ($offersContent['offers_check'] == 1) {
            $date = new \DateTime();
            $expirydate_now = $date->format('Y-m-d');
            $offeronhome = $this->objMdl->rv_select_all('tbl_offers', ['*'], ['isMarkForDel' => 0, 'status' => 1, 'displayOnHome' => 1, 'expiryDate >' => $expirydate_now], ['id' => 'DESC'], 10);
            // echo"<pre>";print_r($offeronhome);die('asjhdh');
        }

        $whychooseusonhome = array();
        if ($this->stylecss == 'lts' || $this->stylecss == 'uamongus' || $this->stylecss == 'flynwander') {
            if ($whychooseusContent['whychooseus_check'] == 1) {
                $whychooseusonhome = $this->objMdl->rv_select_all('tb_whychooseus', ['*'], ['isMarkForDel' => 0, 'isDisplayOnHome' => 1, 'status' => 1], ['id' => 'DESC'], 10);
                // echo"<pre>";print_r($whychooseusonhome);die;
            } else
                $managequicklinks = $this->objMdl->rv_select_all('tbl_quick_links', ['*'], ['status' => 'Activate'], ['id' => 'DESC'], 10);
        } else if ($this->stylecss == 'atlas') {

            if ($whychooseusContent['whychooseus_check'] == 1) {
                $catagory = 'Umrah';
                $umrahPackage = $this->objMdl->getPackageByCategotyName(['tbl.ItemType' => 1], $catagory, 10);
                // echo"<pre>";print_r($umrahPackage);die;
            }
        }
        $happycustomeronhome = $umrahPackageTour = array();
        if ($this->stylecss == 'travelidea' || $this->stylecss == 'ineedtrip' || $this->stylecss == 'rahattravels') {
            if ($happycustomerContent['happycustomer_check'] == 1) {
                $happycustomeronhome = $this->objMdl->rv_select_all('tb_happycustomer', ['*'], ['isMarkForDel' => 0, 'isDisplayOnHome' => 1, 'status' => 1], ['id' => 'DESC'], 10);
            }
        }
        foreach ($umrahPackage as $key => $value) {
            $umrahPackagePackageCategory = explode(',', $value['PackageCategory']);
            $umrahPackagedestinationArr = explode(',', $value['Destinations']); // get the first destination only by extracting array
            $LongJsonInfo = Zend_Json::decode($value['LongJsonInfo']);
            //echo"<pre>";print_r($value);die;
            if (isset($_SESSION['TravelAgent']['session']) && !empty($_SESSION['TravelAgent']['session'])) {
                $categoryDetails = $this->objHelperGeneral->getCategoryAndPriceArray($LongJsonInfo['package']['TourTypes']['MarketType'], 'B2B', $value['PackageType'], $value['PackageSubType']); // get default category
            } else {
                $categoryDetails = $this->objHelperGeneral->getCategoryAndPriceArray($LongJsonInfo['package']['TourTypes']['MarketType'], 'B2C', $value['PackageType'], $value['PackageSubType']); // get default category
            }

            if (isset($value['Image']) && trim($value['Image']) != '') {
                //die($LongJsonInfo['package']['ImgThumbnail']);
                $tourImage1 = explode(',', $value['Image']);
                if ($tourImage1[0] != '') {
                    $tourImage = $this->baseUrl . 'public/upload/' . $this->stylecss . '/tours/' . $value['PkgSysId'] . '/{size}/' . $tourImage1[0];
                } else if ($tourImage1[1] != '') {
                    $tourImage = $this->baseUrl . 'public/upload/' . $this->stylecss . '/tours/' . $value['PkgSysId'] . '/{size}/' . $tourImage1[1];
                }
            } else {
                $tourImage = $LongJsonInfo['package']['ImgThumbnail'];
            }

            $defaultCategoryId = $categoryDetails['defaultCategoryId'];
            $defaultCategory = $categoryDetails['defaultCategory'];
            $defaultTourType = $categoryDetails['defaultTourType'];
            $TPId = ($value['PackageType'] == $this->packageTypeStatic) ? $LongJsonInfo['package']['TPId'] : $categoryDetails['TPId'];
            $MPType = (!empty($categoryDetails['MPType']) && ($categoryDetails['MPType'] != 'LowestCost')) ? array_search($categoryDetails['MPType'], unserialize(CONST_MEAL_PLAN_ARR)) : 0;

            $tourTypeChar = ($defaultTourType == 1) ? 'P' : 'G'; // if private than P else G for Group tour type
            $priceArrJson = $categoryDetails['priceArrJson'];
            $displayFinalPrice = $this->objHelperGeneral->getPackagePrice($defaultCategoryId, $tourTypeChar, $priceArrJson, true);  // Param 4: true ( if calculate discounted price )
            $getCurrencyType = $priceArrJson[$tourTypeChar][$defaultCategoryId]['price'][0]['Currency'];
            $defaultCategoryIdm = isset($LongJsonInfo['package']['Itineraries']['Itinerary'][0]['ItineraryItem'][1]['Items'][0]['Id']) ? $LongJsonInfo['package']['Itineraries']['Itinerary'][0]['ItineraryItem'][1]['Items'][0]['Id'] : 0;

            $umrahPackageTour[] = [
                'name' => $this->objHelperGeneral->trimContent($LongJsonInfo['package']['Name'], 24),
                'nameF' => trim($LongJsonInfo['package']['Name']), // full name of package name
                'img' => $tourImage,
                'night' => $value['Nights'],
                'price' => $this->objHelperGeneral->moneyFormatINR(round($displayFinalPrice)),
                'currencyType' => $currencyTypeArray[$getCurrencyType],
                'star' => $value['StarRating'],
                'Destination' => $value['Destinations'],
                'PkgSysId' => $value['PkgSysId'],
                'GTXPkgId' => $value['GTXPkgId'],
                'defaultCategoryId' => ($defaultCategoryId != '') ? $defaultCategoryId : $defaultCategoryIdm,
                'defaultCategory' => $defaultCategory,
                'tourtype' => ($defaultTourType != '') ? $defaultTourType : 1,
                'TPId' => $TPId,
                'PackageType' => $value['PackageType'],
                'mp' => $MPType,
                'Countries' => $value['Countries'],
                'isFixedDeparturesPackage' => $LongJsonInfo['package']['IsFixedDeparturePackage'],
                'BookingValidUntil' => $value['BookingValidUntil'],
                'oldPrice' => $value['oldPrice'],
            ];
        }

        $flightsourcedestin = $this->objMdl->rv_select_all('tbl_flight', ['*'], ['IsActive' => 1], [], 20);
        $this->view->travelogues = $travelogues;
        $this->view->offeronhome = $offeronhome;
        $this->view->managequicklinks = $managequicklinks;
        $this->view->whychooseusonhome = $whychooseusonhome;
        $this->view->happycustomeronhome = $happycustomeronhome;
        $this->view->getOfferDetail = $getOfferDetail;
        $this->view->flightsourcedestin = $flightsourcedestin;
        $this->view->getCmsPageDetail = $getCmsPageDetail;
        $this->view->resultPromotionCategory = $resultPromotionCategory;
        $this->view->homePromotionTypeOne = $homePromotionTypeOne;
        $this->view->homePromotionTypeTwo = $homePromotionTypeTwoArr;
        $this->view->homePromotionTypeThree = $homePromotionTypeThree[0];
        $this->view->testimonials = $testimonials;
        $this->view->bannerDetail = $bannerDetail;
        $this->view->bannerDetailll = $bannerDetailll;
        $this->view->baseUrl = $this->baseUrl;
        $this->view->toursFinal = $toursFinal;
        $this->view->toursFinalinter = $toursFinalinter;
        $this->view->lastMinuteTours = $lastMinuteToursFinal;
        $this->view->carStationArray = $decodedcarstationArray;
        $this->view->activityFinal = $activityFinal;
        $this->view->nationalityArray = $nationalityArray;
        $this->view->destinationJsonArray = $destinationJsonArray;
        //echo"<pre>";print_R($destinationJsonArray);die;
        $this->view->umrahPackageTour = $umrahPackageTour;
        $this->view->MobileDetect = $this->objHelperGeneral->getDevice();
        //$this->view->destinationsDomestic = $destinationsDomestic;
        //$this->view->destinationsInternational = $destinationsInternational;
        $popularDestination = $this->objMdl->rv_select_all('tbl_countries', ['contSysId', 'title', 'Image', 'description', 'countryId'], ['IsActive' => 1, 'IsMarkForDel' => 0, 'displayOnVisa' => 1], ['title' => 'ASC']);
        $countryCode = $this->objMdl->rv_select_all('tb_master_geo_country', ['contId', 'code'], ['isActive' => 1, 'isMarkForDel' => 0], ['contId' => 'DESC']);
        $countryCodeArr = array();

        foreach ($countryCode as $cKey => $cVal) {
            $countryCodeArr[$cVal['contId']] = $cVal['code'];
        }
        foreach ($popularDestination as $desKey => $desValue) {
            $popularDestinationArray[] = [
                'contSysId' => $desValue['contSysId'],
                'Image' => $desValue['Image'],
                'title' => $desValue['title'],
                'description' => $desValue['description'],
                'code' => $countryCodeArr[$desValue['countryId']],
            ];
        }
        $specialDeals = $this->objMdl->rv_select_all('tb_tbb2c_packages_master', ['PkgSysId', 'Image', 'GTXPkgId', 'Destinations', 'Countries', 'LongJsonInfo', 'StarRating', 'packageNameUrl', 'CountryIds'], ['IsActive' => 1, 'IsMarkForDel' => 0, 'ItemType' => 6, 'IsFeatured' => 1], ['PkgSysId' => 'DESC'], 6);
        $specialDealsArray = array();
        // echo"<pre>";print_r($specialDeals);die();
        foreach ($specialDeals as $dealKey => $dealValue) {

            $LongJsonInfo = Zend_Json::decode($dealValue['LongJsonInfo']);
            $VisaAdultRates = $LongJsonInfo['VisaAdultRates'] + $LongJsonInfo['Markup'][0]['MarkUp'];
            $specialDealsArray[] = [
                'PkgSysId' => $dealValue['PkgSysId'],
                'GTXPkgId' => $dealValue['GTXPkgId'],
                'VisaName' => $LongJsonInfo['VisaName'],
                'Nationality' => $LongJsonInfo['Nationality'],
                'VisaAdultRates' => $VisaAdultRates,
                'CurrencyType' => $currencyTypeArray[$LongJsonInfo['CurrencyType']],
                'Country' => $LongJsonInfo['Country'],
                'PrecessingTime' => $LongJsonInfo['PrecessingTime'],
                'packageNameUrl' => $dealValue['packageNameUrl'],
                'searchUrl' => strtolower(Catabatic_Helper::getSeoName(trim($LongJsonInfo['Country']))) . '-visa/' . strtolower(Catabatic_Helper::getSeoName(trim($dealValue['packageNameUrl']))) . '.html',
                'code' => $countryCodeArr[$dealValue['CountryIds']],
            ];
        }
        $this->view->specialDealsArray = $specialDealsArray;

        // tb_tbb2c_packages_master
        $checkDuplicateCountries = array();
        foreach ($geoCityData as $cdKey => $cdVal) {
            if (!in_array(trim($cdVal['CountryIds']), $checkDuplicateCountries)) {
                $finalgeoCityData[] = $cdVal;
                $checkDuplicateCountries[] = trim($cdVal['CountryIds']);
            }
        }

        $this->view->countryNameArray = $finalgeoCityData;
        $sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
        $this->view->sessionFlightSearchParams = $sessionFlightSearchParams->params;
        $this->view->popularDestinationArray = $popularDestinationArray;
        $this->view->gtxBtoBsite = $this->gtxBtoBsite;
        $SearchCarData = new Zend_Session_Namespace('SearchCarData');
        $this->view->sessionSearchCarData = $SearchCarData->params;
        $homeContentdata["internationalTourTitle"] = $popularTourContent['internationalTourTitle'];
        $homeContentdata["internationalTourDescription"] = $popularTourContent['internationalTourDescription'];
        $homeContentdata["international_check"] = $popularTourContent['international_check'];
        $homeContentdata["international_order_byhome"] = $popularTourContent['international_order_byhome'];
        $homeContentdata["destinationTitle"] = $destinationContent['destinationTitle'];
        $homeContentdata["destinationDescription"] = $destinationContent['destinationDescription'];
        $homeContentdata["destination_order_byhome"] = $destinationContent['destination_order_byhome'];
        $homeContentdata["domesticTourTitle"] = $perfectTourContent['domesticTourTitle'];
        $homeContentdata["domesticTourDescription"] = $perfectTourContent['domesticTourDescription'];
        $homeContentdata["domestic_order_byhome"] = $perfectTourContent['domestic_order_byhome'];
        $homeContentdata["blogTitle"] = $blogContent['blogTitle'];
        $homeContentdata["blogDescription"] = $blogContent['blogDescription'];
        $homeContentdata["blog_order_byhome"] = $blogContent['blog_order_byhome'];
        $homeContentdata["offersTitle"] = $offersContent['offersTitle'];
        $homeContentdata["offersDescription"] = $offersContent['offersDescription'];
        $homeContentdata["offers_order_byhome"] = $offersContent['offers_order_byhome'];
		
		  $homeContentdata["statesTitle"] = $statesContent['statesTitle'];
        $homeContentdata["statesDescription"] = $statesContent['statesDescription'];
        $homeContentdata["states_order_byhome"] = $statesContent['states_order_byhome'];
		  $homeContentdata["countriesTitle"] = $countriesContent['countriesTitle'];
        $homeContentdata["countriesDescription"] = $countriesContent['countriesDescription'];
        $homeContentdata["countries_order_byhome"] = $countriesContent['countries_order_byhome'];
		
        $homeContentdata["whychooseusTitle"] = $whychooseusContent['whychooseusTitle'];
        $homeContentdata["whychooseus_order_byhome"] = $whychooseusContent['whychooseus_order_byhome'];
        $homeContentdata["whychooseus_check"] = $whychooseusContent['whychooseus_check'];

        $homeContentdata["happycustomerTitle"] = $happycustomerContent['happycustomerTitle'];
        $homeContentdata["happycustomer_order_byhome"] = $happycustomerContent['happycustomer_order_byhome'];

        $homeContentdata["themeTitle"] = $otherUsefulContent['themeTitle'];
        $homeContentdata["theme_check"] = $otherUsefulContent['theme_check'];
        $homeContentdata["theme_order_byhome"] = $otherUsefulContent['theme_order_byhome'];
        $homeContentdata["themeDescription"] = $otherUsefulContent['themeDescription'];
        $homeContentdata["testimonialTitle"] = $interestingFactsContent['testimonialTitle'];
        $homeContentdata["testimonialDescription"] = $interestingFactsContent['testimonialDescription'];
        $homeContentdata["testmonial_order_byhome"] = $interestingFactsContent['testmonial_order_byhome'];

        $this->view->homeContentdata = $homeContentdata;
        $resultsetTheme = array();
        if ($otherUsefulContent['theme_check'] == 1) {
            $resultsetTheme = $this->objMdl->rv_select_all('tbl_pack_type', ['*'], ['isMarkForDel' => 0, 'IsActive' => 1, 'displayOnHome' => 1], ['packType' => 'ASC'], 6);
        }
        $this->view->resultsetTheme = $resultsetTheme;

        $order_array = array(
            $homeContentdata["theme_order_byhome"] => array('view' => 'theme', 'Title' => $otherUsefulContent['themeTitle'], 'Description' => $otherUsefulContent['themeDescription'], 'data' => $resultsetTheme),
            $homeContentdata["international_order_byhome"] => array('view' => 'internationaltour', 'Title' => $popularTourContent['internationalTourTitle'], 'Description' => $popularTourContent['internationalTourDescription'], 'data' => $toursFinalinter),
            $homeContentdata["domestic_order_byhome"] => array('view' => 'domestic', 'Title' => $perfectTourContent['domesticTourTitle'], 'Description' => $perfectTourContent['domesticTourDescription'], 'data' => $toursFinal),
            $homeContentdata["testmonial_order_byhome"] => array('view' => 'testmonial', 'Title' => $interestingFactsContent['testimonialTitle'], 'Description' => $interestingFactsContent['testimonialDescription'], 'data' => $testimonials),
            $homeContentdata["blog_order_byhome"] => array('view' => 'travelogues', 'Title' => $blogContent['blogTitle'], 'Description' => $blogContent['blogDescription'], 'data' => $travelogues),
            $homeContentdata["offers_order_byhome"] => array('view' => 'offers', 'Title' => $offersContent['offersTitle'], 'Description' => $offersContent['offersDescription'], 'data' => $offeronhome),
            $homeContentdata["whychooseus_order_byhome"] => array('view' => 'whychooseusonhome', 'Title' => $whychooseusContent['whychooseusTitle'], 'data' => $whychooseusonhome),
            $homeContentdata["happycustomer_order_byhome"] => array('view' => 'happycustomeronhome', 'Title' => $happycustomerContent['happycustomerTitle'], 'data' => $happycustomeronhome),
            $homeContentdata["destination_order_byhome"] => array('view' => 'destination', 'Title' => $destinationContent['destinationTitle'], 'Description' => $destinationContent['destinationDescription'], 'data' => $destinatonTopArr),
		     $homeContentdata["states_order_byhome"] => array('view' => 'states', 'Title' => $statesContent['statesTitle'], 'Description' => $statesContent['statesDescription'], 'data' => $offeronhome),
			$homeContentdata["countries_order_byhome"] => array('view' => 'countries', 'Title' => $countriesContent['countriesTitle'], 'Description' => $countriesContent['countriesDescription'], 'data' => $offeronhome), 	
        );

        ksort($order_array);

        $finalArray = $order_array;
        $this->view->finalArray = $finalArray;

        $homeContentdata["internationalTourTitle"] = $popularTourContent['internationalTourTitle'];
        $homeContentdata["internationalTourDescription"] = $popularTourContent['internationalTourDescription'];
        $homeContentdata["international_check"] = $popularTourContent['international_check'];
        $homeContentdata["international_order_byhome"] = $popularTourContent['international_order_byhome'];
        $homeContentdata["destinationTitle"] = $destinationContent['destinationTitle'];
        $homeContentdata["destinationDescription"] = $destinationContent['destinationDescription'];
        $homeContentdata["destination_order_byhome"] = $destinationContent['destination_order_byhome'];
        $homeContentdata["domesticTourTitle"] = $perfectTourContent['domesticTourTitle'];
        $homeContentdata["domesticTourDescription"] = $perfectTourContent['domesticTourDescription'];
        $homeContentdata["domestic_order_byhome"] = $perfectTourContent['domestic_order_byhome'];
        $homeContentdata["blogTitle"] = $blogContent['blogTitle'];
        $homeContentdata["blogDescription"] = $blogContent['blogDescription'];
        $homeContentdata["blog_order_byhome"] = $blogContent['blog_order_byhome'];

        $homeContentdata["offersTitle"] = $offersContent['offersTitle'];
        $homeContentdata["offersDescription"] = $offersContent['offersDescription'];
        $homeContentdata["offers_order_byhome"] = $offersContent['offers_order_byhome'];
		
			  $homeContentdata["statesTitle"] = $statesContent['statesTitle'];
        $homeContentdata["statesDescription"] = $statesContent['statesDescription'];
        $homeContentdata["states_order_byhome"] = $statesContent['states_order_byhome'];
		  $homeContentdata["countriesTitle"] = $countriesContent['countriesTitle'];
        $homeContentdata["countriesDescription"] = $countriesContent['countriesDescription'];
        $homeContentdata["countries_order_byhome"] = $countriesContent['countries_order_byhome'];

        $homeContentdata["whychooseusTitle"] = $whychooseusContent['whychooseusTitle'];
        $homeContentdata["whychooseus_order_byhome"] = $whychooseusContent['whychooseus_order_byhome'];
        $homeContentdata["whychooseus_check"] = $whychooseusContent['whychooseus_check'];

        $homeContentdata["happycustomerTitle"] = $happycustomerContent['happycustomerTitle'];
        $homeContentdata["happycustomer_order_byhome"] = $happycustomerContent['happycustomer_order_byhome'];
        $homeContentdata["themeTitle"] = $otherUsefulContent['themeTitle'];
        $homeContentdata["theme_check"] = $otherUsefulContent['theme_check'];
        $homeContentdata["theme_order_byhome"] = $otherUsefulContent['theme_order_byhome'];
        $homeContentdata["themeDescription"] = $otherUsefulContent['themeDescription'];
        $homeContentdata["testimonialTitle"] = $interestingFactsContent['testimonialTitle'];
        $homeContentdata["testimonialDescription"] = $interestingFactsContent['testimonialDescription'];
        $homeContentdata["testmonial_order_byhome"] = $interestingFactsContent['testmonial_order_byhome'];

        $this->view->homeContentdata = $homeContentdata;
        $resultsetTheme = array();
        if ($otherUsefulContent['theme_check'] == 1) {
            $resultsetTheme = $this->objMdl->rv_select_all('tbl_pack_type', ['*'], ['isMarkForDel' => 0, 'IsActive' => 1, 'displayOnHome' => 1], ['packType' => 'ASC'], 6);
        }
        $this->view->resultsetTheme = $resultsetTheme;
        //echo"<pre>";
        // print_r($homeContentdata);
        $order_array = array(
            $homeContentdata["theme_order_byhome"] => array('view' => 'theme', 'Title' => $otherUsefulContent['themeTitle'], 'Description' => $otherUsefulContent['themeDescription'], 'data' => $resultsetTheme),
            $homeContentdata["international_order_byhome"] => array('view' => 'internationaltour', 'Title' => $popularTourContent['internationalTourTitle'], 'Description' => $popularTourContent['internationalTourDescription'], 'data' => $toursFinalinter),
            $homeContentdata["domestic_order_byhome"] => array('view' => 'domestic', 'Title' => $perfectTourContent['domesticTourTitle'], 'Description' => $perfectTourContent['domesticTourDescription'], 'data' => $toursFinal),
            $homeContentdata["testmonial_order_byhome"] => array('view' => 'testmonial', 'Title' => $interestingFactsContent['testimonialTitle'], 'Description' => $interestingFactsContent['testimonialDescription'], 'data' => $testimonials),
            $homeContentdata["blog_order_byhome"] => array('view' => 'travelogues', 'Title' => $blogContent['blogTitle'], 'Description' => $blogContent['blogDescription'], 'data' => $travelogues),
            $homeContentdata["offers_order_byhome"] => array('view' => 'offers', 'Title' => $offersContent['offersTitle'], 'Description' => $offersContent['offersDescription'], 'data' => $offeronhome),
            $homeContentdata["whychooseus_order_byhome"] => array('view' => 'whychooseus', 'Title' => $whychooseusContent['whychooseusTitle'], 'data' => $whychooseusonhome),
            $homeContentdata["happycustomer_order_byhome"] => array('view' => 'happycustomer', 'Title' => $happycustomerContent['happycustomerTitle'], 'data' => $happycustomeronhome),
            $homeContentdata["destination_order_byhome"] => array('view' => 'destination', 'Title' => $destinationContent['destinationTitle'], 'Description' => $destinationContent['destinationDescription'], 'data' => $destinatonTopArr),
			
		    $homeContentdata["states_order_byhome"] => array('view' => 'states', 'Title' => $statesContent['statesTitle'], 'Description' => $statesContent['statesDescription'], 'data' => $offeronhome),
			$homeContentdata["countries_order_byhome"] => array('view' => 'countries', 'Title' => $countriesContent['countriesTitle'], 'Description' => $countriesContent['countriesDescription'], 'data' => $offeronhome), 
        );
         //echo"<pre>";print_r($homeContentdata);die('dsfs');
        ksort($order_array);
        $DomesPopularCity = $this->objMdl->rv_select_all($this->tablePopularCity, ['*'], ['popularCityType' => 0, 'IsMarkForDel' => 0, 'isb2b' => 0], ['AboutId' => 'DESC']);
        $InterPopularCity = $this->objMdl->rv_select_all($this->tablePopularCity, ['*'], ['popularCityType' => 1, 'IsMarkForDel' => 0, 'isb2b' => 0], ['AboutId' => 'DESC']);
        if ($whychooseusContent['whychooseus_check'] == 1) {
            //echo"<pre>";print_r($whychooseusContent);die;
            if ($this->stylecss == 'tripbel' || $this->stylecss == 'sbjtrips') {
                $date = new \DateTime();
                $expirydate_now = $date->format('Y-m-d');
                $CheapPopularCity = $this->objMdl->rv_select_all($this->tablePopularCity, ['*'], ['IsMarkForDel' => 0, 'isb2b' => 0, 'expiryDate >' => $expirydate_now], ['AboutId' => 'DESC']);
            } else {
                $CheapPopularCity = $this->objMdl->rv_select_all($this->tablePopularCity, ['*'], ['IsMarkForDel' => 0, 'isb2b' => 0], ['AboutId' => 'DESC']);
            }
        }
        foreach ($CheapPopularCity as $key => $value) {
            if (trim($value['AboutImage']) != '') {
                $flightImage1 = explode(',', $value['AboutImage']);
                // echo "<pre>"; print_r($flightImage1);
                if (file_exists('public/upload/' . $this->stylecss . '/aboutyit/' . $value['AboutId'] . '/small/' . trim($flightImage1[0]))) {
                    $flightImage = $this->baseUrl . 'public/upload/' . $this->stylecss . '/aboutyit/' . $value['AboutId'] . '/{size}/' . $flightImage1[0];
                } else if (file_exists('public/upload/' . $this->stylecss . '/aboutyit/' . $value['AboutId'] . '/small/' . trim($flightImage1[1]))) {
                    $flightImage = $this->baseUrl . 'public/upload/' . $this->stylecss . '/aboutyit/' . $value['AboutId'] . '/{size}/' . $flightImage1[1];
                } else {
                    $flightImage = $this->baseUrl . 'public/images/no-image.jpg';
                }
            } else {
                $flightImage = $this->baseUrl . 'public/images/no-image.jpg'; //$Flight['package']['ImgThumbnail'];
            }
            $CheapPopularCity[] = [
                'AboutId' => $value['AboutId'],
                'AboutImage' => $flightImage,
                'AboutImage_check' => $value['AboutImage'],
                'price' => $value['price'],
                'Fromcity' => $value['Fromcity'],
                'Tocity' => $value['Tocity'],
                'source' => $value['source'],
                'destination' => $value['destination'],
                'source_city' => $value['source_city'],
                'destination_city' => $value['destination_city'],
                'ContSysId1' => $value['ContSysId1'],
                'ContSysId2' => $value['ContSysId2'],
                'popularCityType' => $value['popularCityType'],
                'AboutDescription' => $value['AboutDescription'],
                'url' => $value['url'],
                'opt' => $value['opt'],
                'status' => $value['status'],
                'expiryDate' => $value['expiryDate'],
            ];
        }
        foreach ($DomesPopularCity as $key => $value) {
            if (trim($value['AboutImage']) != '') {
                $flightImage1 = explode(',', $value['AboutImage']);
                //echo "<pre>"; print_r($flightImage1);
                if (file_exists('public/upload/' . $this->stylecss . '/aboutyit/' . $value['AboutId'] . '/small/' . trim($flightImage1[0]))) {
                    $flightImage = $this->baseUrl . 'public/upload/' . $this->stylecss . '/aboutyit/' . $value['AboutId'] . '/{size}/' . $flightImage1[0];
                } else if (file_exists('public/upload/' . $this->stylecss . '/aboutyit/' . $value['AboutId'] . '/small/' . trim($flightImage1[1]))) {
                    $flightImage = $this->baseUrl . 'public/upload/' . $this->stylecss . '/aboutyit/' . $value['AboutId'] . '/{size}/' . $flightImage1[1];
                } else {
                    $flightImage = $this->baseUrl . 'public/images/no-image.jpg';
                }
            } else {
                $flightImage = $this->baseUrl . 'public/images/no-image.jpg'; //$Flight['package']['ImgThumbnail'];
            }
            $DomesPopularCity1[] = [
                'AboutId' => $value['AboutId'],
                'AboutImage' => $flightImage,
                'AboutImage_check' => $value['AboutImage'],
                'price' => $value['price'],
                'Fromcity' => $value['Fromcity'],
                'Tocity' => $value['Tocity'],
                'source' => $value['source'],
                'destination' => $value['destination'],
                'source_city' => $value['source_city'],
                'destination_city' => $value['destination_city'],
                'ContSysId1' => $value['ContSysId1'],
                'ContSysId2' => $value['ContSysId2'],
                'popularCityType' => $value['popularCityType'],
                'AboutDescription' => $value['AboutDescription'],
                'url' => $value['url'],
                'opt' => $value['opt'],
                'status' => $value['status'],
                'isMarkForDel' => $value['isMarkForDel'],
            ];
        }
        foreach ($InterPopularCity as $key => $value) {
            if (trim($value['AboutImage']) != '') {

                $flightImage1 = explode(',', $value['AboutImage']);
                //echo "<pre>"; print_r($flightImage1);
                if (file_exists('public/upload/' . $this->stylecss . '/aboutyit/' . $value['AboutId'] . '/small/' . trim($flightImage1[0]))) {
                    $flightImage = $this->baseUrl . 'public/upload/' . $this->stylecss . '/aboutyit/' . $value['AboutId'] . '/{size}/' . $flightImage1[0];
                } else if (file_exists('public/upload/' . $this->stylecss . '/aboutyit/' . $value['AboutId'] . '/small/' . trim($flightImage1[1]))) {
                    $flightImage = $this->baseUrl . 'public/upload/' . $this->stylecss . '/aboutyit/' . $value['AboutId'] . '/{size}/' . $flightImage1[1];
                } else {
                    $flightImage = $this->baseUrl . 'public/images/no-image.jpg';
                }
            } else {
                $flightImage = $this->baseUrl . 'public/images/no-image.jpg'; //$Flight['package']['ImgThumbnail'];
            }

            $InterPopularCity1[] = [
                'AboutId' => $value['AboutId'],
                'AboutImage' => $flightImage,
                'price' => $value['price'],
                'Fromcity' => $value['Fromcity'],
                'Tocity' => $value['Tocity'],
                'source' => $value['source'],
                'destination' => $value['destination'],
                'source_city' => $value['source_city'],
                'destination_city' => $value['destination_city'],
                'ContSysId1' => $value['ContSysId1'],
                'ContSysId2' => $value['ContSysId2'],
                'popularCityType' => $value['popularCityType'],
                'AboutDescription' => $value['AboutDescription'],
                'url' => $value['url'],
                'opt' => $value['opt'],
                'status' => $value['status'],
                'isMarkForDel' => $value['isMarkForDel'],
            ];
        }
        $offers = $this->objMdl->rv_select_all('tbl_offers', ['*'], ['isActive' => 1, 'isMarkForDel' => 0, 'isb2b' => '0'], ['Id' => 'DESC']);
        $whychooseus = $this->objMdl->rv_select_all('tb_whychooseus', ['*'], ['status' => 1, 'isMarkForDel' => 0], ['Id' => 'DESC']);
        $happycustomer = $this->objMdl->rv_select_all('tb_happycustomer', ['*'], ['status' => 1, 'isMarkForDel' => 0], ['Id' => 'DESC']);
        if ($this->stylecss == 'atlas' || $this->stylecss == 'bookmytournow' || $this->stylecss == 'bhoomitravelservices' || $this->stylecss == 'rdluxurydestinations' || $this->stylecss == 'truefare' || $this->stylecss == 'aasaan' || $this->stylecss == 'holidaybazaar') {
            $popads = $this->objMdl->rv_random_popads('tbl_popads', ['*'], ['isMarkForDel' => 0]);
            $this->view->popads = $popads;
        } else {
            $this->view->popads = [];
        }
        $array = array();
        $SFSectors = array();
        $SeriesFareSecotrs = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetAgencyInventorySector(1);
        if (isset($SeriesFareSecotrs)) {
            $MergeSecotrs = array_merge($SeriesFareSecotrs, $SFSectors);
        }
        // $FromAirPortCode = array_unique(array_column($MergeSecotrs, 'FromAirPortCode'));
        // $MergeSecotrs = (array_values(array_intersect_key($MergeSecotrs, $FromAirPortCode)));
        $MergeSecotrsArray = [];
        // echo "<pre>";print_r($MergeSecotrs);die;
        if ($MergeSecotrs) {
            foreach ($MergeSecotrs as $key => $value) {
                $FlightType = isset($value['FlightType']) ? (int) $value['FlightType'] : 1;
                $FromAirPortCode = isset($value['FromAirPortCode']) ? $value['FromAirPortCode'] : '';
                $ToAirPortCode = isset($value['ToAirPortCode']) ? $value['ToAirPortCode'] : '';
                $InwardToAirPortCode = isset($value['InwardToAirPortCode']) ? $value['InwardToAirPortCode'] : '';
                if ($FlightType == 2) {
                    $MergeSecotrsArrayFrom1[$FromAirPortCode . '-' . $ToAirPortCode . '-' . $InwardToAirPortCode] = $value;
                    $MergeSecotrsArrayto2[$ToAirPortCode] = $value;
                } else {
                    $MergeSecotrsArrayFrom[$FromAirPortCode] = $value;
                    $MergeSecotrsArrayTo[$ToAirPortCode] = $value;
                }
            }
        }
        // Zend_Session::namespaceUnset('sessionFlightSearchParams');
        $sessionFlightSearchParams->params['MergeSecotrsArrayFrom'] = $MergeSecotrsArrayFrom;
        $sessionFlightSearchParams->params['MergeSecotrsArrayTo'] = $MergeSecotrsArrayTo;
        $sessionFlightSearchParams->params['MergeSecotrsArrayTo2'] = $MergeSecotrsArrayto2;
        // echo "<pre>"; print_r($MergeSecotrsArrayTo);die;
        // echo "SeriesFareSecotrsFrom<pre>"; print_r($MergeSecotrsArrayFrom);
        // echo "SeriesFareSecotrsFromInt<pre>"; print_r($MergeSecotrsArrayFrom1);die;
        if (isset($MergeSecotrsArrayFrom)) {
            $this->view->SeriesFareSecotrsFrom = array_values($MergeSecotrsArrayFrom);
        }
        if (isset($MergeSecotrsArrayFrom1)) {
            $this->view->SeriesFareSecotrsFromInt = array_values($MergeSecotrsArrayFrom1);
        }
        $aboutpartners = $this->objMdl->rv_select_all('tbl_about_agency', ['id', 'title', 'icon', 'url', 'tab'], ['IsActive' => 1, 'IsMarkForDel' => 0,], ['id' => 'DESC'], 20);
        foreach ($aboutpartners as $aboutKey => $aboutValue) {
            $aboutPartnersArray[] = [
                'id' => $aboutValue['id'],
                'icon' => $aboutValue['icon'],
                'url' => $aboutValue['url'],
                'title' => $aboutValue['title'],
            ];
        }
        $this->view->aboutPartnersArray = $aboutPartnersArray;
        $this->view->CheapPopularCity = $CheapPopularCity;
        $this->view->CheapPopularCity = $CheapPopularCity;
        // echo"<pre>";print_r($CheapPopularCity);die;
        $this->view->DomesPopularCity1 = $DomesPopularCity1;
        $this->view->InterPopularCity1 = $InterPopularCity1;
        $this->view->offers = $offers;
        $this->view->whychooseus = $whychooseus;
        $this->view->happycustomer = $happycustomer;

        $this->view->gtxagencysysid = $this->gtxagencysysid;
        $this->view->hotel_enable_status = $this->check_enabled_hotel_api();

        $countriesToptrand = $this->objMdl->rv_select_all('tbl_countries', ['contSysId', 'title', 'image', 'description', 'countryId'], ['IsActive' => 1, 'IsMarkForDel' => 0, 'displayOnHome' => 1], ['title' => 'ASC']);
        $this->view->countriesToptrand = $countriesToptrand;

        $statesHometrand = $this->objMdl->rv_select_all('tbl_states', ['*'], ['displayOnHome' => 1, 'IsActive' => 1, 'IsMarkForDel' => 0,], ['title' => 'DESC'], 20);
        $this->view->statesHometrand = $statesHometrand;
    }

    public function url_get_contents($Url)
    {
        if (!function_exists('curl_init')) {
            die('CURL is not installed!');
        }
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $Url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        $output = curl_exec($ch);
        curl_close($ch);
        return $output;
    }

    public function destinationAction()
    {
        $this->objMdl = new Admin_Model_CRUD();
        $destinations = $this->objMdl->getDestinationsHeader(['tbl.IsActive' => 1, 'tbl.IsPublish' => 1, 'tbl.IsMarkForDel' => 0, 'tb2.IsMarkForDel' => 0], ['tbl.DesSysId' => 'ASC'], 100);
        //        echo "<pre>";print_r($destinations);die;
        $destinationsAll = $this->objMdl->getDestinationsHeader(['tbl.IsActive' => 1, 'tbl.IsPublish' => 1, 'tbl.IsMarkForDel' => 0], ['tbl.DesSysId' => 'ASC'], 100);

        $region_names = $finalDestination = $finalDestinationAll = [];
        $regionnew = '';
        $region = trim($this->getRequest()->getParam('region'));
        $des = trim($this->getRequest()->getParam('des'));

        if (isset($region) && $region != '') {


            foreach ($destinations as $key => $value) {
                if (isset($region) && !empty($region)) {
                    if ($region == $value['region_label']) {
                        if (($value['region_label'] != NULL) && !in_array($value['region_label'], $region_names)) {
                            $region_names[] = $value['region_label'];
                            if ($region == $value['region_label']) {
                                $regionnew = $value['region_name'];
                            }
                        }

                        $finalDestination[$value['region_label']][] = [
                            'DesSysId' => $value['DesSysId'],
                            'Title' => $value['Title'],
                            'Image' => $value['Image'],
                            'Tours' => $value['Tours'],
                        ];
                    }
                }
            }
        } else if (isset($des) && $des != '') {
            if ($des == 'Domestic') {
                $destinationsAll = $this->objMdl->getDestinationsInd(['tbl.IsActive' => 1, 'tbl.IsPublish' => 1, 'tbl.IsMarkForDel' => 0], ['tbl.DesSysId' => 'ASC'], 100);
            } else {
                $destinationsAll = $this->objMdl->getDestinationsInt(['tbl.IsActive' => 1, 'tbl.IsPublish' => 1, 'tbl.IsMarkForDel' => 0], ['tbl.DesSysId' => 'ASC'], 100, 101);
            }
            foreach ($destinationsAll as $allkey => $allvalue) {

                $finalDestinationAll[] = [
                    'DesSysId' => $allvalue['DesSysId'],
                    'Title' => $allvalue['Title'],
                    'Image' => $allvalue['Image'],
                    'Tours' => $allvalue['Tours'],
                ];
            }
        } else {

            foreach ($destinationsAll as $allkey => $allvalue) {

                $finalDestinationAll[] = [
                    'DesSysId' => $allvalue['DesSysId'],
                    'Title' => $allvalue['Title'],
                    'Image' => $allvalue['Image'],
                    'Tours' => $allvalue['Tours'],
                ];
            }
        }
        $regionImage = $this->objMdl->getRegionImage($region);

        $this->view->baseUrl = $this->baseUrl;
        $this->view->finalDestinationAll = $finalDestinationAll;
        $this->view->finalDestination = $finalDestination;
        $this->view->region_names = $region_names;
        //        $this->view->region = $region;
        $this->view->region = $regionnew;
        $this->view->des = $des;
    }

    public function saveLetterAction()
    {
        $this->view->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        if ($this->getRequest()->isPost()) {
            $param = $this->getRequest()->getParams();
            $date = new Zend_Date();
            $currentDate = $date->get('YYYY-MM-dd HH:mm:ss');
            $email = $param['email'];

            $newsletter = new Travel_Model_PackagesMaster();

            $savePageData = [
                'created_date' => $currentDate,
                'news_letter_email' => $email,
                'status' => 1,
            ];

            $resultset = $newsletter->checkLetter("tb_tbb2c_newsletter", ['*'], ['news_letter_email' => $savePageData['news_letter_email']]);

            if (isset($resultset) && !empty($resultset)) {
                $response = array('success' => false, 'msg' => 'This Email Id Already Exists!!!');
                echo json_encode($response);
                exit;
            } else {
                $returnId = $newsletter->sendNewsLetter('tb_tbb2c_newsletter', $savePageData);
                if ($returnId) {
                    $response = array('success' => true, 'msg' => 'Your query has been submitted successfully!');
                    echo json_encode($response);
                    exit;
                }
            }
        }
    }

    public function autosuggestdesAction()
    {
        try {
            $arrResponse = array();
            if ($this->getRequest()->getParam("term")) {
                $term = $this->getRequest()->getParam("term");
                $objDes = new Travel_Model_PackagesMaster();
                $arrResponse = $objDes->getDestinationAutoSuggest($term, $this->tablename);
            }
            //print_r($arrResponse);die('okkk');
            echo json_encode($arrResponse);
            exit;
        } catch (Exception $e) {
            $response = array('success' => false, 'msg' => $e->getMessage());
            echo json_encode($response);
            exit;
        }
    }

    public function autosuggestAction()
    {
        $this->_helper->viewRenderer->setNoRender(true);
        $this->_helper->layout->disableLayout();
        try {
            $arrResponse = array();
            if ($this->getRequest()->getParam("term") or $this->getRequest()->getParam("query")) {
                $term = $this->getRequest()->getParam("term") ? $this->getRequest()->getParam("term") : $this->getRequest()->getParam("query");
                $countryId = $this->getRequest()->getParam("countryId") ? $this->getRequest()->getParam("countryId") : '';

                $condCity = "tbl.Title like '" . $term . "%'";
                if (isset($countryId) && !empty($countryId)) {
                    $condCity .= " AND tbl.ContSysId = " . $countryId . "";
                }
                $arrResponse = $this->objMdl->getBuyHotelCityAutoSuggest($condCity);
            }
            echo json_encode($arrResponse);
            exit;
        } catch (Exception $e) {
            $response = array('success' => false, 'msg' => $e->getMessage());
            echo json_encode($response);
            exit;
        }
    }

    public function customerloginAction()
    {
        // die('here');
        $request = Zend_Controller_Front::getInstance()->getRequest();
        if ($this->getRequest()->isPost()) {
            $data = $request->getPost();
            //echo "<pre>";print_r($data);die;
            $this->_session->session = $data;
            //            echo $data['redirect_link_r'];die;
            //            $this->_redirect($data['redirect_link_r']);
            $response = array('status' => true, 'msg' => 'success');
            echo json_encode($response);
            exit;
        }
    }

    public function logoutAction()
    {
        $storage = new Zend_Session_Namespace('User');
        $storage->unsetAll();
        $this->_redirect('/');
    }

    /*
     * writeSessionPopup is used to show the request a callback popup window after interval on landing page
     */

    public function writeSessionPopupAction()
    {
        $myNamespace = new Zend_Session_Namespace('MypopSess');
        $myNamespace->setPopup = true;
        $myNamespace->session_time = time();
        exit;
    }

    public function awardsAction()
    {

        $this->view->baseUrl = $this->baseUrl;
    }

    public function galleryAction()
    {

        $this->view->baseUrl = $this->baseUrl;
        $this->objMdl = new Admin_Model_CRUD();
        $galleryDetail = $this->objMdl->rv_select_all('tb_gallery_detail', ['gallery_id', 'image', 'title'], ['status' => 1], ['gallery_id' => 'DESC']);
        $this->view->galleryDetail = $galleryDetail;
    }

    public function sendSearchFlightEmailAction()
    {
        $this->view->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        $arrPrefferedAirlines = unserialize(CONST_FLIGHT_PREFERRED_AIRLINES);
        $arrCabinClass = unserialize(CONST_FLIGHT_CABIN_CLASS);

        if ($this->getRequest()->isPost()) {
            $param = $this->getRequest()->getParams();
            $contactDetail_mail = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getContactDetailForFooter();
            //            echo "<pre>";print_r($param);die;

            $sourceName = $param['sourceName'];
            $destinationName = $param['destinationName'];
            $depart_date = isset($param['depart_date']) ? $param['depart_date'] : '';
            $return_date = isset($param['return_date']) ? $param['return_date'] : '';
            $adults = $param['adults'];
            $childs = $param['childs'];
            $infants = $param['infants'];
            $cabin_class = $arrCabinClass[$param['cabin_class']];
            $subject = "Flight Enquiry Details";
            $message = '';
            $message .= '<table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" style=" font-size:14px; font-family: Roboto, sans-serif;">
                                <tr>
                                  <td colspan="2" style=" padding:5px 40px;vertical-align: middle;">Dear Admin, <br>
                                    <br>
                                    You have received a new flight query detail as below:</td>
                                </tr>
                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">From Destination : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $sourceName . '</td>
                                </tr>
                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">To Destination : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $destinationName . '</td>
                                </tr>

                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">Departing : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $depart_date . '</td>
                                </tr>';
            if ($return_date != '') {
                $message .= '<tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">Returning : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $return_date . '</td>
                                </tr>';
            }

            $message .= '<tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">Travelers : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">Adult(s) : ' . $adults . ', Child(s) : ' . $childs . ', Infant(s) : ' . $infants . '</td>
                                </tr>
                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">Cabin Class : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $cabin_class . '</td>
                                </tr>
                                <tr>
                                  <td colspan="2" style=" padding:5px 40px;vertical-align: middle;">Thanks ! <br>
                                    <hr / style="border-width: 0.6px;">
                                    <br>
                                    <br>
                                    contact number: ' . $contactDetail_mail["mobile"] . '<br>
                                    Email: ' . $contactDetail_mail["email"] . '</td>
                                </tr>
                              </table>
                              <div style="text-align:center;">
                                   <img style="width:100px;" src="' . $this->baseUrl . 'public/images/logo.png" />
                                </div>
                              <table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" >
                              <tr>
                                  <td style=" text-align:right;">Powered by &#45; <a  href="http://www.hellogtx.com/" target="_blank" style="font-family:AvantGarde Bk BT;color:#0b74c4; text-decoration:none">hello<span style="font-family:AvantGarde Bk BT;color:#fb5a2d;">GTX</span></a></td>
                                </tr>
                              </table>';

            $configs = [
                'to' => $contactDetail_mail['email'],
                'fromName' => $this->siteName,
                'fromEmail' => $contactDetail_mail['email'],
                'subject' => $subject,
                'bodyHtml' => $message,
            ];

            $emailres = $this->_helper->General->mailSentByElastice($configs, 'Flight');

            if ($emailres) {
                $response = array('status' => true, 'msg' => 'Flight enquiry sent successfully.');
                echo json_encode($response);
                exit;
            } else {
                $response = array('status' => false, 'msg' => 'Unable to send enquiry.');
                echo json_encode($response);
                exit;
            }
        }
    }

    public function sendSearchHotelEmailAction()
    {
        $this->view->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        $arrPrefferedAirlines = unserialize(CONST_FLIGHT_PREFERRED_AIRLINES);
        $arrCabinClass = unserialize(CONST_FLIGHT_CABIN_CLASS);

        if ($this->getRequest()->isPost()) {
            $param = $this->getRequest()->getParams();
            $contactDetail_mail = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getContactDetailForFooter();
            //            echo "<pre>";print_r($param);die;

            $cityName = $param['cityNameVal'];
            $cityId = $param['cityId'];
            echo $cityName;
            echo $cityId;
            die();
            $check_in = isset($param['check_in']) ? $param['check_in'] : '';
            $check_out = isset($param['check_out']) ? $param['check_out'] : '';
            $roomDetail = '';
            for ($m = 1; $m <= $param['roomcount']; $m++) {

                $roomDetail .= 'Room ' . $m . ' : Adult : ' . $param['traveler_hotel_adult_' . $m] . ', Child : ' . $param['traveler_hotel_child_' . $m] . '<br>';
            }

            $cabin_class = $arrCabinClass[$param['cabin_class']];
            $subject = "Hotel Enquiry Details";
            $message = '';
            $message .= '<table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" style=" font-size:14px; font-family: Roboto, sans-serif;">
                                <tr>
                                  <td colspan="2" style=" padding:5px 40px;vertical-align: middle;">Dear Admin, <br>
                                    <br>
                                    You have received a new hotel query detail as below:</td>
                                </tr>
                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">Destination : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $cityName . '</td>
                                </tr>

                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">Check In  : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $check_in . '</td>
                                </tr>
                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">Check Out  : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $check_out . '</td>
                                </tr>
                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">Travelers : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $roomDetail . '</td>
                                </tr>

                                <tr>
                                  <td colspan="2" style=" padding:5px 40px;vertical-align: middle;">Thanks ! <br>
                                    <hr / style="border-width: 0.6px;">
                                    <br>
                                    <br>
                                    contact number: ' . $contactDetail_mail["mobile"] . '<br>
                                    Email: ' . $contactDetail_mail["email"] . '</td>
                                </tr>
                              </table>
                              <div style="text-align:center;">
                                   <img style="width:100px;" src="' . $this->baseUrl . 'public/images/logo.png" />
                                </div>
                              <table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" >
                              <tr>
                                  <td style=" text-align:right;">Powered by &#45; <a  href="http://www.hellogtx.com/" target="_blank" style="font-family:AvantGarde Bk BT;color:#0b74c4; text-decoration:none">hello<span style="font-family:AvantGarde Bk BT;color:#fb5a2d;">GTX</span></a></td>
                                </tr>
                              </table>';

            $configs = [
                'to' => $contactDetail_mail['email'],
                'fromName' => $this->siteName,
                'fromEmail' => $contactDetail_mail['email'],
                'subject' => $subject,
                'bodyHtml' => $message,
            ];

            $emailres = $this->_helper->General->mailSentByElastice($configs, 'Hotel');

            if ($emailres) {
                $response = array('status' => true, 'msg' => 'Hotel enquiry sent successfully.');
                echo json_encode($response);
                exit;
            } else {
                $response = array('status' => false, 'msg' => 'Unable to send enquiry.');
                echo json_encode($response);
                exit;
            }
        }
    }

    public function sendSearchCabsEmailAction()
    {
        $this->view->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        $arrPrefferedAirlines = unserialize(CONST_FLIGHT_PREFERRED_AIRLINES);
        $arrCabinClass = unserialize(CONST_FLIGHT_CABIN_CLASS);

        if ($this->getRequest()->isPost()) {
            $param = $this->getRequest()->getParams();
            $contactDetail_mail = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getContactDetailForFooter();
            //            echo "<pre>";print_r($param);die;

            $cabFromDestinationName = $param['cabFromDestinationName'];
            $cabToDestinationName = $param['cabToDestinationName'];
            $cab_start_date = isset($param['cab_start_date']) ? $param['cab_start_date'] : '';
            $cab_end_date = isset($param['cab_end_date']) ? $param['cab_end_date'] : '';

            $subject = "Cabs Enquiry Details";
            $message = '';
            $message .= '<table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" style=" font-size:14px; font-family: Roboto, sans-serif;">
                                <tr>
                                  <td colspan="2" style=" padding:5px 40px;vertical-align: middle;">Dear Admin, <br>
                                    <br>
                                    You have received a new hotel query detail as below:</td>
                                </tr>
                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">From Destination : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $cabFromDestinationName . '</td>
                                </tr>
                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">To Destination : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $cabToDestinationName . '</td>
                                </tr>

                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">Start Date  : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $cab_start_date . '</td>
                                </tr>
                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">End Date  : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $cab_end_date . '</td>
                                </tr>

                                <tr>
                                  <td colspan="2" style=" padding:5px 40px;vertical-align: middle;">Thanks ! <br>
                                    <hr / style="border-width: 0.6px;">
                                    <br>
                                    <br>
                                    contact number: ' . $contactDetail_mail["mobile"] . '<br>
                                    Email: ' . $contactDetail_mail["email"] . '</td>
                                </tr>
                              </table>
                              <div style="text-align:center;">
                                   <img style="width:100px;" src="' . $this->baseUrl . 'public/images/logo.png" />
                                </div>
                              <table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" >
                              <tr>
                                  <td style=" text-align:right;">Powered by &#45; <a  href="http://www.hellogtx.com/" target="_blank" style="font-family:AvantGarde Bk BT;color:#0b74c4; text-decoration:none">hello<span style="font-family:AvantGarde Bk BT;color:#fb5a2d;">GTX</span></a></td>
                                </tr>
                              </table>';

            $configs = [
                'to' => $contactDetail_mail['email'],
                'fromName' => $this->siteName,
                'fromEmail' => $contactDetail_mail['email'],
                'subject' => $subject,
                'bodyHtml' => $message,
            ];

            $emailres = $this->_helper->General->mailSentByElastice($configs, 'Cabs');

            if ($emailres) {
                $response = array('status' => true, 'msg' => 'Cab enquiry sent successfully.');
                echo json_encode($response);
                exit;
            } else {
                $response = array('status' => false, 'msg' => 'Unable to send enquiry.');
                echo json_encode($response);
                exit;
            }
        }
    }

    public function sendSearchForexEmailAction()
    {
        $this->view->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        $arrPrefferedAirlines = unserialize(CONST_FLIGHT_PREFERRED_AIRLINES);
        $arrCabinClass = unserialize(CONST_FLIGHT_CABIN_CLASS);

        if ($this->getRequest()->isPost()) {
            $param = $this->getRequest()->getParams();
            $contactDetail_mail = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getContactDetailForFooter();
            //            echo "<pre>";print_r($param);die;

            $forexFromDestinationName = $param['forexFromDestinationName'];
            $forexToDestinationName = $param['forexToDestinationName'];
            $forex_depart_date = isset($param['forex_depart_date']) ? $param['forex_depart_date'] : '';
            $forex_return_date = isset($param['forex_return_date']) ? $param['forex_return_date'] : '';

            $subject = "Forex Enquiry Details";
            $message = '';
            $message .= '<table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" style=" font-size:14px; font-family: Roboto, sans-serif;">
                                <tr>
                                  <td colspan="2" style=" padding:5px 40px;vertical-align: middle;">Dear Admin, <br>
                                    <br>
                                    You have received a new hotel query detail as below:</td>
                                </tr>
                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">From Destination : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $forexFromDestinationName . '</td>
                                </tr>
                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">To Destination : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $forexToDestinationName . '</td>
                                </tr>

                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">Departing Date  : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $forex_depart_date . '</td>
                                </tr>
                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">Returning Date  : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $forex_return_date . '</td>
                                </tr>

                                <tr>
                                  <td colspan="2" style=" padding:5px 40px;vertical-align: middle;">Thanks ! <br>
                                    <hr / style="border-width: 0.6px;">
                                    <br>
                                    <br>
                                    contact number: ' . $contactDetail_mail["mobile"] . '<br>
                                    Email: ' . $contactDetail_mail["email"] . '</td>
                                </tr>
                              </table>
                              <div style="text-align:center;">
                                   <img style="width:100px;" src="' . $this->baseUrl . 'public/images/logo.png" />
                                </div>
                              <table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" >
                              <tr>
                                  <td style=" text-align:right;">Powered by &#45; <a  href="http://www.hellogtx.com/" target="_blank" style="font-family:AvantGarde Bk BT;color:#0b74c4; text-decoration:none">hello<span style="font-family:AvantGarde Bk BT;color:#fb5a2d;">GTX</span></a></td>
                                </tr>
                              </table>';

            $configs = [
                'to' => $contactDetail_mail['email'],
                'fromName' => $this->siteName,
                'fromEmail' => $contactDetail_mail['email'],
                'subject' => $subject,
                'bodyHtml' => $message,
            ];

            $emailres = $this->_helper->General->mailSentByElastice($configs, 'Forex');

            if ($emailres) {
                $response = array('status' => true, 'msg' => 'Forex enquiry sent successfully.');
                echo json_encode($response);
                exit;
            } else {
                $response = array('status' => false, 'msg' => 'Unable to send enquiry.');
                echo json_encode($response);
                exit;
            }
        }
    }

    public function sendSearchTrainEmailAction()
    {
        $this->view->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        $arrPrefferedAirlines = unserialize(CONST_FLIGHT_PREFERRED_AIRLINES);
        $arrCabinClass = unserialize(CONST_TRAIN_CABIN_CLASS);

        if ($this->getRequest()->isPost()) {
            $param = $this->getRequest()->getParams();
            $contactDetail_mail = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getContactDetailForFooter();
            //            echo "<pre>";print_r($param);die;

            $trainFromDestinationName = $param['trainFromDestinationName'];
            $trainToDestinationName = $param['trainToDestinationName'];
            $train_depart_date = isset($param['train_depart_date']) ? $param['train_depart_date'] : '';
            $train_return_date = isset($param['train_return_date']) ? $param['train_return_date'] : '';

            $adults = $param['adults'];
            $childs = $param['childs'];
            $infants = $param['infants'];
            $cabin_class = $arrCabinClass[$param['train_class']];
            $subject = "Train Enquiry Details";
            $message = '';
            $message .= '<table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" style=" font-size:14px; font-family: Roboto, sans-serif;">
                                <tr>
                                  <td colspan="2" style=" padding:5px 40px;vertical-align: middle;">Dear Admin, <br>
                                    <br>
                                    You have received a new hotel query detail as below:</td>
                                </tr>
                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">From Destination : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $trainFromDestinationName . '</td>
                                </tr>
                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">To Destination : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $trainToDestinationName . '</td>
                                </tr>

                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">Departing Date  : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $train_depart_date . '</td>
                                </tr>
                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">Returning Date  : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $train_return_date . '</td>
                                </tr>
                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">Travelers : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">Adult(s) : ' . $adults . ', Child(s) : ' . $childs . ', Infant(s) : ' . $infants . '</td>
                                </tr>
                                <tr>
                                  <td width="30%" style=" padding:5px 40px;vertical-align: middle;">Cabin Class : </td>
                                  <td width="70%" style=" padding:5px 40px;vertical-align: middle;">' . $cabin_class . '</td>
                                </tr>

                                <tr>
                                  <td colspan="2" style=" padding:5px 40px;vertical-align: middle;">Thanks ! <br>
                                    <hr / style="border-width: 0.6px;">
                                    <br>
                                    <br>
                                    contact number: ' . $contactDetail_mail["mobile"] . '<br>
                                    Email: ' . $contactDetail_mail["email"] . '</td>
                                </tr>
                              </table>
                              <div style="text-align:center;">
                                   <img style="width:100px;" src="' . $this->baseUrl . 'public/images/logo.png" />
                                </div>
                              <table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" >
                              <tr>
                                  <td style=" text-align:right;">Powered by &#45; <a  href="http://www.hellogtx.com/" target="_blank" style="font-family:AvantGarde Bk BT;color:#0b74c4; text-decoration:none">hello<span style="font-family:AvantGarde Bk BT;color:#fb5a2d;">GTX</span></a></td>
                                </tr>
                              </table>';

            $configs = [
                'to' => $contactDetail_mail['email'],
                'fromName' => $this->siteName,
                'fromEmail' => $contactDetail_mail['email'],
                'subject' => $subject,
                'bodyHtml' => $message,
            ];

            $emailres = $this->_helper->General->mailSentByElastice($configs, 'Forex');

            if ($emailres) {
                $response = array('status' => true, 'msg' => 'Train enquiry sent successfully.');
                echo json_encode($response);
                exit;
            } else {
                $response = array('status' => false, 'msg' => 'Unable to send enquiry.');
                echo json_encode($response);
                exit;
            }
        }
    }

    public function getCitydataAction()
    {
        $this->_helper->viewRenderer->setNoRender(true);
        $this->_helper->layout->disableLayout();
        $crud = new Admin_Model_CRUD();
        //       print_r($this->getRequest()->getParam("term"));
        //       exit;
        try {
            $arrResponse = array();
            if ($this->getRequest()->getParam("term") or $this->getRequest()->getParam("query")) {
                $term = $this->getRequest()->getParam("term") ? $this->getRequest()->getParam("term") : $this->getRequest()->getParam("query");
                $countryId = $this->getRequest()->getParam("countryId") ? $this->getRequest()->getParam("countryId") : '';

                $condCity = "tbl.Title like '" . $term . "%'";
                if (isset($countryId) && !empty($countryId)) {
                    $condCity .= " AND tbl.ContSysId = " . $countryId . "";
                }
                //echo $condCity;
                $arrResponse = $crud->getBuyHotelCityAutoSuggest($condCity);
                //                 print_r($arrResponse);die;
            }
            echo json_encode($arrResponse);
            exit;
        } catch (Exception $e) {
            $response = array('success' => false, 'msg' => $e->getMessage());
            echo json_encode($response);
            exit;
        }
    }

    public function thanksAction()
    {
        $this->view->baseUrl = $this->baseUrl;
    }

    function curl_get($url, array $get = NULL, array $options = array())
    {
        $defaults = array(
            CURLOPT_URL => $url . (strpos($url, '?') === FALSE ? '?' : '') . http_build_query($get),
            CURLOPT_HEADER => 0,
            CURLOPT_RETURNTRANSFER => TRUE,
            CURLOPT_TIMEOUT => 4
        );

        $ch = curl_init();
        curl_setopt_array($ch, ($options + $defaults));
        if (!$result = curl_exec($ch)) {
            trigger_error(curl_error($ch));
        }
        curl_close($ch);
        return $result;
    }

    public function sendFeedbackImageUploadAction()
    {
        //$filename = $_FILES['file']['name'];
        $orignalFIle = @$_FILES["file1"]["name"];
        //echo "<pre>";print_r($_FILES);die;
        if (isset($_FILES) && !empty($_FILES)) {
            foreach ($_FILES as $key => $orignalFIleName) {
                if (!empty($orignalFIleName)) {
                    $orignalFIleName = $_FILES[$key]["name"];
                    $orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/public/upload/feedback/image";
                    $originalSmallFolder = $orignalFolderName . "/small";
                    $fileExt = $this->_helper->General->getFileExtension($orignalFIleName);
                    $fileName = 'feedback_' . $key . '_' . time() . '.' . $fileExt;
                    if (!file_exists($orignalFolderName)) {
                        @mkdir($orignalFolderName, 0777, true);
                    }
                    if (!file_exists($originalSmallFolder)) {
                        @mkdir($originalSmallFolder, 0777, true);
                    }
                    $temp_file_name = $_FILES[$key]["tmp_name"]; // temprary file name
                    if (move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName)) {
                        $fileNameArray[] = $fileName;
                    }
                }
            }
            $resultArr = array('status' => true, 'fileNameArray' => $fileNameArray, 'total' => count($fileNameArray));
        } else {
            $resultArr = array('status' => false, 'total' => 0);
        }
        echo json_encode($resultArr);
        exit;
    }

    public function sendFeedbackAction()
    {
        //         $objCustomerRewiew = new CustomerReview_Model_Feedback();
        $this->_helper->layout->disableLayout();
        $front = Zend_Controller_Front::getInstance();
        $front->setParam('noViewRenderer', true);
        if ($this->getRequest()->getPost()) {
            $param = $this->getRequest()->getParams();
            $contactDetail_mail = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getContactDetailForFooter();
            $date = date('Y');
            $TravelMonthArr = [
                1 => 'Jan ' . $date,
                2 => 'Feb ' . $date,
                3 => 'Mar ' . $date,
                4 => 'Apr ' . $date,
                5 => 'May ' . $date,
                6 => 'Jun ' . $date,
                7 => 'Jul ' . $date,
                8 => 'Aug ' . $date,
                9 => 'Sep ' . $date,
                10 => 'Oct ' . $date,
                11 => 'Nov ' . $date,
                12 => 'Dec ' . $date,
            ];

            //            $objAgency = new Travel_Model_TblAgency();
            //            $agencyData = $objAgency->getUserDataByAgency($param['AgencySysId']);

            $TripImageName = (isset($param['TripImageName']) && !empty($param['TripImageName'])) ? implode(',', $param['TripImageName']) : '';
            $saveData = [
                'AgencySysId' => $this->gtxagencysysid,
                'Name' => $param['Name'],
                'EmailId' => $param['EmailId'],
                'Destination' => $param['Destination'],
                'DestinationId' => 1,
                'TravelMonth' => $param['TravelMonth'],
                'ReviewStarValue' => $param['ReviewStarValue'],
                'ReviewTitle' => $param['ReviewTitle'],
                'Review' => $param['Review'],
                'TripImage' => $TripImageName,
                'isActive' => 1,
                'isMarkForDel' => 0
            ];
            //  echo "<pre>";print_r($saveData);die;
            $crud = new Admin_Model_CRUD();
            $feedback = $crud->rv_insert('tbl_feedback', $saveData);
            $html = '';
            $htmlImage = '';
            if (isset($param['TripImageName']) && !empty($param['TripImageName'])) {
                $mi = 1;
                foreach ($param['TripImageName'] as $key => $val) {
                    $TripImageName = $val;
                    $html .= '<a href="' . $this->baseUrl . 'public/upload/feedback/image/' . $TripImageName . '">Image Url ' . $mi . '</a><br>';
                    $mi++;
                }
                $htmlImage = '<tr>
                    <td style=" padding:5px 40px;vertical-align: middle;">Trip Images : </td>
                    <td style=" padding:5px 40px;vertical-align: middle;">' . $html . '</td>
                  </tr>';
            }
            // echo "<pre>";print_r($html);die;
            if ($feedback) {

                $mailBody = '<table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" style=" border: dashed 1px #ccc; font-size:14px; font-family: Roboto, sans-serif;">

                <tr>
                  <td colspan="2" style=" padding:5px 40px;vertical-align: middle;">Dear ' . ucfirst($param['Name']) . ', <br>
                    <br>
                    Greetings from ' . $this->siteName . '!  <br> <br>
                    Thank you for your feedback!</td>
                </tr>
                <tr>
            <td colspan="2" style=" padding:5px 40px;vertical-align: middle;">Thanks ! <br>
              <hr / style="border-width: 0.6px;">
              <br>
              contact number: ' . $contactDetail_mail['phone'] . '<br>
              Email:' . $contactDetail_mail['email'] . '</td>
          </tr>
              </table>';

                $mailBodyAdmin = '<table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" style=" border: dashed 1px #ccc; font-size:14px; font-family: Roboto, sans-serif;">

                <tr>
                  <td colspan="2" style=" padding:5px 40px;vertical-align: middle;">Dear Admin, <br>
                    <br>
                    Greetings !  <br> <br>
                    You have received a new feedback detail as below:</td>
                </tr>
                <tr>
    <td colspan="2" style=" padding:5px 40px;vertical-align: middle;">&nbsp;</td>

  </tr>
  <tr>
    <td style=" padding:5px 40px;vertical-align: middle;">Name :</td>
    <td style=" padding:5px 40px;vertical-align: middle;">' . ucfirst($param['Name']) . '</td>
  </tr>
  <tr>
    <td style=" padding:5px 40px;vertical-align: middle;">Email :</td>
    <td style=" padding:5px 40px;vertical-align: middle;">' . ($param['EmailId']) . '</td>
  </tr>
  <tr>
    <td style=" padding:5px 40px;vertical-align: middle;">Destination : </td>
    <td style=" padding:5px 40px;vertical-align: middle;">' . ($param['Destination']) . '</td>
  </tr>
  <tr>
    <td style=" padding:5px 40px;vertical-align: middle;">Month : </td>
    <td style=" padding:5px 40px;vertical-align: middle;">' . ($TravelMonthArr[$param['TravelMonth']]) . '</td>
  </tr>
  <tr>
    <td style=" padding:5px 40px;vertical-align: middle;">Experience : </td>
    <td style=" padding:5px 40px;vertical-align: middle;">' . ($param['ReviewStarValue']) . ' Star</td>
  </tr>
  <tr>
    <td style=" padding:5px 40px;vertical-align: middle;">ReviewTitle : </td>
    <td style=" padding:5px 40px;vertical-align: middle;">' . ($param['ReviewTitle']) . '</td>
  </tr>
  <tr>
    <td style=" padding:5px 40px;vertical-align: middle;">Review : </td>
    <td style=" padding:5px 40px;vertical-align: middle;">' . ($param['Review']) . '</td>
  </tr>
  ' . $htmlImage . '

                <tr>
            <td colspan="2" style=" padding:5px 40px;vertical-align: middle;">Thanks ! <br>
              <hr / style="border-width: 0.6px;">
              <br>
              contact number: ' . $contactDetail_mail['phone'] . '<br>
              Email:' . $contactDetail_mail['email'] . '</td>
          </tr>
              </table>';
            }

            $subject = 'Feedback';
            $configs = [
                'to' => $param['EmailId'],
                'fromName' => $this->siteName,
                'fromEmail' => $contactDetail_mail['email'],
                'subject' => $subject,
                'bodyHtml' => $mailBody,
            ];

            $custMail = $this->objHelperGeneral->mailSentByElastice($configs, 'package');
            $configsAdmin = [
                'to' => $contactDetail_mail['email'],
                'fromName' => $this->siteName,
                'fromEmail' => $contactDetail_mail['email'],
                'subject' => $subject,
                'bodyHtml' => $mailBodyAdmin,
            ];

            $adminMail = $this->objHelperGeneral->mailSentByElastice($configsAdmin, 'package');
            $returnArray = array('status' => true, 'message' => 'Feedback submitted successfully!!!');
            echo json_encode($returnArray);
            exit;
        }
    }

    public function dealsAction()
    {
        $this->view->baseUrl = $this->baseUrl;
        $this->view->siteName = $this->siteName;

        $lastMinuteTours = $this->objMdl->rv_select_all('tb_tbb2c_packages_master', ['PkgSysId', 'Image', 'GTXPkgId', 'Destinations', 'Countries', 'BookingValidUntil', 'LongJsonInfo', 'Nights', 'StarRating', 'PackageType', 'PackageSubType'], ['IsActive' => 1, 'IsPublish' => 1, 'IsMarkForDel' => 0, 'ItemType' => 1, 'lastMinuteDeal' => 1], ['PkgSysId' => 'DESC'], 6);

        foreach ($lastMinuteTours as $key => $values) {

            $destinationArr = explode(',', $values['Destinations']); // get the first destination only by extracting array
            $LongJsonInfo = Zend_Json::decode($values['LongJsonInfo']);

            $categoryDetails = $this->objHelperGeneral->getCategoryAndPriceArray($LongJsonInfo['package']['TourTypes']['MarketType'], 'B2C', $values['PackageType'], $values['PackageSubType']); // get default category

            $tourImage1 = explode(',', $values['Image']);
            $tourImage = $tourImage1[0];

            $defaultCategoryId = $categoryDetails['defaultCategoryId'];
            $defaultCategory = $categoryDetails['defaultCategory'];
            $defaultTourType = $categoryDetails['defaultTourType'];
            $TPId = ($values['PackageType'] == $this->packageTypeStatic) ? $LongJsonInfo['package']['TPId'] : $categoryDetails['TPId'];
            $MPType = (!empty($categoryDetails['MPType']) && ($categoryDetails['MPType'] != 'LowestCost')) ? array_search($categoryDetails['MPType'], unserialize(CONST_MEAL_PLAN_ARR)) : 0;

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

            $displayFinalPrice = $this->objHelperGeneral->getPackagePrice($defaultCategoryId, $tourTypeChar, $priceArrJson, true);  // Param 4: true ( if calculate discounted price )
            $defaultCategoryIdm = isset($LongJsonInfo['package']['Itineraries']['Itinerary'][0]['ItineraryItem'][1]['Items'][0]['Id']) ? $LongJsonInfo['package']['Itineraries']['Itinerary'][0]['ItineraryItem'][1]['Items'][0]['Id'] : 0;
            $lastMinuteToursFinal[] = [
                'name' => $this->objHelperGeneral->trimContent($LongJsonInfo['package']['Name'], 24),
                'nameF' => $LongJsonInfo['package']['Name'], // full name of package name
                'img' => $tourImage,
                'night' => $values['Nights'],
                'price' => $this->objHelperGeneral->moneyFormatINR(round($displayFinalPrice)),
                'pricerange' => $LongJsonInfo['package']['PriceRange'],
                'star' => $values['StarRating'],
                'Destination' => $values['Destinations'],
                'PkgSysId' => $values['PkgSysId'],
                'GTXPkgId' => $values['GTXPkgId'],
                'defaultCategoryId' => ($defaultCategoryId != '') ? $defaultCategoryId : $defaultCategoryIdm,
                'defaultCategory' => $defaultCategory,
                'tourtype' => ($defaultTourType != '') ? $defaultTourType : 1,
                'TPId' => $TPId,
                'PackageType' => $values['PackageType'],
                'mp' => $MPType,
                'Countries' => $values['Countries'],
                'isFixedDeparturesPackage' => $LongJsonInfo['package']['IsFixedDeparturePackage'],
                'BookingValidUntil' => $values['BookingValidUntil'],
            ];
        }
        $this->view->lastMinuteTours = $lastMinuteToursFinal;
        $getPageDetail = $this->objMdl->rv_select_row('tbl_static_pages', ['*'], ['sid' => 194, 'status' => 'Activate'], ['sid' => 'desc']);

        $this->view->getPageDetail = $getPageDetail;
    }

    //  SELECT * FROM `tbl_offers` WHERE expiryDate>2022/03/10

    public function offersAction()
    {
        //echo $this->stylecss;
        $current_date = date("Y-m-d");
        $REQUEST_URI = str_replace('%E2%80%99', '’', ltrim($_SERVER['REQUEST_URI'], '/'));
        $pageid = $REQUEST_URI;
        //  print_r($REQUEST_URI);die;
        //echo $this->stylecss;
        $current_date = date("Y-m-d");
        $this->view->baseUrl = $this->baseUrl;
        // $CONST_OFFERS = unserialize(CONST_OFFERS);
        // echo "<pre>";print_r($CONST_OFFERS);die;
        $this->objMdl = new Admin_Model_CRUD();
        $offers = $this->objMdl->rv_select_all('tbl_offers', ['*'], ['isActive' => 1, 'isb2b' => 0, 'isMarkForDel' => 0, 'expiryDate >' => $current_date], ['Id' => 'DESC']);
        $getPageDetail = $this->objMdl->rv_select_row('tbl_static_pages', ['*'], ['identifier' => 'offers', 'status' => 'Activate'], ['sid' => 'desc']);
        // echo"<pre>";print_r($getPageDetail);die();
        $this->view->pagedetail = $getPageDetail;
        $offersArr = $offersAllArr = array();
        foreach ($offers as $key => $value) {
            $offersArr[$value['category']][] = $value;
            $offersAllArr[] = $value;
            //print_r($offersAllArr);
        }
        $this->view->offersAllArr = $offersAllArr;

        //   echo "<pre>";
        //  print_r($offersAllArr); die;
        // echo "<pre>";
        //  print_r($offersAllArr); die;
        $this->view->offers = $offersArr;
        $this->view->CONST_OFFERS = $CONST_OFFERS;
        //  echo "<pre>";print_r($offersArr);die;
        $resultsetSeoForBlog['TravTitle'] = $getPageDetail['page_title']; // get package Keyword
        $resultsetSeoForBlog['Keyword'] = $getPageDetail['meta_keywords']; // get package Keyword
        $resultsetSeoForBlog['Description'] = $getPageDetail['meta_description']; // get package Description
        $resultsetSeoForBlog['metaTitle'] = (trim($getPageDetail['meta_title']) != '') ? $getPageDetail['meta_title'] : $getPageDetail['page_title']; // get package Metatag
        $this->view->detailLayout = $resultsetSeoForBlog;
    }

    public function testmailAction()
    {
        //$url="http://103.239.139.156:8003/api/v1/car/hotel-master/";
        $url = "http://103.239.139.156";
        $datashd = get_headers($url);
        //print_r($datashd);
        //die();
        $contactDetail_mail = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getContactDetailForFooter();
        if ($this->getRequest()->isPost()) {
            $param = $this->getRequest()->getParams();
            $to = $param['to'];
            $from = $param['from'];
            $subject = $param['subject'];
            $message = $param['message'];

            $configs = [
                'to' => $to,
                'fromName' => 'test Mail',
                'fromEmail' => $contactDetail_mail['email'],
                'subject' => $subject,
                'bodyHtml' => $message,
            ];
            $this->_helper->General->mailSentByElastice($configs, 'test');

            $this->view->message = "Successfully mail has been sent";
        }
    }

    public function mediaAction()
    {
        $this->view->baseUrl = $this->baseUrl;
        $this->objMdl = new Admin_Model_CRUD();
        $mediagallery = $this->objMdl->rv_select_all('tbl_home_exploregallery', ['*'], ['IsActive' => 1, 'isMarkForDel' => 0, 'type' => 1], ['id' => 'DESC'], 15);
        // echo "<pre>"; print_r($mediagallery); die();
        $mediavideo = $this->objMdl->rv_select_all('tbl_home_exploregallery', ['*'], ['IsActive' => 1, 'isMarkForDel' => 0, 'type' => 2], ['id' => 'DESC'], 15);
        $staticdataMedia = $this->objMdl->rv_select_row('tbl_static_pages', ['*'], ['status' => 'Activate', 'identifier' => 'media'], ['sid' => 'desc']);
        //echo"<pre>";print_r($staticdataMedia);die();
        $categorymaster = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->categorymaster();

        //echo "<pre>"; print_r($categorymaster); die();
        $allverticalArray = $allCategoryArray = $masterData = array();

        foreach ($categorymaster as $key => $masterVal) {

            $allverticalArray[$masterVal['type']] = $masterVal['categaryName'];
            // $allCategoryArray[$masterVal['type']][$masterVal['Id']] = $masterVal['title'];
            $masterData[$masterVal['type']][$masterVal['categoryId']]['catTitle'] = $masterVal['categaryName'];
            $masterData[$masterVal['type']][$masterVal['categoryId']]['catImg'] = $masterVal['categaryImage'];
            $masterData[$masterVal['type']][$masterVal['categoryId']]['masterCatId'] = $masterVal['categoryId'];

            $masterData[$masterVal['type']][$masterVal['categoryId']]['data'][] = $masterVal;

            // if($masterVal['type']==1) {
            //     $mediagallery1[] = [
            //          'id' =>   $masterVal['id'],
            //          'title' => $masterVal['title'],
            //          'gallery' => $masterVal['gallery'],
            //          'type' =>    $masterVal['type'],
            //          'IsActive' =>   $masterVal['IsActive'],
            //          'IsmarkForDel' =>  $masterVal['IsmarkForDel'],
            //          'IsFeatured' =>$masterVal['IsFeatured'],
            //          'categoryId' =>    $masterVal['categoryId'],
            //          'Id' => $masterVal['Id'],
            //          'categaryName' =>$masterVal['categaryName'],
            //          'categaryImage' =>    $masterVal['categaryImage'],
            //    ];
            // }  else {
            //     $mediavideo1[] = [
            //          'id' =>   $masterVal['id'],
            //          'title' => $masterVal['title'],
            //          'video' => $masterVal['video'],
            //          'type' =>    $masterVal['type'],
            //          'IsActive' =>   $masterVal['IsActive'],
            //          'IsmarkForDel' =>  $masterVal['IsmarkForDel'],
            //          'IsFeatured' =>$masterVal['IsFeatured'],
            //          'categoryId' =>    $masterVal['categoryId'],
            //          'Id' => $masterVal['Id'],
            //          'categaryName' =>$masterVal['categaryName'],
            //          'categaryImage' =>    $masterVal['categaryImage'],
            //    ];
            // }
        } //end foreach
        // echo "<pre>"; print_r($categorymaster); die("");
        $this->view->masterData = $masterData;

        $this->view->staticdataMedia = $staticdataMedia;
        $this->view->mediagallery = $mediagallery;
        $this->view->mediavideo = $mediavideo;
        $this->view->categorymaster = $categorymaster;
    }

    public function testimonialListAction()
    {

        // die("check");

        $this->view->baseUrl = $this->baseUrl;
        $this->objMdl = new Admin_Model_CRUD();

        $testimonials = $this->objMdl->rv_select_all('tbl_feedback', ['*'], ['IsActive' => 1], ['FeedbackId' => 'DESC']);
        $this->view->testimonials = $testimonials;
        $this->view->gtxBtoBsite = $this->gtxBtoBsite;
    }

    public function sitemapAction()
    {
        $this->_helper->layout->disableLayout();
        $html = new Zend_View();
        $folder = $this->stylecss;
        $html->setScriptPath(APPLICATION_PATH . '/sites/' . $folder);
        header("Content-type: text/xml");
        $bodyText = $html->render('sitemap.xml');
        echo $bodyText;
        die();
    }

    public function robotsAction()
    {
        $this->_helper->layout->disableLayout();
        $html = new Zend_View();
        $folder = $this->stylecss;
        $html->setScriptPath(APPLICATION_PATH . '/sites/' . $folder);
        header("Content-type: text/txt");
        $bodyText = $html->render('robots.txt');
        echo $bodyText;
        die();
    }

    private function check_enabled_hotel_api()
    { //pankaj 29/07/2022
        $tj_hotel = $this->configuration['IsTJHotelAPI'];
        $tbo_hotel = $this->configuration['IsTBOHotelAPI'];
        if ($tj_hotel == 0 && $tbo_hotel == 1) {
            return "TBO_ENABLED";
        } elseif ($tj_hotel == 1 && $tbo_hotel == 0) {
            return "TJ_ENABLED";
        } elseif ($tj_hotel == 1 && $tbo_hotel == 1) {
            return false;
        } else {
            return false;
        }
    }

    private function hotel_nationality_list()
    {
        $arrContextOptions = array(
            "ssl" => array(
                "verify_peer" => false,
                "verify_peer_name" => false,
            ),
        );
        // $check_hotel_enable = $this->check_enabled_hotel_api();
        // if ($check_hotel_enable == 'TJ_ENABLED') {
        //     $urln = $this->baseUrl . 'public/data/dynamic/nationality.json';
        //     $nationality = file_get_contents($urln, false, stream_context_create($arrContextOptions));
        //     $response = ($nationality != '') ? Zend_Json::decode($nationality) : array();
        // } else if ($check_hotel_enable == 'TBO_ENABLED') {
        //     $urln = $this->baseUrl . 'public/data/dynamic/tbo_hotel_nationality.json';
        //     $nationality = file_get_contents($urln, false, stream_context_create($arrContextOptions));
        //     $response = ($nationality != '') ? Zend_Json::decode($nationality) : array();
        // } else {
        //     $response = [];
        // }
        $urln = $this->baseUrl . 'public/data/dynamic/nationality.json';
        $nationality = file_get_contents($urln, false, stream_context_create($arrContextOptions));
        $response = ($nationality != '') ? Zend_Json::decode($nationality) : array();
        return $response;
    }

    public function checkPaymentStatusAction()
    {

        // ini_set('display_errors', 1);
        // ini_set('display_startup_errors', 1);
        // error_reporting(E_ALL);
        $this->_helper->viewRenderer->setNoRender(true);

        $param = json_decode('{"encdata":"077784899E223D64B191A605B908A8DA7AEFB88A99C4CF598B67EB4B2395CEF83E068E72BCF033D40CE9BAD38E86BBA0D9CCCCBCE3D0C99669CD3B82B6F66AE1A6FFD734B9EBE398D20FF61D51362134AFB673614C3E73895B376C39E5ED6B977E49080A93C9EDDD935FEE14F9D99F9EBA81E89B3919E90CA99377072EBBCB5C233FAB15677437D26546E8C3D0EC7490A20BCE4D9674DEC0BFBC6F4F27338BA18F68156EB0E6800C2C645C45422B43D5B4FE1B2BA4ADA5BA78E851EC2177B52B352A61F48468DA96AED10CE637C767E93F5F0F68E7D47219201F0AB8670DE0694779EBDD032959523D099C150E4DAC03442505BC439C516C3562C947E33DFE2EC5439E34DEF49DE0C17773D49855B93A21B3C14A424997CCC4C57F5355768A19EF2B970C502AC3FD1363FAD7BFF100CC97E9CD5523FE9BAD0A761F230D01CB65F96E434D47EB46E9D8326A18BDE2058C20C9779C44582C6575DF9D004A999800339EAE7C86570E31977D1032AADA9CC6654313D84C7418EAE54995BD0D61921D65A7B87A8360A1B19FE619482208A94CA2340770A1926173CAD1C355DA815F91EDED5CCE8BAB7019FC5484EAD513C73112210278A3F3FCCD768134B882A96C1579A16AC4E1C53BD6220C29FC7F2E44C88E042CB5ACECEB0F0E2FCCE407FC5874EE6D648E5FF53E07A6E451DBF705663114F374091CC29E608B5536CE80EC9C0103896B4748797A55FEA1179D05AF7C727726CEB7B240770D3D6B002450FB6D3A677AB02D3486D7C422D6B04DB324E1C9A97F99936A8BBB8BC252A6CBCF689FDB009D33F8036326D7B3CE094038DAE568636AF6417A330CA8F7B1D8494DC6C4AA38C7983270493D5FABD6D60BA58CFFC839B22D2CF3ABBC5CC7852A5C9309EAFE394091C2143B9C0B1EDAAC51F9D6764F38F0D3D25AF3770EE88B176ECCF32C1B2C23A54A59628997C0A0B93BC8A820CA615EE72262B855085686F3E9BD4AB33F07522975F0FBDC745A29821987E8E3E1E11A817E49FFC9920BC25B2B79DFB3C6B9B07E30ED26A7ADA98394382146E08EEE7CDD0ED187CE31E39226828B6392C776077F82CAE1A569506AFE893CF76293E67D2428DE1EF8E5F73E08596DE9A89A2A006148E4BA65E63F5B6D5D6F361432E6A469CE5CB08004D900B651A882F98D745C0A92C2EBBAB8B674B4D7AE0F650C2CC6839E99A2DC154B985A2DFB04D6BAB886A157D36BE7DCD6BB2F49DCA78FEAD49C7D888C4517541A652A1F36F1DFF2515BACA79CCA3FAC99EA2F32A6175D06AD4BF0B9F6959B05E82A241420279AA6F3D9985A98DD130C5B3DEF272081672DF1B70BE8AB63DA590EA8EDF7DEEA927AB0CD9B29E06C5306064264E2FE059317C2CA099929B8D91BB54AB789C360BC73937FBA695730F93EFC5918E07543DC0A825442F21479D46FB17551E292A4A1C4","type":""}', true);
        if (!empty($param)) {
            $PGType = (isset($param['type']) && !empty($param['type'])) ? $param['type'] : '';
            $transactionResponse = new Travel_Model_TransactionResponse();
            $transactionResponse->setRespHashKey($this->respHashKey);
            $transactionResponse->setResponseEncypritonKey($this->aesResponseKey);
            $transactionResponse->setSalt($this->aesResponseIv);
            if ($PGType == 'easebuzz') {
                $transactionResponse->setRespHashKey($this->respHashKey);
                $transactionResponse->setResponseEncypritonKey($this->aesRequestKey);
                $transactionResponse->setSalt($this->aesRequestKey);
                $returnPerameter = $transactionResponse->decryptResponseInEasebuzz($param['encdata']);
                $returnPerameter = json_decode($returnPerameter, 1);
                $returnPerameter['f_code'] = ($returnPerameter['status'] == 'success') ? 'Ok' : '';
                $returnPerameter['bank_txn'] = $returnPerameter['easepayid'];
                $returnPerameter['mer_txn'] = $returnPerameter['txnid'];
                $returnPerameter['ipg_txn_id'] = $returnPerameter['bank_ref_num'];
                $returnPerameter['mmp_txn'] = $returnPerameter['bank_ref_num'];
                $returnPerameter['desc'] = $returnPerameter['error_Message'];
                $returnPerameter['error'] = $returnPerameter['error_Message'];
            } elseif ($param['type'] == 'CCAVENUE') {
                $workingKey = $this->CCAVENUEWorkingKey; //$checkPaymentSetting['PaymentSecretPwd'];
                $encResponse = $param["encdata"];
                $rcvdString = $transactionResponse->decrypt_cc($encResponse, $workingKey);
                $decryptValues = explode('&', $rcvdString);
                echo "<pre>";
                print_r($decryptValues);
                $dataSize = sizeof($decryptValues);
                $bank_ref_no = $order_id = $tracking_id = $status_message = $merchant_param5 = $order_status = '';
                for ($i = 0; $i < $dataSize; $i++) {
                    $information = explode('=', $decryptValues[$i]);
                    if (isset($information[0])) {
                        if ($information[0] == 'order_status') {
                            $order_status = $information[1];
                        }
                        if ($information[0] == 'merchant_param5') {
                            $merchant_param5 = $information[1];
                        }
                        if ($information[0] == 'status_message') {
                            $status_message = $information[1];
                        }
                        if ($information[0] == 'tracking_id') {
                            $tracking_id = $information[1];
                        }
                        if ($information[0] == 'order_id') {
                            $order_id = $information[1];
                        }
                        if ($information[0] == 'bank_ref_no') {
                            $bank_ref_no = $information[1];
                        }
                    }
                }
                $returnPerameter['f_code'] = ($order_status == 'Success') ? 'Ok' : '';
                $returnPerameter['bank_txn'] = $tracking_id;
                $returnPerameter['mer_txn'] = $order_id;
                $returnPerameter['ipg_txn_id'] = $bank_ref_no;
                $returnPerameter['mmp_txn'] = $tracking_id;
                $returnPerameter['desc'] = $status_message;
                $returnPerameter['error'] = $order_status;
                $returnPerameter['udf9'] = $merchant_param5;
            } else {
                $returnPerameter = $transactionResponse->decryptResponseIntoArray($param['encdata']);
            }
        }
        echo "<pre>";
        print_r($this->CCAVENUEWorkingKey);
        echo "<pre>";
        print_r($param);
        print_r($returnPerameter);
        die('d');
    }

    public function setdefaultAction()
    {
        $param = $this->getRequest()->getParams();
        if (isset($param['id']) && !empty($param['id'])) {
            Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CurrencyData($this->gtxagencysysid, $param['id']);
            $this->_redirect(base64_decode($param['redirect_link']));
        } else {
            die('Invalid request');
        }
    }

    public function findtocityseriesAction()
    {
        $toCity = [];
        unset($toCity);
        $data = $this->getRequest()->getParams();
        // echo "data<pre>";print_r($data);die;
        $dataval = explode("__", $data['From']);
        // echo "fromVal($dataval)";
        // print_r($dataval);
        // die;
        $sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
        $sessionFlightSearchParams = $sessionFlightSearchParams->params;
        // echo "<pre>";print_r($sessionFlightSearchParams['MergeSecotrsArrayTo']);die;
        if ($sessionFlightSearchParams['MergeSecotrsArrayTo'] && $data['tripType'] == 1) {
            foreach ($sessionFlightSearchParams['MergeSecotrsArrayTo'] as $key => $value) {
                // if($key == $dataval[1]){
                //   $toCity[] = $value['ToAirPortCode'];
                // }
                if ($value['FromAirPortCode'] == $data['From']) {
                    $toCity[] = $key;
                }
            }
        } else {
            foreach ($sessionFlightSearchParams['MergeSecotrsArrayTo2'] as $key => $value) {
                if ($value['FromAirPortCode'] == $data['From']) {
                    $toCity[] = $key;
                }
            }
        }
        $data = ['status' => 'true', 'toCity' => $toCity];
        echo json_encode($data);
        exit;
    }

    public function checkHotelPaymentAction()
    {
        //$this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        $param = $this->getRequest()->getParams();

        $PGType = (isset($param['type']) && !empty($param['type'])) ? $param['type'] : '';
        $transactionResponse = new Travel_Model_TransactionResponse();
        $transactionResponse->setRespHashKey($this->respHashKey);
        $transactionResponse->setResponseEncypritonKey($this->aesResponseKey);
        $transactionResponse->setSalt($this->aesResponseIv);
        if ($PGType == 'easebuzz') {
            $returnPerameter = $transactionResponse->decryptResponseInEasebuzz($param['encdata']);
            $returnPerameter = json_decode($returnPerameter, 1);
            $returnPerameter['f_code'] = ($returnPerameter['status'] == 'success') ? 'Ok' : '';
            $returnPerameter['bank_txn'] = $returnPerameter['easepayid'];
            $returnPerameter['mer_txn'] = $returnPerameter['txnid'];
            $returnPerameter['ipg_txn_id'] = $returnPerameter['bank_ref_num'];
            $returnPerameter['mmp_txn'] = $returnPerameter['bank_ref_num'];
            $returnPerameter['desc'] = $returnPerameter['error_Message'];
            $returnPerameter['error'] = $returnPerameter['error_Message'];
        } else {
            $returnPerameter = $transactionResponse->decryptResponseIntoArray($param['encdata']);
        }

        $checkVal = $transactionResponse->validateResponse($returnPerameter, $PGType);
        if ($checkVal == true) {

            $status = $returnPerameter["f_code"];
            $mer_txn = $returnPerameter["mer_txn"];
            $decodePerameter = Zend_Json::decode(base64_decode($returnPerameter["udf9"]), true);

            $encypetedId = $decodePerameter[5];
            $TrxId = $decodePerameter[6];
            $TrxId = explode(',', base64_decode($TrxId));
            $GUID = $returnPerameter['mmp_txn'];
            $error = isset($returnPerameter['error']) ? $returnPerameter['error'] : '';
            $error_Message = isset($returnPerameter['desc']) ? $returnPerameter['desc'] : 0;

            $decodePerameter = Zend_Json::decode(base64_decode($returnPerameter["udf9"]), true);

            $objFlight = new Travel_Model_FlightMaster();
            $arrPayment = [
                "error_Message" => $error_Message,
                "error" => $error,
                "GUID" => $GUID,
            ];

            $id = $decodePerameter[5];
            $encryptedData = new Travel_Model_AtomAES();
            $id = $traceId = $encryptedData->decrypt($id, SECURITYKEY, SECURITYKEY);

            $temp_data = $this->objMdl->selectOne('tbl_temp_data', ['*'], ['TraceId' => $traceId], ['id' => 'ASC']);
            $temData = $this->objMdl->rv_select_row("tbl_hotel_booking", ['*'], ['TraceId' => $traceId], ['Id' => 'DESC']);
            $UrlData = json_decode($temData['API_Response'], true);

            $response = json_decode($temp_data['json_data'], true);

            $HotelData = new Zend_Session_Namespace('HotelData');
            $HotelData->params = $response['HotelData'];
            $RoomInfoData = new Zend_Session_Namespace('RoomInfoData');
            $RoomInfoData->params = $response['RoomInfoData'];
            $sessionHotelSearchParams = new Zend_Session_Namespace('sessionHotelSearchParams');
            $sessionHotelSearchParams->params = $response['sessionHotelSearchParams'];

            $hotelbookingid = new Zend_Session_Namespace('hotelbookingid');
            $hotelbookingid->params = $response['hotelbookingid'];
            $SearchHotelTraceId = new Zend_Session_Namespace('SearchHotelTraceId');
            $SearchHotelTraceId->params = $response['SearchHotelTraceId'];

            $BookingRefNo = $temData['BookingRefNo'];

            // echo "<pre>";
            // print_r($TrxId);
            // die;
            $BookingId = $BookingRefNo;

            if ($id && $TrxId) {
                if ($status == "Ok") {
                    $arrPayment['paymentStatus'] = 1;
                    foreach ($TrxId as $key => $hotel_booking_id) {
                        $where = "id = " . $hotel_booking_id; //exit;
                        $updated = $objFlight->UpdateFlightData('tbl_hotel_booking', $arrPayment, $where);
                    }
                    if ($updated) {
                        $this->_redirect('hotelsinv/index/book-hotel/data/' . $id . '/code/' . $decodePerameter[5] . '?type=' . $PGType);
                    }
                } else if ($status == "C") { // cancelled by User
                    $arrPayment['paymentStatus'] = 2;
                    $arrPayment['status'] = 4;
                    foreach ($TrxId as $key => $hotel_booking_id) {
                        $where = "id = " . $hotel_booking_id; //exit;
                        $updated = $objFlight->UpdateFlightData('tbl_hotel_booking', $arrPayment, $where);
                    }

                    $this->_redirect("/hotelsinv/search/payment-failed/data/" . $id . "/status/" . $status);
                } else { // payment failed case...
                    $arrPayment['paymentStatus'] = 3;
                    $arrPayment['status'] = 4;
                    foreach ($TrxId as $key => $hotel_booking_id) {
                        $where = "id = " . $hotel_booking_id; //exit;
                        $updated = $objFlight->UpdateFlightData('tbl_hotel_booking', $arrPayment, $where);
                    }

                    $this->_redirect("/hotelsinv/search/payment-failed/data/" . $id . "/status/" . $status);
                }
            }
        } else {
            echo 'Please contact to administrator';
            exit;
        }
    }

    public function landingPageAction()
    {
        $this->_helper->layout->disableLayout();
        $this->view->baseUrl = $this->baseUrl;
        $url = $this->API_GET_LANDING_PAGE_DATA;
        //$url = 'https://st.globaltravelexchange.com/gtxwebservices/agency/get-landingpage-data';

        $param = $this->getRequest()->getParams();
        $this->view->param = $param;
        $lp = isset($param['lp']) ? explode('-', $param['lp']) : '';
        $lpid = array_reverse($lp);
        $response = array();
        if (isset($lpid[0]) && (int)$lpid[0] > 0) {
            $data['agencySysyId'] = $this->gtxagencysysid;
            $data['leadSysId'] = (int)$lpid[0];
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            $str = curl_exec($ch);
            //                       echo"<pre>";print_r($str);die('dd');
            $response = json_decode($str, true);
        }

        $this->view->result = $response;
    }

    public function sendqueryLandingpageAction()
    {
        $this->_helper->viewRenderer->setNoRender(true);
        $this->_helper->layout->disableLayout();
        if ($_POST) {

            $Name = explode(' ', trim($_POST['FirstName']));
            $_POST['FirstName'] = $Name['0'];
            $_POST['LastName'] = $Name['1'];
            if ($_POST['leadsend'] == 0) {
                $csrf_token = isset($_POST['csrf_token']) ? trim($_POST['csrf_token']) : '';
                $verifyCsrfToken = Catabatic_Helper::verifyCsrfToken($csrf_token);
                if ($verifyCsrfToken == true) {
                    $_SESSION['csrf_token'] = '';
                } else {
                    echo json_encode(array('status' => false, 'message' => 'Invalid Data', 'queryType' => 'lead'));
                    exit;
                }
                try {
                    $_POST['Noofdays'] = (int) $_POST['Noofdays'];
                    $curl = curl_init($this->API_LANDING_PAGE_LEAD); // b2c site url
                    curl_setopt($curl, CURLOPT_POST, true);
                    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($_POST));
                    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
                    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
                        'SecurityKey:' . 'SnRjV2E0T3Y2dTgwT1pqOVVOODVIL09ubk1mRytyQ0FQOHN6eXNhWTFvZ0RsTVZONm1iQ1piOXhOVXJRdGV2VzBsbkZSanVSai9jNjRrQ0JaQ2pYTWQ0dnNQQTZiYnpwZjBzY2ZDSGVGZjdDbUdxeXpVc3B4RHh2czhhZWxHYzhhdW5aTlozRXV6VElvZ2N0OVdIQ3BzVDFkTlg5Q09RM3R2ZWw3OEdwNFpsWVkzL21rcnFUOXVLSnR4czR0SUFqTVJGd01kdXJwcEVWdTVWVnRHcWdQb3puaDRzd21HQWtXOTFLOXBQZjhvc1E2cS9OUm8rai9XbGpjM0RuRUg1WQ'
                    ));
                    $response = curl_exec($curl);
                    curl_close($curl);
                    $responseArr = json_decode($response, 1);
                    if ($responseArr['status'] == 'success') {
                        echo json_encode(array('status' => true, 'message' => '', 'queryType' => 'lead', 'leadID' => $responseArr['leadID'], 'BookingType' => $responseArr['BookingType'], 'PkgType' => $responseArr['PkgType'], 'DestinationValue' => $responseArr['DestinationValue'], 'DestinationId' => $responseArr['DestinationId'], 'byopacktypeCat' => $responseArr['byopacktypeCat'], 'noofday' => $responseArr['noofday']));
                    } else {
                        echo json_encode(array('status' => false, 'message' => $response, 'queryType' => 'lead'));
                    }
                } catch (Exception $ex) {
                    echo $message = $ex->getMessage();
                    exit;
                }
            } else {
                if ($_POST['PlanType'] == 6) {
                    try {
                        $apiData = [
                            'AgencySysId' => (int) $this->gtxagencysysid,
                            'AgentSysId' => (int) $this->gtxagentsysid,
                            'leadsend' => (int) ($_POST['leadsend']),
                            'PlanType' => (int) (isset($_POST['PlanType']) && $_POST['PlanType'] != '') ? $_POST['PlanType'] : 1,
                            'leadID' => (int) ($_POST['leadID']),
                            'multivisacountry' => $this->sanitize_data($_POST['DestinationValue']),
                            'search_multi_visa' => $this->sanitize_data($_POST['DestinationId']),
                            'email' => $this->sanitize_data($_POST['Email']),
                            'phone' => $this->sanitize_data($_POST['MobileNumber']),
                            'salutation' => 0,
                            'fname' => $this->sanitize_data($_POST['FirstName']),
                            'visa_firstname' => $this->sanitize_data($_POST['FirstName']),
                            'lname' => $this->sanitize_data($_POST['LastName']),
                            'visa_lastname' => $this->sanitize_data($_POST['LastName']),
                            'salution' => 0,
                            'visa_category' => '',
                            'visa_type' => '',
                            'visa_aplicants' => (int) ($_POST['NoofTraveler']),
                            'visa_travel_date' => $this->sanitize_data($_POST['PKGCheckInDate']),
                            'visa_duration' => '',
                            'selectNationality' => (int) $this->sanitize_data($_POST['FromDestinationId']),
                            'visa_pax_type' => '',
                            'visaInventoryId' => (int) ($_POST['packageSysId']),
                            'MPType' => 1,
                            'leadsource' => isset($_POST['leadsource']) ? $this->sanitize_data($_POST['leadsource']) : '',
                        ];

                        $curl = curl_init($this->API_LANDING_PAGE_VISA); // b2c site url
                        curl_setopt($curl, CURLOPT_POST, true);
                        curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($apiData));
                        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
                        curl_setopt($curl, CURLOPT_HTTPHEADER, array(
                            'SecurityKey:' . 'SnRjV2E0T3Y2dTgwT1pqOVVOODVIL09ubk1mRytyQ0FQOHN6eXNhWTFvZ0RsTVZONm1iQ1piOXhOVXJRdGV2VzBsbkZSanVSai9jNjRrQ0JaQ2pYTWQ0dnNQQTZiYnpwZjBzY2ZDSGVGZjdDbUdxeXpVc3B4RHh2czhhZWxHYzhhdW5aTlozRXV6VElvZ2N0OVdIQ3BzVDFkTlg5Q09RM3R2ZWw3OEdwNFpsWVkzL21rcnFUOXVLSnR4czR0SUFqTVJGd01kdXJwcEVWdTVWVnRHcWdQb3puaDRzd21HQWtXOTFLOXBQZjhvc1E2cS9OUm8rai9XbGpjM0RuRUg1WQ'
                        ));
                        $response = curl_exec($curl);
                        curl_close($curl);
                        $responseArr = json_decode($response, 1);

                        echo json_encode(array('status' => true, 'queryType' => 'query', 'data' => $responseArr));
                    } catch (Exception $ex) {
                        echo $message = $ex->getMessage();
                        exit;
                    }
                } else if (isset($_POST['BookingType']) && $_POST['BookingType'] == 1 && isset($_POST['PkgType']) && $_POST['PkgType'] == 1) {

                    $PKGCheckInDate = isset($_POST['PKGCheckInDate']) ? $this->sanitize_data($_POST['PKGCheckInDate']) : '';
                    $FromDestinationId = isset($_POST['FromDestinationId']) ? $this->sanitize_data($_POST['FromDestinationId']) : '';
                    if (empty($FromDestinationId)) {
                        echo json_encode(array('status' => false, 'message' => 'Please Select Destination', 'data' => ''));
                        exit;
                    }
                    if (empty($PKGCheckInDate)) {
                        echo json_encode(array('status' => false, 'message' => 'Please Select Date', 'data' => ''));
                        exit;
                    } else {
                        $d = DateTime::createFromFormat('d/m/Y', $PKGCheckInDate);
                        $returnD =  $d && $d->format('d/m/Y') === $PKGCheckInDate;
                        if ($returnD == false) {
                            echo json_encode(array('status' => false, 'message' => 'Date Format Should be DD/MM/YYYY', 'data' => ''));
                            exit;
                        }
                    }

                    try {

                        $roominfojson = [];
                        $countRooms = (int) $_POST['room'];
                        for ($i = 0, $k = 1; $k <= $countRooms; $k++, $i++) {
                            $roominfojson[$k]['Adult'] = (int) $_POST['adult'][$i];
                            $roominfojson[$k]['Child'] = (int) $_POST['child'][$i];
                            $roominfojson[$k]['Infant'] = (int) $_POST['infant'][$i];

                            if ($_POST['adult'][$i] == 3) {
                                $roominfojson[$k]['bedtype'] = $_POST['adult_bed_type'][$i];
                            }
                            if ($_POST['child'][$i] > 0) {
                                for ($c = 1; $c <= $_POST['child'][$i]; $c++) {
                                    $roominfojson[$k]['ChildBedType_' . $c] = $_POST['child' . $c . '_bed_type'][$i];
                                    $roominfojson[$k]['ChildAge_' . $c] = '';
                                }
                            }
                        }

                        $PKGCheckInDate = explode('/', @$_POST['PKGCheckInDate']);
                        $PKGCheckInDate1 = $PKGCheckInDate[2] . '-' . $PKGCheckInDate[1] . '-' . $PKGCheckInDate[0];
                        $Noofdays = (int) $_POST['Noofdays'];

                        $PKGCheckOutDate = date('d/m/Y', strtotime($PKGCheckInDate1 . ' + ' . $Noofdays . 'days'));
                        $Destination = isset($_POST['Destination']) ? $this->sanitize_data($_POST['Destination']) : '';
                        $FromDestinationId = isset($_POST['FromDestinationId']) ? $this->sanitize_data($_POST['FromDestinationId']) : '';

                        if (trim($Destination) == '') {

                            $FromDestinationIdEx = explode('~~', $FromDestinationId);
                            $Destination = isset($FromDestinationIdEx[1]) ? trim($FromDestinationIdEx[1]) : '';
                            $FromDestinationId = (int) $FromDestinationIdEx[0];
                        }
                        $apiData = [
                            'AgencySysId' => $this->gtxagencysysid,
                            'AgentSysId' => $this->gtxagentsysid,
                            'leadsend' => (int) ($_POST['leadsend']),
                            'PlanType' => (int) (isset($_POST['PlanType']) && $_POST['PlanType'] != '') ? $_POST['PlanType'] : 1,
                            'leadID' => (int) ($_POST['leadID']),
                            'BookingType' => (int) ($_POST['BookingType']),
                            'PkgType' => isset($_POST['PkgType']) ? (int) $_POST['PkgType'] : 0,
                            'FirstName' => $this->sanitize_data($_POST['FirstName']),
                            'LastName' => $this->sanitize_data($_POST['LastName']),
                            'Email' => $this->sanitize_data($_POST['Email']),
                            'CountryCode' => $this->sanitize_data($_POST['CountryCode']),
                            'MobileNumber' => $this->sanitize_data($_POST['MobileNumber']),
                            'TravelPlanId' => (int) $this->sanitize_data($_POST['packageSysId']),
                            'PKGCheckInDate' => $this->sanitize_data($_POST['PKGCheckInDate']),
                            'PKGCheckOutDate' => $this->sanitize_data($PKGCheckOutDate),
                            'NoofTraveler' => (int) ($_POST['NoofTraveler']),
                            'Noofdays' => (int) ($_POST['Noofdays']),
                            'DestinationID' => isset($_POST['DestinationId']) ? (int) $_POST['DestinationId'] : 0,
                            'Destination' => isset($_POST['DestinationValue']) ? $this->sanitize_data($_POST['DestinationValue']) : '',
                            'FromDestination' => trim($Destination),
                            'FromDestination' => trim($Destination),
                            'FromDestinationId' => (int) $FromDestinationId,
                            'remark' => $_POST['remark'],
                            'leadsource' => isset($_POST['leadsource']) ? $this->sanitize_data($_POST['leadsource']) : '',
                            'Currency' => isset($_POST['Currency']) ? (int) ($_POST['Currency']) : '',
                            'pickupLocation' => '',
                            'PickupTime' => '',
                            'IsBusRoutePackage' => '',
                            'roomjson' => json_encode($roominfojson),
                            'emailsubject' => trim($_POST['FirstName']) . ' ' . trim($_POST['LastName']) . ' your proposal detail for ' . isset($_POST['DestinationValue']) ? $this->sanitize_data(trim($_POST['DestinationValue'])) : ''
                        ];
                        if (trim($apiData['AgencySysId']) == 4995) {
                            $apiData["PMNS"] = "TYRYUEH";
                        }
                        $curl = curl_init($this->API_LANDING_PAGE_QUERY_PROPOSAL); // b2c site url
                        curl_setopt($curl, CURLOPT_POST, true);
                        curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($apiData));
                        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
                        curl_setopt($curl, CURLOPT_HTTPHEADER, array(
                            'SecurityKey:' . 'SnRjV2E0T3Y2dTgwT1pqOVVOODVIL09ubk1mRytyQ0FQOHN6eXNhWTFvZ0RsTVZONm1iQ1piOXhOVXJRdGV2VzBsbkZSanVSai9jNjRrQ0JaQ2pYTWQ0dnNQQTZiYnpwZjBzY2ZDSGVGZjdDbUdxeXpVc3B4RHh2czhhZWxHYzhhdW5aTlozRXV6VElvZ2N0OVdIQ3BzVDFkTlg5Q09RM3R2ZWw3OEdwNFpsWVkzL21rcnFUOXVLSnR4czR0SUFqTVJGd01kdXJwcEVWdTVWVnRHcWdQb3puaDRzd21HQWtXOTFLOXBQZjhvc1E2cS9OUm8rai9XbGpjM0RuRUg1WQ'
                        ));
                        $response = curl_exec($curl);
                        curl_close($curl);
                        $responseArr = json_decode($response, 1);
                        echo json_encode(array('status' => true, 'queryType' => 'query', 'data' => $responseArr));
                    } catch (Exception $ex) {
                        echo $message = $ex->getMessage();
                        exit;
                    }
                } else if (isset($_POST['BookingType']) && $_POST['BookingType'] == 1 && isset($_POST['PkgType']) && $_POST['PkgType'] == 2) {
                    $PKGCheckInDate = isset($_POST['PKGCheckInDate']) ? $this->sanitize_data($_POST['PKGCheckInDate']) : '';
                    $FromDestinationId = isset($_POST['FromDestinationId']) ? $this->sanitize_data($_POST['FromDestinationId']) : '';
                    if (empty($FromDestinationId)) {
                        echo json_encode(array('status' => false, 'message' => 'Please Select Destination', 'data' => ''));
                        exit;
                    }
                    if (empty($PKGCheckInDate)) {
                        echo json_encode(array('status' => false, 'message' => 'Please Select Date', 'data' => ''));
                        exit;
                    } else {
                        $d = DateTime::createFromFormat('d/m/Y', $PKGCheckInDate);
                        $returnD =  $d && $d->format('d/m/Y') === $PKGCheckInDate;
                        if ($returnD == false) {
                            echo json_encode(array('status' => false, 'message' => 'Date Format Should be DD/MM/YYYY', 'data' => ''));
                            exit;
                        }
                    }
                    try {
                        $roominfojson = [];
                        $countRooms = $_POST['room'];
                        for ($i = 0, $k = 1; $k <= $countRooms; $k++, $i++) {
                            $roominfojson[$k]['Adult'] = (int) $_POST['adult'][$i];
                            $roominfojson[$k]['Child'] = (int) $_POST['child'][$i];
                            $roominfojson[$k]['Infant'] = (int) $_POST['infant'][$i];

                            if ($_POST['adult'][$i] == 3) {
                                $roominfojson[$k]['bedtype'] = $_POST['adult_bed_type'][$i];
                            }
                            if ($_POST['child'][$i] > 0) {
                                for ($c = 1; $c <= $_POST['child'][$i]; $c++) {
                                    $roominfojson[$k]['ChildBedType_' . $c] = $_POST['child' . $c . '_bed_type'][$i];
                                    $roominfojson[$k]['ChildAge_' . $c] = '';
                                }
                            }
                        }
                        $PKGCheckInDate = explode('/', @$_POST['PKGCheckInDate']);
                        $PKGCheckInDate1 = $PKGCheckInDate[2] . '-' . $PKGCheckInDate[1] . '-' . $PKGCheckInDate[0];
                        $Noofdays = (int) $_POST['Noofdays'];
                        $PKGCheckOutDate = date('d/m/Y', strtotime($PKGCheckInDate1 . ' + ' . $Noofdays . ' days'));
                        $apiData = [];
                        $DestinationId = explode(',', $_POST['DestinationId']);
                        $DestinationValue = explode(',', $_POST['DestinationValue']);
                        $destinationArray = array();
                        foreach ($DestinationId as $ddKey => $ddVal) {
                            $destinationArray[$ddVal] = $DestinationValue[$ddKey];
                        }
                        $Destination = isset($_POST['Destination']) ? $_POST['Destination'] : '';
                        $apiData['packid'] = (int) ($_POST['packageSysId']);
                        $apiData['leadID'] = (int) ($_POST['leadID']);
                        $apiData['TravelPlanId'] = (int) ($_POST['packageSysId']);
                        $apiData['minpax'] = 2;
                        $apiData['catID'] = (int) ($_POST['byopacktypeCat']);
                        $apiData['tourID'] = 1;
                        $apiData['FirstName'] = $this->sanitize_data($_POST['FirstName']);
                        $apiData['TotalNights'] = (int) $_POST['Noofdays'] - 1;
                        $apiData['DestinationPlaces'] = base64_encode(json_encode($destinationArray)); // 'eyI3NzAxIjoiRGVsaGkiLCIxMDU3NiI6IkdvYSJ9';
                        $apiData['search_going_to'] = $DestinationId[0] . '__' . $this->sanitize_data($DestinationValue[0]);   // '7701__Delhi';
                        $apiData['pkgCheckInDate'] = $this->sanitize_data($_POST['PKGCheckInDate']);
                        $apiData['pkgCheckOutDate'] = $this->sanitize_data($PKGCheckOutDate);
                        $apiData['tripstartdate'] = $this->sanitize_data($_POST['PKGCheckInDate']);
                        $apiData['custemail'] = $this->sanitize_data($_POST['Email']);
                        $apiData['custname'] = $this->sanitize_data($_POST['FirstName'] . ' ' . $_POST['LastName']);
                        $apiData['custphone'] = $this->sanitize_data($_POST['MobileNumber']);
                        $apiData['tripaddress'] = str_replace(',', ';', $this->sanitize_data($Destination));
                        $apiData['aboutpackage'] = '';
                        $apiData['pricetype'] = 'wp';
                        $apiData['AgencySysId'] = (int) $this->gtxagencysysid;
                        $apiData['AgentSysId'] = (int) $this->gtxagentsysid;
                        $apiData['Email'] = $this->sanitize_data($_POST['Email']);
                        $apiData['MobileNumber'] = $this->sanitize_data($_POST['MobileNumber']);
                        $apiData['leadsource'] = isset($_POST['leadsource']) ? $this->sanitize_data($_POST['leadsource']) : '';
                        $apiData['EmailTemplateType'] = 1;
                        $apiData['FromDestination'] = isset($_POST['Destination']) ? $this->sanitize_data($_POST['Destination']) : '';
                        $apiData['FromDestinationId'] = isset($_POST['FromDestinationId']) ? $this->sanitize_data($_POST['FromDestinationId']) : '';
                        $apiData['emailsubject'] = trim($_POST['FirstName']) . ' ' . trim($_POST['LastName']) . ' your proposal detail for ' . trim($_POST['DestinationValue']);
                        for ($k = 1; $k <= count($roominfojson); $k++) {
                            $roominfojson[$k]['departuredate'] = $_POST['PKGCheckInDate'];
                            $roominfojson[$k]['returndate'] = $_POST['PKGCheckInDate'];
                        }
                        $apiData['roomjson'] = json_encode($roominfojson);
                        $curl = curl_init($this->API_LANDING_PAGE_DYNAMIC_QUERY); // b2c site url
                        curl_setopt($curl, CURLOPT_POST, true);
                        curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($apiData));
                        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
                        curl_setopt($curl, CURLOPT_HTTPHEADER, array(
                            'SecurityKey:' . 'SnRjV2E0T3Y2dTgwT1pqOVVOODVIL09ubk1mRytyQ0FQOHN6eXNhWTFvZ0RsTVZONm1iQ1piOXhOVXJRdGV2VzBsbkZSanVSai9jNjRrQ0JaQ2pYTWQ0dnNQQTZiYnpwZjBzY2ZDSGVGZjdDbUdxeXpVc3B4RHh2czhhZWxHYzhhdW5aTlozRXV6VElvZ2N0OVdIQ3BzVDFkTlg5Q09RM3R2ZWw3OEdwNFpsWVkzL21rcnFUOXVLSnR4czR0SUFqTVJGd01kdXJwcEVWdTVWVnRHcWdQb3puaDRzd21HQWtXOTFLOXBQZjhvc1E2cS9OUm8rai9XbGpjM0RuRUg1WQ'
                        ));
                        $response = curl_exec($curl);
                        curl_close($curl);
                        $responseArr = json_decode($response, 1);
                        if ($responseArr['status'] == 'success') {
                            echo json_encode(array('status' => true, 'queryType' => 'query', 'data' => $responseArr));
                        } else {
                            echo json_encode(array('status' => false, 'queryType' => 'query', 'data' => $responseArr));
                        }
                    } catch (Exception $ex) {
                        echo $message = $ex->getMessage();
                        exit;
                    }
                } else {
                    try {
                        $_POST['Noofdays'] = trim($_POST['Noofdays']);
                        $curl = curl_init($this->API_LANDING_PAGE_LEAD_UPDATE); // b2c site url
                        curl_setopt($curl, CURLOPT_POST, true);
                        curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($_POST));
                        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
                        $response = curl_exec($curl);
                        // echo "<pre>";print_r($response);die('query');

                        curl_close($curl);
                        $responseArr = json_decode($response, 1);
                        if ($responseArr['status'] == 'success') {
                            echo json_encode(array('status' => true, 'message' => $response, 'queryType' => 'query', 'data' => $responseArr));
                        } else {
                            echo json_encode(array('status' => false, 'message' => $response, 'queryType' => 'query', 'data' => $responseArr));
                        }
                    } catch (Exception $ex) {
                        echo $message = $ex->getMessage();
                        exit;
                    }
                }
            }
        }
    }

    public function masterDataDestinationAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        $this->view->baseUrl = $this->baseUrl;
        $url = $this->API_LANDING_Master_DESTINATION;
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        $str = curl_exec($ch);
        $response = json_decode($str, true);
        echo $str;
        exit;
    }

    function sanitize_data($input_data)
    {
        $searchArr = array("document", "write", "alert", "%", "$", ";", "+", "|", "#", "<", ">", "\'");
        $input_data = str_replace("script", "", $input_data);
        $input_data = str_replace("iframe", "", $input_data);
        $input_data = str_replace($searchArr, "", $input_data);
        return htmlentities(stripslashes($input_data), ENT_QUOTES);
    }
    // jyt added new htoel api for review data
    public function reviewapiAction()
    {
        $this->_helper->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        /* =======================
        ✅ CORS HEADERS (ADD THIS)
        ======================= */
        header("Access-Control-Allow-Origin: *"); // or specific domain
        header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
        header("Access-Control-Allow-Headers: Content-Type, Securitykey, Authorization");
        header("Content-Type: application/json");

        /* =======================
        ✅ HANDLE PREFLIGHT (OPTIONS)
        ======================= */
        if ($this->getRequest()->getMethod() === 'OPTIONS') {
            http_response_code(200);
            exit;
        }
        
        try {

            /* 1️⃣ Allow only POST */
            if (!$this->getRequest()->isPost()) {
                echo json_encode([
                    'status' => false,
                    'message' => 'Invalid Request Method'
                ]);
                return;
            }

            /* 2️⃣ Validate Security Key */
            $headers = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getallheaders();
            $securityKey = $headers['Securitykey'] ?? '';

            if ($securityKey !== SECURITYKEY) {
                echo json_encode([
                    'status' => false,
                    'message' => 'Invalid Securitykey'
                ]);
                return;
            }

            /* 3️⃣ Read JSON body */
            $params = json_decode(file_get_contents("php://input"), true);
            
            if (empty($params)) {
                echo json_encode([
                    'status' => false,
                    'message' => 'Invalid JSON payload'
                ]);
                return;
            }

            /* 4️⃣ Generate TraceId */
            $TraceId = 'PKG' . round(microtime(true) * 1000);

            /* 5️⃣ Extract Required Params */
            $HotelId   = $params['hotelId'] ?? '';
            $RoomId    = $params['RoomId'] ?? '';
            $RoomsData = $params['hotelDetails']['Rooms'] ?? [];
            $ICSourceSysId = $params['ICSourceSysId'] ?? '';

            $AllData['checkIn']  = $params['checkin_date'] ?? '';
            $AllData['CheckOut'] = $params['checkout_date'] ?? '';

            /* Basic mapping */
            $AllData['Nationality'] = $params['nationality'];
            $AllData['cityid']      = (isset($params['cityId']) && $params['cityId'] !== '') ? (int) $params['cityId'] : 0;
            $AllData['TBBCityId']   = (isset($params['cityId']) && $params['cityId'] !== '') ? (int) $params['cityId'] : 0;

            /* Destination clean */
            $AllData['destination'] = trim(str_replace('(India)', '', $params['cityname']));
            $AllData['cityName'] = trim(str_replace('(India)', '', $params['cityname']));

            $AllData['hotel_countryCode'] = $params['hotel_countryCode'];
            $AllData['GuestNationality']  = $params['hotel_countryCode'];
            $AllData['interNationalSearch']  = ($params['hotel_countryCode'] == 'IN') ? 'false' : 'true';
            $AllData['CountryId']  = ($params['hotel_countryCode'] == 'IN') ? '101' : '';
            $AllData['room'] = $params['rooms'];

            /* Room-wise params */
            $adultArr = [];
            $childArr = [];
            $childAgeArr = [];

            $totalAdult = 0;
            $totalChild = 0;
            $totalInfant = 0; // agar infant ka params ho to yahan add kar sakte ho

            for ($i = 1; $i <= $params['rooms']; $i++) {

                $adults   = (int)($params["room{$i}_adults"] ?? 0);
                $children = (int)($params["room{$i}_children"] ?? 0);

                $adultArr[] = (string)$adults;
                $childArr[] = (string)$children;

                $totalAdult += $adults;
                $totalChild += $children;

                /* Child age handling */
                if ($children > 0) {
                    for ($c = 1; $c <= $children; $c++) {
                        if (isset($params["room{$i}_child{$c}_age"])) {
                            $childAgeArr[] = (string)$params["room{$i}_child{$c}_age"];
                             $AllData['child'.$c.'_age'][$i-1] = (string)$params["room{$i}_child{$c}_age"];
                        }
                    }
                }
            }
            $AllData['adult'] = $adultArr;
            $AllData['child'] = $childArr;
            /* Totals */
            $AllData['totadlt']  = (string)$totalAdult;
            $AllData['totchld']  = (string)$totalChild;
            $AllData['totinfnt'] = (string)$totalInfant;
            // echo "AllData ===== <pre>";print_r(json_encode($AllData));die;
            // create session search param
            Zend_Controller_Action_HelperBroker::getStaticHelper("Hotel")->CreateHotelSessionSearchNew($AllData, $TraceId);

            $sessionHotelSearchParams = new Zend_Session_Namespace('sessionHotelSearchParams');
            $SearchHotelData = new Zend_Session_Namespace('SearchHotelData');
            // echo "SearchHotelData ===== <pre>";print_r(json_encode($SearchHotelData->params));die;
            // $dataALl['getData'] = isset($sessionHotelSearchParams->params) ? json_encode($sessionHotelSearchParams->params) : '';
            $dataALl['HotelDetails'] = [
                    "SearchHotelTraceId" => $TraceId,
                    "HotelId" => $HotelId,
                    "HotelName" => isset($params['hotelDetails']['HotelName']) ? $params['hotelDetails']['HotelName'] : "",
                    "HotelDescription" => isset($params['hotelDetails']['HotelDescription']) ? $params['hotelDetails']['HotelDescription'] : "",
                    "HotelImages" => isset($params['hotelDetails']['HotelImages']) ? $params['hotelDetails']['HotelImages'] : [],
                    "HotelStars" => isset($params['hotelDetails']['HotelStars']) ? $params['hotelDetails']['HotelStars'] : "",

                    "HotelGeioLocation" => isset($params['hotelDetails']['HotelGeioLocation']) ? $params['hotelDetails']['HotelGeioLocation'] : "",

                    "HotelAddress" => isset($params['hotelDetails']['HotelAddress']) ? $params['hotelDetails']['HotelAddress'] : "",

                    "HotelCity" => isset($params['cityname']) ? $params['cityname'] : "",
                    "HotelCountry" => isset($params['hotelDetails']['HotelCountry']) ? $params['hotelDetails']['HotelCountry'] : "India",
                    "postalCode" => isset($params['hotelDetails']['postalCode']) ? $params['hotelDetails']['postalCode']:"",
                    "HotelPropertyType" => isset($params['hotelDetails']['HotelPropertyType']) ? $params['hotelDetails']['HotelPropertyType'] : "",
                    "Hotelphone" => isset($params['hotelDetails']['Hotelphone']) ? $params['hotelDetails']['Hotelphone'] : "",
                    "HotelFaciality" => isset($params['hotelDetails']['HotelFaciality']) ? $params['hotelDetails']['HotelFaciality'] : "",

                    "ICSourceSysId" => $ICSourceSysId,
                    "currencySysId" => isset($params['currencySysId']) ? $params['currencySysId'] : 1,
                    "Currency" => isset($params['Currency']) ? $params['Currency'] : "INR",

                    "HotelDetails" => [
                        "SearchHotelTraceId" => $TraceId,
                        "HotelId" => $HotelId,
                        "HotelName" => isset($params['hotelDetails']['HotelName']) ? $params['hotelDetails']['HotelName'] : "",
                        "HotelStars" => isset($params['hotelDetails']['HotelStars']) ? $params['hotelDetails']['HotelStars'] : "",
                        "HotelCity" => isset($params['cityname']) ? $params['cityname'] : "",
                        "HotelCountry" => isset($params['hotelDetails']['HotelCountry']) ? $params['hotelDetails']['HotelCountry'] : "",
                        "Currency" => isset($params['Currency']) ? $params['Currency'] : "INR"
                    ],
                    "StarRating" => isset($params['hotelDetails']['HotelStars']) ? $params['hotelDetails']['HotelStars'] : "",
            ];
            $dataALl[0] = [
                "Rooms" => $RoomsData,
                "RoomId" => $RoomId
            ];
            $tempData = array(
                'TraceId' => $TraceId,
                'json_data' => json_encode($dataALl),
            );
            // echo "tempData ===== <pre>";print_r(($tempData));die;
            // $cacheKey = 'bookroom_' . str_replace("-", "", $TraceId);
            // $this->cache->save($tempData, $cacheKey);
            // $objFlight = new Travel_Model_FlightMaster();
            // $insert = $objFlight->insertFlightTempData($tempData);
            Zend_Session::namespaceUnset('HotelBookingDetails');
            $HotelBookingDetail = new Zend_Session_Namespace('HotelBookingDetails');
            $HotelBookingDetail->params = $dataALl;
            
           
            /* ✅ SUCCESS RESPONSE */
            echo json_encode([
                'status' => true,
                'TraceId' => $TraceId,
                'redirectUrl' => $this->baseUrl . 'hotel/hotel-travellers/' . $TraceId
            ]);
            return;

        } catch (Exception $e) {
            echo json_encode([
                'status' => false,
                'message' => 'Server Error',
                'error' => $e->getMessage()
            ]);
            return;
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit