Fix Request for ctegory stats

This commit is contained in:
Unknown 2018-03-06 19:40:57 +01:00
parent 39cc5ef906
commit 9dc60ca0cd
2 changed files with 24 additions and 19 deletions

View File

@ -33,28 +33,28 @@ class category extends Repo_i{
}
public function getStats(?int $id = null){
$st = $this->pdo->prepare("SELECT VHCours, VHTd, VHTp, Cat.idCategorie idCat, count(P.idProfesseur) nbrProf, Cat.labelCategorie labelCat
$st = $this->pdo->prepare("SELECT IFNULL(VHCours,0) VHCours, IFNULL(VHTd,0)VHTd, IFNULL(VHTp,0)VHTp, Cat.idCategorie idCat, count(P.idProfesseur) nbrProf, Cat.labelCategorie labelCat
FROM Categorie Cat
LEFT JOIN (SELECT IFNULL(SUM(Cours.volume),0) VHCours, Prof.Categorie_idCategorie idCat
FROM Professeur Prof
LEFT JOIN Cours ON Prof.idProfesseur = Cours.Professeur_idProfesseur
JOIN UE U ON Cours.UE_code = U.code
WHERE U.disabled = 0
GROUP BY Prof.Categorie_idCategorie) VHCours ON VHCours.idCat = Cat.idCategorie
FROM Professeur Prof
LEFT JOIN Cours ON Prof.idProfesseur = Cours.Professeur_idProfesseur
LEFT JOIN UE U ON Cours.UE_code = U.code
GROUP BY Prof.Categorie_idCategorie, U.disabled
HAVING U.disabled = 0) VHCours ON VHCours.idCat = Cat.idCategorie
LEFT JOIN (SELECT IFNULL(SUM(TD.volume),0) VHTd , Prof.Categorie_idCategorie idCat
FROM Professeur Prof
LEFT JOIN TD ON TD.Professeur_idProfesseur = Prof.idProfesseur
JOIN UE U2 ON TD.UE_code = U2.code
WHERE U2.disabled = 0
GROUP BY Prof.Categorie_idCategorie) VHTd ON VHTd.idCat = Cat.idCategorie
FROM Professeur Prof
LEFT JOIN TD ON TD.Professeur_idProfesseur = Prof.idProfesseur
LEFT JOIN UE U2 ON TD.UE_code = U2.code
GROUP BY Prof.Categorie_idCategorie, U2.disabled
HAVING U2.disabled = 0) VHTd ON VHTd.idCat = Cat.idCategorie
LEFT JOIN (SELECT IFNULL(SUM(TP.volume),0) VHTp, Prof.Categorie_idCategorie idCat
FROM Professeur Prof
LEFT JOIN TP ON TP.Professeur_idProfesseur = Prof.idProfesseur
JOIN UE U3 ON TP.UE_code = U3.code
WHERE U3.disabled = 0
GROUP BY Prof.Categorie_idCategorie) VHTp ON VHTp.idCat = Cat.idCategorie
FROM Professeur Prof
LEFT JOIN TP ON TP.Professeur_idProfesseur = Prof.idProfesseur
LEFT JOIN UE U3 ON TP.UE_code = U3.code
GROUP BY Prof.Categorie_idCategorie, U3.disabled
HAVING U3.disabled = 0) VHTp ON VHTp.idCat = Cat.idCategorie
LEFT JOIN Professeur P ON Cat.idCategorie = P.Categorie_idCategorie
".($id ? " WHERE Cat.idCategorie = :idCat" : "")."
GROUP BY Cat.idCategorie;");

View File

@ -320,7 +320,12 @@ class professor extends Repo_i {
$prof['VHComp'] = ( $prof['VHComp'] < 0 ) ? 0 : $prof['VHComp'];
}else{
$VH["equiTD"] = $prof["VHTd"] + (2/3)*$prof["VHTp"] + 1.5*$prof["VHCours"];
$prof['VHComp'] = null;
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'];
}else{
$prof['VHComp'] = 0;
}
}
}