Commit 70c5f0c6 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Correction du problème d'activation des plafonds

parent b0ecdfab
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -45,7 +45,8 @@ SELECT
  s.element_pedagogique_id                      element_pedagogique_id,
  s.type_intervention_id                        type_intervention_id,
  s.heures                                      heures,
  COALESCE(c.heures * c.groupes,0)            plafond
  COALESCE(c.heures * c.groupes,0)              plafond,
  (SELECT id FROM plafond_etat WHERE code = 'desactive') plafond_etat_id
FROM
            s
       JOIN type_intervention ti ON ti.id = s.type_intervention_id
+19 −10
Original line number Diff line number Diff line
@@ -340,11 +340,16 @@ class PlafondService extends AbstractEntityService
                }
            }
            $view .= "\n  COALESCE(p.PLAFOND,ps.heures,0) PLAFOND,";
            if ($perimetre->getCode() !== $perimetre::VOLUME_HORAIRE) {
                $view .= "\n  CASE";
                $view .= "\n    WHEN p.type_volume_horaire_id = $tvhPrevuId THEN ps.plafond_etat_prevu_id";
                $view .= "\n    WHEN p.type_volume_horaire_id = $tvhRealiseId THEN ps.plafond_etat_realise_id";
                $view .= "\n    ELSE COALESCE(p.plafond_etat_id,1)";
                $view .= "\n  END plafond_etat_id,";
            } else {
                $view .= "\n  COALESCE(p.plafond_etat_id,1) plafond_etat_id,";
            }

            $view     .= "\n  COALESCE(pd.heures, 0) derogation,";
            $view     .= "\n  CASE WHEN p.heures > COALESCE(p.PLAFOND,ps.heures,0) + COALESCE(pd.heures, 0) + 0.05 THEN 1 ELSE 0 END depassement";
            $view     .= "\nFROM\n  (";
@@ -383,10 +388,14 @@ class PlafondService extends AbstractEntityService
            $view .= "\n  LEFT JOIN " . $configTablesJoin[$perimetre->getCode()];
            $view .= "\n  LEFT JOIN plafond_derogation pd ON pd.plafond_id = p.plafond_id AND pd.intervenant_id = p.intervenant_id AND pd.histo_destruction IS NULL";
            $view .= "\nWHERE\n";
            if ($perimetre->getCode() !== $perimetre::VOLUME_HORAIRE) {
                $view .= "  CASE\n";
                $view .= "    WHEN p.type_volume_horaire_id = $tvhPrevuId THEN ps.plafond_etat_prevu_id\n";
                $view .= "    WHEN p.type_volume_horaire_id = $tvhRealiseId THEN ps.plafond_etat_realise_id\n";
                $view .= "  END IS NOT NULL";
            } else {
                $view .= "  1=1";
            }
            foreach ($cols as $col) {
                if ($col != 'PLAFOND' && $col != 'HEURES' && $col != 'DEROGATION') {
                    $view .= "\n  /*@$col=p.$col*/";