| 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';
$customer_id = isset($_GET['customer_id']) ? intval($_GET['customer_id']) : 0;
$month = $_GET['month'] ?? '';
if (!$customer_id || !$month) {
echo "Missing customer or month.";
exit;
}
$tax_rate = 0.072;
// Get business info
$business_name = "Wilson Creek Farm Supply";
$address = "117 3rd St S, Wilson Creek WA 98860";
$phone = "509-345-2572";
$email = "info@wilsoncreekfarmsupply.com";
$website = "www.wilsoncreekfarmsupply.com";
$logo = "Logo.jpg"; // truncated for readability
// Get customer name
$stmt = $conn->prepare("SELECT first_name, last_name FROM customers WHERE id = ?");
$stmt->bind_param("i", $customer_id);
$stmt->execute();
$customer = $stmt->get_result()->fetch_assoc();
$customer_name = $customer['first_name'] . ' ' . $customer['last_name'];
// Get transactions
$stmt = $conn->prepare("
SELECT * FROM archived_transactions
WHERE customer_id = ? AND DATE_FORMAT(archived_on, '%Y-%m') = ?
ORDER BY original_date ASC
");
$stmt->bind_param("is", $customer_id, $month);
$stmt->execute();
$result = $stmt->get_result();
$transactions = [];
$total = 0;
while ($row = $result->fetch_assoc()) {
$line_total = $row['price'] * $row['quantity'];
if ($row['taxable']) {
$line_total *= (1 + $tax_rate);
}
$total += $line_total;
$transactions[] = $row;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Statement for <?= htmlspecialchars($customer_name) ?> - <?= date('F Y', strtotime($month . '-01')) ?></title>
<style>
body { font-family: Arial, sans-serif; margin: 40px; }
.header { display: flex; align-items: center; border-bottom: 2px solid #000; margin-bottom: 20px; }
.header img { height: 80px; margin-right: 20px; }
.header div { font-size: 14px; }
h2 { margin-top: 0; }
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
th, td { border: 1px solid #000; padding: 8px; text-align: left; }
th { background-color: #eee; }
.total-row td { font-weight: bold; }
.print-btn { margin-top: 20px; }
</style>
</head>
<body>
<div class="header">
<img src="<?= $logo ?>" alt="Logo">
<div>
<strong><?= $business_name ?></strong><br>
<?= $address ?><br>
<?= $phone ?><br>
<?= $email ?><br>
<?= $website ?>
</div>
</div>
<h2>Statement for <?= htmlspecialchars($customer_name) ?></h2>
<p>For the month of <strong><?= date('F Y', strtotime($month . '-01')) ?></strong></p>
<table>
<tr>
<th>Date</th>
<th>Qty</th>
<th>Item</th>
<th>Price</th>
<th>Taxable</th>
<th>Total</th>
</tr>
<?php foreach ($transactions as $t): ?>
<?php
$line_total = $t['price'] * $t['quantity'];
if ($t['taxable']) {
$line_total *= (1 + $tax_rate);
}
?>
<tr>
<td><?= $t['original_date'] ?></td>
<td><?= $t['quantity'] ?></td>
<td><?= htmlspecialchars($t['item_name']) ?></td>
<td>$<?= number_format($t['price'], 2) ?></td>
<td><?= $t['taxable'] ? 'Yes' : 'No' ?></td>
<td>$<?= number_format($line_total, 2) ?></td>
</tr>
<?php endforeach; ?>
<tr class="total-row">
<td colspan="5" align="right">Total:</td>
<td>$<?= number_format($total, 2) ?></td>
</tr>
</table>
<div class="print-btn">
<button onclick="window.print()">??? Print This Statement</button>
</div>
</body>
</html>