{% 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('convert_inventory') }}">Convert 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>Convert Supply No.</label>
                        <div>{{ convertInventory.convertInventorynoparsed }}</div>
                    </div>
                </div>
                <div class="column">
                    <div class="info-group">
                        <label>Date</label>
                        <div>{{ convertInventory.convertdateasstring }}</div>
                    </div>
                </div>
                <div class="column">
                    <div class="info-group">
                        <label>Branch</label>
                        <div>{{ convertInventory.healthFacility.description }}</div>
                    </div>
                </div>
                <div class="column">
                    <div class="info-group">
                        <label>Status</label>
                        <div>{{ convertInventory.status }}</div>
                    </div>
                </div>
                {#<div class="column">
                    <div class="info-group">
                        <label>Total Cost</label>
                        <div>{{ convertInventory.totalcost|number_format(2, '.', ',') }}</div>
                    </div>
                </div>#}
                <div class="column">
                    <div class="info-group">
                        <label>Notes</label>
                        <div>{{ convertInventory.note }}</div>
                    </div>
                </div>
            </div>
            <div class="content-container has-loading">
                <div class="content-container-content hide">
                    {% if convertInventory.status != 'Completed' and convertInventory.status != 'Pending Admin Approval' %}
                        <div class="text-right">
                            {% if userData.type == 'Super Admin' or 'Admin Convert Inventory Item Send' in userData.accesses %}
                                <a href="javascript:void(0)" class="button small" id="href-convertInventory-send" data-open="send-ask-modal" style="margin: 0 0 10px 10px;">
                                    {% if convertInventory.status in ['New', 'Rejected'] %}
                                        Submit
                                    {% elseif convertInventory.status == 'Approved' %}
                                        For Processing
                                    {% elseif convertInventory.status == 'In Processing' and convertInventory.itembictr > 1 %}
                                        Submit For Costing
                                    {% else %}
                                        Complete Transaction
                                    {% endif %}
                                </a>
                            {% endif %}
                        </div>
                    {% endif %}
                    <div class="content-container has-loading">
                        <div class="content-container-content hide">
                            <ul class="tabs custom-tabs" data-tabs id="convert-inventory-tabs">
                                <li class="tabs-title is-active"><a href="#panel-raw-inventory" aria-selected="true">Raw Materials</a></li>
                                {#<li class="tabs-title"><a href="#panel-status" aria-selected="false">Status</a></li>#}
                                <li class="tabs-title"><a href="#panel-bi-inventory" aria-selected="false">End Products</a></li>
                            </ul>
                            <div class="tabs-content custom-tabs-content" data-tabs-content="convert-inventory-tabs">
                                <div class="tabs-panel is-active" id="panel-raw-inventory">
                                    {% if convertInventory.status == 'New' or convertInventory.status == 'Rejected' %}
                                        <div class="text-right">
                                            {% if userData.type == 'Super Admin' or 'Admin Convert Inventory Item New' in userData.accesses %}
                                                <a href="javascript:void(0)" class="href-new-action href-convertInventoryItem-form" data-action="n" data-id="0" style="margin: 0 0 10px 10px;">Add Material</a>
                                            {% endif %}
                                        </div>
                                    {% endif %}
                                    <table class="display responsive" id="convertInventoryItem-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Item</th>
                                            <th>Quantity</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                {#<div class="tabs-panel" id="panel-status">#}
                                    {#{% if convertInventory.canApproveByUser(userData) %}#}
                                    {#{% if canApproveByUser %}#}
                                        {#<form method="POST" action="{{ path('convert_inventory_status_approval') }}">#}
                                            {#<input type="hidden" name="convertInventory_id" value="{{ convertInventory_id }}" />#}
                                            {#<input type="hidden" class="form-action" name="action" />#}
                                            {#<div class="row max-width-initial">#}
                                                {#<div class="small-12 columns">#}
                                                    {#<label>Notes</label>#}
                                                    {#<textarea name="notes" placeholder="Enter your notes here"></textarea>#}
                                                {#</div>#}
                                                {#<div class="small-12 columns">#}
                                                    {#<div class="button-container">#}
                                                        {#<button type="submit" class="button ask-continue no-margin-bottom" name="action" value="approve"#}
                                                                {#data-message="Are you sure you want to approve this request?"#}
                                                        {#>Approve</button>#}
                                                        {#<button type="submit" class="button alert ask-continue no-margin-bottom" name="action" value="reject"#}
                                                                {#data-message="Are you sure you want to reject this request?"#}
                                                        {#>Reject</button>#}
                                                    {#</div>#}
                                                {#</div>#}
                                            {#</div>#}
                                        {#</form>#}
                                        {#<hr class="max-width-initial">#}
                                    {#{% endif %}#}
                                    {#<h5>History</h5>#}
                                    {#<table class="display response" id="convertInventoryStatusHistory-datalist" width="100%">#}
                                        {#<thead>#}
                                        {#<tr>#}
                                            {#<th>Date / Time</th>#}
                                            {#<th>Status</th>#}
                                            {#<th>Approval</th>#}
                                            {#<th>User</th>#}
                                            {#<th>Notes</th>#}
                                        {#</tr>#}
                                        {#</thead>#}
                                        {#<tbody>#}
                                        {#{% for ctr in convertInventory.approvalbatchno..0 %}#}
                                            {#{% for convertInventoryStatus in convertInventory.convertinventorystatuses %}#}
                                                {#{% if convertInventoryStatus.batchno == ctr and (convertInventoryStatus.approvaldescription == 'Approved' or convertInventoryStatus.approvaldescription == 'Rejected') %}#}
                                                    {#<tr>#}
                                                        {#<td>{{ convertInventoryStatus.updatedat|date('m/d/Y h:i:s A') }}</td>#}
                                                        {#<td>{{ convertInventoryStatus.status }}</td>#}
                                                        {#<td>{{ convertInventoryStatus.approvaldescription }}</td>#}
                                                        {#<td>{{ convertInventoryStatus.user.fullname }} - {{ convertInventoryStatus.user.type }}</td>#}
                                                        {#<td>{{ convertInventoryStatus.note }}</td>#}
                                                    {#</tr>#}
                                                {#{% endif %}#}
                                            {#{% endfor %}#}
                                        {#{% endfor %}#}
                                        {#</tbody>#}
                                    {#</table>#}
                                {#</div>#}
                                <div class="tabs-panel" id="panel-bi-inventory">
                                    {% if convertInventory.status in ['New', 'Approved', 'Rejected', 'In Processing'] %}
                                        <div class="text-right">
                                            {% if userData.type == 'Super Admin' or 'Admin Convert Inventory Item New' in userData.accesses %}
                                                <a href="javascript:void(0)" class="href-new-action href-convertInventoryItemBi-form" data-action="n" data-id="0" style="margin: 0 0 10px 10px;">Add End Product</a>
                                            {% endif %}
                                        </div>
                                    {% endif %}
                                    <table class="display responsive" id="convertInventoryItemBi-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Item</th>
                                            <th>Serial No.</th>
                                            <th>Location</th>
                                            <th>Quantity</th>
                                            {#<th>Total Cost</th>#}
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                            </div>
                        </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="modal-small" style="top: -12% !important;" data-reveal>
        <div id="modal-content-small"></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(){
            convertInventoryItem.settings.convertInventory_id = '{{ convertInventory_id }}';
            convertInventoryItem.settings.ajaxUrl = '{{ path('convert_inventory_item_ajax_list') }}';
            convertInventoryItem.settings.formUrl = '{{ path('convert_inventory_item_form') }}';
            convertInventoryItem.settings.formActionUrl = '{{ path('convert_inventory_item_form_action') }}';
            convertInventoryItem.settings.biAjaxUrl = '{{ path('convert_inventory_item_bi_ajax_list') }}';
            convertInventoryItem.settings.biFormUrl = '{{ path('convert_inventory_item_bi_form') }}';
            convertInventoryItem.settings.biFormActionUrl = '{{ path('convert_inventory_item_bi_form_action') }}';
            convertInventoryItem.settings.biFormCostingUrl = '{{ path('convert_inventory_item_bi_form_costing') }}';
            convertInventoryItem.settings.biFormCostingActionUrl = '{{ path('convert_inventory_item_bi_form_costing_action') }}';
            convertInventoryItem.settings.sendUrl = '{{ path('convert_inventory_send') }}';
            convertInventoryItem.settings.inventory_autocomplete_url = '{{ path('inventory_autocomplete') }}';
            convertInventoryItem.settings.item_autocomplete_url = '{{ path('item_autocomplete') }}';
            convertInventoryItem.settings.location_autocomplete_url = '{{ path('location_autocomplete') }}';
            convertInventoryItem.settings.health_facility_id = '{{ convertInventory.healthFacility.idEncoded }}';
            convertInventoryItem.init();
        });
        //]]>
    </script>
{% endblock %}