{% extends 'base.html.twig' %} {% import "macros/widgets.html.twig" as widgets %} {% import "macros/datatables.html.twig" as tables %} {% import "macros/search.html.twig" as search %} {% if not showSummary is defined %} {% set showSummary = false %} {% endif %} {% if not showStartEndTime is defined %} {% set showStartEndTime = true %} {% endif %} {% set columns = { 'id': {'class': 'alwaysVisible multiCheckbox', 'orderBy': false, 'title': false, 'html_before': tables.datatable_multiupdate_all()}, 'date': {'class': 'alwaysVisible', 'orderBy': 'begin'}, } %} {% if showStartEndTime %} {% set columns = columns|merge({ 'starttime': {'class': 'hidden-xs', 'orderBy': 'begin'}, 'endtime': {'class': 'hidden-xs', 'orderBy': 'end'} }) %} {% endif %} {% set columns = columns|merge({'duration': ''}) %} {% if canSeeRate %} {% set columns = columns|merge({'rate': ''}) %} {% endif %} {% set columns = columns|merge({ 'customer': {'class': 'hidden-xs hidden-sm hidden-md'}, 'project': {'class': 'hidden-xs hidden-sm hidden-md'}, 'activity': {'class': 'hidden-xs hidden-sm'}, 'description': {'class': '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|trans, 'class': 'hidden-xs hidden-sm', 'orderBy': false} }) %} {% endfor %} {% if canSeeUsername %} {% set columns = columns|merge({ 'username': {'class': 'hidden-xs', 'orderBy': false}, }) %} {% endif %} {% set columns = columns|merge({ 'billable': {'class': 'text-center hidden w-min', 'orderBy': false}, 'exported': {'class': 'text-center hidden w-min', 'orderBy': false}, 'actions': {'class': 'actions alwaysVisible'}, }) %} {% block page_search %}{{ search.searchModal(toolbarForm) }}{% endblock %} {% block main_before %} {{ tables.data_table_column_modal(tableName, columns) }} {% endblock %} {% block main %} {% if entries.count == 0 %} {{ widgets.nothing_found('kimai.timesheetUpdate') }} {% else %} {{ tables.datatable_header(tableName, columns, query, {'reload': 'kimai.timesheetUpdate kimai.timesheetDelete'}) }} {% set checkOverlappingDesc = false %} {% set checkOverlappingAsc = false %} {% if query.orderBy == 'begin' or query.orderBy == 'end' %} {% set checkOverlappingDesc = (query.order == 'DESC') %} {% set checkOverlappingAsc = not checkOverlappingDesc %} {% endif %} {% set day = null %} {% set dayDuration = 0 %} {% set dayRate = {} %} {% set lastEntry = null %} {% 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) -%} {{ _self.summary(day, dayDuration, dayRate, columns, canSeeRate, canSeeUsername, showStartEndTime, tableName, metaColumns) }} {% set day = entry.begin|date_short %} {% set dayDuration = 0 %} {% set dayRate = {} %} {%- endif -%} {% set class = '' %} {% if checkOverlappingDesc or checkOverlappingAsc %} {% if lastEntry is not null and entry.end is not null and entry.user is same as (lastEntry.user) %} {% if checkOverlappingDesc and entry.end.timestamp > lastEntry.begin.timestamp %} {% set class = class ~ ' overlapping' %} {% elseif checkOverlappingAsc and entry.begin.timestamp < lastEntry.end.timestamp %} {% set class = class ~ ' overlapping' %} {% endif %} {% endif %} {% endif %} {% if not entry.end %} {% set class = class ~ ' recording' %} {% endif %} {% if is_granted('edit', entry) or is_granted('delete', entry) %} {{ tables.datatable_multiupdate_row(entry.id) }} {% 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 or not is_granted('view_rate', entry) %} ‐ {% 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) }} {% if allowMarkdown %} {{ entry.description|desc2html }} {% else %} {{ entry.description|nl2br }} {% endif %} {{ widgets.tag_list(entry.tags) }} {% for field in metaColumns %} {{ tables.datatable_meta_column(entry, field) }} {% endfor %} {% if canSeeUsername %} {{ widgets.label_user(entry.user) }} {% endif %} {{ widgets.label_boolean(entry.billable) }} {{ widgets.label_boolean(entry.exported) }} {{ block('row_action') }} {%- 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 -%} {% set lastEntry = entry %} {% endfor %} {% if showSummary %} {{ _self.summary(day, dayDuration, dayRate, columns, canSeeRate, canSeeUsername, showStartEndTime, tableName, metaColumns) }} {% endif %} {{ tables.data_table_footer(entries, paginationRoute, multiUpdateForm) }} {% endif %} {% endblock %} {% macro summary(day, duration, dayRates, columns, canSeeRate, canSeeUsername, 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 %} {% if canSeeUsername %} {% endif %} {% endmacro %}