|
|
@@ -298,6 +298,7 @@ class DolibarrSyncService
|
|
|
|
|
|
if ($operation->getStatus() === BaseRestOperation::STATUS_ERROR) {
|
|
|
$this->logger->error('Error while executing operation : ' . $operation);
|
|
|
+ $this->logger->error(implode("\n", $operation->getChangeLog()));
|
|
|
$this->logger->error($operation->getErrorMessage());
|
|
|
$errors++;
|
|
|
} elseif ($operation->getStatus() === BaseRestOperation::STATUS_DONE) {
|
|
|
@@ -587,7 +588,7 @@ class DolibarrSyncService
|
|
|
);
|
|
|
|
|
|
if (strlen($poste) > 80) {
|
|
|
- $poste = substr($poste, 0, 77) . '...';
|
|
|
+ $poste = mb_substr($poste, 0, 77, "utf-8") . '...';
|
|
|
}
|
|
|
return $poste;
|
|
|
}
|
|
|
@@ -600,13 +601,19 @@ class DolibarrSyncService
|
|
|
*/
|
|
|
protected static function formatPhoneNumber(PhoneNumber $phoneNumber): string {
|
|
|
$phoneUtil = PhoneNumberUtil::getInstance();
|
|
|
- return $phoneUtil->format($phoneNumber, PhoneNumberFormat::INTERNATIONAL);
|
|
|
+ return str_replace(
|
|
|
+ ' ',
|
|
|
+ '',
|
|
|
+ $phoneUtil->format($phoneNumber, PhoneNumberFormat::INTERNATIONAL)
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Returns an array containing the keys/values from the newData array
|
|
|
* which are absent or different from $initialData
|
|
|
*
|
|
|
+ * /!\ Sub-arrays shall stay complete and must not be filtered
|
|
|
+ *
|
|
|
* Because for some fields the dolibarr api returns empty strings even when field is null in DB,
|
|
|
* we have to consider null and empty-string as equals. As far as we know, this causes no loss of information.
|
|
|
*
|
|
|
@@ -618,15 +625,11 @@ class DolibarrSyncService
|
|
|
{
|
|
|
$result = [];
|
|
|
foreach ($newData as $field => $value) {
|
|
|
- if (is_array($value)) {
|
|
|
- $filteredValue = self::filterDiff($initialData[$field] ?? [], $value);
|
|
|
- if (!empty($filteredValue)) {
|
|
|
- $result[$field] = $filteredValue;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (($value ?? '') !== ($initialData[$field] ?? '') || !array_key_exists($field, $initialData)) {
|
|
|
- $result[$field] = $value;
|
|
|
- }
|
|
|
+ if (
|
|
|
+ ($value ?? '') !== ($initialData[$field] ?? '') ||
|
|
|
+ !array_key_exists($field, $initialData)
|
|
|
+ ) {
|
|
|
+ $result[$field] = $value;
|
|
|
}
|
|
|
}
|
|
|
return $result;
|