apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -12,29 +12,25 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use function in_array;
class AbstractAccompanyingPeriodExportElement
{
/**
* Add the accompanying period alias to the query.
*
* @throws LogicException if the "person" alias is not present and attaching accompanying period is not possible
* @throws \LogicException if the "person" alias is not present and attaching accompanying period is not possible
*/
protected function addJoinAccompanyingPeriod(QueryBuilder $query): void
{
if (false === in_array('person', $query->getAllAliases(), true)) {
throw new LogicException("the alias 'person' does not exists in "
. 'query builder');
if (false === \in_array('person', $query->getAllAliases(), true)) {
throw new \LogicException("the alias 'person' does not exists in ".'query builder');
}
if (!in_array('acppart', $query->getAllAliases(), true)) {
if (!\in_array('acppart', $query->getAllAliases(), true)) {
$query->join('person.accompanyingPeriodParticipations', 'acppart');
}
if (!in_array('acp', $query->getAllAliases(), true)) {
if (!\in_array('acp', $query->getAllAliases(), true)) {
$query->join('acppart.accompanyingPeriod', 'acp');
}
}

View File

@@ -17,7 +17,6 @@ use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
class AdministrativeLocationAggregator implements AggregatorInterface
{
@@ -30,7 +29,7 @@ class AdministrativeLocationAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acploc', $qb->getAllAliases(), true)) {
if (!\in_array('acploc', $qb->getAllAliases(), true)) {
$qb->leftJoin('acp.administrativeLocation', 'acploc');
}
@@ -47,6 +46,7 @@ class AdministrativeLocationAggregator implements AggregatorInterface
{
// no form
}
public function getFormDefaultData(): array
{
return [];
@@ -65,7 +65,7 @@ class AdministrativeLocationAggregator implements AggregatorInterface
$l = $this->locationRepository->find($value);
return $l->getName() . ' (' . $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ')';
return $l->getName().' ('.$this->translatableStringHelper->localize($l->getLocationType()->getTitle()).')';
};
}

View File

@@ -26,7 +26,7 @@ class ByActionNumberAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data): void
{
$qb->addSelect('(SELECT COUNT(acp_by_action_action.id) FROM ' . AccompanyingPeriodWork::class . ' acp_by_action_action WHERE acp_by_action_action.accompanyingPeriod = acp) AS acp_by_action_number_aggregator')
$qb->addSelect('(SELECT COUNT(acp_by_action_action.id) FROM '.AccompanyingPeriodWork::class.' acp_by_action_action WHERE acp_by_action_action.accompanyingPeriod = acp) AS acp_by_action_number_aggregator')
->addGroupBy('acp_by_action_number_aggregator');
}
@@ -39,6 +39,7 @@ class ByActionNumberAggregator implements AggregatorInterface
{
// No form needed
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -42,6 +42,7 @@ class ClosingMotiveAggregator implements AggregatorInterface
{
// no form
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -14,7 +14,6 @@ namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -42,6 +41,7 @@ class ConfidentialAggregator implements AggregatorInterface
{
// no form
}
public function getFormDefaultData(): array
{
return [];
@@ -57,7 +57,7 @@ class ConfidentialAggregator implements AggregatorInterface
return match ($value) {
true => $this->translator->trans('is confidential'),
false => $this->translator->trans('is not confidential'),
default => throw new LogicException(sprintf('The value %s is not valid', $value)),
default => throw new \LogicException(sprintf('The value %s is not valid', $value)),
};
};
}

View File

@@ -41,16 +41,16 @@ class CreatorJobAggregator implements AggregatorInterface
$qb
->leftJoin(
"acp.userHistories",
'acp.userHistories',
"{$p}_userHistory",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", "acp.id"),
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", 'acp.id'),
$qb->expr()->andX(
$qb->expr()->gte("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.startDate"),
$qb->expr()->gte('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_userHistory.endDate"),
$qb->expr()->lt("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.endDate")
$qb->expr()->lt('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.endDate")
)
)
)
@@ -105,7 +105,7 @@ class CreatorJobAggregator implements AggregatorInterface
public function getQueryKeys($data): array
{
return [self::PREFIX . '_select'];
return [self::PREFIX.'_select'];
}
public function getTitle(): string

View File

@@ -13,9 +13,7 @@ namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Export\Declarations;
use DateTimeImmutable;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -42,11 +40,11 @@ final readonly class DurationAggregator implements AggregatorInterface
'week' => $qb->addSelect('(COALESCE(acp.closingDate, :now) - acp.openingDate) / 7 AS duration_aggregator'),
'month' => $qb->addSelect('(EXTRACT (MONTH FROM AGE(COALESCE(acp.closingDate, :now), acp.openingDate)) * 12 +
EXTRACT (MONTH FROM AGE(COALESCE(acp.closingDate, :now), acp.openingDate))) AS duration_aggregator'),
default => throw new LogicException('precision not supported: ' . $data['precision']),
default => throw new \LogicException('precision not supported: '.$data['precision']),
};
$qb
->setParameter('now', new DateTimeImmutable('now'))
->setParameter('now', new \DateTimeImmutable('now'))
->addGroupBy('duration_aggregator')
->addOrderBy('duration_aggregator');
}
@@ -61,11 +59,12 @@ final readonly class DurationAggregator implements AggregatorInterface
$builder->add('precision', ChoiceType::class, [
'choices' => array_combine(self::CHOICES, self::CHOICES),
'label' => 'export.aggregator.course.duration.Precision',
'choice_label' => static fn (string $c) => 'export.aggregator.course.duration.' . $c,
'choice_label' => static fn (string $c) => 'export.aggregator.course.duration.'.$c,
'multiple' => false,
'expanded' => true,
]);
}
public function getFormDefaultData(): array
{
return [];
@@ -75,7 +74,7 @@ final readonly class DurationAggregator implements AggregatorInterface
{
return static function ($value) use ($data) {
if ('_header' === $value) {
return 'export.aggregator.course.duration.' . $data['precision'];
return 'export.aggregator.course.duration.'.$data['precision'];
}
if (null === $value) {

View File

@@ -14,7 +14,6 @@ namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -42,6 +41,7 @@ class EmergencyAggregator implements AggregatorInterface
{
// no form
}
public function getFormDefaultData(): array
{
return [];
@@ -57,7 +57,7 @@ class EmergencyAggregator implements AggregatorInterface
return match ($value) {
true => $this->translator->trans('is emergency'),
false => $this->translator->trans('is not emergency'),
default => throw new LogicException(sprintf('The value %s is not valid', $value)),
default => throw new \LogicException(sprintf('The value %s is not valid', $value)),
};
};
}

View File

@@ -17,7 +17,6 @@ use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Repository\SocialWork\EvaluationRepository;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
final readonly class EvaluationAggregator implements AggregatorInterface
{
@@ -30,11 +29,11 @@ final readonly class EvaluationAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acpw', $qb->getAllAliases(), true)) {
if (!\in_array('acpw', $qb->getAllAliases(), true)) {
$qb->leftJoin('acp.works', 'acpw');
}
if (!in_array('workeval', $qb->getAllAliases(), true)) {
if (!\in_array('workeval', $qb->getAllAliases(), true)) {
$qb->leftJoin('acpw.accompanyingPeriodWorkEvaluations', 'workeval');
}
@@ -51,6 +50,7 @@ final readonly class EvaluationAggregator implements AggregatorInterface
{
// no form
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -25,7 +25,6 @@ use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
use UnexpectedValueException;
final readonly class GeographicalUnitStatAggregator implements AggregatorInterface
{
@@ -118,6 +117,7 @@ final readonly class GeographicalUnitStatAggregator implements AggregatorInterfa
'expanded' => true,
]);
}
public function getFormDefaultData(): array
{
return ['date_calc' => new RollingDate(RollingDate::T_TODAY)];
@@ -148,7 +148,7 @@ final readonly class GeographicalUnitStatAggregator implements AggregatorInterfa
return $value;
},
default => throw new UnexpectedValueException('this value should not happens'),
default => throw new \UnexpectedValueException('this value should not happens'),
};
}

View File

@@ -14,7 +14,6 @@ namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -42,6 +41,7 @@ class IntensityAggregator implements AggregatorInterface
{
// no form
}
public function getFormDefaultData(): array
{
return [];
@@ -57,7 +57,7 @@ class IntensityAggregator implements AggregatorInterface
return match ($value) {
'occasional' => $this->translator->trans('is occasional'),
'regular' => $this->translator->trans('is regular'),
default => throw new LogicException(sprintf('The value %s is not valid', $value)),
default => throw new \LogicException(sprintf('The value %s is not valid', $value)),
};
};
}

View File

@@ -42,11 +42,11 @@ final readonly class JobWorkingOnCourseAggregator implements AggregatorInterface
$qb
->leftJoin(
AccompanyingPeriodInfo::class,
"acpinfo",
'acpinfo',
Join::WITH,
$qb->expr()->eq("IDENTITY(acpinfo.accompanyingPeriod)", "acp.id")
$qb->expr()->eq('IDENTITY(acpinfo.accompanyingPeriod)', 'acp.id')
)
->leftJoin("acpinfo.user", "{$p}_user")
->leftJoin('acpinfo.user', "{$p}_user")
->leftJoin(
UserJobHistory::class,
"{$p}_history",
@@ -56,10 +56,10 @@ final readonly class JobWorkingOnCourseAggregator implements AggregatorInterface
// job_at based on _info.infoDate
->andWhere(
$qb->expr()->andX(
$qb->expr()->lte("{$p}_history.startDate", "acpinfo.infoDate"),
$qb->expr()->lte("{$p}_history.startDate", 'acpinfo.infoDate'),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_history.endDate"),
$qb->expr()->gt("{$p}_history.endDate", "acpinfo.infoDate")
$qb->expr()->gt("{$p}_history.endDate", 'acpinfo.infoDate')
)
)
)
@@ -100,7 +100,7 @@ final readonly class JobWorkingOnCourseAggregator implements AggregatorInterface
public function getQueryKeys($data): array
{
return [self::PREFIX . '_select'];
return [self::PREFIX.'_select'];
}
public function getTitle(): string

View File

@@ -19,7 +19,6 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
final class OriginAggregator implements AggregatorInterface
{
@@ -39,7 +38,7 @@ final class OriginAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acporigin', $qb->getAllAliases(), true)) {
if (!\in_array('acporigin', $qb->getAllAliases(), true)) {
$qb->leftJoin('acp.origin', 'acporigin');
}
@@ -56,6 +55,7 @@ final class OriginAggregator implements AggregatorInterface
{
// no form
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -37,17 +37,17 @@ final readonly class ReferrerAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$qb
->addSelect('IDENTITY(' . self::A . '.user) AS referrer_aggregator')
->addSelect('IDENTITY('.self::A.'.user) AS referrer_aggregator')
->addGroupBy('referrer_aggregator')
->leftJoin('acp.userHistories', self::A)
->andWhere(
$qb->expr()->orX(
$qb->expr()->isNull(self::A),
$qb->expr()->andX(
$qb->expr()->lte(self::A . '.startDate', ':' . self::P),
$qb->expr()->lte(self::A.'.startDate', ':'.self::P),
$qb->expr()->orX(
$qb->expr()->isNull(self::A . '.endDate'),
$qb->expr()->gt(self::A . '.endDate', ':' . self::P)
$qb->expr()->isNull(self::A.'.endDate'),
$qb->expr()->gt(self::A.'.endDate', ':'.self::P)
)
)
)
@@ -71,6 +71,7 @@ final readonly class ReferrerAggregator implements AggregatorInterface
'required' => true,
]);
}
public function getFormDefaultData(): array
{
return ['date_calc' => new RollingDate(RollingDate::T_TODAY)];

View File

@@ -18,7 +18,6 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
readonly class ReferrerScopeAggregator implements AggregatorInterface
@@ -41,16 +40,16 @@ readonly class ReferrerScopeAggregator implements AggregatorInterface
$qb
->leftJoin(
"acp.userHistories",
'acp.userHistories',
"{$p}_userHistory",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", "acp.id"),
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", 'acp.id'),
$qb->expr()->andX(
$qb->expr()->gte("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.startDate"),
$qb->expr()->gte('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_userHistory.endDate"),
$qb->expr()->lt("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.endDate")
$qb->expr()->lt('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.endDate")
)
)
)
@@ -100,7 +99,7 @@ readonly class ReferrerScopeAggregator implements AggregatorInterface
$scope = $this->scopeRepository->find($value);
if (null === $scope) {
throw new LogicException('no scope found with this id: ' . $value);
throw new \LogicException('no scope found with this id: '.$value);
}
return $this->translatableStringHelper->localize($scope->getName());
@@ -109,7 +108,7 @@ readonly class ReferrerScopeAggregator implements AggregatorInterface
public function getQueryKeys($data): array
{
return [self::PREFIX . '_select'];
return [self::PREFIX.'_select'];
}
public function getTitle(): string

View File

@@ -16,7 +16,6 @@ use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function in_array;
final readonly class RequestorAggregator implements AggregatorInterface
{
@@ -29,7 +28,7 @@ final readonly class RequestorAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acppart', $qb->getAllAliases(), true)) {
if (!\in_array('acppart', $qb->getAllAliases(), true)) {
$qb->join('acp.participations', 'acppart');
}
@@ -63,6 +62,7 @@ final readonly class RequestorAggregator implements AggregatorInterface
{
// no form
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -17,7 +17,6 @@ use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
final readonly class ScopeAggregator implements AggregatorInterface
{
@@ -30,7 +29,7 @@ final readonly class ScopeAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acpscope', $qb->getAllAliases(), true)) {
if (!\in_array('acpscope', $qb->getAllAliases(), true)) {
$qb->leftJoin('acp.scopes', 'acpscope');
}
@@ -47,6 +46,7 @@ final readonly class ScopeAggregator implements AggregatorInterface
{
// no form
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -42,11 +42,11 @@ final readonly class ScopeWorkingOnCourseAggregator implements AggregatorInterfa
$qb
->leftJoin(
AccompanyingPeriodInfo::class,
"acpinfo",
'acpinfo',
Join::WITH,
$qb->expr()->eq("IDENTITY(acpinfo.accompanyingPeriod)", "acp.id")
$qb->expr()->eq('IDENTITY(acpinfo.accompanyingPeriod)', 'acp.id')
)
->leftJoin("acpinfo.user", "{$p}_user")
->leftJoin('acpinfo.user', "{$p}_user")
->leftJoin(
UserScopeHistory::class,
"{$p}_history",
@@ -56,10 +56,10 @@ final readonly class ScopeWorkingOnCourseAggregator implements AggregatorInterfa
// scope_at based on _info.infoDate
->andWhere(
$qb->expr()->andX(
$qb->expr()->lte("{$p}_history.startDate", "acpinfo.infoDate"),
$qb->expr()->lte("{$p}_history.startDate", 'acpinfo.infoDate'),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_history.endDate"),
$qb->expr()->gt("{$p}_history.endDate", "acpinfo.infoDate")
$qb->expr()->gt("{$p}_history.endDate", 'acpinfo.infoDate')
)
)
)
@@ -100,7 +100,7 @@ final readonly class ScopeWorkingOnCourseAggregator implements AggregatorInterfa
public function getQueryKeys($data): array
{
return [self::PREFIX. '_select'];
return [self::PREFIX.'_select'];
}
public function getTitle(): string

View File

@@ -17,7 +17,6 @@ use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
final readonly class SocialActionAggregator implements AggregatorInterface
{
@@ -30,7 +29,7 @@ final readonly class SocialActionAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acpw', $qb->getAllAliases(), true)) {
if (!\in_array('acpw', $qb->getAllAliases(), true)) {
// here, we will only see accompanying period linked with a socialAction
$qb->join('acp.works', 'acpw');
}
@@ -48,6 +47,7 @@ final readonly class SocialActionAggregator implements AggregatorInterface
{
// no form
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -17,7 +17,6 @@ use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
final readonly class SocialIssueAggregator implements AggregatorInterface
{
@@ -30,7 +29,7 @@ final readonly class SocialIssueAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acpsocialissue', $qb->getAllAliases(), true)) {
if (!\in_array('acpsocialissue', $qb->getAllAliases(), true)) {
// we will see accompanying period linked with social issues
$qb->join('acp.socialIssues', 'acpsocialissue');
}
@@ -48,6 +47,7 @@ final readonly class SocialIssueAggregator implements AggregatorInterface
{
// no form
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -20,7 +20,6 @@ use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function in_array;
final readonly class StepAggregator implements AggregatorInterface
{
@@ -37,20 +36,20 @@ final readonly class StepAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array(self::A, $qb->getAllAliases(), true)) {
if (!\in_array(self::A, $qb->getAllAliases(), true)) {
$qb->leftJoin('acp.stepHistories', self::A);
}
$qb
->addSelect(self::A . '.step AS step_aggregator')
->addSelect(self::A.'.step AS step_aggregator')
->andWhere(
$qb->expr()->orX(
$qb->expr()->isNull(self::A . '.step'),
$qb->expr()->isNull(self::A.'.step'),
$qb->expr()->andX(
$qb->expr()->lte(self::A . '.startDate', ':' . self::P),
$qb->expr()->lte(self::A.'.startDate', ':'.self::P),
$qb->expr()->orX(
$qb->expr()->isNull(self::A . '.endDate'),
$qb->expr()->lt(self::A . '.endDate', ':' . self::P)
$qb->expr()->isNull(self::A.'.endDate'),
$qb->expr()->lt(self::A.'.endDate', ':'.self::P)
)
)
)
@@ -68,6 +67,7 @@ final readonly class StepAggregator implements AggregatorInterface
{
$builder->add('on_date', PickRollingDateType::class, []);
}
public function getFormDefaultData(): array
{
return ['on_date' => new RollingDate(RollingDate::T_TODAY)];

View File

@@ -40,16 +40,16 @@ final readonly class UserJobAggregator implements AggregatorInterface
$qb
->leftJoin(
"acp.userHistories",
'acp.userHistories',
"{$p}_userHistory",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", "acp.id"),
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", 'acp.id'),
$qb->expr()->andX(
$qb->expr()->gte("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.startDate"),
$qb->expr()->gte('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_userHistory.endDate"),
$qb->expr()->lt("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.endDate")
$qb->expr()->lt('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.endDate")
)
)
)
@@ -108,7 +108,7 @@ final readonly class UserJobAggregator implements AggregatorInterface
public function getQueryKeys($data): array
{
return [self::PREFIX . '_select'];
return [self::PREFIX.'_select'];
}
public function getTitle(): string

View File

@@ -88,7 +88,7 @@ final readonly class UserWorkingOnCourseAggregator implements AggregatorInterfac
$qb->leftJoin('acpinfo.user', 'acpinfo_user');
}
$qb->addSelect('acpinfo_user.id AS ' . self::COLUMN_NAME);
$qb->addSelect('acpinfo_user.id AS '.self::COLUMN_NAME);
$qb->addGroupBy('acpinfo_user.id');
}

View File

@@ -14,10 +14,8 @@ namespace Chill\PersonBundle\Export\Aggregator\EvaluationAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
final class ByEndDateAggregator implements AggregatorInterface
{
@@ -40,7 +38,7 @@ final class ByEndDateAggregator implements AggregatorInterface
'week' => 'YYYY-IW',
'month' => 'YYYY-MM',
'year' => 'YYYY',
default => throw new LogicException(sprintf("The frequency data '%s' is invalid.", $data['frequency'])),
default => throw new \LogicException(sprintf("The frequency data '%s' is invalid.", $data['frequency'])),
};
$qb->addSelect(sprintf("TO_CHAR(workeval.endDate, '%s') AS eval_by_end_date_aggregator", $fmt));
@@ -62,6 +60,7 @@ final class ByEndDateAggregator implements AggregatorInterface
'empty_data' => self::DEFAULT_CHOICE,
]);
}
public function getFormDefaultData(): array
{
return ['frequency' => self::DEFAULT_CHOICE];

View File

@@ -14,10 +14,8 @@ namespace Chill\PersonBundle\Export\Aggregator\EvaluationAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
final class ByMaxDateAggregator implements AggregatorInterface
{
@@ -40,7 +38,7 @@ final class ByMaxDateAggregator implements AggregatorInterface
'week' => 'YYYY-IW',
'month' => 'YYYY-MM',
'year' => 'YYYY',
default => throw new LogicException(sprintf("The frequency data '%s' is invalid.", $data['frequency'])),
default => throw new \LogicException(sprintf("The frequency data '%s' is invalid.", $data['frequency'])),
};
$qb->addSelect(sprintf("TO_CHAR(workeval.maxDate, '%s') AS eval_by_max_date_aggregator", $fmt));
@@ -62,6 +60,7 @@ final class ByMaxDateAggregator implements AggregatorInterface
'empty_data' => self::DEFAULT_CHOICE,
]);
}
public function getFormDefaultData(): array
{
return ['frequency' => self::DEFAULT_CHOICE];

View File

@@ -14,10 +14,8 @@ namespace Chill\PersonBundle\Export\Aggregator\EvaluationAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
final class ByStartDateAggregator implements AggregatorInterface
{
@@ -40,7 +38,7 @@ final class ByStartDateAggregator implements AggregatorInterface
'week' => 'YYYY-IW',
'month' => 'YYYY-MM',
'year' => 'YYYY',
default => throw new LogicException(sprintf("The frequency data '%s' is invalid.", $data['frequency'])),
default => throw new \LogicException(sprintf("The frequency data '%s' is invalid.", $data['frequency'])),
};
$qb->addSelect(sprintf("TO_CHAR(workeval.startDate, '%s') AS eval_by_start_date_aggregator", $fmt));
@@ -62,6 +60,7 @@ final class ByStartDateAggregator implements AggregatorInterface
'empty_data' => self::DEFAULT_CHOICE,
]);
}
public function getFormDefaultData(): array
{
return ['frequency' => self::DEFAULT_CHOICE];

View File

@@ -42,6 +42,7 @@ class EvaluationTypeAggregator implements AggregatorInterface
{
// no form
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -14,7 +14,6 @@ namespace Chill\PersonBundle\Export\Aggregator\EvaluationAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -43,6 +42,7 @@ class HavingEndDateAggregator implements AggregatorInterface
{
// No form needed
}
public function getFormDefaultData(): array
{
return [];
@@ -58,7 +58,7 @@ class HavingEndDateAggregator implements AggregatorInterface
return match ($value) {
true => $this->translator->trans('export.aggregator.eval.by_end_date.enddate is specified'),
false => $this->translator->trans('export.aggregator.eval.by_end_date.enddate is not specified'),
default => throw new LogicException(sprintf('The value %s is not valid', $value)),
default => throw new \LogicException(sprintf('The value %s is not valid', $value)),
};
};
}

View File

@@ -20,7 +20,6 @@ use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function in_array;
class ChildrenNumberAggregator implements AggregatorInterface
{
@@ -33,7 +32,7 @@ class ChildrenNumberAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('composition_children', $qb->getAllAliases(), true)) {
if (!\in_array('composition_children', $qb->getAllAliases(), true)) {
$clause = $qb->expr()->andX(
$qb->expr()->lte('composition_children.startDate', ':ondate_composition_children'),
$qb->expr()->orX(
@@ -64,6 +63,7 @@ class ChildrenNumberAggregator implements AggregatorInterface
{
$builder->add('on_date', PickRollingDateType::class, []);
}
public function getFormDefaultData(): array
{
return ['on_date' => new RollingDate(RollingDate::T_TODAY)];

View File

@@ -21,7 +21,6 @@ use Chill\PersonBundle\Repository\Household\HouseholdCompositionTypeRepository;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
class CompositionAggregator implements AggregatorInterface
{
@@ -34,7 +33,7 @@ class CompositionAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('composition_type', $qb->getAllAliases(), true)) {
if (!\in_array('composition_type', $qb->getAllAliases(), true)) {
$clause = $qb->expr()->andX(
$qb->expr()->lte('composition_type.startDate', ':ondate_composition_type'),
$qb->expr()->orX(
@@ -65,6 +64,7 @@ class CompositionAggregator implements AggregatorInterface
{
$builder->add('on_date', PickRollingDateType::class, []);
}
public function getFormDefaultData(): array
{
return ['on_date' => new RollingDate(RollingDate::T_TODAY)];

View File

@@ -49,6 +49,7 @@ final readonly class AgeAggregator implements AggregatorInterface, ExportElement
'label' => 'Calculate age in relation to this date',
]);
}
public function getFormDefaultData(): array
{
return ['date_age_calculation' => new RollingDate(RollingDate::T_TODAY)];

View File

@@ -82,6 +82,7 @@ class ByHouseholdCompositionAggregator implements AggregatorInterface
'label' => 'export.aggregator.person.by_household_composition.Calc date',
]);
}
public function getFormDefaultData(): array
{
return ['date_calc' => new RollingDate(RollingDate::T_TODAY)];
@@ -108,7 +109,7 @@ class ByHouseholdCompositionAggregator implements AggregatorInterface
public function getQueryKeys($data)
{
return [self::PREFIX . '_select'];
return [self::PREFIX.'_select'];
}
public function getTitle()

View File

@@ -17,7 +17,6 @@ use Chill\MainBundle\Repository\CenterRepositoryInterface;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\PersonBundle\Export\Declarations;
use Closure;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
@@ -40,11 +39,11 @@ final readonly class CenterAggregator implements AggregatorInterface
public function getFormDefaultData(): array
{
return [
'at_date' => new RollingDate(RollingDate::T_TODAY)
'at_date' => new RollingDate(RollingDate::T_TODAY),
];
}
public function getLabels($key, array $values, $data): Closure
public function getLabels($key, array $values, $data): \Closure
{
return function (null|int|string $value) {
if (null === $value || '' === $value) {
@@ -91,7 +90,7 @@ final readonly class CenterAggregator implements AggregatorInterface
);
$qb->setParameter($atDate, $this->rollingDateConverter->convert($data['at_date']));
$qb->addSelect("IDENTITY({$alias}.center) AS " . self::COLUMN_NAME);
$qb->addSelect("IDENTITY({$alias}.center) AS ".self::COLUMN_NAME);
$qb->addGroupBy(self::COLUMN_NAME);
}

View File

@@ -18,12 +18,10 @@ use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\MainBundle\Util\CountriesInfo;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function in_array;
final readonly class CountryOfBirthAggregator implements AggregatorInterface, ExportElementValidatedInterface
{
@@ -41,15 +39,15 @@ final readonly class CountryOfBirthAggregator implements AggregatorInterface, Ex
$qb->addSelect('countryOfBirth.countryCode as country_of_birth_aggregator');
} elseif ('continent' === $data['group_by_level']) {
$clause = 'CASE '
. 'WHEN countryOfBirth.countryCode IN(:cob_africa_codes) THEN \'AF\' '
. 'WHEN countryOfBirth.countryCode IN(:cob_asia_codes) THEN \'AS\' '
. 'WHEN countryOfBirth.countryCode IN(:cob_europe_codes) THEN \'EU\' '
. 'WHEN countryOfBirth.countryCode IN(:cob_north_america_codes) THEN \'NA\' '
. 'WHEN countryOfBirth.countryCode IN(:cob_south_america_codes) THEN \'SA\' '
. 'WHEN countryOfBirth.countryCode IN(:cob_oceania_codes) THEN \'OC\' '
. 'WHEN countryOfBirth.countryCode IN(:cob_antartica_codes) THEN \'AN\' '
. 'ELSE \'\' '
. 'END as country_of_birth_aggregator ';
.'WHEN countryOfBirth.countryCode IN(:cob_africa_codes) THEN \'AF\' '
.'WHEN countryOfBirth.countryCode IN(:cob_asia_codes) THEN \'AS\' '
.'WHEN countryOfBirth.countryCode IN(:cob_europe_codes) THEN \'EU\' '
.'WHEN countryOfBirth.countryCode IN(:cob_north_america_codes) THEN \'NA\' '
.'WHEN countryOfBirth.countryCode IN(:cob_south_america_codes) THEN \'SA\' '
.'WHEN countryOfBirth.countryCode IN(:cob_oceania_codes) THEN \'OC\' '
.'WHEN countryOfBirth.countryCode IN(:cob_antartica_codes) THEN \'AN\' '
.'ELSE \'\' '
.'END as country_of_birth_aggregator ';
$qb->addSelect($clause);
$params =
[
@@ -66,11 +64,10 @@ final readonly class CountryOfBirthAggregator implements AggregatorInterface, Ex
$qb->setParameter($k, $v);
}
} else {
throw new LogicException("The group_by_level '" . $data['group_by_level']
. ' is not known.');
throw new \LogicException("The group_by_level '".$data['group_by_level'].' is not known.');
}
if (!in_array('countryOfBirth', $qb->getAllAliases(), true)) {
if (!\in_array('countryOfBirth', $qb->getAllAliases(), true)) {
$qb->leftJoin('person.countryOfBirth', 'countryOfBirth');
}
@@ -94,6 +91,7 @@ final readonly class CountryOfBirthAggregator implements AggregatorInterface, Ex
'multiple' => false,
]);
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -15,7 +15,6 @@ use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -41,6 +40,7 @@ final readonly class GenderAggregator implements AggregatorInterface
}
public function buildForm(FormBuilderInterface $builder) {}
public function getFormDefaultData(): array
{
return [];
@@ -70,7 +70,7 @@ final readonly class GenderAggregator implements AggregatorInterface
return $this->translator->trans('Gender');
default:
throw new LogicException(sprintf('The value %s is not valid', $value));
throw new \LogicException(sprintf('The value %s is not valid', $value));
}
};
}

View File

@@ -20,7 +20,6 @@ use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -90,6 +89,7 @@ class GeographicalUnitAggregator implements AggregatorInterface
'expanded' => true,
]);
}
public function getFormDefaultData(): array
{
return ['date_calc' => new RollingDate(RollingDate::T_TODAY)];
@@ -125,7 +125,7 @@ class GeographicalUnitAggregator implements AggregatorInterface
return $value;
},
default => throw new LogicException('key not supported'),
default => throw new \LogicException('key not supported'),
};
}

View File

@@ -25,7 +25,6 @@ use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function in_array;
final readonly class HouseholdPositionAggregator implements AggregatorInterface, ExportElementValidatedInterface
{
@@ -38,11 +37,11 @@ final readonly class HouseholdPositionAggregator implements AggregatorInterface,
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('householdmember', $qb->getAllAliases(), true)) {
if (!\in_array('householdmember', $qb->getAllAliases(), true)) {
$qb->join(HouseholdMember::class, 'householdmember', Expr\Join::WITH, 'householdmember.person = person');
}
if (!in_array('center', $qb->getAllAliases(), true)) {
if (!\in_array('center', $qb->getAllAliases(), true)) {
$qb->join('person.center', 'center');
}
@@ -74,6 +73,7 @@ final readonly class HouseholdPositionAggregator implements AggregatorInterface,
'label' => 'Household position in relation to this date',
]);
}
public function getFormDefaultData(): array
{
return ['date_position' => new RollingDate(RollingDate::T_TODAY)];

View File

@@ -17,7 +17,6 @@ use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Repository\MaritalStatusRepository;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
final readonly class MaritalStatusAggregator implements AggregatorInterface
{
@@ -30,7 +29,7 @@ final readonly class MaritalStatusAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('personmarital', $qb->getAllAliases(), true)) {
if (!\in_array('personmarital', $qb->getAllAliases(), true)) {
$qb->join('person.maritalStatus', 'personmarital');
}

View File

@@ -17,7 +17,6 @@ use Chill\MainBundle\Repository\CountryRepository;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\MainBundle\Util\CountriesInfo;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
@@ -39,15 +38,15 @@ final readonly class NationalityAggregator implements AggregatorInterface, Expor
$qb->addSelect('nationality.countryCode as nationality_aggregator');
} elseif ('continent' === $data['group_by_level']) {
$clause = 'CASE '
. 'WHEN nationality.countryCode IN(:africa_codes) THEN \'AF\' '
. 'WHEN nationality.countryCode IN(:asia_codes) THEN \'AS\' '
. 'WHEN nationality.countryCode IN(:europe_codes) THEN \'EU\' '
. 'WHEN nationality.countryCode IN(:north_america_codes) THEN \'NA\' '
. 'WHEN nationality.countryCode IN(:south_america_codes) THEN \'SA\' '
. 'WHEN nationality.countryCode IN(:oceania_codes) THEN \'OC\' '
. 'WHEN nationality.countryCode IN(:antartica_codes) THEN \'AN\' '
. 'ELSE \'\' '
. 'END as nationality_aggregator ';
.'WHEN nationality.countryCode IN(:africa_codes) THEN \'AF\' '
.'WHEN nationality.countryCode IN(:asia_codes) THEN \'AS\' '
.'WHEN nationality.countryCode IN(:europe_codes) THEN \'EU\' '
.'WHEN nationality.countryCode IN(:north_america_codes) THEN \'NA\' '
.'WHEN nationality.countryCode IN(:south_america_codes) THEN \'SA\' '
.'WHEN nationality.countryCode IN(:oceania_codes) THEN \'OC\' '
.'WHEN nationality.countryCode IN(:antartica_codes) THEN \'AN\' '
.'ELSE \'\' '
.'END as nationality_aggregator ';
$qb->addSelect($clause);
$params =
[
@@ -64,8 +63,7 @@ final readonly class NationalityAggregator implements AggregatorInterface, Expor
$qb->setParameter($k, $v);
}
} else {
throw new LogicException("The group_by_level '" . $data['group_by_level']
. ' is not known.');
throw new \LogicException("The group_by_level '".$data['group_by_level'].' is not known.');
}
$qb->leftJoin('person.nationality', 'nationality');

View File

@@ -18,9 +18,7 @@ use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
final readonly class ActionTypeAggregator implements AggregatorInterface
{
@@ -33,11 +31,11 @@ final readonly class ActionTypeAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acpwsocialaction', $qb->getAllAliases(), true)) {
if (!\in_array('acpwsocialaction', $qb->getAllAliases(), true)) {
$qb->leftJoin('acpw.socialAction', 'acpwsocialaction');
}
if (!in_array('acpwsocialissue', $qb->getAllAliases(), true)) {
if (!\in_array('acpwsocialissue', $qb->getAllAliases(), true)) {
$qb->leftJoin('acpwsocialaction.issue', 'acpwsocialissue');
}
@@ -57,6 +55,7 @@ final readonly class ActionTypeAggregator implements AggregatorInterface
{
// no form
}
public function getFormDefaultData(): array
{
return [];
@@ -87,7 +86,7 @@ final readonly class ActionTypeAggregator implements AggregatorInterface
return $this->socialIssueRender->renderString($si, []);
},
default => throw new LogicException('this key is not supported: ' . $key),
default => throw new \LogicException('this key is not supported: '.$key),
};
}

View File

@@ -14,7 +14,6 @@ namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -46,6 +45,7 @@ class CurrentActionAggregator implements AggregatorInterface
{
// No form needed
}
public function getFormDefaultData(): array
{
return [];
@@ -61,7 +61,7 @@ class CurrentActionAggregator implements AggregatorInterface
return match ($value) {
true => $this->translator->trans('export.aggregator.course_work.by_current_action.Current action'),
false => $this->translator->trans('export.aggregator.course_work.by_current_action.Not current action'),
default => throw new LogicException(sprintf('The value %s is not valid', $value)),
default => throw new \LogicException(sprintf('The value %s is not valid', $value)),
};
};
}

View File

@@ -17,7 +17,6 @@ use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Repository\SocialWork\GoalRepository;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
final readonly class GoalAggregator implements AggregatorInterface
{
@@ -30,7 +29,7 @@ final readonly class GoalAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('goal', $qb->getAllAliases(), true)) {
if (!\in_array('goal', $qb->getAllAliases(), true)) {
$qb->leftJoin('acpw.goals', 'goal');
}
@@ -47,6 +46,7 @@ final readonly class GoalAggregator implements AggregatorInterface
{
// no form
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -17,9 +17,7 @@ use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Repository\SocialWork\GoalRepository;
use Chill\PersonBundle\Repository\SocialWork\ResultRepository;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
class GoalResultAggregator implements AggregatorInterface
{
@@ -32,11 +30,11 @@ class GoalResultAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('goal', $qb->getAllAliases(), true)) {
if (!\in_array('goal', $qb->getAllAliases(), true)) {
$qb->leftJoin('acpw.goals', 'goal');
}
if (!in_array('goalresult', $qb->getAllAliases(), true)) {
if (!\in_array('goalresult', $qb->getAllAliases(), true)) {
$qb->leftJoin('goal.results', 'goalresult');
}
@@ -54,6 +52,7 @@ class GoalResultAggregator implements AggregatorInterface
{
// no form
}
public function getFormDefaultData(): array
{
return [];
@@ -90,7 +89,7 @@ class GoalResultAggregator implements AggregatorInterface
);
default:
throw new LogicException();
throw new \LogicException();
}
};
}

View File

@@ -11,21 +11,15 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User\UserJobHistory;
use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Repository\UserJobRepository;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverter;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
final readonly class JobAggregator implements AggregatorInterface
{
@@ -50,7 +44,7 @@ final readonly class JobAggregator implements AggregatorInterface
UserJob::class,
"{$p}_job",
Expr\Join::WITH,
'EXISTS (SELECT 1 FROM ' . AccompanyingPeriodWorkReferrerHistory::class . " {$p}_ref_history
'EXISTS (SELECT 1 FROM '.AccompanyingPeriodWorkReferrerHistory::class." {$p}_ref_history
JOIN {$p}_ref_history.user {$p}_ref_history_user JOIN {$p}_ref_history_user.jobHistories {$p}_job_history
WHERE {$p}_ref_history.accompanyingPeriodWork = acpw AND IDENTITY({$p}_job_history.job) = {$p}_job.id AND {$p}_job_history.startDate <= {$p}_ref_history.startDate
AND ({$p}_job_history.endDate IS NULL or {$p}_job_history.endDate >= {$p}_ref_history.startDate))"
@@ -94,7 +88,7 @@ final readonly class JobAggregator implements AggregatorInterface
public function getQueryKeys($data): array
{
return [self::PREFIX . '_select'];
return [self::PREFIX.'_select'];
}
public function getTitle(): string

View File

@@ -20,7 +20,6 @@ use Chill\MainBundle\Templating\Entity\UserRender;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
final readonly class ReferrerAggregator implements AggregatorInterface
{
@@ -42,7 +41,7 @@ final readonly class ReferrerAggregator implements AggregatorInterface
$p = self::PREFIX;
$qb
->leftJoin('acpw.referrersHistory', $p . "_acpwusers_history")
->leftJoin('acpw.referrersHistory', $p.'_acpwusers_history')
->andWhere("{$p}_acpwusers_history.startDate <= :{$p}_calc_date AND ({$p}_acpwusers_history.endDate IS NULL or {$p}_acpwusers_history.endDate > :{$p}_calc_date)");
$qb->setParameter("{$p}_calc_date", $this->rollingDateConverter->convert(
@@ -60,7 +59,7 @@ final readonly class ReferrerAggregator implements AggregatorInterface
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('referrer_at', PickRollingDateType::class, [
'label' => 'export.aggregator.course_work.by_treating_agent.Calc date'
'label' => 'export.aggregator.course_work.by_treating_agent.Calc date',
]);
}

View File

@@ -17,7 +17,6 @@ use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Repository\SocialWork\ResultRepository;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
final readonly class ResultAggregator implements AggregatorInterface
{
@@ -30,7 +29,7 @@ final readonly class ResultAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('result', $qb->getAllAliases(), true)) {
if (!\in_array('result', $qb->getAllAliases(), true)) {
$qb->leftJoin('acpw.results', 'result');
}
@@ -47,6 +46,7 @@ final readonly class ResultAggregator implements AggregatorInterface
{
// no form
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -12,20 +12,14 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User\UserScopeHistory;
use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Repository\ScopeRepository;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverter;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
final readonly class ScopeAggregator implements AggregatorInterface
{
@@ -50,7 +44,7 @@ final readonly class ScopeAggregator implements AggregatorInterface
Scope::class,
"{$p}_scope",
Expr\Join::WITH,
'EXISTS (SELECT 1 FROM ' . AccompanyingPeriodWorkReferrerHistory::class . " {$p}_ref_history
'EXISTS (SELECT 1 FROM '.AccompanyingPeriodWorkReferrerHistory::class." {$p}_ref_history
JOIN {$p}_ref_history.user {$p}_ref_history_user JOIN {$p}_ref_history_user.scopeHistories {$p}_scope_history
WHERE {$p}_ref_history.accompanyingPeriodWork = acpw AND IDENTITY({$p}_scope_history.scope) = {$p}_scope.id AND {$p}_scope_history.startDate <= {$p}_ref_history.startDate
AND ({$p}_scope_history.endDate IS NULL or {$p}_scope_history.endDate >= {$p}_ref_history.startDate))"
@@ -94,7 +88,7 @@ final readonly class ScopeAggregator implements AggregatorInterface
public function getQueryKeys($data): array
{
return [self::PREFIX . '_select'];
return [self::PREFIX.'_select'];
}
public function getTitle(): string

View File

@@ -23,7 +23,6 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface
@@ -40,6 +39,7 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface
{
// Nothing to add here
}
public function getFormDefaultData(): array
{
return [];
@@ -63,7 +63,7 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface
public function getLabels($key, array $values, $data)
{
if ('export_result' !== $key) {
throw new LogicException("the key {$key} is not used by this export");
throw new \LogicException("the key {$key} is not used by this export");
}
$labels = array_combine($values, $values);
@@ -104,7 +104,7 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface
->leftJoin('acppart.person', 'person')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM ' . PersonCenterHistory::class . ' acl_count_person_history WHERE acl_count_person_history.person = person
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)

View File

@@ -22,7 +22,6 @@ use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInterface
@@ -33,6 +32,7 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter
{
// No form necessary?
}
public function getFormDefaultData(): array
{
return [];
@@ -56,7 +56,7 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter
public function getLabels($key, array $values, $data)
{
if ('export_result' !== $key) {
throw new LogicException("the key {$key} is not used by this export");
throw new \LogicException("the key {$key} is not used by this export");
}
$labels = array_combine($values, $values);
@@ -98,7 +98,7 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter
->join('acppart.person', 'person')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM ' . PersonCenterHistory::class . ' acl_count_person_history WHERE acl_count_person_history.person = person
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)

View File

@@ -21,7 +21,6 @@ use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
class CountEvaluation implements ExportInterface, GroupedExportInterface
@@ -29,6 +28,7 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface
public function __construct(private readonly EntityManagerInterface $entityManager) {}
public function buildForm(FormBuilderInterface $builder) {}
public function getFormDefaultData(): array
{
return [];
@@ -52,7 +52,7 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface
public function getLabels($key, array $values, $data)
{
if ('export_result' !== $key) {
throw new LogicException("the key {$key} is not used by this export");
throw new \LogicException("the key {$key} is not used by this export");
}
$labels = array_combine($values, $values);
@@ -95,7 +95,7 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface
->join('acppart.person', 'person')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM ' . PersonCenterHistory::class . ' acl_count_person_history WHERE acl_count_person_history.person = person
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)

View File

@@ -23,7 +23,6 @@ use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Security\Authorization\HouseholdVoter;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
class CountHousehold implements ExportInterface, GroupedExportInterface
@@ -36,10 +35,11 @@ class CountHousehold implements ExportInterface, GroupedExportInterface
{
$builder
->add('calc_date', PickRollingDateType::class, [
'label' => self::TR_PREFIX . 'Date of calculation of household members',
'label' => self::TR_PREFIX.'Date of calculation of household members',
'required' => false,
]);
}
public function getFormDefaultData(): array
{
return ['calc_date' => new RollingDate(RollingDate::T_TODAY)];
@@ -52,7 +52,7 @@ class CountHousehold implements ExportInterface, GroupedExportInterface
public function getDescription(): string
{
return self::TR_PREFIX . 'Count household with accompanying course by various parameters.';
return self::TR_PREFIX.'Count household with accompanying course by various parameters.';
}
public function getGroup(): string
@@ -65,9 +65,9 @@ class CountHousehold implements ExportInterface, GroupedExportInterface
return static function ($value) use ($key) {
if ('_header' === $value) {
return match ($key) {
'household_export_result' => self::TR_PREFIX . 'Count households',
'acp_export_result' => self::TR_PREFIX . 'Count accompanying periods',
default => throw new LogicException('Key not supported: ' . $key),
'household_export_result' => self::TR_PREFIX.'Count households',
'acp_export_result' => self::TR_PREFIX.'Count accompanying periods',
default => throw new \LogicException('Key not supported: '.$key),
};
}
@@ -91,7 +91,7 @@ class CountHousehold implements ExportInterface, GroupedExportInterface
public function getTitle(): string
{
return self::TR_PREFIX . 'Count households with accompanying course';
return self::TR_PREFIX.'Count households with accompanying course';
}
public function getType(): string
@@ -114,7 +114,7 @@ class CountHousehold implements ExportInterface, GroupedExportInterface
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM ' . PersonCenterHistory::class . ' acl_count_person_history WHERE acl_count_person_history.person = person
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)

View File

@@ -20,7 +20,6 @@ use Chill\PersonBundle\Repository\PersonRepository;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
class CountPerson implements ExportInterface, GroupedExportInterface
@@ -55,7 +54,7 @@ class CountPerson implements ExportInterface, GroupedExportInterface
public function getLabels($key, array $values, $data)
{
if ('export_result' !== $key) {
throw new LogicException("the key {$key} is not used by this export");
throw new \LogicException("the key {$key} is not used by this export");
}
$labels = array_combine($values, $values);
@@ -98,7 +97,7 @@ class CountPerson implements ExportInterface, GroupedExportInterface
$qb->select('COUNT(DISTINCT person.id) AS export_result')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM ' . PersonCenterHistory::class . ' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
)
)
->setParameter('authorized_centers', $centers);

View File

@@ -22,9 +22,7 @@ use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExportInterface
{
@@ -40,6 +38,7 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor
{
// TODO: Implement buildForm() method.
}
public function getFormDefaultData(): array
{
return [];
@@ -63,7 +62,7 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor
public function getLabels($key, array $values, $data)
{
if ('export_result' !== $key) {
throw new LogicException("the key {$key} is not used by this export");
throw new \LogicException("the key {$key} is not used by this export");
}
$labels = array_combine($values, $values);
@@ -98,17 +97,17 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor
$qb = $this->repository->createQueryBuilder('acp');
if (!in_array('acppart', $qb->getAllAliases(), true)) {
if (!\in_array('acppart', $qb->getAllAliases(), true)) {
$qb->join('acp.participations', 'acppart');
}
if (!in_array('partperson', $qb->getAllAliases(), true)) {
if (!\in_array('partperson', $qb->getAllAliases(), true)) {
$qb->join('acppart.person', 'person');
}
$qb->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM ' . PersonCenterHistory::class . ' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
)
)->setParameter('authorized_centers', $centers);

View File

@@ -11,41 +11,22 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Export;
use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\MainBundle\Export\Helper\DateTimeHelper;
use Chill\MainBundle\Export\Helper\ExportAddressHelper;
use Chill\MainBundle\Export\Helper\UserHelper;
use Chill\MainBundle\Export\ListInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper;
use Chill\PersonBundle\Repository\PersonRepository;
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
use DateTimeImmutable;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function strlen;
final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface
{
@@ -64,10 +45,11 @@ final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExp
'required' => true,
]);
}
public function getFormDefaultData(): array
{
return [
'calc_date' => new RollingDate(RollingDate::T_TODAY)
'calc_date' => new RollingDate(RollingDate::T_TODAY),
];
}
@@ -122,8 +104,8 @@ final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExp
->andWhere('acp.step != :list_acp_step')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part
JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
'
)

View File

@@ -41,7 +41,6 @@ use Chill\PersonBundle\Templating\Entity\SocialActionRender;
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper;
use DateTimeImmutable;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder;
@@ -71,7 +70,7 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
'personsName',
'thirdParties',
'handlingThierParty',
//'acpwReferrers',
// 'acpwReferrers',
'referrers',
'createdAt',
'createdBy',
@@ -103,6 +102,7 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
'required' => true,
]);
}
public function getFormDefaultData(): array
{
return ['calc_date' => new RollingDate(RollingDate::T_TODAY)];
@@ -126,10 +126,10 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
public function getLabels($key, array $values, $data)
{
return match ($key) {
'startDate', 'endDate', 'createdAt', 'updatedAt' => $this->dateTimeHelper->getLabel('export.list.acpw.' . $key),
'startDate', 'endDate', 'createdAt', 'updatedAt' => $this->dateTimeHelper->getLabel('export.list.acpw.'.$key),
'socialAction' => function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.acpw.' . $key;
return 'export.list.acpw.'.$key;
}
if (null === $value) {
@@ -143,7 +143,7 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
},
'socialIssue' => function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.acpw.' . $key;
return 'export.list.acpw.'.$key;
}
if (null === $value) {
@@ -155,17 +155,17 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
[]
);
},
'createdBy', 'updatedBy', 'acp_user' => $this->userHelper->getLabel($key, $values, 'export.list.acpw.' . $key),
'referrers' => $this->userHelper->getLabel($key, $values, 'export.list.acpw.' . $key),
//'acpwReferrers' => $this->userHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key),
'personsName' => $this->personHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key),
'handlingThierParty' => $this->thirdPartyHelper->getLabel($key, $values, 'export.list.acpw.' . $key),
'thirdParties' => $this->thirdPartyHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key),
'personsId', 'goalsId', 'goalResultsId', 'resultsId', 'evaluationsId' => $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key),
'goalsTitle', 'goalResultsTitle', 'resultsTitle', 'evaluationsTitle' => $this->translatableStringExportLabelHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key),
'createdBy', 'updatedBy', 'acp_user' => $this->userHelper->getLabel($key, $values, 'export.list.acpw.'.$key),
'referrers' => $this->userHelper->getLabel($key, $values, 'export.list.acpw.'.$key),
// 'acpwReferrers' => $this->userHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key),
'personsName' => $this->personHelper->getLabelMulti($key, $values, 'export.list.acpw.'.$key),
'handlingThierParty' => $this->thirdPartyHelper->getLabel($key, $values, 'export.list.acpw.'.$key),
'thirdParties' => $this->thirdPartyHelper->getLabelMulti($key, $values, 'export.list.acpw.'.$key),
'personsId', 'goalsId', 'goalResultsId', 'resultsId', 'evaluationsId' => $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.acpw.'.$key),
'goalsTitle', 'goalResultsTitle', 'resultsTitle', 'evaluationsTitle' => $this->translatableStringExportLabelHelper->getLabelMulti($key, $values, 'export.list.acpw.'.$key),
default => static function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.acpw.' . $key;
return 'export.list.acpw.'.$key;
}
if (null === $value) {
@@ -216,7 +216,7 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
->andWhere('acppart.startDate <= :calc_date AND (acppart.endDate > :calc_date OR acppart.endDate IS NULL)')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM ' . PersonCenterHistory::class . ' acl_count_person_history WHERE acl_count_person_history.person = person
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)
@@ -245,7 +245,7 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
];
}
private function addSelectClauses(QueryBuilder $qb, DateTimeImmutable $calcDate): void
private function addSelectClauses(QueryBuilder $qb, \DateTimeImmutable $calcDate): void
{
// add regular fields
foreach ([
@@ -281,14 +281,14 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
// persons
$qb
->addSelect('(SELECT AGGREGATE(person_acpw_member.id) FROM ' . Person::class . ' person_acpw_member '
. 'WHERE person_acpw_member MEMBER OF acpw.persons) AS personsId')
->addSelect('(SELECT AGGREGATE(person1_acpw_member.id) FROM ' . Person::class . ' person1_acpw_member '
. 'WHERE person1_acpw_member MEMBER OF acpw.persons) AS personsName');
->addSelect('(SELECT AGGREGATE(person_acpw_member.id) FROM '.Person::class.' person_acpw_member '
.'WHERE person_acpw_member MEMBER OF acpw.persons) AS personsId')
->addSelect('(SELECT AGGREGATE(person1_acpw_member.id) FROM '.Person::class.' person1_acpw_member '
.'WHERE person1_acpw_member MEMBER OF acpw.persons) AS personsName');
// referrers => at date XXXX
$qb
->addSelect('(SELECT JSON_BUILD_OBJECT(\'uid\', IDENTITY(history.user), \'d\', history.startDate) FROM ' . UserHistory::class . ' history ' .
->addSelect('(SELECT JSON_BUILD_OBJECT(\'uid\', IDENTITY(history.user), \'d\', history.startDate) FROM '.UserHistory::class.' history '.
'WHERE history.accompanyingPeriod = acp AND history.startDate <= :calcDate AND (history.endDate IS NULL OR history.endDate > :calcDate)) AS referrers');
/*
@@ -304,39 +304,39 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
// thirdparties
$qb
->addSelect('(SELECT AGGREGATE(tp.id) FROM ' . ThirdParty::class . ' tp '
. 'WHERE tp MEMBER OF acpw.thirdParties) AS thirdParties');
->addSelect('(SELECT AGGREGATE(tp.id) FROM '.ThirdParty::class.' tp '
.'WHERE tp MEMBER OF acpw.thirdParties) AS thirdParties');
// goals
$qb
->addSelect('(SELECT AGGREGATE(IDENTITY(goal.goal)) FROM ' . AccompanyingPeriodWorkGoal::class . ' goal '
. 'WHERE goal MEMBER OF acpw.goals) AS goalsId')
->addSelect('(SELECT AGGREGATE(g.title) FROM ' . AccompanyingPeriodWorkGoal::class . ' goal1 '
. 'LEFT JOIN ' . Goal::class . ' g WITH goal1.goal = g.id WHERE goal1 MEMBER OF acpw.goals) AS goalsTitle');
->addSelect('(SELECT AGGREGATE(IDENTITY(goal.goal)) FROM '.AccompanyingPeriodWorkGoal::class.' goal '
.'WHERE goal MEMBER OF acpw.goals) AS goalsId')
->addSelect('(SELECT AGGREGATE(g.title) FROM '.AccompanyingPeriodWorkGoal::class.' goal1 '
.'LEFT JOIN '.Goal::class.' g WITH goal1.goal = g.id WHERE goal1 MEMBER OF acpw.goals) AS goalsTitle');
// goals results
$qb
->addSelect('(SELECT AGGREGATE(wr.id) FROM ' . Result::class . ' wr '
. 'JOIN ' . AccompanyingPeriodWorkGoal::class . ' wg WITH wr MEMBER OF wg.results '
. 'WHERE wg MEMBER OF acpw.goals) AS goalResultsId')
->addSelect('(SELECT AGGREGATE(wr1.title) FROM ' . Result::class . ' wr1 '
. 'JOIN ' . AccompanyingPeriodWorkGoal::class . ' wg1 WITH wr1 MEMBER OF wg1.results '
. 'WHERE wg1 MEMBER OF acpw.goals) AS goalResultsTitle');
->addSelect('(SELECT AGGREGATE(wr.id) FROM '.Result::class.' wr '
.'JOIN '.AccompanyingPeriodWorkGoal::class.' wg WITH wr MEMBER OF wg.results '
.'WHERE wg MEMBER OF acpw.goals) AS goalResultsId')
->addSelect('(SELECT AGGREGATE(wr1.title) FROM '.Result::class.' wr1 '
.'JOIN '.AccompanyingPeriodWorkGoal::class.' wg1 WITH wr1 MEMBER OF wg1.results '
.'WHERE wg1 MEMBER OF acpw.goals) AS goalResultsTitle');
// results
$qb
->addSelect('(SELECT AGGREGATE(result.id) FROM ' . Result::class . ' result '
. 'WHERE result MEMBER OF acpw.results ) AS resultsId ')
->addSelect('(SELECT AGGREGATE (result1.title) FROM ' . Result::class . ' result1 '
. 'WHERE result1 MEMBER OF acpw.results ) AS resultsTitle ');
->addSelect('(SELECT AGGREGATE(result.id) FROM '.Result::class.' result '
.'WHERE result MEMBER OF acpw.results ) AS resultsId ')
->addSelect('(SELECT AGGREGATE (result1.title) FROM '.Result::class.' result1 '
.'WHERE result1 MEMBER OF acpw.results ) AS resultsTitle ');
// evaluations
$qb
->addSelect('(SELECT AGGREGATE(IDENTITY(we.evaluation)) FROM ' . AccompanyingPeriodWorkEvaluation::class . ' we '
. 'WHERE we MEMBER OF acpw.accompanyingPeriodWorkEvaluations ) AS evaluationsId ')
->addSelect('(SELECT AGGREGATE(ev.title) FROM ' . AccompanyingPeriodWorkEvaluation::class . ' we1 '
. 'LEFT JOIN ' . Evaluation::class . ' ev WITH we1.evaluation = ev.id '
. 'WHERE we1 MEMBER OF acpw.accompanyingPeriodWorkEvaluations ) AS evaluationsTitle ');
->addSelect('(SELECT AGGREGATE(IDENTITY(we.evaluation)) FROM '.AccompanyingPeriodWorkEvaluation::class.' we '
.'WHERE we MEMBER OF acpw.accompanyingPeriodWorkEvaluations ) AS evaluationsId ')
->addSelect('(SELECT AGGREGATE(ev.title) FROM '.AccompanyingPeriodWorkEvaluation::class.' we1 '
.'LEFT JOIN '.Evaluation::class.' ev WITH we1.evaluation = ev.id '
.'WHERE we1 MEMBER OF acpw.accompanyingPeriodWorkEvaluations ) AS evaluationsTitle ');
$qb->setParameter('calcDate', $calcDate);
}

View File

@@ -20,7 +20,7 @@ use Chill\MainBundle\Export\Helper\TranslatableStringExportLabelHelper;
use Chill\MainBundle\Export\Helper\UserHelper;
use Chill\MainBundle\Export\ListInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
//use Chill\MainBundle\Service\RollingDate\RollingDateConverter;
// use Chill\MainBundle\Service\RollingDate\RollingDateConverter;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
@@ -34,7 +34,6 @@ use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
use DateTimeImmutable;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder;
@@ -80,6 +79,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
'required' => true,
]);
}
public function getFormDefaultData(): array
{
return ['calc_date' => new RollingDate(RollingDate::T_TODAY)];
@@ -103,10 +103,10 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
public function getLabels($key, array $values, $data)
{
return match ($key) {
'startDate', 'endDate', 'maxDate', 'acpw_startDate', 'acpw_endDate', 'createdAt', 'updatedAt' => $this->dateTimeHelper->getLabel('export.list.eval.' . $key),
'startDate', 'endDate', 'maxDate', 'acpw_startDate', 'acpw_endDate', 'createdAt', 'updatedAt' => $this->dateTimeHelper->getLabel('export.list.eval.'.$key),
'acpw_socialaction' => function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.eval.' . $key;
return 'export.list.eval.'.$key;
}
if (null === $value || '' === $value) {
@@ -120,7 +120,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
},
'acpw_socialissue' => function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.eval.' . $key;
return 'export.list.eval.'.$key;
}
if (null === $value || '' === $value) {
@@ -132,15 +132,15 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
[]
);
},
'createdBy', 'updatedBy', 'acpw_acp_user' => $this->userHelper->getLabel($key, $values, 'export.list.eval.' . $key),
'acpw_referrers' => $this->userHelper->getLabelMulti($key, $values, 'export.list.eval.' . $key),
'acpw_persons_id' => $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.eval.' . $key),
'acpw_persons' => $this->personHelper->getLabelMulti($key, $values, 'export.list.eval.' . $key),
'createdBy', 'updatedBy', 'acpw_acp_user' => $this->userHelper->getLabel($key, $values, 'export.list.eval.'.$key),
'acpw_referrers' => $this->userHelper->getLabelMulti($key, $values, 'export.list.eval.'.$key),
'acpw_persons_id' => $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.eval.'.$key),
'acpw_persons' => $this->personHelper->getLabelMulti($key, $values, 'export.list.eval.'.$key),
'eval_title' => $this->translatableStringExportLabelHelper
->getLabel($key, $values, 'export.list.eval.' . $key),
->getLabel($key, $values, 'export.list.eval.'.$key),
default => static function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.eval.' . $key;
return 'export.list.eval.'.$key;
}
if (null === $value) {
@@ -192,7 +192,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
->andWhere('acppart.startDate <= :calc_date AND (acppart.endDate > :calc_date OR acppart.endDate IS NULL)')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM ' . PersonCenterHistory::class . ' acl_count_person_history WHERE acl_count_person_history.person = person
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)
@@ -222,7 +222,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
];
}
private function addSelectClauses(QueryBuilder $qb, DateTimeImmutable $calc_date): void
private function addSelectClauses(QueryBuilder $qb, \DateTimeImmutable $calc_date): void
{
// add the regular fields
foreach (['startDate', 'endDate', 'maxDate', 'warningInterval', 'comment', 'createdAt', 'updatedAt'] as $field) {
@@ -238,7 +238,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
}
foreach (['id', 'startDate', 'endDate', 'note'] as $field) {
$qb->addSelect(sprintf('acpw.%s AS %s', $field, 'acpw_' . $field));
$qb->addSelect(sprintf('acpw.%s AS %s', $field, 'acpw_'.$field));
}
// join socialaction
@@ -255,15 +255,15 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
// referrers => at date XXXX
$qb
->addSelect('(SELECT JSON_BUILD_OBJECT(\'uid\', IDENTITY(history.user), \'d\', history.startDate) FROM ' . UserHistory::class . ' history ' .
->addSelect('(SELECT JSON_BUILD_OBJECT(\'uid\', IDENTITY(history.user), \'d\', history.startDate) FROM '.UserHistory::class.' history '.
'WHERE history.accompanyingPeriod = acp AND history.startDate <= :calc_date AND (history.endDate IS NULL OR history.endDate > :calc_date)) AS referrers');
// persons
$qb
->addSelect('(SELECT AGGREGATE(person_acpw_member.id) FROM ' . Person::class . ' person_acpw_member '
. 'WHERE person_acpw_member MEMBER OF acpw.persons) AS acpw_persons_id')
->addSelect('(SELECT AGGREGATE(person1_acpw_member.id) FROM ' . Person::class . ' person1_acpw_member '
. 'WHERE person1_acpw_member MEMBER OF acpw.persons) AS acpw_persons');
->addSelect('(SELECT AGGREGATE(person_acpw_member.id) FROM '.Person::class.' person_acpw_member '
.'WHERE person_acpw_member MEMBER OF acpw.persons) AS acpw_persons_id')
->addSelect('(SELECT AGGREGATE(person1_acpw_member.id) FROM '.Person::class.' person1_acpw_member '
.'WHERE person1_acpw_member MEMBER OF acpw.persons) AS acpw_persons');
// join evaluation
$qb

View File

@@ -26,12 +26,10 @@ use Chill\PersonBundle\Entity\Household\HouseholdMember;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Security\Authorization\HouseholdVoter;
use DateTimeImmutable;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function strlen;
class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface
{
@@ -62,6 +60,7 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface
'required' => true,
]);
}
public function getFormDefaultData(): array
{
return ['calc_date' => new RollingDate(RollingDate::T_TODAY)];
@@ -89,11 +88,11 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface
}
return match ($key) {
'membersId', 'membersName' => $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.household.' . $key),
'compositionType' => $this->translatableStringHelper->getLabel($key, $values, 'export.list.household.' . $key),
'membersId', 'membersName' => $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.household.'.$key),
'compositionType' => $this->translatableStringHelper->getLabel($key, $values, 'export.list.household.'.$key),
default => static function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.household.' . $key;
return 'export.list.household.'.$key;
}
return (string) $value;
@@ -141,7 +140,7 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM ' . PersonCenterHistory::class . ' acl_count_person_history WHERE acl_count_person_history.person = person
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)
@@ -169,36 +168,36 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface
];
}
private function addSelectClauses(QueryBuilder $qb, DateTimeImmutable $calcDate): void
private function addSelectClauses(QueryBuilder $qb, \DateTimeImmutable $calcDate): void
{
// members at date
$qb
->addSelect('(SELECT COUNT(members0) FROM ' . HouseholdMember::class . ' members0 '
. 'WHERE members0.startDate <= :calcDate AND (members0.endDate IS NULL OR members0.endDate > :calcDate) '
. 'AND members0 MEMBER OF household.members) AS membersCount')
->addSelect('(SELECT COUNT(members0) FROM '.HouseholdMember::class.' members0 '
.'WHERE members0.startDate <= :calcDate AND (members0.endDate IS NULL OR members0.endDate > :calcDate) '
.'AND members0 MEMBER OF household.members) AS membersCount')
->addSelect('(SELECT AGGREGATE(IDENTITY(members1.person)) FROM ' . HouseholdMember::class . ' members1 '
. 'WHERE members1.startDate <= :calcDate AND (members1.endDate IS NULL OR members1.endDate > :calcDate) '
. 'AND members1 MEMBER OF household.members) AS membersId')
->addSelect('(SELECT AGGREGATE(IDENTITY(members1.person)) FROM '.HouseholdMember::class.' members1 '
.'WHERE members1.startDate <= :calcDate AND (members1.endDate IS NULL OR members1.endDate > :calcDate) '
.'AND members1 MEMBER OF household.members) AS membersId')
->addSelect("(SELECT AGGREGATE(CONCAT(person2.firstName, ' ', person2.lastName)) FROM " . HouseholdMember::class . ' members2 '
. 'JOIN members2.person person2 '
. 'WHERE members2.startDate <= :calcDate AND (members2.endDate IS NULL OR members2.endDate > :calcDate) '
. 'AND members2 MEMBER OF household.members) AS membersName');
->addSelect("(SELECT AGGREGATE(CONCAT(person2.firstName, ' ', person2.lastName)) FROM ".HouseholdMember::class.' members2 '
.'JOIN members2.person person2 '
.'WHERE members2.startDate <= :calcDate AND (members2.endDate IS NULL OR members2.endDate > :calcDate) '
.'AND members2 MEMBER OF household.members) AS membersName');
// composition at date
$qb
->addSelect('(SELECT compo.numberOfChildren FROM ' . HouseholdComposition::class . ' compo '
. 'WHERE compo.startDate <= :calcDate AND (compo.endDate IS NULL OR compo.endDate > :calcDate) '
. 'AND compo MEMBER OF household.compositions) AS compositionNumberOfChildren')
->addSelect('(SELECT compo.numberOfChildren FROM '.HouseholdComposition::class.' compo '
.'WHERE compo.startDate <= :calcDate AND (compo.endDate IS NULL OR compo.endDate > :calcDate) '
.'AND compo MEMBER OF household.compositions) AS compositionNumberOfChildren')
->addSelect('(SELECT compo1.comment.comment FROM ' . HouseholdComposition::class . ' compo1 '
. 'WHERE compo1.startDate <= :calcDate AND (compo1.endDate IS NULL OR compo1.endDate > :calcDate) '
. 'AND compo1 MEMBER OF household.compositions) AS compositionComment')
->addSelect('(SELECT compo1.comment.comment FROM '.HouseholdComposition::class.' compo1 '
.'WHERE compo1.startDate <= :calcDate AND (compo1.endDate IS NULL OR compo1.endDate > :calcDate) '
.'AND compo1 MEMBER OF household.compositions) AS compositionComment')
->addSelect('(
SELECT type2.label
FROM ' . HouseholdComposition::class . ' compo2
FROM '.HouseholdComposition::class.' compo2
JOIN compo2.householdCompositionType type2
WHERE compo2.startDate <= :calcDate AND (compo2.endDate IS NULL OR compo2.endDate > :calcDate)
AND compo2 MEMBER OF household.compositions

View File

@@ -34,15 +34,6 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function addcslashes;
use function array_key_exists;
use function array_keys;
use function array_merge;
use function count;
use function in_array;
use function strlen;
use function uniqid;
/**
* Render a list of people.
*/
@@ -84,7 +75,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
},
'constraints' => [new Callback([
'callback' => static function ($selected, ExecutionContextInterface $context) {
if (count($selected) === 0) {
if (0 === \count($selected)) {
$context->buildViolation('You must select at least one element')
->atPath('fields')
->addViolation();
@@ -100,6 +91,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
'input' => 'datetime_immutable',
]);
}
public function getFormDefaultData(): array
{
$choices = array_combine(ListPersonHelper::FIELDS, ListPersonHelper::FIELDS);
@@ -110,7 +102,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
$cf->getSlug();
}
return ['fields' => array_values($choices), 'address_date' => new DateTimeImmutable()];
return ['fields' => array_values($choices), 'address_date' => new \DateTimeImmutable()];
}
public function getAllowedFormattersTypes()
@@ -130,7 +122,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
public function getLabels($key, array $values, $data)
{
if (in_array($key, $this->listPersonHelper->getAllPossibleFields(), true)) {
if (\in_array($key, $this->listPersonHelper->getAllPossibleFields(), true)) {
return $this->listPersonHelper->getLabels($key, $values, $data);
}
@@ -142,18 +134,18 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
$fields = [];
foreach (ListPersonHelper::FIELDS as $key) {
if (!in_array($key, $data['fields'], true)) {
if (!\in_array($key, $data['fields'], true)) {
continue;
}
if (str_starts_with($key, 'address_fields')) {
$fields = array_merge($fields, $this->addressHelper->getKeys(ExportAddressHelper::F_ALL, 'address_fields'));
$fields = \array_merge($fields, $this->addressHelper->getKeys(ExportAddressHelper::F_ALL, 'address_fields'));
continue;
}
if ('lifecycleUpdate' === $key) {
$fields = array_merge($fields, ['createdAt', 'createdBy', 'updatedAt', 'updatedBy']);
$fields = \array_merge($fields, ['createdAt', 'createdBy', 'updatedAt', 'updatedBy']);
continue;
}
@@ -162,7 +154,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
}
// add the key from slugs and return
return array_merge($fields, array_keys($this->slugs));
return \array_merge($fields, \array_keys($this->slugs));
}
public function getResult($query, $data)
@@ -188,9 +180,8 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
$centers = array_map(static fn ($el) => $el['center'], $acl);
// throw an error if any fields are present
if (!array_key_exists('fields', $data)) {
throw new \Doctrine\DBAL\Exception\InvalidArgumentException('any fields '
. 'have been checked');
if (!\array_key_exists('fields', $data)) {
throw new \Doctrine\DBAL\Exception\InvalidArgumentException('any fields have been checked');
}
$qb = $this->entityManager->createQueryBuilder();
@@ -199,7 +190,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
->from(Person::class, 'person')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM ' . Person\PersonCenterHistory::class . ' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
'SELECT 1 FROM '.Person\PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
)
)
->setParameter('authorized_centers', $centers);
@@ -209,7 +200,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
$this->listPersonHelper->addSelect($qb, $fields, $data['address_date']);
foreach ($this->getCustomFields() as $cf) {
if (!in_array($cf->getSlug(), $fields, true)) {
if (!\in_array($cf->getSlug(), $fields, true)) {
continue;
}
@@ -262,9 +253,9 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
);
// check if there is one field starting with address in data
if (count(array_intersect($data['fields'], $addressFields)) > 0) {
if (\count(array_intersect($data['fields'], $addressFields)) > 0) {
// if a field address is checked, the date must not be empty
if (!$data['address_date'] instanceof DateTimeImmutable) {
if (!$data['address_date'] instanceof \DateTimeImmutable) {
$context
->buildViolation('You must set this date if an address is checked')
->atPath('address_date')
@@ -295,12 +286,12 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
{
return $this->entityManager
->createQuery('SELECT cf '
. 'FROM ChillCustomFieldsBundle:CustomField cf '
. 'JOIN cf.customFieldGroup g '
. 'WHERE cf.type != :title AND g.entity LIKE :entity')
.'FROM ChillCustomFieldsBundle:CustomField cf '
.'JOIN cf.customFieldGroup g '
.'WHERE cf.type != :title AND g.entity LIKE :entity')
->setParameters([
'title' => 'title',
'entity' => addcslashes(Person::class, '\\'),
'entity' => \addcslashes(Person::class, '\\'),
])
->getResult();
}
@@ -340,7 +331,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
$label = $cfType->getChoices($cf)[$slugChoice];
return $this->translatableStringHelper->localize($cf->getName())
. ' | ' . $label;
.' | '.$label;
}
if ('_other' === $slugChoice && $cfType->isChecked($cf, $slugChoice, $decoded)) {
@@ -359,7 +350,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
*/
private function slugToDQL(string $slug, string $type = 'default', array $additionalInfos = []): string
{
$uid = 'slug_' . uniqid('', false);
$uid = 'slug_'.\uniqid('', false);
$this->slugs[$uid] = [
'slug' => $slug,

View File

@@ -54,8 +54,8 @@ class ListPersonDuplicate implements DirectExportInterface, ExportElementValidat
$routeParameters
) {
$this->entityManager = $em;
$this->baseUrl = $routeParameters['scheme'] .
'://' . $routeParameters['host'];
$this->baseUrl = $routeParameters['scheme'].
'://'.$routeParameters['host'];
}
public function buildForm(FormBuilderInterface $builder)
@@ -64,6 +64,7 @@ class ListPersonDuplicate implements DirectExportInterface, ExportElementValidat
'label' => 'Precision',
]);
}
public function getFormDefaultData(): array
{
return ['precision' => self::PRECISION_DEFAULT_VALUE];
@@ -81,11 +82,11 @@ class ListPersonDuplicate implements DirectExportInterface, ExportElementValidat
$row['id1'],
$row['firstname1'],
$row['lastname1'],
$this->baseUrl . $this->router->generate('chill_person_view', ['person_id' => $row['id1']]),
$this->baseUrl.$this->router->generate('chill_person_view', ['person_id' => $row['id1']]),
$row['id2'],
$row['firstname2'],
$row['lastname2'],
$this->baseUrl . $this->router->generate('chill_person_view', ['person_id' => $row['id2']]),
$this->baseUrl.$this->router->generate('chill_person_view', ['person_id' => $row['id2']]),
];
}
@@ -94,14 +95,14 @@ class ListPersonDuplicate implements DirectExportInterface, ExportElementValidat
// Make links clickable
for ($i = 1; $spreadsheet->getActiveSheet()->getHighestDataRow() >= $i; ++$i) {
$spreadsheet->getActiveSheet()->getCell('D' . $i)->getHyperlink()
->setUrl($spreadsheet->getActiveSheet()->getCell('D' . $i)->getValue());
$spreadsheet->getActiveSheet()->getCell('H' . $i)->getHyperlink()
->setUrl($spreadsheet->getActiveSheet()->getCell('H' . $i)->getValue());
$spreadsheet->getActiveSheet()->getCell('D'.$i)->getHyperlink()
->setUrl($spreadsheet->getActiveSheet()->getCell('D'.$i)->getValue());
$spreadsheet->getActiveSheet()->getCell('H'.$i)->getHyperlink()
->setUrl($spreadsheet->getActiveSheet()->getCell('H'.$i)->getValue());
}
$writer = new Xlsx($spreadsheet);
$temp_file = sys_get_temp_dir() . '/' . uniqid('export_') . '.xlsx';
$temp_file = sys_get_temp_dir().'/'.uniqid('export_').'.xlsx';
$writer->save($temp_file);
$response = new BinaryFileResponse($temp_file);

View File

@@ -31,10 +31,6 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function array_key_exists;
use function count;
use function in_array;
use function strlen;
/**
* List the persons, having an accompanying period.
@@ -64,7 +60,7 @@ class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterf
},
'constraints' => [new Callback([
'callback' => static function ($selected, ExecutionContextInterface $context) {
if (count($selected) === 0) {
if (0 === \count($selected)) {
$context->buildViolation('You must select at least one element')
->atPath('fields')
->addViolation();
@@ -79,11 +75,12 @@ class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterf
'input' => 'datetime_immutable',
]);
}
public function getFormDefaultData(): array
{
$choices = array_combine(ListPersonHelper::FIELDS, ListPersonHelper::FIELDS);
return ['fields' => array_values($choices), 'address_date' => new DateTimeImmutable()];
return ['fields' => array_values($choices), 'address_date' => new \DateTimeImmutable()];
}
public function getAllowedFormattersTypes()
@@ -111,7 +108,7 @@ class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterf
$fields = [];
foreach (ListPersonHelper::FIELDS as $key) {
if (!in_array($key, $data['fields'], true)) {
if (!\in_array($key, $data['fields'], true)) {
continue;
}
@@ -156,9 +153,8 @@ class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterf
$centers = array_map(static fn ($el) => $el['center'], $acl);
// throw an error if any fields are present
if (!array_key_exists('fields', $data)) {
throw new \Doctrine\DBAL\Exception\InvalidArgumentException('any fields '
. 'have been checked');
if (!\array_key_exists('fields', $data)) {
throw new \Doctrine\DBAL\Exception\InvalidArgumentException('any fields have been checked');
}
$qb = $this->entityManager->createQueryBuilder();
@@ -166,10 +162,10 @@ class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterf
$qb->from(Person::class, 'person')
->join('person.accompanyingPeriodParticipations', 'acppart')
->join('acppart.accompanyingPeriod', 'acp')
->andWhere($qb->expr()->neq('acp.step', "'" . AccompanyingPeriod::STEP_DRAFT . "'"))
->andWhere($qb->expr()->neq('acp.step', "'".AccompanyingPeriod::STEP_DRAFT."'"))
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM ' . PersonCenterHistory::class . ' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
)
)->setParameter('authorized_centers', $centers);
@@ -206,9 +202,9 @@ class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterf
);
// check if there is one field starting with address in data
if (count(array_intersect($data['fields'], $addressFields)) > 0) {
if (\count(array_intersect($data['fields'], $addressFields)) > 0) {
// if a field address is checked, the date must not be empty
if (!$data['address_date'] instanceof DateTimeImmutable) {
if (!$data['address_date'] instanceof \DateTimeImmutable) {
$context
->buildViolation('You must set this date if an address is checked')
->atPath('address_date')

View File

@@ -12,12 +12,9 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Export;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\ExportElementValidatedInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\MainBundle\Export\Helper\ExportAddressHelper;
use Chill\MainBundle\Export\ListInterface;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
@@ -31,18 +28,10 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter;
use DateTimeImmutable;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function array_key_exists;
use function count;
use function in_array;
use function strlen;
/**
* List the persons having an accompanying period, with the accompanying period details
*
* List the persons having an accompanying period, with the accompanying period details.
*/
final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInterface, GroupedExportInterface
{
@@ -60,6 +49,7 @@ final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInte
'help' => 'Data regarding center, addresses, and so on will be computed at this date',
]);
}
public function getFormDefaultData(): array
{
return ['address_date' => new RollingDate(RollingDate::T_TODAY)];
@@ -82,7 +72,7 @@ final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInte
public function getLabels($key, array $values, $data)
{
if (in_array($key, $this->listPersonHelper->getAllKeys(), true)) {
if (\in_array($key, $this->listPersonHelper->getAllKeys(), true)) {
return $this->listPersonHelper->getLabels($key, $values, $data);
}
@@ -124,10 +114,10 @@ final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInte
$qb->from(Person::class, 'person')
->join('person.accompanyingPeriodParticipations', 'acppart')
->join('acppart.accompanyingPeriod', 'acp')
->andWhere($qb->expr()->neq('acp.step', "'" . AccompanyingPeriod::STEP_DRAFT . "'"))
->andWhere($qb->expr()->neq('acp.step', "'".AccompanyingPeriod::STEP_DRAFT."'"))
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM ' . PersonCenterHistory::class . ' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
)
)->setParameter('authorized_centers', $centers);

View File

@@ -20,12 +20,10 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use DateTime;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportInterface
@@ -44,9 +42,10 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn
'label' => 'Closingdate to apply',
]);
}
public function getFormDefaultData(): array
{
return ['closingdate' => new DateTime('now')];
return ['closingdate' => new \DateTime('now')];
}
public function getAllowedFormattersTypes(): array
@@ -73,7 +72,7 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn
'count_acppart_export_result' => 'export.export.acp_stats.count_participations',
'count_acp_export_result' => 'export.export.acp_stats.count_acps',
'count_pers_export_result' => 'export.export.acp_stats.count_persons',
default => throw new LogicException('key not supported: ' . $key),
default => throw new \LogicException('key not supported: '.$key),
};
}
@@ -126,7 +125,7 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM ' . PersonCenterHistory::class . ' acl_count_person_history WHERE acl_count_person_history.person = person
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)

View File

@@ -64,6 +64,7 @@ class ActiveOnDateFilter implements FilterInterface
$builder
->add('on_date', PickRollingDateType::class, []);
}
public function getFormDefaultData(): array
{
return ['on_date' => new RollingDate(RollingDate::T_TODAY)];

View File

@@ -54,6 +54,7 @@ class ActiveOneDayBetweenDatesFilter implements FilterInterface
->add('date_from', PickRollingDateType::class, [])
->add('date_to', PickRollingDateType::class, []);
}
public function getFormDefaultData(): array
{
return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)];

View File

@@ -47,6 +47,7 @@ class AdministrativeLocationFilter implements FilterInterface
'multiple' => true,
]);
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -58,6 +58,7 @@ class ClosingMotiveFilter implements FilterInterface
'expanded' => true,
]);
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -64,6 +64,7 @@ class ConfidentialFilter implements FilterInterface
'empty_data' => self::DEFAULT_CHOICE,
]);
}
public function getFormDefaultData(): array
{
return ['accepted_confidentials' => self::DEFAULT_CHOICE];

View File

@@ -17,7 +17,6 @@ use Chill\MainBundle\Form\Type\PickUserDynamicType;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
class CreatorFilter implements FilterInterface
{
@@ -28,7 +27,7 @@ class CreatorFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acp_creator', $qb->getAllAliases(), true)) {
if (!\in_array('acp_creator', $qb->getAllAliases(), true)) {
$qb->join('acp.createdBy', 'acp_creator');
}
@@ -50,6 +49,7 @@ class CreatorFilter implements FilterInterface
'label' => false,
]);
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -42,16 +42,16 @@ class CreatorJobFilter implements FilterInterface
$qb
->join(
"acp.userHistories",
'acp.userHistories',
"{$p}_userHistory",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", "acp.id"),
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", 'acp.id'),
$qb->expr()->andX(
$qb->expr()->gte("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.startDate"),
$qb->expr()->gte('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_userHistory.endDate"),
$qb->expr()->lt("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.endDate")
$qb->expr()->lt('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.endDate")
)
)
)
@@ -74,7 +74,7 @@ class CreatorJobFilter implements FilterInterface
->andWhere($qb->expr()->in("{$p}_history.job", ":{$p}_jobs"))
->setParameter(
"{$p}_jobs",
$data["creator_job"],
$data['creator_job'],
);
}

