2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2018 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
26 {if $action eq 2 || $action eq 16}
27 <div class="form-item">
28 <div class="crm-accordion-wrapper crm-search_filters-accordion">
29 <div class="crm-accordion-header">
30 {ts}Filter Contacts{/ts}</a>
31 </div><!-- /.crm-accordion-header -->
32 <div class="crm-accordion-body">
33 <table class="no-border form-layout-compressed" id="searchOptions" style="width:100%;">
35 <td class="crm-contact-form-block-contact1">
36 <label for="contact1">{ts}Contact 1{/ts}</label><br />
37 <input type="text" placeholder="Search Contact1" search-column="2" />
39 <td class="crm-contact-form-block-contact2">
40 <label for="contact2">{ts}Contact 2{/ts}</label><br />
41 <input type="text" placeholder="Search Contact2" search-column="4" />
43 <td class="crm-contact-form-block-email1">
44 <label for="email1">{ts}Email 1{/ts}</label><br />
45 <input type="text" placeholder="Search Email1" search-column="5" />
47 <td class="crm-contact-form-block-email2">
48 <label for="email2">{ts}Email 2{/ts}</label><br />
49 <input type="text" placeholder="Search Email2" search-column="6" />
53 <td class="crm-contact-form-block-street-address1">
54 <label for="street-adddress1">{ts}Street Address 1{/ts}</label><br />
55 <input type="text" placeholder="Search Street Address1" search-column="7" />
57 <td class="crm-contact-form-block-street-address2">
58 <label for="street-adddress2">{ts}Street Address 2{/ts}</label><br />
59 <input type="text" placeholder="Search Street Address2" search-column="8" />
61 <td class="crm-contact-form-block-postcode1">
62 <label for="postcode1">{ts}Postcode 1{/ts}</label><br />
63 <input type="text" placeholder="Search Postcode1" search-column="9" />
65 <td class="crm-contact-form-block-postcode2">
66 <label for="postcode2">{ts}Postcode 2{/ts}</label><br />
67 <input type="text" placeholder="Search Postcode2" search-column="10" />
71 </div><!-- /.crm-accordion-body -->
72 </div><!-- /.crm-accordion-wrapper -->
75 <input type='checkbox' id ='steet-address' class='toggle-vis' data-column-main="7" data-column-dupe="8" >
76 <label for="steet-address">{ts}Street Address{/ts} </label>
77 <input type='checkbox' id ='post-code' class='toggle-vis' data-column-main="9" data-column-dupe="10" >
78 <label for="post-code">{ts}Post Code{/ts} </label>
79 <input type='checkbox' id ='conflicts' class='toggle-vis' data-column-main="11" >
80 <label for="conflicts">{ts}Conflicts{/ts} </label>
81 <input type='checkbox' id ='threshold' class='toggle-vis' data-column-main="12" >
82 <label for="threshold">{ts}Threshold{/ts} </label>
84 <span id="dupePairs_length_selection">
85 <input type='checkbox' id ='crm-dedupe-display-selection' name="display-selection">
86 <label for="display-selection">{ts}Within Selections{/ts} </label>
90 class="nestedActivitySelector crm-ajax-table"
93 data-page-length="10",
94 data-searching='true',
97 data-column-defs='{literal}[{"targets": [0,1,3,13], "orderable":false}, {"targets": [7,8,9,10,11,12], "visible":false}]{/literal}'>
99 <tr class="columnheader">
100 <th data-data="is_selected_input" class="crm-dedupe-selection"><input type="checkbox" value="0" name="pnid_all" class="crm-dedupe-select-all"></th>
101 <th data-data="dst_image" class="crm-empty"> </th>
102 <th data-data="dst" class="crm-contact">{ts}Contact{/ts} 1</th>
103 <th data-data="src_image" class="crm-empty"> </th>
104 <th data-data="src" class="crm-contact-duplicate">{ts}Contact{/ts} 2 ({ts}Duplicate{/ts})</th>
105 <th data-data="dst_email" class="crm-contact">{ts}Email{/ts} 1</th>
106 <th data-data="src_email" class="crm-contact-duplicate">{ts}Email{/ts} 2 ({ts}Duplicate{/ts})</th>
107 <th data-data="dst_street" class="crm-contact">{ts}Street Address{/ts} 1</th>
108 <th data-data="src_street" class="crm-contact-duplicate">{ts}Street Address{/ts} 2 ({ts}Duplicate{/ts})</th>
109 <th data-data="dst_postcode" class="crm-contact">{ts}Postcode{/ts} 1</th>
110 <th data-data="src_postcode" class="crm-contact-duplicate">{ts}Postcode{/ts} 2 ({ts}Duplicate{/ts})</th>
111 <th data-data="conflicts" class="crm-contact-conflicts">{ts}Conflicts{/ts}</th>
112 <th data-data="weight" class="crm-threshold">{ts}Threshold{/ts}</th>
113 <th data-data="actions" class="crm-empty"> </th>
121 {if $context eq 'search'}
122 {crmButton href=$backURL icon="times"}{ts}Done{/ts}{/crmButton}
123 {elseif $context eq 'conflicts'}
124 {if call_user_func(array('CRM_Core_Permission','check'), 'force merge duplicate contacts')}
125 {capture assign=backURL}{crmURL p="civicrm/contact/dedupemerge" q="`$urlQuery`&action=map&mode=aggressive" a=1}{/capture}
126 <a href="{$backURL}" title="{ts}Force Merge Selected Duplicates{/ts}" onclick="return confirm('{ts escape="js"}This will run the batch merge process on the selected duplicates. The operation will run in force merge mode - all selected duplicates will be merged into main contacts even in case of any conflicts. Click OK to proceed if you are sure you wish to run this operation.{/ts}');" class="button"><span><i class="crm-i fa-bolt"></i> {ts}Force Merge Selected Duplicates{/ts}</span></a>
128 {capture assign=backURL}{crmURL p="civicrm/contact/dedupemerge" q="`$urlQuery`&action=map" a=1}{/capture}
129 <a href="{$backURL}" title="{ts}Safe Merge Selected Duplicates{/ts}" onclick="return confirm('{ts escape="js"}This will run the batch merge process on the selected duplicates. The operation will run in safe mode - only records with no direct data conflicts will be merged. Click OK to proceed if you are sure you wish to run this operation.{/ts}');" class="button"><span><i class="crm-i fa-compress"></i> {ts}Safe Merge Selected Duplicates{/ts}</span></a>
132 {capture assign=backURL}{crmURL p="civicrm/contact/dedupefind" q="`$urlQuery`&action=update&selected=0" a=1}{/capture}
133 <a href="{$backURL}" title="{ts}List All Duplicates{/ts}" class="button"><span><i class="crm-i fa-refresh"></i> {ts}List All Duplicates{/ts}</span></a>
135 {capture assign=backURL}{crmURL p="civicrm/contact/dedupefind" q="`$urlQuery`&action=renew" a=1}{/capture}
136 <a href="{$backURL}" title="{ts}Refresh List of Duplicates{/ts}" onclick="return confirm('{ts escape="js"}This will refresh the duplicates list. Click OK to proceed.{/ts}');" class="button">
137 <span><i class="crm-i fa-refresh"></i> {ts}Refresh Duplicates{/ts}</span>
140 {capture assign=backURL}{crmURL p="civicrm/contact/dedupemerge" q="`$urlQuery`&action=map" a=1}{/capture}
141 <a href="{$backURL}" title="{ts}Batch Merge Duplicate Contacts{/ts}" onclick="return confirm('{ts escape="js"}This will run the batch merge process on the selected duplicates. The operation will run in safe mode - only records with no direct data conflicts will be merged. Click OK to proceed if you are sure you wish to run this operation.{/ts}');" class="button"><span><i class="crm-i fa-compress"></i> {ts}Batch Merge Selected Duplicates{/ts}</span></a>
143 {capture assign=backURL}{crmURL p="civicrm/contact/dedupemerge" q=$urlQuery a=1}{/capture}
144 <a href="{$backURL}" title="{ts}Batch Merge Duplicate Contacts{/ts}" onclick="return confirm('{ts escape="js"}This will run the batch merge process on the listed duplicates. The operation will run in safe mode - only records with no direct data conflicts will be merged. Click OK to proceed if you are sure you wish to run this operation.{/ts}');" class="button"><span><i class="crm-i fa-compress"></i> {ts}Batch Merge All Duplicates{/ts}</span></a>
146 <a href='#' title="{ts}Flip Selected Duplicates{/ts}" class="crm-dedupe-flip-selections button"><span><i class="crm-i fa-exchange"></i> {ts}Flip Selected Duplicates{/ts}</span></a>
148 {capture assign=backURL}{crmURL p="civicrm/contact/deduperules" q="reset=1" a=1}{/capture}
149 <a href="{$backURL}" class="button crm-button-type-cancel">
150 <span><i class="crm-i fa-times"></i> {ts}Done{/ts}</span>
153 <div style="clear: both;"></div>
155 {include file="CRM/Contact/Form/DedupeFind.tpl"}
158 {* process the dupe contacts *}
159 {include file='CRM/common/dedupe.tpl'}
161 <script type="text/javascript">
163 CRM.$('table#dupePairs').data({
165 "url": {/literal}'{$sourceUrl}{if $isSelected}&selected=1{/if}'{literal}
170 rowCallback: function (row, data) {
171 // Set the checked state of the checkbox in the table
172 $('input.crm-dedupe-select', row).prop('checked', data.is_selected == 1);
173 if (data.is_selected == 1) {
174 $(row).toggleClass('crm-row-selected');
176 // for action column at the last, set nowrap
177 $('td:last', row).attr('nowrap','nowrap');
178 // for conflicts column
179 var col = CRM.$('table#dupePairs thead th.crm-contact-conflicts').index();
180 $('td:eq(' + col + ')', row).attr('nowrap','nowrap');
185 var sourceUrl = {/literal}'{$sourceUrl}'{literal};
186 var context = {/literal}'{$context}'{literal};
188 // redraw datatable if searching within selected records
189 $('#crm-dedupe-display-selection').on('click', function(){
190 reloadUrl = sourceUrl;
191 if($(this).prop('checked')){
192 reloadUrl = sourceUrl+'&selected=1';
194 CRM.$('table#dupePairs').DataTable().ajax.url(reloadUrl).draw();
197 $('#dupePairs_length_selection').appendTo('#dupePairs_length');
199 // apply selected class on click of a row
200 $('#dupePairs tbody').on('click', 'tr', function(e) {
201 $(this).toggleClass('crm-row-selected');
202 $('input.crm-dedupe-select', this).prop('checked', $(this).hasClass('crm-row-selected'));
203 var ele = $('input.crm-dedupe-select', this);
204 toggleDedupeSelect(ele, 0);
207 // when select-all checkbox is checked
208 $('#dupePairs thead tr .crm-dedupe-selection').on('click', function() {
209 var checked = $('.crm-dedupe-select-all').prop('checked');
211 $("#dupePairs tbody tr input[type='checkbox']").prop('checked', true);
212 $("#dupePairs tbody tr").addClass('crm-row-selected');
215 $("#dupePairs tbody tr input[type='checkbox']").prop('checked', false);
216 $("#dupePairs tbody tr").removeClass('crm-row-selected');
218 var ele = $('#dupePairs tbody tr');
219 toggleDedupeSelect(ele, 1);
222 // inline search boxes placed in tfoot
223 $('#dupePairsColFilters thead th').each( function () {
224 var title = $('#dupePairs thead th').eq($(this).index()).text();
225 if (title.length > 1) {
226 $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
231 $('#searchOptions input').on( 'keyup change', function () {
232 $('table#dupePairs').DataTable()
233 .column($(this).attr('search-column'))
238 // show / hide columns
239 $('input.toggle-vis').on('click', function (e) {
240 var column = $('table#dupePairs').DataTable().column( $(this).attr('data-column-main') );
241 column.visible( ! column.visible() );
243 // nowrap to conflicts column is applied only during initial rendering
244 // for show / hide clicks we need to set it explicitly
245 var col = CRM.$('table#dupePairs thead th.crm-contact-conflicts').index() + 1;
247 CRM.$('table#dupePairs tbody tr td:nth-child(' + col + ')').attr('nowrap','nowrap');
250 if ($(this).attr('data-column-dupe')) {
251 column = $('table#dupePairs').DataTable().column( $(this).attr('data-column-dupe') );
252 column.visible( ! column.visible() );
256 // keep the conflicts checkbox checked when context is "conflicts"
257 if(context == 'conflicts') {
258 $('#conflicts').attr('checked', true);
259 var column = $('table#dupePairs').DataTable().column( $('#conflicts').attr('data-column-main') );
260 column.visible( ! column.visible() );
263 // on click of flip link of a row
264 $('#dupePairs tbody').on('click', 'tr .crm-dedupe-flip', function(e) {
267 var $elTr = $(this).closest('tr');
268 var postUrl = {/literal}"{crmURL p='civicrm/ajax/flipDupePairs' h=0 q='snippet=4'}"{literal};
269 var request = $.post(postUrl, {pnid : $el.data('pnid')});
270 request.done(function(dt) {
271 var mapper = {1:3, 2:4, 5:6, 7:8, 9:10}
272 var idx = $('table#dupePairs').DataTable().row($elTr).index();
273 $.each(mapper, function(key, val) {
274 var v1 = $('table#dupePairs').DataTable().cell(idx, key).data();
275 var v2 = $('table#dupePairs').DataTable().cell(idx, val).data();
276 $('table#dupePairs').DataTable().cell(idx, key).data(v2);
277 $('table#dupePairs').DataTable().cell(idx, val).data(v1);
279 // keep the checkbox checked if needed
280 $('input.crm-dedupe-select', $elTr).prop('checked', $elTr.hasClass('crm-row-selected'));
284 $(".crm-dedupe-flip-selections").on('click', function(e) {
286 $('.crm-row-selected').each(function() {
287 var ele = CRM.$('input.crm-dedupe-select', this);
288 ids.push(CRM.$(ele).attr('name').substr(5));
290 if (ids.length > 0) {
291 var dataUrl = {/literal}"{crmURL p='civicrm/ajax/flipDupePairs' h=0 q='snippet=4'}"{literal};
292 CRM.$.post(dataUrl, {pnid: ids}, function (response) {
293 var mapper = {1:3, 2:4, 5:6, 7:8, 9:10}
294 $('.crm-row-selected').each(function() {
295 var idx = $('table#dupePairs').DataTable().row(this).index();
296 $.each(mapper, function(key, val) {
297 var v1 = $('table#dupePairs').DataTable().cell(idx, key).data();
298 var v2 = $('table#dupePairs').DataTable().cell(idx, val).data();
299 $('table#dupePairs').DataTable().cell(idx, key).data(v2);
300 $('table#dupePairs').DataTable().cell(idx, val).data(v1);
302 // keep the checkbox checked if needed
303 $('input.crm-dedupe-select', this).prop('checked', $(this).hasClass('crm-row-selected'));
311 function toggleDedupeSelect(element, isMultiple) {
313 var is_selected = CRM.$(element).prop('checked') ? 1: 0;
314 var id = CRM.$(element).prop('name').substr(5);
318 CRM.$(element).each(function() {
319 var pnName = CRM.$('input.crm-dedupe-select', this).prop('name');
320 if (pnName !== undefined) {
321 id.push(pnName.substr(5));
324 var is_selected = CRM.$('.crm-dedupe-select-all').prop('checked') ? 1 : 0;
327 var criteria = {/literal}'{$criteria|escape}'{literal};
328 criteria = criteria.length > 0 ? criteria : 0;
330 var dataUrl = {/literal}"{crmURL p='civicrm/ajax/toggleDedupeSelect' h=0 q='snippet=4'}"{literal};
331 var rgid = {/literal}"{$rgid}"{literal};
332 var gid = {/literal}"{$gid}"{literal};
334 rgid = rgid.length > 0 ? rgid : 0;
335 gid = gid.length > 0 ? gid : 0;
337 CRM.$.post(dataUrl, {pnid: id, rgid: rgid, gid: gid, is_selected: is_selected, criteria : criteria}, function (data) {
338 // nothing to do for now