Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
2c4c49ca | 3 | | CiviCRM version 4.7 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
8c9251b3 | 5 | | Copyright CiviCRM LLC (c) 2004-2018 | |
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 | {if $action eq 2 || $action eq 16} | |
27 | <div class="form-item"> | |
63ef778e | 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%;"> | |
34 | <tr> | |
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" /> | |
38 | </td> | |
39 | <td class="crm-contact-form-block-contact2"> | |
40 | <label for="contact2">{ts}Contact 2{/ts}</label><br /> | |
579ea9bc | 41 | <input type="text" placeholder="Search Contact2" search-column="4" /> |
63ef778e | 42 | </td> |
43 | <td class="crm-contact-form-block-email1"> | |
44 | <label for="email1">{ts}Email 1{/ts}</label><br /> | |
579ea9bc | 45 | <input type="text" placeholder="Search Email1" search-column="5" /> |
63ef778e | 46 | </td> |
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" /> | |
50 | </td> | |
51 | </tr> | |
52 | <tr> | |
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" /> | |
56 | </td> | |
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" /> | |
60 | </td> | |
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" /> | |
64 | </td> | |
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" /> | |
68 | </td> | |
69 | </tr> | |
70 | </table> | |
71 | </div><!-- /.crm-accordion-body --> | |
72 | </div><!-- /.crm-accordion-wrapper --> | |
73 | <div> | |
74 | Show / Hide columns: | |
80bc2820 | 75 | <input type='checkbox' id ='steet-address' class='toggle-vis' data-column-main="7" data-column-dupe="8" > |
63ef778e | 76 | <label for="steet-address">{ts}Street Address{/ts} </label> |
80bc2820 | 77 | <input type='checkbox' id ='post-code' class='toggle-vis' data-column-main="9" data-column-dupe="10" > |
63ef778e | 78 | <label for="post-code">{ts}Post Code{/ts} </label> |
80bc2820 | 79 | <input type='checkbox' id ='conflicts' class='toggle-vis' data-column-main="11" > |
63ef778e | 80 | <label for="conflicts">{ts}Conflicts{/ts} </label> |
80bc2820 | 81 | <input type='checkbox' id ='threshold' class='toggle-vis' data-column-main="12" > |
63ef778e | 82 | <label for="threshold">{ts}Threshold{/ts} </label> |
83 | </div><br/> | |
84 | <span id="dupePairs_length_selection"> | |
85 | <input type='checkbox' id ='crm-dedupe-display-selection' name="display-selection"> | |
80bc2820 | 86 | <label for="display-selection">{ts}Within Selections{/ts} </label> |
63ef778e | 87 | </span> |
f2515ec6 | 88 | |
89 | <table id="dupePairs" | |
cc86f7ba | 90 | class="nestedActivitySelector crm-ajax-table" |
f2515ec6 | 91 | cellspacing="0" |
92 | width="100%" | |
cc86f7ba | 93 | data-page-length="10", |
f2515ec6 | 94 | data-searching='true', |
95 | data-dom='flrtip', | |
96 | data-order='[]', | |
97 | data-column-defs='{literal}[{"targets": [0,1,3,13], "orderable":false}, {"targets": [7,8,9,10,11,12], "visible":false}]{/literal}'> | |
6a488035 | 98 | <thead> |
80bc2820 | 99 | <tr class="columnheader"> |
f2515ec6 | 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> |
f2515ec6 | 101 | <th data-data="dst_image" class="crm-empty"> </th> |
1fe557c2 | 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> | |
57db188a | 111 | <th data-data="conflicts" class="crm-contact-conflicts">{ts}Conflicts{/ts}</th> |
f2515ec6 | 112 | <th data-data="weight" class="crm-threshold">{ts}Threshold{/ts}</th> |
113 | <th data-data="actions" class="crm-empty"> </th> | |
63ef778e | 114 | </tr> |
6a488035 | 115 | </thead> |
63ef778e | 116 | <tbody> |
117 | </tbody> | |
6a488035 | 118 | </table> |
6a488035 TO |
119 | </div> |
120 | ||
121 | {if $context eq 'search'} | |
80bc2820 | 122 | {crmButton href=$backURL icon="times"}{ts}Done{/ts}{/crmButton} |
63ef778e | 123 | {elseif $context eq 'conflicts'} |
b639c500 | 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} | |
44f15f74 | 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> |
63ef778e | 127 | |
b639c500 | 128 | {capture assign=backURL}{crmURL p="civicrm/contact/dedupemerge" q="`$urlQuery`&action=map" a=1}{/capture} |
44f15f74 | 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> |
b639c500 | 130 | {/if} |
63ef778e | 131 | |
b639c500 | 132 | {capture assign=backURL}{crmURL p="civicrm/contact/dedupefind" q="`$urlQuery`&action=update" a=1}{/capture} |
44f15f74 | 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> |
6a488035 | 134 | {else} |
dc6285d5 | 135 | {capture assign=backURL}{crmURL p="civicrm/contact/dedupefind" q="`$urlQuery`&action=renew" a=1}{/capture} |
fd66df85 | 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"> |
44f15f74 | 137 | <span><i class="crm-i fa-refresh"></i> {ts}Refresh Duplicates{/ts}</span> |
fd66df85 | 138 | </a> |
6a488035 | 139 | |
b639c500 | 140 | {capture assign=backURL}{crmURL p="civicrm/contact/dedupemerge" q="`$urlQuery`&action=map" a=1}{/capture} |
44f15f74 | 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> |
63ef778e | 142 | |
b639c500 | 143 | {capture assign=backURL}{crmURL p="civicrm/contact/dedupemerge" q=$urlQuery a=1}{/capture} |
44f15f74 | 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> |
6a488035 | 145 | |
44f15f74 | 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> |
6a488035 TO |
147 | |
148 | {capture assign=backURL}{crmURL p="civicrm/contact/deduperules" q="reset=1" a=1}{/capture} | |
fd66df85 | 149 | <a href="{$backURL}" class="button crm-button-type-cancel"> |
44f15f74 | 150 | <span><i class="crm-i fa-times"></i> {ts}Done{/ts}</span> |
fd66df85 | 151 | </a> |
6a488035 TO |
152 | {/if} |
153 | <div style="clear: both;"></div> | |
154 | {else} | |
155 | {include file="CRM/Contact/Form/DedupeFind.tpl"} | |
156 | {/if} | |
157 | ||
158 | {* process the dupe contacts *} | |
159 | {include file='CRM/common/dedupe.tpl'} | |
160 | {literal} | |
161 | <script type="text/javascript"> | |
f2515ec6 | 162 | (function($) { |
163 | CRM.$('table#dupePairs').data({ | |
164 | "ajax": { | |
165 | "url": {/literal}'{$sourceUrl}'{literal} | |
f826cbfc | 166 | }, |
3db1e4a3 | 167 | "retrieve": true, |
892be885 | 168 | "processing": true, |
169 | "serverSide": true, | |
f826cbfc | 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'); | |
175 | } | |
176 | // for action column at the last, set nowrap | |
177 | $('td:last', row).attr('nowrap','nowrap'); | |
f6ed5cad | 178 | // for conflicts column |
57db188a | 179 | var col = CRM.$('table#dupePairs thead th.crm-contact-conflicts').index(); |
180 | $('td:eq(' + col + ')', row).attr('nowrap','nowrap'); | |
63ef778e | 181 | } |
f2515ec6 | 182 | }); |
183 | $(function($) { | |
355927bf | 184 | |
f826cbfc | 185 | var sourceUrl = {/literal}'{$sourceUrl}'{literal}; |
186 | var context = {/literal}'{$context}'{literal}; | |
187 | ||
f2515ec6 | 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'; | |
193 | } | |
194 | CRM.$('table#dupePairs').DataTable().ajax.url(reloadUrl).draw(); | |
195 | }); | |
80bc2820 | 196 | |
f2515ec6 | 197 | $('#dupePairs_length_selection').appendTo('#dupePairs_length'); |
63ef778e | 198 | |
f2515ec6 | 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); | |
205 | }); | |
63ef778e | 206 | |
f2515ec6 | 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'); | |
210 | if (checked) { | |
211 | $("#dupePairs tbody tr input[type='checkbox']").prop('checked', true); | |
212 | $("#dupePairs tbody tr").addClass('crm-row-selected'); | |
213 | } | |
214 | else{ | |
215 | $("#dupePairs tbody tr input[type='checkbox']").prop('checked', false); | |
216 | $("#dupePairs tbody tr").removeClass('crm-row-selected'); | |
217 | } | |
218 | var ele = $('#dupePairs tbody tr'); | |
219 | toggleDedupeSelect(ele, 1); | |
220 | }); | |
63ef778e | 221 | |
f2515ec6 | 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+'" />' ); | |
227 | } | |
228 | }); | |
63ef778e | 229 | |
f2515ec6 | 230 | // apply the search |
231 | $('#searchOptions input').on( 'keyup change', function () { | |
2653da92 | 232 | $('table#dupePairs').DataTable() |
f2515ec6 | 233 | .column($(this).attr('search-column')) |
234 | .search(this.value) | |
235 | .draw(); | |
fd630ef9 | 236 | }); |
fd630ef9 | 237 | |
f2515ec6 | 238 | // show / hide columns |
239 | $('input.toggle-vis').on('click', function (e) { | |
2653da92 | 240 | var column = $('table#dupePairs').DataTable().column( $(this).attr('data-column-main') ); |
f2515ec6 | 241 | column.visible( ! column.visible() ); |
80bc2820 | 242 | |
f2515ec6 | 243 | // nowrap to conflicts column is applied only during initial rendering |
244 | // for show / hide clicks we need to set it explicitly | |
57db188a | 245 | var col = CRM.$('table#dupePairs thead th.crm-contact-conflicts').index() + 1; |
246 | if (col > 0) { | |
247 | CRM.$('table#dupePairs tbody tr td:nth-child(' + col + ')').attr('nowrap','nowrap'); | |
248 | } | |
249 | ||
f2515ec6 | 250 | if ($(this).attr('data-column-dupe')) { |
2653da92 | 251 | column = $('table#dupePairs').DataTable().column( $(this).attr('data-column-dupe') ); |
f2515ec6 | 252 | column.visible( ! column.visible() ); |
253 | } | |
254 | }); | |
80bc2820 | 255 | |
f2515ec6 | 256 | // keep the conflicts checkbox checked when context is "conflicts" |
f2515ec6 | 257 | if(context == 'conflicts') { |
80bc2820 | 258 | $('#conflicts').attr('checked', true); |
2653da92 | 259 | var column = $('table#dupePairs').DataTable().column( $('#conflicts').attr('data-column-main') ); |
f2515ec6 | 260 | column.visible( ! column.visible() ); |
261 | } | |
80bc2820 | 262 | |
f2515ec6 | 263 | // on click of flip link of a row |
264 | $('#dupePairs tbody').on('click', 'tr .crm-dedupe-flip', function(e) { | |
265 | e.stopPropagation(); | |
266 | var $el = $(this); | |
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) { | |
1f6dc660 | 271 | var mapper = {1:3, 2:4, 5:6, 7:8, 9:10} |
2653da92 | 272 | var idx = $('table#dupePairs').DataTable().row($elTr).index(); |
fd630ef9 | 273 | $.each(mapper, function(key, val) { |
2653da92 JP |
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); | |
fd630ef9 | 278 | }); |
279 | // keep the checkbox checked if needed | |
f2515ec6 | 280 | $('input.crm-dedupe-select', $elTr).prop('checked', $elTr.hasClass('crm-row-selected')); |
fd630ef9 | 281 | }); |
f2515ec6 | 282 | }); |
80bc2820 | 283 | |
f2515ec6 | 284 | $(".crm-dedupe-flip-selections").on('click', function(e) { |
285 | var ids = []; | |
286 | $('.crm-row-selected').each(function() { | |
287 | var ele = CRM.$('input.crm-dedupe-select', this); | |
288 | ids.push(CRM.$(ele).attr('name').substr(5)); | |
289 | }); | |
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) { | |
1f6dc660 | 293 | var mapper = {1:3, 2:4, 5:6, 7:8, 9:10} |
f2515ec6 | 294 | $('.crm-row-selected').each(function() { |
2653da92 | 295 | var idx = $('table#dupePairs').DataTable().row(this).index(); |
f2515ec6 | 296 | $.each(mapper, function(key, val) { |
2653da92 JP |
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); | |
f2515ec6 | 301 | }); |
302 | // keep the checkbox checked if needed | |
303 | $('input.crm-dedupe-select', this).prop('checked', $(this).hasClass('crm-row-selected')); | |
304 | }); | |
305 | }, 'json'); | |
306 | } | |
307 | }); | |
63ef778e | 308 | }); |
f2515ec6 | 309 | })(CRM.$); |
63ef778e | 310 | |
f2515ec6 | 311 | function toggleDedupeSelect(element, isMultiple) { |
312 | if (!isMultiple) { | |
313 | var is_selected = CRM.$(element).prop('checked') ? 1: 0; | |
314 | var id = CRM.$(element).prop('name').substr(5); | |
315 | } | |
316 | else { | |
317 | var id = []; | |
318 | CRM.$(element).each(function() { | |
0c5fbe6c | 319 | var pnName = CRM.$('input.crm-dedupe-select', this).prop('name'); |
320 | if (pnName !== undefined) { | |
321 | id.push(pnName.substr(5)); | |
322 | } | |
f2515ec6 | 323 | }); |
324 | var is_selected = CRM.$('.crm-dedupe-select-all').prop('checked') ? 1 : 0; | |
325 | } | |
80bc2820 | 326 | |
f2515ec6 | 327 | var dataUrl = {/literal}"{crmURL p='civicrm/ajax/toggleDedupeSelect' h=0 q='snippet=4'}"{literal}; |
328 | var rgid = {/literal}"{$rgid}"{literal}; | |
329 | var gid = {/literal}"{$gid}"{literal}; | |
80bc2820 | 330 | |
f2515ec6 | 331 | rgid = rgid.length > 0 ? rgid : 0; |
332 | gid = gid.length > 0 ? gid : 0; | |
80bc2820 | 333 | |
f2515ec6 | 334 | CRM.$.post(dataUrl, {pnid: id, rgid: rgid, gid: gid, is_selected: is_selected}, function (data) { |
335 | // nothing to do for now | |
336 | }, 'json'); | |
337 | } | |
6a488035 TO |
338 | </script> |
339 | {/literal} |