{% 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('material_requisition_transmittal') }}">Transmittal</a></li>
                    <li>
                        <span class="show-for-sr">Current: </span> Items
                    </li>
                </ul>
            </nav>
            <div class="row small-up-1 medium-up-3 max-width-initial">
                <div class="column">
                    <div class="info-group">
                        <label>Transmittal No.</label>
                        <div>{{ transmittal.transmittalnoparsed }}</div>
                    </div>
                </div>
                <div class="column">
                    <div class="info-group">
                        <label>Delivery No.</label>
                        <div>{{ transmittal.deliveryno }}</div>
                    </div>
                </div>
                <div class="column">
                    <div class="info-group">
                        <label>Delivery Date</label>
                        <div>{{ transmittal.deliverydateasstring }}</div>
                    </div>
                </div>
                <div class="column">
                    <div class="info-group">
                        <label>Delivery Type</label>
                        <div>{{ transmittal.deliverytype ? transmittal.deliverytype.description : '' }}</div>
                    </div>
                </div>
                <div class="column">
                    <div class="info-group">
                        <label>Loader</label>
                        <div>{{ transmittal.loader }}</div>
                    </div>
                </div>
                <div class="column">
                    <div class="info-group">
                        <label>Destination</label>
                        <div>{{ transmittal.branchto.description }}</div>
                    </div>
                </div>
                <div class="column">
                    <div class="info-group">
                        <label>Status</label>
                        <div>{{ transmittal.status }}</div>
                    </div>
                </div>
                <div class="column">
                    <div class="info-group">
                        <label>Notes</label>
                        <div>{{ transmittal.note }}</div>
                    </div>
                </div>
            </div>
            <br/>
            <div class="content-container has-loading">
                <div class="content-container-content hide">
                    <div class="text-right">
                        {% if transmittal.status == 'Loading' and (userData.type == 'Super Admin' or 'Admin Transmittal Send' in userData.accesses) %}
                            <a href="javascript:void(0)" class="button small" id="href-transmittal-send" >Send</a>
                        {% endif %}
                        {% if transmittal.status == 'Delivered' and (userData.type == 'Super Admin' or 'Admin Transmittal Item Receive' in userData.accesses) %}
                            <a href="javascript:void(0)" class="button small" id="href-transmittalItemDelivery-formAll" >Receive Items</a>
                        {% endif %}
                    </div>
                    <ul class="tabs custom-tabs" data-tabs id="tabs-1">
                        <li class="tabs-title is-active"><a href="#panel-1-loading" aria-selected="true">Loading</a></li>
                        {% if transmittal.status != 'Loading' %}
                            <li class="tabs-title"><a href="#panel-1-receive" aria-selected="false">Receiving</a></li>
                        {% endif %}
                    </ul>
                    <div class="tabs-content custom-tabs-content" data-tabs-content="tabs-1">
                        <div class="tabs-panel is-active" id="panel-1-loading">
                            {% if transmittal.status == 'Loading' %}
                                <h5 class="subheader">Available Items For Loading</h5>
                                <table class="display responsive" id="transmittalItemForLoading-datalist" width="100%">
                                    <thead>
                                    <tr>
                                        <th>Item</th>
                                        <th>Quantity</th>
                                        <th>MR No.</th>
                                        <th>PO No.</th>
                                        <th>Invoice No</th>
                                        <th>Action</th>
                                    </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>
                            {% endif %}
                            <h5 class="subheader">Items Loaded</h5>
                            <table class="display responsive" id="transmittalItem-datalist" width="100%">
                                <thead>
                                <tr>
                                    <th>Item</th>
                                    <th>Quantity</th>
                                    <th>MR No.</th>
                                    <th>PO No.</th>
                                    <th>Invoice No</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                        </div>
                        {% if transmittal.status != 'Loading' %}
                            <div class="tabs-panel" id="panel-1-receive">
                                <table class="display responsive" id="transmittalItemDelivery-datalist" width="100%">
                                    <thead>
                                    <tr>
                                        <th>Item</th>
                                        <th>Location</th>
                                        <th>Receive Date</th>
                                        <th>Quantity</th>
                                        <th>Action</th>
                                    </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>
                            </div>
                        {% endif %}
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="reveal small" 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>
    {% include '@RxConnexion/Admin/js.html.twig' %}
    <script language="javascript">
        //<![CDATA[
        jQ(document).ready(function(){
            transmittalItem.settings.transmittal_id = '{{ transmittal_id }}';
            transmittalItem.settings.ajaxUrl = '{{ path('material_requisition_transmittal_item_ajax_list') }}';
            transmittalItem.settings.ajaxUrlForLoading = '{{ path('material_requisition_transmittal_item_ajax_list_for_loading') }}';
            transmittalItem.settings.ajaxUrlItemDelivery = '{{ path('material_requisition_transmittal_item_delivery_ajax_list') }}';
            transmittalItem.settings.loadUrl = '{{ path('material_requisition_transmittal_item_load') }}';
            transmittalItem.settings.unloadUrl = '{{ path('material_requisition_transmittal_item_unload') }}';
            transmittalItem.settings.sendUrl = '{{ path('material_requisition_transmittal_send') }}';
            transmittalItem.settings.transmittalItemDeliveryFormAll_url = '{{ path('material_requisition_transmittal_item_delivery_form_all') }}';
            transmittalItem.settings.transmittalItemDeliveryFormAllAction_url = '{{ path('material_requisition_transmittal_item_delivery_form_all_action') }}';
            transmittalItem.settings.transmittalItemDeliveryForm_url = '{{ path('material_requisition_transmittal_item_delivery_form') }}';
            transmittalItem.settings.transmittalItemDeliveryFormAction_url = '{{ path('material_requisition_transmittal_item_delivery_form_action') }}';
            transmittalItem.init();
        });
        //]]>
    </script>
{% endblock %}