| 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 : D:/bpkd_/ |
Upload File : |
<?php
/**
* Halaman Katalog Dataset - Satu Data Lumajang
* Terintegrasi dengan CMS BPKD
*/
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 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;
}
// =====================================================
// AMBIL PARAMETER
// =====================================================
$opdCode = $config['opd_code'];
$baseUrl = $config['api_url'];
$token = $config['api_token'];
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$search = isset($_GET['search']) ? sanitize($_GET['search']) : '';
$urusanFilter = isset($_GET['urusan_id']) ? (int)$_GET['urusan_id'] : 0;
$perPage = isset($_GET['per_page']) ? (int)$_GET['per_page'] : 10;
// =====================================================
// AMBIL DATA URUSAN UNTUK FILTER
// =====================================================
$urusanData = fetchApi(
$baseUrl . '/urusan?skpd_code=' . $opdCode,
$token,
'urusan_' . $opdCode,
86400
);
$urusans = $urusanData['data'] ?? [];
// =====================================================
// AMBIL DATA DATASET
// =====================================================
$params = [
'skpd_code' => $opdCode,
'page' => $page,
'per_page' => $perPage
];
if ($search) $params['q'] = $search;
if ($urusanFilter) $params['urusan_id'] = $urusanFilter;
$datasetsData = fetchApi(
$baseUrl . '/datasets?' . http_build_query($params),
$token,
'datasets_' . md5(serialize($params)),
3600
);
$datasets = $datasetsData['data'] ?? [];
$pagination = $datasetsData['metadata'] ?? ['page' => 1, 'total_page' => 1, 'total_data' => 0];
$totalData = $pagination['total_data'] ?? 0;
$currentPage = $pagination['page'] ?? 1;
$totalPage = $pagination['total_page'] ?? 1;
// =====================================================
// AMBIL DETAIL DATASET (JIKA ADA)
// =====================================================
$datasetDetail = null;
$detailId = isset($_GET['detail_id']) ? $_GET['detail_id'] : '';
if ($detailId) {
$detailData = fetchApi(
$baseUrl . '/datasets/detail/' . urlencode($detailId),
$token,
'dataset_detail_' . $detailId,
3600
);
$datasetDetail = $detailData['data'] ?? null;
}
// Include header
include 'includes/header.php';
?>
<!-- =====================================================
STYLE KHUSUS UNTUK SATUDATA
===================================================== -->
<style>
.satudata-container {
max-width: 1100px;
margin: 0 auto;
padding: 20px 0;
}
/* Header */
.satudata-header {
margin-bottom: 28px;
}
.satudata-header h1 {
font-size: 28px;
font-weight: 700;
color: #0f172a;
letter-spacing: -0.5px;
}
.satudata-header h1 span {
color: #2563eb;
}
.satudata-header p {
color: #64748b;
font-size: 15px;
margin-top: 4px;
}
/* ===== FILTER BAR ===== */
.satudata-filter {
display: flex;
flex-wrap: wrap;
gap: 12px;
align-items: center;
background: white;
padding: 18px 24px;
border-radius: 12px;
border: 1px solid #e2e8f0;
margin-bottom: 24px;
box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.satudata-filter .search-wrapper {
flex: 2;
min-width: 220px;
position: relative;
}
.satudata-filter .search-wrapper input {
width: 100%;
padding: 11px 18px 11px 44px;
border: 2px solid #e2e8f0;
border-radius: 10px;
font-size: 14px;
background: #f8fafc;
transition: all 0.3s ease;
}
.satudata-filter .search-wrapper input:focus {
outline: none;
border-color: #2563eb;
box-shadow: 0 0 0 4px rgba(37,99,235,0.12);
background: white;
}
.satudata-filter .search-wrapper input::placeholder {
color: #94a3b8;
}
.satudata-filter .search-wrapper .icon {
position: absolute;
left: 16px;
top: 50%;
transform: translateY(-50%);
color: #94a3b8;
font-size: 18px;
pointer-events: none;
}
.satudata-filter .filter-group {
display: flex;
gap: 10px;
flex-wrap: wrap;
flex: 1;
}
.satudata-filter select {
padding: 11px 16px;
border: 2px solid #e2e8f0;
border-radius: 10px;
font-size: 14px;
background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 14px center;
background-size: 12px;
color: #1e293b;
min-width: 160px;
cursor: pointer;
transition: all 0.3s ease;
appearance: none;
-webkit-appearance: none;
padding-right: 40px;
}
.satudata-filter select:focus {
outline: none;
border-color: #2563eb;
box-shadow: 0 0 0 4px rgba(37,99,235,0.12);
background-color: white;
}
.satudata-filter .btn-group {
display: flex;
gap: 8px;
}
.satudata-filter .btn {
padding: 11px 28px;
background: #2563eb;
color: white;
border: none;
border-radius: 10px;
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
white-space: nowrap;
text-decoration: none;
}
.satudata-filter .btn:hover {
background: #1d4ed8;
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}
.satudata-filter .btn-outline {
background: transparent;
color: #64748b;
border: 2px solid #e2e8f0;
padding: 9px 20px;
}
.satudata-filter .btn-outline:hover {
background: #f1f5f9;
transform: none;
box-shadow: none;
}
/* Stats Info */
.satudata-stats {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
gap: 8px;
margin-bottom: 20px;
font-size: 14px;
color: #64748b;
padding: 0 4px;
}
.satudata-stats .count {
font-weight: 600;
color: #0f172a;
}
.satudata-stats .per-page {
display: flex;
align-items: center;
gap: 8px;
}
.satudata-stats .per-page select {
padding: 6px 12px 6px 14px;
border: 2px solid #e2e8f0;
border-radius: 8px;
font-size: 13px;
background: white;
cursor: pointer;
transition: border-color 0.2s;
}
.satudata-stats .per-page select:focus {
outline: none;
border-color: #2563eb;
}
/* Badge */
.badge {
display: inline-block;
padding: 2px 12px;
border-radius: 20px;
font-size: 12px;
font-weight: 500;
}
.badge-blue {
background: #dbeafe;
color: #1d4ed8;
}
.badge-secondary {
background: #e2e8f0;
color: #475569;
}
/* Dataset Grid */
.satudata-grid {
display: grid;
grid-template-columns: 1fr;
gap: 12px;
}
.satudata-item {
background: white;
border-radius: 12px;
border: 1px solid #e2e8f0;
padding: 18px 24px;
display: flex;
justify-content: space-between;
align-items: center;
transition: all 0.2s ease;
box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.satudata-item:hover {
border-color: #94a3b8;
box-shadow: 0 4px 16px rgba(0,0,0,0.08);
transform: translateY(-1px);
}
.satudata-item .info {
flex: 1;
min-width: 0;
}
.satudata-item .info .title {
font-size: 16px;
font-weight: 600;
color: #0f172a;
margin-bottom: 2px;
}
.satudata-item .info .title a {
color: #0f172a;
text-decoration: none;
transition: color 0.2s;
}
.satudata-item .info .title a:hover {
color: #2563eb;
}
.satudata-item .info .desc {
font-size: 14px;
color: #94a3b8;
margin-bottom: 6px;
}
.satudata-item .info .meta {
display: flex;
flex-wrap: wrap;
gap: 12px;
font-size: 13px;
color: #94a3b8;
align-items: center;
}
.satudata-item .info .meta span {
display: inline-flex;
align-items: center;
gap: 4px;
}
.satudata-item .actions {
display: flex;
align-items: center;
gap: 12px;
flex-shrink: 0;
margin-left: 16px;
}
.satudata-item .actions .btn-detail {
padding: 6px 20px;
background: #2563eb;
color: white;
border: none;
border-radius: 8px;
font-size: 13px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s ease;
text-decoration: none;
}
.satudata-item .actions .btn-detail:hover {
background: #1d4ed8;
transform: scale(1.02);
}
.satudata-item .actions .opd-name {
font-size: 13px;
color: #64748b;
white-space: nowrap;
}
/* Detail View */
.satudata-detail {
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);
}
.satudata-detail .back-link {
display: inline-flex;
align-items: center;
gap: 6px;
color: #2563eb;
text-decoration: none;
font-weight: 500;
font-size: 14px;
margin-bottom: 16px;
}
.satudata-detail .back-link:hover {
text-decoration: underline;
}
.satudata-detail .detail-title {
font-size: 24px;
font-weight: 700;
color: #0f172a;
margin-bottom: 4px;
}
.satudata-detail .detail-sub {
color: #64748b;
font-size: 14px;
margin-bottom: 16px;
}
.satudata-detail .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;
}
.satudata-detail .detail-meta .item .label {
font-size: 12px;
color: #94a3b8;
text-transform: uppercase;
letter-spacing: 0.3px;
}
.satudata-detail .detail-meta .item .value {
font-weight: 600;
color: #0f172a;
}
.satudata-detail .chart-container {
position: relative;
height: 300px;
max-width: 700px;
margin: 20px auto;
}
.satudata-detail .table-wrap {
overflow-x: auto;
margin-top: 16px;
}
.satudata-detail table {
width: 100%;
border-collapse: collapse;
font-size: 14px;
}
.satudata-detail table th {
text-align: left;
padding: 10px 14px;
background: #f1f5f9;
font-weight: 600;
color: #475569;
border-bottom: 2px solid #e2e8f0;
}
.satudata-detail table td {
padding: 10px 14px;
border-bottom: 1px solid #f1f5f9;
}
.satudata-detail table tr:hover td {
background: #fafbfc;
}
/* Pagination */
.satudata-pagination {
display: flex;
justify-content: center;
align-items: center;
gap: 6px;
margin-top: 28px;
flex-wrap: wrap;
}
.satudata-pagination a {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 40px;
height: 40px;
padding: 0 14px;
border-radius: 8px;
border: 1px solid #e2e8f0;
background: white;
color: #1e293b;
text-decoration: none;
font-size: 14px;
font-weight: 500;
transition: all 0.2s;
}
.satudata-pagination a:hover {
background: #f1f5f9;
border-color: #94a3b8;
}
.satudata-pagination a.active {
background: #2563eb;
color: white;
border-color: #2563eb;
}
.satudata-pagination a.active:hover {
background: #1d4ed8;
}
.satudata-pagination a.disabled {
opacity: 0.4;
pointer-events: none;
}
/* Empty State */
.satudata-empty {
text-align: center;
padding: 50px 20px;
color: #94a3b8;
}
.satudata-empty .icon {
font-size: 56px;
margin-bottom: 16px;
opacity: 0.5;
}
.satudata-empty h3 {
color: #475569;
margin-bottom: 8px;
}
/* Responsive */
@media (max-width: 640px) {
.satudata-item {
flex-direction: column;
align-items: flex-start;
gap: 12px;
padding: 16px;
}
.satudata-item .actions {
margin-left: 0;
width: 100%;
justify-content: flex-start;
}
.satudata-filter {
flex-direction: column;
align-items: stretch;
padding: 16px;
}
.satudata-filter .search-wrapper {
min-width: unset;
}
.satudata-filter select {
min-width: unset;
width: 100%;
}
.satudata-filter .btn-group {
width: 100%;
}
.satudata-filter .btn-group .btn {
flex: 1;
text-align: center;
}
.satudata-stats {
flex-direction: column;
align-items: flex-start;
}
.satudata-detail {
padding: 20px;
}
.satudata-detail .detail-title {
font-size: 20px;
}
}
</style>
<!-- =====================================================
MAIN CONTENT
===================================================== -->
<div class="container">
<div class="row">
<div class="sidebar col-lg-10 mx-auto">
<div class="card mb-3 py-3 mt-5">
<div class="card-body p-4">
<div class="satudata-container">
<!-- Header -->
<div class="satudata-header">
<h1>📋 Katalog <span>Dataset</span></h1>
<p>Temukan data dan informasi publik dari berbagai instansi di Kabupaten Lumajang.</p>
</div>
<!-- =====================================================
DETAIL VIEW
===================================================== -->
<?php if (!empty($detailId) && $datasetDetail): ?>
<div class="satudata-detail">
<a href="<?php echo BASE_URL; ?>/satudata.php" class="back-link">
<i class="fas fa-arrow-left me-1"></i> Kembali ke katalog
</a>
<div class="detail-title"><?php echo htmlspecialchars($datasetDetail['title'] ?? 'Detail Dataset'); ?></div>
<div class="detail-sub"><?php echo htmlspecialchars($datasetDetail['organization'] ?? 'Instansi tidak diketahui'); ?></div>
<?php if (!empty($datasetDetail['description'])): ?>
<p style="color: #475569; margin-bottom: 16px;"><?php echo htmlspecialchars($datasetDetail['description']); ?></p>
<?php endif; ?>
<div class="detail-meta">
<div class="item">
<div class="label">Satuan</div>
<div class="value"><?php echo htmlspecialchars($datasetDetail['unit'] ?? '-'); ?></div>
</div>
<div class="item">
<div class="label">Periode</div>
<div class="value"><?php echo htmlspecialchars($datasetDetail['frequency'] ?? '-'); ?></div>
</div>
<div class="item">
<div class="label">Terakhir Update</div>
<div class="value"><?php echo htmlspecialchars($datasetDetail['updated_at'] ?? '-'); ?></div>
</div>
</div>
<?php
// =====================================================
// BUILD CHART CONFIG
// =====================================================
$tableData = $datasetDetail['table_data'] ?? [];
$unit = $datasetDetail['unit'] ?? '';
$chartConfig = null;
if (!empty($tableData)) {
$validRow = null;
foreach ($tableData as $row) {
if (isset($row['values']) && is_array($row['values']) && count($row['values']) > 0) {
$validRow = $row;
break;
}
}
if ($validRow) {
$colCount = count($validRow['values']);
$labels = [];
$datasets = [];
if ($colCount === 1) {
$chartType = 'bar';
$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['values'][0] ?? null;
if ($v === '-' || $v === null) return null;
return is_string($v) ? (float)str_replace(',', '', $v) : $v;
}, $sortedData);
$datasets = [[
'label' => 'Nilai',
'data' => $values,
'backgroundColor' => '#2563eb',
'borderColor' => '#2563eb',
'borderWidth' => 1,
'borderRadius' => 4,
'barPercentage' => 0.5
]];
} else {
$chartType = 'line';
if ($colCount === 12) {
$labels = ['Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Agu', 'Sep', 'Okt', 'Nov', 'Des'];
} elseif ($colCount === 4) {
$labels = ['TW I', 'TW II', 'TW III', 'TW IV'];
} elseif ($colCount === 2) {
$labels = ['Smstr I', 'Smstr II'];
} else {
$labels = array_map(function($i) { return 'P' . ($i + 1); }, range(0, $colCount - 1));
}
$colors = ['#2563eb', '#dc2626', '#16a34a', '#d97706', '#9333ea', '#0891b2'];
foreach ($tableData as $idx => $row) {
$values = array_map(function($v) {
if ($v === '-' || $v === null) return null;
return is_string($v) ? (float)str_replace(',', '', $v) : $v;
}, $row['values']);
$datasets[] = [
'label' => $row['year'],
'data' => $values,
'borderColor' => $colors[$idx % count($colors)],
'backgroundColor' => $colors[$idx % count($colors)] . '33',
'borderWidth' => 2,
'pointRadius' => 4,
'fill' => false,
'tension' => 0.3
];
}
}
$chartConfig = ['type' => $chartType, 'labels' => $labels, 'datasets' => $datasets];
}
}
?>
<?php if ($chartConfig): ?>
<div class="chart-container">
<canvas id="detailChart"></canvas>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const canvas = document.getElementById('detailChart');
if (!canvas) return;
const cfg = <?php echo json_encode($chartConfig); ?>;
if (!cfg || !cfg.labels || cfg.labels.length === 0) return;
// Hapus chart yang sudah ada
if (canvas.chart) {
canvas.chart.destroy();
}
const ctx = canvas.getContext('2d');
canvas.chart = new Chart(ctx, {
type: cfg.type,
data: { labels: cfg.labels, datasets: cfg.datasets },
options: {
responsive: true,
maintainAspectRatio: false,
interaction: { mode: 'index', intersect: 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 (!empty($unit)): ?>label += ' <?php echo addslashes($unit); ?>';<?php endif; ?>
}
return label;
}
}
}
},
scales: {
y: {
beginAtZero: true,
grid: { color: 'rgba(0,0,0,0.05)' },
ticks: {
callback: function(v) { return new Intl.NumberFormat('id-ID').format(v); }
}
},
x: { grid: { display: false } }
}
}
});
});
</script>
<?php endif; ?>
<!-- Tabel Data -->
<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
if (isset($row['values']) && is_array($row['values'])) {
echo htmlspecialchars(implode(' | ', $row['values']));
} elseif (isset($row['value'])) {
echo htmlspecialchars($row['value']);
} else {
echo '-';
}
?>
</td>
<?php if (!empty($row['source_producer'] ?? '')): ?>
<td><?php echo htmlspecialchars($row['source_producer']); ?></td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<!-- Stop di sini jika detail view -->
<?php include 'includes/footer.php'; exit; ?>
<?php endif; ?>
<!-- =====================================================
FILTER BAR
===================================================== -->
<form method="GET" action="<?php echo BASE_URL; ?>/satudata.php" class="satudata-filter" id="filterForm">
<!-- Search Box -->
<div class="search-wrapper">
<span class="icon">🔍</span>
<input
type="text"
name="search"
id="searchInput"
placeholder="Cari judul dataset..."
value="<?php echo htmlspecialchars($search); ?>"
autocomplete="off"
>
</div>
<!-- Combo Urusan -->
<div class="filter-group">
<select name="urusan_id" id="urusanSelect">
<option value="0">Semua Urusan</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>
</div>
<!-- Tombol -->
<div class="btn-group">
<button type="submit" class="btn"><i class="fas fa-search me-1"></i>Cari</button>
<?php if (!empty($search) || $urusanFilter > 0): ?>
<a href="<?php echo BASE_URL; ?>/satudata.php" class="btn btn-outline">
<i class="fas fa-times me-1"></i>Reset
</a>
<?php endif; ?>
</div>
</form>
<!-- =====================================================
STATS INFO
===================================================== -->
<div class="satudata-stats">
<span>
Menampilkan <span class="count"><?php echo count($datasets); ?></span>
dari <span class="count"><?php echo number_format($totalData); ?></span> dataset
<?php if (!empty($search)): ?>
untuk pencarian "<strong><?php echo htmlspecialchars($search); ?></strong>"
<?php endif; ?>
<?php if ($urusanFilter > 0): ?>
pada urusan "<strong><?php
foreach ($urusans as $u) {
if ($u['id'] == $urusanFilter) {
echo htmlspecialchars($u['nama_urusan']);
break;
}
}
?></strong>"
<?php endif; ?>
</span>
<div class="per-page">
<span>Per halaman:</span>
<select name="per_page" onchange="document.getElementById('filterForm').submit()">
<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>
<!-- =====================================================
DATASET LIST
===================================================== -->
<?php if (empty($datasets)): ?>
<div class="satudata-empty">
<div class="icon">📭</div>
<h3>Tidak ada dataset ditemukan</h3>
<p>Coba ubah kata kunci pencarian atau filter urusan.</p>
<?php if (!empty($search) || $urusanFilter > 0): ?>
<p style="margin-top:12px;">
<a href="<?php echo BASE_URL; ?>/satudata.php" style="color:#2563eb;text-decoration:none;font-weight:500;">
<i class="fas fa-arrow-left me-1"></i> Kembali ke daftar semua dataset
</a>
</p>
<?php endif; ?>
</div>
<?php else: ?>
<div class="satudata-grid">
<?php foreach ($datasets as $ds): ?>
<div class="satudata-item">
<div class="info">
<div class="title">
<a href="<?php echo BASE_URL; ?>/satudata.php?detail_id=<?php echo urlencode($ds['id_encrypted'] ?? ''); ?>">
<?php echo htmlspecialchars($ds['uraian'] ?? 'Dataset'); ?>
</a>
</div>
<div class="desc">
<?php echo htmlspecialchars($ds['definisi'] ?? 'Tidak ada definisi tersedia.'); ?>
</div>
<div class="meta">
<span><i class="far fa-calendar-alt"></i> <?php echo htmlspecialchars($ds['periode'] ?? '-'); ?></span>
<span><i class="fas fa-chart-bar"></i> <?php echo htmlspecialchars($ds['satuans']['satuan'] ?? '-'); ?></span>
<?php if (!empty($ds['urusan']['nama_urusan'])): ?>
<span class="badge badge-blue"><?php echo htmlspecialchars($ds['urusan']['nama_urusan']); ?></span>
<?php endif; ?>
<?php if (!empty($ds['kode_sds'])): ?>
<span class="badge badge-secondary"><?php echo htmlspecialchars($ds['kode_sds']); ?></span>
<?php endif; ?>
</div>
</div>
<div class="actions">
<span class="opd-name"><?php echo htmlspecialchars($ds['skpd']['nama_pd'] ?? ''); ?></span>
<a href="<?php echo BASE_URL; ?>/satudata.php?detail_id=<?php echo urlencode($ds['id_encrypted'] ?? ''); ?>" class="btn-detail">
Detail <i class="fas fa-arrow-right ms-1"></i>
</a>
</div>
</div>
<?php endforeach; ?>
</div>
<!-- =====================================================
PAGINATION
===================================================== -->
<?php if ($totalPage > 1): ?>
<div class="satudata-pagination">
<?php if ($currentPage > 1): ?>
<a href="?page=<?php echo $currentPage - 1; ?>&search=<?php echo urlencode($search); ?>&urusan_id=<?php echo $urusanFilter; ?>&per_page=<?php echo $perPage; ?>">
<i class="fas fa-chevron-left"></i>
</a>
<?php else: ?>
<a class="disabled"><i class="fas fa-chevron-left"></i></a>
<?php endif; ?>
<?php
$startPage = max(1, $currentPage - 2);
$endPage = min($totalPage, $currentPage + 2);
if ($startPage > 1) {
echo '<a href="satudata?page=1&search=' . urlencode($search) . '&urusan_id=' . $urusanFilter . '&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="satudata?page=' . $i . '&search=' . urlencode($search) . '&urusan_id=' . $urusanFilter . '&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="satudata?page=' . $totalPage . '&search=' . urlencode($search) . '&urusan_id=' . $urusanFilter . '&per_page=' . $perPage . '">' . $totalPage . '</a>';
}
?>
<?php if ($currentPage < $totalPage): ?>
<a href="satudata?page=<?php echo $currentPage + 1; ?>&search=<?php echo urlencode($search); ?>&urusan_id=<?php echo $urusanFilter; ?>&per_page=<?php echo $perPage; ?>">
<i class="fas fa-chevron-right"></i>
</a>
<?php else: ?>
<a class="disabled"><i class="fas fa-chevron-right"></i></a>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
<div class="row">
<hr>
<a style="color: blue">
<i class="fas fa-info-circle me-1"></i>Data diperbarui secara otomatis dari server satudata.lumajangkab.go.id
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include 'includes/footer.php'; ?>