Files
mautic-marketing-program-bu…/Resources/views/Plan/details.html.twig
T
2026-11-07 19:31:49 +01:00

295 lines
16 KiB
Twig

{% extends '@MauticCore/Default/content.html.twig' %}
{% block mauticContent %}plan{% endblock %}
{#
# No routeBase on the page_actions includes: core would turn it into mautic_plan_* route names.
# The buttons use actionRoute (plan_action) from the controller, and the close button gets its URL here.
#}
{% block preHeader %}
{{- include('@MauticCore/Helper/page_actions.html.twig', {
'item': item,
'templateButtons': {
'close': true,
},
'closeUrl': path('plan_index'),
'targetLabel': 'mautic.plan.header.index'|trans,
}) -}}
{# Core's helper renders an empty pill when there is no category. #}
{% if item.category %}
{{ include('@MauticCore/Modules/category--inline.html.twig', {'category': item.category}) }}
{% endif %}
{% endblock %}
{% block headerTitle %}{{ item.name }}{% endblock %}
{#
# Under the title, as on an email's page: the plan status, then the total planned and real costs of the
# allocation items, in the general currency. A real total above the planned total is red, otherwise green.
#}
{% block publishStatus %}
{% set statusColors = {
'draft': 'warm-gray', 'planned': 'blue', 'active': 'green',
'paused': 'warning', 'completed': 'teal', 'archived': 'cool-gray',
} %}
{% include '@MauticCore/Helper/_tag.html.twig' with { tags: [{
color: statusColors[item.status.value]|default('gray'),
label: item.status.labelKey,
icon: 'ri-flag-line',
attributes: {'class': 'plan-status-tag'},
}] } %}
{% set totals = item.allocationTotals %}
{% if totals.planned is not null or totals.real is not null %}
<div class="label__divider"></div>
{% set totalTags = [] %}
{% if totals.planned is not null %}
{% set totalTags = totalTags|merge([{
color: 'high-contrast',
icon: 'ri-wallet-3-line',
label: 'mautic.plan.header.total_planned'|trans({'%amount%': plan_money(totals.planned), '%currency%': plan_currency()}),
attributes: {'class': 'plan-total-planned', 'title': 'mautic.plan.header.total_planned.tooltip'|trans, 'data-toggle': 'tooltip'},
}]) %}
{% endif %}
{% if totals.real is not null %}
{% set overPlan = totals.planned is not null and (totals.real + 0) > (totals.planned + 0) %}
{% set totalTags = totalTags|merge([{
color: overPlan ? 'red' : 'green',
icon: overPlan ? 'ri-error-warning-line' : 'ri-checkbox-circle-line',
label: 'mautic.plan.header.total_real'|trans({'%amount%': plan_money(totals.real), '%currency%': plan_currency()}),
attributes: {'class': 'plan-total-real', 'title': (overPlan ? 'mautic.plan.header.total_real.over' : 'mautic.plan.header.total_real.tooltip')|trans, 'data-toggle': 'tooltip'},
}]) %}
{% endif %}
{% include '@MauticCore/Helper/_tag.html.twig' with { tags: totalTags } %}
{% endif %}
{% endblock %}
{% block actions %}
{{- include('@MauticCore/Helper/page_actions.html.twig', {
'item': item,
'templateButtons': {
'edit': securityHasEntityAccess(permissions['plan:plans:editown'], permissions['plan:plans:editother'], item.createdBy),
'delete': securityHasEntityAccess(permissions['plan:plans:deleteown'], permissions['plan:plans:deleteother'], item.createdBy),
},
'langVar': 'plan',
}) -}}
{% endblock %}
{% block content %}
{% set objectives = item.objectives %}
{% set achievedCount = objectives|filter(o => o.achieved)|length %}
{% set descriptionItems = item.descriptionItems %}
{% set allocationItems = item.allocationItems %}
{% set allocationTotals = item.allocationTotals %}
{{ include('@Plan/Plan/_tabs.html.twig', {'planId': item.id, 'counts': {
'description': descriptionItems|length,
'objectives': objectives|length,
'allocation': allocationItems|length,
'tasks': taskTree|length,
}}) }}
<div class="tab-content pa-md">
{# Details #}
<div class="tab-pane active bdr-w-0" id="plan-tab-details" role="tabpanel">
<table class="table table-hover mb-0 plan-details">
<tbody>
<tr>
<td class="col-md-3 text-muted">{{ 'mautic.plan.field.status'|trans }}</td>
<td>{{ item.status.labelKey|trans }}</td>
</tr>
{% if item.completedAt %}
<tr>
<td class="text-muted">{{ 'mautic.plan.field.completed_at'|trans }}</td>
<td>{{ dateToFull(item.completedAt) }}</td>
</tr>
{% endif %}
<tr>
<td class="text-muted">{{ 'mautic.plan.field.version'|trans }}</td>
<td>{{ item.version }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.plan.field.owner'|trans }}</td>
<td>{{ item.owner ? item.owner.name : 'mautic.plan.owner.none'|trans }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.plan.field.start_date'|trans }}</td>
<td>{{ item.startDate ? dateToFull(item.startDate) : 'mautic.plan.value.none'|trans }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.plan.field.end_date'|trans }}</td>
<td>{{ item.endDate ? dateToFull(item.endDate) : 'mautic.plan.value.none'|trans }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.core.category'|trans }}</td>
<td>{{ item.category ? item.category.title : 'mautic.plan.value.none'|trans }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.core.form.available'|trans }}</td>
<td>{{ (item.isPublished ? 'mautic.core.form.yes' : 'mautic.core.form.no')|trans }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.core.created'|trans }}</td>
<td>{{ item.dateAdded ? dateToFull(item.dateAdded) : '' }}{% if item.createdByUser %} ({{ item.createdByUser }}){% endif %}</td>
</tr>
{% if item.dateModified %}
<tr>
<td class="text-muted">{{ 'mautic.core.modified'|trans }}</td>
<td>{{ dateToFull(item.dateModified) }}{% if item.modifiedByUser %} ({{ item.modifiedByUser }}){% endif %}</td>
</tr>
{% endif %}
<tr>
<td class="text-muted">{{ 'mautic.core.id'|trans }}</td>
<td>{{ item.id }}</td>
</tr>
</tbody>
</table>
</div>
{# Description #}
<div class="tab-pane bdr-w-0" id="plan-tab-description" role="tabpanel">
{% if descriptionItems is empty %}
<p class="text-muted">{{ 'mautic.plan.description_item.empty'|trans }}</p>
{% else %}
{# Three columns: the type's pictogram, the type, the description. #}
<div class="table-responsive">
<table class="table table-hover plan-description-items-view">
<thead>
<tr>
<th class="text-center" style="width: 1%;">{{ 'mautic.plan.description_item.field.pictogram'|trans }}</th>
<th class="col-md-3">{{ 'mautic.plan.description_item.field.type'|trans }}</th>
<th>{{ 'mautic.plan.description_item.field.description'|trans }}</th>
</tr>
</thead>
<tbody>
{% for descriptionItem in descriptionItems %}
{% set typeName = plan_item_type_name('description', descriptionItem.type) %}
{% set typeDescription = plan_item_type_description('description', descriptionItem.type) %}
{% set typeIcon = plan_item_type_icon('description', descriptionItem.type) %}
<tr>
<td class="text-center">
{% if typeIcon %}<i class="{{ typeIcon }} plan-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td>
<strong{% if typeDescription %} title="{{ typeDescription }}" data-toggle="tooltip"{% endif %}>
{{ typeName ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': descriptionItem.type}) }}
</strong>
</td>
<td style="white-space: pre-wrap;">{{ descriptionItem.description }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
{# Objectives #}
<div class="tab-pane bdr-w-0" id="plan-tab-objectives" role="tabpanel">
{% if objectives is empty %}
<p class="text-muted">{{ 'mautic.plan.objective.empty'|trans }}</p>
{% else %}
<p class="text-muted plan-objectives-progress">
{{ 'mautic.plan.objective.progress'|trans({'%achieved%': achievedCount, '%total%': objectives|length}) }}
</p>
<ol class="list-group plan-objectives-view">
{% for objective in objectives %}
<li class="list-group-item">
{% if objective.achieved %}
<i class="ri-checkbox-circle-fill text-success" title="{{ 'mautic.plan.objective.achieved'|trans }}"></i>
{% else %}
<i class="ri-checkbox-blank-circle-line text-muted" title="{{ 'mautic.plan.objective.not_achieved'|trans }}"></i>
{% endif %}
<strong>{{ objective.title }}</strong>
{% if objective.description is not empty %}
<div class="text-muted mt-xs" style="white-space: pre-wrap;">{{ objective.description }}</div>
{% endif %}
</li>
{% endfor %}
</ol>
{% endif %}
</div>
{# Allocation: the plan's budget, then the allocation items (cost lines) with their totals. #}
<div class="tab-pane bdr-w-0" id="plan-tab-allocation" role="tabpanel">
<table class="table table-hover mb-md plan-allocation">
<tbody>
<tr>
<td class="col-md-3 text-muted">{{ 'mautic.plan.field.budget_planned'|trans }}</td>
<td>
{% if item.budgetPlanned is not null %}
{{ plan_money(item.budgetPlanned) }} {{ plan_currency() }}
{% else %}
{{ 'mautic.plan.value.none'|trans }}
{% endif %}
</td>
</tr>
</tbody>
</table>
<h4 class="mb-sm">{{ 'mautic.plan.field.allocation_items'|trans }}</h4>
{% if allocationItems is empty %}
<p class="text-muted">{{ 'mautic.plan.allocation_item.empty'|trans }}</p>
{% else %}
<div class="table-responsive">
<table class="table table-hover plan-allocation-items-view">
<thead>
<tr>
<th>{{ 'mautic.plan.allocation_item.field.type'|trans }}</th>
<th>{{ 'mautic.plan.allocation_item.field.name'|trans }}</th>
<th class="visible-md visible-lg">{{ 'mautic.plan.allocation_item.field.description'|trans }}</th>
<th class="text-right">{{ 'mautic.plan.allocation_item.field.planned_cost'|trans }}</th>
<th class="text-right">{{ 'mautic.plan.allocation_item.field.real_cost'|trans }}</th>
</tr>
</thead>
<tbody>
{% for allocationItem in allocationItems %}
{% set typeName = plan_item_type_name('allocation', allocationItem.type) %}
{% set typeDescription = plan_item_type_description('allocation', allocationItem.type) %}
<tr>
<td{% if typeDescription %} title="{{ typeDescription }}"{% endif %}>
{{ typeName ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': allocationItem.type}) }}
</td>
<td>{{ allocationItem.name }}</td>
<td class="visible-md visible-lg text-muted" style="white-space: pre-wrap;">{{ allocationItem.description }}</td>
<td class="text-right text-nowrap">
{% if allocationItem.plannedCost is not null %}{{ plan_money(allocationItem.plannedCost) }} {{ plan_currency() }}{% endif %}
</td>
<td class="text-right text-nowrap">
{% if allocationItem.realCost is not null %}{{ plan_money(allocationItem.realCost) }} {{ plan_currency() }}{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr class="plan-allocation-total">
<th colspan="3">{{ 'mautic.plan.allocation.total'|trans }}</th>
<th class="text-right text-nowrap">
{% if allocationTotals.planned is not null %}{{ plan_money(allocationTotals.planned) }} {{ plan_currency() }}{% endif %}
</th>
<th class="text-right text-nowrap">
{% if allocationTotals.real is not null %}{{ plan_money(allocationTotals.real) }} {{ plan_currency() }}{% endif %}
</th>
</tr>
</tfoot>
</table>
</div>
{% endif %}
</div>
{# Targets #}
<div class="tab-pane bdr-w-0" id="plan-tab-targets" role="tabpanel">
<p class="text-muted">{{ 'mautic.plan.target.empty'|trans }}</p>
</div>
{# Tasks: same columns as Planning > Tasks, in tree order. #}
<div class="tab-pane bdr-w-0" id="plan-tab-tasks" role="tabpanel">
{{ include('@Plan/Plan/_task_table.html.twig', {
'plan': item,
'taskTree': taskTree,
'taskPermissions': taskPermissions,
}) }}
</div>
</div>
{% endblock %}