function display($tpl = null, $preparecontent = false) { $document = JFactory::getDocument(); $language = $document->getLanguage(); $config = JComponentHelper::getParams('com_bookingforconnector'); $app = JFactory::getApplication(); // 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'); // load scripts $document->addScript('//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js'); $document->addScript('components/com_bookingforconnector/assets/js/bf.js'); $document->addScript('components/com_bookingforconnector/assets/js/jquery.xml2json.js'); $document->addScript('components/com_bookingforconnector/assets/js/jquery.shorten.js'); // Initialise variables $state = $this->get('State'); $params = $state->params; $items = $this->get('Items'); $pagination = $this->get('Pagination'); $sortColumn = $state->get('list.ordering'); $sortDirection = $state->get('list.direction'); $startswith = $params['startswith']; $searchseed = $params['searchseed']; // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } $merchantsCriteo = isset($items) && !empty($items) ? array_unique(array_map(function ($a) { return $a->MerchantId; }, $items)) : array(); $criteoConfig = BFCHelper::getCriteoConfiguration(1, $merchantsCriteo); 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: "viewList", item: ' . json_encode($criteoConfig->merchants) . ' } );'); } $analyticsEnabled = count($items) > 0 && $this->checkAnalytics("Merchants List") && $config->get('eecenabled', 0) == 1; $pagination->setAdditionalUrlParam("filter_order", $sortColumn); $pagination->setAdditionalUrlParam("filter_order_Dir", $sortDirection); $pagination->setAdditionalUrlParam("startswith", $startswith); $pagination->setAdditionalUrlParam("searchseed", $searchseed); $this->assignRef('state', $state); $this->assignRef('params', $params); $this->assignRef('items', $items); $this->assignRef('pagination', $pagination); $this->assignRef('language', $language); $this->assignRef('config', $config); $this->assignRef('analyticsEnabled', $analyticsEnabled); // Display the view parent::display($tpl); }
function display($tpl = null, $preparecontent = false) { $config = JComponentHelper::getParams('com_bookingforconnector'); $document = JFactory::getDocument(); $language = $document->getLanguage(); $app = JFactory::getApplication(); $sitename = $app->get('sitename'); $item = $this->get('Item'); $state = $this->get('State'); $params = $state->params; $this->assignRef('document', $document); $this->assignRef('language', $language); $this->assignRef('config', $config); $this->assignRef('sitename', $sitename); $this->assignRef('item', $item); // $params = null; // JModelLegacy::addIncludePath(JPATH_ROOT. DIRECTORY_SEPARATOR .'components' . DIRECTORY_SEPARATOR . 'com_bookingforconnector'. DIRECTORY_SEPARATOR . 'models', 'BookingForConnectorModel'); // $model = JModelLegacy::getInstance('Resource', 'BookingForConnectorModel'); // // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } $overrideFilters = array(); $toExclude = array(); $requiredOffers = array(); // $parentId = isset($item->CondominiumId) ? $item->CondominiumId : null; $parentId = null; $offer = null; if (!empty($state->params["offerId"])) { $requiredOffers[] = $state->params["offerId"]; $offer = $this->get('Offer'); } if (isset($offer) && $offer->HasValidSearch) { $daySpan = '+' . $offer->MinDuration . ' day'; $dateparsed = BFCHelper::parseJsonDate($offer->FirstAvailableDate, 'Y-m-d'); $overrideFilters['checkin'] = DateTime::createFromFormat('Y-m-d', $dateparsed); $checkInParsed = clone $overrideFilters['checkin']; $overrideFilters['checkout'] = $checkInParsed->modify($daySpan); $overrideFilters['duration'] = $offer->MinDuration; $params['checkin'] = $overrideFilters['checkin']; $params['duration'] = $offer->MinDuration; $params['checkout'] = $overrideFilters['checkout']; } $this->assignRef('params', $params); $alternatRes = BFCHelper::GetAlternateResources(0, 5, null, null, $item->MerchantId, $parentId, false, false, $toExclude, $requiredOffers, $overrideFilters); if (!isset($alternatRes)) { $alternatRes = array(); } $allratePlans = array(); foreach ($alternatRes as $ratePlanStay) { $rs = $ratePlanStay->RatePlan; $rs->ResourceId = $ratePlanStay->ResourceId; $rs->ResName = $ratePlanStay->ResName; $rs->MinCapacityPaxes = $ratePlanStay->MinPaxes; $rs->MaxCapacityPaxes = $ratePlanStay->MaxPaxes; $rs->MrcCategoryName = $ratePlanStay->DefaultLangMrcCategoryName; $rs->Availability = $ratePlanStay->Availability; $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; 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; } // echo "<pre>allratePlans"; // echo print_r($allratePlans); // echo "</pre>"; function cmp($a, $b) { return $a->SortOrder - $b->SortOrder; } $merchants = array(); $merchants[] = $item->MerchantId; $criteoConfig = BFCHelper::getCriteoConfiguration(2, $merchants); usort($allratePlans, "cmp"); $this->assignRef('allstays', $allratePlans); $analyticsEnabled = $this->checkAnalytics(""); $this->assignRef('analyticsEnabled', $analyticsEnabled); $this->assignRef('criteoConfig', $criteoConfig); // // $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('search'); parent::display($tpl, $preparecontent); }
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); }
function display($tpl = NULL, $preparecontent = false) { $document = JFactory::getDocument(); $language = $document->getLanguage(); // load scripts $document->addScript('components/com_bookingforconnector/assets/js/jquery.validate.min.js'); $document->addScript('components/com_bookingforconnector/assets/js/additional-methods.min.js'); // Initialise variables $trackorder = false; $state = $this->get('State'); $actionmode = JRequest::getVar('actionmode', ""); $item = $this->get('Item'); $params =& $state->params; $this->assignRef('state', $state); $this->assignRef('params', $params); $this->assignRef('language', $language); $this->assignRef('item', $item); $this->assignRef('actionmode', $actionmode); if ($actionmode == "orderpayment") { //recupero quanti pagamenti sono stati effettuati $item->paymentCount = BFCHelper::getTotalOrderPayments($item->order->OrderId); $item->overrideAmount = JRequest::getFloat('overrideAmount'); //sostituisco i dati dell'ordine da pagare con i dati passati e l'ordine con un suffisso in più /*$item = $this->get('Item');*/ /*$item = "fet";*/ } if ($actionmode == "orderpaid") { $trackorder = true; } if ($actionmode != '' && $actionmode != 'cancel' && $actionmode != 'donation' && $actionmode != 'orderpayment') { if ($item->order->Status != 5) { $hasPayed = $this->processPayment($actionmode, $item->order->OrderId); /* eccezione per setefi che pretende un url di ritorno */ } else { //$hasPayed = true; $hasPayed = $this->processOrderPayment($actionmode, $item->order->OrderId, $language); } /* $link = ''; if ($hasPayed){ } $app = JFactory::getApplication(); $app->redirect($link, $msg); */ } if ($actionmode == '' && $actionmode != 'donation') { if ($item->order->Status != 5) { $this->inizializePayment($item->order->OrderId); } } if ($actionmode == 'orderpaid') { $hasPayed = $item->order->Status == 5; } if (isset($trackorder) && $trackorder) { $merchants = array(); $merchants[] = $item->order->MerchantId; $criteoConfig = BFCHelper::getCriteoConfiguration(4, $merchants, $item->order->OrderId); 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: "trackTransaction", id: "' . $criteoConfig->transactionid . '", item: [' . json_encode($criteoConfig->orderdetails) . '] } );'); } $analyticsEnabled = $this->checkAnalytics("Sales Resource List"); if ($analyticsEnabled && $config->get('eecenabled', 0) == 1) { $purchaseObject = new stdClass(); $purchaseObject->id = "" . $item->order->OrderId; $purchaseObject->affiliation = "" . $item->order->Label; $purchaseObject->revenue = "" . $item->order->TotalAmount; $purchaseObject->tax = 0.0; $allobjects = array(); $svcTotal = 0; $allservices = array_values(array_filter(simpledom_load_string($order->NotesData)->xpath("//price"), function ($prc) { return (string) $prc->tag == "extrarequested"; })); 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 = "" . $item->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 = $item->order->TotalAmount - $svcTotal; $mainObj->quantity = 1; $allobjects[] = $mainObj; $document->addScriptDeclaration('callAnalyticsEEc("addProduct", ' . json_encode($allobjects) . ', "purchase", "", ' . json_encode($purchaseObject) . ');'); } } // assegno il riferimento dopo gli altri altrimenti non ho nessuna associazione $this->assignRef('hasPayed', $hasPayed); /* $items = $this->get('Items'); $pagination = $this->get('Pagination'); $sortColumn = $state->get('list.ordering'); $sortDirection = $state->get('list.direction'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } $pagination->setAdditionalUrlParam("filter_order", $ordering); $pagination->setAdditionalUrlParam("filter_order_Dir", $direction); $this->assignRef('items', $items); $this->assignRef('pagination', $pagination); */ // Display the view parent::display($tpl); }
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); }
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); }
function display($tpl = null, $preparecontent = false) { // Initialise variables $document = JFactory::getDocument(); $language = $document->getLanguage(); $config = JComponentHelper::getParams('com_bookingforconnector'); $app = JFactory::getApplication(); $session = JFactory::getSession(); $maxItemsView = 3; $this->assignRef('maxItemsView', $maxItemsView); $state = $this->get('State'); $params = $state->params; if (!isset($params) || empty($params['checkin'])) { header("Location: " . JURI::root()); $app->close(); } $items = $this->get('Items'); $pagination = $this->get('Pagination'); $sortColumn = $state->get('list.ordering'); $sortDirection = $state->get('list.direction'); $typologies = $this->getModel()->getMasterTypologies(true, $language); // add stylesheet JHTML::stylesheet('https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css'); 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('//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css'); // load scripts $document->addScript('//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js'); $document->addScript('components/com_bookingforconnector/assets/js/bf.js'); $document->addScript('components/com_bookingforconnector/assets/js/jquery.xml2json.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.form.js'); $document->addScript('components/com_bookingforconnector/assets/js/jquery.blockUI.js'); $document->addScript('components/com_bookingforconnector/assets/js/jquery.ui.touch-punch.min.js'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } $merchants = array(); if (!empty($items)) { $merchants = array_unique(array_map(function ($a) { return $a->MerchantId; }, $items)); } $criteoConfig = BFCHelper::getCriteoConfiguration(1, $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: "viewSearch", checkin_date: "' . $params["checkin"]->format('Y-m-d') . '", checkout_date: "' . $params["checkout"]->format('Y-m-d') . '"}, { event: "viewList", item: ' . json_encode($criteoConfig->merchants) . ' } );'); } $totalItems = array(); $merchantResults = $params['merchantResults']; $condominiumsResults = $params['condominiumsResults']; $listName = ""; if (!empty($items)) { if ($merchantResults) { $resIndex = 0; $listName = "Resources Group List"; foreach ($items as $mrckey => $mrcValue) { $obj = new stdClass(); $obj->Id = $mrcValue->MerchantId . " - Merchant"; $obj->MerchantId = $mrcValue->MerchantId; $obj->Name = $mrcValue->Name; $obj->MrcCategoryName = $mrcValue->MrcCategoryName; $obj->MrcName = $mrcValue->Name; $obj->Position = $mrckey; $totalItems[] = $obj; foreach ($mrcValue->Resources as $resKey => $resValue) { $objRes = new stdClass(); $objRes->Id = $resValue->ResourceId . " - Resource"; $objRes->MerchantId = $mrcValue->MerchantId; $objRes->Name = $resValue->ResName; $objRes->MrcName = $mrcValue->Name; $objRes->MrcCategoryName = $mrcValue->MrcCategoryName; $objRes->Position = $resIndex; if ($resKey >= $maxItemsView) { $objRes->ExcludeInitial = true; } $totalItems[] = $objRes; $resIndex++; } } } else { if ($condominiumsResults) { $resIndex = 0; $listName = "Resources Group List"; foreach ($items as $mrckey => $mrcValue) { $obj = new stdClass(); $obj->Id = $mrcValue->CondominiumId . " - Resource Group"; $obj->MerchantId = $mrcValue->MerchantId; $obj->Name = $mrcValue->Name; $obj->MrcCategoryName = $mrcValue->MrcCategoryName; $obj->MrcName = $mrcValue->MerchantName; $obj->Position = $mrckey; $totalItems[] = $obj; foreach ($mrcValue->Resources as $resKey => $resValue) { $objRes = new stdClass(); $objRes->Id = $resValue->ResourceId . " - Resource"; $objRes->MerchantId = $mrcValue->MerchantId; $objRes->Name = $resValue->ResName; $objRes->MrcName = $mrcValue->Name; $objRes->MrcCategoryName = $mrcValue->MrcCategoryName; $objRes->Position = $resIndex; if ($resKey >= $maxItemsView) { $objRes->ExcludeInitial = true; } $totalItems[] = $objRes; $resIndex++; } } } else { $listName = "Resources Search List"; foreach ($items as $mrckey => $mrcValue) { $obj = new stdClass(); $obj->Id = $mrcValue->ResourceId . " - Resource"; $obj->MerchantId = $mrcValue->MerchantId; $obj->MrcCategoryName = $mrcValue->DefaultLangMrcCategoryName; $obj->Name = $mrcValue->ResName; $obj->MrcName = $mrcValue->MrcName; $obj->Position = $mrckey; $totalItems[] = $obj; } } } } $analyticsEnabled = $this->checkAnalytics($listName) && $config->get('eecenabled', 0) == 1; if (count($totalItems) > 0 && $analyticsEnabled) { $allobjects = array(); $initobjects = array(); foreach ($totalItems as $key => $value) { $obj = new stdClass(); $obj->id = "" . $value->Id; $obj->name = $value->Name; $obj->category = $value->MrcCategoryName; $obj->brand = $value->MrcName; $obj->position = $value->Position; if (!isset($value->ExcludeInitial) || !$value->ExcludeInitial) { $initobjects[] = $obj; } else { ///$obj->merchantid = $value->MerchantId; //$allobjects[] = $obj; } } $document->addScriptDeclaration('var currentResources = ' . json_encode($allobjects) . '; callAnalyticsEEc("addImpression", ' . json_encode($initobjects) . ', "list");'); } //event tracking $pagination->setAdditionalUrlParam("filter_order", $sortColumn); $pagination->setAdditionalUrlParam("filter_order_Dir", $sortDirection); $pagination->setAdditionalUrlParam("searchid", $params['searchid']); $pagination->setAdditionalUrlParam("newsearch", 0); $hidesort = true; $this->assignRef('state', $state); $this->assignRef('params', $params); $this->assignRef('items', $items); $this->assignRef('pagination', $pagination); $this->assignRef('language', $language); $this->assignRef('typologies', $typologies); $this->assignRef('config', $config); $this->assignRef('hidesort', $hidesort); $this->assignRef('analyticsEnabled', $analyticsEnabled); // Display the view parent::display($tpl, true); }