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) { } 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="col-12 col-sm-12 col-lg-10">
<div class="card card-info card-outline"> <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)) { if (strlen($search_player) < 3 && !Validator::number($search_player)) {
echo_error('Player name is too short.'); echo_error('Player name is too short.');
} else { } else {
if (Validator::number($search_player))
$id = (int)$search_player;
else {
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote($search_player)); $query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote($search_player));
if ($query->rowCount() == 1) { if ($query->rowCount() == 1) {
$query = $query->fetch(); $query = $query->fetch();
@ -66,8 +63,9 @@ else if (isset($_REQUEST['search'])) {
} }
} }
} }
} ?>
<div class="row">
<?php
$groups = new OTS_Groups_List(); $groups = new OTS_Groups_List();
if ($id > 0) { if ($id > 0) {
$player = new OTS_Player(); $player = new OTS_Player();
@ -301,9 +299,44 @@ if ($id > 0) {
$player->load($id); $player->load($id);
} }
} }
} } else if ($id == 0) {
$players_db = $db->query('SELECT `id`, `name`, `level` FROM `players` ORDER BY `id` asc');
?> ?>
<div class="row"> <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 <?php
if (isset($player) && $player->isLoaded()) { if (isset($player) && $player->isLoaded()) {
$account = $player->getAccount(); $account = $player->getAccount();
@ -829,16 +862,34 @@ if ($id > 0) {
<div class="card-header"> <div class="card-header">
<h5 class="m-0">Search Player</h5> <h5 class="m-0">Search Player</h5>
</div> </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"> <form action="<?php echo $player_base; ?>" method="post">
<label for="name">Player Name:</label>
<div class="input-group input-group-sm"> <div class="input-group input-group-sm">
<input type="text" class="form-control" name="search" value="<?php echo $search_player; ?>" maxlength="32" size="32"> <input type="text" class="form-control" name="search" value="<?php echo $search_player; ?>" maxlength="32" size="32">
<span class="input-group-append"> <span class="input-group-append"><button type="submit" class="btn btn-info btn-flat">Search</button></span>
<button type="submit" class="btn btn-info btn-flat">Search</button> </div>
</span> </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> </div>
</form> </form>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<script>
$(document).ready(function () {
$('.player_datatable').DataTable({
"order": [[0, "asc"]]
});
});
</script>