Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ability to list all accounts and players in admin editor #115

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add pages for accounts listing
  • Loading branch information
dhmello authored Aug 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 3bcd0bf235d6ed13d53fc162349628bd0392b4a1
25 changes: 22 additions & 3 deletions admin/pages/accounts.php
Original file line number Diff line number Diff line change
@@ -92,7 +92,6 @@ function verify_number($number, $name, $max_length)
}
}


$groups = new OTS_Groups_List();
if ($id > 0) {
$account = new OTS_Account();
@@ -244,6 +243,7 @@ function verify_number($number, $name, $max_length)
}

?>

<div class="row">
<?php if (isset($account) && $account->isLoaded()) { ?>

@@ -497,9 +497,18 @@ class="fa fa-remove"></i> Cancel</span></a>
};
?>
</div>

<?php
// List all accounts
$allAccounts = $db->query("SELECT id, name, email FROM accounts ORDER BY id ASC")->fetchAll();
// Pagination for accounts listing
$limit = 10; // Number of accounts per page
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$start = ($page - 1) * $limit;
$total_accounts = $db->query("SELECT COUNT(*) as count FROM accounts")->fetch()['count'];
$total_pages = ceil($total_accounts / $limit);

// Fetching accounts with pagination
$allAccounts = $db->query("SELECT id, name, email FROM accounts ORDER BY id ASC LIMIT $start, $limit")->fetchAll();

if ($allAccounts) {
echo '<h3>All Accounts:</h3>';
echo '<table class="table table-striped">';
@@ -514,8 +523,18 @@ class="fa fa-remove"></i> Cancel</span></a>
}
echo '</tbody>';
echo '</table>';

// Pagination links
if ($total_pages > 1) {
echo '<nav aria-label="Page navigation example"><ul class="pagination">';
for ($i = 1; $i <= $total_pages; $i++) {
echo '<li class="page-item ' . ($i == $page ? 'active' : '') . '"><a class="page-link" href="' . $base . '&page=' . $i . '">' . $i . '</a></li>';
}
echo '</ul></nav>';
}
}
?>

<script type="text/javascript">
$('#lastlogout').datetimepicker({format: 'unixtime'});
$('#created').datetimepicker({format: 'unixtime'});
Loading