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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/holidays.tripjack.com/application/controllers/PackageController.php
<?php
/***************************************************************
* Catabatic Technology Pvt. Ltd.
* File Name     : IndexController.php
* File Desc.    : Index controller for home page front end
* Created By    : Ranvir Singh <ranvir@catpl.co.in>
* Created Date  : 27 May 2017
* Updated Date  : 29 May 2017
***************************************************************/


class PackageController extends Catabatic_CheckSession {

    public $imageServerUrl = NULL;

    public $baseUrl = '';

    public function init() {
 parent::init();
        $request = Zend_Controller_Front::getInstance()->getRequest();

        $this->baseUrl = $request->getScheme() . '://' . $request->getHttpHost();

         

        $registry = Zend_Registry::getInstance();

        $this->imageServerUrl = $registry->imageServerURL;

    }

    public function packageDetailAction() {

           

        /* If ajax request */

        if ($this->_request->isXmlHttpRequest()) {
            $this->view->intPackageId = $intPackageId = $this->getRequest()->getParam('intPackageId');

            if(empty($intPackageId)) {

                throw new Exception("Package Id not found.");

            }

            /* Disable layout */

           // $this->_helper->viewRenderer->setNoRender(true);

            $this->_helper->layout->disableLayout();

            $objPackage = new Travel_Model_TblPackageMaster();

            $objPackage->intId = $intPackageId;

            $arrPackageDetail = $objPackage->getPackageList();

            $response = array();

            if(count($arrPackageDetail)>0) {

                 //$arrPackageDetail[0]['package_name'] = Zend_Controller_Action_HelperBroker::getStaticHelper('truncate')->truncate($arrPackageDetail[0]['package_name'])->toLength(20);

                 echo json_encode($arrPackageDetail[0]);

                 exit;

            } else {

                 echo json_encode($response);

                 exit;

            }

            exit;

        }

    }

    
    public function enquiryAction() {

        $this->view->intPackageId = $intPackageId  = $this->getRequest()->getParam('intPackageId');

        $this->view->strType      = $strType       = $this->getRequest()->getParam('type');

        $this->view->fltPrice     = $fltPrice      = $this->getRequest()->getParam('price');

        $strPackageIds            = $this->getRequest()->getParam('strPackageIds');

        $this->view->enquiryFrom  = $enquiryFrom   = $this->getRequest()->getParam('enquiryFrom');

        $this->_helper->layout->disableLayout();

      

        if(!empty($intPackageId)) {

            /* Enquiry for Single Package */

            $objPackage = new Travel_Model_TblPackageMaster();

            $objPackage->intId = $intPackageId;

            $this->view->arrPackageDetail = $arrPackageDetail = $objPackage->getPackageList();

//            echo "<pre>";

//            print_r($arrPackageDetail);

//            exit;

            if(count($arrPackageDetail)>0){

                if(empty($fltPrice)) { 

                    $this->view->price          = $arrPackageDetail[0]['s_price'];

                }else {

                    $this->view->price          = $fltPrice;

                }

                if(!empty($strType)) {

                    if(strtoupper($strType) == 'S') {

                        $packageType = 'Standard';

                    }elseif(strtoupper($strType) == 'D') {

                        $packageType = 'Deluxe';

                    }elseif(strtoupper($strType) == 'L') {

                        $packageType = 'Luxury';

                    }

                    $this->view->packageType = $packageType;

                }

                $this->view->intAgentId     = $intAgentId = $arrPackageDetail[0]['agent_id'];

                $this->view->agentName      = $intAgentId = $arrPackageDetail[0]['agent_name'];

                $this->view->packageName    = $arrPackageDetail[0]['package_name'];

                $this->view->intPackageId   = $arrPackageDetail[0]['id'];

            }

        }else if(!empty($strPackageIds)){

            /* Enquiry for Multiple Packages */

           

            $this->view->strPackageIds = $strPackageIds = Zend_Controller_Action_HelperBroker::getStaticHelper('string')->cleanCommaSepString($strPackageIds);

        }

        if($this->getRequest()->isPost()){

             

            $result         = $this->getRequest()->getPost();

            $customerName   = $result['firstname'];

            $intPackageId   = $result['intPackageId'];

            $intAgentId     = $result['intAgentId'];

            $travelDate     = $result['traveldate'];

            $cutomerContactNo = $result['contactno'];

            $travellers     = $result['travellers'];

            $remarks        = $result['remarks'];

            $email          = $result['email'];

            $inquiryDate    = date('d-m-Y');

                 

            if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {

                $msg =  "Email address is not valid.";

                $response = array('success' => false, 'msg' => $msg);

                echo json_encode($response);

                exit;

            }

                /* Verify Captcha Code */

//                if($_SESSION['captcha_code']!=$result['captcha']) {

//                     $response = array('success' => false, 'msg' => 'The Security Code you entered was incorrect.');

//                     echo json_encode($response);

//                     exit;

//                }

                /*********************************/

            /* Create an array of Package Ids */

            if(!empty($intPackageId)) {

                $arrPackageId[] = $intPackageId;

            }else {

                $strPackageIds = $result['strPackageIds'];

                $arrPackageId  = explode(",", $strPackageIds);

            }

            $arrPackageId = array_filter($arrPackageId);

            $fltPrice       = isset($result['fltPrice']) ? $result['fltPrice'] : '';

            $strType        = isset($result['strType']) ? $result['strType'] : '';

            if(count($arrPackageId)>0) {

                foreach($arrPackageId as $intPackageId) {

                    $objPackage = new Travel_Model_TblPackageMaster();

                    $objPackage->intId = $intPackageId;

                    $arrPackageDetail = $objPackage->getPackageList();

                    $objAgent = new Travel_Model_TblAgentInfo();

                    $objAgent->intId = $arrPackageDetail[0]['agent_id'];

                    $arrAgentDetail = $objAgent->getAgentList();

                    $result['package_id']   =  $intPackageId;

                    $result['package_name'] =  $strPackageName = $arrPackageDetail[0]['package_name'];

                    $result['travellers'] =  $travellers;

           

                    /* If package type is not empty, it means the enquiry is from package detail page and of a 

                     * particular package type*/

                    if(!empty($strType)) {

                        $result['package_type'] = $strType;

                        $result['price']        = $fltPrice;

                    }else {

                        $fltPrice = $arrPackageDetail[0]['s_price'];

                        $result['price'] = $fltPrice;

                    }

           

                    $objEnquiry = new Travel_Model_TblEnquiry();

                    

                    if($objEnquiry->save($result)){ 

                        $agentName      = $arrAgentDetail[0]['firstname'];

                        $companyName    = $arrAgentDetail[0]['company_name'];

                        $contactNo      = $arrAgentDetail[0]['mobile_no'];

                        $agentEmailId   = $arrAgentDetail[0]['email'];

                        $packageName    = $arrPackageDetail[0]['package_name'];

                        

                        /* If package type is not empty, it means the enquiry is from package detail page and of a 

                           * particular package type*/

                        $packageType = '';

                        if(!empty($strType)) {

                            $price        = $fltPrice;

                            if(strtoupper($strType) == 'S') {

                                $packageType = "Standard";

                            }else if(strtoupper($strType) == 'D') {

                                $packageType = "Deluxe";

                            }else if(strtoupper($strType) == 'L') {

                                $packageType = "Luxury";

                            }

                        }else {

                            $price = $arrPackageDetail[0]['s_price'];

                        }

                        $price          = $this->_helper->Currency->formatCurrency($price);

                        $arrVars = array('agent_name' => $agentName, 'inquiry_date' => $inquiryDate, 'package_name' => $packageName,

                                   'travel_date' => $travelDate, 'remarks' => $remarks, 'price' => $price, 'packageType' => $packageType,

                                    'travellers' => $travellers, 'customer_name' => $customerName, 'customer_contactno' => $cutomerContactNo,

                                    'customer_email' => $email,'agent_login_url' => 'http://partners.showmetrips.com/agent/login', 

                                   'company_name' => $companyName, 'contact_no' => $contactNo, 'email' => $agentEmailId);

                        // $agentEmailId = "jobs_ravi_2331049@yahoo.com";

                        //$agentEmailId = "imabinash@gmail.com";

                        //$agentEmailId = "gaurav@catpl.co.in";

                        //$agentEmailId = "ravikhare@catpl.co.in";

                        $response1 = $this->_helper->EmailTemplate->SendEnquiryMailToAgent($agentEmailId, $arrVars);

                        //$response2 = $this->_helper->EmailTemplate->SendFeedbackMailToCustomer($email, $arrVars);

                        $arrCustVars = array('cust_name' => $customerName,'CompanyName' => $companyName, 'ContactNumber' => $contactNo,

                            'ContactEmail' => $agentEmailId, 'enquiry_dt' => date('d-M-Y'), 'packageName' => $strPackageName,

                            'travellers' => $travellers,

                            'travel_date' => $travelDate, 'price' => $price, 'packageType' => $packageType);

                        $response2 = $this->_helper->EmailTemplate->SendEnquiryMailToCustomer($email, $arrCustVars);

                    }

              }

              $response = array('success' => true, 'msg' => 'Your Enquiry has been send sucessfully.');

              echo json_encode($response);

              exit;

            } else {

                /* General Enquiry */

                    

                    

                    $objEnquiry = new Travel_Model_TblEnquiry();

                    

                    if($objEnquiry->saveGeneralEnquiry($result)){ 

                                    

                        $arrVars = array('inquiry_date' => $inquiryDate, 

                                   'travel_date' => $travelDate, 'remarks' => $remarks,

                                    'travellers' => $travellers,'customer_name' => $customerName,

                                    'customer_email' => $email,

                                   'agent_login_url' => 'http://partners.showmetrips.com/agent/login', 

                                   'customer_contactno' => $cutomerContactNo,  'remarks' => $remarks);

                        // $agentEmailId = "jobs_ravi_2331049@yahoo.com";

                        //$agentEmailId = "imabinash@gmail.com";

                        //$agentEmailId = "gaurav@catpl.co.in";

                        //$agentEmailId = "ravikhare@catpl.co.in";

                        $response1 = $this->_helper->EmailTemplate->SendGeneralEnquiryMailToAdmin('ravikhare@catpl.co.in', $arrVars);

                        //$response2 = $this->_helper->EmailTemplate->SendFeedbackMailToCustomer($email, $arrVars);

                        $arrCustVars = array('cust_name' => $customerName,'ContactNumber' => $cutomerContactNo,

                            'ContactEmail' => $email, 'enquiry_dt' => date('d-M-Y'), 

                            'travellers' => $travellers,

                            'travel_date' => $travelDate, 'remarks' => $remarks);

                        $response2 = $this->_helper->EmailTemplate->SendGeneralEnquiryMailToCustomer($email, $arrCustVars);

                    }

              

              $response = array('success' => true, 'msg' => 'Your Enquiry has been send sucessfully.');

              echo json_encode($response);

              exit;

            }

        }

    } 

    
    public function sendPackageOnEmailAction() {

        $this->_helper->layout->disableLayout();

        if($this->getRequest()->isPost()){

            $result         = $this->getRequest()->getPost();

            $email    = $result['email'];

            $strPKG   = $result['strPKG'];

            $strPKG   = Zend_Controller_Action_HelperBroker::getStaticHelper('string')->cleanCommaSepString($strPKG);

                    

            if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {

                $msg =  "Email address is not valid or empty.";

                $response = array('success' => false, 'msg' => $msg);

                echo json_encode($response);

                exit;

            }

            if(empty($strPKG) || $strPKG == ',') {

                $msg =  "No Package selected.";

                $response = array('success' => false, 'msg' => $msg);

                echo json_encode($response);

                exit;

            }

            $objPackage = new Travel_Model_TblPackageMaster();

            $objPackage->strCondition = " AND tbl_package_master.id in (" . $strPKG .")";

            $arrPackageDetail = $objPackage->getPackageList();

            $packageHtml = '';

            if(count($arrPackageDetail) > 0) {

                $packageHtml = '<table style="width:100%; border:1px solid gray;border-collapse: collapse;" >';

                $intSno = 1;

                foreach($arrPackageDetail as $package) {

                    $packageHtml .= '<tr>';

                    $packageHtml .= '<td style="width:5%;border:1px solid gray;border-collapse: collapse;">'. $intSno . '</td>';

                    $packageHtml .= '<td style="width:30%;border:1px solid gray;border-collapse: collapse;">'. $package['package_name'] . '</td>';

                    $packageHtml .= '<td style="width:25%;border:1px solid gray;border-collapse: collapse;">'. $package['company_name'] . '</td>';

                    $packageHtml .= '<td style="width:10%;border:1px solid gray;border-collapse: collapse;">'. $package['days_formatted'] . '</td>';

                    $packageHtml .= '<td style="width:20%;border:1px solid gray;border-collapse: collapse;">'. $package['inclusions_formatted'] . '</td>';

                    $packageHtml .= '<td style="width:10%;border:1px solid gray;border-collapse: collapse;">'. $package['price_formatted'] . '</td>';

                    $packageHtml .= '</tr>';

                    $intSno++;

                }

            }

            $arrVars = array('packageHtml' => $packageHtml);

            $response = $this->_helper->EmailTemplate->sendPackagesOnEmail($email, $arrVars);

          }

          $response = array('success' => true, 'msg' => 'The details of the selected packages has been send to your email successfully.');

          echo json_encode($response);

          exit;

    }


    
    public function detailAction() {

               

        $params = $this->getRequest()->getParams();

        if(isset($params['packagedetail'])) {

            $packageString = $params['packagedetail'];

            if(strstr($packageString,'-')) { 

                $this->view->intPackageId = $intPackageId = substr($packageString,0, strpos($packageString , '-'));

            }

        }

       else {

           $this->view->intPackageId = $intPackageId = $params['id'];

        }

        if(empty($intPackageId)) {

             throw new Exception("Package Id not found.");

        }

        //$this->view->strRating       = $strRating = $this->getRequest()->getParam('strRating');

         

        $this->view->imageServerUrl = $this->imageServerUrl;

        $objPackage = new Travel_Model_TblPackageMaster();

        $objPackage->intId = $intPackageId;

        $arrPackageDetail = $objPackage->getPackageList();

//        echo "<pre>";

//        print_r($arrPackageDetail);

//        exit;

        if(count($arrPackageDetail) != 1){ 

           $this->_redirect($this->view->baseUrl); 

        }

        $strPackageCategory = $arrPackageDetail[0]['category'];

        $this->view->packageDetail      = $arrPackageDetail[0];

        $this->view->p_type             = $arrPackageDetail[0]['p_type'];

        $this->view->arrPackageCategory = $arrPackageCategory = explode(",", $strPackageCategory);

        $this->view->packageType        = $arrPackageDetail[0]['p_type'];

        $objAgent        = new Travel_Model_TblAgentInfo();

        $objAgent->intId = $arrPackageDetail[0]['agent_id'];

        $arrAgentInfo = $objAgent->getAgentList();

        if(count($arrAgentInfo)>0) {

            $this->view->agentInfo = $arrAgentInfo[0];

        }

        if($arrPackageDetail[0]['term_condition_isdefault'] == 'Y'){

                $this->view->termscondition = $arrAgentInfo[0]['terms_condition'];

        }else {

            $this->view->termscondition = $arrPackageDetail[0]['term_condition'];

        }

        if($arrPackageDetail[0]['payment_policy_isdefault'] == 'Y'){

            $this->view->paymentPolicy = $arrAgentInfo[0]['payment_policies'];

        }else {

            $this->view->paymentPolicy = $arrPackageDetail[0]['payment_policy'];

        }

        if($arrPackageDetail[0]['cancellation_policy_isdefault'] == 'Y'){

            $this->view->cancellationPolicy = $arrAgentInfo[0]['cancellation_policies'];

        }else {

            if(isset($arrPackageDetail[0]['cancellation_policies'])){

                $this->view->cancellationPolicy = $arrPackageDetail[0]['cancellation_policies'];

            }

        }

         

        $this->view->exclusion      = $arrPackageDetail[0]['exclusion'];

        $this->view->inclusion_text = $arrPackageDetail[0]['inclusion_text'];

        $this->view->notes          = $arrPackageDetail[0]['notes'];    

        $arrPackCat = array();

        $isStandard = false;

        $isDeluxe   = false;

        $isLuxury   = false;

        if(count($arrPackageCategory) > 0 ){

            foreach($arrPackageCategory as $category) { 

                if($category == 'Standard') {

                    $arrPackCat['S'] = 'Standard';

                    $this->view->isStandard = $isStandard = true;

                }

                if($category == 'Deluxe') {

                    $arrPackCat['D'] = 'Deluxe';

                    $this->view->isDeluxe = $isDeluxe = true;

                }

                if($category == 'Luxury') {

                    $arrPackCat['L'] = 'Luxury';

                    $this->view->isLuxury = $isLuxury = true;

                }

            }

        }

        $this->view->arrHotelInfo         = $arrAllHotelsInPackage = $objPackage->getHotelsInPackage($intPackageId);

        $this->view->arrAllStandardHotels = $arrAllStandardHotels  = $objPackage->getHotelsInPackage($intPackageId, 'S');

        $this->view->arrAllDeluxeHotels   = $arrAllDeluxeHotels    = $objPackage->getHotelsInPackage($intPackageId, 'D');

        $this->view->arrAllLuxuryHotels   = $arrAllLuxuryHotels    = $objPackage->getHotelsInPackage($intPackageId, 'L');

        if($isStandard) {

            $strStandardHotelInfo = '';

            if(count($arrAllStandardHotels)>0) {

                foreach($arrAllStandardHotels as $hotel){

                    $strStandardHotelInfo .=  '<strong>'.$hotel['city_name'].'</strong>, ';

                    $strStandardHotelInfo .=  $hotel['hotel_name'];

                    if(!empty($hotel['rating'])){

                        $strStandardHotelInfo .= ' '.$hotel['rating'];

                        $strStandardHotelInfo .= '<img src="'.$this->baseUrl .'/public/travel/images/small_star.png">';

                    }

                    $strStandardHotelInfo .= "<br>";

                }

            }

            $this->view->strStandardHotelInfo = $strStandardHotelInfo;

        }

        if($isDeluxe) {

            $strDeluxeHotelInfo = '';

            if(count($arrAllDeluxeHotels)>0) {

                foreach($arrAllDeluxeHotels as $hotel){

                    $strDeluxeHotelInfo .=  '<strong>'.$hotel['city_name'].'</strong>, ';

                    $strDeluxeHotelInfo .=  $hotel['hotel_name'];

                    if(!empty($hotel['rating'])){

                        $strDeluxeHotelInfo .= ' '.$hotel['rating'];

                        $strDeluxeHotelInfo .= '<img src="'.$this->baseUrl .'/public/travel/images/small_star.png">';

                    }

                    $strDeluxeHotelInfo .= "<br>";

                }

            }

            $this->view->strDeluxeHotelInfo = $strDeluxeHotelInfo;

        }

        if($isLuxury) {

            $strLuxuryHotelInfo = '';

            if(count($arrAllLuxuryHotels)>0) {

                foreach($arrAllLuxuryHotels as $hotel){

                    $strLuxuryHotelInfo .=  '<strong>'.$hotel['city_name'].'</strong>, ';

                    $strLuxuryHotelInfo .=  $hotel['hotel_name'];

                    if(!empty($hotel['rating'])){

                        $strLuxuryHotelInfo .= ' ' .$hotel['rating'];

                        $strLuxuryHotelInfo .= '<img src="'.$this->baseUrl .'/public/travel/images/small_star.png">';

                    }

                    $strLuxuryHotelInfo .= "<br>";

                }

            }

            $this->view->strLuxuryHotelInfo = $strLuxuryHotelInfo;

        }

//          echo "<pre>";

//                    print_r($arrAllStandardHotels);

//                    exit;

                    

        if($arrPackageDetail[0]['p_type'] == 'OH' || $arrPackageDetail[0]['p_type'] == 'HF') {

            $arrHotelInfo = $objPackage->getOnlyHotelPackageInfo();

            if(count($arrHotelInfo)>0) {

                $objHotel = new Travel_Model_TblHotel();

                if($isStandard) {

                    $intHotelIdStandard = $arrHotelInfo[0]['hotel_id_standard'];

                    $objHotel->intId = $intHotelIdStandard;

                    $arrStandardHotelInfo = $objHotel->getHotelList();

                    if(count($arrStandardHotelInfo)>0) {

                        $this->view->strStandardHotelName   = $arrStandardHotelInfo[0]['hotel_name'];

                        $this->view->intStandardHotelRating = $arrStandardHotelInfo[0]['rating'];

                    }

                }

                if($isDeluxe) {

                    $intHotelIdDeluxe   = $arrHotelInfo[0]['hotel_id_deluxe'];

                    $objHotel->intId = $intHotelIdDeluxe;

                    $this->view->arrDeluxeHotelInfo = $arrDeluxeHotelInfo = $objHotel->getHotelList();

                    if(count($arrDeluxeHotelInfo)>0) {

                        $this->view->strDeluxeHotelName   = $arrDeluxeHotelInfo[0]['hotel_name'];

                        $this->view->intDeluxeHotelRating = $arrDeluxeHotelInfo[0]['rating'];

                    }

                }

                if($isLuxury) {

                    $intHotelIdLuxury   = $arrHotelInfo[0]['hotel_id_luxury'];

                    $objHotel->intId = $intHotelIdLuxury;

                    $this->view->arrLuxuryHotelInfo  = $arrLuxuryHotelInfo = $objHotel->getHotelList();

                    if(count($arrLuxuryHotelInfo)>0) {

                        $this->view->strLuxuryHotelName   = $arrLuxuryHotelInfo[0]['hotel_name'];

                        $this->view->intLuxuryHotelRating = $arrLuxuryHotelInfo[0]['rating'];

                    }

                }

                

                if(count($arrHotelInfo)>0) {

                    $strKeyInclusions = '';

                    foreach($arrHotelInfo as $info) {

                        if(!empty($info['services'])) {

                            $strKeyInclusions .= $info['services'] . ",";

                        }

                    }

                    $strKeyInclusions = trim($strKeyInclusions);

                    $this->view->arrKeyFacilities = explode(",", $strKeyInclusions);

                }

        }

        } else {

            /* Show the itenary of Standard Hotel Only*/

         

            /* Get category from Package */

            $category =  $arrPackageDetail[0]['category'];

            $arrCategory = explode(",", $category);

            if(in_array('Standard', $arrCategory)) {

                $strRating = 'S';

                $intHotelCategory = 1;

                $strRatingToDisplay = 'Standard' ;

            }else if(in_array('Deluxe', $arrCategory)) {

                $strRating = 'D';

                $intHotelCategory = 2;

                $strRatingToDisplay = 'Deluxe' ;

            }else if(in_array('Luxury', $arrCategory)) {

                $strRating = 'L';

                 $intHotelCategory = 3;

                 $strRatingToDisplay = 'Luxury' ;

            }

            $objInclusion = new Travel_Model_TblInclusion();

            $this->view->arrKeyInclusions = $objInclusion->getInclusionList($intPackageId);

            $objItenary = new Travel_Model_TblItineraryPackage();

            $objItenary->intPackageId = $intPackageId;

            $objItenary->intHotelCategory = $intHotelCategory;

            $this->view->itenaryDetail = $arrItenaryDetail = $objItenary->view4UI();

            $boolHavingItenary = false;

            if(count($arrItenaryDetail)>0){

                foreach($arrItenaryDetail as $itenary) {

                    $title = trim($itenary['title']);

                    if(!empty($title)) {

                        $boolHavingItenary = true;

                    }

                }

            }

            $this->view->boolHavingItenary = $boolHavingItenary;

          /* if(!empty($intDepartureCity)) {

            $objCity = new Travel_Model_TblCity();

            $objCity->intId = $intDepartureCity;

            $arrCityDetail = $objCity->getCityList();

            if(count($arrCityDetail)>0){

              $this->view->cityName = $arrCityDetail[0]['city_name'];

            }

           }

           */

           $bType = 'B2C';

           

           $this->view->intPackageId    = $intPackageId;

          // $this->view->intDepartureCity = $intDepartureCity;

           $this->view->rating           = $strRating;

           $this->view->busType          = $bType;

           $this->view->strRatingToDisplay = $strRatingToDisplay;

           $this->view->arrDestinationCoveredFormatted = $objPackage->getDestinationCoveredFormatted();

        }

         

      //  $this->view->intPackageId       = $intPackageId       = $this->getRequest()->getParam('intPackageId');

     //   $this->view->intSeasonId        = $intSeasonId        = $this->getRequest()->getParam('intSeasonId');

     //   $this->view->intDepartureCityId = $intDepartureCityId = $this->getRequest()->getParam('intDepartureCity');

        $arrRates = $objPackage->getRates($intPackageId, '');

     

        if(count($arrRates)>0) {

            $this->view->arrRates           = $arrRateBox = $arrRates[0];

            $this->view->showPasoLine = false;

            $this->view->showChildLine = false;

            if(!empty($arrRateBox['s_b2c_paso']) || !empty($arrRateBox['d_b2c_paso']) || !empty($arrRateBox['l_b2c_paso']) ) {

                $this->view->showPasoLine = true;

            }

            if(!empty($arrRateBox['s_b2c_child']) || !empty($arrRateBox['d_b2c_child']) || !empty($arrRateBox['l_b2c_child']) ) {

                $this->view->showChildLine = true;

            }

            if(!empty($arrRates[0]['city_id'])) {

                $this->view->intDepartureCityId = $arrRates[0]['city_id'];

            }

        } else {

            $this->view->arrRates = array();

        }

        $this->view->arrDepartureCities = $arrDepartureCities = $objPackage->getDepartureCities('array');

           

           // $this->view->strRating = $strRating;        

            if(!empty($strRatingToDisplay)) {

                $this->view->title     = "Itinerary for ". $strRatingToDisplay ." Package";

            }

            $this->view->destinationCities = $objPackage->getDepartureCities('array');
        $objPackage = new Travel_Model_TblPackageMaster();

        $objPackage->intId = $intPackageId;

        $objPackage->strSelectedView = 'list';

        $objPackage->intQueryOffset  = 0;

        $objPackage->intListPerPage  = SHOW_SIMILAR_PKG_COUNT;

        $arrSimilarPackages = $objPackage->getSimilarPackages();

        $this->view->arrSimilarPackages = $arrSimilarPackages ;

       // $arrImageDetail = $objPackage->getPackageImage('large');

        $this->view->intCityCoveredCount = $objPackage->getCityCoveredNHavingDestinationsCount($intPackageId);

     

        $objAgent = new Travel_Model_TblAgentInfo();

        $intAgentId = $arrPackageDetail[0]['agent_id'];

        $objAgent->addPackageVisit($intPackageId, $intAgentId);

       /* if(isset($_COOKIE['recentlyViewedPackages'])) {

            $arrRecentlyViewed = explode(",", $_COOKIE['recentlyViewedPackages']);

            if(!in_array($intPackageId, $arrRecentlyViewed)) {

                setcookie('recentlyViewedPackages',$_COOKIE['recentlyViewedPackages'] . ',' . $intPackageId ,time() + (86400), "/");

               

                $arrRecentlyViewed = explode(",", $_COOKIE['recentlyViewedPackages']);

//                echo MAX_RECENTLY_VIEWED_PKGS;

//                exit;

                //if(count($arrRecentlyViewed) > MAX_RECENTLY_VIEWED_PKGS){

                if(count($arrRecentlyViewed) > MAX_RECENTLY_VIEWED_PKGS){

                    /* Remove previous element 

                    array_shift($arrRecentlyViewed);

//                    echo "<pre>"; print_r($arrRecentlyViewed); 

//                    exit;

                    setcookie('recentlyViewedPackages', implode(",", $arrRecentlyViewed),time() + (86400), "/");

                }

            }

        }else {

            setcookie('recentlyViewedPackages',$intPackageId,time() + (86400), "/");

        }*/

        if(isset($_COOKIE['recentlyViewedPackages']) && $_COOKIE['recentlyViewedPackages']!="") {

            $arrRecentlyViewed = explode(",", $_COOKIE['recentlyViewedPackages']);

            if(!in_array($intPackageId, $arrRecentlyViewed)) { 

                $arrRecentlyViewed = explode(",", $_COOKIE['recentlyViewedPackages']);

                array_push($arrRecentlyViewed, $intPackageId);

                setcookie('recentlyViewedPackages', implode(",", $arrRecentlyViewed),time() + (86400), "/");

                if(count($arrRecentlyViewed) > MAX_RECENTLY_VIEWED_PKGS ){

                    setcookie('recentlyViewedPackages', implode(",", $arrRecentlyViewed),time() + (86400), "/");

                    $arrRecentlyViewed = explode(",", $_COOKIE['recentlyViewedPackages']);

                    array_shift($arrRecentlyViewed);

                    $arrRecentlyViewed = array_values($arrRecentlyViewed);

                     setcookie('recentlyViewedPackages', implode(",", $arrRecentlyViewed),time() + (86400), "/");

                }

            }

        }else { 

            setcookie('recentlyViewedPackages',$intPackageId,time() + (86400), "/");

        }

        $packageName       =   $arrPackageDetail[0]['display_name'];

        if(empty($packageName)) {

            $packageName = '';

        }

        //$packageDesc       =   strip_tags($arrPackageDetail[0]['description']);

        $price             =   $arrPackageDetail[0]['s_price'];

        $content = "Package starting from " . $this->_helper->Currency->formatCurrency($arrPackageDetail[0]['s_price']) . " per person. ";

  

       $this->view->doctype('XHTML1_RDFA');  // controller

       $this->view->headMeta()->setProperty('fb:app_id', FACEBOOK_APP_ID);

       $this->view->headMeta()->setProperty('og:type', 'website');

       $this->view->headMeta()->setProperty('og:description',$content); 

       $this->view->headMeta()->setProperty('og:title', $packageName);

      // $this->view->headMeta()->setProperty('og:image:type', 'image/jpg');

       $this->view->headMeta()->setProperty('og:url', $this->_helper->SEO->getPackageDetailPageUrl($arrPackageDetail[0]['id'],$arrPackageDetail[0]['package_name']));

      // $this->view->headMeta()->setProperty('og:url', 'http://www.travelone.co.in/package/1330/travel-package/Best-Shimla-Manali-Family-Holiday-Tour-Package');

       $this->view->headMeta()->setProperty('og:site_name', SITE_NAME);

        $this->view->fb_image_url = $fb_share_image = $objPackage->getFacebookSharingImage('single');

        $arr_fb_images = $objPackage->getFacebookSharingImage('array');

       $packageNameCustomized =  $arrPackageDetail[0]['display_name'];

       $packageNameCustomized = substr($packageNameCustomized, 0, strpos($packageNameCustomized,'- with'));

       $strCitiesCovered = $arrPackageDetail[0]['city_covered_text'];

       $arrCitiesCovered = explode(",", $strCitiesCovered);

       if(count($arrCitiesCovered) > 2) {

           $strCitiesCovered = $arrCitiesCovered[0] .','. $arrCitiesCovered[1];

       }

       $this->view->headMeta()->setName('description', 'Book '. $packageNameCustomized .' at showmetrips.com, one of the 100 '.$strCitiesCovered.' tour options we have for you.See more such travel packages here.');

       /* Get current page url */

       $this->view->canonical = $this->baseUrl  .Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();

       $keyword   = $arrPackageDetail[0]['city_covered_text'];

       $arrKeyword = explode(",", $keyword);

       if(count($arrKeyword)>1 && !empty($keyword)) {

           $keyword = $arrKeyword[0];

       }

       $pageTitle = $keyword .' package | ' .$keyword .' tour packages | '. $keyword.' travel packages';

       $this->view->headTitle($pageTitle);

       $this->view->headMeta()->setName('keywords', $keyword .' package, '.$keyword.' tour packages, '.$keyword.' travel packages, 

                    best '.$keyword.' package, cheap '.$keyword.' tour package');

        $this->view->arr_fb_images = $arr_fb_images;

        //$this->view->headMeta()->setProperty('og:image',$fb_share_image);

        $arrHotelIds = array();

      //  $this->view->dayNight = $this->_helper->General->showDayNight($arrPackageDetail[0]['days']);

        $objAgent        = new Travel_Model_TblAgentInfo();

        $objAgent->intId = $arrPackageDetail[0]['agent_id'];

        $arrAgentInfo = $objAgent->getAgentList();

        if(count($arrAgentInfo)>0) {

            $this->view->agentInfo = $arrAgentInfo[0];

        }
     

    }

     /* Desc: This method is same as detail except that it will also so the unpublised Package on front end */

     public function previewAction() {

         

        $this->view->intPackageId  = $intPackageId = $this->getRequest()->getParam('id');

        $this->view->imageServerUrl = $this->imageServerUrl;

               

        // $params = $this->getRequest()->getParams();

       // $packageString = $params['packagedetail'];

        //$keywords = $this->getRequest()->getParam('lookingfor');

      /*  if(strstr($packageString,'-')) { 

           $this->view->intPackageId = $intPackageId = substr($packageString,0, strpos($packageString , '-'));

        }

*/

        // $this->view->intPackageId = $intPackageId = $this->getRequest()->getParam('intPackageId');

        if(empty($intPackageId)) {

             throw new Exception("Package Id not found.");

        }

        $this->view->imageServerUrl = $this->imageServerUrl;

        $objPackage = new Travel_Model_TblPackageMaster();

        $objPackage->intId = $intPackageId;

        $objPackage->isPreview = true;

        $arrPackageDetail = $objPackage->getPackageList();

//      s

        if(count($arrPackageDetail) != 1){

           $this->_redirect($this->view->baseUrl); 

        }

        $strPackageCategory = $arrPackageDetail[0]['category'];

        $this->view->packageDetail      = $arrPackageDetail[0];

        $this->view->p_type             = $arrPackageDetail[0]['p_type'];

        $this->view->arrPackageCategory = $arrPackageCategory = explode(",", $strPackageCategory);

        $this->view->packageType        = $arrPackageDetail[0]['p_type'];

        $objAgent        = new Travel_Model_TblAgentInfo();

        $objAgent->intId = $arrPackageDetail[0]['agent_id'];

        $arrAgentInfo = $objAgent->getAgentList();

        if(count($arrAgentInfo)>0) {

            $this->view->agentInfo = $arrAgentInfo[0];

        }

        if($arrPackageDetail[0]['term_condition_isdefault'] == 'Y'){

                $this->view->termscondition = $arrAgentInfo[0]['terms_condition'];

        }else {

            $this->view->termscondition = $arrPackageDetail[0]['term_condition'];

        }

        if($arrPackageDetail[0]['payment_policy_isdefault'] == 'Y'){

            $this->view->paymentPolicy = $arrAgentInfo[0]['payment_policies'];

        }else {

            $this->view->paymentPolicy = $arrPackageDetail[0]['payment_policy'];

        }

        if($arrPackageDetail[0]['cancellation_policy_isdefault'] == 'Y'){

            $this->view->cancellationPolicy = $arrAgentInfo[0]['cancellation_policies'];

        }else {

            if(isset($arrPackageDetail[0]['cancellation_policies'])){

                $this->view->cancellationPolicy = $arrPackageDetail[0]['cancellation_policies'];

            }

        }

         

        $this->view->exclusion      = $arrPackageDetail[0]['exclusion'];

        $this->view->inclusion_text = $arrPackageDetail[0]['inclusion_text'];

        $this->view->notes          = $arrPackageDetail[0]['notes'];    

        $arrPackCat = array();

        $isStandard = false;

        $isDeluxe   = false;

        $isLuxury   = false;

        if(count($arrPackageCategory) > 0 ){

            foreach($arrPackageCategory as $category) { 

                if($category == 'Standard') {

                    $arrPackCat['S'] = 'Standard';

                    $this->view->isStandard = $isStandard = true;

                }

                if($category == 'Deluxe') {

                    $arrPackCat['D'] = 'Deluxe';

                    $this->view->isDeluxe = $isDeluxe = true;

                }

                if($category == 'Luxury') {

                    $arrPackCat['L'] = 'Luxury';

                    $this->view->isLuxury = $isLuxury = true;

                }

            }

        }

        $this->view->arrHotelInfo         = $arrAllHotelsInPackage = $objPackage->getHotelsInPackage($intPackageId);

        $this->view->arrAllStandardHotels = $arrAllStandardHotels = $objPackage->getHotelsInPackage($intPackageId, 'S');

        $this->view->arrAllDeluxeHotels   = $arrAllDeluxeHotels = $objPackage->getHotelsInPackage($intPackageId, 'D');

        $this->view->arrAllLuxuryHotels   = $arrAllLuxuryHotels = $objPackage->getHotelsInPackage($intPackageId, 'L');

        if($isStandard) {

            $strStandardHotelInfo = '';

            if(count($arrAllStandardHotels)>0) {

                foreach($arrAllStandardHotels as $hotel){

                    $strStandardHotelInfo .=  '<strong>'.$hotel['city_name'].'</strong>, ';

                    $strStandardHotelInfo .=  $hotel['hotel_name'];

                    if(!empty($hotel['rating'])){

                        $strStandardHotelInfo .= ' '.$hotel['rating'];

                        $strStandardHotelInfo .= '<img src="'.$this->baseUrl .'/public/travel/images/small_star.png">';

                    }

                    $strStandardHotelInfo .= "<br>";

                }

            }

            $this->view->strStandardHotelInfo = $strStandardHotelInfo;

        }

        if($isDeluxe) {

            $strDeluxeHotelInfo = '';

            if(count($arrAllDeluxeHotels)>0) {

                foreach($arrAllDeluxeHotels as $hotel){

                    $strDeluxeHotelInfo .=  '<strong>'.$hotel['city_name'].'</strong>, ';

                    $strDeluxeHotelInfo .=  $hotel['hotel_name'];

                    if(!empty($hotel['rating'])){

                        $strDeluxeHotelInfo .= ' '.$hotel['rating'];

                        $strDeluxeHotelInfo .= '<img src="'.$this->baseUrl .'/public/travel/images/small_star.png">';

                    }

                    $strDeluxeHotelInfo .= "<br>";

                }

            }

            $this->view->strDeluxeHotelInfo = $strDeluxeHotelInfo;

        }

        if($isLuxury) {

            $strLuxuryHotelInfo = '';

            if(count($arrAllLuxuryHotels)>0) {

                foreach($arrAllLuxuryHotels as $hotel){

                    $strLuxuryHotelInfo .=  '<strong>'.$hotel['city_name'].'</strong>, ';

                    $strLuxuryHotelInfo .=  $hotel['hotel_name'];

                    if(!empty($hotel['rating'])){

                        $strLuxuryHotelInfo .= ' ' .$hotel['rating'];

                        $strLuxuryHotelInfo .= '<img src="'.$this->baseUrl .'/public/travel/images/small_star.png">';

                    }

                    $strLuxuryHotelInfo .= "<br>";

                }

            }

            $this->view->strLuxuryHotelInfo = $strLuxuryHotelInfo;

        }

//          echo "<pre>";

//                    print_r($arrAllStandardHotels);

//                    exit;

                    

        if($arrPackageDetail[0]['p_type'] == 'OH' || $arrPackageDetail[0]['p_type'] == 'HF') {

            $arrHotelInfo = $objPackage->getOnlyHotelPackageInfo();

            if(count($arrHotelInfo)>0) {

                $objHotel = new Travel_Model_TblHotel();

                if($isStandard) {

                    $intHotelIdStandard = $arrHotelInfo[0]['hotel_id_standard'];

                    $objHotel->intId = $intHotelIdStandard;

                    $arrStandardHotelInfo = $objHotel->getHotelList();

                    if(count($arrStandardHotelInfo)>0) {

                        $this->view->strStandardHotelName   = $arrStandardHotelInfo[0]['hotel_name'];

                        $this->view->intStandardHotelRating = $arrStandardHotelInfo[0]['rating'];

                    }

                }

                if($isDeluxe) {

                    $intHotelIdDeluxe   = $arrHotelInfo[0]['hotel_id_deluxe'];

                    $objHotel->intId = $intHotelIdDeluxe;

                    $this->view->arrDeluxeHotelInfo = $arrDeluxeHotelInfo = $objHotel->getHotelList();

                    if(count($arrDeluxeHotelInfo)>0) {

                        $this->view->strDeluxeHotelName   = $arrDeluxeHotelInfo[0]['hotel_name'];

                        $this->view->intDeluxeHotelRating = $arrDeluxeHotelInfo[0]['rating'];

                    }

                }

                if($isLuxury) {

                    $intHotelIdLuxury   = $arrHotelInfo[0]['hotel_id_luxury'];

                    $objHotel->intId = $intHotelIdLuxury;

                    $this->view->arrLuxuryHotelInfo  = $arrLuxuryHotelInfo = $objHotel->getHotelList();

                    if(count($arrLuxuryHotelInfo)>0) {

                        $this->view->strLuxuryHotelName   = $arrLuxuryHotelInfo[0]['hotel_name'];

                        $this->view->intLuxuryHotelRating = $arrLuxuryHotelInfo[0]['rating'];

                    }

                }

                

                if(count($arrHotelInfo)>0) {

                    $strKeyInclusions = '';

                    foreach($arrHotelInfo as $info) {

                        if(!empty($info['services'])) {

                            $strKeyInclusions .= $info['services'] . ",";

                        }

                    }

                    $strKeyInclusions = trim($strKeyInclusions);

                    $this->view->arrKeyFacilities = explode(",", $strKeyInclusions);

                }

        }

        } else {

            /* Show the itenary of Standard Hotel Only*/

         

            /* Get category from Package */

            $category =  $arrPackageDetail[0]['category'];

            $arrCategory = explode(",", $category);

            if(in_array('Standard', $arrCategory)) {

                $strRating = 'S';

                $intHotelCategory = 1;

                $strRatingToDisplay = 'Standard' ;

            }else if(in_array('Deluxe', $arrCategory)) {

                $strRating = 'D';

                $intHotelCategory = 2;

                $strRatingToDisplay = 'Deluxe' ;

            }else if(in_array('Luxury', $arrCategory)) {

                $strRating = 'L';

                 $intHotelCategory = 3;

                 $strRatingToDisplay = 'Luxury' ;

            }

            $objInclusion = new Travel_Model_TblInclusion();

            $this->view->arrKeyInclusions = $objInclusion->getInclusionList($intPackageId);

            $objItenary = new Travel_Model_TblItineraryPackage();

            $objItenary->intPackageId = $intPackageId;

            $objItenary->intHotelCategory = $intHotelCategory;

            $this->view->itenaryDetail = $arrItenaryDetail = $objItenary->view4UI();

            $boolHavingItenary = false;

            if(count($arrItenaryDetail)>0){

                foreach($arrItenaryDetail as $itenary) {

                    $title = trim($itenary['title']);

                    if(!empty($title)) {

                        $boolHavingItenary = true;

                    }

                }

            }

            $this->view->boolHavingItenary = $boolHavingItenary;

          /* if(!empty($intDepartureCity)) {

            $objCity = new Travel_Model_TblCity();

            $objCity->intId = $intDepartureCity;

            $arrCityDetail = $objCity->getCityList();

            if(count($arrCityDetail)>0){

              $this->view->cityName = $arrCityDetail[0]['city_name'];

            }

           }

           */

           $bType = 'B2C';

           

           $this->view->intPackageId    = $intPackageId;

          // $this->view->intDepartureCity = $intDepartureCity;

           $this->view->rating           = $strRating;

           $this->view->busType          = $bType;

           $this->view->strRatingToDisplay = $strRatingToDisplay;

            $this->view->arrDestinationCoveredFormatted = $objPackage->getDestinationCoveredFormatted();

        }

         

      //  $this->view->intPackageId       = $intPackageId       = $this->getRequest()->getParam('intPackageId');

     //   $this->view->intSeasonId        = $intSeasonId        = $this->getRequest()->getParam('intSeasonId');

     //   $this->view->intDepartureCityId = $intDepartureCityId = $this->getRequest()->getParam('intDepartureCity');

        $arrRates = $objPackage->getRates($intPackageId, '');

     

        if(count($arrRates)>0) {

            $this->view->arrRates           = $arrRateBox = $arrRates[0];

            $this->view->showPasoLine = false;

            $this->view->showChildLine = false;

            if(!empty($arrRateBox['s_b2c_paso']) || !empty($arrRateBox['d_b2c_paso']) || !empty($arrRateBox['l_b2c_paso']) ) {

                $this->view->showPasoLine = true;

            }

            if(!empty($arrRateBox['s_b2c_child']) || !empty($arrRateBox['d_b2c_child']) || !empty($arrRateBox['l_b2c_child']) ) {

                $this->view->showChildLine = true;

            }

                            

//                echo "<pre>";

//                print_r($arrRateBox);

//                exit;

//            

            if(!empty($arrRates[0]['city_id'])) {

                $this->view->intDepartureCityId = $arrRates[0]['city_id'];

            }

        } else {

            $this->view->arrRates = array();

        }

        $this->view->arrDepartureCities = $arrDepartureCities = $objPackage->getDepartureCities('array');

          /*  if(!empty($intDepartureCityId)) {

                $objCity = new Travel_Model_TblCity();

                $objCity->intId = $intDepartureCityId;

                $arrCityDetail = $objCity->getCityList();

                if(count($arrCityDetail)>0){

                    $this->view->departureCityName = $arrCityDetail[0]['city_name'];

                }

            }

            */

           

         

           

         

           

          /*  

            if(empty($strRating)) {

                /* Get category from Package */

         /*       $category =  $arrPackageDetail[0]['category'];

                $arrCategory = explode(",", $category);

                if(in_array('Standard', $arrCategory)) {

                    $strRating = 'S';

                }else if(in_array('Deluxe', $arrCategory)) {

                    $strRating = 'D';

                }else if(in_array('Luxury', $arrCategory)) {

                    $strRating = 'L';

                }

            }

            if($strRating == 'S') {

                $strCategory = "Standard";

            }else if($strRating == 'D') {

                $strCategory = "Deluxe";

            } else if($strRating == 'L') {

                 $strCategory = "Luxury";

            }

            if(empty($strCategory)) {

                echo "There has been an errror. Please try again later.";

                exit;

            }

            */

           // $this->view->strRating = $strRating;        

            if(!empty($strRatingToDisplay)) {

                $this->view->title     = "Itinerary for ". $strRatingToDisplay ." Package";

            }

            /* Disable layout */

           // $this->_helper->viewRenderer->setNoRender(true);

          //  $this->_helper->layout->disableLayout();

           

            $this->view->destinationCities = $objPackage->getDepartureCities('array');

//            $intAgentId = $arrPackageDetail[0]['agent_id'];

//            $objSeason = new Travel_Model_TblSeason();

//            $objSeason->intAgentId = $intAgentId;

//            $arrSeasonDetail = $objSeason->getSeasonList();

//

//            $this->view->seasonDetail = $arrSeasonDetail;

//            

           /* 

            $strPackageCategory = $arrPackageDetail[0]['category'];

            $arrPackageCategory = explode(",", $strPackageCategory);

            $arrPackCat = array();

            if(count($arrPackageCategory) > 0 ){

                foreach($arrPackageCategory as $category) { 

                    if($category == 'Standard') {

                        $arrPackCat['S'] = 'Standard';

                    }

                    if($category == 'Deluxe') {

                        $arrPackCat['D'] = 'Deluxe';

                    }

                    if($category == 'Luxury') {

                        $arrPackCat['L'] = 'Luxury';

                    }

                }

            }

            $this->view->arrCategories = $arrPackCat;

           */
        $objPackage = new Travel_Model_TblPackageMaster();

        $objPackage->intId = $intPackageId;

        $objPackage->strSelectedView = 'list';

        $objPackage->intQueryOffset  = 0;

        $objPackage->intListPerPage  = SHOW_SIMILAR_PKG_COUNT;

        $arrSimilarPackages = $objPackage->getSimilarPackages();

        $this->view->arrSimilarPackages = $arrSimilarPackages ;

       // $arrImageDetail = $objPackage->getPackageImage('large');

        $this->view->intCityCoveredCount = $objPackage->getCityCoveredNHavingDestinationsCount($intPackageId);

     

        $objAgent = new Travel_Model_TblAgentInfo();

        $intAgentId = $arrPackageDetail[0]['agent_id'];

        $objAgent->addPackageVisit($intPackageId, $intAgentId);

        if(isset($_COOKIE['recentlyViewedPackages'])) {

            $arrRecentlyViewed = explode(",", $_COOKIE['recentlyViewedPackages']);

            if(!in_array($intPackageId, $arrRecentlyViewed)) {

                setcookie('recentlyViewedPackages',$_COOKIE['recentlyViewedPackages'] . ',' . $intPackageId ,time() + (86400), "/");

               

                $arrRecentlyViewed = explode(",", $_COOKIE['recentlyViewedPackages']);

//                echo MAX_RECENTLY_VIEWED_PKGS;

//                exit;

                //if(count($arrRecentlyViewed) > MAX_RECENTLY_VIEWED_PKGS){

                if(count($arrRecentlyViewed) > MAX_RECENTLY_VIEWED_PKGS){

                    /* Remove previous element */

                    array_shift($arrRecentlyViewed);

//                    echo "<pre>"; print_r($arrRecentlyViewed); 

//                    exit;

                    setcookie('recentlyViewedPackages', implode(",", $arrRecentlyViewed),time() + (86400), "/");

                }

            }

        }else {

            setcookie('recentlyViewedPackages',$intPackageId,time() + (86400), "/");

        }

   

        $packageName       =   $arrPackageDetail[0]['display_name'];

        if(empty($packageName)) {

            $packageName = '';

        }

        //$packageDesc       =   strip_tags($arrPackageDetail[0]['description']);

        $price             =   $arrPackageDetail[0]['s_price'];

        $content = "Package starting from " . $this->_helper->Currency->formatCurrency($arrPackageDetail[0]['s_price']) . " per person. ";

  

       $this->view->doctype('XHTML1_RDFA');  // controller

       $this->view->headMeta()->setProperty('fb:app_id', FACEBOOK_APP_ID);

       $this->view->headMeta()->setProperty('og:type', 'website');

       $this->view->headMeta()->setProperty('og:description',$content); 

       $this->view->headMeta()->setProperty('og:title', $packageName);

      // $this->view->headMeta()->setProperty('og:image:type', 'image/jpg');

       $this->view->headMeta()->setProperty('og:url', $this->_helper->SEO->getPackageDetailPageUrl($arrPackageDetail[0]['id'],$arrPackageDetail[0]['package_name']));

      // $this->view->headMeta()->setProperty('og:url', 'http://www.travelone.co.in/package/1330/travel-package/Best-Shimla-Manali-Family-Holiday-Tour-Package');

       $this->view->headMeta()->setProperty('og:site_name', SITE_NAME);

        $this->view->fb_image_url = $fb_share_image = $objPackage->getFacebookSharingImage('single');

        $arr_fb_images = $objPackage->getFacebookSharingImage('array');

       $packageNameCustomized =  $arrPackageDetail[0]['display_name'];

       $packageNameCustomized = substr($packageNameCustomized, 0, strpos($packageNameCustomized,'- with'));

       $strCitiesCovered = $arrPackageDetail[0]['city_covered_text'];

       $arrCitiesCovered = explode(",", $strCitiesCovered);

       if(count($arrCitiesCovered) > 2) {

           $strCitiesCovered = $arrCitiesCovered[0] .','. $arrCitiesCovered[1];

       }

       $this->view->headMeta()->setName('description', 'Book '. $packageNameCustomized .' at showmetrips.com, one of the 100 '.$strCitiesCovered.' tour options we have for you.See more such travel packages here.');

       /* Get current page url */

       $this->view->canonical = $this->baseUrl  .Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();

       $this->view->headTitle($arrPackageDetail[0]['display_name']);

//        echo '<pre>';

//        print_r($arr_fb_images);

//        exit;

        $this->view->arr_fb_images = $arr_fb_images;

        //$this->view->headMeta()->setProperty('og:image',$fb_share_image);

        $arrHotelIds = array();

      //  $this->view->dayNight = $this->_helper->General->showDayNight($arrPackageDetail[0]['days']);

        $objAgent        = new Travel_Model_TblAgentInfo();

        $objAgent->intId = $arrPackageDetail[0]['agent_id'];

        $arrAgentInfo = $objAgent->getAgentList();

        if(count($arrAgentInfo)>0) {

            $this->view->agentInfo = $arrAgentInfo[0];

        }

     

     

        $this->render('detail');

     }

     

    public function rowdetailAction() { 

        $this->view->intPackageId = $intPackageId = $this->getRequest()->getParam('intPackageId');

        $this->view->imageServerUrl = $this->imageServerUrl;

        if(empty($intPackageId)){

            $this->_redirect( $this->baseUrl );

        }

        /* This package id we are using to show pre next slider packagages on front end listig*/

        $packageNamespace = new Zend_Session_Namespace('Package');

        $packageNamespace->currentPackageId  = $intPackageId;

        $objPackage = new Travel_Model_TblPackageMaster();

        $objPackage->intId = $intPackageId;

        $arrPackageDetail = $objPackage->getPackageList();

        if(count($arrPackageDetail)!=1) {

            die("There has been an error in processing your request. Please try again later. ");

        }

  

        $agent_logo = $arrPackageDetail[0]['agetInfo'][0]['agent_logo'];

//        echo "<pre>";

//        print_r($arrPackageDetail[0]['agetInfo'][0]);

//        exit;

        $intAgentId = $arrPackageDetail[0]['agetInfo'][0]['id'];

        $objAgent = new Travel_Model_TblAgentInfo();

        $objAgent->addPackageVisit($intPackageId, $intAgentId);

        if(!empty($agent_logo)) {

            $agent_logo = $this->imageServerUrl . "agent/" . $intAgentId . "/logo/thumb/" . $agent_logo;

            $objAgent->intId = $intAgentId;

            $this->view->arrBranches = $objAgent->getLocations();

        }else {

            $agent_logo = '';

        }

        $this->view->agent_logo = $agent_logo;

        $arrDestinations = $objPackage->getDestinations();

        $arrCityCovered  = $objPackage->getCityCovered();

//        echo "<pre>";

//        print_r($arrCityCovered);

        if(count($arrCityCovered)>0) {

            $arrCityHavingDestinations   = array();

            $strCityNotHavingDestinations = '';

            $i = 0;

            foreach($arrCityCovered as $city) { 

                $objItenaryPackage = new Travel_Model_TblItineraryPackage();

                $objItenaryPackage->intPackageId = $intPackageId;

                $objItenaryPackage->intCity      = $city['city_covered'];

                $arrDestinations   = $objItenaryPackage->getPackageDestinations();

                $intDestinationCounter = count($arrDestinations);

                if(!empty($intDestinationCounter)) {

                   

                    $arrCityHavingDestinations[$i]['city_name'] = $city['city_name'];

                    $arrCityHavingDestinations[$i]['destination_counter'] = $intDestinationCounter;

                    $strDestinations = '';

                    foreach($arrDestinations as $destination){

                        $strDestinations .= $destination['destination_name'] . ',';

                    }

                    $strDestinations = Zend_Controller_Action_HelperBroker::getStaticHelper('string')->viewCommaSepString4UI($strDestinations);

                    $arrCityHavingDestinations[$i]['destinations'] = $strDestinations;

                    $i++;

                }else {

                    $strCityNotHavingDestinations .= $city['city_name'].',';

                }

            }

        }

        $strCityNotHavingDestinations = Zend_Controller_Action_HelperBroker::getStaticHelper('string')->viewCommaSepString4UI($strCityNotHavingDestinations);

        $this->view->arrCityHavingDestinations = $arrCityHavingDestinations;

        $this->view->strCityNotHavingDestinations = $strCityNotHavingDestinations;

//            echo "<pre>";

//            print_r($arrCityHavingDestinations);

//            

//            echo '<pre>';

//            print_r($arrCityNotHavingDestinations);

//            exit;

//               

//       echo "<pre>";

//       print_r($arrDestinations);

//       exit;

//       

//        $arrGallery = array();

//        

//        $imageFound = false;

//        if(count($arrDestinations)>0) {

//            

//            foreach($arrDestinations as $attraction) {

//                 $objDestination = new Travel_Model_TblDestination();

//                 $objDestination->intId = $attraction['id'];

//                 $arrResult= $objDestination->getGallery();

//                 if(count($arrResult)>0) {

//                     foreach($arrResult as $gallery) {

//                         $image_path = $this->imageServerUrl . 'destinations/'.$gallery['destination_id'] . '/large/' . $gallery['image_name'];

//                       //  if(file_exists($image_path)) {

//                            $arrGallery[] = $gallery;

//                            $imageFound = true;

//                        // }

//                     }

//                 }

//            }

//        }

        $this->view->arrGallery = $objPackage->getPackageGallery('thumb');

         

//       echo '<pre>';

//       print_r($arrPackageDetail);

//       exit;

//        

        $objItenary = new Travel_Model_TblItineraryPackage();

        $objItenary->intPackageId = $intPackageId;

       // $objItenary->strCondition = " tbl_hotel.category = '1'";

        $arrItenaryDetail = $objItenary->view();

        $this->view->itenaryDetail = $arrItenaryDetail;

        $this->view->packageDetail = $arrPackageDetail[0];

        $this->view->dayNight = $this->_helper->General->showDayNight($arrPackageDetail[0]['days']);

       // $arrPackageGallery = $objPackage->getPackageGallery();

        //$this->view->arrPackageGallery = $arrPackageGallery;

        $this->_helper->layout->disableLayout();

    }

    

     public function showslideAction() {

        $this->_helper->viewRenderer('rowdetail');  

        $this->_helper->layout->disableLayout();

         

        $intPackageId = $this->getRequest()->getParam('intPackageId');

        $objPackage = new Travel_Model_TblPackageMaster();

        $strCondition = '';

        if(isset($_COOKIE['cookie_searched_pack_ids'])) { 

            $strPackageIds = $_COOKIE['cookie_searched_pack_ids'];

            $strPackageIds = Zend_Controller_Action_HelperBroker::getStaticHelper('string')->cleanCommaSepString($strPackageIds);

            $strCondition .= " AND tbl_package_master.id in (" . $_COOKIE['cookie_searched_pack_ids'] . ")";

            $objPackage->strCondition = $strCondition;

            // $objPackages->strPackageIdIn = $strPackageIds;

             $arrPackageDetail = $objPackage->getPackageList();

             if(count($arrPackageDetail)>0) {

                 foreach($arrPackageDetail as $package) {

                     $searchedPackages[] = $package['id'];

                 }

             }

            // $searchedPackages = $searchNamespace->searchPackages;

             if(is_array($searchedPackages)) {

                 $searchedPackages = array_values($searchedPackages);

                 $current_index = array_search($intPackageId, $searchedPackages);

             }

             $scrollTo = $this->getRequest()->getParam('scrollTo'); 

             //echo count($searchedPackages);

            if($scrollTo == 'next'){

                if($current_index > count($searchedPackages)-2) {

                    $current_index = 0; 

                }else {

                   $current_index++; 

                }

            }else {

                if($current_index-1 < 0) $current_index = count($searchedPackages)-1; else $current_index--;

            }

            $intPackageId = $searchedPackages[$current_index];

            if(empty($intPackageId)){

               // $this->_redirect( $this->baseUrl );

                return false;

            }

                 

            $objPackage = new Travel_Model_TblPackageMaster();

            $objPackage->intId = $intPackageId;

            $arrPackageDetail = $objPackage->getPackageList();

            $agent_logo = $arrPackageDetail[0]['agetInfo'][0]['agent_logo'];

    //        echo "<pre>";

    //        print_r($arrPackageDetail[0]['agetInfo'][0]);

    //        exit;

            if(!empty($agent_logo)) {

                $intAgentId = $arrPackageDetail[0]['agetInfo'][0]['id'];

                $agent_logo = $this->imageServerUrl . "agent/" . $intAgentId . "/logo/thumb/" . $agent_logo;

            }else {

                $agent_logo = '';

            }

            $this->view->agent_logo = $agent_logo;

            $objItenary = new Travel_Model_TblItineraryPackage();

            $objItenary->intPackageId = $intPackageId;

            $arrItenaryDetail = $objItenary->view();

            $this->view->itenaryDetail = $arrItenaryDetail;

            $this->view->imageServerUrl = $this->imageServerUrl;

            $arrDestinations = $objPackage->getDestinations();

              $arrCityCovered  = $objPackage->getCityCovered();

//        echo "<pre>";

//        print_r($arrCityCovered);

        if(count($arrCityCovered)>0) {

            $arrCityHavingDestinations   = array();

            $strCityNotHavingDestinations = '';

            $i = 0;

            foreach($arrCityCovered as $city) { 

                $objItenaryPackage = new Travel_Model_TblItineraryPackage();

                $objItenaryPackage->intPackageId = $intPackageId;

                $objItenaryPackage->intCity      = $city['city_covered'];

                $arrDestinations   = $objItenaryPackage->getPackageDestinations();

                $intDestinationCounter = count($arrDestinations);

                if(!empty($intDestinationCounter)) {

                   

                    $arrCityHavingDestinations[$i]['city_name'] = $city['city_name'];

                    $arrCityHavingDestinations[$i]['destination_counter'] = $intDestinationCounter;

                    $strDestinations = '';

                    foreach($arrDestinations as $destination){

                        $strDestinations .= $destination['destination_name'] . ',';

                    }

                    $strDestinations = Zend_Controller_Action_HelperBroker::getStaticHelper('string')->viewCommaSepString4UI($strDestinations);

                    $arrCityHavingDestinations[$i]['destinations'] = $strDestinations;

                    $i++;

                }else {

                    $strCityNotHavingDestinations .= $city['city_name'].',';

                }

            }

        }

        $strCityNotHavingDestinations = Zend_Controller_Action_HelperBroker::getStaticHelper('string')->viewCommaSepString4UI($strCityNotHavingDestinations);

        $this->view->arrCityHavingDestinations = $arrCityHavingDestinations;

        $this->view->strCityNotHavingDestinations = $strCityNotHavingDestinations;

        $this->view->arrGallery = $objPackage->getPackageGallery('thumb');

        $this->view->packageDetail = $arrPackageDetail[0];

        $this->view->dayNight = $this->_helper->General->showDayNight($arrPackageDetail[0]['days']);

        }

    }

     public function compareboxAction() {

         

        $this->view->intPackageId =  $intPackageId = $this->getRequest()->getParam('intPackageId');

        if(empty($intPackageId)){

             throw new Exception("Package Id not found.");

        }

        $objPackage = new Travel_Model_TblPackageMaster();

        $objPackage->intId = $intPackageId;

        $arrPackageDetail = $objPackage->getPackageList();

         

        $this->view->packageBox = $arrPackageDetail;

        $this->_helper->layout->disableLayout();

    }

    public function comparepackageAction() {

        $searchNamespace = new Zend_Session_Namespace('search');

        $this->view->searchFor    = $searchNamespace->searchFor;

        //$strPackageIds = $this->getRequest()->getParam('ids');

        if(isset($_COOKIE['strComparePackagesIds'])) {

            $strPackageIds = $_COOKIE['strComparePackagesIds'];

        }else {

            $this->_redirect('/search');

        }

        $strPackageIds = $this->_helper->String->cleanCommaSepString($strPackageIds);

        $arrPackageIds = explode(",",$strPackageIds);

        if(count($arrPackageIds)>4 || count($arrPackageIds)<2) {

            $this->_redirect('/search');

        }

        $this->view->detailUrl = $this->view->baseUrl(). '/package/detail';

        if(!empty($strPackageIds)) {

            $objPackage = new Travel_Model_TblPackageMaster();

            $objPackage->strPackageIdIn = $strPackageIds ;

            $this->view->arrPackageList = $objPackage->getPackages2Compare();

        }

    }

    public function ratetableAction() { 

        $this->_helper->layout->disableLayout();

        /* If ajax request */

        if ($this->_request->isXmlHttpRequest()) { 

            $this->view->intPackageId       = $intPackageId       = $this->getRequest()->getParam('intPackageId');

            $this->view->intSeasonId        = $intSeasonId        = $this->getRequest()->getParam('intSeasonId');

            $this->view->intDepartureCityId = $intDepartureCityId = $this->getRequest()->getParam('intDepartureCity');

            $objPackage       = new Travel_Model_TblPackageMaster();

            $objPackage->intId = $intPackageId;

            $objPackage->isPreview = true;

            $this->view->packageDetail  = $arrPackageDetail = $objPackage->getPackageList();

            if(count($arrPackageDetail)!=1) {

                throw new Exception("Package detail not found.");

            }

            $arrRates = $objPackage->getRates($intPackageId, $intDepartureCityId);

            if(count($arrRates)>0) {

                $this->view->arrRates           = $arrRates[0];

                if(!empty($arrRates[0]['city_id'])) {

                    $this->view->intDepartureCityId = $arrRates[0]['city_id'];

                }

            } else {

                $this->view->arrRates = array();

            }

//            $arrDistinctDates = $objPackage->getDistinctRateDates($intPackageId);

//            

//            $arrDates = array();

//            if(count($arrDistinctDates)>0) {

//                foreach($arrDistinctDates as $date) {

//                    $format     = Zend_Controller_Action_HelperBroker::getStaticHelper('dateFormat')->db2UI($date['from_dt']) . ' / ' . Zend_Controller_Action_HelperBroker::getStaticHelper('dateFormat')->db2UI($date['to_dt']);

//                    $arrDates[] = $format;

//                }

//            }

//            

//            echo "<pre>";

//            print_r($arrDates);

//            exit;

//            

            //$this->view->arrDistinctDates = $arrDates;

//            echo "<pre>";

//            print_r($arrRates);

//            exit;

           /*

            $objSeason = new Travel_Model_TblSeason();

            $objSeason->intAgentId   = $arrPackageDetail[0]['agent_id'];

            $objSeason->intPackageId = $intPackageId;

            $this->view->arrSeasons = $arrSeasons = $objSeason->getSeasonList();

//            echo "<pre>";

//            print_r($arrSeasons);

//            exit;

//            

           

             $objSeason = new Travel_Model_TblSeason();

             $objSeason->intAgentId   = $arrPackageDetail[0]['agent_id'];

             $objSeason->intPackageId = $intPackageId;

             if(!empty($intSeasonId)) {

                $objSeason->intId        = $intSeasonId;

             }else {

                $objSeason->intId        = '';

             }

             

             $arrSeasonDetail         = $objSeason->getSeasonList();

//                echo '<pre>';

//                print_r($arrSeasonDetail);

//                exit;

            if(count($arrSeasonDetail)>0){

                $this->view->season_title = $arrSeasonDetail[0]['title'];

                $this->view->season_from  = $arrSeasonDetail[0]['from_dt'];

                $this->view->season_to    = $arrSeasonDetail[0]['to_dt'];

            }

            */

           

            $this->view->arrDepartureCities = $arrDepartureCities = $objPackage->getDepartureCities('array');

            $strPackageCategory = $arrPackageDetail[0]['category'];

            $this->view->arrPackageCategory = $arrPackageCategory = explode(",", $strPackageCategory);

            $arrPackCat = array();

            $isStandard = false;

            $isDeluxe   = false;

            $isLuxury   = false;

            if(count($arrPackageCategory) > 0 ){

                foreach($arrPackageCategory as $category) { 

                    if($category == 'Standard') {

                        $arrPackCat['S'] = 'Standard';

                        $this->view->isStandard = $isStandard = true;

                    }

                    if($category == 'Deluxe') {

                        $arrPackCat['D'] = 'Deluxe';

                        $this->view->isDeluxe = $isDeluxe = true;

                    }

                    if($category == 'Luxury') {

                        $arrPackCat['L'] = 'Luxury';

                        $this->view->isLuxury = $isLuxury = true;

                    }

                }

            }

            $this->view->p_type = $arrPackageDetail[0]['p_type'] ;

         

            if($arrPackageDetail[0]['p_type'] == 'OH') {

                   $arrHotelInfo = $objPackage->getOnlyHotelPackageInfo();

                   if(count($arrHotelInfo)>0) {

                       $objHotel = new Travel_Model_TblHotel();

                       if($isStandard) {

                           $intHotelIdStandard = $arrHotelInfo[0]['hotel_id_standard'];

                           $objHotel->intId = $intHotelIdStandard;

                           $arrStandardHotelInfo = $objHotel->getHotelList();

                           if(count($arrStandardHotelInfo)>0) {

                               $this->view->strStandardHotelName   = $arrStandardHotelInfo[0]['hotel_name'];

                               $this->view->intStandardHotelRating = $arrStandardHotelInfo[0]['rating'];

                           }

                       }

                       if($isDeluxe) {

                           $intHotelIdDeluxe   = $arrHotelInfo[0]['hotel_id_deluxe'];

                           $objHotel->intId = $intHotelIdDeluxe;

                           $this->view->arrDeluxeHotelInfo = $arrDeluxeHotelInfo = $objHotel->getHotelList();

                           if(count($arrDeluxeHotelInfo)>0) {

                               $this->view->strDeluxeHotelName   = $arrDeluxeHotelInfo[0]['hotel_name'];

                               $this->view->intDeluxeHotelRating = $arrDeluxeHotelInfo[0]['rating'];

                           }

                       }

                       if($isLuxury) {

                           $intHotelIdLuxury   = $arrHotelInfo[0]['hotel_id_luxury'];

                           $objHotel->intId = $intHotelIdLuxury;

                           $this->view->arrLuxuryHotelInfo  = $arrLuxuryHotelInfo = $objHotel->getHotelList();

                           if(count($arrLuxuryHotelInfo)>0) {

                               $this->view->strLuxuryHotelName   = $arrLuxuryHotelInfo[0]['hotel_name'];

                               $this->view->intLuxuryHotelRating = $arrLuxuryHotelInfo[0]['rating'];

                           }

                       }

                   }

        }

//            if(empty($intDepartureCityId)) {

//                if(count($arrDepartureCities)>0){

//                    $this->view->intDepartureCityId = $intDepartureCityId = $arrDepartureCities[0]['city_id'];

//                }

//            }

//           if(!empty($intDepartureCityId)) {

//                if(count($arrDepartureCities)>0){

//                    $this->view->intDepartureCityId = $intDepartureCityId = $arrDepartureCities[0]['city_id'];

//                }

//            }

            if(!empty($intDepartureCityId)) {

                $objCity = new Travel_Model_TblCity();

                $objCity->intId = $intDepartureCityId;

                $arrCityDetail = $objCity->getCityList();

                if(count($arrCityDetail)>0){

                    $this->view->departureCityName = $arrCityDetail[0]['city_name'];

                }

            }

//            if(empty($intSeasonId)) { 

//                if(count($arrSeasons)>0) {

//                    $this->view->intSeasonId = $intSeasonId = $arrSeasons[0]['id'];

//                }

//            }

//        

           

//        $this->view->arrStadardDetail = $arrStadardRateDetail = $objSeason->getRate($intPackageId, $intSeasonId, $intDepartureCityId, 'S', 'B2C');

//        $this->view->arrDeluxeDetail  = $arrDeluxeRateDetail  = $objSeason->getRate($intPackageId, $intSeasonId, $intDepartureCityId, 'D', 'B2C');

//        $this->view->arrLuxuryDetail  = $arrLuxuryRateDetail  = $objSeason->getRate($intPackageId, $intSeasonId, $intDepartureCityId, 'L', 'B2C');

      

      /*  if(count($arrStadardRateDetail)>0) {

            $this->view->pats_standard  = $pats_standard   = $arrStadardRateDetail[0]['pats'];

            $this->view->child_standard = $child_standard  = $arrStadardRateDetail[0]['child'];

            $this->view->paso_standard  = $paso_standard   = $arrStadardRateDetail[0]['paso'];

        }

        if(count($arrDeluxeRateDetail)>0) {

            $this->view->pats_deluxe    = $pats_deluxe     = $arrDeluxeRateDetail[0]['pats'];

            $this->view->child_deluxe   = $child_deluxe    = $arrDeluxeRateDetail[0]['child'];

            $this->view->paso_deluxe    = $paso_deluxe     = $arrDeluxeRateDetail[0]['paso'];

        }

        if(count($arrLuxuryRateDetail)>0) {

            $this->view->pats_luxury    = $pats_luxury      = $arrLuxuryRateDetail[0]['pats'];

            $this->view->child_luxury   = $child_luxury     = $arrLuxuryRateDetail[0]['child'];

            $this->view->paso_luxury    = $paso_luxury      = $arrLuxuryRateDetail[0]['paso'];

        }

        */

         

        }

                   

     

      

    }

    

    public function itineraryAction() { 

        $registry = Zend_Registry::getInstance();

        $this->view->imageServerUrl = $registry->imageServerURL;

        $this->view->noImageUrl = $this->_helper->Image->getNoImageUrl('general','thumb');

         

        /* If ajax request */

        if ($this->_request->isXmlHttpRequest()) {

            $intPackageId                = $this->getRequest()->getParam('intPackageId');

            $this->view->strRating       = $strRating = $this->getRequest()->getParam('strRating');

            $intDepartureCity            = $this->getRequest()->getParam('intDepartureCity');

           

            $this->view->noImageUrl     = $this->_helper->Image->getNoImageUrl('general','thumb');

            $this->view->imageServerUrl = $this->imageServerUrl;

            if(empty($intPackageId)){

               throw new Exception("Package Id not found.");

            }

            $objPackage = new Travel_Model_TblPackageMaster();

            $objPackage->intId = $intPackageId;

            /* Set this variable to fetch the Package if it is published / unpublised */

            $objPackage->isPreview = true;

            $arrPackageDetail = $objPackage->getPackageList();

            if(count($arrPackageDetail)!=1) {

                $this->_redirect($this->baseUrl());

            }

               

            $this->view->arrPackageDetail = $arrPackageDetail[0];

            if(empty($strRating)) {

                /* Get category from Package */

                $category =  $arrPackageDetail[0]['category'];

                $arrCategory = explode(",", $category);

                if(in_array('Standard', $arrCategory)) {

                    $strRating = 'S';

                }else if(in_array('Deluxe', $arrCategory)) {

                    $strRating = 'D';

                }else if(in_array('Luxury', $arrCategory)) {

                    $strRating = 'L';

                }

            }

            if($strRating == 'S') {

                $strCategory = "Standard";

            }else if($strRating == 'D') {

                $strCategory = "Deluxe";

            } else if($strRating == 'L') {

                 $strCategory = "Luxury";

            }

            if(empty($strCategory)) {

                echo "There has been an errror. Please try again later.";

                exit;

            }

            $this->view->strRating = $strRating;            

            $this->view->title     = "Itinerary for ". $strCategory ." Package";

            /* Disable layout */

           // $this->_helper->viewRenderer->setNoRender(true);

            $this->_helper->layout->disableLayout();

            $this->view->packageDetail = $arrPackageDetail[0];

            $this->view->destinationCities = $objPackage->getDepartureCities('array');

            $intAgentId = $arrPackageDetail[0]['agent_id'];

            $objSeason = new Travel_Model_TblSeason();

            $objSeason->intAgentId = $intAgentId;

            $arrSeasonDetail = $objSeason->getSeasonList();

            $this->view->seasonDetail = $arrSeasonDetail;

            $strPackageCategory = $arrPackageDetail[0]['category'];

            $arrPackageCategory = explode(",", $strPackageCategory);

            $arrPackCat = array();

            if(count($arrPackageCategory) > 0 ){

                foreach($arrPackageCategory as $category) { 

                    if($category == 'Standard') {

                        $arrPackCat['S'] = 'Standard';

                    }

                    if($category == 'Deluxe') {

                        $arrPackCat['D'] = 'Deluxe';

                    }

                    if($category == 'Luxury') {

                        $arrPackCat['L'] = 'Luxury';

                    }

                }

            }

            $this->view->arrCategories = $arrPackCat;

           

            /* Show the itenary of Standard Hotel Only*/

            $intHotelCategory = '';

            if($strRating == 'S'){

                 $intHotelCategory = 1;

            }elseif($strRating == 'D') {

                 $intHotelCategory = 2;

            }elseif($strRating == 'L') {

                 $intHotelCategory = 3;

            }

           $objItenary = new Travel_Model_TblItineraryPackage();

           $objItenary->intPackageId = $intPackageId;

           $objItenary->intHotelCategory = $intHotelCategory;

           $this->view->itenaryDetail = $arrItenaryDetail = $objItenary->view4UI();

           $boolHavingItenary = false;

           if(count($arrItenaryDetail)>0){

               foreach($arrItenaryDetail as $itenary) {

                   $title = trim($itenary['title']);

                   if(!empty($title)) {

                       $boolHavingItenary = true;

                   }

               }

           }

           $this->view->boolHavingItenary = $boolHavingItenary;

           $objCity = new Travel_Model_TblCity();

           $objCity->intId = $intDepartureCity;

           $arrCityDetail = $objCity->getCityList();

           if(count($arrCityDetail)>0){

             $this->view->cityName = $arrCityDetail[0]['city_name'];

           }

           

           if(empty($strRating)) {

               $strRating = 'S' ;

           }

           if($strRating == 'D'){

               $strRatingToDisplay = 'Deluxe' ;

           }else if($strRating == 'L'){

               $strRatingToDisplay = 'Luxury' ;

           }else if($strRating == 'S'){

               $strRatingToDisplay = 'Standard' ;

           }

           

         

           $bType = 'B2C';

           

           $this->view->intPackageId    = $intPackageId;

           $this->view->intDepartureCity = $intDepartureCity;

           $this->view->rating           = $strRating;

           $this->view->busType          = $bType;

           $this->view->strRatingToDisplay = $strRatingToDisplay;

           
          // $this->arrSeasons = $arrSeasons;

        }

    }

    public function getpricetocompareAction() {

        /* Disable layout */

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

        $this->_helper->layout->disableLayout();

       /* If ajax request */

        if ($this->_request->isXmlHttpRequest()) {
            $intPackageId = $this->getRequest()->getParam('intPackageId');

            $intDepartureCity = $this->getRequest()->getParam('intDepartureCity');

            if(empty($intPackageId) || empty($intDepartureCity)){

                //$this->_redirect( $this->baseUrl );

            }

            $objPackage = new Travel_Model_TblPackageMaster();

            $objPackage->intId = $intPackageId;

            return $objPackage->getPriceToCompare($intDepartureCity);

       }

    }

    

    public function autosuggestAction() {

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

        $this->_helper->layout->disableLayout();

        $arrResponse = array();

        if($this->getRequest()->getParam("term")) {

             $term = $this->getRequest()->getParam("term");

             

             $objPackage = new Travel_Model_TblPackageMaster();

             $arrResponse = $objPackage->getAutoSuggest($term);

        }

        echo json_encode( $arrResponse );

        exit;

    }

    

    public function autosuggestByAgentAction() {

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

        $this->_helper->layout->disableLayout();

        $arrResponse = array();

        if($this->getRequest()->getParam("term")) {

             $term = $this->getRequest()->getParam("term");

             

             $objPackage = new Travel_Model_TblPackageMaster();

             $arrResponse = $objPackage->getAutoSuggestByAgent($term);

        }

        echo json_encode( $arrResponse );

        exit;

    }

     

  public function captchaAction(){

  //disable layout and view

  $this->_helper->layout->disableLayout();

  $this->_helper->viewRenderer->setNoRender();

  //load Zend_Captcha_Image

    $captcha = new Zend_Captcha_Image();

    $captcha->setImgDir(APPLICATION_PATH . '/../public/images/captcha/');

    $captcha->setImgUrl($this->view->baseUrl('/images/captcha/'));

    $captcha->setFont(APPLICATION_PATH . '/../public/css/LeagueGothic/League_Gothic-webfont.ttf');

    $captcha->setWordlen(5);

    $captcha->setFontSize(28);

    $captcha->setLineNoiseLevel(3);

    $captcha->setWidth(90);

    $captcha->setHeight(64);

    $captcha->generate();

    $this->view->captcha = $captcha;

}

    public function refinesearchAction() {

        $this->_helper->layout->disableLayout();

        //$this->headMeta()->setCharset('UTF-8');

        if ($this->getRequest()->isXmlHttpRequest()) { 

//            $objPackage = new Travel_Model_TblPackageMaster();

//            $arrResult = $objPackage->getPacakgePriceRange(true);

//            $this->view->minPrice = trim($arrResult[0]['minPrice']);

//            $this->view->maxPrice = trim($arrResult[0]['maxPrice']);

            $this->view->arrGoingFor = $arrGoingFor = array('0-2' => '0-2', '3-5' => '3-5', '6-8' => '6-8','9+' => '9+');

            $this->view->arrStayin = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 =>5);

            $objPackType = new Travel_Model_TblPackageType();

            $arrPackageType = $objPackType->getPackageTypeList();

            $this->view->arrPackageType = $arrPackageType;

            $objInclusionCat = new Travel_Model_TblInclusionCat();

            $this->view->inclustionCategories = $objInclusionCat->getInclusionCategories();

            $this->view->selectedPriceRange = isset($_COOKIE['cookie_pricerange']) ? $_COOKIE['cookie_pricerange'] : '';

        }

    }

