summaryrefslogtreecommitdiffstats
path: root/admin/survey/script/notifications.js
blob: 2494385f5807043e5d996c33359ecc7f39fb8476 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// poslje novo sporocilo
function sendNotification() {

	var recipient = $( "input[name='recipient']" ).val();	
	var title = $( "input[name='title']" ).val();
	var notification = $( "textarea[name='notification']" ).val();
	
	if ($( "input[name='recipient_all_slo']" ).is(':checked'))
		var recipient_all_slo = 1;
	else
		var recipient_all_slo = 0;
		
	if ($( "input[name='recipient_all_ang']" ).is(':checked'))
		var recipient_all_ang = 1;
	else
		var recipient_all_ang = 0;
	
	if ($( "input[name='force_show']" ).is(':checked'))
		var force_show = 1;
	else
		var force_show = 0;
	
	$('#notifications').load('ajax.php?t=notifications&a=sendNotification', {anketa:srv_meta_anketa_id, recipient:recipient, recipient_all_slo:recipient_all_slo, recipient_all_ang:recipient_all_ang, title:title, notification:notification, force_show:force_show});
}

// prikaze sporocilo in ga oznaci kot viewed
function viewMessage(id) {
	
	$('#notifications').load('ajax.php?t=notifications&a=viewMessage', {anketa:srv_meta_anketa_id, id:id});
}

// oznaci sporocilo kot prebrano vsem prejemnikom
function resolveMessages(id) {
	
	$('.sent_list').load('ajax.php?t=notifications&a=resolveMessages', {anketa:srv_meta_anketa_id, id:id});
}

// Prikaze popup z neprebranimi sporocili
function showUnreadMessages(){

	$('#unread_notifications').load('ajax.php?t=notifications&a=viewUnreadMessages', {anketa:srv_meta_anketa_id}, function (data) {
		$('#unread_notifications').show();
		$('#fade').fadeTo('slow', 1);
	});
}

function closeUnreadMessages(){
	
	// Pobrisemo opozorilo na vrhu strani
	$('#new_notification_alert').remove();
	
	// Zapremo okno
	$('#fade').fadeOut('slow');
	$("#unread_notifications").fadeOut();
}

function recipient_all_disable_email(){
	
	if ($( "input[name='recipient_all_slo']" ).is(':checked'))
		var recipient_all_slo = 1;
	else
		var recipient_all_slo = 0;
		
	if ($( "input[name='recipient_all_ang']" ).is(':checked'))
		var recipient_all_ang = 1;
	else
		var recipient_all_ang = 0;
		
	if(recipient_all_slo == 0 && recipient_all_ang == 0)
		$("#recipient").attr('disabled', false);
	else
		$("#recipient").attr('disabled', true);
}


// Prikaze popup z neprebranimi sporocili
function showGDPRMessage(){

	$('#unread_notifications').load('ajax.php?t=notifications&a=viewGDPRMessage', {anketa:srv_meta_anketa_id}, function (data) {
		$('#unread_notifications').show();
		$('#fade').fadeTo('slow', 1);
	});
}

function enableGDPRPopupButton(){
	$("#GDPR_popup_button").css("visibility", "visible");
}

function saveGDPRMessage(){
	
	var gdpr_agree = '-1';
	
	if ($("input[name='gdpr_agree']:checked").val())
		gdpr_agree = $("input[name=gdpr_agree]:checked").val();
	
	if(gdpr_agree == '0' || gdpr_agree == '1'){
		$.post('ajax.php?t=notifications&a=saveGDPRAgree', {gdpr_agree:gdpr_agree, anketa:srv_meta_anketa_id}, function (data) {
			
			// Zapremo okno
			$('#fade').fadeOut('slow');
			$("#unread_notifications").fadeOut();
		});
	}
}

function toggleGDPRMore(){
	
	$("#gdpr_popup_more").toggle();
}