Subversion Repositories SmartDukaan

Rev

Rev 24439 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
24417 govind 1
$(function() {
2
 
3
	$(".create-ticket-category").live('click', function() {
4
		console.log("create ticket category clicked......");
5
		loadCreateCategory("main-content");
6
	});
7
	$(".create-region").live('click', function() {
8
		loadCreateRegion("main-content");
9
	});
10
	$(".ticketType").live('click', function() {
11
		loadCreateRegion("main-content");
12
	});
13
	$(".activities").live('click', function() {
14
		var ticketId = $(this).data('ticketid');
15
		var assignee = $(this).data('assignee');
16
		console.log(assignee);
17
		loadActivities(ticketId, assignee);
18
	});
19
	$(".my-ticket").live('click', function() {
20
		loadMyTicket("main-content");
21
	});
22
	$("#close-ticket").live('click', function() {
23
		var ticketId = $(this).data('ticketid');
24
		if (confirm("Are you sure you want to close ticket!") == true) {
25
			closeTicket(ticketId);
26
		}
27
	});
28
	$(".submit-message-button").live('click', function() {
29
		var message = $("#activityMessage").val();
30
		if (message == "" || message == null || message == undefined) {
31
			alert("message field can't be empty");
32
		}
33
		var ticketId = $("#ticketIdforactivity").val();
34
		var assignee = $("#assigneeUser").val();
35
		console.log(message, ticketId, assignee);
36
		createActivity(message, ticketId, assignee);
37
	});
38
 
39
	$("#tickets-paginated .next").live(
40
			'click',
41
			function() {
42
				loadPaginatedNextItems('/cs/myticketPaginated', null,
43
						'tickets-paginated', 'my-ticket-table',
44
						'ticket-details-container');
45
				$(this).blur();
46
			});
47
 
48
	$("#tickets-paginated .previous").live(
49
			'click',
50
			function() {
51
				loadPaginatedPreviousItems('/cs/myticketPaginated', null,
52
						'tickets-paginated', 'my-ticket-table',
53
						'ticket-details-container');
54
			});
55
 
56
	$(".create-partner-region").live('click', function() {
57
		loadCreatePartnerRegion("main-content");
58
	});
59
	$(".create-ticket").live('click', function() {
60
		loadCreateTicket("main-content");
61
	});
62
	$(".create-ticket-button")
63
			.live(
64
					'click',
65
					function() {
66
						var categoryId = $('#category').val();
67
						var subCategoryId = $('#subCategory').val();
68
						if (categoryId == "" || categoryId == null
69
								|| categoryId == undefined) {
70
							alert("select appropriate category");
71
							return false;
72
						}
73
						if (subCategoryId == "" || subCategoryId == null
74
								|| subCategoryId == undefined) {
75
							alert("select appropriate subCategoryId");
76
							return false;
77
						}
78
						var dialog = bootbox
79
								.dialog({
80
									title : "Are you sure want to change create ticket!",
81
									message : "<div class=form-inline'>"
82
											+ "<label for='message'>Message:</label>"
83
											+ "<textarea class='form-control' rows='2' id='message'></textarea>"
84
											+ "</div>",
85
									buttons : {
86
										cancel : {
87
											label : "cancel",
88
											className : 'btn-danger',
89
											callback : function() {
90
												loadCreateTicket("main-content");
91
											}
92
										},
93
										ok : {
94
											label : "ok",
95
											className : 'btn-info',
96
											callback : function() {
97
												message = $('#message').val();
98
												console.log(message);
99
												if (message == ""
100
														|| message == null
101
														|| message == undefined) {
102
													alert("message field can't be empty");
103
													return false;
104
												}
105
												var params = {
106
													"categoryId" : categoryId,
107
													"subCategoryId" : subCategoryId,
108
													"message" : message
109
												}
110
												doPostAjaxRequestWithParamsHandler(
111
														context
112
																+ "/cs/createTicket",
113
														params,
114
														function(response) {
115
															if (response == "true") {
116
																alert("successfully created");
117
																loadCreateTicket("main-content");
118
															}
119
														});
120
 
121
											}
122
										}
123
									}
124
								});
125
 
126
					});
127
	$(".create-position").live('click', function() {
128
		loadCreatePosition("main-content");
129
	});
130
 
131
	$("#category").live('change', function() {
132
		var categoryId = $("#category").val();
133
		loadSubCategories(categoryId);
134
	});
135
	$(".create-ticket-category-button")
136
			.live(
137
					'click',
138
					function() {
139
						console
140
								.log("create-ticket-category-button clicked......");
141
						var name = $("#categoryName").val();
142
						var description = $("#categorydescription").val();
143
						console.log(name, description);
144
						if (name == "" || name == null || name == undefined) {
145
							alert("Name field can't be empty");
146
							return false;
147
						}
148
						if (description == "" || description == null
149
								|| description == undefined) {
150
							alert("Description field can't be empty");
151
							return false;
152
						}
153
						if (confirm("Are you sure you want to create ticket category!") == true) {
154
							createCategory("main-content", name, description);
155
						}
156
					});
157
	$(".create-region-button")
158
			.live(
159
					'click',
160
					function() {
161
						var name = $("#regionName").val();
162
						var description = $("#regiondescription").val();
163
						if (name == "" || name == null || name == undefined) {
164
							alert("Name field can't be empty");
165
							return false;
166
						}
167
						if (description == "" || description == null
168
								|| description == undefined) {
169
							alert("Description field can't be empty");
170
							return false;
171
						}
172
						if (confirm("Are you sure you want to create region!") == true) {
173
							createRegion("main-content", name, description);
174
						}
175
					});
176
 
177
	$(".create-partner-region-button")
178
			.live(
179
					'click',
180
					function() {
181
 
182
						var regionId = $("#region").val();
183
						var fofoIds = $("#partner").val();
184
						console.log(regionId, fofoIds);
185
						if (regionId == "" || regionId == null
186
								|| regionId == undefined) {
187
							alert("regionId field can't be empty");
188
							return false;
189
						}
190
						if (fofoIds == "" || fofoIds == null
191
								|| fofoIds == undefined) {
192
							alert("select appropriate partner");
193
							return false;
194
						}
195
						if (confirm("Are you sure you want to create partner region!") == true) {
196
							createPartnerRegion("main-content", regionId,
197
									fofoIds);
198
						}
199
					});
200
	$(".create-position-button")
201
			.live(
202
					'click',
203
					function() {
204
 
205
						var authUser = $("#authUser").val();
206
						var ticketCategoryPosition = $(
207
								"#ticketCategoryPosition").val();
208
						var escalationType = $("#escalationType").val();
209
						var regionPosition = $("#regionPosition").val();
210
						console.log(authUser, ticketCategoryPosition,
211
								escalationType, regionPosition);
212
						if (authUser == "" || authUser == null
213
								|| authUser == undefined) {
214
							alert("select appropriate authUser");
215
							return false;
216
						}
217
						if (ticketCategoryPosition == ""
218
								|| ticketCategoryPosition == null
219
								|| ticketCategoryPosition == undefined) {
220
							alert("select appropriate category");
221
							return false;
222
						}
223
						if (escalationType == "" || escalationType == null
224
								|| escalationType == undefined) {
225
							alert("select appropriate escalationType");
226
							return false;
227
						}
228
						if (regionPosition == "" || regionPosition == null
229
								|| regionPosition == undefined) {
230
							alert("select appropriate Region");
231
							return false;
232
						}
233
						if (confirm("Are you sure you want to create Position!") == true) {
234
							createPosition("main-content", authUser,
235
									ticketCategoryPosition, escalationType,
236
									regionPosition);
237
						}
238
					});
239
 
240
	$("#ticketCategory").live('change', function() {
241
		console.log("change ticket category clicked......");
242
		var ticketCategoryId = $(this).val();
243
		console.log(ticketCategoryId);
244
		loadticketSubCategoryById(ticketCategoryId);
245
	});
246
	$(".create-ticket-sub-category").live('click', function() {
247
		console.log("create ticket category clicked......");
248
		loadCreateSubCategory("main-content");
249
	});
250
 
251
	$(".create-ticket-sub-category-button")
252
			.live(
253
					'click',
254
					function() {
255
						console
256
								.log("create-ticket-category-button clicked......");
257
						var name = $("#subcategoryName").val();
258
						var description = $("#subcategorydescription").val();
259
						var ticketCategoryId = $("#ticketCategory").val();
260
						console.log(name, description);
261
						if (name == "" || name == null || name == undefined) {
262
							alert("Name field can't be empty");
263
							return false;
264
						}
265
						if (description == "" || description == null
266
								|| description == undefined) {
267
							alert("Description field can't be empty");
268
							return false;
269
						}
270
						if (ticketCategoryId == "" || ticketCategoryId == null
271
								|| ticketCategoryId == undefined) {
272
							alert("select appropriate category name");
273
							return false;
274
						}
275
						if (confirm("Are you sure you want to create ticket category!") == true) {
276
							createSubCategory("main-content", name,
277
									description, ticketCategoryId);
278
						}
279
					});
280
 
281
});
282
 
