{% 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;
        }
    </style>
    <h5 class="report-header">{{ page_title }}</h5>
    <table width="100%">
        <thead>
        <tr>
            <td colspan="2"></td>
            {% for branch in branches %}
                <td style="background-color: #1D4962!important;color: white!important;" nowrap colspan="3">{{ branch.description }}</td>
            {% endfor %}
        </tr>
        <tr>
            <td>Code</td>
            <td>Item</td>
            {% for branch in branches %}
                <td nowrap>Qty</td>
                <td nowrap>Cost</td>
                <td nowrap>Value</td>
            {% endfor %}
        </tr>
        </thead>
        <tbody>
        {% for inventory in inventories %}
            <tr>
                <td nowrap>{{ inventory.codes }}</td>
                <td nowrap>{{ inventory.item }}</td>
                {% for branch in branches %}
                    {% set qty = '' %}
                    {% set ave_cost = '' %}
                    {% set total_cost = '' %}
                    {% set stop = false %}
                    {% for inv_branch in inventory.branches if stop == false %}
                        {% if inv_branch.id == branch.id %}
                            {% set qty = inv_branch['quantity'] %}
                            {% set ave_cost = inv_branch['ave_cost'] %}
                            {% set total_cost = inv_branch['total_cost'] %}
                            {% set stop = true %}
                        {% endif %}
                    {% endfor %}
                    <td nowrap>{{ qty|number_format(0) }}</td>
                    <td nowrap>{{ ave_cost|number_format(2, '.', ',') }}</td>
                    <td nowrap>{{ total_cost|number_format(2, '.', ',') }}</td>
                {% endfor %}
            </tr>
        {% endfor %}
    </table>
    {% include '@RxConnexion/Admin/js.html.twig' %}
    <script>
        //<![CDATA[
        jQ(document).ready(function(){
            report_preview.init();
        });
        //]]>
    </script>
{% endblock %}