View File

@@ -64,6 +64,7 @@ class EmergencyFilter implements FilterInterface
'empty_data' => self::DEFAULT_CHOICE,
]);
}
public function getFormDefaultData(): array
{
return ['accepted_emergency' => self::DEFAULT_CHOICE];

View File

@@ -19,7 +19,6 @@ use Chill\PersonBundle\Repository\SocialWork\EvaluationRepositoryInterface;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
class EvaluationFilter implements FilterInterface
{
@@ -32,15 +31,15 @@ class EvaluationFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acpw', $qb->getAllAliases(), true)) {
if (!\in_array('acpw', $qb->getAllAliases(), true)) {
$qb->join('acp.works', 'acpw');
}
if (!in_array('workeval', $qb->getAllAliases(), true)) {
if (!\in_array('workeval', $qb->getAllAliases(), true)) {
$qb->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval');
}
if (!in_array('eval', $qb->getAllAliases(), true)) {
if (!\in_array('eval', $qb->getAllAliases(), true)) {
$qb->join('workeval.evaluation', 'eval');
}
@@ -65,6 +64,7 @@ class EvaluationFilter implements FilterInterface
'attr' => ['class' => 'select2'],
]);
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -44,10 +44,10 @@ class GeographicalUnitStatFilter implements FilterInterface
$subQueryDql =
'SELECT
1
FROM ' . AccompanyingPeriod\AccompanyingPeriodLocationHistory::class . ' acp_geog_filter_location_history
LEFT JOIN ' . PersonHouseholdAddress::class . ' acp_geog_filter_address_person_location
FROM '.AccompanyingPeriod\AccompanyingPeriodLocationHistory::class.' acp_geog_filter_location_history
LEFT JOIN '.PersonHouseholdAddress::class.' acp_geog_filter_address_person_location
WITH IDENTITY(acp_geog_filter_location_history.personLocation) = IDENTITY(acp_geog_filter_address_person_location.person)
LEFT JOIN ' . Address::class . ' acp_geog_filter_address
LEFT JOIN '.Address::class.' acp_geog_filter_address
WITH COALESCE(IDENTITY(acp_geog_filter_address_person_location.address), IDENTITY(acp_geog_filter_location_history.addressLocation)) = acp_geog_filter_address.id
LEFT JOIN acp_geog_filter_address.geographicalUnits acp_geog_filter_units
WHERE
@@ -88,13 +88,14 @@ class GeographicalUnitStatFilter implements FilterInterface
'placeholder' => 'Select a geographical unit',
'choices' => $this->geographicalUnitRepository->findAll(),
'choice_value' => static fn (SimpleGeographicalUnitDTO $item) => $item->id,
'choice_label' => fn (SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName,
'choice_label' => fn (SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()).' > '.$item->unitName,
'attr' => [
'class' => 'select2',
],
'multiple' => true,
]);
}
public function getFormDefaultData(): array
{
return ['date_calc' => new RollingDate(RollingDate::T_TODAY)];
@@ -107,7 +108,7 @@ class GeographicalUnitStatFilter implements FilterInterface
'%units' => implode(
', ',
array_map(
fn (SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName,
fn (SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()).' > '.$item->unitName,
$data['units']
)
),

View File

@@ -26,7 +26,7 @@ class HasNoActionFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data): void
{
$qb->andWhere('NOT EXISTS (SELECT 1 FROM ' . AccompanyingPeriodWork::class . ' work WHERE work.accompanyingPeriod = acp)');
$qb->andWhere('NOT EXISTS (SELECT 1 FROM '.AccompanyingPeriodWork::class.' work WHERE work.accompanyingPeriod = acp)');
}
public function applyOn(): string
@@ -38,6 +38,7 @@ class HasNoActionFilter implements FilterInterface
{
// no form
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -34,7 +34,7 @@ class HasNoReferrerFilter implements FilterInterface
$qb
->andWhere('
NOT EXISTS (
SELECT 1 FROM ' . UserHistory::class . ' uh
SELECT 1 FROM '.UserHistory::class.' uh
WHERE uh.startDate <= :has_no_referrer_filter_date
AND (
uh.endDate IS NULL
@@ -61,6 +61,7 @@ class HasNoReferrerFilter implements FilterInterface
'label' => 'Has no referrer on this date',
]);
}
public function getFormDefaultData(): array
{
return ['calc_date' => new RollingDate(RollingDate::T_TODAY)];

View File

@@ -17,7 +17,6 @@ use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -44,7 +43,7 @@ class HasTemporaryLocationFilter implements FilterInterface
match ($data['having_temporarily']) {
true => $qb->andWhere('acp_having_temporarily_location.addressLocation IS NOT NULL'),
false => $qb->andWhere('acp_having_temporarily_location.personLocation IS NOT NULL'),
default => throw new LogicException('value not supported'),
default => throw new \LogicException('value not supported'),
};
}
@@ -65,13 +64,14 @@ class HasTemporaryLocationFilter implements FilterInterface
'choice_label' => static fn ($choice) => match ($choice) {
true => 'export.filter.course.having_temporarily.Having a temporarily location',
false => 'export.filter.course.having_temporarily.Having a person\'s location',
default => throw new LogicException('this choice is not supported'),
default => throw new \LogicException('this choice is not supported'),
},
])
->add('calc_date', PickRollingDateType::class, [
'label' => 'export.filter.course.having_temporarily.Calculation date',
]);
}
public function getFormDefaultData(): array
{
return ['calc_date' => new RollingDate(RollingDate::T_TODAY)];
@@ -82,7 +82,7 @@ class HasTemporaryLocationFilter implements FilterInterface
return match ($data['having_temporarily']) {
true => ['export.filter.course.having_temporarily.Having a temporarily location', []],
false => ['export.filter.course.having_temporarily.Having a person\'s location', []],
default => throw new LogicException('value not supported'),
default => throw new \LogicException('value not supported'),
};
}

