<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <title>Laporan Audit 5S</title>
    <style>
        body { font-family: "Times New Roman", Times, serif; font-size: 10px; margin: 15px; }
        .page { page-break-after: always; }
        .header { text-align: center; margin-bottom: 10px; }
        .header h2 { margin: 0; font-size: 14px; font-weight: bold; }
        .header p { margin: 0; font-size: 11px; }

        table { width: 100%; border-collapse: collapse; margin-bottom: 8px; table-layout: fixed; }
        td, th { border: 1px solid #000; padding: 3px; font-size: 9px; vertical-align: top; word-wrap: break-word; }
        th { text-align: center; background: #eee; }

        /* foto */
        .foto-cell {
            text-align: center;
            vertical-align: middle;
        }
        .foto {
            max-width: 90%;       /* supaya tidak mepet */
            max-height: 90px;     /* pas sampai kolom Status */
            object-fit: contain;  /* proporsi tetap */
        }

        /* status warna */
        .status-open { color: red; font-weight: bold; }
        .status-close { color: green; font-weight: bold; }

        /* A4 */
        @page { size: A4 portrait; margin: 15mm; }
        @media print { .page { page-break-after: always; } }
    </style>
</head>
<body>

<div class="header">
    <h2>LAPORAN AUDIT 5S</h2>
    <p>Periode: <?php echo e($periodeAwal); ?> s/d <?php echo e($periodeAkhir); ?></p>
</div>

<?php
    $chunks = $audits->chunk(5); // maksimal 5 audit per halaman
    $no = 1;
?>

<?php $__currentLoopData = $chunks; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $group): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<div class="page">
    <?php $__currentLoopData = $group; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $audit): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <table>
            <tr>
                <th style="width:20%;">No <?php echo e($no++); ?></th>
                <th style="width:40%;">Sebelum</th>
                <th style="width:40%;">Sesudah</th>
            </tr>
            <tr>
                <td><b>Divisi</b><br><?php echo e(optional($audit->bagian)->nama_bagian ?? '-'); ?></td>
                <td rowspan="4" class="foto-cell">
                    <?php if($audit->foto_sebelum): ?>
                        <img src="<?php echo e(public_path('storage/'.$audit->foto_sebelum)); ?>" class="foto">
                    <?php endif; ?>
                </td>
                <td rowspan="4" class="foto-cell">
                    <?php if($audit->foto_sesudah): ?>
                        <img src="<?php echo e(public_path('storage/'.$audit->foto_sesudah)); ?>" class="foto">
                    <?php endif; ?>
                </td>
            </tr>
            <tr><td><b>Tema</b><br><?php echo e(optional($audit->tema)->nama ?? '-'); ?></td></tr>
            <tr><td><b>Kategori</b><br><?php echo e($audit->kategori ?? '-'); ?></td></tr>
            <tr>
                <td><b>Status</b><br>
                    <?php if(strtolower($audit->status) == 'open'): ?>
                        <span class="status-open">Open</span>
                    <?php elseif(strtolower($audit->status) == 'close'): ?>
                        <span class="status-close">Close</span>
                    <?php else: ?>
                        <?php echo e(ucfirst($audit->status) ?? '-'); ?>

                    <?php endif; ?>
                </td>
            </tr>
            <tr>
                <td><b>Area Temuan</b><br><?php echo e($audit->lokasi ?? '-'); ?></td>
                <td><?php echo e($audit->keterangan ?? '-'); ?></td>
                <td><?php echo e($audit->keterangan_sesudah ?? '-'); ?></td>
            </tr>
        </table>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</div>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

</body>
</html>
<?php /**PATH C:\xampp\htdocs\ea-systems\resources\views/admin/exports/laporan-pdf.blade.php ENDPATH**/ ?>