{% if searchParam is not defined or searchParam.getDateFrom() is empty %}
{% set fromDate = null %}
{% else %}
{% set fromDate = demi_getSearchFrom() %}
{% endif %}
{% set imgSrc = demi_getFirstImageForHousePackageMaster(housePackageMaster, accommodation, fromDate) %}
{% set useGal = true %}
{% if imgSrc == null %}
{% set imgSrc = demi_core_configuration("getTeaserFallbackImage",[]) %}
{% set useGal = false %}
{% endif %}
{% set validDatesString = "" %}
{% set validDates = housePackageMaster.getValidDates() %}
{% set earliestFromDate = null %}
{% set latestToDate = null %}
{% if validDates is not empty and validDates.getItems() is not empty %}
{% for item in validDates.getItems() %}
{% if item.getTo().getTimestamp() > 'now'|date('U') %}
{% if earliestFromDate == null or earliestFromDate.gt(item.getFrom()) %}
{% set earliestFromDate = item.getFrom() %}
{% endif %}
{% if latestToDate == null or latestToDate.lt(item.getTo()) %}
{% set latestToDate = item.getTo() %}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% set price = 0 %}
{% if cheapestProducts is not empty %}
{% set pricearray = demi_getMinPriceOfHousePackageMasterResultSet(cheapestProducts) %}
{% set price = pricearray["price"] %}
{% set priceInfo = pricearray["priceInfo"] %}
{% set cP = pricearray["cP"] %}
{% endif %}
{% set earlyDate = elements_dateFormat( earliestFromDate, 'date-short') %}
{% if earliestFromDate is not empty %}
{% set earlyDateTimeFormat = earliestFromDate|format('Y-m-d') %}
{% else %}
{% set earlyDateTimeFormat = '' %}
{% endif %}
{% set latestDate = elements_dateFormat( latestToDate, 'date-long') %}
{% if latestToDate is not empty %}
{% set latestDateTimeFormat = latestToDate|format('Y-m-d') %}
{% else %}
{% set latestDateTimeFormat = '' %}
{% endif %}
{% set validDatesString = validDatesString ~ '<time datetime="' ~ earlyDateTimeFormat ~ '">' ~ earlyDate ~ '</time> - <time datetime="' ~ latestDateTimeFormat ~ '">' ~ latestDate ~ '</time>' %}
{% set validDatesString = '<div>' ~ validDatesString ~ '</div>' %}
{% if searchParam.getDateFrom() %}
{% set mealObj = demi_getMealTypeByFid(cP.getMealCode() ?? '') %}
{% if mealObj is not null %}
{% set priceInfoString = '<div class="small text-nowrap"><div class="demi-icon demi-icon-restaurant mr-1 icon-in-text" aria-label="' ~ "demi.detail.room.meals"|trans ~ '" title="' ~ "demi.detail.room.meals"|trans ~ '"></div>' ~ mealObj.getText() ~ '</div>' %}
{% if cP.getPriceData() is not empty and cP.getPriceData().getPriceBeforeSpecial() != cP.getPrice() %}
{% set specialPrice= '<div class="sr-only">' ~ "demi.instead-of"|trans ~ '</div>' ~ '<s>' ~ demi_paymentGetPriceObject(cP.getPriceData().getPriceBeforeSpecial(), pimcore_object(accommodation.getId())) ~ '</s>' %}
{% endif %}
{% endif %}
{% else %}
{% if price>0 %}
{% set priceInfoString = '<div class="mt-1">' ~ include('@ElementsDemiFrontend/Includes/priceInfoStr.html.twig',{'type': null,'nights': null}) ~ '</div>' %}
{% endif %}
{% endif %}
{% if isAffiliate %}
{% set route = 'demi_acco_affiliate_detail_package_page' %}
{% else %}
{% set route = 'demi_acco_detail_package_page' %}
{% endif %}
{% set packageDetailUrl = demi_demiUrl({
'accommodation': accommodation,
'package': housePackageMaster
}, route) %}
{% set template = demi_getDeviceDependentTemplate('@ElementsDemiFrontend/Includes/teaser/', 'offer-teaser', container) %}
{{ include(template, {
'text': validDatesString,
'priceInfo': priceInfoString is defined ? priceInfoString : null,
'specialPrice': specialPrice is defined ? specialPrice : null,
'id': housePackageMaster.getId(),
'img': imgSrc,
'title': housePackageMaster.getName(),
'price': price,
'href': packageDetailUrl,
'opensOverlay': false,
'position': position,
'useGal': useGal
}
) }}