mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
Feature: [export] Add a list of accompanying periods
This commit is contained in:
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Export\Helper;
|
||||
|
||||
use Chill\MainBundle\Export\Helper\ExportAddressHelper;
|
||||
use Chill\MainBundle\Repository\CenterRepositoryInterface;
|
||||
use Chill\MainBundle\Repository\CivilityRepositoryInterface;
|
||||
use Chill\MainBundle\Repository\CountryRepository;
|
||||
use Chill\MainBundle\Repository\LanguageRepositoryInterface;
|
||||
@@ -72,16 +73,10 @@ class ListPersonHelper
|
||||
'lifecycleUpdate',
|
||||
];
|
||||
|
||||
public const HELPER_ATTRIBUTES = ExportAddressHelper::F_ATTRIBUTES |
|
||||
ExportAddressHelper::F_BUILDING |
|
||||
ExportAddressHelper::F_COUNTRY |
|
||||
ExportAddressHelper::F_GEOM |
|
||||
ExportAddressHelper::F_POSTAL_CODE |
|
||||
ExportAddressHelper::F_STREET |
|
||||
ExportAddressHelper::F_AS_STRING;
|
||||
|
||||
private ExportAddressHelper $addressHelper;
|
||||
|
||||
private CenterRepositoryInterface $centerRepository;
|
||||
|
||||
private CivilityRepositoryInterface $civilityRepository;
|
||||
|
||||
private CountryRepository $countryRepository;
|
||||
@@ -98,6 +93,7 @@ class ListPersonHelper
|
||||
|
||||
public function __construct(
|
||||
ExportAddressHelper $addressHelper,
|
||||
CenterRepositoryInterface $centerRepository,
|
||||
CivilityRepositoryInterface $civilityRepository,
|
||||
CountryRepository $countryRepository,
|
||||
LanguageRepositoryInterface $languageRepository,
|
||||
@@ -107,6 +103,7 @@ class ListPersonHelper
|
||||
UserRepositoryInterface $userRepository
|
||||
) {
|
||||
$this->addressHelper = $addressHelper;
|
||||
$this->centerRepository = $centerRepository;
|
||||
$this->civilityRepository = $civilityRepository;
|
||||
$this->countryRepository = $countryRepository;
|
||||
$this->languageRepository = $languageRepository;
|
||||
@@ -134,12 +131,9 @@ class ListPersonHelper
|
||||
break;
|
||||
|
||||
case 'address_fields':
|
||||
foreach ($this->addressHelper->getKeys(ListPersonHelper::HELPER_ATTRIBUTES, 'address_fields') as $key) {
|
||||
$qb
|
||||
->addSelect(sprintf('IDENTITY(personHouseholdAddress.address) AS %s', $key));
|
||||
}
|
||||
|
||||
$this->addCurrentAddressAt($qb, $computedDate);
|
||||
$qb->leftJoin('personHouseholdAddress.address', 'personAddress');
|
||||
$this->addressHelper->addSelectClauses(ExportAddressHelper::F_ALL, $qb, 'personAddress', 'address_fields');
|
||||
|
||||
break;
|
||||
|
||||
@@ -154,7 +148,10 @@ class ListPersonHelper
|
||||
}
|
||||
|
||||
if (in_array('address_fields', $fields, true)) {
|
||||
$qb->addGroupBy('address_fieldsid');
|
||||
$qb
|
||||
->addGroupBy('address_fieldsid')
|
||||
->addGroupBy('address_fieldscountry_t.id')
|
||||
->addGroupBy('address_fieldspostcode_t.id');
|
||||
}
|
||||
|
||||
if (in_array('household_id', $fields, true)) {
|
||||
@@ -234,7 +231,7 @@ class ListPersonHelper
|
||||
return array_merge(
|
||||
self::FIELDS,
|
||||
['createdAt', 'createdBy', 'updatedAt', 'updatedBy'],
|
||||
$this->addressHelper->getKeys(self::HELPER_ATTRIBUTES, 'address_fields')
|
||||
$this->addressHelper->getKeys(ExportAddressHelper::F_ALL, 'address_fields')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -245,6 +242,19 @@ class ListPersonHelper
|
||||
}
|
||||
|
||||
switch ($key) {
|
||||
case 'center':
|
||||
return function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return $this->translator->trans($key);
|
||||
}
|
||||
|
||||
if (null === $value || null === $center = $this->centerRepository->find($value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $center->getName();
|
||||
};
|
||||
|
||||
case 'birthdate':
|
||||
case 'deathdate':
|
||||
case 'maritalStatusDate':
|
||||
@@ -413,7 +423,7 @@ class ListPersonHelper
|
||||
->leftJoin('person.householdAddresses', 'personHouseholdAddress')
|
||||
->andWhere(
|
||||
$qb->expr()->orX(
|
||||
// no address at this time
|
||||
// no address at this time
|
||||
$qb->expr()->isNull('personHouseholdAddress'),
|
||||
// there is one address...
|
||||
$qb->expr()->andX(
|
||||
|
Reference in New Issue
Block a user