[repo.ue]Fix additionnals data computation

This commit is contained in:
Unknown 2018-03-29 23:51:15 +02:00
parent 5ea9d901a9
commit a79710f3fe
1 changed files with 50 additions and 46 deletions

View File

@ -180,52 +180,56 @@ class ue extends Repo_i {
$parm = is_null($code) ? [] : [':code' => $code]; $parm = is_null($code) ? [] : [':code' => $code];
/* (2) Prepare Statement */ /* (2) Prepare Statement */
$st = $this->pdo->prepare("SELECT $st = $this->pdo->prepare("
ue.code, SELECT
ue.label, ue.code,
ue.disabled, ue.label,
ue.required, ue.disabled,
ue.volumeCours, ue.required,
ue.volumeTD, ue.volumeCours,
ue.volumeTP, ue.volumeTD,
IFNULL(ue.Formation_idFormation, -1) idForm, ue.volumeTP,
fdef.labelFormation labelForm, IFNULL(ue.Formation_idFormation, -1) idForm,
IFNULL(formlist.formations, '[]') formations, fdef.labelFormation labelForm,
IFNULL(formlist.nbrCours,0) nbrCours, IFNULL(formlist.formations, '[]') formations,
IFNULL(formlist.nbrTD,0) nbrTD, IFNULL(formlist.nbrCours,0) nbrCours,
IFNULL(formlist.nbrTP,0) nbrTP, IFNULL(formlist.nbrTD,0) nbrTD,
IFNULL(formlist.modCours,0) modCours, IFNULL(formlist.nbrTP,0) nbrTP,
IFNULL(formlist.modTD,0) modTD, IFNULL(formlist.modCours,1) modCours,
IFNULL(formlist.modTP,0) modTP, IFNULL(formlist.modTD,1) modTD,
IFNULL(formlist.nbrProfCours,0) nbrProfCours, IFNULL(formlist.modTP,1) modTP,
IFNULL(formlist.nbrProfTD,0) nbrProfTD, IFNULL(formlist.nbrProfCours,0) nbrProfCours,
IFNULL(formlist.nbrProfTP,0) nbrProfTP IFNULL(formlist.nbrProfTD,0) nbrProfTD,
FROM UE ue IFNULL(formlist.nbrProfTP,0) nbrProfTP
LEFT JOIN Formation fdef ON ue.Formation_idFormation = fdef.idFormation FROM UE ue
LEFT JOIN ( LEFT JOIN Formation fdef ON ue.Formation_idFormation = fdef.idFormation
SELECT ue2.code code, CONCAT('[',GROUP_CONCAT(DISTINCT Formation.idFormation), ']') formations, LEFT JOIN (
count(DISTINCT C.idCours) nbrCours, count(DISTINCT T.idTD) nbrTD, count(DISTINCT T2.idTP) nbrTP, SELECT ue2.code code, CONCAT('[',GROUP_CONCAT(DISTINCT Formation.idFormation), ']') formations,
MOD(sum(DISTINCT C.volume),ue2.volumeCours) modCours, count(DISTINCT C.idCours) nbrCours, count(DISTINCT T.idTD) nbrTD, count(DISTINCT T2.idTP) nbrTP,
MOD(sum(DISTINCT T.volume),ue2.volumeTD) modTD, MOD(volC.vol,ue2.volumeCours) modCours,
MOD(sum(DISTINCT T2.volume),ue2.volumeTP) modTP, MOD(volTD.vol,ue2.volumeTD) modTD,
count(DISTINCT C.Professeur_idProfesseur) nbrProfCours, MOD(volTP.vol,ue2.volumeTP) modTP,
count(DISTINCT T.Professeur_idProfesseur) nbrProfTD, count(DISTINCT C.Professeur_idProfesseur,C.idCours) nbrProfCours,
count(DISTINCT T2.Professeur_idProfesseur) nbrProfTP count(DISTINCT T.Professeur_idProfesseur,T.idTD) nbrProfTD,
FROM UE ue2 count(DISTINCT T2.Professeur_idProfesseur,T2.idTP) nbrProfTP
LEFT JOIN Cours C ON ue2.code = C.UE_code FROM UE ue2
LEFT JOIN TD T ON ue2.code = T.UE_code LEFT JOIN (SELECT sum(CO.volume) vol, CO.UE_code FROM Cours CO GROUP BY CO.UE_code) volC ON ue2.code = volC.UE_code
LEFT JOIN TP T2 ON ue2.code = T2.UE_code LEFT JOIN (SELECT sum(TD2.volume) vol, TD2.UE_code FROM TD TD2 GROUP BY TD2.UE_code) volTD ON ue2.code = volTD.UE_code
LEFT JOIN GroupeCours C2 ON C.idCours = C2.Cours_idCours LEFT JOIN (SELECT sum(TP2.volume) vol, TP2.UE_code FROM TP TP2 GROUP BY TP2.UE_code) volTP ON ue2.code = volTP.UE_code
LEFT JOIN GroupeTD TD2 ON T.idTD = TD2.TD_idTD LEFT JOIN Cours C ON ue2.code = C.UE_code
LEFT JOIN GroupeTP TP2 ON T2.idTP = TP2.TP_idTP LEFT JOIN TD T ON ue2.code = T.UE_code
JOIN Formation ON C2.Formation_idFormation = Formation.idFormation LEFT JOIN TP T2 ON ue2.code = T2.UE_code
OR TD2.Formation_idFormation = Formation.idFormation LEFT JOIN GroupeCours C2 ON C.idCours = C2.Cours_idCours
OR TP2.Formation_idFormation = Formation.idFormation LEFT JOIN GroupeTD TD2 ON T.idTD = TD2.TD_idTD
GROUP BY `ue2`.`code` LEFT JOIN GroupeTP TP2 ON T2.idTP = TP2.TP_idTP
) formlist ON formlist.code = ue.code JOIN Formation ON C2.Formation_idFormation = Formation.idFormation
GROUP BY `ue`.`code` OR TD2.Formation_idFormation = Formation.idFormation
$cond OR TP2.Formation_idFormation = Formation.idFormation
ORDER BY `ue`.`label` ASC"); GROUP BY `ue2`.`code`
) formlist ON formlist.code = ue.code
GROUP BY `ue`.`code`
$cond
ORDER BY `ue`.`label` ASC");
/* (3) Bind params and execute statement */ /* (3) Bind params and execute statement */
if( is_bool($st) ) return []; if( is_bool($st) ) return [];