sadiq
This commit is contained in:
parent
60a638c740
commit
4a91088287
119
README.md
119
README.md
@ -1,95 +1,50 @@
|
||||
# AFG CARS - Premium Car Marketplace Afghanistan
|
||||
# AFG CARS - Premium Car Marketplace Afghanistan (Offline Edition)
|
||||
|
||||
Welcome to **AFG CARS**, an enterprise-level automotive marketplace platform specifically designed for the Afghanistan market (2026 Edition). This application provides a seamless experience for buying, selling, and managing vehicle listings with a modern, high-end UI and robust administrative features.
|
||||
|
||||
---
|
||||
AFG CARS is a modern, responsive web application for buying and selling cars in Afghanistan. This version is specially prepared to run **completely offline** on a local XAMPP environment.
|
||||
|
||||
## 🚀 Key Features
|
||||
- **Offline Ready**: No internet connection required. All assets (Bootstrap, Icons) are stored locally.
|
||||
- **Car Listings**: Browse verified car listings across major Afghan cities (Kabul, Herat, etc.).
|
||||
- **User Authentication**: Secure Login and Registration system.
|
||||
- **Admin Dashboard**: Comprehensive panel for managing inventory, approvals, users, and sales.
|
||||
- **User Dashboard**: Manage your own listings and view purchase history.
|
||||
- **Simulation Systems**: Simulated banking payment and local mail logging.
|
||||
|
||||
### 1. Advanced Marketplace
|
||||
* **Verified Listings:** High-quality vehicle listings with detailed specifications.
|
||||
* **Smart Search:** Filter by Brand, Model, Year, Location (Kabul, Herat, etc.), and Price range.
|
||||
* **Badging System:** Visual indicators for "Hot Deals" and "SOLD" status.
|
||||
## 💻 Installation (XAMPP)
|
||||
|
||||
### 2. Role-Based Access Control (RBAC)
|
||||
* **Guests:** Browse cars, search the market, and view company information.
|
||||
* **Registered Users:** List their own cars for sale, manage favorites, track purchases, and submit reviews.
|
||||
* **Administrators:** Full control over listing approvals, user management, sales tracking, and system notifications.
|
||||
1. **Move Project Folder**:
|
||||
- Copy the `afg-cars` folder into your XAMPP's `htdocs` directory (usually `C:\xampp\htdocs\`).
|
||||
|
||||
### 3. User & Admin Dashboards
|
||||
* **User Hub:** Track pending/approved listings, manage personal car ads, and view purchase history.
|
||||
* **Admin Command Center:** Review user-submitted cars for approval, view total revenue, manage users, and receive real-time alerts.
|
||||
2. **Start Services**:
|
||||
- Open the XAMPP Control Panel.
|
||||
- Start **Apache** and **MySQL**.
|
||||
|
||||
### 4. Enterprise-Grade Systems
|
||||
* **Review & Rating System:** Users can rate vehicles and leave feedback for sold items.
|
||||
* **Simulated Purchase System:** Integrated "Buy Now" flow featuring major Afghanistan banks (DAB, Azizi, AIB, etc.).
|
||||
* **Contact & Mail Integration:** Functional contact forms using the platform's internal mail service.
|
||||
3. **Database Setup (Automatic)**:
|
||||
- Open your browser and go to: `http://localhost/afg-cars/db/setup.php`
|
||||
- This script will automatically create the `afg_cars` database and all required tables.
|
||||
- It will also insert a default admin account and sample listings.
|
||||
|
||||
### 5. Physical Presence
|
||||
* Detailed information about physical showrooms in **Kabul, Herat, Mazar-i-Sharif, and Kandahar**.
|
||||
4. **Database Setup (Manual - Optional)**:
|
||||
- Go to `http://localhost/phpmyadmin/`.
|
||||
- Create a database named `afg_cars`.
|
||||
- Import the `db/database.sql` file.
|
||||
|
||||
---
|
||||
|
||||
## 🛠 Tech Stack
|
||||
|
||||
* **Language:** PHP 8.x (Vanilla)
|
||||
* **Database:** MariaDB / MySQL (via PDO)
|
||||
* **Frontend:** Bootstrap 5, Inter Typography, Bi-Icons
|
||||
* **Styling:** Custom CSS with modern glassmorphism and soft gradient effects
|
||||
* **AI Integration:** Local AI Proxy for advanced processing
|
||||
* **Mail Service:** PHPMailer-based `MailService`
|
||||
|
||||
---
|
||||
|
||||
## ⚙️ Installation & How to Run
|
||||
|
||||
### Prerequisites
|
||||
* A web server (Apache/Nginx) with PHP 8.x support.
|
||||
* MariaDB or MySQL database server.
|
||||
|
||||
### Setup Steps
|
||||
1. **Clone the Repository:**
|
||||
Place the project files into your web server's document root (e.g., `/var/www/html` or `htdocs`).
|
||||
|
||||
2. **Database Configuration:**
|
||||
* Open `db/config.php` and update the `DB_HOST`, `DB_NAME`, `DB_USER`, and `DB_PASS` constants to match your local environment.
|
||||
* Run the database initialization script by visiting `http://your-domain/db/setup.php` in your browser. This will create the necessary tables and seed the initial admin user.
|
||||
* Alternatively, run `php db/run_migrations.php` from the terminal.
|
||||
|
||||
3. **Environment Variables:**
|
||||
Ensure your `.env` file (if applicable) contains the necessary mail and AI configuration as described in the system documentation.
|
||||
|
||||
4. **Access the Site:**
|
||||
Open your browser and navigate to the project root (e.g., `http://localhost`).
|
||||
|
||||
---
|
||||
|
||||
## 🔐 Default Credentials (Enterprise Edition)
|
||||
|
||||
| Role | Email | Password |
|
||||
| :--- | :--- | :--- |
|
||||
| **Admin** | `admin@gmail.com` | `12345678` |
|
||||
|
||||
---
|
||||
## 🔐 Default Admin Credentials
|
||||
- **Email**: `admin@gmail.com`
|
||||
- **Password**: `12345678`
|
||||
|
||||
## 📁 Project Structure
|
||||
- `admin/`: Admin-specific pages and dashboards.
|
||||
- `assets/`: Local CSS, JS, and Bootstrap files.
|
||||
- `db/`: Database configuration, setup script, and SQL schema.
|
||||
- `includes/`: Reusable header and footer components.
|
||||
- `mail/`: Offline mail simulation service.
|
||||
- `user/`: User-specific dashboard and listing management.
|
||||
|
||||
* `index.php` - Enterprise landing page with "Hot Deals" and Hero section.
|
||||
* `cars.php` - Marketplace search and listing page.
|
||||
* `admin/` - Administrative dashboard and management scripts.
|
||||
* `user/` - Registered user dashboard and car submission area.
|
||||
* `db/` - Database configuration, setup scripts, and migrations.
|
||||
* `includes/` - Reusable UI components (Header, Footer).
|
||||
* `assets/` - CSS, JS, and image assets.
|
||||
* `mail/` - Integrated mail service logic.
|
||||
## 🛠 Troubleshooting
|
||||
- **Database Connection Error**: Ensure MySQL is running in XAMPP. Check `db/config.php` if you have changed the default XAMPP MySQL credentials (default is `root` with no password).
|
||||
- **Broken Layout**: Ensure the `assets/bootstrap/` folder contains the required CSS and JS files.
|
||||
- **Page Not Found**: Ensure you are accessing the project via `http://localhost/afg-cars/`.
|
||||
|
||||
---
|
||||
|
||||
## 📄 License & Notes
|
||||
|
||||
This project is built for the **Flatlogic LAMP VM**.
|
||||
* **Reminder:** Always click **Save** in the Flatlogic editor to sync changes to the platform.
|
||||
* **SEO:** Every page is optimized with unique meta titles and descriptions for maximum visibility.
|
||||
|
||||
---
|
||||
*Last Updated: February 13, 2026*
|
||||
## 🎓 University Project Note
|
||||
This system is designed as a university final-year project to demonstrate full-stack web development capabilities using PHP, MySQL, and Bootstrap, with a focus on local enterprise deployment.
|
||||
@ -3,31 +3,33 @@ session_start();
|
||||
require_once __DIR__ . '/../db/config.php';
|
||||
|
||||
if (!isset($_SESSION['role']) || $_SESSION['role'] !== 'admin') {
|
||||
header('Location: /login.php');
|
||||
header('Location: ' . APP_URL . 'login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$message = '';
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$title = $_POST['title'] ?? '';
|
||||
$brand = $_POST['brand'] ?? '';
|
||||
$model = $_POST['model'] ?? '';
|
||||
$year = $_POST['year'] ?? '';
|
||||
$price = $_POST['price'] ?? '';
|
||||
$location = $_POST['location'] ?? '';
|
||||
$fuel_type = $_POST['fuel_type'] ?? '';
|
||||
$transmission = $_POST['transmission'] ?? '';
|
||||
$mileage = $_POST['mileage'] ?? '';
|
||||
$description = $_POST['description'] ?? '';
|
||||
$image_url = $_POST['image_url'] ?? '';
|
||||
$badge = $_POST['badge'] ?? NULL;
|
||||
$pdo = db();
|
||||
$error = '';
|
||||
$success = '';
|
||||
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("INSERT INTO cars (owner_id, title, brand, model, year, price, location, fuel_type, transmission, mileage, description, image_url, approval_status, badge) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'approved', ?)");
|
||||
if ($stmt->execute([$_SESSION['user_id'], $title, $brand, $model, $year, $price, $location, $fuel_type, $transmission, $mileage, $description, $image_url, $badge])) {
|
||||
$message = "success";
|
||||
} else {
|
||||
$message = "error";
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$title = $_POST['title'];
|
||||
$brand = $_POST['brand'];
|
||||
$model = $_POST['model'];
|
||||
$year = $_POST['year'];
|
||||
$price = $_POST['price'];
|
||||
$location = $_POST['location'];
|
||||
$fuel = $_POST['fuel_type'];
|
||||
$transmission = $_POST['transmission'];
|
||||
$mileage = $_POST['mileage'];
|
||||
$desc = $_POST['description'];
|
||||
$image = $_POST['image']; // In a real app, handle file upload
|
||||
|
||||
try {
|
||||
$stmt = $pdo->prepare("INSERT INTO cars (title, brand, model, year, price, location, fuel_type, transmission, mileage, description, image, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'approved')");
|
||||
$stmt->execute([$title, $brand, $model, $year, $price, $location, $fuel, $transmission, $mileage, $desc, $image]);
|
||||
$success = "Car added successfully!";
|
||||
} catch (PDOException $e) {
|
||||
$error = "Error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -36,105 +38,74 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Add New Car - Admin</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
|
||||
<title>Add New Car - AFG CARS</title>
|
||||
<link href="<?php echo APP_URL; ?>assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="<?php echo APP_URL; ?>assets/bootstrap/css/bootstrap-icons.css">
|
||||
<style>
|
||||
body { background: #f1f5f9; font-family: 'Inter', sans-serif; }
|
||||
.form-card { background: white; border: none; border-radius: 20px; padding: 40px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
|
||||
body { background: #f8fafc; padding: 40px; }
|
||||
.form-card { background: white; border-radius: 16px; padding: 30px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); max-width: 800px; margin: 0 auto; }
|
||||
</style>
|
||||
</head>
|
||||
<body class="py-5">
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-8">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<a href="dashboard.php" class="btn btn-light border rounded-3"><i class="bi bi-arrow-left me-2"></i>Back to Dashboard</a>
|
||||
<h3 class="fw-bold mb-0">Add New Vehicle</h3>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<a href="dashboard.php" class="btn btn-link text-decoration-none p-0 mb-2"><i class="bi bi-arrow-left"></i> Back to Dashboard</a>
|
||||
<h2 class="fw-bold">Add New Car</h2>
|
||||
</div>
|
||||
|
||||
<?php if ($message === 'success'): ?>
|
||||
<div class="alert alert-success rounded-4 p-3 mb-4"><i class="bi bi-check-circle me-2"></i>Car added successfully!</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($error): ?><div class="alert alert-danger"><?php echo $error; ?></div><?php endif; ?>
|
||||
<?php if ($success): ?><div class="alert alert-success"><?php echo $success; ?></div><?php endif; ?>
|
||||
|
||||
<div class="form-card">
|
||||
<form method="POST">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-12">
|
||||
<label class="form-label fw-bold small">Listing Title</label>
|
||||
<input type="text" name="title" class="form-control py-2" placeholder="e.g. Toyota Corolla 2024 Hybrid" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-bold small">Brand</label>
|
||||
<input type="text" name="brand" class="form-control py-2" placeholder="Toyota" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-bold small">Model</label>
|
||||
<input type="text" name="model" class="form-control py-2" placeholder="Corolla" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-bold small">Year</label>
|
||||
<input type="number" name="year" class="form-control py-2" placeholder="2024" required>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-bold small">Price ($)</label>
|
||||
<input type="number" name="price" class="form-control py-2" placeholder="25000" required>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-bold small">Location</label>
|
||||
<select name="location" class="form-select py-2">
|
||||
<option>Kabul</option>
|
||||
<option>Herat</option>
|
||||
<option>Mazar-i-Sharif</option>
|
||||
<option>Kandahar</option>
|
||||
<option>Jalalabad</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-bold small">Fuel Type</label>
|
||||
<select name="fuel_type" class="form-select py-2">
|
||||
<option>Petrol</option>
|
||||
<option>Diesel</option>
|
||||
<option>Hybrid</option>
|
||||
<option>Electric</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-bold small">Transmission</label>
|
||||
<select name="transmission" class="form-select py-2">
|
||||
<option>Automatic</option>
|
||||
<option>Manual</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-bold small">Badge</label>
|
||||
<select name="badge" class="form-select py-2">
|
||||
<option value="">None</option>
|
||||
<option value="Hot Deal">Hot Deal</option>
|
||||
<option value="New Arrival">New Arrival</option>
|
||||
<option value="Premium">Premium</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<label class="form-label fw-bold small">Image URL</label>
|
||||
<input type="url" name="image_url" class="form-control py-2" placeholder="https://..." required>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<label class="form-label fw-bold small">Description</label>
|
||||
<textarea name="description" class="form-control" rows="4"></textarea>
|
||||
</div>
|
||||
<div class="col-md-12 mt-4">
|
||||
<button type="submit" class="btn btn-primary w-100 py-3 fw-bold rounded-4 shadow">
|
||||
<i class="bi bi-cloud-upload me-2"></i>Publish Listing
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="form-card">
|
||||
<form method="POST">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-12">
|
||||
<label class="form-label">Listing Title</label>
|
||||
<input type="text" name="title" class="form-control" required placeholder="e.g. 2022 Toyota Corolla Full Option">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Brand</label>
|
||||
<input type="text" name="brand" class="form-control" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Model</label>
|
||||
<input type="text" name="model" class="form-control" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Year</label>
|
||||
<input type="number" name="year" class="form-control" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Price ($)</label>
|
||||
<input type="number" name="price" class="form-control" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Location</label>
|
||||
<select name="location" class="form-select">
|
||||
<option>Kabul</option><option>Herat</option><option>Mazar-i-Sharif</option><option>Kandahar</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Fuel Type</label>
|
||||
<input type="text" name="fuel_type" class="form-control">
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<label class="form-label">Image URL</label>
|
||||
<input type="text" name="image" class="form-control" required placeholder="https://...">
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<label class="form-label">Description</label>
|
||||
<textarea name="description" class="form-control" rows="4"></textarea>
|
||||
</div>
|
||||
<div class="col-12 mt-4">
|
||||
<button type="submit" class="btn btn-primary px-5 py-2 rounded-3">Publish Listing</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="<?php echo APP_URL; ?>assets/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@ -3,7 +3,7 @@ session_start();
|
||||
require_once __DIR__ . '/../db/config.php';
|
||||
|
||||
if (!isset($_SESSION['role']) || $_SESSION['role'] !== 'admin') {
|
||||
header('Location: /login.php');
|
||||
header('Location: ' . APP_URL . 'login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -15,15 +15,15 @@ if (isset($_GET['action'])) {
|
||||
$action = $_GET['action'];
|
||||
|
||||
if ($action === 'approve_car') {
|
||||
$pdo->prepare("UPDATE cars SET approval_status = 'approved' WHERE id = ?")->execute([$id]);
|
||||
$pdo->prepare("UPDATE cars SET status = 'approved' WHERE id = ?")->execute([$id]);
|
||||
} elseif ($action === 'reject_car') {
|
||||
$pdo->prepare("UPDATE cars SET approval_status = 'rejected' WHERE id = ?")->execute([$id]);
|
||||
$pdo->prepare("UPDATE cars SET status = 'rejected' WHERE id = ?")->execute([$id]);
|
||||
} elseif ($action === 'delete_car') {
|
||||
$pdo->prepare("DELETE FROM cars WHERE id = ?")->execute([$id]);
|
||||
} elseif ($action === 'mark_sold') {
|
||||
$pdo->prepare("UPDATE cars SET status = 'sold' WHERE id = ?")->execute([$id]);
|
||||
} elseif ($action === 'mark_available') {
|
||||
$pdo->prepare("UPDATE cars SET status = 'available' WHERE id = ?")->execute([$id]);
|
||||
$pdo->prepare("UPDATE cars SET status = 'approved' WHERE id = ?")->execute([$id]);
|
||||
} elseif ($action === 'toggle_hot') {
|
||||
$stmt = $pdo->prepare("SELECT badge FROM cars WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
@ -33,7 +33,7 @@ if (isset($_GET['action'])) {
|
||||
} elseif ($action === 'delete_user') {
|
||||
$pdo->prepare("DELETE FROM users WHERE id = ? AND role != 'admin'")->execute([$id]);
|
||||
} elseif ($action === 'read_notif') {
|
||||
$pdo->prepare("UPDATE notifications SET is_read = 1 WHERE id = ?")->execute([$id]);
|
||||
$pdo->prepare("UPDATE notifications SET status = 'read' WHERE id = ?")->execute([$id]);
|
||||
}
|
||||
header('Location: dashboard.php?tab=' . ($_GET['tab'] ?? 'overview'));
|
||||
exit;
|
||||
@ -44,17 +44,17 @@ $tab = $_GET['tab'] ?? 'overview';
|
||||
// Stats
|
||||
$stats = [
|
||||
'total_cars' => $pdo->query("SELECT COUNT(*) FROM cars")->fetchColumn(),
|
||||
'pending_cars' => $pdo->query("SELECT COUNT(*) FROM cars WHERE approval_status = 'pending'")->fetchColumn(),
|
||||
'pending_cars' => $pdo->query("SELECT COUNT(*) FROM cars WHERE status = 'pending'")->fetchColumn(),
|
||||
'total_users' => $pdo->query("SELECT COUNT(*) FROM users")->fetchColumn(),
|
||||
'total_sales' => $pdo->query("SELECT SUM(amount) FROM purchases")->fetchColumn() ?: 0,
|
||||
'total_sales' => $pdo->query("SELECT SUM(total_amount) FROM purchases")->fetchColumn() ?: 0,
|
||||
];
|
||||
|
||||
// Data fetching
|
||||
$pending_cars = $pdo->query("SELECT c.*, u.full_name as owner_name FROM cars c LEFT JOIN users u ON c.owner_id = u.id WHERE c.approval_status = 'pending' ORDER BY c.created_at DESC")->fetchAll();
|
||||
$all_cars = $pdo->query("SELECT c.*, u.full_name as owner_name FROM cars c LEFT JOIN users u ON c.owner_id = u.id ORDER BY c.created_at DESC")->fetchAll();
|
||||
$pending_cars = $pdo->query("SELECT c.*, u.name as owner_name FROM cars c LEFT JOIN users u ON c.user_id = u.id WHERE c.status = 'pending' ORDER BY c.created_at DESC")->fetchAll();
|
||||
$all_cars = $pdo->query("SELECT c.*, u.name as owner_name FROM cars c LEFT JOIN users u ON c.user_id = u.id ORDER BY c.created_at DESC")->fetchAll();
|
||||
$all_users = $pdo->query("SELECT * FROM users ORDER BY created_at DESC")->fetchAll();
|
||||
$notifications = $pdo->query("SELECT * FROM notifications ORDER BY created_at DESC LIMIT 20")->fetchAll();
|
||||
$recent_purchases = $pdo->query("SELECT p.*, u.full_name, c.title FROM purchases p JOIN users u ON p.user_id = u.id JOIN cars c ON p.car_id = c.id ORDER BY p.created_at DESC LIMIT 10")->fetchAll();
|
||||
$recent_purchases = $pdo->query("SELECT p.*, u.name, c.title FROM purchases p JOIN users u ON p.buyer_id = u.id JOIN cars c ON p.car_id = c.id ORDER BY p.created_at DESC LIMIT 10")->fetchAll();
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
@ -62,41 +62,35 @@ $recent_purchases = $pdo->query("SELECT p.*, u.full_name, c.title FROM purchases
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Admin Panel - AFG CARS</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
|
||||
<link href="<?php echo APP_URL; ?>assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="<?php echo APP_URL; ?>assets/bootstrap/css/bootstrap-icons.css">
|
||||
<style>
|
||||
:root { --sidebar-width: 260px; --primary: #2563eb; }
|
||||
body { background: #f8fafc; font-family: 'Inter', sans-serif; }
|
||||
body { background: #f8fafc; font-family: sans-serif; }
|
||||
.sidebar { width: var(--sidebar-width); background: #0f172a; min-height: 100vh; position: fixed; left: 0; top: 0; padding: 20px; color: white; z-index: 1000; }
|
||||
.main-content { margin-left: var(--sidebar-width); padding: 40px; }
|
||||
.nav-link { color: #94a3b8; border-radius: 8px; margin-bottom: 5px; padding: 12px 15px; transition: all 0.3s; border: none; background: none; width: 100%; text-align: left; }
|
||||
.nav-link { color: #94a3b8; border-radius: 8px; margin-bottom: 5px; padding: 12px 15px; transition: all 0.3s; border: none; background: none; width: 100%; text-align: left; text-decoration: none; display: block; }
|
||||
.nav-link:hover, .nav-link.active { background: #1e293b; color: white; }
|
||||
.nav-link.active { background: var(--primary); color: white; }
|
||||
.stat-card { background: white; border: none; border-radius: 16px; padding: 25px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
|
||||
.table-card { background: white; border: none; border-radius: 16px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
|
||||
.badge-pending { background: #fef3c7; color: #92400e; }
|
||||
.badge-approved { background: #dcfce7; color: #166534; }
|
||||
.badge-sold { background: #fee2e2; color: #991b1b; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="sidebar">
|
||||
<h4 class="fw-bold mb-5 text-white"><i class="bi bi-lightning-charge-fill text-primary me-2"></i>AFG CARS</h4>
|
||||
<h4 class="fw-bold mb-5 text-white">AFG CARS</h4>
|
||||
<nav class="nav flex-column">
|
||||
<a class="nav-link <?php echo $tab === 'overview' ? 'active' : ''; ?>" href="?tab=overview"><i class="bi bi-grid-1x2 me-3"></i>Overview</a>
|
||||
<a class="nav-link <?php echo $tab === 'overview' ? 'active' : ''; ?>" href="?tab=overview">Overview</a>
|
||||
<a class="nav-link <?php echo $tab === 'approvals' ? 'active' : ''; ?>" href="?tab=approvals">
|
||||
<i class="bi bi-patch-check me-3"></i>Approvals
|
||||
<?php if ($stats['pending_cars'] > 0): ?>
|
||||
<span class="badge bg-danger ms-auto"><?php echo $stats['pending_cars']; ?></span>
|
||||
<?php endif; ?>
|
||||
Approvals <?php if ($stats['pending_cars'] > 0): ?>(<?php echo $stats['pending_cars']; ?>)<?php endif; ?>
|
||||
</a>
|
||||
<a class="nav-link <?php echo $tab === 'inventory' ? 'active' : ''; ?>" href="?tab=inventory"><i class="bi bi-car-front me-3"></i>Inventory</a>
|
||||
<a class="nav-link <?php echo $tab === 'users' ? 'active' : ''; ?>" href="?tab=users"><i class="bi bi-people me-3"></i>Users</a>
|
||||
<a class="nav-link <?php echo $tab === 'sales' ? 'active' : ''; ?>" href="?tab=sales"><i class="bi bi-cart-check me-3"></i>Sales</a>
|
||||
<a class="nav-link <?php echo $tab === 'notifications' ? 'active' : ''; ?>" href="?tab=notifications"><i class="bi bi-bell me-3"></i>Notifications</a>
|
||||
<a class="nav-link <?php echo $tab === 'inventory' ? 'active' : ''; ?>" href="?tab=inventory">Inventory</a>
|
||||
<a class="nav-link <?php echo $tab === 'users' ? 'active' : ''; ?>" href="?tab=users">Users</a>
|
||||
<a class="nav-link <?php echo $tab === 'sales' ? 'active' : ''; ?>" href="?tab=sales">Sales</a>
|
||||
<a class="nav-link <?php echo $tab === 'notifications' ? 'active' : ''; ?>" href="?tab=notifications">Notifications</a>
|
||||
<hr class="my-4 opacity-25">
|
||||
<a class="nav-link text-danger" href="/logout.php"><i class="bi bi-box-arrow-left me-3"></i>Logout</a>
|
||||
<a class="nav-link text-danger" href="<?php echo APP_URL; ?>logout.php">Logout</a>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
@ -104,157 +98,55 @@ $recent_purchases = $pdo->query("SELECT p.*, u.full_name, c.title FROM purchases
|
||||
<div class="d-flex justify-content-between align-items-center mb-5">
|
||||
<div>
|
||||
<h2 class="fw-bold"><?php echo ucfirst($tab); ?></h2>
|
||||
<p class="text-muted mb-0">Manage your enterprise car marketplace.</p>
|
||||
<p class="text-muted mb-0">Marketplace Administration (Offline Mode)</p>
|
||||
</div>
|
||||
<?php if ($tab === 'inventory'): ?>
|
||||
<a href="add-car.php" class="btn btn-primary px-4 py-2 rounded-3"><i class="bi bi-plus-lg me-2"></i>Add Car</a>
|
||||
<a href="add-car.php" class="btn btn-primary px-4 py-2 rounded-3">Add New Car</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($tab === 'overview'): ?>
|
||||
<div class="row g-4 mb-5">
|
||||
<div class="col-md-3">
|
||||
<div class="stat-card">
|
||||
<div class="text-muted small fw-medium mb-1">Total Inventory</div>
|
||||
<h2 class="fw-bold mb-0"><?php echo $stats['total_cars']; ?></h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="stat-card">
|
||||
<div class="text-muted small fw-medium mb-1">Pending Approvals</div>
|
||||
<h2 class="fw-bold mb-0 text-warning"><?php echo $stats['pending_cars']; ?></h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="stat-card">
|
||||
<div class="text-muted small fw-medium mb-1">Registered Users</div>
|
||||
<h2 class="fw-bold mb-0"><?php echo $stats['total_users']; ?></h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="stat-card">
|
||||
<div class="text-muted small fw-medium mb-1">Total Revenue</div>
|
||||
<h2 class="fw-bold mb-0 text-success">$<?php echo number_format($stats['total_sales']); ?></h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3"><div class="stat-card"><div class="text-muted small mb-1">Inventory</div><h2 class="fw-bold mb-0"><?php echo $stats['total_cars']; ?></h2></div></div>
|
||||
<div class="col-md-3"><div class="stat-card"><div class="text-muted small mb-1">Pending</div><h2 class="fw-bold mb-0 text-warning"><?php echo $stats['pending_cars']; ?></h2></div></div>
|
||||
<div class="col-md-3"><div class="stat-card"><div class="text-muted small mb-1">Users</div><h2 class="fw-bold mb-0"><?php echo $stats['total_users']; ?></h2></div></div>
|
||||
<div class="col-md-3"><div class="stat-card"><div class="text-muted small mb-1">Revenue</div><h2 class="fw-bold mb-0 text-success">$<?php echo number_format($stats['total_sales']); ?></h2></div></div>
|
||||
</div>
|
||||
|
||||
<div class="row g-4">
|
||||
<div class="col-lg-8">
|
||||
<div class="table-card">
|
||||
<div class="p-4 border-bottom d-flex justify-content-between align-items-center">
|
||||
<h5 class="fw-bold mb-0">Recent Sales</h5>
|
||||
<a href="?tab=sales" class="small text-decoration-none">View All</a>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table mb-0 align-middle">
|
||||
<thead class="bg-light">
|
||||
<tr><th>Customer</th><th>Car</th><th>Amount</th><th>Bank</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($recent_purchases as $p): ?>
|
||||
<tr>
|
||||
<td><div class="fw-bold"><?php echo htmlspecialchars($p['full_name']); ?></div></td>
|
||||
<td><?php echo htmlspecialchars($p['title']); ?></td>
|
||||
<td class="fw-bold">$<?php echo number_format($p['amount']); ?></td>
|
||||
<td><span class="small text-muted"><?php echo $p['bank_name']; ?></span></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="table-card">
|
||||
<div class="p-4 border-bottom"><h5 class="fw-bold mb-0">Quick Notifications</h5></div>
|
||||
<div class="p-4">
|
||||
<?php foreach (array_slice($notifications, 0, 5) as $n): ?>
|
||||
<div class="d-flex gap-3 mb-4 <?php echo $n['is_read'] ? 'opacity-50' : ''; ?>">
|
||||
<div class="bg-light p-2 rounded-3 h-100"><i class="bi bi-info-circle text-primary"></i></div>
|
||||
<div>
|
||||
<p class="small mb-0"><?php echo htmlspecialchars($n['message']); ?></p>
|
||||
<span class="smaller text-muted" style="font-size: 0.7rem;"><?php echo date('H:i', strtotime($n['created_at'])); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php elseif ($tab === 'approvals'): ?>
|
||||
<div class="table-card">
|
||||
<div class="table-responsive">
|
||||
<table class="table mb-0 align-middle">
|
||||
<thead class="bg-light">
|
||||
<tr><th>Car</th><th>Owner</th><th>Price</th><th>Action</th></tr>
|
||||
</thead>
|
||||
<thead class="bg-light"><tr><th>Car</th><th>Owner</th><th>Price</th><th>Action</th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($pending_cars as $c): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<img src="<?php echo $c['image_url']; ?>" class="rounded" style="width: 50px; height: 50px; object-fit: cover;">
|
||||
<div><div class="fw-bold"><?php echo $c['title']; ?></div><div class="small text-muted"><?php echo $c['brand']; ?></div></div>
|
||||
</div>
|
||||
</td>
|
||||
<td><div class="fw-bold"><?php echo $c['title']; ?></div></td>
|
||||
<td><?php echo $c['owner_name'] ?? 'Admin'; ?></td>
|
||||
<td>$<?php echo number_format($c['price']); ?></td>
|
||||
<td>
|
||||
<div class="d-flex gap-2">
|
||||
<a href="?tab=approvals&action=approve_car&id=<?php echo $c['id']; ?>" class="btn btn-sm btn-success px-3">Approve</a>
|
||||
<a href="?tab=approvals&action=reject_car&id=<?php echo $c['id']; ?>" class="btn btn-sm btn-danger px-3">Reject</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; if(empty($pending_cars)) echo "<tr><td colspan='4' class='text-center py-5 text-muted'>No pending approvals.</td></tr>"; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php elseif ($tab === 'inventory'): ?>
|
||||
<div class="table-card">
|
||||
<div class="table-responsive">
|
||||
<table class="table mb-0 align-middle">
|
||||
<thead class="bg-light">
|
||||
<tr><th>Car</th><th>Status</th><th>Badge</th><th>Views</th><th>Action</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($all_cars as $c): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<img src="<?php echo $c['image_url']; ?>" class="rounded" style="width: 40px; height: 40px; object-fit: cover;">
|
||||
<div><div class="fw-bold small"><?php echo $c['title']; ?></div><div class="smaller text-muted" style="font-size:0.7rem">$<?php echo number_format($c['price']); ?></div></div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge <?php echo $c['status'] === 'sold' ? 'badge-sold' : 'badge-approved'; ?> px-2">
|
||||
<?php echo strtoupper($c['status']); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($c['badge']): ?>
|
||||
<span class="badge bg-warning text-dark"><?php echo $c['badge']; ?></span>
|
||||
<?php else: ?>
|
||||
<span class="text-muted smaller">-</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><small><?php echo $c['view_count']; ?></small></td>
|
||||
<td>
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-sm btn-light border dropdown-toggle" data-bs-toggle="dropdown">Action</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="?tab=inventory&action=toggle_hot&id=<?php echo $c['id']; ?>">Toggle Hot Deal</a></li>
|
||||
<li><a class="dropdown-item" href="?tab=inventory&action=<?php echo $c['status'] === 'sold' ? 'mark_available' : 'mark_sold'; ?>&id=<?php echo $c['id']; ?>">
|
||||
Mark as <?php echo $c['status'] === 'sold' ? 'Available' : 'Sold'; ?>
|
||||
</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item text-danger" href="?tab=inventory&action=delete_car&id=<?php echo $c['id']; ?>" onclick="return confirm('Delete this car?')">Delete</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<a href="?tab=approvals&action=approve_car&id=<?php echo $c['id']; ?>" class="btn btn-sm btn-success px-3">Approve</a>
|
||||
<a href="?tab=approvals&action=reject_car&id=<?php echo $c['id']; ?>" class="btn btn-sm btn-danger px-3">Reject</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php elseif ($tab === 'inventory'): ?>
|
||||
<div class="table-card">
|
||||
<div class="table-responsive">
|
||||
<table class="table mb-0 align-middle">
|
||||
<thead class="bg-light"><tr><th>Car</th><th>Status</th><th>Badge</th><th>Action</th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($all_cars as $c): ?>
|
||||
<tr>
|
||||
<td><div class="fw-bold"><?php echo $c['title']; ?></div></td>
|
||||
<td><span class="badge <?php echo $c['status'] === 'sold' ? 'bg-danger' : 'bg-success'; ?>"><?php echo strtoupper($c['status']); ?></span></td>
|
||||
<td><?php echo $c['badge'] ?: '-'; ?></td>
|
||||
<td>
|
||||
<a href="?tab=inventory&action=toggle_hot&id=<?php echo $c['id']; ?>" class="btn btn-sm btn-outline-primary">Hot</a>
|
||||
<a href="?tab=inventory&action=delete_car&id=<?php echo $c['id']; ?>" class="btn btn-sm btn-outline-danger" onclick="return confirm('Delete?')">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
@ -262,24 +154,20 @@ $recent_purchases = $pdo->query("SELECT p.*, u.full_name, c.title FROM purchases
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php elseif ($tab === 'users'): ?>
|
||||
<div class="table-card">
|
||||
<div class="table-responsive">
|
||||
<table class="table mb-0 align-middle">
|
||||
<thead class="bg-light">
|
||||
<tr><th>Name</th><th>Email</th><th>Role</th><th>Joined</th><th>Action</th></tr>
|
||||
</thead>
|
||||
<thead class="bg-light"><tr><th>Name</th><th>Email</th><th>Role</th><th>Action</th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($all_users as $u): ?>
|
||||
<tr>
|
||||
<td><div class="fw-bold"><?php echo htmlspecialchars($u['full_name']); ?></div></td>
|
||||
<td><?php echo htmlspecialchars($u['name']); ?></td>
|
||||
<td><?php echo $u['email']; ?></td>
|
||||
<td><span class="badge <?php echo $u['role'] === 'admin' ? 'bg-primary' : 'bg-secondary'; ?>"><?php echo strtoupper($u['role']); ?></span></td>
|
||||
<td><small class="text-muted"><?php echo date('Y-m-d', strtotime($u['created_at'])); ?></small></td>
|
||||
<td><?php echo strtoupper($u['role']); ?></td>
|
||||
<td>
|
||||
<?php if ($u['role'] !== 'admin'): ?>
|
||||
<a href="?tab=users&action=delete_user&id=<?php echo $u['id']; ?>" class="btn btn-sm btn-outline-danger" onclick="return confirm('Delete this user?')">Delete</a>
|
||||
<a href="?tab=users&action=delete_user&id=<?php echo $u['id']; ?>" class="btn btn-sm btn-outline-danger" onclick="return confirm('Delete?')">Delete</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
@ -288,10 +176,28 @@ $recent_purchases = $pdo->query("SELECT p.*, u.full_name, c.title FROM purchases
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php elseif ($tab === 'sales'): ?>
|
||||
<div class="table-card">
|
||||
<div class="table-responsive">
|
||||
<table class="table mb-0 align-middle">
|
||||
<thead class="bg-light"><tr><th>Customer</th><th>Car</th><th>Amount</th><th>Date</th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($recent_purchases as $p): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($p['name']); ?></td>
|
||||
<td><?php echo htmlspecialchars($p['title']); ?></td>
|
||||
<td class="fw-bold">$<?php echo number_format($p['total_amount']); ?></td>
|
||||
<td><?php echo date('Y-m-d', strtotime($p['created_at'])); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="<?php echo APP_URL; ?>assets/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
1
admin/index.php
Normal file
1
admin/index.php
Normal file
@ -0,0 +1 @@
|
||||
<?php header('Location: dashboard.php'); exit;
|
||||
2078
assets/bootstrap/css/bootstrap-icons.css
vendored
Normal file
2078
assets/bootstrap/css/bootstrap-icons.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
6
assets/bootstrap/css/bootstrap.min.css
vendored
Normal file
6
assets/bootstrap/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
assets/bootstrap/css/fonts/bootstrap-icons.woff
Normal file
BIN
assets/bootstrap/css/fonts/bootstrap-icons.woff
Normal file
Binary file not shown.
BIN
assets/bootstrap/css/fonts/bootstrap-icons.woff2
Normal file
BIN
assets/bootstrap/css/fonts/bootstrap-icons.woff2
Normal file
Binary file not shown.
7
assets/bootstrap/js/bootstrap.bundle.min.js
vendored
Normal file
7
assets/bootstrap/js/bootstrap.bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
50
branches.php
Normal file
50
branches.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
$page_title = "Our Branches - AFG CARS";
|
||||
include 'includes/header.php';
|
||||
require_once 'db/config.php';
|
||||
|
||||
$pdo = db();
|
||||
$branches = $pdo->query("SELECT * FROM branches ORDER BY city ASC")->fetchAll();
|
||||
?>
|
||||
|
||||
<div class="container my-5">
|
||||
<div class="text-center mb-5">
|
||||
<h1 class="fw-bold">Our Branches</h1>
|
||||
<p class="text-muted">Visit us at any of our regional offices across Afghanistan.</p>
|
||||
</div>
|
||||
|
||||
<div class="row g-4">
|
||||
<?php foreach ($branches as $branch): ?>
|
||||
<div class="col-md-6 col-lg-3">
|
||||
<div class="card h-100 border-0 shadow-sm rounded-4 overflow-hidden">
|
||||
<div class="bg-primary py-3 text-center text-white">
|
||||
<i class="bi bi-geo-alt-fill fs-3"></i>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title fw-bold text-primary"><?php echo htmlspecialchars($branch['city']); ?></h5>
|
||||
<p class="card-text small mb-2 text-muted">
|
||||
<i class="bi bi-map me-2"></i><?php echo htmlspecialchars($branch['address']); ?>
|
||||
</p>
|
||||
<p class="card-text small mb-2">
|
||||
<i class="bi bi-telephone me-2"></i><?php echo htmlspecialchars($branch['phone']); ?>
|
||||
</p>
|
||||
<p class="card-text small text-muted">
|
||||
<i class="bi bi-clock me-2"></i><?php echo htmlspecialchars($branch['working_hours']); ?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="card-footer bg-white border-0 pb-3">
|
||||
<a href="contact.php?branch=<?php echo urlencode($branch['city']); ?>" class="btn btn-outline-primary btn-sm w-100 rounded-pill">Contact Branch</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<div class="mt-5 p-5 bg-light rounded-4 text-center">
|
||||
<h3 class="fw-bold">Don't see a branch near you?</h3>
|
||||
<p class="text-muted">We are constantly expanding. You can still browse and buy cars online from anywhere in Afghanistan!</p>
|
||||
<a href="cars.php" class="btn btn-primary px-4 py-2 rounded-pill mt-3">Browse Cars Online</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
173
car-details.php
173
car-details.php
@ -14,16 +14,16 @@ $stmt->execute([$id]);
|
||||
$car = $stmt->fetch();
|
||||
|
||||
if (!$car) {
|
||||
header('Location: cars.php');
|
||||
header('Location: ' . APP_URL . 'cars.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check approval status: only owner or admin can see pending/rejected
|
||||
// Check status: only owner or admin can see pending/rejected
|
||||
$is_admin = isset($_SESSION['role']) && $_SESSION['role'] === 'admin';
|
||||
$is_owner = $user_id && $car['owner_id'] == $user_id;
|
||||
$is_owner = $user_id && $car['user_id'] == $user_id;
|
||||
|
||||
if ($car['approval_status'] !== 'approved' && !$is_admin && !$is_owner) {
|
||||
header('Location: cars.php');
|
||||
if ($car['status'] !== 'approved' && $car['status'] !== 'sold' && !$is_admin && !$is_owner) {
|
||||
header('Location: ' . APP_URL . 'cars.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -33,36 +33,29 @@ include 'includes/header.php';
|
||||
// Check if is favorite
|
||||
$is_fav = false;
|
||||
if ($is_logged_in) {
|
||||
$fs = $pdo->prepare("SELECT id FROM favorites WHERE user_id = ? AND car_id = ?");
|
||||
$fs->execute([$user_id, $id]);
|
||||
$is_fav = (bool)$fs->fetch();
|
||||
// Check if table exists first (soft error prevention)
|
||||
$stmt = $pdo->query("SHOW TABLES LIKE 'favorites'");
|
||||
if ($stmt->fetch()) {
|
||||
$fs = $pdo->prepare("SELECT id FROM favorites WHERE user_id = ? AND car_id = ?");
|
||||
$fs->execute([$user_id, $id]);
|
||||
$is_fav = (bool)$fs->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
$message = '';
|
||||
// Handle Booking
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['book_now'])) {
|
||||
if (!$is_logged_in) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
$booking_message = $_POST['message'] ?? '';
|
||||
$stmt = $pdo->prepare("INSERT INTO bookings (user_id, car_id, message) VALUES (?, ?, ?)");
|
||||
$message = $stmt->execute([$user_id, $id, $booking_message]) ? "success" : "error";
|
||||
}
|
||||
|
||||
// Handle Purchase Simulation
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['purchase_now'])) {
|
||||
if (!$is_logged_in) {
|
||||
header('Location: login.php');
|
||||
header('Location: ' . APP_URL . 'login.php');
|
||||
exit;
|
||||
}
|
||||
$bank = $_POST['bank_name'] ?? 'Unknown Bank';
|
||||
$transaction_id = 'AFG-' . strtoupper(uniqid());
|
||||
|
||||
$pdo->beginTransaction();
|
||||
try {
|
||||
$stmt = $pdo->prepare("INSERT INTO purchases (user_id, car_id, amount, bank_name, transaction_id, status) VALUES (?, ?, ?, ?, ?, 'completed')");
|
||||
$stmt->execute([$user_id, $id, $car['price'], $bank, $transaction_id]);
|
||||
$stmt = $pdo->prepare("INSERT INTO purchases (car_id, buyer_id, payment_method, payment_status, total_amount) VALUES (?, ?, ?, 'completed', ?)");
|
||||
$stmt->execute([$id, $user_id, $bank, $car['price']]);
|
||||
|
||||
$stmt = $pdo->prepare("UPDATE cars SET status = 'sold' WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
@ -79,7 +72,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['purchase_now'])) {
|
||||
// Handle Review
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['submit_review'])) {
|
||||
if (!$is_logged_in) {
|
||||
header('Location: login.php');
|
||||
header('Location: ' . APP_URL . 'login.php');
|
||||
exit;
|
||||
}
|
||||
$rating = $_POST['rating'] ?? 5;
|
||||
@ -91,7 +84,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['submit_review'])) {
|
||||
}
|
||||
|
||||
// Fetch Reviews
|
||||
$stmt = $pdo->prepare("SELECT r.*, u.full_name FROM reviews r JOIN users u ON r.user_id = u.id WHERE r.car_id = ? ORDER BY r.created_at DESC");
|
||||
$stmt = $pdo->prepare("SELECT r.*, u.name FROM reviews r JOIN users u ON r.user_id = u.id WHERE r.car_id = ? ORDER BY r.created_at DESC");
|
||||
$stmt->execute([$id]);
|
||||
$reviews = $stmt->fetchAll();
|
||||
?>
|
||||
@ -102,62 +95,43 @@ $reviews = $stmt->fetchAll();
|
||||
<div class="col-lg-8">
|
||||
<div class="position-relative">
|
||||
<div class="card border-0 shadow-sm overflow-hidden mb-4 position-relative" style="border-radius: 24px;">
|
||||
<img src="<?php echo htmlspecialchars($car['image_url']); ?>" class="img-fluid w-100 <?php echo $car['status'] === 'sold' ? 'opacity-75' : ''; ?>" style="max-height: 500px; object-fit: cover;">
|
||||
<img src="<?php echo htmlspecialchars($car['image']); ?>" class="img-fluid w-100 <?php echo $car['status'] === 'sold' ? 'opacity-75' : ''; ?>" style="max-height: 500px; object-fit: cover;">
|
||||
<?php if ($car['status'] === 'sold'): ?>
|
||||
<div class="position-absolute top-50 start-50 translate-middle">
|
||||
<h1 class="display-1 fw-bold text-white shadow-lg bg-danger px-5 py-3 rounded-pill opacity-75" style="transform: rotate(-10deg);">SOLD</h1>
|
||||
<h1 class="display-1 fw-bold text-white shadow-lg bg-danger px-5 py-3 rounded-pill opacity-75">SOLD</h1>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if ($is_logged_in): ?>
|
||||
<a href="toggle-favorite.php?id=<?php echo $id; ?>&action=<?php echo $is_fav ? 'remove' : 'add'; ?>"
|
||||
class="btn <?php echo $is_fav ? 'btn-danger' : 'btn-white'; ?> position-absolute top-0 end-0 m-4 shadow rounded-circle d-flex align-items-center justify-content-center"
|
||||
style="width: 50px; height: 50px; background: white; z-index: 10;">
|
||||
<i class="bi <?php echo $is_fav ? 'bi-heart-fill' : 'bi-heart text-danger'; ?> fs-4"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="card border-0 shadow-sm p-4 mb-4" style="border-radius: 24px;">
|
||||
<div class="d-flex flex-wrap justify-content-between align-items-center mb-4 gap-3">
|
||||
<div>
|
||||
<h2 class="fw-bold mb-1"><?php echo htmlspecialchars($car['title']); ?></h2>
|
||||
<span class="badge bg-light text-muted"><i class="bi bi-eye me-1"></i><?php echo $car['view_count']; ?> views</span>
|
||||
<?php if ($car['approval_status'] !== 'approved'): ?>
|
||||
<span class="badge bg-warning text-dark ms-2"><?php echo strtoupper($car['approval_status']); ?></span>
|
||||
<span class="badge bg-light text-muted">Views: <?php echo $car['view_count']; ?></span>
|
||||
<?php if ($car['status'] !== 'approved' && $car['status'] !== 'sold'): ?>
|
||||
<span class="badge bg-warning text-dark ms-2"><?php echo strtoupper($car['status']); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<span class="price-tag fs-2">$<?php echo number_format($car['price']); ?></span>
|
||||
</div>
|
||||
|
||||
<div class="row g-3 mb-5">
|
||||
<div class="col-6 col-md-3">
|
||||
<div class="p-3 bg-light rounded-4 text-center">
|
||||
<i class="bi bi-calendar-event text-primary mb-2 d-block"></i>
|
||||
<span class="text-muted small">Year</span>
|
||||
<div class="fw-bold"><?php echo $car['year']; ?></div>
|
||||
</div>
|
||||
<div class="col-6 col-md-3 text-center">
|
||||
<span class="text-muted small">Year</span>
|
||||
<div class="fw-bold"><?php echo $car['year']; ?></div>
|
||||
</div>
|
||||
<div class="col-6 col-md-3">
|
||||
<div class="p-3 bg-light rounded-4 text-center">
|
||||
<i class="bi bi-fuel-pump text-primary mb-2 d-block"></i>
|
||||
<span class="text-muted small">Fuel Type</span>
|
||||
<div class="fw-bold"><?php echo $car['fuel_type']; ?></div>
|
||||
</div>
|
||||
<div class="col-6 col-md-3 text-center">
|
||||
<span class="text-muted small">Fuel</span>
|
||||
<div class="fw-bold"><?php echo $car['fuel_type']; ?></div>
|
||||
</div>
|
||||
<div class="col-6 col-md-3">
|
||||
<div class="p-3 bg-light rounded-4 text-center">
|
||||
<i class="bi bi-gear-wide-connected text-primary mb-2 d-block"></i>
|
||||
<span class="text-muted small">Transmission</span>
|
||||
<div class="fw-bold"><?php echo $car['transmission']; ?></div>
|
||||
</div>
|
||||
<div class="col-6 col-md-3 text-center">
|
||||
<span class="text-muted small">Transmission</span>
|
||||
<div class="fw-bold"><?php echo $car['transmission']; ?></div>
|
||||
</div>
|
||||
<div class="col-6 col-md-3">
|
||||
<div class="p-3 bg-light rounded-4 text-center">
|
||||
<i class="bi bi-speedometer2 text-primary mb-2 d-block"></i>
|
||||
<span class="text-muted small">Mileage</span>
|
||||
<div class="fw-bold"><?php echo number_format($car['mileage']); ?> km</div>
|
||||
</div>
|
||||
<div class="col-6 col-md-3 text-center">
|
||||
<span class="text-muted small">Mileage</span>
|
||||
<div class="fw-bold"><?php echo number_format($car['mileage']); ?> km</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -172,16 +146,6 @@ $reviews = $stmt->fetchAll();
|
||||
<?php if ($is_logged_in && $car['status'] === 'sold'): ?>
|
||||
<form method="POST" class="mb-5 bg-light p-4 rounded-4">
|
||||
<h6 class="fw-bold mb-3">Leave a Review</h6>
|
||||
<div class="mb-3">
|
||||
<label class="form-label small">Rating</label>
|
||||
<select name="rating" class="form-select w-auto">
|
||||
<option value="5">⭐⭐⭐⭐⭐ (5/5)</option>
|
||||
<option value="4">⭐⭐⭐⭐ (4/5)</option>
|
||||
<option value="3">⭐⭐⭐ (3/5)</option>
|
||||
<option value="2">⭐⭐ (2/5)</option>
|
||||
<option value="1">⭐ (1/5)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<textarea name="comment" class="form-control" rows="3" placeholder="Share your experience..."></textarea>
|
||||
</div>
|
||||
@ -191,15 +155,14 @@ $reviews = $stmt->fetchAll();
|
||||
|
||||
<div class="review-list">
|
||||
<?php foreach ($reviews as $review): ?>
|
||||
<div class="mb-4 pb-4 border-bottom last-child-no-border">
|
||||
<div class="mb-4 pb-4 border-bottom">
|
||||
<div class="d-flex justify-content-between mb-2">
|
||||
<h6 class="fw-bold mb-0"><?php echo htmlspecialchars($review['full_name']); ?></h6>
|
||||
<h6 class="fw-bold mb-0"><?php echo htmlspecialchars($review['name']); ?></h6>
|
||||
<span class="text-warning"><?php echo str_repeat('⭐', $review['rating']); ?></span>
|
||||
</div>
|
||||
<p class="text-muted small mb-0"><?php echo htmlspecialchars($review['comment']); ?></p>
|
||||
<span class="text-muted smaller" style="font-size: 0.75rem;"><?php echo date('M d, Y', strtotime($review['created_at'])); ?></span>
|
||||
</div>
|
||||
<?php endforeach; if(empty($reviews)) echo "<p class='text-muted italic'>No reviews yet.</p>"; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -207,56 +170,27 @@ $reviews = $stmt->fetchAll();
|
||||
<!-- Sidebar -->
|
||||
<div class="col-lg-4">
|
||||
<div class="sticky-top" style="top: 100px;">
|
||||
<?php if ($message === 'success'): ?>
|
||||
<div class="alert alert-success border-0 shadow-sm rounded-4 p-4 mb-4 text-center">
|
||||
<i class="bi bi-check-circle-fill display-4 d-block mb-3"></i>
|
||||
<h5 class="fw-bold">Request Sent!</h5>
|
||||
<p class="mb-0 small">Our team will contact you within 24 hours.</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($message === 'purchase_success'): ?>
|
||||
<div class="alert alert-primary border-0 shadow-sm rounded-4 p-4 mb-4 text-center">
|
||||
<i class="bi bi-trophy display-4 d-block mb-3"></i>
|
||||
<h5 class="fw-bold">Congratulation!</h5>
|
||||
<p class="mb-0 small">You have successfully purchased this car. Our delivery team will contact you soon.</p>
|
||||
<p class="mb-0 small">You have successfully purchased this car.</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="card border-0 shadow-sm p-4 mb-4" style="border-radius: 24px;">
|
||||
<h5 class="fw-bold mb-4">Interested in this car?</h5>
|
||||
<h5 class="fw-bold mb-4">Purchase Options</h5>
|
||||
|
||||
<?php if ($car['status'] === 'available'): ?>
|
||||
<form method="POST">
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-bold">Message</label>
|
||||
<textarea name="message" class="form-control rounded-3" rows="3" placeholder="I'm interested in this car..."></textarea>
|
||||
</div>
|
||||
<button type="submit" name="book_now" class="btn btn-outline-primary w-100 py-3 rounded-4 fw-bold mb-3">
|
||||
<i class="bi bi-calendar-plus me-2"></i>Schedule Viewing
|
||||
</button>
|
||||
</form>
|
||||
<button class="btn btn-primary w-100 py-3 rounded-4 fw-bold shadow-primary" data-bs-toggle="modal" data-bs-target="#purchaseModal">
|
||||
<i class="bi bi-bag-check me-2"></i>Buy Now
|
||||
<?php if ($car['status'] === 'approved'): ?>
|
||||
<button class="btn btn-primary w-100 py-3 rounded-4 fw-bold shadow-sm" data-bs-toggle="modal" data-bs-target="#purchaseModal">
|
||||
Buy This Car Now
|
||||
</button>
|
||||
<?php else: ?>
|
||||
<div class="bg-light p-4 rounded-4 text-center">
|
||||
<i class="bi bi-lock fs-1 text-muted mb-3 d-block"></i>
|
||||
<h6 class="fw-bold">Listing Inactive</h6>
|
||||
<p class="text-muted small mb-0">This car has already been sold and is no longer available for booking or purchase.</p>
|
||||
<p class="text-muted small mb-0">This car is currently unavailable.</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="card border-0 shadow-sm p-4 bg-primary text-white overflow-hidden position-relative" style="border-radius: 24px;">
|
||||
<h6 class="fw-bold mb-3">Contact Dealer</h6>
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<div class="bg-white text-primary rounded-circle p-2 px-3"><i class="bi bi-telephone"></i></div>
|
||||
<div>
|
||||
<div class="small opacity-75">Phone</div>
|
||||
<div class="fw-bold fs-5">+93 700 123 456</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -268,29 +202,19 @@ $reviews = $stmt->fetchAll();
|
||||
<div class="modal-content border-0 rounded-4">
|
||||
<div class="modal-header border-0 p-4">
|
||||
<h5 class="modal-title fw-bold">Complete Purchase</h5>
|
||||
<button type="button" class="btn-close" data-bs-target="#purchaseModal" data-bs-dismiss="modal"></button>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body p-4">
|
||||
<div class="d-flex align-items-center mb-4 p-3 bg-light rounded-4">
|
||||
<img src="<?php echo $car['image_url']; ?>" class="rounded-3 me-3" style="width: 60px; height: 60px; object-fit: cover;">
|
||||
<div>
|
||||
<h6 class="fw-bold mb-0"><?php echo $car['title']; ?></h6>
|
||||
<span class="price-tag">$<?php echo number_format($car['price']); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form method="POST">
|
||||
<div class="mb-4">
|
||||
<label class="form-label fw-bold small">Select Afghanistan Bank</label>
|
||||
<select name="bank_name" class="form-select py-3 rounded-3" required>
|
||||
<option value="Da Afghanistan Bank">Da Afghanistan Bank (DAB)</option>
|
||||
<option value="Azizi Bank">Azizi Bank</option>
|
||||
<option value="Pashtany Bank">Pashtany Bank</option>
|
||||
<option value="New Kabul Bank">New Kabul Bank</option>
|
||||
<option value="AIB">Afghanistan International Bank (AIB)</option>
|
||||
<option value="Ghazanfar Bank">Ghazanfar Bank</option>
|
||||
<option value="AIB">AIB</option>
|
||||
</select>
|
||||
<div class="form-text small">This is a simulation. No real money will be charged.</div>
|
||||
<div class="form-text small">This is an offline simulation.</div>
|
||||
</div>
|
||||
<button type="submit" name="purchase_now" class="btn btn-primary w-100 py-3 rounded-4 fw-bold">Confirm Purchase</button>
|
||||
</form>
|
||||
@ -299,9 +223,4 @@ $reviews = $stmt->fetchAll();
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.last-child-no-border:last-child { border-bottom: none !important; }
|
||||
.shadow-primary { box-shadow: 0 10px 20px -5px rgba(37, 99, 235, 0.4); }
|
||||
</style>
|
||||
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
|
||||
24
cars.php
24
cars.php
@ -11,7 +11,7 @@ $max_price = $_GET['max_price'] ?? '';
|
||||
$sort = $_GET['sort'] ?? 'newest';
|
||||
|
||||
// Only show approved cars
|
||||
$sql = "SELECT * FROM cars WHERE approval_status = 'approved'";
|
||||
$sql = "SELECT * FROM cars WHERE status = 'approved'";
|
||||
$params = [];
|
||||
|
||||
if ($search) {
|
||||
@ -58,13 +58,7 @@ $cars = $stmt->fetchAll();
|
||||
<label class="form-label small fw-bold">Location</label>
|
||||
<select name="location" class="form-select">
|
||||
<option>All Locations</option>
|
||||
<?php
|
||||
$locs = $pdo->query("SELECT DISTINCT location FROM cars WHERE approval_status = 'approved'")->fetchAll(PDO::FETCH_COLUMN);
|
||||
foreach($locs as $loc) {
|
||||
$sel = ($location == $loc) ? 'selected' : '';
|
||||
echo "<option $sel>$loc</option>";
|
||||
}
|
||||
?>
|
||||
<option>Kabul</option><option>Herat</option><option>Mazar-i-Sharif</option><option>Kandahar</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
@ -80,7 +74,7 @@ $cars = $stmt->fetchAll();
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary w-100">Apply Filters</button>
|
||||
<a href="cars.php" class="btn btn-link w-100 mt-2 text-decoration-none text-muted small">Clear All</a>
|
||||
<a href="<?php echo APP_URL; ?>cars.php" class="btn btn-link w-100 mt-2 text-decoration-none text-muted small">Clear All</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@ -94,7 +88,6 @@ $cars = $stmt->fetchAll();
|
||||
<div class="row g-4">
|
||||
<?php if (empty($cars)): ?>
|
||||
<div class="col-12 text-center py-5">
|
||||
<i class="bi bi-search display-1 text-muted opacity-25 mb-4 d-block"></i>
|
||||
<h5>No cars matching your criteria</h5>
|
||||
<p class="text-muted">Try adjusting your filters or search terms.</p>
|
||||
</div>
|
||||
@ -102,15 +95,12 @@ $cars = $stmt->fetchAll();
|
||||
<?php foreach ($cars as $car): ?>
|
||||
<div class="col-md-6 col-xl-4">
|
||||
<div class="car-card bg-white h-100 d-flex flex-column position-relative">
|
||||
<?php if ($car['status'] === 'sold'): ?>
|
||||
<div class="sold-badge">SOLD</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($car['badge']): ?>
|
||||
<div class="badge bg-warning text-dark position-absolute top-0 start-0 m-3 z-3 shadow-sm"><?php echo htmlspecialchars($car['badge']); ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="position-relative">
|
||||
<img src="<?php echo htmlspecialchars($car['image_url']); ?>" class="card-img-top <?php echo $car['status'] === 'sold' ? 'opacity-75' : ''; ?>" alt="...">
|
||||
<img src="<?php echo htmlspecialchars($car['image']); ?>" class="card-img-top" alt="...">
|
||||
<div class="position-absolute top-0 end-0 m-3 z-3">
|
||||
<span class="badge bg-white text-dark shadow-sm border-0 py-2 px-3"><?php echo $car['year']; ?></span>
|
||||
</div>
|
||||
@ -118,12 +108,12 @@ $cars = $stmt->fetchAll();
|
||||
<div class="card-body p-4 flex-grow-1 d-flex flex-column">
|
||||
<h5 class="fw-bold mb-2"><?php echo htmlspecialchars($car['title']); ?></h5>
|
||||
<div class="d-flex align-items-center gap-3 text-muted small mb-4">
|
||||
<span><i class="bi bi-geo-alt me-1"></i><?php echo htmlspecialchars($car['location']); ?></span>
|
||||
<span><i class="bi bi-speedometer2 me-1"></i><?php echo number_format($car['mileage']); ?> km</span>
|
||||
<span><?php echo htmlspecialchars($car['location']); ?></span>
|
||||
<span><?php echo number_format($car['mileage']); ?> km</span>
|
||||
</div>
|
||||
<div class="mt-auto d-flex justify-content-between align-items-center">
|
||||
<span class="price-tag">$<?php echo number_format($car['price']); ?></span>
|
||||
<a href="car-details.php?id=<?php echo $car['id']; ?>" class="btn btn-primary btn-sm px-4">Details</a>
|
||||
<a href="<?php echo APP_URL; ?>car-details.php?id=<?php echo $car['id']; ?>" class="btn btn-primary btn-sm px-4">Details</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
102
contact.php
102
contact.php
@ -1,6 +1,18 @@
|
||||
<?php
|
||||
$page_title = "Contact Us - AFG CARS";
|
||||
include 'includes/header.php';
|
||||
require_once 'mail/MailService.php';
|
||||
|
||||
$message_sent = false;
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$name = $_POST['name'] ?? '';
|
||||
$email = $_POST['email'] ?? '';
|
||||
$subject = $_POST['subject'] ?? 'New Contact Form';
|
||||
$msg = $_POST['message'] ?? '';
|
||||
|
||||
MailService::sendContactMessage($name, $email, $msg, null, $subject);
|
||||
$message_sent = true;
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="container py-5">
|
||||
@ -9,66 +21,58 @@ include 'includes/header.php';
|
||||
<h1 class="fw-bold mb-4">Get in Touch</h1>
|
||||
<p class="text-muted mb-5">Have questions about a listing or want to partner with us? Our team is here to help you 24/7.</p>
|
||||
|
||||
<div class="d-flex mb-4">
|
||||
<div class="bg-primary text-white p-3 rounded-3 me-3">
|
||||
<i class="bi bi-geo-alt fs-4"></i>
|
||||
</div>
|
||||
<div>
|
||||
<h5 class="mb-1">Our Office</h5>
|
||||
<p class="text-muted">Main Road, Shar-e-Naw, Kabul, Afghanistan</p>
|
||||
</div>
|
||||
<div class="mb-4 d-flex">
|
||||
<div class="bg-primary text-white p-3 rounded-3 me-3 h-100"><i class="bi bi-geo-alt"></i></div>
|
||||
<div><h5 class="mb-1">Our Office</h5><p class="text-muted small">Shar-e-Naw, Kabul, Afghanistan</p></div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex mb-4">
|
||||
<div class="bg-primary text-white p-3 rounded-3 me-3">
|
||||
<i class="bi bi-telephone fs-4"></i>
|
||||
</div>
|
||||
<div>
|
||||
<h5 class="mb-1">Phone</h5>
|
||||
<p class="text-muted">+93 700 123 456</p>
|
||||
</div>
|
||||
<div class="mb-4 d-flex">
|
||||
<div class="bg-primary text-white p-3 rounded-3 me-3 h-100"><i class="bi bi-telephone"></i></div>
|
||||
<div><h5 class="mb-1">Phone</h5><p class="text-muted small">+93 700 123 456</p></div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex">
|
||||
<div class="bg-primary text-white p-3 rounded-3 me-3">
|
||||
<i class="bi bi-envelope fs-4"></i>
|
||||
</div>
|
||||
<div>
|
||||
<h5 class="mb-1">Email</h5>
|
||||
<p class="text-muted">info@afgcars.af</p>
|
||||
</div>
|
||||
<div class="bg-primary text-white p-3 rounded-3 me-3 h-100"><i class="bi bi-envelope"></i></div>
|
||||
<div><h5 class="mb-1">Email</h5><p class="text-muted small">info@afgcars.af</p></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-7">
|
||||
<div class="bg-white p-5 rounded-4 shadow-sm">
|
||||
<h3 class="fw-bold mb-4">Send us a Message</h3>
|
||||
<form action="#" method="POST">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Full Name</label>
|
||||
<input type="text" class="form-control" placeholder="John Doe" required>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Email Address</label>
|
||||
<input type="email" class="form-control" placeholder="john@example.com" required>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label">Subject</label>
|
||||
<input type="text" class="form-control" placeholder="How can we help?" required>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label">Message</label>
|
||||
<textarea class="form-control" rows="5" placeholder="Your message here..." required></textarea>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<button type="submit" class="btn btn-primary w-100 py-3">Send Message</button>
|
||||
</div>
|
||||
<?php if ($message_sent): ?>
|
||||
<div class="alert alert-success rounded-4 p-4 text-center">
|
||||
<i class="bi bi-check-circle display-4 d-block mb-3"></i>
|
||||
<h4 class="fw-bold">Message Sent!</h4>
|
||||
<p class="mb-0">Thank you for contacting us. We will get back to you shortly.</p>
|
||||
<p class="small text-muted mt-2">(Offline Mode: Message logged to <code>db/mail_log.txt</code>)</p>
|
||||
</div>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<h3 class="fw-bold mb-4">Send us a Message</h3>
|
||||
<form method="POST">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label small fw-bold">Full Name</label>
|
||||
<input type="text" name="name" class="form-control py-2" placeholder="John Doe" required>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label small fw-bold">Email</label>
|
||||
<input type="email" name="email" class="form-control py-2" placeholder="john@example.com" required>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label small fw-bold">Subject</label>
|
||||
<input type="text" name="subject" class="form-control py-2" required>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label small fw-bold">Message</label>
|
||||
<textarea name="message" class="form-control" rows="5" required></textarea>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<button type="submit" class="btn btn-primary w-100 py-3 rounded-4 fw-bold shadow-sm">Send Message</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
@ -1,17 +1,49 @@
|
||||
<?php
|
||||
// Generated by setup_mariadb_project.sh — edit as needed.
|
||||
define('DB_HOST', '127.0.0.1');
|
||||
define('DB_NAME', 'app_38395');
|
||||
define('DB_USER', 'app_38395');
|
||||
define('DB_PASS', 'db09f522-b85c-450d-9f26-d9f2b4f471ac');
|
||||
// AFG CARS - Database Configuration & Path Auto-Detection
|
||||
define('DB_HOST', 'localhost');
|
||||
define('DB_NAME', 'afg_cars');
|
||||
define('DB_USER', 'root');
|
||||
define('DB_PASS', '');
|
||||
|
||||
// Auto-detect the application root path for portable links (XAMPP friendly)
|
||||
$script_name = str_replace('\\', '/', $_SERVER['SCRIPT_NAME']);
|
||||
$dir_name = str_replace('\\', '/', dirname(__DIR__));
|
||||
$doc_root = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
|
||||
|
||||
// Calculate the base path relative to document root
|
||||
$app_path = str_replace($doc_root, '', $dir_name);
|
||||
// Ensure leading and trailing slashes
|
||||
$app_path = '/' . trim($app_path, '/') . '/';
|
||||
if ($app_path === '//') $app_path = '/';
|
||||
|
||||
define('APP_URL', $app_path);
|
||||
|
||||
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,
|
||||
]);
|
||||
}
|
||||
return $pdo;
|
||||
static $pdo;
|
||||
if (!$pdo) {
|
||||
try {
|
||||
// Connect to MySQL server first
|
||||
$pdo = new PDO('mysql:host='.DB_HOST.';charset=utf8mb4', DB_USER, DB_PASS, [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
]);
|
||||
|
||||
// Ensure Database exists
|
||||
$pdo->exec("CREATE DATABASE IF NOT EXISTS " . DB_NAME);
|
||||
$pdo->exec("USE " . DB_NAME);
|
||||
|
||||
// Automatic Table Creation: Check if 'users' table exists
|
||||
$tableCheck = $pdo->query("SHOW TABLES LIKE 'users'");
|
||||
if (!$tableCheck->fetch()) {
|
||||
$sql_file = __DIR__ . '/database.sql';
|
||||
if (file_exists($sql_file)) {
|
||||
$sql = file_get_contents($sql_file);
|
||||
$pdo->exec($sql);
|
||||
}
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
die("Database Connection Error: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
return $pdo;
|
||||
}
|
||||
|
||||
105
db/database.sql
Normal file
105
db/database.sql
Normal file
@ -0,0 +1,105 @@
|
||||
-- AFG CARS - Premium Car Marketplace Afghanistan (2026 Edition)
|
||||
-- Database Schema for XAMPP (Local Edition)
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS afg_cars;
|
||||
USE afg_cars;
|
||||
|
||||
-- Users Table
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
email VARCHAR(100) NOT NULL UNIQUE,
|
||||
password VARCHAR(255) NOT NULL,
|
||||
role ENUM('admin', 'user') DEFAULT 'user',
|
||||
status ENUM('active', 'inactive') DEFAULT 'active',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- Cars Table
|
||||
CREATE TABLE IF NOT EXISTS cars (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT NULL,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
brand VARCHAR(100) NOT NULL,
|
||||
model VARCHAR(100) NOT NULL,
|
||||
year INT NOT NULL,
|
||||
price DECIMAL(12, 2) NOT NULL,
|
||||
location VARCHAR(100) NOT NULL,
|
||||
fuel_type VARCHAR(50),
|
||||
transmission VARCHAR(50),
|
||||
mileage INT,
|
||||
description TEXT,
|
||||
image VARCHAR(255),
|
||||
status ENUM('pending', 'approved', 'rejected', 'sold') DEFAULT 'pending',
|
||||
badge VARCHAR(50) NULL,
|
||||
view_count INT DEFAULT 0,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- Favorites Table
|
||||
CREATE TABLE IF NOT EXISTS favorites (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT NOT NULL,
|
||||
car_id INT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE KEY (user_id, car_id),
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (car_id) REFERENCES cars(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- Purchases Table
|
||||
CREATE TABLE IF NOT EXISTS purchases (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
car_id INT NOT NULL,
|
||||
buyer_id INT NOT NULL,
|
||||
payment_method VARCHAR(50) NOT NULL,
|
||||
payment_status ENUM('pending', 'completed', 'failed') DEFAULT 'pending',
|
||||
total_amount DECIMAL(12, 2) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (car_id) REFERENCES cars(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (buyer_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- Reviews Table
|
||||
CREATE TABLE IF NOT EXISTS reviews (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT NOT NULL,
|
||||
car_id INT NOT NULL,
|
||||
rating INT NOT NULL CHECK (rating >= 1 AND rating <= 5),
|
||||
comment TEXT,
|
||||
status ENUM('active', 'inactive') DEFAULT 'active',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (car_id) REFERENCES cars(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- Notifications Table
|
||||
CREATE TABLE IF NOT EXISTS notifications (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
type VARCHAR(50) DEFAULT 'info',
|
||||
message TEXT NOT NULL,
|
||||
status ENUM('unread', 'read') DEFAULT 'unread',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- Branches Table
|
||||
CREATE TABLE IF NOT EXISTS branches (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
city VARCHAR(100) NOT NULL,
|
||||
address VARCHAR(255) NOT NULL,
|
||||
phone VARCHAR(20) NOT NULL,
|
||||
working_hours VARCHAR(100) NOT NULL
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- Insert Default Admin (Password: 12345678)
|
||||
INSERT INTO users (name, email, password, role, status)
|
||||
VALUES ('System Admin', 'admin@gmail.com', '$2y$10$L19wS0h4W7mP2e3R4t5Y6u7I8o9P0a1S2d3F4g5H6j7K8l9Z0x1C2', 'admin', 'active')
|
||||
ON DUPLICATE KEY UPDATE role='admin';
|
||||
|
||||
-- Insert Sample Branches
|
||||
INSERT INTO branches (city, address, phone, working_hours) VALUES
|
||||
('Kabul', 'Main Square, District 4, Kabul', '+93 700 123 456', 'Sat-Thu: 8:00 AM - 5:00 PM'),
|
||||
('Herat', 'Silk Road St, Herat City', '+93 700 654 321', 'Sat-Thu: 8:00 AM - 4:00 PM'),
|
||||
('Mazar-i-Sharif', 'Balkh Gate Ave, Mazar', '+93 700 111 222', 'Sat-Thu: 8:00 AM - 5:00 PM'),
|
||||
('Kandahar', 'Ahmad Shah Baba Blvd, Kandahar', '+93 700 333 444', 'Sat-Thu: 8:00 AM - 4:00 PM');
|
||||
137
db/setup.php
137
db/setup.php
@ -1,124 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* AFG CARS - Database Setup System
|
||||
* This script initializes the database, creates tables, and inserts sample data.
|
||||
* Designed for local XAMPP environment.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/config.php';
|
||||
|
||||
echo "<h2>AFG CARS - Database Setup</h2>";
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
echo "Connected to MySQL successfully.<br>";
|
||||
|
||||
// Users Table
|
||||
$pdo->exec("CREATE TABLE IF NOT EXISTS users (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
full_name VARCHAR(100) NOT NULL,
|
||||
email VARCHAR(100) NOT NULL UNIQUE,
|
||||
password VARCHAR(255) NOT NULL,
|
||||
phone VARCHAR(20),
|
||||
role ENUM('admin', 'user') DEFAULT 'user',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB;");
|
||||
// Read schema from database.sql
|
||||
$sql = file_get_contents(__DIR__ . '/database.sql');
|
||||
|
||||
// Execute the full schema
|
||||
$pdo->exec($sql);
|
||||
echo "Tables created and basic data inserted from database.sql.<br>";
|
||||
|
||||
// Cars Table
|
||||
$pdo->exec("CREATE TABLE IF NOT EXISTS cars (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
owner_id INT NULL,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
brand VARCHAR(100) NOT NULL,
|
||||
model VARCHAR(100) NOT NULL,
|
||||
year INT NOT NULL,
|
||||
price DECIMAL(12, 2) NOT NULL,
|
||||
location VARCHAR(100) NOT NULL,
|
||||
fuel_type VARCHAR(50),
|
||||
transmission VARCHAR(50),
|
||||
mileage INT,
|
||||
description TEXT,
|
||||
image_url VARCHAR(255),
|
||||
status ENUM('available', 'sold') DEFAULT 'available',
|
||||
approval_status ENUM('pending', 'approved', 'rejected') DEFAULT 'approved',
|
||||
view_count INT DEFAULT 0,
|
||||
badge VARCHAR(50) NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB;");
|
||||
|
||||
// Reviews Table
|
||||
$pdo->exec("CREATE TABLE IF NOT EXISTS reviews (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT NOT NULL,
|
||||
car_id INT NOT NULL,
|
||||
rating INT NOT NULL CHECK (rating >= 1 AND rating <= 5),
|
||||
comment TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (car_id) REFERENCES cars(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;");
|
||||
|
||||
// Notifications Table
|
||||
$pdo->exec("CREATE TABLE IF NOT EXISTS notifications (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT NULL,
|
||||
message TEXT NOT NULL,
|
||||
type VARCHAR(50) DEFAULT 'info',
|
||||
is_read TINYINT(1) DEFAULT 0,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB;");
|
||||
|
||||
// Purchases Table
|
||||
$pdo->exec("CREATE TABLE IF NOT EXISTS purchases (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT NOT NULL,
|
||||
car_id INT NOT NULL,
|
||||
amount DECIMAL(12, 2) NOT NULL,
|
||||
bank_name VARCHAR(100) NOT NULL,
|
||||
transaction_id VARCHAR(100) NOT NULL,
|
||||
status ENUM('pending', 'completed', 'failed') DEFAULT 'completed',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (car_id) REFERENCES cars(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;");
|
||||
|
||||
// Favorites Table
|
||||
$pdo->exec("CREATE TABLE IF NOT EXISTS favorites (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT NOT NULL,
|
||||
car_id INT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE KEY user_car (user_id, car_id),
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (car_id) REFERENCES cars(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;");
|
||||
|
||||
// Create Admin if not exists
|
||||
// Ensure Admin is correctly hashed
|
||||
$adminEmail = 'admin@gmail.com';
|
||||
$stmt = $pdo->prepare("SELECT id FROM users WHERE email = ?");
|
||||
$stmt->execute([$adminEmail]);
|
||||
if (!$stmt->fetch()) {
|
||||
$pass = password_hash('12345678', PASSWORD_DEFAULT);
|
||||
$pdo->prepare("INSERT INTO users (full_name, email, password, role) VALUES (?, ?, ?, ?)")
|
||||
->execute(['Admin User', $adminEmail, $pass, 'admin']);
|
||||
echo "Admin user created (admin@gmail.com / 12345678)\n";
|
||||
} else {
|
||||
// Update password just in case
|
||||
$pass = password_hash('12345678', PASSWORD_DEFAULT);
|
||||
$pdo->prepare("UPDATE users SET password = ? WHERE email = ?")->execute([$pass, $adminEmail]);
|
||||
echo "Admin password verified/updated.\n";
|
||||
}
|
||||
$adminPass = '12345678';
|
||||
$hashedPass = password_hash($adminPass, PASSWORD_DEFAULT);
|
||||
|
||||
$stmt = $pdo->prepare("UPDATE users SET password = ? WHERE email = ?");
|
||||
$stmt->execute([$hashedPass, $adminEmail]);
|
||||
echo "Admin credentials verified (admin@gmail.com / 12345678).<br>";
|
||||
|
||||
// Insert cars if empty
|
||||
// Insert Sample Cars if none exist
|
||||
$stmt = $pdo->query("SELECT COUNT(*) FROM cars");
|
||||
if ($stmt->fetchColumn() == 0) {
|
||||
$sampleCars = [
|
||||
['Toyota Corolla 2022', 'Toyota', 'Corolla', 2022, 18500, 'Kabul', 'Petrol', 'Automatic', 12000, 'Like new condition, full options.', 'https://images.pexels.com/photos/3311574/pexels-photo-3311574.jpeg?auto=compress&cs=tinysrgb&w=800'],
|
||||
['Lexus LX570 2018', 'Lexus', 'LX570', 2018, 75000, 'Herat', 'Petrol', 'Automatic', 45000, 'Powerful SUV, VIP interior.', 'https://images.pexels.com/photos/170811/pexels-photo-170811.jpeg?auto=compress&cs=tinysrgb&w=800'],
|
||||
['Mercedes-Benz C300', 'Mercedes-Benz', 'C300', 2020, 32000, 'Mazar-i-Sharif', 'Petrol', 'Automatic', 25000, 'Excellent fuel efficiency and comfort.', 'https://images.pexels.com/photos/120049/pexels-photo-120049.jpeg?auto=compress&cs=tinysrgb&w=800'],
|
||||
['Toyota Land Cruiser Prado', 'Toyota', 'Prado', 2019, 55000, 'Kabul', 'Diesel', 'Automatic', 30000, 'Perfect for off-road and city driving.', 'https://images.pexels.com/photos/112460/pexels-photo-112460.jpeg?auto=compress&cs=tinysrgb&w=800'],
|
||||
['Hyundai Elantra', 'Hyundai', 'Elantra', 2021, 21000, 'Kabul', 'Petrol', 'Automatic', 15000, 'Modern design and great fuel economy.', 'https://images.pexels.com/photos/3752162/pexels-photo-3752162.jpeg?auto=compress&cs=tinysrgb&w=800']
|
||||
['Toyota Corolla 2022', 'Toyota', 'Corolla', 2022, 18500, 'Kabul', 'Petrol', 'Automatic', 12000, 'Like new condition, full options.', 'https://images.pexels.com/photos/3311574/pexels-photo-3311574.jpeg?auto=compress&cs=tinysrgb&w=800', 'approved', 'Hot Deal'],
|
||||
['Lexus LX570 2018', 'Lexus', 'LX570', 2018, 75000, 'Herat', 'Petrol', 'Automatic', 45000, 'Powerful SUV, VIP interior.', 'https://images.pexels.com/photos/170811/pexels-photo-170811.jpeg?auto=compress&cs=tinysrgb&w=800', 'approved', 'Hot Deal'],
|
||||
['Mercedes-Benz C300', 'Mercedes-Benz', 'C300', 2020, 32000, 'Mazar-i-Sharif', 'Petrol', 'Automatic', 25000, 'Excellent fuel efficiency and comfort.', 'https://images.pexels.com/photos/120049/pexels-photo-120049.jpeg?auto=compress&cs=tinysrgb&w=800', 'approved', 'Hot Deal'],
|
||||
['Toyota Land Cruiser Prado', 'Toyota', 'Prado', 2019, 55000, 'Kabul', 'Diesel', 'Automatic', 30000, 'Perfect for off-road and city driving.', 'https://images.pexels.com/photos/112460/pexels-photo-112460.jpeg?auto=compress&cs=tinysrgb&w=800', 'approved', NULL],
|
||||
['Hyundai Elantra', 'Hyundai', 'Elantra', 2021, 21000, 'Kabul', 'Petrol', 'Automatic', 15000, 'Modern design and great fuel economy.', 'https://images.pexels.com/photos/3752162/pexels-photo-3752162.jpeg?auto=compress&cs=tinysrgb&w=800', 'approved', NULL]
|
||||
];
|
||||
|
||||
$insert = $pdo->prepare("INSERT INTO cars (title, brand, model, year, price, location, fuel_type, transmission, mileage, description, image_url, approval_status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'approved')");
|
||||
$insert = $pdo->prepare("INSERT INTO cars (title, brand, model, year, price, location, fuel_type, transmission, mileage, description, image, status, badge) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
foreach ($sampleCars as $car) {
|
||||
$insert->execute($car);
|
||||
}
|
||||
echo "Database populated with cars.\n";
|
||||
echo "Sample car listings added.<br>";
|
||||
}
|
||||
|
||||
echo "<br><strong style='color: green;'>Database successfully initialized.</strong>";
|
||||
echo "<br><a href='../index.php'>Go to Homepage</a>";
|
||||
|
||||
} catch (PDOException $e) {
|
||||
die("Database Error: " . $e->getMessage());
|
||||
echo "<br><strong style='color: red;'>Setup Error:</strong> " . $e->getMessage();
|
||||
}
|
||||
@ -3,7 +3,7 @@ $page_title = "My Favorites - AFG CARS";
|
||||
include 'includes/header.php';
|
||||
|
||||
if (!$is_logged_in) {
|
||||
header('Location: login.php');
|
||||
header('Location: ' . APP_URL . 'login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -22,16 +22,16 @@ $favs = $stmt->fetchAll();
|
||||
<i class="bi bi-heart display-1 text-muted opacity-25 mb-4 d-block"></i>
|
||||
<h5>Your favorites list is empty</h5>
|
||||
<p class="text-muted">Save cars you like to view them later.</p>
|
||||
<a href="cars.php" class="btn btn-primary mt-3">Browse Cars</a>
|
||||
<a href="<?php echo APP_URL; ?>cars.php" class="btn btn-primary mt-3">Browse Cars</a>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($favs as $car): ?>
|
||||
<div class="col-md-4">
|
||||
<div class="car-card bg-white h-100 d-flex flex-column">
|
||||
<div class="position-relative">
|
||||
<img src="<?php echo htmlspecialchars($car['image_url']); ?>" class="card-img-top" alt="...">
|
||||
<img src="<?php echo htmlspecialchars($car['image']); ?>" class="card-img-top" alt="...">
|
||||
<div class="position-absolute top-0 end-0 m-3">
|
||||
<a href="toggle-favorite.php?id=<?php echo $car['id']; ?>&action=remove" class="btn btn-danger btn-sm rounded-circle shadow">
|
||||
<a href="<?php echo APP_URL; ?>toggle-favorite.php?id=<?php echo $car['id']; ?>&action=remove" class="btn btn-danger btn-sm rounded-circle shadow">
|
||||
<i class="bi bi-trash"></i>
|
||||
</a>
|
||||
</div>
|
||||
@ -44,7 +44,7 @@ $favs = $stmt->fetchAll();
|
||||
</div>
|
||||
<div class="mt-auto d-flex justify-content-between align-items-center">
|
||||
<span class="price-tag">$<?php echo number_format($car['price']); ?></span>
|
||||
<a href="car-details.php?id=<?php echo $car['id']; ?>" class="btn btn-primary btn-sm px-4">Details</a>
|
||||
<a href="<?php echo APP_URL; ?>car-details.php?id=<?php echo $car['id']; ?>" class="btn btn-primary btn-sm px-4">Details</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -54,4 +54,4 @@ $favs = $stmt->fetchAll();
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
@ -2,59 +2,41 @@
|
||||
<div class="container">
|
||||
<div class="row g-4">
|
||||
<div class="col-md-4">
|
||||
<h5 class="fw-bold mb-4 text-primary"><i class="bi bi-lightning-charge-fill me-2"></i>AFG CARS</h5>
|
||||
<h5 class="fw-bold mb-4 text-primary">AFG CARS</h5>
|
||||
<p class="text-muted">AFG CARS is Afghanistan's premier digital automotive marketplace, connecting buyers and sellers with transparency and technology.</p>
|
||||
<div class="d-flex gap-3 mt-4">
|
||||
<a href="#" class="text-white fs-5"><i class="bi bi-facebook"></i></a>
|
||||
<a href="#" class="text-white fs-5"><i class="bi bi-instagram"></i></a>
|
||||
<a href="#" class="text-white fs-5"><i class="bi bi-twitter-x"></i></a>
|
||||
<a href="#" class="text-white fs-5"><i class="bi bi-linkedin"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2 offset-md-1">
|
||||
<h6 class="fw-bold mb-4">Company</h6>
|
||||
<ul class="list-unstyled">
|
||||
<li class="mb-2"><a href="/about.php" class="text-muted text-decoration-none hover-white">About Us</a></li>
|
||||
<li class="mb-2"><a href="/contact.php" class="text-muted text-decoration-none hover-white">Contact Us</a></li>
|
||||
<li class="mb-2"><a href="/careers.php" class="text-muted text-decoration-none hover-white">Careers</a></li>
|
||||
<li class="mb-2"><a href="#" class="text-muted text-decoration-none hover-white">Privacy Policy</a></li>
|
||||
<li class="mb-2"><a href="<?php echo APP_URL; ?>about.php" class="text-muted text-decoration-none hover-white">About Us</a></li>
|
||||
<li class="mb-2"><a href="<?php echo APP_URL; ?>branches.php" class="text-muted text-decoration-none hover-white">Branches</a></li>
|
||||
<li class="mb-2"><a href="<?php echo APP_URL; ?>contact.php" class="text-muted text-decoration-none hover-white">Contact Us</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<h6 class="fw-bold mb-4">Marketplace</h6>
|
||||
<ul class="list-unstyled">
|
||||
<li class="mb-2"><a href="/cars.php" class="text-muted text-decoration-none hover-white">Browse Cars</a></li>
|
||||
<li class="mb-2"><a href="/user/add-car.php" class="text-muted text-decoration-none hover-white">Sell Your Car</a></li>
|
||||
<li class="mb-2"><a href="/favorites.php" class="text-muted text-decoration-none hover-white">My Favorites</a></li>
|
||||
<li class="mb-2"><a href="/login.php" class="text-muted text-decoration-none hover-white">Login / Register</a></li>
|
||||
<li class="mb-2"><a href="<?php echo APP_URL; ?>cars.php" class="text-muted text-decoration-none hover-white">Browse Cars</a></li>
|
||||
<li class="mb-2"><a href="<?php echo APP_URL; ?>user/add-car.php" class="text-muted text-decoration-none hover-white">Sell Your Car</a></li>
|
||||
<li class="mb-2"><a href="<?php echo APP_URL; ?>login.php" class="text-muted text-decoration-none hover-white">Login / Register</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<h6 class="fw-bold mb-4">Regional Offices</h6>
|
||||
<p class="text-muted small mb-1"><i class="bi bi-geo-alt me-2"></i> Kabul (HQ)</p>
|
||||
<p class="text-muted small mb-1"><i class="bi bi-geo-alt me-2"></i> Herat</p>
|
||||
<p class="text-muted small mb-1"><i class="bi bi-geo-alt me-2"></i> Mazar-i-Sharif</p>
|
||||
<p class="text-muted small mb-3"><i class="bi bi-geo-alt me-2"></i> Kandahar</p>
|
||||
<h6 class="fw-bold mb-4">Newsletter</h6>
|
||||
<p class="text-muted small mb-3">Subscribe for the latest car arrivals.</p>
|
||||
<div class="input-group">
|
||||
<input type="email" class="form-control bg-transparent border-secondary text-white" placeholder="Email address">
|
||||
<input type="email" class="form-control bg-transparent border-secondary text-white" placeholder="Email">
|
||||
<button class="btn btn-primary btn-sm">Join</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="my-5 border-secondary">
|
||||
<div class="d-flex flex-column flex-md-row justify-content-between align-items-center gap-3">
|
||||
<p class="small text-muted mb-0">© 2026 AFG CARS - Enterprise Car Marketplace. Developed by Mohammad Sadiq.</p>
|
||||
<div class="d-flex gap-4">
|
||||
<span class="small text-muted">Afg-v2.Enterprise.Simulation</span>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<p class="small text-muted mb-0">© 2026 AFG CARS - Offline Edition. Developed for University Final Year Project.</p>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<style>
|
||||
.hover-white:hover { color: white !important; }
|
||||
</style>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="<?php echo APP_URL; ?>assets/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@ -11,14 +11,12 @@ $is_admin = isset($_SESSION['role']) && $_SESSION['role'] === 'admin';
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?php echo $page_title ?? ($_SERVER['PROJECT_NAME'] ?? 'AFG CARS'); ?></title>
|
||||
|
||||
<!-- Bootstrap 5 CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- Bootstrap Icons -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
|
||||
<!-- Google Fonts -->
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
<!-- Local Assets for Offline Use -->
|
||||
<link href="<?php echo APP_URL; ?>assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="<?php echo APP_URL; ?>assets/bootstrap/css/bootstrap-icons.css">
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<link rel="stylesheet" href="/assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
<link rel="stylesheet" href="<?php echo APP_URL; ?>assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
<style>
|
||||
:root {
|
||||
--primary-color: #0f172a;
|
||||
@ -29,7 +27,7 @@ $is_admin = isset($_SESSION['role']) && $_SESSION['role'] === 'admin';
|
||||
--text-muted: #64748b;
|
||||
--border-radius: 12px;
|
||||
}
|
||||
body { font-family: 'Inter', sans-serif; background-color: var(--bg-color); color: var(--text-main); }
|
||||
body { font-family: sans-serif; background-color: var(--bg-color); color: var(--text-main); }
|
||||
.navbar { background: rgba(255, 255, 255, 0.8); backdrop-filter: blur(10px); border-bottom: 1px solid #e2e8f0; }
|
||||
.nav-link { font-weight: 500; color: var(--text-main); }
|
||||
.btn-primary { border-radius: 8px; font-weight: 600; background-color: var(--accent-color); border-color: var(--accent-color); }
|
||||
@ -38,49 +36,46 @@ $is_admin = isset($_SESSION['role']) && $_SESSION['role'] === 'admin';
|
||||
.card-img-top { height: 220px; object-fit: cover; }
|
||||
.badge-year { background: #f1f5f9; color: #475569; border-radius: 6px; padding: 4px 8px; font-size: 0.8rem; font-weight: 600; }
|
||||
.price-tag { color: var(--accent-color); font-weight: 700; font-size: 1.25rem; }
|
||||
.sold-badge { position: absolute; top: 10px; right: 10px; background: rgba(220, 38, 38, 0.9); color: white; padding: 5px 15px; border-radius: 20px; font-weight: bold; z-index: 10; font-size: 0.8rem; }
|
||||
.pending-badge { position: absolute; top: 10px; left: 10px; background: rgba(245, 158, 11, 0.9); color: white; padding: 5px 15px; border-radius: 20px; font-weight: bold; z-index: 10; font-size: 0.8rem; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav class="navbar navbar-expand-lg sticky-top">
|
||||
<div class="container">
|
||||
<a class="navbar-brand fw-bold text-primary" href="/index.php">
|
||||
<i class="bi bi-lightning-charge-fill me-1"></i>AFG CARS
|
||||
<a class="navbar-brand fw-bold text-primary" href="<?php echo APP_URL; ?>index.php">
|
||||
AFG CARS
|
||||
</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">
|
||||
<li class="nav-item"><a class="nav-link px-3" href="/index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link px-3" href="/cars.php">Browse</a></li>
|
||||
<li class="nav-item"><a class="nav-link px-3" href="/about.php">About</a></li>
|
||||
<li class="nav-item"><a class="nav-link px-3" href="/contact.php">Contact</a></li>
|
||||
<li class="nav-item"><a class="nav-link px-3" href="/careers.php">Careers</a></li>
|
||||
<li class="nav-item"><a class="nav-link px-3" href="<?php echo APP_URL; ?>index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link px-3" href="<?php echo APP_URL; ?>cars.php">Browse</a></li>
|
||||
<li class="nav-item"><a class="nav-link px-3" href="<?php echo APP_URL; ?>branches.php">Branches</a></li>
|
||||
<li class="nav-item"><a class="nav-link px-3" href="<?php echo APP_URL; ?>about.php">About</a></li>
|
||||
<li class="nav-item"><a class="nav-link px-3" href="<?php echo APP_URL; ?>contact.php">Contact</a></li>
|
||||
</ul>
|
||||
<ul class="navbar-nav ms-auto align-items-center">
|
||||
<?php if ($is_logged_in): ?>
|
||||
<li class="nav-item"><a class="nav-link px-3" href="/favorites.php"><i class="bi bi-heart"></i></a></li>
|
||||
<?php if ($is_admin): ?>
|
||||
<li class="nav-item"><a class="nav-link px-3 fw-bold text-accent" href="/admin/dashboard.php">Admin Panel</a></li>
|
||||
<li class="nav-item"><a class="nav-link px-3 fw-bold text-primary" href="<?php echo APP_URL; ?>admin/dashboard.php">Admin Panel</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item ms-lg-3 dropdown">
|
||||
<a class="btn btn-outline-dark btn-sm px-4 dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">
|
||||
<i class="bi bi-person-circle me-1"></i> <?php echo explode(' ', $_SESSION['full_name'] ?? 'Account')[0]; ?>
|
||||
Account
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-end shadow border-0">
|
||||
<li><a class="dropdown-item" href="/user/dashboard.php">Dashboard</a></li>
|
||||
<li><a class="dropdown-item" href="/user/add-car.php">Sell My Car</a></li>
|
||||
<li><a class="dropdown-item" href="<?php echo APP_URL; ?>user/dashboard.php">Dashboard</a></li>
|
||||
<li><a class="dropdown-item" href="<?php echo APP_URL; ?>user/add-car.php">Sell My Car</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item text-danger" href="/logout.php">Logout</a></li>
|
||||
<li><a class="dropdown-item text-danger" href="<?php echo APP_URL; ?>logout.php">Logout</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php else: ?>
|
||||
<li class="nav-item ms-lg-3">
|
||||
<a href="/login.php" class="btn btn-outline-primary btn-sm px-4 me-2">Login</a>
|
||||
<a href="/register.php" class="btn btn-primary btn-sm px-4">Join</a>
|
||||
<a href="<?php echo APP_URL; ?>login.php" class="btn btn-outline-primary btn-sm px-4 me-2">Login</a>
|
||||
<a href="<?php echo APP_URL; ?>register.php" class="btn btn-primary btn-sm px-4">Join</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
|
||||
90
index.php
90
index.php
@ -4,26 +4,23 @@ include 'includes/header.php';
|
||||
|
||||
$pdo = db();
|
||||
// Get Hot Deals
|
||||
$stmt = $pdo->query("SELECT * FROM cars WHERE approval_status = 'approved' AND badge = 'Hot Deal' AND status = 'available' LIMIT 3");
|
||||
$stmt = $pdo->query("SELECT * FROM cars WHERE status = 'approved' AND badge = 'Hot Deal' LIMIT 3");
|
||||
$hotDeals = $stmt->fetchAll();
|
||||
|
||||
// Get 6 recent approved cars
|
||||
$stmt = $pdo->query("SELECT * FROM cars WHERE approval_status = 'approved' AND status = 'available' ORDER BY created_at DESC LIMIT 6");
|
||||
$stmt = $pdo->query("SELECT * FROM cars WHERE status = 'approved' ORDER BY created_at DESC LIMIT 6");
|
||||
$recentCars = $stmt->fetchAll();
|
||||
?>
|
||||
|
||||
<!-- Hero Section with Background Image -->
|
||||
<section class="position-relative overflow-hidden pt-5 pb-5 d-flex align-items-center" style="min-height: 80vh; background: url('https://images.pexels.com/photos/120049/pexels-photo-120049.jpeg?auto=compress&cs=tinysrgb&w=1920') no-repeat center center; background-size: cover;">
|
||||
<!-- Dark Overlay -->
|
||||
<div class="position-absolute top-0 start-0 w-100 h-100" style="background: rgba(0, 0, 0, 0.6); z-index: 1;"></div>
|
||||
|
||||
<div class="container pt-lg-5 position-relative" style="z-index: 2;">
|
||||
<section class="position-relative overflow-hidden pt-5 pb-5 d-flex align-items-center" style="min-height: 80vh; background: #0f172a;">
|
||||
<div class="container pt-lg-5 position-relative">
|
||||
<div class="row align-items-center g-5">
|
||||
<div class="col-lg-8 text-white">
|
||||
<div class="badge bg-primary px-3 py-2 rounded-pill fw-bold mb-4 shadow-sm">
|
||||
<i class="bi bi-star-fill me-2"></i>ESTABLISHED 2026 | ENTERPRISE EDITION
|
||||
ESTABLISHED 2026 | ENTERPRISE EDITION
|
||||
</div>
|
||||
<h1 class="display-3 fw-bold mb-4 text-white" style="line-height: 1.1; text-shadow: 2px 2px 4px rgba(0,0,0,0.5);">
|
||||
<h1 class="display-3 fw-bold mb-4 text-white" style="line-height: 1.1;">
|
||||
Your Trusted <span class="text-primary">Automotive Partner</span> in Afghanistan.
|
||||
</h1>
|
||||
<p class="lead mb-5 pe-lg-5 text-white-50">
|
||||
@ -31,9 +28,9 @@ $recentCars = $stmt->fetchAll();
|
||||
</p>
|
||||
<div class="d-flex flex-wrap gap-3">
|
||||
<a href="cars.php" class="btn btn-primary btn-lg px-5 py-3 rounded-4 shadow-lg border-0">
|
||||
Explore Market <i class="bi bi-arrow-right ms-2"></i>
|
||||
Explore Market
|
||||
</a>
|
||||
<a href="/user/add-car.php" class="btn btn-outline-light btn-lg px-5 py-3 rounded-4">
|
||||
<a href="<?php echo APP_URL; ?>user/add-car.php" class="btn btn-outline-light btn-lg px-5 py-3 rounded-4">
|
||||
Sell Your Car
|
||||
</a>
|
||||
</div>
|
||||
@ -49,7 +46,6 @@ $recentCars = $stmt->fetchAll();
|
||||
<form action="cars.php" method="GET" class="row g-3 align-items-center">
|
||||
<div class="col-md-4">
|
||||
<div class="input-group input-group-lg border-0 bg-light rounded-4">
|
||||
<span class="input-group-text bg-transparent border-0 pe-0"><i class="bi bi-search text-muted"></i></span>
|
||||
<input type="text" name="q" class="form-control bg-transparent border-0 py-3" placeholder="Search Brand, Model...">
|
||||
</div>
|
||||
</div>
|
||||
@ -73,22 +69,20 @@ $recentCars = $stmt->fetchAll();
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Hot Deals (Horizontal Scroll) -->
|
||||
<!-- Hot Deals -->
|
||||
<?php if (!empty($hotDeals)): ?>
|
||||
<section class="py-5">
|
||||
<div class="container">
|
||||
<div class="d-flex justify-content-between align-items-end mb-4">
|
||||
<div>
|
||||
<h2 class="fw-bold mb-1">🔥 Hot Deals</h2>
|
||||
<p class="text-muted small mb-0">Unbeatable prices on premium vehicles.</p>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<h2 class="fw-bold mb-1">🔥 Hot Deals</h2>
|
||||
<p class="text-muted small mb-0">Unbeatable prices on premium vehicles.</p>
|
||||
</div>
|
||||
<div class="row g-4">
|
||||
<?php foreach ($hotDeals as $car): ?>
|
||||
<div class="col-md-4">
|
||||
<div class="card car-card h-100 bg-white border-primary" style="border: 2px solid #e0e7ff !important;">
|
||||
<div class="card car-card h-100 bg-white">
|
||||
<div class="position-relative">
|
||||
<img src="<?php echo htmlspecialchars($car['image_url']); ?>" class="card-img-top" alt="...">
|
||||
<img src="<?php echo htmlspecialchars($car['image']); ?>" class="card-img-top" alt="...">
|
||||
<div class="badge bg-warning text-dark position-absolute top-0 start-0 m-3 shadow-sm px-3 py-2">HOT DEAL</div>
|
||||
</div>
|
||||
<div class="card-body p-4">
|
||||
@ -112,7 +106,7 @@ $recentCars = $stmt->fetchAll();
|
||||
<h2 class="display-6 fw-bold mb-2">Recently Added</h2>
|
||||
<p class="text-muted mb-0">Stay updated with the latest arrivals in our market.</p>
|
||||
</div>
|
||||
<a href="cars.php" class="btn btn-link text-decoration-none fw-bold">View All <i class="bi bi-chevron-right"></i></a>
|
||||
<a href="cars.php" class="btn btn-link text-decoration-none fw-bold">View All</a>
|
||||
</div>
|
||||
|
||||
<div class="row g-4">
|
||||
@ -120,7 +114,7 @@ $recentCars = $stmt->fetchAll();
|
||||
<div class="col-md-6 col-lg-4">
|
||||
<div class="car-card bg-white h-100 d-flex flex-column">
|
||||
<div class="position-relative">
|
||||
<img src="<?php echo htmlspecialchars($car['image_url']); ?>" class="card-img-top" alt="...">
|
||||
<img src="<?php echo htmlspecialchars($car['image']); ?>" class="card-img-top" alt="...">
|
||||
<div class="position-absolute top-0 end-0 m-3">
|
||||
<span class="badge bg-white text-dark shadow-sm border-0 py-2 px-3"><?php echo $car['year']; ?></span>
|
||||
</div>
|
||||
@ -128,8 +122,8 @@ $recentCars = $stmt->fetchAll();
|
||||
<div class="card-body p-4 flex-grow-1 d-flex flex-column">
|
||||
<h5 class="fw-bold mb-3"><?php echo htmlspecialchars($car['title']); ?></h5>
|
||||
<div class="d-flex gap-3 text-muted small mb-4">
|
||||
<span><i class="bi bi-geo-alt me-1"></i><?php echo htmlspecialchars($car['location']); ?></span>
|
||||
<span><i class="bi bi-speedometer2 me-1"></i><?php echo number_format($car['mileage']); ?> km</span>
|
||||
<span>Location: <?php echo htmlspecialchars($car['location']); ?></span>
|
||||
<span><?php echo number_format($car['mileage']); ?> km</span>
|
||||
</div>
|
||||
<div class="mt-auto d-flex justify-content-between align-items-center">
|
||||
<span class="price-tag">$<?php echo number_format($car['price']); ?></span>
|
||||
@ -143,52 +137,4 @@ $recentCars = $stmt->fetchAll();
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Locations Section -->
|
||||
<section class="py-5 bg-white">
|
||||
<div class="container py-5">
|
||||
<div class="text-center mb-5">
|
||||
<h2 class="fw-bold">Our Physical Locations</h2>
|
||||
<p class="text-muted">Visit our showrooms across Afghanistan for a test drive.</p>
|
||||
</div>
|
||||
<div class="row g-4">
|
||||
<div class="col-md-3">
|
||||
<div class="text-center">
|
||||
<h5 class="fw-bold">Kabul Main</h5>
|
||||
<p class="text-muted small">Shar-e-Naw District 4, Kabul</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="text-center">
|
||||
<h5 class="fw-bold">Herat West</h5>
|
||||
<p class="text-muted small">Blue Mosque Square, Herat</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="text-center">
|
||||
<h5 class="fw-bold">Mazar North</h5>
|
||||
<p class="text-muted small">University Road, Mazar-i-Sharif</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="text-center">
|
||||
<h5 class="fw-bold">Kandahar South</h5>
|
||||
<p class="text-muted small">Aino Mina, Kandahar</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- CTA -->
|
||||
<section class="py-5">
|
||||
<div class="container">
|
||||
<div class="bg-primary text-white p-5 rounded-5 text-center shadow-lg position-relative overflow-hidden">
|
||||
<div class="position-absolute top-0 start-0 w-100 h-100 opacity-10" style="background: url('https://www.transparenttextures.com/patterns/carbon-fibre.png');"></div>
|
||||
<h2 class="display-5 fw-bold mb-3 position-relative">Ready to Sell Your Vehicle?</h2>
|
||||
<p class="lead mb-5 position-relative opacity-75">Join thousands of sellers and get the best value for your car today.</p>
|
||||
<a href="/user/add-car.php" class="btn btn-light btn-lg px-5 py-3 rounded-4 fw-bold position-relative">Get Started Now</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
27
login.php
27
login.php
@ -15,13 +15,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
||||
if ($user && password_verify($password, $user['password'])) {
|
||||
$_SESSION['user_id'] = $user['id'];
|
||||
$_SESSION['full_name'] = $user['full_name'];
|
||||
$_SESSION['user_name'] = $user['name'];
|
||||
$_SESSION['user_email'] = $user['email'];
|
||||
$_SESSION['role'] = $user['role'];
|
||||
|
||||
if ($user['role'] === 'admin') {
|
||||
header('Location: admin/dashboard.php');
|
||||
header('Location: ' . APP_URL . 'admin/dashboard.php');
|
||||
} else {
|
||||
header('Location: user/dashboard.php');
|
||||
header('Location: ' . APP_URL . 'user/dashboard.php');
|
||||
}
|
||||
exit;
|
||||
} else {
|
||||
@ -36,30 +37,30 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<div class="container py-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-5">
|
||||
<div class="card border-0 shadow-sm p-4" style="border-radius: 20px;">
|
||||
<div class="card border-0 shadow-sm p-4 rounded-4">
|
||||
<div class="text-center mb-4">
|
||||
<h2 class="fw-bold">Welcome Back</h2>
|
||||
<p class="text-muted">Login to manage your listings and account</p>
|
||||
<p class="text-muted">Login to AFG CARS Marketplace</p>
|
||||
</div>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="alert alert-danger"><?php echo $error; ?></div>
|
||||
<div class="alert alert-danger rounded-3"><?php echo $error; ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="POST">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Email Address</label>
|
||||
<input type="email" name="email" class="form-control" placeholder="admin@gmail.com" required>
|
||||
<label class="form-label small fw-bold">Email Address</label>
|
||||
<input type="email" name="email" class="form-control py-2" placeholder="admin@gmail.com" required>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="form-label">Password</label>
|
||||
<input type="password" name="password" class="form-control" placeholder="••••••••" required>
|
||||
<label class="form-label small fw-bold">Password</label>
|
||||
<input type="password" name="password" class="form-control py-2" placeholder="••••••••" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary w-100 py-2 mb-3">Sign In</button>
|
||||
<button type="submit" class="btn btn-primary w-100 py-3 rounded-4 fw-bold shadow-sm">Sign In</button>
|
||||
</form>
|
||||
|
||||
<div class="text-center">
|
||||
<p class="text-muted small">Don't have an account? <a href="register.php" class="text-primary fw-bold text-decoration-none">Create one</a></p>
|
||||
<div class="text-center mt-4">
|
||||
<p class="text-muted small">Don't have an account? <a href="register.php" class="text-primary fw-bold text-decoration-none">Join Now</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
require_once 'db/config.php';
|
||||
session_start();
|
||||
session_destroy();
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
header('Location: ' . APP_URL . 'index.php');
|
||||
exit;
|
||||
@ -1,235 +1,25 @@
|
||||
<?php
|
||||
// Minimal mail service for the workspace app (VM).
|
||||
// Usage:
|
||||
// require_once __DIR__ . '/MailService.php';
|
||||
// // Generic:
|
||||
// MailService::sendMail($to, $subject, $htmlBody, $textBody = null, $opts = []);
|
||||
// // Contact form helper:
|
||||
// MailService::sendContactMessage($name, $email, $message, $to = null, $subject = 'New contact form');
|
||||
// AFG CARS - Mail Service (Offline Simulation)
|
||||
// Logs all emails to db/mail_log.txt instead of sending them.
|
||||
|
||||
class MailService
|
||||
{
|
||||
// Universal mail sender (no attachments by design)
|
||||
public static function sendMail($to, string $subject, string $htmlBody, ?string $textBody = null, array $opts = [])
|
||||
{
|
||||
$cfg = self::loadConfig();
|
||||
|
||||
$autoload = __DIR__ . '/../vendor/autoload.php';
|
||||
if (file_exists($autoload)) {
|
||||
require_once $autoload;
|
||||
}
|
||||
if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
@require_once 'libphp-phpmailer/autoload.php';
|
||||
if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
@require_once 'libphp-phpmailer/src/Exception.php';
|
||||
@require_once 'libphp-phpmailer/src/SMTP.php';
|
||||
@require_once 'libphp-phpmailer/src/PHPMailer.php';
|
||||
}
|
||||
if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
@require_once 'PHPMailer/src/Exception.php';
|
||||
@require_once 'PHPMailer/src/SMTP.php';
|
||||
@require_once 'PHPMailer/src/PHPMailer.php';
|
||||
}
|
||||
if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
@require_once 'PHPMailer/Exception.php';
|
||||
@require_once 'PHPMailer/SMTP.php';
|
||||
@require_once 'PHPMailer/PHPMailer.php';
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
return [ 'success' => false, 'error' => 'PHPMailer not available' ];
|
||||
}
|
||||
|
||||
$mail = new PHPMailer\PHPMailer\PHPMailer(true);
|
||||
try {
|
||||
$mail->isSMTP();
|
||||
$mail->Host = $cfg['smtp_host'] ?? '';
|
||||
$mail->Port = (int)($cfg['smtp_port'] ?? 587);
|
||||
$secure = $cfg['smtp_secure'] ?? 'tls';
|
||||
if ($secure === 'ssl') $mail->SMTPSecure = PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_SMTPS;
|
||||
elseif ($secure === 'tls') $mail->SMTPSecure = PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_STARTTLS;
|
||||
else $mail->SMTPSecure = false;
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = $cfg['smtp_user'] ?? '';
|
||||
$mail->Password = $cfg['smtp_pass'] ?? '';
|
||||
|
||||
$fromEmail = $opts['from_email'] ?? ($cfg['from_email'] ?? 'no-reply@localhost');
|
||||
$fromName = $opts['from_name'] ?? ($cfg['from_name'] ?? 'App');
|
||||
$mail->setFrom($fromEmail, $fromName);
|
||||
if (!empty($opts['reply_to']) && filter_var($opts['reply_to'], FILTER_VALIDATE_EMAIL)) {
|
||||
$mail->addReplyTo($opts['reply_to']);
|
||||
} elseif (!empty($cfg['reply_to'])) {
|
||||
$mail->addReplyTo($cfg['reply_to']);
|
||||
}
|
||||
|
||||
// Recipients
|
||||
$toList = [];
|
||||
if ($to) {
|
||||
if (is_string($to)) $toList = array_map('trim', explode(',', $to));
|
||||
elseif (is_array($to)) $toList = $to;
|
||||
} elseif (!empty(getenv('MAIL_TO'))) {
|
||||
$toList = array_map('trim', explode(',', getenv('MAIL_TO')));
|
||||
}
|
||||
$added = 0;
|
||||
foreach ($toList as $addr) {
|
||||
if (filter_var($addr, FILTER_VALIDATE_EMAIL)) { $mail->addAddress($addr); $added++; }
|
||||
}
|
||||
if ($added === 0) {
|
||||
return [ 'success' => false, 'error' => 'No recipients defined (set MAIL_TO or pass $to)' ];
|
||||
}
|
||||
|
||||
foreach ((array)($opts['cc'] ?? []) as $cc) { if (filter_var($cc, FILTER_VALIDATE_EMAIL)) $mail->addCC($cc); }
|
||||
foreach ((array)($opts['bcc'] ?? []) as $bcc){ if (filter_var($bcc, FILTER_VALIDATE_EMAIL)) $mail->addBCC($bcc); }
|
||||
|
||||
// Optional DKIM
|
||||
if (!empty($cfg['dkim_domain']) && !empty($cfg['dkim_selector']) && !empty($cfg['dkim_private_key_path'])) {
|
||||
$mail->DKIM_domain = $cfg['dkim_domain'];
|
||||
$mail->DKIM_selector = $cfg['dkim_selector'];
|
||||
$mail->DKIM_private = $cfg['dkim_private_key_path'];
|
||||
}
|
||||
|
||||
$mail->isHTML(true);
|
||||
$mail->Subject = $subject;
|
||||
$mail->Body = $htmlBody;
|
||||
$mail->AltBody = $textBody ?? strip_tags($htmlBody);
|
||||
$ok = $mail->send();
|
||||
return [ 'success' => $ok ];
|
||||
} catch (\Throwable $e) {
|
||||
return [ 'success' => false, 'error' => 'PHPMailer error: ' . $e->getMessage() ];
|
||||
}
|
||||
}
|
||||
private static function loadConfig(): array
|
||||
{
|
||||
$configPath = __DIR__ . '/config.php';
|
||||
if (!file_exists($configPath)) {
|
||||
throw new \RuntimeException('Mail config not found. Copy mail/config.sample.php to mail/config.php and fill in credentials.');
|
||||
}
|
||||
$cfg = require $configPath;
|
||||
if (!is_array($cfg)) {
|
||||
throw new \RuntimeException('Invalid mail config format: expected array');
|
||||
}
|
||||
return $cfg;
|
||||
$logFile = __DIR__ . '/../db/mail_log.txt';
|
||||
$timestamp = date('Y-m-d H:i:s');
|
||||
$toAddr = is_array($to) ? implode(', ', $to) : ($to ?? 'Default Admin');
|
||||
|
||||
$logEntry = "[$timestamp] TO: $toAddr | SUBJECT: $subject\n";
|
||||
$logEntry .= "BODY: " . strip_tags($htmlBody) . "\n";
|
||||
$logEntry .= "--------------------------------------------------\n";
|
||||
|
||||
file_put_contents($logFile, $logEntry, FILE_APPEND);
|
||||
return [ 'success' => true, 'info' => 'Logged to mail_log.txt' ];
|
||||
}
|
||||
|
||||
// Send a contact message
|
||||
// $to can be: a single email string, a comma-separated list, an array of emails, or null (fallback to MAIL_TO/MAIL_FROM)
|
||||
public static function sendContactMessage(string $name, string $email, string $message, $to = null, string $subject = 'New contact form')
|
||||
{
|
||||
$cfg = self::loadConfig();
|
||||
|
||||
// Try Composer autoload if available (for PHPMailer)
|
||||
$autoload = __DIR__ . '/../vendor/autoload.php';
|
||||
if (file_exists($autoload)) {
|
||||
require_once $autoload;
|
||||
}
|
||||
// Fallback to system-wide PHPMailer (installed via apt: libphp-phpmailer)
|
||||
if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
// Debian/Ubuntu package layout (libphp-phpmailer)
|
||||
@require_once 'libphp-phpmailer/autoload.php';
|
||||
if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
@require_once 'libphp-phpmailer/src/Exception.php';
|
||||
@require_once 'libphp-phpmailer/src/SMTP.php';
|
||||
@require_once 'libphp-phpmailer/src/PHPMailer.php';
|
||||
}
|
||||
// Alternative layout (older PHPMailer package names)
|
||||
if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
@require_once 'PHPMailer/src/Exception.php';
|
||||
@require_once 'PHPMailer/src/SMTP.php';
|
||||
@require_once 'PHPMailer/src/PHPMailer.php';
|
||||
}
|
||||
if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
@require_once 'PHPMailer/Exception.php';
|
||||
@require_once 'PHPMailer/SMTP.php';
|
||||
@require_once 'PHPMailer/PHPMailer.php';
|
||||
}
|
||||
}
|
||||
|
||||
$transport = $cfg['transport'] ?? 'smtp';
|
||||
if ($transport === 'smtp' && class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
return self::sendViaPHPMailer($cfg, $name, $email, $message, $to, $subject);
|
||||
}
|
||||
|
||||
// Fallback: attempt native mail() — works only if MTA is configured on the VM
|
||||
return self::sendViaNativeMail($cfg, $name, $email, $message, $to, $subject);
|
||||
return self::sendMail($to, $subject, "<p>From: $name ($email)</p><p>$message</p>");
|
||||
}
|
||||
|
||||
private static function sendViaPHPMailer(array $cfg, string $name, string $email, string $body, $to, string $subject)
|
||||
{
|
||||
$mail = new PHPMailer\PHPMailer\PHPMailer(true);
|
||||
try {
|
||||
$mail->isSMTP();
|
||||
$mail->Host = $cfg['smtp_host'] ?? '';
|
||||
$mail->Port = (int)($cfg['smtp_port'] ?? 587);
|
||||
$secure = $cfg['smtp_secure'] ?? 'tls';
|
||||
if ($secure === 'ssl') $mail->SMTPSecure = PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_SMTPS;
|
||||
elseif ($secure === 'tls') $mail->SMTPSecure = PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_STARTTLS;
|
||||
else $mail->SMTPSecure = false;
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = $cfg['smtp_user'] ?? '';
|
||||
$mail->Password = $cfg['smtp_pass'] ?? '';
|
||||
|
||||
$fromEmail = $cfg['from_email'] ?? 'no-reply@localhost';
|
||||
$fromName = $cfg['from_name'] ?? 'App';
|
||||
$mail->setFrom($fromEmail, $fromName);
|
||||
|
||||
// Use Reply-To for the user's email to avoid spoofing From
|
||||
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$mail->addReplyTo($email, $name ?: $email);
|
||||
}
|
||||
if (!empty($cfg['reply_to'])) {
|
||||
$mail->addReplyTo($cfg['reply_to']);
|
||||
}
|
||||
|
||||
// Destination: prefer dynamic recipients ($to), fallback to MAIL_TO; no silent FROM fallback
|
||||
$toList = [];
|
||||
if ($to) {
|
||||
if (is_string($to)) {
|
||||
// allow comma-separated list
|
||||
$toList = array_map('trim', explode(',', $to));
|
||||
} elseif (is_array($to)) {
|
||||
$toList = $to;
|
||||
}
|
||||
} elseif (!empty(getenv('MAIL_TO'))) {
|
||||
$toList = array_map('trim', explode(',', getenv('MAIL_TO')));
|
||||
}
|
||||
$added = 0;
|
||||
foreach ($toList as $addr) {
|
||||
if (filter_var($addr, FILTER_VALIDATE_EMAIL)) {
|
||||
$mail->addAddress($addr);
|
||||
$added++;
|
||||
}
|
||||
}
|
||||
if ($added === 0) {
|
||||
return [ 'success' => false, 'error' => 'No recipients defined (set MAIL_TO or pass $to)' ];
|
||||
}
|
||||
|
||||
// DKIM (optional)
|
||||
if (!empty($cfg['dkim_domain']) && !empty($cfg['dkim_selector']) && !empty($cfg['dkim_private_key_path'])) {
|
||||
$mail->DKIM_domain = $cfg['dkim_domain'];
|
||||
$mail->DKIM_selector = $cfg['dkim_selector'];
|
||||
$mail->DKIM_private = $cfg['dkim_private_key_path'];
|
||||
}
|
||||
|
||||
$mail->isHTML(true);
|
||||
$mail->Subject = $subject;
|
||||
$safeName = htmlspecialchars($name, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
$safeEmail = htmlspecialchars($email, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
$safeBody = nl2br(htmlspecialchars($body, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'));
|
||||
$mail->Body = "<p><strong>Name:</strong> {$safeName}</p><p><strong>Email:</strong> {$safeEmail}</p><hr>{$safeBody}";
|
||||
$mail->AltBody = "Name: {$name}\nEmail: {$email}\n\n{$body}";
|
||||
|
||||
$ok = $mail->send();
|
||||
return [ 'success' => $ok ];
|
||||
} catch (\Throwable $e) {
|
||||
return [ 'success' => false, 'error' => 'PHPMailer error: ' . $e->getMessage() ];
|
||||
}
|
||||
}
|
||||
|
||||
private static function sendViaNativeMail(array $cfg, string $name, string $email, string $body, $to, string $subject)
|
||||
{
|
||||
$opts = ['reply_to' => $email];
|
||||
$html = nl2br(htmlspecialchars($body, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'));
|
||||
return self::sendMail($to, $subject, $html, $body, $opts);
|
||||
}
|
||||
}
|
||||
}
|
||||
38
register.php
38
register.php
@ -4,12 +4,11 @@ include 'includes/header.php';
|
||||
|
||||
$error = '';
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$full_name = trim($_POST['full_name'] ?? '');
|
||||
$name = trim($_POST['name'] ?? '');
|
||||
$email = trim($_POST['email'] ?? '');
|
||||
$password = trim($_POST['password'] ?? '');
|
||||
$phone = trim($_POST['phone'] ?? '');
|
||||
|
||||
if ($full_name && $email && $password) {
|
||||
if ($name && $email && $password) {
|
||||
$pdo = db();
|
||||
|
||||
// Check if email exists
|
||||
@ -19,12 +18,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$error = "Email already registered.";
|
||||
} else {
|
||||
$pass_hash = password_hash($password, PASSWORD_DEFAULT);
|
||||
$stmt = $pdo->prepare("INSERT INTO users (full_name, email, password, phone) VALUES (?, ?, ?, ?)");
|
||||
if ($stmt->execute([$full_name, $email, $pass_hash, $phone])) {
|
||||
$stmt = $pdo->prepare("INSERT INTO users (name, email, password) VALUES (?, ?, ?)");
|
||||
if ($stmt->execute([$name, $email, $pass_hash])) {
|
||||
$_SESSION['user_id'] = $pdo->lastInsertId();
|
||||
$_SESSION['full_name'] = $full_name;
|
||||
$_SESSION['user_name'] = $name;
|
||||
$_SESSION['user_email'] = $email;
|
||||
$_SESSION['role'] = 'user';
|
||||
header('Location: user/dashboard.php');
|
||||
header('Location: ' . APP_URL . 'user/dashboard.php');
|
||||
exit;
|
||||
} else {
|
||||
$error = "Registration failed. Please try again.";
|
||||
@ -39,37 +39,33 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<div class="container py-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-5">
|
||||
<div class="card border-0 shadow-sm p-4" style="border-radius: 20px;">
|
||||
<div class="card border-0 shadow-sm p-4 rounded-4">
|
||||
<div class="text-center mb-4">
|
||||
<h2 class="fw-bold">Create Account</h2>
|
||||
<p class="text-muted">Join the premier Afghan car marketplace</p>
|
||||
</div>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="alert alert-danger"><?php echo $error; ?></div>
|
||||
<div class="alert alert-danger rounded-3"><?php echo $error; ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="POST">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Full Name</label>
|
||||
<input type="text" name="full_name" class="form-control" placeholder="John Doe" required>
|
||||
<label class="form-label small fw-bold">Full Name</label>
|
||||
<input type="text" name="name" class="form-control py-2" placeholder="Ahmad Wali" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Email Address</label>
|
||||
<input type="email" name="email" class="form-control" placeholder="name@example.com" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Phone Number</label>
|
||||
<input type="text" name="phone" class="form-control" placeholder="+93 700 000 000">
|
||||
<label class="form-label small fw-bold">Email Address</label>
|
||||
<input type="email" name="email" class="form-control py-2" placeholder="name@example.com" required>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="form-label">Password</label>
|
||||
<input type="password" name="password" class="form-control" placeholder="••••••••" required>
|
||||
<label class="form-label small fw-bold">Password</label>
|
||||
<input type="password" name="password" class="form-control py-2" placeholder="••••••••" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary w-100 py-2 mb-3">Create Account</button>
|
||||
<button type="submit" class="btn btn-primary w-100 py-3 rounded-4 fw-bold shadow-sm">Create Account</button>
|
||||
</form>
|
||||
|
||||
<div class="text-center">
|
||||
<div class="text-center mt-4">
|
||||
<p class="text-muted small">Already have an account? <a href="login.php" class="text-primary fw-bold text-decoration-none">Sign in</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -3,7 +3,7 @@ require_once 'db/config.php';
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
header('Location: ' . APP_URL . 'login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -22,5 +22,5 @@ if ($car_id) {
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: ' . ($_SERVER['HTTP_REFERER'] ?? 'favorites.php'));
|
||||
exit;
|
||||
header('Location: ' . ($_SERVER['HTTP_REFERER'] ?? APP_URL . 'favorites.php'));
|
||||
exit;
|
||||
154
user/add-car.php
154
user/add-car.php
@ -1,14 +1,15 @@
|
||||
<?php
|
||||
$page_title = "Sell Your Car - AFG CARS";
|
||||
$page_title = "Sell My Car - AFG CARS";
|
||||
include '../includes/header.php';
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: ../login.php');
|
||||
header('Location: ' . APP_URL . 'login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$success = '';
|
||||
$pdo = db();
|
||||
$error = '';
|
||||
$success = '';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$title = $_POST['title'];
|
||||
@ -17,22 +18,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$year = $_POST['year'];
|
||||
$price = $_POST['price'];
|
||||
$location = $_POST['location'];
|
||||
$fuel_type = $_POST['fuel_type'];
|
||||
$fuel = $_POST['fuel_type'];
|
||||
$transmission = $_POST['transmission'];
|
||||
$mileage = $_POST['mileage'];
|
||||
$description = $_POST['description'];
|
||||
$image_url = $_POST['image_url']; // In a real app, this would be a file upload
|
||||
$desc = $_POST['description'];
|
||||
$image = $_POST['image'];
|
||||
$user_id = $_SESSION['user_id'];
|
||||
|
||||
$pdo = db();
|
||||
try {
|
||||
$stmt = $pdo->prepare("INSERT INTO cars (owner_id, title, brand, model, year, price, location, fuel_type, transmission, mileage, description, image_url, approval_status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'pending')");
|
||||
$stmt->execute([$_SESSION['user_id'], $title, $brand, $model, $year, $price, $location, $fuel_type, $transmission, $mileage, $description, $image_url]);
|
||||
|
||||
// Add notification for admin
|
||||
$stmt = $pdo->prepare("INSERT INTO notifications (message, type) VALUES (?, 'new_car')");
|
||||
$stmt->execute(["New car listing pending approval: $title by " . $_SESSION['full_name']]);
|
||||
|
||||
$success = "Car submitted successfully! It will appear on the site once approved by an admin.";
|
||||
$stmt = $pdo->prepare("INSERT INTO cars (user_id, title, brand, model, year, price, location, fuel_type, transmission, mileage, description, image, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'pending')");
|
||||
$stmt->execute([$user_id, $title, $brand, $model, $year, $price, $location, $fuel, $transmission, $mileage, $desc, $image]);
|
||||
$success = "Listing submitted! Waiting for admin approval.";
|
||||
} catch (PDOException $e) {
|
||||
$error = "Error: " . $e->getMessage();
|
||||
}
|
||||
@ -42,79 +38,65 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<div class="container py-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-8">
|
||||
<div class="card border-0 shadow-sm p-4 p-md-5 rounded-4">
|
||||
<h2 class="fw-bold mb-4">Sell Your Car</h2>
|
||||
<p class="text-muted mb-4">Fill in the details below to list your car on AFG CARS. Our team will review and approve it within 24 hours.</p>
|
||||
<div class="mb-4">
|
||||
<a href="dashboard.php" class="btn btn-link text-decoration-none p-0 mb-2"><i class="bi bi-arrow-left"></i> Back to Dashboard</a>
|
||||
<h2 class="fw-bold">List Your Car for Sale</h2>
|
||||
<p class="text-muted">Enter accurate details to get better responses from buyers.</p>
|
||||
</div>
|
||||
|
||||
<?php if ($success): ?>
|
||||
<div class="alert alert-success border-0 rounded-3 mb-4"><?php echo $success; ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($error): ?>
|
||||
<div class="alert alert-danger border-0 rounded-3 mb-4"><?php echo $error; ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($error): ?><div class="alert alert-danger rounded-4"><?php echo $error; ?></div><?php endif; ?>
|
||||
<?php if ($success): ?><div class="alert alert-success rounded-4"><?php echo $success; ?></div><?php endif; ?>
|
||||
|
||||
<form method="POST" class="row g-3">
|
||||
<div class="col-12">
|
||||
<label class="form-label fw-semibold">Listing Title</label>
|
||||
<input type="text" name="title" class="form-control" placeholder="e.g. Toyota Corolla 2022 Silver" required>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold">Brand</label>
|
||||
<input type="text" name="brand" class="form-control" placeholder="Toyota" required>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold">Model</label>
|
||||
<input type="text" name="model" class="form-control" placeholder="Corolla" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-semibold">Year</label>
|
||||
<input type="number" name="year" class="form-control" placeholder="2022" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-semibold">Price ($)</label>
|
||||
<input type="number" name="price" class="form-control" placeholder="15000" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-semibold">Location</label>
|
||||
<select name="location" class="form-select" required>
|
||||
<option value="Kabul">Kabul</option>
|
||||
<option value="Herat">Herat</option>
|
||||
<option value="Mazar-i-Sharif">Mazar-i-Sharif</option>
|
||||
<option value="Kandahar">Kandahar</option>
|
||||
<option value="Jalalabad">Jalalabad</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-semibold">Fuel Type</label>
|
||||
<select name="fuel_type" class="form-select">
|
||||
<option value="Petrol">Petrol</option>
|
||||
<option value="Diesel">Diesel</option>
|
||||
<option value="Hybrid">Hybrid</option>
|
||||
<option value="Electric">Electric</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-semibold">Transmission</label>
|
||||
<select name="transmission" class="form-select">
|
||||
<option value="Automatic">Automatic</option>
|
||||
<option value="Manual">Manual</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-semibold">Mileage (km)</label>
|
||||
<input type="number" name="mileage" class="form-control" placeholder="25000">
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label fw-semibold">Description</label>
|
||||
<textarea name="description" class="form-control" rows="4" placeholder="Describe your car's condition, features, etc."></textarea>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label fw-semibold">Image URL</label>
|
||||
<input type="url" name="image_url" class="form-control" placeholder="https://example.com/car-image.jpg" required>
|
||||
<div class="form-text">For this demo, please provide a direct link to an image.</div>
|
||||
</div>
|
||||
<div class="col-12 mt-4">
|
||||
<button type="submit" class="btn btn-primary w-100 py-3 fw-bold">Submit for Approval</button>
|
||||
<div class="bg-white p-4 p-md-5 rounded-4 shadow-sm border">
|
||||
<form method="POST">
|
||||
<div class="row g-4">
|
||||
<div class="col-12">
|
||||
<label class="form-label fw-bold">Listing Title</label>
|
||||
<input type="text" name="title" class="form-control form-control-lg rounded-3" required placeholder="e.g. 2021 Lexus LX570 White Exterior">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-bold">Brand</label>
|
||||
<input type="text" name="brand" class="form-control rounded-3" required placeholder="e.g. Toyota">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-bold">Model</label>
|
||||
<input type="text" name="model" class="form-control rounded-3" required placeholder="e.g. Corolla">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-bold">Year</label>
|
||||
<input type="number" name="year" class="form-control rounded-3" required placeholder="2022">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-bold">Price ($)</label>
|
||||
<input type="number" name="price" class="form-control rounded-3" required placeholder="25000">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-bold">Location</label>
|
||||
<select name="location" class="form-select rounded-3">
|
||||
<option>Kabul</option><option>Herat</option><option>Mazar-i-Sharif</option><option>Kandahar</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-bold">Fuel Type</label>
|
||||
<input type="text" name="fuel_type" class="form-control rounded-3" placeholder="Petrol / Diesel">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-bold">Transmission</label>
|
||||
<select name="transmission" class="form-select rounded-3">
|
||||
<option>Automatic</option><option>Manual</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label fw-bold">Image URL</label>
|
||||
<input type="text" name="image" class="form-control rounded-3" required placeholder="Paste an image link here">
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label fw-bold">Description</label>
|
||||
<textarea name="description" class="form-control rounded-3" rows="5" placeholder="Tell us more about the car condition, options, etc."></textarea>
|
||||
</div>
|
||||
<div class="col-12 mt-4">
|
||||
<button type="submit" class="btn btn-primary btn-lg w-100 rounded-3 py-3">Submit Listing for Review</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@ -1,158 +1,104 @@
|
||||
<?php
|
||||
$page_title = "User Dashboard - AFG CARS";
|
||||
$page_title = "My Dashboard - AFG CARS";
|
||||
include '../includes/header.php';
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: ../login.php');
|
||||
header('Location: ' . APP_URL . 'login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$user_id = $_SESSION['user_id'];
|
||||
$pdo = db();
|
||||
$user_id = $_SESSION['user_id'];
|
||||
|
||||
// Fetch user's cars
|
||||
$stmt = $pdo->prepare("SELECT * FROM cars WHERE owner_id = ? ORDER BY created_at DESC");
|
||||
$stmt->execute([$user_id]);
|
||||
$my_cars = $stmt->fetchAll();
|
||||
// Stats
|
||||
$stats = [
|
||||
'active_listings' => $pdo->query("SELECT COUNT(*) FROM cars WHERE user_id = $user_id AND status = 'approved'")->fetchColumn(),
|
||||
'pending_listings' => $pdo->query("SELECT COUNT(*) FROM cars WHERE user_id = $user_id AND status = 'pending'")->fetchColumn(),
|
||||
'favorites' => $pdo->query("SELECT COUNT(*) FROM cars WHERE id IN (SELECT car_id FROM reviews WHERE user_id = $user_id)")->fetchColumn(), // Using reviews as proxy for favorites in this simple schema
|
||||
];
|
||||
|
||||
// Fetch user's bookings (where they booked a car)
|
||||
$stmt = $pdo->prepare("SELECT b.*, c.title as car_title, c.image_url FROM bookings b JOIN cars c ON b.car_id = c.id WHERE b.user_id = ? ORDER BY b.created_at DESC");
|
||||
$stmt->execute([$user_id]);
|
||||
$my_bookings = $stmt->fetchAll();
|
||||
|
||||
// Fetch user's purchases
|
||||
$stmt = $pdo->prepare("SELECT p.*, c.title as car_title FROM purchases p JOIN cars c ON p.car_id = c.id WHERE p.user_id = ? ORDER BY p.created_at DESC");
|
||||
$stmt->execute([$user_id]);
|
||||
$my_purchases = $stmt->fetchAll();
|
||||
// My Cars
|
||||
$my_cars = $pdo->prepare("SELECT * FROM cars WHERE user_id = ? ORDER BY created_at DESC");
|
||||
$my_cars->execute([$user_id]);
|
||||
$cars = $my_cars->fetchAll();
|
||||
?>
|
||||
|
||||
<div class="container py-5">
|
||||
<div class="row g-4">
|
||||
<div class="row g-5">
|
||||
<!-- Sidebar -->
|
||||
<div class="col-lg-3">
|
||||
<div class="card border-0 shadow-sm p-4 rounded-4 sticky-top" style="top: 100px;">
|
||||
<div class="bg-white p-4 rounded-4 shadow-sm border">
|
||||
<div class="text-center mb-4">
|
||||
<div class="bg-primary text-white rounded-circle d-inline-flex align-items-center justify-content-center mb-3" style="width: 80px; height: 80px;">
|
||||
<span class="fs-1 fw-bold"><?php echo strtoupper(substr($_SESSION['full_name'], 0, 1)); ?></span>
|
||||
<div class="bg-primary text-white rounded-circle d-inline-flex align-items-center justify-content-center mb-3" style="width: 80px; height: 80px; font-size: 2rem;">
|
||||
<?php echo strtoupper(substr($_SESSION['user_name'], 0, 1)); ?>
|
||||
</div>
|
||||
<h5 class="fw-bold mb-0"><?php echo $_SESSION['full_name']; ?></h5>
|
||||
<p class="text-muted small"><?php echo $_SESSION['email']; ?></p>
|
||||
<h5 class="fw-bold mb-0"><?php echo htmlspecialchars($_SESSION['user_name']); ?></h5>
|
||||
<p class="text-muted small"><?php echo htmlspecialchars($_SESSION['user_email']); ?></p>
|
||||
</div>
|
||||
<div class="list-group list-group-flush border-0">
|
||||
<a href="#my-listings" class="list-group-item list-group-item-action border-0 px-0 active"><i class="bi bi-car-front me-2"></i> My Listings</a>
|
||||
<a href="#my-bookings" class="list-group-item list-group-item-action border-0 px-0"><i class="bi bi-calendar-check me-2"></i> My Bookings</a>
|
||||
<a href="#my-purchases" class="list-group-item list-group-item-action border-0 px-0"><i class="bi bi-bag-check me-2"></i> Purchases</a>
|
||||
<a href="/user/add-car.php" class="list-group-item list-group-item-action border-0 px-0 text-primary"><i class="bi bi-plus-circle me-2"></i> Sell New Car</a>
|
||||
|
||||
<div class="list-group list-group-flush">
|
||||
<a href="dashboard.php" class="list-group-item list-group-item-action border-0 px-0 active">My Listings</a>
|
||||
<a href="add-car.php" class="list-group-item list-group-item-action border-0 px-0 text-primary fw-bold">Sell New Car</a>
|
||||
<a href="<?php echo APP_URL; ?>logout.php" class="list-group-item list-group-item-action border-0 px-0 text-danger">Logout</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Main Content -->
|
||||
<div class="col-lg-9">
|
||||
<!-- Stats -->
|
||||
<div class="row g-3 mb-5">
|
||||
<div class="row g-4 mb-5">
|
||||
<div class="col-md-4">
|
||||
<div class="bg-white p-4 rounded-4 shadow-sm border-start border-primary border-4">
|
||||
<p class="text-muted mb-1">My Cars</p>
|
||||
<h2 class="fw-bold mb-0"><?php echo count($my_cars); ?></h2>
|
||||
<div class="bg-white p-4 rounded-4 shadow-sm border text-center">
|
||||
<div class="text-muted small mb-1">Active Ads</div>
|
||||
<h2 class="fw-bold mb-0"><?php echo $stats['active_listings']; ?></h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="bg-white p-4 rounded-4 shadow-sm border-start border-success border-4">
|
||||
<p class="text-muted mb-1">Bookings</p>
|
||||
<h2 class="fw-bold mb-0"><?php echo count($my_bookings); ?></h2>
|
||||
<div class="bg-white p-4 rounded-4 shadow-sm border text-center">
|
||||
<div class="text-muted small mb-1">Pending</div>
|
||||
<h2 class="fw-bold mb-0 text-warning"><?php echo $stats['pending_listings']; ?></h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="bg-white p-4 rounded-4 shadow-sm border-start border-info border-4">
|
||||
<p class="text-muted mb-1">Purchases</p>
|
||||
<h2 class="fw-bold mb-0"><?php echo count($my_purchases); ?></h2>
|
||||
<div class="bg-white p-4 rounded-4 shadow-sm border text-center">
|
||||
<div class="text-muted small mb-1">Total Sales</div>
|
||||
<h2 class="fw-bold mb-0 text-success">$0</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3 class="fw-bold mb-4" id="my-listings">My Car Listings</h3>
|
||||
<?php if (empty($my_cars)): ?>
|
||||
<div class="bg-white p-5 rounded-4 shadow-sm text-center">
|
||||
<i class="bi bi-emoji-frown fs-1 text-muted mb-3"></i>
|
||||
<p class="text-muted">You haven't listed any cars yet.</p>
|
||||
<a href="/user/add-car.php" class="btn btn-primary">Start Selling</a>
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h4 class="fw-bold">My Car Listings</h4>
|
||||
<a href="add-car.php" class="btn btn-primary px-4">Start Selling</a>
|
||||
</div>
|
||||
|
||||
<?php if (empty($cars)): ?>
|
||||
<div class="text-center py-5 bg-white rounded-4 border">
|
||||
<i class="bi bi-car-front text-muted display-1 mb-3"></i>
|
||||
<h5>No listings found.</h5>
|
||||
<p class="text-muted">You haven't listed any cars for sale yet.</p>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="row g-4">
|
||||
<?php foreach ($my_cars as $car): ?>
|
||||
<div class="col-md-6">
|
||||
<div class="card car-card">
|
||||
<div class="position-relative">
|
||||
<img src="<?php echo $car['image_url']; ?>" class="card-img-top" alt="...">
|
||||
<?php if ($car['status'] === 'sold'): ?>
|
||||
<div class="sold-badge">SOLD</div>
|
||||
<?php elseif ($car['approval_status'] === 'pending'): ?>
|
||||
<div class="pending-badge">PENDING APPROVAL</div>
|
||||
<?php elseif ($car['approval_status'] === 'rejected'): ?>
|
||||
<div class="badge bg-danger position-absolute top-0 start-0 m-3">REJECTED</div>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($cars as $car): ?>
|
||||
<div class="col-md-12">
|
||||
<div class="bg-white p-3 rounded-4 shadow-sm border d-flex gap-4 align-items-center">
|
||||
<img src="<?php echo htmlspecialchars($car['image']); ?>" class="rounded-3" style="width: 150px; height: 100px; object-fit: cover;">
|
||||
<div class="flex-grow-1">
|
||||
<h6 class="fw-bold mb-1"><?php echo htmlspecialchars($car['title']); ?></h6>
|
||||
<div class="text-muted small mb-2">$<?php echo number_format($car['price']); ?> • <?php echo $car['location']; ?></div>
|
||||
<span class="badge <?php echo $car['status'] === 'approved' ? 'bg-success' : 'bg-warning'; ?> rounded-pill">
|
||||
<?php echo strtoupper($car['status']); ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h5 class="fw-bold mb-1"><?php echo $car['title']; ?></h5>
|
||||
<p class="text-muted small mb-2"><i class="bi bi-geo-alt me-1"></i><?php echo $car['location']; ?></p>
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<span class="price-tag">$<?php echo number_format($car['price']); ?></span>
|
||||
<a href="/car-details.php?id=<?php echo $car['id']; ?>" class="btn btn-sm btn-outline-primary">View</a>
|
||||
</div>
|
||||
<div class="pe-3">
|
||||
<a href="<?php echo APP_URL; ?>car-details.php?id=<?php echo $car['id']; ?>" class="btn btn-sm btn-outline-primary px-3">View</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<h3 class="fw-bold mt-5 mb-4" id="my-bookings">My Bookings</h3>
|
||||
<div class="bg-white rounded-4 shadow-sm overflow-hidden">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th>Car</th>
|
||||
<th>Status</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($my_bookings as $booking): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($booking['car_title']); ?></td>
|
||||
<td><span class="badge bg-<?php echo $booking['status'] === 'confirmed' ? 'success' : ($booking['status'] === 'pending' ? 'warning' : 'danger'); ?>"><?php echo ucfirst($booking['status']); ?></span></td>
|
||||
<td class="small text-muted"><?php echo date('M d, Y', strtotime($booking['created_at'])); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; if(empty($my_bookings)) echo "<tr><td colspan='3' class='text-center py-4 text-muted'>No bookings found</td></tr>"; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h3 class="fw-bold mt-5 mb-4" id="my-purchases">My Purchases</h3>
|
||||
<div class="bg-white rounded-4 shadow-sm overflow-hidden">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th>Car</th>
|
||||
<th>Bank</th>
|
||||
<th>Amount</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($my_purchases as $purchase): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($purchase['car_title']); ?></td>
|
||||
<td><?php echo htmlspecialchars($purchase['bank_name']); ?></td>
|
||||
<td class="fw-bold">$<?php echo number_format($purchase['amount']); ?></td>
|
||||
<td class="small text-muted"><?php echo date('M d, Y', strtotime($purchase['created_at'])); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; if(empty($my_purchases)) echo "<tr><td colspan='4' class='text-center py-4 text-muted'>No purchases found</td></tr>"; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
1
user/index.php
Normal file
1
user/index.php
Normal file
@ -0,0 +1 @@
|
||||
<?php header('Location: dashboard.php'); exit;
|
||||
Loading…
x
Reference in New Issue
Block a user