{% extends 'vacancy_mgr/base.html' %}
{% load static %}
{% load humanize %}

    {% block head_title %}賃貸管理業者一覧{% endblock %}
    {% block head %}
        <link rel="stylesheet" href="{% static 'trader/css/style.css' %}">
    {% endblock %}

    {% block page_top %}{% endblock %}

    {% block header %}{% endblock %}

    {% block h1_title %}【賃貸管理業者一覧】{% endblock %}

    {% block contents %}
        <div id="search-conditions-form">
            <form action="" method="post" enctype="multipart/form-data">
                {% csrf_token %}
                <div class="form-group row">
                    <div class="col col-2 col-form-label"><label class="float-right">業者名</label></div>
                    <div class="col-8">{{ form.trader_name }}</div>
                    <div class="col-2"></div>
                </div>
                <div class="form-group row">
                    <div class="col-2"></div>
                    <div class="col-4">
                        <input type="submit" value="検索" class="btn d-block mx-auto d-flex align-items-center btn-primary">
                    </div>
                    <div class="col-4">
                        <input type="submit" value="クリア" v-on:click="clearConditions($event)" class="btn d-block mx-auto d-flex align-items-center btn-secondary">
                    </div>
                    <div class="col-2"></div>
                </div>
            </form>
        </div>

        <div  id="data-list-header">
            <div class="row">
                <div id="link-add-item" class="col col-6 text-left">
                    <a href="{% url 'trader_create_trader' %}">業者追加</a>
                </div>
                <div id="link-change-list" class="col col-6 text-right">
                {% if all_traders %}
                    <a href="{% url 'trader_trader_list' %}">業者一覧</a>
                {% else %}
                    <a href="{% url 'trader_all_trader_list' %}">全業者一覧</a>
                {% endif %}
                </div>
            </div>
        </div>
        <div id="data-list">
        {% if traders %}
            <div class="row">
                <div class="col col-10 text-center">賃貸管理業者名</div>
                <div class="col col-1 text-center">停止</div>
                <div class="col col-1 text-center">削除</div>
            </div>
            {% for item in traders %}
            <div class="row">
                <div class="col col-10"><a href="{% url 'trader_detail' item.idb64 %}" target="_blank" rel="noopener noreferrer">{{ item.trader_name }}</a></div>
                <div class="col col-1 text-center">{% if item.is_stopped %}×{% else %}－{% endif %}</div>
                <div class="col col-1 text-center">{% if item.is_deleted %}×{% else %}－{% endif %}</div>
            </div>
            {% endfor %}
        {% else %}
            <div class="row">
                <div class="col col-12 text-center">該当する賃貸管理業者はありません。</div>
            </div>
        {% endif %}
        </div>
    {% endblock %}

    {% block footer %}{% endblock %}

    {% block page_bottom %}
        <script type="text/javascript" src="{% static 'trader/js/search_name.js' %}"></script>
        <script type="text/javascript">
            var searchApp = createSearchNameVue(
                "{{ default_trader_name | default_if_none:'' }}"
            );
        </script>
    {% endblock %}
