Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* common dupe contacts processing *} |
2 | <div id='processDupes' class="success-status" style="display:none;"></div> | |
3 | {literal} | |
4 | <script type='text/javascript'> | |
5 | ||
6 | cj( '#processDupes' ).hide( ); | |
7 | ||
8 | function processDupes( cid, oid, oper, context, reloadURL ) { | |
9 | //currently we are doing in a single way. | |
10 | //later we might want two way operations. | |
11 | ||
12 | if ( !cid || !oid || !oper ) return; | |
13 | ||
14 | var title = {/literal}'{ts escape="js"}Mark as Dedupe Exception{/ts}'{literal}; | |
15 | var msg = {/literal}'{ts escape="js"}Are you sure you want to mark this pair of contacts as NOT duplicates?{/ts}'{literal}; | |
16 | if ( oper == 'nondupe-dupe' ) { | |
17 | var title = {/literal}'{ts escape="js"}Remove Dedupe Exception{/ts}'{literal}; | |
18 | var msg = {/literal}'{ts escape="js"}Are you sure you want to remove this dedupe exception.{/ts}'{literal}; | |
19 | } | |
20 | ||
21 | cj("#processDupes").show( ); | |
22 | cj("#processDupes").dialog({ | |
23 | title: title, | |
24 | modal: true, | |
6a488035 TO |
25 | |
26 | open:function() { | |
27 | cj( '#processDupes' ).show( ).html( msg ); | |
28 | }, | |
29 | ||
30 | buttons: { | |
31 | "Cancel": function() { | |
32 | cj(this).dialog("close"); | |
33 | }, | |
34 | "OK": function() { | |
35 | saveProcessDupes( cid, oid, oper, context ); | |
36 | cj(this).dialog( 'close' ); | |
37 | if ( context == 'merge-contact' && reloadURL ) { | |
38 | // redirect after a small delay | |
39 | setTimeout("window.location.href = '" + reloadURL + "'", 500); | |
40 | } | |
41 | } | |
42 | } | |
43 | }); | |
44 | } | |
45 | ||
46 | ||
47 | function saveProcessDupes( cid, oid, oper, context ) { | |
48 | //currently we are doing in a single way. | |
49 | //later we might want two way operations. | |
50 | ||
51 | if ( !cid || !oid || !oper ) return; | |
52 | ||
53 | var statusMsg = {/literal}'{ts escape="js"}Marked as non duplicates.{/ts}'{literal}; | |
54 | if ( oper == 'nondupe-dupe' ) { | |
55 | var statusMsg = {/literal}'{ts escape="js"}Marked as duplicates.{/ts}'{literal}; | |
56 | } | |
57 | ||
58 | var url = {/literal}"{crmURL p='civicrm/ajax/rest' q='className=CRM_Contact_Page_AJAX&fnName=processDupes' h=0 }"{literal}; | |
59 | //post the data to process dupes. | |
60 | cj.post( url, | |
61 | {cid: cid, oid: oid, op: oper}, | |
62 | function( result ) { | |
63 | if ( result.status == oper ) { | |
64 | ||
65 | if ( oper == 'dupe-nondupe' && | |
66 | context == 'dupe-listing' ) { | |
67 | oTable.fnDraw(); | |
68 | } else if ( oper == 'nondupe-dupe' ) { | |
69 | cj( "#dupeRow_" + cid + '_' + oid ).hide( ); | |
70 | } | |
71 | } | |
72 | }, | |
73 | 'json' ); | |
74 | } | |
75 | </script> | |
76 | {/literal} |