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

198 lines
12 KiB
HTML

{% extends "layouts/base.html" %}
{% load i18n %}
{% load static %}
{% block title %}{{ title }} - PX 360{% endblock %}
{% block content %}
<div class="max-w-3xl mx-auto p-6">
<!-- Header -->
<div class="mb-6">
<div class="flex items-center gap-4">
<a href="{% url 'complaints:oncall_schedule_list' %}" 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">
{% if schedule %}{% trans "Update on-call schedule settings" %}{% else %}{% trans "Create a new on-call schedule" %}{% 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 %}
<!-- Scope Section -->
<div class="mb-8">
<h2 class="text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2">
<i data-lucide="building" class="w-5 h-5 text-[#005696]"></i>
{% trans "Schedule Scope" %}
</h2>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">
{% trans "Hospital (Optional)" %}
</label>
<select name="hospital" 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 "System-wide (All Hospitals)" %}</option>
{% for hospital in hospitals %}
<option value="{{ hospital.id }}" {% if schedule.hospital_id == hospital.id %}selected{% endif %}>
{{ hospital.name }}
</option>
{% endfor %}
</select>
<p class="mt-1 text-sm text-[#64748b]">
{% trans "Leave empty for system-wide configuration, or select a specific hospital." %}
</p>
</div>
<div class="flex items-center gap-3">
<input type="checkbox" name="is_active" id="is_active"
{% if not schedule or schedule.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 "Schedule is active" %}
</label>
</div>
</div>
</div>
<!-- Working Hours Section -->
<div class="mb-8">
<h2 class="text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2">
<i data-lucide="clock" class="w-5 h-5 text-[#005696]"></i>
{% trans "Working Hours Configuration" %}
</h2>
<div class="space-y-4">
<!-- Working Days -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">
{% trans "Working Days" %}
</label>
<div class="flex flex-wrap gap-3">
{% with working_days=schedule.get_working_days_list|default:"0,1,2,3,4"|slice:":" %}
<label class="flex items-center gap-2 px-3 py-2 border border-gray-200 rounded-lg cursor-pointer hover:bg-gray-50">
<input type="checkbox" name="working_day_0" value="0"
{% if schedule and 0 in schedule.get_working_days_list %}checked{% elif not schedule %}checked{% endif %}
class="w-4 h-4 text-[#005696] border-gray-300 rounded focus:ring-[#005696]">
<span class="text-sm">{% trans "Mon" %}</span>
</label>
<label class="flex items-center gap-2 px-3 py-2 border border-gray-200 rounded-lg cursor-pointer hover:bg-gray-50">
<input type="checkbox" name="working_day_1" value="1"
{% if schedule and 1 in schedule.get_working_days_list %}checked{% elif not schedule %}checked{% endif %}
class="w-4 h-4 text-[#005696] border-gray-300 rounded focus:ring-[#005696]">
<span class="text-sm">{% trans "Tue" %}</span>
</label>
<label class="flex items-center gap-2 px-3 py-2 border border-gray-200 rounded-lg cursor-pointer hover:bg-gray-50">
<input type="checkbox" name="working_day_2" value="2"
{% if schedule and 2 in schedule.get_working_days_list %}checked{% elif not schedule %}checked{% endif %}
class="w-4 h-4 text-[#005696] border-gray-300 rounded focus:ring-[#005696]">
<span class="text-sm">{% trans "Wed" %}</span>
</label>
<label class="flex items-center gap-2 px-3 py-2 border border-gray-200 rounded-lg cursor-pointer hover:bg-gray-50">
<input type="checkbox" name="working_day_3" value="3"
{% if schedule and 3 in schedule.get_working_days_list %}checked{% elif not schedule %}checked{% endif %}
class="w-4 h-4 text-[#005696] border-gray-300 rounded focus:ring-[#005696]">
<span class="text-sm">{% trans "Thu" %}</span>
</label>
<label class="flex items-center gap-2 px-3 py-2 border border-gray-200 rounded-lg cursor-pointer hover:bg-gray-50">
<input type="checkbox" name="working_day_4" value="4"
{% if schedule and 4 in schedule.get_working_days_list %}checked{% elif not schedule %}checked{% endif %}
class="w-4 h-4 text-[#005696] border-gray-300 rounded focus:ring-[#005696]">
<span class="text-sm">{% trans "Fri" %}</span>
</label>
<label class="flex items-center gap-2 px-3 py-2 border border-gray-200 rounded-lg cursor-pointer hover:bg-gray-50">
<input type="checkbox" name="working_day_5" value="5"
{% if schedule and 5 in schedule.get_working_days_list %}checked{% endif %}
class="w-4 h-4 text-[#005696] border-gray-300 rounded focus:ring-[#005696]">
<span class="text-sm">{% trans "Sat" %}</span>
</label>
<label class="flex items-center gap-2 px-3 py-2 border border-gray-200 rounded-lg cursor-pointer hover:bg-gray-50">
<input type="checkbox" name="working_day_6" value="6"
{% if schedule and 6 in schedule.get_working_days_list %}checked{% endif %}
class="w-4 h-4 text-[#005696] border-gray-300 rounded focus:ring-[#005696]">
<span class="text-sm">{% trans "Sun" %}</span>
</label>
{% endwith %}
</div>
<p class="mt-1 text-sm text-[#64748b]">
{% trans "Select the days that are considered working days. Outside these days, only on-call admins will be notified." %}
</p>
</div>
<!-- Time Range -->
<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 "Work Start Time" %}
</label>
<input type="time" name="work_start_time"
value="{{ schedule.work_start_time|time:'H:i'|default:'08:00' }}"
class="w-full px-4 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-[#005696] focus:border-transparent">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">
{% trans "Work End Time" %}
</label>
<input type="time" name="work_end_time"
value="{{ schedule.work_end_time|time:'H:i'|default:'17:00' }}"
class="w-full px-4 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-[#005696] focus:border-transparent">
</div>
</div>
<!-- Timezone -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">
{% trans "Timezone" %}
</label>
<select name="timezone" class="w-full px-4 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-[#005696] focus:border-transparent">
{% for tz in timezones %}
<option value="{{ tz }}" {% if schedule.timezone == tz %}selected{% elif not schedule and tz == 'Asia/Riyadh' %}selected{% endif %}>
{{ tz }}
</option>
{% endfor %}
</select>
</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 "How it works" %}</h3>
<p class="text-sm text-[#64748b] mt-1">
{% trans "During working hours, ALL PX Admins are notified of new complaints via email only. Outside working hours (after work end time, before work start time, or on non-working days), only the on-call admins assigned to this schedule will be notified via BOTH email and SMS." %}
</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_list' %}"
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 schedule %}{% trans "Update Schedule" %}{% else %}{% trans "Create Schedule" %}{% endif %}
</button>
</div>
</form>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
lucide.createIcons();
});
</script>
{% endblock %}