Subversion Repositories SmartDukaan

Rev

Rev 24500 | Rev 24557 | Go to most recent revision | Details | Compare with Previous | 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
	});
24471 govind 10
 
11
	$(".change-ticket-button")
12
			.live(
13
					'click',
14
					function() {
15
						var ticketId = $("#ticketId").val();
16
						var subCategory = $("#subCategory").val();
17
						var authUserId = $("#authUser").val();
24534 govind 18
						var categoryId = $("#category").val();
24471 govind 19
						console.log(ticketId);
20
						if (subCategory == null || subCategory == ""
21
								|| subCategory == undefined) {
22
							alert("Choose appropriate subCategory");
24500 govind 23
							return false;
24471 govind 24
						}
24500 govind 25
						console.log(authUserId);
24471 govind 26
						if (confirm("Are you sure you want to change ticket!") == true) {
24534 govind 27
							changeTicket(ticketId, subCategory, authUserId,
28
									categoryId);
24471 govind 29
						}
30
					});
24439 govind 31
	$("#edit-ticket").live('click', function() {
24471 govind 32
 
33
		var ticketId = $(this).data('ticketid1');
24467 govind 34
		console.log(ticketId);
35
		loadEditTicket(ticketId);
24439 govind 36
	});
37
	$(".manager-ticket").live('click', function() {
38
		loadManagerTicket("main-content");
39
	});
24417 govind 40
	$(".ticketType").live('click', function() {
24534 govind 41
		console.log("create Region");
24417 govind 42
		loadCreateRegion("main-content");
43
	});
24469 govind 44
	$("#activities").live('click', function() {
24417 govind 45
		var ticketId = $(this).data('ticketid');
46
		var assignee = $(this).data('assignee');
47
		console.log(assignee);
48
		loadActivities(ticketId, assignee);
49
	});
50
	$(".my-ticket").live('click', function() {
24534 govind 51
		loadMyTicket("main-content", null, null);
24417 govind 52
	});
53
	$("#close-ticket").live('click', function() {
54
		var ticketId = $(this).data('ticketid');
24439 govind 55
		closeTicket(ticketId);
24417 govind 56
	});
57
	$(".submit-message-button").live('click', function() {
58
		var message = $("#activityMessage").val();
59
		if (message == "" || message == null || message == undefined) {
60
			alert("message field can't be empty");
24500 govind 61
			return false;
24417 govind 62
		}
63
		var ticketId = $("#ticketIdforactivity").val();
64
		var assignee = $("#assigneeUser").val();
65
		console.log(message, ticketId, assignee);
66
		createActivity(message, ticketId, assignee);
67
	});
68
 
69
	$("#tickets-paginated .next").live(
70
			'click',
71
			function() {
72
				loadPaginatedNextItems('/cs/myticketPaginated', null,
73
						'tickets-paginated', 'my-ticket-table',
74
						'ticket-details-container');
75
				$(this).blur();
76
			});
77
 
24467 govind 78
	$("#manager-tickets-paginated .previous").live(
79
			'click',
80
			function() {
81
				loadPaginatedPreviousItems('/cs/managerTicket-paginated', null,
82
						'manager-tickets-paginated', 'manager-ticket-table',
83
						'manager-ticket-details-container');
84
				$(this).blur();
85
			});
86
	$("#manager-tickets-paginated .next").live(
87
			'click',
88
			function() {
89
				loadPaginatedNextItems('/cs/managerTicket-paginated', null,
90
						'manager-tickets-paginated', 'manager-ticket-table',
91
						'manager-ticket-details-container');
92
				$(this).blur();
93
			});
94
 
24417 govind 95
	$("#tickets-paginated .previous").live(
96
			'click',
97
			function() {
98
				loadPaginatedPreviousItems('/cs/myticketPaginated', null,
99
						'tickets-paginated', 'my-ticket-table',
100
						'ticket-details-container');
24467 govind 101
				$(this).blur();
24417 govind 102
			});
24471 govind 103
	$("#positions-paginated .next").live(
104
			'click',
105
			function() {
106
				loadPaginatedNextItems('/cs/position-paginated', null,
107
						'positions-paginated', 'position-table',
108
						'position-details-container');
109
				$(this).blur();
110
			});
24417 govind 111
 
24471 govind 112
	$("#positions-paginated .previous").live(
113
			'click',
114
			function() {
115
				loadPaginatedPreviousItems('/cs/position-paginated', null,
116
						'positions-paginated', 'position-table',
117
						'position-details-container');
118
				$(this).blur();
119
			});
120
 
