Commit 0ba71481 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Correction de problèmes au niveau du calcul des plafonds par structure

Début d'application du contrôle des plafonds aux offres d'emploi
parent a940c360
Loading
Loading
Loading
Loading
+1
Changes for config/autoload/unicaen-tbl.global.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -493,6 +493,7 @@ return [
                ],
                'key_values_if_null' => [
                    'PLAFOND_ID'             => 0,
                    'INTERVENANT_ID'         => 0,
                    'TYPE_VOLUME_HORAIRE_ID' => 0,
                ],
            ],
+1 −1
Changes for data/ddl/table/TBL_PLAFOND_STRUCTURE.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ return [
            'length'      => 0,
            'scale'       => NULL,
            'precision'   => NULL,
            'nullable'    => FALSE,
            'nullable'    => TRUE,
            'default'     => NULL,
            'position'    => 5,
            'commentaire' => NULL,
+20 −1
Changes for module/Mission/src/Controller/OffreEmploiController.php: 20 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ use Mission\Form\OffreEmploiFormAwareTrait;
use Mission\Service\CandidatureServiceAwareTrait;
use Mission\Service\MissionServiceAwareTrait;
use Mission\Service\OffreEmploiServiceAwareTrait;
use Plafond\Processus\PlafondProcessusAwareTrait;
use Service\Service\TypeVolumeHoraireServiceAwareTrait;
use UnicaenVue\View\Model\AxiosModel;


@@ -35,6 +37,8 @@ class OffreEmploiController extends AbstractController
    use ContextServiceAwareTrait;
    use MissionServiceAwareTrait;
    use WorkflowServiceAwareTrait;
    use PlafondProcessusAwareTrait;
    use TypeVolumeHoraireServiceAwareTrait;


    public function indexAction()
@@ -56,9 +60,24 @@ class OffreEmploiController extends AbstractController
        } else {
            $title = "Modification d'une offre d'emploi";
        }
        $form->bindRequestSave($offreEmploi, $this->getRequest(), function () use ($offreEmploi, $form) {

        // A adapter pour utiliser le futur type de volume horaire "BESOIN"
        $typeVolumeHoraire = $this->getServiceTypeVolumeHoraire()->getPrevu();

        $hDeb = $offreEmploi->getNombreHeures() * $offreEmploi->getNombrePostes();
        $form->bindRequestSave($offreEmploi, $this->getRequest(), function () use ($offreEmploi, $form, $hDeb, $typeVolumeHoraire) {

            $this->getProcessusPlafond()->beginTransaction();
            try {
                $this->getServiceOffreEmploi()->save($offreEmploi);
                $hFin = $offreEmploi->getNombreHeures() * $offreEmploi->getNombrePostes();
                $this->getProcessusPlafond()->endTransaction($offreEmploi->getStructure(), $typeVolumeHoraire, $hFin < $hDeb);

            } catch (\Exception $e) {
                $this->flashMessenger()->addErrorMessage($this->translate($e));
                $this->em()->rollback();
            }


            $this->flashMessenger()->addSuccessMessage(
                "Enregistrement effectué"
+3 −1
Changes for module/Plafond/src/Service/PlafondService.php: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -488,7 +488,7 @@ class PlafondService extends AbstractEntityService
        $tvhPrevuId = $this->getServiceTypeVolumeHoraire()->getPrevu()->getId();
        $tvhRealiseId = $this->getServiceTypeVolumeHoraire()->getRealise()->getId();
        $configTablesJoin = [
            "structure"      => "plafond_structure ps ON ps.plafond_id = p.plafond_id AND ps.structure_id = p.structure_id AND ps.annee_id = i.annee_id AND ps.histo_destruction IS NULL",
            "structure"      => "plafond_structure ps ON ps.plafond_id = p.plafond_id AND ps.structure_id = p.structure_id AND ps.annee_id = p.annee_id AND ps.histo_destruction IS NULL",
            "intervenant"    => "plafond_statut ps ON ps.plafond_id = p.plafond_id AND ps.statut_id = i.statut_id AND ps.annee_id = i.annee_id AND ps.histo_destruction IS NULL",
            "element"        => "plafond_statut ps ON 1 = 0",
            "volume_horaire" => "plafond_statut ps ON 1 = 0",
@@ -567,7 +567,9 @@ class PlafondService extends AbstractEntityService
                $view .= " FROM dual WHERE 0 = 1";
            }
            $view .= "\n  ) p";
            if ($perimetre->getCode() !== $perimetre::STRUCTURE) {
                $view .= "\n  JOIN intervenant i ON i.id = p.intervenant_id";
            }
            $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";