    /**

    * This function is used to show Short listed packages.

    * @param  void

    * @return array  responseArr	

    */	

    public function shortlistedPackagesAction() {

        $objPackage = new Travel_Model_TblPackageMaster();

        if(isset($_COOKIE['shortlistPackages'])) {

            $strShortListPackages = $_COOKIE['shortlistPackages'];

            $strShortListPackages = $this->_helper->String->cleanCommaSepString($strShortListPackages);

            $objPackage->strCondition =  " AND tbl_package_master.id in (" . $strShortListPackages .")";

        }else {

            $objPackage->strCondition =  " AND 1 = 2 ";

        }

        $this->view->imageServerUrl = $this->imageServerUrl;

        $objPackage->isBackend = 'N';

        $objPackage->orderByField = 's_price';

        $this->view->arrShortListPackages = $objPackage->getPackageList();

    }

    

    public function overviewAction() {

        $this->_helper->layout->disableLayout();

        if ($this->getRequest()->isXmlHttpRequest()) {

            $intPackageId = $this->view->intPackageId = $this->getRequest()->getParam('intPackageId');

            $objPackage = new Travel_Model_TblPackageMaster();

            $objPackage->intId = $intPackageId;

            $arrPackageDetail = $objPackage->getPackageList();

            $this->view->description             = $arrPackageDetail[0]['description'];

            $this->view->exclusion               = $arrPackageDetail[0]['exclusion'];

            $this->view->inclusion_text          = $arrPackageDetail[0]['inclusion_text'];

            $objPackage->strSelectedView = 'list';

            $objPackage->intQueryOffset = 0 ;

            $objPackage->intListPerPage = 3;

            $arrCityCovered = $objPackage->getOverviewCitiCovered();

            $response = array();

            if(count($arrCityCovered)>0) {

                $intCounter = 0;

                foreach($arrCityCovered as $city) {

                    $intCityId = $city['city_covered'];

                    

                    $objCity = new Travel_Model_TblCity();

                    $objCity->intId = $intCityId;

                    $arrCityDetail = $objCity->getCityList();

                    

                    if(count($arrCityDetail)>0) {

                        $response[$intCounter]['id'] = $arrCityDetail[0]['id'];

                        $response[$intCounter]['city_name'] = $arrCityDetail[0]['city_name'];

                        $response[$intCounter]['description'] = $arrCityDetail[0]['description'];

                        $response[$intCounter]['thumb_image_url'] = $arrCityDetail[0]['thumb_image_url'];

                        $intCounter++;

                    }

                }

            }

            $intCityCount = count($arrCityCovered);

            $intDifference = 3 - $intCityCount;

            if($intDifference > 0 ) { 

                /*

                $objItenary = new Travel_Model_TblItineraryPackage();

                $objItenary->intPackageId = $intPackageId;

                $objItenary->intQueryOffset  = 0;

                $objItenary->intListPerPage  = $intDifference;

                $objItenary->strSelectedView = 'list';

                $objItenary->strCondition = " AND destinations <> '' ";

                $this->view->arrDestinations = $objItenary->getItenaryDestinations();

                */

                $strDestinationIds = $arrPackageDetail[0]['destination_covered_ids'];

                    

                if(!empty($strDestinationIds)) {

                    /*

                    $objItenary->intPackageId = $intPackageId;

                    $objItenary->intQueryOffset  = 0;

                    $objItenary->intListPerPage  = $intDifference;

                    $objItenary->strSelectedView = 'list';

                    $objItenary->strCondition = " AND destinations <> '' ";

                    $this->view->arrDestinations = $objItenary->getItenaryDestinations();

                     * 

                     */

                    $objDestination = new Travel_Model_TblDestination();

                    $objDestination->intQueryOffset  = 0;

                    $objDestination->intListPerPage  = $intDifference;

                    $objDestination->strSelectedView = 'list';

                    $objDestination->strCondition = " AND tbl_destination.id in (" . $strDestinationIds . ")";

                    $this->view->arrDestinations = $objDestination->getDestinationList();

                }

                    

                    

//                echo "<pre>";

//                print_r($objItenary->getItenaryDestinations());

//                exit;

            }

           

//            echo "<pre>";

//            print_r($response);

//            exit;

            $this->view->arrDetail = $response;

            }

        }

