Compare commits
1
Commits
dev
...
new-timetable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d453b93a0 |
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
include_once(__DIR__ . '/../../controller/DatabaseController.php');
|
||||
include_once(__DIR__ . '/../../controller/DataController.php');
|
||||
|
||||
class changeTimetable{
|
||||
/**
|
||||
* get Teachers
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTeachers() : array {
|
||||
$teachers = [];
|
||||
$teachers = DatabaseShow(
|
||||
'Lehrer',
|
||||
'NAME'
|
||||
);
|
||||
|
||||
return $teachers;
|
||||
}
|
||||
|
||||
/**
|
||||
* get Rooms
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRooms() : array {
|
||||
$rooms = [];
|
||||
$rooms = DatabaseShow(
|
||||
'Raum',
|
||||
'RAUM_NR'
|
||||
);
|
||||
|
||||
return $rooms;
|
||||
}
|
||||
|
||||
/**
|
||||
* get Lessons
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLessons() : array {
|
||||
$lessons = [];
|
||||
$lessons = DatabaseShow(
|
||||
'Fach',
|
||||
'FACH'
|
||||
);
|
||||
|
||||
return $lessons;
|
||||
}
|
||||
|
||||
/**
|
||||
* add a new Teacher to the Table
|
||||
*
|
||||
* @param array $teachers
|
||||
* @return boolean
|
||||
*/
|
||||
public function addTeachers(array $teachers) : bool {
|
||||
try {
|
||||
foreach ($teachers as $teacher) {
|
||||
DatabaseInsert(
|
||||
'Lehrer',
|
||||
'NAME',
|
||||
$teacher
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (Exception $error) {
|
||||
echo $error;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* add a new Room Number to the Tabke
|
||||
*
|
||||
* @param array $roomnrs
|
||||
* @return bool
|
||||
*/
|
||||
public function addRooms(array $roomnrs) : bool {
|
||||
try {
|
||||
foreach ($roomnrs as $roomnr) {
|
||||
DatabaseInsert(
|
||||
'Raum',
|
||||
'RAUM_NR',
|
||||
$roomnr,
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (Exception $error) {
|
||||
echo $error;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function addLessons(array $lessons) : bool {
|
||||
try {
|
||||
foreach ($lessons as $lesson) {
|
||||
DatabaseInsert(
|
||||
'Fach',
|
||||
'FACH',
|
||||
$lesson
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (Exception $error) {
|
||||
echo $error;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function setInitial(string $Teacher, string $Initial) : bool {
|
||||
try {
|
||||
$ID = DatabaseShow(
|
||||
'Lehrer',
|
||||
'ID',
|
||||
'NAME = ?',
|
||||
$Teacher,
|
||||
);
|
||||
|
||||
$ID = $ID[0]['ID'];
|
||||
|
||||
DatabaseUpdate(
|
||||
'Lehrer',
|
||||
'INITIALS = ?',
|
||||
'ID = ?',
|
||||
$Initial,
|
||||
$ID
|
||||
);
|
||||
|
||||
return true;
|
||||
} catch (Exception $error) {
|
||||
echo $error;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$TimeTable = new changeTimetable();
|
||||
|
||||
#$TimeTable->addTeachers([
|
||||
# '',
|
||||
#]);
|
||||
|
||||
#$TimeTable->addRooms([
|
||||
# '',
|
||||
#]);
|
||||
|
||||
#$TimeTable->addLessons([
|
||||
# '',
|
||||
#]);
|
||||
|
||||
#(new changeTimetable()->addLessons(['', '']));
|
||||
|
||||
#(new changeTimetable()->setInitial('', ''));
|
||||
Reference in new issue
Block a user