123 lines
5.8 KiB
PHP
123 lines
5.8 KiB
PHP
<?php
|
|
session_start();
|
|
require_once __DIR__ . '/db/config.php';
|
|
|
|
// Check if LeadID is provided
|
|
if (!isset($_GET['id']) || empty($_GET['id'])) {
|
|
$_SESSION['error_message'] = 'No lead selected for editing.';
|
|
header('Location: index.php');
|
|
exit();
|
|
}
|
|
|
|
$lead_id = $_GET['id'];
|
|
|
|
// Fetch lead details
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare('SELECT * FROM leads WHERE LeadID = ?');
|
|
$stmt->execute([$lead_id]);
|
|
$lead = $stmt->fetch();
|
|
|
|
if (!$lead) {
|
|
$_SESSION['error_message'] = 'Lead not found.';
|
|
header('Location: index.php');
|
|
exit();
|
|
}
|
|
} catch (PDOException $e) {
|
|
$_SESSION['error_message'] = 'Error fetching lead details: ' . $e->getMessage();
|
|
header('Location: index.php');
|
|
exit();
|
|
}
|
|
|
|
$projectName = $_SERVER['PROJECT_NAME'] ?? 'CRM';
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Edit Lead - <?= htmlspecialchars($projectName) ?></title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
<style>
|
|
body {
|
|
background-color: #ecf0f1;
|
|
font-family: 'Lato', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
}
|
|
.navbar {
|
|
background-color: #2c3e50;
|
|
}
|
|
.navbar-brand {
|
|
font-weight: bold;
|
|
color: #fff;
|
|
}
|
|
.card {
|
|
border: none;
|
|
border-radius: 0.5rem;
|
|
box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.1);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<nav class="navbar navbar-expand-lg navbar-dark mb-4">
|
|
<div class="container">
|
|
<a class="navbar-brand" href="index.php"><i class="fas fa-chart-line me-2"></i><?= htmlspecialchars($projectName) ?></a>
|
|
</div>
|
|
</nav>
|
|
|
|
<main class="container">
|
|
<div class="row justify-content-center">
|
|
<div class="col-lg-6">
|
|
<div class="card">
|
|
<div class="card-header bg-white py-3">
|
|
<h5 class="mb-0"><i class="fas fa-edit me-2 text-primary"></i>Edit Lead</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<form action="update_lead.php" method="POST">
|
|
<input type="hidden" name="lead_id" value="<?= htmlspecialchars($lead['LeadID']) ?>">
|
|
<div class="mb-3">
|
|
<label for="name" class="form-label">Full Name*</label>
|
|
<input type="text" class="form-control" id="name" name="name" value="<?= htmlspecialchars($lead['Name']) ?>" required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="companyName" class="form-label">Company Name</label>
|
|
<input type="text" class="form-control" id="companyName" name="companyName" value="<?= htmlspecialchars($lead['CompanyName']) ?>">
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="email" class="form-label">Email*</label>
|
|
<input type="email" class="form-control" id="email" name="email" value="<?= htmlspecialchars($lead['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" value="<?= htmlspecialchars($lead['Phone']) ?>">
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="potentialAmount" class="form-label">Potential Amount ($)</label>
|
|
<input type="number" step="0.01" class="form-control" id="potentialAmount" name="potentialAmount" value="<?= htmlspecialchars($lead['PotentialAmount']) ?>">
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="status" class="form-label">Status</label>
|
|
<select class="form-select" id="status" name="status">
|
|
<option value="New" <?= $lead['Status'] == 'New' ? 'selected' : '' ?>>New</option>
|
|
<option value="Contacted" <?= $lead['Status'] == 'Contacted' ? 'selected' : '' ?>>Contacted</option>
|
|
<option value="Qualified" <?= $lead['Status'] == 'Qualified' ? 'selected' : '' ?>>Qualified</option>
|
|
<option value="Proposal Sent" <?= $lead['Status'] == 'Proposal Sent' ? 'selected' : '' ?>>Proposal Sent</option>
|
|
<option value="Won" <?= $lead['Status'] == 'Won' ? 'selected' : '' ?>>Won</option>
|
|
<option value="Lost" <?= $lead['Status'] == 'Lost' ? 'selected' : '' ?>>Lost</option>
|
|
</select>
|
|
</div>
|
|
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
|
|
<a href="index.php" class="btn btn-secondary">Cancel</a>
|
|
<button type="submit" class="btn btn-primary">Update Lead</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|