| 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_/admin/ |
Upload File : |
<?php
// bpkd/admin/ppid_sync.php
$page_title = 'Sync Berita PPID';
require_once 'config/database.php';
require_once '../includes/config.php';
require_once 'includes/header.php';
require_once 'includes/init.php';
require_once __DIR__ . '/lib/PPIDService.php';
$config = include __DIR__ . '/config/ppid.php';
$ppid = new PPIDService($config);
$msg = '';
$error = '';
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['action']) && $_POST['action'] == 'sync') {
$judul = trim($_POST['judul'] ?? '');
$link = trim($_POST['link'] ?? '');
$egovNewsId = (int)($_POST['egov_news_id'] ?? 0);
if (!empty($judul) && !empty($link) && $egovNewsId > 0) {
$result = $ppid->syncBerita($judul, $link, $egovNewsId);
if (isset($result['error']) && $result['error'] === false) {
$msg = '<div class="alert alert-success">✅ Berita berhasil disinkronkan ke PPID!</div>';
} else {
$error = '<div class="alert alert-danger">❌ Gagal sync: ' . ($result['message'] ?? 'Unknown error') . '</div>';
}
} else {
$error = '<div class="alert alert-danger">❌ Mohon lengkapi semua field.</div>';
}
}
// Ambil rekap konten terakhir
$rekap = $ppid->getRekapKonten(['limit' => 10]);
?>
<div class="container-fluid">
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">
<i class="fas fa-sync-alt me-2"></i>Sync Berita PPID
</h1>
<a href="ppid_dashboard.php" class="btn btn-secondary">
<i class="fas fa-arrow-left me-2"></i>Dashboard
</a>
</div>
<?php echo $msg; ?>
<?php echo $error; ?>
<!-- Info -->
<div class="alert alert-info">
<i class="fas fa-info-circle me-2"></i>
<strong>Informasi:</strong> Gunakan form ini untuk mensinkronkan berita yang dipublikasikan di website dinas ke sistem PPID pusat.
Pastikan <strong>Egov News ID</strong> adalah ID unik berita di database website dinas untuk menghindari duplikasi.
</div>
<!-- Sync Form -->
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">
<i class="fas fa-paper-plane me-2"></i>Sinkronisasi Berita
</h6>
</div>
<div class="card-body">
<form method="POST">
<input type="hidden" name="action" value="sync">
<div class="row g-3">
<div class="col-md-12">
<label class="form-label">Judul Berita *</label>
<input type="text" class="form-control" name="judul" required placeholder="Masukkan judul berita">
</div>
<div class="col-md-8">
<label class="form-label">Link Berita *</label>
<input type="url" class="form-control" name="link" required placeholder="https://website-anda/berita/...">
</div>
<div class="col-md-4">
<label class="form-label">Egov News ID *</label>
<input type="number" class="form-control" name="egov_news_id" required placeholder="ID di database website">
</div>
<div class="col-12">
<button type="submit" class="btn btn-primary">
<i class="fas fa-sync-alt me-2"></i>Sinkronkan ke PPID
</button>
</div>
</div>
</form>
</div>
</div>
<!-- Rekap Konten Terakhir -->
<div class="card shadow mb-4">
<div class="card-header py-3 d-flex justify-content-between align-items-center">
<h6 class="m-0 font-weight-bold text-primary">
<i class="fas fa-clock me-2"></i>Rekap Konten Terakhir
</h6>
<a href="ppid_rekap.php" class="btn btn-sm btn-primary">Lihat Semua</a>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>#</th>
<th>Judul</th>
<th>Tipe</th>
<th>Kategori</th>
<th>Status</th>
<th>Tanggal</th>
</tr>
</thead>
<tbody>
<?php if (isset($rekap['data']) && count($rekap['data']) > 0): ?>
<?php foreach ($rekap['data'] as $idx => $item): ?>
<tr>
<td><?php echo $idx + 1; ?></td>
<td><?php echo htmlspecialchars(substr($item['judul'] ?? '', 0, 40)) . (strlen($item['judul'] ?? '') > 40 ? '...' : ''); ?></td>
<td>
<span class="badge bg-<?php echo ($item['tipe'] ?? '') == 'berita' ? 'info' : 'secondary'; ?>">
<?php echo htmlspecialchars($item['tipe'] ?? '-'); ?>
</span>
</td>
<td><?php echo htmlspecialchars($item['kategori'] ?? '-'); ?></td>
<td>
<?php if (($item['status_verifikasi'] ?? '') == 'valid'): ?>
<span class="badge bg-success">Valid</span>
<?php elseif (($item['status_verifikasi'] ?? '') == 'pending'): ?>
<span class="badge bg-warning">Pending</span>
<?php else: ?>
<span class="badge bg-danger">Tidak Valid</span>
<?php endif; ?>
</td>
<td><?php echo htmlspecialchars($item['created_at'] ?? '-'); ?></td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="6" class="text-center py-4 text-muted">
Belum ada data rekap konten
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php require_once 'includes/footer.php'; ?>