{#
/**
 * Copyright (C) 2020 Xibo Signage Ltd
 *
 * Xibo - Digital Signage - http://www.xibo.org.uk
 *
 * This file is part of Xibo.
 *
 * Xibo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * Xibo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
 */
#}
{% extends "form-base.twig" %}
{% import "forms.twig" as forms %}

{% block formTitle %}
    {% trans "Edit Daypart" %}
{% endblock %}

{% block formButtons %}
    {% trans "Cancel" %}, XiboDialogClose()
    {% trans "Save" %}, $("#dayPartEditForm").submit()
{% endblock %}

{% block extra %}{{ extra|json_encode|raw }}{% endblock %}

{% block callBack %}dayPartFormOpen{% endblock %}

{% block formHtml %}
    <div class="row">
        <div class="col-md-12">
            <ul class="nav nav-tabs" role="tablist">
                <li class="nav-item"><a class="nav-link active" href="#general" role="tab" data-toggle="tab"><span>{% trans "General" %}</span></a></li>
                <li class="nav-item"><a class="nav-link" href="#description" role="tab" data-toggle="tab"><span>{% trans "Description" %}</span></a></li>
                <li class="nav-item"><a class="nav-link" href="#exceptions" role="tab" data-toggle="tab"><span>{% trans "Exceptions" %}</span></a></li>
            </ul>
            <form id="dayPartEditForm" class="XiboForm form-horizontal" method="put" action="{{ url_for("daypart.edit", {id: dayPart.dayPartId}) }}">
                <div class="tab-content">
                    <div class="tab-pane active" id="general">
                        {% set title %}{% trans "Name" %}{% endset %}
                        {% set helpText %}{% trans "The Name for this Daypart" %}{% endset %}
                        {{ forms.input("name", title, dayPart.name, helpText, "", "required") }}

                        {% set title %}{% trans "Retired" %}{% endset %}
                        {% set helpText %}{% trans "Retire? It will no longer be visible when scheduling" %}{% endset %}
                        {{ forms.checkbox("isRetired", title, dayPart.isRetired, helpText) }}

                        {% set title %}{% trans "Start Time" %}{% endset %}
                        {% set helpText %}{% trans "Enter the start time for this daypart" %}{% endset %}
                        {{ forms.time("startTime", title, dayPart.startTime, helpText) }}

                        {% set title %}{% trans "End Time" %}{% endset %}
                        {% set helpText %}{% trans "Enter the end time for this daypart. If the end time is before the start time, then the daypart will cross midnight." %}{% endset %}
                        {{ forms.time("endTime", title, dayPart.endTime, helpText) }}

                        {% set title %}{% trans "If this daypart is already in use, the events will be adjusted to use the new times provided. If used on a recurring event and that event has already recurred. The event will be split in two and the future event time adjusted." %}{% endset %}
                        {{ forms.message(title) }}
                    </div>
                    <div class="tab-pane" id="description">
                        {% set title %}{% trans "Description" %}{% endset %}
                        {% set helpText %}{% trans "A Description of Daypart" %}{% endset %}
                        {{ forms.textarea("description", title, dayPart.description, helpText) }}
                    </div>
                    <div class="tab-pane" id="exceptions">
                        {% set title %}{% trans "If there are any exceptions enter them below by selecting the Day from the list and entering a start/end time." %}{% endset %}
                        {{ forms.message(title) }}
                        <div id="dayPartExceptions">

                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
{% endblock %}