function basedisplay($tpl = NULL, $preparecontent = false)
 {
     // Initialise variables
     $state = $this->get('State');
     //$item		= $this->get('Item');
     //$document 	= JFactory::getDocument();
     //$language 	= $document->getLanguage();
     //$document->addScript('//jquery-ui.googlecode.com/svn/tags/legacy/ui/i18n/ui.datepicker-' . substr($language,0,2) . '.js');
     //$document->addStyleSheet('components/com_bookingforconnector/assets/css/resource.css');
     $params = $state->params;
     // se è un pdf non elaboro tutte le richieste
     if ($this->getLayout() != 'pdf') {
         // Check for errors.
         if (count($errors = $this->get('Errors'))) {
             JError::raiseWarning(500, implode("\n", $errors));
             return false;
         }
         if (isset($item->Merchant)) {
             BFCHelper::setState($item->Merchant, 'merchant', 'resource');
         }
         /* creating totals */
     }
     $this->assignRef('state', $state);
     $this->assignRef('params', $params);
     //$this->assignRef('item', $item);
 }
Ejemplo n.º 2
0
 function display($tpl = null, $preparecontent = false)
 {
     BookingForConnectorViewOnSellUnitBase::basedisplay($tpl);
     $item = $this->get('Item');
     $document = JFactory::getDocument();
     $language = $document->getLanguage();
     $config = JComponentHelper::getParams('com_bookingforconnector');
     BFCHelper::setState($item, 'onsellunit', 'onsellunit');
     //		$document->addStyleSheet('components/com_bookingforconnector/assets/css/resource.css');
     // add stylesheet
     JHTML::stylesheet('components/com_bookingforconnector/assets/css/bookingfor.css');
     JHTML::stylesheet('components/com_bookingforconnector/assets/css/bookingfor-responsive.css');
     $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');
     if ($this->checkAnalytics("Sales Resources Page") && $config->get('eecenabled', 0) == 1) {
         $obj = new stdClass();
         $obj->id = "" . $item->ResourceId . " - Sales Resource";
         $obj->name = $item->Name;
         $obj->category = $item->MerchantCategoryName;
         $obj->brand = $item->MerchantName;
         $obj->variant = 'NS';
         $document->addScriptDeclaration('callAnalyticsEEc("addProduct", [' . json_encode($obj) . '], "item");');
     }
     $this->assignRef('document', $document);
     $this->assignRef('language', $language);
     $this->assignRef('item', $item);
     $this->assignRef('config', $config);
     //		$item		= $this->get('Item');
     //$item->Name = $item->nome;
     //$this->setBreadcrumb($item, 'resources');
     $this->setBreadcrumb($item, 'onsellunits', $language);
     parent::display($tpl, true);
 }
Ejemplo n.º 3
0
 function display($tpl = null)
 {
     BookingForConnectorViewCondominiumBase::basedisplay($tpl);
     $state = $this->get('State');
     $item = $this->get('Item');
     $document = JFactory::getDocument();
     $language = $document->getLanguage();
     $isFromSearch = false;
     BFCHelper::setState($item, 'condominium', 'condominium');
     if (JRequest::getString('layout') == 'resourcesajax') {
         $items = $this->get('ItemsResourcesAjax');
     } else {
         //if (JRequest::getString('layout') == 'resources') {
         if (JRequest::getString('search') == '1') {
             $isFromSearch = true;
             $items = $this->get('ItemsSearch');
             $pagination = $this->get('Pagination');
         } else {
             $items = $this->get('Items');
             $pagination = $this->get('Pagination');
         }
     }
     //		$document->addStyleSheet(COM_BOOKINGFORCONNECTOR_SCRIPT_PATH.'assets/css/resource.css');
     // add stylesheet
     $document->addStylesheet(COM_BOOKINGFORCONNECTOR_SCRIPT_PATH . 'assets/css/bookingfor.css');
     $document->addStylesheet(COM_BOOKINGFORCONNECTOR_SCRIPT_PATH . 'assets/css/bookingfor-responsive.css');
     $document->addScript(COM_BOOKINGFORCONNECTOR_SCRIPT_PATH . 'assets/js/jquery.form.js');
     $document->addScript(COM_BOOKINGFORCONNECTOR_SCRIPT_PATH . 'assets/js/jquery.blockUI.js');
     $document->addScript(COM_BOOKINGFORCONNECTOR_SCRIPT_PATH . 'assets/js/bf.js');
     $this->assignRef('document', $document);
     $this->assignRef('language', $language);
     $this->assignRef('item', $item);
     $this->assignRef('items', $items);
     $this->assignRef('pagination', $pagination);
     $this->assignRef('isFromSearch', $isFromSearch);
     //		$item		= $this->get('Item');
     //$item->Name = $item->nome;
     //$this->setBreadcrumb($item, 'resources');
     $this->setBreadcrumb($item, 'condominiums', $language);
     parent::display($tpl);
 }