        public function overviewSlideAction() {

        $this->_helper->layout->disableLayout();

        if ($this->getRequest()->isXmlHttpRequest()) {

            $intPackageId = $this->view->intPackageId = $this->getRequest()->getParam('intPackageId');

            $objPackage = new Travel_Model_TblPackageMaster();

            $objPackage->intId = $intPackageId;

            $objPackage->isPreview = true;

            $arrPackageDetail = $objPackage->getPackageList();

//            echo '<pre>';

//            print_r($arrPackageDetail);

//            exit;

            if(count($arrPackageDetail)>0) {

                $this->view->arrPackageDetail = $arrPackageDetail[0];

                        

                /* For only hotel package */

                if($arrPackageDetail[0]['p_type'] == 'OH') {

                    $this->view->arrHotelInfo = $objPackage->getHotelsInPackage($intPackageId);

                    $this->render('overview-hotel');

                }

            else {

                $intOffset    = $this->view->intOffset = $this->getRequest()->getParam('intOffset');

                $strDirection = $this->getRequest()->getParam('direction');

                if(empty($intOffset)) {

                    $intOffset = 0;

                }

           

                $this->view->intCityCoveredCount = $intCityCoveredCount = $objPackage->getCityCoveredNHavingDestinationsCount($intPackageId);

//                $strCityCovered = $arrPackageDetail[0]['city_covered'];

//                if(!empty($strCityCovered)) {

//                    $intCityCoveredCount = count(explode(",", $strCityCovered));

//                }else {

//                    $intCityCoveredCount = 0;

//                }

             //   $this->view->intCityCoveredCount = $intCityCoveredCount = $objPackage->getCityCoveredNHavingDestinationsCount($intPackageId);

              //  echo $intCityCoveredCount;exit;

                $objPackage->strSelectedView = 'list';

                if($strDirection == 'prev') {

                    if($intOffset >6) {

                        $intOffset = $intOffset - 6;

                    }else {

                        $intOffset = 0;

                    }

                }

                $objPackage->intQueryOffset = $intOffset ;

                $objPackage->intListPerPage = 3;

                $arrCityCovered = $objPackage->getOverviewCitiCovered();

//

//               echo $intCityCoveredCount;

//    //            

//                echo "<pre>";

//                print_r($arrCityCovered);

//                exit;

                $response = array();

                if(count($arrCityCovered)>0  && count($arrCityCovered) <= $intCityCoveredCount) {

                    $intCounter = 0;

                    foreach($arrCityCovered as $city) {

                        $intCityId = $city['city_covered'];

                        $objCity = new Travel_Model_TblCity();

                        $objCity->intId = $intCityId;

                        

                        $arrCityDetail = $objCity->getCityList();

                     

                        if(count($arrCityDetail)>0) {

                            $response[$intCounter]['id'] = $arrCityDetail[0]['id'];

                            $response[$intCounter]['city_name'] = $arrCityDetail[0]['city_name'];

                            $response[$intCounter]['about'] = $arrCityDetail[0]['about'];

                            $response[$intCounter]['short_description'] = $arrCityDetail[0]['short_description'];

                            $response[$intCounter]['thumb_image_url'] = $arrCityDetail[0]['thumb_image_url'];

                            $intCounter++;

                        }

                    }

                }

                $intCityCount = count($arrCityCovered);

                //echo $intCityCount;exit;

                $intDifference = 3 - $intCityCount;

                $this->view->hasMoreCity  = $intDifference >= 0 ? 'N' : 'Y';

                if($intDifference > 0 ) { 

                    $objItenary = new Travel_Model_TblItineraryPackage();

                    

                    $strDestinationIds = $arrPackageDetail[0]['destination_covered_ids'];

                    

                    if(!empty($strDestinationIds)) {

                        /*

                        $objItenary->intPackageId = $intPackageId;

                        $objItenary->intQueryOffset  = 0;

                        $objItenary->intListPerPage  = $intDifference;

                        $objItenary->strSelectedView = 'list';

                        $objItenary->strCondition = " AND destinations <> '' ";

                        $this->view->arrDestinations = $objItenary->getItenaryDestinations();

                         * 

                         */

                        

                      //  echo $intDifference;exit;

                        

                        $objDestination = new Travel_Model_TblDestination();

                        $objDestination->intQueryOffset  = 0;

                        $objDestination->intListPerPage  = $intDifference;

                        $objDestination->strSelectedView = 'list';

                        $objDestination->strCondition = " AND tbl_destination.id in (" . $strDestinationIds . ")";

                        $this->view->arrDestinations = $objDestination->getDestinationList();

                    }

//                    echo "<pre>";

//                    print_r($objItenary->getItenaryDestinations());

//                    exit;

                }

    //            echo "<pre>";

    //            print_r($response);

    //            exit;

                $this->view->arrDetail = $response;

              }

            }

          }

        }

