Sfepro v1

This commit is contained in:
Flatlogic Bot 2025-10-19 03:26:15 +00:00
parent 2a30fbdcdb
commit b4397b355f
15 changed files with 837 additions and 144 deletions

76
add_contact.php Normal file
View File

@ -0,0 +1,76 @@
<?php
require_once 'db/config.php';
$success_message = '';
$error_message = '';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = trim($_POST['name']);
$company = trim($_POST['company']);
$email = trim($_POST['email']);
$phone = trim($_POST['phone']);
$source = trim($_POST['source']);
$tags = trim($_POST['tags']);
if (empty($name) || empty($email)) {
$error_message = "Name and Email are required fields.";
} else {
try {
$stmt = db()->prepare("INSERT INTO contacts (name, company, email, phone, source, tags) VALUES (?, ?, ?, ?, ?, ?)");
$stmt->execute([$name, $company, $email, $phone, $source, $tags]);
header("Location: index.php?success=1");
exit();
} catch (PDOException $e) {
$error_message = "Error: " . $e->getMessage();
}
}
}
include 'header.php';
?>
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h4 class="mb-0">Add New Contact</h4>
</div>
<div class="card-body">
<?php if ($error_message): ?>
<div class="alert alert-danger" role="alert">
<?php echo $error_message; ?>
</div>
<?php endif; ?>
<form action="add_contact.php" method="post">
<div class="mb-3">
<label for="name" class="form-label">Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="name" name="name" required>
</div>
<div class="mb-3">
<label for="company" class="form-label">Company</label>
<input type="text" class="form-control" id="company" name="company">
</div>
<div class="mb-3">
<label for="email" class="form-label">Email <span class="text-danger">*</span></label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="mb-3">
<label for="phone" class="form-label">Phone</label>
<input type="tel" class="form-control" id="phone" name="phone">
</div>
<div class="mb-3">
<label for="source" class="form-label">Source</label>
<input type="text" class="form-control" id="source" name="source">
</div>
<div class="mb-3">
<label for="tags" class="form-label">Tags (comma-separated)</label>
<input type="text" class="form-control" id="tags" name="tags">
</div>
<button type="submit" class="btn btn-primary w-100">Add Contact</button>
</form>
</div>
</div>
</div>
</div>
<?php include 'footer.php'; ?>

86
add_deal.php Normal file
View File

@ -0,0 +1,86 @@
<?php
require_once 'db/config.php';
$error_message = '';
// Fetch contacts for the dropdown
$contacts = db()->query("SELECT id, name FROM contacts ORDER BY name ASC")->fetchAll();
$deal_stages = ['Lead', 'Qualified', 'Proposal', 'Won', 'Lost'];
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$title = trim($_POST['title']);
$value = trim($_POST['value']);
$stage = trim($_POST['stage']);
$close_date = trim($_POST['close_date']);
$contact_id = trim($_POST['contact_id']);
if (empty($title) || empty($value) || empty($stage) || empty($contact_id)) {
$error_message = "Title, Value, Stage, and Contact are required fields.";
} elseif (!is_numeric($value)) {
$error_message = "Deal value must be a number.";
} else {
try {
$stmt = db()->prepare("INSERT INTO deals (title, value, stage, close_date, contact_id) VALUES (?, ?, ?, ?, ?)");
$stmt->execute([$title, $value, $stage, $close_date, $contact_id]);
header("Location: index.php?success_deal=1");
exit();
} catch (PDOException $e) {
$error_message = "Error: " . $e->getMessage();
}
}
}
include 'header.php';
?>
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h4 class="mb-0">Add New Deal</h4>
</div>
<div class="card-body">
<?php if ($error_message): ?>
<div class="alert alert-danger" role="alert">
<?php echo $error_message; ?>
</div>
<?php endif; ?>
<form action="add_deal.php" method="post">
<div class="mb-3">
<label for="title" class="form-label">Title <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="title" name="title" required>
</div>
<div class="mb-3">
<label for="value" class="form-label">Value ($) <span class="text-danger">*</span></label>
<input type="number" step="0.01" class="form-control" id="value" name="value" required>
</div>
<div class="mb-3">
<label for="stage" class="form-label">Stage <span class="text-danger">*</span></label>
<select class="form-select" id="stage" name="stage" required>
<?php foreach($deal_stages as $stage): ?>
<option value="<?php echo $stage; ?>"><?php echo $stage; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="mb-3">
<label for="close_date" class="form-label">Expected Close Date</label>
<input type="date" class="form-control" id="close_date" name="close_date">
</div>
<div class="mb-3">
<label for="contact_id" class="form-label">Contact <span class="text-danger">*</span></label>
<select class="form-select" id="contact_id" name="contact_id" required>
<option value="">Select a contact</option>
<?php foreach($contacts as $contact): ?>
<option value="<?php echo $contact['id']; ?>"><?php echo htmlspecialchars($contact['name']); ?></option>
<?php endforeach; ?>
</select>
</div>
<button type="submit" class="btn btn-primary w-100">Add Deal</button>
</form>
</div>
</div>
</div>
</div>
<?php include 'footer.php'; ?>

