

<?php $__env->startSection('styles'); ?>
<link rel="stylesheet" href="<?php echo e(asset('css/penyuluh.css')); ?>">
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>

<div class="page-wrapper">

    
    <div class="page-header">
        <div>
            <h2 class="page-title">📋 Validasi Laporan</h2>
            <p class="page-sub">Laporan masuk menunggu persetujuan penyuluh</p>
        </div>
        <div class="header-badge">
            <?php echo e($laporan->count()); ?> Menunggu
        </div>
    </div>

    
    <div class="table-card">

        
        <div class="table-topbar">
            <input type="text" id="searchInput" placeholder="🔍 Cari petani atau hama..." oninput="filterTable()">
        </div>

        <div class="table-scroll">
            <table class="data-table" id="mainTable">
                <thead>
                    <tr>
                        <th>Petani</th>
                        <th>Hama</th>
                        <th>Tanggal</th>
                        <th>Status</th>
                        <th>Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $laporan; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr class="data-row">
                        <td>
                            <div class="petani-name"><?php echo e($item->nama_petani); ?></div>
                            <div class="petani-loc"><?php echo e($item->lokasi ?? '-'); ?></div>
                        </td>
                        <td>
                            <span class="hama-tag"><?php echo e($item->jenis_hama); ?></span>
                        </td>
                        <td class="date-cell">
                            <?php echo e($item->created_at->format('d M Y')); ?>

                        </td>
                        <td>
                            <span class="status-badge
                                <?php if($item->status == 'menunggu_validasi'): ?> s-waiting
                                <?php elseif($item->status == 'menunggu'): ?> s-info
                                <?php elseif($item->status == 'diproses'): ?> s-process
                                <?php elseif($item->status == 'selesai'): ?> s-success
                                <?php elseif($item->status == 'ditolak'): ?> s-danger
                                <?php endif; ?>">
                                <?php echo e(str_replace('_',' ', $item->status)); ?>

                            </span>
                        </td>
                        <td>
                            <div class="action-group">
                                <a href="<?php echo e(url('/lapor/'.$item->id)); ?>" class="btn-sm btn-detail">
                                    🔍 Detail
                                </a>
                                <?php if($item->status == 'menunggu_validasi'): ?>
                                <button onclick="openModal(<?php echo e($item->id); ?>)" class="btn-sm btn-validasi">
                                    ✔ Validasi
                                </button>
                                <button onclick="openModalTolak(<?php echo e($item->id); ?>)" class="btn-sm btn-tolak">
                                    ✕ Tolak
                                </button>
                                <?php endif; ?>
                            </div>
                        </td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="5" class="empty-cell">
                            <div class="empty-state">
                                <span>📭</span>
                                <p>Tidak ada laporan yang menunggu validasi</p>
                            </div>
                        </td>
                    </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>

    </div>

</div>


<div id="modalValidasi" class="modal-overlay">
    <div class="modal-box">
        <div class="modal-icon">✅</div>
        <h3>Konfirmasi Validasi</h3>
        <p>Laporan ini akan divalidasi dan masuk antrian penanganan.</p>
        <div class="modal-actions">
            <button onclick="closeModal()" class="btn-cancel">Batal</button>
            <form id="formValidasi" method="POST">
                <?php echo csrf_field(); ?>
                <button type="submit" class="btn-confirm">Ya, Validasi</button>
            </form>
        </div>
    </div>
</div>


<div id="modalTolak" class="modal-overlay">
    <div class="modal-box">
        <div class="modal-icon danger">❌</div>
        <h3>Tolak Laporan</h3>
        <p>Laporan ini akan ditolak dan tidak diproses lebih lanjut.</p>
        <div class="modal-actions">
            <button onclick="closeModalTolak()" class="btn-cancel">Batal</button>
            <form id="formTolak" method="POST">
                <?php echo csrf_field(); ?>
                <button type="submit" class="btn-danger-confirm">Ya, Tolak</button>
            </form>
        </div>
    </div>
</div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
<script>
function openModal(id){
    document.getElementById('formValidasi').action = "/lapor/"+id+"/validasi";
    document.getElementById('modalValidasi').classList.add('active');
    document.body.style.overflow = 'hidden';
}
function closeModal(){
    document.getElementById('modalValidasi').classList.remove('active');
    document.body.style.overflow = '';
}
function openModalTolak(id){
    document.getElementById('formTolak').action = "/lapor/"+id+"/tolak";
    document.getElementById('modalTolak').classList.add('active');
    document.body.style.overflow = 'hidden';
}
function closeModalTolak(){
    document.getElementById('modalTolak').classList.remove('active');
    document.body.style.overflow = '';
}
// Tutup modal klik luar
document.querySelectorAll('.modal-overlay').forEach(m => {
    m.addEventListener('click', e => {
        if(e.target === m){ m.classList.remove('active'); document.body.style.overflow=''; }
    });
});
// Search filter
function filterTable(){
    const q = document.getElementById('searchInput').value.toLowerCase();
    document.querySelectorAll('#mainTable tbody .data-row').forEach(row => {
        row.style.display = row.innerText.toLowerCase().includes(q) ? '' : 'none';
    });
}
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\Maylha\pelaporanpertanian\resources\views/penyuluh/dashboard.blade.php ENDPATH**/ ?>