{% extends "base.html" %} {% from "components/ui.html" import page_header, breadcrumb_nav, badge %} {% block title %}{{ deal.name }} - {{ config.APP_NAME }}{% endblock %} {% block content %} {% set breadcrumbs = [ {'text': _('Deals'), 'url': url_for('deals.list_deals')}, {'text': deal.name} ] %} {% set actions_html %}
{{ _('Edit') }} {{ _('Add Activity') }} {{ _('Pipeline') }}
{% endset %} {{ page_header( icon_class='fas fa-handshake', title_text=deal.name, subtitle_text=deal.client.name if deal.client else (deal.stage|replace('_', ' ')|title), breadcrumbs=breadcrumbs, actions_html=actions_html ) }}

{{ _('Deal Information') }}

{% if deal.client %}

{{ _('Client') }}

{{ deal.client.name }}

{% endif %} {% if deal.contact %}

{{ _('Contact') }}

{{ deal.contact.full_name }}

{% endif %}

{{ _('Stage') }}

{{ deal.stage|replace('_', ' ')|title }}

{{ _('Status') }}

{{ deal.status|title }}
{% if deal.value is not none and deal.value %}

{{ _('Value') }}

{{ "%.2f"|format(deal.value) }} {{ deal.currency_code }}

{% endif %}

{{ _('Probability') }}

{{ deal.probability }}%

{% if deal.expected_close_date %}

{{ _('Expected Close') }}

{{ deal.expected_close_date|format_date }}

{% endif %} {% if deal.actual_close_date %}

{{ _('Actual Close') }}

{{ deal.actual_close_date|format_date }}

{% endif %} {% if deal.owner %}

{{ _('Owner') }}

{{ deal.owner.display_name if deal.owner.display_name else deal.owner.email }}

{% endif %} {% if deal.lead %}

{{ _('Related Lead') }}

{{ deal.lead.display_name }}

{% endif %}

{{ _('Created') }}

{{ deal.created_at|user_datetime if deal.created_at else '—' }}

{{ _('Updated') }}

{{ deal.updated_at|user_datetime if deal.updated_at else '—' }}

{% if deal.description %}

{{ _('Description') }}

{{ deal.description }}

{% endif %} {% if deal.notes %}

{{ _('Notes') }}

{{ deal.notes }}

{% endif %} {% if deal.status == 'lost' and deal.loss_reason %}

{{ _('Loss Reason') }}

{{ deal.loss_reason }}

{% endif %} {% if deal.related_quote %}

{{ _('Related Quote') }}

{{ deal.related_quote.quote_number }}{% if deal.related_quote.title %} - {{ deal.related_quote.title }}{% endif %}

{% endif %} {% if deal.related_project %}

{{ _('Related Project') }}

{{ deal.related_project.name }}

{% endif %}

{{ _('Activity') }}

{{ _('Add Activity') }}
{% if activities %}
{% for activity in activities %}

{{ activity.subject or activity.type|replace('_', ' ')|title }}

{{ activity.activity_date|user_datetime if activity.activity_date else '' }} {% if activity.creator %} · {{ _('by') }} {{ activity.creator.display_name if activity.creator.display_name else activity.creator.email }} {% endif %}

{% if activity.description %}

{{ activity.description }}

{% endif %}
{{ activity.type|replace('_', ' ')|title }}
{% endfor %}
{% else %}

{{ _('No activities recorded yet') }}

{{ _('Add first activity') }} {% endif %}

{{ _('History') }}

{% if current_user.is_admin or has_permission('view_audit_logs') %} {{ _('View full history') }} {% endif %}
{% if audit_logs %}
{% for log in audit_logs %} {% endfor %}
{{ _('Timestamp') }} {{ _('User') }} {{ _('Action') }} {{ _('Field') }} {{ _('Change') }}
{{ log.created_at|user_datetime }} {% if log.user %}{{ log.user.display_name }}{% else %}{{ _('System') }}{% endif %} {{ badge(log.action, log.get_color()) }} {% if log.field_name %}{{ log.field_name }}{% else %}{% endif %} {% if log.field_name %}
{% if log.old_value %}
{{ log.get_old_value() }}
{% endif %} {% if log.new_value %}
+ {{ log.get_new_value() }}
{% endif %}
{% else %} {{ log.change_description or '—' }} {% endif %}
{% else %}

{{ _('No change history yet') }}

{% endif %}
{% endblock %}