345 lines
15 KiB
HTML
345 lines
15 KiB
HTML
{% extends "layouts/base.html" %}
|
|
{% load i18n %}
|
|
|
|
{% block title %}{% trans "PX Sources" %} - PX360{% endblock %}
|
|
|
|
{% block extra_css %}
|
|
<style>
|
|
:root {
|
|
--hh-navy: #005696;
|
|
--hh-blue: #007bbd;
|
|
--hh-light: #eef6fb;
|
|
--hh-slate: #64748b;
|
|
--hh-success: #10b981;
|
|
--hh-warning: #f59e0b;
|
|
--hh-danger: #ef4444;
|
|
}
|
|
|
|
.page-header {
|
|
background: linear-gradient(135deg, var(--hh-navy) 0%, #0069a8 50%, var(--hh-blue) 100%);
|
|
color: white;
|
|
padding: 2rem 2.5rem;
|
|
border-radius: 1rem;
|
|
margin-bottom: 2rem;
|
|
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.page-header::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
right: 0;
|
|
width: 200px;
|
|
height: 200px;
|
|
background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
|
|
}
|
|
|
|
.data-card {
|
|
background: white;
|
|
border-radius: 1rem;
|
|
border: 1px solid #e2e8f0;
|
|
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.data-card:hover {
|
|
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.card-header {
|
|
background: linear-gradient(135deg, var(--hh-light), #e0f2fe);
|
|
padding: 1.25rem 1.75rem;
|
|
border-bottom: 1px solid #bae6fd;
|
|
border-radius: 1rem 1rem 0 0;
|
|
}
|
|
|
|
.data-table th {
|
|
background: linear-gradient(135deg, var(--hh-light), #e0f2fe);
|
|
padding: 0.875rem 1rem;
|
|
text-align: left;
|
|
font-size: 0.75rem;
|
|
font-weight: 700;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
color: var(--hh-navy);
|
|
border-bottom: 2px solid #bae6fd;
|
|
}
|
|
|
|
.data-table td {
|
|
padding: 1rem;
|
|
border-bottom: 1px solid #f1f5f9;
|
|
color: #475569;
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
.data-table tbody tr {
|
|
transition: background-color 0.2s ease;
|
|
}
|
|
|
|
.data-table tbody tr:hover {
|
|
background-color: var(--hh-light);
|
|
}
|
|
|
|
.source-type-badge {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 0.375rem;
|
|
padding: 0.25rem 0.75rem;
|
|
border-radius: 9999px;
|
|
font-size: 0.75rem;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.source-type-badge.internal {
|
|
background: linear-gradient(135deg, #dbeafe, #bfdbfe);
|
|
color: #1e40af;
|
|
}
|
|
|
|
.source-type-badge.external {
|
|
background: linear-gradient(135deg, #dcfce7, #bbf7d0);
|
|
color: #166534;
|
|
}
|
|
|
|
.source-type-badge.partner {
|
|
background: linear-gradient(135deg, #fef3c7, #fde68a);
|
|
color: #92400e;
|
|
}
|
|
|
|
.source-type-badge.government {
|
|
background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
|
|
color: #3730a3;
|
|
}
|
|
|
|
.usage-stat {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 0.25rem;
|
|
font-size: 0.75rem;
|
|
color: var(--hh-slate);
|
|
}
|
|
|
|
@keyframes fadeIn {
|
|
from { opacity: 0; transform: translateY(20px); }
|
|
to { opacity: 1; transform: translateY(0); }
|
|
}
|
|
|
|
.animate-in {
|
|
animation: fadeIn 0.5s ease-out forwards;
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="px-4 py-6">
|
|
<!-- Page Header -->
|
|
<div class="page-header animate-in">
|
|
<div class="flex items-center justify-between">
|
|
<div>
|
|
<h1 class="text-2xl font-bold mb-2">
|
|
<i data-lucide="radio" class="w-7 h-7 inline-block me-2"></i>
|
|
{% trans "PX Sources" %}
|
|
</h1>
|
|
<p class="text-white/90">{% trans "Manage patient experience source channels" %}</p>
|
|
</div>
|
|
<a href="{% url 'px_sources:source_create' %}"
|
|
class="inline-flex items-center gap-2 bg-white text-navy px-5 py-2.5 rounded-xl font-bold hover:bg-light transition shadow-lg">
|
|
<i data-lucide="plus" class="w-4 h-4"></i>
|
|
{% trans "Add Source" %}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Sources Card -->
|
|
<div class="data-card animate-in">
|
|
<div class="card-header">
|
|
<h2 class="text-lg font-bold text-navy flex items-center gap-2 m-0">
|
|
<i data-lucide="database" class="w-5 h-5"></i>
|
|
{% trans "All Sources" %}
|
|
</h2>
|
|
</div>
|
|
|
|
<div class="p-6">
|
|
<!-- Filters -->
|
|
<div class="flex flex-wrap gap-3 mb-6">
|
|
<div class="flex-1 min-w-[250px]">
|
|
<label class="block text-sm font-semibold text-slate mb-1.5">{% trans "Search" %}</label>
|
|
<div class="relative">
|
|
<i data-lucide="search" class="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate"></i>
|
|
<input type="text" id="search-input"
|
|
class="w-full pl-10 pr-4 py-2.5 border-2 border-slate-200 rounded-xl focus:outline-none focus:border-blue focus:ring-2 focus:ring-blue/20 transition"
|
|
placeholder="{% trans 'Search by name, code, or description...' %}" value="{{ search }}">
|
|
</div>
|
|
</div>
|
|
<div class="w-48">
|
|
<label class="block text-sm font-semibold text-slate mb-1.5">{% trans "Status" %}</label>
|
|
<select id="status-filter"
|
|
class="w-full px-4 py-2.5 border-2 border-slate-200 rounded-xl focus:outline-none focus:border-blue bg-white transition">
|
|
<option value="">{% trans "All Status" %}</option>
|
|
<option value="true" {% if is_active == 'true' %}selected{% endif %}>
|
|
{% trans "Active" %}
|
|
</option>
|
|
<option value="false" {% if is_active == 'false' %}selected{% endif %}>
|
|
{% trans "Inactive" %}
|
|
</option>
|
|
</select>
|
|
</div>
|
|
<div class="flex items-end">
|
|
<button id="apply-filters"
|
|
class="inline-flex items-center gap-2 px-6 py-2.5 bg-navy text-white rounded-xl font-bold hover:bg-blue transition shadow-lg shadow-navy/25">
|
|
<i data-lucide="filter" class="w-4 h-4"></i>
|
|
{% trans "Filter" %}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Sources Table -->
|
|
<div class="overflow-x-auto">
|
|
<table class="w-full data-table">
|
|
<thead>
|
|
<tr>
|
|
<th>{% trans "Code" %}</th>
|
|
<th>{% trans "Name (EN)" %}</th>
|
|
<th>{% trans "Name (AR)" %}</th>
|
|
<th>{% trans "Type" %}</th>
|
|
<th>{% trans "Usage" %}</th>
|
|
<th class="text-center">{% trans "Status" %}</th>
|
|
<th class="text-center">{% trans "Actions" %}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for source in sources %}
|
|
<tr>
|
|
<td>
|
|
<span class="font-mono text-xs bg-slate-100 px-2 py-1 rounded">{{ source.code }}</span>
|
|
</td>
|
|
<td>
|
|
<a href="{% url 'px_sources:source_detail' source.pk %}"
|
|
class="font-semibold text-navy hover:text-blue transition">
|
|
{{ source.name_en }}
|
|
</a>
|
|
</td>
|
|
<td dir="rtl">
|
|
<span class="text-slate">{{ source.name_ar|default:"-" }}</span>
|
|
</td>
|
|
<td>
|
|
<span class="source-type-badge {{ source.source_type }}">
|
|
{% if source.source_type == 'internal' %}
|
|
<i data-lucide="building" class="w-3 h-3"></i>
|
|
{% elif source.source_type == 'external' %}
|
|
<i data-lucide="globe" class="w-3 h-3"></i>
|
|
{% elif source.source_type == 'partner' %}
|
|
<i data-lucide="handshake" class="w-3 h-3"></i>
|
|
{% elif source.source_type == 'government' %}
|
|
<i data-lucide="landmark" class="w-3 h-3"></i>
|
|
{% else %}
|
|
<i data-lucide="circle" class="w-3 h-3"></i>
|
|
{% endif %}
|
|
{{ source.get_source_type_display }}
|
|
</span>
|
|
</td>
|
|
<td>
|
|
<div class="flex flex-col gap-1">
|
|
<span class="usage-stat">
|
|
<i data-lucide="file-text" class="w-3 h-3"></i>
|
|
{{ source.total_complaints }} {% trans "complaints" %}
|
|
</span>
|
|
<span class="usage-stat">
|
|
<i data-lucide="help-circle" class="w-3 h-3"></i>
|
|
{{ source.total_inquiries }} {% trans "inquiries" %}
|
|
</span>
|
|
</div>
|
|
</td>
|
|
<td class="text-center">
|
|
{% if source.is_active %}
|
|
<span class="inline-flex items-center gap-1.5 px-3 py-1.5 bg-green-100 text-green-700 rounded-full text-xs font-bold">
|
|
<i data-lucide="check-circle" class="w-3.5 h-3.5"></i>
|
|
{% trans "Active" %}
|
|
</span>
|
|
{% else %}
|
|
<span class="inline-flex items-center gap-1.5 px-3 py-1.5 bg-slate-100 text-slate-600 rounded-full text-xs font-bold">
|
|
<i data-lucide="x-circle" class="w-3.5 h-3.5"></i>
|
|
{% trans "Inactive" %}
|
|
</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="text-center">
|
|
<div class="flex items-center justify-center gap-1.5">
|
|
<a href="{% url 'px_sources:source_detail' source.pk %}"
|
|
class="p-2 text-blue hover:bg-blue-50 rounded-lg transition" title="{% trans 'View' %}">
|
|
<i data-lucide="eye" class="w-4 h-4"></i>
|
|
</a>
|
|
{% if user.is_px_admin or user.is_hospital_admin %}
|
|
<a href="{% url 'px_sources:source_edit' source.pk %}"
|
|
class="p-2 text-navy hover:bg-navy/10 rounded-lg transition" title="{% trans 'Edit' %}">
|
|
<i data-lucide="edit" class="w-4 h-4"></i>
|
|
</a>
|
|
<a href="{% url 'px_sources:source_toggle_status' source.pk %}"
|
|
class="p-2 hover:bg-slate-100 rounded-lg transition"
|
|
title="{% if source.is_active %}{% trans 'Deactivate' %}{% else %}{% trans 'Activate' %}{% endif %}">
|
|
{% if source.is_active %}
|
|
<i data-lucide="pause" class="w-4 h-4 text-yellow-600"></i>
|
|
{% else %}
|
|
<i data-lucide="play" class="w-4 h-4 text-green-600"></i>
|
|
{% endif %}
|
|
</a>
|
|
{% if user.is_px_admin %}
|
|
<a href="{% url 'px_sources:source_delete' source.pk %}"
|
|
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>
|
|
{% endif %}
|
|
{% endif %}
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% empty %}
|
|
<tr>
|
|
<td colspan="7" class="py-12 text-center">
|
|
<div class="flex flex-col items-center">
|
|
<div class="w-16 h-16 bg-slate-100 rounded-full flex items-center justify-center mb-4">
|
|
<i data-lucide="database" class="w-8 h-8 text-slate-400"></i>
|
|
</div>
|
|
<p class="text-slate font-medium">{% trans "No sources found" %}</p>
|
|
<p class="text-slate text-sm mt-1">{% trans "Add your first source to get started" %}</p>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
lucide.createIcons();
|
|
|
|
// Filter functionality
|
|
document.getElementById('apply-filters').addEventListener('click', function() {
|
|
const search = document.getElementById('search-input').value;
|
|
const status = document.getElementById('status-filter').value;
|
|
|
|
let url = new URL(window.location.href);
|
|
url.searchParams.set('search', search);
|
|
if (status) {
|
|
url.searchParams.set('is_active', status);
|
|
} else {
|
|
url.searchParams.delete('is_active');
|
|
}
|
|
window.location.href = url.toString();
|
|
});
|
|
|
|
// Enter key to search
|
|
document.getElementById('search-input').addEventListener('keypress', function(e) {
|
|
if (e.key === 'Enter') {
|
|
document.getElementById('apply-filters').click();
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|