diff --git a/app.php b/app.php new file mode 100644 index 0000000..e3ed86b --- /dev/null +++ b/app.php @@ -0,0 +1,421 @@ +query("SELECT COUNT(*) FROM candidates WHERE status NOT IN ('Hired', 'Rejected')")->fetchColumn(); + $newCandidatesThisWeek = $pdo->query("SELECT COUNT(*) FROM candidates WHERE created_at >= NOW() - INTERVAL 7 DAY")->fetchColumn(); + + // Assuming tasks with "interview" in the name are interviews + $interviewsThisWeek = $pdo->query("SELECT COUNT(*) FROM tasks WHERE title LIKE '%interview%' AND due_date >= CURDATE() AND due_date < CURDATE() + INTERVAL 7 DAY")->fetchColumn(); + + $pendingTasks = $pdo->query("SELECT COUNT(*) FROM tasks WHERE status NOT IN ('Completed')")->fetchColumn(); + $overdueTasksCount = $pdo->query("SELECT COUNT(*) FROM tasks WHERE status NOT IN ('Completed') AND due_date < CURDATE()")->fetchColumn(); + + $newHiresThisMonth = $pdo->query("SELECT COUNT(*) FROM candidates WHERE status = 'Hired' AND created_at >= NOW() - INTERVAL 1 MONTH")->fetchColumn(); + + // Recent Activity Feed from workflow_logs + $recentActivities = $pdo->query(" + SELECT wl.*, w.name as workflow_name, c.name as candidate_name + FROM workflow_logs wl + LEFT JOIN workflows w ON wl.workflow_id = w.id + LEFT JOIN candidates c ON wl.candidate_id = c.id + ORDER BY wl.executed_at DESC + LIMIT 10 + ")->fetchAll(); + + // At-Risk Items + $overdueTasks = $pdo->query(" + SELECT t.title, t.due_date, c.name as candidate_name + FROM tasks t + LEFT JOIN candidates c ON t.assigned_to = c.id + WHERE t.status != 'Completed' AND t.due_date < CURDATE() + ORDER BY t.due_date ASC + ")->fetchAll(); + + $inactiveCandidates = $pdo->query(" + SELECT name, email, created_at + FROM candidates + WHERE status = 'Applied' AND created_at <= NOW() - INTERVAL 7 DAY + ")->fetchAll(); + + $incompleteOnboarding = $pdo->query(" + SELECT t.title, c.name as candidate_name, t.due_date + FROM tasks t + JOIN candidates c ON t.assigned_to = c.id + WHERE c.status = 'Hired' AND t.status != 'Completed' + ")->fetchAll(); + + $all_candidates = $pdo->query("SELECT * FROM candidates ORDER BY name ASC")->fetchAll(); + +} catch (PDOException $e) { + error_log("Dashboard Data Fetch Error: " . $e->getMessage()); + // Initialize variables to prevent errors in the view + $totalActiveCandidates = $newCandidatesThisWeek = $interviewsThisWeek = $pendingTasks = $overdueTasksCount = $newHiresThisMonth = 0; + $recentActivities = $overdueTasks = $inactiveCandidates = $incompleteOnboarding = $all_candidates = []; +} + +function time_ago($datetime, $full = false) { + $now = new DateTime; + $ago = new DateTime($datetime); + $diff = $now->diff($ago); + + $diff->w = floor($diff->d / 7); + $diff->d -= $diff->w * 7; + + $string = array( + 'y' => 'year', + 'm' => 'month', + 'w' => 'week', + 'd' => 'day', + 'h' => 'hour', + 'i' => 'minute', + 's' => 'second', + ); + foreach ($string as $k => &$v) { + if ($diff->$k) { + $v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : ''); + } else { + unset($string[$k]); + } + } + + if (!$full) $string = array_slice($string, 0, 1); + return $string ? implode(', ', $string) . ' ago' : 'just now'; +} + +?> + + + + + + + Executive Dashboard - FinMox Flow + + + + + + + + + + + + + + + +
+ + +
+ +
+
+ + +
+
+
+
+
+
+
+
Total Active Candidates
+
+ this week
+
+
+
+
+
+
+
+
+
+
+
Interviews This Week
+
+
+
+
+
+
+
+
+
+
+
Pending Tasks
+ 0): ?> +
overdue
+ +
+
+
+
+
+
+
+
+
+
+
New Hires This Month
+
+
+
+
+
+ + +
+
+ + + View Weekly Report + Manage Workflows +
+
+ +
+ +
+
+
+
Recent Activity
+
+
+ +

No recent activity.

+ + +
+
+
+
+ +
+ +
+ Details +
+ + +
+
+
+ + +
+
+
+
At-Risk Items
+
+
+ +
Overdue Tasks
+
+ + + + + + + + + + +
+
+ + + +
Inactive Candidates (>7 days)
+
+ + + + + + + + + +
+
+ + + +
Incomplete Onboarding
+
+ + + + + + + + + +
+
+ + + +

No at-risk items found. Great job!

+ +
+
+
+
+
+
+ + + + + + + + + + \ No newline at end of file diff --git a/assets/pasted-20251120-051320-b2b0cdfa.png b/assets/pasted-20251120-051320-b2b0cdfa.png new file mode 100644 index 0000000..9efafe3 Binary files /dev/null and b/assets/pasted-20251120-051320-b2b0cdfa.png differ diff --git a/chat.php b/chat.php index 9feab1d..9b2acdd 100644 --- a/chat.php +++ b/chat.php @@ -65,9 +65,13 @@ if (!is_logged_in()) {
- +