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