Commit | Line | Data |
---|---|---|
685a6418 TO |
1 | (function($, CRM) { |
2 | ||
3 | /** | |
4 | * Usage: | |
5 | * | |
6 | * cj('.my-link').crmRevisionLink({ | |
7 | * 'reportId': 123, // CRM_Report_Utils_Report::getInstanceIDForValue('logging/contact/summary'), | |
8 | * 'tableName': 'my_table', | |
9 | * 'contactId': 123 | |
10 | * )); | |
11 | * | |
12 | * Note: This file is used by CivHR | |
13 | */ | |
14 | $.fn.crmRevisionLink = function(options) { | |
15 | return this.each(function(){ | |
16 | var $dialog = $('<div><div class="revision-content"></div></div>'); | |
17 | $('body').append($dialog); | |
18 | $(this).on("click", function() { | |
19 | $dialog.show(); | |
20 | $dialog.dialog({ | |
21 | title: ts("Revisions"), | |
22 | modal: true, | |
23 | width: "680px", | |
24 | bgiframe: true, | |
25 | overlay: { opacity: 0.5, background: "black" }, | |
26 | open:function() { | |
27 | var ajaxurl = CRM.url("civicrm/report/instance/" + options.reportId); | |
28 | cj.ajax({ | |
29 | data: "reset=1&snippet=4§ion=2&altered_contact_id_op=eq&altered_contact_id_value="+options.contactId+"&log_type_table_op=has&log_type_table_value=" + options.tableName, | |
30 | url: ajaxurl, | |
31 | success: function (data) { | |
32 | $dialog.find(".revision-content").html(data); | |
33 | if (!$dialog.find(".revision-content .report-layout").length) { | |
34 | $dialog.find(".revision-content").html("Sorry, couldn't find any revisions."); | |
35 | } | |
36 | } | |
37 | }); | |
38 | }, | |
39 | buttons: { | |
40 | "Done": function() { | |
41 | $(this).dialog("destroy"); | |
42 | } | |
43 | } | |
44 | }); | |
45 | return false; | |
46 | }); | |
47 | }); // this.each | |
48 | }; // fn.crmRevisionLink | |
49 | ||
50 | })(jQuery, CRM); |