View File

@@ -12,7 +12,6 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\DateIntervalType;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
@@ -24,7 +23,7 @@ use Symfony\Component\Form\FormBuilderInterface;
/**
* Filter accompanying course which have a row in AccompanyingPeriodInfo within the given
* interval
* interval.
*/
final readonly class HavingAnAccompanyingPeriodInfoWithinDatesFilter implements FilterInterface
{
@@ -42,6 +41,7 @@ final readonly class HavingAnAccompanyingPeriodInfoWithinDatesFilter implements
'label' => 'export.filter.course.having_info_within_interval.end_date',
]);
}
public function getFormDefaultData(): array
{
return ['start_date' => new RollingDate(RollingDate::T_TODAY), 'end_date' => new RollingDate(RollingDate::T_TODAY)];
@@ -59,7 +59,7 @@ final readonly class HavingAnAccompanyingPeriodInfoWithinDatesFilter implements
[
'%startDate%' => $this->rollingDateConverter->convert($data['start_date'])->format('d-m-Y'),
'%endDate%' => $this->rollingDateConverter->convert($data['end_date'])->format('d-m-Y'),
]
],
];
}
@@ -77,7 +77,7 @@ final readonly class HavingAnAccompanyingPeriodInfoWithinDatesFilter implements
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM ' . AccompanyingPeriodInfo::class . " {$ai} WHERE {$ai}.infoDate BETWEEN :{$as} AND :{$ae} AND IDENTITY({$ai}.accompanyingPeriod) = acp.id"
'SELECT 1 FROM '.AccompanyingPeriodInfo::class." {$ai} WHERE {$ai}.infoDate BETWEEN :{$as} AND :{$ae} AND IDENTITY({$ai}.accompanyingPeriod) = acp.id"
)
)
->setParameter($as, $this->rollingDateConverter->convert($data['start_date']), Types::DATETIME_IMMUTABLE)

