Limmat/admin/admins.php

86 lines
4.1 KiB
PHP
Raw Normal View History

2025-01-07 03:45:35 +01:00
<?php include('includes/header.php'); ?>
<div>
<div class="card card-body p-4">
<div class="row">
<div class="col-8">
<h3 class="fw-semibold mb-4">Administratoren</h3>
</div>
<div class="col-4">
<a href="admins-create.php" class="btn btn-info mx-1 float-end"> <i class="ti ti-plus"></i> Hinzufügen</a>
</div>
</div>
<?= alertMessage(); ?>
<div class="table-responsive">
<table class="table table-hover" id="sortTable">
<thead>
<tr>
<th style="cursor: pointer;" onclick="sortTable(0)">Vorname</th>
<th style="cursor: pointer;" onclick="sortTable(1)">Nachname</th>
<th style="cursor: pointer;" onclick="sortTable(2)">Benutzer-ID</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$admins = getAll('id, firstname, lastname, userid, status', 'tbl_admins', "WHERE userid != 'root'");
if(mysqli_num_rows($admins) > 0)
{
foreach($admins as $adminEntry)
{
if($adminEntry['status'] == 'active'){$status = 'aktiv'; $colour = "success";}
elseif($adminEntry['status'] == 'disabled'){$status = 'inaktiv'; $colour = "danger";}
?>
<tr>
<td><?= $adminEntry['firstname']; ?></td>
<td><?= $adminEntry['lastname']; ?></td>
<td><?= $adminEntry['userid']; ?></td>
<td><span style="font-size:0.8em;" class="badge rounded-pill text-bg-<?= $colour;?>"><?= $status; ?></span></td>
<td>
<button type="button"
class="btn btn-danger btn-sm float-end mx-1"
data-bs-toggle="modal" data-bs-target="#deleteAdmin<?= $adminEntry['id']; ?>"> <i class="ti ti-trash"></i>
</button>
<a href="admins-edit.php?id=<?= $adminEntry['id']; ?>" class="btn btn-light btn-sm float-end mx-1"> <i class="ti ti-pencil"></i></a>
</td>
</tr>
<!-- Modal -->
<div class="modal fade" id="deleteAdmin<?= $adminEntry['id']; ?>" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="staticBackdropLabel">Administrator entfernen</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Sind Sie sicher, dass Sie <b><?= $adminEntry['firstname'] . ' ' . $adminEntry['lastname']?></b> entfernen möchten?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Abbrechen</button>
<a href="admins-delete.php?id=<?= $adminEntry['id']; ?>" class="btn btn-danger"><i class="ti ti-trash"></i> Löschen</a>
</div>
</div>
</div>
</div>
<!-- Modal Ende -->
<?php
}
}
else
{
?>
<tr>
<td colspan="7"> Keine Einträge gefunden</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
<?php include('includes/footer.php'); ?>