{# /************************************************************* File name: property-calendar.html.twig Project: Villas3 Copyright 2023 Michael J. Miller, All rights reserved Purpose: markup for the days in a calendar page on property page Requires: villa reservation - if not included just shows dates pre_min_date - date for beginning of minimum stay prior to start post_min_date - date for ending of minimum stay after ends Revision History: Date Version Details **************************************************************/ #} {# setting it this way is useful for debugging on browser #} {% set webmaster = role == 'webmaster' ? 1 : 1 %} {% set page_title = first_day|date("F Y") %}

{{page_title}}

{% for day_name in WEEK_DAY_NAMES %}
{{day_name}}
{% endfor %} {% for day in calendar %} {% if reservation is defined %} {% set day_state = day.state %} {% if day.date == reservation.starts %} {% set book_class = 'cal-available book-start' %} {% elseif day.date == reservation.ends %} {% set book_class = 'cal-available book-end' %} {% elseif day.date > reservation.starts and day.date <= reservation.ends %} {% set book_class = 'cal-available book' %} {% elseif day.state == 'booked' and day.reservation_id is not empty and loop.index0 > 1 and calendar[loop.index0 - 1].reservation_id is empty %} {% set book_class = block_checkout_day ? 'cal-blocked' : 'cal-available' %} {% set RULE5 = 1 %} {% else %} {% set book_class = day_state == 'open' or day.min_stay ? 'cal-available' : 'cal-blocked' %} {% endif %} {# num the number of the day to display first_day date of first day of the pages month last_day date of last day of the pages month first_after date if first blocked day after end of reservation (may be empty) last_before date of last blocked day before start of reservation (may be empty) These are the rules which govern how a date is shown: 1 date is be in a different month from page month - no date is shown 2 date is before first_after or after last_before so is unselectable and shown blocked 3 date is before today so not selected and shown blocked 4 date is in current reservation 5 day is booked by a reservation, it's not the first booked day in a series #} {% set num = day.date|slice(8,2)|trim('0','left') %} {% set before_after = ' last_before '~last_before~' first_after '~first_after %} {% if day.date < first_day or day.date > last_day %} {% set title = day.date~': '~(day_state == 'blocked' or day.date < today) ? 'blocked' : 'available' %}
{% elseif first_after is not empty and (day.date < max(last_before, today) or day.date > first_after) %}
 {{num}} 
{% elseif day.date < today %}
 {{num}} 
{% elseif RULE5 is defined %} {% set description = day.date~': available '~(day.price / 100)|number_format(2) %}
 {{num}} 
{% else %} {% set description = day_state != 'open' or (reservation is defined and reservation.reservation_id == day.reservation_id) ? day.date~': blocked' : day.date~': available '~(day.price / 100)|number_format(2) %}
 {{num}} 
{% endif %} {% endif %} {% endfor %}