24417 govind 121
	$(".create-partner-region").live('click', function() {
122
		loadCreatePartnerRegion("main-content");
123
	});
124
	$(".create-ticket").live('click', function() {
125
		loadCreateTicket("main-content");
126
	});
127
	$(".create-ticket-button")
128
			.live(
129
					'click',
130
					function() {
131
						var categoryId = $('#category').val();
132
						var subCategoryId = $('#subCategory').val();
133
						if (categoryId == "" || categoryId == null
134
								|| categoryId == undefined) {
135
							alert("select appropriate category");
136
							return false;
137
						}
138
						if (subCategoryId == "" || subCategoryId == null
139
								|| subCategoryId == undefined) {
140
							alert("select appropriate subCategoryId");
141
							return false;
142
						}
143
						var dialog = bootbox
144
								.dialog({
145
									title : "Are you sure want to change create ticket!",
146
									message : "<div class=form-inline'>"
147
											+ "<label for='message'>Message:</label>"
148
											+ "<textarea class='form-control' rows='2' id='message'></textarea>"
149
											+ "</div>",
150
									buttons : {
151
										cancel : {
152
											label : "cancel",
153
											className : 'btn-danger',
154
											callback : function() {
155
												loadCreateTicket("main-content");
156
											}
157
										},
158
										ok : {
159
											label : "ok",
160
											className : 'btn-info',
161
											callback : function() {
162
												message = $('#message').val();
163
												console.log(message);
164
												if (message == ""
165
														|| message == null
166
														|| message == undefined) {
167
													alert("message field can't be empty");
168
													return false;
169
												}
170
												var params = {
171
													"categoryId" : categoryId,
172
													"subCategoryId" : subCategoryId,
173
													"message" : message
174
												}
175
												doPostAjaxRequestWithParamsHandler(
176
														context
177
																+ "/cs/createTicket",
178
														params,
179
														function(response) {
180
															if (response == "true") {
181
																alert("successfully created");
182
																loadCreateTicket("main-content");
183
															}
184
														});
185
 
186
											}
187
										}
188
									}
189
								});
190
 
191
					});
192
	$(".create-position").live('click', function() {
193
		loadCreatePosition("main-content");
194
	});
195
 
24534 govind 196
	$("#ticketStatus").live('change', function() {
197
		var status = $("#ticketStatus").val();
198
		var sortOrder = $("#sortOrder").val();
199
		console.log(status);
200
		console.log(sortOrder);
201
		loadMyTicket("main-content", status, sortOrder);
202
	});
203
	$("#sortOrder").live('change', function() {
204
		var status = $("#ticketStatus").val();
205
		var sortOrder = $("#sortOrder").val();
206
		console.log(status);
207
		console.log(sortOrder);
208
		loadMyTicket("main-content", status, sortOrder);
209
	});
24417 govind 210
	$("#category").live('change', function() {
211
		var categoryId = $("#category").val();
24500 govind 212
		$("#auth-user-for-category").hide();
24417 govind 213
		loadSubCategories(categoryId);
214
	});
215
	$(".create-ticket-category-button")
216
			.live(
217
					'click',
218
					function() {
219
						console
220
								.log("create-ticket-category-button clicked......");
221
						var name = $("#categoryName").val();
222
						var description = $("#categorydescription").val();
223
						console.log(name, description);
224
						if (name == "" || name == null || name == undefined) {
225
							alert("Name field can't be empty");
226
							return false;
227
						}
228
						if (description == "" || description == null
229
								|| description == undefined) {
230
							alert("Description field can't be empty");
231
							return false;
232
						}
233
						if (confirm("Are you sure you want to create ticket category!") == true) {
234
							createCategory("main-content", name, description);
235
						}
236
					});
237
	$(".create-region-button")
238
			.live(
239
					'click',
240
					function() {
241
						var name = $("#regionName").val();
242
						var description = $("#regiondescription").val();
243
						if (name == "" || name == null || name == undefined) {
244
							alert("Name field can't be empty");
245
							return false;
246
						}
247
						if (description == "" || description == null
248
								|| description == undefined) {
249
							alert("Description field can't be empty");
250
							return false;
251
						}
252
						if (confirm("Are you sure you want to create region!") == true) {
253
							createRegion("main-content", name, description);
254
						}
255
					});
256
 
257
	$(".create-partner-region-button")
