138 lines
6.2 KiB
PHP
138 lines
6.2 KiB
PHP
<?php
|
|
require_once __DIR__ . '/header.php';
|
|
|
|
// Fetch some stats
|
|
$stats = [
|
|
'total_customers' => 0,
|
|
'active_onboarding' => 0,
|
|
'qbrs_scheduled' => 4,
|
|
'open_tickets' => 12
|
|
];
|
|
|
|
try {
|
|
$stmt = db()->query("SELECT COUNT(*) FROM customers");
|
|
$stats['total_customers'] = $stmt->fetchColumn();
|
|
|
|
$stmt = db()->query("SELECT COUNT(*) FROM customers WHERE status = 'onboarding'");
|
|
$stats['active_onboarding'] = $stmt->fetchColumn();
|
|
} catch (PDOException $e) {
|
|
// Handle error gracefully
|
|
}
|
|
|
|
// Fetch recent customers
|
|
$recent_customers = [];
|
|
try {
|
|
$stmt = db()->query("SELECT * FROM customers ORDER BY created_at DESC LIMIT 5");
|
|
$recent_customers = $stmt->fetchAll();
|
|
} catch (PDOException $e) {
|
|
// Handle error
|
|
}
|
|
?>
|
|
|
|
<div class="container">
|
|
<div style="margin-bottom: 2rem;">
|
|
<h2 style="font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem;">MSP Operations Dashboard</h2>
|
|
<p style="color: var(--text-muted); font-size: 0.875rem;">Welcome back, Admin. Here's what's happening today.</p>
|
|
</div>
|
|
|
|
<div class="stats-grid">
|
|
<div class="stat-card">
|
|
<div class="stat-label">Total Customers</div>
|
|
<div class="stat-value"><?php echo (int)$stats['total_customers']; ?></div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-label">Active Onboarding</div>
|
|
<div class="stat-value" style="color: var(--primary);"><?php echo (int)$stats['active_onboarding']; ?></div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-label">QBRs This Quarter</div>
|
|
<div class="stat-value"><?php echo (int)$stats['qbrs_scheduled']; ?></div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-label">Open Support Tickets</div>
|
|
<div class="stat-value" style="color: var(--danger);"><?php echo (int)$stats['open_tickets']; ?></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-title">
|
|
<span>Recent Customers</span>
|
|
<a href="customers.php" class="btn btn-outline">View All</a>
|
|
</div>
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>Customer Name</th>
|
|
<th>Email Address</th>
|
|
<th>Status</th>
|
|
<th>Added On</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($recent_customers)): ?>
|
|
<tr>
|
|
<td colspan="5" style="text-align: center; color: var(--text-muted); padding: 2rem;">
|
|
<i class="bi bi-inbox" style="font-size: 2rem; display: block; margin-bottom: 1rem;"></i>
|
|
No customers added yet. <a href="add_customer.php" style="color: var(--primary);">Add your first customer.</a>
|
|
</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($recent_customers as $customer): ?>
|
|
<tr>
|
|
<td style="font-weight: 600;"><?php echo htmlspecialchars($customer['name']); ?></td>
|
|
<td><?php echo htmlspecialchars($customer['contact_email'] ?? 'N/A'); ?></td>
|
|
<td><span class="badge badge-<?php echo $customer['status']; ?>"><?php echo $customer['status']; ?></span></td>
|
|
<td><?php echo date('M d, Y', strtotime($customer['created_at'])); ?></td>
|
|
<td>
|
|
<?php if ($customer['status'] == 'onboarding'): ?>
|
|
<a href="onboarding.php?id=<?php echo $customer['id']; ?>" class="btn btn-outline" style="padding: 0.25rem 0.5rem;">
|
|
Onboarding
|
|
</a>
|
|
<?php else: ?>
|
|
<a href="#" class="btn btn-outline" style="padding: 0.25rem 0.5rem;">Details</a>
|
|
<?php endif; ?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem;">
|
|
<div class="card">
|
|
<div class="card-title">Quick Actions</div>
|
|
<div style="display: flex; flex-direction: column; gap: 0.75rem;">
|
|
<a href="add_customer.php" class="btn btn-primary" style="justify-content: flex-start;">
|
|
<i class="bi bi-person-plus" style="margin-right: 0.75rem;"></i> Onboard New Customer
|
|
</a>
|
|
<button class="btn btn-outline" style="justify-content: flex-start;">
|
|
<i class="bi bi-calendar-event" style="margin-right: 0.75rem;"></i> Schedule QBR Meeting
|
|
</button>
|
|
<button class="btn btn-outline" style="justify-content: flex-start;">
|
|
<i class="bi bi-ticket-perforated" style="margin-right: 0.75rem;"></i> Create Internal Ticket
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="card">
|
|
<div class="card-title">Integration Status</div>
|
|
<div style="display: flex; flex-direction: column; gap: 0.75rem;">
|
|
<div style="display: flex; justify-content: space-between; align-items: center; font-size: 0.875rem;">
|
|
<span>ConnectWise PSA</span>
|
|
<span style="color: var(--success);"><i class="bi bi-check-circle-fill"></i> Connected</span>
|
|
</div>
|
|
<div style="display: flex; justify-content: space-between; align-items: center; font-size: 0.875rem;">
|
|
<span>Microsoft 365</span>
|
|
<span style="color: var(--success);"><i class="bi bi-check-circle-fill"></i> Connected</span>
|
|
</div>
|
|
<div style="display: flex; justify-content: space-between; align-items: center; font-size: 0.875rem;">
|
|
<span>Datto RMM</span>
|
|
<span style="color: var(--warning);"><i class="bi bi-exclamation-triangle"></i> Configure</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php require_once __DIR__ . '/footer.php'; ?>
|