implement new export service for accompanyingcourse exports

This commit is contained in:
Julie Lenaerts 2023-09-21 13:06:50 +02:00
parent 5d41b37620
commit 500b37601a
17 changed files with 124 additions and 17 deletions

View File

@ -14,6 +14,7 @@ namespace Chill\ActivityBundle\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
@ -30,10 +31,14 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface
{
protected EntityRepository $repository;
private AccompanyingCourseExportHelper $accompanyingCourseExportHelper;
public function __construct(
EntityManagerInterface $em
EntityManagerInterface $em,
AccompanyingCourseExportHelper $accompanyingCourseExportHelper
) {
$this->repository = $em->getRepository(Activity::class);
$this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper;
}
public function buildForm(FormBuilderInterface $builder) {}
@ -108,6 +113,8 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface
)
->setParameter('authorized_centers', $centers);
$this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
return $qb;
}

View File

@ -14,6 +14,7 @@ namespace Chill\ActivityBundle\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
@ -30,10 +31,14 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac
{
protected EntityRepository $repository;
private AccompanyingCourseExportHelper $accompanyingCourseExportHelper;
public function __construct(
EntityManagerInterface $em
EntityManagerInterface $em,
AccompanyingCourseExportHelper $accompanyingCourseExportHelper
) {
$this->repository = $em->getRepository(Activity::class);
$this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper;
}
public function buildForm(FormBuilderInterface $builder)
@ -111,6 +116,8 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac
)
->setParameter('authorized_centers', $centers);
$this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
return $qb;
}

View File

@ -14,6 +14,7 @@ namespace Chill\ActivityBundle\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
@ -30,10 +31,15 @@ class CountActivity implements ExportInterface, GroupedExportInterface
{
protected EntityRepository $repository;
private AccompanyingCourseExportHelper $accompanyingCourseExportHelper;
public function __construct(
EntityManagerInterface $em
) {
EntityManagerInterface $em,
AccompanyingCourseExportHelper $accompanyingCourseExportHelper
) {
$this->repository = $em->getRepository(Activity::class);
$this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper;
}
public function buildForm(FormBuilderInterface $builder) {}
@ -105,6 +111,8 @@ class CountActivity implements ExportInterface, GroupedExportInterface
)
->setParameter('authorized_centers', $centers);
$this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
$qb->select('COUNT(DISTINCT activity.id) as export_count_activity');
return $qb;

View File

@ -15,6 +15,7 @@ use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Export\ListActivityHelper;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\MainBundle\Export\Helper\TranslatableStringExportLabelHelper;
use Chill\MainBundle\Export\ListInterface;
@ -30,14 +31,18 @@ class ListActivity implements ListInterface, GroupedExportInterface
private TranslatableStringExportLabelHelper $translatableStringExportLabelHelper;
private AccompanyingCourseExportHelper $accompanyingCourseExportHelper;
public function __construct(
ListActivityHelper $helper,
EntityManagerInterface $entityManager,
TranslatableStringExportLabelHelper $translatableStringExportLabelHelper
TranslatableStringExportLabelHelper $translatableStringExportLabelHelper,
AccompanyingCourseExportHelper $accompanyingCourseExportHelper
) {
$this->helper = $helper;
$this->entityManager = $entityManager;
$this->translatableStringExportLabelHelper = $translatableStringExportLabelHelper;
$this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper;
}
public function buildForm(FormBuilderInterface $builder)
@ -147,6 +152,8 @@ class ListActivity implements ListInterface, GroupedExportInterface
->addSelect('(SELECT AGGREGATE(acpScope.name) FROM ' . Scope::class . ' acpScope WHERE acpScope MEMBER OF acp.scopes) AS scopesNames')
->addGroupBy('scopesNames');
$this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
return $qb;
}

View File

@ -14,6 +14,7 @@ namespace Chill\ActivityBundle\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
@ -30,10 +31,14 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface
{
protected EntityRepository $repository;
private AccompanyingCourseExportHelper $accompanyingCourseExportHelper;
public function __construct(
EntityManagerInterface $em
EntityManagerInterface $em,
AccompanyingCourseExportHelper $accompanyingCourseExportHelper
) {
$this->repository = $em->getRepository(Activity::class);
$this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper;
}
public function buildForm(FormBuilderInterface $builder)
@ -111,6 +116,8 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface
)
->setParameter('authorized_centers', $centers);
$this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
return $qb;
}

View File

