diff --git a/build/api/module/excelController.php b/build/api/module/excelController.php index 3be39ea..e3c4a4d 100644 --- a/build/api/module/excelController.php +++ b/build/api/module/excelController.php @@ -61,6 +61,16 @@ class excelController * declare the lambda that will add finalized UE to the array */ $addEU = function() use (&$UECode,&$allUE,&$UE){ + //determine if UE is disabled (if cours+td+tp = 0) + $totalVH = 0; + foreach ($UE["groups"] as $groups){ + foreach ($groups as $group){ + $totalVH += $group["VH"]; + } + } + + $UE["disabled"] = $totalVH == 0; + if($UECode != ""){ if(isset($allUE[$UECode])){ $counter = 1; @@ -352,7 +362,7 @@ class excelController $UE["CourseVH"], $UE["TdVH"], $UE["TpVH"], - false, + $UE["disabled"], $UE["defaultFormationId"] ); if(isset($UE["groups"])){ @@ -369,19 +379,19 @@ class excelController case "Course": $coursRepo->create( $codeUE, $allProf[$group["professor"]]["dbId"], - $group["VH"], + $UE["disabled"] ? $UE["CourseVH"] : $group["VH"], $formations); break; case "TD": $tdRepo->create($codeUE, $allProf[$group["professor"]]["dbId"], - $group["VH"], + $UE["disabled"] ? $UE["TdVH"] : $group["VH"], $formations); break; case "TP": $tpRepo->create($codeUE, $allProf[$group["professor"]]["dbId"], - $group["VH"], + $UE["disabled"] ? $UE["TpVH"] : $group["VH"], $formations); break; } diff --git a/build/database/repo/category.php b/build/database/repo/category.php index 71fd68f..b1abe50 100644 --- a/build/database/repo/category.php +++ b/build/database/repo/category.php @@ -35,9 +35,26 @@ 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 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 GROUP BY Prof.Categorie_idCategorie) 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 GROUP BY Prof.Categorie_idCategorie) 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 GROUP BY Prof.Categorie_idCategorie) VHTp ON VHTp.idCat = Cat.idCategorie + 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 + + 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 + + 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 LEFT JOIN Professeur P ON Cat.idCategorie = P.Categorie_idCategorie ".($id ? " WHERE Cat.idCategorie = :idCat" : "")." GROUP BY Cat.idCategorie;"); diff --git a/build/database/repo/professor.php b/build/database/repo/professor.php index 28e4daa..e8bc9fb 100644 --- a/build/database/repo/professor.php +++ b/build/database/repo/professor.php @@ -259,9 +259,26 @@ class professor extends Repo_i { FROM Professeur Prof, Categorie Cat, - (SELECT IFNULL(SUM(Cours.volume),0) VHCours, Prof.idProfesseur idProf FROM Professeur Prof LEFT JOIN Cours ON Prof.idProfesseur = Cours.Professeur_idProfesseur GROUP BY Prof.idProfesseur) VHCours, - (SELECT IFNULL(SUM(TD.volume),0) VHTd , Prof.idProfesseur idProf FROM Professeur Prof LEFT JOIN TD ON TD.Professeur_idProfesseur = Prof.idProfesseur GROUP BY Prof.idProfesseur) VHTd, - (SELECT IFNULL(SUM(TP.volume),0) VHTp, Prof.idProfesseur idProf FROM Professeur Prof LEFT JOIN TP ON TP.Professeur_idProfesseur = Prof.idProfesseur GROUP BY Prof.idProfesseur) VHTp + (SELECT IFNULL(SUM(Cours.volume),0) VHCours, Prof.idProfesseur idProf + 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.idProfesseur) VHCours, + + (SELECT IFNULL(SUM(TD.volume),0) VHTd , Prof.idProfesseur idProf + 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.idProfesseur) VHTd, + + (SELECT IFNULL(SUM(TP.volume),0) VHTp, Prof.idProfesseur idProf + 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.idProfesseur) VHTp WHERE $cond Prof.Categorie_idCategorie = Cat.idCategorie AND VHCours.idProf = Prof.idProfesseur