{% extends "layout-2-col.html" %}

{% block title %}Добавить книгу — Яндекс.Библиотека{% endblock %}

{% block l-page %}l-page_add{% endblock %}

{% block add_link %}<lego:item current=""><lego:text>Добавить книгу</lego:text></lego:item>{% endblock %}

{% block content %}
<lego:b-page-title>
    <lego:title>Добавление экземпляра книги в каталог</lego:title>
</lego:b-page-title>

<form class="b-add-book" onclick="return {list_publishers_json: '{% url list_publishers_json %}', list_books_json: '{% url list_books_json %}', addmy_url: '{% url add_my_book %}', current_user_login: '{{ user.profile.login_ld }}'}" action="{% url add_book %}" method="post">
    <div>
        <label class="section" style="margin-bottom: 30px; overflow: hidden;">
            <span class="label" style="font-size: 90%">Ссылка на книгу в магазине:</span>
            <div style="width: 50%; float: left; border: 2px;">
                <input type="text" value="{% if url %}{{ url }}{% endif %}" id="book_url" style="width: 70%;"/>
                <button id="fill_fields" disabled="">Заполнить поля</button>
            </div>
        </label>
        {{ form.publisher_id }}

        <label class="section">
            <strong class="label">{{ form.title.label }}:</strong>
            {{ form.title }}
        </label>
        {% if showerrors %}{{ form.title.errors }}{% endif %}

        <label class="section">
            <span class="label">{{ form.isbn.label }}:</span>
            {{ form.isbn }}
        </label>
        {% if showerrors %}{{ form.isbn.errors }}{% endif %}

        <label class="section">
            <span class="label">{{ form.authors_string.label }}:</span>
            {{ form.authors_string }}
        </label>
        {% if showerrors %}{{ form.authors_string.errors }}{% endif %}

        <label class="section">
            <span class="label">{{ form.publisher_name.label }}:</span>
            {{ form.publisher_name }}
        </label>
        {% if showerrors %}{{ form.publisher_name.errors }}{% endif %}

        <label class="section">
            <span class="label">{{ form.year.label }}:</span>
            {{ form.year }}
        </label>
        {% if showerrors %}{{ form.year.errors }}{% endif %}

        <label class="section js-owner-select">
            <span class="label">{{ form.ownership_choices.label }}:</span>
            {{ form.ownership_choices }}
        </label>
        {% if showerrors %}{{ form.ownership_choices.errors }}{% endif %}

        <label class="section js-owner js-autocomplete_staff {% if showerrors %}{% else %}g-hidden{% endif %}">
            <span class="label">{{ form.owner.label }}:</span>
            {{ form.owner }}
        </label>
        {% if showerrors %}{{ form.owner.errors }}{% endif %}

        <div class="section js-loc-select">
            <table border="0">
                <tr>
                    <td>
                        <span class="label">{{ form.location_choices.label }}:</span>
                    </td>
                    <td width="150px">
                        {{ form.location_choices }}
                    </td>
                    <td>
                        <div class="rfid-block">
                        <span class="rfid-label">{{ form.rfid.label }}:</span>
                        {{ form.rfid }}
                        </div>
			{% if showerrors %}<span style="color: red;">{{ rfid_exists_error }}</span>{% endif %}

                    </td>
                </tr>
            </table>
            {% if showerrors %}{{ form.location_choices.errors }}{% endif %}
        </div>

        <label class="section js-loc-who js-autocomplete_staff g-hidden">
            <span class="label">{{ form.location_staff.label }}:</span>
            {{ form.location_staff }}<br/><span class="label"></span>
            {{ form.is_tablebook }}<label for="id_is_tablebook"> {{ form.is_tablebook.label }}</label>
        </label>
        {% if showerrors %}{{ form.location_staff.errors }}{% endif %}

        <label class="section js-loc-where">
            <span class="label">{{ form.office.label }}:</span>
            {{ form.office }}
        </label>
        {% if showerrors %}{{ form.office.errors }}{% endif %}

        <label class="section">
            <span class="label">{{ form.cost.label }}:</span>
            {{ form.cost }}
        </label>
        {% if showerrors %}{{ form.cost.errors }}{% endif %}

        <label class="section">
            <span class="label">{{ form.comment.label }}:</span>
            {{ form.comment }}
        </label>
        {% if showerrors %}{{ form.comment.errors }}{% endif %}

        <label class="section">
            <span class="label">{{ form.shelf.label }}:</span>
            {{ form.shelf }}
        </label>
        {% if showerrors %}{{ form.shelf.errors }}{% endif %}

        <label class="section">
            <span class="label">{{ form.case.label }}:</span>
            {{ form.case }}
        </label>
        {% if showerrors %}{{ form.case.errors }}{% endif %}

        <input class="submit" type="submit" value="Добавить" />
    </div>
</form>
{% endblock %}
