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

    {% block head_title %}{% if all_staffs %}全{% endif %}スタッフ一覧{% endblock %}
    {% block head %}
        <link rel="stylesheet" href="{% static 'company/css/style.css' %}">
    {% endblock %}

    {% block page_top %}{% endblock %}

    {% block header %}{% endblock %}

    {% block h1_title %}【{% if all_staffs %}全{% endif %}スタッフ一覧】{% endblock %}

    {% block contents %}
        <div id="search-conditions-form">
        {% if all_staffs %}
            <form action="{% url 'company_all_staff_list' %}" method="post" enctype="multipart/form-data">
        {% else %}
            <form action="{% url 'company_staff_list' %}" method="post" enctype="multipart/form-data">
        {% endif %}
                {% csrf_token %}
                <div class="form-group row">
                    <div class="col col-2 col-form-label"><label class="float-right">{{ form.last_name.label }}</label></div>
                    <div class="col-8">{{ form.last_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" name="clear_conditions" 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 'company_create_staff' %}">スタッフ追加</a>
                </div>
                <div id="link-change-list" class="col col-6 text-right">
                {% if all_staffs %}
                    <a href="{% url 'company_staff_list' %}">スタッフ一覧</a>
                {% else %}
                    <a href="{% url 'company_all_staff_list' %}">全スタッフ一覧</a>
                {% endif %}
                </div>
            </div>
        </div>
        <div id="data-list">
        {% if staffs %}
            <div class="row">
                <div class="col col-4 text-center">スタッフ名</div>
                <div class="col col-4 text-center">部署名</div>
                <div class="col col-2 text-center">表示順</div>
                <div class="col col-1 text-center">停止</div>
                <div class="col col-1 text-center">削除</div>
            </div>
            {% for item in staffs %}
            <div class="row">
                <div class="col col-4"><a href="{% url 'company_staff' item.idb64 %}" target="_blank" rel="noopener noreferrer">{{ item.full_name }}</a></div>
                <div class="col col-4">{{ item.department.department_name }}</div>
                <div class="col col-2 text-center">{{ item.priority }}</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 %}
    {% endblock %}

    {% block footer %}{% endblock %}

    {% block page_bottom %}
        <script type="text/javascript" src="{% static 'company/js/search_staff.js' %}"></script>
        <script type="text/javascript">
            var searchApp = createSearchStaffVue(
                "{{ last_name | default_if_none:'' }}"
            );
        </script>
    {% endblock %}