283
function loadCreateCategory(domId) {
284
	doGetAjaxRequestHandler(context + "/cs/createCategory", function(response) {
285
		$('#' + domId).html(response);
286
	});
287
}
288
 
289
function loadCreateRegion(domId) {
290
	doGetAjaxRequestHandler(context + "/cs/createRegion", function(response) {
291
		$('#' + domId).html(response);
292
	});
293
}
294
function loadMyTicket(domId) {
295
	doGetAjaxRequestHandler(context + "/cs/myticket", function(response) {
296
		$('#' + domId).html(response);
297
	});
298
}
299
 
300
function loadCreatePartnerRegion(domId) {
301
	doGetAjaxRequestHandler(context + "/cs/createPartnerRegion", function(
302
			response) {
303
		$('#' + domId).html(response);
304
	});
305
}
306
function loadCreatePosition(domId) {
307
	doGetAjaxRequestHandler(context + "/cs/createPosition", function(response) {
308
		$('#' + domId).html(response);
309
	});
310
}
311
function loadSubCategories(categoryId) {
312
	doGetAjaxRequestHandler(context
313
			+ "/cs/getSubCategoriesByCategoryId?categoryId=" + categoryId,
314
			function(response) {
315
				$('#' + "create-ticket-sub-categories").html(response);
316
			});
317
}
318
function createCategory(domId, name, description) {
319
	var params = {
320
		"name" : name,
321
		"description" : description
322
	}
323
	doPostAjaxRequestWithParamsHandler(context + "/cs/createCategory", params,
324
			function(response) {
325
				alert("Category created successfully");
326
				loadCreateCategory(domId);
327
			});
328
}
329
function createRegion(domId, name, description) {
330
	var params = {
331
		"name" : name,
332
		"description" : description
333
	}
334
	doPostAjaxRequestWithParamsHandler(context + "/cs/createRegion", params,
335
			function(response) {
336
				if (response == "true") {
337
					alert("Region created successfully");
338
					loadCreateRegion(domId);
339
				}
340
			});
341
}
342
function loadCreateSubCategory(domId) {
343
	doGetAjaxRequestHandler(context + "/cs/createSubCategory", function(
344
			response) {
345
		$('#' + domId).html(response);
346
	});
347
}
348
function loadCreateTicket(domId) {
349
	doGetAjaxRequestHandler(context + "/cs/createTicket", function(response) {
350
		$('#' + domId).html(response);
351
	});
352
}
353
function loadticketSubCategoryById(ticketCategoryId) {
354
	doGetAjaxRequestHandler(context
355
			+ "/cs/getSubCategoryByCategoryId?ticketCategoryId="
356
			+ ticketCategoryId, function(response) {
357
		$(".ticket-sub-category-container").html(response);
358
	});
359
}
360
function createPartnerRegion(domId, regionId, fofoIds) {
361
	doPostAjaxRequestWithJsonHandler(context
362
			+ "/cs/createPartnerRegion?regionId=" + regionId, JSON
363
			.stringify(fofoIds), function(response) {
364
		if (response == "true") {
365
			alert("added region to partner successfully");
366
			loadCreatePartnerRegion(domId);
367
		}
368
	});
369
}
370
function createSubCategory(domId, name, description, categoryId) {
371
	var params = {
372
		"categoryId" : categoryId,
373
		"name" : name,
374
		"description" : description
375
	}
376
	doPostAjaxRequestWithParamsHandler(context + "/cs/createSubCategory",
377
			params, function(response) {
378
				alert("Sub Category created successfully");
379
				loadCreateSubCategory(domId);
380
			});
381
}
382
function closeTicket(ticketId) {
383
	var params = {
384
		"ticketId" : ticketId
385
	}
386
	doPostAjaxRequestWithParamsHandler(context + "/cs/closeTicket", params,
387
			function(response) {
388
				alert("Ticket close successfully");
389
				loadMyTicket("main-content");
390
			});
391
}
392
function createPosition(domId, authUserId, categoryId, escalationType, regionId) {
393
	var params = {
394
		"authUserId" : authUserId,
395
		"categoryId" : categoryId,
396
		"escalationType" : escalationType,
397
		"regionId" : regionId
398
	}
399
	doPostAjaxRequestWithParamsHandler(context + "/cs/createPosition", params,
400
			function(response) {
401
				if (response == "true") {
402
					alert("Position created successfully");
403
					loadCreatePosition(domId);
404
				}
405
			});
406
}
407
function createActivity(message, ticketId, assigneeId) {
408
	var params = {
409
		"message" : message,
410
		"ticketId" : ticketId,
411
	}
412
	doPostAjaxRequestWithParamsHandler(context + "/cs/createActivity", params,
413
			function(response) {
414
				response = JSON.parse(response);
415
				var assigneeName = response.firstName;
416
				loadActivities(ticketId, assigneeName)
417
			});
418
}
419
function loadActivities(ticketId, assignee) {
420
 
421
	$(".modal-body").empty();
422
	$("#activityMessage").val("");
423
	$("#ticketIdforactivity").val(ticketId);
424
	var assigned = "<div class=\"white_box\"><span>AssignedTo:-" + assignee
425
			+ "</span></div>";
426
	$(".modal-body").append(assigned);
427
	console.log(ticketId);
428
	doGetAjaxRequestHandler(
429
			context + "/cs/getActivities?ticketId=" + ticketId,
430
			function(response) {
431
				response = JSON.parse(response);
432
				console.log(response);
433
				for (var i = 0; i < response.length; i++) {
434
					if ((response[i].type == "OPENED" || response[i].type == "COMMUNICATION_IN")
435
							&& response[i].createdBy == 0) {
436
 
437
						var partnerMessage = "<div class=\"incoming_msg\">"
438
								+ "<div class=\"received_msg\">"
439
								+ "<div class=\"received_withd_msg\">" + "<p>"
440
								+ response[i].message + "</p>"
441
								+ "<span class=\"time_date\"> "
442
								+ response[i].createTimestamp.hour + ":"
443
								+ response[i].createTimestamp.minute + "|"
444
								+ response[i].createTimestamp.dayOfMonth + "/"
445
								+ response[i].createTimestamp.monthValue + "/"
446
								+ response[i].createTimestamp.year
447
								+ "</span></div>" + "</div>" + "</div>";
448
						$(".modal-body").append(partnerMessage);
449
					}
450
					if (response[i].type = "COMMUNICATION_OUT"
451
							&& response[i].createdBy > 0) {
452
 
453
						var assigneeMessage = "<div class=\"outgoing_msg\">"
454
								+ "<div class=\"sent_msg\">" + "<p>"
455
								+ response[i].message + "</p>"
456
								+ "<span class=\"time_date\">"
457
								+ response[i].createTimestamp.hour + ":"
458
								+ response[i].createTimestamp.minute + "|"
459
								+ response[i].createTimestamp.dayOfMonth + "/"
460
								+ response[i].createTimestamp.monthValue + "/"
461
								+ response[i].createTimestamp.year
462
								+ "</span> </div>" + "</div>";
463
						$(".modal-body").append(assigneeMessage);
464
					}
465
				}
466
			});
467
}