{%- macro search_filter(route, options) -%} {% set opts = {'performSearch': 1} %} {% if options.begin is defined and options.end is defined %} {% set opts = opts|merge({'daterange': (options.begin|report_date ~ ' - ' ~ options.end|report_date)}) %} {% endif %} {% if options.customer is defined %} {% set opts = opts|merge({'customers[]': options.customer}) %} {% endif %} {% if options.project is defined %} {% set opts = opts|merge({'projects[]': options.project}) %} {% endif %} {% if options.activity is defined %} {% set opts = opts|merge({'activities[]': options.activity}) %} {% endif %} {% if options.user is defined %} {% set opts = opts|merge({'users[]': options.user}) %} {% endif %} {% if options.preview is defined %} {% set opts = opts|merge({'preview': options.preview}) %} {% endif %} {{- path(route, opts) -}} {% endmacro %} {%- macro page_actions(actions) -%} {% set btnClasses = 'btn-primary' %} {% set helpClasses = '' %} {% if tabler_bundle.isNavbarOverlapping() %} {% set helpClasses = 'btn-dark' %} {% elseif not tabler_bundle.isDarkMode() %} {% set btnClasses = 'btn-white' %} {% endif %} {% set later = {} %} {% set help = null %}
{{ _self.actions(actions, {large: true, button_class: btnClasses}) }} {% if help is not null %} {% set help = help|merge({class: helpClasses ~ ' action-help ' ~ (help.class|default(''))}) %} {{ _self.action_button('help', help) }} {% endif %}
{% set btnClass = 'btn btn-icon ' %} {% if tabler_bundle.isNavbarOverlapping() %} {% set btnClass = 'btn btn-icon btn-dark' %} {% elseif not tabler_bundle.isDarkMode() %} {% set btnClass = 'btn btn-icon btn-white' %} {% endif %} {{ _self.table_actions(actions, btnClass) }}
{%- endmacro -%} {%- macro actions(actions, options) -%} {% set large = options.large ?? true %} {% set btnClasses = options.button_class ?? 'btn-primary' %} {%- for icon, values in actions %} {% if 'help' in icon %} {% set help = values %} {% elseif 'divider' in icon and values is null %} {# what to do here ? #} {% else %} {% if values.children is defined and values.children|length > 0 %} {% else %} {% set values = values|merge({combined: large, class: btnClasses ~ ' action-' ~ icon ~ ' ' ~ (values.class|default(''))}) %} {{ _self.action_button(icon, values) }} {% endif %} {% endif %} {% endfor -%} {%- endmacro -%} {% macro page_header(title) %} {% endmacro %} {% macro label_boolean(visible) %} {% if visible %} {{ _self.label('yes'|trans, 'success') }} {% else %} {{ _self.label('no'|trans, 'default') }} {% endif %} {% endmacro %} {% macro label_visible(visible) %} {{ _self.label_boolean(visible) }} {% endmacro %} {% macro label_role(role) %} {% set color = 'primary' %} {% if role == 'ROLE_SUPER_ADMIN' %} {% set color = 'danger' %} {% elseif role == 'ROLE_ADMIN' %} {% set color = 'warning' %} {% elseif role == 'ROLE_TEAMLEAD' %} {% set color = 'success' %} {% elseif role == 'ROLE_USER' %} {% set color = 'gray' %} {% endif %} {{ _self.label(role|trans, color) }} {% endmacro %} {% macro username(user) %} {{- user.displayName -}} {% endmacro %} {% macro label_user(user) %} {{ _self.label_color(user.displayName, user.color|colorize(user.displayName)) }} {% endmacro %} {% macro label_team(team) %} {{ _self.label_color(team.name, team.color|colorize(team.name)) }} {% endmacro %} {% macro user_avatar(user, tooltip, class, badge) %} {% set avatar = null %} {% if user.avatar is not empty and kimai_config.themeAllowAvatarUrls %} {% set avatar = asset(user.avatar, 'avatars') %} {% endif %} {% if not user.enabled %} {% set badge = 'danger' %} {% endif %} {% set color = user.color|colorize(user.displayName) %}   {% else %} style="background-color: {{ color }}; color: {{ color|font_contrast }}">{{ user.initials }} {% endif %} {%- if badge is not null -%}{%-endif -%} {% endmacro %} {% macro avatar(initials, color, tooltip, class) %} {% set color = color|colorize(initials) %} {{ initials }} {% endmacro %} {% macro avatar_deleted(tooltip) %} {% set initials = tooltip ?? '??' %} {% set tooltip = 'deleted'|trans %} {% set color = null|colorize(initials) %} {{ initials }} {% endmacro %} {# options = {'inherit': true} #} {% macro label_activity(activity, options) %} {% set inherit = options.inherit ?? true %} {% set isVisible = activity.visible %} {% set color = activity.color %} {% if color is empty and inherit and activity.project is not null %} {% set color = activity.project.color ?? activity.project.customer.color %} {% endif %} {% if color is empty %} {% set color = color|colorize(activity.name) %} {% endif %} {% if isVisible and not activity.project is null %} {% set isVisible = activity.project.visible %} {% if isVisible and not activity.project.customer is null %} {% set isVisible = activity.project.customer.visible %} {% endif %} {% endif %} {{ _self.label_color_dot('activity', isVisible, activity.name, null, color) }} {% endmacro %} {# options = {'inherit': true} #} {% macro label_project(project, options) %} {% set inherit = options.inherit ?? true %} {% set isVisible = false %} {% if project.visible and project.customer.visible %} {% set isVisible = true %} {% endif %} {% set color = project.color %} {% if color is empty and inherit %} {% set color = project.customer.color %} {% endif %} {% if color is empty %} {% set color = color|colorize(project.name) %} {% endif %} {{ _self.label_color_dot('project', isVisible, project.name, null, color) }} {% endmacro %} {% macro label_customer(customer) %} {% set color = customer.color %} {% if color is empty %} {% set color = color|colorize(customer.name) %} {% endif %} {{ _self.label_color_dot('customer', customer.visible, customer.name, null, color) }} {% endmacro %} {# Use for list views and the main column (if the entity has something like a name) #} {% macro label_name(label, color, isVisible) %} {{ _self.label_color_dot('color', isVisible, label, null, color) }} {% endmacro %} {# Use in datatables to show linked entity names #} {% macro label_dot(label, color, isVisible) %} {{ _self.label_color_dot('color', isVisible, label, null, color|colorize(label)) }} {% endmacro %} {# for @internal use only #} {% macro label_color_dot(type, isVisible, name, url, color) %} {%- if url is not empty -%}{% endif %} {{- name -}} {%- if url is not empty -%}{% endif %} {% endmacro %} {% macro badge_team_access(teams) %} {% if teams|length > 0 %} {{ _self.badge_counter(teams|length) }} {% else %} {{ _self.badge_counter(0, null, 'bg-gray') }} {% endif %} {% endmacro %} {% macro badge_counter(count, url, type) %} {% if url %} {{ count }} {% else %} {{ count }} {% endif %} {% endmacro %} {% macro label(title, type, tooltip) %} {{ title }} {% endmacro %} {% macro label_color(title, color) %} {{ title }} {% endmacro %} {% macro badge(title, color) %} {{ title }} {% endmacro %} {% macro form_errors(form) %} {% if form.vars.errors|length > 0 %} {% set message = '' %} {% for error in form.vars.errors %} {% set message = message ~ error.message %} {% if not loop.last %} {% set message = message ~ '
' %} {% endif %} {% endfor %} {% if message != '' %} {{ _self.alert('danger', message) }} {% endif %} {% endif %} {% endmacro %} {% macro alert(type, description, title, icon, dismissible) %} {% from '@theme/components/alert.html.twig' import alert %} {{ alert({type: type, description: description|trans, title: title|trans, icon: icon, dismissible: dismissible, important: true}) }} {% endmacro %} {% macro callout(type, description, title, icon) %} {% from '@theme/components/alert.html.twig' import alert %} {{ alert({type: type|default('danger'), description: description|trans, title: title|trans, icon: icon, dismissible: false, important: true}) }} {% endmacro %} {% macro table_actions(actions, class) %} {% if actions|length >= 1 %} {% import '@theme/components/actions.html.twig' as macro %} {{ macro.actions(actions, {'class': class|default('btn-sm'), translationDomain: 'actions'}) }} {% endif %} {% endmacro %} {% macro card_tool_visibility(tableName) %} {{ _self.card_tool_button('visibility', {'modal': ('#modal_' ~ tableName)}) }} {% endmacro %} {% macro card_tool_button(icon, values) %} {% import '@theme/components/buttons.html.twig' as macro %} {% set values = values|merge({'tooltip_attr': 'data-toggle'}) %} {{ macro.action_cardtoolbutton(icon, values) }} {% endmacro %} {% macro card_tool_create(create_url) %} {{ _self.card_tool_button('create', {'url': create_url, 'class': 'modal-ajax-form open-edit', 'title': 'create'|trans}) }} {% endmacro %} {% macro action_button(icon, values, type) %} {% import '@theme/components/button.html.twig' as macro %} {% set values = (values ?? {})|merge({'tooltip_attr': 'data-toggle'}) %} {{ macro.button(icon, values, type) }} {% endmacro %} {% macro tag_list(taglist) %} {% for tag in taglist %} {{ _self.badge(tag.name, tag.color|colorize(tag.name)) }} {% endfor %} {% endmacro %} {% macro meta_field_value(entity, field) %} {% set metaField = entity.metaField(field.name) %} {% if not metaField is null %} {% set metaField = metaField.merge(field) %} {{ _self.form_type_value(metaField.type, metaField.value, entity) }} {% endif %} {% endmacro %} {% macro form_type_value(type, value, entity) %} {% if 'ColorPickerType' in type or 'ColorChoiceType' in type %} {% if value is not empty %} {% endif %} {% elseif 'DurationType' in type %} {{ value|duration }} {% elseif 'YesNoType' in type or 'CheckBoxType' in type %} {{ _self.label_boolean(value) }} {% elseif 'DatePickerType' in type %} {{ value|date_short }} {% elseif 'DateTimePickerType' in type %} {{ value|date_time }} {% elseif 'CountryType' in type %} {{ value|country_name }} {% elseif 'CurrencyType' in type %} {{ value|currency_name }} {% elseif 'LanguageType' in type %} {{ value|locale_name }} {% elseif 'TagsType' in type %} {% for tag in value|split(',') %} {% if tag is not empty %} {{ _self.badge(tag, null|colorize(tag)) }} {% endif %} {% endfor %} {% elseif 'MoneyType' in type %} {% set classname = class_name(entity) %} {% if entity is null %} {{ value }} {% elseif classname == 'App\\Entity\\Timesheet' %} {{ value|money(entity.project.customer.currency) }} {% elseif classname == 'App\\Entity\\Customer' %} {{ value|money(entity.currency) }} {% elseif classname == 'App\\Entity\\Project' %} {{ value|money(entity.customer.currency) }} {% elseif classname == 'App\\Entity\\Activity' and entity.project is not null %} {{ value|money(entity.project.customer.currency) }} {% else %} {{ value }} {% endif %} {% elseif 'TextareaType' in type %} {{ value|nl2br }} {% elseif 'EmailType' in type %} {{ value }} {% elseif 'UrlType' in type %} {{ value }} {% else %} {{ value }} {% endif %} {% endmacro %} {% macro team_list(teams, options) %} {% set showTitle = options['title'] ?? true %} {% set collapseAt = options['collapse'] ?? 12 %} {% set nameClass = options['name_class'] ?? '' %} {% set viewTeam = is_granted('view_team') %} {% if showTitle %} {% endif %} {% for team in teams|sort((a, b) => a.name <=> b.name) %} {% set members = team.members|filter(m => m.user.enabled) %} {% set class = 'avatar-rounded' %} {% endfor %}
{{ 'team'|trans }} {{ 'team.member'|trans({}, 'teams') }}
{{ _self.label_color_dot('color', true, team.name, null, team.color|colorize(team.name)) }} {% for member in members|sort((a, b) => b.teamlead <=> a.teamlead) %} {% set user = member.user %} {% if member.teamlead %} {{ _self.user_avatar(user, ('teamlead'|trans ~ ': ' ~ user.displayName), (class ~ ' teamlead'), 'info') }} {% else %} {{ _self.user_avatar(user, null, class) }} {% endif %} {% endfor %}
{% endmacro %} {% macro nothing_found(events) %} {{ _self.callout('warning', 'error.no_entries_found') }} {% if events is not empty %} {% endif %} {% endmacro %} {# To be used like this: #} {% macro class_customer_row(customer, now) %} {%- if not customer.visible %}bg-orange-lt{% endif -%} {% endmacro %} {# To be used like this: #} {% macro class_tag_row(tag) %} {%- if not tag.visible %}bg-orange-lt{% endif -%} {% endmacro %} {# To be used like this: #} {% macro customer_row_attr(customer, now) %} {%- set class = _self.class_customer_row(customer, now) %} {% set dataHref = '' %} {% if is_granted('view', customer) %} {% set class = class ~ ' alternative-link open-edit' %} {% set dataHref = path('customer_details', {'id': customer.id}) %} {% endif -%} class="{{ class }}" data-href="{{ dataHref }}" {% endmacro %} {# To be used like this: #} {% macro class_project_row(project, now) %} {%- if not project.visible or (project.end is not null and project.end < now) %}bg-orange-lt{% endif -%} {% endmacro %} {# To be used like this: #} {% macro project_row_attr(project, now) %} {%- set class = _self.class_project_row(project, now) %} {% set dataHref = '' %} {% if is_granted('view', project) %} {% set class = class ~ ' alternative-link open-edit' %} {% set dataHref = path('project_details', {'id': project.id}) %} {% endif -%} class="{{ class }}" data-href="{{ dataHref }}" {% endmacro %} {# To be used like this: #} {% macro class_activity_row(activity, now) %} {%- if not activity.visible %}bg-orange-lt{% endif -%} {% endmacro %} {# To be used like this: #} {% macro activity_row_attr(activity, now) %} {%- set class = _self.class_activity_row(activity, now) %} {% set dataHref = '' %} {% if is_granted('view', activity) %} {% set class = class ~ ' alternative-link open-edit' %} {% set dataHref = path('activity_details', {'id': activity.id}) %} {% endif -%} class="{{ class }}" data-href="{{ dataHref }}" {% endmacro %} {# To be used like this: #} {% macro class_user_row(user) %} {%- if not user.enabled %}bg-orange-lt{% endif -%} {% endmacro %} {# To be used like this: #} {% macro user_row_attr(user) %} {%- set class = _self.class_user_row(user) %} {% set dataHref = '' %} {% if is_granted('view', user) %} {% set class = class ~ ' alternative-link open-edit' %} {% set dataHref = path('user_profile', {'username': user.username}) %} {% endif -%} class="{{ class }}" data-href="{{ dataHref }}" {% endmacro %} {# To be used mainly in #} {% macro short_stats_row(stats) %}
{% set colLength = 12 / stats|length %} {% for title, value in stats %}
{{ value }}
{{ title }}
{% endfor %}
{% endmacro %} {% macro percent(maximum, current) %} {% if maximum > 0 %} {{ (current / (maximum / 100))|number_format(2) }} % {% else %} {{ 0|number_format(2) }} % {% endif %} {% endmacro %} {% macro page_reloader(events, full_reload) %} {% endmacro %} {% macro work_times_result(should, actual, decimal) %} {% set result = actual - should %} {% if result == 0 %} {{ result|duration(decimal) }} {% elseif should == 0 and actual > 0 %} +{{ actual|duration(decimal) }} {% elseif result < 0 %} {{ result|duration(decimal) }} {% else %} +{{ result|duration(decimal) }} {% endif %} {% endmacro %}