From b1b7f2fedd613a18523a099856d96c7fdb3ab1b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20L=C3=A9cluse?= <laurent.lecluse@unicaen.fr> Date: Thu, 19 Nov 2020 15:22:59 +0100 Subject: [PATCH] =?UTF-8?q?Correction=20de=20l'apparition=20du=20bouton=20?= =?UTF-8?q?r=C3=A9alis=C3=A9=20vers=20pr=C3=A9vu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Intervenant/ServiceProcessus.php | 28 ++++++------------- .../Application/View/Helper/Service/Liste.php | 5 ++-- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/module/Application/src/Application/Processus/Intervenant/ServiceProcessus.php b/module/Application/src/Application/Processus/Intervenant/ServiceProcessus.php index f6db7e5041..84f7187bb1 100644 --- a/module/Application/src/Application/Processus/Intervenant/ServiceProcessus.php +++ b/module/Application/src/Application/Processus/Intervenant/ServiceProcessus.php @@ -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 diff --git a/module/Application/src/Application/View/Helper/Service/Liste.php b/module/Application/src/Application/View/Helper/Service/Liste.php index 501e6fa26d..5615b3ba9c 100755 --- a/module/Application/src/Application/View/Helper/Service/Liste.php +++ b/module/Application/src/Application/View/Helper/Service/Liste.php @@ -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> '; $out .= '<div class="modal fade" id="prevu-to-prevu-modal" tabindex="-1" role="dialog" aria-hidden="true">'; $out .= '<div class="modal-dialog modal-md">'; -- GitLab