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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /bpkd_29052026/admin//dashboard.php
<?php
$page_title = 'Dashboard';
require_once 'config/database.php';
require_once 'includes/init.php';
requireLogin();

// Get statistics
$stats = [];

// Total articles
$result = $conn->query("SELECT COUNT(*) as total FROM articles");
$stats['total_articles'] = $result->fetch_assoc()['total'];

// Published articles
$result = $conn->query("SELECT COUNT(*) as total FROM articles WHERE status = 'published'");
$stats['published_articles'] = $result->fetch_assoc()['total'];

// Draft articles
$result = $conn->query("SELECT COUNT(*) as total FROM articles WHERE status = 'draft'");
$stats['draft_articles'] = $result->fetch_assoc()['total'];

// Total categories
$result = $conn->query("SELECT COUNT(*) as total FROM categories");
$stats['total_categories'] = $result->fetch_assoc()['total'];

// Total tags
$result = $conn->query("SELECT COUNT(*) as total FROM tags");
$stats['total_tags'] = $result->fetch_assoc()['total'];

// Total pages
$result = $conn->query("SELECT COUNT(*) as total FROM pages");
$stats['total_pages'] = $result->fetch_assoc()['total'];

// Today's visitors
$today = date('Y-m-d');
$result = $conn->query("SELECT COUNT(DISTINCT ip_address) as total FROM visitors WHERE visit_date = '$today'");
$stats['today_visitors'] = $result->fetch_assoc()['total'];

// Total visitors (all time)
$result = $conn->query("SELECT COUNT(DISTINCT ip_address) as total FROM visitors");
$stats['total_visitors'] = $result->fetch_assoc()['total'];

