Loading module/Oscar/src/Oscar/Command/OscarNotificationsRunCommand.php +30 −4 Original line number Diff line number Diff line Loading @@ -22,7 +22,8 @@ class OscarNotificationsRunCommand extends OscarAdvancedCommandAbstract protected static $defaultName = OscarCommandAbstract::COMMAND_NOTIFICATIONS_RUN; const OPTION_DATEREF = 'date'; const OPTION_PERSON = 'persons'; const OPTION_PERSON = 'show-persons'; const OPTION_USER = 'users'; protected function configure() { Loading @@ -41,16 +42,25 @@ class OscarNotificationsRunCommand extends OscarAdvancedCommandAbstract 'p', InputOption::VALUE_NONE, "Afficher les personnes impliquées" ); ) ->addOption( self::OPTION_USER, 'u', InputOption::VALUE_REQUIRED, "Affiche uniquement pour la personne (identifiant)" ) ; } protected function execute(InputInterface $input, OutputInterface $output): int { parent::execute($input, $output); $io = $this->getIO(); $io->title("Calcule des notifications (v2)"); $dateRef = $input->getOption(self::OPTION_DATEREF); $displayPersons = $input->getOption(self::OPTION_PERSON); $user = $input->getOption(self::OPTION_USER); if ($dateRef === false) { $date = new \DateTime(); } else { Loading @@ -62,6 +72,8 @@ class OscarNotificationsRunCommand extends OscarAdvancedCommandAbstract } } $infoDate = $date->format("d M Y"); try { /** @var MilestoneService $milestoneService */ $milestoneService = $this->getProjectGrantService()->getMilestoneService(); Loading @@ -75,11 +87,25 @@ class OscarNotificationsRunCommand extends OscarAdvancedCommandAbstract "Nature du rappel" ]; $person = null; if( $user ){ try { $person = $this->getPersonService()->getPersonByLdapLogin($user); } catch (Exception $e) { $io->error("Impossible de trouver la personne associée à l'identifiant '$user'"); return self::FAILURE; } $io->title("Calcule des notifications pour $person($user) le $infoDate (v2)"); } else { $io->title("Calcule des notifications le $infoDate (v2)"); } if ($displayPersons) { $milestones = $milestoneService->getMilestonesRecallableWithPersons($date); $headers[] = "Personnes"; } else { $milestones = $milestoneService->getMilestonesRecallableAtDate($date); $milestones = $milestoneService->getMilestonesRecallableAtDate($date, $person); } $io->table($headers, $milestones); Loading module/Oscar/src/Oscar/Entity/ActivityDate.php +4 −1 Original line number Diff line number Diff line Loading @@ -245,11 +245,14 @@ class ActivityDate implements ITrackable } /** * @param mixed $type * @param DateType $type */ public function setType($type) { $this->type = $type; if( $type && $type->isFinishable() ){ } return $this; } Loading module/Oscar/src/Oscar/Entity/ActivityDateRepository.php +1 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ class ActivityDateRepository extends EntityRepository ->select('m') ->innerJoin('m.type', 't') ->andWhere('t.finishable = TRUE') ->andWhere('m.dateStart < :date AND m.finished < 100') // AND m.dateStart <= :now') ->andWhere('m.dateStart < :date AND (m.finished < 100 OR m.finished IS NULL)') // AND m.dateStart <= :now') ; $query->setParameters([ 'date' => $date Loading module/Oscar/src/Oscar/Entity/ActivityRepository.php +26 −0 Original line number Diff line number Diff line Loading @@ -429,6 +429,32 @@ class ActivityRepository extends EntityRepository ); } /** * @param array $idsOrganisations * @return int[] */ public function getIdsForOrganizations( array $idsOrganisations ):array{ $qb = $this->createQueryBuilder('a') ->select('a.id') ->leftJoin('a.organizations', 'act_org') ->leftJoin('a.project', 'prj') ->leftJoin('prj.partners', 'prj_org'); $parameters = [ 'organizations' => $idsOrganisations ]; $qb->where('act_org.organization IN(:organizations) OR prj_org.organization IN(:organizations)'); return array_map( 'current', $qb ->getQuery() ->setParameters($parameters) ->getResult() ); } public function getIdsForPersons(array $idsPersons): array { $qb = $this->createQueryBuilder('a') Loading module/Oscar/src/Oscar/Entity/Organization.php +27 −9 Original line number Diff line number Diff line Loading @@ -405,6 +405,7 @@ class Organization implements ResourceInterface, IConnectedObject $this->persons = new ArrayCollection(); $this->setDateCreated(new \DateTime()); $this->flag_newParentCycle = null; $this->children = []; } public function getCodePcru() Loading @@ -422,7 +423,7 @@ class Organization implements ResourceInterface, IConnectedObject } /** * @return mixed * @return Organization[] */ public function getChildren() { Loading @@ -438,6 +439,24 @@ class Organization implements ResourceInterface, IConnectedObject return $out; } public function getChildrenDeepWithSelf(array $out = [], bool $justId = false): array { $out[] = $justId ? $this->getId() : $this; return $this->getChildrenDeep($out, $justId); } public function getChildrenDeep($out = [], $justId = false): array { foreach ($this->getChildren() as $organization) { $out[] = $justId ? $organization->getId() : $organization; if (count($organization->getChildren())) { $out = array_merge($out, $organization->getChildrenDeep($out, $justId)); } } return $out; } /** * @param mixed $children */ Loading Loading @@ -465,7 +484,6 @@ class Organization implements ResourceInterface, IConnectedObject } public function isClose() { return $this->getDateEnd() && $this->getDateEnd() <= new \DateTime(); Loading Loading
module/Oscar/src/Oscar/Command/OscarNotificationsRunCommand.php +30 −4 Original line number Diff line number Diff line Loading @@ -22,7 +22,8 @@ class OscarNotificationsRunCommand extends OscarAdvancedCommandAbstract protected static $defaultName = OscarCommandAbstract::COMMAND_NOTIFICATIONS_RUN; const OPTION_DATEREF = 'date'; const OPTION_PERSON = 'persons'; const OPTION_PERSON = 'show-persons'; const OPTION_USER = 'users'; protected function configure() { Loading @@ -41,16 +42,25 @@ class OscarNotificationsRunCommand extends OscarAdvancedCommandAbstract 'p', InputOption::VALUE_NONE, "Afficher les personnes impliquées" ); ) ->addOption( self::OPTION_USER, 'u', InputOption::VALUE_REQUIRED, "Affiche uniquement pour la personne (identifiant)" ) ; } protected function execute(InputInterface $input, OutputInterface $output): int { parent::execute($input, $output); $io = $this->getIO(); $io->title("Calcule des notifications (v2)"); $dateRef = $input->getOption(self::OPTION_DATEREF); $displayPersons = $input->getOption(self::OPTION_PERSON); $user = $input->getOption(self::OPTION_USER); if ($dateRef === false) { $date = new \DateTime(); } else { Loading @@ -62,6 +72,8 @@ class OscarNotificationsRunCommand extends OscarAdvancedCommandAbstract } } $infoDate = $date->format("d M Y"); try { /** @var MilestoneService $milestoneService */ $milestoneService = $this->getProjectGrantService()->getMilestoneService(); Loading @@ -75,11 +87,25 @@ class OscarNotificationsRunCommand extends OscarAdvancedCommandAbstract "Nature du rappel" ]; $person = null; if( $user ){ try { $person = $this->getPersonService()->getPersonByLdapLogin($user); } catch (Exception $e) { $io->error("Impossible de trouver la personne associée à l'identifiant '$user'"); return self::FAILURE; } $io->title("Calcule des notifications pour $person($user) le $infoDate (v2)"); } else { $io->title("Calcule des notifications le $infoDate (v2)"); } if ($displayPersons) { $milestones = $milestoneService->getMilestonesRecallableWithPersons($date); $headers[] = "Personnes"; } else { $milestones = $milestoneService->getMilestonesRecallableAtDate($date); $milestones = $milestoneService->getMilestonesRecallableAtDate($date, $person); } $io->table($headers, $milestones); Loading
module/Oscar/src/Oscar/Entity/ActivityDate.php +4 −1 Original line number Diff line number Diff line Loading @@ -245,11 +245,14 @@ class ActivityDate implements ITrackable } /** * @param mixed $type * @param DateType $type */ public function setType($type) { $this->type = $type; if( $type && $type->isFinishable() ){ } return $this; } Loading
module/Oscar/src/Oscar/Entity/ActivityDateRepository.php +1 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ class ActivityDateRepository extends EntityRepository ->select('m') ->innerJoin('m.type', 't') ->andWhere('t.finishable = TRUE') ->andWhere('m.dateStart < :date AND m.finished < 100') // AND m.dateStart <= :now') ->andWhere('m.dateStart < :date AND (m.finished < 100 OR m.finished IS NULL)') // AND m.dateStart <= :now') ; $query->setParameters([ 'date' => $date Loading
module/Oscar/src/Oscar/Entity/ActivityRepository.php +26 −0 Original line number Diff line number Diff line Loading @@ -429,6 +429,32 @@ class ActivityRepository extends EntityRepository ); } /** * @param array $idsOrganisations * @return int[] */ public function getIdsForOrganizations( array $idsOrganisations ):array{ $qb = $this->createQueryBuilder('a') ->select('a.id') ->leftJoin('a.organizations', 'act_org') ->leftJoin('a.project', 'prj') ->leftJoin('prj.partners', 'prj_org'); $parameters = [ 'organizations' => $idsOrganisations ]; $qb->where('act_org.organization IN(:organizations) OR prj_org.organization IN(:organizations)'); return array_map( 'current', $qb ->getQuery() ->setParameters($parameters) ->getResult() ); } public function getIdsForPersons(array $idsPersons): array { $qb = $this->createQueryBuilder('a') Loading
module/Oscar/src/Oscar/Entity/Organization.php +27 −9 Original line number Diff line number Diff line Loading @@ -405,6 +405,7 @@ class Organization implements ResourceInterface, IConnectedObject $this->persons = new ArrayCollection(); $this->setDateCreated(new \DateTime()); $this->flag_newParentCycle = null; $this->children = []; } public function getCodePcru() Loading @@ -422,7 +423,7 @@ class Organization implements ResourceInterface, IConnectedObject } /** * @return mixed * @return Organization[] */ public function getChildren() { Loading @@ -438,6 +439,24 @@ class Organization implements ResourceInterface, IConnectedObject return $out; } public function getChildrenDeepWithSelf(array $out = [], bool $justId = false): array { $out[] = $justId ? $this->getId() : $this; return $this->getChildrenDeep($out, $justId); } public function getChildrenDeep($out = [], $justId = false): array { foreach ($this->getChildren() as $organization) { $out[] = $justId ? $organization->getId() : $organization; if (count($organization->getChildren())) { $out = array_merge($out, $organization->getChildrenDeep($out, $justId)); } } return $out; } /** * @param mixed $children */ Loading Loading @@ -465,7 +484,6 @@ class Organization implements ResourceInterface, IConnectedObject } public function isClose() { return $this->getDateEnd() && $this->getDateEnd() <= new \DateTime(); Loading