Ejemplo n.º 4
0
 function display($tpl = null, $preparecontent = false)
 {
     BookingForConnectorViewOnSellUnitBase::basedisplay($tpl);
     $item = $this->get('Item');
     $document = JFactory::getDocument();
     $language = $document->getLanguage();
     BFCHelper::setState($item, 'onsellunit', 'onsellunit');
     //		$document->addStyleSheet('components/com_bookingforconnector/assets/css/resource.css');
     // add stylesheet
     JHTML::stylesheet('components/com_bookingforconnector/assets/css/bookingfor.css');
     JHTML::stylesheet('components/com_bookingforconnector/assets/css/bookingfor-responsive.css');
     $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);
     //		$item		= $this->get('Item');
     //$item->Name = $item->nome;
     //$this->setBreadcrumb($item, 'resources');
     $this->setBreadcrumb($item, 'onsellunits', $language);
     parent::display($tpl, true);
 }
//$areamin;
//$areamax;
//$services="";
//if (count($resource->Services) > 0){
//	$tmpservices = array();
//	foreach ($resource->Services as $service){
//		$tmpservices[] = BFCHelper::getLanguage($service->Name, $this->language);
//	}
//	$services = implode(', ',$tmpservices);
//}
//$resource->Price
/**** for search similar *****/
//add counter
$model = $this->getModel();
$retCounter = $model->setCounterByResourceId($resource->ResourceId, "details", $this->language);
BFCHelper::setState($resource->Merchant, 'merchant', 'merchant');
//$test = BFCHelper::getState('merchant', 'merchant');
//
//echo "<pre>";
//echo print_r($test);
//echo "</pre>";
?>
<form action="<?php 
echo $formAction;
?>
" method="post" id="searchformsimilaronsellunit">
	<input type="hidden" value="<?php 
echo uniqid('', true);
?>
" name="searchid" />
	<input type="hidden" value="1" name="newsearch" />
Ejemplo n.º 6
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);
    }
Ejemplo n.º 7
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);
 }
Ejemplo n.º 8
0
 function display($tpl = null, $preparecontent = false)
 {
     BookingForConnectorViewCondominiumBase::basedisplay($tpl);
     $state = $this->get('State');
     $item = $this->get('Item');
     $document = JFactory::getDocument();
     $language = $document->getLanguage();
     $isFromSearch = false;
     $app = JFactory::getApplication();
     $sitename = $app->get('sitename');
     $config = JComponentHelper::getParams('com_bookingforconnector');
     $params = $this->params;
     BFCHelper::setState($item, 'condominium', 'condominium');
     $allobjects = array();
     if (JRequest::getString('layout') == 'resourcesajax') {
         $items = $this->get('ItemsResourcesAjax');
     } else {
         //if (JRequest::getString('layout') == 'resources') {
         if (JRequest::getString('search') == '1') {
             $isFromSearch = true;
             $items = $this->get('ItemsSearch');
             $pagination = $this->get('Pagination');
         } else {
             $items = $this->get('Items');
             $pagination = $this->get('Pagination');
         }
         if (!empty($items)) {
             foreach ($items as $key => $value) {
                 $obj = new stdClass();
                 $obj->id = "" . $value->ResourceId . " - Resource";
                 $obj->name = $value->ResName;
                 $obj->category = $value->DefaultLangMrcCategoryName;
                 $obj->brand = $value->MrcName;
                 $obj->position = $key;
                 $allobjects[] = $obj;
             }
         }
     }
     $analyticsEnabled = $this->checkAnalytics("Condominium page");
     if ($analyticsEnabled && $config->get('eecenabled', 0) == 1) {
         $obj = new stdClass();
         $obj->id = "" . $item->CondominiumId . " - Resource Group";
         $obj->name = $item->Name;
         $obj->category = $item->MrcCategoryName;
         $obj->brand = $item->MerchantName;
         $obj->variant = 'NS';
         $document->addScriptDeclaration('callAnalyticsEEc("addProduct", [' . json_encode($obj) . '], "item");');
         $document->addScriptDeclaration('callAnalyticsEEc("addImpression", ' . json_encode($allobjects) . ', "list", "Condominium Resources Search List");');
     }
     //		$document->addStyleSheet('components/com_bookingforconnector/assets/css/resource.css');
     // add stylesheet
     $document->addStylesheet('components/com_bookingforconnector/assets/css/bookingfor.css');
     $document->addStylesheet('components/com_bookingforconnector/assets/css/bookingfor-responsive.css');
     $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('items', $items);
     $this->assignRef('pagination', $pagination);
     $this->assignRef('isFromSearch', $isFromSearch);
     $this->assignRef('sitename', $sitename);
     $this->assignRef('config', $config);
     $this->assignRef('analyticsEnabled', $analyticsEnabled);
     $this->setBreadcrumb($item, 'condominiums', $language);
     parent::display($tpl);
 }
