{% extends "base.html" %} {% load static django_bootstrap5 %} {% block title %}Отделы{% endblock %} {% block extra_css %} {% endblock %} {% block content %}
{# ===== НОВАЯ ШАПКА С КОМПОНЕНТОМ ===== #} {# Кнопка создания отдела: staff/superuser ИЛИ право add_department #} {% if user.is_staff or user.is_superuser or perms.employees.add_department %} {% include "includes/components/page_header.html" with icon="bi-diagram-3" title="Отделы" count=departments|length count_label="Всего:" search_id="deptFilter" search_placeholder="Поиск по названию или руководителю" create_as_card=True create_modal="createDepartmentModal" create_text="Создать отдел" %} {% else %} {% include "includes/components/page_header.html" with icon="bi-diagram-3" title="Отделы" count=departments|length count_label="Всего:" search_id="deptFilter" search_placeholder="Поиск по названию или руководителю" %} {% endif %}
{# поддержка обоих форматов: dict(results) или list #} {% with rows=departments.results|default:departments %} {% for dept in rows %} {% with h=dept.head emp=dept.employees_count|default:0 %} {% url 'employees:department_detail' dept.id as dept_url %}
{% if dept_url %} {{ dept.name }} {% else %} {{ dept.name }} {% endif %}
{% if h %} Руководитель: {{ h.last_name }}{% if h.first_name %} {{ h.first_name }}{% endif %} {% endif %} {% if h and emp %} · {% endif %} {% if emp %}{{ emp }} сотрудников{% endif %}
{% if dept_url %} {% endif %}
{% endwith %} {% empty %}
Отделов пока нет.
{% endfor %} {% endwith %}
{# Пагинация #} {% if next_url or prev_url %}
Назад {% if count %} Всего: {{ count }} {% endif %} Вперёд
{% endif %}
Всего сотрудников: 0
{# Модальное окно для создания отдела #} {% include "employees/components/modal_create_department.html" %} {% endblock %}