403Webshell
Server IP : 127.0.0.1  /  Your IP : 192.168.99.1
Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9
System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64
User : Administrator ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /bpkd/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /bpkd//satudata2.php
<?php
require_once 'includes/config.php';
require_once 'includes/init.php';
require_once 'includes/tokenkab.php';

$page_title = 'Katalog Dataset - ' . ($settings['site_title'] ?? 'Website Instansi');
$meta_description = 'Temukan data dan informasi publik dari berbagai instansi di Kabupaten Lumajang.';

// Load konfigurasi API
$config = include 'includes/tokenkab.php';

// Fungsi helper untuk fetch API dengan caching
function fetchApi($url, $token, $cacheKey, $ttl = 3600) {
    $cacheDir = __DIR__ . '/cache';
    $cacheFile = $cacheDir . '/' . md5($cacheKey) . '.json';
    
    if (!is_dir($cacheDir)) {
        mkdir($cacheDir, 0755, true);
    }
    
    if (file_exists($cacheFile) && (time() - filemtime($cacheFile)) < $ttl) {
        return json_decode(file_get_contents($cacheFile), true);
    }
    
    $ch = curl_init();
    curl_setopt_array($ch, [
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_TIMEOUT => 10,
        CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_HTTPHEADER => [
            'Authorization: Bearer ' . $token,
            'Accept: application/json',
            'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)'
        ]
    ]);
    
    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $error = curl_error($ch);
    curl_close($ch);
    
    if ($error || $httpCode !== 200) {
        error_log("Satu Data API Error: " . ($error ?: $httpCode));
        return null;
    }
    
    $data = json_decode($response, true);
    if ($data) {
        file_put_contents($cacheFile, json_encode($data));
    }
    
    return $data;
}

$opdCode = $config['opd_code'];
$baseUrl = $config['api_url'];
$token = $config['api_token'];

// Ambil parameter
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$search = isset($_GET['search']) ? $_GET['search'] : '';
$urusanFilter = isset($_GET['urusan_id']) ? (int)$_GET['urusan_id'] : 0;
$statusFilter = isset($_GET['status']) ? $_GET['status'] : '';
$perPage = isset($_GET['per_page']) ? (int)$_GET['per_page'] : 10;

// 1. Ambil daftar Urusan untuk filter
$urusanData = fetchApi(
    $baseUrl . '/urusan?skpd_code=' . $opdCode,
    $token,
    'urusan_' . $opdCode,
    86400
);
$urusans = $urusanData['data'] ?? [];

// 2. Ambil daftar DSSD
$params = [
    'skpd_code' => $opdCode,
    'page' => $page,
    'per_page' => $perPage
];
if ($search) $params['q'] = $search;
if ($urusanFilter) $params['urusan_id'] = $urusanFilter;

$dssdData = fetchApi(
    $baseUrl . '/dssd?' . http_build_query($params),
    $token,
    'dssd_' . md5(serialize($params)),
    3600
);
$dssdList = $dssdData['data'] ?? [];
$pagination = $dssdData['metadata'] ?? ['page' => 1, 'total_page' => 1, 'total_data' => 0];
$totalData = $pagination['total_data'] ?? 0;
$currentPage = $pagination['page'] ?? 1;
$totalPage = $pagination['total_page'] ?? 1;

// 3. Ambil detail DSSD jika ada parameter dssd_id
$dssdDetail = null;
$detailId = isset($_GET['dssd_id']) ? $_GET['dssd_id'] : '';
if ($detailId) {
    $detailData = fetchApi(
        $baseUrl . '/dssd/detail/' . urlencode($detailId),
        $token,
        'dssd_detail_' . $detailId,
        3600
    );
    $dssdDetail = $detailData['data'] ?? null;
}

