{% load i18n %}

{% trans "Send To Department" %}

{% if complaint.sent_to_any_department %}
{% for idept in complaint.involved_departments.all %} {% if idept.sent %}
{{ idept.department.get_localized_name }} {% if idept.is_primary %} {% trans "Primary" %} {% endif %}
{{ idept.forwarded_at|date:"M d, Y" }}
{% if not idept.response_submitted %} {% trans "Awaiting Response" %} {% elif idept.manager_review_status == 'pending' %} {% trans "Pending Manager Review" %} {% elif idept.manager_review_status == 'rejected' %} {% trans "Rejected by Manager" %} {% elif idept.manager_review_status == 'approved' and idept.acceptance_status == 'pending' %} {% trans "Approved — Awaiting PX Review" %} {% elif idept.acceptance_status == 'acceptable' %} {% trans "Accepted" %} {% elif idept.acceptance_status == 'not_acceptable' %} {% trans "Rejected by PX" %} {% endif %}
{% if idept.response_notes %}

{% trans "Response" %}

{{ idept.response_notes|truncatechars:150 }}

{% endif %} {% if idept.manager_reviews.exists %}

{% trans "Manager Review Answers" %}

{% for review in idept.manager_reviews.all %}
{% for answer in review.answers.all %}
{{ answer.question.text_ar|default:answer.question.text_en }}: {% if answer.text_value == 'yes' %}{% trans "Yes" %}{% elif answer.text_value == 'no' %}{% trans "No" %}{% else %}{{ answer.text_value }}{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
{% endif %} {% endfor %}
{% if can_manage_actions and complaint.is_active_status %} {% endif %} {% endif %} {% if explanations %}
{% if can_manage_actions and complaint.is_active_status %} {% endif %}
{% for exp in explanations %}
{{ exp.staff.first_name|first }}{{ exp.staff.last_name|first }}

{{ exp.staff }}

{{ exp.staff.employee_id }} {% if exp.staff.department %} {{ exp.staff.department.get_localized_name }} {% endif %}
{% if exp.is_used %}{% trans "Submitted" %}{% else %}{% trans "Pending" %}{% endif %} {% if exp.is_used %} {{ exp.get_acceptance_status_display }} {% endif %}
{% if exp.escalated_to_manager %}
{% trans "Escalated to Manager" %} ({{ exp.escalated_to_manager.staff.get_full_name }})
{% if exp.acceptance_notes %}

{{ exp.acceptance_notes }}

{% endif %}
{% endif %} {% if exp.is_used and exp.explanation %} {% with linked_dept=exp.linked_involved_department %} {% if linked_dept and linked_dept.manager_review_status == 'pending' %}
{% trans "Pending Manager Review" %}

{% trans "Awaiting department manager approval." %}

{% elif linked_dept and linked_dept.manager_review_status == 'rejected' %}
{% trans "Rejected by Manager" %}

{% trans "Champion needs to re-submit." %}

{% else %}

{{ exp.explanation }}

{% if exp.attachment_count > 0 %}
{{ exp.attachment_count }} {% trans "attachment(s)" %}
{% endif %}
{% endif %} {% endwith %} {% endif %} {% if can_manage_actions and complaint.is_active_status and exp.is_used and not exp.escalated_to_manager %} {% with linked_dept=exp.linked_involved_department %} {% if not linked_dept or linked_dept.manager_review_status == 'approved' %}
{% if exp.acceptance_status == 'pending' %}
{% if exp.staff.report_to %} {% else %} {% trans "No Manager to Escalate" %} {% endif %}
{% else %}
{% trans "Reviewed by:" %} {{ exp.accepted_by.get_full_name }} {% trans "on" %} {{ exp.accepted_at|date:"Y-m-d H:i" }}
{% endif %}
{% endif %} {% endwith %} {% endif %} {% for inv in exp.investigation.all %}
{% trans "Feedback" %} {{ inv.questions.count }} {% trans "questions" %}
{% for resp in inv.responses.all %}
{% if resp.is_completed %} {{ resp.staff.get_full_name }} {{ resp.completed_at|date:"M d, H:i" }} {% else %} {{ resp.staff.get_full_name }} {% trans "Pending" %} {% endif %}
{% endfor %}
{% if inv.questions.exists %}
{% for question in inv.questions.all %}
{{ forloop.counter }}

{{ question.question_text }}

{% for resp in inv.responses.all %} {% if resp.is_completed %} {% with answer=resp.answers.all %} {% for a in answer %} {% if a.question_id == question.id and a.answer_text %}
{{ resp.staff.get_full_name }}: {{ a.answer_text|truncatewords:40 }}
{% endif %} {% endfor %} {% endwith %} {% endif %} {% endfor %}
{% endfor %}
{% endif %} {% if inv.status == 'answers_received' and inv.explanation.token %} {% trans "Review & Submit Reply" %} {% endif %} {% if inv.status == 'reply_submitted' and inv.final_reply %}

{% trans "Final Reply" %}

{{ inv.final_reply|truncatewords:30 }}

{% endif %} {% if inv.status == 'reply_submitted' and inv.negligence_finding %}
{% if inv.negligence_finding == 'yes' %} {% trans "Negligence" %} {% endif %} {% if inv.policy_issue_finding == 'yes' %} {% trans "Policy Issue" %} {% endif %} {% if inv.requires_improvement_project == 'yes' %} {% trans "Improvement Project" %} {% endif %}
{% endif %} {% if inv.status == 'reply_submitted' and inv.requires_improvement_project == 'yes' and inv.improvement_project_note %}

{% trans "Improvement Project Recommended" %}

{{ inv.improvement_project_note }}

{% endif %}
{% endfor %} {% if can_manage_actions and complaint.is_active_status and not exp.is_used %}
{% if not exp.reminder_sent_at %} {% elif not exp.second_reminder_sent_at %} {% else %} {% trans "Reminders Sent" %} {% endif %}
{% if exp.reminder_sent_at %}
{% trans "1st reminder:" %} {{ exp.reminder_sent_at|date:"Y-m-d H:i" }} {% if exp.second_reminder_sent_at %} {% trans "2nd reminder:" %} {{ exp.second_reminder_sent_at|date:"Y-m-d H:i" }} {% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% else %} {% if not complaint.sent_to_any_department %}

{% trans "No requests sent yet" %}

{% if can_manage_actions and complaint.is_active_status %} {% endif %}
{% endif %} {% endif %}