2026-10-04 17:34:43 +02:00
< ? php
$pageTitle = 'Benutzer verwalten' ;
require __DIR__ . '/../partials/header.php' ;
?>
< h1 > Benutzer verwalten </ h1 >
< ? php if ( ! empty ( $message )) : ?>
< p style = " color: green; " >< ? php echo htmlspecialchars ( $message ); ?> </p>
< ? php endif ; ?>
< ? php if ( ! empty ( $error )) : ?>
< p style = " color: red; " >< ? php echo htmlspecialchars ( $error ); ?> </p>
< ? php endif ; ?>
2026-10-18 21:40:43 +02:00
<!-- Form for editing a user -->
< ? php if ( $editUser ) : ?>
< h2 > Benutzer bearbeiten </ h2 >
2026-10-04 17:34:43 +02:00
< form action = " /index.php?page=admin_users " method = " post " >
2026-10-18 21:40:43 +02:00
< input type = " hidden " name = " action " value = " update " >
< input type = " hidden " name = " id " value = " <?php echo htmlspecialchars( $editUser['id'] ); ?> " >
2026-10-04 17:34:43 +02:00
< div class = " form-group " >
< label for = " firstname " > Vorname :</ label >
2026-10-18 21:40:43 +02:00
< input type = " text " id = " firstname " name = " firstname " value = " <?php echo htmlspecialchars( $editUser['firstname'] ); ?> " required >
2026-10-04 17:34:43 +02:00
</ div >
< div class = " form-group " >
< label for = " lastname " > Nachname :</ label >
2026-10-18 21:40:43 +02:00
< input type = " text " id = " lastname " name = " lastname " value = " <?php echo htmlspecialchars( $editUser['lastname'] ); ?> " required >
2026-10-04 17:34:43 +02:00
</ div >
< div class = " form-group " >
< label for = " email " > E - Mail :</ label >
2026-10-18 21:40:43 +02:00
< input type = " email " id = " email " name = " email " value = " <?php echo htmlspecialchars( $editUser['email'] ); ?> " required >
2026-10-04 17:34:43 +02:00
</ div >
< div class = " form-group " >
< label for = " password " > Passwort :</ label >
2026-10-18 21:40:43 +02:00
< input type = " password " id = " password " name = " password " placeholder = " Leer lassen, um nicht zu ändern " >
2026-10-04 17:34:43 +02:00
</ div >
< div class = " form-group " >
< label for = " admin " > Admin :</ label >
< input type = " checkbox " id = " admin " name = " admin " value = " 1 " < ? php echo ! empty ( $editUser [ 'admin' ]) ? 'checked' : '' ; ?> >
</ div >
2026-10-04 17:40:59 +02:00
2026-10-18 21:40:43 +02:00
< ? php if ( ! empty ( $currentSeason )) : ?>
2026-10-04 17:40:59 +02:00
< div class = " form-group " >
< label for = " has_paid " > Bezahlt ( < ? php echo htmlspecialchars ( $currentSeason [ 'name' ]); ?> ):</label>
< input type = " checkbox " id = " has_paid " name = " has_paid " value = " 1 " < ? php echo isset ( $payments [ $editUser [ 'id' ]]) ? 'checked' : '' ; ?> >
</ div >
< ? php endif ; ?>
2026-10-04 17:34:43 +02:00
< div class = " form-group " >
2026-10-18 21:40:43 +02:00
< button type = " submit " > Speichern </ button >
< a href = " /index.php?page=admin_users " > Abbrechen </ a >
2026-10-04 17:34:43 +02:00
</ div >
</ form >
< hr >
2026-10-18 21:40:43 +02:00
< ? php endif ; ?>
2026-10-04 17:34:43 +02:00
<!-- User List -->
< h2 > Benutzerliste </ h2 >
< table >
< thead >
< tr >
< th > Name </ th >
< th > E - Mail </ th >
< th > Admin </ th >
2026-10-04 17:40:59 +02:00
< ? php if ( ! empty ( $currentSeason )) : ?>
< th > Bezahlt ( < ? php echo htmlspecialchars ( $currentSeason [ 'name' ]); ?> )</th>
< ? php endif ; ?>
2026-10-04 17:34:43 +02:00
< th > Aktionen </ th >
</ tr >
</ thead >
< tbody >
< ? php foreach ( $users as $user ) : ?>
< tr >
< td >< ? php echo htmlspecialchars ( $user [ 'name' ]); ?> </td>
< td >< ? php echo htmlspecialchars ( $user [ 'email' ]); ?> </td>
< td >< ? php echo $user [ 'admin' ] ? 'Ja' : 'Nein' ; ?> </td>
2026-10-04 17:40:59 +02:00
< ? php if ( ! empty ( $currentSeason )) : ?>
< td >
< ? php if ( isset ( $payments [ $user [ 'id' ]])) : ?>
Ja ( < ? php echo date ( 'd.m.Y' , strtotime ( $payments [ $user [ 'id' ]])); ?> )
< ? php else : ?>
Nein
< ? php endif ; ?>
</ td >
< ? php endif ; ?>
2026-10-04 17:34:43 +02:00
< td >
< a href = " /index.php?page=admin_users&edit_id=<?php echo $user['id'] ; ?> " > Bearbeiten </ a >
< form action = " /index.php?page=admin_users " method = " post " style = " display: inline; " onsubmit = " return confirm('Sicher, dass du diesen Benutzer löschen willst?'); " >
< input type = " hidden " name = " action " value = " delete " >
< input type = " hidden " name = " id " value = " <?php echo $user['id'] ; ?> " >
< button type = " submit " class = " link-button " > Löschen </ button >
</ form >
</ td >
</ tr >
< ? php endforeach ; ?>
</ tbody >
</ table >
< style >
/* From login.php, for consistency */
. form - group {
margin - bottom : 1 rem ;
}
. form - group label {
display : inline - block ;
width : 150 px ;
text - align : right ;
margin - right : 10 px ;
}
. form - group button , . form - group a {
margin - left : calc ( 150 px + 10 px );
}
. link - button {
background : none ;
border : none ;
2026-10-04 23:38:41 +02:00
color : var ( -- link );
2026-10-04 17:34:43 +02:00
cursor : pointer ;
padding : 0 ;
font - size : inherit ;
text - decoration : underline ;
font - family : inherit ;
}
</ style >
< ? php require __DIR__ . '/../partials/footer.php' ; ?>