diff --git a/build/api/module/departement/statsController.php b/build/api/module/departement/statsController.php new file mode 100644 index 0000000..54563d6 --- /dev/null +++ b/build/api/module/departement/statsController.php @@ -0,0 +1,25 @@ + $repo->getStats()]; + } +} \ No newline at end of file diff --git a/build/database/repo/departement.php b/build/database/repo/departement.php index de9d1e6..946b4fc 100644 --- a/build/database/repo/departement.php +++ b/build/database/repo/departement.php @@ -9,6 +9,7 @@ namespace database\repo; +use database\core\Repo; use database\core\Repo_i; class departement extends Repo_i @@ -88,4 +89,82 @@ class departement extends Repo_i return $results; } + public function getStats() : array{ + + /* (1) Potentiel horaire du département */ + $Potentiel = $this->pdo->prepare("SELECT SUM(hoursToDo) potentiel + FROM Professeur + WHERE Categorie_idCategorie IN (1,2,3) + GROUP BY Categorie_idCategorie IN (1,2,3);"); + + $Potentiel->execute([]); + + $results = $Potentiel->fetch(); + + /* (2) Sous-service (professeurs ayant moins d'heure prévu que d'heure du) */ + /** @var professor $ProfRepo */ + $ProfRepo = Repo::getRepo("professor"); + + $profs = $ProfRepo->getWithVH(null); + + $results["sous_service"] = 0; + $results["heures_comp"] = 0; + $results["heures_vacataire"] = 0; + + foreach ($profs as $prof){ + if(in_array($prof["idCat"],[1,2,3,4]) and $prof["equiTD"] < $prof["hoursToDo"]){ + $results["sous_service"] += $prof["hoursToDo"] - $prof["equiTD"]; + + /* (3) Heures effectués par des vacataires */ + }else if(in_array($prof["idCat"],[5,6])){ + $results["heures_vacataire"] += $prof["equiTD"]; + } + + /* (4) Heures complementaires */ + + if(is_numeric($prof["VHComp"])){ + $results["heures_comp"] += $prof["VHComp"]; + } + + } + + /* (5) Heures effectuées pour des départements exterieurs */ + //je crois que j'ai créé un montre - Lucas - 2018 + $HDepExt = $this->pdo->prepare(" + SELECT U.disabled disabled, + count(U.code) nbrUe, + SUM((IFNULL(T1.VolumeCours,0)*IFNULL(tauxInfoCours,0) + IFNULL(T2.VolumeTD,0)*IFNULL(tauxInfoTD,0) + IFNULL(T3.VolumeTP,0)*IFNULL(tauxInfoTP,0))) totalInfo, + SUM((IFNULL(T1.VolumeCours,0)*(1-IFNULL(tauxInfoCours,0)) + IFNULL(T2.VolumeTD,0)*(1-IFNULL(tauxInfoTD,0)) + IFNULL(T3.VolumeTP,0)*(1-IFNULL(tauxInfoTP,0)))) totalExterieur + FROM UE U + LEFT JOIN (SELECT SUM(F.isInternal)/count(F.idFormation) tauxInfoCours,SUM(C.volume)*1.5 VolumeCours, C.UE_code code_UE + FROM Cours C + JOIN GroupeCours C2 ON C.idCours = C2.Cours_idCours + JOIN Formation F ON C2.Formation_idFormation = F.idFormation + GROUP BY C.UE_code) T1 ON U.code = T1.code_UE + LEFT JOIN (SELECT SUM(F.isInternal)/count(F.idFormation) tauxInfoTD,SUM(T1.volume) VolumeTD, T1.UE_code code_UE + FROM TD T1 + JOIN GroupeTD GT ON T1.idTD = GT.TD_idTD + JOIN Formation F ON GT.Formation_idFormation = F.idFormation + GROUP BY T1.UE_code) T2 ON U.code = T2.code_UE + LEFT JOIN (SELECT SUM(F.isInternal)/count(F.idFormation) tauxInfoTP,SUM(T1.volume) VolumeTP, T1.UE_code code_UE + FROM TP T1 + JOIN GroupeTP TP2 ON T1.idTP = TP2.TP_idTP + JOIN Formation F ON TP2.Formation_idFormation = F.idFormation + GROUP BY T1.UE_code) T3 ON U.code = T3.code_UE + GROUP BY U.disabled"); + + $HDepExt->execute([]); + + $HDepExtData = $HDepExt->fetchAll(); + + $results = array_merge($results,[ + "heures_exterieur" => $HDepExtData[0]["totalExterieur"], + "heures_ue_desactive" => $HDepExtData[1]["totalExterieur"] + $HDepExtData[1]["totalInfo"], + "nbr_ue_desactive" => $HDepExtData[1]["nbrUe"] + ]); + + return $results; + + } + } \ No newline at end of file diff --git a/build/database/repo/professor.php b/build/database/repo/professor.php index 1fcfad0..fa22578 100644 --- a/build/database/repo/professor.php +++ b/build/database/repo/professor.php @@ -319,7 +319,7 @@ class professor extends Repo_i { $prof['VHComp'] = round($prof['equiTD'] - $prof['hoursToDo'], 2); $prof['VHComp'] = ( $prof['VHComp'] < 0 ) ? 0 : $prof['VHComp']; }else{ - $VH["equiTD"] = $prof["VHTd"] + (2/3)*$prof["VHTp"] + 1.5*$prof["VHCours"]; + $prof["equiTD"] = $prof["VHTd"] + (2/3)*$prof["VHTp"] + 1.5*$prof["VHCours"]; if(is_numeric($prof["hoursToDo"]) and $prof["hoursToDo"] > 0){ $prof['VHComp'] = round($prof['equiTD'] - $prof['hoursToDo'], 2); $prof['VHComp'] = ( $prof['VHComp'] < 0 ) ? 0 : $prof['VHComp']; diff --git a/config/modules.json b/config/modules.json index 13e7c3c..f9f363c 100644 --- a/config/modules.json +++ b/config/modules.json @@ -79,6 +79,14 @@ "par": { } } + }, + "stats":{ + "GET": { + "des": "Get the statistics about the departement", + "per": [], + "par": { + } + } } },