Commit 94fdfba3 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Récup du type d'intervenant sans passer par les services

parent e5718213
Loading
Loading
Loading
Loading
+31 −5
Changes for module/Application/src/Assertion/ServiceAssertion.php: 31 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertPage(array $page)
    {
        $role = $this->getRole();
@@ -95,6 +96,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    /**
     * @param ResourceInterface $entity
     * @param string            $privilege
@@ -206,6 +208,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    /**
     * @param string $controller
     * @param string $action
@@ -249,6 +252,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertPageServices(Role $role, Intervenant $intervenant = null, string $typeVolumeHoraireCode)
    {
        if (!$intervenant) return true;
@@ -274,6 +278,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertEnseignements(Role $role)
    {
        return $this->asserts([
@@ -288,6 +293,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertImportAgenda(Role $role)
    {
        return true;
@@ -295,6 +301,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertServiceVisualisation(Role $role, Service $service)
    {
        $typeVolumeHoraire = $service->getTypeVolumeHoraire();
@@ -318,6 +325,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertServiceReferentielVisualisation(Role $role, ServiceReferentiel $serviceReferentiel)
    {
        $typeVolumeHoraire = $serviceReferentiel->getTypeVolumeHoraire();
@@ -341,6 +349,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertServiceEdition(Role $role, Service $service)
    {
        $structure = $role->getStructure();
@@ -373,6 +382,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertServiceReferentielEdition(Role $role, ServiceReferentiel $serviceReferentiel)
    {
        $asserts = [];
@@ -403,18 +413,19 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertHasServices(Intervenant $intervenant, Structure $structure, string $etape, Role $role)
    {
        $services                         = $intervenant->getService();
        $serviceEnComposanteAffectation   = [];
        $serviceHorsComposanteAffectation = [];
        $typeIntervenant                  = $intervenant->getStatut()->getTypeIntervenant();

        foreach ($services as $service) {

            if ($service->getHistoDestruction()) continue;
            if (!$service->getElementPedagogique()) continue;

            $typeIntervenant = $service->getIntervenant()->getStatut()->getTypeIntervenant();
            $intervenantStructure = $service->getIntervenant()->getStructure();
            $serviceStructure     = $service->getElementPedagogique()->getStructure();
            if ($intervenantStructure == $serviceStructure) {
@@ -422,7 +433,6 @@ class ServiceAssertion extends AbstractAssertion
            } else {
                $serviceHorsComposanteAffectation[] = $service;
            }

        }

        $reglesValidation = $this->getServiceRegleStructureValidation()->getList();
@@ -438,7 +448,6 @@ class ServiceAssertion extends AbstractAssertion
                        return true;
                    }
                }

            }

            if ($etape == WfEtape::CODE_SERVICE_VALIDATION_REALISE && $regle->getTypeVolumeHoraire()->getCode() == 'REALISE') {
@@ -450,9 +459,7 @@ class ServiceAssertion extends AbstractAssertion
                        return true;
                    }
                }

            }

        }


@@ -460,6 +467,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertCampagneSaisie(Role $role, TypeVolumeHoraire $typeVolumeHoraire)
    {
        if ($typeVolumeHoraire && $role->getIntervenant()) {
@@ -474,6 +482,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertCloture(Role $role, Intervenant $intervenant)
    {
        if ($intervenant->getStatut()->getCloture()) {
@@ -494,6 +503,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertServiceVisualisationValidation(Role $role, Service $service)
    {
        $wfEtape = $this->getWorkflowEtape($service->getTypeVolumeHoraire(), 'validation-enseignement');
@@ -505,6 +515,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertVolumeHoraireValidation(Role $role, VolumeHoraire $volumeHoraire)
    {
        $service = $volumeHoraire->getService();
@@ -513,12 +524,14 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertServiceValidation(Role $role, Service $service)
    {
        return $this->assertValidation($role, $service->getIntervenant(), $service->getStructure());
    }



    protected function assertVolumeHoraireReferentielValidation(Role $role, VolumeHoraireReferentiel $volumeHoraireReferentiel)
    {
        $serviceReferentiel = $volumeHoraireReferentiel->getServiceReferentiel();
@@ -527,12 +540,14 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertServiceReferentielValidation(Role $role, ServiceReferentiel $serviceReferentiel)
    {
        return $this->assert($role, $serviceReferentiel->getIntervenant(), $serviceReferentiel->getStructure());
    }



    protected function assertValidationValidation(Role $role, Validation $validation)
    {
        return $this->asserts([
@@ -542,6 +557,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertValidation(Role $role, Intervenant $intervenant, ?Structure $structure)
    {
        return $this->asserts([
@@ -551,6 +567,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertValidationDevalidation(Role $role, Validation $validation)
    {
        return $this->asserts([
@@ -561,6 +578,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertServiceExterieur(Role $role, Service $service)
    {
        return $this->asserts([
@@ -569,6 +587,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertIntervenantServiceExterieur(Role $role, Intervenant $intervenant)
    {
        return $this->asserts([
@@ -578,6 +597,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertMotifNonPaiement(Role $role, Intervenant $intervenant)
    {
        // filtrer pour la structure ? ?
@@ -588,6 +608,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertIntervenant(Role $role, Intervenant $intervenant = null)
    {
        if ($intervenant) {
@@ -602,6 +623,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertIntervenantService(
        Role $role,
        Intervenant $intervenant,
@@ -623,6 +645,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertIntervenantReferentiel(
        Role $role,
        Intervenant $intervenant,
@@ -644,6 +667,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertStructure(Role $role, ?Structure $structure = null)
    {
        if ($structure) {
@@ -658,6 +682,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    protected function assertEtapeAtteignable($etape, Intervenant $intervenant = null)
    {
        if ($intervenant) {
@@ -671,6 +696,7 @@ class ServiceAssertion extends AbstractAssertion
    }



    private function getWorkflowEtape(TypeVolumeHoraire $typeVolumeHoraire, $action)
    {
        $key    = $action . '-' . strtolower($typeVolumeHoraire->getCode());