Commit 37cce19a authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

- Fix : Pour les versements prévisionnels en retard, ainsi que pour les...

 - Fix : Pour les versements prévisionnels en retard, ainsi que pour les jalons à faire non-fait, l'application repasse la dernière notification impliquée en non-lue avant de déclencher l'envoi par email. Cela aura pour effet de toujours envoyer par email ces notifications.
parent a5c0bc73
Loading
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ class OscarNotificationsCheckCommand extends OscarCommandAbstract
            $io->error(
                "Vous devez préciser la personne (avec --person <IDPERSON>) ou l'activité (avec --activity <IDACTIVITY)"
            );
            exit(1);
            exit(self::INVALID);
        }

        if ($personId) {
@@ -91,5 +91,7 @@ class OscarNotificationsCheckCommand extends OscarCommandAbstract
            }
            $io->table($headers, $rows);
        }

        return self::SUCCESS;
    }
}
 No newline at end of file
+5 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ class OscarNotificationsMailsPersonsCommand extends OscarCommandAbstract
        $this
            ->setDescription("Déclenche la procédure d'envoi des notifications par mail")
            ->addOption('date', 'd', InputOption::VALUE_OPTIONAL, 'date de déclenchement', null)
            ->addOption('force', 'f', InputOption::VALUE_NONE, "Force l'envoi en ignorant l'inscription au créneau d'envoi configuré")
        ;
    }

@@ -36,10 +37,13 @@ class OscarNotificationsMailsPersonsCommand extends OscarCommandAbstract
            $dateRef = new \DateTime($date);
        }

        $force = $input->getOption('force');


        /** @var PersonService $personService */
        $personService = $this->getServicemanager()->get(PersonService::class);
        try {
            $personService->mailPersonsWithUnreadNotification($dateRef->format('Y-m-d H:i:s'), $io);
            $personService->mailPersonsWithUnreadNotification($dateRef->format('Y-m-d H:i:s'), $io, $force);
        } catch (\Exception $e) {
            $io->error($e->getMessage());
            return self::FAILURE;
+0 −8
Original line number Diff line number Diff line
@@ -26,12 +26,6 @@ class OscarNotificationsRebuildCommand extends OscarAdvancedCommandAbstract
        parent::configure();
        $this
            ->setDescription("Reconstruction des notifications des activités de recherche")
//            ->addOption(
//                self::OPTION_INCLUDE_PAST,
//                null,
//                InputArgument::OPTIONAL,
//                "Forcer le recalcule des notifications pour les activités"
//            )
            ->addOption(
                self::OPTION_PURGE,
                'p',
@@ -45,9 +39,7 @@ class OscarNotificationsRebuildCommand extends OscarAdvancedCommandAbstract
    {
        parent::execute($input, $output);

        //$includePast = $input->getOption(self::OPTION_INCLUDE_PAST);
        $purgeBefore = $input->getOption(self::OPTION_PURGE);
        var_dump($purgeBefore);

        try {
            // TODO Récupérer les activités en fonction des critères
+10 −20
Original line number Diff line number Diff line
@@ -144,31 +144,21 @@ class ActivityDateRepository extends EntityRepository
    }


    public function getMilestonesFinishable($status = null)
    public function getMilestonesFinishable(\DateTime $dateRef = null): array
    {
        if (null === $dateRef) {
            $dateRef = new \DateTime();
        }
        $query = $this->createQueryBuilder('m')
            ->select('m')
            ->innerJoin('m.type', 't')
            ->andWhere('t.id = 53') // AND m.dateStart <= :now')
        ;

        $query->where('t.finishable = :finishable')
            ->where('t.finishable = :finishable')
            ->andWhere('m.finished IS NULL OR m.finished <= 0')
            ->andWhere('m.dateStart <= :date')
            ->setParameter('finishable', true)
            ->andWhere('m.finished IS NULL OR m.finished <= 0');

        //$query->setParameter('now', date('Y-m-d'));
        // AND m.dateStart <= :now')


        $result = $query->getQuery()->getResult();

        /** @var ActivityDate $r */
        foreach ($result as $r) {
            $fin = ($r->getDateFinish() ? $r->getDateFinish()->format('Y-m-d') : 'Pas fini');
            echo $r->getType()->getId() . " - $r - " . $r->getFinished() . " / " . $fin . "\n";
        }
        echo $query->getDQL();
            ->setParameter('date', $dateRef)
            ;

        die("TOTAL : " . count($result));
        return $query->getQuery()->getResult();
    }
}
+38 −0
Original line number Diff line number Diff line
@@ -122,6 +122,44 @@ class NotificationRepository extends EntityRepository
        return $qb->getQuery()->execute();
    }

    /**
     * @param int $milestoneId
     * @return Notification[]
     */
    public function getNotificationsMilestone(int $milestoneId): array
    {
        $qb = $this->createQueryBuilder("n")
            ->where("n.context = :context")
            ->orderBy('n.dateEffective', 'ASC');

        $qb->setParameters(
            [
                'context' => 'milestone:'.$milestoneId
            ]
        );

        return $qb->getQuery()->getResult();
    }

    /**
     * @param int $paymentId
     * @return Notification[]
     */
    public function getNotificationsPaymentPrevLate(int $paymentId): array
    {
        $qb = $this->createQueryBuilder("n")
            ->where("n.context = :context")
            ->orderBy('n.dateEffective', 'ASC');

        $qb->setParameters(
            [
                'context' => 'payment:'.$paymentId
            ]
        );

        return $qb->getQuery()->getResult();
    }

    public function removeNotificationsActivity(int $activityId)
    {
        foreach ($this->getNotificationsActivity($activityId) as $notification) {
Loading