Commit 3b5a2e1f authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Correction #51512

parent 8b33d4ec
Loading
Loading
Loading
Loading
+111 −95
Changes for module/Enseignement/src/View/Helper/VolumeHoraire/ListeViewHelper.php: 111 added lines, 95 removed lines.
Original line number Diff line number Diff line
@@ -57,29 +57,6 @@ class ListeViewHelper extends AbstractHtmlElement
    protected $hasForbiddenPeriodes = false;


    /**
     *
     * @return boolean
     */
    public function getReadOnly()
    {
        return $this->readOnly || $this->forcedReadOnly;
    }


    /**
     *
     * @param boolean $readOnly
     *
     * @return self
     */
    public function setReadOnly($readOnly)
    {
        $this->readOnly = $readOnly;

        return $this;
    }


    public function hasForbiddenPeriodes ()
    {
@@ -87,6 +64,7 @@ class ListeViewHelper extends AbstractHtmlElement
    }



    /**
     * Helper entry point.
     *
@@ -104,6 +82,7 @@ class ListeViewHelper extends AbstractHtmlElement
    }



    /**
     * Retourne le code HTML généré par cette aide de vue.
     *
@@ -115,20 +94,6 @@ class ListeViewHelper extends AbstractHtmlElement
    }


    public function getRefreshUrl()
    {
        $url = $this->getView()->url(
            'volume-horaire/liste',
            [
                'service' => $this->getVolumeHoraireListe()->getService()->getId(),
            ], ['query' => [
            'read-only'           => $this->getReadOnly() ? '1' : '0',
            'type-volume-horaire' => $this->getVolumeHoraireListe()->getTypeVolumehoraire()->getId(),
        ]]);

        return $url;
    }


    /**
     * Génère le code HTML.
@@ -231,7 +196,6 @@ class ListeViewHelper extends AbstractHtmlElement
                    }
                    $out .= "</tr>\n";
                }

            }
        }
        $out .= '</table>' . "\n";
@@ -240,6 +204,75 @@ class ListeViewHelper extends AbstractHtmlElement
    }



    /**
     *
     * @return VolumeHoraireListe
     */
    public function getVolumeHoraireListe ()
    {
        return $this->volumeHoraireListe;
    }



    public function setVolumeHoraireListe (VolumeHoraireListe $volumeHoraireListe)
    {
        $typeVolumeHoraire        = $volumeHoraireListe->getTypeVolumeHoraire();
        $this->volumeHoraireListe = $volumeHoraireListe;
        $this->forcedReadOnly     = !$this->getView()->isAllowed($volumeHoraireListe->getService(), $typeVolumeHoraire->getPrivilegeEnseignementEdition());
        $this->typesIntervention  = null;

        return $this;
    }



    public function getTypesInterventions ()
    {
        if (!$this->typesIntervention) {
            if ($this->getVolumeHoraireListe()->getService()->getElementPedagogique()) {
                $tis = $this->getVolumeHoraireListe()->getService()->getElementPedagogique()->getTypeIntervention();
            } else {
                $qb = $this->getServiceTypeIntervention()->finderByContext();
                $this->getServiceTypeIntervention()->finderByVisibleExterieur(true, $qb);
                $this->getServiceTypeIntervention()->finderByHistorique($qb);
                $tis = $this->getServiceTypeIntervention()->getList($qb);
            }
            $this->typesIntervention = [];
            foreach ($tis as $ti) {
                $this->typesIntervention[] = $ti;
            }
            uasort($this->typesIntervention, function ($a, $b) {
                return $a->getordre() - $b->getOrdre();
            });
        }

        return $this->typesIntervention;
    }



    public function getPeriodes ()
    {
        $vhl = $this->getVolumeHoraireListe()->createChild()
            ->setTypeIntervention(false)
            ->setPeriode(false);

        $periodes   = $this->getServiceService()->getPeriodes($vhl->getService());
        $vhPeriodes = $vhl->getPeriodes();
        foreach ($vhPeriodes as $periode) {
            if (!isset($periodes[$periode->getId()])) $periodes[$periode->getId()] = $periode;
        }
        uasort($periodes, function ($a, $b) {
            return ($a ? $a->getOrdre() : '') > ($b ? $b->getOrdre() : '') ? 1 : 0;
        });

        return $periodes;
    }



    protected function renderPeriode ($periode)
    {
        if (!$periode) return "Indéterminée";
@@ -249,6 +282,7 @@ class ListeViewHelper extends AbstractHtmlElement
    }



    public function renderHeures (VolumeHoraireListe $volumeHoraireListe, $readOnly = false)
    {
        $heures = $volumeHoraireListe->getHeures();
@@ -273,6 +307,33 @@ class ListeViewHelper extends AbstractHtmlElement
    }



    /**
     *
     * @return boolean
     */
    public function getReadOnly ()
    {
        return $this->readOnly || $this->forcedReadOnly;
    }



    /**
     *
     * @param boolean $readOnly
     *
     * @return self
     */
    public function setReadOnly ($readOnly)
    {
        $this->readOnly = $readOnly;

        return $this;
    }



    protected function renderMotifNonPaiement ($motifNonPaiement)
    {
        if (!empty($motifNonPaiement)) {
@@ -284,6 +345,8 @@ class ListeViewHelper extends AbstractHtmlElement
        return $out;
    }



    protected function renderTag ($tag)
    {
        /**
@@ -300,66 +363,19 @@ class ListeViewHelper extends AbstractHtmlElement
    }


    /**
     *
     * @return VolumeHoraireListe
     */
    public function getVolumeHoraireListe()
    {
        return $this->volumeHoraireListe;
    }


    public function setVolumeHoraireListe(VolumeHoraireListe $volumeHoraireListe)
    {
        $typeVolumeHoraire = $volumeHoraireListe->getTypeVolumeHoraire();
        $this->volumeHoraireListe = $volumeHoraireListe;
        $this->forcedReadOnly = !$this->getView()->isAllowed($volumeHoraireListe->getService(), $typeVolumeHoraire->getPrivilegeEnseignementEdition());
        $this->typesIntervention = null;

        return $this;
    }


    public function getTypesInterventions()
    {
        if (!$this->typesIntervention) {
            if ($this->getVolumeHoraireListe()->getService()->getElementPedagogique()) {
                $tis = $this->getVolumeHoraireListe()->getService()->getElementPedagogique()->getTypeIntervention();
            } else {
                $qb = $this->getServiceTypeIntervention()->finderByContext();
                $this->getServiceTypeIntervention()->finderByHistorique($qb);
                $tis = $this->getServiceTypeIntervention()->getList($qb);
            }
            $this->typesIntervention = [];
            foreach ($tis as $ti) {
                $this->typesIntervention[] = $ti;
            }
            uasort($this->typesIntervention, function ($a, $b) {
                return $a->getordre() - $b->getOrdre();
            });
        }

        return $this->typesIntervention;
    }


    public function getPeriodes()
    public function getRefreshUrl ()
    {
        $vhl = $this->getVolumeHoraireListe()->createChild()
            ->setTypeIntervention(false)
            ->setPeriode(false);

        $periodes = $this->getServiceService()->getPeriodes($vhl->getService());
        $vhPeriodes = $vhl->getPeriodes();
        foreach ($vhPeriodes as $periode) {
            if (!isset($periodes[$periode->getId()])) $periodes[$periode->getId()] = $periode;
        }
        uasort($periodes, function ($a, $b) {
            return ($a ? $a->getOrdre() : '') > ($b ? $b->getOrdre() : '') ? 1 : 0;
        });
        $url = $this->getView()->url(
            'volume-horaire/liste',
            [
                'service' => $this->getVolumeHoraireListe()->getService()->getId(),
            ], ['query' => [
            'read-only'           => $this->getReadOnly() ? '1' : '0',
            'type-volume-horaire' => $this->getVolumeHoraireListe()->getTypeVolumehoraire()->getId(),
        ]]);

        return $periodes;
        return $url;
    }

}
 No newline at end of file