HH/templates/complaints/request_explanation_form.html
2026-03-15 23:48:45 +03:00

324 lines
13 KiB
HTML

{% extends "layouts/base.html" %}
{% load i18n %}
{% block title %}{% trans "Request Explanation" %} - {{ complaint.reference_number }} - PX360{% endblock %}
{% block extra_css %}
<style>
.page-header-gradient {
background: linear-gradient(135deg, #005696 0%, #0069a8 50%, #007bbd 100%);
color: white;
padding: 1.5rem 2rem;
border-radius: 1rem;
margin-bottom: 1.5rem;
box-shadow: 0 10px 15px -3px rgba(0, 86, 150, 0.2);
}
.form-section {
background: #fff;
border: 2px solid #e2e8f0;
border-radius: 1rem;
padding: 1.5rem;
margin-bottom: 1.5rem;
transition: all 0.3s ease;
}
.form-section:hover {
border-color: #005696;
box-shadow: 0 4px 12px rgba(0, 86, 150, 0.1);
}
.form-label {
display: block;
font-size: 0.875rem;
font-weight: 600;
color: #1e293b;
margin-bottom: 0.5rem;
}
.form-control, .form-select {
width: 100%;
padding: 0.75rem 1rem;
border: 2px solid #e2e8f0;
border-radius: 0.75rem;
font-size: 0.875rem;
transition: all 0.2s ease;
}
.form-control:focus, .form-select:focus {
outline: none;
border-color: #005696;
box-shadow: 0 0 0 3px rgba(0, 86, 150, 0.1);
}
.btn-primary {
display: inline-flex;
align-items: center;
gap: 0.5rem;
padding: 0.75rem 1.5rem;
background: #005696;
color: white;
border-radius: 0.75rem;
font-weight: 600;
transition: all 0.2s ease;
border: none;
cursor: pointer;
}
.btn-primary:hover {
background: #007bbd;
}
.btn-secondary {
display: inline-flex;
align-items: center;
gap: 0.5rem;
padding: 0.75rem 1.5rem;
background: white;
color: #64748b;
border: 2px solid #e2e8f0;
border-radius: 0.75rem;
font-weight: 600;
transition: all 0.2s ease;
}
.btn-secondary:hover {
background: #f1f5f9;
border-color: #005696;
}
</style>
{% endblock %}
{% block content %}
<!-- Back Button -->
<div class="mb-6">
<a href="{% url 'complaints:complaint_detail' pk=complaint.pk %}" class="btn-secondary">
<i data-lucide="arrow-left" class="w-4 h-4"></i> {% trans "Back to Complaint" %}
</a>
</div>
<!-- Header -->
<div class="page-header-gradient">
<div class="flex items-center gap-2 text-sm text-white/80 mb-2">
<a href="{% url 'complaints:complaint_list' %}" class="hover:text-white">{% trans "Complaints" %}</a>
<i data-lucide="chevron-right" class="w-4 h-4"></i>
<a href="{% url 'complaints:complaint_detail' pk=complaint.pk %}" class="hover:text-white">{{ complaint.reference_number }}</a>
<i data-lucide="chevron-right" class="w-4 h-4"></i>
<span class="font-bold">{% trans "Request Explanation" %}</span>
</div>
<h1 class="text-2xl font-bold">{% trans "Request Explanation" %}</h1>
<p class="text-white/80 mt-1">{{ complaint.title }}</p>
</div>
<form method="post" class="space-y-6">
{% csrf_token %}
<!-- Recipients Selection -->
<section class="form-section">
<div class="flex items-center justify-between mb-6">
<h3 class="font-bold text-[#1e293b] text-lg flex items-center gap-2">
<i data-lucide="users" class="w-5 h-5 text-[#005696]"></i>
{% trans "Select Recipients" %}
</h3>
<div class="flex gap-2">
<button type="button" onclick="selectAllStaff()" class="px-3 py-1.5 text-xs font-semibold text-[#005696] border-2 border-[#e2e8f0] rounded-lg hover:border-[#005696] hover:bg-[#f1f5f9] transition">
{% trans "Select All Staff" %}
</button>
<button type="button" onclick="selectAllManagers()" class="px-3 py-1.5 text-xs font-semibold text-[#005696] border-2 border-[#e2e8f0] rounded-lg hover:border-[#005696] hover:bg-[#f1f5f9] transition">
{% trans "Select All Managers" %}
</button>
<button type="button" onclick="deselectAll()" class="px-3 py-1.5 text-xs font-semibold text-[#64748b] border-2 border-[#e2e8f0] rounded-lg hover:border-[#005696] hover:bg-[#f1f5f9] transition">
{% trans "Deselect All" %}
</button>
</div>
</div>
{% if recipients %}
<div class="space-y-4">
{% for recipient in recipients %}
<div class="border-2 border-[#e2e8f0] rounded-xl p-4 hover:border-[#005696] transition">
<div class="flex items-start gap-4">
<!-- Staff Checkbox -->
<div class="pt-1">
<input type="checkbox"
name="selected_staff"
value="{{ recipient.staff_id }}"
id="staff_{{ recipient.staff_id }}"
class="staff-checkbox w-5 h-5 text-[#005696] border-2 border-[#e2e8f0] rounded focus:ring-[#005696]"
checked
onchange="updateManagerCheckbox('{{ recipient.staff_id }}', '{{ recipient.manager_id }}')">
</div>
<!-- Staff Info -->
<div class="flex-1">
<div class="flex items-center gap-3 mb-2">
<div class="w-10 h-10 bg-[#005696] rounded-full flex items-center justify-center text-white font-bold text-sm">
{{ recipient.staff_name|first }}
</div>
<div>
<h4 class="font-bold text-[#1e293b]">{{ recipient.staff_name }}</h4>
<span class="text-xs text-[#64748b]">{{ recipient.role }}</span>
</div>
<span class="ml-auto px-2.5 py-1 bg-[#f1f5f9] rounded-lg text-xs font-bold text-[#64748b]">
{{ recipient.department }}
</span>
</div>
{% if recipient.manager %}
<div class="mt-3 pl-4 border-l-2 border-[#005696]/20">
<div class="flex items-center gap-3">
<!-- Manager Checkbox -->
<input type="checkbox"
name="selected_managers"
value="{{ recipient.manager_id }}"
id="manager_{{ recipient.manager_id }}"
class="manager-checkbox w-4 h-4 text-[#005696] border-2 border-[#e2e8f0] rounded focus:ring-[#005696]"
checked
data-staff-id="{{ recipient.staff_id }}">
<div class="flex items-center gap-2">
<i data-lucide="user-check" class="w-4 h-4 text-[#005696]"></i>
<span class="text-sm font-semibold text-[#64748b]">{% trans "Manager:" %}</span>
<span class="text-sm font-bold text-[#1e293b]">{{ recipient.manager_name }}</span>
</div>
</div>
<p class="text-xs text-[#64748b] mt-1 ml-7">
{% trans "Will receive notification only (no explanation link)" %}
</p>
</div>
{% else %}
<div class="mt-3 pl-4 border-l-2 border-[#e2e8f0]">
<p class="text-xs text-[#64748b] flex items-center gap-2">
<i data-lucide="alert-circle" class="w-4 h-4 text-amber-500"></i>
{% trans "No manager assigned to this staff member" %}
</p>
</div>
{% endif %}
{% if not recipient.staff_email %}
<div class="mt-2 p-2 bg-red-50 border-2 border-red-200 rounded-lg">
<p class="text-xs text-red-600 flex items-center gap-2">
<i data-lucide="alert-triangle" class="w-4 h-4"></i>
{% trans "This staff member has no email address. Request cannot be sent." %}
</p>
</div>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
{% else %}
<div class="text-center py-12">
<i data-lucide="users" class="w-16 h-16 mx-auto text-[#e2e8f0] mb-4"></i>
<p class="text-[#64748b] font-medium">{% trans "No staff members are involved in this complaint." %}</p>
</div>
{% endif %}
</section>
<!-- Message -->
<section class="form-section">
<h3 class="font-bold text-[#1e293b] mb-4 text-lg flex items-center gap-2">
<i data-lucide="message-square" class="w-5 h-5 text-[#005696]"></i>
{% trans "Additional Message" %}
</h3>
<div>
<label for="request_message" class="form-label">
{% trans "Optional message to include in the email" %}
</label>
<textarea name="request_message"
id="request_message"
rows="4"
class="form-control resize-none"
placeholder="{% trans 'Enter any additional context or instructions for the recipients...' %}"></textarea>
</div>
</section>
<!-- Summary -->
<section class="form-section bg-[#f8fafc]">
<div class="flex items-center justify-between flex-wrap gap-4">
<div>
<h4 class="font-bold text-[#1e293b] mb-1">{% trans "Summary" %}</h4>
<p class="text-sm text-[#64748b]">
<span id="staff-count">0</span> {% trans "staff will receive explanation links" %}
<span class="mx-2"></span>
<span id="manager-count">0</span> {% trans "managers will be notified" %}
</p>
</div>
<div class="flex items-center gap-4">
<a href="{% url 'complaints:complaint_detail' pk=complaint.pk %}"
class="btn-secondary">
{% trans "Cancel" %}
</a>
<button type="submit"
class="btn-primary"
id="submit-btn">
<i data-lucide="send" class="w-5 h-5"></i>
{% trans "Send Requests" %}
</button>
</div>
</div>
</section>
</form>
<script>
// Initialize counts on page load
document.addEventListener('DOMContentLoaded', function() {
updateCounts();
lucide.createIcons();
});
function selectAllStaff() {
document.querySelectorAll('.staff-checkbox').forEach(cb => {
cb.checked = true;
});
updateCounts();
}
function selectAllManagers() {
document.querySelectorAll('.manager-checkbox').forEach(cb => {
cb.checked = true;
});
updateCounts();
}
function deselectAll() {
document.querySelectorAll('.staff-checkbox, .manager-checkbox').forEach(cb => {
cb.checked = false;
});
updateCounts();
}
function updateManagerCheckbox(staffId, managerId) {
// If staff is unchecked, also uncheck their manager
const staffCheckbox = document.getElementById('staff_' + staffId);
if (managerId && !staffCheckbox.checked) {
const managerCheckbox = document.getElementById('manager_' + managerId);
if (managerCheckbox) {
managerCheckbox.checked = false;
}
}
updateCounts();
}
function updateCounts() {
const staffCount = document.querySelectorAll('.staff-checkbox:checked').length;
const managerCount = document.querySelectorAll('.manager-checkbox:checked').length;
document.getElementById('staff-count').textContent = staffCount;
document.getElementById('manager-count').textContent = managerCount;
// Enable/disable submit button
const submitBtn = document.getElementById('submit-btn');
if (staffCount === 0) {
submitBtn.disabled = true;
submitBtn.classList.add('opacity-50', 'cursor-not-allowed');
} else {
submitBtn.disabled = false;
submitBtn.classList.remove('opacity-50', 'cursor-not-allowed');
}
}
// Update counts when any checkbox changes
document.querySelectorAll('.staff-checkbox, .manager-checkbox').forEach(cb => {
cb.addEventListener('change', updateCounts);
});
</script>
{% endblock %}