Files
mautic-marketing-program-bu…/Resources/views/Plan/details.html.twig
T
Alexandre Gain 8696acd01c feat: Add TargetType form and migration for plan targets
- Implemented TargetType form for managing target details including name, type, priority, stages, estimated size, profile criteria, pain points, value proposition, and preferred channels.
- Created migration scripts for adding type and priority columns to plan objectives and tasks.
- Added migration for creating plan targets and plan target stages tables, including foreign key constraints.
- Introduced stakeholder management with forms and views for creating, editing, and listing stakeholders.
- Enhanced UI with read more functionality for long text descriptions and filtering options in plan tab tables.
2026-11-08 11:54:25 +01:00

451 lines
29 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,
'targets': item.targets|length,
'stakeholders': item.stakeholders|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 %}
{# Harmonized columns: Pictogram (no label), Type, Description. Description items have no
name of their own, so the Name column is left out here. Filter + click-to-sort (plan.js). #}
{{ include('@Plan/Plan/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover plan-tab-table plan-description-items-view"
data-plan-tab-table data-empty-text="{{ 'mautic.plan.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.plan.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="plan-col-pictogram" aria-label="{{ 'mautic.plan.description_item.field.pictogram'|trans }}"></th>
<th class="plan-col-type">{{ 'mautic.plan.description_item.field.type'|trans }}</th>
<th class="plan-col-description">{{ '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="plan-col-pictogram text-center">
{% if typeIcon %}<i class="{{ typeIcon }} plan-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td class="plan-col-type"{% if typeDescription %} title="{{ typeDescription }}" data-toggle="tooltip"{% endif %}>
{{ typeName ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': descriptionItem.type}) }}
</td>
<td class="plan-col-description">
{{ include('@Plan/Plan/_description_read_more.html.twig', {
'text': descriptionItem.description,
'id': 'plan-desc-item-' ~ descriptionItem.id,
}) }}
</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>
{# Harmonized columns: Pictogram (no label), Type, Name (title), Description, Priority,
Status (achieved). Filter + click-to-sort (plan.js). #}
{{ include('@Plan/Plan/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover plan-tab-table plan-objectives-view"
data-plan-tab-table data-empty-text="{{ 'mautic.plan.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.plan.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="plan-col-pictogram" aria-label="{{ 'mautic.plan.objective.field.pictogram'|trans }}"></th>
<th class="plan-col-type">{{ 'mautic.plan.objective.field.type'|trans }}</th>
<th class="plan-col-name">{{ 'mautic.plan.objective.field.name'|trans }}</th>
<th class="plan-col-description">{{ 'mautic.plan.objective.field.description'|trans }}</th>
<th class="plan-col-priority">{{ 'mautic.plan.objective.field.priority'|trans }}</th>
<th class="plan-col-status">{{ 'mautic.plan.objective.field.is_achieved'|trans }}</th>
</tr>
</thead>
<tbody>
{% for objective in objectives %}
{% set typeName = plan_item_type_name('objective', objective.type) %}
{% set typeDescription = plan_item_type_description('objective', objective.type) %}
{% set typeIcon = plan_item_type_icon('objective', objective.type) %}
<tr>
<td class="plan-col-pictogram text-center">
{% if typeIcon %}<i class="{{ typeIcon }} plan-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td class="plan-col-type"{% if typeDescription %} title="{{ typeDescription }}" data-toggle="tooltip"{% endif %}>
{{ typeName ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': objective.type}) }}
</td>
<td class="plan-col-name">{{ objective.title }}</td>
<td class="plan-col-description text-muted" style="white-space: pre-wrap;">{{ objective.description|plan_linkify }}</td>
<td class="plan-col-priority">{{ objective.priority ?? '—' }}</td>
<td class="plan-col-status">
{% if objective.achieved %}
<span class="label label-success"><i class="ri-checkbox-circle-fill" title="{{ 'mautic.plan.objective.achieved'|trans }}"></i> {{ 'mautic.plan.objective.achieved'|trans }}</span>
{% else %}
<span class="label label-default"><i class="ri-checkbox-blank-circle-line" title="{{ 'mautic.plan.objective.not_achieved'|trans }}"></i> {{ 'mautic.plan.objective.not_achieved'|trans }}</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% 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 %}
{# Harmonized columns: Pictogram (no label), Type, Name, Description, then the costs.
Filter + click-to-sort (plan.js). #}
{{ include('@Plan/Plan/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover plan-tab-table plan-allocation-items-view"
data-plan-tab-table data-empty-text="{{ 'mautic.plan.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.plan.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="plan-col-pictogram" aria-label="{{ 'mautic.plan.allocation_item.field.pictogram'|trans }}"></th>
<th class="plan-col-type">{{ 'mautic.plan.allocation_item.field.type'|trans }}</th>
<th class="plan-col-name">{{ 'mautic.plan.allocation_item.field.name'|trans }}</th>
<th class="plan-col-description">{{ 'mautic.plan.allocation_item.field.description'|trans }}</th>
<th class="plan-col-cost text-right">{{ 'mautic.plan.allocation_item.field.planned_cost'|trans }}</th>
<th class="plan-col-cost 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) %}
{% set typeIcon = plan_item_type_icon('allocation', allocationItem.type) %}
<tr>
<td class="plan-col-pictogram text-center">
{% if typeIcon %}<i class="{{ typeIcon }} plan-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td class="plan-col-type"{% if typeDescription %} title="{{ typeDescription }}" data-toggle="tooltip"{% endif %}>
{{ typeName ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': allocationItem.type}) }}
</td>
<td class="plan-col-name">{{ allocationItem.name }}</td>
<td class="plan-col-description text-muted" style="white-space: pre-wrap;">{{ allocationItem.description|plan_linkify }}</td>
<td class="plan-col-cost text-right text-nowrap">
{% if allocationItem.plannedCost is not null %}{{ plan_money(allocationItem.plannedCost) }} {{ plan_currency() }}{% endif %}
</td>
<td class="plan-col-cost 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="4">{{ 'mautic.plan.allocation.total'|trans }}</th>
<th class="plan-col-cost text-right text-nowrap">
{% if allocationTotals.planned is not null %}{{ plan_money(allocationTotals.planned) }} {{ plan_currency() }}{% endif %}
</th>
<th class="plan-col-cost text-right text-nowrap">
{% if allocationTotals.real is not null %}{{ plan_money(allocationTotals.real) }} {{ plan_currency() }}{% endif %}
</th>
</tr>
</tfoot>
</table>
</div>
{% endif %}
</div>
{# Stakeholders: the plan's links to the global directory, harmonized like the other tabs. #}
<div class="tab-pane bdr-w-0" id="plan-tab-stakeholders" role="tabpanel">
{% set stakeholders = item.stakeholders %}
{% if stakeholders is empty %}
<p class="text-muted">{{ 'mautic.plan.stakeholder.empty'|trans }}</p>
{% else %}
{# Harmonized columns: Pictogram (no label), Type, Name, then the link's own fields.
Filter + click-to-sort (plan.js). #}
{{ include('@Plan/Plan/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover plan-tab-table plan-stakeholders-view"
data-plan-tab-table data-empty-text="{{ 'mautic.plan.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.plan.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="plan-col-pictogram" aria-label="{{ 'mautic.plan.stakeholder.field.pictogram'|trans }}"></th>
<th class="plan-col-type">{{ 'mautic.plan.stakeholder.field.type'|trans }}</th>
<th class="plan-col-name">{{ 'mautic.plan.stakeholder.field.name'|trans }}</th>
<th class="plan-col-role">{{ 'mautic.plan.stakeholder.field.role_in_plan'|trans }}</th>
<th class="plan-col-role">{{ 'mautic.plan.stakeholder.field.role'|trans }}</th>
<th class="plan-col-email">{{ 'mautic.plan.stakeholder.field.email'|trans }}</th>
<th class="plan-col-phone">{{ 'mautic.plan.stakeholder.field.phone'|trans }}</th>
<th class="plan-col-active">{{ 'mautic.plan.stakeholder.field.active'|trans }}</th>
</tr>
</thead>
<tbody>
{% for link in stakeholders %}
{% set stakeholder = link.stakeholder %}
<tr>
<td class="plan-col-pictogram text-center">
{% set typeIcon = plan_item_type_icon('stakeholder', stakeholder.type) %}
{% if typeIcon %}<i class="{{ typeIcon }} plan-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td class="plan-col-type"{% if plan_item_type_description('stakeholder', stakeholder.type) %} title="{{ plan_item_type_description('stakeholder', stakeholder.type) }}" data-toggle="tooltip"{% endif %}>
{{ plan_item_type_name('stakeholder', stakeholder.type) ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': stakeholder.type}) }}
</td>
<td class="plan-col-name">
<a href="{{ path('plan_stakeholder_action', {'objectAction': 'view', 'objectId': stakeholder.id}) }}" data-toggle="ajax">{{ stakeholder.name }}</a>
</td>
<td class="plan-col-role">{{ link.roleInPlan }}</td>
<td class="plan-col-role text-muted">{{ stakeholder.role }}</td>
<td class="plan-col-email">
{% if stakeholder.email %}<a href="mailto:{{ stakeholder.email }}">{{ stakeholder.email }}</a>{% endif %}
</td>
<td class="plan-col-phone text-nowrap">
{% if stakeholder.phone %}<a href="tel:{{ stakeholder.phone|replace({' ': ''}) }}">{{ stakeholder.phone }}</a>{% endif %}
</td>
<td class="plan-col-active">
<span class="label {{ stakeholder.isPublished ? 'label-success' : 'label-gray' }}">
{{ (stakeholder.isPublished ? 'mautic.plan.stakeholder.active' : 'mautic.plan.stakeholder.inactive')|trans }}
</span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
{# Targets: the plan's audiences, harmonized like the other tabs. #}
<div class="tab-pane bdr-w-0" id="plan-tab-targets" role="tabpanel">
{% set targets = item.targets %}
{% if targets is empty %}
<p class="text-muted">{{ 'mautic.plan.target.empty'|trans }}</p>
{% else %}
{# Harmonized columns: Pictogram (no label, fixed per target type), Type, Name, then the
target's own fields. Filter + click-to-sort (plan.js). #}
{{ include('@Plan/Plan/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover plan-tab-table plan-targets-view"
data-plan-tab-table data-empty-text="{{ 'mautic.plan.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.plan.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="plan-col-pictogram" aria-label="{{ 'mautic.plan.target.field.pictogram'|trans }}"></th>
<th class="plan-col-type">{{ 'mautic.plan.target.field.type'|trans }}</th>
<th class="plan-col-name">{{ 'mautic.plan.target.field.name'|trans }}</th>
<th class="plan-col-priority">{{ 'mautic.plan.target.field.priority'|trans }}</th>
<th class="plan-col-stages">{{ 'mautic.plan.target.field.stages'|trans }}</th>
<th class="plan-col-size text-right">{{ 'mautic.plan.target.field.estimated_size'|trans }}</th>
<th class="plan-col-description">{{ 'mautic.plan.target.field.profile_criteria'|trans }}</th>
<th class="plan-col-description">{{ 'mautic.plan.target.field.pain_points'|trans }}</th>
<th class="plan-col-description">{{ 'mautic.plan.target.field.value_proposition'|trans }}</th>
<th class="plan-col-channels">{{ 'mautic.plan.target.field.preferred_channels'|trans }}</th>
</tr>
</thead>
<tbody>
{% for target in targets %}
<tr>
<td class="plan-col-pictogram text-center">
<i class="{{ target.targetType.icon }} plan-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>
</td>
<td class="plan-col-type">{{ target.targetType.labelKey|trans }}</td>
<td class="plan-col-name">{{ target.name }}</td>
<td class="plan-col-priority">
<span class="label {{ target.priority.labelClass }}">{{ target.priority.labelKey|trans }}</span>
</td>
<td class="plan-col-stages text-muted">
{{ target.stages|map(stage => stage.name)|join(', ') }}
</td>
<td class="plan-col-size text-right text-nowrap">{{ target.estimatedSize }}</td>
<td class="plan-col-description text-muted" style="white-space: pre-wrap;">{{ target.profileCriteria }}</td>
<td class="plan-col-description text-muted" style="white-space: pre-wrap;">{{ target.painPoints }}</td>
<td class="plan-col-description text-muted" style="white-space: pre-wrap;">{{ target.valueProposition }}</td>
<td class="plan-col-channels">
{% for channel in target.preferredChannels ?? [] %}
<span class="label label-default">{{ plan_target_channel_label(channel)|trans }}</span>
{% endfor %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</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 %}