@extends('layouts.admin')

@section('title', 'Riwayat Pesanan')

@section('content')
    <section class="section">
        <div class="card">
            <div class="card-body">

                <div class="nav nav-pills nav-fill mb-4" id="v-pills-tab" role="tablist" aria-orientation="horizontal">
                    <a class="nav-link active" id="v-pills-home-tab" data-bs-toggle="pill" href="#v-pills-home" role="tab"
                        aria-controls="v-pills-home" aria-selected="true">
                        Buket
                    </a>
                    <a class="nav-link" id="v-pills-profile-tab" data-bs-toggle="pill" href="#v-pills-profile"
                        role="tab" aria-controls="v-pills-profile" aria-selected="false">
                        Foto
                    </a>
                </div>

                <div class="tab-content" id="v-pills-tabContent">

                    <div class="tab-pane fade show active" id="v-pills-home" role="tabpanel"
                        aria-labelledby="v-pills-home-tab">
                        <table class="table table-striped" id="riwayat-buket">
                            <thead>
                                <tr>
                                    <th>No. Invoice</th>
                                    <th>Nama Pelanggan</th>
                                    <th>Nama Buket</th>
                                    <th>Tanggal Ambil</th>
                                    <th>Total</th>
                                    <th>Status</th>
                                    <th>Aksi</th>
                                </tr>
                            </thead>
                            <tbody>
                                @forelse ($riwayatBuket as $rb)
                                    <tr>
                                        <td>{{ $rb->no_invoice }}</td>
                                        <td>{{ $rb->pelanggan->nama }}</td>
                                        <td>{{ $rb->buket->nama }}</td>
                                        <td>{{ \Carbon\Carbon::parse($rb->tgl_ambil)->translatedFormat('d M Y') }}</td>
                                        <td>Rp {{ number_format($rb->total_bayar, 0, ',', '.') }}</td>
                                        <td>
                                            <span class="badge {{ $rb->status_label->class }}">
                                                {{ $rb->status_label->text }}
                                            </span>
                                        </td>
                                        <td class="col-auto">
                                            <a href="#" class="btn icon btn-primary btn-action" data-bs-toggle="modal"
                                                data-bs-target="#riwayatBuket{{ $rb->id_transaksi }}">
                                                <i class="bi bi-eye"></i>
                                            </a>
                                        </td>
                                    </tr>
                                    @include('admin.pesanan.partials.modal-riwayat-buket')
                                @empty
                                    <tr>
                                        <td colspan="4" class="text-center text-muted">Belum ada data riwayat pesanan
                                            buket.
                                        </td>
                                    </tr>
                                @endforelse
                            </tbody>
                        </table>
                    </div>

                    <div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab">
                        <table class="table table-striped" id="riwayat-foto">
                            <thead>
                                <tr>
                                    <th>No. Invoice</th>
                                    <th>Nama Pelanggan</th>
                                    <th>Nama Paket</th>
                                    <th>Tanggal Booking</th>
                                    <th>Total</th>
                                    <th>Status</th>
                                    <th>Aksi</th>
                                </tr>
                            </thead>
                            <tbody>
                                @forelse ($riwayatFoto as $rf)
                                    <tr>
                                        <td>{{ $rf->no_invoice }}</td>
                                        <td>{{ $rf->pelanggan->nama }}</td>
                                        <td>{{ $rf->paketFoto->nama }}</td>
                                        <td>{{ \Carbon\Carbon::parse($rf->tgl_booking)->translatedFormat('d M Y') }}</td>
                                        <td>Rp {{ number_format($rf->total_bayar, 0, ',', '.') }}</td>
                                        <td>
                                            <span class="badge {{ $rf->status_label->class }}">
                                                {{ $rf->status_label->text }}
                                            </span>
                                        </td>
                                        <td class="col-auto">
                                            <a href="#" class="btn icon btn-primary btn-action" data-bs-toggle="modal"
                                                data-bs-target="#riwayatFoto{{ $rf->id_booking }}">
                                                <i class="bi bi-eye"></i>
                                            </a>
                                        </td>
                                    </tr>
                                    @include('admin.pesanan.partials.modal-riwayat-foto')
                                @empty
                                    <tr>
                                        <td colspan="4" class="text-center text-muted">Belum ada data riwayat pesanan
                                            foto.</td>
                                    </tr>
                                @endforelse
                            </tbody>
                        </table>
                    </div>

                </div>
            </div>
        </div>

    </section>

@endsection
