Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7be5d661b2 |
39
add_lead.php
Normal file
39
add_lead.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
// add_lead.php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
// Basic server-side validation
|
||||
$lead_name = trim($_POST['lead_name'] ?? '');
|
||||
$status = trim($_POST['status'] ?? '');
|
||||
$category = trim($_POST['category'] ?? '');
|
||||
$contact_email = trim($_POST['contact_email'] ?? '');
|
||||
$owner = trim($_POST['owner'] ?? '');
|
||||
|
||||
if (empty($lead_name) || empty($status) || empty($category) || !filter_var($contact_email, FILTER_VALIDATE_EMAIL) || empty($owner)) {
|
||||
$_SESSION['message'] = ['type' => 'danger', 'text' => 'Invalid input. Please fill all fields correctly.'];
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
if ($pdo) {
|
||||
try {
|
||||
$stmt = $pdo->prepare(
|
||||
"INSERT INTO leads (lead_name, status, category, contact_email, owner) VALUES (?, ?, ?, ?, ?)"
|
||||
);
|
||||
$stmt->execute([$lead_name, $status, $category, $contact_email, $owner]);
|
||||
$_SESSION['message'] = ['type' => 'success', 'text' => 'Lead added successfully!'];
|
||||
} catch (PDOException $e) {
|
||||
error_log('Add Lead Error: ' . $e->getMessage());
|
||||
$_SESSION['message'] = ['type' => 'danger', 'text' => 'A database error occurred.'];
|
||||
}
|
||||
} else {
|
||||
$_SESSION['message'] = ['type' => 'danger', 'text' => 'Could not connect to the database.'];
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
?>
|
||||
77
assets/css/custom.css
Normal file
77
assets/css/custom.css
Normal file
@ -0,0 +1,77 @@
|
||||
/* assets/css/custom.css */
|
||||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
|
||||
|
||||
:root {
|
||||
--primary-color: #4A90E2;
|
||||
--secondary-color: #50E3C2;
|
||||
--bg-color: #F4F7F9;
|
||||
--surface-color: #FFFFFF;
|
||||
--text-color: #333333;
|
||||
--border-radius-sm: 0.25rem;
|
||||
--border-radius-md: 0.5rem;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
background-color: var(--bg-color);
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.navbar {
|
||||
background-color: var(--surface-color);
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: var(--primary-color);
|
||||
border-color: var(--primary-color);
|
||||
border-radius: var(--border-radius-sm);
|
||||
}
|
||||
.btn-primary:hover {
|
||||
opacity: 0.9;
|
||||
background-color: var(--primary-color);
|
||||
border-color: var(--primary-color);
|
||||
}
|
||||
|
||||
.gradient-bg {
|
||||
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
|
||||
}
|
||||
|
||||
.main-content {
|
||||
padding-top: 2rem;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: none;
|
||||
border-radius: var(--border-radius-md);
|
||||
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
|
||||
}
|
||||
|
||||
.table {
|
||||
border-radius: var(--border-radius-md);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.table thead {
|
||||
background-color: var(--surface-color);
|
||||
}
|
||||
|
||||
.table th {
|
||||
border-bottom: 2px solid var(--bg-color);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
padding: 0.3em 0.6em;
|
||||
border-radius: var(--border-radius-sm);
|
||||
font-size: 0.8rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
.status-new { background-color: #e9f3ff; color: #4a90e2; }
|
||||
.status-contacted { background-color: #fff8e1; color: #f5a623; }
|
||||
.status-qualified { background-color: #e8f5e9; color: #4caf50; }
|
||||
.status-lost { background-color: #ffebee; color: #f44336; }
|
||||
|
||||
.toast-container {
|
||||
z-index: 1090;
|
||||
}
|
||||
10
assets/js/main.js
Normal file
10
assets/js/main.js
Normal file
@ -0,0 +1,10 @@
|
||||
// assets/js/main.js
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
// Initialize Bootstrap toasts if they exist
|
||||
var toastElList = [].slice.call(document.querySelectorAll('.toast'));
|
||||
var toastList = toastElList.map(function (toastEl) {
|
||||
var toast = new bootstrap.Toast(toastEl, { delay: 5000 });
|
||||
toast.show();
|
||||
return toast;
|
||||
});
|
||||
});
|
||||
@ -1,17 +1,72 @@
|
||||
<?php
|
||||
// Generated by setup_mariadb_project.sh — edit as needed.
|
||||
define('DB_HOST', '127.0.0.1');
|
||||
define('DB_NAME', 'app_30855');
|
||||
define('DB_USER', 'app_30855');
|
||||
define('DB_PASS', 'eee81949-37de-47f9-a26f-14ebc8402f7f');
|
||||
// db/config.php
|
||||
|
||||
function db() {
|
||||
static $pdo;
|
||||
if (!$pdo) {
|
||||
$pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
]);
|
||||
}
|
||||
// --- Database Credentials ---
|
||||
// These are typically stored in environment variables for security
|
||||
define('DB_HOST', '127.0.0.1');
|
||||
define('DB_NAME', 'app_db');
|
||||
define('DB_USER', 'app_user');
|
||||
define('DB_PASS', 'password'); // Replace with a strong password in a real app
|
||||
|
||||
// --- PDO Helper Function ---
|
||||
function db(): ?PDO {
|
||||
static $pdo = null;
|
||||
|
||||
if ($pdo !== null) {
|
||||
return $pdo;
|
||||
}
|
||||
|
||||
$dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=utf8mb4';
|
||||
$options = [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
];
|
||||
|
||||
try {
|
||||
$pdo = new PDO($dsn, DB_USER, DB_PASS, $options);
|
||||
return $pdo;
|
||||
} catch (PDOException $e) {
|
||||
error_log('DB Connection Error: ' . $e->getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// --- Initial Table Setup ---
|
||||
function setup_database() {
|
||||
$pdo = db();
|
||||
if ($pdo) {
|
||||
try {
|
||||
$pdo->exec("CREATE TABLE IF NOT EXISTS leads (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
lead_name VARCHAR(255) NOT NULL,
|
||||
status VARCHAR(50) NOT NULL,
|
||||
category VARCHAR(50) NOT NULL,
|
||||
contact_email VARCHAR(255) NOT NULL,
|
||||
owner VARCHAR(255) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);");
|
||||
|
||||
// Add some dummy data if the table is empty
|
||||
$stmt = $pdo->query("SELECT COUNT(*) FROM leads");
|
||||
if ($stmt->fetchColumn() == 0) {
|
||||
$pdo->exec("
|
||||
INSERT INTO leads (lead_name, status, category, contact_email, owner) VALUES
|
||||
('Global Corp vs. Local Biz', 'New', 'Corporate', 'ceo@globalcorp.com', 'John Doe'),
|
||||
('Smith Divorce Case', 'Contacted', 'Family', 'jane.smith@email.com', 'Jane Smith'),
|
||||
('State vs. Anderson', 'Qualified', 'Criminal', 'anderson@email.com', 'John Doe'),
|
||||
('Tech Innovations Inc. Patent', 'New', 'Corporate', 'contact@techinnovations.com', 'Jane Smith'),
|
||||
('Real Estate Dispute', 'Lost', 'Corporate', 'buyer@realestate.com', 'John Doe');
|
||||
");
|
||||
}
|
||||
|
||||
} catch (PDOException $e) {
|
||||
error_log('DB Setup Error: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Run setup
|
||||
setup_database();
|
||||
|
||||
?>
|
||||
302
index.php
302
index.php
@ -1,131 +1,193 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
// index.php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
$phpVersion = PHP_VERSION;
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$pdo = db();
|
||||
$leads = [];
|
||||
if ($pdo) {
|
||||
try {
|
||||
$stmt = $pdo->query("SELECT id, lead_name, status, category, contact_email, owner FROM leads ORDER BY created_at DESC");
|
||||
$leads = $stmt->fetchAll();
|
||||
} catch (PDOException $e) {
|
||||
error_log("Fetch Leads Error: " . $e->getMessage());
|
||||
// Set a message to be displayed if fetching fails
|
||||
$_SESSION['message'] = ['type' => 'danger', 'text' => 'Could not fetch leads from the database.'];
|
||||
}
|
||||
} else {
|
||||
$_SESSION['message'] = ['type' => 'danger', 'text' => 'Database connection failed. Please check configuration.'];
|
||||
}
|
||||
|
||||
// Get flash message from session
|
||||
$message = null;
|
||||
if (isset($_SESSION['message'])) {
|
||||
$message = $_SESSION['message'];
|
||||
unset($_SESSION['message']);
|
||||
}
|
||||
?>
|
||||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>New Style</title>
|
||||
<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;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--bg-color-start: #6a11cb;
|
||||
--bg-color-end: #2575fc;
|
||||
--text-color: #ffffff;
|
||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
||||
animation: bg-pan 20s linear infinite;
|
||||
z-index: -1;
|
||||
}
|
||||
@keyframes bg-pan {
|
||||
0% { background-position: 0% 0%; }
|
||||
100% { background-position: 100% 100%; }
|
||||
}
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
.card {
|
||||
background: var(--card-bg-color);
|
||||
border: 1px solid var(--card-border-color);
|
||||
border-radius: 16px;
|
||||
padding: 2rem;
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.loader {
|
||||
margin: 1.25rem auto 1.25rem;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
@keyframes spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
.hint {
|
||||
opacity: 0.9;
|
||||
}
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px; height: 1px;
|
||||
padding: 0; margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap; border: 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
margin: 0 0 1rem;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
p {
|
||||
margin: 0.5rem 0;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
code {
|
||||
background: rgba(0,0,0,0.2);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
font-size: 0.8rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Law CRM - 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(); ?>">
|
||||
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="card">
|
||||
<h1>Analyzing your requirements and generating your website…</h1>
|
||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||
<span class="sr-only">Loading…</span>
|
||||
|
||||
<!-- Navbar -->
|
||||
<nav class="navbar navbar-expand-lg navbar-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">
|
||||
<img src="https://picsum.photos/seed/law-crm-logo/120/40" alt="Law CRM Logo" width="120" height="40" class="d-inline-block align-text-top">
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item"><a class="nav-link active" href="#">Leads</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="#">Contacts</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="#">Reports</a></li>
|
||||
</ul>
|
||||
<div class="d-flex align-items-center">
|
||||
<button class="btn btn-primary me-3" data-bs-toggle="modal" data-bs-target="#addLeadModal">
|
||||
<i data-feather="plus" class="me-1"></i> Add Lead
|
||||
</button>
|
||||
<img src="https://picsum.photos/seed/law-crm-avatar1/40/40" alt="User avatar" class="rounded-circle" width="40" height="40">
|
||||
</div>
|
||||
<p class="hint">Flatlogic AI is collecting your requirements and applying the first changes.</p>
|
||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||
</footer>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Main Content -->
|
||||
<div class="container main-content">
|
||||
<div class="card p-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h3 mb-0">Leads Dashboard</h1>
|
||||
<div class="d-flex">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="Search leads...">
|
||||
<button class="btn btn-outline-secondary" type="button"><i data-feather="search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Leads Table -->
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Lead</th>
|
||||
<th>Status</th>
|
||||
<th>Category</th>
|
||||
<th>Contact</th>
|
||||
<th>Owner</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($leads)): ?>
|
||||
<tr>
|
||||
<td colspan="6" class="text-center py-5">
|
||||
<p class="mb-2">No leads found.</p>
|
||||
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addLeadModal">Add your first lead</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($leads as $lead): ?>
|
||||
<tr>
|
||||
<td><strong><?php echo htmlspecialchars($lead['lead_name']); ?></strong></td>
|
||||
<td>
|
||||
<span class="status-badge status-<?php echo strtolower(htmlspecialchars($lead['status'])); ?>">
|
||||
<?php echo htmlspecialchars($lead['status']); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td><?php echo htmlspecialchars($lead['category']); ?></td>
|
||||
<td><?php echo htmlspecialchars($lead['contact_email']); ?></td>
|
||||
<td><?php echo htmlspecialchars($lead['owner']); ?></td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-outline-secondary"><i data-feather="edit-2"></i></button>
|
||||
<button class="btn btn-sm btn-outline-danger"><i data-feather="trash-2"></i></button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add Lead Modal -->
|
||||
<div class="modal fade" id="addLeadModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<form action="add_lead.php" method="POST">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Add New Lead</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="mb-3">
|
||||
<label for="lead_name" class="form-label">Lead Name</label>
|
||||
<input type="text" class="form-control" id="lead_name" name="lead_name" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="status" class="form-label">Status</label>
|
||||
<select class="form-select" id="status" name="status" required>
|
||||
<option value="New">New</option>
|
||||
<option value="Contacted">Contacted</option>
|
||||
<option value="Qualified">Qualified</option>
|
||||
<option value="Lost">Lost</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="category" class="form-label">Category</label>
|
||||
<select class="form-select" id="category" name="category" required>
|
||||
<option value="Corporate">Corporate</option>
|
||||
<option value="Family">Family</option>
|
||||
<option value="Criminal">Criminal</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="contact_email" class="form-label">Contact Email</label>
|
||||
<input type="email" class="form-control" id="contact_email" name="contact_email" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="owner" class="form-label">Owner</label>
|
||||
<input type="text" class="form-control" id="owner" name="owner" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="submit" class="btn btn-primary">Save Lead</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Toast Notification -->
|
||||
<?php if ($message): ?>
|
||||
<div class="toast-container position-fixed bottom-0 end-0 p-3">
|
||||
<div class="toast align-items-center text-white bg-<?php echo $message['type']; ?> border-0" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="d-flex">
|
||||
<div class="toast-body">
|
||||
<?php echo htmlspecialchars($message['text']); ?>
|
||||
</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 src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||
<script>
|
||||
feather.replace();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user