{% import "backend/macros.html" as macros %}
{% extends "backend/custom/surround.html" %}

{% block content %}
    {% if not origin %}
        {% set origin = False %}
    {% endif %}
    {% set record = record %}

            {{ macros.getRecordButtons(classname,classid,current_user,record,editable,backlink)}}

            {% if editable %}
            <form method="post" enctype="multipart/form-data" id="form-record" class="main-object-form">
            <!-- Inputs ocultos -->
            <input type="hidden" id="csrf_token" name="csrf_token" value="{{ csrf_token() }}">

            {% endif %}
            <div class="bg-white shadow-sm rounded-3 p-4">
                <!-- Tabs superiores -->
                <ul class="nav nav-tabs mb-3" id="mainTab" role="tablist">
                    <li class="nav-item" role="presentation">
                        <button class="nav-link active" id="identificacion-tab" data-bs-toggle="tab"
                            data-bs-target="#identificacion" type="button" role="tab">IDENTIFICACIÓN</button>
                    </li>
                    <li class="nav-item" role="presentation">
                        <button class="nav-link" id="imagenes-tab" data-bs-toggle="tab" data-bs-target="#imagenes"
                            type="button" role="tab">IMÁGENES</button>
                    </li>
                    <li class="nav-item" role="presentation">
                        <button class="nav-link" id="documentos-tab" data-bs-toggle="tab" data-bs-target="#documentos"
                            type="button" role="tab">DOCUMENTOS</button>
                    </li>
                    <li class="nav-item" role="presentation">
                        <button class="nav-link" id="registro-tab" data-bs-toggle="tab" data-bs-target="#registro"
                            type="button" role="tab">REGISTRO Y CONTROL DE OBRA</button>
                    </li>
                </ul>
                <div class="tab-content" id="mainTabContent">
                    <!-- Tab IDENTIFICACIÓN -->
                    <div class="tab-pane fade show active" id="identificacion" role="tabpanel">
                        <!-- Tabs internos -->
                        <ul class="nav nav-pills mb-3" id="infoTab" role="tablist">
                            <li class="nav-item" role="presentation">
                                <button class="nav-link active" id="clave-tab" data-bs-toggle="pill"
                                    data-bs-target="#clave" type="button" role="tab">INFORMACIÓN CLAVE</button>
                            </li>
                            <li class="nav-item" role="presentation">
                                <button class="nav-link" id="descripcion-tab" data-bs-toggle="pill"
                                    data-bs-target="#descripcion" type="button" role="tab">DESCRIPCIÓN</button>
                            </li>
                            <li class="nav-item" role="presentation">
                                <button class="nav-link" id="medidas-tab" data-bs-toggle="pill"
                                    data-bs-target="#medidas" type="button" role="tab">MEDIDAS</button>
                            </li>
                            <li class="nav-item" role="presentation">
                                <button class="nav-link" id="contexto-tab" data-bs-toggle="pill"
                                    data-bs-target="#contexto" type="button" role="tab">CONTEXTO
                                    HISTÓRICO-CULTURAL</button>
                            </li>
                            <li class="nav-item" role="presentation">
                                <button class="nav-link" id="grupo-tab" data-bs-toggle="pill" data-bs-target="#grupo"
                                    type="button" role="tab">GRUPO / OBJETOS RELACIONADOS</button>
                            </li>
                            <li class="nav-item" role="presentation">
                                <button class="nav-link" id="creadores-tab" data-bs-toggle="pill"
                                    data-bs-target="#creadores" type="button" role="tab">CREADORES / AUTORES</button>
                            </li>
                            <li class="nav-item" role="presentation">
                                <button class="nav-link" id="exposiciones-tab" data-bs-toggle="pill"
                                    data-bs-target="#exposiciones" type="button" role="tab">HISTORIAL DE EXPOSICIONES
                                    (1)</button>
                            </li>
                        </ul>
                        <div class="tab-content" id="infoTabContent">
                            <!-- Información Clave -->
                            <div class="tab-pane fade show active" id="clave" role="tabpanel">
                                <!-- Aquí va el contenido de Información Clave y Clasificación -->
                                <div class="card mb-4">
                                    <div class="card-header bg-light fw-semibold">
                                        Información Clave
                                    </div>
                                    <div class="card-body">
                                        <div class="row g-4">
                                            <div class="col-md-2">
                                                {{ macros.fieldForm(fields["featuredImage"],record,editable, origin,label=" ")}}
                                            </div>
                                            <div class="col-md-10">
                                            {{ macros.fieldForm(fields["creator"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["coAuthors"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["title"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["suggestedTitle"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["creationDate"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["creationDateText"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["dateEra"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["accessionNumber"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["additionalAccessionNumber"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["rfid"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["collection"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["theme"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["lastLocation"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["numObjects"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["allMeasurements"],record,editable, origin)}}
                                            
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- Clasificación -->
                                <div class="card">
                                    <div class="card-header bg-light fw-semibold d-flex justify-content-between align-items-center">
                                        Clasificación
                                    </div>
                                    <div class="card-body">
                                        <div class="row g-3">
                                            <div class="col-md-6">
                                                {{ macros.fieldForm(fields["categoryList"],record,editable, origin)}}
                                                {{ macros.fieldForm(fields["objectTypeList"],record,editable, origin)}}
                                                {{ macros.fieldForm(fields["methodsTechniquesList"],record,editable, origin)}}
                                                {{ macros.fieldForm(fields["materialsList"],record,editable, origin)}}
                                                
                                            </div>
                                            <div class="col-md-6">
                                                {{ macros.fieldForm(fields["category"],record,editable, origin)}}
                                                {{ macros.fieldForm(fields["objectType"],record,editable, origin)}}
                                                {{ macros.fieldForm(fields["methodsTechniques"],record,editable, origin)}}
                                                {{ macros.fieldForm(fields["material"],record,editable, origin)}}
                                                {{ macros.fieldForm(fields["support"],record,editable, origin)}}
                                            
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane fade" id="descripcion" role="tabpanel">
                                <div class="mt-4">
                                    <div class="card">
                                        <div class="card-header">
                                            Descripción
                                        </div>
                                        <div class="card-body">
                                            {{ macros.fieldForm(fields["description"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["signature"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["signatureLocation"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["distinctiveFeatures"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["inscriptions"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["observations"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["process"],record,editable, origin)}}
                                            
                                        </div>
                                    </div>
                                    <div class="card">
                                        <div class="card-header">
                                            Descripción iconográfica
                                            
                                        </div>
                                        <div class="card-body">
                                            {{ macros.fieldForm(fields["iconographicDescription"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["tags"],record,editable, origin)}}
                                            
                                        </div>
                                    </div>
                                    <div class="card">
                                        <div class="card-header">
                                            Fuentes de Referencias
                                            
                                        </div>
                                        <div class="card-body">
                                            
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane fade" id="medidas" role="tabpanel">
                                <div aria-labelledby="headingOne" class="accordion-collapse collapse show"
                                    data-bs-parent="#medidasAccordion" id="collapseOne">
                                    <div class="accordion-body">
                                        {% if record %}
                                        {% set origin = 'object:' ~ record.id ~ ':' ~ classid %}
                                        {% set fieldsMeasurements = ["item",
                                                                    "withFrame",
                                                                    "units",
                                                                    "exactApprox",
                                                                    "height",
                                                                    "width",
                                                                    "depth",
                                                                    "circumference",
                                                                    "diameter",
                                                                    "length",
                                                                    "weight",
                                                                    "weightUnit"
                                                                    ]%}
                                        {{ macros.getConnectedTable(record, 6,fields=fieldsMeasurements,origin=origin)}}
                                        {%else%}
                                        <p>Debe guardar primero el objeto para poder añadir medidas.</p>
                                        {% endif %}
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane fade" id="contexto" role="tabpanel">
                                <div class="card mb-4">
                                    <div class="card-header bg-light d-flex justify-content-between align-items-center">
                                        Contexto
                                    </div>
                                    <div class="card-body">
                                        {{ macros.fieldForm(fields["periods"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["specify"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["creationDate"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["creationDateText"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["approximateDate"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["noDate"],record,editable, origin)}}
                                            
                                        <hr class="my-4" />
                                        {{ macros.fieldForm(fields["culture"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["cultureSpecify"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["useFunction"],record,editable, origin)}}
                                        
                                            
                                    </div>
                                </div>
                                <div class="card mb-4">
                                    <div class="card-header bg-light d-flex justify-content-between align-items-center">
                                        Lugar de Origen
                                        <button class="btn btn-sm" type="button">
                                            <i class="material-icons">expand_less</i>
                                        </button>
                                    </div>
                                    <div class="card-body">
                                        {{ macros.fieldForm(fields["unknownOrigin"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["countryOrigin"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["stateProvince"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["locality"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["specificPlace"],record,editable, origin)}}
                                            
                                    </div>
                                </div>
                                <div class="card">
                                    <div class="card-header bg-light">
                                        Contexto Histórico
                                    </div>
                                    <div class="card-body">
                                        {{ macros.fieldForm(fields["thesaurusPeriod"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["contextObservations"],record,editable, origin)}}
                                            
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane fade" id="grupo" role="tabpanel">
                                <div class="card">
                                    <div class="card-header">
                                        Pertenencia a un grupo
                                    </div>
                                    <div class="card-body">
                                        {{ macros.fieldForm(fields["groupType"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["groupName"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["numComponents"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["partOf"],record,editable, origin)}}
                                    </div>
                                </div>
                                <div class="card">
                                    <div class="card-header">
                                        Objetos Relacionados
                                    </div>
                                    <div class="card-body">
                                        
                                    </div>
                                </div>
                                <div class="card">
                                    <div aria-controls="objetosQueContiene" aria-expanded="true" class="card-header"
                                        data-bs-toggle="collapse" href="#objetosQueContiene" role="button">
                                        <span>Objetos que contiene</span>
                                        <span class="material-icons text-muted">expand_less</span>
                                    </div>
                                    <div class="collapse show" id="objetosQueContiene">
                                        <div class="card-body">
                                            <div class="d-flex justify-content-end mb-3">
                                            </div>
                                            <div class="table-responsive">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane fade" id="creadores" role="tabpanel">
                                <div class="card mb-4">
                                    <div aria-controls="creatorAuthorSection" aria-expanded="true"
                                        class="card-header bg-secondary-subtle d-flex justify-content-between align-items-center"
                                        data-bs-toggle="collapse" href="#creatorAuthorSection" role="button">
                                        Creador / Autor Principal
                                        <span class="material-icons text-muted">expand_less</span>
                                    </div>
                                    <div class="collapse show" id="creatorAuthorSection">
                                        <div class="card-body">
                                            {{ macros.fieldForm(fields["principalAuthorRole"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["anonymous"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["unknownAuthor"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["attributedToCreator"],record,editable, origin)}}
                                            
                                        </div>
                                    </div>
                                </div>
                                <div class="card">
                                    <div aria-controls="otherAuthorsSection" aria-expanded="true"
                                        class="card-header bg-secondary-subtle d-flex justify-content-between align-items-center"
                                        data-bs-toggle="collapse" href="#otherAuthorsSection" role="button">
                                        Otros Autores
                                        <span class="material-icons text-muted">expand_less</span>
                                    </div>
                                    <div class="collapse show" id="otherAuthorsSection">
                                        <div class="card-body">
                                         {% if record %}
                                        {% set origin = 'object:' ~ record.id ~ ':' ~ classid %}
                                        {% set fieldsMeasurements = ["creator",
                                                        "role",
                                                        "observation"]%}
                                        {{ macros.getConnectedTable(record, 15,fields=fieldsMeasurements,origin=origin)}}
                                        {%else%}
                                        <p>Debe guardar primero el objeto para poder añadir autores adicionales.</p>
                                        {% endif %}
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane fade" id="exposiciones" role="tabpanel">
                                <div class="card mb-4">
                                    <div aria-controls="creatorAuthorSection" aria-expanded="true"
                                        class="card-header bg-secondary-subtle d-flex justify-content-between align-items-center"
                                        data-bs-toggle="collapse" href="#creatorAuthorSection" role="button">
                                        Grupos / Exposiciones
                                        <span class="material-icons text-muted">expand_less</span>
                                    </div>
                                    <div class="collapse show" id="creatorAuthorSection">
                                        <div class="card-body">
                                            {{ macros.fieldForm(fields["objectGroup"],record,editable, origin)}}
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- Otros tabs superiores -->
                    <div class="tab-pane fade" id="imagenes" role="tabpanel">
                        <div class="card shadow-sm">
                            <div class="card-body">
                                <div class="d-flex align-items-center mb-4">
                                    IMÁGENES RELACIONADAS
                                </div>
                                <div class="d-flex justify-content-end mb-3">
                                    <button class="btn btn-outline-secondary btn-sm me-2" type="button"><span
                                        class="material-icons align-middle">filter_alt</span></button>
                                        <button class="btn btn-outline-secondary btn-sm" type="button"><span
                                            class="material-icons align-middle">settings</span></button>
                                </div>
                                <div class="">
                                        {% if record %}
                                        {% set origin = 'object:' ~ record.id ~ ':' ~ classid %}
                                        {{ macros.getConnectedTable(record, 7, False,origin=origin) }}
                                        {%else%}
                                        <p>Debe guardar primero el objeto para poder añadir imágenes.</p>
                                        {% endif %}
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="tab-pane fade" id="documentos" role="tabpanel">
                        <div class="card">
                            <div class="card-header bg-light d-flex justify-content-between align-items-center">
                                Documentos Relacionados
                                <button aria-label="Cerrar" class="btn btn-sm btn-close"></button>
                            </div>
                            <div class="card-body">
                                {% if record %}
                                {% set origin = 'object:' ~ record.id ~ ':' ~ classid %}
                                {{ macros.getConnectedTable(record, 16, False,origin=origin) }}
                                {%else%}
                                    <p>Debe guardar primero el objeto para poder añadir documentos.</p>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                    <div class="tab-pane fade" id="registro" role="tabpanel">
                        <ul class="nav nav-pills mb-3 small justify-content-start" id="myTab" role="tablist"
                            style="gap: 0.25rem;">
                            <li class="nav-item" role="presentation">
                                <button aria-controls="localizacion" aria-selected="true"
                                    class="nav-link active px-3 py-1" data-bs-target="#localizacion"
                                    data-bs-toggle="tab" id="localizacion-tab" role="tab" type="button">LOCALIZACIÓN /
                                    MOVIMIENTOS (2)</button>
                            </li>
                            <li class="nav-item" role="presentation">
                                <button aria-controls="conservacion" aria-selected="false" class="nav-link px-3 py-1"
                                    data-bs-target="#conservacion" data-bs-toggle="tab" id="conservacion-tab" role="tab"
                                    type="button">CONSERVACIÓN</button>
                            </li>
                            <li class="nav-item" role="presentation">
                                <button aria-controls="bitacora" aria-selected="false" class="nav-link px-3 py-1"
                                    data-bs-target="#bitacora" data-bs-toggle="tab" id="bitacora-tab" role="tab"
                                    type="button">BITÁCORA / ANOTACIONES</button>
                            </li>
                            <li class="nav-item" role="presentation">
                                <button aria-controls="adquisicion" aria-selected="false" class="nav-link px-3 py-1"
                                    data-bs-target="#adquisicion" data-bs-toggle="tab" id="adquisicion-tab" role="tab"
                                    type="button">ADQUISICIÓN Y DESADECSIÓN</button>
                            </li>
                            <li class="nav-item" role="presentation">
                                <button aria-controls="valor" aria-selected="false" class="nav-link px-3 py-1"
                                    data-bs-target="#valor" data-bs-toggle="tab" id="valor-tab" role="tab"
                                    type="button">VALOR / SEGURO</button>
                            </li>
                        </ul>
                        <div class="tab-content" id="myTabContent">
                            <div aria-labelledby="localizacion-tab" class="tab-pane fade show active"
                                id="localizacion" role="tabpanel">
                                {{ macros.fieldForm(fields["gpsLocation"],record,editable, origin)}}
                                {{ macros.fieldForm(fields["lastLocation"],record,editable, origin)}}
                                {% if record %}
                                {% set origin = 'object:' ~ record.id ~ ':' ~ classid %}
                                {{ macros.getConnectedTable(record, 19, False,origin=origin) }}
                                {%else%}
                                    <p>Debe guardar primero el objeto para poder añadir historial de localización.</p>
                                {% endif %}
                            </div>
                            <div aria-labelledby="conservacion-tab" class="tab-pane fade" id="conservacion" role="tabpanel">
                                <div class="card mb-4">
                                    <div class="card-header d-flex justify-content-between align-items-center">
                                        Conservación
                                        
                                    </div>
                                    <div class="card-body">
                                        {{ macros.fieldForm(fields["conservationState"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["conservationStateSpecify"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["temperatureSpecifications"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["humidityVulnerable"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["humiditySpecifications"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["lightVulnerable"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["lightSpecifications"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["conservationRecommendations"],record,editable, origin)}}
                                            
                                    </div>
                                </div>
                                <div class="card mb-4">
                                    <div class="card-header d-flex justify-content-between align-items-center">
                                        Alteración / Deterioro
                                        
                                    </div>
                                    <div class="card-body">
                                        {{ macros.fieldForm(fields["ornamentalAlteration"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["ornamentalDeterioration"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["structuralAlteration"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["structuralDeterioration"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["otherDeterioration"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["conservationInformation"],record,editable, origin)}}
                                            
                                    </div>
                                </div>
                                <div class="card">
                                    <div class="card-header d-flex justify-content-between align-items-center">
                                        Intervenciones
                                        <div>
                                            <span class="material-icons align-middle ms-2">expand_less</span>
                                        </div>
                                    </div>
                                    <div class="card-body">
                                        {% if record %}
                                        {% set origin = 'object:' ~ record.id ~ ':' ~ classid %}
                                        {{ macros.getConnectedTable(record, 17, False,origin=origin) }}
                                        {%else%}
                                        <p>Debe guardar primero el objeto para poder añadir intervenciones.</p>
                                        {% endif %}
                                            
                                    </div>
                                </div>
                            </div>
                            <div aria-labelledby="bitacora-tab" class="tab-pane fade" id="bitacora" role="tabpanel">
                                <div class="card mb-4">
                                    <div class="card-header d-flex justify-content-between align-items-center">
                                        Bitácora
                                    </div>
                                    <div class="card-body p-4">
                                        {% if record %}
                                        {% set origin = 'object:' ~ record.id ~ ':' ~ classid %}
                                        {{ macros.getConnectedTable(record, 20, False,origin=origin) }}
                                        {%else%}
                                        <p>Debe guardar primero el objeto para poder añadir entradas en la bitácora.</p>
                                        {% endif %}
                                    </div>
                                </div>
                                <div class="card">
                                    <div class="card-header d-flex justify-content-between align-items-center">
                                        Historia
                                        <span class="material-icons cursor-pointer">expand_less</span>
                                    </div>
                                    <div class="card-body p-4">
                                        {% if record %}
                                        {% set origin = 'object:' ~ record.id ~ ':' ~ classid %}
                                        {{ macros.getConnectedTable(record, 20, False,origin=origin) }}
                                        {% endif %}
                                        <div class="row">
                                            <div class="col-md-6">
                                                {{ macros.fieldForm("createdby",record,editable, origin)}}
                                                {{ macros.fieldForm("modifiedby",record,editable, origin)}}
                                            </div>
                                            <div class="col-md-6">
                                                {{ macros.fieldForm("creationDate",record,editable, origin)}}
                                                {{ macros.fieldForm("modificationDate",record,editable, origin)}}
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div aria-labelledby="adquisicion-tab" class="tab-pane fade" id="adquisicion" role="tabpanel">
                                <div class="card mb-4">
                                    <div class="card-header d-flex justify-content-between align-items-center">
                                        Adquisición y Desaccesión
                                        
                                    </div>
                                    <div class="card-body">
                                        {{ macros.fieldForm(fields["entryMethod"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["acquisitionDate"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["acquisitionHistory"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["provenance"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["acquisitionCountry"],record,editable, origin)}}
                                        
                                    </div>
                                </div>
                                <div class="card mb-4">
                                    <div class="card-header">
                                        Información de Desaccesión
                                    </div>
                                    <div class="card-body">
                                        {{ macros.fieldForm(fields["deaccessionDate"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["deaccessionMethod"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["deaccessionObservations"],record,editable, origin)}}
                                    </div>
                                </div>
                                <div class="card">
                                    <div class="card-header d-flex justify-content-between align-items-center">
                                        Documentos Relacionados
                                        
                                    </div>
                                    <div class="card-body">
                                        <div class="table-responsive">
                                        {% if record %}
                                        {% set origin = 'object:' ~ record.id ~ ':' ~ classid %}
                                        {{ macros.getConnectedTable(record, 16, False,origin=origin) }}
                                        {%else%}
                                        <p>Debe guardar primero el objeto para poder añadir documentos relacionados.</p>
                                        {% endif %}
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div aria-labelledby="valor-tab" class="tab-pane fade" id="valor" role="tabpanel">
                                <div class="card mb-4">
                                    <div class="card-header d-flex justify-content-between align-items-center bg-secondary-subtle">
                                        Valor / Seguro
                                        
                                    </div>
                                    <div class="card-body">
                                        {% if current_user.is_authenticated and current_user.usergroup.id == 1 %}
                                        {{ macros.fieldForm(fields["currency"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["purchasePrice"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["estimatedValue"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["salePrice"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["appraisalDate"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["appraiser"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["appraisalNotes"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["insuranceValue"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["insurerName"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["policyNumber"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["insuranceDateExpiration"],record,editable, origin)}}
                                        
                                        {% endif %}
                                    </div>
                                </div>
                                <div class="card mb-4">
                                    <div class="card-header d-flex justify-content-between align-items-center bg-secondary-subtle">
                                        Datos Administrativos
                                        
                                    </div>
                                    <div class="card-body">
                                        {% if current_user.is_authenticated and current_user.usergroup.id == 1 %}
                                        {{ macros.fieldForm(fields["costAdmin"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["costUSDAdmin"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["annualTDC_admin"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["originAdmin"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["valueUSDAdmin"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["insuranceResponsible"],record,editable, origin)}}
                                        {{ macros.fieldForm(fields["insuranceAmountAdmin"],record,editable, origin)}}
                                        {% endif %}
                                    </div>
                                </div>
                                <div class="card">
                                    <div class="card-header d-flex justify-content-between align-items-center bg-secondary-subtle">
                                        Documentos Relacionados
                                        
                                    </div>
                                    <div class="card-body">
                                        {% if record %}
                                        {% set origin = 'object:' ~ record.id ~ ':' ~ classid %}
                                        {{ macros.getConnectedTable(record, 16, False,origin=origin) }}
                                        {%else%}
                                            <p>Debe guardar primero el objeto para poder añadir documentos.</p>
                                        {% endif %}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            {{ macros.fieldForm(fields["qtySD"],record,editable, origin)}}
            {{ macros.fieldForm(fields["qtyHD"],record,editable, origin)}}
            {{ macros.fieldForm(fields["qtyImage"],record,editable, origin)}}
            {%if editable %}
            </form>
            {% endif %}
{% endblock %}