Ejemplo n.º 9
0
    function display($tpl = null, $preparecontent = false)
    {
        // Initialise variables
        $state = $this->get('State');
        $item = $this->get('Item');
        $document = JFactory::getDocument();
        $language = $document->getLanguage();
        $params = $state->params;
        $app = JFactory::getApplication();
        $sitename = $app->get('sitename');
        $config = JComponentHelper::getParams('com_bookingforconnector');
        $orderid = 0;
        // add stylesheet
        JHTML::stylesheet('components/com_bookingforconnector/assets/css/font-awesome.css');
        JHTML::stylesheet('components/com_bookingforconnector/assets/bootstrap/css/bootstrap.css');
        $document->addStyleSheet('components/com_bookingforconnector/assets/css/bookingfor.css');
        $document->addStyleSheet('components/com_bookingforconnector/assets/css/bookingfor-responsive.css');
        $document->addStyleSheet('//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css');
        $document->addScript('//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js');
        $document->addScript('components/com_bookingforconnector/assets/js/jquery.shorten.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.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');
        }
        $checkAnalytics = false;
        if (!isset($item)) {
            header("Location: " . JURI::root());
            $app->close();
        }
        if ($item->HasResources) {
            if (JRequest::getString('layout') == 'resourcesajax') {
                $items = $this->get('ItemsResourcesAjax');
            }
        }
        if ($item->HasResources) {
            if (JRequest::getString('layout') == 'resources') {
                $items = $this->get('Items');
                $checkAnalytics = true;
                $pagination = $this->get('Pagination');
            }
        }
        if (JRequest::getString('layout') == 'packages') {
            $items = $this->get('ItemsPackages');
            $checkAnalytics = true;
            $pagination = $this->get('PaginationPackages');
        }
        if (JRequest::getString('layout') == 'package') {
            $items = $this->get('Package');
            $checkAnalytics = true;
            BFCHelper::setState($items, 'packages', 'merchant');
        }
        if (JRequest::getString('layout') == 'offers') {
            $items = $this->get('ItemsOffer');
            $checkAnalytics = true;
            $pagination = $this->get('PaginationOffers');
        }
        if (JRequest::getString('layout') == 'offer') {
            $items = $this->get('Offer');
            $checkAnalytics = true;
            BFCHelper::setState($items, 'offers', 'merchant');
        }
        if (JRequest::getString('layout') == 'onsellunits') {
            $items = $this->get('ItemsOnSellUnit');
            $checkAnalytics = true;
            $pagination = $this->get('PaginationOnSellUnits');
        }
        if (JRequest::getString('layout') == 'onsellunit') {
            $items = array($this->get('OnSellUnit'));
            $checkAnalytics = true;
            BFCHelper::setState($items, 'onsellunits', 'merchant');
        }
        if (JRequest::getString('layout') == 'ratings') {
            $items = $this->get('ItemsRating');
            $pagination = $this->get('PaginationRatings');
            // load scripts
            $document->addScript('components/com_bookingforconnector/assets/js/jquery.expander.min.js');
        }
        if (JRequest::getString('layout', 'default') == 'default') {
            $checkAnalytics = true;
        }
        if (JRequest::getString('layout', 'default') == 'thanks') {
            $checkAnalytics = true;
        }
        if (JRequest::getString('layout') == 'rating') {
            // load css
            $document->addStyleSheet('components/com_bookingforconnector/assets/css/jquery.rating.css');
            $document->addStyleSheet('components/com_bookingforconnector/assets/css/jquery.validate.css');
            // load scripts
            $document->addScript('components/com_bookingforconnector/assets/js/jquery.rating.pack.js');
            $document->addScript('components/com_bookingforconnector/assets/js/jquery.form.js');
            $document->addScript('components/com_bookingforconnector/assets/js/jquery.blockUI.js');
        }
        $listName = "";
        if ($checkAnalytics) {
            $checkAnalytics = false;
            $itemType = 0;
            $totalItems = array();
            $type = "";
            switch (JRequest::getString('layout', 'default')) {
                case "resources":
                    $listName = "Resources List";
                    $type = "Resource";
                    $itemType = 1;
                    foreach ($items as $key => $value) {
                        $obj = new stdClass();
                        $obj->Id = $value->ResourceId;
                        $obj->Name = $value->Name;
                        $totalItems[] = $obj;
                    }
                    break;
                case "packages":
                    $listName = "Packages List";
                    $type = "Package";
                    $itemType = 1;
                    foreach ($items as $key => $value) {
                        $obj = new stdClass();
                        $obj->Id = $value->PackageId;
                        $obj->Name = $value->Name;
                        $totalItems[] = $obj;
                    }
                    break;
                case "offers":
                    $listName = "Offers List";
                    $type = "Offer";
                    $itemType = 1;
                    foreach ($items as $key => $value) {
                        $obj = new stdClass();
                        $obj->Id = $value->VariationPlanId;
                        $obj->Name = $value->Name;
                        $totalItems[] = $obj;
                    }
                    break;
                case "onsellunits":
                    $listName = "Sales Resources Merchant List";
                    $type = "Sales Resource";
                    $itemType = 1;
                    foreach ($items as $key => $value) {
                        $obj = new stdClass();
                        $obj->Id = $value->ResourceId;
                        $obj->Name = $value->Name;
                        $totalItems[] = $obj;
                    }
                    break;
                case "package":
                    $listName = "Packages Page";
                    $type = "Package";
                    $itemType = 0;
                    $obj = new stdClass();
                    $obj->Id = $items->PackageId;
                    $obj->Name = $items->Name;
                    $totalItems[] = $obj;
                    break;
                case "offer":
                    $listName = "Offers Page";
                    $type = "Offer";
                    $itemType = 0;
                    $obj = new stdClass();
                    $obj->Id = $items->VariationPlanId;
                    $obj->Name = $items->Name;
                    $totalItems[] = $obj;
                    break;
                case "onsellunit":
                    $listName = "Sales Resources Merchant Page";
                    $type = "Sales Resource";
                    $itemType = 0;
                    $obj = new stdClass();
                    $obj->Id = $items->ResourceId;
                    $obj->Name = $items->Name;
                    $totalItems[] = $obj;
                    break;
                case "thanks":
                    $itemType = 2;
                    break;
                case "default":
                    $listName = "Merchants Page";
                    $type = "Merchant";
                    $itemType = 0;
                    $obj = new stdClass();
                    $obj->Id = $item->MerchantId;
                    $obj->Name = $item->Name;
                    $totalItems[] = $obj;
                    break;
            }
            if ($this->checkAnalytics($listName) && $config->get('eecenabled', 0) == 1) {
                $checkAnalytics = true;
                switch ($itemType) {
                    case 0:
                        $value = $totalItems[0];
                        $obj = new stdClass();
                        $obj->id = "" . $value->Id . " - " . $type;
                        $obj->name = $value->Name;
                        $obj->category = $item->MainCategoryName;
                        $obj->brand = $item->Name;
                        $obj->variant = 'NS';
                        $document->addScriptDeclaration('callAnalyticsEEc("addProduct", [' . json_encode($obj) . '], "item");');
                        break;
                    case 1:
                        $allobjects = array();
                        foreach ($totalItems as $key => $value) {
                            $obj = new stdClass();
                            $obj->id = "" . $value->Id . " - " . $type;
                            $obj->name = $value->Name;
                            $obj->category = $item->MainCategoryName;
                            $obj->brand = $item->Name;
                            $obj->position = $key;
                            $allobjects[] = $obj;
                        }
                        $document->addScriptDeclaration('callAnalyticsEEc("addImpression", ' . json_encode($allobjects) . ', "list");');
                        break;
                    case 2:
                        $orderid = JRequest::getString('orderid');
                        if (!empty($orderid)) {
                            $order = BFCHelper::getSingleOrderFromService($orderid);
                            $purchaseObject = new stdClass();
                            $purchaseObject->id = "" . $order->OrderId;
                            $purchaseObject->affiliation = "" . $order->Label;
                            $purchaseObject->revenue = $order->TotalAmount;
                            $purchaseObject->tax = 0.0;
                            $allobjects = array();
                            $allservices = array();
                            $svcTotal = 0;
                            if (!empty($order->NotesData) && !empty(simpledom_load_string($order->NotesData)->xpath("//price"))) {
                                $allservices = array_values(array_filter(simpledom_load_string($order->NotesData)->xpath("//price"), function ($prc) {
                                    return (string) $prc->tag == "extrarequested";
                                }));
                                if (!empty($allservices)) {
                                    foreach ($allservices as $svc) {
                                        $svcObj = new stdClass();
                                        $svcObj->id = "" . (int) $svc->priceId . " - Service";
                                        $svcObj->name = (string) $svc->name;
                                        $svcObj->category = "Services";
                                        $svcObj->brand = $item->Name;
                                        $svcObj->variant = (string) BFCHelper::getItem($order->NotesData, 'nome', 'unita');
                                        $svcObj->price = round((double) $svc->discountedamount / (int) $svc->quantity, 2);
                                        $svcObj->quantity = (int) $svc->quantity;
                                        $allobjects[] = $svcObj;
                                        $svcTotal += (double) $svc->discountedamount;
                                    }
                                }
                                $mainObj = new stdClass();
                                $mainObj->id = "" . $order->RequestedItemId . " - Resource";
                                $mainObj->name = (string) BFCHelper::getItem($order->NotesData, 'nome', 'unita');
                                $mainObj->variant = (string) BFCHelper::getItem($order->NotesData, 'refid', 'rateplan');
                                $mainObj->category = $item->MainCategoryName;
                                $mainObj->brand = $item->Name;
                                $mainObj->price = $order->TotalAmount - $svcTotal;
                                $mainObj->quantity = 1;
                                $allobjects[] = $mainObj;
                                $document->addScriptDeclaration('callAnalyticsEEc("addProduct", ' . json_encode($allobjects) . ', "purchase", "", ' . json_encode($purchaseObject) . ');');
                            }
                        }
                        break;
                }
            }
        }
        // Check for errors.
        if (count($errors = $this->get('Errors'))) {
            JError::raiseWarning(500, implode("\n", $errors));
            return false;
        }
        $layout = JRequest::getString('layout', "default");
        if ($layout == "thanks" || $layout == "default") {
            $merchants = array();
            $merchants[] = $item->MerchantId;
            if ($layout == "thanks") {
                $orderid = JRequest::getString('orderid');
                $criteoConfig = BFCHelper::getCriteoConfiguration(4, $merchants, $orderid);
            } else {
                if ($layout == "") {
                    $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');
                if ($layout == "thanks") {
                    $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: "trackTransaction", id: "' . $criteoConfig->transactionid . '",  item: [' . json_encode($criteoConfig->orderdetails) . '] }
					);');
                } else {
                    if ($layout == "default") {
                        $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: "viewItem", item: "' . $criteoConfig->merchants[0] . '" }
					);');
                    }
                }
            }
        }
        BFCHelper::setState($item, 'merchant', 'merchant');
        $this->setBreadcrumb($item, JRequest::getString('layout'));
        $this->assignRef('params', $params);
        $this->assignRef('item', $item);
        $this->assignRef('items', $items);
        $this->assignRef('pagination', $pagination);
        $this->assignRef('document', $document);
        $this->assignRef('language', $language);
        $this->assignRef('sitename', $sitename);
        $this->assignRef('config', $config);
        $this->assignRef('state', $state);
        $this->assignRef('checkAnalytics', $checkAnalytics);
        $this->assignRef('analyticsListName', $listName);
        // Display the view
        parent::display($tpl, true);
    }
