reorganization of templates

This commit is contained in:
Julie Lenaerts 2022-03-01 11:07:53 +01:00
parent a59994355b
commit d6bad9e030
8 changed files with 345 additions and 615 deletions

View File

@ -0,0 +1,66 @@
{% set entity = person is defined ? person : household %}
{% set actualResources = [] %}
{% set futureResources = [] %}
{% set pastResources = [] %}
{% for r in resources %}
{% if r.startDate|date('U') <= 'now'|date('U') %}
{% if r.endDate is null or r.endDate|date('U') >= 'now'|date('U') %}
{% set actualResources = actualResources|merge([ r ]) %}
{% else %}
{% set pastResources = pastResources|merge([ r ]) %}
{% endif %}
{% else %}
{% set futureResources = futureResources|merge([ r ]) %}
{% endif %}
{% endfor %}
{% set actualCharges = [] %}
{% set futureCharges = [] %}
{% set pastCharges = [] %}
{% for c in charges %}
{% if c.startDate|date('U') <= 'now'|date('U') %}
{% if c.endDate is null or c.endDate|date('U') >= 'now'|date('U') %}
{% set actualCharges = actualCharges|merge([ c ]) %}
{% else %}
{% set pastCharges = pastCharges|merge([ c ]) %}
{% endif %}
{% else %}
{% set futureCharges = futureCharges|merge([ c ]) %}
{% endif %}
{% endfor %}
{% if resources|length == 0 and charges|length == 0 %}
<div class="flex-table">
<div class="item-bloc">
<p><span class="chill-no-data-statement">{{ "There isn't any element recorded"|trans }}</span></p>
</div>
</div>
{% else %}
{% include 'ChillBudgetBundle:Budget:_current_budget.html.twig' with {
'actualResources': actualResources,
'actualCharges': actualCharges,
'results': results,
'entity': entity
} %}
{% endif %}
{% if pastCharges|length > 0 or pastResources|length > 0 %}
{% include 'ChillBudgetBundle:Budget:_past_budget.html.twig' with {
'pastCharges': pastCharges,
'pastResources': pastResources,
'entity': entity
} %}
{% endif %}
{% if futureCharges|length > 0 or futureResources|length > 0 %}
{% include 'ChillBudgetBundle:Budget:_future_budget.html.twig' with {
'futureResources': futureResources,
'futureCharges': futureCharges,
'entity': entity
} %}
{% endif %}

View File

