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 :  D:/bpkd_29052026/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : D://bpkd_29052026/laporan.php
<?php
/**
 * Halaman Laporan & Dokumen - Versi Sederhana
 */

require_once 'includes/init.php';

$page_title = 'Laporan & Dokumen - ' . ($settings['site_title'] ?? 'Website Instansi');
$meta_description = 'Unduh berbagai laporan dan dokumen resmi instansi.';

global $conn;

// Get all reports with their categories
$reports = $conn->query("
    SELECT r.*, 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' 
    ORDER BY r.created_at DESC
");

// Get unique categories for filter
$categories = [];
$all_reports = [];
while($row = $reports->fetch_assoc()) {
    $all_reports[] = $row;
    if (!empty($row['category_name']) && !in_array($row['category_name'], $categories)) {
        $categories[] = $row['category_name'];
    }
}
sort($categories);

include 'includes/header.php';
?>

<!-- Page Header -->
<section class="page-header text-white py-4">
</section>

<div class="container">
  <div class="row">
    <?php if (isset($_SESSION['download_error'])): ?>
    <div class="alert alert-danger alert-dismissible fade show" role="alert">
        <i class="fas fa-exclamation-triangle me-2"></i>
        <?php 
            echo $_SESSION['download_error'];
            unset($_SESSION['download_error']);
        ?>
        <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    </div>
    <?php endif; ?>
  </div>  
  <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">

                <h4 class="text-center">PUBLIKASI LAPORAN KEUANGAN DAERAH</h4>
                
                <br/>
                <div class="row" style="overflow: auto">

                    <div class="card-body">

                        <!-- Laporan Section -->
                        <section class="laporan-section py-2">
                            <div class="container">
                                <!-- Filter Bar -->
                                <div class="card shadow-sm mb-4">
                                    <div class="card-body">
                                        <div class="row g-3 align-items-end">
                                            <div class="col-md-4">
                                                <label class="form-label fw-semibold mb-1">Kategori Laporan</label>
                                                <select id="categoryFilter" class="form-select">
                                                    <option value="all">-- Semua Kategori --</option>
                                                    <?php foreach ($categories as $cat): ?>
                                                        <option value="<?php echo htmlspecialchars($cat); ?>">
                                                            <?php echo htmlspecialchars($cat); ?>
                                                        </option>
                                                    <?php endforeach; ?>
                                                </select>
                                            </div>
                                            <div class="col-md-5">
                                                <label class="form-label fw-semibold mb-1">Cari Laporan</label>
                                                <div class="input-group">
                                                    <input type="text" id="searchInput" class="form-control" placeholder="Cari judul laporan...">
                                                    <button class="btn btn-primary" id="searchBtn" type="button">
                                                        <i class="fas fa-search"></i>
                                                    </button>
                                                </div>
                                            </div>
                                            <div class="col-md-3">
                                                <button id="resetBtn" class="btn btn-outline-secondary w-100">
                                                    <i class="fas fa-sync-alt me-2"></i>Reset Filter
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <!-- Data Table -->
                                <div class="card shadow-sm">
                                    <div class="card-body p-0">
                                        <div class="table-responsive">
                                            <table class="table table-hover mb-0" id="reportsTable">
                                                <thead class="table-light">
                                                    <tr>
                                                        <th width="5%">No</th>
                                                        <th width="40%">Judul Laporan</th>
                                                        <th width="15%">Kategori</th>
                                                        <th width="10%">Ukuran</th>
                                                        <th width="15%">TglUpload</th>
                                                        <th width="15%">Aksi</th>
                                                    </thead>
                                                    <tbody id="tableBody">
                                                        <?php 
                                                        $no = 1;
                                                        foreach ($all_reports as $report): 
                                                        ?>
                                                        <tr data-category="<?php echo htmlspecialchars($report['category_name'] ?? ''); ?>"
                                                            data-title="<?php echo htmlspecialchars(strtolower($report['title'])); ?>"
                                                            data-date="<?php echo $report['created_at']; ?>">
                                                            <td class="text-center"><?php echo $no++; ?></td>
                                                            <td>
                                                                <strong><?php echo htmlspecialchars($report['title']); ?></strong>
                                                                <?php if(!empty($report['description'])): ?>
                                                                <br><small class="text-muted"><?php echo htmlspecialchars(substr($report['description'], 0, 80)); ?>...</small>
                                                                <?php endif; ?>
                                                            </td>
                                                            <td>
                                                                <?php if(!empty($report['category_name'])): ?>
                                                                <span class="badge bg-info"><?php echo htmlspecialchars($report['category_name']); ?></span>
                                                                <?php else: ?>
                                                                <span class="badge bg-secondary">-</span>
                                                                <?php endif; ?>
                                                            </td>
                                                            <td><?php echo $report['file_size']; ?></td>
                                                            <td><?php echo date('d-m-Y H:i:s', strtotime($report['created_at'])); ?></td>
                                                            <td>
                                                                <a href="download.php?id=<?php echo $report['id']; ?>" >
                                                                    <img src="uploads/statis/pdf1.png" height="40px" width="40px"/>
                                                                </a>
                                                            </td>
                                                        </tr>
                                                        <?php endforeach; ?>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                    
                                    <!-- Pagination -->
                                    <div class="card-footer bg-white">
                                        <div class="d-flex justify-content-between align-items-center flex-wrap">
                                            <div class="mb-2 mb-md-0">
                                                <select id="pageSize" class="form-select form-select-sm" style="width: auto; display: inline-block;">
                                                    <option value="10">10 per halaman</option>
                                                    <option value="15" selected>15 per halaman</option>
                                                    <option value="25">25 per halaman</option>
                                                    <option value="50">50 per halaman</option>
                                                    <option value="all">Semua</option>
                                                </select>
                                            </div>
                                            <div>
                                                <nav>
                                                    <ul class="pagination pagination-sm mb-0" id="pagination">
                                                        <!-- Pagination akan di-generate oleh JavaScript -->
                                                    </ul>
                                                </nav>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </section>

                    </div>
                </div>
            </div>
        </div>
    </div>
  </div>
</div>                        

<script>
// Data dari PHP
const allReports = <?php echo json_encode($all_reports); ?>;
let currentPage = 1;
let pageSize = 15;
let filteredReports = [...allReports];

// Fungsi untuk merender tabel
function renderTable() {
    const tbody = document.getElementById('tableBody');
    tbody.innerHTML = '';
    
    // Hitung pagination
    let displayReports = filteredReports;
    let totalPages = 1;
    
    if (pageSize !== 'all') {
        totalPages = Math.ceil(filteredReports.length / pageSize);
        const start = (currentPage - 1) * pageSize;
        const end = start + pageSize;
        displayReports = filteredReports.slice(start, end);
    }
    
    // Render baris tabel
    let no = (pageSize !== 'all') ? (currentPage - 1) * pageSize + 1 : 1;
    
    displayReports.forEach((report, index) => {
        const row = tbody.insertRow();
        
        // No
        const cellNo = row.insertCell(0);
        cellNo.className = 'text-center';
        cellNo.textContent = no++;
        
        // Judul
        const cellTitle = row.insertCell(1);
        let titleHtml = `<strong>${escapeHtml(report.title)}</strong>`;
        if (report.description) {
            titleHtml += `<br><small class="text-muted">${escapeHtml(report.description.substring(0, 80))}${report.description.length > 80 ? '...' : ''}</small>`;
        }
        cellTitle.innerHTML = titleHtml;
        
        // Kategori
        const cellCategory = row.insertCell(2);
        if (report.category_name) {
            cellCategory.innerHTML = `<span class="badge bg-info">${escapeHtml(report.category_name)}</span>`;
        } else {
            cellCategory.innerHTML = `<span class="badge bg-secondary">-</span>`;
        }
        
        // Ukuran
        const cellSize = row.insertCell(3);
        cellSize.textContent = report.file_size || '-';
        
        // Tanggal
        const cellDate = row.insertCell(4);
        cellDate.textContent = report.created_at ? formatDate(report.created_at) : '-';
        
        // Aksi
        const cellAction = row.insertCell(5);
        cellAction.innerHTML = `<a href="download.php?id=${report.id}"><img src="uploads/statis/pdf1.png" height="40px" width="40px"/></a>`;
    });
    
    // Update pagination controls
    if (pageSize !== 'all') {
        renderPagination(totalPages);
    } else {
        document.getElementById('pagination').innerHTML = '';
    }
    
    // Update info jumlah data
    updateInfo();
}

// Fungsi untuk render pagination
function renderPagination(totalPages) {
    const paginationUl = document.getElementById('pagination');
    paginationUl.innerHTML = '';
    
    // Previous button
    const prevLi = document.createElement('li');
    prevLi.className = `page-item ${currentPage === 1 ? 'disabled' : ''}`;
    prevLi.innerHTML = `<a class="page-link" href="#" data-page="${currentPage - 1}">&laquo;</a>`;
    paginationUl.appendChild(prevLi);
    
    // Page numbers
    let startPage = Math.max(1, currentPage - 2);
    let endPage = Math.min(totalPages, currentPage + 2);
    
    if (startPage > 1) {
        const firstLi = document.createElement('li');
        firstLi.className = 'page-item';
        firstLi.innerHTML = `<a class="page-link" href="#" data-page="1">1</a>`;
        paginationUl.appendChild(firstLi);
        
        if (startPage > 2) {
            const dotsLi = document.createElement('li');
            dotsLi.className = 'page-item disabled';
            dotsLi.innerHTML = '<span class="page-link">...</span>';
            paginationUl.appendChild(dotsLi);
        }
    }
    
    for (let i = startPage; i <= endPage; i++) {
        const li = document.createElement('li');
        li.className = `page-item ${i === currentPage ? 'active' : ''}`;
        li.innerHTML = `<a class="page-link" href="#" data-page="${i}">${i}</a>`;
        paginationUl.appendChild(li);
    }
    
    if (endPage < totalPages) {
        if (endPage < totalPages - 1) {
            const dotsLi = document.createElement('li');
            dotsLi.className = 'page-item disabled';
            dotsLi.innerHTML = '<span class="page-link">...</span>';
            paginationUl.appendChild(dotsLi);
        }
        
        const lastLi = document.createElement('li');
        lastLi.className = 'page-item';
        lastLi.innerHTML = `<a class="page-link" href="#" data-page="${totalPages}">${totalPages}</a>`;
        paginationUl.appendChild(lastLi);
    }
    
    // Next button
    const nextLi = document.createElement('li');
    nextLi.className = `page-item ${currentPage === totalPages ? 'disabled' : ''}`;
    nextLi.innerHTML = `<a class="page-link" href="#" data-page="${currentPage + 1}">&raquo;</a>`;
    paginationUl.appendChild(nextLi);
    
    // Add click handlers
    document.querySelectorAll('#pagination .page-link').forEach(link => {
        link.addEventListener('click', function(e) {
            e.preventDefault();
            const page = parseInt(this.dataset.page);
            if (!isNaN(page) && page >= 1 && page <= totalPages && page !== currentPage) {
                currentPage = page;
                renderTable();
            }
        });
    });
}

// Fungsi untuk update info jumlah data
function updateInfo() {
    const infoDiv = document.querySelector('.dataTables_info');
    if (!infoDiv) {
        const infoContainer = document.createElement('div');
        infoContainer.className = 'dataTables_info small text-muted mt-2';
        document.querySelector('.card-footer .d-flex').prepend(infoContainer);
    }
    
    const infoContainer = document.querySelector('.dataTables_info');
    const start = (pageSize !== 'all') ? (currentPage - 1) * pageSize + 1 : 1;
    const end = (pageSize !== 'all') ? Math.min(currentPage * pageSize, filteredReports.length) : filteredReports.length;
    
    infoContainer.innerHTML = `Menampilkan ${start} sampai ${end} dari ${filteredReports.length} data`;
}

// Helper function
function escapeHtml(text) {
    if (!text) return '';
    const div = document.createElement('div');
    div.textContent = text;
    return div.innerHTML;
}

function formatDate(dateString) {
    //const date = new Date(dateString);
    //return date.toLocaleDateString('id-ID');
    
    if (!dateString) return '-';
    
    const date = new Date(dateString);
    
    // Cek apakah date valid
    if (isNaN(date.getTime())) return '-';
    
    const day = String(date.getDate()).padStart(2, '0');
    const month = String(date.getMonth() + 1).padStart(2, '0'); // Bulan dimulai dari 0
    const year = date.getFullYear();
    const hours = String(date.getHours()).padStart(2, '0');
    const minutes = String(date.getMinutes()).padStart(2, '0');
    const seconds = String(date.getSeconds()).padStart(2, '0');
    
    return `${day}-${month}-${year} ${hours}:${minutes}:${seconds}`;
}

// Filter functions
function applyFilters() {
    const selectedCategory = document.getElementById('categoryFilter').value;
    const searchText = document.getElementById('searchInput').value.toLowerCase();
    
    filteredReports = allReports.filter(report => {
        // Filter kategori
        if (selectedCategory !== 'all' && report.category_name !== selectedCategory) {
            return false;
        }
        
        // Filter pencarian
        if (searchText && !report.title.toLowerCase().includes(searchText)) {
            return false;
        }
        
        return true;
    });
    
    // Reset ke halaman pertama
    currentPage = 1;
    renderTable();
}

// Event listeners
document.getElementById('categoryFilter').addEventListener('change', applyFilters);
document.getElementById('searchBtn').addEventListener('click', applyFilters);
document.getElementById('searchInput').addEventListener('keyup', function(e) {
    if (e.key === 'Enter') {
        applyFilters();
    }
});
document.getElementById('resetBtn').addEventListener('click', function() {
    document.getElementById('categoryFilter').value = 'all';
    document.getElementById('searchInput').value = '';
    filteredReports = [...allReports];
    currentPage = 1;
    renderTable();
});
document.getElementById('pageSize').addEventListener('change', function() {
    pageSize = this.value === 'all' ? 'all' : parseInt(this.value);
    currentPage = 1;
    renderTable();
});

// Initial render
renderTable();
</script>

<style>
/* Table Styles */
.table th {
    background-color: #f8f9fc;
    border-bottom: 2px solid #e3e6f0;
}
.table td {
    vertical-align: middle;
}
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    transition: all 0.3s;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102,126,234,0.3);
}
.badge {
    font-weight: 500;
    padding: 5px 10px;
}
/* Pagination styles */
.pagination .page-item.active .page-link {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #4e73df;
    color: white;
}
.pagination .page-link {
    color: #4e73df;
    cursor: pointer;
}
.pagination .page-link:hover {
    background: #e9ecef;
    color: #224abe;
}
.dataTables_info {
    padding-top: 0.5rem;
}
</style>

<?php include 'includes/footer.php'; ?>

Youez - 2016 - github.com/yon3zu
LinuXploit