998 lines
34 KiB
PHP
998 lines
34 KiB
PHP
<?php
|
|
require '../config/function.php';
|
|
|
|
if(isset($_POST['createstudent']))
|
|
{
|
|
$firstname = validate($_POST['firstname']);
|
|
$lastname = validate($_POST['lastname']);
|
|
$userid = validate($_POST['user-id']);
|
|
$dateofbirth = validate($_POST['dateofbirth']);
|
|
$password = validate($_POST['password']);
|
|
$gender = validate($_POST['gender']);
|
|
$class = validate($_POST['class']);
|
|
$emailstudent = validate($_POST['email-student']);
|
|
$emailparents1 = validate($_POST['email-parents-1']);
|
|
$emailparents2 = validate($_POST['email-parents-2']);
|
|
$status = validate($_POST['status']);
|
|
|
|
|
|
if($firstname != '' || $lastname != '' || $userid != '' || $dateofbirth != '' || $password != '' || $gender != '' || $class != '' || $emailstudent != '' || $emailparents1 != '')
|
|
{
|
|
$query="SELECT userid FROM tbl_students WHERE userid='$userid';";
|
|
$result=mysqli_query($conn,$query);
|
|
|
|
if (mysqli_num_rows($result) > 0)
|
|
{
|
|
|
|
$row = mysqli_fetch_assoc($result);
|
|
if($userid==isset($row['userid']))
|
|
{
|
|
redirect('students-create.php','Diese Benutzer-ID ist bereits vorhanden');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$query = "INSERT INTO tbl_students (userid,firstname,lastname,dateofbirth,password,gender,emailstudent,emailparent1,emailparent2,class,status) VALUES ('$userid','$firstname','$lastname','$dateofbirth','$password','$gender','$emailstudent','$emailparents1','$emailparents2','$class','$status')";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
if($result){
|
|
redirect('students.php','Schüler:in erfolgreich hinzugefügt','success');
|
|
} else{
|
|
redirect('students-create.php','Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
redirect('students-create.php','Bitte füllen Sie alle Felder aus','alert');
|
|
}
|
|
|
|
}
|
|
|
|
if(isset($_POST['updatestudent']))
|
|
{
|
|
$firstname = validate($_POST['firstname']);
|
|
$lastname = validate($_POST['lastname']);
|
|
$dateofbirth = validate($_POST['dateofbirth']);
|
|
$password = validate($_POST['password']);
|
|
$gender = validate($_POST['gender']);
|
|
$class = validate($_POST['class']);
|
|
$emailstudent = validate($_POST['email-student']);
|
|
$emailparents1 = validate($_POST['email-parents-1']);
|
|
$emailparents2 = validate($_POST['email-parents-2']);
|
|
$status = validate($_POST['status']);
|
|
|
|
$id = validate($_POST['id']);
|
|
$student = getById('tbl_students',$id);
|
|
if($student['status' != 200])
|
|
{
|
|
redirect('students-edit.php?id='.$id,'Keine/n Schüler:in mit dieser ID gefunden','danger');
|
|
}
|
|
|
|
if($firstname != '' || $lastname != '' || $userid != '' || $dateofbirth != '' || $password != '' || $gender != '' || $class != '' || $emailstudent != '' || $emailparents1 != '')
|
|
{
|
|
$query = "UPDATE tbl_students SET
|
|
firstname='$firstname',
|
|
lastname='$lastname',
|
|
dateofbirth='$dateofbirth',
|
|
password='$password',
|
|
gender='$gender',
|
|
emailstudent='$emailstudent',
|
|
emailparent1='$emailparents1',
|
|
emailparent2='$emailparents2',
|
|
class='$class',
|
|
status='$status'
|
|
WHERE id='$id' ";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
if($result)
|
|
{
|
|
redirect('students-edit.php?id='.$id,'Schüler:in erfolgreich bearbeitet','success');
|
|
}
|
|
else
|
|
{
|
|
redirect('students-create.php','Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
redirect('students-edit.php','Bitte füllen Sie alle Felder aus','alert');
|
|
}
|
|
}
|
|
|
|
if(isset($_POST['createteacher']))
|
|
{
|
|
$firstname = validate($_POST['firstname']);
|
|
$lastname = validate($_POST['lastname']);
|
|
$email = validate($_POST['email']);
|
|
|
|
if($firstname != '' || $lastname != '' || $email != '')
|
|
{
|
|
$query = "INSERT INTO tbl_teachers (firstname,lastname,email) VALUES ('$firstname','$lastname','$email')";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
if($result){
|
|
redirect('teachers.php','Lehrperson erfolgreich hinzugefügt','success');
|
|
} else{
|
|
redirect('teachers-create.php','Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
redirect('teachers-create.php','Bitte füllen Sie alle Felder aus','alert');
|
|
}
|
|
|
|
}
|
|
|
|
if(isset($_POST['updateteacher']))
|
|
{
|
|
$firstname = validate($_POST['firstname']);
|
|
$lastname = validate($_POST['lastname']);
|
|
$email = validate($_POST['email']);
|
|
|
|
$id = validate($_POST['id']);
|
|
$teacher = getById('tbl_teachers',$id);
|
|
if($teacher['status' != 200])
|
|
{
|
|
redirect('teachers-edit.php?id='.$id,'Keinen User mit dieser ID gefunden','danger');
|
|
}
|
|
|
|
if($firstname != '' || $lastname != '' || $email != '')
|
|
{
|
|
$query = "UPDATE tbl_teachers SET
|
|
firstname='$firstname',
|
|
lastname='$lastname',
|
|
email='$email'
|
|
WHERE id='$id'";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
if($result)
|
|
{
|
|
redirect('teachers-edit.php?id='.$id,'Lehrperson erfolgreich bearbeitet','success');
|
|
}
|
|
else
|
|
{
|
|
redirect('teachers-create.php','Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
redirect('teachers-edit.php','Bitte füllen Sie alle Felder aus','alert');
|
|
}
|
|
}
|
|
|
|
if(isset($_POST['createadmin']))
|
|
{
|
|
$firstname = validate($_POST['firstname']);
|
|
$lastname = validate($_POST['lastname']);
|
|
$userid = validate($_POST['user-id']);
|
|
$password = validate($_POST['password']);
|
|
$status = validate($_POST['status']);
|
|
|
|
if($firstname != '' || $lastname != '' || $userid != '' || $password != '' || $status != '')
|
|
{
|
|
$query="SELECT userid FROM tbl_admins WHERE userid='$userid';";
|
|
$result=mysqli_query($conn,$query);
|
|
|
|
if (mysqli_num_rows($result) > 0)
|
|
{
|
|
|
|
$row = mysqli_fetch_assoc($result);
|
|
if($userid==isset($row['userid']))
|
|
{
|
|
redirect('admins-create.php','Diese Benutzer-ID ist bereits vorhanden','danger');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$query = "INSERT INTO tbl_admins (userid,firstname,lastname,password,status) VALUES ('$userid','$firstname','$lastname','$password','$status')";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
if($result){
|
|
redirect('admins.php','Administrator erfolgreich hinzugefügt','success');
|
|
} else{
|
|
redirect('admins-create.php','Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
redirect('admins-create.php','Bitte füllen Sie alle Felder aus','alert');
|
|
}
|
|
|
|
}
|
|
|
|
if(isset($_POST['updateadmin']))
|
|
{
|
|
$firstname = validate($_POST['firstname']);
|
|
$lastname = validate($_POST['lastname']);
|
|
$userid = validate($_POST['user-id']);
|
|
$password = validate($_POST['password']);
|
|
$status = validate($_POST['status']);
|
|
|
|
$id = validate($_POST['id']);
|
|
$admin = getById('tbl_admins',$id);
|
|
if($admin['status' != 200])
|
|
{
|
|
redirect('admins-edit.php?id='.$id,'Keinen Administrator mit dieser ID gefunden','danger');
|
|
}
|
|
|
|
if($firstname != '' || $lastname != '' || $userid != '' || $password != '' || $status != '')
|
|
{
|
|
$query = "UPDATE tbl_admins SET
|
|
userid='$userid',
|
|
firstname='$firstname',
|
|
lastname='$lastname',
|
|
password='$password',
|
|
status='$status'
|
|
WHERE id='$id' ";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
if($result)
|
|
{
|
|
redirect('admins-edit.php?id='.$id,'Administrator erfolgreich bearbeitet','success');
|
|
}
|
|
else
|
|
{
|
|
redirect('admins-create.php','Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
redirect('admins-edit.php','Bitte füllen Sie alle Felder aus','alert');
|
|
}
|
|
}
|
|
|
|
if(isset($_POST['createclass']))
|
|
{
|
|
$sek = validate($_POST['sek']);
|
|
$type = validate($_POST['type']);
|
|
$name = validate($_POST['name']);
|
|
$status = 'active';
|
|
|
|
|
|
if($sek != '' || $type != '' || $name != '' || $status != '' )
|
|
{
|
|
|
|
$query = "INSERT INTO tbl_classes (name,sek,type,status) VALUES ('$name','$sek','$type','$status')";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
if($result){
|
|
redirect('classes.php','Klasse erfolgreich hinzugefügt','success');
|
|
} else{
|
|
redirect('classes-create.php','Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
redirect('classes-create.php','Bitte füllen Sie alle Felder aus','alert');
|
|
}
|
|
|
|
}
|
|
|
|
if(isset($_POST['updateclass']))
|
|
{
|
|
$sek = validate($_POST['sek']);
|
|
$type = validate($_POST['type']);
|
|
$name = validate($_POST['name']);
|
|
|
|
$id = validate($_POST['id']);
|
|
$class = getById('tbl_classes',$id);
|
|
if($class['status' != 200])
|
|
{
|
|
redirect('classes-edit.php?id='.$id,'Keine Klasse mit dieser ID gefunden','danger');
|
|
}
|
|
|
|
if($sek != '' || $type != '' || $name != '')
|
|
{
|
|
$query = "UPDATE tbl_classes SET
|
|
sek='$sek',
|
|
type='$type',
|
|
name='$name'
|
|
WHERE id='$id' ";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
if($result)
|
|
{
|
|
redirect('classes-edit.php?id='.$id,'Klasse erfolgreich bearbeitet','success');
|
|
}
|
|
else
|
|
{
|
|
redirect('classes-edit.php','Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
redirect('classes-edit.php','Bitte füllen Sie alle Felder aus','alert');
|
|
}
|
|
}
|
|
|
|
if(isset($_POST['createcategory']))
|
|
{
|
|
$name = validate($_POST['name']);
|
|
|
|
if($name != '' )
|
|
{
|
|
|
|
$query = "INSERT INTO tbl_categories (name) VALUES ('$name')";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
if($result){
|
|
$ID = mysqli_insert_id($conn);
|
|
header("Location: categories-edit.php?id=$ID");
|
|
} else{
|
|
redirect('categories-create.php','Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
redirect('categories-create.php','Bitte füllen Sie alle Felder aus','alert');
|
|
}
|
|
|
|
}
|
|
|
|
if(isset($_POST['createform']))
|
|
{
|
|
$name = validate($_POST['name']);
|
|
|
|
if($name != '' )
|
|
{
|
|
|
|
$query = "INSERT INTO tbl_forms (name) VALUES ('$name')";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
if($result){
|
|
$ID = mysqli_insert_id($conn);
|
|
header("Location: forms-edit.php?id=$ID");
|
|
} else{
|
|
redirect('forms-create.php','Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
redirect('forms-create.php','Bitte füllen Sie alle Felder aus','alert');
|
|
}
|
|
|
|
}
|
|
|
|
|
|
if(isset($_POST['updatecategory']))
|
|
{
|
|
$name = validate($_POST['name']);
|
|
$deadline = validate($_POST['deadline']);
|
|
$min_courses = validate($_POST['min_courses']);
|
|
$max_courses = validate($_POST['max_courses']);
|
|
$maxassign_courses = validate($_POST['maxassign_courses']);
|
|
$showuntil = validate($_POST['showuntil']);
|
|
|
|
$registration = isset($_POST['regbtnradio']) ? $_POST['regbtnradio'] : '';
|
|
switch($registration){
|
|
case 'registrationyes': $registration = 'yes';
|
|
break;
|
|
case 'registrationno': $registration = 'no';
|
|
break;
|
|
case 'registrationcustom': $registration = 'custom';
|
|
break;
|
|
}
|
|
$confirmation= isset($_POST['confbtnradio']) ? $_POST['confbtnradio'] : '';
|
|
switch($confirmation){
|
|
case 'confirmationyes': $confirmation = 'yes';
|
|
break;
|
|
case 'confirmationno': $confirmation = 'no';
|
|
break;
|
|
case 'confirmationcustom': $confirmation = 'custom';
|
|
break;
|
|
}
|
|
$type= isset($_POST['typebtnradio']) ? $_POST['typebtnradio'] : '';
|
|
switch($type){
|
|
case 'typeyear': $type = 'year';
|
|
break;
|
|
case 'typesemester': $type = 'semester';
|
|
break;
|
|
}
|
|
$priority= isset($_POST['priobtnradio']) ? $_POST['priobtnradio'] : '';
|
|
switch($priority){
|
|
case 'prioyes': $priority = 'yes';
|
|
break;
|
|
case 'priono': $priority = 'no';
|
|
break;
|
|
}
|
|
$showuntil_set= isset($_POST['datebtnradio']) ? $_POST['datebtnradio'] : '';
|
|
switch($showuntil_set){
|
|
case 'showdateyes': $showuntil_set = 'yes';
|
|
break;
|
|
case 'showdatecustom': $showuntil_set = 'custom';
|
|
break;
|
|
}
|
|
$deadline_set= isset($_POST['deadlbtnradio']) ? $_POST['deadlbtnradio'] : '';
|
|
switch($deadline_set){
|
|
case 'showdeadlineyes': $deadline_set = 'yes';
|
|
break;
|
|
case 'showdeadlinecustom': $deadline_set = 'custom';
|
|
break;
|
|
}
|
|
$selectedClasses = isset($_POST['selected_classes']) ? $_POST['selected_classes'] : array();
|
|
$id = validate($_POST['id']);
|
|
$category = getById('tbl_categories',$id);
|
|
if($category['status' != 200])
|
|
{
|
|
redirect('category-edit.php?id='.$id,'Keine Kategorie mit dieser ID gefunden','danger');
|
|
}
|
|
|
|
$deleteQuery = "DELETE FROM tbl_assign_categories_classes WHERE category_id = '$id'";
|
|
mysqli_query($conn, $deleteQuery);
|
|
|
|
foreach ($selectedClasses as $classId) {
|
|
$insertQuery = "INSERT INTO tbl_assign_categories_classes (category_id, class_id) VALUES ('$id', '$classId')";
|
|
mysqli_query($conn, $insertQuery);
|
|
}
|
|
|
|
|
|
if($name != '' || $registration != '')
|
|
{
|
|
$query = "UPDATE tbl_categories SET
|
|
name='$name',
|
|
registration='$registration',
|
|
confirmation='$confirmation',
|
|
type='$type',
|
|
set_priority='$priority',
|
|
deadline='$deadline',
|
|
min_courses='$min_courses',
|
|
max_courses='$max_courses',
|
|
maxassign_courses='$maxassign_courses',
|
|
showuntil='$showuntil',
|
|
deadline_set='$deadline_set',
|
|
showuntil_set='$showuntil_set'
|
|
WHERE id='$id'";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
if($result)
|
|
{
|
|
redirect('categories-edit.php?id='.$id,'Kategorie erfolgreich bearbeitet','success');
|
|
}
|
|
else
|
|
{
|
|
redirect('categories-edit.php','Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
redirect('categories-edit.php','Bitte füllen Sie alle Felder aus','alert');
|
|
}
|
|
}
|
|
|
|
|
|
if(isset($_POST['updateform'])) {
|
|
$name = validate($_POST['name']);
|
|
$deadline = validate($_POST['deadline']);
|
|
|
|
// Lektionen für jede Klasse
|
|
$lessonNumbers = isset($_POST['lesson_numbers']) ? $_POST['lesson_numbers'] : array();
|
|
|
|
$selectedClasses = isset($_POST['selected_classes']) ? $_POST['selected_classes'] : array();
|
|
$id = validate($_POST['id']);
|
|
$form = getById('tbl_forms',$id);
|
|
|
|
if($form['status' != 200]) {
|
|
redirect('forms-edit.php?id='.$id,'Kein Formular mit dieser ID gefunden','danger');
|
|
}
|
|
|
|
// Vorhandene Zuweisungen für das Formular löschen
|
|
$deleteQuery = "DELETE FROM tbl_assign_forms_classes WHERE form_id = '$id'";
|
|
mysqli_query($conn, $deleteQuery);
|
|
|
|
// Neue Zuweisungen für jede Klasse eintragen
|
|
foreach ($_POST['selected_classes'] as $classId) {
|
|
$lessonNumber = isset($_POST['lesson_number_' . $classId]) ? validate($_POST['lesson_number_' . $classId]) : NULL;
|
|
|
|
// SQL-Abfrage für das Einfügen der Zuweisungen mit Lektionsnummer
|
|
$insertQuery = "INSERT INTO tbl_assign_forms_classes (form_id, class_id) VALUES ('$id', '$classId')";
|
|
mysqli_query($conn, $insertQuery);
|
|
}
|
|
|
|
// Das Formular aktualisieren, falls Name und Deadline vorhanden sind
|
|
if($name != '' || $deadline != '') {
|
|
$query = "UPDATE tbl_forms SET
|
|
name='$name',
|
|
deadline='$deadline'
|
|
WHERE id='$id'";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
if($result) {
|
|
redirect('forms-edit.php?id='.$id,'Formular erfolgreich bearbeitet','success');
|
|
} else {
|
|
redirect('forms-edit.php?id='.$id,'Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
} else {
|
|
redirect('forms-edit.php?id='.$id,'Bitte füllen Sie alle Felder aus','alert');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(isset($_POST['createcourse']))
|
|
{
|
|
$category = validate($_POST['category_id']);
|
|
$name = validate($_POST['name']);
|
|
$description = $_POST['description'];
|
|
$slogan = validate($_POST['slogan']);
|
|
$place = validate($_POST['place']);
|
|
$days = $_POST['days'];
|
|
$start_times = $_POST['start_times'];
|
|
$end_times = $_POST['end_times'];
|
|
|
|
$registration= isset($_POST['regbtnradio']) ? $_POST['regbtnradio'] : '';
|
|
switch($registration){
|
|
case 'registrationyes': $registration = 'yes';
|
|
break;
|
|
case 'registrationno': $registration = 'no';
|
|
break;
|
|
}
|
|
$confirmation= isset($_POST['confbtnradio']) ? $_POST['confbtnradio'] : '';
|
|
switch($confirmation){
|
|
case 'confirmationyes': $confirmation = 'yes';
|
|
break;
|
|
case 'confirmationno': $confirmation = 'no';
|
|
break;
|
|
}
|
|
$maxbehavior= isset($_POST['maxbtnradio']) ? $_POST['maxbtnradio'] : '';
|
|
switch($maxbehavior){
|
|
case 'hidecourse': $maxbehavior = 'hide';
|
|
break;
|
|
case 'showcourse': $maxbehavior = 'show';
|
|
break;
|
|
}
|
|
if(array_key_exists('showuntil', $_POST)) {
|
|
$showuntil = $_POST['showuntil'];
|
|
}else{
|
|
$showuntil = "";
|
|
}
|
|
if(array_key_exists('deadline', $_POST)) {
|
|
$deadline = $_POST['deadline'];
|
|
}else{
|
|
$deadline = "";
|
|
}
|
|
if(array_key_exists('minstudentyear', $_POST)) {
|
|
$minstudentyear = $_POST['minstudentyear'];
|
|
}else{
|
|
$minstudentyear = "";
|
|
}
|
|
if(array_key_exists('maxstudentyear', $_POST)) {
|
|
$maxstudentyear = $_POST['maxstudentyear'];
|
|
}else{
|
|
$maxstudentyear = "";
|
|
}
|
|
if(array_key_exists('minstudent1sem', $_POST)) {
|
|
$minstudent1sem = $_POST['minstudent1sem'];
|
|
}else{
|
|
$minstudent1sem = "";
|
|
}
|
|
if(array_key_exists('minstudent2sem', $_POST)) {
|
|
$minstudent2sem = $_POST['minstudent2sem'];
|
|
}else{
|
|
$minstudent2sem = "";
|
|
}
|
|
if(array_key_exists('maxstudent1sem', $_POST)) {
|
|
$maxstudent1sem = $_POST['maxstudent1sem'];
|
|
}else{
|
|
$maxstudent1sem = "";
|
|
}
|
|
if(array_key_exists('maxstudent2sem', $_POST)) {
|
|
$maxstudent2sem = $_POST['maxstudent2sem'];
|
|
}else{
|
|
$maxstudent2sem = "";
|
|
}
|
|
if(array_key_exists('teacheryear', $_POST)) {
|
|
$teacheryear = $_POST['teacheryear'];
|
|
}else{
|
|
$teacheryear = "";
|
|
}
|
|
if(array_key_exists('teacher1sem', $_POST)) {
|
|
$teacher1sem = $_POST['teacher1sem'];
|
|
}else{
|
|
$teacher1sem = "";
|
|
}
|
|
if(array_key_exists('teacher2sem', $_POST)) {
|
|
$teacher2sem = $_POST['teacher2sem'];
|
|
}else{
|
|
$teacher2sem = "";
|
|
}
|
|
|
|
if($name != '' || $place != '')
|
|
{
|
|
|
|
$query = "INSERT INTO tbl_courses
|
|
(name,slogan,description,category_id,show_until,deadline,place,teacherid_year,teacherid_1sem,teacherid_2sem,minstudents_year,maxstudents_year,minstudents_1sem,maxstudents_1sem,minstudents_2sem,maxstudents_2sem,registration,confirmation,max_behavior)
|
|
VALUES ('$name','$slogan','$description','$category',NULLIF('$showuntil',''),NULLIF('$deadline',''),'$place',NULLIF('$teacheryear',''),NULLIF('$teacher1sem',''),NULLIF('$teacher2sem',''),NULLIF('$minstudentyear',''),NULLIF('$maxstudentyear',''),NULLIF('$minstudent1sem',''),NULLIF('$maxstudent1sem',''),NULLIF('$minstudent2sem',''),NULLIF('$maxstudent2sem',''),'$registration','$confirmation','$maxbehavior')";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
if($result){
|
|
$courseID = mysqli_insert_id($conn);
|
|
$selectedClasses = isset($_POST['selected_classes']) ? $_POST['selected_classes'] : array();
|
|
if(!empty($selectedClasses)){
|
|
foreach ($selectedClasses as $classId) {
|
|
$insertQuery = "INSERT INTO tbl_assign_courses_classes (course_id, class_id) VALUES ('$courseID', '$classId')";
|
|
$classresult = mysqli_query($conn, $insertQuery);
|
|
}
|
|
}
|
|
else{
|
|
$classresult = "Keine Klassen ausgewählt";
|
|
}
|
|
|
|
if (!empty($days) && !empty($start_times) && !empty($end_times)) {
|
|
for ($i = 0; $i < count($days); $i++) {
|
|
$day = $days[$i];
|
|
$start_time = $start_times[$i];
|
|
$end_time = $end_times[$i];
|
|
|
|
// SQL-Abfrage zum Einfügen der Daten
|
|
$datequery = "INSERT INTO tbl_coursedates (course_id, day, start_time, end_time) VALUES ('$courseID','$day', '$start_time', '$end_time')";
|
|
$dateresult = mysqli_query($conn, $datequery);
|
|
}
|
|
}
|
|
else{
|
|
$dateresult = "Keine Daten ausgewählt";
|
|
}
|
|
|
|
if(($result && $classresult && $dateresult)){
|
|
redirect('courses-edit.php?id=' . $courseID,'Kurs wurde erfolgreich erstellt','success');
|
|
}
|
|
else{
|
|
redirect('courses-create.php?cat_id=' . $category,'Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
} else{
|
|
redirect('courses-create.php?cat_id=' . $category,'Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
redirect('courses-create.php?cat_id=' . $category,'Bitte füllen Sie alle Felder aus','alert');
|
|
}
|
|
|
|
}
|
|
|
|
if(isset($_POST['createformcontent']))
|
|
{
|
|
$form = validate($_POST['form_id']);
|
|
$name = validate($_POST['name']);
|
|
$min = $_POST['min'];
|
|
$max = $_POST['max'];
|
|
|
|
if($name != '')
|
|
{
|
|
|
|
$query = "INSERT INTO tbl_formcontents
|
|
(name,form_id,min,max)
|
|
VALUES ('$name','$form','$min','$maxs')";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
if($result){
|
|
$formcontentID = mysqli_insert_id($conn);
|
|
$selectedClasses = isset($_POST['selected_classes']) ? $_POST['selected_classes'] : array();
|
|
if(!empty($selectedClasses)){
|
|
foreach ($selectedClasses as $classId) {
|
|
$insertQuery = "INSERT INTO tbl_assign_formcontents_classes (formcontent_id, class_id) VALUES ('$formcontentID', '$classId')";
|
|
$classresult = mysqli_query($conn, $insertQuery);
|
|
}
|
|
}
|
|
else{
|
|
$classresult = "Keine Klassen ausgewählt";
|
|
}
|
|
|
|
|
|
if(($result && $classresult)){
|
|
redirect('formscontents-edit.php?id=' . $formcontentID,'Formularabschnitt wurde erfolgreich erstellt','success');
|
|
}
|
|
else{
|
|
redirect('formscontents-create.php?form_id=' . $form,'Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
} else{
|
|
redirect('formscontents-create.php?form_id=' . $form,'Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
redirect('formscontents-create.php?form_id=' . $form,'Bitte füllen Sie alle Felder aus','alert');
|
|
}
|
|
|
|
}
|
|
|
|
if(isset($_POST['createformcourse']))
|
|
{
|
|
$formcontent = validate($_POST['formcontent_id']);
|
|
$name = validate($_POST['name']);
|
|
$lessons = $_POST['lessons'];
|
|
|
|
if($name != '' && $lessons != '')
|
|
{
|
|
|
|
$query = "INSERT INTO tbl_formcourses
|
|
(name,lessons,formcontent_id)
|
|
VALUES ('$name','$lessons','$formcontent')";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
if($result){
|
|
$formcourseID = mysqli_insert_id($conn);
|
|
$selectedClasses = isset($_POST['selected_classes']) ? $_POST['selected_classes'] : array();
|
|
if(!empty($selectedClasses)){
|
|
foreach ($selectedClasses as $classId) {
|
|
$insertQuery = "INSERT INTO tbl_assign_formcourses_classes (formcourses_id, class_id) VALUES ('$formcourseID', '$classId')";
|
|
$classresult = mysqli_query($conn, $insertQuery);
|
|
}
|
|
}
|
|
else{
|
|
$classresult = "Keine Klassen ausgewählt";
|
|
}
|
|
|
|
|
|
if(($result && $classresult)){
|
|
redirect('formscontents-edit.php?id=' . $formcontent,'Kurs wurde erfolgreich erstellt','success');
|
|
}
|
|
else{
|
|
redirect('formscontents-edit.php?id=' . $formcontent,'Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
} else{
|
|
redirect('formscontents-edit.php?id=' . $formcontent,'Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
redirect('formscontents-edit.php?id=' . $formcontent,'Bitte füllen Sie alle Felder aus','alert');
|
|
}
|
|
|
|
}
|
|
|
|
if(isset($_POST['updatecourse']))
|
|
{
|
|
$name = validate($_POST['name']);
|
|
$description = $_POST['description'];
|
|
$slogan = validate($_POST['slogan']);
|
|
$place = validate($_POST['place']);
|
|
$days = $_POST['days'];
|
|
$start_times = $_POST['start_times'];
|
|
$end_times = $_POST['end_times'];
|
|
|
|
$registration= isset($_POST['regbtnradio']) ? $_POST['regbtnradio'] : '';
|
|
switch($registration){
|
|
case 'registrationyes': $registration = 'yes';
|
|
break;
|
|
case 'registrationno': $registration = 'no';
|
|
break;
|
|
}
|
|
$confirmation= isset($_POST['confbtnradio']) ? $_POST['confbtnradio'] : '';
|
|
switch($confirmation){
|
|
case 'confirmationyes': $confirmation = 'yes';
|
|
break;
|
|
case 'confirmationno': $confirmation = 'no';
|
|
break;
|
|
}
|
|
$maxbehavior= isset($_POST['maxbtnradio']) ? $_POST['maxbtnradio'] : '';
|
|
switch($maxbehavior){
|
|
case 'hidecourse': $maxbehavior = 'hide';
|
|
break;
|
|
case 'showcourse': $maxbehavior = 'show';
|
|
break;
|
|
}
|
|
if(array_key_exists('showuntil', $_POST)) {
|
|
$showuntil = $_POST['showuntil'];
|
|
}else{
|
|
$showuntil = "";
|
|
}
|
|
if(array_key_exists('deadline', $_POST)) {
|
|
$deadline = $_POST['deadline'];
|
|
}else{
|
|
$deadline = "";
|
|
}
|
|
if(array_key_exists('minstudentyear', $_POST)) {
|
|
$minstudentyear = $_POST['minstudentyear'];
|
|
}else{
|
|
$minstudentyear = "";
|
|
}
|
|
if(array_key_exists('maxstudentyear', $_POST)) {
|
|
$maxstudentyear = $_POST['maxstudentyear'];
|
|
}else{
|
|
$maxstudentyear = "";
|
|
}
|
|
if(array_key_exists('minstudent1sem', $_POST)) {
|
|
$minstudent1sem = $_POST['minstudent1sem'];
|
|
}else{
|
|
$minstudent1sem = "";
|
|
}
|
|
if(array_key_exists('minstudent2sem', $_POST)) {
|
|
$minstudent2sem = $_POST['minstudent2sem'];
|
|
}else{
|
|
$minstudent2sem = "";
|
|
}
|
|
if(array_key_exists('maxstudent1sem', $_POST)) {
|
|
$maxstudent1sem = $_POST['maxstudent1sem'];
|
|
}else{
|
|
$maxstudent1sem = "";
|
|
}
|
|
if(array_key_exists('maxstudent2sem', $_POST)) {
|
|
$maxstudent2sem = $_POST['maxstudent2sem'];
|
|
}else{
|
|
$maxstudent2sem = "";
|
|
}
|
|
if(array_key_exists('teacheryear', $_POST)) {
|
|
$teacheryear = $_POST['teacheryear'];
|
|
}else{
|
|
$teacheryear = "";
|
|
}
|
|
if(array_key_exists('teacher1sem', $_POST)) {
|
|
$teacher1sem = $_POST['teacher1sem'];
|
|
}else{
|
|
$teacher1sem = "";
|
|
}
|
|
if(array_key_exists('teacher2sem', $_POST)) {
|
|
$teacher2sem = $_POST['teacher2sem'];
|
|
}else{
|
|
$teacher2sem = "";
|
|
}
|
|
$course_id = validate($_POST['course_id']);
|
|
|
|
if($name != '' || $place != '')
|
|
{
|
|
|
|
$query = "UPDATE tbl_courses SET
|
|
name='$name',
|
|
slogan='$slogan',
|
|
description='$description',
|
|
show_until=NULLIF('$showuntil',''),
|
|
deadline=NULLIF('$deadline',''),
|
|
place='$place',
|
|
teacherid_year=NULLIF('$teacheryear',''),
|
|
teacherid_1sem=NULLIF('$teacher1sem',''),
|
|
teacherid_2sem=NULLIF('$teacher2sem',''),
|
|
minstudents_year=NULLIF('$minstudentyear',''),
|
|
maxstudents_year=NULLIF('$maxstudentyear',''),
|
|
minstudents_1sem=NULLIF('$minstudent1sem',''),
|
|
maxstudents_1sem=NULLIF('$maxstudent1sem',''),
|
|
minstudents_2sem=NULLIF('$minstudent2sem',''),
|
|
maxstudents_2sem=NULLIF('$maxstudent2sem',''),
|
|
registration='$registration',
|
|
confirmation='$confirmation',
|
|
max_behavior='$maxbehavior'
|
|
WHERE id='$course_id'";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
$deleteclassesquery = "DELETE FROM tbl_assign_courses_classes WHERE course_id='$course_id'";
|
|
$deleteclassesresult = mysqli_query($conn, $deleteclassesquery);
|
|
|
|
$selectedClasses = isset($_POST['selected_classes']) ? $_POST['selected_classes'] : array();
|
|
|
|
if(!empty($selectedClasses)){
|
|
foreach ($selectedClasses as $classId) {
|
|
$insertQuery = "INSERT INTO tbl_assign_courses_classes (course_id, class_id) VALUES ('$course_id', '$classId')";
|
|
$classresult = mysqli_query($conn, $insertQuery);
|
|
}
|
|
}
|
|
else{
|
|
$classresult = "Keine Klassen zugewiesen";
|
|
}
|
|
|
|
$deletetimesquery = "DELETE FROM tbl_coursedates WHERE course_id='$course_id'";
|
|
$deletetimesresult = mysqli_query($conn, $deletetimesquery);
|
|
|
|
if (!empty($days) && !empty($start_times) && !empty($end_times)) {
|
|
for ($i = 0; $i < count($days); $i++) {
|
|
$day = $days[$i];
|
|
$start_time = $start_times[$i];
|
|
$end_time = $end_times[$i];
|
|
|
|
// SQL-Abfrage zum Einfügen der Daten
|
|
$datequery = "INSERT INTO tbl_coursedates (course_id, day, start_time, end_time) VALUES ('$course_id','$day', '$start_time', '$end_time')";
|
|
$dateresult = mysqli_query($conn, $datequery);
|
|
}
|
|
}
|
|
else{
|
|
$dateresult = "Keine Daten vorhanden";
|
|
}
|
|
|
|
if($result && $classresult && $dateresult){
|
|
redirect('courses-edit.php?id=' . $course_id,'Kurs wurde erfolgreich bearbeitet','success');
|
|
}
|
|
else{
|
|
redirect('courses-edit.php?id=' . $course_id,'Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
redirect('courses-edit.php?id=' . $course_id,'Bitte füllen Sie alle Felder aus','alert');
|
|
}
|
|
|
|
}
|
|
|
|
if(isset($_POST['updateformcontent']))
|
|
{
|
|
$name = validate($_POST['name']);
|
|
$min = $_POST['min'];
|
|
$max = $_POST['max'];
|
|
$formcontent_id = validate($_POST['formcontent_id']);
|
|
|
|
if($name != '')
|
|
{
|
|
|
|
$query = "UPDATE tbl_formcontents SET
|
|
name='$name',
|
|
min='$min',
|
|
max='$max'
|
|
WHERE id='$formcontent_id'";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
$deleteclassesquery = "DELETE FROM tbl_assign_formcontents_classes WHERE formcontent_id='$formcontent_id'";
|
|
$deleteclassesresult = mysqli_query($conn, $deleteclassesquery);
|
|
|
|
$selectedClasses = isset($_POST['selected_classes']) ? $_POST['selected_classes'] : array();
|
|
|
|
if(!empty($selectedClasses)){
|
|
foreach ($selectedClasses as $classId) {
|
|
$insertQuery = "INSERT INTO tbl_assign_formcontents_classes (formcontent_id, class_id) VALUES ('$formcontent_id', '$classId')";
|
|
$classresult = mysqli_query($conn, $insertQuery);
|
|
}
|
|
}
|
|
else{
|
|
$classresult = "Keine Klassen zugewiesen";
|
|
}
|
|
if($result && $classresult){
|
|
redirect('formscontents-edit.php?id=' . $formcontent_id,'Formularabschnitt wurde erfolgreich bearbeitet','success');
|
|
}
|
|
else{
|
|
redirect('formscontents-edit.php?id=' . $formcontent_id,'Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
redirect('formscontents-edit.php?id=' . $formcontent_id,'Bitte füllen Sie alle Felder aus','alert');
|
|
}
|
|
|
|
}
|
|
|
|
if(isset($_POST['updateformcourse']))
|
|
{
|
|
$name = validate($_POST['name']);
|
|
$lessons = $_POST['lessons'];
|
|
$formcourse_id = validate($_POST['formcourse_id']);
|
|
|
|
if($name != '' && $lessons != '')
|
|
{
|
|
|
|
$query = "UPDATE tbl_formcourses SET
|
|
name='$name',
|
|
lessons='$lessons'
|
|
WHERE id='$formcourse_id'";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
$deleteclassesquery = "DELETE FROM tbl_assign_formcourses_classes WHERE formcourses_id='$formcourse_id'";
|
|
$deleteclassesresult = mysqli_query($conn, $deleteclassesquery);
|
|
|
|
$selectedClasses = isset($_POST['selected_classes']) ? $_POST['selected_classes'] : array();
|
|
|
|
if(!empty($selectedClasses)){
|
|
foreach ($selectedClasses as $classId) {
|
|
$insertQuery = "INSERT INTO tbl_assign_formcourses_classes (formcourses_id, class_id) VALUES ('$formcourse_id', '$classId')";
|
|
$classresult = mysqli_query($conn, $insertQuery);
|
|
}
|
|
}
|
|
else{
|
|
$classresult = "Keine Klassen zugewiesen";
|
|
}
|
|
if($result && $classresult){
|
|
redirect('formscourses-edit.php?id=' . $formcourse_id,'Kurs wurde erfolgreich bearbeitet','success');
|
|
}
|
|
else{
|
|
redirect('formscourses-edit.php?id=' . $formcourse_id,'Es ist ein Fehler aufgetreten','danger');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
redirect('formscourses-edit.php?id=' . $formcourse_id,'Bitte füllen Sie alle Felder aus','alert');
|
|
}
|
|
|
|
}
|
|
?>
|