@ -0,0 +1,38 @@
{% from 'ChillBudgetBundle:Budget:_macros.html.twig' import table_elements, table_results %}
<h2 class="subtitle">{{ 'Actual budget'|trans }}</h2>
<div class="flex-table">
<h3 class="family-title">{{ 'Actual resources'|trans }}</h3>
{% if actualResources|length > 0 %}
<div class="item-bloc">
{{ table_elements(actualResources, 'resource') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No resources registered'|trans }}</span>
</div>
{% endif %}
</div>
<div class="flex-table">
<h3 class="family-title">{{ 'Actual charges'|trans }}</h3>
{% if actualCharges|length > 0 %}
<div class="item-bloc">
{{ table_elements(actualCharges, 'charge') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No charges registered'|trans }}</span>
</div>
{% endif %}
{% if results|length > 0 %}
<h2>{{ 'Budget calculator'|trans }}</h2>
<div class="item-bloc">
{{ table_results(results) }}
</div>
{% endif %}
</div>

View File

@ -0,0 +1,53 @@
{% from 'ChillBudgetBundle:Budget:_macros.html.twig' import table_elements, table_results %}
<h2 class="subtitle">{{ 'Future budget'|trans }}</h2>
<div class="accordion" id="future_{{ entity.id }}">
<div class="accordion-item">
<h2 class="accordion-header" id="heading_future_{{ entity.id }}">
<button
class="accordion-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target="#collapse_future_{{ entity.id }}"
aria-expanded="false"
aria-controls="collapse_future_{{ entity.id }}">
<span class="folded">{{ 'Show future budget'|trans }}</span>
<span class="unfolded text-secondary">{{ 'Hide budget'|trans }}</span>
</button>
</h2>
<div id="collapse_future_{{ entity.id }}"
class="accordion-collapse collapse"
aria-labelledby="heading_future_{{ entity.id }}"
data-bs-parent="#future_{{ entity.id }}">
<div class="flex-table">
<h3 class="family-title">{{ 'Future resources'|trans }}</h3>
{% if futureResources|length > 0 %}
<div class="item-bloc">
{{ table_elements(futureResources, 'resource') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No future resources registered'|trans }}</span>
</div>
{% endif %}
</div>
<div class="flex-table">
<h3 class="family-title">{{ 'Future charges'|trans }}</h3>
{% if futureCharges|length > 0 %}
<div class="item-bloc">
{{ table_elements(futureCharges, 'charge') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No future charges registered'|trans }}</span>
</div>
{% endif %}
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,87 @@
{% macro table_elements(elements, family) %}
<table class="budget-table">
<thead>
<tr>
<th class="{{ family }}">{{ 'Budget element type'|trans }}</th>
<th class="{{ family }}">{{ 'Amount'|trans }}</th>
<th class="{{ family }}">{{ 'Validity period'|trans }}</th>
<th class="{{ family }}">&nbsp;</th>
</tr>
</thead>
<tbody>
{% set total = 0 %}
{% for f in elements %}
{% set total = total + f.amount %}
<tr>
<td class="column-wide bold">
{{ f.type|budget_element_type_display(family) }}
</td>
<td class="column-small">{{ f.amount|format_currency('EUR') }}</td>
<td class="column-small">
{% if f.endDate is not null %}
{{ 'Valid since %startDate% until %endDate%'|trans( { '%startDate%': f.startDate|format_date('short'), '%endDate%': f.endDate|format_date('short') } ) }}
{% else %}
{{ 'Valid since %startDate%'|trans( { '%startDate%': f.startDate|format_date('short') } ) }}
{% endif %}
</td>
<td class="column-small">
<ul class="record_actions">
{% if is_granted('CHILL_BUDGET_ELEMENT_SEE', f) %}
<li>
<a href="{{ path('chill_budget_' ~ family ~ '_view', { 'id': f.id } ) }}" class="btn btn-sm btn-show"></a>
</li>
{% endif %}
{% if is_granted('CHILL_BUDGET_ELEMENT_UPDATE', f) %}
<li>
<a href="{{ path('chill_budget_' ~ family ~'_edit', { 'id': f.id } ) }}" class="btn btn-sm btn-edit"></a>
</li>
{% endif %}
{% if is_granted('CHILL_BUDGET_ELEMENT_DELETE', f) %}
<li>
<a href="{{ path('chill_budget_' ~ family ~ '_delete', { 'id': f.id } ) }}" class="btn btn-sm btn-delete"></a>
</li>
{% endif %}
</ul>
</td>
</tr>
{% endfor %}
<tr class="total">
<td>
{{ 'Total'|trans }}
</td>
<td>
{{ total|format_currency('EUR') }}
</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
{% endmacro %}
{% macro table_results(results) %}
<table>
<thead>
<tr>
<th>&nbsp;</th>
<th>{{ 'Budget calculator result'|trans }}</th>
</tr>
</thead>
<tbody>
{% for result in results %}
<tr>
<td>{{ result.label }}</td>
<td>
{% if result.type == constant('CHILL\\BudgetBundle\\Calculator\\CalculatorResult::TYPE_CURRENCY') %}
{{ result.result|format_currency('EUR') }}
{% elseif result.type == constant('CHILL\\BudgetBundle\\Calculator\\CalculatorResult::TYPE_PERCENTAGE') %}
{{ result.result|round(2, 'ceil') ~ '%' }}
{% else %}
{{ result.result|round(2, 'common') }}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endmacro %}

View File

@ -0,0 +1,54 @@
{% from 'ChillBudgetBundle:Budget:_macros.html.twig' import table_elements, table_results %}
<h2 class="subtitle">{{ 'Past budget'|trans }}</h2>
<div class="accordion" id="past_{{ entity.id }}">
<div class="accordion-item">
<h2 class="accordion-header" id="heading_past_{{ entity.id }}">
<button
class="accordion-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target="#collapse_past_{{ entity.id }}"
aria-expanded="false"
aria-controls="collapse_past_{{ entity.id }}">
<span class="folded">{{ 'Show past budget'|trans }}</span>
<span class="unfolded text-secondary">{{ 'Hide budget'|trans }}</span>
</button>
</h2>
<div id="collapse_past_{{ entity.id }}"
class="accordion-collapse collapse"
aria-labelledby="heading_past_{{ entity.id }}"
data-bs-parent="#past_{{ entity.id }}">
<div class="flex-table">
<h3 class="family-title">{{ 'Past resources'|trans }}</h3>
{% if pastResources|length > 0 %}
<div class="item-bloc">
{{ table_elements(pastResources, 'resource') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No past resources registered'|trans }}</span>
<div class="item-bloc">
{% endif %}
</div>
<div class="flex-table">
<h3 class="family-title">{{ 'Past charges'|trans }}</h3>
{% if pastCharges|length > 0 %}
<div class="item-bloc">
{{ table_elements(pastCharges, 'charge') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No past charges registered'|trans }}</span>
</div>
{% endif %}
</div>
</div>
</div>
</div>

View File

@ -1,5 +1,7 @@
{% extends "@ChillPerson/Household/layout.html.twig" %}
{% from 'ChillBudgetBundle:Budget:_macros.html.twig' import table_elements, table_results %}
{% set activeRouteKey = '' %}
{% set title = 'Budget for household %household%'|trans({ '%household%' : household.id } ) %}
{% block title title %}
@ -58,283 +60,14 @@
</style>
{% endblock %}
{% set actualResources = [] %}
{% set futureResources = [] %}
{% set pastResources = [] %}
{% for r in resources %}
{% if r.startDate|date('U') <= 'now'|date('U') %}
{% if r.endDate is null or r.endDate|date('U') >= 'now'|date('U') %}
{% set actualResources = actualResources|merge([ r ]) %}
{% else %}
{% set pastResources = pastResources|merge([ r ]) %}
{% endif %}
{% else %}
{% set futureResources = futureResources|merge([ r ]) %}
{% endif %}
{% endfor %}
{% set actualCharges = [] %}
{% set futureCharges = [] %}
{% set pastCharges = [] %}
{% for c in charges %}
{% if c.startDate|date('U') <= 'now'|date('U') %}
{% if c.endDate is null or c.endDate|date('U') >= 'now'|date('U') %}
{% set actualCharges = actualCharges|merge([ c ]) %}
{% else %}
{% set pastCharges = pastCharges|merge([ c ]) %}
{% endif %}
{% else %}
{% set futureCharges = futureCharges|merge([ c ]) %}
{% endif %}
{% endfor %}
{% macro table_elements(elements, family) %}
<table class="budget-table">
<thead>
<tr>
<th class="{{ family }}">{{ 'Budget element type'|trans }}</th>
<th class="{{ family }}">{{ 'Amount'|trans }}</th>
<th class="{{ family }}">{{ 'Validity period'|trans }}</th>
<th class="{{ family }}">&nbsp;</th>
</tr>
</thead>
<tbody>
{% set total = 0 %}
{% for f in elements %}
{% set total = total + f.amount %}
<tr>
<td class="column-wide bold">
{{ f.type|budget_element_type_display(family) }}
</td>
<td class="column-small">{{ f.amount|format_currency('EUR') }}</td>
<td class="column-small">
{% if f.endDate is not null %}
{{ 'Valid since %startDate% until %endDate%'|trans( { '%startDate%': f.startDate|format_date('short'), '%endDate%': f.endDate|format_date('short') } ) }}
{% else %}
{{ 'Valid since %startDate%'|trans( { '%startDate%': f.startDate|format_date('short') } ) }}
{% endif %}
</td>
<td class="column-small">
<ul class="record_actions">
{% if is_granted('CHILL_BUDGET_ELEMENT_SEE', f) %}
<li>
<a href="{{ path('chill_budget_' ~ family ~ '_view', { 'id': f.id } ) }}" class="btn btn-sm btn-show"></a>
</li>
{% endif %}
{% if is_granted('CHILL_BUDGET_ELEMENT_UPDATE', f) %}
<li>
<a href="{{ path('chill_budget_' ~ family ~'_edit', { 'id': f.id } ) }}" class="btn btn-sm btn-edit"></a>
</li>
{% endif %}
{% if is_granted('CHILL_BUDGET_ELEMENT_DELETE', f) %}
<li>
<a href="{{ path('chill_budget_' ~ family ~ '_delete', { 'id': f.id } ) }}" class="btn btn-sm btn-delete"></a>
</li>
{% endif %}
</ul>
</td>
</tr>
{% endfor %}
<tr class="total">
<td>
{{ 'Total'|trans }}
</td>
<td>
{{ total|format_currency('EUR') }}
</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
{% endmacro %}
{% macro table_results(results) %}
<table>
<thead>
<tr>
<th>&nbsp;</th>
<th>{{ 'Budget calculator result'|trans }}</th>
</tr>
</thead>
<tbody>
{% for result in results %}
<tr>
<td>{{ result.label }}</td>
<td>
{% if result.type == constant('CHILL\\BudgetBundle\\Calculator\\CalculatorResult::TYPE_CURRENCY') %}
{{ result.result|format_currency('EUR') }}
{% elseif result.type == constant('CHILL\\BudgetBundle\\Calculator\\CalculatorResult::TYPE_PERCENTAGE') %}
{{ result.result|round(2, 'ceil') ~ '%' }}
{% else %}
{{ result.result|round(2, 'common') }}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endmacro %}
{% import _self as m %}
{% block content %}
<h1>{{ title }}</h1>
<h2 class="subtitle">{{ 'Actual budget'|trans }}</h2>
{% if resources|length == 0 and charges|length == 0 %}
<p><span class="chill-no-data-statement">{{ "There isn't any element recorded"|trans }}</span></p>
{% else %}
<div class="flex-table">
<h3 class="family-title">{{ 'Actual resources'|trans }}</h3>
{% if actualResources|length > 0 %}
<div class="item-bloc">
{{ m.table_elements(actualResources, 'resource') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No resources registered'|trans }}</span>
</div>
{% endif %}
</div>
<div class="flex-table">
<h3 class="family-title">{{ 'Actual charges'|trans }}</h3>
{% if actualCharges|length > 0 %}
<div class="item-bloc">
{{ m.table_elements(actualCharges, 'charge') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No charges registered'|trans }}</span>
</div>
{% endif %}
{% if results|length > 0 %}
<h2>{{ 'Budget calculator'|trans }}</h2>
<div class="item-bloc">
{{ m.table_results(results) }}
</div>
{% endif %}
</div>
{% endif %}
{% if pastCharges|length > 0 or pastResources|length > 0 %}
<h2 class="subtitle">{{ 'Past budget'|trans }}</h2>
<div class="accordion" id="past_{{ household.id }}">
<div class="accordion-item">
<h2 class="accordion-header" id="heading_past_{{ household.id }}">
<button
class="accordion-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target="#collapse_past_{{ household.id }}"
aria-expanded="false"
aria-controls="collapse_past_{{ household.id }}">
<span class="folded">{{ 'Show past budget'|trans }}</span>
<span class="unfolded text-secondary">{{ 'Hide budget'|trans }}</span>
</button>
</h2>
<div id="collapse_past_{{ household.id }}"
class="accordion-collapse collapse"
aria-labelledby="heading_past_{{ household.id }}"
data-bs-parent="#past_{{ household.id }}">
<div class="flex-table">
<h3 class="family-title">{{ 'Past resources'|trans }}</h3>
{% if pastResources|length > 0 %}
<div class="item-bloc">
{{ m.table_elements(pastResources, 'resource') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No past resources registered'|trans }}</span>
<div class="item-bloc">
{% endif %}
</div>
<div class="flex-table">
<h3 class="family-title">{{ 'Past charges'|trans }}</h3>
{% if pastCharges|length > 0 %}
<div class="item-bloc">
{{ m.table_elements(pastCharges, 'charge') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No past charges registered'|trans }}</span>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endif %}
{% if futureCharges|length > 0 or futureResources|length > 0 %}
<h2 class="subtitle">{{ 'Future budget'|trans }}</h2>
<div class="accordion" id="future_{{ household.id }}">
<div class="accordion-item">
<h2 class="accordion-header" id="heading_future_{{ household.id }}">
<button
class="accordion-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target="#collapse_{{ household.id }}"
aria-expanded="false"
aria-controls="collapse_{{ household.id }}">
<span class="folded">{{ 'Show future budget'|trans }}</span>
<span class="unfolded text-secondary">{{ 'Hide budget'|trans }}</span>
</button>
</h2>
<div id="collapse_{{ household.id }}"
class="accordion-collapse collapse"
aria-labelledby="heading_{{ household.id }}"
data-bs-parent="#future_{{ household.id }}">
<div class="flex-table">
<h3 class="family-title">{{ 'Future resources'|trans }}</h3>
{% if futureResources|length > 0 %}
<div class="item-bloc">
{{ m.table_elements(futureResources, 'resource') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No future resources registered'|trans }}</span>
</div>
{% endif %}
</div>
<div class="flex-table">
<h3 class="family-title">{{ 'Future charges'|trans }}</h3>
{% if futureCharges|length > 0 %}
<div class="item-bloc">
{{ m.table_elements(futureCharges, 'charge') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No future charges registered'|trans }}</span>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endif %}
{% include 'ChillBudgetBundle:Budget:_budget.html.twig' with {
'resources': resources,
'charges': charges,
'household': household
} %}
{% if household.getCurrentMembers|length > 0 %}
<h2 class="subtitle">{{ 'Current budget household members'|trans }}</h2>
@ -352,7 +85,7 @@
aria-expanded="false"
aria-controls="collapse_{{ member.id }}">
<span class="folded">{{ 'Show budget of %name%'|trans({'%name%': member.firstName ~ " " ~ member.lastName }) }}</span>
<span class="unfolded text-secondary">{{ 'Hide budget'|trans }}</span>
<span class="unfolded text-secondary">{{ 'Hide budget of %name%'|trans({'%name%': member.firstName ~ " " ~ member.lastName }) }}</span>
</button>
</h2>
@ -361,50 +94,26 @@
aria-labelledby="heading_{{ member.id }}"
data-bs-parent="#nonCurrent">
{% if member.getBudgetResources|length > 0 or member.getBudgetCharges|length > 0 %}
<<<<<<< HEAD
{% include 'ChillBudgetBundle:Budget:_budget.html.twig' with {
'resources': member.getBudgetResources,
'charges': member.getBudgetCharges,
'person': member
} %}
=======
>>>>>>> 26373e5d238031e1af840ab2e9b4034a2227df0a
<div class="flex-table">
<h3 class="family-title">{{ 'Actual resources for %name%'|trans({ '%name%' : member.firstName ~ " " ~ member.lastName }) }}</h3>
{% if member.getBudgetResources|length > 0 %}
{% set memberResources = member.getBudgetResources %}
<div class="item-bloc">
{{ m.table_elements(memberResources, 'resource') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No resources registered'|trans }}</span>
</div>
{% endif %}
</div>
<div class="flex-table">
<h3 class="family-title">{{ 'Actual charges for %name%'|trans({ '%name%' : member.firstName ~ " " ~ member.lastName }) }}</h3>
{% if member.getBudgetCharges|length > 0 %}
{% set memberCharges = member.getBudgetCharges %}
<div class="item-bloc">
{{ m.table_elements(memberCharges, 'charge') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No charges registered'|trans }}</span>
</div>
{% endif %}
</div>
{% else %}
<div class="flex-table">
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No current budget element registered'|trans }}</span>
</div>
</div>
{% endif %}
<ul class="record_actions">
<li>
<a class="btn btn-show" href="{{ path('chill_budget_elements_index', { 'id': member.id } ) }}">{{ 'See complete budget'|trans }}</a>
</li>
{% if is_granted('CHILL_BUDGET_ELEMENT_SEE', member) %}
<li>
<a class="btn btn-show" title={{ 'See person'|trans }} href="{{ path('chill_person_view', { 'person_id': member.id } ) }}"></a>
</li>
{% endif %}
{% if is_granted('CHILL_BUDGET_ELEMENT_CREATE', member) %}
<li>
<a class="btn btn-create" title={{ 'Create new resource'|trans }} href="{{ path('chill_budget_resource_new', { 'id': member.id} ) }}">{{ 'Resource'|trans }}</a>
</li>
<li>
<a class="btn btn-create" title={{ 'Create new charge'|trans }} href="{{ path('chill_budget_charge_new', { 'id': member.id} ) }}">{{ 'Charge'|trans }}</a>
</li>
{% endif %}
</ul>
</div>
</div>
@ -412,18 +121,17 @@
{% endfor %}
{% endif %}
{% if (resources|length + charges|length) == 0 or futureCharges|length > 0 or futureResources|length > 0 or pastCharges|length > 0 or pastResources|length > 0 %}
{% if is_granted('CHILL_BUDGET_ELEMENT_CREATE', household) %}
<ul class="record_actions sticky-form-buttons">
<li>
<a class="btn btn-create" href="{{ path('chill_budget_resource_household_new', { 'id': household.id} ) }}">{{ 'Create new resource'|trans }}</a>
</li>
<li>
<a class="btn btn-create" href="{{ path('chill_budget_charge_household_new', { 'id': household.id} ) }}">{{ 'Create new charge'|trans }}</a>
</li>
</ul>
{% endif %}
{% if is_granted('CHILL_BUDGET_ELEMENT_CREATE', household) %}
<ul class="record_actions sticky-form-buttons">
<li>
<a class="btn btn-create" href="{{ path('chill_budget_resource_household_new', { 'id': household.id} ) }}">{{ 'Create new resource'|trans }}</a>
</li>
<li>
<a class="btn btn-create" href="{{ path('chill_budget_charge_household_new', { 'id': household.id} ) }}">{{ 'Create new charge'|trans }}</a>
</li>
</ul>
{% endif %}
{% endblock %}

View File

@ -57,296 +57,16 @@
</style>
{% endblock %}
{% set actualResources = [] %}
{% set futureResources = [] %}
{% set pastResources = [] %}
{% for r in resources %}
{% if r.startDate|date('U') <= 'now'|date('U') %}
{% if r.endDate is null or r.endDate|date('U') >= 'now'|date('U') %}
{% set actualResources = actualResources|merge([ r ]) %}
{% else %}
{% set pastResources = pastResources|merge([ r ]) %}
{% endif %}
{% else %}
{% set futureResources = futureResources|merge([ r ]) %}
{% endif %}
{% endfor %}
{% set actualCharges = [] %}
{% set futureCharges = [] %}
{% set pastCharges = [] %}
{% for c in charges %}
{% if c.startDate|date('U') <= 'now'|date('U') %}
{% if c.endDate is null or c.endDate|date('U') >= 'now'|date('U') %}
{% set actualCharges = actualCharges|merge([ c ]) %}
{% else %}
{% set pastCharges = pastCharges|merge([ c ]) %}
{% endif %}
{% else %}
{% set futureCharges = futureCharges|merge([ c ]) %}
{% endif %}
{% endfor %}
{% macro table_elements(elements, family) %}
<table class="budget-table">
<thead>
<tr>
<th class="{{ family }}">{{ 'Budget element type'|trans }}</th>
<th class="{{ family }}">{{ 'Amount'|trans }}</th>
<th class="{{ family }}">{{ 'Validity period'|trans }}</th>
<th class="{{ family }}">&nbsp;</th>
</tr>
</thead>
<tbody>
{% set total = 0 %}
{% for f in elements %}
{% set total = total + f.amount %}
<tr>
<td class="column-wide bold">
{{ f.type|budget_element_type_display(family) }}
</td>
<td class="column-small">{{ f.amount|format_currency('EUR') }}</td>
<td class="column-small">
{% if f.endDate is not null %}
{{ 'Valid since %startDate% until %endDate%'|trans( { '%startDate%': f.startDate|format_date('short'), '%endDate%': f.endDate|format_date('short') } ) }}
{% else %}
{{ 'Valid since %startDate%'|trans( { '%startDate%': f.startDate|format_date('short') } ) }}
{% endif %}
</td>
<td class="column-small">
<ul class="record_actions">
{% if is_granted('CHILL_BUDGET_ELEMENT_SEE', f) %}
<li>
<a href="{{ path('chill_budget_' ~ family ~ '_view', { 'id': f.id } ) }}" class="btn btn-sm btn-show"></a>
</li>
{% endif %}
{% if is_granted('CHILL_BUDGET_ELEMENT_UPDATE', f) %}
<li>
<a href="{{ path('chill_budget_' ~ family ~'_edit', { 'id': f.id } ) }}" class="btn btn-sm btn-edit"></a>
</li>
{% endif %}
{% if is_granted('CHILL_BUDGET_ELEMENT_DELETE', f) %}
<li>
<a href="{{ path('chill_budget_' ~ family ~ '_delete', { 'id': f.id } ) }}" class="btn btn-sm btn-delete"></a>
</li>
{% endif %}
</ul>
</td>
</tr>
{% endfor %}
<tr class="total">
<td>
{{ 'Total'|trans }}
</td>
<td>
{{ total|format_currency('EUR') }}
</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
{% endmacro %}
{% macro table_results(results) %}
<table>
<thead>
<tr>
<th>&nbsp;</th>
<th>{{ 'Budget calculator result'|trans }}</th>
</tr>
</thead>
<tbody>
{% for result in results %}
<tr>
<td>{{ result.label }}</td>
<td>
{% if result.type == constant('CHILL\\BudgetBundle\\Calculator\\CalculatorResult::TYPE_CURRENCY') %}
{{ result.result|format_currency('EUR') }}
{% elseif result.type == constant('CHILL\\BudgetBundle\\Calculator\\CalculatorResult::TYPE_PERCENTAGE') %}
{{ result.result|round(2, 'ceil') ~ '%' }}
{% else %}
{{ result.result|round(2, 'common') }}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endmacro %}
{% import _self as m %}
{% block content %}
<h1>{{ title }}</h1>
<h2 class="subtitle">{{ 'Actual budget'|trans }}</h2>
{% include 'ChillBudgetBundle:Budget:_budget.html.twig' with {
'resources': resources,
'charges': charges,
'person': person
} %}
{% if resources|length == 0 and charges|length == 0 %}
<p><span class="chill-no-data-statement">{{ "There isn't any element recorded"|trans }}</span></p>
{% else %}
<div class="flex-table">
<h3 class="family-title">{{ 'Actual resources'|trans }}</h3>
{% if actualResources|length > 0 %}
<div class="item-bloc">
{{ m.table_elements(actualResources, 'resource') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No resources registered'|trans }}</span>
</div>
{% endif %}
</div>
<div class="flex-table">
<h3 class="family-title">{{ 'Actual charges'|trans }}</h3>
{% if actualCharges|length > 0 %}
<div class="item-bloc">
{{ m.table_elements(actualCharges, 'charge') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No charges registered'|trans }}</span>
</div>
{% endif %}
{% if results|length > 0 %}
<h2>{{ 'Budget calculator'|trans }}</h2>
<div class="item-bloc">
{{ m.table_results(results) }}
</div>
{% endif %}
</div>
{# {% if is_granted('CHILL_BUDGET_ELEMENT_CREATE', person) %}
<ul class="record_actions sticky-form-buttons">
<li>
<a class="btn btn-create" href="{{ path('chill_budget_resource_new', { 'id': person.id} ) }}">{{ 'Create new resource'|trans }}</a>
</li>
<li>
<a class="btn btn-create" href="{{ path('chill_budget_charge_new', { 'id': person.id} ) }}">{{ 'Create new charge'|trans }}</a>
</li>
</ul>
{% endif %} #}
{% endif %}
{% if pastCharges|length > 0 or pastResources|length > 0 %}
<h2 class="subtitle">{{ 'Past budget'|trans }}</h2>
<div class="accordion" id="past_{{ person.id }}">
<div class="accordion-item">
<h2 class="accordion-header" id="heading_past_{{ person.id }}">
<button
class="accordion-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target="#collapse_past_{{ person.id }}"
aria-expanded="false"
aria-controls="collapse_past_{{ person.id }}">
<span class="folded">{{ 'Show past budget'|trans }}</span>
<span class="unfolded text-secondary">{{ 'Hide budget'|trans }}</span>
</button>
</h2>
<div id="collapse_past_{{ person.id }}"
class="accordion-collapse collapse"
aria-labelledby="heading_past_{{ person.id }}"
data-bs-parent="#past_{{ person.id }}">
<div class="flex-table">
<h3 class="family-title">{{ 'Past resources'|trans }}</h3>
{% if pastResources|length > 0 %}
<div class="item-bloc">
{{ m.table_elements(pastResources, 'resource') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No past resources registered'|trans }}</span>
<div class="item-bloc">
{% endif %}
</div>
<div class="flex-table">
<h3 class="family-title">{{ 'Past charges'|trans }}</h3>
{% if pastCharges|length > 0 %}
<div class="item-bloc">
{{ m.table_elements(pastCharges, 'charge') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No past charges registered'|trans }}</span>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endif %}
{% if futureCharges|length > 0 or futureResources|length > 0 %}
<h2 class="subtitle">{{ 'Future budget'|trans }}</h2>
<div class="accordion" id="future_{{ person.id }}">
<div class="accordion-item">
<h2 class="accordion-header" id="heading_future_{{ person.id }}">
<button
class="accordion-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target="#collapse_{{ person.id }}"
aria-expanded="false"
aria-controls="collapse_{{ person.id }}">
<span class="folded">{{ 'Show future budget'|trans }}</span>
<span class="unfolded text-secondary">{{ 'Hide budget'|trans }}</span>
</button>
</h2>
<div id="collapse_{{ person.id }}"
class="accordion-collapse collapse"
aria-labelledby="heading_{{ person.id }}"
data-bs-parent="#future_{{ person.id }}">
<div class="flex-table">
<h3 class="family-title">{{ 'Future resources'|trans }}</h3>
{% if futureResources|length > 0 %}
<div class="item-bloc">
{{ m.table_elements(futureResources, 'resource') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No future resources registered'|trans }}</span>
</div>
{% endif %}
</div>
<div class="flex-table">
<h3 class="family-title">{{ 'Future charges'|trans }}</h3>
{% if futureCharges|length > 0 %}
<div class="item-bloc">
{{ m.table_elements(futureCharges, 'charge') }}
</div>
{% else %}
<div class="item-bloc">
<span class="chill-no-data-statement">{{ 'No future charges registered'|trans }}</span>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endif %}
{% if (resources|length + charges|length) == 0 or futureCharges|length > 0 or futureResources|length > 0 or pastCharges|length > 0 or pastResources|length > 0 %}
{# {% if (resources|length + charges|length) == 0 or futureCharges|length > 0 or futureResources|length > 0 or pastCharges|length > 0 or pastResources|length > 0 %} #}
{% if is_granted('CHILL_BUDGET_ELEMENT_CREATE', person) %}
<ul class="record_actions sticky-form-buttons">
<li>
@ -357,7 +77,7 @@
</li>
</ul>
{% endif %}
{% endif %}
{# {% endif %} #}
{% endblock %}

View File

@ -1,10 +1,13 @@
Budget: Budget
Resource: Ressource
Charge: Charge
Budget for %name%: Budget de %name%
Budget for household %household%: Budget de ménage %household%
Current budget household members: Budgets actuelles des membres du ménage
Show budget of %name%: Montrer budget de %name%
See complete budget: Voir budget complet
Hide budget: Masquer
Hide budget of %name%: Masquer budget de %name%
Resource element type: Nature de la ressource
Actual budget: Budget actuel
Actual resources: Ressources actuelles
@ -26,6 +29,7 @@ End of validity period: Fin de la période de validité
Total: Total
Create new resource: Créer une nouvelle ressource
Create new charge: Créer une nouvelle charge
See person: Voir person
There isn't any element recorded: Aucun élément enregistré
No resources registered: Aucune ressource enregistrée