Преглед на файлове

Merge branch 'hotfix/V8-7108-revoir-la-synchro-dolibarr-pour-' into develop

Olivier Massot преди 9 месеца
родител
ревизия
cd52fb04db
променени са 2 файла, в които са добавени 10 реда и са изтрити 7 реда
  1. 1 1
      .env
  2. 9 6
      src/Service/Dolibarr/DolibarrSyncService.php

+ 1 - 1
.env

@@ -93,7 +93,7 @@ MERCURE_URL=xxx
 # The public URL of the Mercure hub, used by the browser to connect
 MERCURE_PUBLIC_URL=xxx
 # The secret key used to sign the JWTs
-MERCURE_JWT_SECRET=xxx
+# >> MERCURE_JWT_SECRET, with the secret vars above
 ###< symfony/mercure-bundle ###
 
 ###> typo3 client ###

+ 9 - 6
src/Service/Dolibarr/DolibarrSyncService.php

@@ -160,8 +160,11 @@ class DolibarrSyncService
             }
 
             // Sync contact
-            $newSocietyData['email'] = $this->getOrganizationEmail($organization);
-            $newSocietyData['phone'] = $this->getOrganizationPhone($organization);
+            $organizationEmail = $this->getOrganizationEmail($organization);
+            $newSocietyData['email'] = !empty($organizationEmail) ? $organizationEmail : $dolibarrSociety['email'];
+
+            $organizationPhone = $this->getOrganizationPhone($organization);
+            $newSocietyData['phone'] = !empty($organizationPhone) ? $organizationPhone : $dolibarrSociety['phone'];
 
             // Sync Network
             if (!in_array($organization->getId(), [NetworkEnum::CMF, NetworkEnum::FFEC], true)) {
@@ -253,10 +256,10 @@ class DolibarrSyncService
                     'civility_code' => $person->getGender() ? $this->translator->trans($person->getGender()->value) : null,
                     'lastname' => trim($person->getName()),
                     'firstname' => trim($person->getGivenName()),
-                    'email' => $contact?->getEmail(),
-                    'phone_pro' => $contact?->getTelphone() ? $this->formatPhoneNumber($contact->getTelphone()) : null,
-                    'phone_mobile' => $contact?->getMobilPhone() ? $this->formatPhoneNumber($contact->getMobilPhone()) : null,
-                    'poste' => $this->formatContactPosition($missions, $person->getGender()?->value),
+                    'email' => $contact?->getEmail() ?? $dolibarrContact['email'] ?? null,
+                    'phone_pro' => !empty($contact?->getTelphone()) ? $this->formatPhoneNumber($contact->getTelphone()) : $dolibarrContact['phone_pro'] ?? null,
+                    'phone_mobile' => !empty($contact?->getMobilPhone()) ? $this->formatPhoneNumber($contact->getMobilPhone()) : $dolibarrContact['phone_mobile'] ?? null,
+                    'poste' => !empty($missions) ? $this->formatContactPosition($missions, $person->getGender()?->value) : $dolibarrContact['poste'] ?? null,
                     'statut' => '1',
                 ];