diff --git a/htdocs/data.php b/htdocs/data.php index 7c17100edc528380aeaa36663233a634c73552ae..4fdb68568ca9f2b054fc2604025a85004effc22a 100644 --- a/htdocs/data.php +++ b/htdocs/data.php @@ -35,6 +35,7 @@ function fill_table($bdd){ $bdd->query($sql); $sql = "CREATE TABLE requests ( + ID int NOT NULL, student int NOT NULL, teacher int NOT NULL, dispo varchar(20) NOT NULL, diff --git a/htdocs/forms.php b/htdocs/forms.php index e515cd216bb04609001eb346acfee797c4585a93..a6f5a6c2feac96a7f30cf9819e781a93a9fedfe5 100644 --- a/htdocs/forms.php +++ b/htdocs/forms.php @@ -83,7 +83,7 @@ function inscription_student($bdd){ </div> </div> - <div class="col-sm-1"> + <div class="col-sm-2"> <div class="form-check form-check-inline"> <input class="form-check-input" type="checkbox" id="inlineCheckbox23" value="mercredi" name="mercredi"> <label class="form-check-label" for="inlineCheckbox23">Mercredi</label> @@ -97,7 +97,7 @@ function inscription_student($bdd){ </div> </div> - <div class="col-sm-1"> + <div class="col-sm-2"> <div class="form-check form-check-inline"> <input class="form-check-input" type="checkbox" id="inlineCheckbox25" value="vendredi" name="vendredi"> <label class="form-check-label" for="inlineCheckbox25">Vendredi</label> @@ -314,16 +314,4 @@ function connection($bdd){ <?php } -function match($student, $userRepository) { - $matchs = match_script($student, $userRepository); - - foreach($matchs as $match) { - $firstnameProf = $match["teacher"]->getFirstname(); - $nameProf = $match["teacher"]->getName(); - $subject = $match["subject"]; - $dispo = $match["dispo"]; - echo "Le professeur <b>$firstnameProf $nameProf</b> est disponible pour un cours de <b>$subject</b> le <b>$dispo</b>.</br>"; - } -} - ?> diff --git a/htdocs/requests/requests.php b/htdocs/requests/requests.php index c74990a983ddbcc984391ee43b267e30fc21fe0f..515093de341633c313d9e57f24d4ddf4003cc98b 100644 --- a/htdocs/requests/requests.php +++ b/htdocs/requests/requests.php @@ -23,4 +23,4 @@ include("/opt/lampp/htdocs/pima/head.php"); </div> </div> </section> -<?php #include("/opt/lampp/htdocs/pima/footer.php"); ?> \ No newline at end of file +<?php #include("/opt/lampp/htdocs/pima/footer.php"); ?> diff --git a/htdocs/student/matchs.php b/htdocs/student/matchs.php index c833e4b0b38bfda90d39ac7fe6d677df678700d2..f7939dfae5c85bf2d16b9d51a8ce69446547b24c 100644 --- a/htdocs/student/matchs.php +++ b/htdocs/student/matchs.php @@ -14,54 +14,63 @@ include("/opt/lampp/htdocs/pima/head.php"); if (isset($_SESSION['currentMail'])) { $students = $userRepository->fetchStudent(); foreach($students as $student) { - if ($_SESSION['currentMail'] == $student->getMail()) { - echo "<header><h2>Mes matchs</h2></header> <p>"; - match($student, $userRepository); - echo "</p>"; - } - } - } + if ($_SESSION['currentMail'] != $student->getMail()) { + ?> - if (isset($_POST['id'])) { - $students = $userRepository->fetchStudent(); - foreach($students as $student) { - if ($_POST['id'] == $student->getID()) { - $firstname = $student->getFirstname(); - $name = $student->getName(); - echo "<header><h2>Mes matchs ($firstname $name)</h2></header> <p>"; - match($student, $userRepository); - echo "</p>"; + <header><h2>Accès interdit</h2></header> + <p>Vous devez être authentifié⋅e en tant qu'élève pour avoir accès à cette page.</p> + + <?php } - } - } + else { + echo "<header><h2>Mes matchs</h2></header> <p>"; - else { - ?> - <header><h2>Accès interdit</h2></header> - <p>Vous devez être authentifié⋅e en tant qu'élève pour avoir accès à cette page.</p> - <?php - } - ?> + $matchs = match_script($student, $userRepository); + $idMatch = 0; - <!-- Formulaire pour tester l'affichage. Quand l'authentification sera faite, - le supprimer et utiliser l'ID dans _SESSION au lieu de _POST --> - <p> - <form action="matchs.php" method="post"> - <div class="form-group form-row"> - <label for="inputId" class="col-sm-2 col-form-label">Identifiant</label> - <div class="col-sm-10"> - <input type='text' class="form-control" id="inputIde" name='id' placeholder="Identifiant"> - </div> - </div> + echo '<form action="/pima/student/matchs.php" method="post">'; - <div class="form-group form-row"> - <div class="offset-sm-2"> - <!-- <button type="submit">S'inscrire</button> --> - <input type="submit" value="Se connecter"> + foreach($matchs as $match) { + $firstnameProf = $match["teacher"]->getFirstname(); + $nameProf = $match["teacher"]->getName(); + $subject = $match["subject"]; + $dispo = $match["dispo"]; + $idMatch++; + + ?> + <div class="form-group form-row"> + <div class="form-check"> + <input class="form-check-input" type="checkbox" id="checkbox<?php echo "$idMatch" ?>" value="match<?php echo "$idMatch" ?>" name="match<?php echo "$idMatch" ?>"> + <label class="form-check-label" for="checkbox<?php echo "$idMatch" ?>" style="font-weight: 300;"> + <?php echo "Cours de <b>$subject</b> le <b>$dispo</b> par <b>$firstnameProf $nameProf</b>" ?> + </label> + </div> + </div> + <?php + } + ?> + <div class="form-group form-row"> + <input type="submit" value="Demander"> </div> - </div> - </form> - </p> + + </form> + + </p> + <?php + /*if (isset($_POST['match1'])){ + $firstname = $_POST['firstname']; + $name = $_POST['name']; + $type = "Student"; + $mail = $_POST['mail']; + $mdp = $_POST['mdp']; + + $sql = "INSERT INTO users(student, teacher, dispo, subject, accepted) values (?, ?, ?, ?, ?, ?)"; + $bdd->prepare($sql)->execute([$firstname,$name,$type,$mail,$mdp]); + }*/ + } + } + } + ?> </div> </div> </section>