src/Elements/Bundle/DemiFrontendBundle/Resources/views/Includes/forms/search.html.twig line 1

Open in your IDE?
  1. {% set fromDate =  demi_getSearchFrom() %}
  2. {% set toDate = demi_getSearchTo() %}
  3. {% if not tvbPackage is defined and housePackageContainer is defined %}
  4.     {% set tvbPackage = housePackageContainer %}
  5. {% endif %}
  6. {% if housePackageContainer is defined and tvbPackage is not defined %}
  7.     {% set tvbPackage = housePackageContainer %}
  8. {% endif %}
  9. {% set isTVB = tvbPackage is defined ? true : false %}
  10. {% if isTVB %}
  11.     {% set packageWithoutAcco = isTVB and tvbPackage.getClassName() == 'demiPackage' and tvbPackage.hasAccommodationSection() == false %}
  12.     {% set nextPossibleArrivalDay = demi_getNextPossibleArrivalDay(tvbPackage) %}
  13. {% endif %}
  14. {% set datePickerData = demi_core_configuration('getDatepickerInfoTexts',[]) %}
  15. {% if datePickerData is not null and datePickerData|length >0 %}
  16.     {% set datePickerTexts = [] %}
  17.     {% for item in datePickerData.getItems() %}
  18.         {% if item.getDateTo() is not empty and item.getDateFrom() is not empty and item.getDateTo() > date('now') %}
  19.             {% set datePickerTexts= datePickerTexts|merge([{
  20.                 'from': elements_customDateFormat(item.getDateFrom()),
  21.                 'to': elements_customDateFormat(item.getDateTo()),
  22.                 'message': item.getText()}]) %}
  23.         {% endif %}
  24.     {% endfor %}
  25.     {% if datePickerTexts|length > 0 %}
  26.         {% do jsConfig().add({'datepickerRangeMessages': datePickerTexts}) %}
  27.     {% endif %}
  28. {% endif %}
  29. {% if not isTVB or (isTVB and nextPossibleArrivalDay is not null) %}
  30.     <script type="text/javascript" data-cookieconsent="ignore">
  31.         _config.overlay = true;
  32.         _config.searchForm = true;
  33.         _config.searchOverlay = true;
  34.         _config.quickFilter = true;
  35.     </script>
  36.     <form id="search-form" action="" class="js-search-form">
  37.         <div class="row row--gutter-width-10">
  38.             {% if not isTVB %}
  39.                 <div class="col col-12">
  40.                     <button class="form-box mb-3 js-overlay__toggle" type="button"
  41.                             data-target="#search-duration-overlay">
  42.                         <span class="form-box__label">{{ "demi.search.for"|trans }}</span>
  43.                         <span class="form-box__content">
  44.                         <span class="js-search-form__period">{{ "demi.search.exact-period"|trans }}</span>
  45.                     </span>
  46.                         <span class="demi-icon demi-icon-chevron-down form-box__icon"></span>
  47.                     </button>
  48.                 </div>
  49.             {% endif %}
  50.             {% if isTVB %}
  51.                 <div class="col col-6">
  52.                     <button type="button"
  53.                             class="form-box mb-3 js-overlay__toggle"
  54.                             data-target="#date-overlay">
  55.                     <span class="form-box__label">
  56.                         <span
  57.                             class="js-search-form__exact-label">{{ (isTVB and packageWithoutAcco ? "demi.start-date" : "demi.search.arrival")|trans }}</span>
  58.                         <span
  59.                             class="js-search-form__variable-label">{{ "demi.search.earliest-arrival-from"|trans }}></span>
  60.                     </span>
  61.                         <span class="form-box__content">
  62.                     {% if availabilityIsChecked is defined and availabilityIsChecked==true %}
  63.                         <time class="js-search-form__arrival-text"
  64.                               datetime="{{ fromDate.formatLocalized('%Y-%m-%d') }}">
  65.                         {{ elements_dateFormat(fromDate, 'date-long') }}</time>
  66.                     {% else %}
  67.                         <time class="js-search-form__arrival-text"
  68.                               datetime="{{ nextPossibleArrivalDay.formatLocalized('%Y-%m-%d') }}">
  69.                                 {{ elements_dateFormat(nextPossibleArrivalDay, 'date-long') }}</time>
  70.                         <script>
  71.                                 _initialState.searchForm.from = '{{ elements_customDateFormat(nextPossibleArrivalDay) }}';
  72.                             </script>
  73.                     {% endif %}
  74.                     </span>
  75.                         <span class="demi-icon demi-icon-calendar-insert form-box__icon"></span>
  76.                     </button>
  77.                 </div>
  78.                 <div class="col col-6">
  79.                     <script>
  80.                         _config.datepickerRanges = [
  81.                             {% for range in demi_getDestinationPackageRangesAsTimestring(tvbPackage) %}
  82.                             {
  83.                                 start: '{{ range['from'] }}',
  84.                                 end: '{{ range['to'] }}'
  85.                             },
  86.                             {% endfor %}
  87.                         ];
  88.                         {% set weekdayDurationDaysArray = demi_getDestinationPackageWeekdayDurations(tvbPackage) %}
  89.                         {% set possibleDurations = [] %}
  90.                         {% for weekDay,durations in weekdayDurationDaysArray %}
  91.                             {% for d in durations %}
  92.                                 {% if d not in possibleDurations %}
  93.                                     {% set possibleDurations = possibleDurations|merge([d]) %}
  94.                                 {% endif %}
  95.                             {% endfor %}
  96.                         {% endfor %}
  97.                         {% set possibleDurations = possibleDurations|sort %}
  98.                         {% set isOnlyOneDuration = possibleDurations|length is same as 1 %}
  99.                         {# define available duration nights for every weekday (0 - Sun to 6 - Sat)
  100.                      combine all possible days as a string in "all" #}
  101.                         _config.datepickerWeekdays = {
  102.                             "all": "{{ (weekdayDurationDaysArray|keys)|join }}",
  103.                             {% for weekday,durations in  weekdayDurationDaysArray %}
  104.                             "{{ weekday }}": [{{ durations|join(',') }}],
  105.                             {% endfor %}
  106.                         }
  107.                         {# max rooms for TVB packages is always 1 #}
  108.                         _config.searchFormMaxRooms = 1;
  109.                         _config.searchFormMinAdults = {{ tvbPackage.getAdultsMin() }};
  110.                         _config.searchFormMaxAdults = {{ tvbPackage.getAdultsMax() }};
  111.                         _config.searchFormMaxChildren = {{ tvbPackage.getChildrenMax() }};
  112.                         _config.searchFormMinChildren = {{ tvbPackage.getChildrenMin() }};
  113.                         {% if availabilityIsChecked is defined and availabilityIsChecked==true %}
  114.                         _initialState.search.durationNights = {{ toDate.diff(fromDate).d }};
  115.                         {% else %}
  116.                         {% set defaultChildAges  = [] %}
  117.                         {% if tvbPackage.getChildrenMin() > 0 %}
  118.                         {% for i in 0..((tvbPackage.getChildrenMin()|length)-1) %}
  119.                         {% set defaultChildAges = defaultChildAges|merge([0]) %}
  120.                         {% endfor %}
  121.                         {% endif %}
  122.                         {% if isOnlyOneDuration %}
  123.                         _initialState.searchForm.durationNights = {{ possibleDurations|first }};
  124.                         _initialState.search.to =  '{{ elements_customDateFormat(nextArivalDay.addDays((possibleDurations|first))) }}';
  125.                         {% endif %}
  126.                         {% set possibleChildAges =[] %}
  127.                         {% if tvbPackage.getChildAgeGroups() is not empty %}
  128.                             {% for fc in tvbPackage.getChildAgeGroups() %}
  129.                                 {% for i in fc.getAgeFrom()..fc.getAgeTo() %}
  130.                                     {% set possibleChildAges = possibleChildAges|merge([i]) %}
  131.                                 {% endfor %}
  132.                             {% endfor %}
  133.                         {% else %}
  134.                             {% for i in 0..18 %}
  135.                                 {% set possibleChildAges=possibleChildAges|merge([i]) %}
  136.                             {% endfor %}
  137.                         {% endif %}
  138.                         _config.searchFormPossibleChildAges = [{{ possibleChildAges|join(',') }}];
  139.                         _initialState.occupancy.rooms = [{
  140.                             adults: {{ tvbPackage.getAdultsMin() is not empty ? tvbPackage.getAdultsMin()  : 2 }},
  141.                             childAges: [{{ defaultChildAges|join(',') }}],
  142.                             quantity: 1
  143.                         }];
  144.                         {% endif %}
  145.                         _config.parsley = true;
  146.                     </script>
  147.                     <div class="js-form-group">
  148.                         <label class="form-box">
  149.                             <span
  150.                                 class="form-box__label">{{ (isTVB and packageWithoutAcco ? 'demi.booking.period' : 'demi.nights')|trans }}</span>
  151.                             <select name="count"
  152.                                     class="form-box__content form-control js-search-form__nights-select js-parsley"
  153.                                     required>
  154.                                 {% if not isOnlyOneDuration %}
  155.                                 <option value=""
  156.                                         disabled>{{ 'demi.search.destinationpackage.please-choose'|trans }}</option>
  157.                                 {% endif %}
  158.                                 {% for possibleDuration in possibleDurations %}
  159.                                     {% if packageWithoutAcco is defined %}
  160.                                         <option value="{{ possibleDuration }}"
  161.                                         {{ isOnlyOneDuration ? "selected" : "disabled" }}>{{ possibleDuration+1 }} {{ 'demi.days'|trans }}</option>
  162.                                     {% else %}
  163.                                         <option value="{{ possibleDuration }}" {{ isOnlyOneDuration ? "selected" : "disabled" }}>{{ possibleDuration }}
  164.                                             ({{ possibleDuration +1 }} {{ 'demi.days'|trans }})
  165.                                         </option>
  166.                                     {% endif %}
  167.                                 {% endfor %}
  168.                             </select>
  169.                             <span class="demi-icon demi-icon-chevron-down form-box__select-icon"
  170.                                   aria-hidden="true"></span>
  171.                         </label>
  172.                         <div class="form-errors"></div>
  173.                     </div>
  174.                 </div>
  175.             {% else %}
  176.                 <div class="col col-12">
  177.                     <button type="button"
  178.                             class="form-box mb-3 js-overlay__toggle"
  179.                             data-target="#date-overlay">
  180.                     <span class="form-box__label">
  181.                         <span class="js-search-form__exact-label">
  182.                             {{ "demi.search.arrival"|trans }} - {{ "demi.search.departure"|trans }}
  183.                         </span>
  184.                         <span class="js-search-form__variable-label">
  185.                             {{ "demi.search.earliest-arrival-from"|trans }} - {{ "demi.search.latest-departure-to"|trans }}
  186.                         </span>
  187.                     </span>
  188.                         <span class="form-box__content">
  189.                         <time class="js-search-form__arrival-text"
  190.                               datetime="{{ fromDate.formatLocalized('%Y-%m-%d') }}">{{ elements_dateFormat(fromDate, 'date-long') }}</time>
  191.                         -
  192.                         <time class="js-search-form__departure-text"
  193.                               datetime="{{ toDate.formatLocalized('%Y-%m-%d') }}">{{ elements_dateFormat(toDate, 'date-long') }}</time>
  194.                     </span>
  195.                         <span class="demi-icon demi-icon-calendar-insert form-box__icon"></span>
  196.                     </button>
  197.                 </div>
  198.             {% endif %}
  199.             <div class="col col-12">
  200.                 <button class="form-box mb-3 js-overlay__toggle" data-target="#occupancy-overlay" type="button">
  201.                     <span
  202.                         class="form-box__label">{{ (isTVB and packageWithoutAcco ? "demi.guests" : "demi.search.guests-rooms")|trans }}</span>
  203.                     <span class="form-box__content js-search-form__occupancy">
  204.                     {{ demi_getOccupancyType() is not empty ? "demi.search.multiple-rooms"|trans : '' }}
  205.                 </span>
  206.                     <span class="demi-icon demi-icon-chevron-down form-box__icon"></span>
  207.                 </button>
  208.             </div>
  209.             {%  set route = app.request.get('_route') %}
  210.             {%  set isDetail =  'detail' in route  %}
  211.             {% if not isDetail
  212.                 and not (isTVB and tvbPackage.getClassName() == 'demiPackage')
  213.                 and (demi_core_configuration('getNearbySearchByLocation',[]) == 'active' or demi_core_configuration('getNearbySearchByLocation',[]) == 'checked' )%}
  214.             <div class="col col-12 mb-4">
  215.                 {{ include('@ElementsDemiFrontend/Includes/elements/checkboxes/checkbox.html.twig', {
  216.                     'name': '' ,
  217.                     'label': 'demi.search.my-location'|trans,
  218.                     'isChecked': demi_core_configuration('getNearbySearchByLocation',[]) == 'checked' ? true : false,
  219.                     'value': "on",
  220.                     'customClass': 'js-search-form__search-nearby'
  221.                 }) }}
  222.             </div>
  223.             {% endif %}
  224.         </div>
  225.         {% if showMoreOptions is defined and showMoreOptions == true and not isTVB %}
  226.             <div class="text-center mb-4 mt-2 text-primary">
  227.                 <button type="button"
  228.                         class="btn-no-styling increased-click-area js-overlay__toggle"
  229.                         data-target="#additional-search-overlay">
  230.                     <span class="fz17 text-primary font-medium">{{ "demi.search.more.options"|trans }}</span>
  231.                     <span aria-label="{{ "demi.open"|trans }}"
  232.                           class="demi-icon demi-icon-chevron-down icon-in-text ml-1"></span>
  233.                 </button>
  234.             </div>
  235.         {% endif %}
  236.         <div class="row justify-content-center">
  237.             <div class="col-8">
  238.                 <button class="btn btn-success btn-lg btn-block js-search-form__submit"
  239.                         type="{{ pageSubmit is defined and pageSubmit == true? 'submit': 'button' }}">{{ (isTVB and packageWithoutAcco ? "demi.detail.package.add-to-cart" : "demi.search")|trans }}</button>
  240.             </div>
  241.         </div>
  242.         <div class="mt-4 js-search-form__range-messages" hidden></div>
  243.     </form>
  244. {% else %}
  245.     {{ "demi.destinationpackages.no-arrival-date"|trans }}
  246. {% endif %}
  247. {% if isTVB %}
  248.     <div class="card box-shadow mt-4">
  249.         <div class="card-body">
  250.             <div class="row row--gutter-width-10 ">
  251.                 <div class="col">
  252.                     <div class="h5 mb-2">{{ "demi.search.destinationpackage.form.packageinfos"|trans }}</div>
  253.                 </div>
  254.             </div>
  255.             <div class="row row--gutter-width-10 ">
  256.                 <div class="col-12 col-md-6">
  257.                     {% set adultsString = tvbPackage.getAdultsMin() %}
  258.                     {% if tvbPackage.getAdultsMax() != tvbPackage.getAdultsMin() %}
  259.                         {% set adultsString = adultsString ~ " - " ~ tvbPackage.getAdultsMax() %}
  260.                     {% endif %}
  261.                     {% set childrenString = null %}
  262.                     {% if tvbPackage.getChildrenMax() %}
  263.                         {% set childrenString = tvbPackage.getChildrenMin() %}
  264.                         {% if tvbPackage.getChildrenMax() != tvbPackage.getChildrenMin() %}
  265.                             {% set childrenString = childrenString ~ " - " ~ tvbPackage.getChildrenMax() %}
  266.                         {% endif %}
  267.                     {% endif %}
  268.                     <div
  269.                         class="h6 mb-2">{{ (isTVB and packageWithoutAcco ? "demi.guests" : "demi.search.destinationpackage.occupancy")|trans }}</div>
  270.                     <div class="small">
  271.                         {{ adultsString }} {{ 'demi.adults'|trans }}{% if childrenString is not empty %}, {{ childrenString }} {{ 'demi.children'|trans }}{% endif %}
  272.                     </div>
  273.                     <div class="h6 mb-2 mt-4">{{ "demi.search.destinationpackage.possible-periods"|trans }}</div>
  274.                     <ul class="small list-default">
  275.                         {% for item in tvbPackage.getValidDates() %}
  276.                             <li>
  277.                                 <time
  278.                                     datetime="{{ item.getDateFrom().formatLocalized('%Y-%m-%d') }}">{{ elements_dateFormat(item.getDateFrom(),'date-long') }}</time>
  279.                                 -
  280.                                 <time
  281.                                     datetime="{{ item.getDateTo().formatLocalized('%Y-%m-%d') }}">{{ elements_dateFormat(item.getDateTo(),'date-long') }}</time>
  282.                             </li>
  283.                         {% endfor %}
  284.                     </ul>
  285.                 </div>
  286.                 <div class="col-12 col-md-6">
  287.                     <div
  288.                         class="h6 mb-2 mt-4 mt-md-0">{{ (packageWithoutAcco ? "demi.search.destinationpackage.duration-and-arrival-days" : "demi.search.destinationpackage.stay-and-arrival-days")|trans }}</div>
  289.                     <ul class="small list-default">
  290.                         {% for item in tvbPackage.getPackageDuration() %}
  291.                             <li>
  292.                                 {% if packageWithoutAcco %}
  293.                                     {{ item.getDurationDays() }} {{ (item.getDurationDays()==2? 'demi.day' : 'demi.days')|trans }} -
  294.                                 {% else %}
  295.                                     {{ item.getDurationDays()-1 }} {{ (item.getDurationDays()==2? 'demi.night' : 'demi.nights')|trans }} -
  296.                                 {% endif %}
  297.                                 {% set days = [] %}
  298.                                 {% if item.getMon() %}
  299.                                     {% set days = days|merge([('demi.search.destinationpackage.mon')|trans]) %}
  300.                                 {% endif %}
  301.                                 {% if item.getTue() %}
  302.                                     {% set days = days|merge([('demi.search.destinationpackage.tue')|trans]) %}
  303.                                 {% endif %}
  304.                                 {% if item.getWed() %}
  305.                                     {% set days = days|merge([('demi.search.destinationpackage.wed')|trans]) %}
  306.                                 {% endif %}
  307.                                 {% if item.getThu() %}
  308.                                     {% set days = days|merge([('demi.search.destinationpackage.thu')|trans]) %}
  309.                                 {% endif %}
  310.                                 {% if item.getFri() %}
  311.                                     {% set days = days|merge([('demi.search.destinationpackage.fri')|trans]) %}
  312.                                 {% endif %}
  313.                                 {% if item.getSat() %}
  314.                                     {% set days = days|merge([('demi.search.destinationpackage.sat')|trans]) %}
  315.                                 {% endif %}
  316.                                 {% if item.getSun() %}
  317.                                     {% set days = days|merge([('demi.search.destinationpackage.sun')|trans]) %}
  318.                                 {% endif %}
  319.                                 {% if days|length == 7 %}
  320.                                     {{ 'demi.search.destinationpackage.arrival-every-day'|trans }}
  321.                                 {% else %}
  322.                                     {{ days|join(', ') }}
  323.                                 {% endif %}
  324.                             </li>
  325.                         {% endfor %}
  326.                     </ul>
  327.                 </div>
  328.             </div>
  329.         </div>
  330.     </div>
  331. {% endif %}