From 0e7a5a50ffb612906fd0b44953476a59daa1e5bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Laurent=20L=C3=A9cluse?= <laurent.lecluse@unicaen.fr>
Date: Wed, 27 Apr 2022 11:44:38 +0200
Subject: [PATCH] =?UTF-8?q?Blocage=20au=20niveau=20des=20validations=20si?=
 =?UTF-8?q?=20d=C3=A9passement=20de=20plafond=20Meilleure=20prise=20en=20c?=
 =?UTF-8?q?harge=20des=20d=C3=A9rogations=20:=20on=20n'affiche=20plus=20de?=
 =?UTF-8?q?=20d=C3=A9passement=20dans=20ce=20cas?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 module/Application/src/Controller/ServiceController.php | 5 +++++
 module/Plafond/src/View/Helper/PlafondsViewHelper.php   | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/module/Application/src/Controller/ServiceController.php b/module/Application/src/Controller/ServiceController.php
index 01d011a7c8..e08bfff15e 100755
--- a/module/Application/src/Controller/ServiceController.php
+++ b/module/Application/src/Controller/ServiceController.php
@@ -625,6 +625,11 @@ class ServiceController extends AbstractController
         /* @var $structure Structure */
 
 
+        $plafondOk = $this->getProcessusPlafond()->controle($intervenant, $typeVolumeHoraire, true);
+        if (!$plafondOk) {
+            return new MessengerViewModel();
+        }
+
         $validation = $this->getProcessusValidationEnseignement()->creer($intervenant, $structure);
 
         if ($this->isAllowed($validation, $typeVolumeHoraire->getPrivilegeEnseignementValidation())) {
diff --git a/module/Plafond/src/View/Helper/PlafondsViewHelper.php b/module/Plafond/src/View/Helper/PlafondsViewHelper.php
index 570cbdbaea..79a03f4613 100755
--- a/module/Plafond/src/View/Helper/PlafondsViewHelper.php
+++ b/module/Plafond/src/View/Helper/PlafondsViewHelper.php
@@ -119,13 +119,13 @@ class PlafondsViewHelper extends AbstractHtmlElement
         $text = '';
 
         $max = $plafond->getPlafond() + $plafond->getDerogation();
-        if ($plafond->getHeures() >= $max) {
+        if ($plafond->getHeures() > $max) {
             $max = $plafond->getHeures();
             if ($plafond->getHeures() > 0) {
                 if ($plafond->getPlafond() == 0) {
                     $text = floatToString($plafond->getHeures()) . 'h pour aucune autorisée';
                 } else {
-                    $text = floatToString($plafond->getHeures()) . 'h pour ' . floatToString($plafond->getPlafond()) . ' max.';
+                    $text = floatToString($plafond->getHeures()) . 'h pour ' . floatToString($plafond->getPlafond() + $plafond->getDerogation()) . ' max.';
                 }
             }
 
-- 
GitLab