258
			.live(
259
					'click',
260
					function() {
261
 
262
						var regionId = $("#region").val();
263
						var fofoIds = $("#partner").val();
264
						console.log(regionId, fofoIds);
265
						if (regionId == "" || regionId == null
266
								|| regionId == undefined) {
267
							alert("regionId field can't be empty");
268
							return false;
269
						}
270
						if (fofoIds == "" || fofoIds == null
271
								|| fofoIds == undefined) {
272
							alert("select appropriate partner");
273
							return false;
274
						}
275
						if (confirm("Are you sure you want to create partner region!") == true) {
276
							createPartnerRegion("main-content", regionId,
277
									fofoIds);
278
						}
279
					});
280
	$(".create-position-button")
281
			.live(
282
					'click',
283
					function() {
284
 
285
						var authUser = $("#authUser").val();
286
						var ticketCategoryPosition = $(
287
								"#ticketCategoryPosition").val();
288
						var escalationType = $("#escalationType").val();
289
						var regionPosition = $("#regionPosition").val();
290
						console.log(authUser, ticketCategoryPosition,
291
								escalationType, regionPosition);
292
						if (authUser == "" || authUser == null
293
								|| authUser == undefined) {
294
							alert("select appropriate authUser");
295
							return false;
296
						}
297
						if (ticketCategoryPosition == ""
298
								|| ticketCategoryPosition == null
299
								|| ticketCategoryPosition == undefined) {
300
							alert("select appropriate category");
301
							return false;
302
						}
303
						if (escalationType == "" || escalationType == null
304
								|| escalationType == undefined) {
305
							alert("select appropriate escalationType");
306
							return false;
307
						}
308
						if (regionPosition == "" || regionPosition == null
309
								|| regionPosition == undefined) {
310
							alert("select appropriate Region");
311
							return false;
312
						}
313
						if (confirm("Are you sure you want to create Position!") == true) {
314
							createPosition("main-content", authUser,
315
									ticketCategoryPosition, escalationType,
316
									regionPosition);
317
						}
318
					});
319
 
320
	$("#ticketCategory").live('change', function() {
321
		console.log("change ticket category clicked......");
322
		var ticketCategoryId = $(this).val();
323
		console.log(ticketCategoryId);
324
		loadticketSubCategoryById(ticketCategoryId);
325
	});
326
	$(".create-ticket-sub-category").live('click', function() {
327
		console.log("create ticket category clicked......");
328
		loadCreateSubCategory("main-content");
329
	});
330
 
331
	$(".create-ticket-sub-category-button")
332
			.live(
333
					'click',
334
					function() {
335
						console
336
								.log("create-ticket-category-button clicked......");
337
						var name = $("#subcategoryName").val();
338
						var description = $("#subcategorydescription").val();
339
						var ticketCategoryId = $("#ticketCategory").val();
340
						console.log(name, description);
341
						if (name == "" || name == null || name == undefined) {
342
							alert("Name field can't be empty");
343
							return false;
344
						}
345
						if (description == "" || description == null
346
								|| description == undefined) {
347
							alert("Description field can't be empty");
348
							return false;
349
						}
350
						if (ticketCategoryId == "" || ticketCategoryId == null
351
								|| ticketCategoryId == undefined) {
352
							alert("select appropriate category name");
353
							return false;
354
						}
355
						if (confirm("Are you sure you want to create ticket category!") == true) {
356
							createSubCategory("main-content", name,
357
									description, ticketCategoryId);
358
						}
359
					});
24471 govind 360
	$(".remove-position").live('click', function() {
361
		var positionId = $(this).data('positionid');
362
		if (confirm("Are you sure you want to remove position!") == true) {
24534 govind 363
			removePosition(positionId);
24471 govind 364
		}
365
	});
24417 govind 366
 
367
});
368
 
369
function loadCreateCategory(domId) {
370
	doGetAjaxRequestHandler(context + "/cs/createCategory", function(response) {
371
		$('#' + domId).html(response);
372
	});
373
}
24534 govind 374
function removePosition(positionId) {
375
	doDeleteAjaxRequestHandler(context + "/cs/removePosition?positionId="
376
			+ positionId, function(response) {
24471 govind 377
		if (response == "true") {
378
			alert("Position removed successfully");
379
			loadCreatePosition("main-content");
380
		}
381
	});
382
}
24417 govind 383
 
384
function loadCreateRegion(domId) {
385
	doGetAjaxRequestHandler(context + "/cs/createRegion", function(response) {
386
		$('#' + domId).html(response);
387
	});
388
}
24534 govind 389
function loadMyTicket(domId, status, orderBy) {
390
	if (status == null && orderBy == null) {
391
		doGetAjaxRequestHandler(context + "/cs/myticket", function(response) {
392
			$('#' + domId).html(response);
393
		});
394
	} else {
395
		doGetAjaxRequestHandler(context + "/cs/myticket?status=" + status
396
				+ "&orderBy=" + orderBy, function(response) {
397
			$('#' + domId).html(response);
398
		});
399
	}
24417 govind 400
}
401
 
