mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
household list of accompanying periods + upgrade DBAL version to 3.1
This commit is contained in:
@@ -14,6 +14,8 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Household\Position;
|
||||
use Chill\PersonBundle\Repository\Household\PositionRepository;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/person/household")
|
||||
@@ -24,11 +26,14 @@ class HouseholdController extends AbstractController
|
||||
|
||||
private PositionRepository $positionRepository;
|
||||
|
||||
public function __construct(TranslatorInterface $translator, PositionRepository $positionRepository)
|
||||
private Security $security;
|
||||
|
||||
public function __construct(TranslatorInterface $translator, PositionRepository $positionRepository, Security $security)
|
||||
|
||||
{
|
||||
$this->translator = $translator;
|
||||
$this->positionRepository = $positionRepository;
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,17 +82,46 @@ class HouseholdController extends AbstractController
|
||||
*/
|
||||
public function accompanyingPeriod(Request $request, Household $household)
|
||||
{
|
||||
// TODO ACL
|
||||
|
||||
$members = $household->getMembers();
|
||||
foreach($members as $m) {
|
||||
$accompanyingPeriods = $m->getPerson()->getAccompanyingPeriods();
|
||||
$currentMembers = $household->getCurrentPersons();
|
||||
$accompanyingPeriods = [];
|
||||
|
||||
foreach ($currentMembers as $p) {
|
||||
$accompanyingPeriodsMember = $p->getCurrentAccompanyingPeriods();
|
||||
|
||||
foreach ($accompanyingPeriodsMember as $accompanyingPeriod) {
|
||||
if (!$this->security->isGranted(AccompanyingPeriodVoter::SEE, $accompanyingPeriod)) {
|
||||
continue;
|
||||
} else {
|
||||
$accompanyingPeriods[$accompanyingPeriod->getId()] = $accompanyingPeriod;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$oldMembers = $household->getNonCurrentMembers();
|
||||
$accompanyingPeriodsOld = [];
|
||||
|
||||
foreach ($oldMembers as $m) {
|
||||
$accompanyingPeriodsOldMember = $m->getPerson()->getAccompanyingPeriods();
|
||||
|
||||
foreach ($accompanyingPeriodsOldMember as $accompanyingPeriod) {
|
||||
if (!$this->security->isGranted(AccompanyingPeriodVoter::SEE, $accompanyingPeriod)) {
|
||||
continue;
|
||||
} else {
|
||||
$id = $accompanyingPeriod->getId();
|
||||
|
||||
if (!array_key_exists($id, $accompanyingPeriodsOld) && !array_key_exists($id, $accompanyingPeriods)) {
|
||||
$accompanyingPeriodsOld[$id] = $accompanyingPeriod;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('@ChillPerson/Household/accompanying_period.html.twig',
|
||||
[
|
||||
'household' => $household,
|
||||
'accompanying_periods' => $accompanyingPeriods
|
||||
'accompanying_periods' => $accompanyingPeriods,
|
||||
'accompanying_periods_old' => $accompanyingPeriodsOld
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@@ -41,14 +41,14 @@ class MaritalStatus
|
||||
|
||||
/**
|
||||
* @var string array
|
||||
* @ORM\Column(type="json_array")
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
@@ -57,7 +57,7 @@ class MaritalStatus
|
||||
|
||||
/**
|
||||
* Set id
|
||||
*
|
||||
*
|
||||
* @param string $id
|
||||
* @return MaritalStatus
|
||||
*/
|
||||
@@ -76,17 +76,17 @@ class MaritalStatus
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return string array
|
||||
* @return string array
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -406,7 +406,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* Array where customfield's data are stored
|
||||
* @var array
|
||||
*
|
||||
* @ORM\Column(type="json_array")
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
private $cFData;
|
||||
|
||||
@@ -613,6 +613,26 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $accompanyingPeriods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current accompanyingPeriods array
|
||||
*/
|
||||
public function getCurrentAccompanyingPeriods(): array
|
||||
{
|
||||
$currentAccompanyingPeriods = [];
|
||||
$currentDate = new DateTime();
|
||||
|
||||
foreach ($this->accompanyingPeriodParticipations as $participation)
|
||||
{
|
||||
$endDate = $participation->getEndDate();
|
||||
|
||||
if ($endDate === null || $endDate > $currentDate){
|
||||
$currentAccompanyingPeriods[] = $participation->getAccompanyingPeriod();
|
||||
}
|
||||
}
|
||||
|
||||
return $currentAccompanyingPeriods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get AccompanyingPeriodParticipations Collection
|
||||
*
|
||||
|
@@ -21,11 +21,11 @@ use Chill\MainBundle\Export\FilterInterface;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Chill\PersonBundle\Export\AbstractAccompanyingPeriodExportElement;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
class AccompanyingPeriodClosingFilter extends AbstractAccompanyingPeriodExportElement implements FilterInterface
|
||||
@@ -38,14 +38,14 @@ class AccompanyingPeriodClosingFilter extends AbstractAccompanyingPeriodExportEl
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$this->addJoinAccompanyingPeriod($qb);
|
||||
|
||||
|
||||
$clause = $qb->expr()->andX(
|
||||
$qb->expr()->lte('accompanying_period.closingDate', ':date_to'),
|
||||
$qb->expr()->gte('accompanying_period.closingDate', ':date_from'));
|
||||
|
||||
$qb->andWhere($clause);
|
||||
$qb->setParameter('date_from', $data['date_from'], Type::DATE);
|
||||
$qb->setParameter('date_to', $data['date_to'], Type::DATE);
|
||||
$qb->setParameter('date_from', $data['date_from'], Types::DATE_MUTABLE);
|
||||
$qb->setParameter('date_to', $data['date_to'], Types::DATE_MUTABLE);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@@ -59,7 +59,7 @@ class AccompanyingPeriodClosingFilter extends AbstractAccompanyingPeriodExportEl
|
||||
'label' => "Having an accompanying period closed after this date",
|
||||
'data' => new \DateTime("-1 month"),
|
||||
));
|
||||
|
||||
|
||||
$builder->add('date_to', ChillDateType::class, array(
|
||||
'label' => "Having an accompanying period closed before this date",
|
||||
'data' => new \DateTime(),
|
||||
|
@@ -21,11 +21,11 @@ use Chill\MainBundle\Export\FilterInterface;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Chill\PersonBundle\Export\AbstractAccompanyingPeriodExportElement;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
class AccompanyingPeriodFilter extends AbstractAccompanyingPeriodExportElement implements FilterInterface
|
||||
@@ -38,9 +38,9 @@ class AccompanyingPeriodFilter extends AbstractAccompanyingPeriodExportElement i
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$this->addJoinAccompanyingPeriod($qb);
|
||||
|
||||
|
||||
$clause = $qb->expr()->andX();
|
||||
|
||||
|
||||
$clause->add(
|
||||
$qb->expr()->lte('accompanying_period.openingDate', ':date_to')
|
||||
);
|
||||
@@ -52,8 +52,8 @@ class AccompanyingPeriodFilter extends AbstractAccompanyingPeriodExportElement i
|
||||
);
|
||||
|
||||
$qb->andWhere($clause);
|
||||
$qb->setParameter('date_from', $data['date_from'], Type::DATE);
|
||||
$qb->setParameter('date_to', $data['date_to'], Type::DATE);
|
||||
$qb->setParameter('date_from', $data['date_from'], Types::DATE_MUTABLE);
|
||||
$qb->setParameter('date_to', $data['date_to'], Types::DATE_MUTABLE);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@@ -67,7 +67,7 @@ class AccompanyingPeriodFilter extends AbstractAccompanyingPeriodExportElement i
|
||||
'label' => "Having an accompanying period opened after this date",
|
||||
'data' => new \DateTime("-1 month"),
|
||||
));
|
||||
|
||||
|
||||
$builder->add('date_to', ChillDateType::class, array(
|
||||
'label' => "Having an accompanying period ending before this date, or "
|
||||
. "still opened at this date",
|
||||
|
@@ -21,11 +21,11 @@ use Chill\MainBundle\Export\FilterInterface;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Chill\PersonBundle\Export\AbstractAccompanyingPeriodExportElement;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
class AccompanyingPeriodOpeningFilter extends AbstractAccompanyingPeriodExportElement implements FilterInterface
|
||||
@@ -38,14 +38,14 @@ class AccompanyingPeriodOpeningFilter extends AbstractAccompanyingPeriodExportEl
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$this->addJoinAccompanyingPeriod($qb);
|
||||
|
||||
|
||||
$clause = $qb->expr()->andX(
|
||||
$qb->expr()->lte('accompanying_period.openingDate', ':date_to'),
|
||||
$qb->expr()->gte('accompanying_period.openingDate', ':date_from'));
|
||||
|
||||
$qb->andWhere($clause);
|
||||
$qb->setParameter('date_from', $data['date_from'], Type::DATE);
|
||||
$qb->setParameter('date_to', $data['date_to'], Type::DATE);
|
||||
$qb->setParameter('date_from', $data['date_from'], Types::DATE_MUTABLE);
|
||||
$qb->setParameter('date_to', $data['date_to'], Types::DATE_MUTABLE);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@@ -59,7 +59,7 @@ class AccompanyingPeriodOpeningFilter extends AbstractAccompanyingPeriodExportEl
|
||||
'label' => "Having an accompanying period opened after this date",
|
||||
'data' => new \DateTime("-1 month"),
|
||||
));
|
||||
|
||||
|
||||
$builder->add('date_to', ChillDateType::class, array(
|
||||
'label' => "Having an accompanying period opened before this date",
|
||||
'data' => new \DateTime(),
|
||||
|
@@ -77,7 +77,7 @@
|
||||
<div class="wl-row">
|
||||
<div class="wl-col title"><h3>{{ 'Participants'|trans }}</h3></div>
|
||||
<div class="wl-col list">
|
||||
{% for p in accompanying_period.participations %}
|
||||
{% for p in accompanying_period.getCurrentParticipations %}
|
||||
<span class="wl-item badge-person">
|
||||
<a href="{{ path('chill_person_accompanying_period_list', { person_id: p.person.id }) }}">
|
||||
{{ p.person|chill_entity_render_string }}
|
||||
|
@@ -9,6 +9,37 @@
|
||||
|
||||
{% include 'ChillPersonBundle:AccompanyingPeriod:_list.html.twig' %}
|
||||
|
||||
{% if accompanying_periods_old|length > 0 %}
|
||||
<style>
|
||||
button[aria-expanded="true"] > span.folded,
|
||||
button[aria-expanded="false"] > span.unfolded { display: none; }
|
||||
button[aria-expanded="false"] > span.folded,
|
||||
button[aria-expanded="true"] > span.unfolded { display: inline; }
|
||||
</style>
|
||||
<div class="accordion" id="nonCurrent">
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="heading_{{ household.id }}">
|
||||
<button
|
||||
class="accordion-button collapsed"
|
||||
type="button"
|
||||
data-bs-toggle="collapse"
|
||||
data-bs-target="#collapse_{{ household.id }}"
|
||||
aria-expanded="false"
|
||||
aria-controls="collapse_{{ household.id }}">
|
||||
<span class="folded">{{ 'household.Show accompanying periods of past or future memberships'|trans({'length': accompanying_periods_old|length}) }}</span>
|
||||
<span class="unfolded text-secondary">{{ 'household.Hide memberships'|trans }}</span>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="collapse_{{ household.id }}"
|
||||
class="accordion-collapse collapse"
|
||||
aria-labelledby="heading_{{ household.id }}"
|
||||
data-bs-parent="#nonCurrent">
|
||||
{% include 'ChillPersonBundle:AccompanyingPeriod:_list.html.twig' with {'accompanying_periods' : accompanying_periods_old} %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
<li class="cancel">
|
||||
<a href="{{ path ('chill_person_household_summary', {'household_id' : household.id } ) }}" class="btn btn-cancel">
|
||||
|
@@ -22,7 +22,7 @@ namespace Chill\PersonBundle\Widget;
|
||||
use Chill\MainBundle\Templating\Widget\WidgetInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Query\Expr;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
|
||||
@@ -33,11 +33,11 @@ use Chill\CustomFieldsBundle\Entity\CustomField;
|
||||
use Twig\Environment;
|
||||
|
||||
/**
|
||||
* add a widget with person list.
|
||||
*
|
||||
* add a widget with person list.
|
||||
*
|
||||
* The configuration is defined by `PersonListWidgetFactory`
|
||||
*
|
||||
* If the options 'custom_fields' is used, the custom fields entity will be
|
||||
*
|
||||
* If the options 'custom_fields' is used, the custom fields entity will be
|
||||
* queried from the db and transmitted to the view under the `customFields` variable.
|
||||
*/
|
||||
class PersonListWidget implements WidgetInterface
|
||||
@@ -48,33 +48,33 @@ class PersonListWidget implements WidgetInterface
|
||||
* @var PersonRepository
|
||||
*/
|
||||
protected $personRepository;
|
||||
|
||||
|
||||
/**
|
||||
* The entity manager
|
||||
*
|
||||
* @var EntityManager
|
||||
*/
|
||||
protected $entityManager;
|
||||
|
||||
|
||||
/**
|
||||
* the authorization helper
|
||||
*
|
||||
*
|
||||
* @var AuthorizationHelper;
|
||||
*/
|
||||
protected $authorizationHelper;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @var TokenStorage
|
||||
*/
|
||||
protected $tokenStorage;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @var UserInterface
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
|
||||
public function __construct(
|
||||
PersonRepository $personRepostory,
|
||||
EntityManager $em,
|
||||
@@ -88,26 +88,26 @@ class PersonListWidget implements WidgetInterface
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param type $place
|
||||
* @param array $context
|
||||
* @param array $config
|
||||
* @return string
|
||||
*/
|
||||
public function render(Environment $env, $place, array $context, array $config)
|
||||
{
|
||||
{
|
||||
$numberOfItems = $config['number_of_items'] ?? 20;
|
||||
|
||||
|
||||
$qb = $this->personRepository
|
||||
->createQueryBuilder('person');
|
||||
|
||||
|
||||
// show only the person from the authorized centers
|
||||
$and = $qb->expr()->andX();
|
||||
$centers = $this->authorizationHelper
|
||||
->getReachableCenters($this->getUser(), new Role(PersonVoter::SEE));
|
||||
$and->add($qb->expr()->in('person.center', ':centers'));
|
||||
$qb->setParameter('centers', $centers);
|
||||
|
||||
|
||||
|
||||
// add the "only active" query
|
||||
if (\array_key_exists('only_active', $config) && $config['only_active'] === true) {
|
||||
@@ -123,37 +123,37 @@ class PersonListWidget implements WidgetInterface
|
||||
(new Expr())->between(':now', 'ap.openingDate', 'ap.closingDate')
|
||||
);
|
||||
$and->add($or);
|
||||
$qb->setParameter('now', new \DateTime(), Type::DATE);
|
||||
$qb->setParameter('now', new \DateTime(), Types::DATE_MUTABLE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (\array_key_exists('filtering_class', $config) && $config['filtering_class'] !== NULL) {
|
||||
$filteringClass = new $config['filtering_class'];
|
||||
if ( ! $filteringClass instanceof PersonListWidget\PersonFilteringInterface) {
|
||||
throw new \UnexpectedValueException(sprintf("the class %s does not "
|
||||
. "implements %s", $config['filtering_class'],
|
||||
. "implements %s", $config['filtering_class'],
|
||||
PersonListWidget\PersonFilteringInterface::class));
|
||||
}
|
||||
$ids = $filteringClass->getPersonIds($this->entityManager,
|
||||
$ids = $filteringClass->getPersonIds($this->entityManager,
|
||||
$this->getUser());
|
||||
$in = (new Expr())->in('person.id', ':ids');
|
||||
$and->add($in);
|
||||
$qb->setParameter('ids', $ids);
|
||||
}
|
||||
|
||||
|
||||
// adding the where clause to the query
|
||||
$qb->where($and);
|
||||
|
||||
|
||||
// ordering the query by lastname, firstname
|
||||
$qb->addOrderBy('person.lastName', 'ASC')
|
||||
->addOrderBy('person.firstName', 'ASC');
|
||||
|
||||
|
||||
|
||||
|
||||
$qb->setFirstResult(0)->setMaxResults($numberOfItems);
|
||||
|
||||
|
||||
$persons = $qb->getQuery()->getResult();
|
||||
|
||||
// get some custom field when the view is overriden and we want to
|
||||
|
||||
// get some custom field when the view is overriden and we want to
|
||||
// show some custom field in the overriden view.
|
||||
$cfields = array();
|
||||
if (isset($config['custom_fields'])) {
|
||||
@@ -166,39 +166,39 @@ class PersonListWidget implements WidgetInterface
|
||||
$cfields[$cf->getSlug()] = $cf;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $env->render(
|
||||
'ChillPersonBundle:Widget:homepage_person_list.html.twig',
|
||||
array(
|
||||
'persons' => $persons,
|
||||
'customFields' => $cfields
|
||||
|
||||
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return UserInterface
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
private function getUser()
|
||||
{
|
||||
$token = $this->tokenStorage->getToken();
|
||||
|
||||
|
||||
if ($token === null) {
|
||||
throw new \RuntimeException("the token should not be null");
|
||||
}
|
||||
|
||||
|
||||
$user = $token->getUser();
|
||||
|
||||
|
||||
if (!$user instanceof UserInterface || $user == null) {
|
||||
throw new \RuntimeException("the user should implement UserInterface. "
|
||||
. "Are you logged in ?");
|
||||
}
|
||||
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ use Chill\MainBundle\Entity\User;
|
||||
/**
|
||||
* Interface to implement on classes called in configuration for
|
||||
* PersonListWidget (`person_list`), under the key `filtering_class` :
|
||||
*
|
||||
*
|
||||
* ```
|
||||
* widgets:
|
||||
* homepage:
|
||||
@@ -35,41 +35,41 @@ use Chill\MainBundle\Entity\User;
|
||||
* # where \FQDN\To\Class implements PersonFiltering
|
||||
* class_filtering: \FQDN\To\Class
|
||||
* ```
|
||||
*
|
||||
*
|
||||
*/
|
||||
interface PersonFilteringInterface
|
||||
interface PersonFilteringInterface
|
||||
{
|
||||
/**
|
||||
* Return an array of persons id to show.
|
||||
*
|
||||
* Those ids are inserted into the query like this (where ids is the array
|
||||
*
|
||||
* Those ids are inserted into the query like this (where ids is the array
|
||||
* returned by this class) :
|
||||
*
|
||||
*
|
||||
* ```
|
||||
* SELECT p FROM ChillPersonBundle:Persons p
|
||||
* SELECT p FROM ChillPersonBundle:Persons p
|
||||
* WHERE p.id IN (:ids)
|
||||
* AND
|
||||
* AND
|
||||
* -- security/authorization statement: restraint person to authorized centers
|
||||
* p.center in :authorized_centers
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* Example of use : filtering based on custom field data :
|
||||
* ```
|
||||
|
||||
|
||||
class HomepagePersonFiltering implements PersonFilteringInterface {
|
||||
|
||||
public function getPersonIds(EntityManager $em, User $user)
|
||||
{
|
||||
$rsmBuilder = new ResultSetMappingBuilder($em);
|
||||
$rsmBuilder->addScalarResult('id', 'id', Type::BIGINT);
|
||||
|
||||
$rsmBuilder->addScalarResult('id', 'id', Types::BIGINT);
|
||||
|
||||
$personTable = $em->getClassMetadata('ChillPersonBundle:Person')
|
||||
->getTableName();
|
||||
$personIdColumn = $em->getClassMetadata('ChillPersonBundle:Person')
|
||||
->getColumnName('id');
|
||||
$personCfDataColumn = $em->getClassMetadata('ChillPersonBundle:Person')
|
||||
->getColumnName('cfData');
|
||||
|
||||
|
||||
return $em->createNativeQuery(sprintf("SELECT %s FROM %s WHERE "
|
||||
. "jsonb_exists(%s, 'school-2fb5440e-192c-11e6-b2fd-74d02b0c9b55')",
|
||||
$personIdColumn, $personTable, $personCfDataColumn), $rsmBuilder)
|
||||
@@ -77,7 +77,7 @@ interface PersonFilteringInterface
|
||||
}
|
||||
}
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* @param EntityManager $em
|
||||
* @return int[] an array of persons id to show
|
||||
*/
|
||||
|
@@ -17,7 +17,6 @@ class Version20150607231010 extends AbstractMigration
|
||||
. 'recorded.';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
@@ -28,36 +27,26 @@ class Version20150607231010 extends AbstractMigration
|
||||
'Migration can only be executed safely on \'postgresql\'.'
|
||||
);
|
||||
|
||||
// retrieve center for setting a default center
|
||||
$centers = $this->connection->fetchAll('SELECT id FROM centers');
|
||||
|
||||
if (count($centers) > 0) {
|
||||
$defaultCenterId = $centers[0]['id'];
|
||||
} else { // if no center, performs other checks
|
||||
//check if there are data in person table
|
||||
$nbPeople = $this->connection->fetchColumn('SELECT count(*) FROM person');
|
||||
|
||||
if ($nbPeople > 0) {
|
||||
// we have data ! We have to create a center !
|
||||
$newCenterId = $this->connection->fetchColumn('SELECT nextval(\'centers_id_seq\');');
|
||||
$this->addSql(
|
||||
'INSERT INTO centers (id, name) VALUES (:id, :name)',
|
||||
['id' => $newCenterId, 'name' => 'Auto-created center']
|
||||
);
|
||||
$defaultCenterId = $newCenterId;
|
||||
}
|
||||
}
|
||||
|
||||
$this->addSql('ALTER TABLE person ADD center_id INT');
|
||||
|
||||
// retrieve center for setting a default center
|
||||
$stmt = $this->connection->executeQuery("SELECT id FROM centers ORDER BY id ASC LIMIT 1");
|
||||
$center = $stmt->fetchOne();
|
||||
|
||||
if ($center !== false) {
|
||||
$defaultCenterId = $center['id'];
|
||||
}
|
||||
|
||||
if (isset($defaultCenterId)) {
|
||||
$this->addSql('UPDATE person SET center_id = :id', array('id' => $defaultCenterId));
|
||||
}
|
||||
|
||||
// this will fail if a person is defined, which should not happen any more at this
|
||||
// time of writing (2021-11-09)
|
||||
$this->addSql('ALTER TABLE person ALTER center_id SET NOT NULL');
|
||||
$this->addSql('ALTER TABLE person '
|
||||
. 'ADD CONSTRAINT FK_person_center FOREIGN KEY (center_id) '
|
||||
. 'REFERENCES centers (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE person ALTER center_id SET NOT NULL');
|
||||
$this->addSql('CREATE INDEX IDX_person_center ON person (center_id)');
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,6 @@ final class Version20200310090632 extends AbstractMigration
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE chill_person_closingmotive ADD parent_id INT DEFAULT NULL');
|
||||
$this->addSql('COMMENT ON COLUMN chill_person_closingmotive.name IS \'(DC2Type:json_array)\'');
|
||||
$this->addSql('ALTER TABLE chill_person_closingmotive ADD CONSTRAINT FK_92351ECE727ACA70 FOREIGN KEY (parent_id) REFERENCES chill_person_closingmotive (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE INDEX IDX_92351ECE727ACA70 ON chill_person_closingmotive (parent_id)');
|
||||
$this->addsql("ALTER TABLE chill_person_closingmotive ADD ordering DOUBLE PRECISION DEFAULT '0' NOT NULL;");
|
||||
|
@@ -24,6 +24,5 @@ final class Version20210419112619 extends AbstractMigration
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_closingmotive.name IS \'(DC2Type:json_array)\'');
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,12 @@ household:
|
||||
many {Montrer # anciennes ou futures appartenances}
|
||||
other {Montrer # anciennes ou futures appartenances}
|
||||
}
|
||||
Show accompanying periods of past or future memberships: >-
|
||||
{length, plural,
|
||||
one {Montrer les parcours d'une ancienne appartenance}
|
||||
many {Montrer # parcours des anciennes ou futures appartenances}
|
||||
other {Montrer # parcours des anciennes ou futures appartenances}
|
||||
}
|
||||
Hide memberships: Masquer
|
||||
Those members does not share address: Ces usagers ne partagent pas l'adresse du ménage.
|
||||
Any persons into this position: Aucune personne n'appartient au ménage à cette position.
|
||||
|
Reference in New Issue
Block a user