View File

@@ -64,6 +64,7 @@ class IntensityFilter implements FilterInterface
'empty_data' => self::DEFAULT_CHOICE,
]);
}
public function getFormDefaultData(): array
{
return ['accepted_intensities' => self::DEFAULT_CHOICE];

View File

@@ -26,7 +26,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
/**
* Filter course where a user with the given job is "working" on it
* Filter course where a user with the given job is "working" on it.
*
* Makes use of AccompanyingPeriodInfo
*/
@@ -52,15 +52,15 @@ readonly class JobWorkingOnCourseFilter implements FilterInterface
$qb
->andWhere(
$qb->expr()->exists(
"SELECT 1 FROM " . AccompanyingPeriodInfo::class . " {$p}_info "
. "JOIN {$p}_info.user {$p}_user "
. "JOIN " . UserJobHistory::class . " {$p}_history WITH {$p}_history.user = {$p}_user "
. "WHERE IDENTITY({$p}_info.accompanyingPeriod) = acp.id "
. "AND {$p}_history.job IN (:{$p}_jobs) "
'SELECT 1 FROM '.AccompanyingPeriodInfo::class." {$p}_info "
."JOIN {$p}_info.user {$p}_user "
.'JOIN '.UserJobHistory::class." {$p}_history WITH {$p}_history.user = {$p}_user "
."WHERE IDENTITY({$p}_info.accompanyingPeriod) = acp.id "
."AND {$p}_history.job IN (:{$p}_jobs) "
// job_at based on _info.infoDate
. "AND {$p}_history.startDate <= {$p}_info.infoDate "
. "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > {$p}_info.infoDate) "
. "AND {$p}_info.infoDate >= :{$p}_start and {$p}_info.infoDate < :{$p}_end"
."AND {$p}_history.startDate <= {$p}_info.infoDate "
."AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > {$p}_info.infoDate) "
."AND {$p}_info.infoDate >= :{$p}_start and {$p}_info.infoDate < :{$p}_end"
)
)
->setParameter("{$p}_jobs", $data['jobs'])
@@ -94,16 +94,16 @@ readonly class JobWorkingOnCourseFilter implements FilterInterface
'expanded' => true,
])
->add('start_date', PickRollingDateType::class, [
'label' => 'export.filter.course.by_job_working.Job working after'
'label' => 'export.filter.course.by_job_working.Job working after',
])
->add('end_date', PickRollingDateType::class, [
'label' => 'export.filter.course.by_job_working.Job working before'
'label' => 'export.filter.course.by_job_working.Job working before',
])
//->add('job_at', PickRollingDateType::class, [
// ->add('job_at', PickRollingDateType::class, [
// 'label' => 'bla',
// 'help' => 'bli',
// 'required' => false,
//])
// ])
;
}
@@ -130,7 +130,7 @@ readonly class JobWorkingOnCourseFilter implements FilterInterface
'jobs' => [],
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
'end_date' => new RollingDate(RollingDate::T_TODAY),
//'job_at' => null,
// 'job_at' => null,
];
}

