summaryrefslogtreecommitdiffstats
path: root/admin/survey/script/surveyCondition.js
blob: 7223b66e80c0bf48e5641c3723263abb71b85c44 (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
function showSurveyCondition(cid)
{
	var chooseProfileJSAction = $("#chooseProfileJSAction").val();
	$("#fullscreen").load('ajax.php?t=surveyCondition&a=showCondition', {anketa:srv_meta_anketa_id,cid:cid, surveyConditionProfileAction:chooseProfileJSAction});
}

function newSurveyCondition()
{
	var name = $("#newSurveyConditionName").val();
	var chooseProfileJSAction = $("#chooseProfileJSAction").val();
	// kreiramo nov profil z novim id
	$.post('ajax.php?t=surveyCondition&a=newCondition', { anketa : srv_meta_anketa_id, name : name, surveyConditionProfileAction:chooseProfileJSAction}, 
		function(response) 
		{
		var data = jQuery.parseJSON(response);
			if (data.if_id > 0) 
			{
				showSurveyCondition(data.if_id);
			} 
			else 
			{
				genericAlertPopup('alert_error_code',data.error);
			}
		}
	)
}

function deleteSurveyCondition(cid)
{
	var chooseProfileJSAction = $("#chooseProfileJSAction").val();
	// kreiramo nov profil z novim id
	$.post('ajax.php?t=surveyCondition&a=deleteCondition', { anketa : srv_meta_anketa_id, cid:cid, surveyConditionProfileAction:chooseProfileJSAction}, 
			function(response) 
			{
		var data = jQuery.parseJSON(response);
		if (data.error == 0) 
		{
			showSurveyCondition(data.cid);
			
			if ( $("#surveyConditionPage").val() == 'invitations')
			{
				// osvežimo background
				$("#conditionProfileNote").hide();
				//
				$("#inv_rec_filter a").data('cid',0);
			}
		} 
		else 
		{
			genericAlertPopup('alert_error_code',data.error);
		}
	}
	);
}
function showRenameSurveyCondition(cid)
{
	var chooseProfileJSAction = $("#chooseProfileJSAction").val();	
	$("#surveyConditionCover").show();
	$("#divConditionProfiles #renameProfileDiv").load('ajax.php?t=surveyCondition&a=showRename', { anketa : srv_meta_anketa_id, cid:cid}).show();
	
}
function renameSurveyCondition()
{
	var cid = $("#divConditionProfiles #renameProfileId").val();
	var name = $("#divConditionProfiles #renameProfileName").val();
	$.post('ajax.php?t=surveyCondition&a=renameCondition', { anketa : srv_meta_anketa_id, cid:cid, name:name}, 
		function(response) 
		{
			var data = jQuery.parseJSON(response);
			if (data.error == 0 && data.if_id > 0) 
			{
				showSurveyCondition(data.if_id);
			} 
			else 
			{
				genericAlertPopup('alert_parameter_dataerrormsg');
			}
		}
	);
	
}