Loading module/Oscar/src/Oscar/Controller/OrganizationController.php +3 −3 Original line number Diff line number Diff line Loading @@ -157,11 +157,11 @@ class OrganizationController extends AbstractOscarController implements UseOrgan $error = _("Expression de recherche incorrecte") . ' : ' . $e->getMessage(); } catch (NoNodesAvailableException $e) { $error = "Le moteur de recherche est introuvable"; } catch (\Exception $exception){ $this->getLoggerService()->error($exception->getMessage()); return $this->jsonError("Quelquechose c'est mal passé..."); } if ($this->getRequest()->isXmlHttpRequest() || $this->params()->fromQuery('f') === 'json') { // test : return $this->getResponseUnauthorized("nop"); $result = ['datas' => []]; Loading module/Oscar/src/Oscar/Entity/ActivityRepository.php +150 −4 Original line number Diff line number Diff line Loading @@ -881,11 +881,11 @@ class ActivityRepository extends EntityRepository * @return array * @throws OscarException */ public function getIdsForPersonAndOrWithRole(array $idPersons, int $idRole): array public function getIdsForPersonAndOrWithRole(array $idPersons, int $idRole, bool $not = false): array { return array_map( 'current', $this->getQueryIdsForPersonOrWithRole($idPersons, $idRole)->select('a.id') $this->getQueryIdsForPersonOrWithRole($idPersons, $idRole, $not)->select('a.id') ->getQuery()->getResult() ); } Loading @@ -905,6 +905,11 @@ class ActivityRepository extends EntityRepository ); } /** * Retourne les IDs des projets pour la liste des IDs d'activité donnée. * @param array|null $ids * @return array */ public function getIdsProjectsForActivity(?array $ids): array { if ($ids) { Loading @@ -921,8 +926,149 @@ class ActivityRepository extends EntityRepository ->getQuery() ->getResult() ); } else { } else { return []; } } /** * Retourne la liste des IDS inverse * @param array $ids * @return array */ public function getIdsInverse(array $ids): array { $qb = $this->getEntityManager()->createQueryBuilder() ->select('DISTINCT c.id') ->from(Activity::class, 'c'); if (count($ids) > 0) { $qb->where('c.id NOT IN(:ids)') ->setParameter('ids', $ids); } return array_map('current', $qb->getQuery()->getResult()); } public function getIdsAmount(mixed $min, mixed $max) { $qb = $this->getEntityManager()->createQueryBuilder() ->select('DISTINCT c.id') ->from(Activity::class, 'c'); $parameters = []; if ($min !== null) { $qb->where('c.amount >= :min'); $parameters['min'] = $min; } if ($max !== null) { $qb->where('c.amount >= :max'); $parameters['max'] = $max; } return array_map('current', $qb->getQuery()->setParameters($parameters)->getResult()); } /** * Liste des ID avec une des disciplines * @param array $disciplines * @return array */ public function getIdsDisciplines(array $disciplines): array { $qb = $this->getEntityManager()->createQueryBuilder() ->select('DISTINCT c.id') ->from(Activity::class, 'c') ->innerJoin('c.disciplines', 'd') ->where('d IN (:disciplines)') ->setParameter('disciplines', $disciplines); return array_map('current', $qb->getQuery()->getResult()); } /** * @param int $milestoneId (DateType->id) * @param array|null $progression * @return array */ public function getIdsMilestone(int $milestoneId, ?array $progression): array { $q = $this->createQueryBuilder('c') ->select('c.id') ->innerJoin('c.milestones', 'm') ->where('m.type = :jalonId'); if (is_array($progression) && count($progression) > 0) { $clause = 'm.finished IN(:progression)'; if (in_array('0', $progression)) { $clause .= ' OR m.finished IS NULL'; } $q->andWhere($clause) ->setParameter('progression', $progression); } $q->setParameter('jalonId', $milestoneId); $activities = $q->getQuery()->getResult(); return array_map('current', $activities); } /** * @param string $field * @param mixed $value1 * @param mixed $value2 * @return integer[] * @throws \Exception */ public function getIdsByDate(string $field, mixed $value1, mixed $value2): array { if (!$value1 && !$value2) { throw new \Exception("Aucune date à filtrer"); } $q = $this->createQueryBuilder('c') ->select('c.id'); $parameters = []; if ($value1) { $q->andWhere('c.' . $field . ' >= :from'); $parameters['from'] = $value1; } if ($value2) { $q->andWhere('c.' . $field . ' <= :to'); $parameters['to'] = $value2; } $q->setParameters($parameters); $activities = $q->getQuery()->getResult(); return array_map('current', $activities); } public function getIdsFinancialImpact(mixed $value1, bool $inversed = false): array { if (!array_key_exists($value1, Activity::getFinancialImpactValues())) { throw new \Exception("Ce type d'incidence financière n'existe pas"); } $param = Activity::getFinancialImpactValues()[$value1]; $q = $this->createQueryBuilder('c') ->select('c.id'); if ($inversed) { $q->andWhere('c.financialImpact != :param'); } else { $q->where('c.financialImpact = :param'); } $q->setParameter('param', $param); return array_map('current', $q->getQuery()->getResult()); } } No newline at end of file module/Oscar/src/Oscar/Service/OrganizationService.php +11 −6 Original line number Diff line number Diff line Loading @@ -675,11 +675,16 @@ class OrganizationService implements UseOscarConfigurationService, UseEntityMana { static $searchStrategy; if ($searchStrategy === null) { try { $opt = $this->getOscarConfigurationService()->getConfiguration('strategy.organization.search_engine'); $class = new \ReflectionClass($opt['class']); $params = $opt['params']; $params[] = $this->getLoggerService(); $searchStrategy = $class->newInstanceArgs($params); } catch (\Throwable $e) { $this->getLoggerService()->critical($e->getMessage()); throw new OscarException("Impossible d'instancier l'accès au moteur de recherche"); } } return $searchStrategy; } Loading @@ -699,7 +704,6 @@ class OrganizationService implements UseOscarConfigurationService, UseEntityMana public function getOrganizationsSearchPaged(string $search, int $page, array $filter = []): UnicaenDoctrinePaginator { $qb = $this->getSearchQuery($search, $filter); return new UnicaenDoctrinePaginator($qb, $page); } Loading Loading @@ -803,6 +807,7 @@ class OrganizationService implements UseOscarConfigurationService, UseEntityMana public function getSearchQuery($search, $filter) { $this->getLoggerService()->debug(__METHOD__); $qb = $this->getBaseQuery(); if ($search != "") { Loading module/Oscar/src/Oscar/Service/ProjectGrantSearchService.php +402 −357 File changed.Preview size limit exceeded, changes collapsed. Show changes module/Oscar/src/Oscar/Service/ProjectGrantService.php +177 −174 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ namespace Oscar\Service; use Cocur\Slugify\Slugify; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; use Doctrine\Persistence\ObjectRepository; use Oscar\Entity\ActivityDate; use Oscar\Entity\ActivityDateRepository; Loading Loading @@ -282,7 +283,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if (!array_key_exists('role_person_id', $options)) { $role_organisation_id = []; } else { } else { $role_organisation_id = ArrayUtils::normalizeArray($options['role_organisation_id']); } Loading Loading @@ -445,7 +447,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi } if (preg_match_all($regex, $pfiTested, $matches, PREG_SET_ORDER, 0)) { $out['valids'][] = $pfiTested; } else { } else { $badPfi = "Un ou plusieurs N°Financier ne correspondent pas au format attendu"; $out['warnings'][] = $pfiTested; } Loading Loading @@ -544,7 +547,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if (!$activity) { if ($throw === true) { throw new OscarException("Impossible de charger l'activité (ID = $id)"); } else { } else { return null; } } Loading @@ -563,7 +567,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if (!$activity) { if ($throw === true) { throw new OscarException("Impossible de charger l'activité (UID = $importedUid)"); } else { } else { return null; } } Loading Loading @@ -695,7 +700,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if (!$activity) { if ($throw === true) { throw new OscarException("Impossible de charger l'activité (OSCAR N° = $oscarNum)"); } else { } else { return null; } } Loading @@ -718,7 +724,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi foreach ($types as $type) { $documentTypes[$type->getId()] = $type->getLabel(); } } else { } else { $documentTypes = $types; } return $documentTypes; Loading Loading @@ -784,30 +791,6 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi return array_map('current', $projects); } public function getActivityIdsByJalon($jalonTypeId, $progression = null) { $q = $this->getActivityRepository()->createQueryBuilder('c') ->select('c.id') ->innerJoin('c.milestones', 'm') ->where('m.type = :jalonId'); if (is_array($progression) && count($progression) > 0) { $clause = 'm.finished IN(:progression)'; if (in_array('0', $progression)) { $clause .= ' OR m.finished IS NULL'; } $q->andWhere($clause) ->setParameter('progression', $progression); } $q->setParameter('jalonId', $jalonTypeId); $activities = $q->getQuery()->getResult(); return array_map('current', $activities); } /** * @param $ids * @param int $page Loading Loading @@ -909,7 +892,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if (is_array($restricted_ids)) { if ($ids_search === null) { $ids_search = $restricted_ids; } else { } else { $ids_search = array_intersect($ids_search, $restricted_ids); } } Loading Loading @@ -1070,7 +1054,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if ($ids_search === null) { $ids_search = $ids; } else { } else { $ids_search = array_intersect($ids_search, $ids); } } catch (\Exception $e) { Loading Loading @@ -1100,7 +1085,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi return $a1ID > $a2ID; }; usort($resultRaw, $pertinenceFunction); } else { } else { $queryBuilder->orderBy('c.' . $sort, $direction); $resultRaw = $queryBuilder->getQuery()->getResult(); } Loading @@ -1122,6 +1108,11 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi return $output; } public function getActivitiesIdsInverse(array $idsActivitySearch): array { return $this->getActivityRepository()->getIdsInverse($idsActivitySearch); } protected function debug__displayIds(array $ids) { echo " = "; Loading Loading @@ -1675,12 +1666,6 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi return $this->getActivityRepository()->getActivitiesIdsWithTypeDocument($idsTypeDocument, $reverse); } public function getActivitiesWithNumerotation(array $numerotations): array { $ids = $this->getActivityRepository()->getActivitiesIdsWithNumerotations($numerotations); return $ids; } /** * Renomage des clefs pour les numérotations personnalisées; * Loading Loading @@ -1788,7 +1773,7 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi * @param \DateTime $from * @param \DateTime $to * @param string $field * @return \Doctrine\ORM\QueryBuilder * @return QueryBuilder */ public function getActivitiesBeetween2dates(\DateTime $from, \DateTime $to, $field = 'dateStart') { Loading @@ -1809,7 +1794,7 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi * * @param string $gap * @param string $start * @return \Doctrine\ORM\QueryBuilder * @return QueryBuilder */ public function getActivityAlmostDone($gap = '+1 month', $start = 'now') { Loading @@ -1824,7 +1809,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi /** * @param string $gap * @param string $start * @return \Doctrine\ORM\QueryBuilder * @return QueryBuilder * @throws \DateMalformedStringException */ public function getActivityBeginsSoon($gap = '+2 weeks', $start = 'now') { Loading Loading @@ -1865,7 +1851,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if (!$this->searchIndex_checkPath()) { $this->index = \Zend_Search_Lucene::create($path); $this->index = \Zend_Search_Lucene::create($path); } else { } else { $this->index = \Zend_Search_Lucene::open($path); } // Lucene configuration globale Loading @@ -1886,12 +1873,12 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi } /** * Retourne les jalons de l'activités. * Retourne les jalons de l'activité. * * @param $idActivity * @return array */ public function getMilestones($idActivity) public function getMilestones($idActivity): array { return $this->getMilestoneService()->getMilestonesByActivityId($idActivity); } Loading Loading @@ -2141,7 +2128,7 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi } /** * @return \Doctrine\ORM\QueryBuilder * @return QueryBuilder */ protected function getQueryBuilderDateType() { Loading Loading @@ -2367,13 +2354,15 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if ($datePayment) { $payment->setDatePayment(new \DateTime($datePayment)); } else { } else { $payment->setDatePayment(null); } if ($datePredicted) { $payment->setDatePredicted(new \DateTime($datePredicted)); } else { } else { $payment->setDatePredicted(null); } $payment->setRate($rate) Loading Loading @@ -2420,13 +2409,15 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if ($datePayment) { $payment->setDatePayment(new \DateTime($datePayment)); } else { } else { $payment->setDatePayment(null); } if ($datePredicted) { $payment->setDatePredicted(new \DateTime($datePredicted)); } else { } else { $payment->setDatePredicted(null); } Loading Loading @@ -2710,7 +2701,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if ($deep) { $ids = $this->getOrganizationService()->getOrganizationIdsDeep($idOrganization); $ids[] = $idOrganization; } else { } else { $ids = [$idOrganization]; } return $this->getBaseQuery() Loading Loading @@ -2770,7 +2762,7 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi /** * Retourne la requète pour obtenir la liste complète des contrats. * * @return \Doctrine\ORM\QueryBuilder * @return QueryBuilder */ public function getGrants() { Loading Loading @@ -2874,7 +2866,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi while ($close > 0) { if ($open[count($open) - 1] < $grantType->getLft()) { array_pop($open); } else { } else { $prefix .= " - "; $prefix .= " - "; } Loading @@ -2884,7 +2877,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if ($grantType->getLft() + 1 == $grantType->getRgt()) { $prefix .= ' # '; $qt = ''; } else { } else { $open[] = $grantType->getRgt(); $qt = sprintf(' (%s)', (($grantType->getRgt() - $grantType->getLft() - 1) / 2)); } Loading Loading @@ -3041,7 +3035,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi try { if (!$activityorganization->getRoleObj()) { $updateNotification = $roleOrganization->isPrincipal(); } else { } else { $updateNotification = $activityorganization->getRoleObj()->isPrincipal( ) !== $roleOrganization->isPrincipal(); } Loading Loading @@ -3163,13 +3158,14 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi //////////////////////////////////////////////////////////////////////////// /** * @return \Doctrine\ORM\QueryBuilder * @return QueryBuilder */ public function getBaseQuery($includeObsolet = false) { if ($includeObsolet === true) { $roleClaude = ' AND ((m.dateStart is NULL OR m.dateStart <= :dateRef)AND(m.dateEnd is NULL OR m.dateEnd >= :dateRef))'; } else { } else { $roleClaude = ''; } $qb = $this->getEntityManager()->createQueryBuilder() Loading Loading @@ -3239,7 +3235,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi } catch (\Exception $e) { throw new OscarException("Impossible d'ajouter le pôle '$label', " . $e->getMessage()); } } else { } else { throw new OscarException("Le pôle '$label' existe déjà"); } } Loading @@ -3258,7 +3255,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi } catch (\Exception $e) { throw new OscarException("Impossible d'ajouter la source de financement '$label', " . $e->getMessage()); } } else { } else { throw new OscarException("La source de financement '$label' existe déjà"); } } Loading @@ -3277,7 +3275,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi } catch (\Exception $e) { throw new OscarException("Impossible d'ajouter le type de contrat '$label', " . $e->getMessage()); } } else { } else { throw new OscarException("Le type de contrat '$label' existe déjà"); } } Loading @@ -3293,7 +3292,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi $repository = $this->getEntityManager()->getRepository(PcruTypeContract::class); if ($format == AsArrayFormatter::ARRAY_FLAT) { return $repository->getFlatArrayLabel(); } else { } else { throw new OscarException("Format pour la liste des Type de contrat PCRU non-disponible"); } } Loading Loading @@ -3383,12 +3383,14 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if ($format == AsArrayFormatter::ARRAY_FLAT) { if ($withEmptyAtFirst == true) { $array = ["Aucun"]; } else { } else { $array = []; } $array = array_merge($array, $repository->getFlatArrayLabel()); return $array; } else { } else { throw new OscarException("Format pour la liste des pôles de compétivité PCRU non-disponible"); } } Loading @@ -3404,7 +3406,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi $repository = $this->getEntityManager()->getRepository(PcruSourceFinancement::class); if ($format == AsArrayFormatter::ARRAY_FLAT) { return $repository->getFlatArrayLabel(); } else { } else { throw new OscarException("Format pour la liste des sources de financement PCRU non-disponible"); } } Loading Loading
module/Oscar/src/Oscar/Controller/OrganizationController.php +3 −3 Original line number Diff line number Diff line Loading @@ -157,11 +157,11 @@ class OrganizationController extends AbstractOscarController implements UseOrgan $error = _("Expression de recherche incorrecte") . ' : ' . $e->getMessage(); } catch (NoNodesAvailableException $e) { $error = "Le moteur de recherche est introuvable"; } catch (\Exception $exception){ $this->getLoggerService()->error($exception->getMessage()); return $this->jsonError("Quelquechose c'est mal passé..."); } if ($this->getRequest()->isXmlHttpRequest() || $this->params()->fromQuery('f') === 'json') { // test : return $this->getResponseUnauthorized("nop"); $result = ['datas' => []]; Loading
module/Oscar/src/Oscar/Entity/ActivityRepository.php +150 −4 Original line number Diff line number Diff line Loading @@ -881,11 +881,11 @@ class ActivityRepository extends EntityRepository * @return array * @throws OscarException */ public function getIdsForPersonAndOrWithRole(array $idPersons, int $idRole): array public function getIdsForPersonAndOrWithRole(array $idPersons, int $idRole, bool $not = false): array { return array_map( 'current', $this->getQueryIdsForPersonOrWithRole($idPersons, $idRole)->select('a.id') $this->getQueryIdsForPersonOrWithRole($idPersons, $idRole, $not)->select('a.id') ->getQuery()->getResult() ); } Loading @@ -905,6 +905,11 @@ class ActivityRepository extends EntityRepository ); } /** * Retourne les IDs des projets pour la liste des IDs d'activité donnée. * @param array|null $ids * @return array */ public function getIdsProjectsForActivity(?array $ids): array { if ($ids) { Loading @@ -921,8 +926,149 @@ class ActivityRepository extends EntityRepository ->getQuery() ->getResult() ); } else { } else { return []; } } /** * Retourne la liste des IDS inverse * @param array $ids * @return array */ public function getIdsInverse(array $ids): array { $qb = $this->getEntityManager()->createQueryBuilder() ->select('DISTINCT c.id') ->from(Activity::class, 'c'); if (count($ids) > 0) { $qb->where('c.id NOT IN(:ids)') ->setParameter('ids', $ids); } return array_map('current', $qb->getQuery()->getResult()); } public function getIdsAmount(mixed $min, mixed $max) { $qb = $this->getEntityManager()->createQueryBuilder() ->select('DISTINCT c.id') ->from(Activity::class, 'c'); $parameters = []; if ($min !== null) { $qb->where('c.amount >= :min'); $parameters['min'] = $min; } if ($max !== null) { $qb->where('c.amount >= :max'); $parameters['max'] = $max; } return array_map('current', $qb->getQuery()->setParameters($parameters)->getResult()); } /** * Liste des ID avec une des disciplines * @param array $disciplines * @return array */ public function getIdsDisciplines(array $disciplines): array { $qb = $this->getEntityManager()->createQueryBuilder() ->select('DISTINCT c.id') ->from(Activity::class, 'c') ->innerJoin('c.disciplines', 'd') ->where('d IN (:disciplines)') ->setParameter('disciplines', $disciplines); return array_map('current', $qb->getQuery()->getResult()); } /** * @param int $milestoneId (DateType->id) * @param array|null $progression * @return array */ public function getIdsMilestone(int $milestoneId, ?array $progression): array { $q = $this->createQueryBuilder('c') ->select('c.id') ->innerJoin('c.milestones', 'm') ->where('m.type = :jalonId'); if (is_array($progression) && count($progression) > 0) { $clause = 'm.finished IN(:progression)'; if (in_array('0', $progression)) { $clause .= ' OR m.finished IS NULL'; } $q->andWhere($clause) ->setParameter('progression', $progression); } $q->setParameter('jalonId', $milestoneId); $activities = $q->getQuery()->getResult(); return array_map('current', $activities); } /** * @param string $field * @param mixed $value1 * @param mixed $value2 * @return integer[] * @throws \Exception */ public function getIdsByDate(string $field, mixed $value1, mixed $value2): array { if (!$value1 && !$value2) { throw new \Exception("Aucune date à filtrer"); } $q = $this->createQueryBuilder('c') ->select('c.id'); $parameters = []; if ($value1) { $q->andWhere('c.' . $field . ' >= :from'); $parameters['from'] = $value1; } if ($value2) { $q->andWhere('c.' . $field . ' <= :to'); $parameters['to'] = $value2; } $q->setParameters($parameters); $activities = $q->getQuery()->getResult(); return array_map('current', $activities); } public function getIdsFinancialImpact(mixed $value1, bool $inversed = false): array { if (!array_key_exists($value1, Activity::getFinancialImpactValues())) { throw new \Exception("Ce type d'incidence financière n'existe pas"); } $param = Activity::getFinancialImpactValues()[$value1]; $q = $this->createQueryBuilder('c') ->select('c.id'); if ($inversed) { $q->andWhere('c.financialImpact != :param'); } else { $q->where('c.financialImpact = :param'); } $q->setParameter('param', $param); return array_map('current', $q->getQuery()->getResult()); } } No newline at end of file
module/Oscar/src/Oscar/Service/OrganizationService.php +11 −6 Original line number Diff line number Diff line Loading @@ -675,11 +675,16 @@ class OrganizationService implements UseOscarConfigurationService, UseEntityMana { static $searchStrategy; if ($searchStrategy === null) { try { $opt = $this->getOscarConfigurationService()->getConfiguration('strategy.organization.search_engine'); $class = new \ReflectionClass($opt['class']); $params = $opt['params']; $params[] = $this->getLoggerService(); $searchStrategy = $class->newInstanceArgs($params); } catch (\Throwable $e) { $this->getLoggerService()->critical($e->getMessage()); throw new OscarException("Impossible d'instancier l'accès au moteur de recherche"); } } return $searchStrategy; } Loading @@ -699,7 +704,6 @@ class OrganizationService implements UseOscarConfigurationService, UseEntityMana public function getOrganizationsSearchPaged(string $search, int $page, array $filter = []): UnicaenDoctrinePaginator { $qb = $this->getSearchQuery($search, $filter); return new UnicaenDoctrinePaginator($qb, $page); } Loading Loading @@ -803,6 +807,7 @@ class OrganizationService implements UseOscarConfigurationService, UseEntityMana public function getSearchQuery($search, $filter) { $this->getLoggerService()->debug(__METHOD__); $qb = $this->getBaseQuery(); if ($search != "") { Loading
module/Oscar/src/Oscar/Service/ProjectGrantSearchService.php +402 −357 File changed.Preview size limit exceeded, changes collapsed. Show changes
module/Oscar/src/Oscar/Service/ProjectGrantService.php +177 −174 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ namespace Oscar\Service; use Cocur\Slugify\Slugify; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; use Doctrine\Persistence\ObjectRepository; use Oscar\Entity\ActivityDate; use Oscar\Entity\ActivityDateRepository; Loading Loading @@ -282,7 +283,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if (!array_key_exists('role_person_id', $options)) { $role_organisation_id = []; } else { } else { $role_organisation_id = ArrayUtils::normalizeArray($options['role_organisation_id']); } Loading Loading @@ -445,7 +447,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi } if (preg_match_all($regex, $pfiTested, $matches, PREG_SET_ORDER, 0)) { $out['valids'][] = $pfiTested; } else { } else { $badPfi = "Un ou plusieurs N°Financier ne correspondent pas au format attendu"; $out['warnings'][] = $pfiTested; } Loading Loading @@ -544,7 +547,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if (!$activity) { if ($throw === true) { throw new OscarException("Impossible de charger l'activité (ID = $id)"); } else { } else { return null; } } Loading @@ -563,7 +567,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if (!$activity) { if ($throw === true) { throw new OscarException("Impossible de charger l'activité (UID = $importedUid)"); } else { } else { return null; } } Loading Loading @@ -695,7 +700,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if (!$activity) { if ($throw === true) { throw new OscarException("Impossible de charger l'activité (OSCAR N° = $oscarNum)"); } else { } else { return null; } } Loading @@ -718,7 +724,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi foreach ($types as $type) { $documentTypes[$type->getId()] = $type->getLabel(); } } else { } else { $documentTypes = $types; } return $documentTypes; Loading Loading @@ -784,30 +791,6 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi return array_map('current', $projects); } public function getActivityIdsByJalon($jalonTypeId, $progression = null) { $q = $this->getActivityRepository()->createQueryBuilder('c') ->select('c.id') ->innerJoin('c.milestones', 'm') ->where('m.type = :jalonId'); if (is_array($progression) && count($progression) > 0) { $clause = 'm.finished IN(:progression)'; if (in_array('0', $progression)) { $clause .= ' OR m.finished IS NULL'; } $q->andWhere($clause) ->setParameter('progression', $progression); } $q->setParameter('jalonId', $jalonTypeId); $activities = $q->getQuery()->getResult(); return array_map('current', $activities); } /** * @param $ids * @param int $page Loading Loading @@ -909,7 +892,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if (is_array($restricted_ids)) { if ($ids_search === null) { $ids_search = $restricted_ids; } else { } else { $ids_search = array_intersect($ids_search, $restricted_ids); } } Loading Loading @@ -1070,7 +1054,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if ($ids_search === null) { $ids_search = $ids; } else { } else { $ids_search = array_intersect($ids_search, $ids); } } catch (\Exception $e) { Loading Loading @@ -1100,7 +1085,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi return $a1ID > $a2ID; }; usort($resultRaw, $pertinenceFunction); } else { } else { $queryBuilder->orderBy('c.' . $sort, $direction); $resultRaw = $queryBuilder->getQuery()->getResult(); } Loading @@ -1122,6 +1108,11 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi return $output; } public function getActivitiesIdsInverse(array $idsActivitySearch): array { return $this->getActivityRepository()->getIdsInverse($idsActivitySearch); } protected function debug__displayIds(array $ids) { echo " = "; Loading Loading @@ -1675,12 +1666,6 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi return $this->getActivityRepository()->getActivitiesIdsWithTypeDocument($idsTypeDocument, $reverse); } public function getActivitiesWithNumerotation(array $numerotations): array { $ids = $this->getActivityRepository()->getActivitiesIdsWithNumerotations($numerotations); return $ids; } /** * Renomage des clefs pour les numérotations personnalisées; * Loading Loading @@ -1788,7 +1773,7 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi * @param \DateTime $from * @param \DateTime $to * @param string $field * @return \Doctrine\ORM\QueryBuilder * @return QueryBuilder */ public function getActivitiesBeetween2dates(\DateTime $from, \DateTime $to, $field = 'dateStart') { Loading @@ -1809,7 +1794,7 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi * * @param string $gap * @param string $start * @return \Doctrine\ORM\QueryBuilder * @return QueryBuilder */ public function getActivityAlmostDone($gap = '+1 month', $start = 'now') { Loading @@ -1824,7 +1809,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi /** * @param string $gap * @param string $start * @return \Doctrine\ORM\QueryBuilder * @return QueryBuilder * @throws \DateMalformedStringException */ public function getActivityBeginsSoon($gap = '+2 weeks', $start = 'now') { Loading Loading @@ -1865,7 +1851,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if (!$this->searchIndex_checkPath()) { $this->index = \Zend_Search_Lucene::create($path); $this->index = \Zend_Search_Lucene::create($path); } else { } else { $this->index = \Zend_Search_Lucene::open($path); } // Lucene configuration globale Loading @@ -1886,12 +1873,12 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi } /** * Retourne les jalons de l'activités. * Retourne les jalons de l'activité. * * @param $idActivity * @return array */ public function getMilestones($idActivity) public function getMilestones($idActivity): array { return $this->getMilestoneService()->getMilestonesByActivityId($idActivity); } Loading Loading @@ -2141,7 +2128,7 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi } /** * @return \Doctrine\ORM\QueryBuilder * @return QueryBuilder */ protected function getQueryBuilderDateType() { Loading Loading @@ -2367,13 +2354,15 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if ($datePayment) { $payment->setDatePayment(new \DateTime($datePayment)); } else { } else { $payment->setDatePayment(null); } if ($datePredicted) { $payment->setDatePredicted(new \DateTime($datePredicted)); } else { } else { $payment->setDatePredicted(null); } $payment->setRate($rate) Loading Loading @@ -2420,13 +2409,15 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if ($datePayment) { $payment->setDatePayment(new \DateTime($datePayment)); } else { } else { $payment->setDatePayment(null); } if ($datePredicted) { $payment->setDatePredicted(new \DateTime($datePredicted)); } else { } else { $payment->setDatePredicted(null); } Loading Loading @@ -2710,7 +2701,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if ($deep) { $ids = $this->getOrganizationService()->getOrganizationIdsDeep($idOrganization); $ids[] = $idOrganization; } else { } else { $ids = [$idOrganization]; } return $this->getBaseQuery() Loading Loading @@ -2770,7 +2762,7 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi /** * Retourne la requète pour obtenir la liste complète des contrats. * * @return \Doctrine\ORM\QueryBuilder * @return QueryBuilder */ public function getGrants() { Loading Loading @@ -2874,7 +2866,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi while ($close > 0) { if ($open[count($open) - 1] < $grantType->getLft()) { array_pop($open); } else { } else { $prefix .= " - "; $prefix .= " - "; } Loading @@ -2884,7 +2877,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if ($grantType->getLft() + 1 == $grantType->getRgt()) { $prefix .= ' # '; $qt = ''; } else { } else { $open[] = $grantType->getRgt(); $qt = sprintf(' (%s)', (($grantType->getRgt() - $grantType->getLft() - 1) / 2)); } Loading Loading @@ -3041,7 +3035,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi try { if (!$activityorganization->getRoleObj()) { $updateNotification = $roleOrganization->isPrincipal(); } else { } else { $updateNotification = $activityorganization->getRoleObj()->isPrincipal( ) !== $roleOrganization->isPrincipal(); } Loading Loading @@ -3163,13 +3158,14 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi //////////////////////////////////////////////////////////////////////////// /** * @return \Doctrine\ORM\QueryBuilder * @return QueryBuilder */ public function getBaseQuery($includeObsolet = false) { if ($includeObsolet === true) { $roleClaude = ' AND ((m.dateStart is NULL OR m.dateStart <= :dateRef)AND(m.dateEnd is NULL OR m.dateEnd >= :dateRef))'; } else { } else { $roleClaude = ''; } $qb = $this->getEntityManager()->createQueryBuilder() Loading Loading @@ -3239,7 +3235,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi } catch (\Exception $e) { throw new OscarException("Impossible d'ajouter le pôle '$label', " . $e->getMessage()); } } else { } else { throw new OscarException("Le pôle '$label' existe déjà"); } } Loading @@ -3258,7 +3255,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi } catch (\Exception $e) { throw new OscarException("Impossible d'ajouter la source de financement '$label', " . $e->getMessage()); } } else { } else { throw new OscarException("La source de financement '$label' existe déjà"); } } Loading @@ -3277,7 +3275,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi } catch (\Exception $e) { throw new OscarException("Impossible d'ajouter le type de contrat '$label', " . $e->getMessage()); } } else { } else { throw new OscarException("Le type de contrat '$label' existe déjà"); } } Loading @@ -3293,7 +3292,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi $repository = $this->getEntityManager()->getRepository(PcruTypeContract::class); if ($format == AsArrayFormatter::ARRAY_FLAT) { return $repository->getFlatArrayLabel(); } else { } else { throw new OscarException("Format pour la liste des Type de contrat PCRU non-disponible"); } } Loading Loading @@ -3383,12 +3383,14 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi if ($format == AsArrayFormatter::ARRAY_FLAT) { if ($withEmptyAtFirst == true) { $array = ["Aucun"]; } else { } else { $array = []; } $array = array_merge($array, $repository->getFlatArrayLabel()); return $array; } else { } else { throw new OscarException("Format pour la liste des pôles de compétivité PCRU non-disponible"); } } Loading @@ -3404,7 +3406,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi $repository = $this->getEntityManager()->getRepository(PcruSourceFinancement::class); if ($format == AsArrayFormatter::ARRAY_FLAT) { return $repository->getFlatArrayLabel(); } else { } else { throw new OscarException("Format pour la liste des sources de financement PCRU non-disponible"); } } Loading