Ejemplo n.º 10
0
 function display($tpl = null, $preparecontent = false)
 {
     // Initialise variables
     $state = $this->get('State');
     $item = $this->get('Item');
     $document = JFactory::getDocument();
     $language = $document->getLanguage();
     $params = $state->params;
     $app = JFactory::getApplication();
     $sitename = $app->get('sitename');
     $config = JComponentHelper::getParams('com_bookingforconnector');
     // add stylesheet
     $document->addStyleSheet('components/com_bookingforconnector/assets/css/bookingfor.css');
     $document->addStyleSheet('components/com_bookingforconnector/assets/css/bookingfor-responsive.css');
     $document->addStyleSheet('//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css');
     $document->addScript('//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js');
     $document->addScript('components/com_bookingforconnector/assets/js/jquery.shorten.js');
     $document->addScript('components/com_bookingforconnector/assets/js/jquery.validate.min.js');
     $document->addScript('components/com_bookingforconnector/assets/js/additional-methods.min.js');
     if (!isset($item)) {
         header("Location: " . JURI::root());
         $app->close();
     }
     if ($item->HasResources) {
         if (JRequest::getString('layout') == 'resourcesajax') {
             $items = $this->get('ItemsResourcesAjax');
         }
     }
     if ($item->HasResources) {
         if (JRequest::getString('layout') == 'resources') {
             $items = $this->get('Items');
             $pagination = $this->get('Pagination');
         }
     }
     if (JRequest::getString('layout') == 'offers') {
         $items = $this->get('ItemsOffer');
         $pagination = $this->get('Pagination');
     }
     if (JRequest::getString('layout') == 'offer') {
         $items = array($this->get('Offer'));
         BFCHelper::setState($items, 'offers', 'merchant');
     }
     if (JRequest::getString('layout') == 'onsellunits') {
         $items = $this->get('ItemsOnSellUnit');
         $pagination = $this->get('PaginationOnSellUnits');
     }
     if (JRequest::getString('layout') == 'onsellunit') {
         $items = array($this->get('OnSellUnit'));
         BFCHelper::setState($items, 'onsellunits', 'merchant');
     }
     if (JRequest::getString('layout') == 'ratings') {
         $items = $this->get('ItemsRating');
         $pagination = $this->get('PaginationRatings');
         // load scripts
         $document->addScript('components/com_bookingforconnector/assets/js/jquery.expander.min.js');
     }
     if (JRequest::getString('layout') == 'rating') {
         // load css
         $document->addStyleSheet('components/com_bookingforconnector/assets/css/jquery.rating.css');
         $document->addStyleSheet('components/com_bookingforconnector/assets/css/jquery.validate.css');
         // load scripts
         $document->addScript('components/com_bookingforconnector/assets/js/jquery.rating.pack.js');
         $document->addScript('components/com_bookingforconnector/assets/js/jquery.form.js');
         $document->addScript('components/com_bookingforconnector/assets/js/jquery.blockUI.js');
     }
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     BFCHelper::setState($item, 'merchant', 'merchant');
     $this->setBreadcrumb($item, JRequest::getString('layout'));
     $this->assignRef('params', $params);
     $this->assignRef('item', $item);
     $this->assignRef('items', $items);
     $this->assignRef('pagination', $pagination);
     $this->assignRef('document', $document);
     $this->assignRef('language', $language);
     $this->assignRef('sitename', $sitename);
     $this->assignRef('config', $config);
     // Display the view
     parent::display($tpl, true);
 }
Ejemplo n.º 11
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);
 }