@extends('tablar::page')

@section('content')
<div class="page-header d-print-none">
    <div class="container-xl">
        <div class="row g-2 align-items-center">
            <div class="col">
                <h2 class="page-title">Winners By Item</h2>
            </div>
        </div>
    </div>
</div>

<div class="page-body">
    <div class="container-xl">
        <div class="row row-cards">
            <div class="col-12">
                <div class="card" id="winners-by-item-table">
                    <div class="table-responsive">
                        <table class="table table-vcenter card-table">
                            <thead>
                                <tr>
                                    <th class="sort" data-sort="item-num">Item Number</th>
                                    <th class="sort" data-sort="item-desc">Item Description</th>
                                    <th class="sort" data-sort="winner">Winner</th>
                                    <th class="sort" data-sort="bid">Winning Bid</th>
                                    <th>Actions</th>
                                </tr>
                                </thead>
                                <tbody class="list">
                                @foreach($winnersbyitem_results as $winner)
                                    <tr>
                                        <td class="item-num">{{ $winner->items->item_assigned_num }}</td>
                                        <td class="item-desc">{{ $winner->items->item_desc }}</td>
                                        <td class="winner">{{ $winner->bidders->bidder_fname }} {{ $winner->bidders->bidder_lname }}</td>
                                        <td class="bid">${{ number_format($winner->winning_cost, 2) }}</td>
                                        <td>
                                            <a href="/editwinners?id={{ $winner->idwinning_bids }}" class="btn btn-sm btn-white">Edit</a>
                                        </td>
                                    </tr>
                                @endforeach                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

@push('js')
<script src="https://cdnjs.cloudflare.com/ajax/libs/list.js/2.3.1/list.min.js"></script>
<script>
    new List('winners-by-item-table', {
        valueNames: ['item-num', 'item-desc', 'winner', 'bid']
    });
</script>
@endpush
