{% extends "Global/layout.html.twig" %}

{% set pagetitle = venue.name ~ " - " ~ ("Seating plans"|trans) %}

{% block title %}{{pagetitle}}{% endblock %}

{% block content %}

    {% set navigation = [{ "dashboard_index": ('Dashboard' | trans),  "dashboard_organizer_venue": ('my venues' | trans), "current":(pagetitle) }] %}
    {% include "Global/navigation.html.twig" with navigation %}

    <section class="section-content padding-y bg-white">
        <div class="{{ services.getSetting("app_layout") }}">
            <div class="row">
                <aside class="col-lg-3 pt-3 pt-lg-0">
                    {% include "Dashboard/sidebar.html.twig" %}
                </aside>
                <div class="col-lg-9 mt-4 mt-lg-0">

                    <div class="box shadow-none bg-gray mb-4">
                        <div class="row">
                            <a href="{{ path('dashboard_organizer_venue_seating_plans_add', {venueSlug: venue.slug}) }}" class="btn btn-primary ml-3 float-right"><i class="fas fa-plus"></i> {{'Add a new seating plan' | trans}}</a>
                        </div>
                    </div>
                    {% if seatingPlans|length > 0 %}

                        <div class="row">

                            <div class="col-12">
                                <div class="card">
                                    <div class="table-responsive">
                                        <table class="table table-hover table-vcenter text-nowrap">
                                            <thead>
                                                <tr>
                                                    <th>{{'Name' | trans}}</th>
                                                    <th>{{'Sections' | trans}}</th>
                                                    <th>{{'Total seats' | trans}}</th>
                                                    <th class="text-center"><i class="fas fa-cog"></i></th>
                                                </tr>
                                            </thead>
                                            <tbody>

                                                {% for seatingPlan in seatingPlans %}

                                                    <tr>
                                                        <td>
                                                            {{ seatingPlan.name }}
                                                        </td>
                                                        <td>
                                                            {{ seatingPlan.design.sections|length }}
                                                        </td>
                                                        <td>
                                                            {{ seatingPlan.countTotalSeats }}
                                                        </td>

                                                        <td class="text-center">
                                                            <div class="item-action dropdown">
                                                                <a href="javascript:void(0)" data-toggle="dropdown" data-boundary="window" class="icon"><i class="fas fa-ellipsis-v"></i></a>
                                                                <div class="dropdown-menu dropdown-menu-right">
                                                                    <span class="dropdown-item cursor-pointer" data-toggle="modal" data-target="#seatingPlan-{{ seatingPlan.id }}-details"><i class="dropdown-icon fas fa-braille fa-fw text-muted"></i> {{ "Details"|trans }}</span>
                                                                    <a href="{{ path('dashboard_organizer_venue_seating_plans_edit', { venueSlug : seatingPlan.venue.slug, seatingPlanSlug: seatingPlan.slug }) }}" class="dropdown-item"><i class="dropdown-icon fas fa-edit fa-fw text-muted"></i> {{ "Edit"|trans }}</a>
                                                                    <a href="{{ path('dashboard_organizer_venue_seating_plans_duplicate', { venueSlug : seatingPlan.venue.slug, seatingPlanSlug: seatingPlan.slug }) }}" class="dropdown-item"><i class="dropdown-icon fas fa-copy fa-fw text-muted"></i> {{ "Duplicate"|trans }}</a>
                                                                </div>
                                                            </div>
                                                        </td>
                                                    </tr>



                                                {% endfor %}
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>

                        </div>

                        {% for seatingPlan in seatingPlans %}
                            <div class="modal fade" id="seatingPlan-{{ seatingPlan.id }}-details">
                                <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <h4 class="modal-title">{{ seatingPlan.name }}</h4>
                                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                                        </div>
                                        <div class="modal-body">

                                            <div class="table-responsive">
                                                <table class="table table-borderless table-striped table-hover table-sm">
                                                    <thead>
                                                    <th>{{ "Section"|trans }}</th>
                                                    <th>{{ "Seats count"|trans }}</th>
                                                    </thead>
                                                    <tbody>
                                                        {% for sectionName, sectionSeatsCount in seatingPlan.getSectionsSeatsQuantityArray %}
                                                            <tr>
                                                                <td>{{ sectionName }}</td>
                                                                <td>{{ sectionSeatsCount }}</td>
                                                            </tr>
                                                        {% endfor %}
                                                    </tbody>
                                                </table>
                                            </div>


                                        </div>
                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-primary" data-dismiss="modal">{{ "Close"|trans }}</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        {% endfor %}

                    {% else %}

                        {% include "Global/message.html.twig" with { type: "info", message: ('No seating plans found for this venue'|trans), icon: "fas fa-exclamation-circle" } %}

                    {% endif %}
                </div>
            </div>

        </div>
    </section>

{% endblock %}

{% block javascripts %}

    <script>

        $(document).ready(function () {
        });

    </script>

{% endblock %}