View File

@@ -52,6 +52,7 @@ class OpenBetweenDatesFilter implements FilterInterface
->add('date_from', PickRollingDateType::class, [])
->add('date_to', PickRollingDateType::class, []);
}
public function getFormDefaultData(): array
{
return ['date_from' => new RollingDate(RollingDate::T_MONTH_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)];

View File

@@ -58,6 +58,7 @@ class OriginFilter implements FilterInterface
'expanded' => true,
]);
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -16,7 +16,6 @@ use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Form\Type\PickUserDynamicType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Templating\Entity\UserRender;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
@@ -42,15 +41,15 @@ class ReferrerFilter implements FilterInterface
->join('acp.userHistories', self::A)
->andWhere(
$qb->expr()->andX(
$qb->expr()->lte(self::A . '.startDate', ':' . self::P),
$qb->expr()->lte(self::A.'.startDate', ':'.self::P),
$qb->expr()->orX(
$qb->expr()->isNull(self::A . '.endDate'),
$qb->expr()->gt(self::A . '.endDate', ':' . self::P)
$qb->expr()->isNull(self::A.'.endDate'),
$qb->expr()->gt(self::A.'.endDate', ':'.self::P)
)
)
)
->andWhere(
$qb->expr()->in(self::A . '.user', ':' . self::PU)
$qb->expr()->in(self::A.'.user', ':'.self::PU)
)
->setParameter(self::PU, $data['accepted_referrers'])
->setParameter(
@@ -75,6 +74,7 @@ class ReferrerFilter implements FilterInterface
'required' => true,
]);
}
public function getFormDefaultData(): array
{
return ['date_calc' => new RollingDate(RollingDate::T_TODAY), 'accepted_referrers' => []];

View File

@@ -16,11 +16,9 @@ use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\Expr\Andx;
use Doctrine\ORM\QueryBuilder;
use Exception;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function in_array;
final readonly class RequestorFilter implements FilterInterface
{
@@ -46,7 +44,7 @@ final readonly class RequestorFilter implements FilterInterface
switch ($data['accepted_choices']) {
case 'participation':
if (!in_array('acppart', $qb->getAllAliases(), true)) {
if (!\in_array('acppart', $qb->getAllAliases(), true)) {
$qb->join('acp.participations', 'acppart');
}
@@ -92,7 +90,7 @@ final readonly class RequestorFilter implements FilterInterface
break;
default:
throw new Exception('Uncaught choice exception');
throw new \Exception('Uncaught choice exception');
}
if ($where instanceof Andx) {
@@ -118,6 +116,7 @@ final readonly class RequestorFilter implements FilterInterface
'empty_data' => self::DEFAULT_CHOICE,
]);
}
public function getFormDefaultData(): array
{
return ['accepted_choices' => self::DEFAULT_CHOICE];

View File

@@ -26,7 +26,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
/**
* Filter course where a user with the given scope is "working" on it
* Filter course where a user with the given scope is "working" on it.
*
* Makes use of AccompanyingPeriodInfo
*/
@@ -52,25 +52,25 @@ readonly class ScopeWorkingOnCourseFilter implements FilterInterface
$qb
->andWhere(
$qb->expr()->exists(
"SELECT 1 FROM " . AccompanyingPeriodInfo::class . " {$p}_info "
. "JOIN {$p}_info.user {$p}_user "
. "JOIN " . UserScopeHistory::class . " {$p}_history WITH {$p}_history.user = {$p}_user "
. "WHERE IDENTITY({$p}_info.accompanyingPeriod) = acp.id "
. "AND {$p}_history.scope IN ( :{$p}_scopes ) "
'SELECT 1 FROM '.AccompanyingPeriodInfo::class." {$p}_info "
."JOIN {$p}_info.user {$p}_user "
.'JOIN '.UserScopeHistory::class." {$p}_history WITH {$p}_history.user = {$p}_user "
."WHERE IDENTITY({$p}_info.accompanyingPeriod) = acp.id "
."AND {$p}_history.scope IN ( :{$p}_scopes ) "
// scope_at based on _info.infoDate
. "AND {$p}_history.startDate <= {$p}_info.infoDate "
. "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > {$p}_info.infoDate) "
. "AND {$p}_info.infoDate >= :{$p}_start AND {$p}_info.infoDate < :{$p}_end"
."AND {$p}_history.startDate <= {$p}_info.infoDate "
."AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > {$p}_info.infoDate) "
."AND {$p}_info.infoDate >= :{$p}_start AND {$p}_info.infoDate < :{$p}_end"
)
)
->setParameter("{$p}_scopes", $data["scopes"])
->setParameter("{$p}_scopes", $data['scopes'])
->setParameter(
"{$p}_start",
$this->rollingDateConverter->convert($data["start_date"]),
$this->rollingDateConverter->convert($data['start_date']),
)
->setParameter(
"{$p}_end",
$this->rollingDateConverter->convert($data["end_date"])
$this->rollingDateConverter->convert($data['end_date'])
)
;
}
@@ -94,10 +94,10 @@ readonly class ScopeWorkingOnCourseFilter implements FilterInterface
'expanded' => true,
])
->add('start_date', PickRollingDateType::class, [
'label' => 'export.filter.course.by_scope_working.Scope working after'
'label' => 'export.filter.course.by_scope_working.Scope working after',
])
->add('end_date', PickRollingDateType::class, [
'label' => 'export.filter.course.by_scope_working.Scope working before'
'label' => 'export.filter.course.by_scope_working.Scope working before',
])
;
}

