« Back to History
list.php
|
20260722_120325.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 (c.company_name LIKE ? OR l.license_key LIKE ? OR p.plan_name LIKE ? OR l.license_type LIKE ?) "; $searchWildcard = "%$search%"; array_push($params, $searchWildcard, $searchWildcard, $searchWildcard, $searchWildcard); } try { $countStmt = $pdo->prepare(" SELECT COUNT(*) FROM license_master l JOIN company_master c ON c.id = l.company_id LEFT JOIN plans p ON p.id = l.plan_id $whereClause "); $countStmt->execute($params); $totalRecords = $countStmt->fetchColumn(); $totalPages = ceil($totalRecords / $limit); $dataStmt = $pdo->prepare(" SELECT l.*, c.company_name, p.plan_name FROM license_master l JOIN company_master c ON c.id = l.company_id LEFT JOIN plans p ON p.id = l.plan_id $whereClause ORDER BY l.id DESC LIMIT $limit OFFSET $offset "); $dataStmt->execute($params); $licenses = $dataStmt->fetchAll(); } catch (PDOException $e) { $licenses = []; $totalPages = 1; } $today = new DateTime(); ?> <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">📋 License Database Registry</h4> <a href="add.php" class="btn btn-primary btn-sm">+ Add License</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 company, license key, or plan metrics..." value="<?= htmlspecialchars($search) ?>"> </div> <div class="col-12 col-md-2"> <button type="submit" class="btn btn-sm btn-secondary w-100">Filter Nodes</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>Company Name</th> <th>License Key</th> <th>Plan Name</th> <th>License Type</th> <th>Status</th> <th>Start Date</th> <th>End Date</th> <th class="text-center">Max Users</th> <th class="text-center">Max Companies</th> <th class="text-center">Days Remaining</th> <th class="text-center">Actions</th> </tr> </thead> <tbody> <?php if (empty($licenses)): ?> <tr><td colspan="11" class="text-center py-4 text-muted">No managed license nodes registered.</td></tr> <?php else: ?> <?php foreach ($licenses as $row): $endDate = new DateTime($row['end_date']); $interval = $today->diff($endDate); $daysRemaining = (int)$interval->format("%r%a"); $statusBadge = ($row['status'] === 'ACTIVE') ? '<span class="badge bg-success">ACTIVE</span>' : '<span class="badge bg-danger">SUSPENDED</span>'; $typeClass = 'bg-dark'; if ($row['license_type'] === 'PAID') $typeClass = 'bg-primary'; if ($row['license_type'] === 'TRIAL') $typeClass = 'bg-warning text-dark'; if ($row['license_type'] === 'LIFETIME') $typeClass = 'bg-info text-dark'; $isExpired = ($row['license_type'] !== 'LIFETIME' && $daysRemaining < 0); ?> <tr class="<?= $isExpired ? 'table-danger' : '' ?>"> <td class="fw-semibold"><?= htmlspecialchars($row['company_name']) ?></td> <td><code><?= htmlspecialchars($row['license_key']) ?></code></td> <td><?= htmlspecialchars($row['plan_name'] ?? 'Custom Plan') ?></td> <td><span class="badge <?= $typeClass ?>"><?= htmlspecialchars($row['license_type']) ?></span></td> <td><?= $statusBadge ?></td> <td><?= htmlspecialchars($row['start_date']) ?></td> <td><?= htmlspecialchars($row['end_date']) ?></td> <td class="text-center"><?= (int)$row['max_users'] ?></td> <td class="text-center"><?= (int)$row['max_companies'] ?></td> <td class="text-center"> <?php if ($row['license_type'] === 'LIFETIME'): ?> <span class="badge bg-info text-dark">Lifetime</span> <?php elseif ($isExpired): ?> <span class="badge bg-danger">Expired</span> <?php else: ?> <span class="badge bg-light text-dark border fw-bold"><?= $daysRemaining ?> Days</span> <?php endif; ?> </td> <td class="text-center"> <div class="d-inline-flex gap-1"> <a href="edit.php?id=<?= $row['id'] ?>" class="btn btn-sm btn-outline-secondary px-2">Edit</a> </div> </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'; ?>