Subversion Repositories SmartDukaan

Rev

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