HH/templates/complaints/oncall/admin_form.html
2026-02-22 08:35:53 +03:00

217 lines
11 KiB
HTML

{% extends "layouts/base.html" %}
{% load i18n %}
{% load static %}
{% block title %}{{ title }} - PX 360{% endblock %}
{% block content %}
<div class="max-w-2xl mx-auto p-6">
<!-- Header -->
<div class="mb-6">
<div class="flex items-center gap-4">
<a href="{% url 'complaints:oncall_schedule_detail' schedule.id %}" class="text-[#64748b] hover:text-[#005696]">
<i data-lucide="arrow-left" class="w-6 h-6"></i>
</a>
<div>
<h1 class="text-2xl font-bold text-[#005696]">{{ title }}</h1>
<p class="text-[#64748b] mt-1">
{% trans "Schedule" %}: {% if schedule.hospital %}{{ schedule.hospital.name }}{% else %}{% trans "System-wide" %}{% endif %}
</p>
</div>
</div>
</div>
<!-- Form -->
<div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
<form method="post" class="p-6">
{% csrf_token %}
<!-- Admin Selection (only for new) -->
{% if not on_call_admin %}
<div class="mb-6">
<h2 class="text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2">
<i data-lucide="user" class="w-5 h-5 text-[#005696]"></i>
{% trans "Select Admin" %}
</h2>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">
{% trans "PX Admin User" %} <span class="text-red-500">*</span>
</label>
<select name="admin_user" required
class="w-full px-4 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-[#005696] focus:border-transparent">
<option value="">{% trans "Select an admin..." %}</option>
{% for admin in available_admins %}
<option value="{{ admin.id }}">
{{ admin.get_full_name|default:admin.email }} ({{ admin.email }})
</option>
{% empty %}
<option value="" disabled>{% trans "No available PX Admins" %}</option>
{% endfor %}
</select>
{% if not available_admins %}
<p class="mt-1 text-sm text-amber-600">
{% trans "All PX Admins are already assigned to this schedule." %}
</p>
{% endif %}
</div>
</div>
{% else %}
<div class="mb-6">
<h2 class="text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2">
<i data-lucide="user" class="w-5 h-5 text-[#005696]"></i>
{% trans "Admin" %}
</h2>
<div class="flex items-center gap-3 p-4 bg-gray-50 rounded-lg">
<div class="w-12 h-12 bg-[#eef6fb] rounded-full flex items-center justify-center">
<span class="text-[#005696] font-medium text-lg">
{{ on_call_admin.admin_user.first_name|first|default:on_call_admin.admin_user.email|first|upper }}
</span>
</div>
<div>
<p class="font-medium text-gray-900">{{ on_call_admin.admin_user.get_full_name|default:on_call_admin.admin_user.email }}</p>
<p class="text-sm text-[#64748b]">{{ on_call_admin.admin_user.email }}</p>
</div>
</div>
</div>
{% endif %}
<!-- Active Period -->
<div class="mb-6">
<h2 class="text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2">
<i data-lucide="calendar" class="w-5 h-5 text-[#005696]"></i>
{% trans "Active Period" %}
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">
{% trans "Start Date (Optional)" %}
</label>
<input type="date" name="start_date"
value="{{ on_call_admin.start_date|date:'Y-m-d'|default:'' }}"
class="w-full px-4 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-[#005696] focus:border-transparent">
<p class="mt-1 text-xs text-[#64748b]">{% trans "Leave empty for immediate activation" %}</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">
{% trans "End Date (Optional)" %}
</label>
<input type="date" name="end_date"
value="{{ on_call_admin.end_date|date:'Y-m-d'|default:'' }}"
class="w-full px-4 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-[#005696] focus:border-transparent">
<p class="mt-1 text-xs text-[#64748b]">{% trans "Leave empty for permanent assignment" %}</p>
</div>
</div>
</div>
<!-- Notification Settings -->
<div class="mb-6">
<h2 class="text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2">
<i data-lucide="bell" class="w-5 h-5 text-[#005696]"></i>
{% trans "Notification Settings" %}
</h2>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">
{% trans "Notification Priority" %}
</label>
<select name="notification_priority"
class="w-full px-4 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-[#005696] focus:border-transparent">
{% for i in "12345" %}
<option value="{{ i }}" {% if on_call_admin.notification_priority == i|add:0 %}selected{% endif %}>
{{ i }} - {% if i == "1" %}{% trans "Highest" %}{% elif i == "5" %}{% trans "Lowest" %}{% else %}{% trans "Priority" %} {{ i }}{% endif %}
</option>
{% endfor %}
</select>
<p class="mt-1 text-xs text-[#64748b]">{% trans "Lower numbers = higher priority in notification order" %}</p>
</div>
<div class="flex items-center gap-3">
<input type="checkbox" name="is_active" id="is_active"
{% if not on_call_admin or on_call_admin.is_active %}checked{% endif %}
class="w-5 h-5 text-[#005696] border-gray-300 rounded focus:ring-[#005696]">
<label for="is_active" class="text-sm font-medium text-gray-700">
{% trans "On-call assignment is active" %}
</label>
</div>
</div>
</div>
<!-- Contact Preferences -->
<div class="mb-6">
<h2 class="text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2">
<i data-lucide="mail" class="w-5 h-5 text-[#005696]"></i>
{% trans "Contact Preferences" %}
</h2>
<div class="space-y-4">
<div class="flex items-center gap-3">
<input type="checkbox" name="notify_email" id="notify_email"
{% if not on_call_admin or on_call_admin.notify_email %}checked{% endif %}
class="w-5 h-5 text-[#005696] border-gray-300 rounded focus:ring-[#005696]">
<label for="notify_email" class="text-sm font-medium text-gray-700">
{% trans "Send email notifications" %}
</label>
</div>
<div class="flex items-center gap-3">
<input type="checkbox" name="notify_sms" id="notify_sms"
{% if on_call_admin.notify_sms %}checked{% endif %}
class="w-5 h-5 text-[#005696] border-gray-300 rounded focus:ring-[#005696]">
<label for="notify_sms" class="text-sm font-medium text-gray-700">
{% trans "Send SMS notifications (for high priority complaints)" %}
</label>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">
{% trans "SMS Phone Number (Optional)" %}
</label>
<input type="tel" name="sms_phone"
value="{{ on_call_admin.sms_phone|default:'' }}"
placeholder="+966501234567"
class="w-full px-4 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-[#005696] focus:border-transparent">
<p class="mt-1 text-xs text-[#64748b]">
{% trans "Leave empty to use the user's profile phone number" %}
</p>
</div>
</div>
</div>
<!-- Info Box -->
<div class="bg-[#eef6fb] rounded-lg p-4 mb-6">
<div class="flex items-start gap-3">
<i data-lucide="info" class="w-5 h-5 text-[#005696] flex-shrink-0 mt-0.5"></i>
<div>
<h3 class="font-medium text-[#005696]">{% trans "When are on-call admins notified?" %}</h3>
<p class="text-sm text-[#64748b] mt-1">
{% trans "On-call admins are notified outside of working hours (as configured in the schedule) via BOTH email and SMS. During working hours, ALL PX Admins are notified via email only." %}
</p>
</div>
</div>
</div>
<!-- Actions -->
<div class="flex items-center justify-end gap-3 pt-6 border-t border-gray-100">
<a href="{% url 'complaints:oncall_schedule_detail' schedule.id %}"
class="px-6 py-2 border border-gray-200 text-gray-600 rounded-lg hover:bg-gray-50 transition-colors">
{% trans "Cancel" %}
</a>
<button type="submit" class="px-6 py-2 bg-[#005696] text-white rounded-lg hover:bg-[#007bbd] transition-colors"
{% if not on_call_admin and not available_admins %}disabled{% endif %}>
{% if on_call_admin %}{% trans "Update Assignment" %}{% else %}{% trans "Add Admin" %}{% endif %}
</button>
</div>
</form>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
lucide.createIcons();
});
</script>
{% endblock %}