| 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/thelittlebigshow/self-hosted/ |
Upload File : |
<?php
require_once __DIR__ . '/protect.php';
require_once __DIR__ . '/brand_header.php';
?>
<?php if (!empty($_SESSION['is_impersonating_store'])): ?>
<div style="background:#fff7ed;border:1px solid #fdba74;color:#9a3412;padding:10px 14px;margin:10px 0;border-radius:8px;">
You are viewing this store as Super Admin
(<?php echo htmlspecialchars($_SESSION['impersonated_by_admin'] ?? 'admin', ENT_QUOTES, 'UTF-8'); ?>).
<a href="/admin.php" style="margin-left:12px;">Return to Super Admin</a>
</div>
<?php endif; ?>
<?php
include 'db.php';
include 'store_settings.php';
$letter = $_GET['letter'] ?? '';
$search = $_GET['search'] ?? '';
$taxRate = getStoreTaxRate($conn);
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</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;
}
.tools-layout {
display: flex;
gap: 24px;
align-items: flex-start;
justify-content: space-between;
}
.tools-list {
flex: 1 1 auto;
min-width: 0;
}
.tools-brand {
flex: 0 0 180px;
text-align: center;
}
.tools-brand img {
width: 156px;
height: auto;
display: block;
margin: 4px auto 0;
}
.tools-brand p {
margin: 14px 0 0;
font-size: 24px;
font-weight: 700;
color: #1d4ed8;
line-height: 1.2;
}
.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;
}
@media (max-width: 720px) {
.tools-layout {
flex-direction: column;
}
.tools-brand {
width: 100%;
}
}
</style>
<?php echo appBrandStyles(); ?>
</head>
<body>
<div class="container">
<?php renderAppBrandHeader(); ?>
<?php if (!empty($_GET['license_activated']) && function_exists('selfHostedModeEnabled') && selfHostedModeEnabled()): ?>
<div style="background:#ecfdf5;border:1px solid #86efac;color:#166534;padding:10px 14px;margin:0 0 16px;border-radius:8px;">
Self-hosted license activated successfully for this server.
</div>
<?php endif; ?>
<h1>Customer Accounts
<span style="font-size:14px;color:#666;font-weight:normal;">
- <?php echo htmlspecialchars($_SESSION['store_name'] ?? $_SESSION['store_db'] ?? '', ENT_QUOTES, 'UTF-8'); ?>
</span>
</h1>
<div class="monthly-tools">
<div class="tools-layout">
<div class="tools-list">
<h3>🔧 Tools</h3>
<ul>
<li><a href="add_customer.php">➕ Add New Customer</a></li>
<li><a href="monthly_summary.php">📄 View Monthly Customer Summaries</a></li>
<li><a href="daily_totals.php">🧊 Daily Totals</a></li>
<li><a href="print_all_statements.php?month=<?php echo date('Y-m'); ?>" target="_blank">🖨 Print All Statements (<?php echo date('F Y'); ?>)</a></li>
<li><a href="export_form.php">💾 Export to QuickBooks (CSV)</a></li>
<li><a href="total_balance.php">💲 Total Outstanding Balance (all accounts)</a></li>
<li><a href="stats.php">📊 Monthly Stats</a></li>
<li><a href="archive_all.php">📦 Clear-Archive Monthly</a></li>
<li><a href="rename_customer.php">🔤 Rename Customers</a></li>
<li><a href="view_credits.php">💰 Customers with Credits</a></li>
<li><a href="tax_settings.php">💵 Sales Tax Settings (<?php echo formatTaxRatePercent($taxRate); ?>%)</a></li>
</ul>
</div>
<div class="tools-brand">
<img src="house-tab-pro-app-icon.svg" alt="HouseTab Pro icon">
<p>HouseTab Pro</p>
</div>
</div>
</div>
<div class="filter">
<strong>Filter by Last Name:</strong><br>
<?php foreach (range('A', 'Z') as $l): ?>
<a href="index.php?letter=<?php echo $l; ?>"><?php echo $l; ?></a>
<?php endforeach; ?>
<a href="index.php">[All]</a>
</div>
<form method="get" class="search-form">
<input type="text" name="search" placeholder="Search by name..." value="<?php echo htmlspecialchars($search, ENT_QUOTES, 'UTF-8'); ?>">
<input type="submit" value="Search">
</form>
<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="<?php echo (int) $row['id']; ?>">
<?php echo htmlspecialchars($row['last_name'] . ', ' . $row['first_name'], ENT_QUOTES, 'UTF-8'); ?>
</option>
<?php endwhile; ?>
</select><br>
<input type="submit" value="View Account">
</form>
</div>
<?php if ($search || $letter): ?>
<?php
$stmt->execute();
$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=<?php echo (int) $row['id']; ?>">
<?php echo htmlspecialchars($row['last_name'] . ', ' . $row['first_name'], ENT_QUOTES, 'UTF-8'); ?>
</a>
</li>
<?php endwhile; ?>
</ul>
</div>
<?php endif; ?>
</div>
</body>
</html>