« Back to History
dashboard.php
|
20260722_120325.php
Initial Domain Snapshot
Copy Code
<?php // Strict Error Reporting Enablers error_reporting(E_ALL); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); if (session_status() === PHP_SESSION_NONE) { session_start(); } require_once __DIR__ . '/../../includes/bootstrap.php'; require_once __DIR__ . '/../../includes/header.php'; require_once __DIR__ . '/../../includes/sidebar.php'; $errMessage = ''; $current_user_id = (int)($_SESSION['user_id'] ?? 1); // Initialize Default Metrics $task_counts = [ 'PENDING' => 0, 'WORKING' => 0, 'TESTING' => 0, 'COMPLETED' => 0, 'HOLD' => 0, 'CANCELLED' => 0 ]; $total_tasks = 0; $total_ideas = 0; $total_milestones = 0; $urgent_tasks = []; $milestones_list = []; $recent_activities = []; $module_breakdown = []; // Data Fetching Engine try { // 1. Task Counts by Status $stmt = $pdo->query("SELECT status, COUNT(*) as count FROM project_tasks GROUP BY status"); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { if (isset($task_counts[$row['status']])) { $task_counts[$row['status']] = (int)$row['count']; } } $total_tasks = array_sum($task_counts); // 2. Total Ideas Count $ideasStmt = $pdo->query("SELECT COUNT(*) FROM project_ideas"); $total_ideas = (int)$ideasStmt->fetchColumn(); // 3. Total Active Milestones Count $msCountStmt = $pdo->query("SELECT COUNT(*) FROM project_milestones WHERE status != 'COMPLETED'"); $total_milestones = (int)$msCountStmt->fetchColumn(); // 4. Critical & High Priority Tasks $urgentStmt = $pdo->query(" SELECT id, title, priority, status, due_date, module_name FROM project_tasks WHERE priority IN ('CRITICAL', 'HIGH') AND status NOT IN ('COMPLETED', 'CANCELLED') ORDER BY FIELD(priority, 'CRITICAL', 'HIGH'), due_date ASC LIMIT 5 "); $urgent_tasks = $urgentStmt->fetchAll(PDO::FETCH_ASSOC); // 5. Active Milestones $msListStmt = $pdo->query(" SELECT id, title, target_date, status, progress FROM project_milestones ORDER BY target_date ASC LIMIT 4 "); $milestones_list = $msListStmt->fetchAll(PDO::FETCH_ASSOC); // 6. Tasks Breakdown by Module $modStmt = $pdo->query(" SELECT COALESCE(NULLIF(module_name, ''), 'General') as module, COUNT(*) as count FROM project_tasks GROUP BY module ORDER BY count DESC LIMIT 5 "); $module_breakdown = $modStmt->fetchAll(PDO::FETCH_ASSOC); // 7. Recent Activity Audit Logs $actStmt = $pdo->query(" SELECT activity, details, created_at FROM project_activity_log ORDER BY created_at DESC LIMIT 6 "); $recent_activities = $actStmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { $errMessage = "Dashboard Query Error: " . $e->getMessage(); } ?> <div class="container-fluid p-0" style="max-width: 1200px;"> <!-- Top Header Block --> <div class="d-flex justify-content-between align-items-center mb-4"> <div> <h4 class="m-0 fw-bold text-dark">Development Board Overview</h4> <small class="text-muted">Real-time metrics, sprint health, and release roadmaps</small> </div> <div class="d-flex gap-2"> <a href="list.php" class="btn btn-sm btn-primary px-3"> <i class="bi bi-list-task me-1"></i> Task Registry </a> <a href="ideas.php" class="btn btn-sm btn-outline-secondary"> <i class="bi bi-lightbulb me-1"></i> Post Idea </a> </div> </div> <!-- Feedback Alerts --> <?php if (!empty($errMessage)): ?> <div class="alert alert-danger small p-3 mb-4"><?= htmlspecialchars($errMessage) ?></div> <?php endif; ?> <!-- Metrics Strip --> <div class="row g-3 mb-4"> <div class="col-md-3"> <div class="card border-0 shadow-sm bg-white p-3 border-start border-4 border-primary"> <div class="text-muted small fw-semibold text-uppercase">Total Tasks</div> <div class="fs-3 fw-bold text-dark mt-1"><?= number_format($total_tasks) ?></div> </div> </div> <div class="col-md-3"> <div class="card border-0 shadow-sm bg-white p-3 border-start border-4 border-warning"> <div class="text-muted small fw-semibold text-uppercase">In Progress</div> <div class="fs-3 fw-bold text-warning mt-1"><?= number_format($task_counts['WORKING']) ?></div> </div> </div> <div class="col-md-3"> <div class="card border-0 shadow-sm bg-white p-3 border-start border-4 border-success"> <div class="text-muted small fw-semibold text-uppercase">Completed</div> <div class="fs-3 fw-bold text-success mt-1"><?= number_format($task_counts['COMPLETED']) ?></div> </div> </div> <div class="col-md-3"> <div class="card border-0 shadow-sm bg-white p-3 border-start border-4 border-info"> <div class="text-muted small fw-semibold text-uppercase">Ideas & Backlog</div> <div class="fs-3 fw-bold text-info mt-1"><?= number_format($total_ideas) ?></div> </div> </div> </div> <!-- Status Overview Bar --> <div class="card border-0 shadow-sm bg-white p-3 mb-4"> <div class="row text-center"> <div class="col border-end"> <small class="text-muted d-block text-uppercase">Pending</small> <span class="fw-bold fs-5 text-secondary"><?= $task_counts['PENDING'] ?></span> </div> <div class="col border-end"> <small class="text-muted d-block text-uppercase">Testing</small> <span class="fw-bold fs-5 text-info"><?= $task_counts['TESTING'] ?></span> </div> <div class="col border-end"> <small class="text-muted d-block text-uppercase">On Hold</small> <span class="fw-bold fs-5 text-warning"><?= $task_counts['HOLD'] ?></span> </div> <div class="col"> <small class="text-muted d-block text-uppercase">Cancelled</small> <span class="fw-bold fs-5 text-danger"><?= $task_counts['CANCELLED'] ?></span> </div> </div> </div> <!-- Main Grid Content --> <div class="row g-4"> <!-- Left Column: Critical Tasks & Active Milestones --> <div class="col-xl-8 col-lg-7"> <!-- Critical & High Priority Tasks --> <div class="card border-0 shadow-sm bg-white p-0 mb-4"> <div class="p-3 border-bottom d-flex justify-content-between align-items-center"> <h6 class="m-0 fw-bold text-danger"><i class="bi bi-exclamation-triangle-fill me-2"></i>Critical & High Priority Tasks</h6> <a href="list.php" class="small text-decoration-none">View All</a> </div> <div class="table-responsive"> <table class="table table-hover align-middle mb-0"> <thead class="table-light small text-uppercase"> <tr> <th>Task Title</th> <th>Module</th> <th>Priority</th> <th>Status</th> <th>Due Date</th> </tr> </thead> <tbody> <?php if (!empty($urgent_tasks)): ?> <?php foreach ($urgent_tasks as $t): ?> <tr> <td> <a href="detail.php?id=<?= $t['id'] ?>" class="text-dark fw-bold text-decoration-none"> <?= htmlspecialchars($t['title']) ?> </a> </td> <td><span class="badge bg-light text-dark border font-monospace"><?= htmlspecialchars($t['module_name'] ?: 'General') ?></span></td> <td><span class="badge <?= $t['priority'] === 'CRITICAL' ? 'bg-danger' : 'bg-warning text-dark' ?>"><?= $t['priority'] ?></span></td> <td><span class="badge bg-secondary"><?= $t['status'] ?></span></td> <td class="small text-muted font-monospace"><?= $t['due_date'] ? date('d M Y', strtotime($t['due_date'])) : '--' ?></td> </tr> <?php endforeach; ?> <?php else: ?> <tr><td colspan="5" class="text-center py-3 text-muted small">No pending critical tasks.</td></tr> <?php endif; ?> </tbody> </table> </div> </div> <!-- Active Release Milestones --> <div class="card border-0 shadow-sm bg-white p-4"> <div class="d-flex justify-content-between align-items-center mb-3"> <h6 class="m-0 fw-bold text-dark"><i class="bi bi-bullseye me-2 text-primary"></i>Active Release Milestones</h6> <a href="milestones.php" class="small text-decoration-none">Manage Milestones</a> </div> <?php if (!empty($milestones_list)): ?> <div class="row g-3"> <?php foreach ($milestones_list as $m): ?> <div class="col-md-6"> <div class="p-3 border rounded bg-light"> <div class="d-flex justify-content-between mb-1"> <strong class="small text-dark"><?= htmlspecialchars($m['title']) ?></strong> <span class="small font-monospace"><?= $m['progress'] ?>%</span> </div> <div class="progress mb-2" style="height: 6px;"> <div class="progress-bar bg-primary" style="width: <?= $m['progress'] ?>%"></div> </div> <div class="d-flex justify-content-between align-items-center small text-muted font-monospace" style="font-size:0.75rem;"> <span>Target: <?= $m['target_date'] ? date('d M Y', strtotime($m['target_date'])) : '--' ?></span> <span class="badge bg-secondary"><?= $m['status'] ?></span> </div> </div> </div> <?php endforeach; ?> </div> <?php else: ?> <p class="text-center text-muted small m-0 py-2">No active milestones created.</p> <?php endif; ?> </div> </div> <!-- Right Column: Module Breakdown & Activity Trail --> <div class="col-xl-4 col-lg-5"> <!-- Tasks by Module --> <div class="card border-0 shadow-sm bg-white p-4 mb-4"> <h6 class="fw-bold text-dark mb-3"><i class="bi bi-boxes me-2 text-secondary"></i>Tasks by Module</h6> <ul class="list-group list-group-flush small"> <?php if (!empty($module_breakdown)): ?> <?php foreach ($module_breakdown as $mb): ?> <li class="list-group-item d-flex justify-content-between align-items-center px-0 py-2"> <span><?= htmlspecialchars($mb['module']) ?></span> <span class="badge bg-primary rounded-pill font-monospace"><?= $mb['count'] ?></span> </li> <?php endforeach; ?> <?php else: ?> <li class="list-group-item text-muted text-center border-0 px-0">No module data found.</li> <?php endif; ?> </ul> </div> <!-- Audit Activity Logs --> <div class="card border-0 shadow-sm bg-white p-4"> <div class="d-flex justify-content-between align-items-center mb-3"> <h6 class="m-0 fw-bold text-dark"><i class="bi bi-clock-history me-2 text-info"></i>Recent Activity</h6> <a href="activity.php" class="small text-decoration-none">Full Log</a> </div> <?php if (!empty($recent_activities)): ?> <?php foreach ($recent_activities as $act): ?> <div class="border-start border-2 border-primary ps-3 mb-3"> <div class="fw-semibold text-dark small"><?= htmlspecialchars($act['activity']) ?></div> <div class="text-muted small"><?= htmlspecialchars($act['details'] ?? '') ?></div> <div class="text-muted font-monospace" style="font-size:0.7rem;"><?= date('d M Y, h:i A', strtotime($act['created_at'])) ?></div> </div> <?php endforeach; ?> <?php else: ?> <p class="text-center text-muted small m-0 py-2">No recent activities logged.</p> <?php endif; ?> </div> </div> </div> </div> <?php require_once __DIR__ . '/../../includes/footer.php'; ?>