mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
229 lines
8.1 KiB
Twig
229 lines
8.1 KiB
Twig
{% extends "@ChillPerson/layout.html.twig" %}
|
|
|
|
{% set activeRouteKey = '' %}
|
|
{% set title = 'Budget for %name%'|trans({ '%name%' : person.firstName ~ " " ~ person.lastName } ) %}
|
|
{% block title title %}
|
|
|
|
|
|
{% 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>
|
|
<thead>
|
|
<tr>
|
|
<th>{{ 'Budget element type'|trans }}</th>
|
|
<th>{{ 'Amount'|trans }}</th>
|
|
<th>{{ 'Validity period'|trans }}</th>
|
|
<th> </th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% set total = 0 %}
|
|
{% for f in elements %}
|
|
{% set total = total + f.amount %}
|
|
<tr>
|
|
<td>
|
|
{{ f.type|budget_element_type_display(family) }}
|
|
</td>
|
|
<td>{{ f.amount|localizedcurrency('EUR') }}</td>
|
|
<td>
|
|
{% if f.endDate is not null %}
|
|
{{ 'Valid since %startDate% until %endDate%'|trans( { '%startDate%': f.startDate|localizeddate('long', 'none'), '%endDate%': f.endDate|localizeddate('long', 'none') } ) }}
|
|
{% else %}
|
|
{{ 'Valid since %startDate%'|trans( { '%startDate%': f.startDate|localizeddate('long', 'none') } ) }}
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
<ul class="record_actions">
|
|
{% if is_granted(constant('Chill\\AMLI\\BudgetBundle\\Security\\Authorization\\BudgetElementVoter::SHOW'), f) %}
|
|
<li>
|
|
<a href="{{ path('chill_budget_' ~ family ~ '_view', { 'id': f.id } ) }}" class="sc-button bt-show"></a>
|
|
</li>
|
|
{% endif %}
|
|
{% if is_granted(constant('Chill\\AMLI\\BudgetBundle\\Security\\Authorization\\BudgetElementVoter::UPDATE'), f) %}
|
|
<li>
|
|
<a href="{{ path('chill_budget_' ~ family ~'_edit', { 'id': f.id } ) }}" class="sc-button bt-edit"></a>
|
|
</li>
|
|
{% endif %}
|
|
{% if is_granted(constant('Chill\\AMLI\\BudgetBundle\\Security\\Authorization\\BudgetElementVoter::DELETE'), f) %}
|
|
<li>
|
|
<a href="{{ path('chill_budget_' ~ family ~ '_delete', { 'id': f.id } ) }}" class="sc-button bt-delete"></a>
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
<tr>
|
|
<td>
|
|
{{ 'Total'|trans }}
|
|
</td>
|
|
<td>
|
|
{{ total|localizedcurrency('EUR') }}
|
|
</td>
|
|
<td> </td>
|
|
<td> </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
{% endmacro %}
|
|
|
|
{% macro table_results(results) %}
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th> </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\\AMLI\\BudgetBundle\\Calculator\\CalculatorResult::TYPE_CURRENCY') %}
|
|
{{ result.result|localizedcurrency('EUR') }}
|
|
{% elseif result.type == constant('CHILL\\AMLI\\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 personcontent %}
|
|
<h1>{{ title }}</h1>
|
|
|
|
<h2>{{ '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 %}
|
|
<h3>{{ 'Actual resources'|trans }}</h3>
|
|
|
|
{% if actualResources|length > 0 %}
|
|
{{ m.table_elements(actualResources, 'resource') }}
|
|
{% else %}
|
|
<span class="chill-no-data-statement">{{ 'No resources registered'|trans }}</span>
|
|
{% endif %}
|
|
|
|
<h3>{{ 'Actual charges'|trans }}</h3>
|
|
|
|
{% if actualCharges|length > 0 %}
|
|
{{ m.table_elements(actualCharges, 'charge') }}
|
|
{% else %}
|
|
<span class="chill-no-data-statement">{{ 'No charges registered'|trans }}</span>
|
|
{% endif %}
|
|
|
|
{% if results|length > 0 %}
|
|
<h2>{{ 'Budget calculator'|trans }}</h2>
|
|
|
|
{{ m.table_results(results) }}
|
|
{% endif %}
|
|
|
|
{% if is_granted(constant('Chill\\AMLI\\BudgetBundle\\Security\\Authorization\\BudgetElementVoter::CREATE'), person) %}
|
|
<ul class="record_actions">
|
|
<li>
|
|
<a class="sc-button bt-create" href="{{ path('chill_budget_resource_new', { 'id': person.id} ) }}">{{ 'Create new resource'|trans }}</a>
|
|
</li>
|
|
<li>
|
|
<a class="sc-button bt-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>{{ 'Past budget'|trans }}</h2>
|
|
|
|
<h3>{{ 'Past resources'|trans }}</h3>
|
|
|
|
{% if pastResources|length > 0 %}
|
|
{{ m.table_elements(pastResources, 'resource') }}
|
|
{% else %}
|
|
<span class="chill-no-data-statement">{{ 'No past resources registered'|trans }}</span>
|
|
{% endif %}
|
|
|
|
<h3>{{ 'Past charges'|trans }}</h3>
|
|
|
|
{% if pastCharges|length > 0 %}
|
|
{{ m.table_elements(pastCharges, 'charge') }}
|
|
{% else %}
|
|
<span class="chill-no-data-statement">{{ 'No past charges registered'|trans }}</span>
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
{% if futureCharges|length > 0 or futureResources|length > 0 %}
|
|
<h2>{{ 'Future budget'|trans }}</h2>
|
|
|
|
<h3>{{ 'Future resources'|trans }}</h3>
|
|
|
|
{% if futureResources|length > 0 %}
|
|
{{ m.table_elements(futureResources, 'resource') }}
|
|
{% else %}
|
|
<span class="chill-no-data-statement">{{ 'No future resources registered'|trans }}</span>
|
|
{% endif %}
|
|
|
|
<h3>{{ 'Future charges'|trans }}</h3>
|
|
|
|
{% if futureCharges|length > 0 %}
|
|
{{ m.table_elements(futureCharges, 'charge') }}
|
|
{% else %}
|
|
<span class="chill-no-data-statement">{{ 'No future charges registered'|trans }}</span>
|
|
{% endif %}
|
|
{% 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(constant('Chill\\AMLI\\BudgetBundle\\Security\\Authorization\\BudgetElementVoter::CREATE'), person) %}
|
|
<ul class="record_actions">
|
|
<li>
|
|
<a class="sc-button bt-create" href="{{ path('chill_budget_resource_new', { 'id': person.id} ) }}">{{ 'Create new resource'|trans }}</a>
|
|
</li>
|
|
<li>
|
|
<a class="sc-button bt-create" href="{{ path('chill_budget_charge_new', { 'id': person.id} ) }}">{{ 'Create new charge'|trans }}</a>
|
|
</li>
|
|
</ul>
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
{% endblock %}
|
|
|