support different formats in user timesheet exports (#1222)

This commit is contained in:
Kevin Papst
2019-11-08 16:10:38 +01:00
committed by GitHub
parent 0705c26513
commit fa1c79e15c
75 changed files with 1872 additions and 951 deletions

View File

@@ -3,7 +3,16 @@
{% set actions = {'search': {'class': 'search-toggle visible-xs-inline'}} %}
{% if is_granted('export_own_timesheet') %}
{% set actions = actions|merge({'download': {'url': path('timesheet_export'), 'class': 'toolbar-action'}}) %}
{% set exporterIds = timesheet_exporter() %}
{% if exporterIds|length == 1 %}
{% set actions = actions|merge({'download': {'url': path('timesheet_export', {'exporter': exporterIds.0}), 'class': 'toolbar-action'}}) %}
{% elseif exporterIds|length > 1 %}
{% set children = {} %}
{% for exporter in exporterIds %}
{% set children = children|merge({(exporter): {'title': ('button.' ~ exporter)|trans, 'url': path('timesheet_export', {'exporter': exporter}), 'class': 'toolbar-action exporter-' ~ exporter}}) %}
{% endfor %}
{% set actions = actions|merge({'download': {'children': children}}) %}
{% endif %}
{% endif %}
{% set actions = actions|merge({'visibility': {'modal': '#modal_timesheet'}}) %}
{% if is_granted('create_own_timesheet') %}

View File

@@ -3,6 +3,10 @@
{% extends 'invoice/layout.html.twig' %}
{% block invoice %}
{% set showUserColumn = true %}
{% if query.user %}
{% set showUserColumn = false %}
{% endif %}
<div class="row">
<div class="col-xs-12">
@@ -10,16 +14,20 @@
<span contenteditable="true">
{% if query.begin is not empty and query.end is not empty %}
{% if query.begin|date('m') != query.end|date('m') or query.begin|date('Y') != query.end|date('Y') %}
{{ query.begin|date_short }} - {{ query.end|date_short }}:
{{ query.begin|date_short }} - {{ query.end|date_short }}
{% elseif query.end is not empty %}
{{ query.end|month_name|trans }} {{ query.end|date('Y') }}:
{{ query.end|month_name|trans }} {{ query.end|date('Y') }}
{% elseif query.begin is not empty %}
{{ query.begin|month_name|trans }} {{ query.begin|date('Y') }}:
{{ query.begin|month_name|trans }} {{ query.begin|date('Y') }}
{% endif %}
{% endif %}
{{ widgets.username(query.user) }}
</span>
</h2>
{% if not showUserColumn %}
<p>
{{ 'label.user'|trans }}: {{ widgets.username(query.user) }}
</p>
{% endif %}
</div>
</div>
@@ -29,6 +37,9 @@
<thead>
<tr>
<th>{{ 'label.date'|trans }}</th>
{% if showUserColumn %}
<th>{{ 'label.username'|trans }}</th>
{% endif %}
<th>{{ 'label.description'|trans }}</th>
{% for field in metaColumns %}
<th>{{ field.label|trans }}</th>
@@ -42,11 +53,14 @@
{% set timeWorked = timeWorked + entry.duration %}
<tr>
<td class="text-nowrap">{{ entry.begin|date_short }}</td>
{% if showUserColumn %}
<td>{{ widgets.username(entry.user) }}</td>
{% endif %}
<td>
{% if entry.description is not empty %}
<div>
{{ entry.description|escape|desc2html }}
</div>
<div>
{{ entry.description|escape|desc2html }}
</div>
{% endif %}
<span class="small">
{{ 'label.activity'|trans }}: {{ entry.activity.name }} |
@@ -64,6 +78,9 @@
<tfoot>
<tr>
<th></th>
{% if showUserColumn %}
<th></th>
{% endif %}
{% for field in metaColumns %}
<th></th>
{% endfor %}