Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
2c4c49ca | 3 | | CiviCRM version 4.7 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
fa938177 | 5 | | Copyright CiviCRM LLC (c) 2004-2016 | |
6a488035 TO |
6 | +--------------------------------------------------------------------+ |
7 | | This file is a part of CiviCRM. | | |
8 | | | | |
9 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
10 | | under the terms of the GNU Affero General Public License | | |
11 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
12 | | | | |
13 | | CiviCRM is distributed in the hope that it will be useful, but | | |
14 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
15 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
16 | | See the GNU Affero General Public License for more details. | | |
17 | | | | |
18 | | You should have received a copy of the GNU Affero General Public | | |
19 | | License and the CiviCRM Licensing Exception along | | |
20 | | with this program; if not, contact CiviCRM LLC | | |
21 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
22 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
23 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
24 | +--------------------------------------------------------------------+ | |
25 | *} | |
26 | <div class="crm-block crm-form-block crm-contact-merge-form-block"> | |
3bb59daf AH |
27 | <div class="help"> |
28 | {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"} | |
29 | </div> | |
ffd39a49 | 30 | |
ffd39a49 J |
31 | <div class="message status"> |
32 | <div class="icon inform-icon"></div> | |
3bb59daf | 33 | <strong>{ts}WARNING: The duplicate contact record WILL BE DELETED after the merge is complete.{/ts}</strong> |
ffd39a49 | 34 | </div> |
ffd39a49 | 35 | |
3bb59daf AH |
36 | {if $user} |
37 | <div class="message status"> | |
38 | <div class="icon inform-icon"></div> | |
39 | <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. | |
40 | 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). | |
41 | 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> | |
42 | </div> | |
43 | {/if} | |
44 | ||
45 | <div class="crm-submit-buttons"> | |
46 | {include file="CRM/common/formButtons.tpl" location="top"} | |
47 | </div> | |
6a488035 | 48 | |
3bb59daf AH |
49 | <div class="action-link"> |
50 | {if $prev}<a href="{$prev}" class="crm-hover-button action-item"><i class="crm-i fa-chevron-left"></i> {ts}Previous{/ts}</a>{/if} | |
51 | {if $next}<a href="{$next}" class="crm-hover-button action-item">{ts}Next{/ts} <i class="crm-i fa-chevron-right"></i></a>{/if} | |
52 | <a href="{$flip}" class="action-item crm-hover-button"> | |
53 | <i class="crm-i fa-random"></i> | |
54 | {ts}Flip between original and duplicate contacts.{/ts} | |
55 | </a> | |
56 | </div> | |
6a488035 | 57 | |
3bb59daf AH |
58 | <div class="action-link"> |
59 | <a href="#" class="action-item crm-hover-button crm-notDuplicate" title={ts}Mark this pair as not a duplicate.{/ts} onClick="processDupes( {$main_cid}, {$other_cid}, 'dupe-nondupe', 'merge-contact', '{if $rgid}{crmURL p="civicrm/contact/dedupefind" q="reset=1&action=update&rgid=$rgid"}{/if}' );return false;"> | |
60 | <i class="crm-i fa-times-circle"></i> | |
61 | {ts}Mark this pair as not a duplicate.{/ts} | |
62 | </a> | |
63 | </div> | |
6a488035 | 64 | |
3bb59daf AH |
65 | <div class="action-link"> |
66 | <a href="javascript:void(0);" class="action-item crm-hover-button toggle_equal_rows"> | |
67 | <i class="crm-i fa-eye-slash"></i> | |
68 | {ts}Show/hide rows with the same data on each contact record.{/ts} | |
69 | </a> | |
70 | </div> | |
08ef1f91 | 71 | |
3bb59daf AH |
72 | <table class="row-highlight"> |
73 | <tr class="columnheader"> | |
74 | <th> </th> | |
75 | <th><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$other_cid"}">{$other_name}</a> ({ts}duplicate{/ts})</th> | |
76 | <th>{ts}Mark All{/ts}<br />=={$form.toggleSelect.html} ==></th> | |
77 | <th><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$main_cid"}">{$main_name}</a></th> | |
78 | <th width="300">Add/overwrite?</th> | |
79 | </tr> | |
eb61dc07 | 80 | |
3bb59daf | 81 | {crmAPI var='other_result' entity='Contact' action='get' return="modified_date" id=$other_cid} |
3b8dfec6 | 82 | |
3bb59daf | 83 | {crmAPI var='main_result' entity='Contact' action='get' return="modified_date" id=$main_cid} |
eb61dc07 | 84 | |
3bb59daf AH |
85 | <tr> |
86 | <td>Last modified</td> | |
87 | <td>{$other_result.values.0.modified_date|crmDate} {if $other_result.values.0.modified_date gt $main_result.values.0.modified_date} (Most recent) {/if}</td> | |
88 | <td></td> | |
89 | <td>{$main_result.values.0.modified_date|crmDate} {if $main_result.values.0.modified_date gt $other_result.values.0.modified_date} (Most recent) {/if}</td> | |
90 | <td></td> | |
91 | </tr> | |
eb61dc07 | 92 | |
3bb59daf | 93 | {foreach from=$rows item=row key=field} |
6a488035 | 94 | |
3bb59daf AH |
95 | {if !isset($row.main) && !isset($row.other)} |
96 | <tr style="background-color: #fff !important; border-bottom:1px solid #ccc !important;" class="no-data"> | |
eb61dc07 | 97 | <td> |
3bb59daf | 98 | <strong>{$row.title}</strong> |
eb61dc07 | 99 | </td> |
3bb59daf AH |
100 | {else} |
101 | {if $row.main eq $row.other} | |
102 | <tr class="merge-row-equal crm-row-ok {cycle values="odd-row,even-row"}"> | |
103 | {else} | |
104 | <tr class="crm-row-error {cycle values="odd-row,even-row"}"> | |
105 | {/if} | |
eb61dc07 | 106 | <td> |
3bb59daf | 107 | {$row.title} |
eb61dc07 | 108 | </td> |
3bb59daf | 109 | {/if} |
53e45f60 | 110 | |
3bb59daf AH |
111 | {assign var=position value=$field|strrpos:'_'} |
112 | {assign var=blockId value=$field|substr:$position+1} | |
113 | {assign var=blockName value=$field|substr:14:$position-14} | |
eb61dc07 J |
114 | |
115 | <td> | |
3bb59daf | 116 | {if $row.title|substr:0:7 == "Address"}<span style="white-space:pre">{else}<span>{/if}{if !is_array($row.other)}{$row.other}{elseif $row.other.fileName}{$row.other.fileName}{else}{', '|implode:$row.other}{/if}</span> |
eb61dc07 J |
117 | </td> |
118 | ||
3bb59daf AH |
119 | <td style='white-space: nowrap'> |
120 | {if $form.$field}=={$form.$field.html|crmAddClass:"select-row"}==>{/if} | |
121 | </td> | |
122 | ||
123 | {* For location blocks *} | |
124 | {if $row.title|substr:0:5 == "Email" OR | |
125 | $row.title|substr:0:7 == "Address" OR | |
126 | $row.title|substr:0:2 == "IM" OR | |
127 | $row.title|substr:0:7 == "Website" OR | |
128 | $row.title|substr:0:5 == "Phone"} | |
129 | ||
130 | <td> | |
131 | {if $row.title|substr:0:7 == "Address"}<span id="main_{$blockName}_{$blockId}" style="white-space:pre">{else}<span id="main_{$blockName}_{$blockId}">{/if}{if !is_array($row.main)}{$row.main}{elseif $row.main.fileName}{$row.main.fileName}{else}{', '|implode:$row.main}{/if}</span> | |
132 | </td> | |
133 | ||
134 | <td> | |
135 | {* Display location for fields with locations *} | |
136 | {if $blockName eq 'email' || $blockName eq 'phone' || $blockName eq 'address' || $blockName eq 'im' } | |
137 | {$form.location.$blockName.$blockId.locTypeId.html} | |
138 | {/if} | |
139 | ||
140 | {* Display other_type_id for websites, ims and phones *} | |
141 | {if $blockName eq 'website' || $blockName eq 'im' || $blockName eq 'phone' } | |
142 | {$form.location.$blockName.$blockId.typeTypeId.html} | |
143 | {/if} | |
144 | ||
145 | {* Display the overwrite/add/add new label *} | |
146 | <span id="main_{$blockName}_{$blockId}_overwrite"> | |
147 | {if $row.main} | |
148 | <span class="action_label">({ts}overwrite{/ts})</span> | |
149 | {if $blockName eq 'email' || $blockName eq 'phone' } | |
150 | {$form.location.$blockName.$blockId.operation.html} | |
151 | {/if} | |
152 | <br /> | |
153 | {else} | |
154 | <span class="action_label">({ts}add{/ts})</span> | |
155 | {/if} | |
156 | </span> | |
157 | </td> | |
158 | ||
159 | {* For non-location blocks *} | |
160 | {else} | |
161 | ||
162 | <td> | |
3b8dfec6 | 163 | <span> |
3bb59daf AH |
164 | {if !is_array($row.main)} |
165 | {$row.main} | |
166 | {elseif $row.main.fileName} | |
167 | {$row.main.fileName} | |
168 | {else} | |
169 | {', '|implode:$row.main} | |
eb61dc07 | 170 | {/if} |
08ef1f91 | 171 | </span> |
3bb59daf AH |
172 | </td> |
173 | ||
174 | <td> | |
175 | {if isset($row.main) || isset($row.other)} | |
176 | <span> | |
177 | {if $row.main == $row.other} | |
178 | <span class="action_label">({ts}match{/ts})</span><br /> | |
179 | {elseif $row.main} | |
180 | <span class="action_label">({ts}overwrite{/ts})</span><br /> | |
181 | {else} | |
182 | <span class="action_label">({ts}add{/ts})</span> | |
183 | {/if} | |
184 | </span> | |
185 | {/if} | |
186 | </td> | |
eb61dc07 | 187 | |
3bb59daf | 188 | {/if} |
08ef1f91 | 189 | |
3bb59daf AH |
190 | </tr> |
191 | {/foreach} | |
6a488035 | 192 | |
3bb59daf AH |
193 | {foreach from=$rel_tables item=params key=paramName} |
194 | {if $paramName eq 'move_rel_table_users'} | |
195 | <tr class="{cycle values="even-row,odd-row"}"> | |
196 | <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"}==>{else}<td style='white-space: nowrap'></td>{/if}</td><td>{if $mainUfId}<a target="_blank" href="{$params.main_url}">{$mainUfName}</a>{/if}</td> | |
197 | <td>({ts}migrate{/ts})</td> | |
198 | </tr> | |
199 | {else} | |
6a488035 | 200 | <tr class="{cycle values="even-row,odd-row"}"> |
3bb59daf AH |
201 | <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"}==></td><td><a href="{$params.main_url}">{$params.title}</a>{if $form.operation.$paramName.add.html} {$form.operation.$paramName.add.html}{/if}</td> |
202 | <td>({ts}migrate{/ts})</td> | |
203 | </tr> | |
204 | {/if} | |
205 | {/foreach} | |
206 | </table> | |
207 | <div class='form-item'> | |
208 | <!--<p>{$form.moveBelongings.html} {$form.moveBelongings.label}</p>--> | |
209 | <!--<p>{$form.deleteOther.html} {$form.deleteOther.label}</p>--> | |
210 | </div> | |
6a488035 | 211 | |
3bb59daf AH |
212 | <div class="crm-submit-buttons"> |
213 | {include file="CRM/common/formButtons.tpl" location="bottom"} | |
214 | </div> | |
6a488035 TO |
215 | </div> |
216 | ||
217 | {literal} | |
218 | <script type="text/javascript"> | |
219 | ||
06f557c5 J |
220 | function mergeBlock(blockname, element, blockId, type) { |
221 | var allBlock = {/literal}{$mainLocBlock}{literal}; | |
222 | ||
223 | // Get type of select list that's been changed (location or type) | |
224 | var locTypeId = ''; | |
225 | var typeTypeId = ''; | |
226 | ||
227 | // If the location was changed, lookup the type if it exists | |
228 | if (type == 'locTypeId') { | |
229 | locTypeId = element.value; | |
d9b043a1 | 230 | typeTypeId = CRM.$( 'select#location_' + blockname + '_' + blockId + '_typeTypeId' ).val(); |
06f557c5 J |
231 | } |
232 | ||
233 | // Otherwise the type was changed, lookup the location if it exists | |
234 | else { | |
235 | locTypeId = CRM.$( 'select#location_' + blockname + '_' + blockId + '_locTypeId' ).val(); | |
236 | typeTypeId = element.value; | |
237 | } | |
238 | ||
34917198 J |
239 | // @todo Fix this 'special handling' for websites (no location id) |
240 | if (!locTypeId) { locTypeId = 0; } | |
241 | ||
06f557c5 | 242 | // Get the matching block, based on location and type, from the main contact record |
34917198 J |
243 | var blockQuery = "allBlock.main_" + blockname + "_" + locTypeId; |
244 | if (typeTypeId) { | |
245 | blockQuery += "_" + typeTypeId; | |
06f557c5 | 246 | } |
34917198 J |
247 | var block = eval( blockQuery ); |
248 | var mainBlockId = 0; | |
249 | var mainBlockDisplay = ''; | |
204ad1b2 | 250 | |
06f557c5 | 251 | // Create appropriate label / add new link after changing the block |
34917198 | 252 | if (typeof block == 'undefined') { |
fbdef2da | 253 | label = '<span class="action_label">({/literal}{ts}add{/ts}{literal})</span>'; |
06f557c5 J |
254 | } |
255 | else { | |
34917198 J |
256 | |
257 | // Set display and ID | |
258 | mainBlockDisplay = block['display']; | |
259 | mainBlockId = block['id']; | |
260 | ||
261 | // Set label | |
fbdef2da | 262 | var label = '<span class="action_label">({/literal}{ts}overwrite{/ts}{literal})</span> '; |
06f557c5 J |
263 | if (blockname == 'email' || blockname == 'phone') { |
264 | var opLabel = 'location[' + blockname + '][' + blockId + '][operation]'; | |
fbdef2da | 265 | label += '<input id="' + opLabel + '" name="' + opLabel + '" type="checkbox" value="1" class="crm-form-checkbox"> <label for="' + opLabel + '">{/literal}{ts}add new{/ts}{literal}</label><br />'; |
06f557c5 J |
266 | } |
267 | label += '<br>'; | |
268 | } | |
204ad1b2 | 269 | |
34917198 J |
270 | // Update DOM |
271 | CRM.$( "input[name='location[" + blockname + "][" + blockId + "][mainContactBlockId]']" ).val( mainBlockId ); | |
272 | CRM.$( "#main_" + blockname + "_" + blockId ).html( mainBlockDisplay ); | |
06f557c5 J |
273 | CRM.$( "#main_" + blockname + "_" + blockId + "_overwrite" ).html( label ); |
274 | } | |
275 | ||
ae8f569f | 276 | CRM.$(function($) { |
53e45f60 | 277 | |
06f557c5 J |
278 | $('body').on('change', "input[id*='[operation]']", function() { |
279 | var originalHtml = $(this).prevAll('span.action_label').html(); | |
280 | if ($(this).is(":checked")) { | |
fbdef2da | 281 | $(this).prevAll('span.action_label').html(originalHtml.replace('({/literal}{ts}overwrite{/ts}{literal})', '({/literal}{ts}add new{/ts}{literal})')); |
06f557c5 J |
282 | } |
283 | else { | |
fbdef2da | 284 | $(this).prevAll('span.action_label').html(originalHtml.replace('({/literal}{ts}add new{/ts}{literal})', '({/literal}{ts}overwrite{/ts}{literal})')); |
06f557c5 J |
285 | } |
286 | }); | |
287 | ||
ae8f569f | 288 | $('table td input.form-checkbox').each(function() { |
204ad1b2 J |
289 | var ele = null; |
290 | var element = $(this).attr('id').split('_',3); | |
291 | ||
292 | switch ( element['1'] ) { | |
293 | case 'addressee': | |
294 | ele = '#' + element['0'] + '_' + element['1']; | |
295 | break; | |
296 | ||
297 | case 'email': | |
298 | case 'postal': | |
299 | ele = '#' + element['0'] + '_' + element['1'] + '_' + element['2']; | |
300 | break; | |
301 | } | |
eb61dc07 | 302 | |
204ad1b2 | 303 | if( ele ) { |
eb61dc07 J |
304 | $(this).on('click', function() { |
305 | var val = $(this).prop('checked'); | |
306 | $('input' + ele + ', input' + ele + '_custom').prop('checked', val); | |
307 | }); | |
204ad1b2 | 308 | } |
6a488035 | 309 | }); |
53e45f60 | 310 | |
eb61dc07 J |
311 | // Show/hide matching data rows |
312 | $('.toggle_equal_rows').click(function() { | |
13919cf8 | 313 | $('tr.merge-row-equal').toggle(); |
6a488035 | 314 | }); |
53e45f60 | 315 | |
ae8f569f | 316 | }); |
6a488035 TO |
317 | |
318 | </script> | |
319 | {/literal} | |
320 | ||
321 | {* process the dupe contacts *} | |
322 | {include file="CRM/common/dedupe.tpl"} |