Loading module/Mission/src/Service/MissionService.php +40 −5 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace Mission\Service; use Application\Acl\Role; use Application\Constants; use Application\Entity\Db\Validation; use Application\Provider\Privilege\Privileges; use Application\Service\AbstractEntityService; Loading Loading @@ -164,6 +165,36 @@ class MissionService extends AbstractEntityService public function controleChevauchementOk(VolumeHoraireMission $vhm): bool { $sql = " SELECT vhm.id FROM volume_horaire_mission vhm JOIN mission m ON m.id = vhm.mission_id WHERE vhm.histo_destruction IS NULL AND vhm.type_volume_horaire_id = :typeVolumeHoraire AND m.intervenant_id = :intervenant AND vhm.horaire_debut IS NOT NULL AND vhm.horaire_fin IS NOT NULL AND NOT( :horaireDebut >= to_char(vhm.horaire_fin, 'YYYY-mm-dd HH24:MI') OR :horaireFin <= to_char(vhm.horaire_debut, 'YYYY-mm-dd HH24:MI') )"; $params = [ 'typeVolumeHoraire' => $vhm->getTypeVolumeHoraire()->getId(), 'intervenant' => $vhm->getMission()->getIntervenant()->getId(), 'horaireDebut' => $vhm->getHoraireDebut()->format('Y-m-d H:i'), 'horaireFin' => $vhm->getHoraireFin()->format('Y-m-d H:i'), ]; $r = $this->entityManager->getConnection()->fetchAssociative($sql, $params); return $r === false; } public function saveVolumeHoraire(VolumeHoraireMission $vhm): self { if (!$vhm->getTypeVolumeHoraire()) { Loading @@ -190,6 +221,10 @@ class MissionService extends AbstractEntityService if ($vhm->getHoraireFin() > $now) { throw new \Exception('Vous ne pouvez saisir de suivi avant qu\'il ne soit terminé'); } if (!$this->controleChevauchementOk($vhm)) { throw new \Exception('Impossible d\'ajouter ce suivi : il y a chevauchement avec d\'autres heures renseignées'); } } $this->getEntityManager()->persist($vhm); Loading Loading
module/Mission/src/Service/MissionService.php +40 −5 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace Mission\Service; use Application\Acl\Role; use Application\Constants; use Application\Entity\Db\Validation; use Application\Provider\Privilege\Privileges; use Application\Service\AbstractEntityService; Loading Loading @@ -164,6 +165,36 @@ class MissionService extends AbstractEntityService public function controleChevauchementOk(VolumeHoraireMission $vhm): bool { $sql = " SELECT vhm.id FROM volume_horaire_mission vhm JOIN mission m ON m.id = vhm.mission_id WHERE vhm.histo_destruction IS NULL AND vhm.type_volume_horaire_id = :typeVolumeHoraire AND m.intervenant_id = :intervenant AND vhm.horaire_debut IS NOT NULL AND vhm.horaire_fin IS NOT NULL AND NOT( :horaireDebut >= to_char(vhm.horaire_fin, 'YYYY-mm-dd HH24:MI') OR :horaireFin <= to_char(vhm.horaire_debut, 'YYYY-mm-dd HH24:MI') )"; $params = [ 'typeVolumeHoraire' => $vhm->getTypeVolumeHoraire()->getId(), 'intervenant' => $vhm->getMission()->getIntervenant()->getId(), 'horaireDebut' => $vhm->getHoraireDebut()->format('Y-m-d H:i'), 'horaireFin' => $vhm->getHoraireFin()->format('Y-m-d H:i'), ]; $r = $this->entityManager->getConnection()->fetchAssociative($sql, $params); return $r === false; } public function saveVolumeHoraire(VolumeHoraireMission $vhm): self { if (!$vhm->getTypeVolumeHoraire()) { Loading @@ -190,6 +221,10 @@ class MissionService extends AbstractEntityService if ($vhm->getHoraireFin() > $now) { throw new \Exception('Vous ne pouvez saisir de suivi avant qu\'il ne soit terminé'); } if (!$this->controleChevauchementOk($vhm)) { throw new \Exception('Impossible d\'ajouter ce suivi : il y a chevauchement avec d\'autres heures renseignées'); } } $this->getEntityManager()->persist($vhm); Loading