<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <title>Laporan SKM - <?php echo e($opd->name); ?></title>
    <style>
        body {
            font-family: Arial, sans-serif;
            font-size: 12px;
        }
        .header {
            text-align: center;
            margin-bottom: 30px;
            border-bottom: 2px solid #333;
            padding-bottom: 20px;
        }
        .header h1 {
            margin: 0;
            font-size: 24px;
        }
        .header h2 {
            margin: 10px 0;
            font-size: 18px;
            color: #666;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: left;
        }
        th {
            background-color: #0d6efd;
            color: white;
            font-weight: bold;
        }
        tr:nth-child(even) {
            background-color: #f2f2f2;
        }
        .summary {
            margin-top: 30px;
            padding: 15px;
            background-color: #f8f9fa;
            border-radius: 5px;
        }
        .footer {
            margin-top: 30px;
            text-align: center;
            font-size: 10px;
            color: #666;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>LAPORAN SURVEY KEPUASAN MASYARAKAT (SKM)</h1>
        <h2><?php echo e($opd->name); ?></h2>
        <p>Periode: <?php echo e(now()->format('d F Y')); ?></p>
        <?php if(isset($skmData)): ?>
        <div style="margin-top: 15px;">
            <p style="font-size: 16px; font-weight: bold;">
                Nilai SKM: <?php echo e($skmData['skm_value']); ?> | 
                Kualitas Pelayanan: 
                <?php if($skmData['service_quality'] == 'A'): ?>
                    A (Sangat Baik)
                <?php elseif($skmData['service_quality'] == 'B'): ?>
                    B (Baik)
                <?php elseif($skmData['service_quality'] == 'C'): ?>
                    C (Kurang Baik)
                <?php else: ?>
                    D (Tidak Baik)
                <?php endif; ?>
            </p>
        </div>
        <?php endif; ?>
    </div>

    <table>
        <thead>
            <tr>
                <th>No</th>
                <th>Kode</th>
                <th>Elemen</th>
                <th>Pertanyaan</th>
                <th>Total Response</th>
                <th>Rata-rata Score</th>
                <th>Rata-rata Weighted</th>
                <th>Distribusi Jawaban</th>
            </tr>
        </thead>
        <tbody>
            <?php $__currentLoopData = $results; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $result): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                    <td><?php echo e($index + 1); ?></td>
                    <td><?php echo e($result['question']->code); ?></td>
                    <td><?php echo e($result['question']->element); ?></td>
                    <td><?php echo e($result['question']->question); ?></td>
                    <td><?php echo e($result['stats']['total']); ?></td>
                    <td><?php echo e(number_format($result['stats']['average_score'], 2)); ?></td>
                    <td><?php echo e(number_format($result['stats']['average_weighted_score'], 2)); ?></td>
                    <td>
                        <?php $__currentLoopData = $result['distribution']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dist): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <?php echo e($dist['option']->label); ?>: <?php echo e($dist['count']); ?>;
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </tbody>
    </table>

    <?php if(isset($elementStats) && count($elementStats) > 0): ?>
    <table style="margin-top: 20px;">
        <thead>
            <tr>
                <th>Elemen</th>
                <th>Rata-rata Weighted Score</th>
                <th>Total Response</th>
                <th>Jumlah Pertanyaan</th>
            </tr>
        </thead>
        <tbody>
            <?php $__currentLoopData = $elementStats; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $element => $stats): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                    <td><strong><?php echo e($element); ?></strong></td>
                    <td><?php echo e(number_format($stats['average'], 2)); ?></td>
                    <td><?php echo e($stats['total_responses']); ?></td>
                    <td><?php echo e($stats['question_count']); ?></td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </tbody>
    </table>
    <?php endif; ?>

    <div class="summary">
        <h3>Ringkasan</h3>
        <p><strong>Total Pertanyaan:</strong> <?php echo e(count($results)); ?></p>
        <?php if(isset($skmData)): ?>
        <p><strong>Total Response:</strong> <?php echo e($skmData['total_responses']); ?></p>
        <p><strong>Nilai SKM:</strong> <?php echo e($skmData['skm_value']); ?></p>
        <p><strong>Kualitas Pelayanan:</strong> 
            <?php if($skmData['service_quality'] == 'A'): ?>
                A (Sangat Baik)
            <?php elseif($skmData['service_quality'] == 'B'): ?>
                B (Baik)
            <?php elseif($skmData['service_quality'] == 'C'): ?>
                C (Kurang Baik)
            <?php else: ?>
                D (Tidak Baik)
            <?php endif; ?>
        </p>
        <?php endif; ?>
    </div>

    <div class="footer">
        <p>Dicetak pada: <?php echo e(now()->format('d F Y H:i:s')); ?></p>
        <p>SKM Survey System</p>
    </div>
</body>
</html>

<?php /**PATH /Users/user/Documents/giriwidyan/project/inhouse/skm/resources/views/admin/pdf-report.blade.php ENDPATH**/ ?>