{% set userData = app.session.get('userData') %}
<form id="form-transferInventoryItemDelivery" method="POST">
    <input type="hidden" name="transferInventory_id" value="{{ transferInventory_id }}" />
    <h4>{{ page_title }}</h4>
    <div id="flash-messages-content-modal"></div>
    <p class="form-hint-text">Enter basic information below</p>
    <div class="row max-width-initial">
        <div class="large-4 columns">
            <div class="row">
                <div class="large-4 large-text-right columns">
                    <label class="middle">Receive Date</label>
                </div>
                <div class="large-8 columns">
                    <input type="text" name="transferInventoryItemDelivery[receiveDate]" class="date" value="{{ 'now'|date('m/d/Y') }}" placeholder="MM/DD/YYYY" />
                </div>
            </div>
        </div>
    </div>
    <table class="display responsive" id="transferInventoryItemList-datalist" width="100%">
        <thead>
        <tr>
            <th>Item</th>
            <th>Receiving Location</th>
            {#<th class="text-right">Required Quantity</th>#}
            <th class="text-right">Delivered Quantity</th>
            <th class="text-right">Received Quantity</th>
            <th class="text-right">Quantity</th>
        </tr>
        </thead>
        <tbody>
        {% set branchId = transferInventory.branchFrom.id %}
        {% for key,transferInventoryItem in transferInventory.transferinventoryitems %}
            {% set item = transferInventoryItem.item %}
            {% set invs = item.getInventoriesByBranchIdAndStatus(branchId, constant('RxConnexionBundle\\Entity\\InventoryEntity::STATUS_STOCK_ON_HAND')) %}

            <tr>
                <td>{{ transferInventoryItem.item.description }}</td>
                <td>
                    {% if transferInventory.locationTo %}
                        <input type="hidden" name="transferInventoryItems[{{ key }}][location_id]" value="{{ transferInventory.locationTo.id }}">
                        <input type="text" value="{{ transferInventory.locationTo.description }}" disabled>
                    {% else %}
                        <select name="transferInventoryItems[{{ key }}][location_id]" style="height: auto;">
                            {% for location in transferInventory.branchTo.locations %}
                                <option value="{{ location.id }}">{{ location.description }}</option>
                            {% endfor %}
                        </select>
                    {% endif %}
                </td>
                {#<td class="text-right">{{ transferInventoryItem.quantity|number_format(0, '.', ',') }}</td>#}
                <td class="text-right">{{ transferInventoryItem.quantityDelivered|number_format(0, '.', ',') }}</td>
                <td class="text-right">{{ transferInventoryItem.quantityreceived|number_format(0, '.', ',') }}</td>
                <td>
                    <input type="hidden" name="transferInventoryItems[{{ key }}][id]" value="{{ transferInventoryItem.id }}" />
                    <input type="text" class="pull-right numeric" name="transferInventoryItems[{{ key }}][quantity]" value="" />
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
    <br/>
    <div class="row max-width-initial">
        <div class="small-12 columns no-padding-right">
            <div class="button-container clearfix">
                <button type="button" class="button just-continue href-transferInventoryItemDelivery-actionAll float-right no-margin-right" id="href-transferInventoryItemDelivery-actionAll" name="action" value=""
                        data-message="Are you sure you want to save this information?"
                >Save</button>
            </div>
        </div>
    </div>
</form>