فهرست منبع

dolibarr sync service full refactoring

Olivier Massot 3 سال پیش
والد
کامیت
56e7eb326e

+ 2 - 0
src/Enum/Access/FunctionEnum.php

@@ -7,6 +7,8 @@ use MyCLabs\Enum\Enum;
 
 /**
  * Activities functions.
+ * @method static STUDENT()
+ * @method static ADHERENT()
  */
 class FunctionEnum extends Enum
 {

+ 1 - 0
src/Enum/Access/RoleEnum.php

@@ -7,6 +7,7 @@ use MyCLabs\Enum\Enum;
 
 /**
  * Role
+ * @method static ROLE_ADMIN()
  */
 class RoleEnum extends Enum
 {

+ 4 - 0
src/Enum/Core/ContactPointTypeEnum.php

@@ -8,6 +8,10 @@ use MyCLabs\Enum\Enum;
 /**
  * Type de point de contact
  *
+ * @method static BILL()
+ * @method static CONTACT()
+ * @method static PRINCIPAL()
+ * @method static OTHER()
  */
 class ContactPointTypeEnum extends Enum
 {

+ 5 - 0
src/Enum/Organization/AddressPostalOrganizationTypeEnum.php

@@ -7,6 +7,11 @@ use MyCLabs\Enum\Enum;
 
 /**
  * Type d'adresse postale pour une organization
+ * @method static ADDRESS_BILL()
+ * @method static ADDRESS_CONTACT()
+ * @method static ADDRESS_HEAD_OFFICE()
+ * @method static ADDRESS_PRACTICE()
+ * @method static ADDRESS_OTHER()
  */
 class AddressPostalOrganizationTypeEnum extends Enum
 {

+ 2 - 0
src/Enum/Organization/OrganizationIdsEnum.php

@@ -7,6 +7,8 @@ use MyCLabs\Enum\Enum;
 
 /**
  * Id de structure spécifiques
+ * @method static CMF()
+ * @method static FFEC()
  */
 class OrganizationIdsEnum extends Enum
 {

+ 17 - 0
src/Enum/Person/GenderEnum.php

@@ -0,0 +1,17 @@
+<?php
+declare(strict_types=1);
+
+namespace App\Enum\Person;
+
+use MyCLabs\Enum\Enum;
+
+/**
+ * Genres des personnes
+ * @method static MISS()
+ * @method static MISTER()
+ */
+class GenderEnum extends Enum
+{
+    private const MISTER = 'MISTER';
+    private const MISS = 'MISS';
+}

+ 176 - 158
src/Service/Dolibarr/DolibarrSync/DolibarrSyncService.php

@@ -3,16 +3,15 @@ declare(strict_types=1);
 
 namespace App\Service\Dolibarr\DolibarrSync;
 
-use App\Entity\Core\AddressPostal;
 use App\Entity\Organization\Organization;
 use App\Entity\Person\Person;
 use App\Enum\Access\FunctionEnum;
 use App\Enum\Access\RoleEnum;
 use App\Enum\Core\ContactPointTypeEnum;
-use App\Enum\Network\NetworkEnum;
 use App\Enum\Organization\AddressPostalOrganizationTypeEnum;
 use App\Enum\Organization\OrganizationIdsEnum;
 use App\Enum\Organization\SettingsProductEnum;
+use App\Enum\Person\GenderEnum;
 use App\Repository\Access\AccessRepository;
 use App\Repository\Access\FunctionTypeRepository;
 use App\Repository\Core\ContactPointRepository;
@@ -27,6 +26,7 @@ use HttpException;
 use libphonenumber\PhoneNumber;
 use libphonenumber\PhoneNumberFormat;
 use libphonenumber\PhoneNumberUtil;
+use Psr\Log\LoggerInterface;
 use Symfony\Contracts\Translation\TranslatorInterface;
 
 /**
@@ -43,7 +43,8 @@ class DolibarrSyncService
         private ContactPointRepository $contactPointRepository,
         private FunctionTypeRepository $functionTypeRepository,
         private DolibarrApiService $dolibarrApiService,
-        private TranslatorInterface $translator
+        private TranslatorInterface $translator,
+        private LoggerInterface $logger
     ) {}
 
     /**
@@ -55,157 +56,120 @@ class DolibarrSyncService
      * Returns an array of DolibarrSyncOperations
      *
      * @return array<DolibarrSyncOperation>
-     * @throws HttpException
+     * @throws Exception
      */
     public function scan(): array {
-
-        var_dump($this->translator->trans('HOUR_PRESIDENT', ['gender' => 'F'] )); die;
+        $this->logger->info("Dolibarr sync started");
 
         // Index the dolibarr clients by organization ids
         $dolibarrClientsIndex = $this->getDolibarrSocietiesIndex();
+        $this->logger->info(count($dolibarrClientsIndex) . " clients fetched from dolibarr");
 
         // Get all active accesses
         $membersIndex = $this->getActiveMembersIndex();
 
         // Get all the missions with an admin default role
         $adminMissions = [];
-        foreach ($this->functionTypeRepository->findBy(['roleByDefault' => RoleEnum::ROLE_ADMIN()]) as $functionType) {
+        foreach ($this->functionTypeRepository->findBy(['roleByDefault' => RoleEnum::ROLE_ADMIN()->getValue()]) as $functionType) {
             $adminMissions[] = $functionType->getMission();
         }
 
+        // Store networks ids id dolibarr
+        $cmfDolibarrId = (int)($this->dolibarrApiService->getSociety(OrganizationIdsEnum::CMF()->getValue())['id']);
+        $ffecDolibarrId = (int)($this->dolibarrApiService->getSociety(OrganizationIdsEnum::FFEC()->getValue())['id']);
+
         // Loop over the Opentalent organizations, and fill up the operations list
         $operations = [];
-        foreach ($this->organizationRepository->findAll() as $organization) {
-            if (!array_key_exists($organization->getId(), $dolibarrClientsIndex)) {
-                // this organization is not a client, probably a federation member
+        foreach ($dolibarrClientsIndex as $organizationId => $dolibarrSociety) {
+            $organization = $this->organizationRepository->find($organizationId);
+            if ($organization === null) {
+                $this->logger->error("Organization " . $organizationId . " not found in the Opentalent DB");
                 continue;
             }
 
-            $dolibarrSociety = $dolibarrClientsIndex[$organization->getId()];
-
             // Populate the expectedContacts array
-            if (array_key_exists($organization->getId(), $membersIndex)) {
-                $organizationMembers = $membersIndex[$organization->getId()];
-            } else {
-                $organizationMembers = [];
-            }
+            $organizationMembers = $membersIndex[$organization->getId()] ?? [];
 
-            $putSocietyData = [];
 
-            // ** Sync name
-            if ($organization->getName() !== $dolibarrSociety['name']) {
-                $putSocietyData['name'] = $organization->getName();
-            }
+            // ===== Update Society =====
+            $newSocietyData = [];
 
-            // ** Sync contact data of the client
-            // Postal address
-            /** @var AddressPostal | null */
-            $mainAddress = $this->getOrganizationPostalAddress($organization);
+            // Sync name
+            $newSocietyData['name'] = $organization->getName();
 
+            // Sync contact data of the client
+            $mainAddress = $this->getOrganizationPostalAddress($organization);
             if ($mainAddress !== null) {
-                $streetAddress = AddressPostalUtils::getFullStreetAddress($mainAddress, '\n');
+                $streetAddress = AddressPostalUtils::getFullStreetAddress($mainAddress);
                 if (trim($mainAddress->getAddressOwner() ?? '') !== '') {
                     $streetAddress = $mainAddress->getAddressOwner() . '\n' . $streetAddress;
                 }
-
-                if (
-                    preg_replace('/\s/', ' ', $streetAddress) !==
-                    preg_replace('/\s/', ' ', $dolibarrSociety['address'])
-                ) {
-                    $putSocietyData['address'] = $streetAddress;
-                }
-
-                if ($mainAddress->getPostalCode() !== $dolibarrSociety['zip']) {
-                    $putSocietyData['zip'] = $mainAddress->getPostalCode();
-                }
-
-                if ($mainAddress->getAddressCity() !== $dolibarrSociety['town']) {
-                    $putSocietyData['town'] = $mainAddress->getAddressCity();
-                }
+                $newSocietyData['address'] = $streetAddress;
+                $newSocietyData['zip'] = $mainAddress->getPostalCode();
+                $newSocietyData['town'] = $mainAddress->getAddressCity();
+            } else {
+                $newSocietyData['address'] = null;
+                $newSocietyData['zip'] = null;
+                $newSocietyData['town'] = null;
             }
 
             // Sync contact
-            $email = $this->getOrganizationEmail($organization);
-            if ($email !== $dolibarrSociety['email']) {
-                $putSocietyData['email'] = $email;
-            }
-
-            $phone = $this->getOrganizationPhone($organization);
-            if ($phone !== $dolibarrSociety['phone']) {
-                $putSocietyData['phone'] = $phone;
-            }
-
-            // ** Sync Network
-            $network = $organization->getNetworkOrganizations()->first()->getNetwork();
-            $parentOrganizationId = null;
+            $newSocietyData['email'] = $this->getOrganizationEmail($organization);
+            $newSocietyData['phone'] = $this->getOrganizationPhone($organization);
 
-            if ($network->getId() === NetworkEnum::CMF()->getValue()) {
-                $parentOrganizationId = OrganizationIdsEnum::CMF()->getValue();
-            } else if ($network->getId() === NetworkEnum::FFEC()->getValue()) {
-                $parentOrganizationId = OrganizationIdsEnum::FFEC()->getValue();
-            } else {
-                $parentOrganizationId = OrganizationIdsEnum::_2IOS()->getValue();
-            }
-
-            $parent = $this->dolibarrApiService->getSociety($parentOrganizationId);
-            if ((int)$parent['id'] !== (int)$dolibarrSociety['parent']) {
-                $putSocietyData['parent'] = (int)$parent['id'];
-            }
+            // Sync Network
+            $newSocietyData['parent'] = match (
+                $organization->getNetworkOrganizations()?->first()?->getNetwork()?->getId()
+            ) {
+                OrganizationIdsEnum::CMF()->getValue() => $cmfDolibarrId,
+                OrganizationIdsEnum::FFEC()->getValue() => $ffecDolibarrId,
+                default => null
+            };
 
             // More infos
-            $infosArray = [];
-
+            $infos = [];
             $product = $organization->getSettings()->getProduct();
-
             if (SettingsProductEnum::isSchool($product)) {
-                $studentsCount = count(array_filter(
-                    $organizationMembers,
-                    function ($missions) { return in_array(FunctionEnum::STUDENT()->getValue(), $missions); }
-                ));
-                $infosArray[] = "Nombre d'élèves : " . $studentsCount;
+                $infos[] = $this->translator->trans('STUDENTS_COUNT') . " : " .
+                    $this->countWithMission([FunctionEnum::STUDENT()->getValue()], $organizationMembers);
             }
-
-            if (
-                SettingsProductEnum::isSchool($product) ||
-                SettingsProductEnum::isArtist($product)
-            ) {
-                $membersCount = count(array_filter(
-                    $organizationMembers,
-                    function ($missions) { return in_array(FunctionEnum::ADHERENT()->getValue(), $missions); }
-                ));
-                $infosArray[] = "Nombre d'adhérents : " . $membersCount;
+            if (SettingsProductEnum::isSchool($product) || SettingsProductEnum::isArtist($product)) {
+                $infos[] = $this->translator->trans('ADHERENTS_COUNT') . " : " .
+                    $this->countWithMission([FunctionEnum::ADHERENT()->getValue()], $organizationMembers);
             }
+            $infos[] = $this->translator->trans('ADMIN_ACCESS_COUNT') . " : " .
+                $this->countWithMission($adminMissions, $organizationMembers);
+
+            // /!\ On est forcé de passer la sub-array entière pour mettre à jour le champ modifié, sinon
+            //     tous les autres champs seront passés à null...
+            $newSocietyData['array_options'] = $dolibarrSociety["array_options"];
+            $newSocietyData['array_options']['options_2iopeninfoopentalent'] = implode('\n', $infos);
+
+            // Only update the fields that are different
+            $newSocietyData = array_filter(
+                $newSocietyData,
+                function($v, $k) use ($dolibarrSociety) { return $v !== $dolibarrSociety[$k]; },
+                ARRAY_FILTER_USE_BOTH
+            );
 
-            $adminsCount = count(array_filter(
-                $organizationMembers,
-                function ($missions) use ($adminMissions) { return !empty(array_intersect($adminMissions, $missions)); }
-            ));
-            $infosArray[] = "Nombre d'accès admin : " . $adminsCount;
-
-            $infos = implode('\n', $infosArray);
-            if ($infos !== $dolibarrSociety["array_options"]["options_2iopeninfoopentalent"]) {
-                // /!\ On est forcé de passer la sub-array entière pour mettre à jour le champs modifié, sinon
-                //     tous les autres champs seront mis à null...
-                $arrayOptions = $dolibarrSociety["array_options"];
-                $arrayOptions['options_2iopeninfoopentalent'] = $infos;
-                $putSocietyData['array_options'] = $arrayOptions;
+            // add an update operation if some data has to be updated
+            if (!empty($newSocietyData)) {
+                $operations[] = new DolibarrUpdateOperation(
+                    'Update society : ' . $organization->getName() . ' (' . $organization->getId() . ')',
+                    'thirdparties',
+                    $dolibarrSociety,
+                    $newSocietyData
+                );
             }
 
-            $operations[] = new DolibarrUpdateOperation(
-                'Update society : ' . $organization->getName() . ' (' . $organization->getId() . ')',
-                'thirdparties',
-                $dolibarrSociety,
-                $putSocietyData
-            );
 
-            // ** Contacts
-            $officeMissions = FunctionEnum::getOfficeMissions();
+            // ===== Update Contacts =====
             $dolibarrContactsIndex = $this->getDolibarrContactsIndex((int)$dolibarrSociety['id']);
             $contactsProcessed = [];
 
             foreach ($organizationMembers as $accessId => $missions) {
                 foreach ($missions as $mission) {
-                    if (in_array($mission, $officeMissions)) {
+                    if (in_array($mission, FunctionEnum::getOfficeMissions())) {
                         $access = $this->accessRepository->find($accessId);
                         $person = $access->getPerson();
 
@@ -231,49 +195,38 @@ class DolibarrSyncService
 
                         $contact = $this->getPersonContact($person);
 
-                        $newData = [
-                            'civility_code' => ['MISS' => 'MME', 'MISTER' => 'MR'][$person->getGender()] ?? null,
+                        $newContactData = [
+                            'civility_code' => $person->getGender() ? $this->translator->trans($person->getGender()) : null,
                             'lastname' => $person->getName(),
                             'firstname' => $person->getGivenName(),
                             'email' => $contact?->getEmail(),
                             'phone_pro' => $contact?->getTelphone() ? $this->formatPhoneNumber($contact?->getTelphone()) : null,
                             'phone_mobile' => $contact?->getMobilPhone() ? $this->formatPhoneNumber($contact?->getMobilPhone()): null,
-                            'poste' => implode(
-                                ', ',
-                                array_map(
-                                    function($m) use ($person) {
-                                        return $this->translator->trans($m, ['gender' => ['MISS' => 'F', 'MISTER' => 'M'][$person->getGender()] ?? '?'] );
-                                        },
-                                    array_filter(
-                                        $missions,
-                                        function ($m) { return $m !== FunctionEnum::ADHERENT()->getValue() && $m !== FunctionEnum::STUDENT()->getValue(); }
-                                    )
-                                )
-                            )
+                            'poste' => $this->formatContactPosition($missions, $person->getGender())
                         ];
 
                         if ($dolibarrContact === null) {
                             $operations[] = new DolibarrCreateOperation(
                                 'New contact: ' . $person->getName() . ' ' . $person->getGivenName() . ' (' . $person->getId() . ')',
                                 'contacts',
-                                $newData
+                                $newContactData
                             );
                         } else {
                             // Only update the fields that are different
-                            $newData = array_filter(
-                                $newData,
+                            $newContactData = array_filter(
+                                $newContactData,
                                 function($v, $k) use ($dolibarrContact) { return $v !== $dolibarrContact[$k]; },
                                 ARRAY_FILTER_USE_BOTH
                             );
 
                             // add an update operation if some data has to be updated
-                            if (!empty($newData)) {
+                            if (!empty($newContactData)) {
                                 $operations[] = new DolibarrUpdateOperation(
                                     'Update contact: ' . $person->getName() . ' ' . $person->getGivenName() . ' (' . $person->getId() . ')' .
                                     ' in ' . $organization->getName() . ' (' . $organization->getId() . ')',
                                     'contacts',
                                     $dolibarrContact,
-                                    $newData,
+                                    $newContactData,
                                 );
                             }
                         }
@@ -285,7 +238,7 @@ class DolibarrSyncService
             }
 
             foreach ($dolibarrContactsIndex as $personId => $contactData) {
-                if ($contactData['statut'] === 0) {
+                if ((int)$contactData['statut'] === 0) {
                     // contact is already disabled
                     continue;
                 }
@@ -302,6 +255,14 @@ class DolibarrSyncService
             }
         }
 
+        $this->logger->info('Scan done, ' . count($operations) . ' required operations listed');
+        foreach ($operations as $operation) {
+            $this->logger->debug($operation->getLabel());
+            foreach ($operation->getChangeLog() as $message) {
+                $this->logger->debug($message);
+            }
+        }
+
         return $operations;
     }
 
@@ -316,14 +277,33 @@ class DolibarrSyncService
      */
     public function execute(array $operations): array
     {
+        $this->logger->info('Execution started, ' . count($operations) . ' operations pending...');
+        $done = 0; $errors = 0; $unknown = 0;
+
         foreach ($operations as $operation) {
             if ($operation->getStatus() !== DolibarrSyncOperation::STATUS_READY) {
                 // operation has already been treated
                 continue;
             }
             $operation->execute();
+
+            if ($operation->getStatus() === DolibarrSyncOperation::STATUS_ERROR) {
+                $this->logger->error('Error while executing : ' . $operation);
+                $this->logger->error($operation->getErrorMessage());
+                $errors++;
+            } elseif ($operation->getStatus() === DolibarrSyncOperation::STATUS_DONE) {
+                $done++;
+            } else {
+                $unknown++;
+            }
         }
 
+        $this->logger->info('Execution ended');
+        $this->logger->info('Done : ' . $done);
+        $this->logger->info('Errors : ' . $errors);
+        if ($unknown > 0)
+            $this->logger->warning('Unknown : ' . $unknown);
+
         return $operations;
     }
 
@@ -343,32 +323,25 @@ class DolibarrSyncService
         return $operations;
     }
 
-    /**
-     * Log a new scanning error
-     * @param $errorMsg
-     */
-    private function logScanError($errorMsg) {
-        // TODO : implement
-    }
-
     /**
      * Get the client societies dolibarr and index them by organization id
      *
      * @return array An index of the form [$organizationId => $dolibarrData]
-     * @throws HttpException
      */
     private function getDolibarrSocietiesIndex(): array
     {
         $index = [];
         foreach ($this->dolibarrApiService->getAllClients() as $clientData) {
-            if (!$clientData["array_options"]["options_2iopen_organization_id"] > 0) {
-                $this->logScanError(
-                    "Missing organization id : " . $clientData["name"] . "(" . $clientData["code_client"] .")"
+            $organizationId = $clientData["array_options"]["options_2iopen_organization_id"] ?? null;
+            if (!$organizationId > 0) {
+                $this->logger->warning(
+                    'Dolibarr client has no organization id: ' .
+                    $clientData['name'] . ' (' . $clientData['id'] . ')'
                 );
                 continue;
             }
 
-            $index[$clientData["array_options"]["options_2iopen_organization_id"]] = $clientData;
+            $index[$organizationId] = $clientData;
         }
         return $index;
     }
@@ -422,11 +395,11 @@ class DolibarrSyncService
      */
     private function getOrganizationPostalAddress(Organization $organization) {
         $addressPriorities = [
-            AddressPostalOrganizationTypeEnum::ADDRESS_BILL()->getValue(),
-            AddressPostalOrganizationTypeEnum::ADDRESS_CONTACT()->getValue(),
-            AddressPostalOrganizationTypeEnum::ADDRESS_HEAD_OFFICE()->getValue(),
-            AddressPostalOrganizationTypeEnum::ADDRESS_PRACTICE()->getValue(),
-            AddressPostalOrganizationTypeEnum::ADDRESS_OTHER()->getValue()
+            AddressPostalOrganizationTypeEnum::ADDRESS_BILL(),
+            AddressPostalOrganizationTypeEnum::ADDRESS_CONTACT(),
+            AddressPostalOrganizationTypeEnum::ADDRESS_HEAD_OFFICE(),
+            AddressPostalOrganizationTypeEnum::ADDRESS_PRACTICE(),
+            AddressPostalOrganizationTypeEnum::ADDRESS_OTHER()
         ];
 
         foreach ($addressPriorities as $addressType) {
@@ -448,15 +421,15 @@ class DolibarrSyncService
     private function getOrganizationPhone(Organization $organization): ?string
     {
         $contactPriorities = [
-            ContactPointTypeEnum::BILL()->getValue(),
-            ContactPointTypeEnum::CONTACT()->getValue(),
-            ContactPointTypeEnum::PRINCIPAL()->getValue(),
-            ContactPointTypeEnum::OTHER()->getValue()
+            ContactPointTypeEnum::BILL(),
+            ContactPointTypeEnum::CONTACT(),
+            ContactPointTypeEnum::PRINCIPAL(),
+            ContactPointTypeEnum::OTHER()
         ];
 
         foreach ($contactPriorities as $contactType) {
             foreach ($organization->getContactPoints() as $contactPoint) {
-                if ($contactPoint->getContactType() == $contactType) {
+                if ($contactPoint->getContactType() === $contactType) {
                     if ($contactPoint->getTelphone() !== null) {
                         return $this->formatPhoneNumber($contactPoint->getTelphone());
                     }
@@ -477,10 +450,10 @@ class DolibarrSyncService
      */
     private function getOrganizationEmail(Organization $organization) {
         $contactPriorities = [
-            ContactPointTypeEnum::BILL()->getValue(),
-            ContactPointTypeEnum::CONTACT()->getValue(),
-            ContactPointTypeEnum::PRINCIPAL()->getValue(),
-            ContactPointTypeEnum::OTHER()->getValue()
+            ContactPointTypeEnum::BILL(),
+            ContactPointTypeEnum::CONTACT(),
+            ContactPointTypeEnum::PRINCIPAL(),
+            ContactPointTypeEnum::OTHER()
         ];
 
         foreach ($contactPriorities as $contactType) {
@@ -493,15 +466,29 @@ class DolibarrSyncService
         return null;
     }
 
+    /**
+     * Returns the number of accesses posseding at least one of the missions
+     *
+     * @param array $missions A list of missions
+     * @param array $members An organization members as returned by getActiveMembersIndex: [$accessID => [$missions...]]
+     * @return int
+     */
+    private function countWithMission(array $missions, array $members): int {
+        return count(array_filter(
+            $members,
+            function ($actualMissions) use ($missions) { return !empty(array_intersect($actualMissions, $missions)); }
+        ));
+    }
+
     private function getPersonContact(Person $person) {
         $contactPriorities = [
-            ContactPointTypeEnum::PRINCIPAL()->getValue(),
-            ContactPointTypeEnum::OTHER()->getValue()
+            ContactPointTypeEnum::PRINCIPAL(),
+            ContactPointTypeEnum::OTHER()
         ];
 
-        foreach ($contactPriorities as $contactType) {
+        foreach ($contactPriorities as $contactTypeEnum) {
             $result = $this->contactPointRepository->getByTypeAndPerson(
-                ContactPointTypeEnum::PRINCIPAL()->getValue(), $person
+                $contactTypeEnum->getValue(), $person
             );
             if (!empty($result)) {
                 return $result[0];
@@ -510,6 +497,37 @@ class DolibarrSyncService
         return null;
     }
 
+    /**
+     * Format the contact position from its gender and missions
+     *
+     * @param array $missions
+     * @param string|null $gender
+     * @return string
+     */
+    private function formatContactPosition(array $missions, ?string $gender = 'X'): string {
+        $to_exclude = [FunctionEnum::ADHERENT(), FunctionEnum::STUDENT()];
+        return implode(
+            ', ',
+            array_map(
+                function($m) use ($gender) {
+                    return $this->translator->trans(
+                        $m,
+                        ['gender' => [
+                                GenderEnum::MISS()->getValue() => 'F',
+                                GenderEnum::MISTER()->getValue() => 'M'
+                            ][$gender] ?? 'X']
+                    );
+                },
+                array_filter(
+                    $missions,
+                    function ($m) use ($to_exclude) {
+                        return !in_array($m, $to_exclude);
+                    }
+                )
+            )
+        );
+    }
+
     /**
      * Format a phone number into international format
      *

+ 2 - 2
src/Service/Dolibarr/DolibarrSync/SyncOperation/DolibarrCreateOperation.php

@@ -27,10 +27,10 @@ class DolibarrCreateOperation extends DolibarrSyncOperation
      */
     public function getChangeLog(): array {
         $messages = [
-            '> POST ' . $this->entity
+            '[POST ' . $this->entity . ']'
         ];
         foreach ($this->parameters as $field => $newValue) {
-            $messages[] = $field . ' : ' . $newValue;
+            $messages[] = $field . ' : `' . $newValue . '`';
         }
         return $messages;
     }

+ 1 - 1
src/Service/Dolibarr/DolibarrSync/SyncOperation/DolibarrDeleteOperation.php

@@ -31,7 +31,7 @@ class DolibarrDeleteOperation extends DolibarrSyncOperation
      */
     public function getChangeLog(): array {
         return [
-            '> DELETE ' . $this->entity . '/' . $this->id
+            '[DELETE ' . $this->entity . '/' . $this->id . ']'
         ];
     }
 }

+ 1 - 1
src/Service/Dolibarr/DolibarrSync/SyncOperation/DolibarrUpdateOperation.php

@@ -35,7 +35,7 @@ class DolibarrUpdateOperation extends DolibarrSyncOperation
      */
     public function getChangeLog(): array {
         $messages = [
-            '> PUT ' . $this->entity . '/' . $this->id
+            '[PUT ' . $this->entity . '/' . $this->id . ']'
         ];
         foreach ($this->parameters as $field => $newValue) {
             if (!array_key_exists($field, $this->currentData)) {

+ 9 - 4
translations/enum/missions/messages+intl-icu.fr.yaml

@@ -99,7 +99,12 @@ COORDINATOR: >-
   }
 TECHNICAL_STAFF: Personnel technique
 ACCOUNTANT: Comptable
-ACTIVE_MEMBER_OF_THE_CA: Membre actif du CA
+ACTIVE_MEMBER_OF_THE_CA: >-
+  {gender, select,
+  M      {Membre actif du CA}
+  F      {Membre active du CA}
+  other  {Membre actif du CA}
+  }
 HONORARY_PRESIDENT: >-
   {gender, select,
   M      {Président d'honneur}
@@ -139,9 +144,9 @@ TREASURER_ASSISTANT: >-
   }
 VICE_PRESIDENT: >-
   {gender, select,
-  M      {Vice président}
-  F      {Vice présidente}
-  other  {Vice président(e)}
+  M      {Vice-président}
+  F      {Vice-présidente}
+  other  {Vice-président(e)}
   }
 ADHERENT: >-
   {gender, select,

+ 2 - 0
translations/enum/person/gender/messages+intl-icu.fr.yaml

@@ -0,0 +1,2 @@
+MISS: MME
+MISTER: MR

+ 3 - 0
translations/services/dolibarr-sync/messages+intl-icu.fr.yaml

@@ -0,0 +1,3 @@
+ADHERENTS_COUNT: Nombre d'adhérents
+STUDENTS_COUNT: Nombre d'élèves
+ADMIN_ACCESS_COUNT: Nombre d'accès admin