141 lines
4.9 KiB
PHP
141 lines
4.9 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
@ini_set('display_errors', '1');
|
|
@error_reporting(E_ALL);
|
|
@date_default_timezone_set('UTC');
|
|
|
|
require_once 'db/config.php';
|
|
|
|
$message = '';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$pdo = db();
|
|
try {
|
|
$sql = "INSERT INTO customers (name, email, phone, address) VALUES (?, ?, ?, ?)";
|
|
$stmt= $pdo->prepare($sql);
|
|
$stmt->execute([
|
|
$_POST['name'],
|
|
$_POST['email'],
|
|
$_POST['phone'],
|
|
$_POST['address']
|
|
]);
|
|
$message = '<div class="alert alert-success">Customer added successfully!</div>';
|
|
} catch (PDOException $e) {
|
|
$message = '<div class="alert alert-danger">Error adding customer: ' . $e->getMessage() . '</div>';
|
|
}
|
|
}
|
|
|
|
?>
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>Add Customer</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css" rel="stylesheet">
|
|
<style>
|
|
body {
|
|
background-color: #f0f2f5;
|
|
}
|
|
.sidebar {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
height: 100%;
|
|
width: 250px;
|
|
background-color: #fff;
|
|
padding-top: 1rem;
|
|
}
|
|
.main-content {
|
|
margin-left: 250px;
|
|
padding: 2rem;
|
|
}
|
|
.sidebar .nav-link {
|
|
color: #333;
|
|
font-weight: 500;
|
|
}
|
|
.sidebar .nav-link:hover, .sidebar .nav-link.active {
|
|
color: #0d6efd;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="sidebar">
|
|
<h4 class="px-3">POS System</h4>
|
|
<ul class="nav flex-column">
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="index.php"><i class="bi bi-grid-fill"></i> Dashboard</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="pos.php"><i class="bi bi-cart-check-fill"></i> POS</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="#" data-bs-toggle="collapse" data-bs-target="#inventory-submenu" aria-expanded="false" aria-controls="inventory-submenu"><i class="bi bi-box-seam-fill"></i> Inventory</a>
|
|
<div class="collapse" id="inventory-submenu">
|
|
<ul class="nav flex-column ms-3">
|
|
<li class="nav-item"><a class="nav-link" href="view_items.php">View Items</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="add_item.php">Add Item</a></li>
|
|
</ul>
|
|
</div>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link active" href="customers.php"><i class="bi bi-people-fill"></i> Customers</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="#"><i class="bi bi-truck"></i> Suppliers</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="sales.php"><i class="bi bi-receipt"></i> Sales</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="#"><i class="bi bi-wallet-fill"></i> Expenses</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="#"><i class="bi bi-person-circle"></i> Users</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="main-content">
|
|
<header class="d-flex justify-content-between align-items-center mb-4">
|
|
<h2>Add New Customer</h2>
|
|
<a href="customers.php" class="btn btn-secondary">Back to Customers</a>
|
|
</header>
|
|
|
|
<?= $message ?>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<form action="add_customer.php" method="post">
|
|
<div class="mb-3">
|
|
<label for="name" class="form-label">Name</label>
|
|
<input type="text" class="form-control" id="name" name="name" required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="email" class="form-label">Email</label>
|
|
<input type="email" class="form-control" id="email" name="email">
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="phone" class="form-label">Phone</label>
|
|
<input type="text" class="form-control" id="phone" name="phone">
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="address" class="form-label">Address</label>
|
|
<textarea class="form-control" id="address" name="address" rows="3"></textarea>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Add Customer</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<footer class="pt-3 mt-4 text-muted border-top">
|
|
POS System © <?= date('Y') ?>
|
|
</footer>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|