Sélectionner une révision Git
match_script.php
match_script.php 2,89 Kio
<?php
function match_script($student, $userRepository){
$dispoStudent = $student->getDispo();
$subjectStudent = $student->getSubject();
$prof = $userRepository->fetchTeacher();
$matchs = [];
#$bool = false;
foreach($prof as $p){
#$firstnameProf = $p->getFirstname();
#$nameProf = $p->getName();
$subjectProf = $p->getSubject();
$dispoProf = $p->getDispo();
$mailProf = $p->getMail();
foreach($subjectStudent as $ss){
foreach($subjectProf as $sp){
foreach($dispoStudent as $ds){
foreach($dispoProf as $dp){
if (($ss==$sp)&&($ds==$dp)){
$match = [
"teacher" => $p,
"subject" => $sp,
"dispo" => $dp,
"mail" => $mailProf
];
$matchs[] = $match;
#echo "Le professeur <b>$firstnameProf $nameProf</b> est disponible pour l'élève le <b>$ds</b> pour un cours de <b>$sp</b> </br>";
#$bool = true;
#echo "Le mail du <b>$firstnameProf $nameProf</b> est <b>$mailProf</b>
}
}
}
}
}
}
return $matchs;
#if (!$bool){
# echo "<p>Aucun prof trouvé</p>";
#}
}
function print_requests($users,$requests){
$noRequest = true;
foreach($requests as $r){
if (isset($_POST['accept'])){
echo "Demande accepté";
set_accepted();
}
else{
$subject = $r->subject;
$studentId = $r->student;
$dispo = $r->dispo;
$accepted = $r->accepted;
foreach ($users as $u){
if ($u->id = $studentId){
$studentName = $u->getName();