Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. <?php
  2.  
  3. // Require database class
  4. require("../database.class.php");
  5.  
  6. // Start session
  7. if(session_id() == '') {
  8. session_start();
  9. }
  10.  
  11. class TimeTableController extends Database {
  12.  
  13. // Array of all dates and their times `after the function GetDates has been called
  14. public $dates = array();
  15.  
  16. // Function to check how many students have signed up for a specific 'tijdstip'
  17. public function CheckAvailability($timeID) {
  18. // SQL to get the row 'bezet' whith the ID of the mentor
  19. $sql = "SELECT bezet FROM tijdstip WHERE id='$timeID'";
  20. // Execute the SQL Query into the database
  21. $result = mysqli_query($this->mysqli, $sql);
  22. // Get array of the result
  23. $row = mysqli_fetch_assoc($result);
  24.  
  25. // Return the data of the row 'bezet'
  26. return $row['bezet'];
  27. }
  28.  
  29. // Function to check all dates and their timeSEs for a specific mentor
  30. public function GetDates($mentorID) {
  31. // SQL Query to get the datum, tijd_start, tijd_einde with a specific mentor ID
  32. $sql = "SELECT datum, tijd_start, tijd_einde FROM tijdstip WHERE mentor_id='$mentorID'";
  33. // Execute the query into the database
  34. $result = mysqli_query($this->mysqli, $sql);
  35.  
  36. // Loop through all the rows and put them in a multidimensional array
  37. while($row = mysqli_fetch_array($result)) {
  38. $this->dates[] = array($row['datum'], $row['tijd_start'], $row['tijd_einde']);
  39. }
  40. }
  41.  
  42. public function CreateReservation() {
  43. // Check if inputs are empty
  44. if($_POST['student_id'] == "") {
  45. $_SESSION['errormsg'] = "U heeft geen studenten id ingevuld!";
  46. return false;
  47. } else {
  48. $student_id = $_POST['student_id'];
  49. }
  50.  
  51. if($_POST['mentor_id'] == "") {
  52. $_SESSION['errormsg'] = "U heeft geen mentor id ingevuld!";
  53. return false;
  54. } else {
  55. $mentor_id = $_POST['mentor_id'];
  56. }
  57.  
  58. if($_POST['inputTime'] == "") {
  59. $_SESSION['errormsg'] = "U heeft geen tijd ingevuld!";
  60. return false;
  61. } else {
  62. $tijden = $_POST['inputTime'];
  63. }
  64.  
  65. if($_POST['inputPersons'] == "") {
  66. $_SESSION['errormsg'] = "U heeft geen personen ingevuld!";
  67. return false;
  68. } else {
  69. $inputPersons = $_POST['inputPersons'];
  70. }
  71.  
  72. // Get times from the input, explode it to get the start and end time
  73. $timeArray = explode(" - ", $tijden);
  74. $timeBegin = $timeArray[0];
  75. $timeEnd = $timeArray[1];
  76. $class_id = $_SESSION['class_id'];
  77.  
  78. // Sql query to get the tijdstip_id from the database
  79. $sql = "SELECT id FROM tijdstip WHERE tijd_start='$timeBegin' AND tijd_einde='$timeEnd' AND mentor_id= ( SELECT id FROM mentor WHERE klas_id='$class_id')";
  80. $result = mysqli_query($this->mysqli, $sql);
  81. $rij = mysqli_fetch_array($result);
  82. $tijdstip_id = $rij['id'];
  83. }
  84. }
  85. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement