107 lines
4.5 KiB
PHP
107 lines
4.5 KiB
PHP
<?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'; ?>
|