Update twig templates for display budget elements

This commit is contained in:
Julie Lenaerts 2025-05-06 17:02:51 +02:00
parent b024eef493
commit 3f1e625dee
4 changed files with 77 additions and 6 deletions

View File

@ -34,8 +34,8 @@ class AddEventBudgetElementType extends AbstractType
$builder->add('kind', ChoiceType::class, [
'choices' => [
'Charges' => $charges,
'Resources' => $resources,
'event.budget.charges' => $charges,
'event.budget.resources' => $resources,
],
'choice_label' => fn (EventBudgetKind $kind) => $this->translatableStringHelper->localize($kind->getName()),
'choice_value' => fn (?EventBudgetKind $kind) => $kind?->getId(),

View File

@ -20,6 +20,7 @@
{{ form_row(edit_form.themes) }}
{{ form_row(edit_form.moderator) }}
{{ form_row(edit_form.location) }}
{{ form_row(edit_form.budgetElements) }}
{{ form_row(edit_form.organizationCost) }}
{{ form_row(edit_form.comment) }}

View File

@ -50,10 +50,6 @@
<th>{{ 'Moderator'|trans }}</th>
<td>{{ event.moderator|trans|default('-') }}</td>
</tr>
<tr>
<th>{{ 'event.fields.organizationCost'|trans }}</th>
<td>{{ event.organizationCost|format_currency('EUR') }}</td>
</tr>
<tr>
<th>{{ 'event.fields.location'|trans }}</th>
<td>
@ -68,6 +64,77 @@
</tbody>
</table>
<div class="budget-wrapper" style="background-color: whitesmoke; padding: 1rem; margin-bottom: .5rem;">
{% set resources = event.budgetElements|filter(e => e.kind.type.value == 'Resource') %}
{% set charges = event.budgetElements|filter(e => e.kind.type.value == 'Charge') %}
<h2>Budget de l'événement</h2>
<h3>Ressources</h3>
{% if resources is not empty %}
<table class="table table-bordered border-dark align-middle">
<thead>
<tr>
<th>{{ 'event.budget.element type'|trans }}</th>
<th>{{ 'event.budget.amount'|trans }}</th>
<th>{{ 'event.budget.comment'|trans }}</th>
</tr>
</thead>
<tbody>
{% set totalResources = 0 %}
{% for res in resources %}
<tr>
<td>{{ res.kind.name|localize_translatable_string }}</td>
<td>{{ res.amount|format_currency('EUR') }}</td>
<td>{{ res.comment.comment|chill_print_or_message(null, 'blockquote') }}</td>
</tr>
{% set totalResources = totalResources + res.amount %}
{% endfor %}
</tbody>
<tfoot>
<tr>
<th>Total</th>
<td>{{ totalResources|format_currency('EUR') }}</td>
</tr>
</tfoot>
</table>
{% else %}
<p class="chill-no-data-statement">{{ 'event.budget.no elements'|trans }}</p>
{% endif %}
<h3>Charges</h3>
{% if charges is not empty %}
<table class="table table-bordered border-dark align-middle">
<thead>
<tr>
<th>{{ 'event.budget.element type'|trans }}</th>
<th>{{ 'event.budget.amount'|trans }}</th>
<th>{{ 'event.budget.comment'|trans }}</th>
</tr>
</thead>
<tbody>
{% set totalCharges = 0 %}
{% for chg in charges %}
<tr>
<td>{{ chg.kind.name|localize_translatable_string }}</td>
<td>{{ chg.amount|format_currency('EUR') }}</td>
<td>{{ chg.comment.comment|chill_print_or_message(null, 'blockquote') }}</td>
</tr>
{% set totalCharges = totalCharges + chg.amount %}
{% endfor %}
</tbody>
<tfoot>
<tr>
<th>Total</th>
<td>{{ totalCharges|format_currency('EUR') }}</td>
</tr>
</tfoot>
</table>
{% else %}
<p class="chill-no-data-statement">{{ 'event.budget.no elements' }}</p>
{% endif %}
</div>
{% if event.documents|length > 0 %}
<div>
<p><strong>{{ 'event.fields.documents'|trans }}</strong></p>

View File

@ -142,6 +142,9 @@ event:
filter:
event_types: Par types d'événement
event_dates: Par date d'événement
budget:
resources: Ressources
charges: Charges
crud:
event_theme: