Commit 0d23021a authored by root's avatar root
Browse files

Correction de l'envoi des notification d'avancement des EPS

parent 4bc30955
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
Version 3.2.8 (XX/XX/2023)
====

Évolution
---
- Filtrage des agents ayant un entretien professionnel sur les emploi-types avec un paramètre 
- Correction de l'envoi des notifications d'avancement des campagnes d'EP ou supérieurs et autorités ayant complétés leur campagne.

Modification en BD
---

```postgresql
INSERT INTO unicaen_parametre_parametre(CATEGORIE_ID, CODE, LIBELLE, DESCRIPTION, VALEURS_POSSIBLES, VALEUR, ORDRE)
WITH d(CODE, LIBELLE, DESCRIPTION, VALEURS_POSSIBLES, VALEUR, ORDRE) AS (
    SELECT 'TEMOIN_EMPLOITYPE','Filtrage sur les codes des emploi-type',null,'String',true, 2000
)
SELECT cp.id, d.CODE, d.LIBELLE, d.DESCRIPTION, d.VALEURS_POSSIBLES, d.VALEUR, d.ORDRE
FROM d
JOIN unicaen_parametre_categorie cp ON cp.CODE = 'ENTRETIEN_PROFESSIONNEL';
```

Evolution des librairies 
---



```bash
```

Ou réinstalle des libraires 
```bash
rm -fr vendor
rm -fr composer.lock
composer install
```

Evolution des macros et templates 
---
+10 −0
Original line number Diff line number Diff line
@@ -261,6 +261,16 @@ class Agent implements
        return $statuts;
    }

	/** @return AgentGrade[] */
    public function getEmploiTypesActifs(?DateTime $date = null, ?array $structures = null) : array
    {
        if ($date === null) $date = (new DateTime());
        $affectations =  $this->getGrades($date);
        if ($structures !== null) $affectations = array_filter($affectations, function (AgentGrade $a) use ($structures) { return in_array($a->getStructure(), $structures);});
        return $affectations;
    }	


    /** Autres accesseurs *********************************************************************************************/

    public function getUtilisateur() : ?AbstractUser
+71 −0
Original line number Diff line number Diff line
@@ -731,6 +731,34 @@ EOS;
        return $result;
    }

public function isValideEmploiType(Agent $agent, ?Parametre $parametre, ?DateTime $date = null, ?Structure $structure = null) : bool
    {
        $listing = explode(";", $parametre->getValeur());
        $on = []; $off = [];
        foreach ($listing as $item) {
            if ($item[0] === '!') $off[] = substr($item,1); else $on[] = $item;
        }

        $emploitypes = $agent->getEmploiTypesActifs($date, $structure?[$structure]:null);
        $count = [];
        foreach ($emploitypes as $grade) {
            $count[$grade->getEmploiType()->getCode()] = true;
        }

        $keep = true;
        foreach($on as $temoin) {
            if (!isset($count[$temoin])) {
                $keep = false ; break;
            }
        }
        foreach($off as $temoin) {
            if (isset($count[$temoin])) {
                $keep = false ; break;
            }
        }
        return $keep;
    }

    /**
     * @param Agent[] $agents
     * @param Parametre|null $parametre
@@ -778,6 +806,49 @@ EOS;
        return $result;
    }

/**
     * @param Agent[] $agents
     * @param Parametre|null $parametre
     * @param DateTime|null $date
     * @param Structure|null $structure
     * @return Agent[]
     */
    public function filtrerWithEmploiTypeTemoin(array $agents, ?Parametre $parametre, ?DateTime $date = null, ?Structure $structure = null) : array
    {
        if ($parametre === null || $parametre->getValeur() === null || $parametre->getValeur() === '') return $agents;
        if ($date === null) $date = new DateTime();

        $listing = explode(";", $parametre->getValeur());
        $on = []; $off = [];
        foreach ($listing as $item) {
            if ($item[0] === '!') $off[] = substr($item,1); else $on[] = $item;
        }

        $result = [];
        foreach ($agents as $agent) {
            $count = [];
            $grades = $agent->getEmploiTypesActifs($date, $structure);
            foreach ($grades as $grade) {
                $count[$grade->getEmploiType()->getCode()] = true;
            }

            $keep = true;
            foreach($on as $temoin) {
                if (!isset($count[$temoin])) {
                    $keep = false ; break;
                }
            }
            foreach($off as $temoin) {
                if (isset($count[$temoin])) {
                    $keep = false ; break;
                }
            }
            if ($keep) $result[] = $agent;
        }

        return $result;
    }

    /**
     * @return Agent[]
     */
+1 −0
Original line number Diff line number Diff line
@@ -11,4 +11,5 @@ class EntretienProfessionnelParametres {
    const MAIL_LISTE_BIATS = 'MAIL_LISTE_BIATS';
    const MAIL_LISTE_DAC = 'MAIL_LISTE_DAC';
    const TEMOIN_AFFECTATION = 'TEMOIN_AFFECTATION';
    const TEMOIN_EMPLOITYPE = 'TEMOIN_EMPLOITYPE';
}
 No newline at end of file
+18 −1
Original line number Diff line number Diff line
@@ -18,11 +18,15 @@ use UnicaenApp\Service\EntityManagerAwareTrait;
use Laminas\Mvc\Controller\AbstractActionController;
use UnicaenEtat\Entity\Db\Etat;
use UnicaenEtat\Service\Etat\EtatServiceAwareTrait;
use UnicaenParametre\Service\Parametre\ParametreServiceAwareTrait;
use EntretienProfessionnel\Provider\Parametre\EntretienProfessionnelParametres;


class CampagneService {
    use EntityManagerAwareTrait;
    use AgentServiceAwareTrait;
    use EtatServiceAwareTrait;
	use ParametreServiceAwareTrait;

    /** GESTION DES ENTITES *******************************************************************************************/

@@ -444,12 +448,25 @@ class CampagneService {
        return $result;
    }


	public function trierAgents(Campagne $campagne, array $agents) : array
    {
        $obligatoires = [];  $facultatifs = [];
        $dateMinEnPoste = (DateTime::createFromFormat('d/m/Y', $campagne->getDateFin()->format('d/m/Y')))->sub(new DateInterval('P12M'));

        /** @var Agent $agent */
        foreach ($agents as $agent) {
            if (!empty($agent->getAffectationsActifs($dateMinEnPoste))) $obligatoires[] = $agent; else $facultatifs[] = $agent;
            $ok = false;
            if (empty($agent->getAffectationsActifs($dateMinEnPoste))) {
                $facultatifs[] = $agent;
                $ok = true;
            }
            $res = $this->getAgentService()->isValideEmploiType($agent,  $this->getParametreService()->getParametreByCode(EntretienProfessionnelParametres::TYPE, EntretienProfessionnelParametres::TEMOIN_EMPLOITYPE), $dateMinEnPoste);
            if (!$ok && !$res) {
                $facultatifs[] = $agent;
                $ok = true;
            }
            if (!$ok) $obligatoires[] = $agent;
        }
        return [$obligatoires, $facultatifs];
    }
Loading