Wrap another set of hardcoded strings in {ts}
[civicrm-core.git] / templates / CRM / Contact / Form / Merge.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
1188c7a8 3 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 4 | |
1188c7a8
TO
5 | This work is published under the GNU AGPLv3 license with some |
6 | permitted exceptions and without any warranty. For full license |
7 | and copyright information, see https://civicrm.org/licensing |
6a488035
TO
8 +--------------------------------------------------------------------+
9*}
10<div class="crm-block crm-form-block crm-contact-merge-form-block">
3bb59daf
AH
11 <div class="help">
12 {ts}Click <strong>Merge</strong> to move data from the Duplicate Contact on the left into the Main Contact. In addition to the contact data (address, phone, email...), you may choose to move all or some of the related activity records (groups, contributions, memberships, etc.).{/ts} {help id="intro"}
13 </div>
ffd39a49 14
ffd39a49 15 <div class="message status">
34d6cec4 16 {icon icon="fa-info-circle"}{/icon}
3bb59daf 17 <strong>{ts}WARNING: The duplicate contact record WILL BE DELETED after the merge is complete.{/ts}</strong>
ffd39a49 18 </div>
ffd39a49 19
3bb59daf
AH
20 {if $user}
21 <div class="message status">
34d6cec4 22 {icon icon="fa-info-circle"}{/icon}
3bb59daf
AH
23 <strong>{ts 1=$config->userFramework}WARNING: There are %1 user accounts associated with both the original and duplicate contacts. Ensure that the %1 user you want to retain is on the right - if necessary use the 'Flip between original and duplicate contacts.' option at top to swap the positions of the two records before doing the merge.
24 The user record associated with the duplicate contact will not be deleted, but will be unlinked from the associated contact record (which will be deleted).
25 You will need to manually delete that user (click on the link to open the %1 user account in new screen). You may need to give thought to how you handle any content or contents associated with that user.{/ts}</strong>
26 </div>
27 {/if}
28
29 <div class="crm-submit-buttons">
30 {include file="CRM/common/formButtons.tpl" location="top"}
31 </div>
6a488035 32
3bb59daf 33 <div class="action-link">
13a3d214
AH
34 {if $prev}<a href="{$prev}" class="crm-hover-button action-item"><i class="crm-i fa-chevron-left" aria-hidden="true"></i> {ts}Previous{/ts}</a>{/if}
35 {if $next}<a href="{$next}" class="crm-hover-button action-item">{ts}Next{/ts} <i class="crm-i fa-chevron-right" aria-hidden="true"></i></a>{/if}
577b8995 36 <a href="{$flip}" class="action-item crm-hover-button">
13a3d214 37 <i class="crm-i fa-random" aria-hidden="true"></i>
3bb59daf
AH
38 {ts}Flip between original and duplicate contacts.{/ts}
39 </a>
40 </div>
6a488035 41
3bb59daf 42 <div class="action-link">
095b12d6 43 <a href="#" class="action-item crm-hover-button crm-notDuplicate" title={ts}Mark this pair as not a duplicate.{/ts} onClick="processDupes( {$main_cid|escape}, {$other_cid|escape}, 'dupe-nondupe', 'merge-contact', '{$browseUrl}' );return false;">
13a3d214 44 <i class="crm-i fa-times-circle" aria-hidden="true"></i>
3bb59daf
AH
45 {ts}Mark this pair as not a duplicate.{/ts}
46 </a>
47 </div>
6a488035 48
3bb59daf
AH
49 <div class="action-link">
50 <a href="javascript:void(0);" class="action-item crm-hover-button toggle_equal_rows">
13a3d214 51 <i class="crm-i fa-eye-slash" aria-hidden="true"></i>
3bb59daf
AH
52 {ts}Show/hide rows with the same data on each contact record.{/ts}
53 </a>
54 </div>
08ef1f91 55
3bb59daf
AH
56 <table class="row-highlight">
57 <tr class="columnheader">
58 <th>&nbsp;</th>
58edb71b 59 <th>{$otherContactTypeIcon} <a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$other_cid"}">{$other_name|escape}</a> ({ts}duplicate{/ts})</th>
3bb59daf 60 <th>{ts}Mark All{/ts}<br />=={$form.toggleSelect.html} ==&gt;</th>
58edb71b 61 <th>{$mainContactTypeIcon}<a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$main_cid"}">{$main_name|escape}</a></th>
c995124e 62 <th width="300">{ts}Add/overwrite?{/ts}</th>
3bb59daf 63 </tr>
eb61dc07 64
3b8dfec6 65
c8e6c437 66 {foreach from=$summary_rows item=summaryRow}
67 <tr>
68 <td>{$summaryRow.label}</td>
69 <td>{$summaryRow.other_contact_value}</td>
70 <td></td>
71 <td>{$summaryRow.main_contact_value}</td>
72 <td></td>
73 </tr>
74 {/foreach}
eb61dc07 75
3bb59daf 76 {foreach from=$rows item=row key=field}
6a488035 77
f9a69126 78 {if !$row.main && !$row.other}
3bb59daf 79 <tr style="background-color: #fff !important; border-bottom:1px solid #ccc !important;" class="no-data">
eb61dc07 80 <td>
095b12d6 81 <strong>{$row.title|escape}</strong>
eb61dc07 82 </td>
3bb59daf
AH
83 {else}
84 {if $row.main eq $row.other}
85 <tr class="merge-row-equal crm-row-ok {cycle values="odd-row,even-row"}">
86 {else}
87 <tr class="crm-row-error {cycle values="odd-row,even-row"}">
88 {/if}
eb61dc07 89 <td>
095b12d6 90 {$row.title|escape}
eb61dc07 91 </td>
3bb59daf 92 {/if}
53e45f60 93
3bb59daf
AH
94 {assign var=position value=$field|strrpos:'_'}
95 {assign var=blockId value=$field|substr:$position+1}
96 {assign var=blockName value=$field|substr:14:$position-14}
eb61dc07
J
97
98 <td>
041d6d6b 99 {* @TODO check if this is ever an array or a fileName? *}
86b14b59 100 {if $row.location_entity == "email" OR
101 $row.location_entity == "address"}
2a7e1ddc
TS
102 <span style="white-space: pre">
103 {else}
104 <span>
105 {/if}
106 {if !is_array($row.other)}
095b12d6 107 {$row.other|escape}
2a7e1ddc 108 {elseif $row.other.fileName}
095b12d6 109 {$row.other.fileName|escape}
2a7e1ddc
TS
110 {else}
111 {', '|implode:$row.other}
112 {/if}
113 </span>
eb61dc07
J
114 </td>
115
3bb59daf
AH
116 <td style='white-space: nowrap'>
117 {if $form.$field}=={$form.$field.html|crmAddClass:"select-row"}==&gt;{/if}
118 </td>
119
120 {* For location blocks *}
86b14b59 121 {if $row.location_entity}
3bb59daf
AH
122
123 <td>
edc36333 124 {strip}
86b14b59 125 {if $row.location_entity == "email" OR
126 $row.location_entity == "address"}
095b12d6 127 <span style="white-space: pre" id="main_{$blockName|escape}_{$blockId|escape}">
edc36333 128 {else}
095b12d6 129 <span id="main_{$blockName|escape}_{$blockId|escape}">
edc36333
J
130 {/if}
131 {* @TODO check if this is ever an array or a fileName? *}
132 {if !is_array($row.main)}
095b12d6 133 {$row.main|escape}
edc36333 134 {elseif $row.main.fileName}
095b12d6 135 {$row.main.fileName|escape}
edc36333
J
136 {else}
137 {', '|implode:$row.main}
138 {/if}
139 </span>
140 {/strip}
3bb59daf
AH
141 </td>
142
143 <td>
144 {* Display location for fields with locations *}
145 {if $blockName eq 'email' || $blockName eq 'phone' || $blockName eq 'address' || $blockName eq 'im' }
972947a7 146 {$form.location_blocks.$blockName.$blockId.locTypeId.html}&nbsp;
3bb59daf
AH
147 {/if}
148
149 {* Display other_type_id for websites, ims and phones *}
150 {if $blockName eq 'website' || $blockName eq 'im' || $blockName eq 'phone' }
972947a7 151 {$form.location_blocks.$blockName.$blockId.typeTypeId.html}&nbsp;
3bb59daf
AH
152 {/if}
153
154 {* Display the overwrite/add/add new label *}
abd0b852
J
155 <span id="main_{$blockName}_{$blockId}_overwrite" class="location_block_controls">
156
157 <span class="location_primary">
c995124e 158 {if $row.main && $row.main_is_primary == "1"}{ts}Primary{/ts}{/if}
abd0b852
J
159 </span>
160
161 <span class="location_block_controls_options">
162 <span class="location_operation_description">
163 {if $row.main}({ts}overwrite{/ts}){else}({ts}add{/ts}){/if}
164 </span>
165 <span style="display: block" class="location_operation_checkbox">
166 {if $row.main && ($blockName eq 'email' || $blockName eq 'phone')}
167 {$form.location_blocks.$blockName.$blockId.operation.html}
041d6d6b 168 {/if}
041d6d6b 169 </span>
abd0b852
J
170 <span style="display: block" class="location_set_other_primary">
171 {if $blockName neq 'website' && (($row.main && $row.main_is_primary != "1") || !$row.main)}
172 {$form.location_blocks.$blockName.$blockId.set_other_primary.html}
173 {/if}
174 </span>
175 </span>
3bb59daf 176 </span>
041d6d6b 177
3bb59daf
AH
178 </td>
179
180 {* For non-location blocks *}
181 {else}
182
183 <td>
3b8dfec6 184 <span>
3bb59daf 185 {if !is_array($row.main)}
095b12d6 186 {$row.main|escape}
3bb59daf 187 {elseif $row.main.fileName}
095b12d6 188 {$row.main.fileName|escape}
3bb59daf
AH
189 {else}
190 {', '|implode:$row.main}
eb61dc07 191 {/if}
08ef1f91 192 </span>
3bb59daf
AH
193 </td>
194
195 <td>
f9a69126 196 {if $row.main || $row.other}
3bb59daf
AH
197 <span>
198 {if $row.main == $row.other}
199 <span class="action_label">({ts}match{/ts})</span><br />
200 {elseif $row.main}
201 <span class="action_label">({ts}overwrite{/ts})</span><br />
202 {else}
203 <span class="action_label">({ts}add{/ts})</span>
204 {/if}
205 </span>
206 {/if}
207 </td>
eb61dc07 208
3bb59daf 209 {/if}
08ef1f91 210
3bb59daf
AH
211 </tr>
212 {/foreach}
6a488035 213
3bb59daf
AH
214 {foreach from=$rel_tables item=params key=paramName}
215 {if $paramName eq 'move_rel_table_users'}
216 <tr class="{cycle values="even-row,odd-row"}">
217 <td><strong>{ts}Move related...{/ts}</strong></td><td>{if $otherUfId}<a target="_blank" href="{$params.other_url}">{$otherUfName}</a></td><td style='white-space: nowrap'>=={$form.$paramName.html|crmAddClass:"select-row"}==&gt;{else}<td style='white-space: nowrap'></td>{/if}</td><td>{if $mainUfId}<a target="_blank" href="{$params.main_url}">{$mainUfName}</a>{/if}</td>
218 <td>({ts}migrate{/ts})</td>
219 </tr>
220 {else}
6a488035 221 <tr class="{cycle values="even-row,odd-row"}">
3bb59daf
AH
222 <td><strong>{ts}Move related...{/ts}</strong></td><td><a href="{$params.other_url}">{$params.title}</a></td><td style='white-space: nowrap'>=={$form.$paramName.html|crmAddClass:"select-row"}==&gt;</td><td><a href="{$params.main_url}">{$params.title}</a>{if $form.operation.$paramName.add.html}&nbsp;{$form.operation.$paramName.add.html}{/if}</td>
223 <td>({ts}migrate{/ts})</td>
224 </tr>
225 {/if}
226 {/foreach}
227 </table>
6a488035 228
3bb59daf
AH
229 <div class="crm-submit-buttons">
230 {include file="CRM/common/formButtons.tpl" location="bottom"}
231 </div>
6a488035
TO
232</div>
233
234{literal}
235<script type="text/javascript">
236
bf43eaac
J
237 var locationBlockInfo = {/literal}{$locationBlockInfo}{literal};
238 var allBlock = {/literal}{$mainLocBlock}{literal};
239
149ae679 240 /**
abd0b852
J
241 * Triggered when a 'location' or 'type' destination is changed, and when
242 * the operation or 'set primary' checkboxes are changed.
86dd5d2e 243 *
149ae679
J
244 * Check to see if the 'main' contact record has a corresponding location
245 * block when the destination of a field is changed. Allow existing location
246 * fields to be overwritten with data from the 'other' contact.
247 *
abd0b852 248 * @param blockName string
149ae679 249 * The name of the entity.
149ae679 250 * @param blockId int
ca792455
J
251 * The block ID being affected.
252 * @param event object
253 * The event that triggered the update.
149ae679 254 */
ca792455 255 function updateMainLocationBlock(blockName, blockId, event) {
06f557c5
J
256
257 // Get type of select list that's been changed (location or type)
abd0b852
J
258 var locTypeId = CRM.$('select#location_blocks_' + blockName + '_' + blockId + '_locTypeId').val();
259 var typeTypeId = CRM.$('select#location_blocks_' + blockName + '_' + blockId + '_typeTypeId').val();
06f557c5 260
34917198 261 // @todo Fix this 'special handling' for websites (no location id)
abd0b852
J
262 if (!locTypeId) {
263 locTypeId = 0;
264 }
34917198 265
bf43eaac 266 // Look for a matching block on the main contact
34917198
J
267 var mainBlockId = 0;
268 var mainBlockDisplay = '';
abd0b852
J
269 var mainBlock = findBlock(blockName, locTypeId, typeTypeId);
270 if (mainBlock != false) {
bf43eaac
J
271 mainBlockDisplay = mainBlock['display'];
272 mainBlockId = mainBlock['id'];
abd0b852
J
273 }
274
275 // Update main location display and id
276 CRM.$("input[name='location_blocks[" + blockName + "][" + blockId + "][mainContactBlockId]']").val(mainBlockId);
277 CRM.$("#main_" + blockName + "_" + blockId).html(mainBlockDisplay);
34917198 278
abd0b852 279 // Update controls area
041d6d6b 280
abd0b852
J
281 // Get the parent block once for speed
282 var this_controls = CRM.$("#main_" + blockName + "_" + blockId + "_overwrite");
283
284 // Update primary label
285 if (mainBlock != false && mainBlock['is_primary'] == '1') {
c995124e 286 this_controls.find(".location_primary").text('{/literal}{ts escape='js'}Primary{/ts}{literal}');
abd0b852
J
287 }
288 else {
289 this_controls.find(".location_primary").text('');
290 }
291
292 // Update operation description
8838f818 293 var operation_description = "{/literal}{ts escape='js'}add{/ts}{literal}";
abd0b852
J
294 var add_new_check_length = this_controls.find(".location_operation_checkbox input:checked").length;
295 if (mainBlock != false) {
296 if (add_new_check_length > 0) {
297 operation_description = "{/literal}{ts}add new{/ts}{literal}";
041d6d6b 298 }
abd0b852
J
299 else {
300 operation_description = "{/literal}{ts}overwrite{/ts}{literal}";
301 }
302 }
303 this_controls.find(".location_operation_description").text("(" + operation_description + ")");
304
305 // Skip if the 'add new' or 'set primary' checkboxes were clicked
306 if (event.target.id.match(/(operation|set_other_primary)/) === null) {
307 // Display 'Add new' checkbox if there is a main block, and this is an
308 // email or phone type.
309 if (mainBlock != false && (blockName == 'email' || blockName == 'phone')) {
310 var op_id = 'location_blocks[' + blockName + '][' + blockId + '][operation]';
311 this_controls.find(".location_operation_checkbox").html(
312 '<input id="' + op_id + '" name="' + op_id + '" type="checkbox" value="1" class="crm-form-checkbox"><label for="' + op_id + '">{/literal}{ts}Add new{/ts}{literal}</label>'
313 );
314 }
315 else {
316 this_controls.find(".location_operation_checkbox").html('');
317 }
318 }
041d6d6b 319
abd0b852
J
320 // Skip if 'set primary' was clicked
321 if (event.target.id.match(/(set_other_primary)/) === null) {
322 // Display 'Set primary' checkbox if applicable
323 if (blockName != 'website' && (mainBlock == false || mainBlock['is_primary'] != "1" || add_new_check_length > 0)) {
324 var prim_id = 'location_blocks[' + blockName + '][' + blockId + '][set_other_primary]';
325 this_controls.find(".location_set_other_primary").html(
326 '<input id="' + prim_id + '" name="' + prim_id + '" type="checkbox" value="1" class="crm-form-checkbox"><label for="' + prim_id + '">{/literal}{ts}Set as primary{/ts}{literal}</label>'
327 );
328 }
329 else {
330 this_controls.find(".location_set_other_primary").html('');
06f557c5 331 }
06f557c5 332 }
204ad1b2 333
06f557c5
J
334 }
335
149ae679
J
336 /**
337 * Look for a matching 'main' contact location block by entity, location and
338 * type
339 *
149ae679
J
340 * @param entName string
341 * The entity name to lookup.
342 * @param locationID int
343 * The location ID to lookup.
344 * @param typeID int
345 * The type ID to lookup.
346 *
347 * @returns boolean|object
348 * Returns false if no match, otherwise an object with the location ID and
349 * display value.
350 */
edf8e092 351 function findBlock(entName, locationID, typeID) {
bf43eaac
J
352 var entityArray = allBlock[entName];
353 var result = false;
354 for (var i = 0; i < entityArray.length; i++) {
355 // Match based on location and type ID, depending on the entity info
356 if (locationBlockInfo[entName]['hasLocation'] == false || locationID == entityArray[i]['location_type_id']) {
357 if (locationBlockInfo[entName]['hasType'] == false || typeID == entityArray[i][locationBlockInfo[entName]['hasType']]) {
358 result = {
359 display: entityArray[i][locationBlockInfo[entName]['displayField']],
041d6d6b
J
360 id: entityArray[i]['id'],
361 is_primary: entityArray[i]['is_primary']
bf43eaac
J
362 };
363 break;
364 }
365 }
366 }
367 return result;
368 }
369
e0aa05fb
J
370 /**
371 * Called when a 'set primary' checkbox is clicked in order to disable any
372 * other 'set primary' checkboxes for blocks of the same entity. So don't let
373 * users try to set two different phone numbers as primary on the form.
ca792455
J
374 *
375 * @param event object
376 * The event that triggered the update
e0aa05fb 377 */
ca792455 378 function updateSetPrimaries(event) {
e0aa05fb
J
379 var nameSplit = event.target.name.split('[');
380 var blockName = nameSplit[1].slice(0, -1);
381 var controls = CRM.$('span.location_block_controls[id^="main_' + blockName + '"]');
382
383 // Enable everything
384 controls.find('input[id$="[set_other_primary]"]:not(:checked)').removeAttr("disabled");
385
386 // If one is checked, disable the others
387 if (controls.find('input[id$="[set_other_primary]"]:checked').length > 0) {
388 controls.find('input[id$="[set_other_primary]"]:not(:checked)').attr("disabled", "disabled");
389 }
390 }
391
972e23db 392 /**
393 * Toggle the location type and the is_primary on & off depending on whether the merge box is ticked.
394 *
395 * @param element
396 */
397 function toggleRelatedLocationFields(element) {
398 relatedElements = CRM.$(element).parent().siblings('td').find('input,select,label,hidden');
399 if (CRM.$(element).is(':checked')) {
400 relatedElements.removeClass('disabled').attr('disabled', false);
204ad1b2 401
972e23db 402 }
403 else {
404 relatedElements.addClass('disabled').attr('disabled', true);
405 }
204ad1b2 406
972e23db 407 }
eb61dc07 408
972e23db 409 CRM.$(function($) {
410 $('input.crm-form-checkbox[data-is_location]').on('click', function(){
411 toggleRelatedLocationFields(this)
6a488035 412 });
53e45f60 413
eb61dc07
J
414 // Show/hide matching data rows
415 $('.toggle_equal_rows').click(function() {
13919cf8 416 $('tr.merge-row-equal').toggle();
6a488035 417 });
53e45f60 418
edf8e092 419 // Call mergeBlock whenever a location type is changed
edc36333
J
420 // (This is applied to the body because the inputs can be added dynamically
421 // to the form, and we need to catch when they change.)
422 $('body').on('change', 'select[id$="locTypeId"],select[id$="typeTypeId"],input[id$="[operation]"],input[id$="[set_other_primary]"]', function(event){
e0aa05fb 423
edf8e092 424 // All the information we need is held in the id, separated by underscores
abd0b852 425 var nameSplit = this.name.split('[');
e0aa05fb 426
edf8e092 427 // Lookup the main value, if any are available
abd0b852 428 if (allBlock[nameSplit[1].slice(0, -1)] != undefined) {
ca792455 429 updateMainLocationBlock(nameSplit[1].slice(0, -1), nameSplit[2].slice(0, -1), event);
edf8e092 430 }
e0aa05fb
J
431
432 // Update all 'set primary' checkboxes
ca792455 433 updateSetPrimaries(event);
e0aa05fb 434
edf8e092
J
435 });
436
ae8f569f 437 });
6a488035
TO
438
439</script>
440{/literal}
441
442{* process the dupe contacts *}
443{include file="CRM/common/dedupe.tpl"}