Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b66eccc21 | ||
|
|
7527f17da8 | ||
|
|
d49002c4b1 |
126
add_customer.php
Normal file
126
add_customer.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once 'db/config.php';
|
||||
|
||||
$msp_id = $_SESSION['msp_id'];
|
||||
|
||||
// Fetch available templates
|
||||
$stmt = db()->prepare("SELECT * FROM onboarding_templates WHERE msp_id = ? ORDER BY name ASC");
|
||||
$stmt->execute([$msp_id]);
|
||||
$templates = $stmt->fetchAll();
|
||||
|
||||
$success = '';
|
||||
$error = '';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$name = $_POST['name'] ?? '';
|
||||
$email = $_POST['email'] ?? '';
|
||||
$template_id = $_POST['template_id'] ?: null;
|
||||
|
||||
if ($name && $email) {
|
||||
try {
|
||||
db()->beginTransaction();
|
||||
|
||||
$stmt = db()->prepare("INSERT INTO customers (msp_id, template_id, name, contact_email, status) VALUES (?, ?, ?, ?, 'onboarding')");
|
||||
$stmt->execute([$msp_id, $template_id, $name, $email]);
|
||||
$customer_id = db()->lastInsertId();
|
||||
|
||||
if ($template_id) {
|
||||
// Seed tasks from template steps
|
||||
$stmt = db()->prepare("SELECT title FROM onboarding_template_steps WHERE template_id = ? ORDER BY order_index ASC");
|
||||
$stmt->execute([$template_id]);
|
||||
$steps = $stmt->fetchAll();
|
||||
|
||||
foreach ($steps as $step) {
|
||||
$stmt = db()->prepare("INSERT INTO onboarding_tasks (customer_id, task_name) VALUES (?, ?)");
|
||||
$stmt->execute([$customer_id, "Complete Step: " . $step['title']]);
|
||||
}
|
||||
} else {
|
||||
// Default tasks if no template
|
||||
$default_tasks = ['Initial Call', 'Service Agreement signed', 'Access credentials received', 'Network audit completed'];
|
||||
foreach ($default_tasks as $task) {
|
||||
$stmt = db()->prepare("INSERT INTO onboarding_tasks (customer_id, task_name) VALUES (?, ?)");
|
||||
$stmt->execute([$customer_id, $task]);
|
||||
}
|
||||
}
|
||||
|
||||
db()->commit();
|
||||
$success = "Customer added successfully!";
|
||||
} catch (PDOException $e) {
|
||||
db()->rollBack();
|
||||
$error = "Error adding customer: " . $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
$error = "Please fill in all required fields.";
|
||||
}
|
||||
}
|
||||
|
||||
include 'header.php';
|
||||
?>
|
||||
|
||||
<div class="container py-5">
|
||||
<div class="header-section mb-5">
|
||||
<h1>Add New Customer</h1>
|
||||
<p class="text-muted">Register a new client and start the onboarding process.</p>
|
||||
</div>
|
||||
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-body p-4 p-md-5">
|
||||
<?php if ($success): ?>
|
||||
<div class="alert alert-success d-flex align-items-center mb-4">
|
||||
<i class="bi bi-check-circle-fill me-2"></i>
|
||||
<div><?php echo $success; ?> <a href="customers.php" class="alert-link">View customer list.</a></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="alert alert-danger d-flex align-items-center mb-4">
|
||||
<i class="bi bi-exclamation-triangle-fill me-2"></i>
|
||||
<div><?php echo $error; ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="POST" action="">
|
||||
<div class="row g-4">
|
||||
<div class="col-md-6">
|
||||
<label for="name" class="form-label fw-bold">Customer Name</label>
|
||||
<input type="text" name="name" id="name" class="form-control" placeholder="e.g. Acme Corporation" required>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="email" class="form-label fw-bold">Primary Contact Email</label>
|
||||
<input type="email" name="email" id="email" class="form-control" placeholder="e.g. contact@acme.com" required>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label for="template_id" class="form-label fw-bold">Onboarding Template</label>
|
||||
<select name="template_id" id="template_id" class="form-select">
|
||||
<option value="">-- No template (use default tasks) --</option>
|
||||
<?php foreach ($templates as $template): ?>
|
||||
<option value="<?php echo $template['id']; ?>"><?php echo htmlspecialchars($template['name']); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<div class="form-text mt-2 small text-muted">Choosing a template will automatically generate onboarding tasks based on that template.</div>
|
||||
</div>
|
||||
<div class="col-12 mt-5">
|
||||
<div class="d-grid gap-2">
|
||||
<button type="submit" class="btn btn-primary btn-lg fw-bold">
|
||||
<i class="bi bi-plus-circle me-2"></i> Create & Start Onboarding
|
||||
</button>
|
||||
<a href="customers.php" class="btn btn-link text-muted">Cancel</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'footer.php'; ?>
|
||||
24
api/update_customer_status.php
Normal file
24
api/update_customer_status.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require_once __DIR__ . '/../db/config.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
echo json_encode(['success' => false, 'message' => 'Invalid request method']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = $_POST['id'] ?? null;
|
||||
$status = $_POST['status'] ?? 'onboarding';
|
||||
|
||||
if (!$id) {
|
||||
echo json_encode(['success' => false, 'message' => 'Missing ID']);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$stmt = db()->prepare("UPDATE customers SET status = ? WHERE id = ?");
|
||||
$result = $stmt->execute([$status, (int)$id]);
|
||||
echo json_encode(['success' => true]);
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
24
api/update_task.php
Normal file
24
api/update_task.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require_once __DIR__ . '/../db/config.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
echo json_encode(['success' => false, 'message' => 'Invalid request method']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = $_POST['id'] ?? null;
|
||||
$completed = $_POST['completed'] ?? 0;
|
||||
|
||||
if (!$id) {
|
||||
echo json_encode(['success' => false, 'message' => 'Missing ID']);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$stmt = db()->prepare("UPDATE onboarding_tasks SET is_completed = ?, updated_at = NOW() WHERE id = ?");
|
||||
$result = $stmt->execute([(int)$completed, (int)$id]);
|
||||
echo json_encode(['success' => true]);
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
@ -1,302 +1,219 @@
|
||||
:root {
|
||||
--primary: #2563eb;
|
||||
--primary-hover: #1d4ed8;
|
||||
--secondary: #64748b;
|
||||
--bg-color: #f8fafc;
|
||||
--surface: #ffffff;
|
||||
--border: #e2e8f0;
|
||||
--text-main: #0f172a;
|
||||
--text-muted: #64748b;
|
||||
--success: #10b981;
|
||||
--warning: #f59e0b;
|
||||
--danger: #ef4444;
|
||||
--radius: 6px;
|
||||
}
|
||||
|
||||
body {
|
||||
background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
|
||||
background-size: 400% 400%;
|
||||
animation: gradient 15s ease infinite;
|
||||
color: #212529;
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
background-color: var(--bg-color);
|
||||
color: var(--text-main);
|
||||
line-height: 1.5;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.main-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 100vh;
|
||||
width: 100%;
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
.navbar {
|
||||
background-color: var(--surface);
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 1rem 2rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
@keyframes gradient {
|
||||
0% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
50% {
|
||||
background-position: 100% 50%;
|
||||
}
|
||||
100% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
.navbar-brand {
|
||||
font-weight: 700;
|
||||
font-size: 1.25rem;
|
||||
color: var(--primary);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.chat-container {
|
||||
width: 100%;
|
||||
max-width: 600px;
|
||||
background: rgba(255, 255, 255, 0.85);
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
border-radius: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 85vh;
|
||||
box-shadow: 0 20px 40px rgba(0,0,0,0.2);
|
||||
backdrop-filter: blur(15px);
|
||||
-webkit-backdrop-filter: blur(15px);
|
||||
overflow: hidden;
|
||||
.nav-links {
|
||||
display: flex;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.chat-header {
|
||||
padding: 1.5rem;
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
font-weight: 700;
|
||||
font-size: 1.1rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
.nav-link {
|
||||
color: var(--text-muted);
|
||||
text-decoration: none;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
.chat-messages {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 1.5rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
.nav-link:hover, .nav-link.active {
|
||||
color: var(--primary);
|
||||
}
|
||||
|
||||
/* Custom Scrollbar */
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 2rem auto;
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
.card {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 1.5rem;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
border-radius: 10px;
|
||||
.card-title {
|
||||
font-size: 1.125rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 1.25rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0.5rem 1rem;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
border-radius: var(--radius);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
border: 1px solid transparent;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.message {
|
||||
max-width: 85%;
|
||||
padding: 0.85rem 1.1rem;
|
||||
border-radius: 16px;
|
||||
line-height: 1.5;
|
||||
font-size: 0.95rem;
|
||||
box-shadow: 0 4px 15px rgba(0,0,0,0.05);
|
||||
animation: fadeIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
||||
.btn-primary {
|
||||
background-color: var(--primary);
|
||||
color: white;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(20px) scale(0.95); }
|
||||
to { opacity: 1; transform: translateY(0) scale(1); }
|
||||
.btn-primary:hover {
|
||||
background-color: var(--primary-hover);
|
||||
}
|
||||
|
||||
.message.visitor {
|
||||
align-self: flex-end;
|
||||
background: linear-gradient(135deg, #212529 0%, #343a40 100%);
|
||||
color: #fff;
|
||||
border-bottom-right-radius: 4px;
|
||||
.btn-outline {
|
||||
border-color: var(--border);
|
||||
background-color: transparent;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.message.bot {
|
||||
align-self: flex-start;
|
||||
background: #ffffff;
|
||||
color: #212529;
|
||||
border-bottom-left-radius: 4px;
|
||||
}
|
||||
|
||||
.chat-input-area {
|
||||
padding: 1.25rem;
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.chat-input-area form {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.chat-input-area input {
|
||||
flex: 1;
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-radius: 12px;
|
||||
padding: 0.75rem 1rem;
|
||||
outline: none;
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.chat-input-area input:focus {
|
||||
border-color: #23a6d5;
|
||||
box-shadow: 0 0 0 3px rgba(35, 166, 213, 0.2);
|
||||
}
|
||||
|
||||
.chat-input-area button {
|
||||
background: #212529;
|
||||
color: #fff;
|
||||
border: none;
|
||||
padding: 0.75rem 1.5rem;
|
||||
border-radius: 12px;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.chat-input-area button:hover {
|
||||
background: #000;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
/* Background Animations */
|
||||
.bg-animations {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 0;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.blob {
|
||||
position: absolute;
|
||||
width: 500px;
|
||||
height: 500px;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-radius: 50%;
|
||||
filter: blur(80px);
|
||||
animation: move 20s infinite alternate cubic-bezier(0.45, 0, 0.55, 1);
|
||||
}
|
||||
|
||||
.blob-1 {
|
||||
top: -10%;
|
||||
left: -10%;
|
||||
background: rgba(238, 119, 82, 0.4);
|
||||
}
|
||||
|
||||
.blob-2 {
|
||||
bottom: -10%;
|
||||
right: -10%;
|
||||
background: rgba(35, 166, 213, 0.4);
|
||||
animation-delay: -7s;
|
||||
width: 600px;
|
||||
height: 600px;
|
||||
}
|
||||
|
||||
.blob-3 {
|
||||
top: 40%;
|
||||
left: 30%;
|
||||
background: rgba(231, 60, 126, 0.3);
|
||||
animation-delay: -14s;
|
||||
width: 450px;
|
||||
height: 450px;
|
||||
}
|
||||
|
||||
@keyframes move {
|
||||
0% { transform: translate(0, 0) rotate(0deg) scale(1); }
|
||||
33% { transform: translate(150px, 100px) rotate(120deg) scale(1.1); }
|
||||
66% { transform: translate(-50px, 200px) rotate(240deg) scale(0.9); }
|
||||
100% { transform: translate(0, 0) rotate(360deg) scale(1); }
|
||||
}
|
||||
|
||||
.admin-link {
|
||||
font-size: 14px;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 8px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.admin-link:hover {
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* Admin Styles */
|
||||
.admin-container {
|
||||
max-width: 900px;
|
||||
margin: 3rem auto;
|
||||
padding: 2.5rem;
|
||||
background: rgba(255, 255, 255, 0.85);
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
border-radius: 24px;
|
||||
box-shadow: 0 20px 50px rgba(0,0,0,0.15);
|
||||
border: 1px solid rgba(255, 255, 255, 0.4);
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.admin-container h1 {
|
||||
margin-top: 0;
|
||||
color: #212529;
|
||||
font-weight: 800;
|
||||
.btn-outline:hover {
|
||||
background-color: #f1f5f9;
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0 8px;
|
||||
margin-top: 1.5rem;
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.table th, .table td {
|
||||
padding: 0.75rem 1rem;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.table th {
|
||||
background: transparent;
|
||||
border: none;
|
||||
padding: 1rem;
|
||||
color: #6c757d;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
font-size: 0.75rem;
|
||||
letter-spacing: 1px;
|
||||
font-size: 0.75rem;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-muted);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.table td {
|
||||
background: #fff;
|
||||
padding: 1rem;
|
||||
border: none;
|
||||
.badge {
|
||||
display: inline-flex;
|
||||
padding: 0.25rem 0.5rem;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
border-radius: 9999px;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.table tr td:first-child { border-radius: 12px 0 0 12px; }
|
||||
.table tr td:last-child { border-radius: 0 12px 12px 0; }
|
||||
.badge-onboarding { background: #dbeafe; color: #1e40af; }
|
||||
.badge-active { background: #dcfce7; color: #166534; }
|
||||
.badge-inactive { background: #f1f5f9; color: #475569; }
|
||||
|
||||
.checklist-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 0.75rem 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.checklist-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.checklist-item input[type="checkbox"] {
|
||||
width: 1.25rem;
|
||||
height: 1.25rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.checklist-item.completed span {
|
||||
text-decoration: line-through;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 1.25rem;
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 0.5rem;
|
||||
font-weight: 600;
|
||||
font-size: 0.9rem;
|
||||
.form-label {
|
||||
display: block;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.form-control {
|
||||
width: 100%;
|
||||
padding: 0.75rem 1rem;
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
transition: all 0.3s ease;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
padding: 0.5rem 0.75rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.form-control:focus {
|
||||
outline: none;
|
||||
border-color: #23a6d5;
|
||||
box-shadow: 0 0 0 3px rgba(35, 166, 213, 0.1);
|
||||
}
|
||||
outline: none;
|
||||
border-color: var(--primary);
|
||||
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 1.5rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
@ -1,39 +1,32 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const chatForm = document.getElementById('chat-form');
|
||||
const chatInput = document.getElementById('chat-input');
|
||||
const chatMessages = document.getElementById('chat-messages');
|
||||
|
||||
const appendMessage = (text, sender) => {
|
||||
const msgDiv = document.createElement('div');
|
||||
msgDiv.classList.add('message', sender);
|
||||
msgDiv.textContent = text;
|
||||
chatMessages.appendChild(msgDiv);
|
||||
chatMessages.scrollTop = chatMessages.scrollHeight;
|
||||
};
|
||||
|
||||
chatForm.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const message = chatInput.value.trim();
|
||||
if (!message) return;
|
||||
|
||||
appendMessage(message, 'visitor');
|
||||
chatInput.value = '';
|
||||
|
||||
try {
|
||||
const response = await fetch('api/chat.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ message })
|
||||
});
|
||||
const data = await response.json();
|
||||
|
||||
// Artificial delay for realism
|
||||
setTimeout(() => {
|
||||
appendMessage(data.reply, 'bot');
|
||||
}, 500);
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
appendMessage("Sorry, something went wrong. Please try again.", 'bot');
|
||||
// MSP Connect - Global Interactivity
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Navbar scroll effect
|
||||
const navbar = document.querySelector('.navbar');
|
||||
window.addEventListener('scroll', () => {
|
||||
if (window.scrollY > 10) {
|
||||
navbar.style.boxShadow = '0 4px 12px rgba(0,0,0,0.05)';
|
||||
} else {
|
||||
navbar.style.boxShadow = 'none';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Fade-in effect for cards
|
||||
const cards = document.querySelectorAll('.card');
|
||||
cards.forEach((card, index) => {
|
||||
card.style.opacity = '0';
|
||||
card.style.transform = 'translateY(10px)';
|
||||
card.style.transition = 'all 0.4s ease-out';
|
||||
setTimeout(() => {
|
||||
card.style.opacity = '1';
|
||||
card.style.transform = 'translateY(0)';
|
||||
}, index * 100);
|
||||
});
|
||||
|
||||
// Tooltip simulation/Simple alerts
|
||||
const buttons = document.querySelectorAll('.btn-outline');
|
||||
buttons.forEach(btn => {
|
||||
if (btn.getAttribute('title')) {
|
||||
// Natural browser title is fine for now
|
||||
}
|
||||
});
|
||||
});
|
||||
128
customer_view.php
Normal file
128
customer_view.php
Normal file
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
require_once 'db/config.php';
|
||||
|
||||
$customer_id = $_GET['id'] ?? null;
|
||||
$step_index = (int)($_GET['step'] ?? 0);
|
||||
|
||||
if (!$customer_id) {
|
||||
die("Invalid access.");
|
||||
}
|
||||
|
||||
$stmt = db()->prepare("SELECT c.*, m.name as msp_name FROM customers c JOIN msps m ON c.msp_id = m.id WHERE c.id = ?");
|
||||
$stmt->execute([$customer_id]);
|
||||
$customer = $stmt->fetch();
|
||||
|
||||
if (!$customer || !$customer['template_id']) {
|
||||
die("No onboarding template assigned to this customer.");
|
||||
}
|
||||
|
||||
// Fetch steps
|
||||
$stmt = db()->prepare("SELECT * FROM onboarding_template_steps WHERE template_id = ? ORDER BY order_index ASC");
|
||||
$stmt->execute([$customer['template_id']]);
|
||||
$steps = $stmt->fetchAll();
|
||||
|
||||
if (empty($steps)) {
|
||||
die("This onboarding flow has no steps.");
|
||||
}
|
||||
|
||||
$current_step = $steps[$step_index] ?? null;
|
||||
if (!$current_step) {
|
||||
$step_index = 0;
|
||||
$current_step = $steps[0];
|
||||
}
|
||||
|
||||
// Fetch fields for current step
|
||||
$stmt = db()->prepare("SELECT * FROM onboarding_template_fields WHERE step_id = ? ORDER BY order_index ASC");
|
||||
$stmt->execute([$current_step['id']]);
|
||||
$fields = $stmt->fetchAll();
|
||||
|
||||
$is_last_step = ($step_index === count($steps) - 1);
|
||||
|
||||
include 'header.php'; // We use the same header for simplicity, but we could make a "customer header"
|
||||
?>
|
||||
|
||||
<div class="container py-5 mt-4">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-9">
|
||||
<div class="text-center mb-5">
|
||||
<h6 class="text-primary fw-bold text-uppercase mb-2">Welcome to <?php echo htmlspecialchars($customer['msp_name']); ?></h6>
|
||||
<h1>Customer Onboarding</h1>
|
||||
<div class="d-flex justify-content-center mt-4">
|
||||
<?php foreach ($steps as $idx => $step): ?>
|
||||
<div class="px-2">
|
||||
<div class="rounded-pill <?php echo $idx === $step_index ? 'bg-primary' : ($idx < $step_index ? 'bg-success' : 'bg-light'); ?>" style="width: 40px; height: 10px;"></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card shadow border-0 overflow-hidden">
|
||||
<div class="card-body p-5">
|
||||
<h2 class="fw-bold mb-3"><?php echo htmlspecialchars($current_step['title']); ?></h2>
|
||||
<p class="text-muted mb-5 lead"><?php echo nl2br(htmlspecialchars($current_step['description'])); ?></p>
|
||||
|
||||
<form method="POST" action="customer_view.php?id=<?php echo $customer_id; ?>&step=<?php echo $step_index + 1; ?>">
|
||||
<div class="row g-4">
|
||||
<?php foreach ($fields as $field): ?>
|
||||
<div class="col-12">
|
||||
<?php if ($field['type'] === 'text'): ?>
|
||||
<div class="p-4 bg-light rounded-3 mb-3">
|
||||
<?php echo nl2br($field['content']); ?>
|
||||
</div>
|
||||
<?php elseif ($field['type'] === 'form_input'): ?>
|
||||
<label class="form-label fw-bold"><?php echo htmlspecialchars($field['label']); ?><?php echo $field['is_required'] ? ' <span class="text-danger">*</span>' : ''; ?></label>
|
||||
<input type="text" class="form-control form-control-lg" <?php echo $field['is_required'] ? 'required' : ''; ?>>
|
||||
<?php elseif ($field['type'] === 'form_textarea'): ?>
|
||||
<label class="form-label fw-bold"><?php echo htmlspecialchars($field['label']); ?><?php echo $field['is_required'] ? ' <span class="text-danger">*</span>' : ''; ?></label>
|
||||
<textarea class="form-control" rows="4" <?php echo $field['is_required'] ? 'required' : ''; ?>></textarea>
|
||||
<?php elseif ($field['type'] === 'form_select'): ?>
|
||||
<label class="form-label fw-bold"><?php echo htmlspecialchars($field['label']); ?><?php echo $field['is_required'] ? ' <span class="text-danger">*</span>' : ''; ?></label>
|
||||
<select class="form-select form-select-lg" <?php echo $field['is_required'] ? 'required' : ''; ?>>
|
||||
<option value="">Select an option...</option>
|
||||
<?php foreach (explode(',', $field['content']) as $opt): ?>
|
||||
<option value="<?php echo trim($opt); ?>"><?php echo trim($opt); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php elseif ($field['type'] === 'download'): ?>
|
||||
<div class="d-flex align-items-center p-3 border rounded-3 bg-light">
|
||||
<i class="bi bi-file-earmark-pdf display-6 text-danger me-3"></i>
|
||||
<div class="flex-grow-1">
|
||||
<div class="fw-bold"><?php echo htmlspecialchars($field['label']); ?></div>
|
||||
<small class="text-muted">Please download and review this document.</small>
|
||||
</div>
|
||||
<a href="<?php echo htmlspecialchars($field['content']); ?>" target="_blank" class="btn btn-primary btn-sm"><i class="bi bi-download"></i> Download</a>
|
||||
</div>
|
||||
<?php elseif ($field['type'] === 'upload'): ?>
|
||||
<label class="form-label fw-bold"><?php echo htmlspecialchars($field['label']); ?><?php echo $field['is_required'] ? ' <span class="text-danger">*</span>' : ''; ?></label>
|
||||
<input type="file" class="form-control" <?php echo $field['is_required'] ? 'required' : ''; ?>>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<div class="mt-5 d-flex justify-content-between">
|
||||
<?php if ($step_index > 0): ?>
|
||||
<a href="customer_view.php?id=<?php echo $customer_id; ?>&step=<?php echo $step_index - 1; ?>" class="btn btn-outline-secondary btn-lg px-5">Back</a>
|
||||
<?php else: ?>
|
||||
<div></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($is_last_step): ?>
|
||||
<button type="submit" class="btn btn-success btn-lg px-5 fw-bold">Finish Onboarding</button>
|
||||
<?php else: ?>
|
||||
<button type="submit" class="btn btn-primary btn-lg px-5 fw-bold">Next Step</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
body { background-color: #f8fafc; }
|
||||
.card { border-radius: 1rem; }
|
||||
</style>
|
||||
|
||||
<?php include 'footer.php'; ?>
|
||||
97
customers.php
Normal file
97
customers.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/header.php';
|
||||
|
||||
$msp_id = $_SESSION['msp_id'];
|
||||
$customers = [];
|
||||
try {
|
||||
$stmt = db()->prepare("SELECT * FROM customers WHERE msp_id = ? ORDER BY name ASC");
|
||||
$stmt->execute([$msp_id]);
|
||||
$customers = $stmt->fetchAll();
|
||||
} catch (PDOException $e) {
|
||||
// Handle error
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="container py-5">
|
||||
<div class="d-flex justify-content-between align-items-end mb-4">
|
||||
<div>
|
||||
<h1>Managed Customers</h1>
|
||||
<p class="text-muted">List of all customers and their current status.</p>
|
||||
</div>
|
||||
<a href="add_customer.php" class="btn btn-primary">
|
||||
<i class="bi bi-person-plus"></i> Add Customer
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-body p-0">
|
||||
<table class="table mb-0">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th class="ps-4 py-3">Customer Name</th>
|
||||
<th class="py-3">Email</th>
|
||||
<th class="py-3">Status</th>
|
||||
<th class="py-3">Onboarding Progress</th>
|
||||
<th class="pe-4 py-3">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($customers)): ?>
|
||||
<tr>
|
||||
<td colspan="5" class="text-center text-muted py-5">
|
||||
No customers found. <a href="add_customer.php" class="text-primary fw-bold">Add your first customer.</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($customers as $customer): ?>
|
||||
<tr>
|
||||
<td class="ps-4 fw-bold"><?php echo htmlspecialchars($customer['name']); ?></td>
|
||||
<td><?php echo htmlspecialchars($customer['contact_email'] ?? 'N/A'); ?></td>
|
||||
<td>
|
||||
<span class="badge <?php echo $customer['status'] == 'active' ? 'bg-success-subtle text-success' : 'bg-primary-subtle text-primary'; ?> rounded-pill">
|
||||
<?php echo ucfirst($customer['status']); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
$progress = 0;
|
||||
try {
|
||||
$stmt = db()->prepare("SELECT COUNT(*) as total, SUM(CASE WHEN is_completed = 1 THEN 1 ELSE 0 END) as completed FROM onboarding_tasks WHERE customer_id = ?");
|
||||
$stmt->execute([$customer['id']]);
|
||||
$row = $stmt->fetch();
|
||||
if ($row && $row['total'] > 0) {
|
||||
$progress = round(($row['completed'] / $row['total']) * 100);
|
||||
}
|
||||
} catch (PDOException $e) {}
|
||||
?>
|
||||
<div class="progress" style="height: 8px; width: 120px; display: inline-flex;">
|
||||
<div class="progress-bar bg-success" role="progressbar" style="width: <?php echo (int)$progress; ?>%;"></div>
|
||||
</div>
|
||||
<span class="small ms-2 fw-bold text-muted"><?php echo (int)$progress; ?>%</span>
|
||||
</td>
|
||||
<td class="pe-4">
|
||||
<div class="btn-group">
|
||||
<a href="onboarding.php?id=<?php echo $customer['id']; ?>" class="btn btn-outline-primary btn-sm" title="View Onboarding">
|
||||
<i class="bi bi-list-check"></i>
|
||||
</a>
|
||||
<a href="#" class="btn btn-outline-secondary btn-sm" title="Edit Details">
|
||||
<i class="bi bi-pencil-square"></i>
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require_once __DIR__ . '/footer.php'; ?>
|
||||
15
db/migrations_001.sql
Normal file
15
db/migrations_001.sql
Normal file
@ -0,0 +1,15 @@
|
||||
CREATE TABLE IF NOT EXISTS customers (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
contact_email VARCHAR(255),
|
||||
status ENUM('onboarding', 'active', 'inactive') DEFAULT 'onboarding',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS onboarding_tasks (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
customer_id INT NOT NULL,
|
||||
task_name VARCHAR(255) NOT NULL,
|
||||
is_completed BOOLEAN DEFAULT FALSE,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
79
db/migrations_002.sql
Normal file
79
db/migrations_002.sql
Normal file
@ -0,0 +1,79 @@
|
||||
-- Plans table
|
||||
CREATE TABLE IF NOT EXISTS plans (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
price DECIMAL(10, 2) DEFAULT 0.00,
|
||||
max_customers INT DEFAULT 10,
|
||||
can_custom_domain BOOLEAN DEFAULT FALSE,
|
||||
is_trial BOOLEAN DEFAULT FALSE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- Seed default plans
|
||||
INSERT INTO plans (name, price, max_customers, can_custom_domain, is_trial) VALUES
|
||||
('Free Trial', 0.00, 5, FALSE, TRUE),
|
||||
('Pro', 49.00, 50, TRUE, FALSE),
|
||||
('Enterprise', 199.00, 1000, TRUE, FALSE);
|
||||
|
||||
-- MSPs table (Tenants)
|
||||
CREATE TABLE IF NOT EXISTS msps (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
plan_id INT NOT NULL,
|
||||
subdomain VARCHAR(255) UNIQUE,
|
||||
custom_domain VARCHAR(255) UNIQUE,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (plan_id) REFERENCES plans(id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- Users table
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
msp_id INT NULL, -- NULL for superadmins
|
||||
name VARCHAR(255) NOT NULL,
|
||||
email VARCHAR(255) UNIQUE NOT NULL,
|
||||
password_hash VARCHAR(255) NOT NULL,
|
||||
role ENUM('superadmin', 'msp_admin', 'msp_staff') NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (msp_id) REFERENCES msps(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- Onboarding Templates
|
||||
CREATE TABLE IF NOT EXISTS onboarding_templates (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
msp_id INT NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (msp_id) REFERENCES msps(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- Onboarding Template Steps (Pages)
|
||||
CREATE TABLE IF NOT EXISTS onboarding_template_steps (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
template_id INT NOT NULL,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
order_index INT DEFAULT 0,
|
||||
FOREIGN KEY (template_id) REFERENCES onboarding_templates(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- Onboarding Template Fields/Content
|
||||
CREATE TABLE IF NOT EXISTS onboarding_template_fields (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
step_id INT NOT NULL,
|
||||
type ENUM('text', 'form_input', 'form_textarea', 'form_select', 'download', 'upload') NOT NULL,
|
||||
label VARCHAR(255) NOT NULL,
|
||||
content TEXT, -- Used for 'text' or 'download' URL or 'options' for select
|
||||
is_required BOOLEAN DEFAULT FALSE,
|
||||
order_index INT DEFAULT 0,
|
||||
FOREIGN KEY (step_id) REFERENCES onboarding_template_steps(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- Update customers table to link to MSP
|
||||
ALTER TABLE customers ADD COLUMN msp_id INT NOT NULL AFTER id;
|
||||
ALTER TABLE customers ADD CONSTRAINT fk_customer_msp FOREIGN KEY (msp_id) REFERENCES msps(id) ON DELETE CASCADE;
|
||||
|
||||
-- Create a default superadmin (password: admin123)
|
||||
-- In a real app, this would be handled via a setup script or CLI.
|
||||
INSERT INTO users (name, email, password_hash, role) VALUES
|
||||
('Super Admin', 'admin@msp-portal.com', '$2y$10$GCGS7B2IaiORPL9MtntJ1uw4QiuzpQgqvexHwRu/CI8M3Lmtex5BS', 'superadmin');
|
||||
15
db/setup.php
Normal file
15
db/setup.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/config.php';
|
||||
|
||||
try {
|
||||
$migrations = glob(__DIR__ . '/migrations_*.sql');
|
||||
sort($migrations);
|
||||
foreach ($migrations as $migration) {
|
||||
$sql = file_get_contents($migration);
|
||||
db()->exec($sql);
|
||||
echo "Executed migration: " . basename($migration) . "\n";
|
||||
}
|
||||
echo "Database setup successful.";
|
||||
} catch (PDOException $e) {
|
||||
echo "Error setting up database: " . $e->getMessage();
|
||||
}
|
||||
249
edit_template.php
Normal file
249
edit_template.php
Normal file
@ -0,0 +1,249 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id']) || !isset($_SESSION['msp_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once 'db/config.php';
|
||||
|
||||
$msp_id = $_SESSION['msp_id'];
|
||||
$template_id = $_GET['id'] ?? null;
|
||||
|
||||
if (!$template_id) {
|
||||
header('Location: templates.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Security: Check if template belongs to the current MSP
|
||||
$stmt = db()->prepare("SELECT * FROM onboarding_templates WHERE id = ? AND msp_id = ?");
|
||||
$stmt->execute([$template_id, $msp_id]);
|
||||
$template = $stmt->fetch();
|
||||
|
||||
if (!$template) {
|
||||
header('Location: templates.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Handle Form Submissions
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
|
||||
if ($_POST['action'] === 'add_step') {
|
||||
$title = $_POST['title'];
|
||||
$description = $_POST['description'];
|
||||
|
||||
$stmt = db()->prepare("SELECT MAX(order_index) FROM onboarding_template_steps WHERE template_id = ?");
|
||||
$stmt->execute([$template_id]);
|
||||
$max_order = $stmt->fetchColumn() ?: 0;
|
||||
|
||||
$stmt = db()->prepare("INSERT INTO onboarding_template_steps (template_id, title, description, order_index) VALUES (?, ?, ?, ?)");
|
||||
$stmt->execute([$template_id, $title, $description, $max_order + 1]);
|
||||
header("Location: edit_template.php?id=$template_id");
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($_POST['action'] === 'add_field') {
|
||||
$step_id = $_POST['step_id'];
|
||||
$type = $_POST['type'];
|
||||
$label = $_POST['label'];
|
||||
$content = $_POST['content'] ?? '';
|
||||
$is_required = isset($_POST['is_required']) ? 1 : 0;
|
||||
|
||||
$stmt = db()->prepare("SELECT MAX(order_index) FROM onboarding_template_fields WHERE step_id = ?");
|
||||
$stmt->execute([$step_id]);
|
||||
$max_order = $stmt->fetchColumn() ?: 0;
|
||||
|
||||
$stmt = db()->prepare("INSERT INTO onboarding_template_fields (step_id, type, label, content, is_required, order_index) VALUES (?, ?, ?, ?, ?, ?)");
|
||||
$stmt->execute([$step_id, $type, $label, $content, $is_required, $max_order + 1]);
|
||||
header("Location: edit_template.php?id=$template_id");
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($_POST['action'] === 'delete_step') {
|
||||
$step_id = $_POST['step_id'];
|
||||
$stmt = db()->prepare("DELETE FROM onboarding_template_steps WHERE id = ? AND template_id = ?");
|
||||
$stmt->execute([$step_id, $template_id]);
|
||||
header("Location: edit_template.php?id=$template_id");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch all steps and their fields
|
||||
$stmt = db()->prepare("SELECT * FROM onboarding_template_steps WHERE template_id = ? ORDER BY order_index ASC");
|
||||
$stmt->execute([$template_id]);
|
||||
$steps = $stmt->fetchAll();
|
||||
|
||||
foreach ($steps as &$step) {
|
||||
$stmt = db()->prepare("SELECT * FROM onboarding_template_fields WHERE step_id = ? ORDER BY order_index ASC");
|
||||
$stmt->execute([$step['id']]);
|
||||
$step['fields'] = $stmt->fetchAll();
|
||||
}
|
||||
|
||||
include 'header.php';
|
||||
?>
|
||||
|
||||
<div class="container py-5">
|
||||
<div class="mb-4">
|
||||
<a href="templates.php" class="btn btn-outline-secondary btn-sm mb-3"><i class="bi bi-arrow-left"></i> Back to Templates</a>
|
||||
<div class="d-flex justify-content-between align-items-end">
|
||||
<div>
|
||||
<h1 class="mb-1">Editing Template: <?php echo htmlspecialchars($template['name']); ?></h1>
|
||||
<p class="text-muted"><?php echo htmlspecialchars($template['description']); ?></p>
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addStepModal">
|
||||
<i class="bi bi-plus-circle"></i> Add Step/Page
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (empty($steps)): ?>
|
||||
<div class="alert alert-info py-5 text-center">
|
||||
<h4 class="mb-3">This template has no steps yet.</h4>
|
||||
<p class="text-muted">Start by adding a new page to your onboarding flow.</p>
|
||||
<button type="button" class="btn btn-primary mt-3" data-bs-toggle="modal" data-bs-target="#addStepModal">
|
||||
<i class="bi bi-plus-circle"></i> Add First Step
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="onboarding-flow mt-5">
|
||||
<?php foreach ($steps as $index => $step): ?>
|
||||
<div class="card shadow-sm border-0 mb-5">
|
||||
<div class="card-header bg-white p-4 border-bottom-0 d-flex justify-content-between align-items-center">
|
||||
<h3 class="fw-bold mb-0">Step <?php echo $index + 1; ?>: <?php echo htmlspecialchars($step['title']); ?></h3>
|
||||
<div>
|
||||
<button type="button" class="btn btn-outline-primary btn-sm me-2" data-bs-toggle="modal" data-bs-target="#addFieldModal<?php echo $step['id']; ?>">
|
||||
<i class="bi bi-plus-lg"></i> Add Item
|
||||
</button>
|
||||
<form method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to delete this entire step?');">
|
||||
<input type="hidden" name="action" value="delete_step">
|
||||
<input type="hidden" name="step_id" value="<?php echo $step['id']; ?>">
|
||||
<button type="submit" class="btn btn-outline-danger btn-sm"><i class="bi bi-trash"></i></button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body p-4 pt-0">
|
||||
<p class="text-muted mb-4"><?php echo htmlspecialchars($step['description']); ?></p>
|
||||
|
||||
<div class="list-group list-group-flush border rounded">
|
||||
<?php foreach ($step['fields'] as $field): ?>
|
||||
<div class="list-group-item p-3">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<span class="badge bg-light text-dark border me-2"><?php echo strtoupper(str_replace('_', ' ', $field['type'])); ?></span>
|
||||
<span class="fw-bold"><?php echo htmlspecialchars($field['label']); ?></span>
|
||||
<?php if ($field['is_required']): ?>
|
||||
<span class="text-danger">*</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn btn-link btn-sm p-0 text-muted me-2"><i class="bi bi-pencil"></i></button>
|
||||
<button class="btn btn-link btn-sm p-0 text-danger"><i class="bi bi-x-lg"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($field['type'] === 'text'): ?>
|
||||
<div class="mt-2 small text-muted border-start ps-3 py-2 italic"><?php echo nl2br(htmlspecialchars($field['content'])); ?></div>
|
||||
<?php elseif ($field['type'] === 'download'): ?>
|
||||
<div class="mt-2"><a href="<?php echo htmlspecialchars($field['content']); ?>" target="_blank" class="btn btn-light btn-sm"><i class="bi bi-download"></i> Download Resource</a></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if (empty($step['fields'])): ?>
|
||||
<div class="list-group-item p-5 text-center text-muted italic">
|
||||
No items added to this step yet.
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add Field Modal for this step -->
|
||||
<div class="modal fade" id="addFieldModal<?php echo $step['id']; ?>" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form method="POST">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Add Item to Step: <?php echo htmlspecialchars($step['title']); ?></h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" name="action" value="add_field">
|
||||
<input type="hidden" name="step_id" value="<?php echo $step['id']; ?>">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Type</label>
|
||||
<select name="type" class="form-select" required onchange="toggleFieldOptions(this, 'options_<?php echo $step['id']; ?>')">
|
||||
<option value="text">Informational Text (HTML Allowed)</option>
|
||||
<option value="form_input">Form Input (Single Line)</option>
|
||||
<option value="form_textarea">Form Textarea (Multi-line)</option>
|
||||
<option value="form_select">Dropdown Menu</option>
|
||||
<option value="download">Download Link/File</option>
|
||||
<option value="upload">Customer Upload Field</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Label/Title</label>
|
||||
<input type="text" name="label" class="form-control" placeholder="e.g. Please enter your VAT number" required>
|
||||
</div>
|
||||
|
||||
<div id="options_<?php echo $step['id']; ?>">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Content/Options</label>
|
||||
<textarea name="content" class="form-control" rows="3" placeholder="Enter text content, download URL, or comma-separated options for dropdown."></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 form-check">
|
||||
<input type="checkbox" name="is_required" class="form-check-input" id="req_<?php echo $step['id']; ?>">
|
||||
<label class="form-check-label" for="req_<?php echo $step['id']; ?>">Is this field required?</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Add Item</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add Step Modal -->
|
||||
<div class="modal fade" id="addStepModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form method="POST">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Add New Page/Step</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" name="action" value="add_step">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Step Title</label>
|
||||
<input type="text" name="title" class="form-control" placeholder="e.g. Company Details" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Description/Instruction</label>
|
||||
<textarea name="description" class="form-control" rows="2" placeholder="Tell the customer what this step is about."></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Add Step</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function toggleFieldOptions(select, optionsId) {
|
||||
// We could hide/show specific inputs based on type here
|
||||
}
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<?php include 'footer.php'; ?>
|
||||
8
footer.php
Normal file
8
footer.php
Normal file
@ -0,0 +1,8 @@
|
||||
<footer class="container" style="text-align: center; color: var(--text-muted); font-size: 0.75rem; margin-top: 4rem; padding-bottom: 2rem;">
|
||||
© <?php echo date('Y'); ?> MSP Connect Platform. All rights reserved.
|
||||
<br>
|
||||
<span style="opacity: 0.5;">v1.0.0-beta | Powered by LAMP</span>
|
||||
</footer>
|
||||
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||
</body>
|
||||
</html>
|
||||
73
header.php
Normal file
73
header.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
$current_page = basename($_SERVER['PHP_SELF']);
|
||||
|
||||
// Auth Check for most pages (excluding login/register)
|
||||
$public_pages = ['login.php', 'register.php'];
|
||||
if (!isset($_SESSION['user_id']) && !in_array($current_page, $public_pages)) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Read project preview data from environment
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'MSP Customer Success Platform for onboarding and management.';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>MSP Connect | Customer Success Platform</title>
|
||||
|
||||
<?php if ($projectDescription): ?>
|
||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<?php endif; ?>
|
||||
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar">
|
||||
<a href="index.php" class="navbar-brand">
|
||||
<i class="bi bi-shield-check"></i> MSP Connect
|
||||
</a>
|
||||
<div class="nav-links">
|
||||
<?php if (isset($_SESSION['user_id'])): ?>
|
||||
<?php if ($_SESSION['role'] === 'superadmin'): ?>
|
||||
<a href="superadmin_dashboard.php" class="nav-link <?php echo $current_page == 'superadmin_dashboard.php' ? 'active' : ''; ?>">Superadmin</a>
|
||||
<a href="manage_msps.php" class="nav-link <?php echo $current_page == 'manage_msps.php' ? 'active' : ''; ?>">MSPs</a>
|
||||
<a href="plans.php" class="nav-link <?php echo $current_page == 'plans.php' ? 'active' : ''; ?>">Plans</a>
|
||||
<?php else: ?>
|
||||
<a href="index.php" class="nav-link <?php echo $current_page == 'index.php' ? 'active' : ''; ?>">Dashboard</a>
|
||||
<a href="customers.php" class="nav-link <?php echo $current_page == 'customers.php' ? 'active' : ''; ?>">Customers</a>
|
||||
<a href="templates.php" class="nav-link <?php echo $current_page == 'templates.php' ? 'active' : ''; ?>">Templates</a>
|
||||
<a href="#" class="nav-link">QBRs</a>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div>
|
||||
<?php if (isset($_SESSION['user_id'])): ?>
|
||||
<span style="font-size: 0.875rem; color: var(--text-muted); margin-right: 1rem;">
|
||||
<?php echo htmlspecialchars($_SESSION['user_name']); ?>
|
||||
(<?php echo strtoupper($_SESSION['role']); ?>)
|
||||
</span>
|
||||
<a href="logout.php" class="btn btn-outline" style="padding: 0.25rem 0.5rem;" title="Logout"><i class="bi bi-box-arrow-right"></i></a>
|
||||
<?php else: ?>
|
||||
<a href="login.php" class="nav-link d-inline-block">Login</a>
|
||||
<a href="register.php" class="btn btn-primary btn-sm ms-2">Register MSP</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</nav>
|
||||
251
index.php
251
index.php
@ -1,150 +1,109 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$phpVersion = PHP_VERSION;
|
||||
$now = date('Y-m-d H:i:s');
|
||||
require_once 'db/config.php';
|
||||
|
||||
// If superadmin, redirect to superadmin dashboard
|
||||
if ($_SESSION['role'] === 'superadmin') {
|
||||
header('Location: superadmin_dashboard.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$msp_id = $_SESSION['msp_id'];
|
||||
|
||||
// Stats for current MSP
|
||||
$total_customers = db()->prepare("SELECT COUNT(*) FROM customers WHERE msp_id = ?");
|
||||
$total_customers->execute([$msp_id]);
|
||||
$total_customers = $total_customers->fetchColumn();
|
||||
|
||||
$onboarding_count = db()->prepare("SELECT COUNT(*) FROM customers WHERE msp_id = ? AND status = 'onboarding'");
|
||||
$onboarding_count->execute([$msp_id]);
|
||||
$onboarding_count = $onboarding_count->fetchColumn();
|
||||
|
||||
$active_count = db()->prepare("SELECT COUNT(*) FROM customers WHERE msp_id = ? AND status = 'active'");
|
||||
$active_count->execute([$msp_id]);
|
||||
$active_count = $active_count->fetchColumn();
|
||||
|
||||
// Recent Customers
|
||||
$stmt = db()->prepare("SELECT * FROM customers WHERE msp_id = ? ORDER BY created_at DESC LIMIT 5");
|
||||
$stmt->execute([$msp_id]);
|
||||
$recent_customers = $stmt->fetchAll();
|
||||
|
||||
include 'header.php';
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>New Style</title>
|
||||
<?php
|
||||
// Read project preview data from environment
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
?>
|
||||
<?php if ($projectDescription): ?>
|
||||
<!-- Meta description -->
|
||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
||||
<!-- Open Graph meta tags -->
|
||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<!-- Twitter meta tags -->
|
||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<!-- Open Graph image -->
|
||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<!-- Twitter image -->
|
||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<?php endif; ?>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--bg-color-start: #6a11cb;
|
||||
--bg-color-end: #2575fc;
|
||||
--text-color: #ffffff;
|
||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
||||
animation: bg-pan 20s linear infinite;
|
||||
z-index: -1;
|
||||
}
|
||||
@keyframes bg-pan {
|
||||
0% { background-position: 0% 0%; }
|
||||
100% { background-position: 100% 100%; }
|
||||
}
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
.card {
|
||||
background: var(--card-bg-color);
|
||||
border: 1px solid var(--card-border-color);
|
||||
border-radius: 16px;
|
||||
padding: 2rem;
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.loader {
|
||||
margin: 1.25rem auto 1.25rem;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
@keyframes spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
.hint {
|
||||
opacity: 0.9;
|
||||
}
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px; height: 1px;
|
||||
padding: 0; margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap; border: 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
margin: 0 0 1rem;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
p {
|
||||
margin: 0.5rem 0;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
code {
|
||||
background: rgba(0,0,0,0.2);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
font-size: 0.8rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="card">
|
||||
<h1>Analyzing your requirements and generating your website…</h1>
|
||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||
<span class="sr-only">Loading…</span>
|
||||
</div>
|
||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
||||
|
||||
<div class="container py-5">
|
||||
<div class="header-section">
|
||||
<h1>Dashboard</h1>
|
||||
<p class="text-muted">Welcome back, <?php echo htmlspecialchars($_SESSION['user_name']); ?>. Here's what's happening with your clients.</p>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card">
|
||||
<div class="stat-value"><?php echo $total_customers; ?></div>
|
||||
<div class="stat-label">Total Clients</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value text-primary"><?php echo $onboarding_count; ?></div>
|
||||
<div class="stat-label">In Onboarding</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value text-success"><?php echo $active_count; ?></div>
|
||||
<div class="stat-label">Active Managed</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-5">
|
||||
<div class="col-md-8">
|
||||
<div class="card shadow-sm border-0 mb-4">
|
||||
<div class="card-body p-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h3 class="fw-bold mb-0">Recent Customers</h3>
|
||||
<a href="customers.php" class="btn btn-outline btn-sm">View All</a>
|
||||
</div>
|
||||
<div class="list-group list-group-flush">
|
||||
<?php foreach ($recent_customers as $customer): ?>
|
||||
<a href="onboarding.php?id=<?php echo $customer['id']; ?>" class="list-group-item list-group-item-action border-0 px-0 py-3 d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<div class="fw-bold text-primary"><?php echo htmlspecialchars($customer['name']); ?></div>
|
||||
<small class="text-muted"><?php echo htmlspecialchars($customer['contact_email']); ?></small>
|
||||
</div>
|
||||
<span class="badge <?php echo $customer['status'] == 'active' ? 'bg-success-subtle text-success' : 'bg-primary-subtle text-primary'; ?> rounded-pill">
|
||||
<?php echo ucfirst($customer['status']); ?>
|
||||
</span>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
<?php if (empty($recent_customers)): ?>
|
||||
<p class="text-muted text-center py-4">No customers yet. <a href="add_customer.php">Add your first one!</a></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card shadow-sm border-0 mb-4 bg-primary text-white">
|
||||
<div class="card-body p-4">
|
||||
<h4 class="fw-bold mb-3">Onboarding Help</h4>
|
||||
<p class="small opacity-75">Need to streamline your client intake? Use our template builder to create custom onboarding flows.</p>
|
||||
<a href="templates.php" class="btn btn-light btn-sm fw-bold">Manage Templates</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-body p-4">
|
||||
<h4 class="fw-bold mb-3">System Updates</h4>
|
||||
<div class="small">
|
||||
<div class="mb-2"><strong>v2.0</strong> - Multi-tenancy & Templates <span class="text-muted float-end">Mar 1</span></div>
|
||||
<div class="mb-2"><strong>v1.5</strong> - QBR Support <span class="text-muted float-end">Feb 20</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'footer.php'; ?>
|
||||
|
||||
72
login.php
Normal file
72
login.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (isset($_SESSION['user_id'])) {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$error = '';
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$email = $_POST['email'] ?? '';
|
||||
$password = $_POST['password'] ?? '';
|
||||
|
||||
$stmt = db()->prepare("SELECT * FROM users WHERE email = ?");
|
||||
$stmt->execute([$email]);
|
||||
$user = $stmt->fetch();
|
||||
|
||||
if ($user && password_verify($password, $user['password_hash'])) {
|
||||
$_SESSION['user_id'] = $user['id'];
|
||||
$_SESSION['msp_id'] = $user['msp_id'];
|
||||
$_SESSION['role'] = $user['role'];
|
||||
$_SESSION['user_name'] = $user['name'];
|
||||
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
} else {
|
||||
$error = 'Invalid email or password.';
|
||||
}
|
||||
}
|
||||
|
||||
include 'header.php';
|
||||
?>
|
||||
|
||||
<div class="container py-5 mt-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-5">
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-body p-5">
|
||||
<div class="text-center mb-4">
|
||||
<h2 class="fw-bold text-primary">MSP Portal Login</h2>
|
||||
<p class="text-muted">Welcome back! Please enter your details.</p>
|
||||
</div>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="alert alert-danger mb-4"><?php echo $error; ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="POST" action="">
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email Address</label>
|
||||
<input type="email" name="email" id="email" class="form-control py-2" required>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label for="password" class="form-label">Password</label>
|
||||
<input type="password" name="password" id="password" class="form-control py-2" required>
|
||||
</div>
|
||||
<div class="d-grid gap-2">
|
||||
<button type="submit" class="btn btn-primary py-2 fw-bold">Sign In</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="text-center mt-4">
|
||||
<p class="mb-0 text-muted small">Don't have an account? <a href="register.php" class="text-primary fw-bold text-decoration-none">Register your MSP</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'footer.php'; ?>
|
||||
5
logout.php
Normal file
5
logout.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
session_start();
|
||||
session_destroy();
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
132
manage_msps.php
Normal file
132
manage_msps.php
Normal file
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'superadmin') {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once 'db/config.php';
|
||||
|
||||
$success = '';
|
||||
$error = '';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
|
||||
if ($_POST['action'] === 'update_msp') {
|
||||
$msp_id = $_POST['msp_id'];
|
||||
$subdomain = $_POST['subdomain'];
|
||||
$custom_domain = $_POST['custom_domain'];
|
||||
$plan_id = $_POST['plan_id'];
|
||||
|
||||
try {
|
||||
$stmt = db()->prepare("UPDATE msps SET subdomain = ?, custom_domain = ?, plan_id = ? WHERE id = ?");
|
||||
$stmt->execute([$subdomain ?: null, $custom_domain ?: null, $plan_id, $msp_id]);
|
||||
$success = "MSP configuration updated successfully.";
|
||||
} catch (PDOException $e) {
|
||||
$error = "Error updating MSP: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$stmt = db()->query("SELECT m.*, p.name as plan_name FROM msps m JOIN plans p ON m.plan_id = p.id ORDER BY m.name ASC");
|
||||
$msps = $stmt->fetchAll();
|
||||
|
||||
$stmt = db()->query("SELECT * FROM plans");
|
||||
$plans = $stmt->fetchAll();
|
||||
|
||||
include 'header.php';
|
||||
?>
|
||||
|
||||
<div class="container py-5">
|
||||
<div class="header-section">
|
||||
<h1>Manage MSPs</h1>
|
||||
<p class="text-muted">Manage tenant subdomains, custom domains, and subscription plans.</p>
|
||||
</div>
|
||||
|
||||
<?php if ($success): ?>
|
||||
<div class="alert alert-success"><?php echo $success; ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($error): ?>
|
||||
<div class="alert alert-danger"><?php echo $error; ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-body p-4">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>MSP Name</th>
|
||||
<th>Current Plan</th>
|
||||
<th>Subdomain</th>
|
||||
<th>Custom Domain</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($msps as $msp): ?>
|
||||
<tr>
|
||||
<td class="fw-bold"><?php echo htmlspecialchars($msp['name']); ?></td>
|
||||
<td><span class="badge bg-light text-dark border"><?php echo htmlspecialchars($msp['plan_name']); ?></span></td>
|
||||
<td><?php echo $msp['subdomain'] ? htmlspecialchars($msp['subdomain']) . '.mspconnect.com' : 'N/A'; ?></td>
|
||||
<td><?php echo $msp['custom_domain'] ? htmlspecialchars($msp['custom_domain']) : 'N/A'; ?></td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#editMspModal<?php echo $msp['id']; ?>">
|
||||
<i class="bi bi-pencil-square"></i> Edit
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Edit MSP Modal -->
|
||||
<div class="modal fade" id="editMspModal<?php echo $msp['id']; ?>" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form method="POST">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Configure MSP: <?php echo htmlspecialchars($msp['name']); ?></h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" name="action" value="update_msp">
|
||||
<input type="hidden" name="msp_id" value="<?php echo $msp['id']; ?>">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Subscription Plan</label>
|
||||
<select name="plan_id" class="form-select">
|
||||
<?php foreach ($plans as $plan): ?>
|
||||
<option value="<?php echo $plan['id']; ?>" <?php echo $plan['id'] == $msp['plan_id'] ? 'selected' : ''; ?>>
|
||||
<?php echo $plan['name']; ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Subdomain</label>
|
||||
<div class="input-group">
|
||||
<input type="text" name="subdomain" class="form-control" value="<?php echo htmlspecialchars($msp['subdomain'] ?? ''); ?>">
|
||||
<span class="input-group-text">.mspconnect.com</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Custom Domain</label>
|
||||
<input type="text" name="custom_domain" class="form-control" placeholder="e.g. portal.acme.com" value="<?php echo htmlspecialchars($msp['custom_domain'] ?? ''); ?>">
|
||||
<small class="text-muted">Only available for Pro and Enterprise plans.</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="submit" class="btn btn-primary">Save Changes</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<?php include 'footer.php'; ?>
|
||||
107
onboarding.php
Normal file
107
onboarding.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once 'db/config.php';
|
||||
|
||||
$msp_id = $_SESSION['msp_id'];
|
||||
$customer_id = $_GET['id'] ?? null;
|
||||
|
||||
if (!$customer_id) {
|
||||
header('Location: customers.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Security: Check if customer belongs to the current MSP
|
||||
$stmt = db()->prepare("SELECT * FROM customers WHERE id = ? AND msp_id = ?");
|
||||
$stmt->execute([$customer_id, $msp_id]);
|
||||
$customer = $stmt->fetch();
|
||||
|
||||
if (!$customer) {
|
||||
header('Location: customers.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Fetch tasks for the customer
|
||||
$stmt = db()->prepare("SELECT * FROM onboarding_tasks WHERE customer_id = ? ORDER BY id ASC");
|
||||
$stmt->execute([$customer_id]);
|
||||
$tasks = $stmt->fetchAll();
|
||||
|
||||
include 'header.php';
|
||||
?>
|
||||
|
||||
<div class="container py-5">
|
||||
<div class="d-flex justify-content-between align-items-end mb-4">
|
||||
<div>
|
||||
<h1>Onboarding: <?php echo htmlspecialchars($customer['name']); ?></h1>
|
||||
<p class="text-muted">Track and manage the setup process for this client.</p>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
<a href="customer_view.php?id=<?php echo $customer_id; ?>" class="btn btn-outline-primary" target="_blank">
|
||||
<i class="bi bi-eye"></i> Customer View
|
||||
</a>
|
||||
<button class="btn btn-success" onclick="updateCustomerStatus(<?php echo $customer_id; ?>, 'active')">
|
||||
<i class="bi bi-check-all"></i> Mark as Active
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row g-4">
|
||||
<div class="col-md-8">
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-body p-4">
|
||||
<h4 class="fw-bold mb-4">Onboarding Checklist</h4>
|
||||
<div class="list-group list-group-flush">
|
||||
<?php foreach ($tasks as $task): ?>
|
||||
<div class="list-group-item px-0 py-3 border-0 d-flex align-items-center">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="task_<?php echo $task['id']; ?>"
|
||||
<?php echo $task['is_completed'] ? 'checked' : ''; ?>
|
||||
onchange="updateTask(<?php echo $task['id']; ?>, this.checked)">
|
||||
<label class="form-check-label ms-3 <?php echo $task['is_completed'] ? 'text-decoration-line-through text-muted' : 'fw-bold'; ?>" for="task_<?php echo $task['id']; ?>">
|
||||
<?php echo htmlspecialchars($task['name']); ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if (empty($tasks)): ?>
|
||||
<div class="text-center py-5 text-muted">
|
||||
<i class="bi bi-clipboard-x display-4"></i>
|
||||
<p class="mt-2">No tasks assigned to this customer.</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="card shadow-sm border-0 mb-4">
|
||||
<div class="card-body p-4">
|
||||
<h5 class="fw-bold mb-3">Customer Information</h5>
|
||||
<div class="mb-3">
|
||||
<label class="small text-muted d-block">Contact Email</label>
|
||||
<span class="fw-bold"><?php echo htmlspecialchars($customer['contact_email']); ?></span>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="small text-muted d-block">Onboarding Status</label>
|
||||
<span class="badge <?php echo $customer['status'] == 'active' ? 'bg-success' : 'bg-primary'; ?> rounded-pill">
|
||||
<?php echo ucfirst($customer['status']); ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="mb-0">
|
||||
<label class="small text-muted d-block">Started On</label>
|
||||
<span class="fw-bold"><?php echo date('M d, Y', strtotime($customer['created_at'])); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="assets/js/main.js"></script>
|
||||
<?php include 'footer.php'; ?>
|
||||
131
register.php
Normal file
131
register.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (isset($_SESSION['user_id'])) {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = db()->query("SELECT * FROM plans");
|
||||
$plans = $stmt->fetchAll();
|
||||
|
||||
$error = '';
|
||||
$success = '';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$msp_name = $_POST['msp_name'] ?? '';
|
||||
$plan_id = $_POST['plan_id'] ?? '';
|
||||
$user_name = $_POST['user_name'] ?? '';
|
||||
$email = $_POST['email'] ?? '';
|
||||
$password = $_POST['password'] ?? '';
|
||||
$confirm_password = $_POST['confirm_password'] ?? '';
|
||||
|
||||
if ($password !== $confirm_password) {
|
||||
$error = 'Passwords do not match.';
|
||||
} else {
|
||||
try {
|
||||
db()->beginTransaction();
|
||||
|
||||
$stmt = db()->prepare("INSERT INTO msps (name, plan_id) VALUES (?, ?)");
|
||||
$stmt->execute([$msp_name, $plan_id]);
|
||||
$msp_id = db()->lastInsertId();
|
||||
|
||||
$password_hash = password_hash($password, PASSWORD_DEFAULT);
|
||||
$stmt = db()->prepare("INSERT INTO users (msp_id, name, email, password_hash, role) VALUES (?, ?, ?, ?, 'msp_admin')");
|
||||
$stmt->execute([$msp_id, $user_name, $email, $password_hash]);
|
||||
|
||||
db()->commit();
|
||||
|
||||
$_SESSION['user_id'] = db()->lastInsertId();
|
||||
$_SESSION['msp_id'] = $msp_id;
|
||||
$_SESSION['role'] = 'msp_admin';
|
||||
$_SESSION['user_name'] = $user_name;
|
||||
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
db()->rollBack();
|
||||
if ($e->getCode() == 23000) {
|
||||
$error = 'Email already registered.';
|
||||
} else {
|
||||
$error = 'Error during registration: ' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
include 'header.php';
|
||||
?>
|
||||
|
||||
<div class="container py-5 mt-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-7">
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-body p-5">
|
||||
<div class="text-center mb-4">
|
||||
<h2 class="fw-bold text-primary">MSP Registration</h2>
|
||||
<p class="text-muted">Start managing your customer onboarding today.</p>
|
||||
</div>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="alert alert-danger mb-4"><?php echo $error; ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="POST" action="">
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="msp_name" class="form-label">MSP Name</label>
|
||||
<input type="text" name="msp_name" id="msp_name" class="form-control py-2" placeholder="e.g. Acme Managed Services" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="plan_id" class="form-label">Select Plan</label>
|
||||
<select name="plan_id" id="plan_id" class="form-select py-2" required>
|
||||
<?php foreach ($plans as $plan): ?>
|
||||
<option value="<?php echo $plan['id']; ?>">
|
||||
<?php echo $plan['name']; ?> - <?php echo $plan['price'] > 0 ? '$'.$plan['price'].'/mo' : 'Free Trial'; ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr class="my-4">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="user_name" class="form-label">Full Name</label>
|
||||
<input type="text" name="user_name" id="user_name" class="form-control py-2" placeholder="Admin Name" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="email" class="form-label">Email Address</label>
|
||||
<input type="email" name="email" id="email" class="form-control py-2" placeholder="admin@domain.com" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="password" class="form-label">Password</label>
|
||||
<input type="password" name="password" id="password" class="form-control py-2" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="confirm_password" class="form-label">Confirm Password</label>
|
||||
<input type="password" name="confirm_password" id="confirm_password" class="form-control py-2" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-grid gap-2 mt-4">
|
||||
<button type="submit" class="btn btn-primary py-2 fw-bold">Create Account</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="text-center mt-4">
|
||||
<p class="mb-0 text-muted small">Already have an account? <a href="login.php" class="text-primary fw-bold text-decoration-none">Sign In</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'footer.php'; ?>
|
||||
77
superadmin_dashboard.php
Normal file
77
superadmin_dashboard.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'superadmin') {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once 'db/config.php';
|
||||
|
||||
// Stats for Superadmin
|
||||
$total_msps = db()->query("SELECT COUNT(*) FROM msps")->fetchColumn();
|
||||
$total_customers = db()->query("SELECT COUNT(*) FROM customers")->fetchColumn();
|
||||
$total_users = db()->query("SELECT COUNT(*) FROM users")->fetchColumn();
|
||||
|
||||
// Recent MSPs
|
||||
$stmt = db()->query("SELECT m.*, p.name as plan_name FROM msps m JOIN plans p ON m.plan_id = p.id ORDER BY m.created_at DESC LIMIT 5");
|
||||
$recent_msps = $stmt->fetchAll();
|
||||
|
||||
include 'header.php';
|
||||
?>
|
||||
|
||||
<div class="container py-5">
|
||||
<div class="header-section">
|
||||
<h1>Superadmin Dashboard</h1>
|
||||
<p class="text-muted">Overview of all MSPs and system health.</p>
|
||||
</div>
|
||||
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card">
|
||||
<div class="stat-value"><?php echo $total_msps; ?></div>
|
||||
<div class="stat-label">Total MSPs</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value"><?php echo $total_customers; ?></div>
|
||||
<div class="stat-label">Total Customers</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value"><?php echo $total_users; ?></div>
|
||||
<div class="stat-label">Total Users</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mt-5 shadow-sm border-0">
|
||||
<div class="card-body p-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h3 class="fw-bold mb-0">Recent MSP Registrations</h3>
|
||||
<a href="manage_msps.php" class="btn btn-outline btn-sm">Manage All MSPs</a>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>MSP Name</th>
|
||||
<th>Plan</th>
|
||||
<th>Subdomain</th>
|
||||
<th>Created At</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($recent_msps as $msp): ?>
|
||||
<tr>
|
||||
<td class="fw-bold text-primary"><?php echo htmlspecialchars($msp['name']); ?></td>
|
||||
<td><span class="badge bg-info text-dark"><?php echo htmlspecialchars($msp['plan_name']); ?></span></td>
|
||||
<td><?php echo $msp['subdomain'] ? htmlspecialchars($msp['subdomain']) . '.mspconnect.com' : 'N/A'; ?></td>
|
||||
<td class="text-muted"><?php echo date('Y-m-d', strtotime($msp['created_at'])); ?></td>
|
||||
<td>
|
||||
<a href="manage_msps.php?id=<?php echo $msp['id']; ?>" class="btn btn-outline btn-sm"><i class="bi bi-gear"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'footer.php'; ?>
|
||||
107
templates.php
Normal file
107
templates.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id']) || !isset($_SESSION['msp_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once 'db/config.php';
|
||||
|
||||
$msp_id = $_SESSION['msp_id'];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
|
||||
if ($_POST['action'] === 'create_template') {
|
||||
$name = $_POST['name'];
|
||||
$description = $_POST['description'];
|
||||
$stmt = db()->prepare("INSERT INTO onboarding_templates (msp_id, name, description) VALUES (?, ?, ?)");
|
||||
$stmt->execute([$msp_id, $name, $description]);
|
||||
$template_id = db()->lastInsertId();
|
||||
header("Location: edit_template.php?id=$template_id");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$stmt = db()->prepare("SELECT * FROM onboarding_templates WHERE msp_id = ? ORDER BY created_at DESC");
|
||||
$stmt->execute([$msp_id]);
|
||||
$templates = $stmt->fetchAll();
|
||||
|
||||
include 'header.php';
|
||||
?>
|
||||
|
||||
<div class="container py-5">
|
||||
<div class="d-flex justify-content-between align-items-center mb-5">
|
||||
<div>
|
||||
<h1>Onboarding Templates</h1>
|
||||
<p class="text-muted">Create multi-page onboarding flows for your customers.</p>
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#createTemplateModal">
|
||||
<i class="bi bi-plus-circle"></i> Create New Template
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="row g-4">
|
||||
<?php foreach ($templates as $template): ?>
|
||||
<div class="col-md-4">
|
||||
<div class="card h-100 shadow-sm border-0 template-card">
|
||||
<div class="card-body p-4">
|
||||
<h4 class="fw-bold text-primary mb-2"><?php echo htmlspecialchars($template['name']); ?></h4>
|
||||
<p class="text-muted small mb-4"><?php echo htmlspecialchars($template['description'] ?: 'No description provided.'); ?></p>
|
||||
|
||||
<?php
|
||||
$stmt = db()->prepare("SELECT COUNT(*) FROM onboarding_template_steps WHERE template_id = ?");
|
||||
$stmt->execute([$template['id']]);
|
||||
$steps_count = $stmt->fetchColumn();
|
||||
?>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mt-auto">
|
||||
<span class="badge bg-light text-dark border"><i class="bi bi-layers"></i> <?php echo $steps_count; ?> Steps</span>
|
||||
<a href="edit_template.php?id=<?php echo $template['id']; ?>" class="btn btn-outline btn-sm">Manage Template</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if (empty($templates)): ?>
|
||||
<div class="col-12 text-center py-5">
|
||||
<div class="bg-light p-5 rounded-4 border">
|
||||
<i class="bi bi-file-earmark-plus display-4 text-muted mb-3"></i>
|
||||
<h3>No Templates Found</h3>
|
||||
<p class="text-muted">You haven't created any onboarding templates yet. Click the button above to start.</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Create Template Modal -->
|
||||
<div class="modal fade" id="createTemplateModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form method="POST">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">New Onboarding Template</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" name="action" value="create_template">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Template Name</label>
|
||||
<input type="text" name="name" class="form-control" placeholder="e.g. Standard Customer Onboarding" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Description (Optional)</label>
|
||||
<textarea name="description" class="form-control" rows="3" placeholder="Briefly describe what this template covers."></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Create & Continue</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<?php include 'footer.php'; ?>
|
||||
Loading…
x
Reference in New Issue
Block a user