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

{% trans_default_domain 'core' %}

{#
{% block invoice_label %}

    <ul id="invoice-like-status" class="list-unstyled">
        <li>
            <span class="label {{ entity.statusString }}">{{ ('invoice.' ~ entity.statusString)|trans }}</span>
        </li>
        <li>
            {% if entity.sentByEmail %}
                <span class="label notice">{% trans %}invoice.sent_by_email{% endtrans %}</span>
            {% else %}
                <span class="label">{% trans %}invoice.not_sent_by_email{% endtrans %}</span>
            {% endif %}
        </li>
    </ul>
{% endblock %}
#}

{% block actionheader %}

{% endblock %}

{% block searchform %}{% endblock %}

{% block body %}

    {{ form_start(form) }}

    <article class="invoice-like">

        <header id="invoice-like-title">
            {% block invoice_actions %}{% endblock %}
            {% block invoice_label %}{% endblock %}
        </header>
        <div class="box pad box-warning">

            <div class="box-header with-border">

                <div class="btn-group">

                    <a href="{{ path('liquidacion_index') }}" class="btn btn-app">
                        <i class="glyphicon glyphicon-list-alt"></i>
                        Listado
                    </a>
                    <a href="{{ path('liquidacion_add') }}" class="btn btn-app">
                        <i class="glyphicon glyphicon-file"></i>
                        Nuevo
                    </a>

                    {% if entity.anulado %}
                        <button type="submit" name="Form-pdf" class="btn btn-app">
                            <i class="fa fa-file-pdf-o"></i>Pdf
                        </button>
                    {% else %}
                        {% include "Core/comprob.show.html.twig" with {'entity': entity} %}
                    {% endif %}

                    {#
                    REVISAR IMPORTANTE SHARA
                    <form action="{{ path('invoice_email', {'id': entity.id}) }}" method="post">
                        <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}">
                        <button type="submit" class="btn btn-default btn-warning"><span
                                    class="glyphicon glyphicon-envelope"></span> {% trans %}show.email{% endtrans %}</button>
                    </form>
                    #}


                </div>

            </div>
            <div class="box-body">
                {% if entity.anulado %}
                    <div class="container-fluid">
                        <div class="row text-center">
                            <div class="col-md-12">
                                <h2 style="color: red">A N U L A D O</h2>
                            </div>
                        </div>
                    </div>
                {% endif %}

                {% include "Core/emisor.show.html.twig" with {'entity': entity} %}

                <div class="row">
                    <div id="invoice-like-customer-data" class="col-md-12">

                        <h3>Liquidación Compra</h3>

                        <div class="row">
                            <div class="col-md-3 clearfix">
                                <label>Serie:</label>
                                {{ entity.serie }}
                            </div>
                            <div class="col-md-3 clearfix">
                                <label>Número:</label>
                                {{ entity.label }}
                            </div>
                            <div class="col-md-3 clearfix">
                                <label>Fecha:</label>
                                {{ entity.issueDate |date("d/m/Y") }}
                            </div>

                        </div>
                        <div class="row">
                            <div class="col-md-6 clearfix">
                                <label>{% trans %}abstract_invoice.show.customer_name{% endtrans %}:</label>
                                {{ entity.customer_name }}
                            </div>
                            <div class="col-md-6 clearfix">
                                <label>{% trans %}abstract_invoice.show.customer_identification{% endtrans %}:</label>
                                {{ entity.customer_identification }}
                            </div>
                            <div class="col-md-6 clearfix">
                                <label>{% trans %}abstract_invoice.show.invoicing_address{% endtrans %}:</label>
                                {{ entity.provider_address|nl2br }}
                            </div>
                            <div class="col-md-6 clearfix">
                                <label>{% trans %}abstract_invoice.show.customer_email{% endtrans %}:</label>
                                {{ entity.customer_email }}
                            </div>

                        </div>
                    </div>

                    {#<div id="invoice-like-properties" class="col-md-5">
                        <div class="panel panel-default">
                            <h3 class="panel-heading">{% trans %}abstract_invoice.show.properties{% endtrans %}</h3>

                            <div class="panel-body">
                                <div class="col-md-12">
                                    <label>Clave acceso:</label>
                                    {{ entity.claveAcceso }}
                                </div>
                                <div class="col-md-12">
                                    <label>{% trans %}show.issue_date{% endtrans %}:</label>
                                    {{ entity.issueDate|localizeddate('none', 'none', app.request.locale, null, 'dd/MM/yyyy') }}
                                </div>
                                <div class="col-md-12">
                                    <label>Fecha de autorización:</label>
                                    {{ entity.fechaAutorizacion }}
                                </div>
                            </div>
                        </div>
                    </div>#}
                </div>

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

                        <h3>{% trans %}abstract_invoice.show.items{% endtrans %}</h3>

                        <table id="invoice-like-items" class="table table-condensed table-striped align-middle">
                            <thead>
                            <tr>
                                <th class="">{% trans %}item.show.description{% endtrans %}</th>
                                <th class="col-md-1 cell-align-center">{% trans %}item.show.quantity{% endtrans %}</th>
                                <th class="col-md-2 cell-align-right">{% trans %}item.show.unitary_cost{% endtrans %}</th>
                                <th class="col-md-2 cell-align-right">{% trans %}item.show.discount{% endtrans %}</th>
                                {# <th class="col-md-1 cell-align-center">{% trans %}item.show.taxes{% endtrans %}</th>#}
                                <th colspan="2" class="cell-align-right">{% trans %}item.show.total{% endtrans %}</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for item in entity.items %}
                                {{ include('Item/show.html.twig', { 'item': item, 'currency': currency }) }}
                            {% endfor %}
                            </tbody>
                        </table>

                    </div>
                </div>

                <div class="row totals">
                    <div class="col-md-4 col-md-offset-8">
                        <table id="invoice-like-totals" class="table table-condensed table-striped">
                            <tbody>
                            <tr>
                                <th class="cell-size-large">{% trans %}abstract_invoice.show.subtotal{% endtrans %}</th>
                                <td class="cell-align-right">{{ entity.baseAmount|localizedcurrency(currency, app.request.locale) }}</td>
                            </tr>
                            <tr>
                                <th>{% trans %}abstract_invoice.show.total_taxes{% endtrans %}</th>
                                <td class="cell-align-right">{{ entity.taxAmount|localizedcurrency(currency, app.request.locale) }}</td>
                            </tr>
                            <tr>
                                <th>{% trans with {'%currency%': currency} %}abstract_invoice.show.total{% endtrans %}</th>
                                <td class="cell-align-right">{{ entity.grossAmount|localizedcurrency(currency, app.request.locale) }}</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>

                <div class="row">
                    <div class="col-md-8">

                        <table id="invoice-like-items" class="table table-condensed table-striped align-middle">
                            <thead>
                            <tr>
                                <th class="col-md-2">Forma Pago</th>
                                <th class="col-md-1 cell-align-right">Valor</th>
                                <th class="col-md-1 cell-align-right">Plazo</th>
                                <th class="col-md-1 cell-align-center">Tiempo</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for item in entity.pagos %}
                                <tr>
                                    <td>
                                        {{ item.formapago.name }}
                                    </td>
                                    <td class="cell-align-right">
                                        {{ item.valor|localizedcurrency(currency, app.request.locale) }}
                                    </td>
                                    <td class="cell-align-right">
                                        {{ item.plazo }}
                                    </td>
                                    <td class="cell-align-center">
                                        {{ item.tiempo}}
                                    </td>
                                </tr>

                            {% endfor %}
                            </tbody>
                        </table>

                    </div>
                </div>


                <div id="invoice-like-notes" class="row">

                    <div class="col-md-6" style="word-wrap: break-word;">
                        <label>{% trans %}abstract_invoice.show.notes{% endtrans %}:</label>
                        <p>{{ entity.notes|nl2br }}</p>
                    </div>
                </div>

                <div class="entity-actions clearfix">
                    {% block invoice_edit_actions %}{% endblock %}
                </div>

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

    {% include "Core/email.show.html.twig" with {'entity': entity} %}

    {{ form_rest(form) }}
    {{ form_end(form) }}

{% endblock %}