View File

@@ -19,7 +19,6 @@ use Chill\PersonBundle\Form\Type\PickSocialActionType;
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
final readonly class SocialActionFilter implements FilterInterface
{
@@ -35,8 +34,8 @@ final readonly class SocialActionFilter implements FilterInterface
$qb->andWhere(
$qb->expr()->exists(
sprintf(
"SELECT 1 FROM %s acp_by_social_action_filter WHERE acp_by_social_action_filter.socialAction "
. "IN (:acp_by_social_action_filter_actions) AND acp_by_social_action_filter.accompanyingPeriod = acp",
'SELECT 1 FROM %s acp_by_social_action_filter WHERE acp_by_social_action_filter.socialAction '
.'IN (:acp_by_social_action_filter_actions) AND acp_by_social_action_filter.accompanyingPeriod = acp',
AccompanyingPeriod\AccompanyingPeriodWork::class
)
)
@@ -56,6 +55,7 @@ final readonly class SocialActionFilter implements FilterInterface
'multiple' => true,
]);
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -19,7 +19,6 @@ use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function in_array;
class SocialIssueFilter implements FilterInterface
{
@@ -42,7 +41,7 @@ class SocialIssueFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acpsocialissue', $qb->getAllAliases(), true)) {
if (!\in_array('acpsocialissue', $qb->getAllAliases(), true)) {
$qb->join('acp.socialIssues', 'acpsocialissue');
}
@@ -66,6 +65,7 @@ class SocialIssueFilter implements FilterInterface
'multiple' => true,
]);
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -21,7 +21,6 @@ use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function in_array;
class StepFilterBetweenDates implements FilterInterface
{
@@ -56,8 +55,8 @@ class StepFilterBetweenDates implements FilterInterface
$qb
->andWhere(
$qb->expr()->exists(
"SELECT 1 FROM " . AccompanyingPeriod\AccompanyingPeriodStepHistory::class . " {$alias} " .
"WHERE {$alias}.step IN (:{$steps}) AND OVERLAPSI ({$alias}.startDate, {$alias}.endDate),(:{$from}, :{$to}) = TRUE " .
'SELECT 1 FROM '.AccompanyingPeriod\AccompanyingPeriodStepHistory::class." {$alias} ".
"WHERE {$alias}.step IN (:{$steps}) AND OVERLAPSI ({$alias}.startDate, {$alias}.endDate),(:{$from}, :{$to}) = TRUE ".
"AND {$alias}.period = acp"
)
)

View File

@@ -21,7 +21,6 @@ use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function in_array;
class StepFilterOnDate implements FilterInterface
{
@@ -52,22 +51,22 @@ class StepFilterOnDate implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array(self::A, $qb->getAllAliases(), true)) {
if (!\in_array(self::A, $qb->getAllAliases(), true)) {
$qb->leftJoin('acp.stepHistories', self::A);
}
$qb
->andWhere(
$qb->expr()->andX(
$qb->expr()->lte(self::A . '.startDate', ':' . self::P),
$qb->expr()->lte(self::A.'.startDate', ':'.self::P),
$qb->expr()->orX(
$qb->expr()->isNull(self::A . '.endDate'),
$qb->expr()->lt(self::A . '.endDate', ':' . self::P)
$qb->expr()->isNull(self::A.'.endDate'),
$qb->expr()->lt(self::A.'.endDate', ':'.self::P)
)
)
)
->andWhere(
$qb->expr()->in(self::A . '.step', ':acp_filter_by_step_steps')
$qb->expr()->in(self::A.'.step', ':acp_filter_by_step_steps')
)
->setParameter(self::P, $this->rollingDateConverter->convert($data['calc_date']))
->setParameter('acp_filter_by_step_steps', $data['accepted_steps_multi']);

View File

@@ -42,16 +42,16 @@ class UserJobFilter implements FilterInterface
$qb
->leftJoin(
"acp.userHistories",
'acp.userHistories',
"{$p}_userHistory",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", "acp.id"),
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", 'acp.id'),
$qb->expr()->andX(
$qb->expr()->gte("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.startDate"),
$qb->expr()->gte('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_userHistory.endDate"),
$qb->expr()->lt("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.endDate")
$qb->expr()->lt('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.endDate")
)
)
)
@@ -65,7 +65,7 @@ class UserJobFilter implements FilterInterface
$qb->expr()->andX(
$qb->expr()->lte("{$p}_jobHistory.startDate", "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_jobHistory" . ".endDate"),
$qb->expr()->isNull("{$p}_jobHistory".'.endDate'),
$qb->expr()->gt("{$p}_jobHistory.endDate", "{$p}_userHistory.startDate")
)
)
@@ -74,7 +74,7 @@ class UserJobFilter implements FilterInterface
->andWhere($qb->expr()->in("{$p}_jobHistory.job", ":{$p}_job"))
->setParameter(
"{$p}_job",
$data["jobs"],
$data['jobs'],
)
;
}

View File

@@ -42,16 +42,16 @@ class UserScopeFilter implements FilterInterface
$qb
->join(
"acp.userHistories",
'acp.userHistories',
"{$p}_userHistory",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", "acp.id"),
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", 'acp.id'),
$qb->expr()->andX(
$qb->expr()->gte("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.startDate"),
$qb->expr()->gte('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_userHistory.endDate"),
$qb->expr()->lt("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.endDate")
$qb->expr()->lt('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.endDate")
)
)
)
@@ -74,7 +74,7 @@ class UserScopeFilter implements FilterInterface
->andWhere($qb->expr()->in("{$p}_scopeHistory.scope", ":{$p}_scopes"))
->setParameter(
"{$p}_scopes",
$data["scopes"],
$data['scopes'],
)
;
}

View File

@@ -24,7 +24,7 @@ use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
/**
* Filter course where a user is "working" on it
* Filter course where a user is "working" on it.
*
* Makes use of AccompanyingPeriodInfo
*/
@@ -42,10 +42,10 @@ readonly class UserWorkingOnCourseFilter implements FilterInterface
'multiple' => true,
])
->add('start_date', PickRollingDateType::class, [
'label' => 'export.filter.course.by_user_working.User working after'
'label' => 'export.filter.course.by_user_working.User working after',
])
->add('end_date', PickRollingDateType::class, [
'label' => 'export.filter.course.by_user_working.User working before'
'label' => 'export.filter.course.by_user_working.User working before',
])
;
}
@@ -96,7 +96,7 @@ readonly class UserWorkingOnCourseFilter implements FilterInterface
$qb
->andWhere(
$qb->expr()->exists(
"SELECT 1 FROM " . AccompanyingPeriod\AccompanyingPeriodInfo::class . " {$ai_alias} " .
'SELECT 1 FROM '.AccompanyingPeriod\AccompanyingPeriodInfo::class." {$ai_alias} ".
"WHERE {$ai_alias}.user IN (:{$ai_users}) AND IDENTITY({$ai_alias}.accompanyingPeriod) = acp.id AND {$ai_alias}.infoDate >= :{$start} and {$ai_alias}.infoDate < :{$end}"
)
)

