<div class="modal-header">
    <button type="button" class="close" ng-click="cancel()">&times;</button>
    <h3 class="modal-title">{[{ product.name}]} Previous Orders</h3>
</div>
<div class="modal-body" style="min-height: 300px;">

	<div class="row">
		<div class="col-sm-12">
			<div class="form-inline">
		        <strong class="muted" >Supplier: </strong>
                <select name="supplier_id" class="form-control" ng-model="filters.supplier_id">
                	<option ng-selected=" ! filters.supplier_id" value="">All Suppliers </option>
                	<option ng-repeat="supplier in suppliers" value="{[{ supplier.id }]}">{[{supplier.name}]}</option>
                </select>
	        </div>
        </div>
	</div>
	<br>
    <table class="table table-condensed table-striped">
        <thead>
            <th>Date</th>
            <th>Supplier</th>
            <th>Cost</th>
            <th>Units</th>
            <th></th>
        </thead>
        <tbody>
        	<tr ng-if="previousOrders.length ==  0">
        		<td colspan="4">There is no orders for this product.</td>
        	</tr>
            <tr ng-repeat="order in previousOrders">
                <td>
                    <span tooltip="{[{ ::order.created_at }]}">{[{ ::order.created_at | fromNow }]}</span>
                </td>
                <td>{[{ (suppliers | filter: {id: order.order.supplier_id})[0].name }]}</td>
                <td>{[{ order.unit_cost | currency:"£" }]}</td>
                <td>{[{ order.quantity }]}</td>
                <td><a ng-href="#/stock/order-summary/{[{ order.stock_purchase_order_id }]}">View order</a></td>
            </tr>
        </tbody>
    </table>
    <br><br>
    <div paginator="paginator"></div>
</div>

