@extends('layouts.admin')

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

@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 Paket</th>
                            <th>Tanggal Booking</th>
                            <th>Waktu</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->paketFoto->nama }}</td>
                                <td>
                                    {{ \Carbon\Carbon::parse($p->tgl_booking)->locale('id')->translatedFormat('d F Y') }}
                                </td>
                                <td>
                                    {{ \Carbon\Carbon::parse($p->jam_mulai)->format('H:i') }} -
                                    {{ \Carbon\Carbon::parse($p->jam_selesai)->format('H:i') }}
                                </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="#foto{{ $p->id_booking }}">
                                        <i class="bi bi-eye"></i>
                                    </a>
                                </td>
                            </tr>
                            @include('admin.pesanan.partials.modal-foto')
                        @empty
                            <tr>
                                <td colspan="4" class="text-center text-muted">Belum ada data pesanan foto.</td>
                            </tr>
                        @endforelse
                    </tbody>
                </table>
            </div>
        </div>

    </section>
    {{-- @include('admin.pesanan.partials.modal-foto') --}}

@endsection
