<?php $__env->startSection('title', 'Riwayat Kunjungan Tamu'); ?>
<?php $__env->startSection('page-title', 'Riwayat Kunjungan Tamu'); ?>

<?php $__env->startSection('content'); ?>
    <!-- TOMBOL KEMBALI -->
    <div class="mb-4">
        <a
            href="<?php echo e(route('admin.tamu.index')); ?>"
            class="btn btn-light border shadow-sm"
        >
            <i class="bi bi-arrow-left me-2"></i> Kembali ke Daftar Tamu
        </a>
    </div>
    <!-- KARTU INFORMASI TAMU -->
    <div class="card border-0 shadow-sm mb-4">
        <div class="card-body p-4">
            <div class="d-flex align-items-center mb-4">
                <div
                    class="bg-primary text-white rounded-circle d-flex align-items-center justify-center me-3"
                    style="width: 50px; height: 50px"
                >
                    <i class="bi bi-person-fill fs-4 m-auto"></i>
                </div>
                <div>
                    <h5 class="fw-bold mb-0">Informasi Profil Tamu</h5>
                    <p
                        class="text-muted mb-0"
                        style="font-size: 0.9rem"
                    >Detail informasi tamu yang terdaftar di sistem</p>
                </div>
            </div>

            <div class="row g-4">
                <div class="col-md-3">
                    <p
                        class="text-muted mb-1"
                        style="font-size: 0.85rem"
                    >Nama Lengkap</p>
                    <p class="fw-semibold mb-0"><?php echo e($tamu->nama); ?></p>
                </div>
                <div class="col-md-3">
                    <p
                        class="text-muted mb-1"
                        style="font-size: 0.85rem"
                    >Instansi/Perusahaan</p>
                    <p class="fw-semibold mb-0"><?php echo e($tamu->instansi ?? '-'); ?></p>
                </div>
                <div class="col-md-3">
                    <p
                        class="text-muted mb-1"
                        style="font-size: 0.85rem"
                    >No. Handphone</p>
                    <p class="fw-semibold mb-0"><?php echo e($tamu->no_hp); ?></p>
                </div>
                <div class="col-md-3">
                    <p
                        class="text-muted mb-1"
                        style="font-size: 0.85rem"
                    >Alamat Email</p>
                    <p class="fw-semibold mb-0"><?php echo e($tamu->email); ?></p>
                </div>
            </div>
        </div>
    </div>
    <!-- KARTU TABEL RIWAYAT KUNJUNGAN -->
    <div class="card border-0 shadow-sm">
        <div
            class="card-header bg-white border-0 pt-4 pb-2 px-4 d-flex justify-content-between align-items-center"
        >
            <div>
                <h5 class="fw-bold mb-1">Riwayat Kunjungan</h5>
                <p
                    class="text-muted mb-0"
                    style="font-size: 0.9rem"
                >Daftar seluruh agenda kunjungan yang pernah diajukan oleh tamu ini.</p>
            </div>
            <div>
                <span class="badge bg-light text-secondary border px-3 py-2">
                    Total: <?php echo e($riwayatKunjungan->count()); ?> Kunjungan
                </span>
            </div>
        </div>

        <div class="card-body p-0 mt-2">
            <div class="table-responsive">
                <table class="table table-hover align-middle mb-0">
                    <thead class="table-light">
                        <tr>
                            <th class="px-4">#</th>
                            <th>No. Antrian</th>
                            <th>Tanggal & Waktu</th>
                            <th>Tujuan Bidang</th>
                            <th>Keperluan</th>
                            <th class="text-center">Status</th>
                            <th class="text-center px-4">Aksi</th>
                        </tr>
                    </thead>

                    <tbody>
                        <?php $__empty_1 = true; $__currentLoopData = $riwayatKunjungan; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $k): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td class="px-4 text-muted"><?php echo e($i + 1); ?></td>

                                <td>
                                    <span
                                        class="badge bg-light text-primary border px-2 py-1"
                                    >
                                        <?php echo e($k->nomor_antrian); ?>

                                    </span>
                                </td>

                                <td>
                                    <div class="fw-semibold text-dark">
                                        <?php echo e(\Carbon\Carbon::parse($k->tanggal_kunjungan)->format('d M Y')); ?>

                                    </div>
                                    <small class="text-muted">
                                        <i class="bi bi-clock me-1"></i>
                                        <?php echo e(substr($k->jam_masuk, 0, 5)); ?> WIB
                                    </small>
                                </td>

                                <td>
                                    <div class="fw-semibold text-dark">
                                        <?php echo e($k->bidang->nama_bidang ?? '-'); ?>

                                    </div>
                                    <small
                                        class="text-muted"
                                        ><?php echo e($k->subbagian->nama_subbagian ?? '-'); ?></small
                                    >
                                </td>

                                <td>
                                    <span
                                        class="text-truncate d-inline-block"
                                        style="max-width: 200px"
                                        title="<?php echo e($k->keperluan); ?>"
                                    >
                                        <?php echo e($k->keperluan); ?>

                                    </span>
                                </td>

                                 <td class="text-center">
                                     <?php if($k->status_kunjungan === 'diterima'): ?>
                                         <?php if($k->is_served): ?>
                                             <span
                                                 class="badge bg-success text-white border border-success px-3 py-2 rounded-pill"
                                             >
                                                 <i
                                                     class="bi bi-check-circle-fill me-1"
                                                 ></i>
                                                 Selesai Dilayani
                                             </span>
                                         <?php else: ?>
                                             <span
                                                 class="badge bg-success bg-opacity-10 text-success border border-success border-opacity-25 px-3 py-2 rounded-pill"
                                             >
                                                 <i
                                                     class="bi bi-check-circle-fill me-1"
                                                 ></i>
                                                 Diterima
                                             </span>
                                         <?php endif; ?>
                                     <?php elseif($k->status_kunjungan === 'ditolak'): ?>
                                         <span
                                             class="badge bg-danger bg-opacity-10 text-danger border border-danger border-opacity-25 px-3 py-2 rounded-pill"
                                         >
                                             <i
                                                 class="bi bi-x-circle-fill me-1"
                                             ></i>
                                             Ditolak
                                         </span>
                                     <?php else: ?>
                                         <span
                                             class="badge bg-warning bg-opacity-10 text-warning border border-warning border-opacity-25 px-3 py-2 rounded-pill"
                                         >
                                             <i
                                                 class="bi bi-hourglass-split me-1"
                                             ></i>
                                             Pending
                                         </span>
                                     <?php endif; ?>
                                 </td>

                                 <td class="text-center px-4">
                                     <div class="d-flex gap-2 justify-content-center align-items-center">
                                         <?php if($k->status_kunjungan === 'diterima' && !$k->is_served): ?>
                                             <form
                                                 action="<?php echo e(route('admin.kunjungan.selesai', $k->id_kunjungan)); ?>"
                                                 method="POST"
                                                 onsubmit="
                                                     return confirm(
                                                         'Apakah Anda yakin ingin menyelesaikan kunjungan ini?',
                                                     );
                                                 "
                                                 class="m-0"
                                             >
                                                 <?php echo csrf_field(); ?>
                                                 <button
                                                     class="btn btn-sm btn-success"
                                                     title="Selesai Dilayani"
                                                 >
                                                     <i class="bi bi-check-lg"></i> Selesai
                                                 </button>
                                             </form>
                                         <?php endif; ?>
                                         <a
                                             href="<?php echo e(route('admin.kunjungan.detail', $k->id_kunjungan)); ?>"
                                             class="btn btn-sm btn-outline-primary"
                                         >
                                             <i class="bi bi-eye me-1"></i> Detail
                                         </a>
                                     </div>
                                 </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="7" class="text-center py-5">
                                    <div
                                        class="d-flex flex-column align-items-center"
                                    >
                                        <i
                                            class="bi bi-calendar-x fs-1 text-secondary mb-3"
                                        ></i>
                                        <h5 class="fw-bold text-secondary">
                                            Belum Ada Riwayat
                                        </h5>
                                        <p class="text-muted mb-0">Tamu ini belum pernah melakukan pendaftaran kunjungan.</p>
                                    </div>
                                </td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/evo/Downloads/buku-tamu-ksop/resources/views/admin/tamu/riwayat.blade.php ENDPATH**/ ?>