34972-vm/contacts.php
Flatlogic Bot abcecf5b5a mak1
2025-10-15 14:43:05 +00:00

112 lines
5.0 KiB
PHP

<?php
require_once 'db/config.php';
// Check if there are any contacts
$stmt = db()->query('SELECT COUNT(*) FROM contacts');
$count = $stmt->fetchColumn();
// If no contacts, add some sample data
if ($count == 0) {
db()->exec("""
INSERT INTO contacts (name, email) VALUES
('John Doe', 'john.doe@example.com'),
('Jane Smith', 'jane.smith@example.com'),
('Peter Jones', 'peter.jones@example.com');
""");
}
// Fetch all contacts
$stmt = db()->query('SELECT * FROM contacts ORDER BY created_at DESC');
$contacts = $stmt->fetchAll();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contacts - Makizto</title>
<meta name="description" content="Built with Flatlogic Generator">
<meta name="keywords" content="crm, sales, contacts, deals, back office, business management, lead tracking, pipeline management, customer relationship management, flatlogic">
<meta property="og:title" content="Contacts - Makizto">
<meta property="og:description" content="Built with Flatlogic Generator">
<meta property="og:image" content="">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.css">
<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;700&display=swap" rel="stylesheet">
</head>
<body>
<div class="sidebar">
<h3>Makizto</h3>
<nav class="nav flex-column">
<a class="nav-link" href="index.php"><i data-feather="home" class="me-2"></i>Dashboard</a>
<a class="nav-link active" href="contacts.php"><i data-feather="users" class="me-2"></i>Contacts</a>
<a class="nav-link" href="deals.php"><i data-feather="dollar-sign" class="me-2"></i>Deals</a>
</nav>
</div>
<div class="main-content">
<div class="container-fluid">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1 class="h2">Contacts</h1>
<a href="contact_form.php" class="btn btn-primary">
<i data-feather="plus" class="me-2"></i>Add Contact
</a>
</div>
<div class="card">
<div class="card-body">
<table class="table table-hover">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Created At</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php if (empty($contacts)):
?>
<tr>
<td colspan="4" class="text-center">No contacts found.</td>
</tr>
<?php else: ?>
<?php foreach ($contacts as $contact): ?>
<tr>
<td><?= htmlspecialchars($contact['name']) ?></td>
<td><?= htmlspecialchars($contact['email']) ?></td>
<td><?= date('M d, Y', strtotime($contact['created_at'])) ?></td>
<td>
<a href="contact_form.php?id=<?= $contact['id'] ?>" class="btn btn-sm btn-outline-primary">
<i data-feather="edit-2" class="me-1"></i> Edit
</a>
<a href="delete_contact.php?id=<?= $contact['id'] ?>" class="btn btn-sm btn-outline-danger" onclick="return confirm('Are you sure you want to delete this contact?');">
<i data-feather="trash-2" class="me-1"></i> Delete
</a>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script>
feather.replace()
</script>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>