| 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';
$selected_month = $_GET['month'] ?? '';
$customers = [];
if ($selected_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", $selected_month);
$stmt->execute();
$customers = $stmt->get_result();
}
// Month options
$month_stmt = $conn->query("
SELECT DISTINCT DATE_FORMAT(archived_on, '%Y-%m') AS month
FROM archived_transactions
ORDER BY month DESC
");
$month_options = [];
while ($row = $month_stmt->fetch_assoc()) {
$month_options[] = $row['month'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Monthly Customer Summaries</title>
<style>
body {
font-family: 'Segoe UI', sans-serif;
background-color: #f9f9f9;
padding: 30px;
margin: 0;
color: #333;
}
.container {
max-width: 800px;
margin: auto;
background: #fff;
padding: 30px;
box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
h1 {
margin-top: 0;
}
form {
margin-bottom: 20px;
}
select {
font-size: 16px;
padding: 8px;
}
.customer {
margin-bottom: 20px;
padding: 15px;
background: #f5f5f5;
border-radius: 6px;
}
.customer h3 {
margin: 0 0 10px;
}
.btn-link {
display: inline-block;
padding: 6px 10px;
background-color: #4CAF50;
color: white;
text-decoration: none;
border-radius: 4px;
}
.btn-link:hover {
background-color: #45a049;
}
.back-link {
margin-top: 30px;
display: block;
}
</style>
</head>
<body>
<div class="container">
<h1>← Monthly Tools: View Summaries</h1>
<form method="get">
<label for="month">Select Month:</label>
<select name="month" id="month" onchange="this.form.submit()">
<option value="">-- Select --</option>
<?php foreach ($month_options as $month): ?>
<option value="<?= $month ?>" <?= $selected_month === $month ? 'selected' : '' ?>>
<?= date('F Y', strtotime($month . '-01')) ?>
</option>
<?php endforeach; ?>
</select>
</form>
<?php if ($selected_month && $customers->num_rows > 0): ?>
<?php while ($c = $customers->fetch_assoc()): ?>
<div class="customer">
<h3><?= htmlspecialchars($c['first_name'] . ' ' . $c['last_name']) ?></h3>
<a class="btn-link" href="generate_statement_pdf.php?customer_id=<?= $c['id'] ?>&month=<?= $selected_month ?>" target="_blank">
Download PDF
</a>
</div>
<?php endwhile; ?>
<?php elseif ($selected_month): ?>
<p><em>No customer summaries found for this month.</em></p>
<?php endif; ?>
<a class="back-link" href="index.php">← Back to Dashboard</a>
</div>
</body>
</html>