    /*

    public function inclusionsAction() {

        $this->_helper->layout->disableLayout();

        if ($this->getRequest()->isXmlHttpRequest()) {

            $intPackageId = $this->getRequest()->getParam('intPackageId');

            $objPackage = new Travel_Model_TblPackageMaster();

            $objPackage->intId = $intPackageId;

            $arrPackageDetail = $objPackage->getPackageList();

            $this->view->inclusion_text = $arrPackageDetail[0]['inclusion_text'];

        }

    }

    */

    public function exclusionsAction() {

        $this->_helper->layout->disableLayout();

        if ($this->getRequest()->isXmlHttpRequest()) {

            $intPackageId = $this->getRequest()->getParam('intPackageId');

            $objPackage = new Travel_Model_TblPackageMaster();

            $objPackage->intId = $intPackageId;

            $objPackage->isPreview = true;

            $arrPackageDetail = $objPackage->getPackageList();

            $this->view->exclusion = $arrPackageDetail[0]['exclusion'];

            $this->view->inclusion_text = $arrPackageDetail[0]['inclusion_text'];

            $this->view->notes = $arrPackageDetail[0]['notes'];

        }

    }

     public function ratesAction() {

        $this->_helper->layout->disableLayout();

        if ($this->getRequest()->isXmlHttpRequest()) {

            $intPackageId = $this->getRequest()->getParam('intPackageId');

            $objPackage = new Travel_Model_TblPackageMaster();

            $objPackage->intId = $intPackageId;

            $arrPackageDetail = $objPackage->getPackageList();

            $this->view->inclusion_text = $arrPackageDetail[0]['inclusion_text'];

        }

    }

