Merge pull request #1199 from totten/master-premature-commit
[civicrm-core.git] / templates / CRM / common / dedupe.tpl
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,
25 bgiframe: true,
26 overlay: {
27 opacity: 0.5,
28 background: "black"
29 },
30
31 open:function() {
32 cj( '#processDupes' ).show( ).html( msg );
33 },
34
35 buttons: {
36 "Cancel": function() {
37 cj(this).dialog("close");
38 },
39 "OK": function() {
40 saveProcessDupes( cid, oid, oper, context );
41 cj(this).dialog( 'close' );
42 if ( context == 'merge-contact' && reloadURL ) {
43 // redirect after a small delay
44 setTimeout("window.location.href = '" + reloadURL + "'", 500);
45 }
46 }
47 }
48 });
49 }
50
51
52 function saveProcessDupes( cid, oid, oper, context ) {
53 //currently we are doing in a single way.
54 //later we might want two way operations.
55
56 if ( !cid || !oid || !oper ) return;
57
58 var statusMsg = {/literal}'{ts escape="js"}Marked as non duplicates.{/ts}'{literal};
59 if ( oper == 'nondupe-dupe' ) {
60 var statusMsg = {/literal}'{ts escape="js"}Marked as duplicates.{/ts}'{literal};
61 }
62
63 var url = {/literal}"{crmURL p='civicrm/ajax/rest' q='className=CRM_Contact_Page_AJAX&fnName=processDupes' h=0 }"{literal};
64 //post the data to process dupes.
65 cj.post( url,
66 {cid: cid, oid: oid, op: oper},
67 function( result ) {
68 if ( result.status == oper ) {
69
70 if ( oper == 'dupe-nondupe' &&
71 context == 'dupe-listing' ) {
72 oTable.fnDraw();
73 } else if ( oper == 'nondupe-dupe' ) {
74 cj( "#dupeRow_" + cid + '_' + oid ).hide( );
75 }
76 }
77 },
78 'json' );
79 }
80 </script>
81 {/literal}