207 lines
7.2 KiB
PHP
207 lines
7.2 KiB
PHP
|
<?php include('includes/header.php'); ?>
|
||
|
<div>
|
||
|
<div class="card card-body p-4">
|
||
|
<?= alertMessage(); ?>
|
||
|
<?php
|
||
|
$paramResult = checkParamId('id');
|
||
|
if(!is_numeric($paramResult)){
|
||
|
echo '<div class="alert alert-danger" role="alert">'.$paramResult.'</div>';
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
$form = getById('tbl_forms',checkParamId('id'));
|
||
|
?>
|
||
|
<?php
|
||
|
if($form['status'] == 200 )
|
||
|
{
|
||
|
?>
|
||
|
<div class="row">
|
||
|
<div class="col-5">
|
||
|
<h3 class="fw-semibold mb-4"><?= $form['data']['name']; ?></h3>
|
||
|
</div>
|
||
|
<div class="col-7">
|
||
|
<a href="forms.php" class="btn ms-2 btn-light float-end"> <i class="ti ti-arrow-left"></i> Zurück zur Übersicht</a>
|
||
|
<a href="forms-reports.php?id=<?= $form['data']['id']; ?>" class="btn btn-danger float-end"> <i class="ti ti-chart-area"></i> Auswertung</a>
|
||
|
</div>
|
||
|
</div>
|
||
|
<form action="code.php" method="POST">
|
||
|
|
||
|
<input type="hidden" name="id" value="<?= $form['data']['id'] ;?>" required>
|
||
|
<div class="row">
|
||
|
<div class="col-auto">
|
||
|
<div class="mb-3">
|
||
|
<label class="form-label">Name</label>
|
||
|
<input type="text" name="name" value="<?= $form['data']['name'] ;?>" required class="form-control">
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="col-auto">
|
||
|
<div class="mb-3">
|
||
|
<label class="form-label">Formular anzeigen bis</label>
|
||
|
<input type="date" name="deadline" value="<?= $form['data']['deadline'] ;?>" class="form-control">
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<?php
|
||
|
$classes = getClassesGroupedByLevel('active');
|
||
|
$assignedClasses = getAssignedItems('tbl_assign_forms_classes', $form['data']['id'], 'class_id', 'form_id');
|
||
|
|
||
|
if (!empty($classes)) {
|
||
|
echo "<h5 class='fw-semibold mb-4 mt-3'>Klassenzuweisung</h5>";
|
||
|
echo "<div class='row'>";
|
||
|
|
||
|
foreach ($classes as $level => $levelClasses) {
|
||
|
echo "<div class='col'>";
|
||
|
echo "<div class='card' style='border-radius:10px;'>";
|
||
|
echo "<div class='card-header fw-semibold bg-info-subtle'>";
|
||
|
echo "$level";
|
||
|
echo "</div>";
|
||
|
|
||
|
// Checkbox für "Alle Auswählen"
|
||
|
$idSafeLevel = str_replace(['.', ' '], '_', $level);
|
||
|
$idSafeLevel = preg_replace('/[^A-Za-z0-9_]/', '', $idSafeLevel);
|
||
|
echo "<div class='form-check ms-3 mt-2 mb-3'>";
|
||
|
echo "<input class='form-check-input' type='checkbox' id='select-all_$idSafeLevel' data-toggle='select-all' data-level='$level'>";
|
||
|
echo "<label class='form-check-label' for='select-all_$idSafeLevel' style='user-select: none; -webkit-user-select: none; -ms-user-select: none;' for=''>Alle auswählen</label>";
|
||
|
echo "</div>";
|
||
|
|
||
|
foreach ($levelClasses as $class) {
|
||
|
$classId = $class['id'];
|
||
|
$className = htmlspecialchars($class['display_name']);
|
||
|
|
||
|
$isChecked = in_array($classId, $assignedClasses) ? 'checked' : '';
|
||
|
|
||
|
// Klassenname und Textfeld für Lektionen nebeneinander
|
||
|
echo "<div class='form-check ms-3 mt-2 mb-3 d-flex align-items-center'>";
|
||
|
echo "<input class='form-check-input me-2' type='checkbox' name='selected_classes[]' id='class_$classId' data-class-id='$level' value='$classId' $isChecked>";
|
||
|
echo "<label class='form-check-label me-2' style='user-select: none; -webkit-user-select: none; -ms-user-select: none;' for='class_$classId'>$className</label>";
|
||
|
|
||
|
// Nummerfeld für Lektionen mit der Klassen-ID als Index
|
||
|
echo "<input type='number' style='width: 120px;' class='form-control' name='lesson_numbers[]' id='lesson_number_$classId' placeholder='Lektionen'>";
|
||
|
|
||
|
echo "</div>";
|
||
|
}
|
||
|
|
||
|
echo "</div>";
|
||
|
echo "</div>";
|
||
|
}
|
||
|
|
||
|
echo "</div>";
|
||
|
} else {
|
||
|
echo "<h5>Keine Klassen gefunden.</h5>";
|
||
|
}
|
||
|
?>
|
||
|
<div class="col-12">
|
||
|
<button type="submit" name="updateform" class="btn btn-info mx-3 float-end"><i class="ti ti-check"></i> Änderungen speichern</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div>
|
||
|
<div class="card card-body p-4">
|
||
|
<div class="row">
|
||
|
<div class="col-6">
|
||
|
<h5 class="fw-semibold mb-4">Formularabschnitte</h5>
|
||
|
</div>
|
||
|
<div class="col-6">
|
||
|
<a href="formscontents-create.php?form_id=<?= $form['data']['id'] ;?>" class="btn btn-info float-end"> <i class="ti ti-plus"></i> Formularabschnitt hinzufügen</a>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="table-responsive">
|
||
|
<table class="table table-hover">
|
||
|
<tbody>
|
||
|
<?php
|
||
|
$form_id = $form['data']['id'];
|
||
|
$formcontents = getAll('id,name', 'tbl_formcontents', "WHERE form_id='$form_id'");
|
||
|
|
||
|
if(mysqli_num_rows($formcontents) > 0)
|
||
|
{
|
||
|
foreach($formcontents as $formcontentEntry)
|
||
|
{
|
||
|
?>
|
||
|
<tr>
|
||
|
<td><?= $formcontentEntry['name']; ?></td>
|
||
|
<td>
|
||
|
<a href="formscontents-edit.php?id=<?= $formcontentEntry['id']; ?>" class="btn btn-light btn-sm float-end mx-1"> <i class="ti ti-arrow-right"></i></a>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<?php
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
?>
|
||
|
<tr>
|
||
|
<td colspan="7"> Keine Formularinhalte vorhanden</td>
|
||
|
</tr>
|
||
|
<?php
|
||
|
}
|
||
|
|
||
|
?>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
</form>
|
||
|
</div>
|
||
|
|
||
|
<?php
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
echo '<div class="alert alert-danger" role="alert">'.$form['message'].'</div>';
|
||
|
}
|
||
|
|
||
|
?>
|
||
|
<script>
|
||
|
$(document).ready(function() {
|
||
|
// Überwache Änderungen an den Klassen-Checkboxen
|
||
|
$('input[name="selected_classes[]"]').change(function() {
|
||
|
updateSelectAllCheckbox($(this).data('class-id'));
|
||
|
});
|
||
|
|
||
|
// Überwache Änderungen an den "Alle auswählen"-Checkboxen
|
||
|
$('input[type="checkbox"][data-toggle="select-all"]').change(function() {
|
||
|
var level = $(this).data('level');
|
||
|
var isChecked = $(this).prop('checked');
|
||
|
$('input[name="selected_classes[]"][data-class-id="' + level + '"]').prop('checked', isChecked);
|
||
|
});
|
||
|
|
||
|
// Initialisiere den Status der "Alle auswählen"-Checkboxen beim Laden der Seite
|
||
|
$('input[data-toggle="select-all"]').each(function() {
|
||
|
updateSelectAllCheckbox($(this).data('level'));
|
||
|
});
|
||
|
});
|
||
|
|
||
|
// Funktion zum Aktualisieren des Status der "Alle auswählen"-Checkboxen
|
||
|
function updateSelectAllCheckbox(level) {
|
||
|
var classCheckboxes = $('input[name="selected_classes[]"][data-class-id="' + level + '"]');
|
||
|
var selectAllCheckbox = $('input[data-toggle="select-all"][data-level="' + level + '"]');
|
||
|
|
||
|
var allChecked = true;
|
||
|
var anyChecked = false;
|
||
|
|
||
|
classCheckboxes.each(function() {
|
||
|
if (!$(this).prop('checked')) {
|
||
|
allChecked = false;
|
||
|
} else {
|
||
|
anyChecked = true;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
selectAllCheckbox.prop('checked', allChecked);
|
||
|
selectAllCheckbox.prop('indeterminate', anyChecked && !allChecked);
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<script>
|
||
|
|
||
|
const popover = new bootstrap.Popover('.popover-dismiss', {
|
||
|
trigger: 'focus'
|
||
|
});
|
||
|
|
||
|
</script>
|
||
|
|
||
|
<?php include('includes/footer.php'); ?>
|