diff --git a/workflow_actions.php b/workflow_actions.php index fa2ebc9..4b4d7d6 100644 --- a/workflow_actions.php +++ b/workflow_actions.php @@ -1,72 +1,24 @@ 'Create Task', 'params' => ['name' => 'Review new candidate', 'assign_to' => 'hiring_manager']], + ['type' => 'Send Email', 'params' => ['subject' => 'Welcome!', 'to' => '{candidate_email}']], + ['type' => 'AI Analysis', 'params' => ['prompt' => 'Summarize candidate resume']], +]; -if (!hasPermission('view_workflows')) { - header('Location: index.php'); - exit; -} - -require_once 'db/config.php'; - -if (!isset($_GET['workflow_id'])) { - header('Location: workflows.php'); - exit; -} - -$workflow_id = $_GET['workflow_id']; -$pdo = db(); - -// Fetch workflow details -$stmt = $pdo->prepare("SELECT * FROM workflows WHERE id = ?"); -$stmt->execute([$workflow_id]); -$workflow = $stmt->fetch(); - -if (!$workflow) { - header('Location: workflows.php'); - exit; -} - -// Handle form submission for new action -if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_action']) && hasPermission('manage_workflows')) { - $action_type = $_POST['action_type'] ?? ''; - $config = []; - - if ($action_type === 'send_email') { - $config['to'] = $_POST['to'] ?? ''; - $config['subject'] = $_POST['subject'] ?? ''; - $config['message'] = $_POST['message'] ?? ''; - } elseif ($action_type === 'create_task') { - $config['task_name'] = $_POST['task_name'] ?? ''; - $config['assign_to'] = $_POST['assign_to'] ?? ''; - } elseif ($action_type === 'send_slack_notification') { - $config['webhook_url'] = $_POST['webhook_url'] ?? ''; - $config['message'] = $_POST['slack_message'] ?? ''; - } elseif ($action_type === 'update_candidate_status') { - $config['new_status'] = $_POST['new_status'] ?? ''; - } - - if (!empty($action_type)) { - try { - $stmt = $pdo->prepare("INSERT INTO workflow_actions (workflow_id, action_type, config) VALUES (?, ?, ?)"); - $stmt->execute([$workflow_id, $action_type, json_encode($config)]); - header("Location: " . $_SERVER['REQUEST_URI']); - exit; - } catch (PDOException $e) { - error_log("Error adding action: " . $e->getMessage()); - } - } -} - -// Fetch actions for the workflow -$stmt = $pdo->prepare("SELECT * FROM workflow_actions WHERE workflow_id = ? ORDER BY created_at DESC"); -$stmt->execute([$workflow_id]); -$actions = $stmt->fetchAll(); +$available_actions = [ + ['name' => 'Send Email', 'icon' => '📧'], + ['name' => 'Create Task', 'icon' => '✅'], + ['name' => 'Send Slack Notification', 'icon' => '💬'], + ['name' => 'Update Candidate Status', 'icon' => '👤'], + ['name' => 'AI Analysis', 'icon' => '🤖'], + ['name' => 'Add to Report', 'icon' => '📊'], + ['name' => 'Schedule Event', 'icon' => '📅'], +]; ?> @@ -74,157 +26,319 @@ $actions = $stmt->fetchAll(); - Workflow Actions + Workflow Builder - <?= htmlspecialchars($workflow_name) ?> - + + -
- - -
-
-
-

Actions for ""

- - - -
- -
-
- - - - - - - - - - - - - - - -
Action TypeConfiguration
-
-
-
- - -