
{% extends 'admin.html.twig' %}

{% block preloader %}{% endblock %}

{% block title %}Ordenes de Compra{% endblock %}

{% block body %}

    <div class="container pb-5">

        <h2 class="my-4 text-primary">
            Ordenes de Compra
        </h2>

    <div class="row mt-4 mb-5">

        <div class="col-md-12">
            
        </div>

        <div class="col-md-12">
            <div class="table-responsive">
                <table class="table table-striped table-bordered">
                    <thead class="thead-dark">
                        <tr class="text-center">
                            <th scope="col">Nro</th>
                            <th scope="col">Usuario</th>
                            <th scope="col">Servicio</th>
                            <th scope="col">Duracion</th>
                            <th scope="col">Costo</th>
                            <th scope="col">Fecha</th>
                            <th scope="col">Estatus</th>
                            <th scope="col">Opciones</th>
                        </tr>
                    </thead>

                    <tbody>

                        {% if ordenes %}
                            {% for orden in ordenes %}
                                <tr>
                                    {% set ordenH = orden.ordenHosting|first %}
                                    {% set ordenD = orden.ordenDominio|first %}

                                    <th class="text-center align-middle">{{ orden.correlativo }}</th>
                                    <td class="align-middle">
                                        <div>
                                            <strong>{{ orden.usuario.username }}</strong>
                                        </div>
                                    </td>
                                    <td class="align-middle">
                                        <div>
                                            {% if ordenH.planDestino is defined %}
                                                Hosting: <strong>{{ ordenH.planDestino.nombre }}</strong>
                                            {% endif %}
                                        </div>
                                        <div>
                                            {% if ordenD.nombre is defined %}
                                                Dominio: <strong>{{ ordenD.nombre }}.{{ ordenD.extension.nombre }}</strong>
                                            {% endif %}
                                        </div>
                                    </td>
                                    <td class="text-center">
                                        <div>
                                            {% if ordenH.planDestino is defined %}
                                                {{ ordenH.duracion }} Año(s)
                                            {% endif %}
                                        </div>
                                        <div>
                                            {% if ordenD.duracion is defined %}
                                                {{ ordenD.duracion }} Año(s)
                                            {% endif %}
                                        </div>
                                    </td>
                                    <td class="text-center">
                                        <div>
                                            {% if ordenH.planDestino is defined %}
                                                <span class="text-primary">${{ ordenH.costo|number_format }}<span>
                                            {% endif %}
                                        </div>
                                        <div>
                                            {% if ordenD.costo is defined %}
                                                <span class="text-primary">${{ ordenD.costo|number_format }}<span>
                                            {% endif %}
                                        </div>
                                    </td>

                                    <td class="text-center align-middle">
                                        <div>
                                            {{ orden.createdAt|date("d-m-Y g:ia") }}
                                        </div>
                                    </td>

                                    <td class="text-center align-middle estatus-orden-{{ orden.id }}">
                                        {% include 'all/orden/_estatus.html.twig' with {'estatus':orden.estatus} %} 
                                    </td>

    <td class="text-center align-middle">

        {% if orden.estatus == constant('ESTATUS_PENDIENTE', orden) or orden.estatus == constant('ESTATUS_PAGADA', orden) %}
            <a class="not-decoration text-dark" href="{{ path('orden_procesar_admin', {'id': orden.id}) }}" title="Procesar">
                <i class="fas fa-arrow-circle-right fa-lg"></i>
            </a>
        {% endif %}

        <a class="not-decoration text-dark" href="{{ path('orden_ver_admin', {'id': orden.id}) }}" title="Ver">
            <i class="fas fa-eye fa-lg"></i>
        </a>

    </td>


                                </tr>
                            {% endfor %}
                        {% else %}
                            <tr>
                                <th colspan="15" class="text-center">No existen ordenes de Compras</th>
                            </tr>
                        {% endif %}

                    </tbody>
                </table>
            </div>

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

{% endblock %}

