Make merge CSS less specific and better integrated
[civicrm-core.git] / templates / CRM / Contact / Form / Merge.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
2c4c49ca 3 | CiviCRM version 4.7 |
6a488035 4 +--------------------------------------------------------------------+
e7112fa7 5 | Copyright CiviCRM LLC (c) 2004-2015 |
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">
f6eedce7 27<div class="help">
6a488035
TO
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
fd66df85 31<div class="crm-submit-buttons">
fd66df85 32 {include file="CRM/common/formButtons.tpl" location="top"}
f62db3ac
AH
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}
fd66df85 35</div>
6a488035
TO
36
37<div class="action-link">
fd66df85 38 <a href="{$flip}" class="action-item crm-hover-button">
f62db3ac 39 <i class="crm-i fa-random"></i>
fd66df85
CW
40 {ts}Flip between original and duplicate contacts.{/ts}
41 </a>
6a488035
TO
42</div>
43
44<div class="action-link">
aeb97cc1 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;">
f62db3ac 46 <i class="crm-i fa-times-circle"></i>
fd66df85
CW
47 {ts}Mark this pair as not a duplicate.{/ts}
48 </a>
6a488035
TO
49</div>
50
08ef1f91
R
51<div class="action-link">
52 <a href="javascript:void(0);" class="action-item crm-hover-button toggle_equal_rows">
eb61dc07 53 <i class="crm-i fa-eye-slash"></i>
08ef1f91
R
54 {ts}Show/hide rows with the same data on each contact record.{/ts}
55 </a>
56</div>
57
a76cd114 58<table class="row-highlight">
6a488035
TO
59 <tr class="columnheader">
60 <th>&nbsp;</th>
f1f27800 61 <th><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$other_cid"}">{$other_name}</a> ({ts}duplicate{/ts})</th>
6a488035 62 <th>{ts}Mark All{/ts}<br />=={$form.toggleSelect.html} ==&gt;</th>
f1f27800 63 <th><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$main_cid"}">{$main_name}</a></th>
08ef1f91
R
64 <th width="300">Add/overwrite?</th>
65 </tr>
eb61dc07 66
08ef1f91 67 {crmAPI var='other_result' entity='Contact' action='get' return="modified_date" id=$other_cid}
eb61dc07
J
68
69 {crmAPI var='main_result' entity='Contact' action='get' return="modified_date" id=$main_cid}
70
13919cf8 71 <tr>
08ef1f91
R
72 <td>Last modified</td>
73 <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>
76e0f310 74 <td></td>
08ef1f91
R
75 <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>
76 <td></td>
6a488035 77 </tr>
eb61dc07 78
6a488035 79 {foreach from=$rows item=row key=field}
eb61dc07
J
80
81 {if !isset($row.main) && !isset($row.other)}
82 <tr style="background-color: #fff !important; border-bottom:1px solid #ccc !important;" class="no-data">
6a488035 83 <td>
08ef1f91 84 <strong>{$row.title}</strong>
6a488035 85 </td>
08ef1f91
R
86 {else}
87 {if $row.main eq $row.other}
66d5b989 88 <tr class="merge-row-equal crm-row-ok {cycle values="odd-row,even-row"}">
08ef1f91 89 {else}
66d5b989 90 <tr class="crm-row-error {cycle values="odd-row,even-row"}">
08ef1f91 91 {/if}
6a488035 92 <td>
08ef1f91
R
93 {$row.title}
94 </td>
eb61dc07
J
95 {/if}
96
97 <td>
98 {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>
99 </td>
100
08ef1f91
R
101 <td style='white-space: nowrap'>
102 {if $form.$field}=={$form.$field.html|crmAddClass:"select-row"}==&gt;{/if}
103 </td>
eb61dc07
J
104
105 {assign var=position value=$field|strrpos:'_'}
106 {assign var=blockId value=$field|substr:$position+1}
107 {assign var=blockName value=$field|substr:14:$position-14}
53e45f60 108
eb61dc07 109 {* For location blocks *}
08ef1f91
R
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
eb61dc07
J
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>
06f557c5 121 {* Display location for fields with locations *}
eb61dc07
J
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 {* Display other_type_id for websites, ims and phones *}
127 {if $blockName eq 'website' || $blockName eq 'im' || $blockName eq 'phone' }
4f2ad1d1 128 {$form.location.$blockName.$blockId.typeTypeId.html}&nbsp;
eb61dc07 129 {/if}
204ad1b2 130
06f557c5
J
131 {* Display the overwrite/add/add new label *}
132 <span id="main_{$blockName}_{$blockId}_overwrite">
133 {if $row.main}
fbdef2da 134 <span class="action_label">({ts}overwrite{/ts})</span>&nbsp;
06f557c5
J
135 {if $blockName eq 'email' || $blockName eq 'phone' }
136 {$form.location.$blockName.$blockId.operation.html}&nbsp;
137 {/if}
138 <br />
139 {else}
fbdef2da 140 <span class="action_label">({ts}add{/ts})</span>&nbsp;
06f557c5
J
141 {/if}
142 </span>
eb61dc07 143 </td>
53e45f60 144
eb61dc07
J
145 {* For non-location blocks *}
146 {else}
147
148 <td>
149 <span id="main_{$blockName}_{$blockId}">
150 {if !is_array($row.main)}
151 {$row.main}
152 {elseif $row.main.fileName}
153 {$row.main.fileName}
154 {else}
155 {', '|implode:$row.main}
156 {/if}
157 </span>
158 </td>
159
160 <td>
161 {if isset($row.main) || isset($row.other)}
08ef1f91 162 <span id="main_{$blockName}_{$blockId}_overwrite">
13919cf8 163 {if $row.main == $row.other}
fbdef2da 164 <span class="action_label">({ts}match{/ts})</span><br />
13919cf8 165 {elseif $row.main}
fbdef2da 166 <span class="action_label">({ts}overwrite{/ts})</span><br />
08ef1f91 167 {else}
fbdef2da 168 <span class="action_label">({ts}add{/ts})</span>
eb61dc07 169 {/if}
08ef1f91 170 </span>
6a488035 171 {/if}
eb61dc07
J
172 </td>
173
174 {/if}
08ef1f91 175
6a488035
TO
176 </tr>
177 {/foreach}
178
179 {foreach from=$rel_tables item=params key=paramName}
180 {if $paramName eq 'move_rel_table_users'}
181 <tr class="{cycle values="even-row,odd-row"}">
a76cd114 182 <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>
08ef1f91 183 <td>(migrate)</td>
6a488035
TO
184 </tr>
185 {else}
186 <tr class="{cycle values="even-row,odd-row"}">
a76cd114 187 <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>
08ef1f91 188 <td>(migrate)</td>
6a488035
TO
189 </tr>
190 {/if}
191 {/foreach}
192</table>
193<div class='form-item'>
194 <!--<p>{$form.moveBelongings.html} {$form.moveBelongings.label}</p>-->
195 <!--<p>{$form.deleteOther.html} {$form.deleteOther.label}</p>-->
196</div>
197<div class="message status">
198 <p><strong>{ts}WARNING: The duplicate contact record WILL BE DELETED after the merge is complete.{/ts}</strong></p>
199 {if $user}
200 <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.
201The 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).
202You 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>
203 {/if}
6a488035
TO
204</div>
205
fd66df85 206<div class="crm-submit-buttons">
fd66df85 207 {include file="CRM/common/formButtons.tpl" location="bottom"}
6a488035
TO
208</div>
209
210{literal}
211<script type="text/javascript">
212
06f557c5
J
213 function mergeBlock(blockname, element, blockId, type) {
214 var allBlock = {/literal}{$mainLocBlock}{literal};
215
216 // Get type of select list that's been changed (location or type)
217 var locTypeId = '';
218 var typeTypeId = '';
219
220 // If the location was changed, lookup the type if it exists
221 if (type == 'locTypeId') {
222 locTypeId = element.value;
223 typeTypeId = CRM.$( 'select#type_' + blockname + '_' + blockId + '_typeTypeId' ).val();
224 }
225
226 // Otherwise the type was changed, lookup the location if it exists
227 else {
228 locTypeId = CRM.$( 'select#location_' + blockname + '_' + blockId + '_locTypeId' ).val();
229 typeTypeId = element.value;
230 }
231
34917198
J
232 // @todo Fix this 'special handling' for websites (no location id)
233 if (!locTypeId) { locTypeId = 0; }
234
06f557c5 235 // Get the matching block, based on location and type, from the main contact record
34917198
J
236 var blockQuery = "allBlock.main_" + blockname + "_" + locTypeId;
237 if (typeTypeId) {
238 blockQuery += "_" + typeTypeId;
06f557c5 239 }
34917198
J
240 var block = eval( blockQuery );
241 var mainBlockId = 0;
242 var mainBlockDisplay = '';
204ad1b2 243
06f557c5 244 // Create appropriate label / add new link after changing the block
34917198 245 if (typeof block == 'undefined') {
fbdef2da 246 label = '<span class="action_label">({/literal}{ts}add{/ts}{literal})</span>';
06f557c5
J
247 }
248 else {
34917198
J
249
250 // Set display and ID
251 mainBlockDisplay = block['display'];
252 mainBlockId = block['id'];
253
254 // Set label
fbdef2da 255 var label = '<span class="action_label">({/literal}{ts}overwrite{/ts}{literal})</span> ';
06f557c5
J
256 if (blockname == 'email' || blockname == 'phone') {
257 var opLabel = 'location[' + blockname + '][' + blockId + '][operation]';
fbdef2da 258 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
259 }
260 label += '<br>';
261 }
204ad1b2 262
34917198
J
263 // Update DOM
264 CRM.$( "input[name='location[" + blockname + "][" + blockId + "][mainContactBlockId]']" ).val( mainBlockId );
265 CRM.$( "#main_" + blockname + "_" + blockId ).html( mainBlockDisplay );
06f557c5
J
266 CRM.$( "#main_" + blockname + "_" + blockId + "_overwrite" ).html( label );
267 }
268
ae8f569f 269 CRM.$(function($) {
53e45f60 270
06f557c5
J
271 $('body').on('change', "input[id*='[operation]']", function() {
272 var originalHtml = $(this).prevAll('span.action_label').html();
273 if ($(this).is(":checked")) {
fbdef2da 274 $(this).prevAll('span.action_label').html(originalHtml.replace('({/literal}{ts}overwrite{/ts}{literal})', '({/literal}{ts}add new{/ts}{literal})'));
06f557c5
J
275 }
276 else {
fbdef2da 277 $(this).prevAll('span.action_label').html(originalHtml.replace('({/literal}{ts}add new{/ts}{literal})', '({/literal}{ts}overwrite{/ts}{literal})'));
06f557c5
J
278 }
279 });
280
ae8f569f 281 $('table td input.form-checkbox').each(function() {
204ad1b2
J
282 var ele = null;
283 var element = $(this).attr('id').split('_',3);
284
285 switch ( element['1'] ) {
286 case 'addressee':
287 ele = '#' + element['0'] + '_' + element['1'];
288 break;
289
290 case 'email':
291 case 'postal':
292 ele = '#' + element['0'] + '_' + element['1'] + '_' + element['2'];
293 break;
294 }
eb61dc07 295
204ad1b2 296 if( ele ) {
eb61dc07
J
297 $(this).on('click', function() {
298 var val = $(this).prop('checked');
299 $('input' + ele + ', input' + ele + '_custom').prop('checked', val);
300 });
204ad1b2 301 }
6a488035 302 });
53e45f60 303
eb61dc07
J
304 // Show/hide matching data rows
305 $('.toggle_equal_rows').click(function() {
13919cf8 306 $('tr.merge-row-equal').toggle();
eb61dc07 307 });
53e45f60 308
08ef1f91 309 });
6a488035
TO
310
311</script>
312{/literal}
313
314{* process the dupe contacts *}
315{include file="CRM/common/dedupe.tpl"}