From a7517eb647b43c95448151ab59a80d612e527c36 Mon Sep 17 00:00:00 2001 From: juminet Date: Tue, 15 Apr 2025 12:59:57 +0000 Subject: [PATCH] Adding a second phone number to thirdparty entity --- .../unreleased/Feature-20250325-164301.yaml | 7 ++++ .../unreleased/Fixed-20250325-164327.yaml | 9 +++++ .../public/vuejs/_components/BadgeEntity.vue | 5 +-- .../PersonsAssociated/ParticipationItem.vue | 3 +- .../components/Requestor.vue | 3 +- .../components/Resources/ResourceItem.vue | 1 + .../vuejs/AccompanyingCourseWorkEdit/App.vue | 7 ++-- .../ThirdpartyCSVExportController.php | 2 ++ .../Entity/ThirdParty.php | 17 ++++++++++ .../Form/ThirdPartyType.php | 4 +++ .../Repository/ThirdPartyRepository.php | 2 ++ .../Entity/ThirdPartyRenderBox.vue | 18 ++++++++++ .../vuejs/_components/OnTheFly/ThirdParty.vue | 22 ++++++++++-- .../Resources/public/vuejs/_js/i18n.js | 1 + .../views/Entity/thirdparty.html.twig | 14 ++++++-- .../views/ThirdParty/_form.html.twig | 1 + .../_form_thirdparty_children.html.twig | 13 +++++-- .../Resources/views/ThirdParty/view.html.twig | 12 +++++++ .../Normalizer/ThirdPartyNormalizer.php | 1 + .../chill.api.specs.yaml | 2 ++ .../migrations/Version20250325085950.php | 34 +++++++++++++++++++ .../translations/messages.fr.yml | 5 ++- 22 files changed, 168 insertions(+), 15 deletions(-) create mode 100644 .changes/unreleased/Feature-20250325-164301.yaml create mode 100644 .changes/unreleased/Fixed-20250325-164327.yaml create mode 100644 src/Bundle/ChillThirdPartyBundle/migrations/Version20250325085950.php diff --git a/.changes/unreleased/Feature-20250325-164301.yaml b/.changes/unreleased/Feature-20250325-164301.yaml new file mode 100644 index 000000000..181466d14 --- /dev/null +++ b/.changes/unreleased/Feature-20250325-164301.yaml @@ -0,0 +1,7 @@ +kind: Feature +body: Added a second phone number "telephone2" to the thirdParty entity. Adapted twig + templates and vuejs apps to handle this phone number +time: 2025-03-25T16:43:01.003712495+01:00 +custom: + Issue: "364" + SchemaChange: Add columns or tables diff --git a/.changes/unreleased/Fixed-20250325-164327.yaml b/.changes/unreleased/Fixed-20250325-164327.yaml new file mode 100644 index 000000000..7bf8b3d6c --- /dev/null +++ b/.changes/unreleased/Fixed-20250325-164327.yaml @@ -0,0 +1,9 @@ +kind: Fixed +body: |- + FIXED wrong translations in the on-the-fly for creation of thirdParty + FIXED update of phone number in on-the-fly edition of thirdParty + FIXED closing of modal when editing thirdParty in accompanying course works +time: 2025-03-25T16:43:27.437038378+01:00 +custom: + Issue: "" + SchemaChange: No schema change diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/BadgeEntity.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/BadgeEntity.vue index 3357d6463..1c5d2b6da 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/BadgeEntity.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/BadgeEntity.vue @@ -26,9 +26,9 @@ trans(THIRDPARTY_CONTACT_OF) }} {{ - trans(THIRDPARTY_A_CONTACT) + trans(THIRDPARTY_A_COMPANY) }} - {{ $t("thirdparty.contact") }} + {{ trans(THIRDPARTY_A_CONTACT) }} @@ -54,6 +54,7 @@ import { ACCEPTED_USERS, THIRDPARTY_A_CONTACT, THIRDPARTY_CONTACT_OF, + THIRDPARTY_A_COMPANY, PERSON, THIRDPARTY, } from "translator"; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue index 3c5562d08..c2dbd6e0c 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue @@ -204,7 +204,8 @@ export default { } else if (payload.type === "thirdparty") { body.name = payload.data.text; body.email = payload.data.email; - body.telephone = payload.data.phonenumber; + body.telephone = payload.data.telephone; + body.telephone2 = payload.data.telephone2; body.address = { id: payload.data.address.address_id }; makeFetch( diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue index 23a191817..5858cdb00 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue @@ -385,7 +385,8 @@ export default { } else if (payload.type === "thirdparty") { body.name = payload.data.text; body.email = payload.data.email; - body.telephone = payload.data.phonenumber; + body.telephone = payload.data.telephone; + body.telephone2 = payload.data.telephone2; if (payload.data.address) { body.address = { id: payload.data.address.address_id }; } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue index 70f09e4e6..87daacf47 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue @@ -194,6 +194,7 @@ export default { body.name = payload.data.name; body.email = payload.data.email; body.telephone = payload.data.telephone; + body.telephone2 = payload.data.telephone2; body.address = payload.data.address ? { id: payload.data.address.address_id } : null; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue index 1f8a99d43..952bbc2d3 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue @@ -745,7 +745,8 @@ export default { let body = { type: payload.type }; body.name = payload.data.text; body.email = payload.data.email; - body.telephone = payload.data.phonenumber; + body.telephone = payload.data.telephone; + body.telephone2 = payload.data.telephone2; body.address = { id: payload.data.address.address_id }; makeFetch( @@ -755,7 +756,9 @@ export default { ) .then((response) => { this.$store.dispatch("updateThirdParty", response); - this.$refs.onTheFly.closeModal(); + for (let otf of this.$refs.onTheFly) { + otf.closeModal(); + } }) .catch((error) => { if (error.name === "ValidationException") { diff --git a/src/Bundle/ChillThirdPartyBundle/Controller/ThirdpartyCSVExportController.php b/src/Bundle/ChillThirdPartyBundle/Controller/ThirdpartyCSVExportController.php index 98d0ffafd..708d08076 100644 --- a/src/Bundle/ChillThirdPartyBundle/Controller/ThirdpartyCSVExportController.php +++ b/src/Bundle/ChillThirdPartyBundle/Controller/ThirdpartyCSVExportController.php @@ -65,6 +65,7 @@ class ThirdpartyCSVExportController extends AbstractController 'Name', 'Profession', 'Telephone', + 'Telephone2', 'Email', 'Address', 'Comment', @@ -76,6 +77,7 @@ class ThirdpartyCSVExportController extends AbstractController 'Contact name', 'Contact firstname', 'Contact phone', + 'Contact phone2', 'Contact email', 'Contact address', 'Contact profession', diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index eb35aea4d..e65a06515 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -209,6 +209,11 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin #[PhonenumberConstraint(type: 'any')] private ?PhoneNumber $telephone = null; + #[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])] + #[ORM\Column(name: 'telephone2', type: 'phone_number', nullable: true)] + #[PhonenumberConstraint(type: 'any')] + private ?PhoneNumber $telephone2 = null; + #[ORM\Column(name: 'types', type: \Doctrine\DBAL\Types\Types::JSON, nullable: true)] private ?array $thirdPartyTypes = []; @@ -429,6 +434,11 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin return $this->telephone; } + public function getTelephone2(): ?PhoneNumber + { + return $this->telephone2; + } + /** * Get type. */ @@ -712,6 +722,13 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin return $this; } + public function setTelephone2(?PhoneNumber $telephone2 = null): self + { + $this->telephone2 = $telephone2; + + return $this; + } + /** * Set type. * diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index 26ed31d32..9cd671872 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php @@ -59,6 +59,10 @@ class ThirdPartyType extends AbstractType 'label' => 'Phonenumber', 'required' => false, ]) + ->add('telephone2', ChillPhoneNumberType::class, [ + 'label' => 'telephone2', + 'required' => false, + ]) ->add('email', EmailType::class, [ 'required' => false, ]) diff --git a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php index d4e0e55ee..111be4089 100644 --- a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php +++ b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php @@ -42,6 +42,7 @@ class ThirdPartyRepository implements ObjectRepository parent.name AS name, parent.profession AS profession, parent.telephone AS telephone, + parent.telephone2 AS telephone2, parent.email AS email, CONCAT_WS(' ', parent_address.street, parent_address.streetnumber, parent_postal.code, parent_postal.label) AS address, parent.comment AS comment, @@ -55,6 +56,7 @@ class ThirdPartyRepository implements ObjectRepository contact.name AS contact_name, contact.firstname AS contact_firstname, contact.telephone AS contact_phone, + contact.telephone2 AS contact_phone2, contact.email AS contact_email, contact.profession AS contact_profession, CONCAT_WS(' ', contact_address.street, contact_address.streetnumber, contact_postal.code, contact_postal.label) AS contact_address diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/Entity/ThirdPartyRenderBox.vue b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/Entity/ThirdPartyRenderBox.vue index aaa80bd08..0fee3dcdb 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/Entity/ThirdPartyRenderBox.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/Entity/ThirdPartyRenderBox.vue @@ -91,6 +91,18 @@ }} +
  • + + {{ + thirdparty.telephone2 + }} +
  • +
  • + + {{ thirdparty.telephone2 }} + +
  • {{ diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue index 9b430d3df..3c949412c 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -223,6 +223,19 @@ /> +
    + + +
    +
  • @@ -135,8 +139,14 @@ }) }}
  • - {% if thirdparty.telephone %} - {{ thirdparty.telephone|chill_format_phonenumber }} + {% if thirdparty.telephone or thirdparty.telephone2 %} + {% if thirdparty.telephone is not null %} + {{ thirdparty.telephone|chill_format_phonenumber }} + {% endif %} + {% if thirdparty.telephone2 is not null %} + {% if thirdparty.telephone is not null %}, {% endif %} + {{ thirdparty.telephone2|chill_format_phonenumber }} + {% endif %} {% else %} {{ 'thirdparty.No_phonenumber'|trans }} {% endif %} diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig index 34da002f0..dd4dd488d 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig @@ -22,6 +22,7 @@ {{ form_row(form.typesAndCategories) }} {{ form_row(form.telephone) }} +{{ form_row(form.telephone2) }} {{ form_row(form.email) }} {% if form.contactDataAnonymous is defined %} diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form_thirdparty_children.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form_thirdparty_children.html.twig index 81dd4997f..fc8e60928 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form_thirdparty_children.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form_thirdparty_children.html.twig @@ -24,17 +24,24 @@
    -
    +
    {{ form_widget(form.telephone) }} {{ form_errors(form.telephone) }} {{ form_label(form.telephone) }}
    -
    +
    + {{ form_widget(form.telephone2) }} + {{ form_errors(form.telephone2) }} + {{ form_label(form.telephone2) }} +
    +
    +
    +
    {{ form_widget(form.email) }} {{ form_errors(form.email) }} {{ form_label(form.email) }}
    -
    +
    {{ form_widget(form.contactDataAnonymous) }} {{ form_label(form.contactDataAnonymous) }} {{ form_errors(form.contactDataAnonymous) }} diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig index 4e7fd159d..bc5fc3325 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig @@ -76,6 +76,18 @@ {% endif %} + +
    {{ 'Phonenumber2'|trans }}
    +
    + {% if thirdParty.telephone2 == null %} + {{ 'thirdparty.No_phonenumber'|trans }} + {% else %} + + {{ thirdParty.telephone2|chill_format_phonenumber }} + + {% endif %} +
    +
    {{ 'email'|trans }}
    {% if thirdParty.email == null %} diff --git a/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php b/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php index 26f175705..929b97c1e 100644 --- a/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php +++ b/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php @@ -55,6 +55,7 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf 'profession' => $this->normalizer->normalize($thirdParty->getProfession(), $format, $context), 'address' => $this->normalizer->normalize($thirdParty->getAddress(), $format, ['address_rendering' => 'short']), 'telephone' => $this->normalizer->normalize($thirdParty->getTelephone(), $format, $context), + 'telephone2' => $this->normalizer->normalize($thirdParty->getTelephone2(), $format, $context), 'email' => $thirdParty->getEmail(), 'isChild' => $thirdParty->isChild(), 'parent' => $this->normalizer->normalize($thirdParty->getParent(), $format, $context), diff --git a/src/Bundle/ChillThirdPartyBundle/chill.api.specs.yaml b/src/Bundle/ChillThirdPartyBundle/chill.api.specs.yaml index 5477075e0..dfb9155f7 100644 --- a/src/Bundle/ChillThirdPartyBundle/chill.api.specs.yaml +++ b/src/Bundle/ChillThirdPartyBundle/chill.api.specs.yaml @@ -28,6 +28,8 @@ components: type: string telephone: type: string + telephone2: + type: string address: $ref: "#/components/schemas/Address" Address: diff --git a/src/Bundle/ChillThirdPartyBundle/migrations/Version20250325085950.php b/src/Bundle/ChillThirdPartyBundle/migrations/Version20250325085950.php new file mode 100644 index 000000000..a2dc8b5ce --- /dev/null +++ b/src/Bundle/ChillThirdPartyBundle/migrations/Version20250325085950.php @@ -0,0 +1,34 @@ +addSql('ALTER TABLE chill_3party.third_party ADD telephone2 VARCHAR(35) DEFAULT NULL'); + $this->addSql('COMMENT ON COLUMN chill_3party.third_party.telephone2 IS \'(DC2Type:phone_number)\''); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_3party.third_party DROP telephone2'); + } +} diff --git a/src/Bundle/ChillThirdPartyBundle/translations/messages.fr.yml b/src/Bundle/ChillThirdPartyBundle/translations/messages.fr.yml index 52bae6fee..c5a5a110f 100644 --- a/src/Bundle/ChillThirdPartyBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillThirdPartyBundle/translations/messages.fr.yml @@ -4,6 +4,7 @@ third parties: tiers firstname: Prénom name: Nom telephone: Téléphone +telephone2: Autre numéro de téléphone adress: Adresse email: Courriel comment: Commentaire @@ -39,7 +40,7 @@ thirdparty.A contact: Une personne physique thirdparty.contact: Personne physique thirdparty.Contact of: Contact de thirdparty.a_company_explanation: >- - Les personnes morales peuvent compter un ou plusieurs contacts, interne à l'instution. Il est également possible de + Les personnes morales peuvent compter un ou plusieurs contacts, interne à l'institution. Il est également possible de leur associer un acronyme, et le nom d'un service. thirdparty.a_contact_explanation: >- Les personnes physiques ne disposent pas d'acronyme, de service, ou de contacts sous-jacents. Il est possible de leur @@ -149,6 +150,8 @@ Contact id: Identifiant du contact Contact name: Nom du contact Contact firstname: Prénom du contact Contact phone: Téléphone du contact +Contact phone2: Autre téléphone du contact +Telephone2: Autre téléphone Contact email: Courrier électronique du contact Contact address: Adresse du contact Contact profession: Profession du contact