{% extends "@AdminLTE/layout/form-theme.html.twig" %}

{# Adds the help icon, including a link to the documentation #}
{% block form_label %}
    {% if form.vars.docu_chapter is defined and form.vars.docu_chapter is not empty %}
        <a href="{{ form.vars.docu_chapter|docu_link }}" target="_blank"><i class="{{ 'help'|icon }}"></i></a>
    {% endif %}
    {{ parent() }}
{% endblock form_label %}

{% block quick_entry_week_row %}
    <tr{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group qe-entry-week-row' ~ (not valid ? ' has-error'))|trim})} %}{{ block('attributes') }}{% endwith %}>
        <td>
            {{ form_row(form.project) }}
        </td>
        <td>
            {{ form_row(form.activity) }}
        </td>
        {% for timesheet in form.timesheets %}
            <td class="text-center{% if timesheet.vars.data.begin is weekend %} weekend{% endif %}{% if timesheet.vars.data.begin is today %} today{% endif %}">
                {{ form_row(timesheet) }}
            </td>
        {% endfor %}
        <td class="text-nowrap text-center total qe-totals-row"></td>
    </tr>
{% endblock %}

{% block _team_edit_form_members_entry_user_widget %}
    {#  this will convert the select box into a hidden field, which are exchangable from an HTML perspective #}
    {%- set type = 'hidden' -%}
    {{ block('form_widget_simple') }}
{% endblock %}

{% block team_member_widget %}
    <div class="row">
        <div class="col-xs-7">
            <div class="checkbox">
            <button class="btn btn-default btn-xs" onclick="jQuery(this).parent().parent().parent().remove();return false;"><i class="{{ 'trash'|icon }}"></i></button>
            {% if form.vars.data is not null and form.vars.data.user is not null %}
                {{ form.vars.data.user.displayName }}
            {% else %}
                __USERNAME__
            {% endif %}
            </div>
            {{ form_widget(form.user) }}
            {{ form_errors(form.user) }}
        </div>
        <div class="col-xs-5">
            {{ form_widget(form.teamlead) }}
        </div>
    </div>
{% endblock team_member_widget %}

{% block daterange_widget %}
    <div class="input-group">
        <div class="input-group-addon">
            <i class="far fa-calendar-alt"></i>
        </div>

        {% set attr = attr|merge({'data-daterangepickerenable':'on'}) %}

        {{ block('form_widget_simple') }}
    </div>
{% endblock daterange_widget %}

{% block duration_widget %}
    {% if (form.vars.duration_presets is defined and form.vars.duration_presets is not empty) and (form.vars.disabled is same as (false)) %}
    <div class="input-group">
        {{ block('form_widget_simple') }}
        <div class="input-group-btn">
            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="caret"></span></button>
            <ul class="dropdown-menu dropdown-menu-right pre-scrollable">
                {% for value in form.vars.duration_presets %}
                    <li class="text-center">
                        <a href="#" onclick="jQuery('#{{ form.vars.id }}').val('{{ value }}').trigger('change');return false;">{{ value }}</a>
                    </li>
                {% endfor %}
            </ul>
        </div>
    </div>
    {% else %}
        {{ block('form_widget_simple') }}
    {% endif %}
{% endblock duration_widget %}

{% block datetime_widget -%}
    <div class="input-group">
        <div class="input-group-addon">
            <a href="#" onclick="if (!jQuery('#{{ id }}').is(':disabled')) { jQuery('#{{ id }}').val(moment().format('{{ attr['data-format'] }}')).change(); }return false;"><i class="{{ 'calendar'|icon }}"></i></a>
        </div>
        {{ block('form_widget_simple') }}
    </div>
{%- endblock datetime_widget %}

{% block date_widget -%}
    <div class="input-group">
        <div class="input-group-addon">
            <a href="#" onclick="if (!jQuery('#{{ id }}').is(':disabled')) { jQuery('#{{ id }}').val(moment().format('{{ attr['data-format'] }}')).change(); }return false;"><i class="{{ 'calendar'|icon }}"></i></a>
        </div>
        {{ block('form_widget_simple') }}
    </div>
{%- endblock date_widget %}

{% block text_widget -%}
    {% if icon is not empty %}
    <div class="input-group">
        <div class="input-group-addon">
            <i class="{{ icon|icon }}"></i>
        </div>
        {{ block('form_widget_simple') }}
    </div>
    {% else %}
        {{ block('form_widget_simple') }}
    {% endif %}
{%- endblock text_widget %}

{% block yearpicker_widget -%}
    <div class="btn-group">
        <a class="btn btn-default btn-left" href="#" onclick="jQuery('#{{ form.vars.id }}').val('{{ previousYear|report_date }}').change()" data-toggle="tooltip" data-placement="top" title="{{ previousYear|date_short }}">
            <i class="{{ 'left'|icon }}"></i>
        </a>
        <a class="btn btn-default" href="#" onclick="return false;">
            <span id="{{ form.vars.id }}_month_name">
                {% if show_range %}
                    {{ year|date_short }} &ndash; {{ nextYear|date_short }}
                {% else %}
                    {{ year|date_format('Y') }}
                {% endif %}
            </span>
        </a>
        <a class="btn btn-default btn-right" href="#" onclick="jQuery('#{{ form.vars.id }}').val('{{ nextYear|report_date }}').change()" data-toggle="tooltip" data-placement="top" title="{{ nextYear|date_short }}">
            <i class="{{ 'right'|icon }}"></i>
        </a>
    </div>
    {{ block('hidden_widget') }}
{%- endblock yearpicker_widget %}

{% block monthpicker_widget -%}
    <div class="btn-group">
        <a class="btn btn-default btn-left" href="#" onclick="jQuery('#{{ form.vars.id }}').val('{{ previousMonth|report_date }}').change()" data-toggle="tooltip" data-placement="top" title="{{ previousMonth|month_name(true) }}">
            <i class="{{ 'left'|icon }}"></i>
        </a>
        <a class="btn btn-default" href="#" onclick="return false;">
            <span id="{{ form.vars.id }}_month_name">{{ month|month_name(true) }}</span>
        </a>
        <a class="btn btn-default btn-right" href="#" onclick="jQuery('#{{ form.vars.id }}').val('{{ nextMonth|report_date }}').change()" data-toggle="tooltip" data-placement="top" title="{{ nextMonth|month_name(true) }}">
            <i class="{{ 'right'|icon }}"></i>
        </a>
    </div>
    {{ block('hidden_widget') }}
{%- endblock monthpicker_widget %}

{% block weekpicker_widget -%}
    <div class="btn-group week-picker-btn-group">
        <a class="btn btn-default btn-left" href="#" onclick="jQuery('#{{ form.vars.id }}').val('{{ previousWeek|report_date }}').change()" data-toggle="tooltip" data-placement="top" title="{{ 'stats.workingTimeWeek'|trans({'%week%': previousWeek|date_format('W')}) }}">
            <i class="{{ 'left'|icon }}"></i>
        </a>
        <a class="btn btn-default" href="#" onclick="return false;">
            <span id="{{ form.vars.id }}_week_number" data-toggle="tooltip" data-placement="top" title="{{ 'stats.workingTimeWeek'|trans({'%week%': week|date_format('W')}) }}">
                {{ week|month_name(true) }}
                &ndash;
                {{ 'stats.workingTimeWeekShort'|trans({'%week%': week|date_format('W')}) }}
            </span>
        </a>
        <a class="btn btn-default btn-right" href="#" onclick="jQuery('#{{ form.vars.id }}').val('{{ nextWeek|report_date }}').change()" data-toggle="tooltip" data-placement="top" title="{{ 'stats.workingTimeWeek'|trans({'%week%': nextWeek|date_format('W')}) }}">
            <i class="{{ 'right'|icon }}"></i>
        </a>
    </div>
    {{ block('hidden_widget') }}
{%- endblock weekpicker_widget %}
