household list of accompanying periods + upgrade DBAL version to 3.1

This commit is contained in:
LenaertsJ 2021-11-08 10:57:14 +00:00 committed by Julien Fastré
parent 092ea4d57f
commit 7fabe0214e
49 changed files with 353 additions and 286 deletions

View File

@ -25,10 +25,12 @@ and this project adheres to
* [person] show current address in search results * [person] show current address in search results
* [person] show alt names in search results * [person] show alt names in search results
* [admin]: links to activity admin section added again. * [admin]: links to activity admin section added again.
* [household]: View accompanying periods of current and old household members.
* [tasks]: different layout for task list / my tasks, and fix link to tasks in alert or in warning * [tasks]: different layout for task list / my tasks, and fix link to tasks in alert or in warning
* [admin]: links to activity admin section added again. * [admin]: links to activity admin section added again.
* [household]: household addresses ordered by ValidFrom date and by id to show the last created address on top. * [household]: household addresses ordered by ValidFrom date and by id to show the last created address on top.
* [socialWorkAction]: display of social issue and parent issues + banner context added. * [socialWorkAction]: display of social issue and parent issues + banner context added.
* [DBAL dependencies] Upgrade to DBAL 3.1
## Test releases ## Test releases

View File

@ -44,7 +44,7 @@ class ActivityReason
/** /**
* @var array * @var array
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private $name; private $name;

View File

@ -43,7 +43,7 @@ class ActivityReasonCategory
/** /**
* @var string * @var string
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private $name; private $name;

View File

@ -44,7 +44,7 @@ class ActivityType
private ?int $id; private ?int $id;
/** /**
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private array $name = []; private array $name = [];

View File

@ -40,7 +40,7 @@ class ActivityTypeCategory
private ?int $id; private ?int $id;
/** /**
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private array $name = []; private array $name = [];

View File

@ -71,7 +71,7 @@ class TranslatableActivityType extends AbstractType
if ($options['active_only'] === true) { if ($options['active_only'] === true) {
$qb->where($qb->expr()->eq('at.active', ':active')); $qb->where($qb->expr()->eq('at.active', ':active'));
$qb->setParameter('active', true, \Doctrine\DBAL\Types\Type::BOOLEAN); $qb->setParameter('active', true, \Doctrine\DBAL\Types\Types::BOOLEAN);
} }
} }

View File

@ -4,7 +4,7 @@ namespace Chill\Migrations\Activity;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
/** /**
* Add an "active" column on activitytype table * Add an "active" column on activitytype table

View File

@ -22,7 +22,6 @@ final class Version20210401090853 extends AbstractMigration
// this up() migration is auto-generated, please modify it to your needs // this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SEQUENCE activitytypecategory_id_seq INCREMENT BY 1 MINVALUE 1 START 1000'); $this->addSql('CREATE SEQUENCE activitytypecategory_id_seq INCREMENT BY 1 MINVALUE 1 START 1000');
$this->addSql('CREATE TABLE activitytypecategory (id INT NOT NULL, name JSON NOT NULL, active BOOLEAN NOT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE TABLE activitytypecategory (id INT NOT NULL, name JSON NOT NULL, active BOOLEAN NOT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN activitytypecategory.name IS \'(DC2Type:json_array)\'');
$this->addSql('INSERT INTO activitytypecategory VALUES(1, \'{"fr": "Défaut", "en": "Default"}\', true)'); $this->addSql('INSERT INTO activitytypecategory VALUES(1, \'{"fr": "Défaut", "en": "Default"}\', true)');
} }

View File

@ -51,7 +51,6 @@ final class Version20210408122329 extends AbstractMigration
$this->addSql('ALTER TABLE activitytype ADD socialDataLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); $this->addSql('ALTER TABLE activitytype ADD socialDataLabel VARCHAR(255) DEFAULT \'\' NOT NULL');
$this->addSql('ALTER TABLE activitytype ALTER name SET NOT NULL'); $this->addSql('ALTER TABLE activitytype ALTER name SET NOT NULL');
$this->addSql('ALTER TABLE activitytype ALTER active DROP DEFAULT'); $this->addSql('ALTER TABLE activitytype ALTER active DROP DEFAULT');
$this->addSql('COMMENT ON COLUMN activitytype.name IS \'(DC2Type:json_array)\'');
} }
public function down(Schema $schema) : void public function down(Schema $schema) : void

View File

@ -34,7 +34,7 @@ class CancelReason
private $canceledBy; private $canceledBy;
/** /**
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private $name = []; private $name = [];

View File

@ -25,7 +25,7 @@ class Invite
private User $user; private User $user;
/** /**
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private array $status = []; private array $status = [];

View File

@ -50,10 +50,7 @@ final class Version20210715141731 extends AbstractMigration
$this->addSql('COMMENT ON COLUMN chill_calendar.calendar_range.startDate IS \'(DC2Type:date_immutable)\''); $this->addSql('COMMENT ON COLUMN chill_calendar.calendar_range.startDate IS \'(DC2Type:date_immutable)\'');
$this->addSql('COMMENT ON COLUMN chill_calendar.calendar_range.endDate IS \'(DC2Type:date_immutable)\''); $this->addSql('COMMENT ON COLUMN chill_calendar.calendar_range.endDate IS \'(DC2Type:date_immutable)\'');
$this->addSql('CREATE TABLE chill_calendar.cancel_reason (id INT NOT NULL, active BOOLEAN NOT NULL, canceledBy JSON NOT NULL, name JSON NOT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE TABLE chill_calendar.cancel_reason (id INT NOT NULL, active BOOLEAN NOT NULL, canceledBy JSON NOT NULL, name JSON NOT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN chill_calendar.cancel_reason.name IS \'(DC2Type:json_array)\'');
$this->addSql('COMMENT ON COLUMN chill_calendar.cancel_reason.canceledBy IS \'(DC2Type:json_array)\'');
$this->addSql('CREATE TABLE chill_calendar.invite (id INT NOT NULL, user_id INT DEFAULT NULL, status JSON NOT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE TABLE chill_calendar.invite (id INT NOT NULL, user_id INT DEFAULT NULL, status JSON NOT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN chill_calendar.invite.status IS \'(DC2Type:json_array)\'');
$this->addSql('CREATE INDEX IDX_F517FFA7A76ED395 ON chill_calendar.invite (user_id)'); $this->addSql('CREATE INDEX IDX_F517FFA7A76ED395 ON chill_calendar.invite (user_id)');
$this->addSql('ALTER TABLE chill_calendar.calendar ADD CONSTRAINT FK_712315ACA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE chill_calendar.calendar ADD CONSTRAINT FK_712315ACA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_calendar.calendar ADD CONSTRAINT FK_712315ACD7FA8EF0 FOREIGN KEY (accompanyingPeriod_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE chill_calendar.calendar ADD CONSTRAINT FK_712315ACD7FA8EF0 FOREIGN KEY (accompanyingPeriod_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');

View File

@ -34,6 +34,5 @@ final class Version20210723074557 extends AbstractMigration
$this->addSql('ALTER TABLE chill_calendar.calendar_to_non_professionals ADD CONSTRAINT fk_fadf2c77217bbb47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE chill_calendar.calendar_to_non_professionals ADD CONSTRAINT fk_fadf2c77217bbb47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_calendar.cancel_reason ALTER canceledBy TYPE JSON'); $this->addSql('ALTER TABLE chill_calendar.cancel_reason ALTER canceledBy TYPE JSON');
$this->addSql('ALTER TABLE chill_calendar.cancel_reason ALTER canceledBy DROP DEFAULT'); $this->addSql('ALTER TABLE chill_calendar.cancel_reason ALTER canceledBy DROP DEFAULT');
$this->addSql('COMMENT ON COLUMN chill_calendar.cancel_reason.canceledby IS \'(DC2Type:json_array)\'');
} }
} }

View File

@ -65,14 +65,14 @@ class CustomField
/** /**
* @var array * @var array
* *
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private $options = array(); private $options = array();
/** /**
* @var array * @var array
* *
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private $name; private $name;

View File

@ -50,7 +50,7 @@ class Option
* A json representation of text (multilingual) * A json representation of text (multilingual)
* *
* @var array * @var array
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private $text; private $text;

View File

@ -45,7 +45,7 @@ class CustomFieldsGroup
/** /**
* @var array * @var array
* *
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private $name; private $name;
@ -80,7 +80,7 @@ class CustomFieldsGroup
/** /**
* @var array * @var array
* *
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private $options = array(); private $options = array();

View File

@ -21,7 +21,7 @@ class DocGeneratorTemplate
private int $id; private int $id;
/** /**
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
* @Serializer\Groups({"read"}) * @Serializer\Groups({"read"})
*/ */
private array $name = []; private array $name = [];

