Commit a0e042a2 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Correction de l'apparition du bouton réalisé vers prévu


(cherry picked from commit b1b7f2fe)
parent fad4e8d9
Loading
Loading
Loading
Loading
+8 −20
Changes for module/Application/src/Application/Processus/Intervenant/ServiceProcessus.php: 8 added lines, 20 removed lines.
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ namespace Application\Processus\Intervenant;


use Application\Entity\Db\Intervenant;
use Application\Entity\Db\TblService;
use Application\Entity\Db\TypeVolumeHoraire;
use Application\Service\Traits\IntervenantServiceAwareTrait;
use UnicaenApp\Service\EntityManagerAwareTrait;

@@ -14,30 +14,18 @@ class ServiceProcessus
    use IntervenantServiceAwareTrait;



    public function canPrevuToPrevu(Intervenant $intervenant)
    public function canInitializePrevu(Intervenant $intervenant, TypeVolumeHoraire $typeVolumeHoraire)
    {
        $intervenant = $this->getServiceIntervenant()->getPrecedent($intervenant);
        if (!$intervenant) return false;

        $dql = "
        SELECT
          s        
        FROM
          " . TblService::class . " s
          JOIN s.typeVolumeHoraire tvh
        WHERE
            s.intervenant = :intervenant
            AND tvh.code = 'PREVU'
            AND s.valide > 0
        ";

        $query = $this->getEntityManager()->createQuery($dql)->setMaxResults(1);
        $query->setParameters(compact('intervenant'));
        $s = $query->getResult();

        return count($s) > 0;
        $sql = "SELECT valide FROM tbl_service WHERE intervenant_id = :intervenant AND type_volume_horaire_id = :typeVolumeHoraire AND valide > 0";
        $res = $this->getEntityManager()->getConnection()->fetchOne($sql, [
            'intervenant'       => $intervenant->getId(),
            'typeVolumeHoraire' => $typeVolumeHoraire->getId(),
        ]);

        return $res !== false;
    }

}
 No newline at end of file
+3 −2
Changes for module/Application/src/Application/View/Helper/Service/Liste.php: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -259,7 +259,8 @@ class Liste extends AbstractViewHelper
            $out     .= '</div>';
            $out     .= '</div>';
        } elseif ($this->prevuToPrevu) {
            if ($this->getProcessusIntervenant()->service()->canPrevuToPrevu($this->prevuToPrevu)) {
            $typeVolumeHoraire = $this->getServiceTypeVolumeHoraire()->getByCode($this->getServiceParametres()->get('report_service'));
            if ($this->getProcessusIntervenant()->service()->canInitializePrevu($this->prevuToPrevu, $typeVolumeHoraire)) {
                $attribs = [
                    'class'       => 'btn btn-warning prevu-to-prevu-show',
                    'data-toggle' => 'modal',
@@ -268,7 +269,7 @@ class Liste extends AbstractViewHelper
                    //'href'          => $this->getAddUrl(),
                    'title'       => "Initialiser le service prévisionnel avec le service prévisionnel validé l'année dernière",
                ];
                $source  = $this->getServiceTypeVolumeHoraire()->getByCode($this->getServiceParametres()->get('report_service'))->getLibelle();
                $source  = $typeVolumeHoraire->getLibelle();
                $out     .= '<button type="button" ' . $this->htmlAttribs($attribs) . '>' . $source . ' ' . $this->getServiceContext()->getAnneePrecedente() . ' <span class="glyphicon glyphicon-arrow-right"></span> Prévisionnel ' . $this->getServiceContext()->getAnnee() . '</button>&nbsp;';
                $out     .= '<div class="modal fade" id="prevu-to-prevu-modal" tabindex="-1" role="dialog" aria-hidden="true">';
                $out     .= '<div class="modal-dialog modal-md">';