diff --git a/analyst_dashboard.php b/analyst_dashboard.php index e329b69..ee9db2a 100644 --- a/analyst_dashboard.php +++ b/analyst_dashboard.php @@ -1,13 +1,50 @@ query("SELECT id, name, status, created_at FROM submissions ORDER BY created_at DESC"); + $stmt = $pdo->query("SELECT * FROM submissions ORDER BY created_at DESC"); $submissions = $stmt->fetchAll(); } catch (PDOException $e) { $submissions = []; - // error_log($e->getMessage()); // It's good practice to log errors + // In a real app, log this error to a file or service + // error_log($e->getMessage()); +} + +// Handle notifications from query parameters +$notification = null; +if (isset($_GET['success'])) { + $count = (int)$_GET['success']; + $notification = [ + 'type' => 'success', + 'message' => "Successfully imported {$count} records from the CSV." + ]; +} elseif (isset($_GET['error'])) { + $notification = [ + 'type' => 'danger', + 'message' => "An error occurred: " . htmlspecialchars($_GET['error']) + ]; +} elseif (isset($_GET['refreshed'])) { + $notification = [ + 'type' => 'info', + 'message' => "Submission has been queued for refresh." + ]; +} + +// Helper to determine badge color based on status +function get_status_badge_class($status) { + switch (strtolower($status)) { + case 'completed': + return 'bg-success-subtle text-success-emphasis'; + case 'processing': + return 'bg-primary-subtle text-primary-emphasis'; + case 'error': + return 'bg-danger-subtle text-danger-emphasis'; + case 'pending': + default: + return 'bg-secondary-subtle text-secondary-emphasis'; + } } ?> @@ -16,7 +53,7 @@ try {