diff --git a/src/Entity/Denomination.php b/src/Entity/Denomination.php index 193773dc..1ba326ff 100644 --- a/src/Entity/Denomination.php +++ b/src/Entity/Denomination.php @@ -30,6 +30,14 @@ class Denomination */ private $label; + /** + * @var string|null + * + * @Gedmo\Translatable + * @ORM\Column(name="short_label", type="string", length=255, nullable=true) + */ + private $shortLabel; + /** * Class constructor */ @@ -72,4 +80,28 @@ public function getLabel() { return $this->label; } + + /** + * Set short label + * + * @param string $label The short version of this denomination's label. + * + * @return self + */ + public function setShortLabel(?string $shortLabel): self + { + $this->shortLabel = $shortLabel; + + return $this; + } + + /** + * Get shortLabel + * + * @return string|null + */ + public function getShortLabel(): ?string + { + return $this->shortLabel; + } } diff --git a/src/Migrations/Version20240204132311.php b/src/Migrations/Version20240204132311.php new file mode 100644 index 00000000..353190be --- /dev/null +++ b/src/Migrations/Version20240204132311.php @@ -0,0 +1,40 @@ +addSql('ALTER TABLE denomination ADD short_label VARCHAR(255) DEFAULT NULL'); + + // Update existing denominations + $this->addSql("UPDATE denomination SET short_label = 'M.' WHERE label = 'Monsieur'"); + $this->addSql("UPDATE denomination SET short_label = 'Mme' WHERE label = 'Madame'"); + $this->addSql("UPDATE denomination SET short_label = 'Mx' WHERE label = 'Mix'"); + $this->addSql("UPDATE denomination SET short_label = 'Dr' WHERE label = 'Docteur'"); + $this->addSql("UPDATE denomination SET short_label = 'Me' WHERE label = 'Maître'"); + $this->addSql("UPDATE denomination SET short_label = 'Sté' WHERE label = 'Société'"); + $this->addSql("UPDATE denomination SET short_label = 'Asso' WHERE label = 'Association'"); + } + + public function down(Schema $schema): void + { + // Remove short_label field + $this->addSql('ALTER TABLE denomination DROP short_label'); + } +} diff --git a/templates/PDF/Tag/_tag.html.twig b/templates/PDF/Tag/_tag.html.twig index 165ab6e0..3ef6c99b 100644 --- a/templates/PDF/Tag/_tag.html.twig +++ b/templates/PDF/Tag/_tag.html.twig @@ -9,7 +9,7 @@ {% endif %} - {{ person.denomination ? person.denomination.label : "" }} + {{ person.denomination ? (person.denomination.shortLabel ?? person.denomination.label) : "" }} {{ person.lastname | upper }} {{ person.firstname }}