    public function termsNConditionsAction() {

        $this->_helper->layout->disableLayout();

        if ($this->getRequest()->isXmlHttpRequest()) {

            $intPackageId = $this->getRequest()->getParam('intPackageId');

            $objPackage = new Travel_Model_TblPackageMaster();

            $objPackage->intId = $intPackageId;

            $arrPackageDetail = $objPackage->getPackageList();

            $objAgent        = new Travel_Model_TblAgentInfo();

            $objAgent->intId = $arrPackageDetail[0]['agent_id'];

            $arrAgentInfo = $objAgent->getAgentList();

            if(count($arrAgentInfo)>0) {

                $this->view->agentInfo = $arrAgentInfo[0];

            }

         

            if($arrPackageDetail[0]['term_condition_isdefault'] == 'Y'){

                $this->view->termscondition = $arrAgentInfo[0]['terms_condition'];

            }else {

                $this->view->termscondition = $arrPackageDetail[0]['term_condition'];

            }

            if($arrPackageDetail[0]['payment_policy_isdefault'] == 'Y'){

                $this->view->paymentPolicy = $arrAgentInfo[0]['payment_policies'];

            }else {

                $this->view->paymentPolicy = $arrPackageDetail[0]['payment_policy'];

            }

            if($arrPackageDetail[0]['cancellation_policy_isdefault'] == 'Y'){

                $this->view->cancellationPolicy = $arrAgentInfo[0]['cancellation_policies'];

            }else {

                if(isset($arrPackageDetail[0]['cancellation_policies'])){

                    $this->view->cancellationPolicy = $arrPackageDetail[0]['cancellation_policies'];

                }

            }

            $this->view->notes = $arrPackageDetail[0]['notes'];

        }

    }