// 4. Ambil data untuk dashboard (statistik ringkasan)
$allDssdParams = ['skpd_code' => $opdCode, 'per_page' => 100];
$allDssdData = fetchApi(
    $baseUrl . '/dssd?' . http_build_query($allDssdParams),
    $token,
    'dssd_all_' . $opdCode,
    3600
);
$allDssdList = $allDssdData['data'] ?? [];

// Statistik
$totalIndikator = count($allDssdList);
$aktifCount = 0;
$urusanCount = [];
foreach ($allDssdList as $d) {
    if (($d['status'] ?? '') == 'AKTIF') $aktifCount++;
    $urusan = $d['bidangurusan'] ?? 'Lainnya';
    if (!isset($urusanCount[$urusan])) $urusanCount[$urusan] = 0;
    $urusanCount[$urusan]++;
}
$topUrusan = !empty($urusanCount) ? array_keys($urusanCount, max($urusanCount))[0] : '-';
$topUrusanCount = !empty($urusanCount) ? max($urusanCount) : 0;

// Fungsi untuk menentukan warna status
function getStatusBadge($status) {
    $status = strtoupper($status);
    if ($status == 'AKTIF') return 'badge-success';
    if ($status == 'TIDAK AKTIF') return 'badge-danger';
    if ($status == 'DALAM REVISI') return 'badge-warning';
    return 'badge-secondary';
}

