{% extends '_layout.html'|pjax:request %}
{% load i18n staticfiles %}

{% block page_title %}{{ block.super }} | {{ item.name }}{% endblock %}

{% block main_content %}
<div class="container">
    <div class="text-right">
    {% if USER_IS_STAFF and USER_CONFIG.show_admin_links %}
        <a class="btn btn-info" href="{% url 'admin:manga_series_change' item.pk %}">{% trans "Edit in admin" %}</a>
    {% endif %}
    {% if user.is_authenticated %}
        <p>¿No encuentras el tomo que tienes? <a class="btn btn-info" href="{% url 'series.suggest-volume' item.pk item.slug %}">Añádelo a Shelfzila</a></p>
    {% endif %}
    </div>
    <br />
    <div class="row">
        <div class="col-md-3">
            <div class="panel panel-warning">
                {% if item.last_volume_cover %}
                <div class="panel-body text-center">
                    <img src="{{ item.last_volume_cover.url }}" class="max-width-80" />
                </div>
                {% endif %}
            </div>
            {% if item.art.count %}
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h2 class="panel-title text-center">{% trans "Art" %}</h2>
                </div>
                <ul class="list-group">
                    {% for person in item.art.all %}
                    <li class="list-group-item">
                        {{ person.name }}
                    </li>
                    {% endfor %}
                </ul>
            </div>
            {% endif %}

            {% if item.story.count %}
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h2 class="panel-title text-center">{% trans "Story" %}</h2>
                </div>
                <ul class="list-group">
                    {% for person in item.story.all %}
                    <li class="list-group-item">
                        {{ person.name }}
                    </li>
                    {% endfor %}
                </ul>
            </div>
            {% endif %}

            <div class="panel panel-default">
                <div class="panel-heading">
                    <h2 class="panel-title text-center">{% trans "Publishers" %}</h2>
                </div>
                <ul class="list-group">
                    {% if item.original_publisher %}
                    <li class="list-group-item">
                        <strong>{% trans "Original publisher" %}:</strong>
                        {% comment %}
                        <a href="{{ publisher.get_absolute_url }}" data-pajax>{{ item.original_publisher.name }}</a>
                        {% endcomment %}
                        <span class="pull-right"><i>{{ item.original_publisher.name }}</i></span>
                    </li>
                    {% endif %}
                    {% if item.publishers.count > 0 %}
                        {% for publisher in item.publishers.all %}
                        <li class="list-group-item">
                            <h4 class="list-group-item-heading">{{ publisher.publisher.name }}</h4>
                            <!--<span class="badge badge-default">{{ publisher.volumes.count }}</span> -->
                            <span class="badge badge-{{ publisher.get_status_display_class }}">{{ publisher.get_status_display }}</span>
                            <div><a href="{{ publisher.publisher.get_absolute_url }}" data-pajax>{% trans "More info" %} &raquo;</a></div>
                        </li>
                        {% endfor %}
                    {% endif %}
                </ul>
            </div>
        </div>
        <div class="col-md-9">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h1 class="panel-title panel-title-alt text-center">{{ item.name }}</h1>
                </div>
            </div>
            {% if item.summaries.count > 0 %}
            <div class="well well-summary">
            {% for summary in item.summaries.all %}
                {% if item.summaries.count > 1 %}
                <img src="{% static "images/flags/"|add:summary.language.code|add:'.gif' code %}"
                    class="pull-left summary-language" />
                {% endif %}
                {{ summary.summary|linebreaks }}
                <div class="clearfix"></div>
            {% endfor %}
            </div>
            {% endif %}
            <div data-pjax-container="volumes">
                {% block volume_list %}
                <div class="well" id="volume_filters">
                    <form class="form-inline" role="form" method="post">
                        {% csrf_token %}
                        <div class="form-group">
                            <label class="" for="language">
                                {% trans "Language" %}</label>
                            <select name="language" class="form-control">
                                <option value="0">{% trans "All" %}</option>
                                {% for lang in item.languages.all %}
                                <option value="{{ lang.pk }}"
                                    {% if volume_filters.language_id == lang.pk %}
                                    selected="selected"
                                    {% endif %}
                                >{{ lang.name }}</option>
                                {% endfor %}
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="" for="publisher">
                                {% trans "Publisher" %}</label>
                            <select name="publisher" class="form-control">
                                <option value="0">{% trans "All" %}</option>
                                {% for pub in item.publishers.all %}
                                <option value="{{ pub.publisher.pk }}"
                                    {% if volume_filters.publisher_id == pub.publisher.pk %}
                                    selected="selected"
                                    {% endif %}
                                    >{{ pub.publisher.name }}</option>
                                {% endfor %}
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="" for="collection">
                                {% trans "Collection" %}</label>
                            <select name="collection" class="form-control">
                                <option value="0">{% trans "All" %}</option>
                                {% for col in item.collections.all %}
                                <option value="{{ col.pk }}"
                                {% if volume_filters.collection_id == col.pk %}
                                    selected="selected"
                                    {% endif %}
                                >{{ col.name }}</option>
                                {% endfor %}
                            </select>
                        </div>
                        <button type="submit" class="btn btn-primary">{% trans "Filter" %}</button>
                    </form>
                </div>
                <div class="row">
                    {% for volume in item_volumes %}
                    <div class="col-sm-4">
                        {% include "manga/series/includes/volume.html" with volume=volume user=user show_publisher=True show_details=True show_language=True %}
                    </div>
                    {% if forloop.counter|divisibleby:3 %}
                    </div>
                    <div class="row">
                    {% endif %}
                    {% endfor %}
                </div>
                {% endblock %}
            </div>
        </div>
    </div>
</div>
{% endblock %}
