|
|
@@ -83,24 +83,32 @@ class AccessRepository extends ServiceEntityRepository implements UserLoaderInte
|
|
|
|
|
|
/**
|
|
|
* Retourne tous les access qui appartiennent à une organisation qui est active dans un réseau.
|
|
|
- *
|
|
|
- * @throws \Exception
|
|
|
*/
|
|
|
- public function findAllValidAccesses(Access $access): mixed
|
|
|
- {
|
|
|
+ public function findAllValidAccesses(
|
|
|
+ Access $access,
|
|
|
+ ): mixed {
|
|
|
$datetime = new \DateTime();
|
|
|
$today = $datetime->format('Y-m-d');
|
|
|
|
|
|
- return $this->createQueryBuilder('access')
|
|
|
- ->innerJoin('access.organization', 'organization')
|
|
|
- ->innerJoin('organization.networkOrganizations', 'networkOrganizations')
|
|
|
- ->where('access.person = :person')
|
|
|
- ->andWhere('networkOrganizations.startDate <= :today')
|
|
|
- ->setParameter('person', $access->getPerson())
|
|
|
- ->setParameter('today', $today)
|
|
|
- ->getQuery()
|
|
|
- ->getResult()
|
|
|
- ;
|
|
|
+ $this->filtersConfigurationService->suspendTimeConstraintFilters();
|
|
|
+
|
|
|
+ try {
|
|
|
+ $q = $this->createQueryBuilder('access')
|
|
|
+ ->innerJoin('access.organization', 'organization')
|
|
|
+ ->innerJoin('organization.networkOrganizations', 'networkOrganizations')
|
|
|
+ ->where('access.person = :person')
|
|
|
+ ->andWhere('networkOrganizations.startDate <= :today')
|
|
|
+ ->andWhere(
|
|
|
+ "networkOrganizations.endDate >= :today
|
|
|
+ OR networkOrganizations.endDate = '0000-00-00'
|
|
|
+ OR networkOrganizations.endDate IS NULL")
|
|
|
+ ->setParameter('person', $access->getPerson())
|
|
|
+ ->setParameter('today', $today);
|
|
|
+
|
|
|
+ return $q->getQuery()->getResult();
|
|
|
+ } finally {
|
|
|
+ $this->filtersConfigurationService->restoreTimeConstraintFilters();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -110,22 +118,22 @@ class AccessRepository extends ServiceEntityRepository implements UserLoaderInte
|
|
|
{
|
|
|
$this->filtersConfigurationService->suspendTimeConstraintFilters();
|
|
|
|
|
|
- $qb = $this->createQueryBuilder('access');
|
|
|
- $qb
|
|
|
- ->innerJoin('access.organizationFunction', 'organization_function')
|
|
|
- ->innerJoin('organization_function.functionType', 'function_type')
|
|
|
- ->where('function_type.mission = :mission')
|
|
|
- ->andWhere('access.id = :id')
|
|
|
- ->setParameter('id', $access->getId())
|
|
|
- ->setParameter('mission', $function)
|
|
|
- ;
|
|
|
- DateConditions::addDateInPeriodCondition($qb, 'organization_function', $date->format('Y-m-d'));
|
|
|
-
|
|
|
- $result = count($qb->getQuery()->getResult()) > 0;
|
|
|
-
|
|
|
- $this->filtersConfigurationService->restoreTimeConstraintFilters();
|
|
|
-
|
|
|
- return $result;
|
|
|
+ try {
|
|
|
+ $qb = $this->createQueryBuilder('access');
|
|
|
+ $qb
|
|
|
+ ->innerJoin('access.organizationFunction', 'organization_function')
|
|
|
+ ->innerJoin('organization_function.functionType', 'function_type')
|
|
|
+ ->where('function_type.mission = :mission')
|
|
|
+ ->andWhere('access.id = :id')
|
|
|
+ ->setParameter('id', $access->getId())
|
|
|
+ ->setParameter('mission', $function);
|
|
|
+
|
|
|
+ DateConditions::addDateInPeriodCondition($qb, 'organization_function', $date->format('Y-m-d'));
|
|
|
+
|
|
|
+ return count($qb->getQuery()->getResult()) > 0;
|
|
|
+ } finally {
|
|
|
+ $this->filtersConfigurationService->restoreTimeConstraintFilters();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -141,22 +149,21 @@ class AccessRepository extends ServiceEntityRepository implements UserLoaderInte
|
|
|
|
|
|
$this->filtersConfigurationService->suspendTimeConstraintFilters();
|
|
|
|
|
|
- $qb = $this->createQueryBuilder('access');
|
|
|
- $qb
|
|
|
- ->innerJoin('access.organizationFunction', 'organization_function')
|
|
|
- ->innerJoin('organization_function.functionType', 'function_type')
|
|
|
- ->where('function_type.mission = :mission')
|
|
|
- ->andWhere('access.organization = :id')
|
|
|
- ->setParameter('id', $organization->getId())
|
|
|
- ->setParameter('mission', $function)
|
|
|
- ;
|
|
|
- DateConditions::addDateInPeriodCondition($qb, 'organization_function', $date->format('Y-m-d'));
|
|
|
-
|
|
|
- $result = $qb->getQuery()->getResult();
|
|
|
-
|
|
|
- $this->filtersConfigurationService->restoreTimeConstraintFilters();
|
|
|
-
|
|
|
- return $result;
|
|
|
+ try {
|
|
|
+ $qb = $this->createQueryBuilder('access');
|
|
|
+ $qb
|
|
|
+ ->innerJoin('access.organizationFunction', 'organization_function')
|
|
|
+ ->innerJoin('organization_function.functionType', 'function_type')
|
|
|
+ ->where('function_type.mission = :mission')
|
|
|
+ ->andWhere('access.organization = :id')
|
|
|
+ ->setParameter('id', $organization->getId())
|
|
|
+ ->setParameter('mission', $function);
|
|
|
+ DateConditions::addDateInPeriodCondition($qb, 'organization_function', $date->format('Y-m-d'));
|
|
|
+
|
|
|
+ return $qb->getQuery()->getResult();
|
|
|
+ } finally {
|
|
|
+ $this->filtersConfigurationService->restoreTimeConstraintFilters();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|