Skip to content
Snippets Groups Projects
Commit b1b7f2fe authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

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

parent 36f56875
No related branches found
No related tags found
1 merge request!55Ll bug report services
......@@ -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
......@@ -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">';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment