Limmat/admin/students-edit.php

154 lines
7.2 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">
<?= alertMessage(); ?>
<div class="row">
<div class="col-6">
<h3 class="fw-semibold mb-4">Schüler:in bearbeiten</h3>
</div>
<div class="col-6">
<a href="students.php" class="btn btn-light float-end"> <i class="ti ti-arrow-left"></i> Zurück zur Übersicht</a>
</div>
</div>
<form action="code.php" method="POST">
<?php
$paramResult = checkParamId('id');
if(!is_numeric($paramResult)){
echo '<div class="alert alert-danger" role="alert">'.$paramResult.'</div>';
return false;
}
$student = getById('tbl_students',checkParamId('id'));
if(($student['status'] == 200) && $student['data']['status'] == 'archived')
{
echo '<div class="alert alert-warning" role="alert">Dieser Eintrag ist archiviert und kann nicht bearbeitet werden. Bitte reaktivieren Sie den Eintrag, um sie zu bearbeiten.</div>';
}
elseif($student['status'] == 200 )
{
?>
<input type="hidden" name="id" value="<?= $student['data']['id'] ;?>" required>
<div class="row">
<div class="col-6">
<div class="mb-3">
<label class="form-label">Vorname</label>
<input type="text" name="firstname" value="<?= $student['data']['firstname'] ;?>" required class="form-control">
</div>
</div>
<div class="col-6">
<div class="mb-3">
<label class="form-label">Nachname</label>
<input type="text" name="lastname" value="<?= $student['data']['lastname'] ;?>" required class="form-control">
</div>
</div>
<div class="col-6">
<div class="mb-3">
<label class="form-label">Benutzer-ID</label>
<input type="text" name="user-id" value="<?= $student['data']['userid'] ;?>" required pattern="[A-Za-z0-9\-]+" onkeydown="if(['Space'].includes(arguments[0].code)){return false;}" class="form-control" disabled >
</div>
</div>
<div class="col-6">
<div class="mb-3">
<label class="form-label">Geburtsdatum</label>
<input type="date" name="dateofbirth" value="<?= $student['data']['dateofbirth'] ;?>" required class="form-control">
</div>
</div>
<div class="col-6">
<div class="mb-3">
<label class="form-label">Kennwort</label>
<input type="password" name="password" value="<?= $student['data']['password'] ;?>" required class="form-control">
</div>
</div>
<div class="col-6">
<div class="mb-3">
<label class="form-label">Geschlecht</label>
<select name="gender" required class="form-select">
<option value="">--- Auswählen ---</option>
<?php createEnumSelect('tbl_students', 'gender', $student['data']['gender']); ?>
</select>
</div>
</div>
<div class="col-6">
<div class="mb-3">
<label class="form-label">Klasse</label>
<select name="class" required class="form-select">
<option value="">--- Auswählen ---</option>
<?php
$classOptions = getAllClasses('active');
foreach ($classOptions as $id => $display_name) {?>
<option value="<?= $id; ?>" <?= $student['data']['class'] == $id ? 'selected':'' ;?>><?= $display_name; ?></option>
<?php }
?>
</select>
</div>
</div>
<div class="col-6">
<div class="mb-3">
<label class="form-label">E-Mail Schüler:in</label>
<input type="email" name="email-student" value="<?= $student['data']['emailstudent'] ;?>" required class="form-control">
</div>
</div>
<div class="col-6">
<div class="mb-3">
<label class="form-label">E-Mail Elternteil 1</label>
<input type="email" name="email-parents-1" value="<?= $student['data']['emailparent1'] ;?>" required class="form-control">
</div>
</div>
<div class="col-6">
<div class="mb-3">
<label class="form-label">E-Mail Elternteil 2</label>
<input type="email" name="email-parents-2" value="<?= $student['data']['emailparent2'] ;?>" class="form-control">
</div>
</div>
<div class="col-6">
<div class="mb-3">
<label class="form-label">Status</label>
<select name="status" class="form-select">
<?php
$enumValueLabels = [
'active' => 'Aktiv',
'disabled' => 'Inaktiv'
];
$selectedValue = isset($enumValueLabels[$student['data']['status']]) ? $student['data']['status'] : '';
createEnumSelectFiltered('tbl_students', 'status', $selectedValue, $enumValueLabels);
?>
</select>
</div>
</div>
<div class="col-md-12">
<button type="submit" name="updatestudent" class="btn btn-info mx-1 float-end"><i class="ti ti-check"></i> Änderungen speichern</button>
<a type="button" class="btn btn-warning float-end mx-1" data-bs-toggle="modal" data-bs-target="#archiveStudent"><i class="ti ti-archive"></i> Archivieren</a>
</div>
</div>
<?php
}
else
{
echo '<div class="alert alert-danger" role="alert">'.$student['message'].'</div>';
}
?>
</form>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="archiveStudent" 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">Schüler:in archivieren</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> <?= $student['data']['firstname'] . ' ' . $student['data']['lastname']?></b> archivieren möchten?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Abbrechen</button>
<a href="students-archive.php?id=<?= $student['data']['id']; ?>" class="btn btn-warning"><i class="ti ti-archive"></i> Archivieren</a>
</div>
</div>
</div>
</div>
<!-- Modal Ende -->
<?php include('includes/footer.php'); ?>