{#
 # ---------------------------------------------------------------------
 #
 # GLPI - Gestionnaire Libre de Parc Informatique
 #
 # http://glpi-project.org
 #
 # @copyright 2015-2026 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 <https://www.gnu.org/licenses/>.
 #
 # ---------------------------------------------------------------------
 #}

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

{% set no_header = no_header|default(not item.isNewItem() and not _get._in_modal|default(false)) %}
{% set bg = '' %}
{% if item.isDeleted() %}
   {% set bg = 'asset-deleted' %}
{% endif %}

<div class="asset {{ bg }}">
   {{ include('components/form/header.html.twig', {'in_twig': true}) }}

   {% set params  = params ?? [] %}
   {% set field_options = {
         'locked_fields': item.getLockedFields(),
   } %}

   <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">

                  {% set field_options = field_options|merge(params) %}

                  <input type="hidden" name="itemtype" value={{ asset.getType() }}>
                  <input type="hidden" name="items_id"value={{ asset.getID() }}>

                  {{ fields.htmlField(
                     asset.getType(),
                     asset.getLink(),
                     asset.getTypeName(1),
                     field_options
                  ) }}

                  {% set is_dynamic_value = call('Dropdown::getYesNo', [item.fields['is_dynamic']]) %}
                  {{ fields.field('is_dynamic', is_dynamic_value, __('Automatic Inventory')) }}

                  {{ fields.textField(
                     'name',
                     item.fields['name'],
                     __('Name'),
                     field_options
                  ) }}

                  {{ fields.textareaField(
                     'comment',
                     item.fields['comment'],
                     _n('Comment', 'Comments', get_plural_number()),
                     field_options
                  ) }}

                  {{ fields.dropdownField(
                     'VirtualMachineType',
                     'virtualmachinetypes_id',
                     item.fields['virtualmachinetypes_id'],
                     'VirtualMachineType'|itemtype_name,
                     field_options
                  ) }}

                  {{ fields.dropdownField(
                     'VirtualMachineSystem',
                     'virtualmachinesystems_id',
                     item.fields['virtualmachinesystems_id'],
                     'VirtualMachineSystem'|itemtype_name,
                     field_options
                  ) }}

                  {{ fields.dropdownField(
                     'VirtualMachineState',
                     'virtualmachinestates_id',
                     item.fields['virtualmachinestates_id'],
                     'VirtualMachineState'|itemtype_name,
                     field_options
                  ) }}

                  {{ fields.textField(
                     'uuid',
                     item.fields['uuid'],
                     __('UUID'),
                     field_options
                  ) }}

                  {{ fields.htmlField(
                     asset.getType(),
                     linked_asset,
                     __('Machine'),
                     field_options
                  ) }}

                  {{ fields.numberField(
                     'ram',
                     item.fields['ram'],
                     __('%1$s (%2$s)')|format(_n('Memory', 'Memories', 1), __('Mio')),
                     field_options|merge({'min': 0})
                  ) }}

                  {{ fields.numberField(
                     'vcpu',
                     item.fields['vcpu'],
                     _x('quantity', 'Processors number'),
                     field_options|merge({'min': 0})
                  ) }}

               </div> {# .row #}
            </div> {# .row #}
         </div> {# .flex-row #}
      </div> {# .flex-column #}
   </div> {# .flex-wrap #}

   {{ include('components/form/buttons.html.twig') }}
</div>
