| 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_dokumen.php
$page_title = 'Dokumen OPD';
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);
$dokumen = $ppid->getDokumen();
$msg = '';
$error = '';
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['action']) && $_POST['action'] == 'upload') {
$kategori = $_POST['kategori'] ?? '';
$file = $_FILES['file'] ?? null;
if (!empty($kategori) && $file && $file['error'] == 0) {
$result = $ppid->uploadDokumen($kategori, $file['tmp_name']);
if (isset($result['error']) && $result['error'] === false) {
$msg = '<div class="alert alert-success">✅ Dokumen berhasil diupload!</div>';
$dokumen = $ppid->getDokumen();
} else {
$error = '<div class="alert alert-danger">❌ Gagal upload: ' . ($result['message'] ?? 'Unknown error') . '</div>';
}
} else {
$error = '<div class="alert alert-danger">❌ Mohon pilih kategori dan file.</div>';
}
}
$kategoriList = [
'Kelembagaan' => 'kelembagaan',
'Tupoksi' => 'tupoksi',
'SK PPID' => 'sk',
'SOP PPID' => 'sop',
'Struktur Organisasi PPID' => 'struktur_ppid'
];
?>
<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-folder-open me-2"></i>Dokumen OPD
</h1>
<!--<small class="text-muted"><?php echo htmlspecialchars($config['opd_name']); ?></small>-->
<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; ?>
<!-- Upload 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-upload me-2"></i>Upload / Update Dokumen
</h6>
</div>
<div class="card-body">
<form method="POST" enctype="multipart/form-data" class="row g-3">
<input type="hidden" name="action" value="upload">
<div class="col-md-4">
<label class="form-label">Kategori Dokumen *</label>
<select class="form-select" name="kategori" required>
<option value="">Pilih Kategori</option>
<option value="Kelembagaan">Kelembagaan</option>
<option value="Tupoksi">Tupoksi</option>
<option value="SK PPID">SK PPID</option>
<option value="SOP PPID">SOP PPID</option>
<option value="Struktur Organisasi PPID">Struktur Organisasi PPID</option>
</select>
</div>
<div class="col-md-5">
<label class="form-label">File Dokumen * (PDF/JPG/PNG, maks 15MB)</label>
<input type="file" class="form-control" name="file" required accept=".pdf,.jpg,.jpeg,.png">
</div>
<div class="col-md-3 d-flex align-items-end">
<button type="submit" class="btn btn-primary w-100">
<i class="fas fa-upload me-2"></i>Upload
</button>
</div>
</form>
</div>
</div>
<!-- Daftar Dokumen -->
<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-list me-2"></i>Daftar Dokumen
</h6>
</div>
<div class="card-body">
<?php if (is_array($dokumen) && isset($dokumen['skpd'])): ?>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>No</th>
<th>Kategori</th>
<th>File</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php
$no = 1;
foreach ($kategoriList as $nama => $field):
?>
<tr>
<td><?php echo $no++; ?></td>
<td><strong><?php echo $nama; ?></strong></td>
<td>
<?php if (!empty($dokumen[$field])): ?>
<a href="<?php echo htmlspecialchars($dokumen[$field]); ?>" target="_blank" class="btn btn-sm btn-info">
<i class="fas fa-file-pdf"></i> Lihat
</a>
<?php else: ?>
<span class="text-muted">Belum diupload</span>
<?php endif; ?>
</td>
<td>
<?php if (!empty($dokumen[$field])): ?>
<span class="badge bg-success"><i class="fas fa-check-circle me-1"></i>Tersedia</span>
<?php else: ?>
<span class="badge bg-secondary"><i class="fas fa-times-circle me-1"></i>Kosong</span>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div class="text-center py-4 text-muted">
<i class="fas fa-exclamation-triangle fa-2x d-block mb-2"></i>
Gagal mengambil data dokumen. Pastikan nama OPD sesuai dengan database PPID.
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php require_once 'includes/footer.php'; ?>