{% extends 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/toolbar.html.twig" as toolbar %}
{% import "macros/datatables.html.twig" as tables %}
{% import "macros/actions.html.twig" as actions %}
{% set columns = {
'date': 'alwaysVisible',
'user': 'hidden-sm',
'description': 'hidden-xs hidden-sm',
'unit_price': 'hidden-xs text-center',
'amount': 'text-center',
'total_rate': 'text-right alwaysVisible',
} %}
{% set tableName = 'invoice' %}
{% block page_title %}{{ 'invoice.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'invoice.subtitle'|trans }}{% endblock %}
{% block page_actions %}{{ actions.invoices('index') }}{% endblock %}
{% block main_before %}
{{ toolbar.toolbar(form, 'collapseInvoice', true) }}
{{ tables.data_table_column_modal(tableName, columns) }}
{% endblock %}
{% block main_after %}
{% endblock %}
{% block main %}
{% set entries = {} %}
{% if model.calculator is not empty and model.calculator.entries is not empty %}
{% set entries = model.calculator.entries %}
{% endif %}
{% if entries is empty %}
{{ widgets.callout('warning', 'error.no_entries_found') }}
{% else %}
{{ widgets.callout('success', 'invoice.preview') }}
{{ tables.data_table_header(tableName, columns) }}
{% for entry in entries %}
{% set duration = entry.duration|duration %}
{% if entry.fixedRate is not null %}
{% set rate = entry.fixedRate %}
{% set duration = 1 %}
{% elseif entry.hourlyRate is not null %}
{% set rate = entry.hourlyRate %}
{% else %}
{% set rate = entry.user.preferenceValue('hourly_rate') %}
{% endif %}
{{ entry.begin|date_short }}
{{ widgets.label_user(entry.user) }}
{% if entry.description is not empty %}
{{ entry.description|escape|desc2html }}
{% else %}
{{ entry.activity.name }} / {{ entry.project.name }}
{% endif %}
{{ rate|money(model.calculator.currency) }}
{{ duration }}
{{ entry.rate|money(model.calculator.currency) }}
{% endfor %}
{{ tables.data_table_footer(entries) }}
{% if is_granted('create_invoice') %}
{% endif %}
{% endif %}
{% endblock %}