{% 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">
            <!-- 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">
                <div class="card">
                    <div class="card-header">
                        Tipo de Autor 
                    </div>
                    <div class="card-body">
                        {{ macros.fieldForm(fields["type"],record,editable, origin)}}
                        {{ macros.fieldForm(fields["fullname"],record,editable, origin)}}
                    </div>
                </div>
                <!-- 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="informacion-tab" data-bs-toggle="tab"
                            data-bs-target="#informacion" type="button" role="tab">INFORMACIÓN GENERAL</button>
                    </li>
                    <li class="nav-item" role="presentation">
                        <button class="nav-link" id="adicional-tab" data-bs-toggle="tab" data-bs-target="#adicional"
                            type="button" role="tab">INFORMACIÓN ADICIONAL</button>
                    </li>
                    <li class="nav-item" role="presentation">
                        <button class="nav-link" id="objetos-tab" data-bs-toggle="tab" data-bs-target="#objetos"
                            type="button" role="tab">OBJETOS RELACIONADOS</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="derechos-tab" data-bs-toggle="tab" data-bs-target="#derechos"
                            type="button" role="tab">DERECHOS DE REPRODUCCIÓN</button>
                    </li>
                </ul>
                <div class="tab-content" id="mainTabContent">
                    <!-- Tab IDENTIFICACIÓN -->
                    <div class="tab-pane fade show active" id="informacion" role="tabpanel">
                        <div class="mt-4">
                            <div class="card">
                                <div class="card-header">
                                    Información Clave de Creador / Autor
                                </div>
                                <div class="card-body">
                                    {{ macros.fieldForm(fields["firstname"],record,editable, origin)}}
                                    {{ macros.fieldForm(fields["lastname"],record,editable, origin)}}
                                    {{ macros.fieldForm(fields["country"],record,editable, origin)}}
                                    {{ macros.fieldForm(fields["mainPicture"],record,editable, origin)}}
                                    {{ macros.fieldForm(fields["authorCode"],record,editable, origin)}}
                                    {{ macros.fieldForm(fields["tags"],record,editable, origin)}}                                              
                                </div>
                            </div>
                            <!-- 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="persona-tab" data-bs-toggle="pill"
                                        data-bs-target="#persona" type="button" role="tab">PERSONA FÍSICA</button>
                                </li>
                                <li class="nav-item" role="presentation">
                                    <button class="nav-link" id="colectivo-tab" data-bs-toggle="pill"
                                        data-bs-target="#colectivo" type="button" role="tab">COLECTIVO</button>
                                </li>
                            </ul>
                            <div class="tab-content" id="infoTabContent">
                                <!-- Información Clave -->
                                <div class="tab-pane fade show active" id="persona" role="tabpanel">
                                    <!-- Aquí va el contenido de Información Clave y Clasificación -->
                                    <div class="card mb-4">
                                        <div class="card-header">
                                        Nacimiento y Deceso
                                        </div>
                                        <div class="card-body">
                                            {{ macros.fieldForm(fields["alias"],record,editable, origin)}}   
                                            {{ macros.fieldForm(fields["gender"],record,editable, origin)}}   
                                            {{ macros.fieldForm(fields["bornYear"],record,editable, origin)}}   
                                            {{ macros.fieldForm(fields["placeBirth"],record,editable, origin)}}   
                                            {{ macros.fieldForm(fields["deceased"],record,editable, origin)}}   
                                            {{ macros.fieldForm(fields["placeDeceased"],record,editable, origin)}}   
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane fade" id="colectivo" role="tabpanel">
                                    <div class="card mb-4">
                                        <div class="card-header">
                                        Fundación / Disolución
                                        </div>
                                        <div class="card-body">
                                            {{ macros.fieldForm(fields["collectiveName"],record,editable, origin)}}
                                            {{ macros.fieldForm(fields["bornYear"],record,editable, origin,label="Fecha de Creación / Fundación")}}
                                            {{ macros.fieldForm(fields["placeBirth"],record,editable, origin,label="Lugar de Creación / Fundación")}}
                                            {{ macros.fieldForm(fields["deceased"],record,editable, origin,label="Fecha de Disolución")}}
                                            {{ macros.fieldForm(fields["placeDeceased"],record,editable, origin,label="Lugar de Disolución")}}
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="card mb-4">
                                <div class="card-header">
                                Nombres alternativos
                                </div>
                                <div class="card-body">

                                </div>
                            </div>
                            <div class="card mb-4">
                                <div class="card-header">
                                Efemérides
                                </div>
                                <div class="card-body">

                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- Otros tabs superiores -->
                    <div class="tab-pane fade" id="adicional" role="tabpanel">
                        {{ macros.fieldForm(fields["disciple"],record,editable, origin)}}   
                        {{ macros.fieldForm(fields["apprenticeOf"],record,editable, origin)}}   
                        {{ macros.fieldForm(fields["atelier"],record,editable, origin)}}   
                        {{ macros.fieldForm(fields["workshop"],record,editable, origin)}}   
                        {{ macros.fieldForm(fields["biography"],record,editable, origin)}}   
                        {{ macros.fieldForm(fields["observation"],record,editable, origin,label="Más información")}}   
                    </div>
                    <div class="tab-pane fade" id="objetos" role="tabpanel">
                        {% if record %}
                        {% set fieldsObj = ["id","featuredImage","title","suggestedTitle"] %}
                        {% set origin = 'creator:' ~ record.id ~ ':' ~ classid %}
                        {{ macros.getConnectedTable(record, 1, fieldsObj,origin=origin) }}
                        {% endif %}
                    </div>
                    <div class="tab-pane fade" id="documentos" role="tabpanel">
                        {% if record %}
                        {% set origin = 'creator:' ~ record.id ~ ':' ~ classid %}
                        {{ macros.getConnectedTable(record, 27, False,origin=origin) }}
                        {% endif %}
                    </div>
                    <div class="tab-pane fade" id="derechos" role="tabpanel">
                        {% if record %}
                        {% set origin = 'creator:' ~ record.id ~ ':' ~ classid %}
                        {{ macros.getConnectedTable(record, 24, False,origin=origin) }}
                        {% endif %}
                    </div>
                </div>
            </div>
            {%if editable %}
            </form>
            {% endif %}
{% endblock %}