{% extends 'base.html.twig' %} {% import "macros/widgets.html.twig" as widgets %} {% import "macros/datatables.html.twig" as tables %} {% import "macros/toolbar.html.twig" as toolbar %} {% import "timesheet/actions.html.twig" as actions %} {% import _self as timesheet %} {% set tableName = 'timesheet' %} {% set canSeeRate = is_granted('view_rate_own_timesheet') %} {% set columns = { 'date': {'class': 'alwaysVisible', 'orderBy': 'begin'}, } %} {% if showStartEndTime %} {% set columns = columns|merge({ 'starttime': {'class': '', 'orderBy': 'begin'}, 'endtime': {'class': 'hidden-xs', 'orderBy': 'end'} }) %} {% endif %} {% set columns = columns|merge({'duration': ''}) %} {% if canSeeRate %} {% set columns = columns|merge({'rate': 'hidden-xs'}) %} {% endif %} {% set columns = columns|merge({ 'customer': 'hidden-xs hidden-sm hidden-md', 'project': 'hidden-xs hidden-sm hidden-md', 'activity': 'hidden-xs hidden-sm', 'description': 'hidden-xs hidden-sm', 'tags': {'class': 'hidden-xs hidden-sm', 'orderBy': false}, }) %} {% for field in metaColumns %} {% set columns = columns|merge({ ('mf_' ~ field.name): {'title': field.label, 'class': 'hidden-xs hidden-sm', 'orderBy': false} }) %} {% endfor %} {% set columns = columns|merge({ 'actions': 'actions alwaysVisible', }) %} {% block page_title %}{{ 'timesheet.title'|trans }}{% endblock %} {% block page_search %}{{ toolbar.dropDownSearch(toolbarForm) }}{% endblock %} {% block page_actions %}{{ actions.timesheets('index') }}{% endblock %} {% block main_before %} {{ tables.data_table_column_modal(tableName, columns) }} {% endblock %} {% block main %} {% if entries.count == 0 %} {{ widgets.callout('warning', 'error.no_entries_found') }} {% else %} {{ tables.datatable_header(tableName, columns, query, {'striped': not showSummary, 'reload': 'kimai.timesheetUpdate'}) }} {% set day = null %} {% set dayDuration = 0 %} {% set dayRate = {} %} {% for entry in entries %} {%- set customerCurrency = entry.project.customer.currency -%} {%- if day is same as(null) -%} {% set day = entry.begin|date_short %} {% endif %} {%- if showSummary and day is not same as(entry.begin|date_short) -%} {{ timesheet.summary(day, dayDuration, dayRate, columns, canSeeRate, showStartEndTime, tableName, metaColumns) }} {% set day = entry.begin|date_short %} {% set dayDuration = 0 %} {% set dayRate = {} %} {%- endif -%} {{ entry.begin|date_short }} {% if showStartEndTime %} {{ entry.begin|time }} {% if entry.end %} {{ entry.end|time }} {% else %} ‐ {% endif %} {% endif %} {% if entry.end %} {{ entry.duration|duration }} {% else %} {{ entry|duration }} {% endif %} {% if canSeeRate %} {% if not entry.end %} ‐ {% else %} {{ entry.rate|money(entry.project.customer.currency) }} {% endif %} {% endif %} {{ widgets.label_customer(entry.project.customer) }} {{ widgets.label_project(entry.project) }} {{ widgets.label_activity(entry.activity) }} {{ entry.description|escape|desc2html }} {{ widgets.tag_list(entry.tags) }} {% for field in metaColumns %} {{ tables.datatable_meta_column(entry, field) }} {% endfor %} {{- actions.timesheet(entry, 'index') -}} {%- if entry.end -%} {% if dayRate[customerCurrency] is not defined %} {% set dayRate = dayRate|merge({(customerCurrency): 0}) %} {% endif %} {% set dayRate = dayRate|merge({(customerCurrency): dayRate[customerCurrency] + entry.rate}) %} {%- endif -%} {%- set dayDuration = dayDuration + entry.duration -%} {% endfor %} {% if showSummary %} {{ timesheet.summary(day, dayDuration, dayRate, columns, canSeeRate, showStartEndTime, tableName, metaColumns) }} {% endif %} {{ tables.data_table_footer(entries, 'timesheet_paginated') }} {% endif %} {% endblock %} {% macro summary(day, duration, dayRates, columns, canSeeRate, showStartEndTime, tableName, metaColumns) %} {% import "macros/datatables.html.twig" as tables %} {{ day }} {% if showStartEndTime %} {% endif %} {{ duration|duration }} {% if canSeeRate %} {% for currency, rate in dayRates %} {{ rate|money(currency) }} {% if not loop.last %}
{% endif %} {% endfor %} {% endif %} {% for field in metaColumns %} {% endfor %} {% endmacro %}