« Back to History
list.php
|
20260920_164915.php
Initial Domain Snapshot
Copy Code
<?php declare(strict_types=1); require_once __DIR__ . '/../includes/bootstrap.php'; require_once __DIR__ . '/../includes/header.php'; require_once __DIR__ . '/../includes/sidebar.php'; $search = trim($_GET['search'] ?? ''); $page = max(1, (int)($_GET['page'] ?? 1)); $limit = 25; $offset = ($page - 1) * $limit; $whereClause = " WHERE 1=1 "; $params = []; if (!empty($search)) { $whereClause .= " AND (tenant_code LIKE ? OR tenant_name LIKE ? OR contact_person LIKE ? OR mobile LIKE ? OR email LIKE ?) "; $searchWildcard = "%$search%"; array_push($params, $searchWildcard, $searchWildcard, $searchWildcard, $searchWildcard, $searchWildcard); } try { $countStmt = $pdo->prepare("SELECT COUNT(*) FROM tenant_master $whereClause"); $countStmt->execute($params); $totalRecords = (int)$countStmt->fetchColumn(); $totalPages = (int)ceil($totalRecords / $limit); $dataStmt = $pdo->prepare("SELECT * FROM tenant_master $whereClause ORDER BY tenant_id DESC LIMIT $limit OFFSET $offset"); $dataStmt->execute($params); $customers = $dataStmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { $customers = []; $totalPages = 1; } ?> <div class="container-fluid p-0 mt-3"> <div class="d-flex justify-content-between align-items-center mb-3"> <h4 class="m-0 fw-bold text-dark">👥 Customer / Tenant Management Directory</h4> <a href="add.php" class="btn btn-primary btn-sm">+ Add Customer</a> </div> <div class="card border-0 shadow-sm p-3 mb-4 bg-white"> <form method="GET" action="list.php" class="row g-2 align-items-center"> <div class="col-12 col-md-6"> <input type="text" name="search" class="form-control form-control-sm" placeholder="Search tenant code, name, contact person, mobile..." value="<?= htmlspecialchars($search) ?>"> </div> <div class="col-12 col-md-2"> <button type="submit" class="btn btn-sm btn-secondary w-100">Filter Records</button> </div> </form> </div> <div class="card border-0 shadow-sm bg-white"> <div class="table-responsive"> <table class="table table-hover align-middle mb-0 text-nowrap small"> <thead class="table-light"> <tr> <th>Tenant Code</th> <th>Tenant / Organization Name</th> <th>Contact Person</th> <th>Mobile</th> <th>Email</th> <th class="text-center">Status</th> <th class="text-center">Actions</th> </tr> </thead> <tbody> <?php if (empty($customers)): ?> <tr><td colspan="7" class="text-center py-4 text-muted">No tenant records found.</td></tr> <?php else: ?> <?php foreach ($customers as $row): $statusBadge = ($row['status'] === 'ACTIVE') ? '<span class="badge bg-success">ACTIVE</span>' : '<span class="badge bg-danger">INACTIVE</span>'; ?> <tr> <td><code><?= htmlspecialchars($row['tenant_code'] ?? '') ?></code></td> <td class="fw-semibold"><?= htmlspecialchars($row['tenant_name'] ?? '') ?></td> <td><?= htmlspecialchars($row['contact_person'] ?? '-') ?></td> <td><?= htmlspecialchars($row['mobile'] ?? '-') ?></td> <td><?= htmlspecialchars($row['email'] ?? '-') ?></td> <td class="text-center"><?= $statusBadge ?></td> <td class="text-center"> <a href="edit.php?id=<?= $row['tenant_id'] ?>" class="btn btn-sm btn-outline-secondary px-2">Edit</a> </td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> </div> <?php if ($totalPages > 1): ?> <div class="card-footer bg-white border-0 py-3"> <nav> <ul class="pagination pagination-sm justify-content-end m-0"> <?php for ($i = 1; $i <= $totalPages; $i++): ?> <li class="page-item <?= $page === $i ? 'active' : '' ?>"> <a class="page-link" href="list.php?page=<?= $i ?>&search=<?= urlencode($search) ?>"><?= $i ?></a> </li> <?php endfor; ?> </ul> </nav> </div> <?php endif; ?> </div> </div> <?php require_once __DIR__ . '/../includes/footer.php'; ?>