Modify translations and if conditions in updateReference method

This commit is contained in:
Julie Lenaerts 2025-02-26 10:55:43 +01:00
parent 6db16e6d0b
commit d84f3ee5ad
4 changed files with 15 additions and 20 deletions

View File

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

View File

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

View File

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

View File

@ -133,6 +133,4 @@ is thirdparty: Le demandeur est un tiers
Filter by person's who have a residential address located at a thirdparty of type: Filtrer les usagers qui ont une addresse de résidence chez un tiers Filter by person's who have a residential address located at a thirdparty of type: Filtrer les usagers qui ont une addresse de résidence chez un tiers
"Filtered by person's who have a residential address located at a thirdparty of type %thirdparty_type% and valid on %date_calc%": "Uniquement les usagers qui ont une addresse de résidence chez un tiers de catégorie %thirdparty_type% et valide sur la date %date_calc%" "Filtered by person's who have a residential address located at a thirdparty of type %thirdparty_type% and valid on %date_calc%": "Uniquement les usagers qui ont une addresse de résidence chez un tiers de catégorie %thirdparty_type% et valide sur la date %date_calc%"
thirdparty_duplicate: find_thirdparty_duplicate: 'Désigner un tiers doublon'
merge: Fussioner
find: 'Désigner un tiers doublon'