{% extends "base.html.twig" %}

{% trans_default_domain 'dashboard' %}

{% block actionheader %}
{% endblock %}

{% block searchform_container %}

{% endblock %}

{% block dashboard %}

 
  
  {#   <font color="red">Aviso; El cambio del IVA al 15% se harÃ¡ de forma automÃ¡tica a partir del 1 de abril del 2024.</font> 
 <font color="green">Aviso, SRI Activo.</font> #}
     
    <div class="row">
        <div class="col-lg-6 col-xs-6">
            <div class="box pad">
                <div class="box-header">
                    <i class="fa fa-file-text-o"></i>
                    <h3 class="box-title">Documentos Electronicos</h3>
                    {#
                    <!-- tools box -->
                    <div class="pull-right box-tools">
                      <button type="button" class="btn btn-info btn-sm" data-widget="remove" data-toggle="tooltip" title="Remove">
                        <i class="fa fa-times"></i>
                      </button>
                    </div>
                    <!-- /. tools -->
                    #}
                </div>

                <div class="box-body">
                    <div class="row">
                        <div class="col-lg-6 col-xs-6">
                            <!-- small box -->
                            <div class="small-box bg-aqua">
                                <div class="inner">
                                    <h3>{{ emitidos }}</h3>
                                    <p>Emitidos</p>
                                </div>
                                <div class="icon">
                                    <i class="ion ion-bag"></i>
                                </div>
                                <a href="#" class="small-box-footer">Ver mas <i
                                            class="fa fa-arrow-circle-right"></i></a>
                            </div>
                        </div>
                        <!-- ./col -->
                        <div class="col-lg-6 col-xs-6">
                            <!-- small box -->
                            <div class="small-box bg-green">
                                <div class="inner">
                                    <h3>{{ recibidos }}</h3>
                                    <p>Recibidos</p>
                                </div>
                                <div class="icon">
                                    <i class="ion ion-stats-bars"></i>
                                </div>
                                <a href="{{ path('descarga_index') }}" class="small-box-footer">Ver mas <i
                                            class="fa fa-arrow-circle-right"></i></a>
                            </div>
                        </div>
                        <!-- ./col -->



                    </div>
                </div>

            </div>
        </div>

        <div class="col-lg-6 col-xs-6">
            <div class="box pad">
                <div class="box-header">
                    <i class="fa fa-file-text-o"></i>
                    <h3 class="box-title">Resumen</h3>
                    {#
                    <!-- tools box -->
                    <div class="pull-right box-tools">
                      <button type="button" class="btn btn-info btn-sm" data-widget="remove" data-toggle="tooltip" title="Remove">
                        <i class="fa fa-times"></i>
                      </button>
                    </div>
                    <!-- /. tools -->
                    #}

                </div>
                <div class="box-body">
                    <div class="row">
                        <div class="col-lg-12 col-xs-12">
                            <!-- small box -->
                            <div class="col-lg-12 col-xs-12">
                                <!-- small box -->

                                    <div id="dashboard-summary">
                                        <div class="box-body">
                                            <div class="row">
                                                <div class="col-lg-6 col-xs-6">
                                                    <table class="table table-bordered sw-table-horizontal payments">
                                                        <thead>
                                                        <tr>
                                                            <th colspan="2">Pagos</th>
                                                        </tr>
                                                        </thead>
                                                        <tbody>
                                                        <tr class="receipts">
                                                            <th>{% trans %}list.payments_received{% endtrans %}</th>
                                                            <td>{{ totals.paid|localizedcurrency(currency, app.request.locale) }}</td>
                                                        </tr>
                                                        <tr class="due">
                                                            <th>{% trans %}list.payments_due{% endtrans %}</th>
                                                            <td>{{ totals.due|localizedcurrency(currency, app.request.locale) }}</td>
                                                        </tr>
                                                        <tr class="overdue">
                                                            <th>{% trans %}list.payments_overdue{% endtrans %}</th>
                                                            <td>{{ totals.overdue|localizedcurrency(currency, app.request.locale) }}</td>
                                                        </tr>
                                                        </tbody>
                                                    </table>
                                                </div>

                                                <div class="col-lg-6 col-xs-6">
                                                    <table class="table table-bordered sw-table-horizontal balance">
                                                        <thead>
                                                        <tr>
                                                            <th colspan="2">{% trans %}list.balance{% endtrans %}</th>
                                                        </tr>
                                                        </thead>
                                                        <tbody>
                                                        <tr class="total">
                                                            <th>{% trans %}list.balance_total{% endtrans %}</th>
                                                            <td>{{ totals.gross|localizedcurrency(currency, app.request.locale) }}</td>
                                                        </tr>
                                                        <tr class="net">
                                                            <th>{% trans %}list.balance_net{% endtrans %}</th>
                                                            <td>{{ totals.net|localizedcurrency(currency, app.request.locale) }}</td>
                                                        </tr>
                                                        <tr class="taxes">
                                                            <th>{% trans %}list.balance_taxes{% endtrans %}</th>
                                                            <td>{{ totals.tax|localizedcurrency(currency, app.request.locale) }}</td>
                                                        </tr>
                                                        </tbody>
                                                    </table>

                                                </div>
                                                {#
                                                                    <div class="col-lg-4 col-xs-6">
                                                                        <table class="table table-bordered sw-table-horizontal taxes">
                                                                            <thead>
                                                                            <tr>
                                                                                <th colspan="2">{% trans %}list.taxes{% endtrans %}</th>
                                                                            </tr>
                                                                            </thead>
                                                                            <tbody>
                                                                            {% for tax in taxes %}
                                                                                <tr>
                                                                                    <th>{{ tax }}</th>
                                                                                    <td>{{ totals.taxes[tax.id]|localizedcurrency(currency, app.request.locale) }}</td>
                                                                                </tr>
                                                                            {% endfor %}
                                                                            </tbody>
                                                                        </table>
                                                                    </div>
                                                                    #}
                                            </div>
                                        </div>
                                    </div>

                            </div>
                            <!-- ./col -->

                        </div>
                        <!-- ./col -->

                    </div>
                </div>

            </div>
        </div>


    </div>


    <div class="modal fade" id="modal-default" style="display: none;">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">Ã—</span></button>
                    <h4 class="modal-title">Mensaje</h4>
                </div>

                <div class="modal-body">
                    {% if alerts is not null %}
                        {% for item in alerts %}
                            <div id="errormodal" class="alert alert-{{ item.prioridad }} alert-dismissible">
                                {{ item.mensaje|striptags('<p>')|raw }}
                            </div>
                        {% endfor %}

                    {% endif %}
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default pull-left" data-dismiss="modal">&nbsp;Cerrar
                    </button>
                </div>

            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>

{% endblock %}
{% block body %}

<div class="box pad">
    <div class="box-header">


        <div class="dashboard-listing">
            <h2>{% trans %}list.invoices_latest{% endtrans %}</h2>
            {% set table_selectable = false %}
            {% include "Invoice/list.html.twig" %}
        </div>

        {#
        <div class="dashboard-listing">
            <h2>{% trans %}list.invoices_due{% endtrans %}</h2>
            {% include "SiwappInvoiceBundle:Invoice:list.html.twig" with {'invoices': overdue_invoices} %}
        </div>
#}
    </div>
</div>
    <script>
        $(document).ready(function () {
            $body = $("body");

            {% if alerts is not null %}
                $('#modal-default').modal('show');
            {% endif %}


        });
    </script>


<!--  AQUI VA A APARECER LOS ANUNCIOS CARGADOS DESDE EL ADMIN  -->
{% if anuncio is defined and anuncio %}
<div id="popup-anuncio" class="popup-overlay">
    <div class="popup-content">

        {# Mostrar t¨ªtulo #}
        <h3 class="popup-titulo">{{ anuncio.titulo }}</h3>

        {# Mostrar imagen #}
        <img src="/anuncios/{{ anuncio.imagen }}" class="popup-img">

        {# Mostrar enlace clickeable #}
        {% if anuncio.enlace %}
        <p><a href="{{ anuncio.enlace }}" target="_blank" class="popup-link">Ir al enlace</a></p>
        {% endif %}

        <button id="cerrar-anuncio" class="btn-cerrar">Cerrar</button>
    </div>
</div>
{% endif %}


<style>
.popup-overlay{
    position:fixed;
    top:0;
    left:0;
    width:100%;
    height:100%;
    background:rgba(0,0,0,0.7);
    display:flex;
    justify-content:center;
    align-items:center;
    z-index:9999;
    overflow:auto;
}

.popup-content{
    background:white;
    padding:20px;
    border-radius:15px;
    max-width:400px;
    width:90%;
    text-align:center;
    box-shadow:0 0 20px rgba(0,0,0,0.4);
    position:relative;
}

.popup-titulo{
    font-size:1.3em;
    margin-bottom:10px;
    color:#d32f2f;
}

.popup-img{
    max-width:100%;
    max-height:50vh; /* Ajustamos la altura */
    object-fit:contain;
    border-radius:10px;
    margin-bottom:10px;
}

.popup-link{
    display:inline-block;
    margin-top:10px;
    color:#007bff;
    text-decoration:none;
    font-weight:bold;
}

.popup-link:hover{
    text-decoration:underline;
}

.btn-cerrar{
    margin-top:15px;
    background:#444;
    color:white;
    border:none;
    padding:10px 20px;
    border-radius:8px;
    cursor:pointer;
    z-index:10;
}

.btn-cerrar:hover{
    background:#222;
}
</style>


<script>

window.addEventListener("load", function(){

    if(localStorage.getItem("anuncio_visto") !== "si"){

        document.getElementById("popup-anuncio").style.display="flex";

    }

    document.getElementById("cerrar-anuncio").onclick=function(){

        document.getElementById("popup-anuncio").style.display="none";

        localStorage.setItem("anuncio_visto","si");

    }

});

</script>



{% endblock %}




