{% extends 'layouts/app.twig' %}
{% import 'macros/base.twig' as m %}
{% import 'macros/form.twig' as f %}

{% block title %}{{ __('shifts.history') }}{% endblock %}

{% block content %}
    <div class="container">
        <h1>
            {{ m.button(m.icon('chevron-left'), url('/admin-shifts'), null, 'sm', __('general.back')) }}
            {% block content_title %}{{ block('title') }}{% endblock %}
        </h1>

        {% include 'layouts/parts/messages.twig' %}

        <div class="row">
{% block row_content %}
    <div class="col-md-12">
        <div class="table-responsive">
            <table class="table table-striped">
                <thead>
                <tr>
                    <th>{{ __('general.id') }}</th>
                    <th>{{ __('title.title') }}</th>
                    <th>{{ __('location.location') }}</th>
                    <th>{{ __('general.count') }}</th>
                    <th>{{ __('shifts.start') }}</th>
                    <th>{{ __('shifts.end') }}</th>
                    <th>{{ __('general.user') }}</th>
                    <th>{{ __('general.created_at') }}</th>
                    <th></th>
                </tr>
                </thead>

                <tbody>
                {% for shift in shifts %}
                    <tr>
                        <td>{{ shift.transaction_id }}</td>
                        <td>
                            {% if shift.schedule %}
                                {{ __('shifts.history.schedule', [shift.schedule.name]) }}
                            {% else %}
                                {{ shift.title }}
                            {% endif %}<br>
                            {{ shift.shiftType.name }}
                        </td>
                        <td>{{ shift.location.name }}</td>
                        <td>{{ shift.count }}</td>
                        <td>{{ shift.start.format(__('general.datetime')) }}</td>
                        <td>{{ shift.end.format(__('general.datetime')) }}</td>
                        <td>{{ m.user(shift.createdBy) }}</td>
                        <td>{{ shift.created_at.format(__('general.datetime')) }}</td>
                        <td>
                            <form method="post" class="ps-1">
                                {{ csrf() }}
                                {{ f.hidden('transaction_id', shift.transaction_id) }}
                                {{ f.delete(null, {
                                    'size': 'sm',
                                    'title': __('form.delete_all'),
                                    'confirm_title': __('shifts.history.delete_all.title', [shift.count]),
                                    'confirm_button_text': __('form.delete_all'),
                                }) }}
                            </form>
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
{% endblock %}
        </div>
    </div>
{% endblock %}