@ -14,6 +14,7 @@ namespace Chill\ActivityBundle\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
@ -30,10 +31,14 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac
{
protected EntityRepository $repository;
private AccompanyingCourseExportHelper $accompanyingCourseExportHelper;
public function __construct(
EntityManagerInterface $em
EntityManagerInterface $em,
AccompanyingCourseExportHelper $accompanyingCourseExportHelper
) {
$this->repository = $em->getRepository(Activity::class);
$this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper;
}
public function buildForm(FormBuilderInterface $builder)
@ -111,6 +116,8 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac
)
->setParameter('authorized_centers', $centers);
$this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
return $qb;
}

View File

@ -4,9 +4,9 @@ namespace Chill\MainBundle\Export;
use Doctrine\ORM\QueryBuilder;
class AccompanyingCourseExportHelper
final readonly class AccompanyingCourseExportHelper
{
public static function addClosingMotiveExclusionCriteria(QueryBuilder $qb): QueryBuilder
public static function addClosingMotiveExclusionClause(QueryBuilder $qb): QueryBuilder
{
$qb->leftJoin('acp.closingMotive', 'cm')
->andWhere(

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Export;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
@ -29,10 +30,14 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface
{
protected EntityRepository $repository;
private AccompanyingCourseExportHelper $accompanyingCourseExportHelper;
public function __construct(
EntityManagerInterface $em
EntityManagerInterface $em,
AccompanyingCourseExportHelper $accompanyingCourseExportHelper
) {
$this->repository = $em->getRepository(AccompanyingPeriod::class);
$this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper;
}
public function buildForm(FormBuilderInterface $builder): void
@ -111,6 +116,8 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface
->setParameter('count_acp_step', AccompanyingPeriod::STEP_DRAFT)
->setParameter('authorized_centers', $centers);
$this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
$qb->select('COUNT(DISTINCT acp.id) AS export_result');
return $qb;

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Export;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
@ -28,10 +29,14 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter
{
protected EntityManagerInterface $em;
private AccompanyingCourseExportHelper $accompanyingCourseExportHelper;
public function __construct(
EntityManagerInterface $em
EntityManagerInterface $em,
AccompanyingCourseExportHelper $accompanyingCourseExportHelper
) {
$this->em = $em;
$this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper;
}
public function buildForm(FormBuilderInterface $builder): void
@ -112,6 +117,8 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter
$qb->select('COUNT(DISTINCT acpw.id) as export_result');
$this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
return $qb;
}

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Export;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
@ -27,10 +28,14 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface
{
private EntityManagerInterface $entityManager;
private AccompanyingCourseExportHelper $accompanyingCourseExportHelper;
public function __construct(
EntityManagerInterface $em
EntityManagerInterface $em,
AccompanyingCourseExportHelper $accompanyingCourseExportHelper
) {
$this->entityManager = $em;
$this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper;
}
public function buildForm(FormBuilderInterface $builder)
@ -110,6 +115,8 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface
)
->setParameter('authorized_centers', $centers);
$this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
$qb->select('COUNT(DISTINCT workeval.id) AS export_result');
return $qb;

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Export;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
@ -29,10 +30,14 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor
{
private EntityRepository $repository;
private AccompanyingCourseExportHelper $accompanyingCourseExportHelper;
public function __construct(
EntityManagerInterface $em
EntityManagerInterface $em,
AccompanyingCourseExportHelper $accompanyingCourseExportHelper
) {
$this->repository = $em->getRepository(AccompanyingPeriod::class);
$this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper;
}
public function buildForm(FormBuilderInterface $builder)
@ -111,6 +116,8 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor
)
)->setParameter('authorized_centers', $centers);
$this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
$qb->select('COUNT(DISTINCT person.id) AS export_result');
return $qb;

View File

@ -13,6 +13,7 @@ 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;
@ -52,6 +53,7 @@ final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExp
private EntityManagerInterface $entityManager,
private RollingDateConverterInterface $rollingDateConverter,
private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper,
private AccompanyingCourseExportHelper $accompanyingCourseExportHelper
) {}
public function buildForm(FormBuilderInterface $builder)
@ -132,6 +134,8 @@ final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExp
$this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date']));
$this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
$qb
->addOrderBy('acp.openingDate')
->addOrderBy('acp.closingDate')

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Export;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\MainBundle\Export\Helper\AggregateStringHelper;
@ -100,6 +101,8 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
private UserHelper $userHelper;
private AccompanyingCourseExportHelper $accompanyingCourseExportHelper;
public function __construct(
EntityManagerInterface $entityManager,
DateTimeHelper $dateTimeHelper,
@ -112,7 +115,8 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
SocialActionRender $socialActionRender,
RollingDateConverterInterface $rollingDateConverter,
AggregateStringHelper $aggregateStringHelper,
SocialActionRepository $socialActionRepository
SocialActionRepository $socialActionRepository,
AccompanyingCourseExportHelper $accompanyingCourseExportHelper
) {
$this->entityManager = $entityManager;
$this->dateTimeHelper = $dateTimeHelper;
@ -126,6 +130,7 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
$this->rollingDateConverter = $rollingDateConverter;
$this->aggregateStringHelper = $aggregateStringHelper;
$this->socialActionRepository = $socialActionRepository;
$this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper;
}
public function buildForm(FormBuilderInterface $builder)
@ -291,6 +296,8 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
->setParameter('authorized_centers', $centers)
->setParameter('calc_date', $this->rollingDateConverter->convert($data['calc_date']));
$this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
$this->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date']));
return $qb;

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Export;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\MainBundle\Export\Helper\AggregateStringHelper;
@ -90,6 +91,8 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
private UserHelper $userHelper;
private AccompanyingCourseExportHelper $accompanyingCourseExportHelper;
public function __construct(
EntityManagerInterface $entityManager,
SocialIssueRender $socialIssueRender,
@ -101,7 +104,8 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
DateTimeHelper $dateTimeHelper,
TranslatableStringExportLabelHelper $translatableStringExportLabelHelper,
AggregateStringHelper $aggregateStringHelper,
RollingDateConverterInterface $rollingDateConverter
RollingDateConverterInterface $rollingDateConverter,
AccompanyingCourseExportHelper $accompanyingCourseExportHelper
) {
$this->entityManager = $entityManager;
$this->socialIssueRender = $socialIssueRender;
@ -114,6 +118,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
$this->translatableStringExportLabelHelper = $translatableStringExportLabelHelper;
$this->aggregateStringHelper = $aggregateStringHelper;
$this->rollingDateConverter = $rollingDateConverter;
$this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper;
}
public function buildForm(FormBuilderInterface $builder)
@ -270,6 +275,8 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
->setParameter('authorized_centers', $centers)
->setParameter('calc_date', $this->rollingDateConverter->convert($data['calc_date']));
$this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
$this->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date']));
return $qb;

View File

@ -11,6 +11,7 @@ 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;
@ -48,14 +49,18 @@ class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterf
private ListPersonHelper $listPersonHelper;
private AccompanyingCourseExportHelper $accompanyingCourseExportHelper;
public function __construct(
ExportAddressHelper $addressHelper,
ListPersonHelper $listPersonHelper,
EntityManagerInterface $em
EntityManagerInterface $em,
AccompanyingCourseExportHelper $accompanyingCourseExportHelper
) {
$this->addressHelper = $addressHelper;
$this->listPersonHelper = $listPersonHelper;
$this->entityManager = $em;
$this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper;
}
public function buildForm(FormBuilderInterface $builder)
@ -190,6 +195,8 @@ class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterf
$this->listPersonHelper->addSelect($qb, $fields, $data['address_date']);
$this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
$qb
->addOrderBy('person.lastName')
->addOrderBy('person.firstName')

View File

@ -11,6 +11,7 @@ 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;
@ -50,6 +51,7 @@ final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInte
private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper,
private EntityManagerInterface $entityManager,
private RollingDateConverterInterface $rollingDateConverter,
private AccompanyingCourseExportHelper $accompanyingCourseExportHelper
) {}
public function buildForm(FormBuilderInterface $builder)
@ -133,6 +135,8 @@ final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInte
$this->listPersonHelper->addSelect($qb, ListPersonHelper::FIELDS, $this->rollingDateConverter->convert($data['address_date']));
$this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['address_date']));
$this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
$qb
->addOrderBy('person.lastName')
->addOrderBy('person.firstName')

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Export;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
@ -31,10 +32,14 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn
{
private EntityRepository $repository;
private AccompanyingCourseExportHelper $accompanyingCourseExportHelper;
public function __construct(
EntityManagerInterface $em
EntityManagerInterface $em,
AccompanyingCourseExportHelper $accompanyingCourseExportHelper
) {
$this->repository = $em->getRepository(AccompanyingPeriod::class);
$this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper;
}
public function buildForm(FormBuilderInterface $builder): void
@ -142,6 +147,8 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn
->setParameter('count_acp_step', AccompanyingPeriod::STEP_DRAFT)
->setParameter('authorized_centers', $centers);
$this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
return $qb;
}