-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.php
More file actions
155 lines (144 loc) Β· 6.56 KB
/
dashboard.php
File metadata and controls
155 lines (144 loc) Β· 6.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
/**
* ALM Compliance Tracking Dashboard
* Displays webhook events and compliance status
*/
$db = new SQLite3(__DIR__ . '/../data/compliance.db');
?>
<!DOCTYPE html>
<html>
<head>
<title>ALM Compliance Tracking Dashboard</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; background: #f5f5f5; }
.container { max-width: 1400px; margin: 0 auto; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
h1 { color: #333; border-bottom: 3px solid #0066cc; padding-bottom: 10px; }
h2 { color: #555; margin-top: 30px; }
table { border-collapse: collapse; width: 100%; margin: 20px 0; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; font-size: 14px; }
th { background: #0066cc; color: white; font-weight: bold; }
.overdue { background: #ffdddd; }
.completed { background: #ddffdd; }
.pending { background: #ffffdd; }
.log { background: #f9f9f9; padding: 15px; font-family: monospace;
white-space: pre-wrap; max-height: 300px; overflow-y: auto;
border: 1px solid #ddd; border-radius: 4px; }
.stats { display: flex; gap: 20px; margin: 20px 0; }
.stat-box { flex: 1; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white; padding: 20px; border-radius: 8px; text-align: center; }
.stat-box h3 { margin: 0; font-size: 36px; }
.stat-box p { margin: 5px 0 0 0; font-size: 14px; opacity: 0.9; }
.refresh-info { text-align: center; color: #666; font-size: 12px; margin-top: 20px; }
</style>
<meta http-equiv="refresh" content="30">
</head>
<body>
<div class="container">
<h1>π ALM Compliance Tracking Dashboard</h1>
<?php
// Get statistics
$total = $db->querySingle('SELECT COUNT(*) FROM compliance_tracking');
$completed = $db->querySingle('SELECT COUNT(*) FROM compliance_tracking WHERE status = "completed"');
$overdue = $db->querySingle('SELECT COUNT(*) FROM compliance_tracking WHERE
CAST((julianday(deadline_date) - julianday("now")) AS INTEGER) < 0 AND status != "completed"');
$events = $db->querySingle('SELECT COUNT(*) FROM webhook_events');
?>
<div class="stats">
<div class="stat-box">
<h3><?php echo $total; ?></h3>
<p>Total Enrollments</p>
</div>
<div class="stat-box" style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);">
<h3><?php echo $completed; ?></h3>
<p>Completed</p>
</div>
<div class="stat-box" style="background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);">
<h3><?php echo $overdue; ?></h3>
<p>Overdue</p>
</div>
<div class="stat-box" style="background: linear-gradient(135deg, #30cfd0 0%, #330867 100%);">
<h3><?php echo $events; ?></h3>
<p>Total Events</p>
</div>
</div>
<h2>π Compliance Status</h2>
<table>
<tr>
<th>User ID</th>
<th>Course ID</th>
<th>Instance</th>
<th>Status</th>
<th>Progress</th>
<th>Enrollment Date</th>
<th>Deadline</th>
<th>Days Left</th>
</tr>
<?php
$stmt = $db->query('SELECT *,
CAST((julianday(deadline_date) - julianday("now")) AS INTEGER) as days_left
FROM compliance_tracking ORDER BY deadline_date DESC LIMIT 50');
while ($row = $stmt->fetchArray(SQLITE3_ASSOC)) {
$class = '';
if ($row['status'] == 'completed') $class = 'completed';
elseif ($row['days_left'] < 0 && $row['status'] != 'completed') $class = 'overdue';
elseif ($row['days_left'] < 3) $class = 'pending';
echo "<tr class='$class'>";
echo "<td>" . htmlspecialchars($row['user_id']) . "</td>";
echo "<td>" . htmlspecialchars($row['course_id']) . "</td>";
echo "<td>" . htmlspecialchars($row['instance_id'] ?? 'N/A') . "</td>";
echo "<td>" . htmlspecialchars($row['status']) . "</td>";
echo "<td>{$row['progress']}%</td>";
echo "<td>" . htmlspecialchars($row['enrollment_date'] ?? 'N/A') . "</td>";
echo "<td>" . htmlspecialchars($row['deadline_date'] ?? 'N/A') . "</td>";
echo "<td>{$row['days_left']}</td>";
echo "</tr>";
}
if ($total == 0) {
echo "<tr><td colspan='8' style='text-align: center; padding: 20px; color: #999;'>No enrollment data yet. Waiting for webhook events...</td></tr>";
}
?>
</table>
<h2>π‘ Recent Webhook Events</h2>
<table>
<tr>
<th>Event ID</th>
<th>Event Name</th>
<th>Account ID</th>
<th>Timestamp</th>
</tr>
<?php
$stmt = $db->query('SELECT * FROM webhook_events ORDER BY created_at DESC LIMIT 20');
$hasEvents = false;
while ($row = $stmt->fetchArray(SQLITE3_ASSOC)) {
$hasEvents = true;
echo "<tr>";
echo "<td>" . htmlspecialchars($row['event_id']) . "</td>";
echo "<td>" . htmlspecialchars($row['event_name']) . "</td>";
echo "<td>" . htmlspecialchars($row['account_id']) . "</td>";
echo "<td>" . htmlspecialchars($row['created_at']) . "</td>";
echo "</tr>";
}
if (!$hasEvents) {
echo "<tr><td colspan='4' style='text-align: center; padding: 20px; color: #999;'>No webhook events received yet...</td></tr>";
}
?>
</table>
<h2>π Recent Webhook Activity Log</h2>
<div class="log">
<?php
$logFile = __DIR__ . '/../logs/webhook-raw.log';
if (file_exists($logFile)) {
$logs = file_get_contents($logFile);
echo htmlspecialchars($logs ?: 'No activity logged yet');
} else {
echo 'Log file not found';
}
?>
</div>
<div class="refresh-info">
<p>β±οΈ Page auto-refreshes every 30 seconds | Last updated: <?php echo date('Y-m-d H:i:s'); ?></p>
<p>π Webhook URL: https://p0qp0q.com/AdobeLearningManager_Webhook_Demo/src/webhook-alm.php</p>
</div>
</div>
</body>
</html>