View File

@ -22,7 +22,6 @@ final class Version20210812214310 extends AbstractMigration
$this->addSql('ALTER TABLE chill_docgen_template ADD entities TEXT'); $this->addSql('ALTER TABLE chill_docgen_template ADD entities TEXT');
$this->addSql('ALTER TABLE chill_docgen_template ADD context VARCHAR(255)'); $this->addSql('ALTER TABLE chill_docgen_template ADD context VARCHAR(255)');
$this->addSql('COMMENT ON COLUMN chill_docgen_template.entities IS \'(DC2Type:simple_array)\''); $this->addSql('COMMENT ON COLUMN chill_docgen_template.entities IS \'(DC2Type:simple_array)\'');
$this->addSql('COMMENT ON COLUMN chill_docgen_template.name IS \'(DC2Type:json_array)\'');
} }
public function down(Schema $schema): void public function down(Schema $schema): void

View File

@ -34,7 +34,7 @@ class DocumentCategory
/** /**
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private $name; private $name;

View File

@ -39,14 +39,14 @@ class StoredObject implements AsyncFileInterface, Document
private $filename; private $filename;
/** /**
* @ORM\Column(type="json_array", name="key") * @ORM\Column(type="json", name="key")
*/ */
private array $keyInfos = []; private array $keyInfos = [];
/** /**
* *
* @var int[] * @var int[]
* @ORM\Column(type="json_array", name="iv") * @ORM\Column(type="json", name="iv")
*/ */
private array $iv = []; private array $iv = [];
@ -69,7 +69,7 @@ class StoredObject implements AsyncFileInterface, Document
private string $type = ''; private string $type = '';
/** /**
* @ORM\Column(type="json_array", name="datas") * @ORM\Column(type="json", name="datas")
* @Serializer\Groups({"read"}) * @Serializer\Groups({"read"})
*/ */
private array $datas = []; private array $datas = [];

