Loading module/Oscar/src/Oscar/Entity/PersonRepository.php +112 −0 Original line number Diff line number Diff line Loading @@ -733,6 +733,118 @@ WHERE WHERE a.id IN(select id from activity_ids) and po.roleobj_id IN(select id from role_payment) ) ; SQL; return $this->getEntityManager() ->getConnection() ->executeQuery($sql) ->fetchAllAssociative(); } public function getPersonsWithMilestoneTodo():array { $sql = <<<SQL WITH -- Liste des jalons à faire jalons_non_faits AS ( SELECT ad.id AS activitydate_id, ad.activity_id, ad.type_id, d.label FROM activitydate ad join datetype d on d.id = ad.type_id WHERE d.finishable = true and (ad.finished IS NULL OR ad.finished = 0) and ad.datestart < now() ), -- Rôles selon les types de jalons roles_needed AS ( SELECT datetype_id, role_id FROM role_datetype ), -- Filtre des personnes actives active_persons AS ( SELECT p.id, p.firstname, p.lastname FROM person p WHERE p.ldapfininscription IS NULL OR p.ldapfininscription::date >= CURRENT_DATE ) -- 1️⃣ Personnes liées directement à l'activité SELECT DISTINCT aperson.id AS id, aperson.firstname, aperson.lastname FROM jalons_non_faits ud JOIN datetype dt ON dt.id = ud.type_id JOIN roles_needed rn ON rn.datetype_id = dt.id JOIN activityperson ap ON ap.activity_id = ud.activity_id AND ap.roleobj_id = rn.role_id AND ap.datedeleted IS NULL JOIN active_persons aperson ON aperson.id = ap.person_id UNION -- 2️⃣ Personnes liées au projet de l'activité SELECT DISTINCT aperson.id AS person_id, aperson.firstname, aperson.lastname FROM jalons_non_faits ud JOIN activity a ON a.id = ud.activity_id JOIN datetype dt ON dt.id = ud.type_id JOIN roles_needed rn ON rn.datetype_id = dt.id JOIN projectmember pm ON pm.project_id = a.project_id AND pm.roleobj_id = rn.role_id AND pm.datedeleted IS NULL JOIN active_persons aperson ON aperson.id = pm.person_id UNION -- 3️⃣ Personnes liées aux organizations de l'activité SELECT DISTINCT aperson.id AS person_id, aperson.firstname, aperson.lastname FROM jalons_non_faits ud JOIN datetype dt ON dt.id = ud.type_id JOIN roles_needed rn ON rn.datetype_id = dt.id JOIN activityorganization ao ON ao.activity_id = ud.activity_id AND ao.datedeleted IS NULL JOIN organizationperson op ON op.organization_id = ao.organization_id AND op.roleobj_id = rn.role_id AND op.datedeleted IS NULL JOIN active_persons aperson ON aperson.id = op.person_id UNION -- 4️⃣ Personnes liées aux organizations du projet SELECT DISTINCT aperson.id AS person_id, aperson.firstname, aperson.lastname FROM jalons_non_faits ud JOIN activity a ON a.id = ud.activity_id JOIN datetype dt ON dt.id = ud.type_id JOIN roles_needed rn ON rn.datetype_id = dt.id JOIN projectpartner pp ON pp.project_id = a.project_id AND pp.datedeleted IS NULL JOIN organizationperson op ON op.organization_id = pp.organization_id AND op.roleobj_id = rn.role_id AND op.datedeleted IS NULL JOIN active_persons aperson ON aperson.id = op.person_id; SQL; return $this->getEntityManager() ->getConnection() Loading module/Oscar/src/Oscar/Service/PersonService.php +54 −119 Original line number Diff line number Diff line Loading @@ -2952,104 +2952,23 @@ class PersonService implements UseOscarConfigurationService, UseEntityManager, U { $personsPayments = $this->getPersonRepository()->getPersonsWithPaymentsLate(); $this->getLoggerService()->info(sprintf("Personnes concernées par un versement prévisionnel en retard : %s", count($personsPayments))); $personIds = []; foreach ($personsPayments as $person) { echo $person['lastname']." ".$person['firstname']."\n"; if( !in_array($person['id'], $personIds) ) { $personIds[] = $person['id']; } die("TODO NEXT"); $personsWithDoingStuff = []; // ------------------------------------- Personnes devant traiter des payments en retard $privilege = Privileges::ACTIVITY_PAYMENT_MANAGE; $ignored_status = Activity::getStatusInactive(); // Rôles ayant la gestion $rolesPaymentsIds = []; /** @var Role[] $rolesPayments */ $rolesPayments = $this->getOscarUserContext()->getRolesWithPrivileges($privilege); foreach ($rolesPayments as $role) { $rolesPaymentsIds[] = $role->getRoleId(); } ////////////////////////////////////////////////////////////////////////////////////////// // Obtention des payments en retard /** @var ActivityPaymentRepository $paymentRepository */ $paymentRepository = $this->getEntityManager()->getRepository(ActivityPayment::class); $payementsLate = $paymentRepository->getPaymentsLate($dateRef); // Récupération des personnes $personsIds = []; $this->getLoggerService()->info(sprintf("Versements prévisionnels en retard : %s", count($payementsLate))); $countPayment = 0; $personsPaymentsTodo = $this->getPersonRepository()->getPersonsWithPaymentsLate(); /** @var ActivityPayment $payement */ foreach ($payementsLate as $payement) { if (in_array($payement->getActivity()->getStatus(), $ignored_status)) { continue; } $countPayment++; foreach ($payement->getActivity()->getPersonsDeeper() as $activityPerson) { if ($activityPerson->getPerson()->isActive()) { if (in_array($activityPerson->getRole(), $rolesPaymentsIds)) { if ($activityPerson->getPerson()->isActive()) { $personId = $activityPerson->getPerson()->getId(); if (!array_key_exists($personId, $personsIds)) { $personsIds[$personId] = [ 'person' => (string)$activityPerson->getPerson(), 'payments' => [], 'milestones' => [], ]; $personsWithDoingStuff[$personId] = $activityPerson->getPerson(); } $personsIds[$personId]['payments'][] = (string)$payement; } $personsMilestonesLate = $this->getPersonRepository()->getPersonsWithMilestoneTodo(); $this->getLoggerService()->info(sprintf("Personnes concernées par un jalons à faire non réalisé : %s", count($personsMilestonesLate))); foreach ($personsMilestonesLate as $person) { if( !in_array($person['id'], $personIds) ) { $personIds[] = $person['id']; } } } } $this->getLoggerService()->info(sprintf("Versements traités : %s", $countPayment)); $this->getLoggerService()->info(sprintf("Personnes impliquées : %s", count(array_keys($personsIds)))); $this->getLoggerService()->info(sprintf("Personnes concernées par un jalons/versements à faire : %s", count($personIds))); ////////////////////////////////////////////////////////////////////////////////////////// /** @var ActivityDateRepository $activityDateRepository */ $privilegeMiletone = Privileges::ACTIVITY_MILESTONE_PROGRESSION; $rolesMilestoneIds = []; foreach ($this->getOscarUserContext()->getRolesWithPrivileges($privilegeMiletone) as $role) { $rolesMilestoneIds[] = $role->getRoleId(); } $activityDateRepository = $this->getEntityManager()->getRepository(ActivityDate::class); $milestonesLate = $activityDateRepository->getMilestonesFinishableUnfinishedAt(new \DateTime($dateRef)); $this->getLoggerService()->info(sprintf("Jalons en retard : %s", count($milestonesLate))); $countMilestones = 0; foreach ($milestonesLate as $milestone) { if( !$milestone->getActivity()->isActive() ) { continue; } $countMilestones++; foreach ($milestone->getActivity()->getPersonsDeep() as $activityPerson) { if ($activityPerson->getPerson()->isActive()) { if (in_array($activityPerson->getRole(), $rolesMilestoneIds)) { $personId = $activityPerson->getPerson()->getId(); if (!array_key_exists($personId, $personsIds)) { $personsIds[$personId] = [ 'person' => (string)$activityPerson->getPerson(), 'payments' => [], 'milestones' => [], ]; $personsWithDoingStuff[$personId] = $activityPerson->getPerson(); } $personsIds[$personId]['milestones'][] = $milestone->getId() . " - " . (string)$milestone; } } } } $this->getLoggerService()->info(sprintf("Jalons traités : %s", $countMilestones)); $logger = $this->getLoggerService(); Loading Loading @@ -3089,24 +3008,42 @@ class PersonService implements UseOscarConfigurationService, UseEntityManager, U ); $this->getLoggerService()->info(sprintf("Personnes avec des notifications non-lues : %s", count($persons))); $personsWithDoingStuff = []; foreach ($persons as $person) { if (!array_key_exists($person->getId(), $personsWithDoingStuff)) { $personsWithDoingStuff[$person->getId()] = $person; } } $personsHaveToDo = $this->getPersonsByIds($personIds); foreach ($personsHaveToDo as $person) { if (!array_key_exists($person->getId(), $personsWithDoingStuff)) { $personsWithDoingStuff[$person->getId()] = $person; } } if (!count($personsWithDoingStuff)) { return; } $this->getLoggerService()->info(sprintf("Personnes impliquées : %s", count($personsWithDoingStuff))); $this->getLoggerService()->info(sprintf("Total des personnes 'notifiable' : %s", count($personsWithDoingStuff))); foreach ($personsWithDoingStuff as $person) { if( !$person->isActive() ) { $this->getLoggerService()->info("$person est inactive, on passe"); continue; } try { $auth = $this->getPersonAuthentification($person); } catch ( NoResultException $e) { $this->getLoggerService()->info("$person ne s'est jamais authentifiée, on passe"); continue; } catch (\Exception $e) { $this->getLoggerService()->error("$person a un soucis d'authentification : " . $e->getMessage()); continue; } $settings = $auth->getSettings(); if (!$settings) { Loading Loading @@ -3134,10 +3071,8 @@ class PersonService implements UseOscarConfigurationService, UseEntityManager, U if (in_array($cron, $settings['frequency'])) { $log(sprintf(" + >>> Envoi de mail pour %s", $text)); $this->mailNotificationsPerson($person, false, $dateRef); } } catch (\Exception $e) { $this->getLoggerService()->error( "Impossible de calculer les notifications pour '$person'" . $e->getMessage()); } else { $this->getLoggerService()->info("$person n'est pas inscrite sur ce créneau, on passe"); } } /********/ Loading module/Oscar/view/oscar/contract-document/list-item.phtml +0 −4 Original line number Diff line number Diff line Loading @@ -26,10 +26,6 @@ $showDelete = isset($showDelete) && $showDelete === true ? true : false; Signature : <strong class="addon"><?php echo $document->getProcess()->getStatusText() ?></strong> </div> <?php endif; ?> <p class="text-highlight" style="display: none"> Fichier <strong><?= $document->getExtension() ?></strong> version <?= $document->getVersion()?>, téléversé le <time><?= $this->moment($document->getDateUpdoad())->full() ?></time> par <?= $this->link()->person($document->getPerson()) ?> </p> <?php if( $document->getGrant() && (isset($showActivity) && $showActivity == true) ): ?> <p class="text-highlight"> Pour l'activité <?= $this->link()->activity($document->getGrant()) ?> Loading Loading
module/Oscar/src/Oscar/Entity/PersonRepository.php +112 −0 Original line number Diff line number Diff line Loading @@ -733,6 +733,118 @@ WHERE WHERE a.id IN(select id from activity_ids) and po.roleobj_id IN(select id from role_payment) ) ; SQL; return $this->getEntityManager() ->getConnection() ->executeQuery($sql) ->fetchAllAssociative(); } public function getPersonsWithMilestoneTodo():array { $sql = <<<SQL WITH -- Liste des jalons à faire jalons_non_faits AS ( SELECT ad.id AS activitydate_id, ad.activity_id, ad.type_id, d.label FROM activitydate ad join datetype d on d.id = ad.type_id WHERE d.finishable = true and (ad.finished IS NULL OR ad.finished = 0) and ad.datestart < now() ), -- Rôles selon les types de jalons roles_needed AS ( SELECT datetype_id, role_id FROM role_datetype ), -- Filtre des personnes actives active_persons AS ( SELECT p.id, p.firstname, p.lastname FROM person p WHERE p.ldapfininscription IS NULL OR p.ldapfininscription::date >= CURRENT_DATE ) -- 1️⃣ Personnes liées directement à l'activité SELECT DISTINCT aperson.id AS id, aperson.firstname, aperson.lastname FROM jalons_non_faits ud JOIN datetype dt ON dt.id = ud.type_id JOIN roles_needed rn ON rn.datetype_id = dt.id JOIN activityperson ap ON ap.activity_id = ud.activity_id AND ap.roleobj_id = rn.role_id AND ap.datedeleted IS NULL JOIN active_persons aperson ON aperson.id = ap.person_id UNION -- 2️⃣ Personnes liées au projet de l'activité SELECT DISTINCT aperson.id AS person_id, aperson.firstname, aperson.lastname FROM jalons_non_faits ud JOIN activity a ON a.id = ud.activity_id JOIN datetype dt ON dt.id = ud.type_id JOIN roles_needed rn ON rn.datetype_id = dt.id JOIN projectmember pm ON pm.project_id = a.project_id AND pm.roleobj_id = rn.role_id AND pm.datedeleted IS NULL JOIN active_persons aperson ON aperson.id = pm.person_id UNION -- 3️⃣ Personnes liées aux organizations de l'activité SELECT DISTINCT aperson.id AS person_id, aperson.firstname, aperson.lastname FROM jalons_non_faits ud JOIN datetype dt ON dt.id = ud.type_id JOIN roles_needed rn ON rn.datetype_id = dt.id JOIN activityorganization ao ON ao.activity_id = ud.activity_id AND ao.datedeleted IS NULL JOIN organizationperson op ON op.organization_id = ao.organization_id AND op.roleobj_id = rn.role_id AND op.datedeleted IS NULL JOIN active_persons aperson ON aperson.id = op.person_id UNION -- 4️⃣ Personnes liées aux organizations du projet SELECT DISTINCT aperson.id AS person_id, aperson.firstname, aperson.lastname FROM jalons_non_faits ud JOIN activity a ON a.id = ud.activity_id JOIN datetype dt ON dt.id = ud.type_id JOIN roles_needed rn ON rn.datetype_id = dt.id JOIN projectpartner pp ON pp.project_id = a.project_id AND pp.datedeleted IS NULL JOIN organizationperson op ON op.organization_id = pp.organization_id AND op.roleobj_id = rn.role_id AND op.datedeleted IS NULL JOIN active_persons aperson ON aperson.id = op.person_id; SQL; return $this->getEntityManager() ->getConnection() Loading
module/Oscar/src/Oscar/Service/PersonService.php +54 −119 Original line number Diff line number Diff line Loading @@ -2952,104 +2952,23 @@ class PersonService implements UseOscarConfigurationService, UseEntityManager, U { $personsPayments = $this->getPersonRepository()->getPersonsWithPaymentsLate(); $this->getLoggerService()->info(sprintf("Personnes concernées par un versement prévisionnel en retard : %s", count($personsPayments))); $personIds = []; foreach ($personsPayments as $person) { echo $person['lastname']." ".$person['firstname']."\n"; if( !in_array($person['id'], $personIds) ) { $personIds[] = $person['id']; } die("TODO NEXT"); $personsWithDoingStuff = []; // ------------------------------------- Personnes devant traiter des payments en retard $privilege = Privileges::ACTIVITY_PAYMENT_MANAGE; $ignored_status = Activity::getStatusInactive(); // Rôles ayant la gestion $rolesPaymentsIds = []; /** @var Role[] $rolesPayments */ $rolesPayments = $this->getOscarUserContext()->getRolesWithPrivileges($privilege); foreach ($rolesPayments as $role) { $rolesPaymentsIds[] = $role->getRoleId(); } ////////////////////////////////////////////////////////////////////////////////////////// // Obtention des payments en retard /** @var ActivityPaymentRepository $paymentRepository */ $paymentRepository = $this->getEntityManager()->getRepository(ActivityPayment::class); $payementsLate = $paymentRepository->getPaymentsLate($dateRef); // Récupération des personnes $personsIds = []; $this->getLoggerService()->info(sprintf("Versements prévisionnels en retard : %s", count($payementsLate))); $countPayment = 0; $personsPaymentsTodo = $this->getPersonRepository()->getPersonsWithPaymentsLate(); /** @var ActivityPayment $payement */ foreach ($payementsLate as $payement) { if (in_array($payement->getActivity()->getStatus(), $ignored_status)) { continue; } $countPayment++; foreach ($payement->getActivity()->getPersonsDeeper() as $activityPerson) { if ($activityPerson->getPerson()->isActive()) { if (in_array($activityPerson->getRole(), $rolesPaymentsIds)) { if ($activityPerson->getPerson()->isActive()) { $personId = $activityPerson->getPerson()->getId(); if (!array_key_exists($personId, $personsIds)) { $personsIds[$personId] = [ 'person' => (string)$activityPerson->getPerson(), 'payments' => [], 'milestones' => [], ]; $personsWithDoingStuff[$personId] = $activityPerson->getPerson(); } $personsIds[$personId]['payments'][] = (string)$payement; } $personsMilestonesLate = $this->getPersonRepository()->getPersonsWithMilestoneTodo(); $this->getLoggerService()->info(sprintf("Personnes concernées par un jalons à faire non réalisé : %s", count($personsMilestonesLate))); foreach ($personsMilestonesLate as $person) { if( !in_array($person['id'], $personIds) ) { $personIds[] = $person['id']; } } } } $this->getLoggerService()->info(sprintf("Versements traités : %s", $countPayment)); $this->getLoggerService()->info(sprintf("Personnes impliquées : %s", count(array_keys($personsIds)))); $this->getLoggerService()->info(sprintf("Personnes concernées par un jalons/versements à faire : %s", count($personIds))); ////////////////////////////////////////////////////////////////////////////////////////// /** @var ActivityDateRepository $activityDateRepository */ $privilegeMiletone = Privileges::ACTIVITY_MILESTONE_PROGRESSION; $rolesMilestoneIds = []; foreach ($this->getOscarUserContext()->getRolesWithPrivileges($privilegeMiletone) as $role) { $rolesMilestoneIds[] = $role->getRoleId(); } $activityDateRepository = $this->getEntityManager()->getRepository(ActivityDate::class); $milestonesLate = $activityDateRepository->getMilestonesFinishableUnfinishedAt(new \DateTime($dateRef)); $this->getLoggerService()->info(sprintf("Jalons en retard : %s", count($milestonesLate))); $countMilestones = 0; foreach ($milestonesLate as $milestone) { if( !$milestone->getActivity()->isActive() ) { continue; } $countMilestones++; foreach ($milestone->getActivity()->getPersonsDeep() as $activityPerson) { if ($activityPerson->getPerson()->isActive()) { if (in_array($activityPerson->getRole(), $rolesMilestoneIds)) { $personId = $activityPerson->getPerson()->getId(); if (!array_key_exists($personId, $personsIds)) { $personsIds[$personId] = [ 'person' => (string)$activityPerson->getPerson(), 'payments' => [], 'milestones' => [], ]; $personsWithDoingStuff[$personId] = $activityPerson->getPerson(); } $personsIds[$personId]['milestones'][] = $milestone->getId() . " - " . (string)$milestone; } } } } $this->getLoggerService()->info(sprintf("Jalons traités : %s", $countMilestones)); $logger = $this->getLoggerService(); Loading Loading @@ -3089,24 +3008,42 @@ class PersonService implements UseOscarConfigurationService, UseEntityManager, U ); $this->getLoggerService()->info(sprintf("Personnes avec des notifications non-lues : %s", count($persons))); $personsWithDoingStuff = []; foreach ($persons as $person) { if (!array_key_exists($person->getId(), $personsWithDoingStuff)) { $personsWithDoingStuff[$person->getId()] = $person; } } $personsHaveToDo = $this->getPersonsByIds($personIds); foreach ($personsHaveToDo as $person) { if (!array_key_exists($person->getId(), $personsWithDoingStuff)) { $personsWithDoingStuff[$person->getId()] = $person; } } if (!count($personsWithDoingStuff)) { return; } $this->getLoggerService()->info(sprintf("Personnes impliquées : %s", count($personsWithDoingStuff))); $this->getLoggerService()->info(sprintf("Total des personnes 'notifiable' : %s", count($personsWithDoingStuff))); foreach ($personsWithDoingStuff as $person) { if( !$person->isActive() ) { $this->getLoggerService()->info("$person est inactive, on passe"); continue; } try { $auth = $this->getPersonAuthentification($person); } catch ( NoResultException $e) { $this->getLoggerService()->info("$person ne s'est jamais authentifiée, on passe"); continue; } catch (\Exception $e) { $this->getLoggerService()->error("$person a un soucis d'authentification : " . $e->getMessage()); continue; } $settings = $auth->getSettings(); if (!$settings) { Loading Loading @@ -3134,10 +3071,8 @@ class PersonService implements UseOscarConfigurationService, UseEntityManager, U if (in_array($cron, $settings['frequency'])) { $log(sprintf(" + >>> Envoi de mail pour %s", $text)); $this->mailNotificationsPerson($person, false, $dateRef); } } catch (\Exception $e) { $this->getLoggerService()->error( "Impossible de calculer les notifications pour '$person'" . $e->getMessage()); } else { $this->getLoggerService()->info("$person n'est pas inscrite sur ce créneau, on passe"); } } /********/ Loading
module/Oscar/view/oscar/contract-document/list-item.phtml +0 −4 Original line number Diff line number Diff line Loading @@ -26,10 +26,6 @@ $showDelete = isset($showDelete) && $showDelete === true ? true : false; Signature : <strong class="addon"><?php echo $document->getProcess()->getStatusText() ?></strong> </div> <?php endif; ?> <p class="text-highlight" style="display: none"> Fichier <strong><?= $document->getExtension() ?></strong> version <?= $document->getVersion()?>, téléversé le <time><?= $this->moment($document->getDateUpdoad())->full() ?></time> par <?= $this->link()->person($document->getPerson()) ?> </p> <?php if( $document->getGrant() && (isset($showActivity) && $showActivity == true) ): ?> <p class="text-highlight"> Pour l'activité <?= $this->link()->activity($document->getGrant()) ?> Loading