View File

@@ -57,6 +57,7 @@ class ByEndDateFilter implements FilterInterface
'label' => 'end period date',
]);
}
public function getFormDefaultData(): array
{
return ['start_date' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)];

View File

@@ -57,6 +57,7 @@ class ByStartDateFilter implements FilterInterface
'label' => 'end period date',
]);
}
public function getFormDefaultData(): array
{
return ['start_date' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)];

View File

@@ -35,8 +35,9 @@ class CurrentEvaluationsFilter implements FilterInterface
public function buildForm(FormBuilderInterface $builder): void
{
//no form needed
// no form needed
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -58,6 +58,7 @@ final readonly class EvaluationTypeFilter implements FilterInterface
'expanded' => true,
]);
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -56,6 +56,7 @@ class MaxDateFilter implements FilterInterface
'expanded' => true,
]);
}
public function getFormDefaultData(): array
{
return [];

View File

@@ -77,6 +77,7 @@ readonly class CompositionFilter implements FilterInterface
])
->add('on_date', PickRollingDateType::class, []);
}
public function getFormDefaultData(): array
{
return ['on_date' => new RollingDate(RollingDate::T_TODAY)];

View File

@@ -15,7 +15,6 @@ use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
@@ -35,7 +34,7 @@ class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface
{
$subQuery =
'SELECT 1
FROM ' . PersonHouseholdAddress::class . ' person_filter_having_address_to_review_person_household_address
FROM '.PersonHouseholdAddress::class.' person_filter_having_address_to_review_person_household_address
JOIN person_filter_having_address_to_review_person_household_address.address person_filter_having_address_to_review_address
WHERE
person_filter_having_address_to_review_person_household_address.validFrom <= :person_filter_having_address_to_review_date
@@ -75,9 +74,10 @@ class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface
'choices' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW, Address::ADDR_REFERENCE_STATUS_REVIEWED, Address::ADDR_REFERENCE_STATUS_MATCH],
'choice_label' => fn (string $item) => 'export.filter.person.by_address_ref_status.'.$item,
'multiple' => true,
'expanded' => true
'expanded' => true,
]);
}
public function getFormDefaultData(): array
{
return ['date_calc' => new RollingDate(RollingDate::T_TODAY), 'ref_statuses' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW]];

