@extends('layouts.admin')

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

@section('content')
    {{-- ALERT SUKSES --}}
    @if (session('success'))
        <div class="alert alert-success alert-dismissible fade show" role="alert">
            {{ session('success') }}
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
    @endif

    {{-- ALERT ERROR UMUM (Jika ada error selain validasi modal) --}}
    @if (session('error'))
        <div class="alert alert-danger alert-dismissible fade show" role="alert">
            {{ session('error') }}
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
    @endif
    <section class="section">
        <div class="card">
            <div class="card-body">
                <table class="table table-striped" id="table1">
                    <thead>
                        <tr>
                            <th>No. Invoice</th>
                            <th>Nama Pelanggan</th>
                            <th>Nama Buket</th>
                            <th>Tanggal Ambil</th>
                            <th>Jam Ambil</th>
                            <th>Total</th>
                            <th>Status</th>
                            <th class="text-center">Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        @forelse ($pesanan as $p)
                            <tr>
                                <td>{{ $p->no_invoice }}</td>
                                <td>{{ $p->pelanggan->nama }}</td>
                                <td>{{ $p->buket->nama }}</td>
                                <td>
                                    {{ \Carbon\Carbon::parse($p->tgl_ambil)->locale('id')->translatedFormat('d F Y') }}
                                </td>
                                <td>
                                    {{ \Carbon\Carbon::parse($p->tgl_ambil)->format('H:i') }} WIB
                                </td>
                                <td>Rp {{ number_format($p->total_bayar, 0, ',', '.') }}</td>
                                <td>
                                    <span class="badge {{ $p->status_label->class }}">
                                        {{ $p->status_label->text }}
                                    </span>
                                </td>
                                <td class="text-center col-auto"><a href="#" class="btn icon btn-primary btn-action"
                                        data-bs-toggle="modal" data-bs-target="#buket{{ $p->id_transaksi }}">
                                        <i class="bi bi-eye"></i>
                                    </a>
                                </td>
                            </tr>
                            @include('admin.pesanan.partials.modal-buket')
                        @empty
                            <tr>
                                <td colspan="4" class="text-center text-muted">Belum ada data pesanan buket.</td>
                            </tr>
                        @endforelse
                    </tbody>
                </table>
            </div>
        </div>

    </section>

@endsection
