{% extends '@RxConnexion/Admin/content.html.twig' %}
{% block content %}
    <div class="row max-width-initial">
        <div class="small-12 columns">
            <nav aria-label="You are here:" role="navigation">
                <ul class="breadcrumbs">
                    <li><a href="{{ path('add_inventory') }}">Add Supplies</a></li>
                    <li>
                        <span class="show-for-sr">Current: </span> Items
                    </li>
                </ul>
            </nav>
            <div class="row small-up-1 medium-up-2 max-width-initial">
                <div class="column">
                    <div class="info-group">
                        <label>Add Supply No.</label>
                        <div>{{ addInventory.addInventorynoparsed }}</div>
                    </div>
                </div>
                <div class="column">
                    <div class="info-group">
                        <label>Date</label>
                        <div>{{ addInventory.adddateasstring }}</div>
                    </div>
                </div>
                <div class="column">
                    <div class="info-group">
                        <label>Branch</label>
                        <div>{{ addInventory.healthFacility.description }}</div>
                    </div>
                </div>
                {#<div class="column">#}
                    {#<div class="info-group">#}
                        {#<label>Supplier</label>#}
                        {#<div>{{ addInventory.supplier.description }}</div>#}
                    {#</div>#}
                {#</div>#}
                <div class="column">
                    <div class="info-group">
                        <label>Status</label>
                        <div>{{ addInventory.status }}</div>
                    </div>
                </div>
                <div class="column">
                    <div class="info-group">
                        <label>Notes</label>
                        <div>{{ addInventory.note }}</div>
                    </div>
                </div>
            </div>
            <div class="content-container has-loading">
                <div class="content-container-content hide">
                    {% if addInventory.status == 'New' %}
                        {% if userData.type == 'Super Admin' or 'Admin Add Inventory Item Send' in userData.accesses %}
                            <div class="text-right">
                                <a href="javascript:void(0)" class="button small" id="href-addInventory-send" data-open="send-ask-modal" style="margin: 0 0 10px 10px;">Complete</a>
                                <a href="{{ path('add_inventory_received_record_print' , { addInventory_id : addInventory.getIdEncoded} ) }}" class="button small success" style="margin: 0 0 10px 10px;" target="_blank">Print RR</a>
                            </div>
                        {% endif %}
                    {% endif %}
                    <ul class="tabs custom-tabs" data-tabs id="add-inventory-tabs">
                        <li class="tabs-title is-active"><a href="#panel-item" aria-selected="true">Items</a></li>
                        <li class="tabs-title"><a href="#panel-payment" aria-selected="false">Payments</a></li>
                    </ul>
                    <div class="tabs-content custom-tabs-content" data-tabs-content="add-inventory-tabs">
                        <div class="tabs-panel is-active" id="panel-item">
                            {% if addInventory.status == 'New' %}
                                {% if userData.type == 'Super Admin' or 'Admin Add Inventory Item New' in userData.accesses %}
                                    <div class="text-right">
                                        <a href="javascript:void(0)" class="href-new-action secondary href-addInventoryItem-form" data-action="n" data-id="0" style="margin: 0 0 10px 10px;">New Item</a>
                                    </div>
                                {% endif %}
                            {% endif %}
                            <table class="display responsive" id="addInventoryItem-datalist" width="100%">
                                <thead>
                                <tr>
                                    <th>Item</th>
                                    <th>Location</th>
                                    <th>Price</th>
                                    <th>Quantity</th>
                                    <th>Total Price</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                        </div>
                        <div class="tabs-panel" id="panel-payment">
                            {% if addInventory.status == 'New' and (userData.type == 'Super Admin' or 'Admin Add Inventory Payment New' in userData.accesses) %}
                                <div class="text-right">
                                    <a href="javascript:void(0)" class="href-add-inventory-payment-form href-new-action" style="margin-right: 0;" data-action="n" data-id="0">Add Payment</a>
                                </div>
                            {% endif %}
                            <table class="display responsive" id="addInventoryPayment-datalist" width="100%">
                                <thead>
                                <tr>
                                    <th>Pay Date</th>
                                    <th>Type</th>
                                    <th>Amount</th>
                                    <th>Check Date</th>
                                    <th>Check No.</th>
                                    <th>Bank</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="reveal large" id="modal" data-reveal>
        <div id="modal-content"></div>
        <button class="close-button" data-close aria-label="Close modal" type="button">
            <span aria-hidden="true">&times;</span>
        </button>
    </div>
    <div class="reveal small" id="send-ask-modal" data-reveal>
        <h4>Are you sure you want to continue?</h4>
        <hr class="max-width-initial">
        <div class="button-container text-right">
            <a href="javascript:void(0);" id="btn-send-ask-modal-continue" data-action="" class="button">&nbsp;&nbsp;Yes&nbsp;&nbsp;</a>
            <a href="javascript:void(0);" class="button secondary no-margin-right" data-close>Cancel</a>
        </div>
        <button class="close-button" data-close aria-label="Close modal" type="button">
            <span aria-hidden="true">&times;</span>
        </button>
    </div>
    {% include '@RxConnexion/Admin/js.html.twig' %}
    <script language="javascript">
        //<![CDATA[
        jQ(document).ready(function(){
            addInventoryItem.settings.addInventory_id = '{{ addInventory_id }}';
            addInventoryItem.settings.ajaxUrl = '{{ path('add_inventory_item_ajax_list') }}';
            addInventoryItem.settings.formUrl = '{{ path('add_inventory_item_form') }}';
            addInventoryItem.settings.formActionUrl = '{{ path('add_inventory_item_form_action') }}';
            addInventoryItem.settings.payment_ajaxUrl = '{{ path('add_inventory_payment_ajax_list') }}';
            addInventoryItem.settings.payment_formUrl = '{{ path('add_inventory_payment_form', {addInventory_id: addInventory.idencoded}) }}';
            addInventoryItem.settings.payment_formActionUrl = '{{ path('add_inventory_payment_form_action') }}';
            addInventoryItem.settings.sendUrl = '{{ path('add_inventory_send') }}';
            addInventoryItem.settings.item_autocomplete_url = '{{ path('item_autocomplete') }}';
            {#addInventoryItem.settings.item_unit_measurement_autocomplete_url = '{{ path('item_unit_measurement_autocomplete') }}';#}
            addInventoryItem.settings.bank_autocomplete_url = '{{ path('bank_autocomplete') }}';
            addInventoryItem.settings.location_autocomplete_url = '{{ path('location_autocomplete') }}';
            addInventoryItem.settings.branch_id = '{{ addInventory.healthFacility.id|base64Encode }}';
            addInventoryItem.init();
        });
        //]]>
    </script>
{% endblock %}