コード例 #1
0
 function display($tpl = null, $preparecontent = false)
 {
     BookingForConnectorViewResourceBase::basedisplay($tpl);
     $item = $this->get('Item');
     $document = JFactory::getDocument();
     $language = $document->getLanguage();
     $app = JFactory::getApplication();
     $sitename = $app->get('sitename');
     $config = JComponentHelper::getParams('com_bookingforconnector');
     $params = $this->params;
     // add stylesheet
     JHTML::stylesheet('components/com_bookingforconnector/assets/css/bookingfor.css');
     JHTML::stylesheet('components/com_bookingforconnector/assets/css/bookingfor-responsive.css');
     $document->addStyleSheet('components/com_bookingforconnector/assets/css/jquery.validate.css');
     $document->addStyleSheet('https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css');
     // load scripts
     $document->addScript('components/com_bookingforconnector/assets/js/jquery.validate.min.js');
     $document->addScript('components/com_bookingforconnector/assets/js/additional-methods.min.js');
     $document->addScript('components/com_bookingforconnector/assets/js/jquery.form.js');
     $document->addScript('components/com_bookingforconnector/assets/js/jquery.blockUI.js');
     $document->addScript('components/com_bookingforconnector/assets/js/bf.js');
     $this->assignRef('document', $document);
     $this->assignRef('language', $language);
     $this->assignRef('item', $item);
     $this->assignRef('sitename', $sitename);
     $this->assignRef('config', $config);
     if (JRequest::getString('layout') == 'form') {
         $model = $this->getModel();
         $allstays = $model->getStay($language);
         //			$allstays = $model->getStay(isset($this->params['refreshcalc']));
         $stay = null;
         if (is_array($allstays) && (!isset($this->params['pricetype']) || empty($this->params['pricetype']))) {
             $selStay = array_values(array_filter($allstays, function ($st) {
                 return $st->SuggestedStay->Available && $st->TotalAmount > 0;
             }));
             if (count($selStay) > 0) {
                 $this->params['pricetype'] = $selStay[0]->RatePlanId;
             }
         }
         if (is_array($allstays) && isset($this->params['pricetype'])) {
             $selStay = array_values(array_filter($allstays, function ($st) {
                 return $this->params['pricetype'] == $st->RatePlanId;
             }));
             if (count($selStay) > 0) {
                 $stay = $selStay[0];
             }
         }
         if (isset($stay->BookingTypes)) {
             $item->MerchantBookingTypes = $stay->BookingTypes;
         }
         if (isset($stay->SelectablePrices)) {
             $Extras = $stay->SelectablePrices;
         }
         BFCHelper::setState(array('resourceId' => $params['resourceId'], 'checkin' => $params['checkin']->format('d/m/Y'), 'checkout' => $params['checkout']->format('d/m/Y'), 'duration' => $params['duration'], 'paxages' => $params['paxages'], 'extras' => $params['extras'], 'packages' => $params['packages'], 'pricetype' => $params['pricetype'], 'rateplanId' => $params['rateplanId'], 'state' => $params['state'], 'variationPlanId' => $params['variationPlanId'], 'gotCalculator' => false), 'stayrequest', 'resource');
         if (!empty($item->MerchantBookingTypes)) {
             BFCHelper::setState($item->MerchantBookingTypes, 'bookingTypes', 'resource');
         }
         BFCHelper::setState($stay, 'stay', 'resource');
         /* creating totals */
         $total = 0;
         $totalDiscounted = 0;
         $totalWithVariation = 0;
         if (!empty($stay)) {
             $suggestedStay = $stay->SuggestedStay;
             if (!empty($suggestedStay->TotalPrice)) {
                 $total = (double) $suggestedStay->TotalPrice;
             }
             if (!empty($suggestedStay->DiscountedPrice)) {
                 $totalDiscounted = (double) $suggestedStay->DiscountedPrice;
             }
             $totalWithVariation = $totalDiscounted;
             //TODO: cosa farne dei pacchetti nel calcolo singolo della risorsa?
             /*
             if(!empty($stay->CalculatedPackages)){
             	foreach ($stay->CalculatedPackages as $pkg) {
             		//$totalDiscounted = $totalDiscounted + $pkg->SuggestedStay->DiscountedPrice;
             		//$total = $total + $pkg->SuggestedStay->DiscountedPrice;
             		
             		
             		$totalDiscounted = $totalDiscounted + $pkg->DiscountedAmount;
             		$total = $total + $pkg->DiscountedAmount;
             	}
             }
             */
             if (!empty($stay->Variations)) {
                 foreach ($stay->Variations as $var) {
                     $var->TotalPackagesAmount = 0;
                     foreach ($stay->CalculatedPackages as $pkg) {
                         foreach ($pkg->Variations as $pvar) {
                             if ($pvar->VariationPlanId == $var->VariationPlanId) {
                                 $var->TotalPackagesAmount += $pvar->TotalAmount;
                                 break;
                             }
                         }
                     }
                 }
             }
         }
         $totalWithVariation = $totalDiscounted + 0;
         // force int cast
         $selVariationId = $params['variationPlanId'];
         $selVariation = null;
         if ($selVariationId != '') {
             $totalWithVariation = $total;
             foreach ($stay->Variations as $variation) {
                 if ($variation->VariationPlanId == $selVariationId) {
                     $selVariation = $variation;
                     $totalWithVariation += (double) $variation->TotalAmount + (double) $variation->TotalPackagesAmount;
                     break;
                 }
             }
         }
         BFCHelper::setState($totalWithVariation, 'total', 'resource');
         $this->assignRef('stay', $stay);
         $this->assignRef('total', $total);
         $this->assignRef('totalDiscounted', $totalDiscounted);
         $this->assignRef('totalWithVariation', $totalWithVariation);
         $this->assignRef('selVariationId', $selVariationId);
         $this->assignRef('selVariation', $selVariation);
         //$Extras =  null;		//$this->get('ExtrasFromService');
         $PriceTypes = $model->getPriceTypesFromServiceRatePlan($allstays);
         //$this->get('PriceTypesFromServiceRatePlan');
         $MerchantBookingTypes = $this->get('MerchantBookingTypesFromService');
         $this->assignRef('Extras', $Extras);
         $this->assignRef('PriceTypes', $PriceTypes);
         $this->assignRef('MerchantBookingTypes', $MerchantBookingTypes);
     }
     //end layout "form"
     //$this->setBreadcrumb($item, 'resources');
     $this->setBreadcrumb($item, 'resources', $language);
     parent::display($tpl, true);
 }
