Subversion Repositories SmartDukaan

Rev

Rev 24098 | Rev 25383 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
24011 tejbeer 1
$(function() {
2
	$('.send-notification').live('click', function() {
3
		loadNotificationPanel("main-content");
4
	});
5
 
6
 
7
	$('.create-notification-button').live('click', function() {
8
		var userIds = $('#fofo-users').val();
9
		console.log("multipleUsers",userIds);
10
		var campaignName = $('input[name="campaignName"]').val();
11
		var title = $('input[name="title"]').val();
12
		var message = $('input[name="message"]').val();
13
		var imageUrl = $('input[name="imageUrl"]').val();
14
		var type = $('#type').val();
15
		var expiryTime=$('#expireSat').val();
16
		var url = $('input[name="url"]').val();
25374 tejbeer 17
		$('#showImage').on('change', function(){
24014 tejbeer 18
			   this.value = this.checked ? true : false;
24011 tejbeer 19
			}).change();		
24014 tejbeer 20
 
21
 
24011 tejbeer 22
 
23
		if(userIds.length === 0 && campaignName === "" && title === "" && message === "" && expiryTime==="" && type===""){
24
		alert("Field can't be empty");
25
		return;
26
	}
27
   if(userIds.length === 0){
28
		alert("please select the user");
29
		return;
30
	}
31
	if(campaignName === ""){
32
		alert("Campaign name is required");
33
		return;
34
	}
35
	if(title === ""){
36
		alert("Title Name is required");
37
		return;
38
	}
39
	if(message === ""){
40
		alert("Message is required");
41
		return;
42
	}
43
	if(expiryTime === ""){
44
		alert("ExpiryTime is required");
45
		return;
46
	}
47
	if(type === ""){
48
		alert("type is required");
49
		return;
50
	}
51
	if(type === "url")
52
	{
53
	if(url === "")
54
	{
55
	alert("url is required");
56
	return;
57
	}
58
 
59
	}	
60
 
61
		var notificationData ={};
62
		notificationData['userIds'] =$('#fofo-users').val();
63
		notificationData['campaignName'] = $('input[name="campaignName"]').val();
64
		notificationData['title']=$('input[name="title"]').val();
24098 tejbeer 65
		notificationData['message']=$('#message').val();
24011 tejbeer 66
		notificationData['imageUrl']=$('input[name="imageUrl"]').val();
67
		notificationData['type']=$('#type').val();
68
		notificationData['url']=$('input[name="url"]').val();
69
		notificationData['expiresat']=startDate;
25374 tejbeer 70
		notificationData['showImage']=$('input[name="showImage"]').val();
24011 tejbeer 71
		console.log(notificationData)
72
 
73
	if(confirm("Are you sure you want to send notification!") == true){
74
	doPostAjaxRequestWithJsonHandler(context+"/sendNotification", JSON.stringify(notificationData), function(response){
75
	               if (response == 'true') {
76
						    alert("successfully send");
77
					loadNotificationPanel("main-content");
78
					}
79
			});
80
 
81
		return false;	
82
	}
83
 
84
 
85
	});
86
 
87
});
88
 
89
function loadNotificationPanel(domId){
90
  	doGetAjaxRequestHandler(context+ "/sendNotificationPanel", function(response){
91
		$('#' + domId).html(response);
92
 
93
	});
94
 
95
}