37
assets/css/custom.css Normal file
View File

@ -0,0 +1,37 @@
/* Add your custom styles here */
body {
background-color: #f8f9fa;
}
.navbar {
margin-bottom: 2rem;
}
.card {
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}
/* Dashboard KPI cards */
.card-text.fs-4 {
font-weight: 600;
}
/* Kanban Board Styles */
.kanban-board .card-header {
font-weight: 600;
}
.kanban-board .card-body {
min-height: 400px;
overflow-y: auto;
background-color: #f4f6f9;
}
.kanban-board .card-body .card {
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
transition: box-shadow 0.2s ease-in-out;
}
.kanban-board .card-body .card:hover {
box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

1
assets/js/main.js Normal file
View File

@ -0,0 +1 @@
// Add your custom scripts here

97
contacts.php Normal file
View File

@ -0,0 +1,97 @@
<?php
session_start();
require_once 'db/config.php';
require_once 'header.php';
$search = $_GET['search'] ?? '';
$sort = $_GET['sort'] ?? 'created_at_desc';
$sort_options = [
'name_asc' => '`name` ASC',
'name_desc' => '`name` DESC',
'company_asc' => '`company` ASC',
'company_desc' => '`company` DESC',
'created_at_asc' => '`created_at` ASC',
'created_at_desc' => '`created_at` DESC',
];
$order_by = $sort_options[$sort] ?? '`created_at` DESC';
try {
$pdo = db();
$search_term = "%$search%";
$stmt = $pdo->prepare("SELECT * FROM contacts WHERE name LIKE :search OR company LIKE :search OR email LIKE :search ORDER BY $order_by");
$stmt->bindParam(':search', $search_term);
$stmt->execute();
$contacts = $stmt->fetchAll();
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
$contacts = [];
}
?>
<div class="container mt-4">
<?php
if (isset($_SESSION['success_message'])) {
echo '<div class="alert alert-success alert-dismissible fade show" role="alert">' . $_SESSION['success_message'] . '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>';
unset($_SESSION['success_message']);
}
if (isset($_SESSION['error_message'])) {
echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">' . $_SESSION['error_message'] . '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>';
unset($_SESSION['error_message']);
}
?>
<div class="d-flex justify-content-between align-items-center mb-3">
<h2><i class="fas fa-address-book me-2"></i>Contacts</h2>
<a href="add_contact.php" class="btn btn-primary"><i class="fas fa-plus me-2"></i>Add Contact</a>
</div>
<form method="get" class="row g-3 mb-3">
<div class="col-md-6">
<input type="text" name="search" class="form-control" placeholder="Search contacts..." value="<?php echo htmlspecialchars($search); ?>">
</div>
<div class="col-md-4">
<select name="sort" class="form-select">
<option value="created_at_desc" <?php if ($sort === 'created_at_desc') echo 'selected'; ?>>Newest First</option>
<option value="created_at_asc" <?php if ($sort === 'created_at_asc') echo 'selected'; ?>>Oldest First</option>
<option value="name_asc" <?php if ($sort === 'name_asc') echo 'selected'; ?>>Name (A-Z)</option>
<option value="name_desc" <?php if ($sort === 'name_desc') echo 'selected'; ?>>Name (Z-A)</option>
<option value="company_asc" <?php if ($sort === 'company_asc') echo 'selected'; ?>>Company (A-Z)</option>
<option value="company_desc" <?php if ($sort === 'company_desc') echo 'selected'; ?>>Company (Z-A)</option>
</select>
</div>
<div class="col-md-2">
<button type="submit" class="btn btn-secondary w-100">Filter</button>
</div>
</form>
<div class="list-group">
<?php if (empty($contacts)): ?>
<div class="list-group-item text-center text-muted">
No contacts found. <a href="add_contact.php">Add one now</a>.
</div>
<?php else: ?>
<?php foreach ($contacts as $contact): ?>
<div class="list-group-item list-group-item-action flex-column align-items-start">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1"><?php echo htmlspecialchars($contact['name']); ?></h5>
<small class="text-muted"><?php echo date('M j, Y', strtotime($contact['created_at'])); ?></small>
</div>
<p class="mb-1"><?php echo htmlspecialchars($contact['company']); ?></p>
<small class="text-muted d-block"><?php echo htmlspecialchars($contact['email']); ?> | <?php echo htmlspecialchars($contact['phone']); ?></small>
<div class="mt-2">
<a href="edit_contact.php?id=<?php echo $contact['id']; ?>" class="btn btn-sm btn-outline-secondary me-2">
<i class="fas fa-pencil-alt me-1"></i>Edit
</a>
<a href="delete_contact.php?id=<?php echo $contact['id']; ?>" class="btn btn-sm btn-outline-danger" onclick="return confirm('Are you sure you want to delete this contact? This action cannot be undone.');">
<i class="fas fa-trash-alt me-1"></i>Delete
</a>
<span class="badge rounded-pill bg-light text-dark ms-2">Source: <?php echo htmlspecialchars($contact['source']); ?></span>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
<?php require_once 'footer.php'; ?>

View File

@ -15,3 +15,37 @@ function db() {
}
return $pdo;
}
function db_init() {
$pdo = db();
$contacts_table_sql = ""
CREATE TABLE IF NOT EXISTS `contacts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`company` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`phone` varchar(255) DEFAULT NULL,
`source` varchar(255) DEFAULT NULL,
`tags` varchar(255) DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
""";
$pdo->exec($contacts_table_sql);
$deals_table_sql = ""
CREATE TABLE IF NOT EXISTS `deals` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`title` VARCHAR(255) NOT NULL,
`value` DECIMAL(10, 2) NOT NULL,
`stage` VARCHAR(50) NOT NULL,
`close_date` DATE,
`contact_id` INT NOT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (contact_id) REFERENCES contacts(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
""";
$pdo->exec($deals_table_sql);
}
db_init();

41
delete_contact.php Normal file
View File

@ -0,0 +1,41 @@
<?php
require_once 'db/config.php';
session_start();
if (!isset($_GET['id']) || empty($_GET['id'])) {
header("Location: contacts.php");
exit;
}
$contact_id = $_GET['id'];
try {
$pdo = db();
// Check for associated deals
$stmt = $pdo->prepare("SELECT COUNT(*) FROM deals WHERE contact_id = :contact_id");
$stmt->bindParam(':contact_id', $contact_id, PDO::PARAM_INT);
$stmt->execute();
$deal_count = $stmt->fetchColumn();
if ($deal_count > 0) {
$_SESSION['error_message'] = "Cannot delete contact. It is associated with {$deal_count} deal(s). Please reassign or delete the deals first.";
} else {
// No associated deals, proceed with deletion
$stmt = $pdo->prepare("DELETE FROM contacts WHERE id = :id");
$stmt->bindParam(':id', $contact_id, PDO::PARAM_INT);
if ($stmt->execute() && $stmt->rowCount() > 0) {
$_SESSION['success_message'] = "Contact deleted successfully.";
} else {
$_SESSION['error_message'] = "Failed to delete contact or contact not found.";
}
}
} catch (PDOException $e) {
$_SESSION['error_message'] = "Database error: " . $e->getMessage();
}
header("Location: contacts.php");
exit;
?>

28
delete_deal.php Normal file
View File

@ -0,0 +1,28 @@
<?php
require_once 'db/config.php';
session_start();
if (!isset($_GET['id']) || empty($_GET['id'])) {
header("Location: index.php");
exit;
}
$deal_id = $_GET['id'];
try {
$pdo = db();
$stmt = $pdo->prepare("DELETE FROM deals WHERE id = :id");
$stmt->bindParam(':id', $deal_id, PDO::PARAM_INT);
if ($stmt->execute() && $stmt->rowCount() > 0) {
$_SESSION['success_message'] = "Deal deleted successfully.";
} else {
$_SESSION['error_message'] = "Failed to delete deal or deal not found.";
}
} catch (PDOException $e) {
$_SESSION['error_message'] = "Database error: " . $e->getMessage();
}
header("Location: index.php");
exit;
?>

99
edit_contact.php Normal file
View File

@ -0,0 +1,99 @@
<?php
require_once 'db/config.php';
require_once 'header.php';
$id = $_GET['id'] ?? null;
if (!$id) {
header("Location: contacts.php");
exit;
}
$pdo = db();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = $_POST['name'] ?? '';
$company = $_POST['company'] ?? '';
$email = $_POST['email'] ?? '';
$phone = $_POST['phone'] ?? '';
$source = $_POST['source'] ?? '';
$tags = $_POST['tags'] ?? '';
if (empty($name) || empty($email)) {
$error = "Name and email are required.";
} else {
try {
$stmt = $pdo->prepare("UPDATE contacts SET name = :name, company = :company, email = :email, phone = :phone, source = :source, tags = :tags WHERE id = :id");
$stmt->execute([
':name' => $name,
':company' => $company,
':email' => $email,
':phone' => $phone,
':source' => $source,
':tags' => $tags,
':id' => $id
]);
header("Location: contacts.php?status=updated");
exit;
} catch (PDOException $e) {
$error = "Database error: " . $e->getMessage();
}
}
}
try {
$stmt = $pdo->prepare("SELECT * FROM contacts WHERE id = :id");
$stmt->execute([':id' => $id]);
$contact = $stmt->fetch();
if (!$contact) {
header("Location: contacts.php");
exit;
}
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
exit;
}
?>
<div class="container mt-4">
<h2><i class="fas fa-edit me-2"></i>Edit Contact</h2>
<?php if (!empty($error)): ?>
<div class="alert alert-danger"><?php echo $error; ?></div>
<?php endif; ?>
<form action="edit_contact.php?id=<?php echo $id; ?>" method="post" class="card p-4">
<div class="row g-3">
<div class="col-md-6">
<label for="name" class="form-label">Name</label>
<input type="text" class="form-control" id="name" name="name" value="<?php echo htmlspecialchars($contact['name']); ?>" required>
</div>
<div class="col-md-6">
<label for="company" class="form-label">Company</label>
<input type="text" class="form-control" id="company" name="company" value="<?php echo htmlspecialchars($contact['company']); ?>">
</div>
<div class="col-md-6">
<label for="email" class="form-label">Email</label>
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($contact['email']); ?>" required>
</div>
<div class="col-md-6">
<label for="phone" class="form-label">Phone</label>
<input type="tel" class="form-control" id="phone" name="phone" value="<?php echo htmlspecialchars($contact['phone']); ?>">
</div>
<div class="col-md-6">
<label for="source" class="form-label">Source</label>
<input type="text" class="form-control" id="source" name="source" value="<?php echo htmlspecialchars($contact['source']); ?>">
</div>
<div class="col-md-6">
<label for="tags" class="form-label">Tags (comma-separated)</label>
<input type="text" class="form-control" id="tags" name="tags" value="<?php echo htmlspecialchars($contact['tags']); ?>">
</div>
</div>
<div class="mt-4">
<button type="submit" class="btn btn-primary">Save Changes</button>
<a href="contacts.php" class="btn btn-secondary">Cancel</a>
</div>
</form>
</div>
<?php require_once 'footer.php'; ?>

116
edit_deal.php Normal file
View File

@ -0,0 +1,116 @@
<?php
require_once 'db/config.php';
require_once 'header.php';
$id = $_GET['id'] ?? null;
if (!$id) {
header("Location: index.php");
exit;
}
$pdo = db();
// Fetch all contacts for the dropdown
try {
$stmt = $pdo->query("SELECT id, name, company FROM contacts ORDER BY name ASC");
$contacts = $stmt->fetchAll();
} catch (PDOException $e) {
$error = "Error fetching contacts: " . $e->getMessage();
$contacts = [];
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$title = $_POST['title'] ?? '';
$value = $_POST['value'] ?? 0;
$stage = $_POST['stage'] ?? 'Lead';
$contact_id = $_POST['contact_id'] ?? null;
$close_date = $_POST['close_date'] ?? null;
if (empty($title) || empty($contact_id)) {
$error = "Title and contact are required.";
} else {
try {
$stmt = $pdo->prepare("UPDATE deals SET title = :title, value = :value, stage = :stage, contact_id = :contact_id, close_date = :close_date WHERE id = :id");
$stmt->execute([
':title' => $title,
':value' => $value,
':stage' => $stage,
':contact_id' => $contact_id,
':close_date' => !empty($close_date) ? $close_date : null,
':id' => $id
]);
header("Location: index.php?status=deal_updated");
exit;
} catch (PDOException $e) {
$error = "Database error: " . $e->getMessage();
}
}
}
try {
$stmt = $pdo->prepare("SELECT * FROM deals WHERE id = :id");
$stmt->execute([':id' => $id]);
$deal = $stmt->fetch();
if (!$deal) {
header("Location: index.php");
exit;
}
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
exit;
}
$deal_stages = ['Lead', 'Prospecting', 'Qualification', 'Proposal', 'Negotiation', 'Closed Won', 'Closed Lost'];
?>
<div class="container mt-4">
<h2><i class="fas fa-edit me-2"></i>Edit Deal</h2>
<?php if (!empty($error)): ?>
<div class="alert alert-danger"><?php echo $error; ?></div>
<?php endif; ?>
<form action="edit_deal.php?id=<?php echo $id; ?>" method="post" class="card p-4">
<div class="row g-3">
<div class="col-md-6">
<label for="title" class="form-label">Deal Title</label>
<input type="text" class="form-control" id="title" name="title" value="<?php echo htmlspecialchars($deal['title']); ?>" required>
</div>
<div class="col-md-6">
<label for="value" class="form-label">Value ($)</label>
<input type="number" step="0.01" class="form-control" id="value" name="value" value="<?php echo htmlspecialchars($deal['value']); ?>">
</div>
<div class="col-md-6">
<label for="stage" class="form-label">Stage</label>
<select class="form-select" id="stage" name="stage">
<?php foreach ($deal_stages as $stage_option): ?>
<option value="<?php echo $stage_option; ?>" <?php if ($deal['stage'] === $stage_option) echo 'selected'; ?>><?php echo $stage_option; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-6">
<label for="contact_id" class="form-label">Contact</label>
<select class="form-select" id="contact_id" name="contact_id" required>
<option value="">Select a contact</option>
<?php foreach ($contacts as $contact): ?>
<option value="<?php echo $contact['id']; ?>" <?php if ($deal['contact_id'] == $contact['id'] ) echo 'selected'; ?>>
<?php echo htmlspecialchars($contact['name']); ?> (<?php echo htmlspecialchars($contact['company']); ?>)
</option>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-12">
<label for="close_date" class="form-label">Expected Close Date</label>
<input type="date" class="form-control" id="close_date" name="close_date" value="<?php echo htmlspecialchars($deal['close_date']); ?>">
</div>
</div>
<div class="mt-4">
<button type="submit" class="btn btn-primary">Save Changes</button>
<a href="index.php" class="btn btn-secondary">Cancel</a>
</div>
</form>
</div>
<?php require_once 'footer.php'; ?>

14
footer.php Normal file
View File

@ -0,0 +1,14 @@
</main>
<footer class="bg-light text-center text-lg-start mt-4">
<div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.05);">
© 2025 Copyright:
<a class="text-dark" href="https://flatlogic.com/">Flatlogic</a>
| <a class="text-dark" href="privacy.php">Privacy Policy</a>
</div>
</footer>
<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>

40
header.php Normal file
View File

@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sales CRM</title>
<meta name="description" content="A lightweight back office to track contacts and deals.">
<meta name="keywords" content="sales, crm, contacts, deals, pipeline, flatlogic">
<meta property="og:title" content="Sales CRM">
<meta property="og:description" content="A lightweight back office to track contacts and deals.">
<meta name="twitter:card" content="summary_large_image">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="index.php">Sales 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 ms-auto">
<li class="nav-item">
<a class="nav-link" href="index.php"><i class="fas fa-chart-line me-1"></i> Pipeline</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contacts.php"><i class="fas fa-address-book me-1"></i> Contacts</a>
</li>
<li class="nav-item">
<a class="nav-link" href="add_deal.php"><i class="fas fa-handshake me-1"></i> Add Deal</a>
</li>
</ul>
</div>
</div>
</nav>
<main class="container mt-4">

276
index.php
View File

@ -1,150 +1,142 @@
<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
session_start();
require_once 'db/config.php';
include 'header.php';
// Fetch all deals to calculate KPIs and group them
$deals_result = db()->query("
SELECT
d.id, d.title, d.value, d.stage, d.close_date,
c.name as contact_name, c.email as contact_email
FROM deals d
JOIN contacts c ON d.contact_id = c.id
ORDER BY d.created_at DESC
");
$all_deals = $deals_result ? $deals_result->fetchAll() : [];
// --- KPI Calculations ---
$total_value = 0;
$deals_won = 0;
$deals_lost = 0;
$deals_in_progress = 0;
$deals_by_stage = [
'Lead' => [],
'Contact Made' => [],
'Proposal' => [],
'Won' => [],
'Lost' => [],
];
foreach ($all_deals as $deal) {
$total_value += $deal['value'];
if ($deal['stage'] == 'Won') {
$deals_won++;
} elseif ($deal['stage'] == 'Lost') {
$deals_lost++;
} else {
$deals_in_progress++;
}
if (array_key_exists($deal['stage'], $deals_by_stage)) {
$deals_by_stage[$deal['stage']][] = $deal;
}
}
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>New Style</title>
<?php
// Read project preview data from environment
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
if (isset($_SESSION['success_message'])) {
echo '<div class="alert alert-success alert-dismissible fade show" role="alert">' . htmlspecialchars($_SESSION['success_message']) . '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>';
unset($_SESSION['success_message']);
}
if (isset($_SESSION['error_message'])) {
echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">' . htmlspecialchars($_SESSION['error_message']) . '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>';
unset($_SESSION['error_message']);
}
?>
<?php if ($projectDescription): ?>
<!-- Meta description -->
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
<!-- Open Graph meta tags -->
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<!-- Twitter meta tags -->
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<!-- Open Graph image -->
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<!-- Twitter image -->
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<?php endif; ?>
<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>
</head>
<body>
<main>
<!-- KPI Dashboard -->
<div class="row mb-4">
<div class="col-md-3">
<div class="card text-white bg-primary">
<div class="card-body">
<h5 class="card-title"><i class="fas fa-dollar-sign me-2"></i>Total Pipeline Value</h5>
<p class="card-text fs-4">$<?php echo number_format($total_value, 2); ?></p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card text-white bg-success">
<div class="card-body">
<h5 class="card-title"><i class="fas fa-trophy me-2"></i>Deals Won</h5>
<p class="card-text fs-4"><?php echo $deals_won; ?></p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card text-white bg-danger">
<div class="card-body">
<h5 class="card-title"><i class="fas fa-times-circle me-2"></i>Deals Lost</h5>
<p class="card-text fs-4"><?php echo $deals_lost; ?></p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card text-white bg-info">
<div class="card-body">
<h5 class="card-title"><i class="fas fa-tasks me-2"></i>Deals In Progress</h5>
<p class="card-text fs-4"><?php echo $deals_in_progress; ?></p>
</div>
</div>
</div>
</div>
<!-- Deal Pipeline (Kanban Board) -->
<div class="d-flex justify-content-between align-items-center mb-3">
<h4 class="mb-0"><i class="fas fa-chart-line me-2"></i>Deal Pipeline</h4>
<a href="add_deal.php" class="btn btn-primary"><i class="fas fa-plus me-1"></i> Add New Deal</a>
</div>
<div class="row">
<?php foreach ($deals_by_stage as $stage => $deals): ?>
<div class="col-md">
<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>
<div class="card-header bg-light">
<h6 class="mb-0 text-uppercase"><?php echo htmlspecialchars($stage); ?> <span class="badge bg-secondary rounded-pill"><?php echo count($deals); ?></span></h6>
</div>
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : '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 class="card-body" style="min-height: 400px; overflow-y: auto;">
<?php if (empty($deals)): ?>
<p class="text-muted small text-center mt-2">No deals in this stage.</p>
<?php else: ?>
<?php foreach ($deals as $deal): ?>
<div class="card mb-2">
<div class="card-body p-2">
<h6 class="card-title mb-1"><?php echo htmlspecialchars($deal['title']); ?></h6>
<p class="card-text small mb-1">
<strong>Value:</strong> $<?php echo number_format($deal['value'], 2); ?>
</p>
<p class="card-text small mb-2">
<i class="fas fa-user me-1"></i>
<a href="mailto:<?php echo htmlspecialchars($deal['contact_email']); ?>"><?php echo htmlspecialchars($deal['contact_name']); ?></a>
</p>
<div class="d-flex justify-content-end">
<a href="edit_deal.php?id=<?php echo $deal['id']; ?>" class="btn btn-sm btn-outline-secondary me-1 py-0 px-1">
<i class="fas fa-pencil-alt fa-xs"></i>
</a>
<a href="delete_deal.php?id=<?php echo $deal['id']; ?>" class="btn btn-sm btn-outline-danger py-0 px-1" onclick="return confirm('Are you sure you want to delete this deal?');">
<i class="fas fa-trash-alt fa-xs"></i>
</a>
</div>
</main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC)
</footer>
</body>
</html>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php include 'footer.php'; ?>

11
privacy.php Normal file
View File

@ -0,0 +1,11 @@
<?php include 'header.php'; ?>
<div class="card">
<div class="card-body">
<h1>Privacy Policy</h1>
<p>This is a placeholder for your privacy policy.</p>
<p>Please replace this content with your actual privacy policy.</p>
</div>
</div>
<?php include 'footer.php'; ?>

21
sitemap.xml Normal file
View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://your-domain.com/index.php</loc>
<lastmod>2025-10-19</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>http://your-domain.com/add_contact.php</loc>
<lastmod>2025-10-19</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>http://your-domain.com/privacy.php</loc>
<lastmod>2025-10-19</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
</urlset>