コード例 #2
0
    function display($tpl = null, $preparecontent = false)
    {
        BookingForConnectorViewResourceBase::basedisplay($tpl);
        $item = $this->get('Item');
        $document = JFactory::getDocument();
        $language = $document->getLanguage();
        $app = JFactory::getApplication();
        $sitename = $app->get('sitename');
        $config = JComponentHelper::getParams('com_bookingforconnector');
        $params = $this->params;
        // add stylesheet
        $document->addStyleSheet('//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css');
        $document->addStyleSheet('components/com_bookingforconnector/assets/css/bookingfor.css');
        $document->addStyleSheet('components/com_bookingforconnector/assets/css/bookingfor-responsive.css');
        //		$document->addStyleSheet('components/com_bookingforconnector/assets/css/jquery.validate.css');
        $document->addStyleSheet('https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css');
        // load scripts
        $document->addScript('//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js');
        $document->addScript('//ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/jquery.validate.min.js');
        $document->addScript('//ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/additional-methods.min.js');
        $document->addScript('//ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/localization/messages_' . substr($language, 0, 2) . '.js');
        //		$document->addScript('components/com_bookingforconnector/assets/js/jquery.validate.min.js');
        //		$document->addScript('components/com_bookingforconnector/assets/js/additional-methods.min.js');
        $document->addScript('components/com_bookingforconnector/assets/js/jquery.form.js');
        $document->addScript('components/com_bookingforconnector/assets/js/jquery.blockUI.js');
        $document->addScript('components/com_bookingforconnector/assets/js/bf.js');
        $document->addScript('components/com_bookingforconnector/assets/js/jquery.shorten.js');
        $document->addScript('components/com_bookingforconnector/assets/js/jquery.expander.min.js');
        if (substr($language, 0, 2) != 'en') {
            //			$document->addScript('//jquery-ui.googlecode.com/svn/tags/legacy/ui/i18n/ui.datepicker-' . substr($language,0,2) . '.js');
            $document->addScript('//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/i18n/datepicker-' . substr($language, 0, 2) . '.min.js?ver=1.11.4');
        }
        $this->assignRef('document', $document);
        $this->assignRef('language', $language);
        $this->assignRef('item', $item);
        $this->assignRef('sitename', $sitename);
        $this->assignRef('config', $config);
        $merchants = array();
        $merchants[] = $item->MerchantId;
        $analyticsEnabled = $this->checkAnalytics("Merchant Resources Search List");
        $criteoConfig = null;
        if (JRequest::getString('layout', "default") == "default") {
            $criteoConfig = BFCHelper::getCriteoConfiguration(2, $merchants);
            if (isset($criteoConfig) && isset($criteoConfig->enabled) && $criteoConfig->enabled && count($criteoConfig->merchants) > 0) {
                $document->addScript('//static.criteo.net/js/ld/ld.js');
                $document->addScriptDeclaration('
				window.criteo_q = window.criteo_q || [];');
                if ($item->IsCatalog) {
                    $document->addScriptDeclaration('
				window.criteo_q.push( 
					{ event: "setAccount", account: ' . $criteoConfig->campaignid . '}, 
					{ event: "setSiteType", type: "d" }, 
					{ event: "setEmail", email: "" }, 
					{ event: "viewItem", item: "' . $criteoConfig->merchants[0] . '" }
				);');
                }
            }
            if ($item->IsCatalog && $analyticsEnabled && $config->get('eecenabled', 0) == 1) {
                $obj = new stdClass();
                $obj->id = "" . $item->ResourceId . " - Resource";
                $obj->name = $item->Name;
                $obj->category = $item->MerchantCategoryName;
                $obj->brand = $item->MerchantName;
                $obj->variant = 'CATALOG';
                $document->addScriptDeclaration('callAnalyticsEEc("addProduct", [' . json_encode($obj) . '], "item");');
            }
        }
        if (JRequest::getString('layout') == 'form') {
            $model = $this->getModel();
            $allstays = $model->getStay($language, null, true);
            //			$allstays = $model->getStay(isset($this->params['refreshcalc']));
            $stay = null;
            if (is_array($allstays) && (!isset($this->params['pricetype']) || empty($this->params['pricetype']))) {
                $selStay = array_values(array_filter($allstays, function ($st) {
                    return $st->SuggestedStay->Available && $st->TotalAmount > 0;
                }));
                if (count($selStay) > 0) {
                    $this->params['pricetype'] = $selStay[0]->RatePlanId;
                }
            }
            if (is_array($allstays) && isset($this->params['pricetype'])) {
                $selStay = array_values(array_filter($allstays, function ($st) {
                    return $this->params['pricetype'] == $st->RatePlanId;
                }));
                if (count($selStay) > 0) {
                    $stay = $selStay[0];
                }
            }
            //echo "<pre>pricetype";
            //echo $this->params['pricetype'];
            //echo "</pre>";
            //
            //			echo "<pre>selStay";
            //						echo print_r($selStay);
            //			echo "</pre>";
            //						echo "<pre>stay";
            //						echo print_r($stay);
            //						echo "</pre>";
            /* creating totals */
            $total = 0;
            $totalDiscounted = 0;
            $totalWithVariation = 0;
            $newAllStays = array();
            if (!empty($stay)) {
                $item->Availability = $stay->SuggestedStay->Availability;
                $stay->CalculatedPricesDetails = json_decode($stay->CalculatedPricesString);
                $stay->SelectablePrices = json_decode($stay->CalculablePricesString);
                $stay->CalculatedPackages = json_decode($stay->PackagesString);
                $stay->DiscountVariation = null;
                // only here
                $item->BookingType = $stay->SuggestedStay->BookingType;
                if (!empty($stay->Discount)) {
                    $stay->DiscountVariation = $stay->Discount;
                }
                $stay->SupplementVariation = null;
                if (!empty($stay->Supplement)) {
                    $stay->SupplementVariation = $stay->Supplement;
                }
                $allVar = json_decode($stay->AllVariationsString);
                $stay->Variations = array();
                $stay->SimpleDiscountIds = array();
                foreach ($allVar as $currVar) {
                    if (empty($currVar->IsExclusive)) {
                        $stay->Variations[] = $currVar;
                        $stay->SimpleDiscountIds[] = $currVar->VariationPlanId;
                    }
                }
                if (isset($stay->BookingTypes)) {
                    $item->MerchantBookingTypes = $stay->BookingTypes;
                }
                if (isset($stay->SelectablePrices)) {
                    $Extras = $stay->SelectablePrices;
                }
                $suggestedStay = $stay->SuggestedStay;
                if (!empty($suggestedStay->TotalPrice)) {
                    $total = (double) $suggestedStay->TotalPrice;
                }
                if (!empty($suggestedStay->DiscountedPrice)) {
                    $totalDiscounted = (double) $suggestedStay->DiscountedPrice;
                }
                $totalWithVariation = $totalDiscounted;
                //TODO: cosa farne dei pacchetti nel calcolo singolo della risorsa?
                /*
                if(!empty($stay->CalculatedPackages)){
                	foreach ($stay->CalculatedPackages as $pkg) {
                		//$totalDiscounted = $totalDiscounted + $pkg->SuggestedStay->DiscountedPrice;
                		//$total = $total + $pkg->SuggestedStay->DiscountedPrice;
                		
                		
                		$totalDiscounted = $totalDiscounted + $pkg->DiscountedAmount;
                		$total = $total + $pkg->DiscountedAmount;
                	}
                }
                */
                if (!empty($stay->Variations)) {
                    foreach ($stay->Variations as $var) {
                        $var->TotalPackagesAmount = 0;
                        foreach ($stay->CalculatedPackages as $pkg) {
                            foreach ($pkg->Variations as $pvar) {
                                if ($pvar->VariationPlanId == $var->VariationPlanId) {
                                    $var->TotalPackagesAmount += $pvar->TotalAmount;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            BFCHelper::setState(array('resourceId' => $params['resourceId'], 'checkin' => $params['checkin']->format('d/m/Y'), 'checkout' => $params['checkout']->format('d/m/Y'), 'duration' => $params['duration'], 'paxages' => $params['paxages'], 'extras' => $params['extras'], 'packages' => $params['packages'], 'pricetype' => $params['pricetype'], 'rateplanId' => $params['rateplanId'], 'state' => $params['state'], 'variationPlanId' => $params['variationPlanId'], 'gotCalculator' => false), 'stayrequest', 'resource');
            if (!empty($item->MerchantBookingTypes)) {
                BFCHelper::setState($item->MerchantBookingTypes, 'bookingTypes', 'resource');
            }
            BFCHelper::setState($stay, 'stay', 'resource');
            if (!empty($stay)) {
            }
            $totalWithVariation = $totalDiscounted + 0;
            // force int cast
            $selVariationId = $params['variationPlanId'];
            $selVariation = null;
            if ($selVariationId != '') {
                $totalWithVariation = $total;
                foreach ($stay->Variations as $variation) {
                    if ($variation->VariationPlanId == $selVariationId) {
                        $selVariation = $variation;
                        $totalWithVariation += (double) $variation->TotalAmount + (double) $variation->TotalPackagesAmount;
                        break;
                    }
                }
            }
            $newAllStays = array();
            foreach ($allstays as $rs) {
                if ($rs != null) {
                    $rs->CalculatedPricesDetails = json_decode($rs->CalculatedPricesString);
                    $rs->SelectablePrices = json_decode($rs->CalculablePricesString);
                    $rs->CalculatedPackages = json_decode($rs->PackagesString);
                    $rs->DiscountVariation = null;
                    // only here
                    $rs->IsBase = $rs->IsBase;
                    $rs->BookingType = 0;
                    if (!empty($rs->SuggestedStay)) {
                        $rs->BookingType = $rs->SuggestedStay->BookingType;
                    }
                    if (!empty($rs->Discount)) {
                        $rs->DiscountVariation = $rs->Discount;
                    }
                    $rs->SupplementVariation = null;
                    if (!empty($rs->Supplement)) {
                        $rs->SupplementVariation = $rs->Supplement;
                    }
                    $allVar = json_decode($rs->AllVariationsString);
                    $rs->Variations = array();
                    $rs->SimpleDiscountIds = array();
                    if (!empty($allVar)) {
                        foreach ($allVar as $currVar) {
                            $rs->Variations[] = $currVar;
                            $rs->SimpleDiscountIds[] = $currVar->VariationPlanId;
                            /*if(empty($currVar->IsExclusive)){
                            		}*/
                        }
                    }
                }
                $newAllStays[] = $rs;
            }
            $criteoConfig = BFCHelper::getCriteoConfiguration(3, $merchants);
            if (isset($criteoConfig) && isset($criteoConfig->enabled) && $criteoConfig->enabled && count($criteoConfig->merchants) > 0) {
                $document->addScript('//static.criteo.net/js/ld/ld.js');
                $document->addScriptDeclaration('window.criteo_q = window.criteo_q || []; 
				window.criteo_q.push( 
					{ event: "setAccount", account: ' . $criteoConfig->campaignid . '}, 
					{ event: "setSiteType", type: "d" }, 
					{ event: "setEmail", email: "" }, 
					{ event: "viewBasket", item: [{ id: "' . $criteoConfig->merchants[0] . '", price: ' . $total . ', quantity: 1 }] }
				);');
            }
            BFCHelper::setState($totalWithVariation, 'total', 'resource');
            $this->assignRef('stay', $stay);
            $this->assignRef('total', $total);
            $this->assignRef('totalDiscounted', $totalDiscounted);
            $this->assignRef('totalWithVariation', $totalWithVariation);
            $this->assignRef('selVariationId', $selVariationId);
            $this->assignRef('selVariation', $selVariation);
            $this->assignRef('resstays', $newAllStays);
            //				$this->assignRef('allstays', $allratePlans);
            //$Extras =  null;		//$this->get('ExtrasFromService');
            $PriceTypes = $model->getPriceTypesFromServiceRatePlan($allstays);
            //$this->get('PriceTypesFromServiceRatePlan');
            $MerchantBookingTypes = $this->get('MerchantBookingTypesFromService');
            $this->assignRef('Extras', $Extras);
            $this->assignRef('PriceTypes', $PriceTypes);
            $this->assignRef('MerchantBookingTypes', $MerchantBookingTypes);
        }
        //end layout "form"
        //$this->setBreadcrumb($item, 'resources');
        $this->setBreadcrumb($item, 'resources', $language);
        $this->assignRef('criteoConfig', $criteoConfig);
        parent::display($tpl, true);
    }
コード例 #3
0
 function display($tpl = null, $preparecontent = false)
 {
     $config = JComponentHelper::getParams('com_bookingforconnector');
     $document = JFactory::getDocument();
     $language = $document->getLanguage();
     $app = JFactory::getApplication();
     $sitename = $app->get('sitename');
     $this->assignRef('document', $document);
     $this->assignRef('language', $language);
     $this->assignRef('config', $config);
     $this->assignRef('sitename', $sitename);
     $params = null;
     $Extras = null;
     //$this->get('ExtrasFromService');
     $PriceTypes = null;
     //$this->get('PriceTypesFromService');
     $additionalJsScripts = "";
     $model = $this->getModel();
     BookingForConnectorViewResourceBase::basedisplay($tpl);
     $item = $this->item;
     $params = $this->params;
     $item->Availability = 0;
     $allstays = $model->getStay($language, isset($this->params['refreshcalc']));
     //$model->getResourceRatePlanFacilieties($item, $stay);
     $stay = null;
     //		echo "<pre>pricetype";
     //		echo $this->params['pricetype'];
     //		echo "</pre>";
     if (is_array($allstays) && (!isset($this->params['pricetype']) || empty($this->params['pricetype']))) {
         $selStay = array_values(array_filter($allstays, function ($st) {
             $resAvailable = 0;
             if (!empty($st->SuggestedStay)) {
                 $resAvailable = $st->SuggestedStay->Available;
             }
             return $resAvailable && $st->TotalAmount > 0;
         }));
         if (count($selStay) > 0) {
             $this->params['pricetype'] = $selStay[0]->RatePlanId;
         }
     }
     if (is_array($allstays) && isset($this->params['pricetype'])) {
         $selStay = array_values(array_filter($allstays, function ($st) {
             return $this->params['pricetype'] == $st->RatePlanId;
         }));
         if (count($selStay) > 0) {
             $stay = $selStay[0];
         }
         if (!empty($stay)) {
             $item->Availability = $stay->SuggestedStay->Availability;
         }
     }
     if (isset($stay->BookingTypes)) {
         $item->MerchantBookingTypes = $stay->BookingTypes;
     }
     if (isset($stay->SelectablePrices)) {
         $Extras = $stay->SelectablePrices;
     }
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     // saves state for accessing from other plugins and components (RSForms specifically) from now on
     BFCHelper::setState(array('resourceId' => $params['resourceId'], 'checkin' => $params['checkin']->format('d/m/Y'), 'checkout' => $params['checkout']->format('d/m/Y'), 'duration' => $params['duration'], 'paxages' => $params['paxages'], 'extras' => $params['extras'], 'packages' => $params['packages'], 'pricetype' => $params['pricetype'], 'rateplanId' => $params['rateplanId'], 'state' => $params['state'], 'variationPlanId' => $params['variationPlanId'], 'gotCalculator' => false), 'stayrequest', 'resource');
     if (!empty($item->MerchantBookingTypes)) {
         BFCHelper::setState($item->MerchantBookingTypes, 'bookingTypes', 'resource');
     }
     BFCHelper::setState($stay, 'stay', 'resource');
     BFCHelper::setState($item->Merchant, 'merchant', 'resource');
     /* creating totals */
     $total = 0;
     $totalDiscounted = 0;
     $totalWithVariation = 0;
     if (!empty($stay->TotalPrice)) {
         $total = $stay->TotalPrice;
     }
     if (!empty($stay->DiscountedPrice)) {
         $totalDiscounted = $stay->DiscountedPrice;
     }
     $totalWithVariation = $totalDiscounted;
     if (!empty($stay)) {
         //TODO: cosa farne dei pacchetti nel calcolo singolo della risorsa?
         /*
         if(!empty($stay->CalculatedPackages)){
         	foreach ($stay->CalculatedPackages as $pkg) {
         		//$totalDiscounted = $totalDiscounted + $pkg->SuggestedStay->DiscountedPrice;
         		//$total = $total + $pkg->SuggestedStay->DiscountedPrice;
         		
         		
         		$totalDiscounted = $totalDiscounted + $pkg->DiscountedAmount;
         		$total = $total + $pkg->DiscountedAmount;
         	}
         }
         */
         if (!empty($stay->Variations)) {
             foreach ($stay->Variations as $var) {
                 $var->TotalPackagesAmount = 0;
                 /*
                 foreach ($stay->CalculatedPackages as $pkg) {
                 	foreach($pkg->Variations as $pvar) {
                 		if($pvar->VariationPlanId == $var->VariationPlanId){
                 			$var->TotalPackagesAmount +=  $pvar->TotalAmount;
                 			break;
                 		}
                 	}
                 }
                 */
             }
         }
     }
     $totalWithVariation = $totalDiscounted + 0;
     // force int cast
     $selVariationId = $params['variationPlanId'];
     if ($selVariationId != '') {
         foreach ($stay->Variations as $variation) {
             if ($variation->VariationPlanId == $selVariationId) {
                 $totalWithVariation += $variation->TotalAmount + $variation->TotalPackagesAmount;
                 break;
             }
         }
     }
     $newAllStays = array();
     foreach ($allstays as $rs) {
         //$rs = $ratePlanStay;
         $rs->MrcCategoryName = $item->MerchantCategoryName;
         if ($rs != null) {
             $rs->CalculatedPricesDetails = json_decode($rs->CalculatedPricesString);
             $rs->SelectablePrices = json_decode($rs->CalculablePricesString);
             $rs->CalculatedPackages = json_decode($rs->PackagesString);
             $rs->DiscountVariation = null;
             if (!empty($rs->Discount)) {
                 $rs->DiscountVariation = $rs->Discount;
             }
             $rs->BookingType = 0;
             if (!empty($rs->SuggestedStay)) {
                 $rs->BookingType = $rs->SuggestedStay->BookingType;
             }
             $rs->SupplementVariation = null;
             if (!empty($rs->Supplement)) {
                 $rs->SupplementVariation = $rs->Supplement;
             }
             $allVar = json_decode($rs->AllVariationsString);
             $rs->Variations = [];
             $rs->SimpleDiscountIds = [];
             if (!empty($allVar)) {
                 foreach ($allVar as $currVar) {
                     $rs->Variations[] = $currVar;
                     $rs->SimpleDiscountIds[] = $currVar->VariationPlanId;
                     /*if(empty($currVar->IsExclusive)){
                     		}*/
                 }
             }
         }
         $newAllStays[] = $rs;
     }
     $toExclude = array();
     $toExclude[] = $item->ResourceId;
     $parentId = isset($item->CondominiumId) ? $item->CondominiumId : null;
     $alternatRes = $model->getSearchResults(0, 5, null, null, $item->Merchant->MerchantId, $parentId, false, false, $toExclude);
     if (!isset($alternatRes)) {
         $alternatRes = array();
     }
     $allratePlans = array();
     foreach ($alternatRes as $ratePlanStay) {
         $rs = $ratePlanStay->RatePlan;
         $rs->ResourceId = $ratePlanStay->ResourceId;
         $rs->ResName = $ratePlanStay->ResName;
         $rs->MrcName = $ratePlanStay->MrcName;
         $rs->MinCapacityPaxes = $ratePlanStay->MinPaxes;
         $rs->MaxCapacityPaxes = $ratePlanStay->MaxPaxes;
         $rs->Availability = $ratePlanStay->Availability;
         $rs->MrcCategoryName = $item->MerchantCategoryName;
         $rs->ImageUrl = $ratePlanStay->ImageUrl;
         if ($ratePlanStay != null) {
             $rs->CalculatedPricesDetails = json_decode($rs->CalculatedPricesString);
             $rs->SelectablePrices = json_decode($rs->CalculablePricesString);
             $rs->CalculatedPackages = json_decode($rs->PackagesString);
             $rs->DiscountVariation = null;
             $rs->BookingType = 0;
             if (!empty($rs->SuggestedStay)) {
                 $rs->BookingType = $rs->SuggestedStay->BookingType;
             }
             if (!empty($rs->Discount)) {
                 $rs->DiscountVariation = $rs->Discount;
             }
             $rs->SupplementVariation = null;
             if (!empty($rs->Supplement)) {
                 $rs->SupplementVariation = $rs->Supplement;
             }
             $allVar = json_decode($rs->AllVariationsString);
             $rs->Variations = [];
             $rs->SimpleDiscountIds = [];
             foreach ($allVar as $currVar) {
                 $rs->Variations[] = $currVar;
                 $rs->SimpleDiscountIds[] = $currVar->VariationPlanId;
                 /*
                 if(empty($currVar->IsExclusive)){
                 }
                 */
             }
         }
         $allratePlans[] = $rs;
     }
     function cmp($a, $b)
     {
         return $a->SortOrder - $b->SortOrder;
     }
     usort($allratePlans, "cmp");
     $merchants = array();
     $merchants[] = $item->MerchantId;
     $criteoConfig = BFCHelper::getCriteoConfiguration(2, $merchants);
     BFCHelper::setState($totalWithVariation, 'total', 'resource');
     $this->assignRef('stay', $stay);
     $this->assignRef('resstays', $newAllStays);
     $this->assignRef('allstays', $allratePlans);
     $this->assignRef('total', $total);
     $this->assignRef('totalDiscounted', $totalDiscounted);
     $this->assignRef('totalWithVariation', $totalWithVariation);
     $analyticsEnabled = $this->checkAnalytics("") && $config->get('eecenabled', 0) == 1;
     $this->assignRef('analyticsEnabled', $analyticsEnabled);
     $this->assignRef('criteoConfig', $criteoConfig);
     //$Extras =  null;		//$this->get('ExtrasFromService');
     $PriceTypes = $model->getPriceTypesFromServiceRatePlan($allstays);
     //$this->get('PriceTypesFromServiceRatePlan');
     $MerchantBookingTypes = $this->get('MerchantBookingTypesFromService');
     $this->assignRef('Extras', $Extras);
     $this->assignRef('PriceTypes', $PriceTypes);
     $this->assignRef('MerchantBookingTypes', $MerchantBookingTypes);
     $this->setLayout('calc');
     parent::display($tpl, $preparecontent);
 }