    public function similarPackagesAction() {

        $this->_helper->layout->disableLayout();

        if ($this->getRequest()->isXmlHttpRequest()) {

            $registry = Zend_Registry::getInstance();

            $this->view->imageServerUrl = $registry->imageServerURL;

            $this->view->noImageUrl = $this->_helper->Image->getNoImageUrl('general','thumb');

            $intPackageId = $this->getRequest()->getParam('intPackageId');

            $objPackage = new Travel_Model_TblPackageMaster();

            $objPackage->intId = $intPackageId;

            $arrSimilarPackages = $objPackage->getSimilarPackages();

//            echo "<pre>";

//            print_r($arrSimilarPackages);

//            exit;

            $this->view->arrSimilarPackages = $arrSimilarPackages ;

         }

    }

    

    public function shortlistBarAction() {

        $this->_helper->layout->disableLayout();

        if ($this->getRequest()->isXmlHttpRequest()) {

        }

    }

    public function comparePackageBarAction() {

        $this->_helper->layout->disableLayout();

        if ($this->getRequest()->isXmlHttpRequest()) {

        }

    }

    public function recentlyViewedBarAction() {

        $this->_helper->layout->disableLayout();

        if ($this->getRequest()->isXmlHttpRequest()) {

        }

    }

    

    public function hotelAction()

