180 lines
8.6 KiB
PHP
180 lines
8.6 KiB
PHP
<?php
|
|
require_once 'db/config.php';
|
|
|
|
$pdo = db();
|
|
$message = null;
|
|
$message_type = '';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$name = trim($_POST['name'] ?? '');
|
|
$email = trim($_POST['email'] ?? '');
|
|
$phone = trim($_POST['phone'] ?? '');
|
|
$entity_name = trim($_POST['entity_name'] ?? '');
|
|
$accreditation_status = $_POST['accreditation_status'] ?? 'Pending';
|
|
|
|
if (empty($name) || empty($email)) {
|
|
$message = 'Name and Email are required.';
|
|
$message_type = 'danger';
|
|
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
$message = 'Invalid email format.';
|
|
$message_type = 'danger';
|
|
} else {
|
|
try {
|
|
$stmt = $pdo->prepare("INSERT INTO investors (name, email, phone, entity_name, accreditation_status) VALUES (?, ?, ?, ?, ?)");
|
|
$stmt->execute([$name, $email, $phone, $entity_name, $accreditation_status]);
|
|
$message = 'Investor added successfully!';
|
|
$message_type = 'success';
|
|
} catch (PDOException $e) {
|
|
if ($e->getCode() == 23000) { // Integrity constraint violation (duplicate email)
|
|
$message = 'An investor with this email already exists.';
|
|
$message_type = 'danger';
|
|
} else {
|
|
$message = 'Error adding investor: ' . $e->getMessage();
|
|
$message_type = 'danger';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$investors = $pdo->query("SELECT * FROM investors ORDER BY created_at DESC")->fetchAll();
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Investor Tracking</title>
|
|
<meta name="description" content="Built with Flatlogic Generator">
|
|
<meta name="keywords" content="investor crm, private lending, capital management, investor relations, financial dashboard, investment tracking, Built with Flatlogic Generator">
|
|
<meta property="og:title" content="Investor Tracking">
|
|
<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/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
|
<link rel="stylesheet" href="assets/css/custom.css">
|
|
</head>
|
|
<body>
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-dark">
|
|
<div class="container-fluid">
|
|
<a class="navbar-brand" href="index.php"><i class="bi bi-cash-coin accent-gold"></i> Investor CRM</a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarNav">
|
|
<ul class="navbar-nav">
|
|
<li class="nav-item">
|
|
<a class="nav-link active" href="investors.php">Investors</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="container mt-4">
|
|
<div class="row">
|
|
<div class="col-lg-4 mb-4">
|
|
<div class="card shadow-sm">
|
|
<div class="card-body">
|
|
<h5 class="card-title"><i class="bi bi-person-plus-fill"></i> Add New Investor</h5>
|
|
<hr>
|
|
<form action="investors.php" method="POST">
|
|
<div class="mb-3">
|
|
<label for="name" class="form-label">Full Name</label>
|
|
<input type="text" class="form-control" id="name" name="name" required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="email" class="form-label">Email Address</label>
|
|
<input type="email" class="form-control" id="email" name="email" required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="phone" class="form-label">Phone Number</label>
|
|
<input type="tel" class="form-control" id="phone" name="phone">
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="entity_name" class="form-label">Entity Name</label>
|
|
<input type="text" class="form-control" id="entity_name" name="entity_name">
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="accreditation_status" class="form-label">Accreditation</label>
|
|
<select class="form-select" id="accreditation_status" name="accreditation_status">
|
|
<option>Pending</option>
|
|
<option>Accredited</option>
|
|
<option>Non-Accredited</option>
|
|
</select>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary w-100">Add Investor</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-8">
|
|
<div class="card shadow-sm">
|
|
<div class="card-body">
|
|
<h5 class="card-title"><i class="bi bi-people-fill"></i> Investor List</h5>
|
|
<hr>
|
|
<div class="table-responsive">
|
|
<table class="table table-hover">
|
|
<thead class="thead-dark">
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Email</th>
|
|
<th>Phone</th>
|
|
<th>Entity</th>
|
|
<th>Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($investors)): ?>
|
|
<tr>
|
|
<td colspan="5" class="text-center">No investors found.</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($investors as $investor): ?>
|
|
<tr>
|
|
<td><?= htmlspecialchars($investor['name']) ?></td>
|
|
<td><?= htmlspecialchars($investor['email']) ?></td>
|
|
<td><?= htmlspecialchars($investor['phone']) ?></td>
|
|
<td><?= htmlspecialchars($investor['entity_name']) ?></td>
|
|
<td><span class="badge bg-secondary"><?= htmlspecialchars($investor['accreditation_status']) ?></span></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if ($message): ?>
|
|
<div class="toast-container">
|
|
<div id="notificationToast" class="toast align-items-center text-white bg-<?= $message_type ?> border-0" role="alert" aria-live="assertive" aria-atomic="true">
|
|
<div class="d-flex">
|
|
<div class="toast-body">
|
|
<?= htmlspecialchars($message) ?>
|
|
</div>
|
|
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
var toastEl = document.getElementById('notificationToast');
|
|
if (toastEl) {
|
|
var toast = new bootstrap.Toast(toastEl);
|
|
toast.show();
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|