View File

@ -17,7 +17,6 @@ final class Version20180605102533 extends AbstractMigration
$this->addSql('CREATE SCHEMA chill_doc'); $this->addSql('CREATE SCHEMA chill_doc');
$this->addSql('CREATE SEQUENCE chill_doc.person_document_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); $this->addSql('CREATE SEQUENCE chill_doc.person_document_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_doc.document_category (bundle_id VARCHAR(255) NOT NULL, id_inside_bundle INT NOT NULL, document_class VARCHAR(255) NOT NULL, name JSON NOT NULL, PRIMARY KEY(bundle_id, id_inside_bundle))'); $this->addSql('CREATE TABLE chill_doc.document_category (bundle_id VARCHAR(255) NOT NULL, id_inside_bundle INT NOT NULL, document_class VARCHAR(255) NOT NULL, name JSON NOT NULL, PRIMARY KEY(bundle_id, id_inside_bundle))');
$this->addSql('COMMENT ON COLUMN chill_doc.document_category.name IS \'(DC2Type:json_array)\'');
$this->addSql('CREATE TABLE chill_doc.person_document (id INT NOT NULL, category_bundle_id VARCHAR(255) DEFAULT NULL, category_id_inside_bundle INT DEFAULT NULL, scope_id INT DEFAULT NULL, user_id INT DEFAULT NULL, person_id INT DEFAULT NULL, title TEXT NOT NULL, description TEXT NOT NULL, content TEXT NOT NULL, date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE TABLE chill_doc.person_document (id INT NOT NULL, category_bundle_id VARCHAR(255) DEFAULT NULL, category_id_inside_bundle INT DEFAULT NULL, scope_id INT DEFAULT NULL, user_id INT DEFAULT NULL, person_id INT DEFAULT NULL, title TEXT NOT NULL, description TEXT NOT NULL, content TEXT NOT NULL, date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_41DA53C369A0BE36EF62EFC ON chill_doc.person_document (category_bundle_id, category_id_inside_bundle)'); $this->addSql('CREATE INDEX IDX_41DA53C369A0BE36EF62EFC ON chill_doc.person_document (category_bundle_id, category_id_inside_bundle)');
$this->addSql('CREATE INDEX IDX_41DA53C682B5931 ON chill_doc.person_document (scope_id)'); $this->addSql('CREATE INDEX IDX_41DA53C682B5931 ON chill_doc.person_document (scope_id)');

View File

@ -16,9 +16,6 @@ final class Version20180606133338 extends AbstractMigration
$this->addSql('CREATE SEQUENCE chill_doc.stored_object_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); $this->addSql('CREATE SEQUENCE chill_doc.stored_object_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_doc.stored_object (id INT NOT NULL, filename TEXT NOT NULL, key JSON NOT NULL, iv JSON NOT NULL, creation_date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, type TEXT NOT NULL, datas JSON NOT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE TABLE chill_doc.stored_object (id INT NOT NULL, filename TEXT NOT NULL, key JSON NOT NULL, iv JSON NOT NULL, creation_date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, type TEXT NOT NULL, datas JSON NOT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN chill_doc.stored_object.key IS \'(DC2Type:json_array)\'');
$this->addSql('COMMENT ON COLUMN chill_doc.stored_object.iv IS \'(DC2Type:json_array)\'');
$this->addSql('COMMENT ON COLUMN chill_doc.stored_object.datas IS \'(DC2Type:json_array)\'');
$this->addSql('ALTER TABLE chill_doc.person_document ADD object_id INT DEFAULT NULL'); $this->addSql('ALTER TABLE chill_doc.person_document ADD object_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_doc.person_document DROP content'); $this->addSql('ALTER TABLE chill_doc.person_document DROP content');
$this->addSql('ALTER TABLE chill_doc.person_document ADD CONSTRAINT FK_41DA53C232D562B FOREIGN KEY (object_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE chill_doc.person_document ADD CONSTRAINT FK_41DA53C232D562B FOREIGN KEY (object_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE');

View File

@ -46,7 +46,7 @@ class EventType
/** /**
* @var array * @var array
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private $name; private $name;

View File

@ -44,7 +44,7 @@ class Role
/** /**
* @var array * @var array
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private $name; private $name;

View File

@ -44,7 +44,7 @@ class Status
/** /**
* @var array * @var array
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private $name; private $name;

View File

@ -18,7 +18,7 @@ class NativeDateIntervalType extends DateIntervalType
public function getName(): string public function getName(): string
{ {
return \Doctrine\DBAL\Types\Type::DATEINTERVAL; return \Doctrine\DBAL\Types\Types::DATEINTERVAL;
} }
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string

View File

@ -28,7 +28,7 @@ class Country
/** /**
* @var string * @var string
* *
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
* @groups({"read"}) * @groups({"read"})
* *
*/ */

View File

@ -43,7 +43,7 @@ class Language
/** /**
* @var string array * @var string array
* *
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private $name; private $name;

View File

@ -52,7 +52,7 @@ class Scope
* *
* @var array * @var array
* *
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
* @Groups({"read"}) * @Groups({"read"})
*/ */
private $name = []; private $name = [];

View File

@ -116,7 +116,7 @@ class User implements AdvancedUserInterface {
* Array where SAML attributes's data are stored * Array where SAML attributes's data are stored
* @var array * @var array
* *
* @ORM\Column(type="json_array", nullable=true) * @ORM\Column(type="json", nullable=true)
*/ */
private $attributes; private $attributes;

View File

@ -20,7 +20,7 @@
namespace Chill\MainBundle\Timeline; namespace Chill\MainBundle\Timeline;
use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
@ -101,7 +101,7 @@ class TimelineBuilder implements ContainerAwareInterface
public function countItems($context, array $args) public function countItems($context, array $args)
{ {
$rsm = (new ResultSetMapping()) $rsm = (new ResultSetMapping())
->addScalarResult('total', 'total', Type::INTEGER); ->addScalarResult('total', 'total', Types::INTEGER);
list($select, $parameters) = $this->buildUnionQuery($context, $args); list($select, $parameters) = $this->buildUnionQuery($context, $args);

View File

@ -20,7 +20,6 @@ final class Version20210304085819 extends AbstractMigration
public function up(Schema $schema) : void public function up(Schema $schema) : void
{ {
$this->addSql('ALTER TABLE users ADD attributes JSONB DEFAULT NULL'); $this->addSql('ALTER TABLE users ADD attributes JSONB DEFAULT NULL');
$this->addSql('COMMENT ON COLUMN users.attributes IS \'(DC2Type:json_array)\'');
} }
public function down(Schema $schema) : void public function down(Schema $schema) : void

View File

@ -14,6 +14,8 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Household\Position; use Chill\PersonBundle\Entity\Household\Position;
use Chill\PersonBundle\Repository\Household\PositionRepository; use Chill\PersonBundle\Repository\Household\PositionRepository;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Symfony\Component\Security\Core\Security;
/** /**
* @Route("/{_locale}/person/household") * @Route("/{_locale}/person/household")
@ -24,11 +26,14 @@ class HouseholdController extends AbstractController
private PositionRepository $positionRepository; 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->translator = $translator;
$this->positionRepository = $positionRepository; $this->positionRepository = $positionRepository;
$this->security = $security;
} }
/** /**
@ -77,17 +82,46 @@ class HouseholdController extends AbstractController
*/ */
public function accompanyingPeriod(Request $request, Household $household) public function accompanyingPeriod(Request $request, Household $household)
{ {
// TODO ACL
$members = $household->getMembers(); $currentMembers = $household->getCurrentPersons();
foreach($members as $m) { $accompanyingPeriods = [];
$accompanyingPeriods = $m->getPerson()->getAccompanyingPeriods();
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', return $this->render('@ChillPerson/Household/accompanying_period.html.twig',
[ [
'household' => $household, 'household' => $household,
'accompanying_periods' => $accompanyingPeriods 'accompanying_periods' => $accompanyingPeriods,
'accompanying_periods_old' => $accompanyingPeriodsOld
] ]
); );
} }

View File

@ -41,7 +41,7 @@ class MaritalStatus
/** /**
* @var string array * @var string array
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private $name; private $name;

View File

@ -406,7 +406,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* Array where customfield's data are stored * Array where customfield's data are stored
* @var array * @var array
* *
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private $cFData; private $cFData;
@ -613,6 +613,26 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $accompanyingPeriods; 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 * Get AccompanyingPeriodParticipations Collection
* *

View File

@ -21,7 +21,7 @@ use Chill\MainBundle\Export\FilterInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillDateType;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
use Chill\PersonBundle\Export\AbstractAccompanyingPeriodExportElement; use Chill\PersonBundle\Export\AbstractAccompanyingPeriodExportElement;
/** /**
@ -44,8 +44,8 @@ class AccompanyingPeriodClosingFilter extends AbstractAccompanyingPeriodExportEl
$qb->expr()->gte('accompanying_period.closingDate', ':date_from')); $qb->expr()->gte('accompanying_period.closingDate', ':date_from'));
$qb->andWhere($clause); $qb->andWhere($clause);
$qb->setParameter('date_from', $data['date_from'], Type::DATE); $qb->setParameter('date_from', $data['date_from'], Types::DATE_MUTABLE);
$qb->setParameter('date_to', $data['date_to'], Type::DATE); $qb->setParameter('date_to', $data['date_to'], Types::DATE_MUTABLE);
} }
public function applyOn(): string public function applyOn(): string

View File

@ -21,7 +21,7 @@ use Chill\MainBundle\Export\FilterInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillDateType;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
use Chill\PersonBundle\Export\AbstractAccompanyingPeriodExportElement; use Chill\PersonBundle\Export\AbstractAccompanyingPeriodExportElement;
/** /**
@ -52,8 +52,8 @@ class AccompanyingPeriodFilter extends AbstractAccompanyingPeriodExportElement i
); );
$qb->andWhere($clause); $qb->andWhere($clause);
$qb->setParameter('date_from', $data['date_from'], Type::DATE); $qb->setParameter('date_from', $data['date_from'], Types::DATE_MUTABLE);
$qb->setParameter('date_to', $data['date_to'], Type::DATE); $qb->setParameter('date_to', $data['date_to'], Types::DATE_MUTABLE);
} }
public function applyOn(): string public function applyOn(): string

View File

@ -21,7 +21,7 @@ use Chill\MainBundle\Export\FilterInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillDateType;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
use Chill\PersonBundle\Export\AbstractAccompanyingPeriodExportElement; use Chill\PersonBundle\Export\AbstractAccompanyingPeriodExportElement;
/** /**
@ -44,8 +44,8 @@ class AccompanyingPeriodOpeningFilter extends AbstractAccompanyingPeriodExportEl
$qb->expr()->gte('accompanying_period.openingDate', ':date_from')); $qb->expr()->gte('accompanying_period.openingDate', ':date_from'));
$qb->andWhere($clause); $qb->andWhere($clause);
$qb->setParameter('date_from', $data['date_from'], Type::DATE); $qb->setParameter('date_from', $data['date_from'], Types::DATE_MUTABLE);
$qb->setParameter('date_to', $data['date_to'], Type::DATE); $qb->setParameter('date_to', $data['date_to'], Types::DATE_MUTABLE);
} }
public function applyOn(): string public function applyOn(): string

View File

@ -77,7 +77,7 @@
<div class="wl-row"> <div class="wl-row">
<div class="wl-col title"><h3>{{ 'Participants'|trans }}</h3></div> <div class="wl-col title"><h3>{{ 'Participants'|trans }}</h3></div>
<div class="wl-col list"> <div class="wl-col list">
{% for p in accompanying_period.participations %} {% for p in accompanying_period.getCurrentParticipations %}
<span class="wl-item badge-person"> <span class="wl-item badge-person">
<a href="{{ path('chill_person_accompanying_period_list', { person_id: p.person.id }) }}"> <a href="{{ path('chill_person_accompanying_period_list', { person_id: p.person.id }) }}">
{{ p.person|chill_entity_render_string }} {{ p.person|chill_entity_render_string }}

View File

@ -9,6 +9,37 @@
{% include 'ChillPersonBundle:AccompanyingPeriod:_list.html.twig' %} {% 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"> <ul class="record_actions sticky-form-buttons">
<li class="cancel"> <li class="cancel">
<a href="{{ path ('chill_person_household_summary', {'household_id' : household.id } ) }}" class="btn btn-cancel"> <a href="{{ path ('chill_person_household_summary', {'household_id' : household.id } ) }}" class="btn btn-cancel">

View File

@ -22,7 +22,7 @@ namespace Chill\PersonBundle\Widget;
use Chill\MainBundle\Templating\Widget\WidgetInterface; use Chill\MainBundle\Templating\Widget\WidgetInterface;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\Expr; use Doctrine\ORM\Query\Expr;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
@ -123,7 +123,7 @@ class PersonListWidget implements WidgetInterface
(new Expr())->between(':now', 'ap.openingDate', 'ap.closingDate') (new Expr())->between(':now', 'ap.openingDate', 'ap.closingDate')
); );
$and->add($or); $and->add($or);
$qb->setParameter('now', new \DateTime(), Type::DATE); $qb->setParameter('now', new \DateTime(), Types::DATE_MUTABLE);
} }

View File

@ -61,7 +61,7 @@ interface PersonFilteringInterface
public function getPersonIds(EntityManager $em, User $user) public function getPersonIds(EntityManager $em, User $user)
{ {
$rsmBuilder = new ResultSetMappingBuilder($em); $rsmBuilder = new ResultSetMappingBuilder($em);
$rsmBuilder->addScalarResult('id', 'id', Type::BIGINT); $rsmBuilder->addScalarResult('id', 'id', Types::BIGINT);
$personTable = $em->getClassMetadata('ChillPersonBundle:Person') $personTable = $em->getClassMetadata('ChillPersonBundle:Person')
->getTableName(); ->getTableName();

View File

@ -17,7 +17,6 @@ class Version20150607231010 extends AbstractMigration
. 'recorded.'; . 'recorded.';
} }
/** /**
* @param Schema $schema * @param Schema $schema
*/ */
@ -28,36 +27,26 @@ class Version20150607231010 extends AbstractMigration
'Migration can only be executed safely on \'postgresql\'.' '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'); $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)) { if (isset($defaultCenterId)) {
$this->addSql('UPDATE person SET center_id = :id', array('id' => $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 ' $this->addSql('ALTER TABLE person '
. 'ADD CONSTRAINT FK_person_center FOREIGN KEY (center_id) ' . 'ADD CONSTRAINT FK_person_center FOREIGN KEY (center_id) '
. 'REFERENCES centers (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); . '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)'); $this->addSql('CREATE INDEX IDX_person_center ON person (center_id)');
} }

View File

@ -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->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('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('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('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;"); $this->addsql("ALTER TABLE chill_person_closingmotive ADD ordering DOUBLE PRECISION DEFAULT '0' NOT NULL;");

View File

@ -24,6 +24,5 @@ final class Version20210419112619 extends AbstractMigration
public function down(Schema $schema) : void public function down(Schema $schema) : void
{ {
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_closingmotive.name IS \'(DC2Type:json_array)\'');
} }
} }

View File

@ -26,6 +26,12 @@ household:
many {Montrer # anciennes ou futures appartenances} many {Montrer # anciennes ou futures appartenances}
other {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 Hide memberships: Masquer
Those members does not share address: Ces usagers ne partagent pas l'adresse du ménage. 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. Any persons into this position: Aucune personne n'appartient au ménage à cette position.

View File

@ -74,7 +74,7 @@ class Report implements HasCenterInterface, HasScopeInterface
/** /**
* @var array * @var array
* @ORM\Column(type="json_array") * @ORM\Column(type="json")
*/ */
private $cFData; private $cFData;

View File

@ -8,7 +8,7 @@ use Doctrine\ORM\QueryBuilder;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\Role;
use Chill\TaskBundle\Security\Authorization\TaskVoter; use Chill\TaskBundle\Security\Authorization\TaskVoter;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Center;
/** /**
@ -191,7 +191,7 @@ class SingleTaskRepository extends EntityRepository
->add($this->buildNowIsAfterStartDate($qb, true)) ->add($this->buildNowIsAfterStartDate($qb, true))
; ;
} }
$qb->setParameter('now', new \DateTime('today'), Type::DATE); $qb->setParameter('now', new \DateTime('today'), Types::DATE_MUTABLE);
$qb->andWhere($andWhere); $qb->andWhere($andWhere);
} }

View File

@ -19,7 +19,6 @@ final class Version20190307111314 extends AbstractMigration
$this->addSql('CREATE SEQUENCE chill_third_party_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); $this->addSql('CREATE SEQUENCE chill_third_party_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_third_party (id INT NOT NULL, name VARCHAR(255) NOT NULL, telephone VARCHAR(64) DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, comment TEXT DEFAULT NULL, type JSON DEFAULT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE TABLE chill_third_party (id INT NOT NULL, name VARCHAR(255) NOT NULL, telephone VARCHAR(64) DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, comment TEXT DEFAULT NULL, type JSON DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN chill_third_party.type IS \'(DC2Type:json_array)\'');
} }