|
|
@@ -26,7 +26,6 @@ use HttpException;
|
|
|
use libphonenumber\PhoneNumber;
|
|
|
use libphonenumber\PhoneNumberFormat;
|
|
|
use libphonenumber\PhoneNumberUtil;
|
|
|
-use Monolog\Handler\RotatingFileHandler;
|
|
|
use Psr\Log\LoggerInterface;
|
|
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
|
|
|
|
|
@@ -153,7 +152,7 @@ class DolibarrSyncService
|
|
|
ARRAY_FILTER_USE_BOTH
|
|
|
);
|
|
|
|
|
|
- // add an update operation if some data has to be updated
|
|
|
+ // Add an update operation if some data has to be updated
|
|
|
if (!empty($newSocietyData)) {
|
|
|
$operations[] = new DolibarrUpdateOperation(
|
|
|
'Update society : ' . $organization->getName() . ' (' . $organization->getId() . ')',
|
|
|
@@ -181,11 +180,16 @@ class DolibarrSyncService
|
|
|
}
|
|
|
$contactsProcessed[] = $person->getId();
|
|
|
|
|
|
+ // special: if the contact has no name, ignore it
|
|
|
+ if (!$person->getName()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
// Build parameters for the query (if a query is needed
|
|
|
$dolibarrContact = $dolibarrContactsIndex[$person->getId()] ?? null;
|
|
|
|
|
|
// <-- special case: for phone numbers, dolibarr api returns empty strings even when field is null in DB
|
|
|
- // if left like this, it would leads to unnecessary updates
|
|
|
+ // if left like this, it would lead to unnecessary updates
|
|
|
if ($dolibarrContact !== null) {
|
|
|
if ($dolibarrContact['phone_pro'] === '')
|
|
|
$dolibarrContact['phone_pro'] = null;
|
|
|
@@ -213,7 +217,7 @@ class DolibarrSyncService
|
|
|
$newContactData
|
|
|
);
|
|
|
} else {
|
|
|
- // Only update the fields that are different
|
|
|
+ // Only update the fields that are different from existing
|
|
|
$newContactData = array_filter(
|
|
|
$newContactData,
|
|
|
function($v, $k) use ($dolibarrContact) { return $v !== $dolibarrContact[$k]; },
|
|
|
@@ -289,7 +293,10 @@ class DolibarrSyncService
|
|
|
$this->logger->warning('Tried to execute an operation that was not marked as ready : ' . $operation);
|
|
|
continue;
|
|
|
}
|
|
|
- $operation->execute();
|
|
|
+
|
|
|
+ $operation->execute(
|
|
|
+ $this->dolibarrApiService
|
|
|
+ );
|
|
|
|
|
|
if ($operation->getStatus() === DolibarrSyncOperation::STATUS_ERROR) {
|
|
|
$this->logger->error('Error while executing operation : ' . $operation);
|
|
|
@@ -509,7 +516,7 @@ class DolibarrSyncService
|
|
|
* @return string
|
|
|
*/
|
|
|
private function formatContactPosition(array $missions, ?string $gender = 'X'): string {
|
|
|
- $to_exclude = [FunctionEnum::ADHERENT(), FunctionEnum::STUDENT()];
|
|
|
+ $to_exclude = [FunctionEnum::ADHERENT(), FunctionEnum::STUDENT(), FunctionEnum::OTHER()];
|
|
|
return implode(
|
|
|
', ',
|
|
|
array_map(
|