Employee Directory
+| Name | +Role | ++ View + | +|
|---|---|---|---|
| + | + | + | + View Overview + | +
diff --git a/.htaccess b/.htaccess index e2bbc23..20ea1a8 100644 --- a/.htaccess +++ b/.htaccess @@ -11,6 +11,7 @@ RewriteRule ^ - [L] # 1) Internal map: /page or /page/ -> /page.php (if such PHP file exists) RewriteCond %{REQUEST_FILENAME}.php -f +RewriteCond %{REQUEST_URI} !\.php$ RewriteRule ^(.+?)/?$ $1.php [L] # 2) Optional: strip trailing slash for non-directories (keeps .php links working) diff --git a/_sidebar.php b/_sidebar.php index 68005ff..b032feb 100644 --- a/_sidebar.php +++ b/_sidebar.php @@ -9,6 +9,12 @@ function render_nav_link($href, $icon, $label, $active_page) { $current_page = basename($_SERVER['PHP_SELF']); ?>
Viewing as Employee
+ Return to Your View +
@@ -20,7 +26,7 @@ $current_page = basename($_SERVER['PHP_SELF']);
render_nav_link('candidates.php', 'users', 'Candidates', $current_page);
render_nav_link('hr_cases.php', 'briefcase', 'HR Cases', $current_page);
render_nav_link('onboarding.php', 'clipboard-list', 'Onboarding', $current_page);
- render_nav_link('employee_view.php', 'user-square', 'Employee View', $current_page);
+ render_nav_link('hr_employee_overview.php', 'user-cog', 'HR Overview', $current_page);
render_nav_link('weekly_summary.php', 'bar-chart-2', 'Weekly Summary', $current_page);
render_nav_link('workflows.php', 'bot', 'Automation', $current_page);
render_nav_link('chat.php', 'sparkles', 'AI Copilot', $current_page);
diff --git a/assets/pasted-20251217-043322-a3b56103.png b/assets/pasted-20251217-043322-a3b56103.png
new file mode 100644
index 0000000..c5965ca
Binary files /dev/null and b/assets/pasted-20251217-043322-a3b56103.png differ
diff --git a/db/migrations/015_add_magic_link_to_users.sql b/db/migrations/015_add_magic_link_to_users.sql
new file mode 100644
index 0000000..158448b
--- /dev/null
+++ b/db/migrations/015_add_magic_link_to_users.sql
@@ -0,0 +1,3 @@
+ALTER TABLE `users`
+ADD COLUMN `magic_token` VARCHAR(255) NULL UNIQUE,
+ADD COLUMN `magic_token_expires_at` DATETIME NULL;
diff --git a/db/migrations/016_fix_tasks_table_for_employees.sql b/db/migrations/016_fix_tasks_table_for_employees.sql
new file mode 100644
index 0000000..6bc65db
--- /dev/null
+++ b/db/migrations/016_fix_tasks_table_for_employees.sql
@@ -0,0 +1,12 @@
+-- Drop the old foreign key constraint that links tasks to candidates.
+-- The name 'tasks_ibfk_1' is the default name generated by MySQL.
+ALTER TABLE `tasks` DROP FOREIGN KEY `tasks_ibfk_1`;
+
+-- Drop the old column linking to candidates.
+ALTER TABLE `tasks` DROP COLUMN `candidate_id`;
+
+-- Add the new column to link tasks to employees (users).
+ALTER TABLE `tasks` ADD COLUMN `assignee_id` INT;
+
+-- Add the new foreign key constraint.
+ALTER TABLE `tasks` ADD FOREIGN KEY (`assignee_id`) REFERENCES `users`(`id`) ON DELETE SET NULL;
diff --git a/employee_view.php b/employee_view.php
index 8f4d2f2..59e5929 100644
--- a/employee_view.php
+++ b/employee_view.php
@@ -1,14 +1,34 @@
'Alex',
- 'initials' => 'AR',
- 'title' => 'Senior Product Designer',
- 'manager' => 'Sarah Johnson',
- 'start_date' => '12/14/2024'
-];
+require_once 'db/config.php';
+// 1. Check for a valid user session
+if (!isset($_SESSION['user_id'])) {
+ header('Location: login.php');
+ exit;
+}
+
+// 2. Fetch user data from the database
+$pdo = db();
+$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
+$stmt->execute([$_SESSION['user_id']]);
+$user = $stmt->fetch();
+
+if (!$user) {
+ // If user not found, destroy session and redirect
+ session_destroy();
+ header('Location: login.php');
+ exit;
+}
+
+// Create initials from the username
+$initials = '';
+$parts = explode(' ', $user['username']);
+foreach ($parts as $part) {
+ $initials .= strtoupper(substr($part, 0, 1));
+}
+
+// 3. Task data remains static for now, but will be moved to database later.
$tasks = [
[
'name' => 'Complete Tax Forms (W-4)',
@@ -59,6 +79,10 @@ $total_tasks = count($tasks);
$completed_count = count($completed_tasks);
$progress_percent = $total_tasks > 0 ? ($completed_count / $total_tasks) * 100 : 0;
+// For display purposes, placeholder data for manager and start date
+$display_manager = 'Sarah Johnson';
+$display_start_date = '12/14/2024';
+
?>
@@ -83,12 +107,12 @@ $progress_percent = $total_tasks > 0 ? ($completed_count / $total_tasks) * 100 :
Welcome, !
- +Welcome, !
+New Employee
Questions? Reach out to your manager or contact HR.
-Start Date:
+Questions? Reach out to your manager or contact HR.
+Start Date:
" . htmlspecialchars($error_message) . "
"; + exit; +} + +// The magic link token would be validated here in a real scenario. +// For now, we just display the page. +?> + + + + + +
+ + We are thrilled to have you join the team. We've prepared a few things to get you started. +
+ + + + + +Need to review some documents before you start?
+ + Read the Employee Handbook + +You can share this link with the new employee or click the button below to open it directly. It is valid for 7 days.
"; + echo "Open Employee View in New Tab"; + echo "Or, manually copy the link:
"; + echo ""; +} else { + echo "Could not generate the magic link. Please try again.
"; +} diff --git a/hr_employee_overview.php b/hr_employee_overview.php new file mode 100644 index 0000000..c789f28 --- /dev/null +++ b/hr_employee_overview.php @@ -0,0 +1,231 @@ +query("SELECT u.id, u.username, u.email, r.name as role_name FROM users u LEFT JOIN roles r ON u.role_id = r.id ORDER BY u.username"); + $users = $stmt->fetchAll(); + ?> + + + + + +| Name | +Role | ++ View + | +|
|---|---|---|---|
| + | + | + | + View Overview + | +
Detailed onboarding progress for .
+Due:
+Completed On:
+Role:
+Manager:
+Start Date:
+%
+If you see the sidebar to the left and this message, the test is successful.
+