{% extends "base.html" %} {% from "components/ui.html" import confirm_dialog %} {% block content %}

{{ client.name }}

Client details and associated projects.

{% if current_user.is_admin or has_any_permission(['edit_clients', 'delete_clients']) %}
{% if current_user.is_admin or has_permission('edit_clients') %} {{ _('Edit Client') }} {% if client.status == 'active' %}
{% else %}
{% endif %} {% endif %} {% if (current_user.is_admin or has_permission('delete_clients')) and client.total_projects == 0 %} {% endif %}
{% endif %}
{% if contacts %}
{% for contact in contacts[:3] %}

{{ contact.full_name }}

{% if contact.title %}

{{ contact.title }}

{% endif %} {% if contact.is_primary %} {{ _('Primary') }} {% endif %}
{% if contact.email %} {{ contact.email }} {% endif %}
{% endfor %} {% if contacts|length > 3 %}

{{ contacts|length - 3 }} {{ _('more contact(s)') }}

{% endif %}
{% else %}

{{ _('No contacts yet') }}

{{ _('Add Contact') }} {% endif %}
{% if client.contact_person or client.email or client.phone or client.address %}

{{ _('Legacy Contact Info') }}

{% if client.contact_person %}

Contact Person

{{ client.contact_person }}

{% endif %} {% if client.email %}

Email

{{ client.email }}

{% endif %} {% if client.phone %}

Phone

{{ client.phone }}

{% endif %} {% if client.address %}

Address

{{ client.address }}

{% endif %}
{% endif %} {% if client.custom_fields %}

{{ _('Custom Fields') }}

{% for key, value in client.custom_fields.items() %}
{% set field_defs = custom_field_definitions_by_key|default({}) %} {% set field_definition = field_defs[key] if key in field_defs else None %}

{% if field_definition %}{{ field_definition.label }}{% else %}{{ key }}{% endif %}

{% set link_template = link_templates_by_field.get(key) if link_templates_by_field else None %} {% if link_template and value %} {# Render as clickable link using link template #} {% set rendered_url = link_template.render_url(value) %} {% if rendered_url %} {{ value }} {% else %} {{ value }} {% endif %} {% elif value is string and (value.startswith('http://') or value.startswith('https://')) %} {# Fallback: If the value looks like a URL, render it as a clickable link #} {{ value }} {% elif value is string and value.startswith('www.') %} {{ value }} {% else %} {{ value }} {% endif %}

{% endfor %}
{% endif %} {% if prepaid_overview %}

{{ _('Prepaid Hours') }}

{{ _('Plan includes %(hours)s hours per cycle. Resets on day %(day)s.', hours='%.2f'|format(prepaid_overview.plan_hours), day=client.prepaid_reset_day) }}

  • {{ _('Current cycle start') }}: {{ prepaid_overview.month_label }}
  • {{ _('Remaining hours') }}: {{ '%.2f'|format(prepaid_overview.remaining_hours) }} {{ _('h') }}
  • {{ _('Consumed this cycle') }}: {{ '%.2f'|format(prepaid_overview.consumed_hours) }} {{ _('h') }}
{% endif %}

{{ _('Attachments') }} {% if attachments %} ({{ attachments|length }}) {% endif %}

{% if current_user.is_admin or has_permission('edit_clients') %} {% endif %}
{% if current_user.is_admin or has_permission('edit_clients') %} {% endif %}
{% if attachments %} {% for attachment in attachments %}
{% if attachment.is_pdf %} {% elif attachment.is_image %} {% elif attachment.is_document %} {% else %} {% endif %}
{{ attachment.original_filename }} {% if attachment.description %}

{{ attachment.description }}

{% endif %}

{{ attachment.file_size_display }} • {{ attachment.uploaded_at|user_datetime('%Y-%m-%d %H:%M') if attachment.uploaded_at else '' }} {% if attachment.is_visible_to_client %} {{ _('Client Visible') }} {% endif %}

{% if current_user.is_admin or has_permission('edit_clients') %}
{% endif %}
{% endfor %} {% else %}

{{ _('No attachments yet') }}

{% endif %}

Projects

{% for project in projects %} {% else %} {% endfor %}
Name Status Actions
{{ project.name }} {% if project.code_display %} {{ project.code_display }} {% endif %}
{% set status_map = { 'active': {'cls': 'bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-300', 'label': _('Active')}, 'inactive': {'cls': 'bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300', 'label': _('Inactive')}, 'archived': {'cls': 'bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-200', 'label': _('Archived')}, } %} {% set st = status_map.get(project.status, status_map['inactive']) %} {{ st.label }} View
No projects found for this client.

{{ _('Recent Hours History') }}

{% if recent_time_entries %}
{% for entry in recent_time_entries %} {% endfor %}
{{ _('Date') }} {{ _('Project') }} {{ _('Task') }} {{ _('User') }} {{ _('Duration') }} {{ _('Notes') }}
{{ entry.start_time|user_datetime('%Y-%m-%d') }}
{{ entry.start_time|user_datetime('%H:%M') }} {% if entry.end_time %} - {{ entry.end_time|user_datetime('%H:%M') }} {% endif %}
{% if entry.project %} {{ entry.project.name }} {% else %} {{ _('Direct') }} {% endif %} {% if entry.task %} {{ entry.task.name }} {% else %} - {% endif %} {{ entry.user.display_name if entry.user else _('N/A') }} {{ "%.2f"|format(entry.duration_hours) }}h {% if entry.notes %} {{ entry.notes[:50] }}{% if entry.notes|length > 50 %}...{% endif %} {% else %} - {% endif %}

{{ _('Showing last %(count)s entries', count=recent_time_entries|length) }} | {{ _('Total hours') }}: {{ "%.2f"|format(recent_time_entries|sum(attribute='duration_hours')) }}h

{% else %}

{{ _('No recent time entries found.') }}

{% endif %}

{{ _('Internal Notes') }}

{% if client.notes %} {% for note in client.notes|sort(attribute='created_at', reverse=True) %}
{{ (note.author_name)[0].upper() }}
{{ note.author_name }}
{{ note.created_at|user_datetime('%B %d, %Y at %I:%M %p') }} {% if note.created_at != note.updated_at %} ({{ _('edited') }}) {% endif %}
{% if note.is_important %} {{ _('Important') }} {% endif %}
{% if note.can_edit(current_user) %}
{{ _('Edit') }} {% if note.can_delete(current_user) %}
{% endif %}
{% endif %}
{{ note.content }}
{% endfor %} {% else %}

{{ _('No notes yet. Add a note to keep track of important information about this client.') }}

{% endif %}
{% if current_user.is_admin or has_permission('delete_clients') %} {{ confirm_dialog( 'confirmDeleteClient-' ~ client.id, 'Delete Client', 'Are you sure you want to delete this client? This action cannot be undone.', 'Delete', 'Cancel', 'danger' ) }} {% endif %} {% endblock %}