{% macro timesheets_team(view) %} {% import "macros/widgets.html.twig" as widgets %} {% set actions = {'search': {'class': 'search-toggle visible-xs-inline'}} %} {% if is_granted('export_own_timesheet') %} {% set exporterIds = timesheet_exporter() %} {% if exporterIds|length == 1 %} {% set actions = actions|merge({'download': {'url': path('admin_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('admin_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_timesheet_admin'}) %} {% if is_granted('create_other_timesheet') %} {% set actions = actions|merge({'create': {'children': {'single': {'title': 'create'|trans,'url': path('admin_timesheet_create'), 'class': 'create-ts modal-ajax-form'}, 'multi-user': {'title': 'create-timesheet-multiuser'|trans({}, 'actions'),'url': path('admin_timesheet_create_multiuser'), 'class': 'create-ts-mu modal-ajax-form'}}}}) %} {% endif %} {% set actions = actions|merge({'help': {'url': 'timesheet.html'|docu_link, 'target': '_blank'}}) %} {% set event = trigger('actions.timesheets_team', {'actions': actions, 'view': view}) %} {{ widgets.page_actions(event.payload.actions) }} {% endmacro %} {% macro timesheet_team(timesheet, view, options) %} {% import "macros/widgets.html.twig" as widgets %} {% set actions = {} %} {% if timesheet.id is not empty %} {% if not timesheet.end and is_granted('stop', timesheet) %} {% set actions = actions|merge({'stop': {'url': path('stop_timesheet', {'id' : timesheet.id}), 'class': 'api-link', 'attr': {'data-event': 'kimai.timesheetStop kimai.timesheetUpdate', 'data-method': 'PATCH', 'data-msg-error': 'timesheet.stop.error', 'data-msg-success': 'timesheet.stop.success'}}}) %} {% endif %} {% if timesheet.end and is_granted('start', timesheet) %} {% set actions = actions|merge({'repeat': {'url': path('restart_timesheet', {'id' : timesheet.id}), 'class': 'api-link', 'attr': {'data-payload': '{"copy": "all"}', 'data-event': 'kimai.timesheetStart kimai.timesheetUpdate', 'data-method': 'PATCH', 'data-msg-error': 'timesheet.start.error', 'data-msg-success': 'timesheet.start.success'}}}) %} {% endif %} {% if is_granted('duplicate', timesheet) %} {% set actions = actions|merge({'copy': {'url': path('duplicate_timesheet', {'id' : timesheet.id}), 'class': 'api-link', 'attr': {'data-payload': '{"copy": "all"}', 'data-event': 'kimai.timesheetStart kimai.timesheetUpdate', 'data-method': 'PATCH', 'data-msg-error': 'action.update.error', 'data-msg-success': 'action.update.success'}}}) %} {% endif %} {% if is_granted('edit', timesheet) %} {% set class = '' %} {% if view != 'edit' %} {% set class = 'modal-ajax-form' %} {% endif %} {% set actions = actions|merge({'edit': {'url': path('admin_timesheet_edit', {'id': timesheet.id}), 'class': class}}) %} {% endif %} {% if actions|length > 0 %} {% set actions = actions|merge({'divider': null}) %} {% endif %} {% if view == 'index' and is_granted('delete', timesheet) %} {% set actions = actions|merge({'trash': {'url': path('delete_timesheet', {'id' : timesheet.id}), 'class': 'api-link', 'attr': {'data-event': 'kimai.timesheetDelete kimai.timesheetUpdate', 'data-method': 'DELETE', 'data-question': 'confirm.delete', 'data-msg-error': 'action.delete.error', 'data-msg-success': 'action.delete.success'}}}) %} {% endif %} {% endif %} {% if view != 'index' %} {% set actions = actions|merge({'back': options.back|default(path('admin_timesheet'))}) %} {% endif %} {% set event = trigger('actions.timesheet_team', {'actions': actions, 'view': view, 'timesheet': timesheet}) %} {% if view == 'index' %} {{ widgets.table_actions(event.payload.actions) }} {% else %} {{ widgets.entity_actions(event.payload.actions) }} {% endif %} {% endmacro %} {% macro timesheets_team_multi_update(view) %} {% import "macros/widgets.html.twig" as widgets %} {% set actions = {} %} {% set actions = actions|merge({'back': path('admin_timesheet')}) %} {% set actions = actions|merge({'help': {'url': 'timesheet.html'|docu_link, 'target': '_blank'}}) %} {% set event = trigger('actions.timesheets_team_multi_update', {'actions': actions, 'view': view}) %} {{ widgets.page_actions(event.payload.actions) }} {% endmacro %}