<?php $__env->startSection('title', 'Kelola Permohonan Informasi - Admin PPID'); ?>

<?php $__env->startSection('content'); ?>
<div class="container">
    <div class="row mb-4">
        <div class="col-md-12">
            <div class="d-flex justify-content-between align-items-center">
                <div>
                    <h3 class="mb-1"><i class="bi bi-envelope-fill me-2"></i>Kelola Permohonan Informasi</h3>
                    <p class="text-muted mb-0">Manajemen permohonan informasi dari masyarakat</p>
                </div>
            </div>
        </div>
    </div>

    <?php if(session('success')): ?>
        <div class="alert alert-success alert-dismissible fade show shadow-sm" role="alert">
            <i class="bi bi-check-circle me-2"></i>
            <strong>Berhasil!</strong> <?php echo e(session('success')); ?>

            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        </div>
    <?php endif; ?>

    <?php if(session('error')): ?>
        <div class="alert alert-danger alert-dismissible fade show shadow-sm" role="alert">
            <i class="bi bi-exclamation-triangle me-2"></i>
            <strong>Error!</strong> <?php echo e(session('error')); ?>

            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        </div>
    <?php endif; ?>

    <!-- Filter -->
    <div class="card card-gov shadow-sm mb-3">
        <div class="card-body">
            <form action="<?php echo e(route('admin.ppid.permohonan.index')); ?>" method="GET" class="row g-3">
                <div class="col-md-4">
                    <label for="status" class="form-label">Filter Status</label>
                    <select class="form-select" id="status" name="status">
                        <option value="">Semua Status</option>
                        <option value="pending" <?php echo e(request('status') == 'pending' ? 'selected' : ''); ?>>Pending</option>
                        <option value="diproses" <?php echo e(request('status') == 'diproses' ? 'selected' : ''); ?>>Diproses</option>
                        <option value="disetujui" <?php echo e(request('status') == 'disetujui' ? 'selected' : ''); ?>>Disetujui</option>
                        <option value="ditolak" <?php echo e(request('status') == 'ditolak' ? 'selected' : ''); ?>>Ditolak</option>
                        <option value="keberatan" <?php echo e(request('status') == 'keberatan' ? 'selected' : ''); ?>>Keberatan</option>
                    </select>
                </div>
                <div class="col-md-6">
                    <label for="search" class="form-label">Cari</label>
                    <input type="text"
                           class="form-control"
                           id="search"
                           name="search"
                           value="<?php echo e(request('search')); ?>"
                           placeholder="Cari nama pemohon atau nomor registrasi...">
                </div>
                <div class="col-md-2 d-flex align-items-end">
                    <button type="submit" class="btn btn-gov-primary w-100">
                        <i class="bi bi-search me-1"></i> Filter
                    </button>
                </div>
            </form>
        </div>
    </div>

    <div class="card card-gov shadow-sm">
        <div class="card-header">
            <h5 class="mb-0"><i class="bi bi-list-ul me-2"></i>Daftar Permohonan</h5>
        </div>
        <div class="card-body">
            <?php if($permohonan->count() > 0): ?>
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead class="table-light">
                            <tr>
                                <th width="5%">No</th>
                                <th width="15%">No. Registrasi</th>
                                <th width="15%">Nama Pemohon</th>
                                <th width="25%">Informasi Dimohon</th>
                                <th width="12%">Tanggal</th>
                                <th width="13%">Status</th>
                                <th width="15%">Aksi</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $permohonan; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td><?php echo e($permohonan->firstItem() + $index); ?></td>
                                    <td>
                                        <strong class="text-primary"><?php echo e($item->nomor_registrasi); ?></strong>
                                    </td>
                                    <td>
                                        <?php echo e($item->nama_pemohon); ?>

                                        <br>
                                        <small class="text-muted">
                                            <i class="bi bi-envelope"></i> <?php echo e($item->email); ?>

                                        </small>
                                    </td>
                                    <td>
                                        <?php echo e(Str::limit($item->informasi_dimohon, 60)); ?>

                                    </td>
                                    <td>
                                        <?php echo e(\Carbon\Carbon::parse($item->tanggal_permohonan)->format('d/m/Y')); ?>

                                    </td>
                                    <td>
                                        <?php if($item->status == 'pending'): ?>
                                            <span class="badge bg-secondary">
                                                <i class="bi bi-clock"></i> Pending
                                            </span>
                                        <?php elseif($item->status == 'diproses'): ?>
                                            <span class="badge bg-info">
                                                <i class="bi bi-gear"></i> Diproses
                                            </span>
                                        <?php elseif($item->status == 'disetujui'): ?>
                                            <span class="badge bg-success">
                                                <i class="bi bi-check-circle"></i> Disetujui
                                            </span>
                                        <?php elseif($item->status == 'ditolak'): ?>
                                            <span class="badge bg-danger">
                                                <i class="bi bi-x-circle"></i> Ditolak
                                            </span>
                                        <?php elseif($item->status == 'keberatan'): ?>
                                            <span class="badge bg-warning">
                                                <i class="bi bi-exclamation-triangle"></i> Keberatan
                                            </span>
                                        <?php endif; ?>
                                    </td>
                                    <td>
                                        <div class="btn-group" role="group">
                                            <a href="<?php echo e(route('admin.ppid.permohonan.show', $item->id)); ?>"
                                               class="btn btn-sm btn-primary"
                                               title="Detail">
                                                <i class="bi bi-eye"></i>
                                            </a>
                                            <button type="button"
                                                    class="btn btn-sm btn-danger"
                                                    onclick="confirmDelete(<?php echo e($item->id); ?>)"
                                                    title="Hapus">
                                                <i class="bi bi-trash"></i>
                                            </button>
                                        </div>
                                        <form id="delete-form-<?php echo e($item->id); ?>"
                                              action="<?php echo e(route('admin.ppid.permohonan.destroy', $item->id)); ?>"
                                              method="POST"
                                              style="display: none;">
                                            <?php echo csrf_field(); ?>
                                            <?php echo method_field('DELETE'); ?>
                                        </form>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>

                <div class="d-flex justify-content-center mt-4">
                    <?php echo e($permohonan->appends(request()->query())->links()); ?>

                </div>
            <?php else: ?>
                <div class="text-center py-5">
                    <i class="bi bi-inbox" style="font-size: 3rem; color: #ccc;"></i>
                    <p class="text-muted mt-3">
                        <?php if(request('status') || request('search')): ?>
                            Tidak ada permohonan yang sesuai dengan filter
                        <?php else: ?>
                            Belum ada permohonan informasi
                        <?php endif; ?>
                    </p>
                    <?php if(request('status') || request('search')): ?>
                        <a href="<?php echo e(route('admin.ppid.permohonan.index')); ?>" class="btn btn-secondary mt-2">
                            <i class="bi bi-x-circle me-1"></i> Reset Filter
                        </a>
                    <?php endif; ?>
                </div>
            <?php endif; ?>
        </div>
    </div>
</div>

<?php $__env->startPush('scripts'); ?>
<script>
function confirmDelete(id) {
    if (confirm('Apakah Anda yakin ingin menghapus permohonan ini?')) {
        document.getElementById('delete-form-' + id).submit();
    }
}
</script>
<?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Users/user/Documents/giriwidyan/project/inhouse/skm/resources/views/admin/ppid/permohonan/index.blade.php ENDPATH**/ ?>