mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 22:04:23 +00:00
Merge branch '111_exports_suite' into testing
This commit is contained in:
commit
71db287ded
@ -14,9 +14,10 @@ namespace Chill\MainBundle\Repository;
|
|||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Doctrine\Persistence\ObjectRepository;
|
use Doctrine\Persistence\ObjectRepository;
|
||||||
|
|
||||||
final class ScopeRepository implements ObjectRepository
|
final class ScopeRepository implements ScopeRepositoryInterface
|
||||||
{
|
{
|
||||||
private EntityRepository $repository;
|
private EntityRepository $repository;
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ final class ScopeRepository implements ObjectRepository
|
|||||||
$this->repository = $entityManager->getRepository(Scope::class);
|
$this->repository = $entityManager->getRepository(Scope::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createQueryBuilder($alias, $indexBy = null)
|
public function createQueryBuilder($alias, $indexBy = null): QueryBuilder
|
||||||
{
|
{
|
||||||
return $this->repository->createQueryBuilder($alias, $indexBy);
|
return $this->repository->createQueryBuilder($alias, $indexBy);
|
||||||
}
|
}
|
||||||
@ -59,7 +60,7 @@ final class ScopeRepository implements ObjectRepository
|
|||||||
return $this->repository->findOneBy($criteria, $orderBy);
|
return $this->repository->findOneBy($criteria, $orderBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getClassName()
|
public function getClassName(): string
|
||||||
{
|
{
|
||||||
return Scope::class;
|
return Scope::class;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\MainBundle\Repository;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\Scope;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Doctrine\Persistence\ObjectRepository;
|
||||||
|
|
||||||
|
interface ScopeRepositoryInterface extends ObjectRepository
|
||||||
|
{
|
||||||
|
public function createQueryBuilder($alias, $indexBy = null): QueryBuilder;
|
||||||
|
|
||||||
|
public function find($id, $lockMode = null, $lockVersion = null): ?Scope;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Scope[]
|
||||||
|
*/
|
||||||
|
public function findAll(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Scope[]
|
||||||
|
*/
|
||||||
|
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array;
|
||||||
|
|
||||||
|
public function findOneBy(array $criteria, ?array $orderBy = null): ?Scope;
|
||||||
|
|
||||||
|
public function getClassName(): string;
|
||||||
|
}
|
@ -0,0 +1,133 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
|
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||||
|
use Chill\MainBundle\Repository\ScopeRepository;
|
||||||
|
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||||
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
class ReferrerScopeAggregator implements AggregatorInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
private const SCOPE_KEY = 'acp_agg_refscope_user_history_ref_scope_name';
|
||||||
|
|
||||||
|
private TranslatableStringHelperInterface $translatableStringHelper;
|
||||||
|
|
||||||
|
private ScopeRepositoryInterface $scopeRepository;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
ScopeRepositoryInterface $scopeRepository,
|
||||||
|
TranslatableStringHelperInterface $translatableStringHelper
|
||||||
|
) {
|
||||||
|
$this->scopeRepository = $scopeRepository;
|
||||||
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getLabels($key, array $values, $data)
|
||||||
|
{
|
||||||
|
return function ($value) {
|
||||||
|
if ('_header' === $value) {
|
||||||
|
return 'export.aggregator.course.by_user_scope.Referrer\'s scope';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === $value) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope = $this->scopeRepository->find($value);
|
||||||
|
|
||||||
|
if (null === $scope) {
|
||||||
|
throw new \LogicException('no scope found with this id: ' . $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->translatableStringHelper->localize($scope->getName());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getQueryKeys($data)
|
||||||
|
{
|
||||||
|
return [self::SCOPE_KEY];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('date_calc', ChillDateType::class, [
|
||||||
|
'input' => 'datetime_immutable',
|
||||||
|
'data' => new \DateTimeImmutable('now'),
|
||||||
|
'label' => 'export.aggregator.course.by_user_scope.Computation date for referrer',
|
||||||
|
'required' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getTitle()
|
||||||
|
{
|
||||||
|
return 'export.aggregator.course.by_user_scope.Group course by referrer\'s scope';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function addRole(): ?string
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$userHistory = 'acp_agg_refscope_user_history';
|
||||||
|
$ref = 'acp_agg_refscope_user_history_ref';
|
||||||
|
$scopeName = self::SCOPE_KEY;
|
||||||
|
$dateCalc = 'acp_agg_refscope_user_history_date_calc';
|
||||||
|
|
||||||
|
$qb
|
||||||
|
->leftJoin('acp.userHistories', $userHistory)
|
||||||
|
->leftJoin($userHistory.'.user', $ref)
|
||||||
|
->andWhere(
|
||||||
|
$qb->expr()->orX(
|
||||||
|
$qb->expr()->isNull($userHistory),
|
||||||
|
$qb->expr()->andX(
|
||||||
|
$qb->expr()->lte($userHistory.'.startDate', ':'.$dateCalc),
|
||||||
|
$qb->expr()->orX(
|
||||||
|
$qb->expr()->isNull($userHistory.'.endDate'),
|
||||||
|
$qb->expr()->lt($userHistory.'.endDate', ':'.$dateCalc)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
->setParameter($dateCalc, $data['date_calc']);
|
||||||
|
|
||||||
|
// add groups
|
||||||
|
$qb
|
||||||
|
->addSelect('IDENTITY('.$ref.'.mainScope) AS '.$scopeName)
|
||||||
|
->addGroupBy($scopeName)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function applyOn()
|
||||||
|
{
|
||||||
|
return Declarations::ACP_TYPE;
|
||||||
|
}
|
||||||
|
}
|
@ -83,6 +83,6 @@ final class ScopeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function getTitle(): string
|
public function getTitle(): string
|
||||||
{
|
{
|
||||||
return 'Group by user scope';
|
return 'Group course by scope';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Export\Aggregator\AccompanyingCourseAggregators;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\Scope;
|
||||||
|
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ReferrerScopeAggregator;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Prophecy\Argument;
|
||||||
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
|
|
||||||
|
class ReferrerScopeAggregatorTest extends AbstractAggregatorTest
|
||||||
|
{
|
||||||
|
use ProphecyTrait;
|
||||||
|
|
||||||
|
public function getAggregator()
|
||||||
|
{
|
||||||
|
$translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class);
|
||||||
|
$translatableStringHelper->localize(Argument::type('array'))->willReturn('localized');
|
||||||
|
|
||||||
|
$scopeRepository = $this->prophesize(ScopeRepositoryInterface::class);
|
||||||
|
$scopeRepository->find(Argument::type('int'))->willReturn(
|
||||||
|
(new Scope())->setName(['fr' => 'scope'])
|
||||||
|
);
|
||||||
|
|
||||||
|
return new ReferrerScopeAggregator(
|
||||||
|
$scopeRepository->reveal(),
|
||||||
|
$translatableStringHelper->reveal()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'date_calc' => new \DateTimeImmutable('now')
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders()
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('count(acp.id)')
|
||||||
|
->from(AccompanyingPeriod::class, 'acp')
|
||||||
|
->join('acp.scopes', 'acpscope')
|
||||||
|
,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -148,7 +148,7 @@ services:
|
|||||||
autowire: true
|
autowire: true
|
||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: accompanyingcourse_referrer_scope_aggregator }
|
- { name: chill.export_aggregator, alias: accompanyingcourse_scope_aggregator }
|
||||||
|
|
||||||
chill.person.export.aggregator_referrer_job:
|
chill.person.export.aggregator_referrer_job:
|
||||||
class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\JobAggregator
|
class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\JobAggregator
|
||||||
@ -255,3 +255,10 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: accompanyingcourse_duration_aggregator }
|
- { name: chill.export_aggregator, alias: accompanyingcourse_duration_aggregator }
|
||||||
|
|
||||||
|
Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\REferrerScopeAggregator:
|
||||||
|
autoconfigure: true
|
||||||
|
autowire: true
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_aggregator, alias: accompanyingcourse_ref_scope_aggregator }
|
||||||
|
|
||||||
|
|
||||||
|
@ -437,7 +437,8 @@ Filtered by person having an activity between %date_from% and %date_to% with rea
|
|||||||
## accompanying course filters/aggr
|
## accompanying course filters/aggr
|
||||||
Filter by user scope: Filtrer les parcours par service du référent
|
Filter by user scope: Filtrer les parcours par service du référent
|
||||||
"Filtered by user main scope: only %scope%": "Filtré par service du référent: uniquement %scope%"
|
"Filtered by user main scope: only %scope%": "Filtré par service du référent: uniquement %scope%"
|
||||||
Group by user scope: Grouper les parcours par service du référent
|
|
||||||
|
Group course by scope: Grouper les parcours par service
|
||||||
|
|
||||||
Filter by user job: Filtrer les parcours par métier du référent
|
Filter by user job: Filtrer les parcours par métier du référent
|
||||||
"Filtered by user job: only %job%": "Filtré par métier du référent: uniquement %job%"
|
"Filtered by user job: only %job%": "Filtré par métier du référent: uniquement %job%"
|
||||||
@ -940,3 +941,11 @@ reassign:
|
|||||||
notification:
|
notification:
|
||||||
Notify referrer: Notifier le référent
|
Notify referrer: Notifier le référent
|
||||||
Notify any: Notifier d'autres utilisateurs
|
Notify any: Notifier d'autres utilisateurs
|
||||||
|
|
||||||
|
export:
|
||||||
|
aggregator:
|
||||||
|
course:
|
||||||
|
by_user_scope:
|
||||||
|
Group course by referrer's scope: Grouper les parcours par service du référent
|
||||||
|
Computation date for referrer: Date à laquelle le référent était actif
|
||||||
|
Referrer's scope: Service du référent de parcours
|
||||||
|
Loading…
x
Reference in New Issue
Block a user