HH/templates/organizations/department_inquiry_detail.html
ismail 185cc67c10 ux(inquiry): visible hint when Resolve is disabled until contact_status set
The department-side Resolve button is disabled (greyed out) until the
department records a patient contact outcome — the contact_status gate
in inquiry_change_status enforces this. Previously only a hover tooltip
explained why; now an inline amber hint appears next to the actions bar
so the reason is immediately visible.
2026-07-20 22:04:24 +03:00

204 lines
12 KiB
HTML

{% extends "layouts/base.html" %}
{% load i18n %}
{% block title %}{{ inquiry.reference_number }} - {{ department.get_localized_name }} - PX360{% endblock %}
{% block content %}
<div class="p-6 max-w-5xl mx-auto">
<div class="flex items-center gap-2 text-sm text-slate-500 mb-4">
<a href="{% url 'organizations:department_list' %}" class="hover:text-navy transition">{% trans "Departments" %}</a>
<i data-lucide="chevron-right" class="w-4 h-4"></i>
<a href="{% url 'organizations:department_detail' department.pk %}" class="hover:text-navy transition">{{ department.get_localized_name }}</a>
<i data-lucide="chevron-right" class="w-4 h-4"></i>
<a href="{% url 'organizations:department_inquiries_list' department.pk %}" class="hover:text-navy transition">{% trans "Inquiries" %}</a>
<i data-lucide="chevron-right" class="w-4 h-4"></i>
<span class="text-navy font-semibold">{{ inquiry.reference_number }}</span>
</div>
<div class="flex items-center justify-between mb-2">
<div class="flex items-center gap-3">
<div class="w-10 h-10 bg-amber-50 rounded-xl flex items-center justify-center">
<i data-lucide="help-circle" class="w-5 h-5 text-amber-600"></i>
</div>
<div>
<div class="flex items-center gap-2">
<h1 class="text-xl font-bold text-navy">{{ inquiry.reference_number }}</h1>
<span class="px-2.5 py-0.5 rounded-full text-[10px] font-bold uppercase
{% if inquiry.status == 'open' %}bg-blue-50 text-blue-700
{% elif inquiry.status == 'in_progress' %}bg-amber-50 text-amber-700
{% elif inquiry.status == 'resolved' %}bg-green-50 text-green-700
{% elif inquiry.status == 'closed' %}bg-slate-100 text-slate-600
{% elif inquiry.status == 'contact_no_response' %}bg-amber-100 text-amber-700
{% else %}bg-slate-50 text-slate-500{% endif %}">
{{ inquiry.get_status_display }}
</span>
</div>
<p class="text-sm text-slate-500">{% trans "Inquiry" %}</p>
</div>
</div>
<div class="flex items-center gap-3">
<a href="{% url 'organizations:department_inquiries_list' department.pk %}" class="text-sm text-slate hover:text-navy transition flex items-center gap-1">
<i data-lucide="arrow-left" class="w-4 h-4"></i> {% trans "Back to inquiries" %}
</a>
</div>
</div>
{% if can_respond and inquiry.status != 'closed' %}
<div class="bg-white rounded-2xl border border-slate-200 p-4 my-4 flex flex-wrap items-center gap-3">
<span class="text-xs font-bold text-slate-500 uppercase mr-2">{% trans "Department Actions" %}</span>
<!-- Set Contact Status -->
<form method="post" action="{% url 'inquiries:inquiry_set_contact_status' inquiry.pk %}" class="flex items-center gap-2">
{% csrf_token %}
<input type="hidden" name="next" value="{% url 'organizations:department_inquiry_detail' department.pk inquiry.pk %}">
<select name="contact_status" onchange="if(this.value){this.form.submit();}"
class="text-sm border border-slate-200 rounded-lg px-3 py-2 focus:ring-2 focus:ring-navy/20 outline-none">
<option value="">{% trans "Set contact status…" %}</option>
<option value="not_contacted" {% if inquiry.contact_status == 'not_contacted' %}selected{% endif %}>{% trans "Not Contacted" %}</option>
<option value="contacted" {% if inquiry.contact_status == 'contacted' %}selected{% endif %}>{% trans "Contacted" %}</option>
<option value="contacted_no_response" {% if inquiry.contact_status == 'contacted_no_response' %}selected{% endif %}>{% trans "Contacted - No Response" %}</option>
</select>
</form>
{% if inquiry.status == 'in_progress' and inquiry.contact_status == 'not_contacted' %}
<span class="inline-flex items-center gap-1.5 text-xs text-amber-700 bg-amber-50 border border-amber-200 rounded-lg px-2.5 py-1.5">
<i data-lucide="info" class="w-3.5 h-3.5"></i>
{% trans "Record a contact outcome above before resolving." %}
</span>
{% endif %}
{% if inquiry.status == 'in_progress' %}
<!-- Mark Resolved (requires a patient contact outcome first) -->
<form method="post" action="{% url 'inquiries:inquiry_change_status' inquiry.pk %}" onsubmit="return confirm('{% filter escapejs %}{% trans "Mark this inquiry as resolved?" %}{% endfilter %}')">
{% csrf_token %}
<input type="hidden" name="status" value="resolved">
<input type="hidden" name="next" value="{% url 'organizations:department_inquiry_detail' department.pk inquiry.pk %}">
<button type="submit"
{% if inquiry.contact_status != 'contacted' and inquiry.contact_status != 'contacted_no_response' %}disabled title="{% trans 'Record a patient contact outcome first' %}"{% endif %}
class="px-3 py-2 rounded-lg text-sm font-semibold flex items-center gap-1 transition
{% if inquiry.contact_status == 'contacted' or inquiry.contact_status == 'contacted_no_response' %}bg-green-600 text-white hover:bg-green-700
{% else %}bg-slate-100 text-slate-400 cursor-not-allowed{% endif %}">
<i data-lucide="check" class="w-4 h-4"></i> {% trans "Resolve" %}
</button>
</form>
<!-- Mark Closed -->
<form method="post" action="{% url 'inquiries:inquiry_change_status' inquiry.pk %}" onsubmit="return confirm('{% filter escapejs %}{% trans "Close this inquiry? No further actions will be available." %}{% endfilter %}')">
{% csrf_token %}
<input type="hidden" name="status" value="closed">
<input type="hidden" name="next" value="{% url 'organizations:department_inquiry_detail' department.pk inquiry.pk %}">
<button type="submit" class="px-3 py-2 bg-slate-200 text-slate-700 rounded-lg text-sm font-semibold hover:bg-slate-300 transition flex items-center gap-1">
<i data-lucide="x" class="w-4 h-4"></i> {% trans "Close" %}
</button>
</form>
<!-- Forward to another department (only available while in progress) -->
<button type="button"
onclick="showSendModal('{{ inquiry.pk }}', 'inquiry');"
class="px-3 py-2 bg-amber-50 text-amber-700 border border-amber-200 rounded-lg text-sm font-semibold hover:bg-amber-100 transition flex items-center gap-1">
<i data-lucide="share-2" class="w-4 h-4"></i> {% trans "Forward" %}
</button>
{% endif %}
</div>
{% endif %}
{% if inquiry.subject %}
<h2 class="text-lg font-semibold text-navy mt-4 mb-6">{{ inquiry.subject }}</h2>
{% endif %}
<div class="space-y-6 mt-6">
<div class="bg-white rounded-2xl border border-slate-200 p-6">
<h3 class="text-sm font-bold text-navy mb-3 flex items-center gap-2">
<i data-lucide="message-circle" class="w-4 h-4"></i> {% trans "Message" %}
</h3>
<p class="text-sm text-slate-700 whitespace-pre-wrap leading-relaxed">{{ inquiry.message|default:"—" }}</p>
</div>
<div class="bg-white rounded-2xl border border-slate-200 p-6">
<h3 class="text-sm font-bold text-navy mb-4 flex items-center gap-2">
<i data-lucide="info" class="w-4 h-4"></i> {% trans "Details" %}
</h3>
<div class="grid grid-cols-2 md:grid-cols-3 gap-4">
<div>
<p class="text-[10px] text-slate-400 uppercase font-bold mb-0.5">{% trans "Department" %}</p>
<p class="text-sm font-medium text-navy">{{ inquiry.department.get_localized_name|default:"—" }}</p>
</div>
{% if inquiry.outgoing_department %}
<div>
<p class="text-[10px] text-slate-400 uppercase font-bold mb-0.5">{% trans "Outgoing Department" %}</p>
<p class="text-sm font-medium text-navy">{{ inquiry.outgoing_department.get_localized_name }}</p>
</div>
{% endif %}
<div>
<p class="text-[10px] text-slate-400 uppercase font-bold mb-0.5">{% trans "Assigned To" %}</p>
<p class="text-sm font-medium text-navy">{{ inquiry.assigned_to.get_full_name|default:"—" }}</p>
</div>
<div>
<p class="text-[10px] text-slate-400 uppercase font-bold mb-0.5">{% trans "Contact" %}</p>
<p class="text-sm font-medium text-navy">{{ inquiry.contact_name|default:"—" }}</p>
</div>
{% if inquiry.contact_phone %}
<div>
<p class="text-[10px] text-slate-400 uppercase font-bold mb-0.5">{% trans "Phone" %}</p>
<p class="text-sm font-medium text-navy">{{ inquiry.contact_phone }}</p>
</div>
{% endif %}
{% if inquiry.contact_email %}
<div>
<p class="text-[10px] text-slate-400 uppercase font-bold mb-0.5">{% trans "Email" %}</p>
<p class="text-sm font-medium text-navy">{{ inquiry.contact_email }}</p>
</div>
{% endif %}
{% if inquiry.category %}
<div>
<p class="text-[10px] text-slate-400 uppercase font-bold mb-0.5">{% trans "Category" %}</p>
<p class="text-sm font-medium text-navy">{{ inquiry.get_category_display }}</p>
</div>
{% endif %}
{% if location_str %}
<div>
<p class="text-[10px] text-slate-400 uppercase font-bold mb-0.5">{% trans "Location" %}</p>
<p class="text-sm font-medium text-navy">{{ location_str }}</p>
</div>
{% endif %}
<div>
<p class="text-[10px] text-slate-400 uppercase font-bold mb-0.5">{% trans "Created" %}</p>
<p class="text-sm font-medium text-navy">{{ inquiry.created_at|date:"Y-m-d H:i" }}</p>
</div>
<div>
<p class="text-[10px] text-slate-400 uppercase font-bold mb-0.5">{% trans "Contact Status" %}</p>
<p class="text-sm font-medium
{% if inquiry.contact_status == 'contacted_no_response' %}text-amber-600
{% elif inquiry.contact_status == 'contacted' %}text-green-600
{% else %}text-navy{% endif %}">
{{ inquiry.get_contact_status_display|default:"—" }}
{% if inquiry.contact_status_at %}<span class="text-[10px] text-slate-400 font-normal ml-1">{{ inquiry.contact_status_at|date:"Y-m-d H:i" }}</span>{% endif %}
</p>
</div>
</div>
</div>
{% if inquiry.department_response_en or inquiry.department_response_ar %}
<div class="bg-green-50 rounded-2xl border border-green-100 p-6">
<h3 class="text-sm font-bold text-green-700 mb-3 flex items-center gap-2">
<i data-lucide="check-circle" class="w-4 h-4"></i> {% trans "Department Response" %}
{% if inquiry.department_responded_at %}
<span class="text-[10px] text-green-600 font-normal ml-2">{{ inquiry.department_responded_at|date:"Y-m-d H:i" }}</span>
{% endif %}
</h3>
{% if inquiry.department_response_en %}
<p class="text-sm text-slate-700 whitespace-pre-wrap mb-2">{{ inquiry.department_response_en }}</p>
{% endif %}
{% if inquiry.department_response_ar %}
<p class="text-sm text-slate-700 whitespace-pre-wrap" dir="rtl">{{ inquiry.department_response_ar }}</p>
{% endif %}
</div>
{% endif %}
{% include "partials/notes_panel.html" %}
</div>
</div>
{% include "components/send_to_modal.html" %}
{% endblock %}