    {

          $params = $this->getRequest()->getParams();

        if(isset($params['packagedetail'])) {

            $packageString = $params['packagedetail'];

            if(strstr($packageString,'-')) { 

                $this->view->intPackageId = $intPackageId = substr($packageString,0, strpos($packageString , '-'));

            }

        }

       else {

           $this->view->intPackageId = $intPackageId = $params['id'];

        }

        if(empty($intPackageId)) {

             throw new Exception("Package Id not found.");

        }

        //$this->view->strRating       = $strRating = $this->getRequest()->getParam('strRating');

         

        $this->view->imageServerUrl = $this->imageServerUrl;

        $objPackage = new Travel_Model_TblPackageMaster();

        $objPackage->intId = $intPackageId;

        $arrPackageDetail = $objPackage->getPackageList();

        if(count($arrPackageDetail) != 1){

           $this->_redirect($this->view->baseUrl); 

        }

        $strPackageCategory = $arrPackageDetail[0]['category'];

        $this->view->packageDetail      = $arrPackageDetail[0];

        $this->view->p_type             = $arrPackageDetail[0]['p_type'];

        $this->view->arrPackageCategory = $arrPackageCategory = explode(",", $strPackageCategory);

        $this->view->packageType        = $arrPackageDetail[0]['p_type'];

        $objAgent        = new Travel_Model_TblAgentInfo();

        $objAgent->intId = $arrPackageDetail[0]['agent_id'];

        $arrAgentInfo = $objAgent->getAgentList();

        if(count($arrAgentInfo)>0) {

            $this->view->agentInfo = $arrAgentInfo[0];

        }

        if($arrPackageDetail[0]['term_condition_isdefault'] == 'Y'){

                $this->view->termscondition = $arrAgentInfo[0]['terms_condition'];

        }else {

            $this->view->termscondition = $arrPackageDetail[0]['term_condition'];

        }

        if($arrPackageDetail[0]['payment_policy_isdefault'] == 'Y'){

            $this->view->paymentPolicy = $arrAgentInfo[0]['payment_policies'];

        }else {

            $this->view->paymentPolicy = $arrPackageDetail[0]['payment_policy'];

        }

        if($arrPackageDetail[0]['cancellation_policy_isdefault'] == 'Y'){

            $this->view->cancellationPolicy = $arrAgentInfo[0]['cancellation_policies'];

        }else {

            if(isset($arrPackageDetail[0]['cancellation_policies'])){

                $this->view->cancellationPolicy = $arrPackageDetail[0]['cancellation_policies'];

            }

        }

         

        $this->view->exclusion      = $arrPackageDetail[0]['exclusion'];

        $this->view->inclusion_text = $arrPackageDetail[0]['inclusion_text'];

        $this->view->notes          = $arrPackageDetail[0]['notes'];    

        $arrPackCat = array();

        $isStandard = false;

        $isDeluxe   = false;

        $isLuxury   = false;

        if(count($arrPackageCategory) > 0 ){

            foreach($arrPackageCategory as $category) { 

                if($category == 'Standard') {

                    $arrPackCat['S'] = 'Standard';

                    $this->view->isStandard = $isStandard = true;

                }

                if($category == 'Deluxe') {

                    $arrPackCat['D'] = 'Deluxe';

                    $this->view->isDeluxe = $isDeluxe = true;

                }

                if($category == 'Luxury') {

                    $arrPackCat['L'] = 'Luxury';

                    $this->view->isLuxury = $isLuxury = true;

                }

            }

        }

        $this->view->arrHotelInfo         = $arrAllHotelsInPackage = $objPackage->getHotelsInPackage($intPackageId);

        $this->view->arrAllStandardHotels = $arrAllStandardHotels  = $objPackage->getHotelsInPackage($intPackageId, 'S');

        $this->view->arrAllDeluxeHotels   = $arrAllDeluxeHotels    = $objPackage->getHotelsInPackage($intPackageId, 'D');

        $this->view->arrAllLuxuryHotels   = $arrAllLuxuryHotels    = $objPackage->getHotelsInPackage($intPackageId, 'L');

        if($isStandard) {

            $strStandardHotelInfo = '';

            if(count($arrAllStandardHotels)>0) {

                foreach($arrAllStandardHotels as $hotel){

                    $strStandardHotelInfo .=  '<strong>'.$hotel['city_name'].'</strong>, ';

                    $strStandardHotelInfo .=  $hotel['hotel_name'];

                    if(!empty($hotel['rating'])){

                        $strStandardHotelInfo .= ' '.$hotel['rating'];

                        $strStandardHotelInfo .= '<img src="'.$this->baseUrl .'/public/travel/images/small_star.png">';

                    }

                    $strStandardHotelInfo .= "<br>";

                }

            }

            $this->view->strStandardHotelInfo = $strStandardHotelInfo;

        }

        if($isDeluxe) {

            $strDeluxeHotelInfo = '';

            if(count($arrAllDeluxeHotels)>0) {

                foreach($arrAllDeluxeHotels as $hotel){

                    $strDeluxeHotelInfo .=  '<strong>'.$hotel['city_name'].'</strong>, ';

                    $strDeluxeHotelInfo .=  $hotel['hotel_name'];

                    if(!empty($hotel['rating'])){

                        $strDeluxeHotelInfo .= ' '.$hotel['rating'];

                        $strDeluxeHotelInfo .= '<img src="'.$this->baseUrl .'/public/travel/images/small_star.png">';

                    }

                    $strDeluxeHotelInfo .= "<br>";

                }

            }

            $this->view->strDeluxeHotelInfo = $strDeluxeHotelInfo;

        }

        if($isLuxury) {

            $strLuxuryHotelInfo = '';

            if(count($arrAllLuxuryHotels)>0) {

                foreach($arrAllLuxuryHotels as $hotel){

                    $strLuxuryHotelInfo .=  '<strong>'.$hotel['city_name'].'</strong>, ';

                    $strLuxuryHotelInfo .=  $hotel['hotel_name'];

                    if(!empty($hotel['rating'])){

                        $strLuxuryHotelInfo .= ' ' .$hotel['rating'];

                        $strLuxuryHotelInfo .= '<img src="'.$this->baseUrl .'/public/travel/images/small_star.png">';

                    }

                    $strLuxuryHotelInfo .= "<br>";

                }

            }

            $this->view->strLuxuryHotelInfo = $strLuxuryHotelInfo;

        }

//          echo "<pre>";

//                    print_r($arrAllStandardHotels);

//                    exit;

                    

        if($arrPackageDetail[0]['p_type'] == 'OH' || $arrPackageDetail[0]['p_type'] == 'HF') {

            $arrHotelInfo = $objPackage->getOnlyHotelPackageInfo();

            if(count($arrHotelInfo)>0) {

                $objHotel = new Travel_Model_TblHotel();

                if($isStandard) {

                    $intHotelIdStandard = $arrHotelInfo[0]['hotel_id_standard'];

                    $objHotel->intId = $intHotelIdStandard;

                    $arrStandardHotelInfo = $objHotel->getHotelList();

                    if(count($arrStandardHotelInfo)>0) {

                        $this->view->strStandardHotelName   = $arrStandardHotelInfo[0]['hotel_name'];

                        $this->view->intStandardHotelRating = $arrStandardHotelInfo[0]['rating'];

                    }

                }

                if($isDeluxe) {

                    $intHotelIdDeluxe   = $arrHotelInfo[0]['hotel_id_deluxe'];

                    $objHotel->intId = $intHotelIdDeluxe;

                    $this->view->arrDeluxeHotelInfo = $arrDeluxeHotelInfo = $objHotel->getHotelList();

                    if(count($arrDeluxeHotelInfo)>0) {

                        $this->view->strDeluxeHotelName   = $arrDeluxeHotelInfo[0]['hotel_name'];

                        $this->view->intDeluxeHotelRating = $arrDeluxeHotelInfo[0]['rating'];

                    }

                }

                if($isLuxury) {

                    $intHotelIdLuxury   = $arrHotelInfo[0]['hotel_id_luxury'];

                    $objHotel->intId = $intHotelIdLuxury;

                    $this->view->arrLuxuryHotelInfo  = $arrLuxuryHotelInfo = $objHotel->getHotelList();

                    if(count($arrLuxuryHotelInfo)>0) {

                        $this->view->strLuxuryHotelName   = $arrLuxuryHotelInfo[0]['hotel_name'];

                        $this->view->intLuxuryHotelRating = $arrLuxuryHotelInfo[0]['rating'];

                    }

                }

                

                if(count($arrHotelInfo)>0) {

                    $strKeyInclusions = '';

                    foreach($arrHotelInfo as $info) {

                        if(!empty($info['services'])) {

                            $strKeyInclusions .= $info['services'] . ",";

                        }

                    }

                    $strKeyInclusions = trim($strKeyInclusions);

                    $this->view->arrKeyFacilities = explode(",", $strKeyInclusions);

                }

        }

        } else {

            /* Show the itenary of Standard Hotel Only*/

         

            /* Get category from Package */

            $category =  $arrPackageDetail[0]['category'];

            $arrCategory = explode(",", $category);

            if(in_array('Standard', $arrCategory)) {

                $strRating = 'S';

                $intHotelCategory = 1;

                $strRatingToDisplay = 'Standard' ;

            }else if(in_array('Deluxe', $arrCategory)) {

                $strRating = 'D';

                $intHotelCategory = 2;

                $strRatingToDisplay = 'Deluxe' ;

            }else if(in_array('Luxury', $arrCategory)) {

                $strRating = 'L';

                 $intHotelCategory = 3;

                 $strRatingToDisplay = 'Luxury' ;

            }

            $objInclusion = new Travel_Model_TblInclusion();

            $this->view->arrKeyInclusions = $objInclusion->getInclusionList($intPackageId);

            $objItenary = new Travel_Model_TblItineraryPackage();

            $objItenary->intPackageId = $intPackageId;

            $objItenary->intHotelCategory = $intHotelCategory;

            $this->view->itenaryDetail = $arrItenaryDetail = $objItenary->view4UI();

            $boolHavingItenary = false;

            if(count($arrItenaryDetail)>0){

                foreach($arrItenaryDetail as $itenary) {

                    $title = trim($itenary['title']);

                    if(!empty($title)) {

                        $boolHavingItenary = true;

                    }

                }

            }

            $this->view->boolHavingItenary = $boolHavingItenary;

          /* if(!empty($intDepartureCity)) {

            $objCity = new Travel_Model_TblCity();

            $objCity->intId = $intDepartureCity;

            $arrCityDetail = $objCity->getCityList();

            if(count($arrCityDetail)>0){

              $this->view->cityName = $arrCityDetail[0]['city_name'];

            }

           }

           */

           $bType = 'B2C';

           

           $this->view->intPackageId    = $intPackageId;

          // $this->view->intDepartureCity = $intDepartureCity;

           $this->view->rating           = $strRating;

           $this->view->busType          = $bType;

           $this->view->strRatingToDisplay = $strRatingToDisplay;

           $this->view->arrDestinationCoveredFormatted = $objPackage->getDestinationCoveredFormatted();

        }

         

      //  $this->view->intPackageId       = $intPackageId       = $this->getRequest()->getParam('intPackageId');

     //   $this->view->intSeasonId        = $intSeasonId        = $this->getRequest()->getParam('intSeasonId');

     //   $this->view->intDepartureCityId = $intDepartureCityId = $this->getRequest()->getParam('intDepartureCity');

        $arrRates = $objPackage->getRates($intPackageId, '');

     

        if(count($arrRates)>0) {

            $this->view->arrRates           = $arrRateBox = $arrRates[0];

            $this->view->showPasoLine = false;

            $this->view->showChildLine = false;

            if(!empty($arrRateBox['s_b2c_paso']) || !empty($arrRateBox['d_b2c_paso']) || !empty($arrRateBox['l_b2c_paso']) ) {

                $this->view->showPasoLine = true;

            }

            if(!empty($arrRateBox['s_b2c_child']) || !empty($arrRateBox['d_b2c_child']) || !empty($arrRateBox['l_b2c_child']) ) {

                $this->view->showChildLine = true;

            }

            if(!empty($arrRates[0]['city_id'])) {

                $this->view->intDepartureCityId = $arrRates[0]['city_id'];

            }

        } else {

            $this->view->arrRates = array();

        }

        $this->view->arrDepartureCities = $arrDepartureCities = $objPackage->getDepartureCities('array');

           

           // $this->view->strRating = $strRating;        

            if(!empty($strRatingToDisplay)) {

                $this->view->title     = "Itinerary for ". $strRatingToDisplay ." Package";

            }

 

            $this->view->destinationCities = $objPackage->getDepartureCities('array');
        $objPackage = new Travel_Model_TblPackageMaster();

        $objPackage->intId = $intPackageId;

        $objPackage->strSelectedView = 'list';

        $objPackage->intQueryOffset  = 0;

        $objPackage->intListPerPage  = SHOW_SIMILAR_PKG_COUNT;

        $arrSimilarPackages = $objPackage->getSimilarPackages();

        $this->view->arrSimilarPackages = $arrSimilarPackages ;

       // $arrImageDetail = $objPackage->getPackageImage('large');

        $this->view->intCityCoveredCount = $objPackage->getCityCoveredNHavingDestinationsCount($intPackageId);

     

        $objAgent = new Travel_Model_TblAgentInfo();

        $intAgentId = $arrPackageDetail[0]['agent_id'];

        $objAgent->addPackageVisit($intPackageId, $intAgentId);

       /* if(isset($_COOKIE['recentlyViewedPackages'])) {

            $arrRecentlyViewed = explode(",", $_COOKIE['recentlyViewedPackages']);

            if(!in_array($intPackageId, $arrRecentlyViewed)) {

                setcookie('recentlyViewedPackages',$_COOKIE['recentlyViewedPackages'] . ',' . $intPackageId ,time() + (86400), "/");

               

                $arrRecentlyViewed = explode(",", $_COOKIE['recentlyViewedPackages']);

//                echo MAX_RECENTLY_VIEWED_PKGS;

//                exit;

                //if(count($arrRecentlyViewed) > MAX_RECENTLY_VIEWED_PKGS){

                if(count($arrRecentlyViewed) > MAX_RECENTLY_VIEWED_PKGS){

                    /* Remove previous element 

                    array_shift($arrRecentlyViewed);

//                    echo "<pre>"; print_r($arrRecentlyViewed); 

//                    exit;

                    setcookie('recentlyViewedPackages', implode(",", $arrRecentlyViewed),time() + (86400), "/");

                }

            }

        }else {

            setcookie('recentlyViewedPackages',$intPackageId,time() + (86400), "/");

        }*/

        if(isset($_COOKIE['recentlyViewedPackages']) && $_COOKIE['recentlyViewedPackages']!="") {

            $arrRecentlyViewed = explode(",", $_COOKIE['recentlyViewedPackages']);

            if(!in_array($intPackageId, $arrRecentlyViewed)) { 

                $arrRecentlyViewed = explode(",", $_COOKIE['recentlyViewedPackages']);

                array_push($arrRecentlyViewed, $intPackageId);

                setcookie('recentlyViewedPackages', implode(",", $arrRecentlyViewed),time() + (86400), "/");

                if(count($arrRecentlyViewed) > MAX_RECENTLY_VIEWED_PKGS ){

                    setcookie('recentlyViewedPackages', implode(",", $arrRecentlyViewed),time() + (86400), "/");

                    $arrRecentlyViewed = explode(",", $_COOKIE['recentlyViewedPackages']);

                    array_shift($arrRecentlyViewed);

                    $arrRecentlyViewed = array_values($arrRecentlyViewed);

                     setcookie('recentlyViewedPackages', implode(",", $arrRecentlyViewed),time() + (86400), "/");

                }

            }

        }else { 

            setcookie('recentlyViewedPackages',$intPackageId,time() + (86400), "/");

        }

        $packageName       =   $arrPackageDetail[0]['display_name'];

        if(empty($packageName)) {

            $packageName = '';

        }

        //$packageDesc       =   strip_tags($arrPackageDetail[0]['description']);

        $price             =   $arrPackageDetail[0]['s_price'];

        $content = "Package starting from " . $this->_helper->Currency->formatCurrency($arrPackageDetail[0]['s_price']) . " per person. ";

  

       $this->view->doctype('XHTML1_RDFA');  // controller

       $this->view->headMeta()->setProperty('fb:app_id', FACEBOOK_APP_ID);

       $this->view->headMeta()->setProperty('og:type', 'website');

       $this->view->headMeta()->setProperty('og:description',$content); 

       $this->view->headMeta()->setProperty('og:title', $packageName);

      // $this->view->headMeta()->setProperty('og:image:type', 'image/jpg');

       $this->view->headMeta()->setProperty('og:url', $this->_helper->SEO->getPackageDetailPageUrl($arrPackageDetail[0]['id'],$arrPackageDetail[0]['package_name']));

      // $this->view->headMeta()->setProperty('og:url', 'http://www.travelone.co.in/package/1330/travel-package/Best-Shimla-Manali-Family-Holiday-Tour-Package');

       $this->view->headMeta()->setProperty('og:site_name', SITE_NAME);

        $this->view->fb_image_url = $fb_share_image = $objPackage->getFacebookSharingImage('single');

        $arr_fb_images = $objPackage->getFacebookSharingImage('array');

       $packageNameCustomized =  $arrPackageDetail[0]['display_name'];

       $packageNameCustomized = substr($packageNameCustomized, 0, strpos($packageNameCustomized,'- with'));

       $strCitiesCovered = $arrPackageDetail[0]['city_covered_text'];

       $arrCitiesCovered = explode(",", $strCitiesCovered);

       if(count($arrCitiesCovered) > 2) {

           $strCitiesCovered = $arrCitiesCovered[0] .','. $arrCitiesCovered[1];

       }

       $this->view->headMeta()->setName('description', 'Book '. $packageNameCustomized .' at showmetrips.com, one of the 100 '.$strCitiesCovered.' tour options we have for you.See more such travel packages here.');

       /* Get current page url */

       $this->view->canonical = $this->baseUrl  .Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();

       $keyword   = $arrPackageDetail[0]['city_covered_text'];

       $arrKeyword = explode(",", $keyword);

       if(count($arrKeyword)>1 && !empty($keyword)) {

           $keyword = $arrKeyword[0];

       }

       $pageTitle = $keyword .' package | ' .$keyword .' tour packages | '. $keyword.' travel packages';

       $this->view->headTitle($pageTitle);

       $this->view->headMeta()->setName('keywords', $keyword .' package, '.$keyword.' tour packages, '.$keyword.' travel packages, 

                    best '.$keyword.' package, cheap '.$keyword.' tour package');

        $this->view->arr_fb_images = $arr_fb_images;

        //$this->view->headMeta()->setProperty('og:image',$fb_share_image);

 

        $arrHotelIds = array();

      //  $this->view->dayNight = $this->_helper->General->showDayNight($arrPackageDetail[0]['days']);

        $objAgent        = new Travel_Model_TblAgentInfo();

        $objAgent->intId = $arrPackageDetail[0]['agent_id'];

        $arrAgentInfo = $objAgent->getAgentList();

        if(count($arrAgentInfo)>0) {

            $this->view->agentInfo = $arrAgentInfo[0];

        }

        $curlUrl = "http://api.tripadvisor.com/api//partner/2.0/location/89575/hotels?key=f652bf61fad841db97239a7885b25096";

        $response = file_get_contents($curlUrl);

        $response = json_decode($response,1);

        if(count($response)>0)

        {

            $data = array();

            foreach($response['data'] as $value)

            {

                $this->view->address1 = $value['address_obj']['street1']; 

                $this->view->address2 = $value['address_obj']['street2']; 

                $this->view->city = $value['address_obj']['city']; 

                $this->view->state = $value['address_obj']['state']; 

                $this->view->country = $value['address_obj']['country']; 

                $this->view->postalcode = $value['address_obj']['postalcode']; 

                $this->view->address_string = $value['address_obj']['address_string']; 

                $this->view->latitude = $value['latitude']; 

                $this->view->longitude = $value['longitude'];

                $this->view->rating = $value['rating'];

                $this->view->rating_image_url = $value['rating_image_url'];

                $this->view->ranking_string = $value['ranking_data']['ranking_string']; 

                $this->view->write_review = $value['write_review'];

                $this->view->web_url = $value['web_url'];

                $this->view->hotel_name = $value['name'];

                $this->view->num_reviews = $value['num_reviews'];

                $this->view->see_all_photos = $value['see_all_photos'];

            }

        }

    }

  

  

}

?>


Youez - 2016 - github.com/yon3zu
LinuXploit