Modify translations and if conditions in updateReference method

This commit is contained in:
Julie Lenaerts 2025-02-26 10:55:43 +01:00
parent 18b86a116f
commit 1eec905a4c
4 changed files with 15 additions and 17 deletions

View File

@ -48,8 +48,8 @@
<li>
<a href="{{ chill_path_add_return_path('chill_thirdparty_find_duplicate',
{ 'thirdparty_id': entity.id }) }}"
title="{{ 'thirdparty_duplicate.merge'|trans }}"
class="btn btn-misc">{{ 'thirdparty_duplicate.merge'|trans }}</a>
title="{{ 'Merge'|trans }}"
class="btn btn-misc">{{ 'Merge'|trans }}</a>
</li>
{% endblock %}
{% block content_view_actions_edit_link %}

View File

@ -8,7 +8,7 @@
{% block content %}
<div class="person-duplicate">
<h1>{{ 'find duplicate thirdparty'|trans }}</h1>
<h1>{{ 'find_thirdparty_duplicate'|trans }}</h1>
{{ form_start(form) }}
{{ form_rest(form) }}

View File

@ -86,7 +86,7 @@ class ThirdpartyMergeService
continue;
}
if (ClassMetadata::TO_ONE === $assoc['type']) {
if ($assoc['type'] & ClassMetadata::TO_ONE) {
$joinColumn = $meta->getSingleAssociationJoinColumnName($assoc['fieldName']);
if (ThirdParty::class === $assoc['sourceEntity'] && 'parent_id' !== $joinColumn) {
@ -104,21 +104,18 @@ class ThirdpartyMergeService
];
}
if (ClassMetadata::TO_MANY === $assoc['type'] && isset($assoc['joinTable'])) {
if ($assoc['type'] === 8 && isset($assoc['joinTable'])) {
$joinTable = $assoc['joinTable']['name'];
$joinColumn = $assoc['joinTable']['joinColumns'][0]['name'];
if ('thirdparty_id' === $joinColumn) {
$queries[] = [
'sql' => "DELETE FROM {$joinTable} WHERE {$joinColumn} = :toDelete",
'params' => ['toDelete' => $toDelete->getId()],
];
} else {
$queries[] = [
'sql' => "UPDATE {$joinTable} SET {$joinColumn} = :toKeep WHERE {$joinColumn} = :toDelete",
'params' => ['toKeep' => $toKeep->getId(), 'toDelete' => $toDelete->getId()],
];
}
$queries[] = [
'sql' => "UPDATE {$joinTable} SET {$joinColumn} = :toKeep WHERE {$joinColumn} = :toDelete AND NOT EXISTS (SELECT 1 FROM {$joinTable} WHERE {$joinColumn} = :toKeep)",
'params' => ['toDelete' => $toDelete->getId(), 'toKeep' => $toKeep->getId()],
];
$queries[] = [
'sql' => "DELETE FROM {$joinTable} WHERE {$joinColumn} = :toDelete",
'params' => ['toDelete' => $toDelete->getId()],
];
}
}
}

View File

@ -162,3 +162,4 @@ Contact profession: Profession du contact
thirdparty_duplicate:
merge: Fussioner
find: 'Désigner un tiers doublon'
find_thirdparty_duplicate: 'Désigner un tiers doublon'