{% 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 actions = actions|merge({'download': {'url': path('admin_timesheet_export'), 'class': 'toolbar-action'}}) %} {% endif %} {% set actions = actions|merge({'visibility': '#modal_timesheet_admin'}) %} {% if is_granted('create_other_timesheet') %} {% set actions = actions|merge({'create': {'url': path('admin_timesheet_create'), 'class': '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) %} {% 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('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 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': 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 %}