diff --git a/module/Referentiel/src/Controller/ServiceReferentielController.php b/module/Referentiel/src/Controller/ServiceReferentielController.php index 0f85d965ae4aafbd023e65a90f51caf6f4abc836..54469491f2c793d02929e0ed2c3a91ff6fabddce 100755 --- a/module/Referentiel/src/Controller/ServiceReferentielController.php +++ b/module/Referentiel/src/Controller/ServiceReferentielController.php @@ -6,6 +6,7 @@ use Application\Controller\AbstractController; use Application\Entity\Db\Intervenant; use Laminas\View\Model\ViewModel; use Referentiel\Entity\Db\ServiceReferentiel; +use Referentiel\Entity\Db\VolumeHoraireReferentiel; use Service\Entity\Db\TypeVolumeHoraire; use Referentiel\Form\SaisieAwareTrait; use Plafond\Processus\PlafondProcessusAwareTrait; @@ -42,17 +43,7 @@ class ServiceReferentielController extends AbstractController use PlafondProcessusAwareTrait; - protected function initFilters() - { - $this->em()->getFilters()->enable('historique')->init([ - \Referentiel\Entity\Db\ServiceReferentiel::class, - \Referentiel\Entity\Db\VolumeHoraireReferentiel::class, - \Application\Entity\Db\Validation::class, - ]); - } - - - public function prevuAction() + public function prevuAction () { $prevu = $this->getServiceTypeVolumeHoraire()->getPrevu(); @@ -60,15 +51,8 @@ class ServiceReferentielController extends AbstractController } - public function realiseAction() - { - $realise = $this->getServiceTypeVolumeHoraire()->getRealise(); - - return $this->indexAction($realise); - } - - public function indexAction(?TypeVolumeHoraire $typeVolumeHoraire = null) + public function indexAction (?TypeVolumeHoraire $typeVolumeHoraire = null) { $this->initFilters(); @@ -89,7 +73,28 @@ class ServiceReferentielController extends AbstractController } - public function saisieAction() + + protected function initFilters () + { + $this->em()->getFilters()->enable('historique')->init([ + \Referentiel\Entity\Db\ServiceReferentiel::class, + \Referentiel\Entity\Db\VolumeHoraireReferentiel::class, + \Application\Entity\Db\Validation::class, + ]); + } + + + + public function realiseAction () + { + $realise = $this->getServiceTypeVolumeHoraire()->getRealise(); + + return $this->indexAction($realise); + } + + + + public function saisieAction () { $this->initFilters(); $this->em()->getFilters()->enable('historique')->init([ @@ -104,8 +109,8 @@ class ServiceReferentielController extends AbstractController $typeVolumeHoraire = $this->getServiceTypeVolumehoraire()->get($typeVolumeHoraire); } $service = $this->getServiceServiceReferentiel(); - $role = $this->getServiceContext()->getSelectedIdentityRole(); - $form = $this->getFormServiceReferentielSaisie(); + $role = $this->getServiceContext()->getSelectedIdentityRole(); + $form = $this->getFormServiceReferentielSaisie(); $form->get('type-volume-horaire')->setValue($typeVolumeHoraire->getId()); $intervenant = $this->getServiceLocalContext()->getIntervenant(); @@ -124,6 +129,24 @@ class ServiceReferentielController extends AbstractController $title = "Ajout de référentiel"; } + //Si volume referentiel est validé alors on passe les motifs de non paiement en lecture seule + $disabled = false; + $listeVolumeReferentiel = $entity->getVolumeHoraireReferentiel(); + foreach ($listeVolumeReferentiel as $vhr) { + /** + * @var $vhr VolumeHoraireReferentiel + */ + + if ($vhr->isValide()) { + $disabled = true; + } + } + if ($disabled) { + $form->get('service')->get('motif-non-paiement')->setAttribute('disabled', 'disabled'); + $form->get('service')->get('motif-non-paiement')->setAttribute('title', 'Vous ne pouvez pas mettre de motif de non paiement sur un volume horaire déjà validé'); + } + + $assertionEntity = $service->newEntity(); $assertionEntity ->setTypeVolumeHoraire($typeVolumeHoraire) @@ -134,7 +157,7 @@ class ServiceReferentielController extends AbstractController if (!$this->isAllowed($assertionEntity, $typeVolumeHoraire->getPrivilegeReferentielEdition())) { throw new \LogicException("Cette opération n'est pas autorisée."); } - $hDeb = $entity->getVolumeHoraireReferentielListe()->getHeures(); + $hDeb = $entity->getVolumeHoraireReferentielListe()->getHeures(); $request = $this->getRequest(); if ($request->isPost()) { $form->setData($request->getPost()); @@ -166,14 +189,25 @@ class ServiceReferentielController extends AbstractController } - public function rafraichirLigneAction() + + private function updateTableauxBord (Intervenant $intervenant, $validation = false) + { + $this->getServiceWorkflow()->calculerTableauxBord(['formule', 'validation_referentiel', 'referentiel'], $intervenant); + if (!$validation) { + $this->getServiceWorkflow()->calculerTableauxBord(['referentiel', 'piece_jointe_fournie'], $intervenant); + } + } + + + + public function rafraichirLigneAction () { $this->initFilters(); - $params = $this->params()->fromPost('params', $this->params()->fromQuery('params')); - $details = 1 == (int)$this->params()->fromQuery('details', (int)$this->params()->fromPost('details', 0)); + $params = $this->params()->fromPost('params', $this->params()->fromQuery('params')); + $details = 1 == (int)$this->params()->fromQuery('details', (int)$this->params()->fromPost('details', 0)); $onlyContent = 1 == (int)$this->params()->fromQuery('only-content', 0); - $service = $this->getEvent()->getParam('serviceReferentiel'); + $service = $this->getEvent()->getParam('serviceReferentiel'); /* @var $service ServiceReferentiel */ if (isset($params['type-volume-horaire'])) { @@ -189,7 +223,8 @@ class ServiceReferentielController extends AbstractController } - public function initialisationAction() + + public function initialisationAction () { $intervenant = $this->getEvent()->getParam('intervenant'); $this->getProcessusPlafond()->beginTransaction(); @@ -202,7 +237,8 @@ class ServiceReferentielController extends AbstractController } - public function constatationAction() + + public function constatationAction () { $this->initFilters(); $services = $this->params()->fromQuery('services'); @@ -229,7 +265,8 @@ class ServiceReferentielController extends AbstractController } - public function suppressionAction() + + public function suppressionAction () { $typeVolumeHoraire = $this->params()->fromQuery('type-volume-horaire', $this->params()->fromPost('type-volume-horaire')); if (empty($typeVolumeHoraire)) { @@ -237,7 +274,7 @@ class ServiceReferentielController extends AbstractController } else { $typeVolumeHoraire = $this->getServiceTypeVolumehoraire()->get($typeVolumeHoraire); } - $id = (int)$this->params()->fromRoute('id', null); + $id = (int)$this->params()->fromRoute('id', null); $service = $this->getServiceServiceReferentiel()->get($id); /* @var $service ServiceReferentiel */ @@ -264,7 +301,8 @@ class ServiceReferentielController extends AbstractController } - public function validationPrevuAction() + + public function validationPrevuAction () { $typeVolumeHoraire = $this->getServiceTypeVolumeHoraire()->getPrevu(); @@ -272,15 +310,8 @@ class ServiceReferentielController extends AbstractController } - public function validationRealiseAction() - { - $typeVolumeHoraire = $this->getServiceTypeVolumeHoraire()->getRealise(); - - return $this->validationAction($typeVolumeHoraire); - } - - private function validationAction(TypeVolumeHoraire $typeVolumeHoraire) + private function validationAction (TypeVolumeHoraire $typeVolumeHoraire) { $this->initFilters(); @@ -309,9 +340,9 @@ class ServiceReferentielController extends AbstractController $validations = $this->getProcessusValidationReferentiel()->lister($typeVolumeHoraire, $intervenant, $filterStructure); foreach ($validations as $validation) { - $key = $validation->getId() ? 'valides' : 'non-valides'; - $vid = $this->getProcessusValidationReferentiel()->getValidationId($validation); - $sList = $this->getProcessusValidationReferentiel()->getServices($typeVolumeHoraire, $validation); + $key = $validation->getId() ? 'valides' : 'non-valides'; + $vid = $this->getProcessusValidationReferentiel()->getValidationId($validation); + $sList = $this->getProcessusValidationReferentiel()->getServices($typeVolumeHoraire, $validation); $services[$key][$vid] = $sList; } @@ -340,7 +371,17 @@ class ServiceReferentielController extends AbstractController } - public function validerAction() + + public function validationRealiseAction () + { + $typeVolumeHoraire = $this->getServiceTypeVolumeHoraire()->getRealise(); + + return $this->validationAction($typeVolumeHoraire); + } + + + + public function validerAction () { $this->initFilters(); @@ -376,7 +417,8 @@ class ServiceReferentielController extends AbstractController } - public function devaliderAction() + + public function devaliderAction () { $this->initFilters(); @@ -402,13 +444,4 @@ class ServiceReferentielController extends AbstractController return new MessengerViewModel(); } - - private function updateTableauxBord(Intervenant $intervenant, $validation = false) - { - $this->getServiceWorkflow()->calculerTableauxBord(['formule', 'validation_referentiel', 'referentiel'], $intervenant); - if (!$validation) { - $this->getServiceWorkflow()->calculerTableauxBord(['referentiel', 'piece_jointe_fournie'], $intervenant); - } - } - }