diff --git a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCancelReason.php b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCancelReason.php index d9e92a049..041c4178e 100644 --- a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCancelReason.php +++ b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCancelReason.php @@ -25,18 +25,18 @@ class LoadCancelReason extends Fixture implements FixtureGroupInterface public function load(ObjectManager $manager): void { $arr = array( - array('name' => array('fr' => 'Annulé par l\'utilisateur')), - array('name' => array('fr' => 'Annulé par l\'usager')), - array('name' => array('fr' => 'Ne pas comptabiliser')), + array('name' => CancelReason::CANCELEDBY_USER), + array('name' => CancelReason::CANCELEDBY_PERSON), + array('name' => CancelReason::CANCELEDBY_DONOTCOUNT), ); foreach ($arr as $a) { - print "Creating calendar cancel reason : " . $a['name']['fr'] . "\n"; + print "Creating calendar cancel reason : " . $a['name'] . "\n"; $cancelReason= (new CancelReason()) ->setCanceledBy($a['name']) ->setActive(true); $manager->persist($cancelReason); - $reference = 'CancelReason_'.$a['name']['fr']; + $reference = 'CancelReason_'.$a['name']; $this->addReference($reference, $cancelReason); static::$references[] = $reference; } diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 8a106efbd..da0f797d7 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -65,15 +65,6 @@ class Calendar */ private ?Collection $persons = null; - /** - * - * @ORM\ManyToMany( - * targetEntity="Chill\PersonBundle\Entity\Person", - * cascade={"persist", "remove", "merge", "detach"}) - * @ORM\JoinTable(name="chill_calendar.calendar_to_non_professionals") - */ - private ?Collection $nonProfessionals = null; - /** * * @ORM\ManyToMany( @@ -140,7 +131,6 @@ class Calendar { $this->comment = new CommentEmbeddable(); $this->persons = new ArrayCollection(); - $this->nonProfessionals = new ArrayCollection(); $this->professionals = new ArrayCollection(); $this->invites = new ArrayCollection(); } @@ -271,30 +261,6 @@ class Calendar return $this; } - /** - * @return Collection|Person[] - */ - public function getNonProfessionals(): Collection - { - return $this->nonProfessionals; - } - - public function addNonProfessional(Person $nonProfessional): self - { - if (!$this->nonProfessionals->contains($nonProfessional)) { - $this->nonProfessionals[] = $nonProfessional; - } - - return $this; - } - - public function removeNonProfessional(Person $nonProfessional): self - { - $this->nonProfessionals->removeElement($nonProfessional); - - return $this; - } - /** * @return Collection|ThirdParty[] */ diff --git a/src/Bundle/ChillCalendarBundle/Entity/CancelReason.php b/src/Bundle/ChillCalendarBundle/Entity/CancelReason.php index 6a21b215c..ce3d1f6e4 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CancelReason.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CancelReason.php @@ -11,6 +11,11 @@ use Doctrine\ORM\Mapping as ORM; */ class CancelReason { + + const CANCELEDBY_USER = 'CANCELEDBY_USER'; + const CANCELEDBY_PERSON = 'CANCELEDBY_PERSON'; + const CANCELEDBY_DONOTCOUNT = 'CANCELEDBY_DONOTCOUNT'; + /** * @ORM\Id * @ORM\GeneratedValue @@ -24,7 +29,7 @@ class CancelReason private $active; /** - * @ORM\Column(type="json_array") + * @ORM\Column(type="string", length=255) */ private $canceledBy; @@ -50,12 +55,12 @@ class CancelReason return $this; } - public function getCanceledBy(): ?array + public function getCanceledBy(): ?string { return $this->canceledBy; } - public function setCanceledBy(array $canceledBy): self + public function setCanceledBy(string $canceledBy): self { $this->canceledBy = $canceledBy; diff --git a/src/Bundle/ChillCalendarBundle/Form/CalendarType.php b/src/Bundle/ChillCalendarBundle/Form/CalendarType.php index 00b410f7f..e8afcabcc 100644 --- a/src/Bundle/ChillCalendarBundle/Form/CalendarType.php +++ b/src/Bundle/ChillCalendarBundle/Form/CalendarType.php @@ -69,7 +69,7 @@ class CalendarType extends AbstractType 'required' => false, 'class' => CancelReason::class, 'choice_label' => function (CancelReason $entity) { - return $this->translatableStringHelper->localize($entity->getCanceledBy()); + return $entity->getCanceledBy(); }, )) ->add('sendSMS', ChoiceType::class, array( diff --git a/src/Bundle/ChillCalendarBundle/migrations/Version20210723074557.php b/src/Bundle/ChillCalendarBundle/migrations/Version20210723074557.php new file mode 100644 index 000000000..3f85968c4 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/migrations/Version20210723074557.php @@ -0,0 +1,39 @@ +addSql('DROP TABLE chill_calendar.calendar_to_non_professionals'); + $this->addSql('ALTER TABLE chill_calendar.cancel_reason ALTER canceledby TYPE VARCHAR(255)'); + $this->addSql('ALTER TABLE chill_calendar.cancel_reason ALTER canceledby DROP DEFAULT'); + $this->addSql('COMMENT ON COLUMN chill_calendar.cancel_reason.canceledBy IS NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('CREATE TABLE chill_calendar.calendar_to_non_professionals (calendar_id INT NOT NULL, person_id INT NOT NULL, PRIMARY KEY(calendar_id, person_id))'); + $this->addSql('CREATE INDEX idx_fadf2c77217bbb47 ON chill_calendar.calendar_to_non_professionals (person_id)'); + $this->addSql('CREATE INDEX idx_fadf2c77a40a2c8 ON chill_calendar.calendar_to_non_professionals (calendar_id)'); + $this->addSql('ALTER TABLE chill_calendar.calendar_to_non_professionals ADD CONSTRAINT fk_fadf2c77a40a2c8 FOREIGN KEY (calendar_id) REFERENCES chill_calendar.calendar (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 DROP DEFAULT'); + $this->addSql('COMMENT ON COLUMN chill_calendar.cancel_reason.canceledby IS \'(DC2Type:json_array)\''); + } +}