| 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';
$month = $_GET['month'] ?? '';
if (!$month) {
echo "Month not specified.";
exit;
}
$tax_rate = 0.072;
// 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 = "data:image/jpeg;base64,/9j/4S2XRXhpZgAATU0AKgAAAAgADAEAAAMAAAABAwEAAAEBAAMAAAABA44AAAECAAMAAAADAAAAn..."; // truncate safely
// Get customers for the month
$stmt = $conn->prepare("
SELECT DISTINCT c.id, c.first_name, c.last_name
FROM customers c
JOIN archived_transactions t ON c.id = t.customer_id
WHERE DATE_FORMAT(t.archived_on, '%Y-%m') = ?
ORDER BY c.last_name, c.first_name
");
$stmt->bind_param("s", $month);
$stmt->execute();
$customers = $stmt->get_result();
?>
<!DOCTYPE html>
<html>
<head>
<title>All Customer Statements - <?= 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: 20px 0; }
.page-break { page-break-after: always; }
</style>
</head>
<body>
<h1>?? All Statements - <?= date('F Y', strtotime($month . '-01')) ?></h1>
<div class="print-btn">
<button onclick="window.print()">??? Print All</button>
</div>
<?php while ($cust = $customers->fetch_assoc()): ?>
<?php
$customer_id = $cust['id'];
$customer_name = $cust['first_name'] . ' ' . $cust['last_name'];
// Get transactions for this customer
$stmt2 = $conn->prepare("
SELECT * FROM archived_transactions
WHERE customer_id = ? AND DATE_FORMAT(archived_on, '%Y-%m') = ?
ORDER BY original_date ASC
");
$stmt2->bind_param("is", $customer_id, $month);
$stmt2->execute();
$results = $stmt2->get_result();
$transactions = [];
$total = 0;
while ($row = $results->fetch_assoc()) {
$line_total = $row['price'] * $row['quantity'];
if ($row['taxable']) {
$line_total *= (1 + $tax_rate);
}
$total += $line_total;
$transactions[] = $row;
}
?>
<div class="statement">
<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>
<div class="page-break"></div>
<?php endwhile; ?>
</body>
</html>