| 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/ |
Upload File : |
<?php
include 'db.php';
$letter = $_GET['letter'] ?? '';
$search = $_GET['search'] ?? '';
// Get filtered customers
if ($search) {
$stmt = $conn->prepare("SELECT * FROM customers WHERE first_name LIKE ? OR last_name LIKE ? ORDER BY last_name, first_name");
$like = "%$search%";
$stmt->bind_param("ss", $like, $like);
} elseif ($letter) {
$stmt = $conn->prepare("SELECT * FROM customers WHERE last_name LIKE ? ORDER BY last_name, first_name");
$like = "$letter%";
$stmt->bind_param("s", $like);
} else {
$stmt = $conn->prepare("SELECT * FROM customers ORDER BY last_name, first_name");
}
$stmt->execute();
$customers = $stmt->get_result();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Customer Accounts - Wilson Creek Farm Supply</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 0;
padding: 30px;
background-color: #f9f9f9;
color: #333;
}
h1 {
margin-top: 0;
}
.container {
max-width: 800px;
margin: auto;
}
.monthly-tools {
background: #fff;
padding: 15px 20px;
border-left: 5px solid #4CAF50;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
margin-bottom: 25px;
}
.monthly-tools h3 {
margin-top: 0;
}
.monthly-tools ul {
list-style: none;
padding: 0;
}
.monthly-tools li {
margin-bottom: 8px;
}
.monthly-tools a {
text-decoration: none;
color: #2a7ae2;
}
.filter {
margin-bottom: 15px;
}
.filter a {
margin-right: 8px;
text-decoration: none;
font-weight: bold;
color: #444;
}
.filter a:hover {
color: #000;
}
.search-form {
margin-bottom: 20px;
}
.search-form input[type="text"] {
padding: 6px 10px;
width: 60%;
font-size: 16px;
}
.search-form input[type="submit"] {
padding: 6px 12px;
font-size: 16px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
.search-form input[type="submit"]:hover {
background-color: #45a049;
}
.customer-select {
background: #fff;
padding: 20px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
border-radius: 5px;
margin-top: 20px;
}
.customer-select select {
width: 100%;
padding: 10px;
font-size: 16px;
}
.customer-select input[type="submit"] {
margin-top: 10px;
padding: 8px 16px;
background-color: #2196F3;
color: white;
border: none;
cursor: pointer;
}
.customer-select input[type="submit"]:hover {
background-color: #1976D2;
}
.filtered-results {
background-color: #fffce8;
padding: 20px;
border-left: 5px solid #f4c542;
box-shadow: 0 2px 5px rgba(0,0,0,0.05);
margin-top: 30px;
border-radius: 4px;
}
.filtered-results h3 {
margin-top: 0;
}
ul.customer-links {
list-style: none;
padding: 0;
margin: 10px 0 0 0;
}
ul.customer-links li {
margin: 6px 0;
}
ul.customer-links a {
text-decoration: none;
color: #2a2a2a;
font-size: 17px;
}
ul.customer-links a:hover {
color: #d9534f;
text-decoration: underline;
}
</style>
</head>
<body>
<div class="container">
<h1>📝 Customer Accounts</h1>
<!-- Tools -->
<div class="monthly-tools">
<h3>🛠 Tools</h3>
<ul>
<li><a href="monthly_summary.php">📄 View Monthly Customer Summaries</a></li>
<li><a href="print_all_statements.php?month=<?= date('Y-m') ?>" target="_blank">🖨 Print All Statements (<?= date('F Y') ?>)</a></li>
<li><a href="add_customer.php">➕ Add New Customer</a></li>
<li><a href="archive_all.php">📦 Archive All Tabs</a></li>
</ul>
</div>
<!-- A�Z Filter -->
<div class="filter">
<strong>Filter by Last Name:</strong><br>
<?php foreach (range('A', 'Z') as $l): ?>
<a href="index.php?letter=<?= $l ?>"><?= $l ?></a>
<?php endforeach; ?>
<a href="index.php">[All]</a>
</div>
<!-- Search -->
<form method="get" class="search-form">
<input type="text" name="search" placeholder="Search by name..." value="<?= htmlspecialchars($search) ?>">
<input type="submit" value="🔍 Search">
</form>
<!-- Customer Dropdown -->
<div class="customer-select">
<form method="get" action="view_account.php">
<label><strong>Select Customer:</strong></label><br>
<select name="customer_id" required>
<option value="">-- Choose a customer --</option>
<?php
$stmt->execute();
$customers = $stmt->get_result();
while ($row = $customers->fetch_assoc()): ?>
<option value="<?= $row['id'] ?>">
<?= htmlspecialchars($row['last_name'] . ', ' . $row['first_name']) ?>
</option>
<?php endwhile; ?>
</select><br>
<input type="submit" value="View Account">
</form>
</div>
<!-- Filtered Results List -->
<?php if ($search || $letter): ?>
<?php
$stmt->execute(); // rerun to reset
$customers = $stmt->get_result();
?>
<div class="filtered-results">
<h3>Filtered Results:</h3>
<ul class="customer-links">
<?php while ($row = $customers->fetch_assoc()): ?>
<li>
<a href="view_account.php?customer_id=<?= $row['id'] ?>">
<?= htmlspecialchars($row['last_name'] . ', ' . $row['first_name']) ?>
</a>
</li>
<?php endwhile; ?>
</ul>
</div>
<?php endif; ?>
</div>
</body>
</html>