{% 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 %} {% macro summary(day, duration, dayRates, columns) %} {{ day }} {{ duration|duration }} {% if is_granted('view_rate_own_timesheet') %} {% for currency, rate in dayRates %} {{ rate|money(currency) }} {% if not loop.last %}
{% endif %} {% endfor %} {% else %} {% endif %} {% endmacro %} {% block page_title %}{{ 'timesheet.title'|trans }}{% endblock %} {% block page_subtitle %}{{ 'timesheet.subtitle'|trans }}{% endblock %} {% block page_actions %} {% set actions = {'filter': '#collapseTimesheet'} %} {% if is_granted('export_own_timesheet') %} {% set actions = actions|merge({'download': 'onclick:return exportTimesheet()'}) %} {% endif %} {% set actions = actions|merge({'visibility': '#modal_timesheet'}) %} {% set actions = actions|merge({'calendar': path('calendar')}) %} {% if is_granted('create_own_timesheet') %} {% set actions = actions|merge({'create': path('timesheet_create')}) %} {% endif %} {{ widgets.page_actions(actions) }} {% endblock %} {% block main_before %} {{ toolbar.toolbar(toolbarForm, 'collapseTimesheet', showFilter) }} {% endblock %} {% block main %} {% import _self as timesheet %} {% if entries.count == 0 %} {{ widgets.callout('warning', 'error.no_entries_found') }} {% else %} {% set columns = {'date': ''} %} {% if not duration_only %} {% set columns = columns|merge({'starttime': '', 'endtime': 'hidden-xs'}) %} {% endif %} {% set columns = columns|merge({'duration': ''}) %} {% if is_granted('view_rate_own_timesheet') %} {% set columns = columns|merge({'rate': 'hidden-xs'}) %} {% endif %} {% set columns = columns|merge({ 'customer': 'hidden-xs hidden-sm', 'project': 'hidden-xs hidden-sm', 'activity': 'hidden-xs hidden-sm', 'description': 'hidden-xs hidden-sm', 'actions': 'alwaysVisible', }) %} {% set tableName = 'timesheet' %} {{ tables.data_table_header(tableName, columns, showSummary) }} {% 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) }} {% set day = entry.begin|date_short %} {% set dayDuration = 0 %} {% set dayRate = {} %} {% endif %} {{ entry.begin|date_short }} {% if not duration_only %} {{ entry.begin|time }} {% endif %} {% if entry.end %} {% if not duration_only %} {{ entry.end|time }} {% endif %} {{ entry.duration|duration }} {% if is_granted('view_rate', entry) %} {{ entry.rate|money(entry.project.customer.currency) }} {% endif %} {% else %} {% if not duration_only %} ‐ {% endif %} {{ entry|duration }} {% if is_granted('view_rate', entry) %} ‐ {% endif %} {% endif %} {{ widgets.label_customer(entry.project.customer) }} {{ widgets.label_project(entry.project) }} {{ widgets.label_activity(entry.activity) }} {{ entry.description|desc2html }} {% set actionButtons = {} %} {% if is_granted('edit', entry) %} {% set actionButtons = actionButtons|merge({'edit': path('timesheet_edit', {'id' : entry.id, 'page': page})}) %} {% endif %} {% if entry.end %} {% if is_granted('start', entry) %} {% set actionButtons = {'repeat': path('timesheet_start', {'id' : entry.id})}|merge(actionButtons) %} {% endif %} {% else %} {% if is_granted('stop', entry) %} {% set actionButtons = {'stop': path('timesheet_stop', {'id' : entry.id})}|merge(actionButtons) %} {% endif %} {% endif %} {% if is_granted('delete', entry) %} {% set actionButtons = actionButtons|merge({'trash': path('timesheet_delete', {'id' : entry.id, 'page': page})}) %} {% endif %} {{ widgets.button_group(actionButtons) }} {% 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) }} {% endif %} {{ tables.data_table_footer(entries, 'timesheet_paginated') }} {% endif %} {% endblock %} {% block javascripts %} {{ parent() }} {% endblock %}