mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
exports: add activity linked_to_acp new filters
This commit is contained in:
parent
9af620ece5
commit
248d56e598
@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\ActivityBundle\Export\Declarations;
|
||||||
|
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||||
|
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
||||||
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
class BySocialActionFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
private SocialActionRender $actionRender;
|
||||||
|
|
||||||
|
public function __construct(SocialActionRender $actionRender)
|
||||||
|
{
|
||||||
|
$this->actionRender = $actionRender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('accepted_socialactions', EntityType::class, [
|
||||||
|
'class' => SocialAction::class,
|
||||||
|
'choice_label' => function (SocialAction $sa) {
|
||||||
|
return $this->actionRender->renderString($sa, []);
|
||||||
|
},
|
||||||
|
'multiple' => true,
|
||||||
|
'expanded' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'Filter activity by linked socialaction';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function describeAction($data, $format = 'string'): array
|
||||||
|
{
|
||||||
|
$actions = [];
|
||||||
|
|
||||||
|
foreach ($data['accepted_socialactions'] as $sa) {
|
||||||
|
$actions[] = $this->actionRender->renderString($sa, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['Filtered activity by linked socialaction: only %actions%', [
|
||||||
|
'%actions%' => implode(", ou", $actions)
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$where = $qb->getDQLPart('where');
|
||||||
|
|
||||||
|
$clause = $qb->expr()->in('activity.socialActions', ':socialactions');
|
||||||
|
|
||||||
|
if ($where instanceof Andx) {
|
||||||
|
$where->add($clause);
|
||||||
|
} else {
|
||||||
|
$where = $qb->expr()->andX($clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->add('where', $where);
|
||||||
|
$qb->setParameter('socialactions', $data['accepted_socialactions']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::ACTIVITY_ACP;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\ActivityBundle\Export\Declarations;
|
||||||
|
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||||
|
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
||||||
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
class BySocialIssueFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
private SocialIssueRender $issueRender;
|
||||||
|
|
||||||
|
public function __construct(SocialIssueRender $issueRender)
|
||||||
|
{
|
||||||
|
$this->issueRender = $issueRender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('accepted_socialissues', EntityType::class, [
|
||||||
|
'class' => SocialIssue::class,
|
||||||
|
'choice_label' => function(SocialIssue $si) {
|
||||||
|
return $this->issueRender->renderString($si, []);
|
||||||
|
},
|
||||||
|
'multiple' => true,
|
||||||
|
'expanded' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'Filter activity by linked socialissue';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function describeAction($data, $format = 'string'): array
|
||||||
|
{
|
||||||
|
$issues = [];
|
||||||
|
|
||||||
|
foreach ($data['accepted_socialissues'] as $si) {
|
||||||
|
$issues[] = $this->issueRender->renderString($si, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['Filtered activity by linked socialissue: only %issues%', [
|
||||||
|
'%issues%' => implode(", ou", $issues)
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$where = $qb->getDQLPart('where');
|
||||||
|
|
||||||
|
$clause = $qb->expr()->in('activity.socialIssues', ':socialissues');
|
||||||
|
|
||||||
|
if ($where instanceof Andx) {
|
||||||
|
$where->add($clause);
|
||||||
|
} else {
|
||||||
|
$where = $qb->expr()->andX($clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->add('where', $where);
|
||||||
|
$qb->setParameter('socialissues', $data['accepted_socialissues']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::ACTIVITY_ACP;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\ActivityBundle\Export\Declarations;
|
||||||
|
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||||
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
class ByUserFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
private UserRender $userRender;
|
||||||
|
|
||||||
|
public function __construct(UserRender $userRender)
|
||||||
|
{
|
||||||
|
$this->userRender = $userRender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('accepted_users', EntityType::class, [
|
||||||
|
'class' => User::class,
|
||||||
|
'choice_label' => function (User $u) {
|
||||||
|
return $this->userRender->renderString($u, []);
|
||||||
|
},
|
||||||
|
'multiple' => true,
|
||||||
|
'expanded' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'Filter activity by linked users';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function describeAction($data, $format = 'string'): array
|
||||||
|
{
|
||||||
|
$users = [];
|
||||||
|
|
||||||
|
foreach ($data['accepted_users'] as $u) {
|
||||||
|
$users[] = $this->userRender->renderString($u, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['Filtered activity by linked users: only %users%', [
|
||||||
|
'%users%' => implode(", ou", $users)
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$where = $qb->getDQLPart('where');
|
||||||
|
|
||||||
|
$clause = $qb->expr()->in('activity.users', ':users');
|
||||||
|
|
||||||
|
if ($where instanceof Andx) {
|
||||||
|
$where->add($clause);
|
||||||
|
} else {
|
||||||
|
$where = $qb->expr()->andX($clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->add('where', $where);
|
||||||
|
$qb->setParameter('users', $data['accepted_users']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::ACTIVITY_ACP;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\ActivityBundle\Export\Declarations;
|
||||||
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
|
class EmergencyFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
private const CHOICES = [
|
||||||
|
'activity is emergency' => true,
|
||||||
|
'activity is not emergency' => false,
|
||||||
|
];
|
||||||
|
|
||||||
|
private CONST DEFAULT_CHOICE = false;
|
||||||
|
|
||||||
|
private TranslatorInterface $translator;
|
||||||
|
|
||||||
|
public function __construct(TranslatorInterface $translator)
|
||||||
|
{
|
||||||
|
$this->translator = $translator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('accepted_emergency', ChoiceType::class, [
|
||||||
|
'choices' => self::CHOICES,
|
||||||
|
'multiple' => false,
|
||||||
|
'expanded' => true,
|
||||||
|
'empty_data' => self::DEFAULT_CHOICE,
|
||||||
|
'data' => self::DEFAULT_CHOICE,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'Filter activity by emergency';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function describeAction($data, $format = 'string'): array
|
||||||
|
{
|
||||||
|
foreach (self::CHOICES as $k => $v) {
|
||||||
|
if ($v === $data['accepted_emergency']) {
|
||||||
|
$choice = $k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['Filtered activity by emergency: only %emergency%', [
|
||||||
|
'%emergency%' => $this->translator->trans($choice)
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$where = $qb->getDQLPart('where');
|
||||||
|
|
||||||
|
$clause = $qb->expr()->eq('activity.emergency', ':emergency');
|
||||||
|
|
||||||
|
if ($where instanceof Andx) {
|
||||||
|
$where->add($clause);
|
||||||
|
} else {
|
||||||
|
$where = $qb->expr()->andX($clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->add('where', $where);
|
||||||
|
$qb->setParameter('emergency', $data['accepted_emergency']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::ACTIVITY_ACP;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\LocationType;
|
||||||
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\ActivityBundle\Export\Declarations;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
class LocationTypeFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
private TranslatableStringHelper $translatableStringHelper;
|
||||||
|
|
||||||
|
public function __construct(TranslatableStringHelper $translatableStringHelper)
|
||||||
|
{
|
||||||
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('accepted_locationtype', EntityType::class, [
|
||||||
|
'class' => LocationType::class,
|
||||||
|
'choice_label' => function(LocationType $type) {
|
||||||
|
return $this->translatableStringHelper->localize($type->getTitle());
|
||||||
|
},
|
||||||
|
'multiple' => true,
|
||||||
|
'expanded' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'Filter activity by locationtype';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function describeAction($data, $format = 'string'): array
|
||||||
|
{
|
||||||
|
$types = [];
|
||||||
|
|
||||||
|
foreach ($data['accepted_locationtype'] as $type) {
|
||||||
|
$types[] = $this->translatableStringHelper->localize(
|
||||||
|
$type->getTitle()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['Filtered activity by locationtype: only %types%', [
|
||||||
|
'%types%' => implode(", ou", $types)
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
if (!in_array('location', $qb->getAllAliases())) {
|
||||||
|
$qb->join('activity.location', 'location');
|
||||||
|
}
|
||||||
|
|
||||||
|
$where = $qb->getDQLPart('where');
|
||||||
|
$clause = $qb->expr()->in('location.locationType', ':locationtype');
|
||||||
|
|
||||||
|
if ($where instanceof Andx) {
|
||||||
|
$where->add($clause);
|
||||||
|
} else {
|
||||||
|
$where = $qb->expr()->andX($clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->add('where', $where);
|
||||||
|
$qb->setParameter('locationtype', $data['accepted_locationtype']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::ACTIVITY_ACP;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\ActivityBundle\Export\Declarations;
|
||||||
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
|
class SentReceivedFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
private const CHOICES = [
|
||||||
|
'is sent' => Activity::SENTRECEIVED_SENT,
|
||||||
|
'is received' => Activity::SENTRECEIVED_RECEIVED,
|
||||||
|
];
|
||||||
|
|
||||||
|
private CONST DEFAULT_CHOICE = Activity::SENTRECEIVED_SENT;
|
||||||
|
|
||||||
|
private TranslatorInterface $translator;
|
||||||
|
|
||||||
|
public function __construct(TranslatorInterface $translator)
|
||||||
|
{
|
||||||
|
$this->translator = $translator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('accepted_sentreceived', ChoiceType::class, [
|
||||||
|
'choices' => self::CHOICES,
|
||||||
|
'multiple' => false,
|
||||||
|
'expanded' => true,
|
||||||
|
'empty_data' => self::DEFAULT_CHOICE,
|
||||||
|
'data' => self::DEFAULT_CHOICE,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'Filter activity by sentreceived';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function describeAction($data, $format = 'string'): array
|
||||||
|
{
|
||||||
|
$sentreceived = array_flip(self::CHOICES)[$data['accepted_sentreceived']];
|
||||||
|
|
||||||
|
return ['Filtered activity by sentreceived: only %sentreceived%', [
|
||||||
|
'%sentreceived%' => $this->translator->trans($sentreceived)
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$where = $qb->getDQLPart('where');
|
||||||
|
|
||||||
|
$clause = $qb->expr()->eq('activity.sentReceived', ':sentreceived');
|
||||||
|
|
||||||
|
if ($where instanceof Andx) {
|
||||||
|
$where->add($clause);
|
||||||
|
} else {
|
||||||
|
$where = $qb->expr()->andX($clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->add('where', $where);
|
||||||
|
$qb->setParameter('sentreceived', $data['accepted_sentreceived']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::ACTIVITY_ACP;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\ActivityBundle\Export\Declarations;
|
||||||
|
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||||
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
class UserFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
private UserRender $userRender;
|
||||||
|
|
||||||
|
public function __construct(UserRender $userRender)
|
||||||
|
{
|
||||||
|
$this->userRender = $userRender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('accepted_users', EntityType::class, [
|
||||||
|
'class' => User::class,
|
||||||
|
'choice_label' => function (User $u) {
|
||||||
|
return $this->userRender->renderString($u, []);
|
||||||
|
},
|
||||||
|
'multiple' => true,
|
||||||
|
'expanded' => true,
|
||||||
|
'label' => 'Creators'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'Filter activity by user';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function describeAction($data, $format = 'string'): array
|
||||||
|
{
|
||||||
|
$users = [];
|
||||||
|
|
||||||
|
foreach ($data['accepted_users'] as $u) {
|
||||||
|
$users[] = $this->userRender->renderString($u, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['Filtered activity by user: only %users%', [
|
||||||
|
'%users%' => implode(", ou", $users)
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$where = $qb->getDQLPart('where');
|
||||||
|
|
||||||
|
$clause = $qb->expr()->in('activity.user', ':users');
|
||||||
|
|
||||||
|
if ($where instanceof Andx) {
|
||||||
|
$where->add($clause);
|
||||||
|
} else {
|
||||||
|
$where = $qb->expr()->andX($clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->add('where', $where);
|
||||||
|
$qb->setParameter('users', $data['accepted_users']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::ACTIVITY_ACP;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\Scope;
|
||||||
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\ActivityBundle\Export\Declarations;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
class UserScopeFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
private TranslatableStringHelper $translatableStringHelper;
|
||||||
|
|
||||||
|
public function __construct(TranslatableStringHelper $translatableStringHelper)
|
||||||
|
{
|
||||||
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('accepted_userscope', EntityType::class, [
|
||||||
|
'class' => Scope::class,
|
||||||
|
'choice_label' => function (Scope $s) {
|
||||||
|
return $this->translatableStringHelper->localize(
|
||||||
|
$s->getName()
|
||||||
|
);
|
||||||
|
},
|
||||||
|
'multiple' => true,
|
||||||
|
'expanded' => true
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'Filter activity by userscope';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function describeAction($data, $format = 'string'): array
|
||||||
|
{
|
||||||
|
$scopes = [];
|
||||||
|
|
||||||
|
foreach ($data['accepted_userscope'] as $s) {
|
||||||
|
$scopes[] = $this->translatableStringHelper->localize(
|
||||||
|
$s->getName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['Filtered activity by userscope: only %scopes%', [
|
||||||
|
'%scopes%' => implode(", ou", $scopes)
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
if (!in_array('user', $qb->getAllAliases())) {
|
||||||
|
$qb->join('activity.user', 'user');
|
||||||
|
}
|
||||||
|
|
||||||
|
$where = $qb->getDQLPart('where');
|
||||||
|
|
||||||
|
$clause = $qb->expr()->in('user.mainScope', ':userscope');
|
||||||
|
|
||||||
|
if ($where instanceof Andx) {
|
||||||
|
$where->add($clause);
|
||||||
|
} else {
|
||||||
|
$where = $qb->expr()->andX($clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->add('where', $where);
|
||||||
|
$qb->setParameter('userscope', $data['accepted_userscope']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::ACTIVITY_ACP;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -67,6 +67,46 @@ services:
|
|||||||
name: chill.export_filter
|
name: chill.export_filter
|
||||||
alias: 'activity_person_having_ac_bw_date_filter'
|
alias: 'activity_person_having_ac_bw_date_filter'
|
||||||
|
|
||||||
|
chill.activity.export.locationtype_filter:
|
||||||
|
class: Chill\ActivityBundle\Export\Filter\ACPFilters\LocationTypeFilter
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: 'activity_locationtype_filter' }
|
||||||
|
|
||||||
|
chill.activity.export.byuser_filter: # TMS (M2M)
|
||||||
|
class: Chill\ActivityBundle\Export\Filter\ACPFilters\ByUserFilter
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: 'activity_byuser_filter' }
|
||||||
|
|
||||||
|
chill.activity.export.emergency_filter:
|
||||||
|
class: Chill\ActivityBundle\Export\Filter\ACPFilters\EmergencyFilter
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: 'activity_emergency_filter' }
|
||||||
|
|
||||||
|
chill.activity.export.sentreceived_filter:
|
||||||
|
class: Chill\ActivityBundle\Export\Filter\ACPFilters\SentReceivedFilter
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: 'activity_sentreceived_filter' }
|
||||||
|
|
||||||
|
chill.activity.export.bysocialaction_filter:
|
||||||
|
class: Chill\ActivityBundle\Export\Filter\ACPFilters\BySocialActionFilter
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: 'activity_bysocialaction_filter' }
|
||||||
|
|
||||||
|
chill.activity.export.bysocialissue_filter:
|
||||||
|
class: Chill\ActivityBundle\Export\Filter\ACPFilters\BySocialIssueFilter
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: 'activity_bysocialissue_filter' }
|
||||||
|
|
||||||
|
chill.activity.export.user_filter: # Creator (M2O)
|
||||||
|
class: Chill\ActivityBundle\Export\Filter\ACPFilters\UserFilter
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: 'activity_user_filter' }
|
||||||
|
|
||||||
|
chill.activity.export.userscope_filter:
|
||||||
|
class: Chill\ActivityBundle\Export\Filter\ACPFilters\UserScopeFilter
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: 'activity_userscope_filter' }
|
||||||
|
|
||||||
## Aggregators
|
## Aggregators
|
||||||
chill.activity.export.reason_aggregator:
|
chill.activity.export.reason_aggregator:
|
||||||
class: Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator
|
class: Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator
|
||||||
|
@ -249,6 +249,32 @@ Activity reasons for those activities: Sujets de ces activités
|
|||||||
|
|
||||||
Filter by activity type: Filtrer les activités par type
|
Filter by activity type: Filtrer les activités par type
|
||||||
|
|
||||||
|
Filter activity by locationtype: Filtrer les activités par type de localisation
|
||||||
|
'Filtered activity by locationtype: only %types%': "Filtré par type de localisation: uniquement %types%"
|
||||||
|
Accepted locationtype: Types de localisation
|
||||||
|
Filter activity by linked users: Filtrer les activités par TMS
|
||||||
|
'Filtered activity by linked users: only %users%': "Filtré par TMS: uniquement %users%"
|
||||||
|
Accepted users: TMS(s)
|
||||||
|
Filter activity by emergency: Filtrer les activités par urgence
|
||||||
|
'Filtered activity by emergency: only %emergency%': "Filtré par urgence: uniquement %emergency%"
|
||||||
|
activity is emergency: l'activité est urgente
|
||||||
|
activity is not emergency: l'activité n'est pas urgente
|
||||||
|
Filter activity by sentreceived: Filtrer les activités par envoyé/reçu
|
||||||
|
'Filtered activity by sentreceived: only %sentreceived%': "Filtré par envoyé/reçu: uniquement %sentreceived%"
|
||||||
|
Accepted sentreceived: ''
|
||||||
|
is sent: envoyé
|
||||||
|
is received: reçu
|
||||||
|
Filter activity by linked socialaction: Filtrer les activités par action liée
|
||||||
|
'Filtered activity by linked socialaction: only %actions%': "Filtré par action liée: uniquement %actions%"
|
||||||
|
Filter activity by linked socialissue: Filtrer les activités par problématique liée
|
||||||
|
'Filtered activity by linked socialissue: only %issues%': "Filtré par problématique liée: uniquement %issues%"
|
||||||
|
Filter activity by user: Filtrer les activités par créateur
|
||||||
|
'Filtered activity by user: only %users%': "Filtré par créateur: uniquement %users%"
|
||||||
|
Creators: Créateurs
|
||||||
|
Filter activity by userscope: Filtrer les activités par service du créateur
|
||||||
|
'Filtered activity by userscope: only %scopes%': "Filtré par service du créateur: uniquement %scopes%"
|
||||||
|
Accepted userscope: Services
|
||||||
|
|
||||||
#aggregators
|
#aggregators
|
||||||
Activity type: Type d'activité
|
Activity type: Type d'activité
|
||||||
Activity user: Utilisateur lié à l'activity
|
Activity user: Utilisateur lié à l'activity
|
||||||
|
Loading…
x
Reference in New Issue
Block a user