View File

@@ -17,7 +17,6 @@ use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\PersonBundle\Export\Declarations;
use DateInterval;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
@@ -41,8 +40,8 @@ class AgeFilter implements ExportElementValidatedInterface, FilterInterface
$max = $data['max_age'] ?? 150;
$calc = $this->rollingDateConverter->convert($data['date_calc']);
$minDate = $calc->sub(new DateInterval('P' . $max . 'Y'));
$maxDate = $calc->sub(new DateInterval('P' . $min . 'Y'));
$minDate = $calc->sub(new \DateInterval('P'.$max.'Y'));
$maxDate = $calc->sub(new \DateInterval('P'.$min.'Y'));
$clause = $qb->expr()->andX(
$qb->expr()->gte(
@@ -99,7 +98,7 @@ class AgeFilter implements ExportElementValidatedInterface, FilterInterface
public function describeAction($data, $format = 'string')
{
return ['Filtered by person\'s age: '
. 'between %min_age% and %max_age%', [
.'between %min_age% and %max_age%', [
'%min_age%' => $data['min_age'],
'%max_age%' => $data['max_age'],
], ];

View File

@@ -72,6 +72,7 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac
'label' => 'Born before this date',
]);
}
public function getFormDefaultData(): array
{
return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)];
@@ -80,7 +81,7 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac
public function describeAction($data, $format = 'string')
{
return ['Filtered by person\'s birthdate: '
. 'between %date_from% and %date_to%', [
.'between %date_from% and %date_to%', [
'%date_from%' => $this->rollingDateConverter->convert($data['date_from'])->format('d-m-Y'),
'%date_to%' => $this->rollingDateConverter->convert($data['date_to'])->format('d-m-Y'),
], ];
@@ -98,13 +99,13 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac
if (null === $date_from) {
$context->buildViolation('The "date from" should not be empty')
//->atPath('date_from')
// ->atPath('date_from')
->addViolation();
}
if (null === $date_to) {
$context->buildViolation('The "date to" should not be empty')
//->atPath('date_to')
// ->atPath('date_to')
->addViolation();
}
@@ -113,7 +114,7 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac
&& $date_from >= $date_to
) {
$context->buildViolation('The date "date to" should be after the '
. 'date given in "date from" field')
.'date given in "date from" field')
->addViolation();
}
}

View File

@@ -42,11 +42,11 @@ class ByHouseholdCompositionFilter implements FilterInterface
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM ' . HouseholdMember::class . " {$p}_hm " .
'JOIN ' . HouseholdComposition::class . " {$p}_compo WITH {$p}_hm.household = {$p}_compo.household " .
"WHERE {$p}_hm.person = person AND {$p}_hm.shareHousehold = 'TRUE' " .
"AND ({$p}_hm.startDate <= :{$p}_date AND ({$p}_hm.endDate IS NULL OR {$p}_hm.endDate > :{$p}_date)) " .
"AND ({$p}_compo.startDate <= :{$p}_date AND ({$p}_compo.endDate IS NULL OR {$p}_compo.endDate > :{$p}_date)) " .
'SELECT 1 FROM '.HouseholdMember::class." {$p}_hm ".
'JOIN '.HouseholdComposition::class." {$p}_compo WITH {$p}_hm.household = {$p}_compo.household ".
"WHERE {$p}_hm.person = person AND {$p}_hm.shareHousehold = 'TRUE' ".
"AND ({$p}_hm.startDate <= :{$p}_date AND ({$p}_hm.endDate IS NULL OR {$p}_hm.endDate > :{$p}_date)) ".
"AND ({$p}_compo.startDate <= :{$p}_date AND ({$p}_compo.endDate IS NULL OR {$p}_compo.endDate > :{$p}_date)) ".
"AND {$p}_compo.householdCompositionType IN (:{$p}_accepted)"
)
)
@@ -74,6 +74,7 @@ class ByHouseholdCompositionFilter implements FilterInterface
'label' => 'export.filter.person.by_composition.Date calc',
]);
}
public function getFormDefaultData(): array
{
return ['calc_date' => new RollingDate(RollingDate::T_TODAY)];

Some files were not shown because too many files have changed in this diff Show More