{% extends "layout.html" %}
{% block title %}Mantenimiento de tipo de documento{% endblock %}

{% set nav_active = 'tablas' %}
{% block content %}

{% if message_error %}
<div class="alert alert-danger alert-dismissible" role="alert">
    {{message_error}}
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">&times;</span>
    </button>
</div>
{% endif %}
{% if message_success %}
<div class="alert alert-success alert-dismissible" role="alert">
    {{message_success}}
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">&times;</span>
    </button>
</div>
{% endif %}

<div class="box">
    <div class="box-header with-border">
        <h3 class="box-title">Tipo documento</h3>
        <div class="box-tools pull-right">
            <button class="btn btn-box-tool" data-widget="collapse">
                <i class="fa fa-minus"></i>
            </button>

            <button class="btn btn-box-tool" data-widget="remove">
                <i class="fa fa-times"></i>
            </button>
        </div>
    </div>
    <div class="box-body">
        <div class="row">
            <div class="col-md-12">

                <form class="form-inline" action="accion_tipodocumento.php" method="POST">
                    <div class="form-group mr-3">
                        <label for="tipo">Tipo</label>
                        <input type="text" class="form-control" id="tipo" name="tipo">
                    </div>
                    <button type="submit" class="btn btn-verdedark ml-3">Agregar</button>
                </form>

                <div class="table-responsive" style="margin-top:20px;">
                    <table class="table">
                        <thead>
                            <tr>
                                <th>Tipo</th>
                                <th>Accion</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for tipo_documento in tipo_documentos %}
                            <form action="accion_tipodocumento.php" method="post">
                                <tr>
                                    <td>
                                        <input class="form-control" type="text" name="editar_tipodocumento"
                                            value="{{tipo_documento.nombre}}">
                                        <input type="hidden" name="id_tipo" value="{{tipo_documento.id}}">
                                    </td>
                                    <td>
                                        <button class="btn btn-verdedark" type="submit">Editar</button>
                                            
                                        <button type="button" class="btn btn btn-warning" data-toggle="modal"
    										data-target="#myModal{{tipo_documento.id}}">
    										Eliminar
    									</button>
    
    									<!-- Modal -->
    									<div class="modal fade" id="myModal{{tipo_documento.id}}" tabindex="-1" role="dialog"
    										aria-labelledby="myModalLabel{{tipo_documento.id}}">
    										<div class="modal-dialog" role="document" style="max-width: 350px;">
    											<div class="modal-content">
    												<div class="modal-header" style="padding: 5px 15px">
    													<button type="button" class="close" data-dismiss="modal"
    														aria-label="Close"><span
    															aria-hidden="true">&times;</span></button>
    													<h4 class="modal-title" id="myModalLabel{{tipo_documento.id}}">Confirmaci&oacute;n</h4>
    												</div>
    												<div class="modal-body" style="font-size: 1.5rem;">
    													¿Estas seguro que deseas eliminar el documento <b>{{tipo_documento.nombre}}</b>?</b>
    												</div>
    												<div class="modal-footer" style="padding: 5px 15px">
    													<button type="button" class="btn btn-default"
    														data-dismiss="modal">No</button>
    													<a class="btn btn-warning" href="accion_tipodocumento.php?accion=delete&tipo={{tipo_documento.id}}">Eliminar</a>
    												</div>
    											</div>
    										</div>
    									</div>
    									<!--/. Modal -->
                                    </td>
                                </tr>
                            </form>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>

            </div>
        </div>
    </div>
</div>




{% endblock %}