217 lines
10 KiB
PHP
217 lines
10 KiB
PHP
<?php
|
|
require_once 'db/config.php';
|
|
|
|
// Create the requests table if it doesn't exist
|
|
try {
|
|
$pdo = db();
|
|
$sql = "
|
|
CREATE TABLE IF NOT EXISTS requests (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
customer_name VARCHAR(255) NOT NULL,
|
|
customer_email VARCHAR(255) NOT NULL,
|
|
customer_phone VARCHAR(50),
|
|
appliance_type VARCHAR(50) NOT NULL,
|
|
issue_description TEXT,
|
|
status VARCHAR(50) DEFAULT 'Pending',
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);";
|
|
$pdo->exec($sql);
|
|
} catch (PDOException $e) {
|
|
// For now, we'll just die on a DB error. In a real app, handle this gracefully.
|
|
die("Database setup failed: " . $e->getMessage());
|
|
}
|
|
|
|
|
|
$success_message = '';
|
|
$error_message = '';
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
$customer_name = trim($_POST['name']);
|
|
$customer_email = trim($_POST['email']);
|
|
$customer_phone = trim($_POST['phone']);
|
|
$appliance_type = trim($_POST['appliance']);
|
|
$issue_description = trim($_POST['issue']);
|
|
|
|
if (empty($customer_name) || empty($customer_email) || empty($appliance_type)) {
|
|
$error_message = "Please fill in all required fields (Name, Email, Appliance Type).";
|
|
} elseif (!filter_var($customer_email, FILTER_VALIDATE_EMAIL)) {
|
|
$error_message = "Invalid email format.";
|
|
} else {
|
|
try {
|
|
$sql = "INSERT INTO requests (customer_name, customer_email, customer_phone, appliance_type, issue_description) VALUES (:name, :email, :phone, :appliance, :issue)";
|
|
$stmt = $pdo->prepare($sql);
|
|
|
|
$stmt->bindParam(':name', $customer_name);
|
|
$stmt->bindParam(':email', $customer_email);
|
|
$stmt->bindParam(':phone', $customer_phone);
|
|
$stmt->bindParam(':appliance', $appliance_type);
|
|
$stmt->bindParam(':issue', $issue_description);
|
|
|
|
$stmt->execute();
|
|
|
|
$success_message = "Thank you! Your service request has been submitted. We will get back to you shortly.";
|
|
} catch (PDOException $e) {
|
|
$error_message = "Error submitting request: " . $e->getMessage();
|
|
}
|
|
}
|
|
}
|
|
|
|
$project_name = htmlspecialchars($_SERVER['PROJECT_NAME'] ?? 'Appliance CRM');
|
|
$project_description = htmlspecialchars($_SERVER['PROJECT_DESCRIPTION'] ?? 'CRM for appliance service requests.');
|
|
$project_image_url = htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? '');
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?= $project_name ?></title>
|
|
<meta name="description" content="<?= $project_description ?>">
|
|
<!-- Open Graph / Facebook -->
|
|
<meta property="og:type" content="website">
|
|
<meta property="og:title" content="<?= $project_name ?>">
|
|
<meta property="og:description" content="<?= $project_description ?>">
|
|
<?php if ($project_image_url): ?>
|
|
<meta property="og:image" content="<?= $project_image_url ?>">
|
|
<?php endif; ?>
|
|
<!-- Twitter -->
|
|
<meta property="twitter:card" content="summary_large_image">
|
|
<meta property="twitter:title" content="<?= $project_name ?>">
|
|
<meta property="twitter:description" content="<?= $project_description ?>">
|
|
<?php if ($project_image_url): ?>
|
|
<meta property="twitter:image" content="<?= $project_image_url ?>">
|
|
<?php endif; ?>
|
|
|
|
<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?v=<?php echo time(); ?>">
|
|
</head>
|
|
<body>
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm">
|
|
<div class="container">
|
|
<a class="navbar-brand fw-bold" href="#"><?= $project_name ?></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 ms-auto">
|
|
<li class="nav-item"><a class="nav-link" href="#">Home</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="#services">Services</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="#booking">Book Service</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<header class="py-5">
|
|
<div class="container text-center">
|
|
<h1 class="display-4 fw-bold">Appliance Repair Made Easy</h1>
|
|
<p class="lead text-muted">Fast, reliable service for your TV, A/C, and Washing Machine. Book a technician today!</p>
|
|
<a href="#booking" class="btn btn-primary btn-lg mt-3">Book a Service</a>
|
|
</div>
|
|
</header>
|
|
|
|
<section id="services" class="py-5 bg-light">
|
|
<div class="container">
|
|
<div class="text-center mb-5">
|
|
<h2 class="fw-bold">Our Services</h2>
|
|
<p class="text-muted">We specialize in the installation and repair of:</p>
|
|
</div>
|
|
<div class="row text-center">
|
|
<div class="col-md-4 mb-4">
|
|
<div class="card h-100 border-0 shadow-sm">
|
|
<div class="card-body">
|
|
<i class="bi bi-tv fs-1 text-primary"></i>
|
|
<h3 class="h4 mt-3">Televisions</h3>
|
|
<p class="text-muted">Screen repairs, sound issues, smart TV setup, and more.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4 mb-4">
|
|
<div class="card h-100 border-0 shadow-sm">
|
|
<div class="card-body">
|
|
<i class="bi bi-snow fs-1 text-primary"></i>
|
|
<h3 class="h4 mt-3">Air Conditioners</h3>
|
|
<p class="text-muted">Cooling problems, regular maintenance, and new installations.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4 mb-4">
|
|
<div class="card h-100 border-0 shadow-sm">
|
|
<div class="card-body">
|
|
<i class="bi bi-water fs-1 text-primary"></i>
|
|
<h3 class="h4 mt-3">Washing Machines</h3>
|
|
<p class="text-muted">Drum issues, water leaks, and electronic faults.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section id="booking" class="py-5">
|
|
<div class="container">
|
|
<div class="row justify-content-center">
|
|
<div class="col-lg-8">
|
|
<div class="text-center mb-5">
|
|
<h2 class="fw-bold">Submit a Service Request</h2>
|
|
</div>
|
|
|
|
<?php if ($success_message): ?>
|
|
<div class="alert alert-success"><?= $success_message ?></div>
|
|
<?php endif; ?>
|
|
<?php if ($error_message): ?>
|
|
<div class="alert alert-danger"><?= $error_message ?></div>
|
|
<?php endif; ?>
|
|
|
|
<div class="card border-0 shadow-sm">
|
|
<div class="card-body p-4">
|
|
<form action="index.php#booking" 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 (Optional)</label>
|
|
<input type="tel" class="form-control" id="phone" name="phone">
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="appliance" class="form-label">Appliance Type</label>
|
|
<select class="form-select" id="appliance" name="appliance" required>
|
|
<option value="" disabled selected>Select an appliance</option>
|
|
<option value="TV">Television</option>
|
|
<option value="AC">Air Conditioner</option>
|
|
<option value="Washing Machine">Washing Machine</option>
|
|
</select>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="issue" class="form-label">Brief Description of Issue</label>
|
|
<textarea class="form-control" id="issue" name="issue" rows="4"></textarea>
|
|
</div>
|
|
<div class="d-grid">
|
|
<button type="submit" class="btn btn-primary btn-lg">Submit Request</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<footer class="py-4 bg-dark text-white">
|
|
<div class="container text-center">
|
|
<p class="mb-0">© <?php echo date("Y"); ?> <?= $project_name ?>. All Rights Reserved.</p>
|
|
</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>
|