summaryrefslogtreecommitdiffstats
path: root/admin/survey/script/notifications.js
blob: cdd507425315754f787cccb009ac86a2c4ba558c (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// poslje novo sporocilo
function sendNotification() {

    if(CKEDITOR.instances['notification']){
		CKEDITOR.instances['notification'].destroy();
	}

	var recipient = $( "input[name='recipient']" ).val();	
	var title = $( "input[name='title']" ).val();
    //var notification = $( "textarea[name='notification']" ).val();
    var notification = $("#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,

        function(){
            if (!CKEDITOR.instances) {
                CKEDITOR.replace['notification'];
            }
        }
    });
}

// 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_toggle(type){

	if (type == 'slo') {
		if ($( "input[name='recipient_all_slo']" ).is(':checked')) {
			$( "input[name='recipient_custom']" ).attr("checked", false);
			$("#recipient").addClass('disabled');
		}
	}

	if (type == 'ang') {
		if ($( "input[name='recipient_all_ang']" ).is(':checked')) {
			$( "input[name='recipient_custom']" ).attr("checked", false);
			$("#recipient").addClass('disabled');
		}
	}

	if (type == 'custom') {
		if ($( "input[name='recipient_custom']" ).is(':checked')) {
			$( "input[name='recipient_all_slo']" ).attr("checked", false);
			$( "input[name='recipient_all_ang']" ).attr("checked", false);
			$("#recipient").removeClass('disabled');
		}
	}
}
	


// 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();
}