First attempt at https://issues.civicrm.org/jira/browse/CRM-17556
[civicrm-core.git] / templates / CRM / Contact / Form / Merge.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.7 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2015 |
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">
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>
30
31 <div class="crm-submit-buttons">
32 {include file="CRM/common/formButtons.tpl" location="top"}
33 {if $prev}<a href="{$prev}" class="crm-hover-button action-item"><i class="crm-i fa-chevron-left"></i> {ts}Previous{/ts}</a>{/if}
34 {if $next}<a href="{$next}" class="crm-hover-button action-item">{ts}Next{/ts} <i class="crm-i fa-chevron-right"></i></a>{/if}
35 </div>
36
37 <div class="action-link">
38 <a href="{$flip}" class="action-item crm-hover-button">
39 <i class="crm-i fa-random"></i>
40 {ts}Flip between original and duplicate contacts.{/ts}
41 </a>
42 </div>
43
44 <div class="action-link">
45 <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;">
46 <i class="crm-i fa-times-circle"></i>
47 {ts}Mark this pair as not a duplicate.{/ts}
48 </a>
49 </div>
50
51 <div class="action-link">
52 <a href="javascript:void(0);" class="action-item crm-hover-button toggle_equal_rows">
53 <span class="icon ui-icon-circle-check"></span>
54 {ts}Show/hide rows with the same data on each contact record.{/ts}
55 </a>
56 </div>
57
58 <table class="row-highlight">
59 <tr class="columnheader">
60 <th>&nbsp;</th>
61 <th><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$other_cid"}">{$other_name}</a> ({ts}duplicate{/ts})</th>
62 <th>{ts}Mark All{/ts}<br />=={$form.toggleSelect.html} ==&gt;</th>
63 <th><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$main_cid"}">{$main_name}</a></th>
64 <th width="300">Add/overwrite?</th>
65 </tr>
66
67 {crmAPI var='other_result' entity='Contact' action='get' return="modified_date" id=$other_cid}
68
69 {crmAPI var='main_result' entity='Contact' action='get' return="modified_date" id=$main_cid}
70
71
72 <tr style="background-color: #FFFFCC !important; border-bottom:1px solid #ccc !important;">
73 <td>Last modified</td>
74 <td>{$other_result.values.0.modified_date|date_format:"%d/%m/%y %H:%M:%S"} {if $other_result.values.0.modified_date gt $main_result.values.0.modified_date} (Most recent) {/if}</td>
75 <td>{if $other_result.values.0.modified_date gt $main_result.values.0.modified_date} &gt;&gt;&gt;&gt;&gt;&gt; {else} &lt;&lt;&lt;&lt;&lt;&lt; {/if} </td>
76 <td>{$main_result.values.0.modified_date|date_format:"%d/%m/%y %H:%M:%S"} {if $main_result.values.0.modified_date gt $other_result.values.0.modified_date} (Most recent) {/if}</td>
77 <td></td>
78 </tr>
79
80 {foreach from=$rows item=row key=field}
81
82 {if !isset($row.main) && !isset($row.other)}
83 <tr style="background-color: #fff !important; border-bottom:1px solid #ccc !important;" class="no-data">
84 <td>
85 <strong>{$row.title}</strong>
86 </td>
87 {else}
88 {if $row.main eq $row.other}
89 <tr style="background-color: #EFFFE7 !important; border-bottom:1px solid #ccc !important;" class="equal-data {cycle values="odd-row,even-row"}">
90 {else}
91 <tr style="background-color: #FFECEC !important; border-bottom:1px solid #ccc !important;" class="diff-data {cycle values="odd-row,even-row"}">
92 {/if}
93 <td>
94 {$row.title}
95 </td>
96 {/if}
97
98 <td>
99 {if $row.title|substr:0:7 == "Address"}<span id="other_{$blockName}_{$blockId}" style="white-space:pre">{else}<span id="other_{$blockName}_{$blockId}">{/if}{if !is_array($row.other)}{$row.other}{elseif $row.other.fileName}{$row.other.fileName}{else}{', '|implode:$row.other}{/if}</span>
100 </td>
101
102 <td style='white-space: nowrap'>
103 {if $form.$field}=={$form.$field.html|crmAddClass:"select-row"}==&gt;{/if}
104 </td>
105
106 {assign var=position value=$field|strrpos:'_'}
107 {assign var=blockId value=$field|substr:$position+1}
108 {assign var=blockName value=$field|substr:14:$position-14}
109
110 {if $row.title|substr:0:5 == "Email" OR
111 $row.title|substr:0:7 == "Address" OR
112 $row.title|substr:0:2 == "IM" OR
113 $row.title|substr:0:7 == "Website" OR
114 $row.title|substr:0:5 == "Phone"}
115
116 <td>
117 {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>
118 </td>
119
120 <td>
121
122 {if $blockName eq 'email' || $blockName eq 'phone' || $blockName eq 'address' || $blockName eq 'im' }
123 {$form.location.$blockName.$blockId.locTypeId.html}&nbsp;
124 {/if}
125
126 {* TODO display other_type_id for websites, ims and phones *}
127 {if $blockName eq 'website' || $blockName eq 'im' || $blockName eq 'phone' }
128 {$form.type.$blockName.$blockId.typeTypeId.html}&nbsp;
129 {/if}
130
131 {if $blockName eq 'email' || $blockName eq 'phone' || $blockName eq 'website' || $blockName eq 'im' }
132 <span id="main_{$blockName}_{$blockId}_overwrite">
133 {if $row.main}
134 (overwrite){$form.location.$blockName.$blockId.html}&nbsp;<br />
135 {else}
136 (add)
137 {/if}
138 </span>
139 {/if}
140
141 {literal}
142 <script type="text/javascript">
143 function mergeBlock(blockname, element, blockId) {
144 var allBlock = {/literal}{$mainLocBlock}{literal};
145 var block = eval( "allBlock." + 'main_'+ blockname + element.value);
146 if(blockname == 'email' || blockname == 'phone'){
147 var label = '(overwrite)'+ '<span id="main_blockname_blockId_overwrite">{/literal}{$form.location.$blockName.$blockId.operation.html}{literal}<br /></span>';
148 }
149 else {
150 label = '(overwrite)<br />';
151 }
152
153 if ( !block ) {
154 block = '';
155 label = '(add)';
156 }
157 cj( "#main_"+ blockname +"_" + blockId ).html( block );
158 cj( "#main_"+ blockname +"_" + blockId +"_overwrite" ).html( label );
159 }
160 </script>
161 {/literal}
162
163 </td>
164
165 {else}
166
167 <td>
168 <span id="main_{$blockName}_{$blockId}">
169 {if !is_array($row.main)}
170 {$row.main}
171 {elseif $row.main.fileName}
172 {$row.main.fileName}
173 {else}
174 {', '|implode:$row.main}
175 {/if}
176 </span>
177 </td>
178
179 <td>
180
181 {if isset($row.main) || isset($row.other)}
182 <span id="main_{$blockName}_{$blockId}_overwrite">
183 {if $row.main}
184 (overwrite)<br />
185 {else}
186 (add)
187 {/if}
188 </span>
189 {/if}
190
191 </td>
192
193 {/if}
194 {*NYSS 5546*}
195
196
197 </tr>
198 {/foreach}
199
200 {foreach from=$rel_tables item=params key=paramName}
201 {if $paramName eq 'move_rel_table_users'}
202 <tr class="{cycle values="even-row,odd-row"}">
203 <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>
204 <td>(migrate)</td>
205 </tr>
206 {else}
207 <tr class="{cycle values="even-row,odd-row"}">
208 <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>
209 <td>(migrate)</td>
210 </tr>
211 {/if}
212 {/foreach}
213 </table>
214 <div class='form-item'>
215 <!--<p>{$form.moveBelongings.html} {$form.moveBelongings.label}</p>-->
216 <!--<p>{$form.deleteOther.html} {$form.deleteOther.label}</p>-->
217 </div>
218 <div class="message status">
219 <p><strong>{ts}WARNING: The duplicate contact record WILL BE DELETED after the merge is complete.{/ts}</strong></p>
220 {if $user}
221 <p><strong>{ts 1=$config->userFramework}There are %1 user accounts associated with both the original and duplicate contacts. Ensure that the Drupal 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.
222 The user record associated with the duplicate contact will not be deleted, but will be un-linked from the associated contact record (which will be deleted).
223 You will need to manually delete that user (click on the link to open Drupal 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></p>
224 {/if}
225 </div>
226
227 <div class="crm-submit-buttons">
228 {include file="CRM/common/formButtons.tpl" location="bottom"}
229 </div>
230
231 {literal}
232 <script type="text/javascript">
233
234 CRM.$(function($) {
235 $('table td input.form-checkbox').each(function() {
236 var ele = null;
237 var element = $(this).attr('id').split('_',3);
238
239 switch ( element['1'] ) {
240 case 'addressee':
241 ele = '#' + element['0'] + '_' + element['1'];
242 break;
243
244 case 'email':
245 case 'postal':
246 ele = '#' + element['0'] + '_' + element['1'] + '_' + element['2'];
247 break;
248 }
249
250 if( ele ) {
251 $(this).on('click', function() {
252 var val = $(this).prop('checked');
253 $('input' + ele + ', input' + ele + '_custom').prop('checked', val);
254 });
255 }
256 });
257 });
258
259 // show / hide same data rows
260
261 CRM.$('.toggle_equal_rows').click( function() {
262 CRM.$('tr.equal-data').toggle();
263 });
264
265 </script>
266 {/literal}
267
268 {* process the dupe contacts *}
269 {include file="CRM/common/dedupe.tpl"}