// =====================================================
// AMBIL 10 ARTIKEL DENGAN VIEWS TERBANYAK
// =====================================================
$top_articles = $conn->query("
    SELECT a.id, a.title, a.slug, a.views, a.status, a.created_at,
           c.name as category_name,
           u.full_name as author_name
    FROM articles a 
    LEFT JOIN categories c ON a.category_id = c.id 
    LEFT JOIN users u ON a.author_id = u.id 
    ORDER BY a.views DESC 
    LIMIT 10
");

// =====================================================
// AMBIL 10 HALAMAN DENGAN VIEWS TERBANYAK (jika ada kolom views di pages)
// Jika tidak ada kolom views di pages, ambil artikel saja
// =====================================================
$top_pages = $conn->query("
    SELECT id, title, slug, views, status, created_at
    FROM pages 
    WHERE views IS NOT NULL
    ORDER BY views DESC 
    LIMIT 10
");

// Jika tabel pages tidak memiliki kolom views, tampilkan artikel populer saja
$has_pages_views = $top_pages && $top_pages->num_rows > 0;

// =====================================================
// AMBIL 5 ARTIKEL TERBARU
// =====================================================
$recent_articles = $conn->query("
    SELECT a.*, c.name as category_name, u.full_name as author_name 
    FROM articles a 
    LEFT JOIN categories c ON a.category_id = c.id 
    LEFT JOIN users u ON a.author_id = u.id 
    ORDER BY a.created_at DESC 
    LIMIT 5
");

// =====================================================
// AMBIL 5 PENGUMUMAN TERBARU
// =====================================================
$recent_announcements = $conn->query("
    SELECT * FROM announcements 
    ORDER BY created_at DESC 
    LIMIT 5
");

// =====================================================
// AMBIL KOMENTAR PENDING
// =====================================================
$pending_comments = $conn->query("
    SELECT c.*, a.title as article_title 
    FROM comments c 
    LEFT JOIN articles a ON c.article_id = a.id 
    WHERE c.status = 'pending' 
    ORDER BY c.created_at DESC 
    LIMIT 5
");

// =====================================================
// DATA ARTIKEL PER BULAN (1 TAHUN TERAKHIR)
// =====================================================
$months = [];
$articles_per_month = [];
$published_per_month = [];
$draft_per_month = [];

// Loop 12 bulan terakhir
for ($i = 11; $i >= 0; $i--) {
    $date = date('Y-m-d', strtotime("-$i months"));
    $month_name = date('M Y', strtotime($date));
    $month_start = date('Y-m-01', strtotime($date));
    $month_end = date('Y-m-t', strtotime($date));
    
    $months[] = $month_name;
    
    // Total artikel bulan ini
    $result = $conn->query("
        SELECT COUNT(*) as total 
        FROM articles 
        WHERE created_at BETWEEN '$month_start' AND '$month_end 23:59:59'
    ");
    $articles_per_month[] = $result->fetch_assoc()['total'];
    
    // Artikel published bulan ini
    $result = $conn->query("
        SELECT COUNT(*) as total 
        FROM articles 
        WHERE status = 'published' 
        AND created_at BETWEEN '$month_start' AND '$month_end 23:59:59'
    ");
    $published_per_month[] = $result->fetch_assoc()['total'];
    
    // Artikel draft bulan ini
    $result = $conn->query("
        SELECT COUNT(*) as total 
        FROM articles 
        WHERE status = 'draft' 
        AND created_at BETWEEN '$month_start' AND '$month_end 23:59:59'
    ");
    $draft_per_month[] = $result->fetch_assoc()['total'];
}


// Visitor chart data (last 7 days)
$visitor_data = [];
for ($i = 6; $i >= 0; $i--) {
    $date = date('Y-m-d', strtotime("-$i days"));
    $result = $conn->query("SELECT COUNT(DISTINCT ip_address) as total FROM visitors WHERE visit_date = '$date'");
    $visitor_data['labels'][] = date('d M', strtotime($date));
    $visitor_data['data'][] = $result->fetch_assoc()['total'];
}

// Include header
require_once 'includes/header.php';
?>

<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">Dashboard</h1>
        <a href="article-add.php" class="btn btn-primary">
            <i class="fas fa-plus me-2"></i>Tulis Berita Baru
        </a>
    </div>

    <!-- Statistics Cards -->
    <div class="row">
        <!-- Total Articles Card -->
        <div class="col-xl-2 col-md-3 mb-4">
            <div class="card stat-card bg-primary text-white h-100">
                <div class="card-body">
                    <div class="row align-items-center">
                        <div class="col-8">
                            <h6 class="text-white-50 mb-1">Total Artikel</h6>
                            <h3 class="mb-0"><?php echo number_format($stats['total_articles']); ?></h3>
                        </div>
                        <div class="col-4 text-end">
                            <i class="fas fa-newspaper fa-3x text-white-50"></i>
                        </div>
                    </div>
                </div>
                <div class="card-footer d-flex align-items-center justify-content-between">
                    <small>Published: <?php echo $stats['published_articles']; ?></small>
                    <small>Draft: <?php echo $stats['draft_articles']; ?></small>
                </div>
            </div>
        </div>

        <!-- Categories Card -->
        <div class="col-xl-2 col-md-3 mb-4">
            <div class="card stat-card bg-success text-white h-100">
                <div class="card-body">
                    <div class="row align-items-center">
                        <div class="col-8">
                            <h6 class="text-white-50 mb-1">Kategori</h6>
                            <h3 class="mb-0"><?php echo number_format($stats['total_categories']); ?></h3>
                        </div>
                        <div class="col-4 text-end">
                            <i class="fas fa-folder fa-3x text-white-50"></i>
                        </div>
                    </div>
                </div>
                <div class="card-footer d-flex align-items-center justify-content-between">
                    <small>Kelola kategori</small>
                    <i class="fas fa-arrow-right"></i>
                </div>
            </div>
        </div>

        <!-- Tags Card -->
        <div class="col-xl-2 col-md-3 mb-4">
            <div class="card stat-card bg-info text-white h-100">
                <div class="card-body">
                    <div class="row align-items-center">
                        <div class="col-8">
                            <h6 class="text-white-50 mb-1">Tag</h6>
                            <h3 class="mb-0"><?php echo number_format($stats['total_tags']); ?></h3>
                        </div>
                        <div class="col-4 text-end">
                            <i class="fas fa-tags fa-3x text-white-50"></i>
                        </div>
                    </div>
                </div>
                <div class="card-footer d-flex align-items-center justify-content-between">
                    <small>Kelola tag</small>
                    <i class="fas fa-arrow-right"></i>
                </div>
            </div>
        </div>

        <!-- Pages Card -->
        <div class="col-xl-2 col-md-3 mb-4">
            <div class="card stat-card bg-warning text-white h-100">
                <div class="card-body">
                    <div class="row align-items-center">
                        <div class="col-8">
                            <h6 class="text-white-50 mb-1">Halaman</h6>
                            <h3 class="mb-0"><?php echo number_format($stats['total_pages']); ?></h3>
                        </div>
                        <div class="col-4 text-end">
                            <i class="fas fa-file-alt fa-3x text-white-50"></i>
                        </div>
                    </div>
                </div>
                <div class="card-footer d-flex align-items-center justify-content-between">
                    <small>Kelola halaman</small>
                    <i class="fas fa-arrow-right"></i>
                </div>
            </div>
        </div>

        <!-- Today Visitors Card -->
        <div class="col-xl-2 col-md-3 mb-4">
            <div class="card stat-card bg-danger text-white h-100">
                <div class="card-body">
                    <div class="row align-items-center">
                        <div class="col-8">
                            <h6 class="text-white-50 mb-1">Pengunjung Hari Ini</h6>
                            <h3 class="mb-0"><?php echo number_format($stats['today_visitors']); ?></h3>
                        </div>
                        <div class="col-4 text-end">
                            <i class="fas fa-users fa-3x text-white-50"></i>
                        </div>
                    </div>
                </div>
                <div class="card-footer d-flex align-items-center justify-content-between">
                    <small>Unique visitors</small>
                    <i class="fas fa-arrow-right"></i>
                </div>
            </div>
        </div>

        <!-- Total Visitors Card -->
        <div class="col-xl-2 col-md-3 mb-4">
            <div class="card stat-card bg-secondary text-white h-100">
                <div class="card-body">
                    <div class="row align-items-center">
                        <div class="col-8">
                            <h6 class="text-white-50 mb-1">Total Pengunjung</h6>
                            <h3 class="mb-0"><?php echo number_format($stats['total_visitors']); ?></h3>
                        </div>
                        <div class="col-4 text-end">
                            <i class="fas fa-chart-line fa-3x text-white-50"></i>
                        </div>
                    </div>
                </div>
                <div class="card-footer d-flex align-items-center justify-content-between">
                    <small>All time</small>
                    <i class="fas fa-arrow-right"></i>
                </div>
            </div>
        </div>
    </div>

    <!-- Content Row -->
    <div class="row">
        <!-- Visitor Chart -->
        <div class="col-xl-12 col-lg-12">
            <div class="card shadow mb-4">
                <div class="card-header py-3">
                    <h6 class="m-0 font-weight-bold text-white">Grafik Pengunjung (7 Hari Terakhir)</h6>
                </div>
                <div class="card-body">
                    <canvas id="visitorChart"></canvas>
                </div>
            </div>
        </div>
    </div>
     
    <div class="row">    
        <!-- Top Articles Card -->
        <div class="col-xl-12 col-lg-12">
            <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-white">
                        <i class="fas fa-fire text-warning me-2"></i>10 Artikel Terpopuler
                    </h6>
                    <a href="articles.php?sort=views" class="btn btn-sm btn-primary">
                        <i class="fas fa-chart-line me-1"></i>Lihat Semua
                    </a>
                </div>
                <div class="card-body p-0">
                    <div class="list-group list-group-flush">
                        <?php if ($top_articles && $top_articles->num_rows > 0): ?>
                            <?php 
                            $rank = 1;
                            while($article = $top_articles->fetch_assoc()): 
                                $rank_class = '';
                                if ($rank == 1) $rank_class = 'bg-warning';
                                elseif ($rank == 2) $rank_class = 'bg-secondary';
                                elseif ($rank == 3) $rank_class = 'bg-danger';
                            ?>
                            <a href="article-edit.php?id=<?php echo $article['id']; ?>" class="list-group-item list-group-item-action">
                                <div class="d-flex justify-content-between align-items-center">
                                    <div class="d-flex align-items-center">
                                        <div class="rank-number me-3">
                                            <span class="badge <?php echo $rank_class; ?> rounded-circle p-2" style="width: 35px; height: 35px; display: flex; align-items: center; justify-content: center;">
                                                <?php echo $rank++; ?>
                                            </span>
                                        </div>
                                        <div>
                                            <h6 class="mb-1"><?php echo htmlspecialchars(substr($article['title'], 0, 50)) . (strlen($article['title']) > 50 ? '...' : ''); ?></h6>
                                            <small class="text-muted">
                                                <i class="fas fa-folder me-1"></i><?php echo $article['category_name'] ?? 'Uncategorized'; ?>
                                                <i class="fas fa-user ms-2 me-1"></i><?php echo $article['author_name']; ?>
                                            </small>
                                        </div>
                                    </div>
                                    <div class="text-end">
                                        <span class="badge bg-primary rounded-pill">
                                            <i class="fas fa-eye me-1"></i><?php echo number_format($article['views']); ?>
                                        </span>
                                        <br>
                                        <small class="text-muted"><?php echo date('d/m/Y', strtotime($article['created_at'])); ?></small>
                                    </div>
                                </div>
                                <div class="progress mt-2" style="height: 5px;">
                                    <?php 
                                    $max_views = $conn->query("SELECT MAX(views) as max FROM articles")->fetch_assoc()['max'];
                                    $percent = ($article['views'] / $max_views) * 100;
                                    ?>
                                    <div class="progress-bar bg-primary" role="progressbar" style="width: <?php echo $percent; ?>%" aria-valuenow="<?php echo $percent; ?>" aria-valuemin="0" aria-valuemax="100"></div>
                                </div>
                            </a>
                            <?php endwhile; ?>
                        <?php else: ?>
                            <div class="text-center py-4">
                                <i class="fas fa-newspaper fa-3x text-muted mb-3"></i>
                                <p class="text-muted mb-0">Belum ada artikel</p>
                            </div>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="card-footer bg-light text-center">
                    <small class="text-muted">
                        <i class="fas fa-info-circle me-1"></i>
                        Berdasarkan jumlah views terbanyak
                    </small>
                </div>
            </div>
        </div>
    </div>

    <!-- Second Row - Monthly Articles Chart -->
    <div class="row">
        <div class="col-12">
            <div class="card shadow mb-4">
                <div class="card-header py-3">
                    <h6 class="m-0 font-weight-bold text-white">
                        <i class="fas fa-chart-bar me-2"></i>Statistik Artikel per Bulan (12 Bulan Terakhir)
                    </h6>
                </div>
                <div class="card-body">
                    <canvas id="monthlyArticlesChart" style="height: 350px;"></canvas>
                </div>
                <div class="card-footer bg-light">
                    <div class="row text-center">
                        <div class="col-md-4">
                            <div class="small">
                                <span class="badge bg-primary me-1"></span> Total Artikel
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="small">
                                <span class="badge bg-success me-1"></span> Published
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="small">
                                <span class="badge bg-secondary me-1"></span> Draft
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Second Row -->
    <div class="row">
        <!-- Recent Articles -->
        <div class="col-xl-6 col-lg-6">
            <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-white">
                        <i class="fas fa-clock me-2"></i>Artikel Terbaru
                    </h6>
                    <a href="articles.php" class="btn btn-sm btn-primary">
                        Lihat Semua <i class="fas fa-arrow-right ms-1"></i>
                    </a>
                </div>
                <div class="card-body p-0">
                    <div class="table-responsive">
                        <table class="table table-hover mb-0">
                            <thead>
                                <tr>
                                    <th>Judul</th>
                                    <th>Kategori</th>
                                    <th>Status</th>
                                    <th>Tanggal</th>
                                    <th>Aksi</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php if ($recent_articles && $recent_articles->num_rows > 0): ?>
                                    <?php while($article = $recent_articles->fetch_assoc()): ?>
                                    <tr>
                                        <td>
                                            <strong><?php echo htmlspecialchars(substr($article['title'], 0, 40)) . (strlen($article['title']) > 40 ? '...' : ''); ?></strong>
                                        </td>
                                        <td><?php echo $article['category_name'] ?? '-'; ?></td>
                                        <td>
                                            <span class="badge bg-<?php echo $article['status'] == 'published' ? 'success' : 'secondary'; ?>">
                                                <?php echo ucfirst($article['status']); ?>
                                            </span>
                                        </td>
                                        <td><?php echo date('d/m/Y', strtotime($article['created_at'])); ?></td>
                                        <td>
                                            <a href="article-edit.php?id=<?php echo $article['id']; ?>" class="btn btn-sm btn-info">
                                                <i class="fas fa-edit"></i>
                                            </a>
                                        </td>
                                    </tr>
                                    <?php endwhile; ?>
                                <?php else: ?>
                                    <tr>
                                        <td colspan="5" class="text-center py-3">Belum ada artikel</td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>

        <!-- Recent Announcements -->
        <div class="col-xl-6 col-lg-6">
            <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-white">
                        <i class="fas fa-bullhorn me-2"></i>Pengumuman Terbaru
                    </h6>
                    <a href="announcements.php" class="btn btn-sm btn-primary">
                        Lihat Semua <i class="fas fa-arrow-right ms-1"></i>
                    </a>
                </div>
                <div class="card-body p-0">
                    <div class="table-responsive">
                        <table class="table table-hover mb-0">
                            <thead>
                                <tr>
                                    <th>Judul</th>
                                    <th>Kategori</th>
                                    <th>Prioritas</th>
                                    <th>Tanggal</th>
                                    <th>Aksi</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php if ($recent_announcements && $recent_announcements->num_rows > 0): ?>
                                    <?php while($ann = $recent_announcements->fetch_assoc()): ?>
                                    <tr>
                                        <td>
                                            <strong><?php echo htmlspecialchars(substr($ann['title'], 0, 40)) . (strlen($ann['title']) > 40 ? '...' : ''); ?></strong>
                                        </td>
                                        <td><?php echo $ann['category'] ?? '-'; ?></td>
                                        <td>
                                            <?php
                                            $priority_class = '';
                                            if ($ann['priority'] == 'high') $priority_class = 'danger';
                                            elseif ($ann['priority'] == 'low') $priority_class = 'info';
                                            else $priority_class = 'primary';
                                            ?>
                                            <span class="badge bg-<?php echo $priority_class; ?>">
                                                <?php echo ucfirst($ann['priority']); ?>
                                            </span>
                                        </td>
                                        <td><?php echo date('d/m/Y', strtotime($ann['publish_date'])); ?></td>
                                        <td>
                                            <a href="announcements.php?edit=<?php echo $ann['id']; ?>" class="btn btn-sm btn-info">
                                                <i class="fas fa-edit"></i>
                                            </a>
                                        </td>
                                    </tr>
                                    <?php endwhile; ?>
                                <?php else: ?>
                                    <tr>
                                        <td colspan="5" class="text-center py-3">Belum ada pengumuman</td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Third Row - Pending Comments -->
    <div class="row">
        <div class="col-12">
            <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-white">
                        <i class="fas fa-comments me-2"></i>Komentar Menunggu Moderasi
                        <?php if ($pending_comments && $pending_comments->num_rows > 0): ?>
                        <span class="badge bg-danger ms-2"><?php echo $pending_comments->num_rows; ?> Baru</span>
                        <?php endif; ?>
                    </h6>
                    <a href="comments.php?status=pending" class="btn btn-sm btn-primary">
                        Moderasi <i class="fas fa-arrow-right ms-1"></i>
                    </a>
                </div>
                <div class="card-body p-0">
                    <?php if ($pending_comments && $pending_comments->num_rows > 0): ?>
                        <div class="list-group list-group-flush">
                            <?php while($comment = $pending_comments->fetch_assoc()): ?>
                            <div class="list-group-item">
                                <div class="d-flex justify-content-between align-items-start">
                                    <div class="flex-grow-1">
                                        <div class="d-flex align-items-center mb-2">
                                            <div class="bg-secondary text-white rounded-circle d-flex align-items-center justify-content-center me-2" style="width: 35px; height: 35px;">
                                                <i class="fas fa-user"></i>
                                            </div>
                                            <div>
                                                <strong><?php echo htmlspecialchars($comment['name']); ?></strong>
                                                <small class="text-muted ms-2"><?php echo htmlspecialchars($comment['email']); ?></small>
                                                <br>
                                                <small class="text-muted">
                                                    <i class="far fa-clock me-1"></i><?php echo date('d M Y H:i', strtotime($comment['created_at'])); ?>
                                                    pada <strong><?php echo $comment['article_title'] ?? 'Halaman'; ?></strong>
                                                </small>
                                            </div>
                                        </div>
                                        <p class="mb-2"><?php echo htmlspecialchars(substr($comment['comment'], 0, 150)) . (strlen($comment['comment']) > 150 ? '...' : ''); ?></p>
                                        <div class="btn-group">
                                            <a href="comments.php?approve=<?php echo $comment['id']; ?>&status=pending" class="btn btn-sm btn-success">
                                                <i class="fas fa-check me-1"></i>Setujui
                                            </a>
                                            <a href="comments.php?reject=<?php echo $comment['id']; ?>&status=pending" class="btn btn-sm btn-warning">
                                                <i class="fas fa-ban me-1"></i>Tolak
                                            </a>
                                            <a href="comments.php?delete=<?php echo $comment['id']; ?>&status=pending" class="btn btn-sm btn-danger" onclick="return confirm('Yakin ingin menghapus?')">
                                                <i class="fas fa-trash me-1"></i>Hapus
                                            </a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <?php endwhile; ?>
                        </div>
                    <?php else: ?>
                        <div class="text-center py-4">
                            <i class="fas fa-comment-dots fa-3x text-muted mb-3"></i>
                            <p class="text-muted mb-0">Tidak ada komentar yang menunggu moderasi</p>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
// Visitor Chart (Line Chart)
const visitorCtx = document.getElementById('visitorChart').getContext('2d');
new Chart(visitorCtx, {
    type: 'line',
    data: {
        labels: <?php echo json_encode($visitor_data['labels']); ?>,
        datasets: [{
            label: 'Pengunjung',
            data: <?php echo json_encode($visitor_data['data']); ?>,
            borderColor: 'rgb(75, 192, 192)',
            backgroundColor: 'rgba(75, 192, 192, 0.1)',
            tension: 0.3,
            fill: true,
            pointBackgroundColor: 'rgb(75, 192, 192)',
            pointBorderColor: '#fff',
            pointRadius: 4,
            pointHoverRadius: 6
        }]
    },
    options: {
        responsive: true,
        maintainAspectRatio: true,
        plugins: {
            legend: {
                position: 'top',
            },
            tooltip: {
                mode: 'index',
                intersect: false,
                callbacks: {
                    label: function(context) {
                        return 'Pengunjung: ' + context.raw.toLocaleString();
                    }
                }
            }
        },
        scales: {
            y: {
                beginAtZero: true,
                ticks: {
                    stepSize: 1,
                    callback: function(value) {
                        return value.toLocaleString();
                    }
                },
                title: {
                    display: true,
                    text: 'Jumlah Pengunjung'
                }
            },
            x: {
                title: {
                    display: true,
                    text: 'Tanggal'
                }
            }
        }
    }
});

// Monthly Articles Chart (Bar Chart)
const monthlyCtx = document.getElementById('monthlyArticlesChart').getContext('2d');
new Chart(monthlyCtx, {
    type: 'bar',
    data: {
        labels: <?php echo json_encode($months); ?>,
        datasets: [
            {
                label: 'Total Artikel',
                data: <?php echo json_encode($articles_per_month); ?>,
                backgroundColor: 'rgba(78, 115, 223, 0.7)',
                borderColor: 'rgba(78, 115, 223, 1)',
                borderWidth: 1,
                borderRadius: 5,
                barPercentage: 0.7,
                categoryPercentage: 0.8
            },
            {
                label: 'Published',
                data: <?php echo json_encode($published_per_month); ?>,
                backgroundColor: 'rgba(28, 200, 138, 0.7)',
                borderColor: 'rgba(28, 200, 138, 1)',
                borderWidth: 1,
                borderRadius: 5,
                barPercentage: 0.7,
                categoryPercentage: 0.8
            },
            {
                label: 'Draft',
                data: <?php echo json_encode($draft_per_month); ?>,
                backgroundColor: 'rgba(133, 135, 150, 0.7)',
                borderColor: 'rgba(133, 135, 150, 1)',
                borderWidth: 1,
                borderRadius: 5,
                barPercentage: 0.7,
                categoryPercentage: 0.8
            }
        ]
    },
    options: {
        responsive: true,
        maintainAspectRatio: true,
        plugins: {
            legend: {
                position: 'top',
                labels: {
                    usePointStyle: true,
                    boxWidth: 10
                }
            },
            tooltip: {
                mode: 'index',
                intersect: false,
                callbacks: {
                    label: function(context) {
                        return context.dataset.label + ': ' + context.raw.toLocaleString();
                    }
                }
            }
        },
        scales: {
            y: {
                beginAtZero: true,
                ticks: {
                    stepSize: 1,
                    callback: function(value) {
                        return value.toLocaleString();
                    }
                },
                title: {
                    display: true,
                    text: 'Jumlah Artikel'
                },
                grid: {
                    drawBorder: true,
                    color: 'rgba(0, 0, 0, 0.05)'
                }
            },
            x: {
                title: {
                    display: true,
                    text: 'Bulan'
                },
                grid: {
                    display: false
                }
            }
        },
        interaction: {
            mode: 'index',
            intersect: false
        },
        responsive: true,
        maintainAspectRatio: true
    }
});
</script>

<style>
/* Custom styles untuk dashboard */
.stat-card {
    border: none;
    border-radius: 10px;
    transition: all 0.3s;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15) !important;
}

.stat-card .card-footer {
    background: rgba(0,0,0,0.1);
    border: none;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 12px 20px;
}

.stat-card .card-footer:hover {
    background: rgba(0,0,0,0.2);
    color: #fff;
}

.rank-number .badge {
    font-size: 1rem;
    font-weight: 600;
}

.progress {
    background-color: #e9ecef;
    border-radius: 10px;
}

.progress-bar {
    border-radius: 10px;
    transition: width 0.5s ease;
}

.list-group-item {
    transition: all 0.2s;
}

.list-group-item:hover {
    background-color: #f8f9fc;
    transform: translateX(5px);
}

.table-responsive {
    max-height: 400px;
    overflow-y: auto;
}

.table th {
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

#visitorChart, #monthlyArticlesChart {
    max-height: 350px;
    width: 100%;
}

</style>

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

Youez - 2016 - github.com/yon3zu
LinuXploit