<vn-crud-model
    vn-id="model"
    url="ItemShelvingPlacementSupplyStocks"
    link="{itemFk: $ctrl.$params.id}"
    data="$ctrl.itemShelvingPlacementSupplyStocks"
    auto-load="true">
</vn-crud-model>
<vn-card>
    <smart-table 
        model="model"
        options="$ctrl.smartTableOptions" 
        expr-builder="$ctrl.exprBuilder(param, value)">
        <slot-actions>
            <div>
                <div class="totalBox" style="text-align: center;">
                    <h6 translate>Total</h6>
                    <vn-label-value 
                        label="Total labels" 
                        value="{{$ctrl.labelTotal.toFixed(2)}}">
                    </vn-label-value>
                </div>
            </div>
            <div class="vn-pa-md">
                <vn-button 
                    disabled="!$ctrl.checked.length"
                    ng-click="removeConfirm.show()"
                    icon="delete"
                    vn-tooltip="Remove selected lines"
                    vn-acl="replenisherBos">
                </vn-button>
            </div>
        </slot-actions>
        <slot-table>
            <table>
                <thead>
                    <tr>
                        <th shrink>
                            <vn-multi-check 
                                model="model">
                            </vn-multi-check>
                        </th>
                        <th field="created">
                            <span translate>Created</span>
                        </th>
                        <th shrink field="itemFk">
                            <span translate>Item</span>
                        </th>
                        <th 
                            field="longName">
                            <span translate>Concept</span>
                        </th>
                        <th 
                            field="parking">
                            <span translate>Parking</span>
                        </th>
                        <th field="shelving">
                            <span translate>Shelving</span>
                        </th>
                        <th 
                            field="label">
                            <span translate>Etiqueta</span>
                        </th>
                        <th 
                            field="packing"
                            shrink>
                            <span translate>Packing</span>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr 
                        ng-repeat="itemShelvingPlacementSupplyStock in $ctrl.itemShelvingPlacementSupplyStocks"
                        vn-repeat-last on-last="$ctrl.calculateTotals()">
                        <td shrink>
                            <vn-check 
                                ng-model="itemShelvingPlacementSupplyStock.checked"
                                vn-click-stop>
                            </vn-check>
                        </td>
                        <td shrink-date>{{::itemShelvingPlacementSupplyStock.created | date: 'dd/MM/yyyy'}}</td>
                        <td>
                            {{::itemShelvingPlacementSupplyStock.itemFk}}
                        </td>
                        <td expand title="{{::itemShelvingPlacementSupplyStock.longName}}">
                            <span
                                vn-click-stop="itemDescriptor.show($event, itemShelvingPlacementSupplyStock.itemFk)"
                                class="link">
                                {{itemShelvingPlacementSupplyStock.longName}}
                            </span>
                        </td>
                        <td>
                            {{::itemShelvingPlacementSupplyStock.parking}}
                        </td>
                        <td>
                            {{::itemShelvingPlacementSupplyStock.shelving}}
                        </td>
                        <td>
                            {{(itemShelvingPlacementSupplyStock.stock / itemShelvingPlacementSupplyStock.packing).toFixed(2)}}
                        </td>
                        <td>
                            {{::itemShelvingPlacementSupplyStock.packing}}
                        </td>
                    </tr>
                </tbody>
            </table>
        </slot-table>
    </smart-table>
</vn-card>
<vn-item-descriptor-popover
    vn-id="item-descriptor">
</vn-item-descriptor-popover>

<vn-confirm 
    vn-id="removeConfirm"
    message="Selected lines will be deleted"
    question="Are you sure you want to continue?"
    on-accept="$ctrl.onRemove()">
</vn-confirm>