// Fungsi untuk parse nilai chart
function parseChartValue($val) {
    if ($val === '-' || $val === null || $val === '') return null;
    if (is_string($val)) {
        $val = str_replace(',', '', $val);
        if (is_numeric($val)) return (float)$val;
    }
    return $val;
}
?>
<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DSSD - Data Strategis Sektoral Daerah Lumajang</title>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            background: #f5f7fa;
            color: #1e293b;
            padding: 24px;
            line-height: 1.6;
        }
        .container {
            max-width: 1100px;
            margin: 0 auto;
        }

        /* Header */
        .page-header {
            margin-bottom: 32px;
        }
        .page-header h1 {
            font-size: 28px;
            font-weight: 700;
            color: #0f172a;
            letter-spacing: -0.5px;
        }
        .page-header h1 span {
            color: #2563eb;
        }
        .page-header p {
            color: #64748b;
            font-size: 15px;
            margin-top: 4px;
        }

        /* Stats Cards */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
            gap: 16px;
            margin-bottom: 24px;
        }
        .stat-card {
            background: white;
            padding: 18px 20px;
            border-radius: 12px;
            border: 1px solid #e2e8f0;
            box-shadow: 0 1px 3px rgba(0,0,0,0.04);
            transition: border-color 0.2s;
        }
        .stat-card:hover {
            border-color: #94a3b8;
        }
        .stat-card .number {
            font-size: 26px;
            font-weight: 700;
            color: #0f172a;
        }
        .stat-card .number.blue { color: #2563eb; }
        .stat-card .number.green { color: #16a34a; }
        .stat-card .number.orange { color: #d97706; }
        .stat-card .number.purple { color: #9333ea; }
        .stat-card .label {
            font-size: 13px;
            color: #64748b;
            margin-top: 2px;
        }
        .stat-card .sub {
            font-size: 12px;
            color: #94a3b8;
            margin-top: 2px;
        }

        /* Filter Bar */
        .filter-bar {
            display: flex;
            flex-wrap: wrap;
            gap: 12px;
            align-items: center;
            background: white;
            padding: 16px 20px;
            border-radius: 12px;
            border: 1px solid #e2e8f0;
            margin-bottom: 24px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.04);
        }
        .filter-bar .search-wrapper {
            flex: 1;
            min-width: 200px;
            position: relative;
        }
        .filter-bar .search-wrapper input {
            width: 100%;
            padding: 10px 16px 10px 40px;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            font-size: 14px;
            background: #f8fafc;
            transition: border-color 0.2s, box-shadow 0.2s;
        }
        .filter-bar .search-wrapper input:focus {
            outline: none;
            border-color: #2563eb;
            box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
            background: white;
        }
        .filter-bar .search-wrapper .icon {
            position: absolute;
            left: 14px;
            top: 50%;
            transform: translateY(-50%);
            color: #94a3b8;
            font-size: 16px;
            pointer-events: none;
        }
        .filter-bar select {
            padding: 10px 16px;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            font-size: 14px;
            background: #f8fafc;
            color: #1e293b;
            min-width: 140px;
            cursor: pointer;
            transition: border-color 0.2s;
        }
        .filter-bar select:focus {
            outline: none;
            border-color: #2563eb;
            box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
        }
        .filter-bar .btn {
            padding: 10px 24px;
            background: #2563eb;
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: background 0.2s;
        }
        .filter-bar .btn:hover {
            background: #1d4ed8;
        }
        .filter-bar .btn-outline {
            background: transparent;
            color: #64748b;
            border: 1px solid #e2e8f0;
            padding: 9px 20px;
        }
        .filter-bar .btn-outline:hover {
            background: #f1f5f9;
        }

        /* Stats Info */
        .stats-info {
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 8px;
            margin-bottom: 20px;
            font-size: 14px;
            color: #64748b;
        }
        .stats-info .count {
            font-weight: 600;
            color: #0f172a;
        }

        /* Badge */
        .badge {
            display: inline-block;
            padding: 2px 12px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: 500;
        }
        .badge-success {
            background: #d1fae5;
            color: #065f46;
        }
        .badge-danger {
            background: #fecaca;
            color: #991b1b;
        }
        .badge-warning {
            background: #fef3c7;
            color: #92400e;
        }
        .badge-secondary {
            background: #e2e8f0;
            color: #475569;
        }
        .badge-blue {
            background: #dbeafe;
            color: #1d4ed8;
        }
        .badge-purple {
            background: #ede9fe;
            color: #6d28d9;
        }

        /* DSSD Grid */
        .dssd-grid {
            display: grid;
            grid-template-columns: 1fr;
            gap: 12px;
        }
        .dssd-item {
            background: white;
            border-radius: 12px;
            border: 1px solid #e2e8f0;
            padding: 18px 24px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            transition: border-color 0.2s, box-shadow 0.2s;
            box-shadow: 0 1px 3px rgba(0,0,0,0.04);
        }
        .dssd-item:hover {
            border-color: #94a3b8;
            box-shadow: 0 4px 12px rgba(0,0,0,0.06);
        }
        .dssd-item .info {
            flex: 1;
            min-width: 0;
        }
        .dssd-item .info .title {
            font-size: 16px;
            font-weight: 600;
            color: #0f172a;
            margin-bottom: 2px;
        }
        .dssd-item .info .title a {
            color: #0f172a;
            text-decoration: none;
            transition: color 0.2s;
        }
        .dssd-item .info .title a:hover {
            color: #2563eb;
        }
        .dssd-item .info .desc {
            font-size: 14px;
            color: #94a3b8;
            margin-bottom: 4px;
        }
        .dssd-item .info .meta {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            font-size: 13px;
            color: #94a3b8;
            align-items: center;
        }
        .dssd-item .info .meta span {
            display: inline-flex;
            align-items: center;
            gap: 4px;
        }
        .dssd-item .actions {
            display: flex;
            align-items: center;
            gap: 12px;
            flex-shrink: 0;
            margin-left: 16px;
        }
        .dssd-item .actions .btn-detail {
            padding: 6px 18px;
            background: #2563eb;
            color: white;
            border: none;
            border-radius: 6px;
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            transition: background 0.2s;
            text-decoration: none;
        }
        .dssd-item .actions .btn-detail:hover {
            background: #1d4ed8;
        }
        .dssd-item .actions .kode {
            font-size: 13px;
            color: #64748b;
            font-family: monospace;
            white-space: nowrap;
        }
        @media (max-width: 640px) {
            .dssd-item {
                flex-direction: column;
                align-items: flex-start;
                gap: 12px;
                padding: 16px;
            }
            .dssd-item .actions {
                margin-left: 0;
                width: 100%;
                justify-content: flex-start;
            }
            .filter-bar {
                flex-direction: column;
                align-items: stretch;
            }
            .filter-bar .search-wrapper {
                min-width: unset;
            }
            .filter-bar select {
                min-width: unset;
            }
            .stats-info {
                flex-direction: column;
                align-items: flex-start;
            }
            .stats-grid {
                grid-template-columns: repeat(2, 1fr);
            }
        }

        /* Pagination */
        .pagination-wrapper {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 6px;
            margin-top: 28px;
            flex-wrap: wrap;
        }
        .pagination-wrapper a {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 40px;
            height: 40px;
            padding: 0 12px;
            border-radius: 8px;
            border: 1px solid #e2e8f0;
            background: white;
            color: #1e293b;
            text-decoration: none;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.2s;
        }
        .pagination-wrapper a:hover {
            background: #f1f5f9;
            border-color: #94a3b8;
        }
        .pagination-wrapper a.active {
            background: #2563eb;
            color: white;
            border-color: #2563eb;
        }
        .pagination-wrapper a.active:hover {
            background: #1d4ed8;
        }
        .pagination-wrapper a.disabled {
            opacity: 0.4;
            pointer-events: none;
        }

        /* Detail View */
        .detail-view {
            background: white;
            border-radius: 12px;
            border: 1px solid #e2e8f0;
            padding: 28px 32px;
            margin-bottom: 24px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.04);
        }
        .detail-view .back-link {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            color: #2563eb;
            text-decoration: none;
            font-weight: 500;
            font-size: 14px;
            margin-bottom: 16px;
        }
        .detail-view .back-link:hover {
            text-decoration: underline;
        }
        .detail-view .detail-title {
            font-size: 24px;
            font-weight: 700;
            color: #0f172a;
            margin-bottom: 4px;
        }
        .detail-view .detail-sub {
            color: #64748b;
            font-size: 14px;
            margin-bottom: 4px;
        }
        .detail-view .detail-kode {
            font-family: monospace;
            color: #94a3b8;
            font-size: 13px;
            margin-bottom: 12px;
        }
        .detail-view .detail-meta {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
            gap: 12px;
            padding: 16px;
            background: #f8fafc;
            border-radius: 8px;
            margin-bottom: 20px;
        }
        .detail-view .detail-meta .item .label {
            font-size: 12px;
            color: #94a3b8;
            text-transform: uppercase;
            letter-spacing: 0.3px;
        }
        .detail-view .detail-meta .item .value {
            font-weight: 600;
            color: #0f172a;
        }
        .detail-view .chart-container {
            position: relative;
            height: 300px;
            max-width: 700px;
            margin: 20px auto;
        }
        .detail-view .table-wrap {
            overflow-x: auto;
            margin-top: 16px;
        }
        .detail-view table {
            width: 100%;
            border-collapse: collapse;
            font-size: 14px;
        }
        .detail-view table th {
            text-align: left;
            padding: 10px 14px;
            background: #f1f5f9;
            font-weight: 600;
            color: #475569;
            border-bottom: 2px solid #e2e8f0;
        }
        .detail-view table td {
            padding: 10px 14px;
            border-bottom: 1px solid #f1f5f9;
        }
        .detail-view table tr:hover td {
            background: #fafbfc;
        }

        /* Empty state */
        .empty-state {
            text-align: center;
            padding: 40px 20px;
            color: #94a3b8;
        }
        .empty-state .icon {
            font-size: 48px;
            margin-bottom: 12px;
            opacity: 0.6;
        }

        /* Per page selector */
        .per-page-selector {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 14px;
            color: #64748b;
        }
        .per-page-selector select {
            padding: 6px 10px;
            border: 1px solid #e2e8f0;
            border-radius: 6px;
            font-size: 13px;
            background: white;
            cursor: pointer;
        }

        /* Footer */
        .footer {
            text-align: center;
            padding: 24px 0 8px;
            color: #94a3b8;
            font-size: 13px;
            border-top: 1px solid #e2e8f0;
            margin-top: 32px;
        }
        .footer a {
            color: #2563eb;
            text-decoration: none;
        }
    </style>
</head>
<body>
<div class="container">

    <!-- ===== HEADER ===== -->
    <div class="page-header">
        <h1>📈 Data Strategis <span>Sektoral Daerah</span></h1>
        <p>Kumpulan indikator kinerja utama dan data strategis pembangunan Kabupaten Lumajang.</p>
    </div>

    <!-- ===== STATS CARDS ===== -->
    <div class="stats-grid">
        <div class="stat-card">
            <div class="number blue"><?php echo number_format($totalIndikator); ?></div>
            <div class="label">Total Indikator</div>
            <div class="sub">Seluruh bidang urusan</div>
        </div>
        <div class="stat-card">
            <div class="number green"><?php echo number_format($aktifCount); ?></div>
            <div class="label">Indikator Aktif</div>
            <div class="sub"><?php echo $totalIndikator > 0 ? round(($aktifCount / $totalIndikator) * 100) : 0; ?>% dari total</div>
        </div>
        <div class="stat-card">
            <div class="number orange"><?php echo number_format($totalIndikator - $aktifCount); ?></div>
            <div class="label">Indikator Non-Aktif</div>
            <div class="sub">Perlu perhatian</div>
        </div>
        <div class="stat-card">
            <div class="number purple"><?php echo htmlspecialchars($topUrusan); ?></div>
            <div class="label">Bidang Terbanyak</div>
            <div class="sub"><?php echo number_format($topUrusanCount); ?> indikator</div>
        </div>
    </div>

    <!-- ===== FILTER BAR ===== -->
    <form method="GET" class="filter-bar">
        <div class="search-wrapper">
            <span class="icon">🔍</span>
            <input type="text" name="search" placeholder="Cari indikator..." 
                   value="<?php echo htmlspecialchars($search); ?>">
        </div>
        <select name="urusan_id">
            <option value="0">Semua Bidang</option>
            <?php foreach ($urusans as $urusan): ?>
            <option value="<?php echo $urusan['id']; ?>" 
                <?php echo ($urusanFilter == $urusan['id']) ? 'selected' : ''; ?>>
                <?php echo htmlspecialchars($urusan['nama_urusan']); ?>
            </option>
            <?php endforeach; ?>
        </select>
        <select name="status">
            <option value="">Semua Status</option>
            <option value="AKTIF" <?php echo $statusFilter == 'AKTIF' ? 'selected' : ''; ?>>Aktif</option>
            <option value="TIDAK AKTIF" <?php echo $statusFilter == 'TIDAK AKTIF' ? 'selected' : ''; ?>>Tidak Aktif</option>
            <option value="DALAM REVISI" <?php echo $statusFilter == 'DALAM REVISI' ? 'selected' : ''; ?>>Dalam Revisi</option>
        </select>
        <select name="per_page">
            <option value="10" <?php echo $perPage == 10 ? 'selected' : ''; ?>>10 Data</option>
            <option value="25" <?php echo $perPage == 25 ? 'selected' : ''; ?>>25 Data</option>
            <option value="50" <?php echo $perPage == 50 ? 'selected' : ''; ?>>50 Data</option>
        </select>
        <button type="submit" class="btn">Cari</button>
        <?php if ($search || $urusanFilter || $statusFilter): ?>
        <a href="dssd.php" class="btn btn-outline">Reset</a>
        <?php endif; ?>
    </form>

    <!-- ===== DETAIL VIEW ===== -->
    <?php if ($detailId && $dssdDetail): ?>
    <div class="detail-view">
        <a href="dssd.php" class="back-link">← Kembali ke daftar</a>
        
        <div class="detail-title"><?php echo htmlspecialchars($dssdDetail['title'] ?? 'Detail DSSD'); ?></div>
        <div class="detail-sub"><?php echo htmlspecialchars($dssdDetail['organization'] ?? 'Bidang tidak diketahui'); ?></div>
        <div class="detail-kode">Kode Indikator: <?php echo htmlspecialchars($dssdDetail['kode_indikator'] ?? '-'); ?></div>
        
        <?php if (!empty($dssdDetail['description'])): ?>
        <p style="color: #475569; margin-bottom: 16px;"><?php echo htmlspecialchars($dssdDetail['description']); ?></p>
        <?php endif; ?>
        
        <div class="detail-meta">
            <div class="item">
                <div class="label">Satuan</div>
                <div class="value"><?php echo htmlspecialchars($dssdDetail['unit'] ?? '-'); ?></div>
            </div>
            <div class="item">
                <div class="label">Periode</div>
                <div class="value"><?php echo htmlspecialchars($dssdDetail['frequency'] ?? 'Tahunan'); ?></div>
            </div>
            <div class="item">
                <div class="label">Status</div>
                <div class="value">
                    <span class="badge <?php echo getStatusBadge($dssdDetail['status'] ?? ''); ?>">
                        <?php echo htmlspecialchars($dssdDetail['status'] ?? '-'); ?>
                    </span>
                </div>
            </div>
            <div class="item">
                <div class="label">Terakhir Update</div>
                <div class="value"><?php echo htmlspecialchars($dssdDetail['updated_at'] ?? '-'); ?></div>
            </div>
        </div>

        <?php
        // Build chart config untuk DSSD
        $tableData = $dssdDetail['table_data'] ?? [];
        $unit = $dssdDetail['unit'] ?? '';
        $chartConfig = null;
        
        if (!empty($tableData)) {
            // DSSD selalu format tahunan dengan value singular
            $sortedData = $tableData;
            usort($sortedData, function($a, $b) { return (int)$a['year'] - (int)$b['year']; });
            $labels = array_column($sortedData, 'year');
            $values = array_map(function($row) {
                $v = $row['value'] ?? null;
                if ($v === '-' || $v === null || $v === '') return null;
                return is_string($v) ? (float)str_replace(',', '', $v) : $v;
            }, $sortedData);
            
            $chartConfig = [
                'type' => 'bar',
                'labels' => $labels,
                'datasets' => [[
                    'label' => 'Nilai',
                    'data' => $values,
                    'backgroundColor' => '#2563eb',
                    'borderColor' => '#2563eb',
                    'borderWidth' => 1,
                    'borderRadius' => 4,
                    'barPercentage' => 0.5
                ]]
            ];
        }
        ?>

        <?php if ($chartConfig): ?>
        <div class="chart-container">
            <canvas id="dssdDetailChart"></canvas>
        </div>
        <script>
            (function() {
                const cfg = <?php echo json_encode($chartConfig); ?>;
                const ctx = document.getElementById('dssdDetailChart').getContext('2d');
                new Chart(ctx, {
                    type: cfg.type,
                    data: { labels: cfg.labels, datasets: cfg.datasets },
                    options: {
                        responsive: true,
                        maintainAspectRatio: false,
                        plugins: {
                            legend: { 
                                display: true, 
                                position: 'bottom',
                                labels: { usePointStyle: true, padding: 16, font: { size: 12 } }
                            },
                            tooltip: {
                                backgroundColor: 'rgba(255,255,255,0.95)',
                                titleColor: '#1e293b',
                                bodyColor: '#475569',
                                borderColor: '#e2e8f0',
                                borderWidth: 1,
                                callbacks: {
                                    label: function(ctx) {
                                        let label = ctx.dataset.label || '';
                                        if (label) label += ': ';
                                        if (ctx.parsed.y !== null && ctx.parsed.y !== undefined) {
                                            label += new Intl.NumberFormat('id-ID').format(ctx.parsed.y);
                                            <?php if ($unit): ?>label += ' <?php echo addslashes($unit); ?>';<?php endif; ?>
                                        }
                                        return label;
                                    }
                                }
                            }
                        },
                        scales: {
                            y: { 
                                beginAtZero: true, 
                                grid: { color: '#f1f5f9' },
                                ticks: { 
                                    callback: function(v) { return new Intl.NumberFormat('id-ID').format(v); }
                                }
                            },
                            x: { grid: { display: false } }
                        }
                    }
                });
            })();
        </script>
        <?php endif; ?>

        <div class="table-wrap">
            <table>
                <thead>
                    <tr>
                        <th>Tahun</th>
                        <th>Nilai <?php echo $unit ? '(' . htmlspecialchars($unit) . ')' : ''; ?></th>
                        <?php if (!empty($tableData[0]['source_producer'] ?? '')): ?>
                        <th>Sumber</th>
                        <?php endif; ?>
                    </tr>
                </thead>
                <tbody>
                    <?php 
                    $sortedTable = $tableData;
                    usort($sortedTable, function($a, $b) { return (int)$b['year'] - (int)$a['year']; });
                    foreach ($sortedTable as $row): 
                    ?>
                    <tr>
                        <td><strong><?php echo htmlspecialchars($row['year'] ?? '-'); ?></strong></td>
                        <td><?php echo htmlspecialchars($row['value'] ?? '-'); ?></td>
                        <?php if (!empty($row['source_producer'] ?? '')): ?>
                        <td><?php echo htmlspecialchars($row['source_producer']); ?></td>
                        <?php endif; ?>
                    </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    </div>
    <?php exit; ?>
    <?php endif; ?>

    <!-- ===== STATS INFO ===== -->
    <div class="stats-info">
        <span>
            Menampilkan <span class="count"><?php echo count($dssdList); ?></span> 
            dari <span class="count"><?php echo number_format($totalData); ?></span> indikator
            <?php if ($search): ?> untuk pencarian "<strong><?php echo htmlspecialchars($search); ?></strong>"<?php endif; ?>
        </span>
        <div class="per-page-selector">
            <span>Per halaman:</span>
            <select onchange="this.form.submit()" name="per_page" form="filterForm">
                <option value="10" <?php echo $perPage == 10 ? 'selected' : ''; ?>>10</option>
                <option value="25" <?php echo $perPage == 25 ? 'selected' : ''; ?>>25</option>
                <option value="50" <?php echo $perPage == 50 ? 'selected' : ''; ?>>50</option>
            </select>
        </div>
    </div>

    <!-- ===== DSSD LIST ===== -->
    <?php if (empty($dssdList)): ?>
    <div class="empty-state">
        <div class="icon">📭</div>
        <p>Tidak ada indikator DSSD yang ditemukan untuk OPD ini.</p>
        <p style="font-size:14px; margin-top:4px;">Coba ubah kata kunci pencarian atau filter bidang urusan.</p>
    </div>
    <?php else: ?>
    <div class="dssd-grid">
        <?php foreach ($dssdList as $dssd): ?>
        <div class="dssd-item">
            <div class="info">
                <div class="title">
                    <a href="dssd.php?dssd_id=<?php echo urlencode($dssd['id_encrypted'] ?? ''); ?>">
                        <?php echo htmlspecialchars($dssd['uraian_indikator'] ?? 'Indikator'); ?>
                    </a>
                </div>
                <div class="desc">
                    <?php echo htmlspecialchars($dssd['definisi_operasional'] ?? 'Tidak ada definisi tersedia.'); ?>
                </div>
                <div class="meta">
                    <span class="badge <?php echo getStatusBadge($dssd['status'] ?? ''); ?>">
                        <?php echo htmlspecialchars($dssd['status'] ?? '-'); ?>
                    </span>
                    <span>📊 <?php echo htmlspecialchars($dssd['satuan'] ?? '-'); ?></span>
                    <?php if (!empty($dssd['bidangurusan'])): ?>
                    <span class="badge badge-blue"><?php echo htmlspecialchars($dssd['bidangurusan']); ?></span>
                    <?php endif; ?>
                </div>
            </div>
            <div class="actions">
                <span class="kode"><?php echo htmlspecialchars($dssd['kodeindikator'] ?? ''); ?></span>
                <a href="dssd.php?dssd_id=<?php echo urlencode($dssd['id_encrypted'] ?? ''); ?>" class="btn-detail">
                    Detail →
                </a>
            </div>
        </div>
        <?php endforeach; ?>
    </div>

    <!-- ===== PAGINATION ===== -->
    <?php if ($totalPage > 1): ?>
    <div class="pagination-wrapper">
        <?php if ($currentPage > 1): ?>
        <a href="?page=<?php echo $currentPage - 1; ?>&search=<?php echo urlencode($search); ?>&urusan_id=<?php echo $urusanFilter; ?>&status=<?php echo urlencode($statusFilter); ?>&per_page=<?php echo $perPage; ?>">‹</a>
        <?php else: ?>
        <a class="disabled">‹</a>
        <?php endif; ?>

        <?php
        $startPage = max(1, $currentPage - 2);
        $endPage = min($totalPage, $currentPage + 2);
        if ($startPage > 1) {
            echo '<a href="?page=1&search=' . urlencode($search) . '&urusan_id=' . $urusanFilter . '&status=' . urlencode($statusFilter) . '&per_page=' . $perPage . '">1</a>';
            if ($startPage > 2) echo '<span style="color:#94a3b8;padding:0 4px;">…</span>';
        }
        for ($i = $startPage; $i <= $endPage; $i++) {
            $active = ($i == $currentPage) ? 'active' : '';
            echo '<a href="?page=' . $i . '&search=' . urlencode($search) . '&urusan_id=' . $urusanFilter . '&status=' . urlencode($statusFilter) . '&per_page=' . $perPage . '" class="' . $active . '">' . $i . '</a>';
        }
        if ($endPage < $totalPage) {
            if ($endPage < $totalPage - 1) echo '<span style="color:#94a3b8;padding:0 4px;">…</span>';
            echo '<a href="?page=' . $totalPage . '&search=' . urlencode($search) . '&urusan_id=' . $urusanFilter . '&status=' . urlencode($statusFilter) . '&per_page=' . $perPage . '">' . $totalPage . '</a>';
        }
        ?>

        <?php if ($currentPage < $totalPage): ?>
        <a href="?page=<?php echo $currentPage + 1; ?>&search=<?php echo urlencode($search); ?>&urusan_id=<?php echo $urusanFilter; ?>&status=<?php echo urlencode($statusFilter); ?>&per_page=<?php echo $perPage; ?>">›</a>
        <?php else: ?>
        <a class="disabled">›</a>
        <?php endif; ?>
    </div>
    <?php endif; ?>
    <?php endif; ?>

    <!-- ===== FOOTER ===== -->
    <div class="footer">
        &copy; <?php echo date('Y'); ?> Dinas Komunikasi dan Informatika Kabupaten Lumajang &bull; 
        Data dari <a href="https://satudata.lumajangkab.go.id" target="_blank">Satu Data Lumajang</a>
        <br><span style="font-size:12px;">Data di-cache selama 1 jam untuk performa optimal</span>
    </div>

</div>

<!-- Hidden form untuk per_page submit -->
<form id="filterForm" method="GET" style="display:none;">
    <input type="hidden" name="search" value="<?php echo htmlspecialchars($search); ?>">
    <input type="hidden" name="urusan_id" value="<?php echo $urusanFilter; ?>">
    <input type="hidden" name="status" value="<?php echo htmlspecialchars($statusFilter); ?>">
    <input type="hidden" name="page" value="<?php echo $currentPage; ?>">
</form>

</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit