175 lines
11 KiB
PHP
175 lines
11 KiB
PHP
<?php
|
|
require_once __DIR__ . '/auth.php';
|
|
require_once __DIR__ . '/db/config.php';
|
|
|
|
// Sample data for leads
|
|
$sample_leads = [
|
|
['id' => 1, 'name' => 'Alice Johnson', 'company' => 'Innovate Corp', 'status' => 'New', 'value' => 5000, 'tag' => 'prospect'],
|
|
['id' => 2, 'name' => 'Bob Williams', 'company' => 'Solutions Inc.', 'status' => 'New', 'value' => 3000, 'tag' => 'prospect'],
|
|
['id' => 3, 'name' => 'Charlie Brown', 'company' => 'Data Systems', 'status' => 'Contacted', 'value' => 7500, 'tag' => 'deal'],
|
|
['id' => 4, 'name' => 'Diana Miller', 'company' => 'Creative Minds', 'status' => 'Qualified', 'value' => 12000, 'tag' => 'deal'],
|
|
['id' => 5, 'name' => 'Ethan Davis', 'company' => 'Tech Forward', 'status' => 'New', 'value' => 2500, 'tag' => 'prospect'],
|
|
['id' => 6, 'name' => 'Fiona Garcia', 'company' => 'Global Connect', 'status' => 'Contacted', 'value' => 6000, 'tag' => 'deal'],
|
|
];
|
|
|
|
$pdo = db();
|
|
|
|
// Check if leads table is empty
|
|
$stmt = $pdo->query("SELECT COUNT(*) FROM leads");
|
|
$lead_count = $stmt->fetchColumn();
|
|
|
|
if ($lead_count == 0) {
|
|
$stmt = $pdo->prepare("INSERT INTO leads (name, company, status, value, tag) VALUES (?, ?, ?, ?, ?)");
|
|
foreach ($sample_leads as $lead) {
|
|
$stmt->execute([$lead['name'], $lead['company'], $lead['status'], $lead['value'], $lead['tag']]);
|
|
}
|
|
}
|
|
|
|
$stmt = $pdo->query("SELECT * FROM leads");
|
|
$leads = $stmt->fetchAll();
|
|
|
|
$columns = ['New', 'Contacted', 'Qualified', 'Closed'];
|
|
|
|
function getLeadsByStatus($leads, $status) {
|
|
$filtered_leads = [];
|
|
foreach ($leads as $lead) {
|
|
if ($lead['status'] === $status) {
|
|
$filtered_leads[] = $lead;
|
|
}
|
|
}
|
|
return $filtered_leads;
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Lead Dashboard</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
<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">
|
|
</head>
|
|
<body>
|
|
|
|
<div class="main-container">
|
|
<aside class="sidebar">
|
|
<div class="logo">SaaSApp</div>
|
|
<nav class="nav flex-column">
|
|
<a class="nav-link active" href="index.php">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z" /></svg>
|
|
Dashboard
|
|
</a>
|
|
<a class="nav-link" href="leads.php">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z" /></svg>
|
|
Leads
|
|
</a>
|
|
<a class="nav-link" href="calendar.php">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>
|
|
Calendar
|
|
</a>
|
|
<?php if (is_admin()): ?>
|
|
<a class="nav-link" href="users.php">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M15 21a6 6 0 00-9-5.197m0 0A5.975 5.975 0 0112 13a5.975 5.975 0 013-1.197M15 21a9 9 0 00-9-9m9 9a9 9 0 00-9-9" /></svg>
|
|
Users
|
|
</a>
|
|
<a class="nav-link" href="settings.php">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.096 2.572-1.065z" /><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" /></svg>
|
|
Settings
|
|
</a>
|
|
<?php endif; ?>
|
|
<a class="nav-link" href="logout.php">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1" /></svg>
|
|
Logout
|
|
</a>
|
|
</nav>
|
|
</aside>
|
|
|
|
<main class="main-content">
|
|
<header class="header">
|
|
<h1>Leads Dashboard</h1>
|
|
</header>
|
|
|
|
<div class="kanban-board">
|
|
<?php foreach ($columns as $column): ?>
|
|
<div class="kanban-column">
|
|
<?php $column_leads = getLeadsByStatus($leads, $column); ?>
|
|
<h2>
|
|
<?php echo htmlspecialchars($column); ?>
|
|
<span class="count"><?php echo count($column_leads); ?></span>
|
|
</h2>
|
|
<div class="kanban-cards" data-status="<?php echo htmlspecialchars($column); ?>">
|
|
<?php foreach ($column_leads as $lead): ?>
|
|
<div class="kanban-card" draggable="true" data-id="<?php echo $lead['id']; ?>" data-name="<?php echo htmlspecialchars($lead['name']); ?>" data-company="<?php echo htmlspecialchars($lead['company']); ?>" data-value="<?php echo number_format($lead['value']); ?>" data-status="<?php echo htmlspecialchars($lead['status']); ?>">
|
|
<div class="card-title"><?php echo htmlspecialchars($lead['name']); ?></div>
|
|
<div class="card-subtitle"><?php echo htmlspecialchars($lead['company']); ?></div>
|
|
<div class="card-footer">
|
|
<span>$<?php echo number_format($lead['value']); ?></span>
|
|
<span class="tag <?php echo $lead['tag'] === 'deal' ? 'tag-deal' : 'tag-prospect'; ?>">
|
|
<?php echo htmlspecialchars($lead['tag']); ?>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
|
|
<div class="modal fade" id="leadModal" tabindex="-1" aria-labelledby="leadModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-lg">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="leadModalLabel">Lead Details</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<ul class="nav nav-tabs" id="leadTab" role="tablist">
|
|
<li class="nav-item" role="presentation">
|
|
<button class="nav-link active" id="details-tab" data-bs-toggle="tab" data-bs-target="#details" type="button" role="tab" aria-controls="details" aria-selected="true">Details</button>
|
|
</li>
|
|
<li class="nav-item" role="presentation">
|
|
<button class="nav-link" id="chat-tab" data-bs-toggle="tab" data-bs-target="#chat" type="button" role="tab" aria-controls="chat" aria-selected="false">Chat</button>
|
|
</li>
|
|
</ul>
|
|
<div class="tab-content" id="leadTabContent">
|
|
<div class="tab-pane fade show active" id="details" role="tabpanel" aria-labelledby="details-tab">
|
|
<div class="p-3">
|
|
<h5 id="leadName"></h5>
|
|
<p id="leadCompany"></p>
|
|
<p><strong>Value:</strong> <span id="leadValue"></span></p>
|
|
<p><strong>Status:</strong> <span id="leadStatus"></span></p>
|
|
</div>
|
|
</div>
|
|
<div class="tab-pane fade" id="chat" role="tabpanel" aria-labelledby="chat-tab">
|
|
<div class="chat-container p-3">
|
|
<div class="chat-messages">
|
|
<div class="message received">
|
|
<p>Hello! I'm interested in your services.</p>
|
|
<span class="timestamp">10:00 AM</span>
|
|
</div>
|
|
<div class="message sent">
|
|
<p>Hi there! How can I help you?</p>
|
|
<span class="timestamp">10:01 AM</span>
|
|
</div>
|
|
</div>
|
|
<div class="chat-input">
|
|
<input type="text" class="form-control" placeholder="Type a message...">
|
|
<button class="btn btn-primary">Send</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
|
</body>
|
|
</html>
|