diff --git a/README.md b/README.md index 35cfbe60d3c3425cb2cc3288f7c074f94ad02074..44502a6be7e0aa7db764e6205a6c7338478d74d0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ #Projet PIMA - +. #Git Avec votre console rendez-vous dans le dossier où vous allez travailler (cd pour se déplacer, mkdir pour créer un dossier). Faites la commande "git clone https://git.iiens.net/pima/projet.git". diff --git a/htdocs/connection/connection.php b/htdocs/connection/connection.php index 340faef3b5e574edbe063b561d356446238c9d7c..075a78776d753d8cf5639587a0dad138e2679e9b 100644 --- a/htdocs/connection/connection.php +++ b/htdocs/connection/connection.php @@ -37,6 +37,7 @@ include("/opt/lampp/htdocs/pima/head.php"); $_SESSION['currentFirstname'] = $firstname; $_SESSION['currentMail'] = $mail; $_SESSION['currentType'] = $user->getType(); + $_SESSION['currentRequest'] = $user->getRequest(); } } @@ -54,4 +55,4 @@ include("/opt/lampp/htdocs/pima/head.php"); </div> </div> </section> -<?php #include("/opt/lampp/htdocs/pima/footer.php"); ?> +<?php include("/opt/lampp/htdocs/pima/footer.php"); ?> diff --git a/htdocs/cours/cours.php b/htdocs/cours/cours.php new file mode 100644 index 0000000000000000000000000000000000000000..a49d1ca2da80df06d34b983e4e380c55bde20d5d --- /dev/null +++ b/htdocs/cours/cours.php @@ -0,0 +1,26 @@ +<?php +$title = 'Projet PIMA'; +include("/opt/lampp/htdocs/pima/head.php"); +?> +</head> + +<?php include("/opt/lampp/htdocs/pima/header.php"); ?> + +<section class="wrapper style1"> + <div class="container"> + <div id="content"> + <article> + <header> + <h2>Mes cours</h2> + </header> + + <p> + <?php + $r = $_SESSION['currentRequest']; + print_cours($users,$r,$bdd); ?> + </p> + </article> + </div> + </div> +</section> +<?php include("/opt/lampp/htdocs/pima/footer.php"); ?> \ No newline at end of file diff --git a/htdocs/data.php b/htdocs/data.php index 7c17100edc528380aeaa36663233a634c73552ae..5d0b19d14d3c248d2d8689ab93a02e52931f7cb6 100644 --- a/htdocs/data.php +++ b/htdocs/data.php @@ -122,6 +122,8 @@ function fill_table($bdd){ #Remplissage de REQUESTS $sql = "INSERT INTO requests(student, teacher, dispo, subject, accepted) values (?, ?, ?, ?, ?)"; $bdd->prepare($sql)->execute([1, 8, 'Lundi', 'Math', 0]); + $sql = "INSERT INTO requests(student, teacher, dispo, subject, accepted) values (?, ?, ?, ?, ?)"; + $bdd->prepare($sql)->execute([2, 8, 'Lundi', 'Math', 1]); } function print_data($users){ diff --git a/htdocs/footer.php b/htdocs/footer.php index d19fc50566a9f57ec1c018ec066ad615ecdffc04..810b6022cec4df2ec2c3b37b21fa4dc7d32b285b 100644 --- a/htdocs/footer.php +++ b/htdocs/footer.php @@ -1,70 +1,5 @@ <div id="footer"> - <div class="container"> - <div class="row-arc"> - <section class="col-arc-3 col-arc-6-narrower col-arc-12-mobilep"> - <h3>Links to Stuff</h3> - <ul class="links"> - <li><a href="#">Mattis et quis rutrum</a></li> - <li><a href="#">Suspendisse amet varius</a></li> - <li><a href="#">Sed et dapibus quis</a></li> - <li><a href="#">Rutrum accumsan dolor</a></li> - <li><a href="#">Mattis rutrum accumsan</a></li> - <li><a href="#">Suspendisse varius nibh</a></li> - <li><a href="#">Sed et dapibus mattis</a></li> - </ul> - </section> - <section class="col-arc-3 col-arc-6-narrower col-arc-12-mobilep"> - <h3>More Links to Stuff</h3> - <ul class="links"> - <li><a href="#">Duis neque nisi dapibus</a></li> - <li><a href="#">Sed et dapibus quis</a></li> - <li><a href="#">Rutrum accumsan sed</a></li> - <li><a href="#">Mattis et sed accumsan</a></li> - <li><a href="#">Duis neque nisi sed</a></li> - <li><a href="#">Sed et dapibus quis</a></li> - <li><a href="#">Rutrum amet varius</a></li> - </ul> - </section> - <section class="col-arc-6 col-arc-12-narrower"> - <h3>Get In Touch</h3> - <form> - <div class="row-arc gtr-50"> - <div class="col-arc-6 col-arc-12-mobilep"> - <input type="text" name="name" id="name" placeholder="Name" /> - </div> - <div class="col-arc-6 col-arc-12-mobilep"> - <input type="email" name="email" id="email" placeholder="Email" /> - </div> - <div class="col-arc-12"> - <textarea name="message" id="message" placeholder="Message" rows="5"></textarea> - </div> - <div class="col-arc-12"> - <ul class="actions"> - <li><input type="submit" class="button alt" value="Send Message" /></li> - </ul> - </div> - </div> - </form> - </section> - </div> - </div> - - <!-- Icons --> - <ul class="icons"> - <li><a href="#" class="icon brands fa-twitter"><span class="label">Twitter</span></a></li> - <li><a href="#" class="icon brands fa-facebook-f"><span class="label">Facebook</span></a></li> - <li><a href="#" class="icon brands fa-github"><span class="label">GitHub</span></a></li> - <li><a href="#" class="icon brands fa-linkedin-in"><span class="label">LinkedIn</span></a></li> - <li><a href="#" class="icon brands fa-google-plus-g"><span class="label">Google+</span></a></li> - </ul> - - <!-- Copyright --> - <div class="copyright"> - <ul class="menu"> - <li>© Untitled. All rights reserved</li><li>Design: <a href="http://html5up.net">HTML5 UP</a></li> - </ul> - </div> - + </div> </div> diff --git a/htdocs/forms.php b/htdocs/forms.php index 9d4cc9fa3de23411fbe2331be83ad644b5158e71..2e7532f072280426de3a7062f0476a23e6e3e9f3 100644 --- a/htdocs/forms.php +++ b/htdocs/forms.php @@ -306,7 +306,6 @@ function connection($bdd){ <div class="form-group form-row"> <div class="offset-sm-2"> - <!-- <button type="submit">S'inscrire</button> --> <input type="submit" value="Se connecter"> </div> </div> diff --git a/htdocs/head.php b/htdocs/head.php index 2bf3be7a78c70e5a293fe445fd364257219383fa..92ef59049b2cf820ffa8b11eaa72effe37b5f776 100644 --- a/htdocs/head.php +++ b/htdocs/head.php @@ -12,6 +12,8 @@ $bdd = new PDO('mysql:host=localhost;dbname=pima;charset=utf8', 'root', ''); $userRepository = new \User\UserRepository($bdd); +$users = $userRepository->fetchAll(); + if (!isset($_SESSION['connected'])){ $_SESSION['connected'] = false; } diff --git a/htdocs/header.php b/htdocs/header.php index 02666cb8a885592aa7a42941260098a707019eb2..1ec1ced28cec575473d71a7f8599c3a28100cd95 100644 --- a/htdocs/header.php +++ b/htdocs/header.php @@ -64,6 +64,29 @@ <a href="/pima/student/matchs.php">Mes matchs</a> </li> + <?php } + + if ($_SESSION['currentType'] == 'Teacher') { + ?> + + <li + + <?php + if (basename(getcwd()) == 'requests') + echo 'class="current"'; + ?> > + <a href="/pima/requests/requests.php">Mes demandes</a> + </li> + + <li + + <?php + if (basename(getcwd()) == 'cours') + echo 'class="current"'; + ?> > + <a href="/pima/cours/cours.php">Mes cours</a> + </li> + <?php } ?> <li diff --git a/htdocs/index.php b/htdocs/index.php index 956a3344f6c2ba1e00aad97d57102de60ce6f171..9c2c8dfc33ba37ca59f49c6b1b91bc0098952532 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -19,7 +19,14 @@ include("head.php"); if ($_SESSION['connected']){ $firstname = $_SESSION['currentFirstname']; $name = $_SESSION['currentName']; - echo "$firstname $name "; + echo "<p>Bienvenue $firstname $name</p>"; + } + + else{ + echo "<p>Bienvenue sur Adopte un prof</p> + <p>Ici vous pourrez contacter un professeur pour des cours particulier ou vous même proposer + des cours.</br> + Inscrivez-vous ou connecter-vous pour marcher sur le chemin de la reussite!</p>"; } if (isset($_POST['reset'])){ @@ -35,4 +42,4 @@ include("head.php"); </div> </div> </section> -<?php #include("footer.php"); ?> +<?php include("footer.php"); ?> diff --git a/htdocs/inscription/inscription_student.php b/htdocs/inscription/inscription_student.php index e8f19d833b590b055acdaef3f1bb6b8224b46ec2..fdd3478ce08cd2def7b0b77fc2079161cd4232eb 100644 --- a/htdocs/inscription/inscription_student.php +++ b/htdocs/inscription/inscription_student.php @@ -28,4 +28,4 @@ include("/opt/lampp/htdocs/pima/head.php"); </div> </section> -<?php #include("/opt/lampp/htdocs/pima/footer.php"); ?> +<?php include("/opt/lampp/htdocs/pima/footer.php"); ?> diff --git a/htdocs/match_script.php b/htdocs/match_script.php index f381933a110087d9532ffd48fb4028a22c256b9e..64e458f2b996e5d6c0b0376f2e488fdfe46d1349 100644 --- a/htdocs/match_script.php +++ b/htdocs/match_script.php @@ -39,4 +39,119 @@ function match_script($student, $userRepository){ #} } +function print_requests($users,$requests,$bdd){ + + $noRequest = true; + + + foreach($requests as $r){ + + if (isset($_POST['accept'])){ + echo "Demande acceptée"; + set_accepted($_POST['idTeacher'],$_POST['idStudent'],$bdd); + } + + else{ + + $subject = $r->subject; + $studentId = $r->student; + $teacherId = $r->teacher; + $dispo = $r->dispo; + $accepted = $r->accepted; + + + foreach ($users as $u){ + if ($u->getId() == $studentId){ + $studentName = $u->getName(); + $studentFirstname = $u->getFirstname(); + } + } + + if (!$accepted){ + echo "<p>Vous avez une demande de $studentFirstname $studentName pour un cours de $subject le $dispo</p>"; + $noRequest = false; + + echo "<form action='/pima/requests/requests.php' method='post'> + <div class='form-group form-row'> + <div class='offset-sm'> + <input type='hidden' value=$studentId name='idTeacher'> + <input type='hidden' value=$teacherId name='idStudent'> + <input type='submit' value='Accepter' name='accept'> + </div> + </div> + </form>"; + } + } + } + + + + if ($noRequest){ + echo "<p>Vous n'avez aucune demande</p>"; + } + + +} + +function print_cours($users,$requests,$bdd){ + + $noCours = true; + + + foreach($requests as $r){ + + if (isset($_POST['accept'])){ + echo "Demande acceptée"; + set_accepted($_POST['idTeacher'],$_POST['idStudent'],$bdd); + } + + else{ + + $subject = $r->subject; + $studentId = $r->student; + $teacherId = $r->teacher; + $dispo = $r->dispo; + $accepted = $r->accepted; + + + foreach ($users as $u){ + if ($u->getId() == $studentId){ + $studentName = $u->getName(); + $studentFirstname = $u->getFirstname(); + } + } + + if ($accepted){ + echo "<p>Vous avez un cours avec $studentFirstname $studentName pour un cours de $subject le $dispo</p>"; + $noCours = false; + + echo "<form action='/pima/requests/requests.php' method='post'> + <div class='form-group form-row'> + <div class='offset-sm'> + <input type='hidden' value=$studentId name='idTeacher'> + <input type='hidden' value=$teacherId name='idStudent'> + <input type='submit' value='Accepter' name='accept'> + </div> + </div> + </form>"; + } + } + } + + + + if ($noCours){ + echo "<p>Vous n'avez aucune demande</p>"; + } + + +} + +function set_accepted($idProf,$idStudent,$bdd){ + + $sql = "UPDATE pima SET accepted = ? WHERE teacher = $idProf"; + $bdd->prepare($sql)->execute([1]); + +} + ?> diff --git a/htdocs/requests/requests.php b/htdocs/requests/requests.php new file mode 100644 index 0000000000000000000000000000000000000000..d68812df4c3bb2a45d179869f540c7a0263d4036 --- /dev/null +++ b/htdocs/requests/requests.php @@ -0,0 +1,26 @@ +<?php +$title = 'Projet PIMA'; +include("/opt/lampp/htdocs/pima/head.php"); +?> +</head> + +<?php include("/opt/lampp/htdocs/pima/header.php"); ?> + +<section class="wrapper style1"> + <div class="container"> + <div id="content"> + <article> + <header> + <h2>Mes demandes</h2> + </header> + + <p> + <?php + $r = $_SESSION['currentRequest']; + print_requests($users,$r,$bdd); ?> + </p> + </article> + </div> + </div> +</section> +<?php include("/opt/lampp/htdocs/pima/footer.php"); ?> \ No newline at end of file diff --git a/htdocs/student/matchs.php b/htdocs/student/matchs.php index c833e4b0b38bfda90d39ac7fe6d677df678700d2..4b8c8125612983a7cdc553b50bd5868579f23c82 100644 --- a/htdocs/student/matchs.php +++ b/htdocs/student/matchs.php @@ -22,19 +22,6 @@ include("/opt/lampp/htdocs/pima/head.php"); } } - 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>"; - } - } - } - else { ?> <header><h2>Accès interdit</h2></header> @@ -42,26 +29,7 @@ include("/opt/lampp/htdocs/pima/head.php"); <?php } ?> - - <!-- 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> - - <div class="form-group form-row"> - <div class="offset-sm-2"> - <!-- <button type="submit">S'inscrire</button> --> - <input type="submit" value="Se connecter"> - </div> - </div> - </form> - </p> </div> </div> </section> +<?php include("/opt/lampp/htdocs/pima/footer.php"); ?> diff --git a/htdocs/tests.php b/htdocs/tests.php index 8ecda81ffce27234e0712f505e9a3e13a957f499..b9354cb57360d7ba16cc9528ab98b8c235beaae3 100644 --- a/htdocs/tests.php +++ b/htdocs/tests.php @@ -50,4 +50,4 @@ include("head.php"); </div> </section> -<?php #include("footer.php"); ?> +<?php include("footer.php"); ?>