HH/templates/organizations/subsection_list.html
2026-02-22 08:35:53 +03:00

147 lines
8.3 KiB
HTML

{% extends 'layouts/base.html' %}
{% load i18n %}
{% block title %}{% trans "Subsections" %} - PX360{% endblock %}
{% block content %}
<div class="mb-8">
<div class="flex justify-between items-center">
<div>
<h1 class="text-3xl font-bold text-gray-800 mb-2">{% trans "Subsections" %}</h1>
<p class="text-gray-400">{% trans "Manage hospital subsections within sections" %}</p>
</div>
<a href="{% url 'organizations:subsection_create' %}" class="bg-light0 text-white px-6 py-3 rounded-2xl font-bold flex items-center gap-2 shadow-lg shadow-blue-200 hover:bg-navy transition">
<i data-lucide="plus" class="w-5 h-5"></i> {% trans "Add Subsection" %}
</a>
</div>
</div>
<!-- Filters -->
<div class="bg-white p-6 rounded-2xl shadow-sm border border-gray-50 mb-6">
<form method="get" class="grid grid-cols-1 md:grid-cols-4 gap-4">
<div class="md:col-span-2">
<label class="block text-sm font-semibold text-gray-700 mb-2">{% trans "Search" %}</label>
<input type="text" class="w-full px-4 py-3 border border-gray-200 rounded-xl text-gray-800 focus:ring-2 focus:ring-navy focus:border-transparent transition" name="search" placeholder="{% trans 'Search subsections...' %}" value="{{ filters.search }}">
</div>
<div>
<label class="block text-sm font-semibold text-gray-700 mb-2">{% trans "Section" %}</label>
<select class="w-full px-4 py-3 border border-gray-200 rounded-xl text-gray-800 focus:ring-2 focus:ring-navy focus:border-transparent transition" name="section">
<option value="">{% trans "All Sections" %}</option>
{% for sec in sections %}
<option value="{{ sec.id }}" {% if filters.section == sec.id|stringformat:'s' %}selected{% endif %}>{{ sec.name }}</option>
{% endfor %}
</select>
</div>
<div>
<label class="block text-sm font-semibold text-gray-700 mb-2">{% trans "Status" %}</label>
<select class="w-full px-4 py-3 border border-gray-200 rounded-xl text-gray-800 focus:ring-2 focus:ring-navy focus:border-transparent transition" name="status">
<option value="">{% trans "All Status" %}</option>
<option value="active" {% if filters.status == 'active' %}selected{% endif %}>{% trans "Active" %}</option>
<option value="inactive" {% if filters.status == 'inactive' %}selected{% endif %}>{% trans "Inactive" %}</option>
</select>
</div>
<div class="md:col-span-2 flex items-end">
<div class="flex gap-2 w-full">
<button type="submit" class="flex-1 bg-light0 text-white px-4 py-3 rounded-xl font-semibold hover:bg-navy transition flex items-center justify-center gap-2">
<i data-lucide="search" class="w-4 h-4"></i> {% trans "Filter" %}
</button>
<a href="{% url 'organizations:subsection_list' %}" class="bg-gray-100 text-gray-600 px-4 py-3 rounded-xl font-semibold hover:bg-gray-200 transition flex items-center justify-center gap-2">
<i data-lucide="x-circle" class="w-4 h-4"></i>
</a>
</div>
</div>
</form>
</div>
<!-- Table -->
<div class="bg-white rounded-2xl shadow-sm border border-gray-50 overflow-hidden">
<div class="overflow-x-auto">
<table class="w-full">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Name" %}</th>
<th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Code" %}</th>
<th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Section" %}</th>
<th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Department" %}</th>
<th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Head" %}</th>
<th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Status" %}</th>
<th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Actions" %}</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-50">
{% for subsection in subsections %}
<tr class="hover:bg-gray-50 transition">
<td class="px-6 py-4">
<span class="font-semibold text-gray-800">{{ subsection.name }}</span>
</td>
<td class="px-6 py-4 text-gray-700">
{{ subsection.code|default:"-" }}
</td>
<td class="px-6 py-4">
<span class="px-2.5 py-1 rounded-lg text-xs font-bold bg-purple-100 text-purple-600">
{{ subsection.section.name }}
</span>
</td>
<td class="px-6 py-4 text-gray-700">
{{ subsection.section.department.name }}
</td>
<td class="px-6 py-4 text-gray-700">
{{ subsection.head|default:"-" }}
</td>
<td class="px-6 py-4">
{% if subsection.status == 'active' %}
<span class="px-2.5 py-1 rounded-lg text-xs font-bold bg-green-100 text-green-600">{% trans "Active" %}</span>
{% else %}
<span class="px-2.5 py-1 rounded-lg text-xs font-bold bg-gray-100 text-gray-600">{% trans "Inactive" %}</span>
{% endif %}
</td>
<td class="px-6 py-4">
<div class="flex gap-1">
<a href="{% url 'organizations:subsection_update' subsection.id %}" class="p-2 text-navy hover:bg-light rounded-lg transition" title="{% trans 'Edit' %}">
<i data-lucide="edit-2" class="w-4 h-4"></i>
</a>
<a href="{% url 'organizations:subsection_delete' subsection.id %}" class="p-2 text-red-500 hover:bg-red-50 rounded-lg transition" title="{% trans 'Delete' %}">
<i data-lucide="trash-2" class="w-4 h-4"></i>
</a>
</div>
</td>
</tr>
{% empty %}
<tr>
<td colspan="7" class="px-6 py-12 text-center text-gray-500">
<i data-lucide="layers" class="w-12 h-12 mx-auto mb-3 text-gray-300"></i>
<p class="font-semibold">{% trans "No subsections found" %}</p>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- Pagination -->
{% if page_obj.has_other_pages %}
<div class="px-6 py-4 border-t border-gray-100 flex justify-between items-center">
<div class="text-sm text-gray-500">
{% blocktrans with current=page_obj.number total=page_obj.paginator.num_pages %}{{ current }} of {{ total }}{% endblocktrans %}
</div>
<div class="flex gap-2">
{% if page_obj.has_previous %}
<a href="?page={{ page_obj.previous_page_number }}&{{ filters|urlencode }}" class="px-3 py-2 border border-gray-200 rounded-lg text-sm font-semibold hover:bg-gray-50 transition">
<i data-lucide="chevron-left" class="w-4 h-4"></i>
</a>
{% endif %}
<span class="px-3 py-2 bg-light0 text-white rounded-lg text-sm font-bold">
{{ page_obj.number }}
</span>
{% if page_obj.has_next %}
<a href="?page={{ page_obj.next_page_number }}&{{ filters|urlencode }}" class="px-3 py-2 border border-gray-200 rounded-lg text-sm font-semibold hover:bg-gray-50 transition">
<i data-lucide="chevron-right" class="w-4 h-4"></i>
</a>
{% endif %}
</div>
</div>
{% endif %}
</div>
{% endblock %}