402
function loadCreatePartnerRegion(domId) {
403
	doGetAjaxRequestHandler(context + "/cs/createPartnerRegion", function(
404
			response) {
405
		$('#' + domId).html(response);
406
	});
407
}
408
function loadCreatePosition(domId) {
409
	doGetAjaxRequestHandler(context + "/cs/createPosition", function(response) {
410
		$('#' + domId).html(response);
411
	});
412
}
413
function loadSubCategories(categoryId) {
414
	doGetAjaxRequestHandler(context
415
			+ "/cs/getSubCategoriesByCategoryId?categoryId=" + categoryId,
416
			function(response) {
417
				$('#' + "create-ticket-sub-categories").html(response);
418
			});
419
}
420
function createCategory(domId, name, description) {
421
	var params = {
422
		"name" : name,
423
		"description" : description
424
	}
425
	doPostAjaxRequestWithParamsHandler(context + "/cs/createCategory", params,
426
			function(response) {
427
				alert("Category created successfully");
428
				loadCreateCategory(domId);
429
			});
430
}
24534 govind 431
function changeTicket(ticketId, subCategoryId, authUserId, categoryId) {
24467 govind 432
	var params = {
24471 govind 433
		"ticketId" : ticketId,
434
		"subCategoryId" : subCategoryId,
24500 govind 435
		"authUserId" : authUserId,
24534 govind 436
		"categoryId" : categoryId
24471 govind 437
	}
438
	doPostAjaxRequestWithParamsHandler(context + "/cs/edit-ticket", params,
439
			function(response) {
440
				if (response == "true") {
441
					alert("Ticket changed successfully");
442
					loadManagerTicket("main-content");
443
				}
444
			});
24467 govind 445
}
24417 govind 446
function createRegion(domId, name, description) {
447
	var params = {
448
		"name" : name,
449
		"description" : description
450
	}
451
	doPostAjaxRequestWithParamsHandler(context + "/cs/createRegion", params,
452
			function(response) {
453
				if (response == "true") {
454
					alert("Region created successfully");
455
					loadCreateRegion(domId);
456
				}
457
			});
458
}
459
function loadCreateSubCategory(domId) {
460
	doGetAjaxRequestHandler(context + "/cs/createSubCategory", function(
461
			response) {
462
		$('#' + domId).html(response);
463
	});
464
}
24471 govind 465
function loadManagerTicket(domId) {
466
	doGetAjaxRequestHandler(context + "/cs/managerTicket", function(response) {
24439 govind 467
		$('#' + domId).html(response);
468
	});
469
}
24417 govind 470
function loadCreateTicket(domId) {
471
	doGetAjaxRequestHandler(context + "/cs/createTicket", function(response) {
472
		$('#' + domId).html(response);
473
	});
474
}
475
function loadticketSubCategoryById(ticketCategoryId) {
476
	doGetAjaxRequestHandler(context
477
			+ "/cs/getSubCategoryByCategoryId?ticketCategoryId="
478
			+ ticketCategoryId, function(response) {
479
		$(".ticket-sub-category-container").html(response);
480
	});
481
}
482
function createPartnerRegion(domId, regionId, fofoIds) {
483
	doPostAjaxRequestWithJsonHandler(context
484
			+ "/cs/createPartnerRegion?regionId=" + regionId, JSON
485
			.stringify(fofoIds), function(response) {
486
		if (response == "true") {
487
			alert("added region to partner successfully");
488
			loadCreatePartnerRegion(domId);
489
		}
490
	});
491
}
492
function createSubCategory(domId, name, description, categoryId) {
493
	var params = {
494
		"categoryId" : categoryId,
495
		"name" : name,
496
		"description" : description
497
	}
498
	doPostAjaxRequestWithParamsHandler(context + "/cs/createSubCategory",
499
			params, function(response) {
500
				alert("Sub Category created successfully");
501
				loadCreateSubCategory(domId);
502
			});
503
}
504
function closeTicket(ticketId) {
24439 govind 505
	var dialog = bootbox
506
			.dialog({
507
				title : "Are you sure want to close ticket!",
508
				message : "<div class=\"col-lg-6 form-group\">"
509
						+ "<input placeholder=\"Happy Code\" id=\"happyCode\" name=\"happyCode\" type=\"text\"  class=\"form-control input-sm\">"
510
						+ "</div>",
511
				buttons : {
512
					cancel : {
513
						label : "cancel",
514
						className : 'btn-danger',
515
						callback : function() {
516
							loadMyTicket("main-content");
517
						}
518
					},
519
					ok : {
520
						label : "ok",
521
						className : 'btn-info',
522
						callback : function() {
523
							happyCode = $('#happyCode').val();
524
							console.log(happyCode);
525
							if (happyCode == "" || happyCode == null
526
									|| happyCode == undefined) {
527
								alert("happyCode field can't be empty");
528
								return false;
529
							}
530
							var params = {
531
								"ticketId" : ticketId,
532
								"happyCode" : happyCode
533
							}
534
							doPostAjaxRequestWithParamsHandler(context
535
									+ "/cs/closeTicket", params, function(
536
									response) {
537
								alert("Ticket close successfully");
538
								loadMyTicket("main-content");
539
							});
540
						}
541
					}
542
				}
24417 govind 543
			});
24439 govind 544
 
24417 govind 545
}
546
function createPosition(domId, authUserId, categoryId, escalationType, regionId) {
547
	var params = {
548
		"authUserId" : authUserId,
549
		"categoryId" : categoryId,
550
		"escalationType" : escalationType,
551
		"regionId" : regionId
552
	}
553
	doPostAjaxRequestWithParamsHandler(context + "/cs/createPosition", params,
554
			function(response) {
555
				if (response == "true") {
556
					alert("Position created successfully");
557
					loadCreatePosition(domId);
558
				}
559
			});
560
}
561
function createActivity(message, ticketId, assigneeId) {
562
	var params = {
563
		"message" : message,
564
		"ticketId" : ticketId,
24534 govind 565
		"assigneeId" : assigneeId,
24417 govind 566
	}
567
	doPostAjaxRequestWithParamsHandler(context + "/cs/createActivity", params,
568
			function(response) {
569
				response = JSON.parse(response);
570
				var assigneeName = response.firstName;
571
				loadActivities(ticketId, assigneeName)
572
			});
573
}
24471 govind 574
function loadEditTicket(ticketId) {
575
	doGetAjaxRequestHandler(context + "/cs/edit-ticket?ticketId=" + ticketId,
576
			function(response) {
577
				$(".modal-content").html(response);
578
			});
24467 govind 579
}
24417 govind 580
function loadActivities(ticketId, assignee) {
581
 
24469 govind 582
	$(".activity-container .modal-body").empty();
24417 govind 583
	$("#activityMessage").val("");
584
	$("#ticketIdforactivity").val(ticketId);
585
	console.log(ticketId);
586
	doGetAjaxRequestHandler(
587
			context + "/cs/getActivities?ticketId=" + ticketId,
588
			function(response) {
589
				response = JSON.parse(response);
590
				console.log(response);
591
				for (var i = 0; i < response.length; i++) {
592
					if ((response[i].type == "OPENED" || response[i].type == "COMMUNICATION_IN")
593
							&& response[i].createdBy == 0) {
594
 
595
						var partnerMessage = "<div class=\"incoming_msg\">"
596
								+ "<div class=\"received_msg\">"
597
								+ "<div class=\"received_withd_msg\">" + "<p>"
598
								+ response[i].message + "</p>"
599
								+ "<span class=\"time_date\"> "
600
								+ response[i].createTimestamp.hour + ":"
601
								+ response[i].createTimestamp.minute + "|"
602
								+ response[i].createTimestamp.dayOfMonth + "/"
603
								+ response[i].createTimestamp.monthValue + "/"
604
								+ response[i].createTimestamp.year
605
								+ "</span></div>" + "</div>" + "</div>";
24471 govind 606
						$(".activity-container .modal-body").append(
607
								partnerMessage);
24417 govind 608
					}
609
					if (response[i].type = "COMMUNICATION_OUT"
610
							&& response[i].createdBy > 0) {
611
 
612
						var assigneeMessage = "<div class=\"outgoing_msg\">"
613
								+ "<div class=\"sent_msg\">" + "<p>"
614
								+ response[i].message + "</p>"
615
								+ "<span class=\"time_date\">"
616
								+ response[i].createTimestamp.hour + ":"
617
								+ response[i].createTimestamp.minute + "|"
618
								+ response[i].createTimestamp.dayOfMonth + "/"
619
								+ response[i].createTimestamp.monthValue + "/"
620
								+ response[i].createTimestamp.year
621
								+ "</span> </div>" + "</div>";
24471 govind 622
 
623
						$(".activity-container .modal-body").append(
624
								assigneeMessage);
24417 govind 625
					}
626
				}
627
			});
628
}