Admin Update

-Account limit fix
-Player editor full player table.
This commit is contained in:
Lee 2020-04-02 20:54:20 +01:00
parent cddd915adf
commit 375bd58a0c
2 changed files with 318 additions and 267 deletions

View File

@ -204,7 +204,7 @@ else if (isset($_REQUEST['search'])) {
}
}
} else if ($id == 0) {
$accounts_db = $db->query('SELECT `id`, `name`,`type` FROM `accounts` ORDER BY `id` DESC LIMIT 10;');
$accounts_db = $db->query('SELECT `id`, `name`,`type` FROM `accounts` ORDER BY `id` ASC');
?>
<div class="col-12 col-sm-12 col-lg-10">
<div class="card card-info card-outline">

View File

@ -44,9 +44,6 @@ else if (isset($_REQUEST['search'])) {
if (strlen($search_player) < 3 && !Validator::number($search_player)) {
echo_error('Player name is too short.');
} else {
if (Validator::number($search_player))
$id = (int)$search_player;
else {
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote($search_player));
if ($query->rowCount() == 1) {
$query = $query->fetch();
@ -65,11 +62,12 @@ else if (isset($_REQUEST['search'])) {
echo_error('No entries found.');
}
}
}
}
$groups = new OTS_Groups_List();
if ($id > 0) {
?>
<div class="row">
<?php
$groups = new OTS_Groups_List();
if ($id > 0) {
$player = new OTS_Player();
$player->load($id);
@ -301,9 +299,44 @@ if ($id > 0) {
$player->load($id);
}
}
}
?>
<div class="row">
} else if ($id == 0) {
$players_db = $db->query('SELECT `id`, `name`, `level` FROM `players` ORDER BY `id` asc');
?>
<div class="col-12 col-sm-12 col-lg-10">
<div class="card card-info card-outline">
<div class="card-header">
<h5 class="m-0">Players</h5>
</div>
<div class="card-body">
<table class="player_datatable table table-striped table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Level</th>
<th style="width: 40px">Edit</th>
</tr>
</thead>
<tbody>
<?php foreach ($players_db as $player_db): ?>
<tr>
<th><?php echo $player_db['id']; ?></th>
<td><?php echo $player_db['name']; ?></a></td>
<td><?php echo $player_db['level']; ?></a></td>
<td><a href="?p=players&id=<?php echo $player_db['id']; ?>" class="btn btn-success btn-sm" title="Edit">
<i class="fas fa-pencil-alt"></i>
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<?php } ?>
<?php
if (isset($player) && $player->isLoaded()) {
$account = $player->getAccount();
@ -829,16 +862,34 @@ if ($id > 0) {
<div class="card-header">
<h5 class="m-0">Search Player</h5>
</div>
<div class="card-body">
<div class="card-body row">
<div class="col-6 col-lg-12">
<form action="<?php echo $player_base; ?>" method="post">
<label for="name">Player Name:</label>
<div class="input-group input-group-sm">
<input type="text" class="form-control" name="search" value="<?php echo $search_player; ?>" maxlength="32" size="32">
<span class="input-group-append">
<button type="submit" class="btn btn-info btn-flat">Search</button>
</span>
<span class="input-group-append"><button type="submit" class="btn btn-info btn-flat">Search</button></span>
</div>
</form>
</div>
<div class="col-6 col-lg-12">
<form action="<?php echo $player_base; ?>" method="post">
<label for="name">Player ID:</label>
<div class="input-group input-group-sm">
<input type="text" class="form-control" name="id" value="" maxlength="32" size="32">
<span class="input-group-append"><button type="submit" class="btn btn-info btn-flat">Search</button></span>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function () {
$('.player_datatable').DataTable({
"order": [[0, "asc"]]
});
});
</script>