{# # --------------------------------------------------------------------- # # GLPI - Gestionnaire Libre de Parc Informatique # # http://glpi-project.org # # @copyright 2015-2025 Teclib' and contributors. # @licence https://www.gnu.org/licenses/gpl-3.0.html # # --------------------------------------------------------------------- # # LICENSE # # This file is part of GLPI. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # --------------------------------------------------------------------- #} {% import 'components/alerts_macros.html.twig' as alerts %} {% set datatable_id = datatable_id|default('datatable' ~ random()) %} {% set filters = filters|default([]) %} {% set additional_params = additional_params|default('') %} {% set sort = sort|default(null) %} {% set nosort = nosort|default(false) %} {% set order = order|default('ASC') %} {% set csv_url = csv_url|default('') %} {% set footers = footers|default([]) %} {% set showmassiveactions = showmassiveactions|default(false) %} {% set use_pager = use_pager|default(start is defined and limit is defined and filtered_number is defined) %} {# nopager is deprecated, use "use_pager" instead #} {% set use_pager = nopager is defined ? not nopager : use_pager %} {% if total_number < 1 and filters|length == 0 %} {% if super_header is defined and super_header is not empty %} {% set super_header_label = super_header is array ? super_header['label'] : super_header %} {% if super_header_label is not empty %} {% set super_header_raw = super_header is array ? (super_header['is_raw'] ?? false) : false %} {% endif %} {% endif %}
{{ super_header_raw ? super_header_label|raw : super_header_label }}
{{ __('No results found') }}
{% else %} {% set total_cols = columns|length + (showmassiveactions ? 1 : 0) + ((nofilter ?? false) ? 0 : 1) %} {% if use_pager %} {{ include('components/pager.html.twig', { 'count': filtered_number, 'additional_params': additional_params ~ '&sort=' ~ sort ~ '&order=' ~ order }) }} {% endif %}
{% if showmassiveactions %}
{% do call('Html::showMassiveActions', [{action_button_classes: 'btn btn-sm btn-outline-secondary me-2'}|merge(massiveactionparams|default({}))]) %}
{% endif %} {% if super_header is defined and super_header is not empty %} {% set super_header_label = super_header is array ? super_header['label'] : super_header %} {% set super_header_raw = super_header is array ? (super_header['is_raw'] ?? false) : false %} {% if super_header_raw is not same as 'th_elements' %}{% endif %} {% endif %} {% if no_header is not defined or no_header == false %} {% if showmassiveactions %} {% endif %} {% for colkey, column in columns %} {% set column_label = column is array ? column['label'] : column %} {% set raw_header = column is array ? column['raw_header']|default(false) : false %} {% set sort_icon = '' %} {% set new_order = "DESC" %} {% if sort == colkey %} {% set sort_icon = order == 'ASC' ? 'ti ti-sort-ascending' : (order == 'DESC' ? 'ti ti-sort-descending' : '') %} {% set new_order = (order == 'ASC' ? 'DESC' : 'ASC') %} {% endif %} {% set sort_href = "javascript:reloadTab('sort=" ~ colkey ~ "&order=" ~ new_order ~ "&" ~ additional_params ~ "');" %} {% endfor %} {% if nofilter is not defined or csv_url|length %} {% endif %} {% endif %} {% if filters|length > 0 %} {% if showmassiveactions %} {% endif %} {% for colkey, colum in columns %} {% set formatter = colum['filter_formatter']|default(formatters[colkey]|default(''))|default('') %} {% endfor %} {% endif %} {% if entries|length > 0 %} {% for entry in entries %} {% set row_massiveactions = entry['showmassiveactions']|default(showmassiveactions) %} {% if row_massiveactions %} {% endif %} {% for colkey, colum in columns %} {% if colkey in entry|keys %} {% set colspan = entry[colkey ~ '_colspan']|default(1) %} {% set aria_label = entry[colkey ~ '_aria_label']|default('') %} {% endif %} {% endfor %} {% if not (nofilter ?? false) %} {% endif %} {% endfor %} {% else %} {% endif %} {% if footers %} {% for footer in footers %} {% if showmassiveactions %} {% endif %} {% for footer_col, footerval in footer %} {% endfor %} {% if nofilter is not defined %} {% endif %} {% endfor %} {% endif %}
{% endif %} {{ super_header_raw ? super_header_label|raw : super_header_label }} {% if super_header_raw is not same as 'th_elements' %}
{% if not nosort and not (column is array and column['nosort'] is defined) %} {% endif %} {{ raw_header ? column_label|raw : column_label }} {% if not nosort and not (column is array and column['nosort'] is defined) %} {% endif %} {% if nofilter is not defined %} {% endif %} {% if csv_url|length %} {{ __('Export') }} {% endif %}
{% if colum is not array or colum['no_filter']|default(false) == false %} {% if formatter == "array" and columns_values[colkey] is defined %} {% elseif formatter == "datetime" %} {{ call("Html::showDateTimeField", [ "filters[" ~ colkey ~ "]", { 'value': filters[colkey] ?? '', 'display': false } ])|raw }} {% elseif formatter == "date" %} {{ call("Html::showDateField", [ "filters[" ~ colkey ~ "]", { 'value': filters[colkey] ?? '', 'display': false } ])|raw }} {% elseif formatter starts with "progress" %} {% elseif formatter == 'avatar' %} {# Cannot be filtered #} {% elseif formatter == 'yesno' %} {% else %} {% endif %} {% endif %}
{% if entry['skip_ma'] is not defined or entry['skip_ma'] == false %} {% endif %} {% set formatter = formatters[colkey] ?? '' %} {% if formatter == "maintext" %} {{ entry[colkey] }} {% elseif formatter == "longtext" %} {{ entry[colkey] }} {% elseif formatter starts with "progress" %} {{ progress_bar(entry[colkey]) }} {% elseif formatter == "date" %} {{ entry[colkey]|formatted_date }} {% elseif formatter == "datetime" %} {{ entry[colkey]|formatted_datetime }} {% elseif formatter == "duration" %} {{ entry[colkey]|formatted_duration }} {% elseif formatter == "bytesize" %} {{ call("Toolbox::getSize", [entry[colkey]])|raw }} {% elseif formatter == 'number' %} {{ entry[colkey]|formatted_number }} {% elseif formatter == 'integer' %} {{ entry[colkey]|formatted_integer }} {% elseif formatter == "raw_html" %} {{ entry[colkey]|raw }} {% elseif formatter == 'avatar' %} {# Note: Does not support anonymization currently #} {% set entry_data = entry[colkey] %} {% set avatar_size = entry_data['avatar_size'] ?? 'avatar-md' %} {% set img = entry_data['picture'] %} {% set initials = entry_data['initials'] %} {% set bg_color = img is not empty ? 'inherit' : entry_data['initials_bg'] %} {% if img is empty %} {{ initials }} {% endif %} {% elseif formatter == "badge" and entry[colkey] is not empty %} {% set entry_data = entry[colkey] %} {% set content = entry_data['content'] %} {% set color = entry_data['color'] ?? '#BBBBBB' %} {% if not (color matches '/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/') %} {% set color = '#BBBBBB' %} {% endif %} {% if content is not empty %}
{{ content }}
{% endif %} {% elseif formatter == 'yesno' %} {% if entry[colkey] == 1 %}
{% else %}
{% endif %} {% else %} {{ entry[colkey] }} {% endif %}
{{ alerts.alert_info(__('No results found')) }}
{{ footerval|nl2br }}
{% if use_pager %}
{{ __('Entries to show:') }} {% include 'components/dropdown/limit.html.twig' %}
{% endif %} {% endif %}