Sindbad~EG File Manager

Current Path : /home/escuelai/public_html/it/marketplace/fields/templates/
Upload File :
Current File : /home/escuelai/public_html/it/marketplace/fields/templates/fields.html.twig

{#
 # -------------------------------------------------------------------------
 # Fields plugin for GLPI
 # -------------------------------------------------------------------------
 #
 # LICENSE
 #
 # This file is part of Fields.
 #
 # Fields 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 2 of the License, or
 # (at your option) any later version.
 #
 # Fields 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 Fields. If not, see <http://www.gnu.org/licenses/>.
 # -------------------------------------------------------------------------
 # @copyright Copyright (C) 2013-2022 by Fields plugin team.
 # @license   GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
 # @link      https://github.com/pluginsGLPI/fields
 # -------------------------------------------------------------------------
 #}

{% import 'components/form/fields_macros.html.twig' as macros %}

{% set already_wrapped = item is instanceof('CommonITILObject') and container.fields['type'] == 'dom' %}

{% if not already_wrapped %}
    <div class="card-body d-flex flex-wrap">
        <div class="col-12 col-xxl-12 flex-column">
            <div class="d-flex flex-row flex-wrap flex-xl-nowrap">
                <div class="row flex-row align-items-start flex-grow-1">
                    <div class="row flex-row">
{% endif %}

{% for field in fields %}

    {% set type     = field['type'] %}
    {% set name     = field['name'] %}
    {% set label    = field['label'] %}
    {% set value    = item.input[name] ?: field['value'] %}
    {% set readonly = field['is_readonly'] %}
    {% set rand = random() %}

    {% set field_options = {
        'readonly':   readonly or not canedit,
        'required':   field['mandatory'],
        'full_width': already_wrapped
    } %}

    {% if type == 'header' %}
        {{ macros.largeTitle(label) }}

    {% elseif type == 'text' %}
        {{ macros.textField(name, value, label, field_options) }}

    {% elseif type == 'number' %}
        {{ macros.numberField(name, value, label, field_options|merge({step: 'any', min: ''})) }}

    {% elseif type == 'url' %}
            {% set ext_link %}
            {% if value|length %}
                <a target="_blank" href="{{ value }}">
                    <i class="ti ti-external-link"></i>
                    {{ __('show', 'fields') }}
                </a>
            {% endif %}
            {% endset %}
            {{ macros.textField(name, value, label, field_options|merge({
                'type': 'url',
                'add_field_html': ext_link
            })) }}
    {% elseif type == 'textarea' %}
        {{ macros.textareaField(name, value, label, field_options) }}

    {% elseif type == 'yesno' %}
        {{ macros.dropdownYesNo(name, value, label, field_options) }}

    {% elseif type == 'date' %}
        {{ macros.dateField(name, value, label, field_options) }}

    {% elseif type == 'datetime' %}
        {{ macros.datetimeField(name, value, label, field_options) }}

    {% elseif type == 'dropdown' %}
        {% if "dropdowns_id" in name %}
            {% set dropdown_itemtype = call("getItemtypeForForeignKeyField", [name]) %}
        {% else %}
            {% set dropdown_itemtype = call("PluginFieldsDropdown::getClassname", [name]) %}
        {% endif %}
        {% set name_fk = call("getForeignKeyFieldForItemType", [dropdown_itemtype]) %}
        {{ macros.dropdownField(dropdown_itemtype, name_fk, value, label, field_options|merge({
            'entity': item.getEntityID(),
        })) }}

    {% elseif type matches '/^dropdown-.+/i' %}
        {% if not massiveaction %}
            {% set dropdown_options = {'condition': field['dropdown_condition'], 'entity': item.getEntityID()} %}
            {% if field['dropdown_class'] == 'User' %}
                {% set dropdown_options = dropdown_options|merge({'entity': -1, 'right': 'all'}) %}
            {% elseif field['dropdown_class'] == 'Entity' %}
                {% set dropdown_options = dropdown_options|merge({'entity_sons': true}) %}
            {% endif %}
            {{ macros.dropdownField(field['dropdown_class'], name, value, label, field_options|merge(dropdown_options)) }}
        {% endif %}

    {% elseif type == 'glpi_item' %}
        {% if not massiveaction %}
            {% set itemtype_prefix = 'itemtype_' %}
            {% set items_id_prefix = 'items_id_' %}

            <div class='form-field row col-12 col-sm-6  mb-2'>
                {{ macros.dropdownArrayField(itemtype_prefix ~ name, value.itemtype, field['allowed_values'], label, field_options|merge({
                    'rand': rand,
                    'display_emptychoice': true,
                })) }}

                {% do call('Ajax::updateItemOnSelectEvent',
                    [
                        'dropdown_' ~ itemtype_prefix ~ name ~ rand,
                        'results_items_id' ~ (rand),
                        config('root_doc') ~ '/ajax/dropdownAllItems.php',
                        {
                            'idtable'             : '__VALUE__',
                            'name'                : items_id_prefix ~ name,
                            'entity_restrict'     : item.getEntityID(),
                            'dom_name'            : items_id_prefix ~ name,
                            'display_emptychoice' : false,
                            'action'              : 'get_items_from_itemtype',
                            'dom_rand'            : rand,
                        }
                ]) %}

                <span id='results_items_id{{rand}}' class='form-field row col-12 col-sm-6  mb-2'>
                    {% if value.itemtype != '' %}
                        {{ macros.dropdownField(value.itemtype, items_id_prefix ~ name, value.items_id, label, field_options|merge({
                            'entity': value.itemtype == 'User' ? -1 : item.getEntityID(),
                            'rand': rand,
                            'right': 'all',
                            'display_emptychoice' : false,
                            'no_label': true
                        })) }}
                    {% endif %}
                </span>
            {% endif %}
        </div>
    {% endif %}
{% endfor %}

{% if not already_wrapped %}
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endif %}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists