{% extends 'base.html' %}
{% load i18n static model_tags %}


{% block content_title %}<h3>{{ object.get_title }}</h3>{% endblock %}

{% block content %}
    <ul class="nav nav-tabs mb-3" id="myTab" role="tablist">
        <li class="nav-item" role="presentation">
            <button class="nav-link active" id="main-tab" data-bs-toggle="tab" data-bs-target="#main" type="button" role="tab" aria-controls="home" aria-selected="true">{% trans "Main" %}</button>
        </li>
        <li class="nav-item" role="presentation">
            <button class="nav-link" id="contact-tab" data-bs-toggle="tab" data-bs-target="#xml" type="button" role="tab" aria-controls="xml" aria-selected="false">{% trans "XML Content" %}</button>
        </li>   
    </ul>

    <div class="tab-content" id="myTabContent">
        <div class="tab-pane fade show active" id="main" role="tabpanel" aria-labelledby="main-tab">
            {% include 'odk/_xformsubmit_detail_main.html' %}
        </div>

        <div class="tab-pane fade" id="xml" role="tabpanel" aria-labelledby="contact-tab">
            <textarea name="xml_content" cols="100" rows="35" class="form-input" readonly="true">
                {{ object.xml_content }}
            </textarea>
        </div>
    </div>

    {% if user.is_authenticated %}
        {% if "delete" in request.path %}
            <br />
            <h4 class="text-danger">{{view.confirm_message}}</h4>
            <form action="" method="post">{% csrf_token %}
                <button type="submit" class="btn btn-primary m-1">{% trans 'Yes' %}</button>
                <a class="btn btn-secondary m-1" href="{% url 'odk:xformsubmit_detail' object.id %}">{% trans 'No/Cancel' %}</a>
            </form>
        {% else %}
            {% if not object.inserted_on %}
                <a class="btn btn-success" href="{% url 'odk:xformsubmit_load' object.id %}">{% trans 'Insert' %}</a>
            {% endif %}
            <a class="btn btn-primary" href="{% url 'odk:xformsubmit_del' object.id %}">{% trans 'Delete' %}</a>
        {% endif %}
        <a class="btn btn-secondary my-2" href="{% url 'odk:xformsubmit_list' %}">{% trans 'Back' %}</a>
        <p>{% blocktrans %}If you want to reload data, set 'inserted on' to null from admin interface or DB and 'Insert' again =>Update{% endblocktrans %}</p>
    {% endif %}
{% endblock content %}
