mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 05:44:24 +00:00
Merge branch '111_exports_suite' into testing
This commit is contained in:
commit
743e0b9403
@ -39,7 +39,7 @@ Household::class,,,household
|
||||
,HouseholdComposition::class,household.compositions,composition
|
||||
Activity::class,,,activity
|
||||
,Person::class,activity.person,actperson
|
||||
,AccompanyingPeriod::class,activity.accompanyingPeriod,actacp
|
||||
,AccompanyingPeriod::class,activity.accompanyingPeriod,acp
|
||||
,Person::class,activity_person_having_activity.person,person_person_having_activity
|
||||
,ActivityReason::class,activity_person_having_activity.reasons,reasons_person_having_activity
|
||||
,ActivityType::class,activity.activityType,acttype
|
||||
|
|
@ -47,7 +47,7 @@ These are alias conventions :
|
||||
| | HouseholdComposition::class | household.compositions | composition |
|
||||
| Activity::class | | | activity |
|
||||
| | Person::class | activity.person | actperson |
|
||||
| | AccompanyingPeriod::class | activity.accompanyingPeriod | actacp |
|
||||
| | AccompanyingPeriod::class | activity.accompanyingPeriod | acp |
|
||||
| | Person::class | activity\_person\_having\_activity.person | person\_person\_having\_activity |
|
||||
| | ActivityReason::class | activity\_person\_having\_activity.reasons | reasons\_person\_having\_activity |
|
||||
| | ActivityType::class | activity.activityType | acttype |
|
||||
|
@ -41,18 +41,11 @@ class BySocialActionAggregator implements AggregatorInterface
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('actsocialaction', $qb->getAllAliases(), true)) {
|
||||
$qb->join('activity.socialActions', 'actsocialaction');
|
||||
$qb->leftJoin('activity.socialActions', 'actsocialaction');
|
||||
}
|
||||
|
||||
$qb->addSelect('actsocialaction.id AS socialaction_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
if (!empty($groupBy)) {
|
||||
$qb->addGroupBy('socialaction_aggregator');
|
||||
} else {
|
||||
$qb->groupBy('socialaction_aggregator');
|
||||
}
|
||||
$qb->addGroupBy('socialaction_aggregator');
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@ -72,6 +65,10 @@ class BySocialActionAggregator implements AggregatorInterface
|
||||
return 'Social action';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$sa = $this->actionRepository->find($value);
|
||||
|
||||
return $this->actionRender->renderString($sa, []);
|
||||
|
@ -41,18 +41,11 @@ class BySocialIssueAggregator implements AggregatorInterface
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('actsocialissue', $qb->getAllAliases(), true)) {
|
||||
$qb->join('activity.socialIssues', 'actsocialissue');
|
||||
$qb->leftJoin('activity.socialIssues', 'actsocialissue');
|
||||
}
|
||||
|
||||
$qb->addSelect('actsocialissue.id AS socialissue_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
if (!empty($groupBy)) {
|
||||
$qb->addGroupBy('socialissue_aggregator');
|
||||
} else {
|
||||
$qb->groupBy('socialissue_aggregator');
|
||||
}
|
||||
$qb->addGroupBy('socialissue_aggregator');
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@ -72,6 +65,10 @@ class BySocialIssueAggregator implements AggregatorInterface
|
||||
return 'Social issues';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$i = $this->issueRepository->find($value);
|
||||
|
||||
return $this->issueRender->renderString($i, []);
|
||||
|
@ -41,18 +41,11 @@ class ByThirdpartyAggregator implements AggregatorInterface
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('acttparty', $qb->getAllAliases(), true)) {
|
||||
$qb->join('activity.thirdParties', 'acttparty');
|
||||
$qb->leftJoin('activity.thirdParties', 'acttparty');
|
||||
}
|
||||
|
||||
$qb->addSelect('acttparty.id AS thirdparty_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
if (!empty($groupBy)) {
|
||||
$qb->addGroupBy('thirdparty_aggregator');
|
||||
} else {
|
||||
$qb->groupBy('thirdparty_aggregator');
|
||||
}
|
||||
$qb->addGroupBy('thirdparty_aggregator');
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@ -72,6 +65,10 @@ class ByThirdpartyAggregator implements AggregatorInterface
|
||||
return 'Accepted thirdparty';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$tp = $this->thirdPartyRepository->find($value);
|
||||
|
||||
return $this->thirdPartyRender->renderString($tp, []);
|
||||
|
@ -41,18 +41,11 @@ class ByUserAggregator implements AggregatorInterface
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('actusers', $qb->getAllAliases(), true)) {
|
||||
$qb->join('activity.users', 'actusers');
|
||||
$qb->leftJoin('activity.users', 'actusers');
|
||||
}
|
||||
|
||||
$qb->addSelect('actusers.id AS users_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
if (!empty($groupBy)) {
|
||||
$qb->addGroupBy('users_aggregator');
|
||||
} else {
|
||||
$qb->groupBy('users_aggregator');
|
||||
}
|
||||
$qb->addGroupBy('users_aggregator');
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@ -72,6 +65,10 @@ class ByUserAggregator implements AggregatorInterface
|
||||
return 'Accepted users';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$u = $this->userRepository->find($value);
|
||||
|
||||
return $this->userRender->renderString($u, []);
|
||||
|
@ -49,11 +49,11 @@ class DateAggregator implements AggregatorInterface
|
||||
|
||||
switch ($data['frequency']) {
|
||||
case 'month':
|
||||
$fmt = 'MM';
|
||||
$fmt = 'YYYY-MM';
|
||||
break;
|
||||
|
||||
case 'week':
|
||||
$fmt = 'IW';
|
||||
$fmt = 'YYYY-IW';
|
||||
break;
|
||||
|
||||
case 'year':
|
||||
@ -65,22 +65,8 @@ class DateAggregator implements AggregatorInterface
|
||||
}
|
||||
|
||||
$qb->addSelect(sprintf("TO_CHAR(activity.date, '%s') AS date_aggregator", $fmt));
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
if (!empty($groupBy)) {
|
||||
$qb->addGroupBy('date_aggregator');
|
||||
} else {
|
||||
$qb->groupBy('date_aggregator');
|
||||
}
|
||||
|
||||
$orderBy = $qb->getDQLPart('orderBy');
|
||||
|
||||
if (!empty($orderBy)) {
|
||||
$qb->addOrderBy('date_aggregator', $order);
|
||||
} else {
|
||||
$qb->orderBy('date_aggregator', $order);
|
||||
}
|
||||
$qb->addGroupBy('date_aggregator');
|
||||
$qb->addOrderBy('date_aggregator', $order);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@ -106,15 +92,12 @@ class DateAggregator implements AggregatorInterface
|
||||
return 'by ' . $data['frequency'];
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
switch ($data['frequency']) {
|
||||
case 'month':
|
||||
$month = DateTime::createFromFormat('!m', $value);
|
||||
|
||||
return sprintf(
|
||||
'%02d (%s)',
|
||||
$value,
|
||||
$month->format('M')
|
||||
);
|
||||
|
||||
case 'week':
|
||||
//return $this->translator->trans('for week') .' '. $value ;
|
||||
|
@ -41,18 +41,11 @@ class LocationTypeAggregator implements AggregatorInterface
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('actloc', $qb->getAllAliases(), true)) {
|
||||
$qb->join('activity.location', 'actloc');
|
||||
$qb->leftJoin('activity.location', 'actloc');
|
||||
}
|
||||
|
||||
$qb->addSelect('IDENTITY(actloc.locationType) AS locationtype_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
if (!empty($groupBy)) {
|
||||
$qb->addGroupBy('locationtype_aggregator');
|
||||
} else {
|
||||
$qb->groupBy('locationtype_aggregator');
|
||||
}
|
||||
$qb->addGroupBy('locationtype_aggregator');
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@ -72,6 +65,10 @@ class LocationTypeAggregator implements AggregatorInterface
|
||||
return 'Accepted locationtype';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$lt = $this->locationTypeRepository->find($value);
|
||||
|
||||
return $this->translatableStringHelper->localize(
|
||||
|
@ -41,18 +41,11 @@ class UserScopeAggregator implements AggregatorInterface
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('actuser', $qb->getAllAliases(), true)) {
|
||||
$qb->join('activity.user', 'actuser');
|
||||
$qb->leftJoin('activity.user', 'actuser');
|
||||
}
|
||||
|
||||
$qb->addSelect('IDENTITY(actuser.mainScope) AS userscope_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
if (!empty($groupBy)) {
|
||||
$qb->addGroupBy('userscope_aggregator');
|
||||
} else {
|
||||
$qb->groupBy('userscope_aggregator');
|
||||
}
|
||||
$qb->addGroupBy('userscope_aggregator');
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@ -72,6 +65,10 @@ class UserScopeAggregator implements AggregatorInterface
|
||||
return 'Scope';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$s = $this->scopeRepository->find($value);
|
||||
|
||||
return $this->translatableStringHelper->localize(
|
||||
|
@ -49,14 +49,7 @@ class ActivityTypeAggregator implements AggregatorInterface
|
||||
}
|
||||
|
||||
$qb->addSelect(sprintf('IDENTITY(activity.activityType) AS %s', self::KEY));
|
||||
|
||||
$groupby = $qb->getDQLPart('groupBy');
|
||||
|
||||
if (!empty($groupBy)) {
|
||||
$qb->addGroupBy(self::KEY);
|
||||
} else {
|
||||
$qb->groupBy(self::KEY);
|
||||
}
|
||||
$qb->addGroupBy(self::KEY);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@ -79,6 +72,10 @@ class ActivityTypeAggregator implements AggregatorInterface
|
||||
return 'Activity type';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$t = $this->activityTypeRepository->find($value);
|
||||
|
||||
return $this->translatableStringHelper->localize($t->getName());
|
||||
|
@ -61,14 +61,15 @@ class ActivityUserAggregator implements AggregatorInterface
|
||||
|
||||
public function getLabels($key, $values, $data): Closure
|
||||
{
|
||||
// preload users at once
|
||||
$this->userRepository->findBy(['id' => $values]);
|
||||
|
||||
return function ($value) {
|
||||
return function ($value) {
|
||||
if ('_header' === $value) {
|
||||
return 'Activity user';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$u = $this->userRepository->find($value);
|
||||
|
||||
return $this->userRender->renderString($u, []);
|
||||
|
@ -86,7 +86,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('activity');
|
||||
|
||||
if (!in_array('actacp', $qb->getAllAliases(), true)) {
|
||||
if (!in_array('acp', $qb->getAllAliases(), true)) {
|
||||
$qb->join('activity.accompanyingPeriod', 'acp');
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('activity');
|
||||
|
||||
if (!in_array('actacp', $qb->getAllAliases(), true)) {
|
||||
if (!in_array('acp', $qb->getAllAliases(), true)) {
|
||||
$qb->join('activity.accompanyingPeriod', 'acp');
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('activity');
|
||||
|
||||
if (!in_array('actacp', $qb->getAllAliases(), true)) {
|
||||
if (!in_array('acp', $qb->getAllAliases(), true)) {
|
||||
$qb->join('activity.accompanyingPeriod', 'acp');
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ final class BySocialActionAggregatorTest extends AbstractAggregatorTest
|
||||
$em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from(Activity::class, 'activity')
|
||||
->join('activity.accompanyingPeriod', 'actacp')
|
||||
->join('activity.accompanyingPeriod', 'acp')
|
||||
->join('activity.socialActions', 'actsocialaction')
|
||||
,
|
||||
];
|
||||
|
@ -51,7 +51,7 @@ final class BySocialIssueAggregatorTest extends AbstractAggregatorTest
|
||||
$em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from(Activity::class, 'activity')
|
||||
->join('activity.accompanyingPeriod', 'actacp')
|
||||
->join('activity.accompanyingPeriod', 'acp')
|
||||
->join('activity.socialIssues', 'actsocialissue')
|
||||
,
|
||||
];
|
||||
|
@ -51,7 +51,7 @@ final class ByThirdpartyAggregatorTest extends AbstractAggregatorTest
|
||||
$em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from(Activity::class, 'activity')
|
||||
->join('activity.accompanyingPeriod', 'actacp')
|
||||
->join('activity.accompanyingPeriod', 'acp')
|
||||
->join('activity.thirdParties', 'acttparty')
|
||||
,
|
||||
];
|
||||
|
@ -51,7 +51,7 @@ final class ByUserAggregatorTest extends AbstractAggregatorTest
|
||||
$em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from(Activity::class, 'activity')
|
||||
->join('activity.accompanyingPeriod', 'actacp')
|
||||
->join('activity.accompanyingPeriod', 'acp')
|
||||
->join('activity.users', 'actusers')
|
||||
,
|
||||
];
|
||||
|
@ -59,7 +59,7 @@ final class DateAggregatorTest extends AbstractAggregatorTest
|
||||
$em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from(Activity::class, 'activity')
|
||||
->join('activity.accompanyingPeriod', 'actacp')
|
||||
->join('activity.accompanyingPeriod', 'acp')
|
||||
,
|
||||
];
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ final class LocationTypeAggregatorTest extends AbstractAggregatorTest
|
||||
$em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from(Activity::class, 'activity')
|
||||
->join('activity.accompanyingPeriod', 'actacp')
|
||||
->join('activity.accompanyingPeriod', 'acp')
|
||||
->join('activity.location', 'actloc')
|
||||
,
|
||||
];
|
||||
|
@ -51,7 +51,7 @@ final class UserScopeAggregatorTest extends AbstractAggregatorTest
|
||||
$em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from(Activity::class, 'activity')
|
||||
->join('activity.accompanyingPeriod', 'actacp')
|
||||
->join('activity.accompanyingPeriod', 'acp')
|
||||
->join('activity.user', 'actuser')
|
||||
,
|
||||
];
|
||||
|
@ -496,8 +496,13 @@ class SpreadSheetFormatter implements FormatterInterface
|
||||
// 3. iterate on `keysExportElementAssociation` to store the callable
|
||||
// in cache
|
||||
foreach ($keysExportElementAssociation as $key => [$element, $data]) {
|
||||
$this->cacheDisplayableResult[$key] =
|
||||
$element->getLabels($key, array_unique($allValues[$key]), $data);
|
||||
// handle the case when there is not results lines (query is empty)
|
||||
if ([] === $allValues) {
|
||||
$this->cacheDisplayableResult[$key] = $element->getLabels($key, ['_header'], $data);
|
||||
} else {
|
||||
$this->cacheDisplayableResult[$key] =
|
||||
$element->getLabels($key, array_unique($allValues[$key]), $data);
|
||||
}
|
||||
}
|
||||
|
||||
// the cache is initialized !
|
||||
|
@ -16,18 +16,19 @@ use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepository;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepositoryInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class ClosingMotiveAggregator implements AggregatorInterface
|
||||
{
|
||||
private EntityManagerInterface $em;
|
||||
private ClosingMotiveRepositoryInterface $motiveRepository;
|
||||
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
public function __construct(
|
||||
ClosingMotiveRepository $motiveRepository,
|
||||
ClosingMotiveRepositoryInterface $motiveRepository,
|
||||
TranslatableStringHelper $translatableStringHelper
|
||||
) {
|
||||
$this->motiveRepository = $motiveRepository;
|
||||
|
@ -15,8 +15,9 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
||||
use UnexpectedValueException;
|
||||
|
||||
final class ClosingMotiveRepository
|
||||
final class ClosingMotiveRepository implements ClosingMotiveRepositoryInterface
|
||||
{
|
||||
private EntityManagerInterface $entityManager;
|
||||
|
||||
@ -54,4 +55,35 @@ final class ClosingMotiveRepository
|
||||
->createNativeQuery($sql, $rsm)
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function find($id): ?ClosingMotive
|
||||
{
|
||||
return $this->repository->find($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|ClosingMotive[]
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|ClosingMotive[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria): ?ClosingMotive
|
||||
{
|
||||
return $this->findOneBy($criteria);
|
||||
}
|
||||
|
||||
public function getClassName(): string
|
||||
{
|
||||
return ClosingMotive::class;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
|
||||
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
interface ClosingMotiveRepositoryInterface extends ObjectRepository
|
||||
{
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getActiveClosingMotive(bool $onlyLeaf = true);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user