<?php
require_admin();
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$t = trim($_POST['title'] ?? '');
$n = intval($_POST['num_states'] ?? 0);
if ($t === '' || $n < 1) {
$error = 'Enter title & at least 1 state.';
} else {
header('Location: index.php?page=workflows_define&title=' . urlencode($t) . '&num_states=' . $n);
exit;
}
}
?>
<div class="page-workflows-create">
<div class="page-header">
<h1 class="page-title">Create New Workflow</h1>
<p class="page-subtitle">Define the basic structure of your workflow</p>
</div>
<?php if ($error): ?>
<div class="error-message"><?php echo htmlspecialchars($error); ?></div>
<?php endif; ?>
<div class="create-form-container">
<form method="post" class="create-form">
<div class="form-group">
<label class="form-label" for="title">Workflow Title</label>
<input type="text" id="title" name="title" class="form-input" required
value="<?php echo htmlspecialchars($_POST['title'] ?? ''); ?>">
<div class="help-text">Choose a descriptive name for your workflow</div>
</div>
<div class="form-group">
<label class="form-label" for="num_states">Number of States</label>
<input type="number" id="num_states" name="num_states" class="form-input" min="1" required
value="<?php echo intval($_POST['num_states'] ?? 2); ?>">
<div class="help-text">How many stages will this workflow have?</div>
</div>
<button type="submit" class="btn btn-primary submit-button">Continue to Define States</button>
</form>
</div>
</div>