diff --git a/dashboard.php b/dashboard.php index 516293c..1524fc2 100644 --- a/dashboard.php +++ b/dashboard.php @@ -10,11 +10,7 @@ if (!is_logged_in()) { require_once 'db/config.php'; $pdo = db(); -// Function to check for permissions -function hasPermission($permission) { - // In a real app, you'd check this against the user's role - return true; -} + // Pagination for Candidates $candidate_page = isset($_GET['candidate_page']) ? (int)$_GET['candidate_page'] : 1; diff --git a/workflows.php b/workflows.php index 83843ba..ba7e155 100644 --- a/workflows.php +++ b/workflows.php @@ -8,8 +8,6 @@ if (!is_logged_in()) { } if (!hasPermission('view_workflows')) { - // Optionally, you can redirect to a generic page or show an error. - // For now, redirecting to the main index page. header('Location: index.php'); exit; } @@ -21,15 +19,77 @@ $pdo = db(); // Handle form submission for adding a new workflow if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_workflow'])) { if (hasPermission('manage_workflows')) { - $name = $_POST['name'] ?? ''; - $trigger = $_POST['trigger'] ?? ''; + $creation_type = $_POST['creation_type'] ?? 'scratch'; - if ($name && $trigger) { - $stmt = $pdo->prepare("INSERT INTO workflows (name, trigger_event) VALUES (?, ?)"); - $stmt->execute([$name, $trigger]); - $newWorkflowId = $pdo->lastInsertId(); - header("Location: workflow_actions.php?id=" . $newWorkflowId); - exit; + if ($creation_type === 'template') { + $template_name = $_POST['template_name'] ?? ''; + $workflow_name = ''; + $trigger_event = ''; + $actions = []; + + switch ($template_name) { + case 'smart_candidate_intake': + $workflow_name = 'Smart Candidate Intake'; + $trigger_event = 'candidate_created'; + $actions = [ + ['action_type' => 'ai_analysis', 'config' => json_encode(['prompt' => 'Enrich candidate data.'])], + ['action_type' => 'create_task', 'config' => json_encode(['task_name' => 'Review new candidate profile', 'assign_to' => 'hiring_manager'])], + ['action_type' => 'send_slack', 'config' => json_encode(['channel' => '#hr-alerts', 'message' => 'New candidate received.'])] + ]; + break; + case 'interview_scheduling': + $workflow_name = 'Interview Scheduling'; + $trigger_event = 'candidate_status_changed'; + $actions = [ + ['action_type' => 'send_email', 'config' => json_encode(['to' => '{candidate_email}', 'subject' => 'Invitation to Interview', 'body' => 'Please schedule your interview...'])], + ['action_type' => 'schedule_event', 'config' => json_encode(['calendar' => 'hiring_manager_calendar', 'title' => 'Interview with {candidate_name}'])] + ]; + break; + case 'onboarding_automation': + $workflow_name = 'Onboarding Automation'; + $trigger_event = 'candidate_hired'; + $actions = [ + ['action_type' => 'create_task', 'config' => json_encode(['task_name' => 'Prepare welcome kit', 'assign_to' => 'hr_specialist'])], + ['action_type' => 'create_task', 'config' => json_encode(['task_name' => 'Set up IT equipment', 'assign_to' => 'it_department'])], + ['action_type' => 'send_email', 'config' => json_encode(['to' => '{candidate_email}', 'subject' => 'Welcome to the team!', 'body' => 'Your onboarding details...'])] + ]; + break; + case 'weekly_reports': + $workflow_name = 'Weekly Reports'; + $trigger_event = 'schedule_weekly'; + $actions = [ + ['action_type' => 'add_to_report', 'config' => json_encode(['report_name' => 'Weekly Candidate Pipeline', 'data' => 'summary'])], + ['action_type' => 'send_email', 'config' => json_encode(['to' => 'management@example.com', 'subject' => 'Weekly Recruiting Report', 'body' => 'See attached report.'])] + ]; + break; + } + + if ($workflow_name && $trigger_event) { + $stmt = $pdo->prepare("INSERT INTO workflows (name, trigger_event) VALUES (?, ?)"); + $stmt->execute([$workflow_name, $trigger_event]); + $workflow_id = $pdo->lastInsertId(); + + $action_stmt = $pdo->prepare("INSERT INTO workflow_actions (workflow_id, action_type, config, action_order) VALUES (?, ?, ?, ?)"); + foreach ($actions as $index => $action) { + $action_stmt->execute([$workflow_id, $action['action_type'], $action['config'], $index + 1]); + } + + header("Location: workflow_actions.php?id=" . $workflow_id); + exit; + } + + } else { // Build from scratch + $name = $_POST['name'] ?? ''; + $trigger_event = $_POST['trigger_event'] ?? ''; + $trigger_condition = $_POST['trigger_condition'] ?? null; + + if ($name && $trigger_event) { + $stmt = $pdo->prepare("INSERT INTO workflows (name, trigger_event, trigger_condition) VALUES (?, ?, ?)"); + $stmt->execute([$name, $trigger_event, $trigger_condition]); + $newWorkflowId = $pdo->lastInsertId(); + header("Location: workflow_actions.php?id=" . $newWorkflowId); + exit; + } } } } @@ -46,9 +106,78 @@ $workflows = $stmt->fetchAll(); FinMox Workflows + +
+
+
+
+ FinMox. +
+ +
+ + +
+
+
+ + + +
+
@@ -68,54 +197,22 @@ $workflows = $stmt->fetchAll();
- -
-
-
-
-

Smart Candidate Intake

-
-

Automatically captures, enriches, and routes new candidates.

-
-
-
-
-
-
-

Interview Scheduling

-
-

Automates calendar checks and interview coordination.

-
-
-
-
-
-
-

Onboarding Automation

-
-

Creates and tracks onboarding tasks for new hires.

-
-
- + +

Smart Candidate Intake

Automatically captures, enriches, and routes new candidates.

+

Interview Scheduling

Automates calendar checks and interview coordination.

+

Onboarding Automation

Creates and tracks onboarding tasks for new hires.

- -
-
-
-
- -
-
-

- Active -
+
+
+
+
+

+ Active
-

- Trigger: -

+

Trigger:

@@ -125,40 +222,170 @@ $workflows = $stmt->fetchAll();