initial commit
[CPE_learningsite] / CPE / CPE.App / CPE.App.Web / static / js / index / coursedetails.js
1 $(document).ready(function () {
2
3     $('#PurchasedCoursesTable').dataTable({
4         "sPaginationType": "full_numbers",
5         "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
6         "iDisplayLength": -1,
7         "sDom": 'Tfrtlip',
8         "oTableTools": {
9             "sSwfPath": "/static/swf/copy.csv.xls.swf",
10             "aButtons": ["copy", "csv"]
11         },
12         "initComplete": function () {
13             $('.sendCert-icon').click(function () {
14                 var email = $(this).data('email');
15                 var a = $(this).data('curl');
16                 var b = $(this).data('cdate');
17                 var c = $(this).data('ticket');
18                 
19                 var emailBody = 'Thank you for purchasing our Self-Study Webcast, and congratulations on successfully completing the final examination!'
20                         + '\r\n' + '\r\n' + 'Please follow the link in this email to download your Certificate of Completion. We recommend that you print a copy of the Certificate for your records.'
21                         + '\r\n' + '\r\n' + 'To register for another CPE Inc. program from our wide selection of Self-Study and Live Webcasts, Seminars and Conferences, please visit us online or call 1-800-544-1114.'
22                         + '\r\n' + '\r\n' + 'http://api.cpeonlinewebcasts.com/Certificate?a=' + a + '&b=' + b + '&c=' + c;
23                 emailBody = encodeURIComponent(emailBody);
24                 var link = 'mailto:' + email
25                      + '?subject=' + escape('Your certificate of completion from CPE Inc.')
26                      + '&body=' + emailBody;
27                 win = window.open(link);
28                 setTimeout(function() { win.close() }, 500);
29                 return true;
30             });
31             $('.revokeAccess-icon').click(function () {
32                 var learnerName = $(this).data('learnername').split(' ');
33                 var blockedCourse = {
34                     firstName: learnerName[0],
35                     lastName: learnerName[1],
36                     purchaseDate: $(this).data('purchasedate'),
37                     email: $(this).data('email'),
38                     ticket: $(this).data('ticket'),
39                     contentUrl: $(this).data('curl')
40                 };
41
42                 $.post("Access/Revoke", blockedCourse, function () {
43                     alert("Access Revoked.");
44                     window.location.reload(true);
45
46                 });
47             });
48
49             $('.restoreAccess-icon').click(function () {
50                 var learnerName = $(this).data('learnername').split(' ');
51                 var blockedCourse = {
52                     firstName: learnerName[0],
53                     lastName: learnerName[1],
54                     purchaseDate: $(this).data('purchasedate'),
55                     email: $(this).data('email'),
56                     ticket: $(this).data('ticket'),
57                     contentUrl: $(this).data('curl')
58                 };
59
60                 $.post("Access/Restore", blockedCourse, function () {
61                     alert("Access Restored");
62                     window.location.reload(true);
63                 });
64             });
65             
66             $('.overrideCert-icon').click(function () {
67                 var learnerName = $(this).data('learnername').split(' ');
68                 var purchasedCourse = {
69                     firstName: learnerName[0],
70                     lastName: learnerName[1],
71                     purchaseDate: $(this).data('purchasedate'),
72                     email: $(this).data('email'),
73                     ticket: $(this).data('ticket'),
74                     contentUrl: $(this).data('curl')
75                 };
76                 if (confirm('Are you sure you want to mark this course as Passed? This action cannot be reversed.')) {
77                     $.post("Access/OverrideCert", purchasedCourse, function() {
78                         alert("Course marked as Passed. You should now see the option to Send Certificate. If not, try refreshing the page.");
79                         window.location.reload(true);
80                     });
81                 }
82             });
83         }
84     });
85
86 });
87