implemented departement stats

This commit is contained in:
Unknown 2018-03-08 18:41:52 +01:00
parent 0e305499ad
commit 271799e9f4
4 changed files with 113 additions and 1 deletions

View File

@ -0,0 +1,25 @@
<?php
/**
* Created by PhpStorm.
* User: lucas
* Date: 08/03/18
* Time: 17:36
*/
namespace api\module\departement;
use database\core\Repo;
use database\repo\departement;
class statsController
{
public static function get($args){
/** @var departement $repo */
$repo = Repo::getRepo("departement");
return ["data" => $repo->getStats()];
}
}

View File

@ -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;
}
}

View File

@ -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'];

View File

@ -79,6 +79,14 @@
"par": {
}
}
},
"stats":{
"GET": {
"des": "Get the statistics about the departement",
"per": [],
"par": {
}
}
}
},