137 lines
4.9 KiB
PHP
137 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';
|
|
|
|
$pdo = db();
|
|
$stmt = $pdo->query("SELECT sales.*, customers.name as customer_name FROM sales LEFT JOIN customers ON sales.customer_id = customers.id ORDER BY sale_date DESC");
|
|
$sales = $stmt->fetchAll();
|
|
|
|
?>
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>Sales</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">
|
|
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.7/css/dataTables.bootstrap5.min.css">
|
|
<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" 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 active" 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>Sales History</h2>
|
|
</header>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<table id="salesTable" class="table table-striped table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>Sale ID</th>
|
|
<th>Customer</th>
|
|
<th>Total Amount</th>
|
|
<th>Date</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($sales as $sale): ?>
|
|
<tr>
|
|
<td><?= htmlspecialchars((string)$sale['id']) ?></td>
|
|
<td><?= htmlspecialchars($sale['customer_name'] ?? 'N/A') ?></td>
|
|
<td><?= htmlspecialchars((string)$sale['payable_amount']) ?></td>
|
|
<td><?= htmlspecialchars($sale['sale_date']) ?></td>
|
|
<td>
|
|
<a href="sale_details.php?id=<?= $sale['id'] ?>" class="btn btn-sm btn-primary"><i class="bi bi-eye-fill"></i></a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<footer class="pt-3 mt-4 text-muted border-top">
|
|
POS System © <?= date('Y') ?>
|
|
</footer>
|
|
</div>
|
|
|
|
<script src="https://code.jquery.com/jquery-3.7.0.js"></script>
|
|
<script src="https://cdn.datatables.net/1.13.7/js/jquery.dataTables.min.js"></script>
|
|
<script src="https://cdn.datatables.net/1.13.7/js/dataTables.bootstrap5.min.js"></script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('#salesTable').DataTable();
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|