{% if not doc -%}
{% else %}
{%- if doc.status -%}
{% if doc.status == "Waiting for Customer" -%}
{% set status = "To Reply" %}
{% else %}
{% set status = doc.status %}
{%- endif -%}
{{ status }}
{{ doc.subject }}
{{ frappe.utils.formatdate(doc.creation) }}
Messages
{%- for comm in
(doc.get({"doctype":"Communication"})|sort(reverse=True, attribute="creation")) %}
{{ comm.sender }} on {{ frappe.utils.formatdate(comm.creation) }}
{{ frappe.utils.is_html(comm.content) and comm.content or
comm.content.replace("\n", " ")}}