Subversion Repositories SmartDukaan

Rev

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