| Server IP : 173.209.174.21 / Your IP : 216.73.216.89 Web Server : Apache/2.4.58 (Ubuntu) System : Linux wcfs-server 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : nodor ( 1000) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/wcfs/tabs/Backups/ |
Upload File : |
<?php
include 'db.php';
$tax_rate = 0.082;
$customer_id = isset($_GET['customer_id']) ? intval($_GET['customer_id']) : 0;
$archive_month = $_GET['archive_month'] ?? '';
$transactions = [];
$total = 0.0;
$customer_name = '';
$customers = $conn->query("SELECT id, first_name, last_name FROM customers ORDER BY last_name, first_name");
if ($customer_id > 0) {
$stmt = $conn->prepare("SELECT first_name, last_name FROM customers WHERE id = ?");
$stmt->bind_param("i", $customer_id);
$stmt->execute();
$result = $stmt->get_result();
if ($row = $result->fetch_assoc()) {
$customer_name = $row['first_name'] . ' ' . $row['last_name'];
} else {
$customer_id = 0;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>View Account - <?= htmlspecialchars($customer_name) ?></title>
<style>
body {
font-family: 'Segoe UI', sans-serif;
background-color: #f9f9f9;
margin: 0;
padding: 30px;
color: #333;
}
.container {
max-width: 1000px;
margin: auto;
background: #fff;
padding: 30px;
box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
}
th {
background-color: #f0f0f0;
}
.total-section {
margin-top: 20px;
font-weight: bold;
}
input[type="number"], input[type="text"] {
width: 100%;
}
.submit-btn {
margin-top: 10px;
padding: 10px 16px;
background-color: #4CAF50;
border: none;
color: white;
font-size: 16px;
border-radius: 4px;
cursor: pointer;
}
.submit-btn:hover {
background-color: #45a049;
}
.back-link {
margin-top: 20px;
display: inline-block;
}
.note-cell {
font-style: italic;
color: #555;
}
.delete-btn {
padding: 4px 8px;
background-color: #f44336;
color: white;
border: none;
cursor: pointer;
border-radius: 4px;
}
.delete-btn:hover {
background-color: #c62828;
}
</style>
</head>
<body>
<div class="container">
<h2><?= htmlspecialchars($customer_name) ?> � Account Details</h2>
<?php if ($customer_id): ?>
<!-- Add Items Form -->
<h3>Add Items</h3>
<form method="post" action="add_transaction.php">
<input type="hidden" name="customer_id" value="<?= $customer_id ?>">
<table>
<tr>
<th>Qty</th>
<th>Item</th>
<th>Price</th>
<th>Taxable</th>
<th>Notes</th>
</tr>
<?php for ($i = 0; $i < 3; $i++): ?>
<tr>
<td><input type="number" name="quantity[]" value="1" min="1"></td>
<td><input type="text" name="item_name[]"></td>
<td><input type="number" name="price[]" step="0.01"></td>
<td><input type="checkbox" name="taxable[<?= $i ?>]"></td>
<td><input type="text" name="notes[]"></td>
</tr>
<?php endfor; ?>
</table>
<input class="submit-btn" type="submit" value="Add Items to Account">
</form>
<!-- Transactions Table -->
<h3>Transactions</h3>
<table>
<tr>
<th>Date</th>
<th>Qty</th>
<th>Item</th>
<th>Price</th>
<th>Taxable</th>
<th>Total</th>
<th>Notes</th>
<th>Action</th>
</tr>
<?php
$stmt = $conn->prepare("SELECT * FROM transactions WHERE customer_id = ? ORDER BY date DESC");
$stmt->bind_param("i", $customer_id);
$stmt->execute();
$result = $stmt->get_result();
$item_total = $tax_total = $grand_total = 0;
while ($row = $result->fetch_assoc()):
$line_total = $row['quantity'] * $row['price'];
$tax = $row['taxable'] ? $line_total * $tax_rate : 0;
$total_with_tax = $line_total + $tax;
$item_total += $line_total;
$tax_total += $tax;
$grand_total += $total_with_tax;
?>
<tr>
<td><?= htmlspecialchars($row['date']) ?></td>
<td><?= $row['quantity'] ?></td>
<td><?= htmlspecialchars($row['item_name']) ?></td>
<td>$<?= number_format($row['price'], 2) ?></td>
<td><?= $row['taxable'] ? 'Yes' : 'No' ?></td>
<td>$<?= number_format($total_with_tax, 2) ?></td>
<td class="note-cell"><?= htmlspecialchars($row['notes']) ?></td>
<td>
<form method="post" action="delete_transaction.php" onsubmit="return confirm('Delete this item?')">
<input type="hidden" name="id" value="<?= $row['id'] ?>">
<input type="hidden" name="customer_id" value="<?= $customer_id ?>">
<input type="submit" class="delete-btn" value="Delete">
</form>
</td>
</tr>
<?php endwhile; ?>
</table>
<!-- Totals -->
<div class="total-section">
Item Total: $<?= number_format($item_total, 2) ?><br>
Tax Total (<?= ($tax_rate * 100) ?>%): $<?= number_format($tax_total, 2) ?><br>
<strong>Total with Tax:</strong> $<?= number_format($grand_total, 2) ?>
</div>
<?php else: ?>
<p>Please select a customer from the dashboard.</p>
<?php endif; ?>
<a class="back-link" href="index.php">← Back to Dashboard</a>
</div>
</body>
</html>