Commit b386fc0f authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Filtrage des agents sans obligation

parent 088caf7d
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ use Application\Service\Agent\AgentServiceAwareTrait;
use DateInterval;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use EntretienProfessionnel\Entity\Db\AgentForceSansObligation;
use EntretienProfessionnel\Entity\Db\Campagne;
use EntretienProfessionnel\Entity\Db\EntretienProfessionnel;
use Exception;
@@ -68,6 +69,7 @@ class Agent implements
    private Collection $fichiers;       /** Fichier[] */
    private Collection $missionsSpecifiques; /** AgentMissionSpecifique[] */
    private Collection $structuresForcees;  /** StructureAgentForce  */
    private Collection $forcesSansObligation;  /** StructureAgentForce  */

    private Collection $autorites;      /** AgentAutorite[] */
    private Collection $superieurs;     /** AgentSuperieur[] */
@@ -81,6 +83,7 @@ class Agent implements
        $this->echelons = new ArrayCollection();
        $this->grades = new ArrayCollection();
        $this->structuresForcees = new ArrayCollection();
        $this->forcesSansObligation = new ArrayCollection();

        $this->autorites = new ArrayCollection();
        $this->superieurs = new ArrayCollection();
@@ -319,6 +322,17 @@ class Agent implements
        return $structures;
    }

    /** SANS OBLIGATION ***********************************************************************************************/

    public function isForceSansObligation(Campagne $campagne): bool
    {
        /** @var AgentForceSansObligation $forcage */
        foreach ($this->forcesSansObligation as $forcage) {
            if ($forcage->getCampagne() === $campagne) return true;
        }
        return false;
    }

    /** FICHES POSTES *************************************************************************************************/

    /**
+1 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@

        <one-to-many target-entity="EntretienProfessionnel\Entity\Db\EntretienProfessionnel" mapped-by="agent" field="entretiens"/>
        <one-to-many target-entity="Structure\Entity\Db\StructureAgentForce" mapped-by="agent" field="structuresForcees"/>
        <one-to-many target-entity="EntretienProfessionnel\Entity\Db\AgentForceSansObligation" mapped-by="agent" field="forcesSansObligation"/>

        <many-to-many field="fichiers" target-entity="Fichier\Entity\Db\Fichier" inversed-by="fichier" fetch="LAZY">
            <join-table name="agent_fichier">
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ $obligatoires = [];
$facultatifs = [];
$dateMinEnPoste = (DateTime::createFromFormat('d/m/Y', $campagne->getDateFin()->format('d/m/Y')))->sub(new DateInterval('P12M'));
foreach ($agents as $agent) {
    if (!empty($agent->getAffectationsActifs($dateMinEnPoste))) $obligatoires[] = $agent; else $facultatifs[] = $agent;
    if (!empty($agent->getAffectationsActifs($dateMinEnPoste)) && !$agent->isForceSansObligation($campagne)) $obligatoires[] = $agent; else $facultatifs[] = $agent;
}

$finalises = [];
+6 −0
Original line number Diff line number Diff line
@@ -303,6 +303,12 @@ class CampagneService
                $facultatifs[] = $agent;
                $ok = true;
            }
            if (!$ok) {
                if ($agent->isForceSansObligation($campagne)) {
                    $facultatifs[] = $agent;
                    $ok=true;
                }
            }
            $res = $this->getAgentService()->isValideEmploiType($agent, $this->getParametreService()->getParametreByCode(EntretienProfessionnelParametres::TYPE, EntretienProfessionnelParametres::TEMOIN_EMPLOITYPE), $dateMinEnPoste);
            if (!$ok && !$res) {
                $facultatifs[] = $agent;
+19 −17
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ if ($nbTotal !== 0) {
?>

<?php if ($mode === 'div') : ?>
    <?php if ($nbTotal !== 0) : ?>
        <div class="progress">
            <div class="progress-bar entretien-agent" role="progressbar" style="width: <?php echo $ratioAgent; ?>%" aria-valuenow="15" aria-valuemin="0" aria-valuemax="100"
                 title="Entretiens complétés <?php echo $nbValiderAgent; ?>/<?php echo $nbTotal; ?>">
@@ -79,6 +80,7 @@ if ($nbTotal !== 0) {
                <?php echo round($ratioSans); ?>%</div>
        </div>
    <?php endif; ?>
<?php endif; ?>
<?php if ($mode === 'table') : ?>
    <table>
        <tr>