85 lines
3.6 KiB
PHP
85 lines
3.6 KiB
PHP
<?php
|
|
require_once __DIR__ . '/header.php';
|
|
|
|
$message = '';
|
|
$error = '';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$name = $_POST['name'] ?? '';
|
|
$email = $_POST['email'] ?? '';
|
|
|
|
if (empty($name)) {
|
|
$error = "Customer name is required.";
|
|
} else {
|
|
try {
|
|
$stmt = db()->prepare("INSERT INTO customers (name, contact_email, status) VALUES (?, ?, 'onboarding')");
|
|
$stmt->execute([$name, $email]);
|
|
$customer_id = db()->lastInsertId();
|
|
|
|
// Seed onboarding tasks
|
|
$tasks = [
|
|
'Initial Kick-off Meeting',
|
|
'Discovery & Asset Inventory',
|
|
'Agent Deployment (RMM)',
|
|
'Network Security Audit',
|
|
'Backup & Disaster Recovery Setup',
|
|
'Microsoft 365 Tenant Review',
|
|
'Final Configuration Handover'
|
|
];
|
|
|
|
$stmt_task = db()->prepare("INSERT INTO onboarding_tasks (customer_id, task_name) VALUES (?, ?)");
|
|
foreach ($tasks as $task) {
|
|
$stmt_task->execute([$customer_id, $task]);
|
|
}
|
|
|
|
$message = "Customer added successfully! <a href='onboarding.php?id=$customer_id' style='color: var(--primary); text-decoration: underline;'>View Onboarding Checklist</a>";
|
|
} catch (PDOException $e) {
|
|
$error = "Error adding customer: " . $e->getMessage();
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
|
|
<div class="container" style="max-width: 600px;">
|
|
<div style="margin-bottom: 2rem;">
|
|
<h2 style="font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem;">Add New Customer</h2>
|
|
<p style="color: var(--text-muted); font-size: 0.875rem;">Enter details to start the onboarding process.</p>
|
|
</div>
|
|
|
|
<?php if ($message): ?>
|
|
<div style="background: #dcfce7; color: #166534; padding: 1rem; border-radius: var(--radius); margin-bottom: 1.5rem; border: 1px solid #bbf7d0;">
|
|
<i class="bi bi-check-circle-fill" style="margin-right: 0.5rem;"></i> <?php echo $message; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($error): ?>
|
|
<div style="background: #fee2e2; color: #991b1b; padding: 1rem; border-radius: var(--radius); margin-bottom: 1.5rem; border: 1px solid #fecaca;">
|
|
<i class="bi bi-exclamation-circle-fill" style="margin-right: 0.5rem;"></i> <?php echo $error; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="card">
|
|
<form method="POST">
|
|
<div class="form-group">
|
|
<label class="form-label" for="name">Company / Customer Name</label>
|
|
<input type="text" id="name" name="name" class="form-control" placeholder="Acme Corp" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label" for="email">Primary Contact Email</label>
|
|
<input type="email" id="email" name="email" class="form-control" placeholder="admin@acmecorp.com">
|
|
</div>
|
|
<div style="display: flex; gap: 1rem; margin-top: 2rem;">
|
|
<button type="submit" class="btn btn-primary" style="flex: 1;">Create Customer Profile</button>
|
|
<a href="customers.php" class="btn btn-outline" style="flex: 1;">Cancel</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<div style="margin-top: 2rem; padding: 1rem; background: #f1f5f9; border-radius: var(--radius); font-size: 0.875rem; color: var(--text-muted);">
|
|
<i class="bi bi-info-circle" style="margin-right: 0.5rem; color: var(--primary);"></i>
|
|
Adding a customer will automatically generate a standard 7-step onboarding checklist to track progress.
|
|
</div>
|
|
</div>
|
|
|
|
<?php require_once __DIR__ . '/footer.php'; ?>
|