@php
    $positions = [
        1 => 'Home Middle',
        2 => 'Home Bottom',
        3 => 'Category Sidebar',
        4 => 'Search Page Sidebar'
    ];
@endphp

@foreach ($positions as $positionKey => $positionName)
    <h3 class="bg-info text-white p-2 mt-12">{{ $positionName }}</h3>
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>Title</th>
                <th>Status</th>
                <th>Date</th>
                <th>Action</th>
            </tr>
        </thead>
        <tbody>
            @foreach ($data->where('position', $positionKey) as $item)
                <tr>
                    <td>
                        {{ $item->title }}
                        <br>
                        <small class="text-muted">Vendor: {{ $item->vendor_name }}</small>
                        <br><span class="badge bg-info">{{ $item->type == 1 ? 'Image' : ($item->type == 2 ? 'Video' : 'Content') }}</span>
                    </td>
                    <td>
                        <span class="btn btn-info">{{ decimalToInt($item->fee) ?? 0 }} {{ setting('CURRENCY_CODE_MIN') }}</span>
                        @if ($item->pay_status == 0)
                            <span class="btn btn-danger">Unpaid</span>
                        @elseif ($item->pay_status == 1)
                            <span class="btn btn-success">Paid</span>
                        @elseif ($item->pay_status == 2)
                            <span class="btn btn-warning">Due</span>
                        @elseif ($item->pay_status == 3)
                            <span class="btn btn-danger">Requested for refund</span>
                        @elseif ($item->pay_status == 4)
                            <span class="btn btn-danger">Refunded</span>
                        @endif

                        @if ($item->status == 0)
                            <span class="btn btn-warning">Pending</span>
                            <br><small class="text-muted">Need to be active</small>
                        @elseif ($item->status == 1)
                            <span class="btn btn-success">Active</span>
                        @elseif ($item->status == 2)
                            <span class="btn btn-dark">In-review</span>
                            <br><small class="text-muted">Need to be check and send to for payment</small>
                        @elseif ($item->status == 3)
                            <span class="btn btn-warning">Waiting for Payment</span>
                        @elseif ($item->status == 4)
                            Rejected
                        @endif
                    </td>
                    <td>
                        Start: {{ \Carbon\Carbon::parse($item->start_date)->format('F j, Y g:i A') }} <br>
                        <span class="text-danger">End: {{ \Carbon\Carbon::parse($item->end_date)->format('F j, Y g:i A') }}</span>
                    </td>
                    <td>
                        <a href="#" class="btn btn-dark">{{ decimalToInt($item->fee) ?? 0 }} {{ setting('CURRENCY_CODE_MIN') }}</a>
                        <a href="{{ route('admin.advertisement.edit', $item->id) }}" class="btn btn-warning">Edit</a>
                        <hr>
                        @if($item->status != 1)
                            <a href="{{ route('admin.advertisement.statusUpdate', [$item->id, 1, $item->pay_status]) }}" class="btn btn-danger">Make Active</a>
                        @else
                            <a href="{{ route('admin.advertisement.statusUpdate', [$item->id, 0, $item->pay_status]) }}" class="btn btn-success">Make Inactive</a>
                        @endif
                        @if($item->pay_status != 1)
                            <a href="{{ route('admin.advertisement.statusUpdate', [$item->id, $item->status, 1]) }}" class="btn btn-danger">Make Paid</a>
                        @else
                            <a href="{{ route('admin.advertisement.statusUpdate', [$item->id, $item->status, 0]) }}" class="btn btn-success">Make Unpaid</a>
                        @endif
                    </td>
                </tr>
            @endforeach
        </tbody>
    </table>
@endforeach