| 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 : |
<?php
/**
* Halaman Manual & Dokumen
* Menampilkan file-file laporan/manual yang dapat diunduh
* Data diambil dari tabel reports
*/
require_once 'includes/config.php';
require_once 'includes/init.php';
$page_title = 'Manual & Dokumen - ' . ($settings['site_title'] ?? 'Website Instansi');
$meta_description = 'Unduh berbagai manual, panduan, dan dokumen resmi instansi.';
// =====================================================
// AMBIL DATA DARI TABEL REPORTS
// =====================================================
// Ambil semua laporan yang memiliki file dan status active
$query = "SELECT
r.id,
r.title,
r.description,
r.file_size,
r.download_count,
r.created_at,
r.category_id,
rc.name as category_name,
m.filename,
m.filepath
FROM reports r
LEFT JOIN report_categories rc ON r.category_id = rc.id
LEFT JOIN media m ON r.file_id = m.id
WHERE r.status = 'active'
AND rc.name = 'ManualBook'
AND m.filepath IS NOT NULL
ORDER BY r.created_at DESC";
$result = $conn->query($query);
$manuals = [];
if ($result && $result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
// Tentukan icon berdasarkan kategori atau tipe file
$icon = 'fa-file-pdf';
$color = 'danger';
// Warna berdasarkan kategori
$category_colors = [
'Anggaran' => 'success',
'Aplikasi' => 'info',
'Pelayanan' => 'warning',
'Akuntansi' => 'primary',
'Aset' => 'secondary',
'Perbendaharaan' => 'danger'
];
if (!empty($row['category_name']) && isset($category_colors[$row['category_name']])) {
$color = $category_colors[$row['category_name']];
}
// Format file size
$file_size = $row['file_size'] ?? '0 KB';
if (is_numeric($file_size)) {
$file_size = formatFileSize($file_size);
}
$manuals[] = [
'id' => $row['id'],
'title' => $row['title'],
'description' => $row['description'] ?? 'Deskripsi tidak tersedia.',
'file' => $row['filepath'],
'file_size' => $file_size,
'category' => $row['category_name'] ?? 'Umum',
'icon' => $icon,
'color' => $color,
'date' => $row['created_at'],
'download_count' => $row['download_count'] ?? 0,
'filename' => $row['filename'] ?? basename($row['filepath'])
];
}
}
// =====================================================
// FUNGSI FORMAT FILE SIZE
// =====================================================
function formatFileSize($bytes) {
if ($bytes >= 1073741824) {
return number_format($bytes / 1073741824, 2) . ' GB';
} elseif ($bytes >= 1048576) {
return number_format($bytes / 1048576, 2) . ' MB';
} elseif ($bytes >= 1024) {
return number_format($bytes / 1024, 2) . ' KB';
} else {
return $bytes . ' B';
}
}
// =====================================================
// GET UNIQUE CATEGORIES UNTUK FILTER
// =====================================================
$categories = array_unique(array_column($manuals, 'category'));
// Include header
include 'includes/header.php';
?>
<style>
/* =====================================================
PAGE STYLE - MANUAL & DOKUMEN
===================================================== */
.manual-header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 60px 0 50px;
color: white;
position: relative;
overflow: hidden;
}
.manual-header::before {
content: '';
position: absolute;
top: -50%;
right: -20%;
width: 500px;
height: 500px;
background: rgba(255,255,255,0.05);
border-radius: 50%;
}
.manual-header::after {
content: '';
position: absolute;
bottom: -40%;
left: -10%;
width: 400px;
height: 400px;
background: rgba(255,255,255,0.03);
border-radius: 50%;
}
.manual-header h1 {
font-weight: 800;
font-size: 2.8rem;
position: relative;
z-index: 1;
}
.manual-header p {
font-size: 1.2rem;
opacity: 0.9;
position: relative;
z-index: 1;
max-width: 600px;
}
/* Filter Buttons */
.filter-section {
margin-top: -30px;
position: relative;
z-index: 2;
}
.filter-buttons {
display: flex;
flex-wrap: wrap;
gap: 10px;
justify-content: center;
}
.filter-btn {
padding: 8px 20px;
border-radius: 30px;
border: 2px solid #e2e8f0;
background: white;
color: #4a5568;
font-size: 0.9rem;
font-weight: 500;
transition: all 0.3s;
cursor: pointer;
}
.filter-btn:hover {
border-color: #667eea;
color: #667eea;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(102,126,234,0.15);
}
.filter-btn.active {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-color: #667eea;
color: white;
}
/* Manual Cards */
.manual-card {
background: white;
border-radius: 16px;
padding: 25px;
box-shadow: 0 4px 20px rgba(0,0,0,0.06);
border: 1px solid #f0f0f0;
transition: all 0.3s;
height: 100%;
display: flex;
flex-direction: column;
}
.manual-card:hover {
transform: translateY(-6px);
box-shadow: 0 12px 40px rgba(0,0,0,0.10);
border-color: #667eea;
}
.manual-card .card-icon {
width: 60px;
height: 60px;
border-radius: 14px;
display: flex;
align-items: center;
justify-content: center;
font-size: 28px;
color: white;
margin-bottom: 16px;
flex-shrink: 0;
}
.manual-card .card-icon.bg-danger { background: linear-gradient(135deg, #e74a3b, #c0392b); }
.manual-card .card-icon.bg-info { background: linear-gradient(135deg, #36b9cc, #2c9faf); }
.manual-card .card-icon.bg-success { background: linear-gradient(135deg, #1cc88a, #13855c); }
.manual-card .card-icon.bg-warning { background: linear-gradient(135deg, #f6c23e, #dda20a); }
.manual-card .card-icon.bg-primary { background: linear-gradient(135deg, #4e73df, #224abe); }
.manual-card .card-icon.bg-secondary { background: linear-gradient(135deg, #858796, #5a5c69); }
.manual-card .card-category {
font-size: 0.7rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.5px;
color: #667eea;
margin-bottom: 4px;
}
.manual-card .card-title {
font-size: 1.15rem;
font-weight: 700;
color: #2d3748;
margin-bottom: 8px;
line-height: 1.4;
}
.manual-card .card-desc {
font-size: 0.9rem;
color: #718096;
line-height: 1.6;
flex-grow: 1;
margin-bottom: 16px;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
.manual-card .card-meta {
display: flex;
align-items: center;
gap: 16px;
font-size: 0.8rem;
color: #a0aec0;
padding-top: 14px;
border-top: 1px solid #f0f0f0;
margin-bottom: 16px;
flex-wrap: wrap;
}
.manual-card .card-meta span {
display: flex;
align-items: center;
gap: 4px;
}
.manual-card .card-meta .download-count {
color: #667eea;
font-weight: 600;
}
.manual-card .btn-download {
padding: 10px 20px;
border-radius: 10px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
font-weight: 600;
font-size: 0.9rem;
transition: all 0.3s;
text-align: center;
text-decoration: none;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 8px;
}
.manual-card .btn-download:hover {
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(102,126,234,0.35);
color: white;
}
.manual-card .btn-download i {
font-size: 1rem;
}
/* Search Box */
.search-box {
position: relative;
max-width: 500px;
margin: 0 auto;
}
.search-box input {
width: 100%;
padding: 14px 20px 14px 50px;
border-radius: 30px;
border: 2px solid #e2e8f0;
font-size: 1rem;
transition: all 0.3s;
background: white;
}
.search-box input:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 4px rgba(102,126,234,0.1);
}
.search-box i {
position: absolute;
left: 18px;
top: 50%;
transform: translateY(-50%);
color: #a0aec0;
font-size: 1.1rem;
}
/* Empty State */
.empty-state {
text-align: center;
padding: 60px 20px;
color: #a0aec0;
}
.empty-state i {
font-size: 64px;
margin-bottom: 20px;
color: #e2e8f0;
}
.empty-state h4 {
color: #2d3748;
margin-bottom: 8px;
}
/* Responsive */
@media (max-width: 768px) {
.manual-header {
padding: 40px 0 30px;
}
.manual-header h1 {
font-size: 2rem;
}
.manual-header p {
font-size: 1rem;
}
.filter-section {
margin-top: -20px;
}
.filter-btn {
padding: 6px 14px;
font-size: 0.8rem;
}
.manual-card {
padding: 20px;
}
.manual-card .card-title {
font-size: 1rem;
}
}
@media (max-width: 576px) {
.manual-header h1 {
font-size: 1.6rem;
}
.search-box input {
padding: 12px 16px 12px 44px;
font-size: 0.9rem;
}
.manual-card .card-meta {
flex-wrap: wrap;
gap: 8px;
}
}
</style>
<!-- =====================================================
HEADER SECTION
===================================================== -->
<section class="manual-header">
<div class="container">
<div class="row align-items-center">
<div class="col-lg-7">
<h1>
<i class="fas fa-book-open me-3"></i>Manual & Dokumen
</h1>
<p class="mb-0">
Unduh berbagai manual, panduan, dan dokumen resmi
untuk memudahkan Anda dalam menggunakan layanan kami.
</p>
</div>
<div class="col-lg-5 text-center text-lg-end mt-4 mt-lg-0">
<span class="badge bg-light text-dark px-4 py-2 rounded-pill">
<i class="fas fa-file-pdf me-2 text-danger"></i>
<?php echo count($manuals); ?> Dokumen Tersedia
</span>
</div>
</div>
</div>
</section>
<!-- =====================================================
FILTER & SEARCH
===================================================== -->
<section class="filter-section">
<div class="container">
<div class="card shadow-sm border-0 rounded-4 p-4">
<div class="row g-3 align-items-center">
<div class="col-lg-7">
<div class="filter-buttons" id="filterButtons">
<button class="filter-btn active" data-filter="all">Semua</button>
<?php foreach ($categories as $category): ?>
<button class="filter-btn" data-filter="<?php echo strtolower($category); ?>">
<?php echo htmlspecialchars($category); ?>
</button>
<?php endforeach; ?>
</div>
</div>
<div class="col-lg-5">
<div class="search-box">
<i class="fas fa-search"></i>
<input type="text" id="searchInput" placeholder="Cari manual atau dokumen...">
</div>
</div>
</div>
</div>
</div>
</section>
<!-- =====================================================
MANUAL CARDS GRID
===================================================== -->
<section class="py-4">
<div class="container">
<div class="row g-4" id="manualGrid">
<?php if (!empty($manuals)): ?>
<?php foreach ($manuals as $manual): ?>
<div class="col-md-6 col-lg-4 manual-item"
data-category="<?php echo strtolower($manual['category']); ?>"
data-title="<?php echo strtolower($manual['title']); ?>"
data-desc="<?php echo strtolower($manual['description']); ?>">
<div class="manual-card">
<!-- Icon -->
<div class="card-icon bg-<?php echo $manual['color']; ?>">
<i class="fas <?php echo $manual['icon']; ?>"></i>
</div>
<!-- Category -->
<div class="card-category">
<i class="fas fa-tag me-1"></i>
<?php echo htmlspecialchars($manual['category']); ?>
</div>
<!-- Title -->
<h5 class="card-title"><?php echo htmlspecialchars($manual['title']); ?></h5>
<!-- Description -->
<p class="card-desc"><?php echo htmlspecialchars($manual['description']); ?></p>
<!-- Meta -->
<div class="card-meta">
<span>
<i class="fas fa-file"></i>
<?php echo $manual['file_size']; ?>
</span>
<span>
<i class="fas fa-calendar-alt"></i>
<?php echo date('d M Y', strtotime($manual['date'])); ?>
</span>
<span class="download-count">
<i class="fas fa-download"></i>
<?php echo number_format($manual['download_count']); ?>x
</span>
</div>
<!-- Download Button -->
<a href="<?php echo BASE_URL . '/' . $manual['file']; ?>"
class="btn-download"
download
onclick="trackDownload(<?php echo $manual['id']; ?>, '<?php echo addslashes($manual['title']); ?>')">
<i class="fas fa-download"></i>
Unduh Dokumen
</a>
</div>
</div>
<?php endforeach; ?>
<?php else: ?>
<div class="col-12">
<div class="empty-state">
<i class="fas fa-file-search"></i>
<h4>Belum Ada Dokumen</h4>
<p class="text-muted">Saat ini belum ada dokumen yang tersedia untuk diunduh.</p>
</div>
</div>
<?php endif; ?>
</div>
<!-- Empty State untuk hasil pencarian -->
<div class="empty-state" id="emptyState" style="display: none;">
<i class="fas fa-file-search"></i>
<h4>Dokumen Tidak Ditemukan</h4>
<p class="text-muted">Tidak ada dokumen yang sesuai dengan pencarian Anda.</p>
</div>
</div>
</section>
<!-- =====================================================
JAVASCRIPT
===================================================== -->
<script>
// BASE_URL dari PHP
const BASE_URL = '<?php echo BASE_URL; ?>';
// =====================================================
// FILTER FUNGSI
// =====================================================
document.addEventListener('DOMContentLoaded', function() {
const filterButtons = document.querySelectorAll('.filter-btn');
const searchInput = document.getElementById('searchInput');
const manualItems = document.querySelectorAll('.manual-item');
const emptyState = document.getElementById('emptyState');
const gridContainer = document.getElementById('manualGrid');
// Fungsi filter
function filterManuals() {
const activeFilter = document.querySelector('.filter-btn.active');
const filterValue = activeFilter ? activeFilter.dataset.filter : 'all';
const searchValue = searchInput.value.toLowerCase().trim();
let visibleCount = 0;
manualItems.forEach(item => {
const category = item.dataset.category;
const title = item.dataset.title;
const desc = item.dataset.desc;
const matchFilter = filterValue === 'all' || category === filterValue;
const matchSearch = searchValue === '' ||
title.includes(searchValue) ||
desc.includes(searchValue);
if (matchFilter && matchSearch) {
item.style.display = 'block';
visibleCount++;
} else {
item.style.display = 'none';
}
});
// Tampilkan empty state jika tidak ada hasil
if (visibleCount === 0 && manualItems.length > 0) {
emptyState.style.display = 'block';
} else {
emptyState.style.display = 'none';
}
}
// Event listener filter buttons
filterButtons.forEach(btn => {
btn.addEventListener('click', function() {
filterButtons.forEach(b => b.classList.remove('active'));
this.classList.add('active');
filterManuals();
});
});
// Event listener search input
searchInput.addEventListener('input', filterManuals);
// Initial filter
filterManuals();
});
// =====================================================
// TRACK DOWNLOAD
// =====================================================
function trackDownload(id, title) {
console.log('📥 Download: ' + title + ' (ID: ' + id + ')');
// Kirim tracking ke server untuk update download_count
fetch(BASE_URL + '/track-download.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: 'id=' + id
}).catch(err => console.log('Tracking error:', err));
}
</script>
<?php include 'includes/footer.php'; ?>