{% extends '@RxConnexion/Admin/global.html.twig' %}
{% block body %}
    <style>
        table {
            border-collapse: collapse;
        }
        table tr,
        table td {
            background-color: #ffffff;
        }
        table td {
            border: 1px solid #c0c0c0;
            padding: 2px 5px;
        }
        thead td{
            background: #ADD8E6 !important;
        }
        .total-border {
            border-bottom: 4px double #383838;
            border-top: 2px solid #383838;
        }
        .sub-total-border {
            border-bottom: 1px solid #383838;
            border-top: 2px solid #383838;
        }
        .border-bottom {
            border-bottom: 1px solid #383838;
        }
        .strong {
            font-weight: 600;
        }
        tbody tr:hover td {
            background: #F2F9F7 !important;
        }
    </style>
    <h5 class="report-header">{{ page_title }}</h5>
    <table width="100%">
        <thead class="">
        <tr>
            <td colspan="2"></td>
            {% for branch in branches %}
                <td nowrap colspan="2" class="text-center" style="background-color: #1d4962!important; color: white;">{{ branch.description }}</td>
            {% endfor %}
        </tr>
        <tr>
            <td>Code</td>
            <td>Item</td>
            {% for branch in branches %}
                <td nowrap class="text-right">Quantity</td>
                <td nowrap class="text-right">Sold Value</td>
            {% endfor %}
        </tr>
        </thead>
        <tbody>
        {% for item in items %}
            <tr>
                <td nowrap>{{ item.codes }}</td>
                <td nowrap>{{ item.description }}</td>
                {% for branch in branches %}
                    {% for record in records if record.item_id == item.id and record.branch_id == branch.id %}
                        <td nowrap class="text-right">{{ record.totalQty|number_format(0) }}</td>
                        <td nowrap class="text-right">{{ record.totalSoldValue|number_format(2, '.', ',') }}</td>
                    {% else %}
                        <td></td>
                        <td></td>
                    {% endfor %}
                {% endfor %}
            </tr>
        {% endfor %}
        </tbody>
        <tfoot>
        <tr>
            <td colspan="2">Total</td>
            {% for branch in branches %}
                <td nowrap class="text-right">{{ branch.totalQty|number_format(0) }}</td>
                <td nowrap class="text-right">{{ branch.totalSoldValue|number_format(2, '.', ',') }}</td>
            {% endfor %}
        </tr>
        </tfoot>
    </table>
    {% include '@RxConnexion/Admin/js.html.twig' %}
    <script>
        //<![CDATA[
        jQ(document).ready(function(){
            report_preview.init();
        });
        //]]>
    </script>
{% endblock %}