Subversion Repositories SmartDukaan

Rev

Rev 27167 | Rev 27270 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
27141 amit.gupta 1
var TEAM_ACTIVITY = [ "COMMUNICATION_OUT", "COMMUNICATION_INTERNAL",
2
		"ESCALATED", "ASSIGNED", "CATEGORY_CHANGED" ];
24417 govind 3
$(function() {
4
 
5
	$(".create-ticket-category").live('click', function() {
6
		console.log("create ticket category clicked......");
7
		loadCreateCategory("main-content");
8
	});
9
	$(".create-region").live('click', function() {
10
		loadCreateRegion("main-content");
11
	});
24748 govind 12
	$("#manager-ticket-search-by-partner-name").live(
24747 govind 13
			'click',
14
			function() {
15
				var searchContent = $(this).data('id');
24748 govind 16
				var searchValue = $("#typeaheadpartnername").val();
24747 govind 17
				var searchType = $("#managersearchType").val();
18
				var managerTicketStatus = $("#managerTicketStatus").val();
19
				var managerTicketorderBy = $("#managerTicketorderBy").val();
20
				if (typeof (searchContent) == "undefined" || !searchContent) {
21
					searchContent = "";
22
				}
23
 
24
				loadManagerTicket("main-content", managerTicketStatus,
25
						managerTicketorderBy, searchType, searchContent,
26
						searchValue);
27
 
28
			});
29
	$("#retailer-details-search-button-by-ticketId").live(
30
			'click',
31
			function() {
32
				var searchContent = $("#search-by-ticketId").val();
33
				var searchType = $("#managersearchType").val();
34
				var managerTicketStatus = $("#managerTicketStatus").val();
35
				var managerTicketorderBy = $("#managerTicketorderBy").val();
36
				if (typeof (searchContent) == "undefined" || !searchContent) {
37
					searchContent = "";
38
				}
39
				if (searchContent == "" || searchContent == undefined
40
						|| searchContent == null) {
41
					alert("Input field can't be empty");
42
					return false;
43
				}
44
				loadManagerTicket("main-content", managerTicketStatus,
45
						managerTicketorderBy, searchType, searchContent, null);
46
 
47
			});
24787 govind 48
	$("#assignee-ticket-search-by-partner-name").live(
49
			'click',
50
			function() {
51
				var searchContent = $(this).data('id');
52
				var searchValue = $("#typeaheadpartnernameforassignee").val();
53
				var searchType = $("#assigneesearchType").val();
54
				var ticketStatus = $("#ticketStatus").val();
55
				var ticketorderBy = $("#orderBy").val();
56
				console.log(ticketStatus);
57
				console.log(ticketorderBy);
58
				console.log(searchValue);
59
				if (typeof (searchContent) == "undefined" || !searchContent) {
60
					searchContent = "";
61
				}
24747 govind 62
 
24824 govind 63
				loadMyTicket("main-content", ticketStatus, ticketorderBy,
64
						searchType, searchContent, searchValue);
24787 govind 65
 
66
			});
67
	$("#assignee-retailer-details-search-button-by-ticketId").live(
68
			'click',
69
			function() {
70
				var searchContent = $("#assignee-search-by-ticketId").val();
71
				var searchType = $("#assigneesearchType").val();
72
				var ticketStatus = $("#ticketStatus").val();
73
				var ticketorderBy = $("#orderBy").val();
74
				if (typeof (searchContent) == "undefined" || !searchContent) {
75
					searchContent = "";
76
				}
77
				if (searchContent == "" || searchContent == undefined
78
						|| searchContent == null) {
79
					alert("Input field can't be empty");
80
					return false;
81
				}
82
				console.log(ticketStatus);
83
				console.log(ticketorderBy);
24824 govind 84
				loadMyTicket("main-content", ticketStatus, ticketorderBy,
85
						searchType, searchContent, null);
24787 govind 86
 
87
			});
88
 
24620 govind 89
	$("#ticket-last-activity").live('click', function() {
90
		var ticketId = $(this).data('ticketid');
91
		var activity = $(this).data('activity');
92
		console.log(ticketId);
93
		console.log(activity);
24699 govind 94
		if (confirm("Are you sure!") == true) {
24620 govind 95
			createLastActivity(ticketId, activity);
96
		}
97
	});
24471 govind 98
 
24557 govind 99
	$("#region").live('change', function() {
24620 govind 100
		var regionId = $("#region").val();
24557 govind 101
		console.log(regionId);
102
		loadPartnerForRegion(regionId);
103
	});
25570 tejbeer 104
 
105
	$("#regionPosition").live('change', function() {
106
		var regionId = $("#regionPosition").val();
107
		console.log(regionId);
108
		loadPartnerForRegionId(regionId);
109
	});
110
 
24747 govind 111
	$("#managersearchType").live('change', function() {
112
		var searchType = $("#managersearchType").val();
113
		console.log(searchType);
114
		var html;
115
		if (searchType == "PARTNER_NAME") {
116
			$('.byPartnerName').css('display', 'inline-block');
117
			$('.byTicketId').css('display', 'none');
118
			$("#search-by-ticketId").val("");
119
		} else {
120
			$('.byPartnerName').css('display', 'none');
121
			$('.byTicketId').css('display', 'inline-block');
24824 govind 122
			$('#manager-ticket-search-by-partner-name').data('id', "");
24747 govind 123
		}
24557 govind 124
 
24747 govind 125
	});
24787 govind 126
	$("#assigneesearchType").live('change', function() {
127
		var searchType = $("#assigneesearchType").val();
128
		console.log(searchType);
129
		var html;
130
		if (searchType == "PARTNER_NAME") {
131
			$('.assigneebyPartnerName').css('display', 'inline-block');
132
			$('.assigneebyTicketId').css('display', 'none');
133
			$("#assignee-search-by-ticketId").val("");
134
		} else {
135
			$('.assigneebyPartnerName').css('display', 'none');
136
			$('.assigneebyTicketId').css('display', 'inline-block');
24824 govind 137
			$("#assignee-ticket-search-by-partner-name").data('id', '');
24787 govind 138
		}
24747 govind 139
 
24787 govind 140
	});
141
 
24471 govind 142
	$(".change-ticket-button")
143
			.live(
144
					'click',
145
					function() {
146
						var ticketId = $("#ticketId").val();
147
						var subCategory = $("#subCategory").val();
148
						var authUserId = $("#authUser").val();
24534 govind 149
						var categoryId = $("#category").val();
24471 govind 150
						console.log(ticketId);
151
						if (subCategory == null || subCategory == ""
152
								|| subCategory == undefined) {
153
							alert("Choose appropriate subCategory");
24500 govind 154
							return false;
24471 govind 155
						}
24500 govind 156
						console.log(authUserId);
24471 govind 157
						if (confirm("Are you sure you want to change ticket!") == true) {
24534 govind 158
							changeTicket(ticketId, subCategory, authUserId,
159
									categoryId);
24471 govind 160
						}
161
					});
24439 govind 162
	$("#edit-ticket").live('click', function() {
24471 govind 163
		var ticketId = $(this).data('ticketid1');
24467 govind 164
		loadEditTicket(ticketId);
24439 govind 165
	});
166
	$(".manager-ticket").live('click', function() {
24747 govind 167
		loadManagerTicket("main-content", null, null);
24439 govind 168
	});
26014 amit.gupta 169
	$(".access-management").live('click', function() {
170
		loadAccessManagement("main-content", null, null);
171
	});
24417 govind 172
	$(".ticketType").live('click', function() {
24534 govind 173
		console.log("create Region");
24417 govind 174
		loadCreateRegion("main-content");
175
	});
24469 govind 176
	$("#activities").live('click', function() {
24417 govind 177
		var ticketId = $(this).data('ticketid');
178
		var assignee = $(this).data('assignee');
24824 govind 179
		var internal = $(this).data('internal');
180
		var roleType = $(this).data('role');
24417 govind 181
		console.log(assignee);
24824 govind 182
		loadActivities(ticketId, assignee, internal, roleType);
24417 govind 183
	});
184
	$(".my-ticket").live('click', function() {
24824 govind 185
		loadMyTicket("main-content", null, null, null, null, null);
24417 govind 186
	});
187
	$("#close-ticket").live('click', function() {
188
		var ticketId = $(this).data('ticketid');
24439 govind 189
		closeTicket(ticketId);
24417 govind 190
	});
191
	$(".submit-message-button").live('click', function() {
192
		var message = $("#activityMessage").val();
24824 govind 193
		var internal = $("#internalCommunication").prop("checked");
24417 govind 194
		if (message == "" || message == null || message == undefined) {
195
			alert("message field can't be empty");
24500 govind 196
			return false;
24417 govind 197
		}
198
		var ticketId = $("#ticketIdforactivity").val();
199
		var assignee = $("#assigneeUser").val();
24824 govind 200
		var roleType = $("#role").val();
24417 govind 201
		console.log(message, ticketId, assignee);
24824 govind 202
		createActivity(message, ticketId, assignee, internal, roleType);
24417 govind 203
	});
204
 
205
	$("#tickets-paginated .next").live(
206
			'click',
207
			function() {
24787 govind 208
				var searchType = $("#assigneesearchType").val();
24699 govind 209
				var ticketStatus = $("#ticketStatus").val();
24787 govind 210
				var ticketStatus = $("#ticketStatus").val();
24699 govind 211
				var orderBy = $("#orderBy").val();
24787 govind 212
				var params;
213
				if (searchType == "" || searchType == undefined
214
						|| searchType == null || searchType == "TICKET_ID") {
215
					params = {
216
						"ticketStatus" : ticketStatus,
217
						"orderby" : orderBy
218
					};
219
				} else {
220
					var searchTerm = $("#assignee-partner-name-input").val();
221
					console.log(searchTerm);
222
					params = {
223
						"ticketStatus" : ticketStatus,
224
						"orderby" : orderBy,
225
						"ticketSearchType" : searchType,
226
						"searchTerm" : searchTerm
227
					};
228
				}
24747 govind 229
				loadPaginatedNextItems('/cs/myticketPaginated', params,
24417 govind 230
						'tickets-paginated', 'my-ticket-table',
231
						'ticket-details-container');
232
				$(this).blur();
233
			});
234
 
24467 govind 235
	$("#manager-tickets-paginated .previous").live(
236
			'click',
237
			function() {
24747 govind 238
 
239
				var ticketStatus = $("#managerTicketStatus").val();
240
				var orderBy = $("#managerTicketorderBy").val();
241
				var searchType = $("#managersearchType").val();
242
				var params;
24751 govind 243
				if (searchType == "" || searchType == undefined
244
						|| searchType == null || searchType == "TICKET_ID") {
24747 govind 245
					params = {
246
						"ticketStatus" : ticketStatus,
247
						"orderby" : orderBy
248
					};
249
				} else {
250
					var searchTerm = $("#partner-name-input").val();
251
					console.log(searchTerm);
252
					params = {
253
						"ticketStatus" : ticketStatus,
254
						"orderby" : orderBy,
255
						"ticketSearchType" : searchType,
256
						"searchTerm" : searchTerm
257
					};
258
				}
259
				loadPaginatedPreviousItems('/cs/managerTicket-paginated',
260
						params, 'manager-tickets-paginated',
261
						'manager-ticket-table',
24467 govind 262
						'manager-ticket-details-container');
263
				$(this).blur();
264
			});
265
	$("#manager-tickets-paginated .next").live(
266
			'click',
267
			function() {
24747 govind 268
				var ticketStatus = $("#managerTicketStatus").val();
269
				var orderBy = $("#managerTicketorderBy").val();
270
				var searchType = $("#managersearchType").val();
271
				var params;
24751 govind 272
				if (searchType == "" || searchType == undefined
273
						|| searchType == null || searchType == "TICKET_ID") {
24747 govind 274
					params = {
275
						"ticketStatus" : ticketStatus,
276
						"orderby" : orderBy
277
					};
278
				} else {
279
					var searchTerm = $("#partner-name-input").val();
280
					console.log(searchTerm);
281
					params = {
282
						"ticketStatus" : ticketStatus,
283
						"orderby" : orderBy,
284
						"ticketSearchType" : searchType,
285
						"searchTerm" : searchTerm
286
					};
287
				}
24699 govind 288
 
24747 govind 289
				loadPaginatedNextItems('/cs/managerTicket-paginated', params,
24467 govind 290
						'manager-tickets-paginated', 'manager-ticket-table',
291
						'manager-ticket-details-container');
292
				$(this).blur();
293
			});
294
 
24417 govind 295
	$("#tickets-paginated .previous").live(
296
			'click',
297
			function() {
24787 govind 298
				var searchType = $("#assigneesearchType").val();
24699 govind 299
				var ticketStatus = $("#ticketStatus").val();
24787 govind 300
				var ticketStatus = $("#ticketStatus").val();
24699 govind 301
				var orderBy = $("#orderBy").val();
24787 govind 302
				var params;
303
				if (searchType == "" || searchType == undefined
304
						|| searchType == null || searchType == "TICKET_ID") {
305
					params = {
306
						"ticketStatus" : ticketStatus,
307
						"orderby" : orderBy
308
					};
309
				} else {
310
					var searchTerm = $("#assignee-partner-name-input").val();
311
					console.log(searchTerm);
312
					params = {
313
						"ticketStatus" : ticketStatus,
314
						"orderby" : orderBy,
315
						"ticketSearchType" : searchType,
316
						"searchTerm" : searchTerm
317
					};
318
				}
24747 govind 319
				loadPaginatedPreviousItems('/cs/myticketPaginated', params,
24417 govind 320
						'tickets-paginated', 'my-ticket-table',
321
						'ticket-details-container');
24467 govind 322
				$(this).blur();
24417 govind 323
			});
24471 govind 324
	$("#positions-paginated .next").live(
325
			'click',
326
			function() {
327
				loadPaginatedNextItems('/cs/position-paginated', null,
328
						'positions-paginated', 'position-table',
329
						'position-details-container');
330
				$(this).blur();
331
			});
24417 govind 332
 
24471 govind 333
	$("#positions-paginated .previous").live(
334
			'click',
335
			function() {
336
				loadPaginatedPreviousItems('/cs/position-paginated', null,
337
						'positions-paginated', 'position-table',
338
						'position-details-container');
339
				$(this).blur();
340
			});
341
 
24417 govind 342
	$(".create-partner-region").live('click', function() {
343
		loadCreatePartnerRegion("main-content");
344
	});
345
	$(".create-ticket").live('click', function() {
346
		loadCreateTicket("main-content");
347
	});
348
	$(".create-ticket-button")
349
			.live(
350
					'click',
351
					function() {
352
						var categoryId = $('#category').val();
353
						var subCategoryId = $('#subCategory').val();
354
						if (categoryId == "" || categoryId == null
355
								|| categoryId == undefined) {
356
							alert("select appropriate category");
357
							return false;
358
						}
359
						if (subCategoryId == "" || subCategoryId == null
360
								|| subCategoryId == undefined) {
361
							alert("select appropriate subCategoryId");
362
							return false;
363
						}
364
						var dialog = bootbox
365
								.dialog({
366
									title : "Are you sure want to change create ticket!",
367
									message : "<div class=form-inline'>"
368
											+ "<label for='message'>Message:</label>"
369
											+ "<textarea class='form-control' rows='2' id='message'></textarea>"
370
											+ "</div>",
371
									buttons : {
372
										cancel : {
373
											label : "cancel",
374
											className : 'btn-danger',
375
											callback : function() {
376
												loadCreateTicket("main-content");
377
											}
378
										},
379
										ok : {
380
											label : "ok",
381
											className : 'btn-info',
382
											callback : function() {
383
												message = $('#message').val();
384
												console.log(message);
385
												if (message == ""
386
														|| message == null
387
														|| message == undefined) {
388
													alert("message field can't be empty");
389
													return false;
390
												}
391
												var params = {
392
													"categoryId" : categoryId,
393
													"subCategoryId" : subCategoryId,
394
													"message" : message
395
												}
396
												doPostAjaxRequestWithParamsHandler(
397
														context
398
																+ "/cs/createTicket",
399
														params,
400
														function(response) {
401
															if (response == "true") {
402
																alert("successfully created");
403
																loadCreateTicket("main-content");
24620 govind 404
															} else {
24836 govind 405
																alert("You have reached maximum number of tickets Resolved , pls click on Resolved for the resolved tickets to create new.");
24417 govind 406
															}
407
														});
408
 
409
											}
410
										}
411
									}
412
								});
413
 
414
					});
415
	$(".create-position").live('click', function() {
416
		loadCreatePosition("main-content");
417
	});
418
 
24824 govind 419
	$("#ticketStatus").live(
420
			'change',
421
			function() {
422
				var ticketStatus = $("#ticketStatus").val();
423
				var orderBy = $("#orderBy").val();
424
				var searchType = $("#assigneesearchType").val();
425
				if (searchType == "" || searchType == undefined
426
						|| searchType == null) {
427
					loadMyTicket("main-content", ticketStatus, orderBy, null,
428
							null, null);
429
				} else {
430
					if (searchType == "PARTNER_NAME") {
431
						var searchTerm = $("#assignee-partner-name-input")
432
								.val();
433
						var searchValue = $("#typeaheadpartnernameforassignee")
434
								.val();
435
						loadMyTicket("main-content", ticketStatus, orderBy,
436
								searchType, searchTerm, searchValue);
437
					} else {
438
						var searchTerm = $("#assignee-search-by-ticketId")
439
								.val();
440
						loadMyTicket("main-content", ticketStatus, orderBy,
441
								searchType, searchTerm, null);
442
					}
443
				}
444
			});
445
	$("#orderBy").live(
446
			'change',
447
			function() {
448
				var ticketStatus = $("#ticketStatus").val();
449
				var orderBy = $("#orderBy").val();
450
				var searchType = $("#assigneesearchType").val();
451
				if (searchType == "" || searchType == undefined
452
						|| searchType == null) {
453
					loadMyTicket("main-content", ticketStatus, orderBy, null,
454
							null, null);
455
				} else {
456
					if (searchType == "PARTNER_NAME") {
457
						var searchTerm = $("#assignee-partner-name-input")
458
								.val();
459
						var searchValue = $("#typeaheadpartnernameforassignee")
460
								.val();
461
						loadMyTicket("main-content", ticketStatus, orderBy,
462
								searchType, searchTerm, searchValue);
463
					} else {
464
						var searchTerm = $("#assignee-search-by-ticketId")
465
								.val();
466
						loadMyTicket("main-content", ticketStatus, orderBy,
467
								searchType, searchTerm, null);
468
					}
469
				}
470
			});
24747 govind 471
	$("#managerTicketStatus").live(
472
			'change',
473
			function() {
474
				var ticketStatus = $("#managerTicketStatus").val();
475
				var orderBy = $("#managerTicketorderBy").val();
476
				var searchType = $("#managersearchType").val();
477
				if (searchType == "" || searchType == undefined
478
						|| searchType == null) {
479
					loadManagerTicket("main-content", ticketStatus, orderBy,
480
							null, null, null);
481
				} else {
482
					if (searchType == "PARTNER_NAME") {
483
						var searchTerm = $("#partner-name-input").val();
24748 govind 484
						var searchValue = $("#typeaheadpartnername").val();
24747 govind 485
						loadManagerTicket("main-content", ticketStatus,
486
								orderBy, searchType, searchTerm, searchValue);
487
					} else {
488
						var searchTerm = $("#search-by-ticketId").val();
489
						loadManagerTicket("main-content", ticketStatus,
490
								orderBy, searchType, searchTerm, null);
491
					}
492
				}
493
 
494
			});
495
	$("#managerTicketorderBy").live(
496
			'change',
497
			function() {
498
				var ticketStatus = $("#managerTicketStatus").val();
499
				var orderBy = $("#managerTicketorderBy").val();
500
				var searchType = $("#managersearchType").val();
501
				var searchType = $("#managersearchType").val();
502
				if (searchType == "" || searchType == undefined
503
						|| searchType == null) {
504
					loadManagerTicket("main-content", ticketStatus, orderBy,
505
							null, null, null);
506
				} else {
507
					if (searchType == "PARTNER_NAME") {
508
						var searchTerm = $("#partner-name-input").val();
24748 govind 509
						var searchValue = $("#typeaheadpartnername").val();
24747 govind 510
						loadManagerTicket("main-content", ticketStatus,
511
								orderBy, searchType, searchTerm, searchValue);
512
					} else {
513
						var searchTerm = $("#search-by-ticketId").val();
514
						loadManagerTicket("main-content", ticketStatus,
515
								orderBy, searchType, searchTerm, null);
516
					}
517
				}
518
 
519
			});
24417 govind 520
	$("#category").live('change', function() {
521
		var categoryId = $("#category").val();
24500 govind 522
		$("#auth-user-for-category").hide();
24417 govind 523
		loadSubCategories(categoryId);
524
	});
525
	$(".create-ticket-category-button")
526
			.live(
527
					'click',
528
					function() {
529
						console
530
								.log("create-ticket-category-button clicked......");
531
						var name = $("#categoryName").val();
532
						var description = $("#categorydescription").val();
533
						console.log(name, description);
534
						if (name == "" || name == null || name == undefined) {
535
							alert("Name field can't be empty");
536
							return false;
537
						}
538
						if (description == "" || description == null
539
								|| description == undefined) {
540
							alert("Description field can't be empty");
541
							return false;
542
						}
543
						if (confirm("Are you sure you want to create ticket category!") == true) {
544
							createCategory("main-content", name, description);
545
						}
546
					});
547
	$(".create-region-button")
548
			.live(
549
					'click',
550
					function() {
551
						var name = $("#regionName").val();
552
						var description = $("#regiondescription").val();
553
						if (name == "" || name == null || name == undefined) {
554
							alert("Name field can't be empty");
555
							return false;
556
						}
557
						if (description == "" || description == null
558
								|| description == undefined) {
559
							alert("Description field can't be empty");
560
							return false;
561
						}
562
						if (confirm("Are you sure you want to create region!") == true) {
563
							createRegion("main-content", name, description);
564
						}
565
					});
566
 
567
	$(".create-partner-region-button")
568
			.live(
569
					'click',
570
					function() {
571
 
572
						var regionId = $("#region").val();
573
						var fofoIds = $("#partner").val();
574
						console.log(regionId, fofoIds);
575
						if (regionId == "" || regionId == null
576
								|| regionId == undefined) {
577
							alert("regionId field can't be empty");
578
							return false;
579
						}
580
						if (fofoIds == "" || fofoIds == null
581
								|| fofoIds == undefined) {
582
							alert("select appropriate partner");
583
							return false;
584
						}
585
						if (confirm("Are you sure you want to create partner region!") == true) {
586
							createPartnerRegion("main-content", regionId,
587
									fofoIds);
588
						}
589
					});
590
	$(".create-position-button")
591
			.live(
592
					'click',
593
					function() {
594
 
595
						var authUser = $("#authUser").val();
596
						var ticketCategoryPosition = $(
597
								"#ticketCategoryPosition").val();
598
						var escalationType = $("#escalationType").val();
599
						var regionPosition = $("#regionPosition").val();
25570 tejbeer 600
						var fofoIds = $("#partner").val();
601
						if (fofoIds.includes("0")) {
602
							fofoIds = [ 0 ];
603
							console.log(fofoIds);
604
						} else {
605
							console.log(fofoIds);
606
						}
24417 govind 607
						console.log(authUser, ticketCategoryPosition,
608
								escalationType, regionPosition);
609
						if (authUser == "" || authUser == null
610
								|| authUser == undefined) {
611
							alert("select appropriate authUser");
612
							return false;
613
						}
614
						if (ticketCategoryPosition == ""
615
								|| ticketCategoryPosition == null
616
								|| ticketCategoryPosition == undefined) {
617
							alert("select appropriate category");
618
							return false;
619
						}
620
						if (escalationType == "" || escalationType == null
621
								|| escalationType == undefined) {
622
							alert("select appropriate escalationType");
623
							return false;
624
						}
625
						if (regionPosition == "" || regionPosition == null
626
								|| regionPosition == undefined) {
627
							alert("select appropriate Region");
628
							return false;
629
						}
25570 tejbeer 630
 
24417 govind 631
						if (confirm("Are you sure you want to create Position!") == true) {
632
							createPosition("main-content", authUser,
633
									ticketCategoryPosition, escalationType,
25570 tejbeer 634
									regionPosition, fofoIds);
24417 govind 635
						}
25570 tejbeer 636
 
24417 govind 637
					});
638
 
639
	$("#ticketCategory").live('change', function() {
640
		console.log("change ticket category clicked......");
641
		var ticketCategoryId = $(this).val();
642
		console.log(ticketCategoryId);
643
		loadticketSubCategoryById(ticketCategoryId);
644
	});
645
	$(".create-ticket-sub-category").live('click', function() {
646
		console.log("create ticket category clicked......");
647
		loadCreateSubCategory("main-content");
648
	});
649
 
650
	$(".create-ticket-sub-category-button")
651
			.live(
652
					'click',
653
					function() {
654
						console
655
								.log("create-ticket-category-button clicked......");
656
						var name = $("#subcategoryName").val();
657
						var description = $("#subcategorydescription").val();
658
						var ticketCategoryId = $("#ticketCategory").val();
659
						console.log(name, description);
660
						if (name == "" || name == null || name == undefined) {
661
							alert("Name field can't be empty");
662
							return false;
663
						}
664
						if (description == "" || description == null
665
								|| description == undefined) {
666
							alert("Description field can't be empty");
667
							return false;
668
						}
669
						if (ticketCategoryId == "" || ticketCategoryId == null
670
								|| ticketCategoryId == undefined) {
671
							alert("select appropriate category name");
672
							return false;
673
						}
674
						if (confirm("Are you sure you want to create ticket category!") == true) {
675
							createSubCategory("main-content", name,
676
									description, ticketCategoryId);
677
						}
678
					});
24471 govind 679
	$(".remove-position").live('click', function() {
680
		var positionId = $(this).data('positionid');
681
		if (confirm("Are you sure you want to remove position!") == true) {
24534 govind 682
			removePosition(positionId);
24471 govind 683
		}
684
	});
24417 govind 685
 
27141 amit.gupta 686
	$(".update-position")
687
			.live(
688
					'click',
689
					function() {
690
						var positionId = $(this).data('positionid');
691
						var regionId = $(this).data('regionid');
25570 tejbeer 692
 
27141 amit.gupta 693
						var row = $(this);
694
						var selectedFofoIds = $(this).closest("tr").find(
695
								'#partners ').val();
696
						if (selectedFofoIds.includes("0")) {
697
							selectedFofoIds = [ 0 ];
698
							console.log(selectedFofoIds);
699
						} else {
700
							console.log(selectedFofoIds);
701
						}
702
						if (confirm("Are you sure you want to update the partners!") == true) {
703
							doPostAjaxRequestWithJsonHandler(context
704
									+ "/cs/updatePartnerPosition?regionId="
705
									+ regionId + "&positionId=" + positionId,
706
									JSON.stringify(selectedFofoIds), function(
707
											response) {
708
										if (response == "true") {
709
											alert("Update successfully");
710
											loadCreatePosition("main-content");
711
										}
712
									});
713
						}
25570 tejbeer 714
 
27141 amit.gupta 715
					});
25570 tejbeer 716
 
24417 govind 717
});
718
 
719
function loadCreateCategory(domId) {
720
	doGetAjaxRequestHandler(context + "/cs/createCategory", function(response) {
721
		$('#' + domId).html(response);
722
	});
723
}
24534 govind 724
function removePosition(positionId) {
725
	doDeleteAjaxRequestHandler(context + "/cs/removePosition?positionId="
726
			+ positionId, function(response) {
24471 govind 727
		if (response == "true") {
728
			alert("Position removed successfully");
729
			loadCreatePosition("main-content");
730
		}
731
	});
732
}
24417 govind 733
 
734
function loadCreateRegion(domId) {
735
	doGetAjaxRequestHandler(context + "/cs/createRegion", function(response) {
736
		$('#' + domId).html(response);
737
	});
738
}
24824 govind 739
function loadMyTicket(domId, ticketStatus, sortOrder, ticketSearchType,
740
		searchTerm, searchValue) {
24620 govind 741
 
24699 govind 742
	if (ticketStatus == null && sortOrder == null) {
743
		doGetAjaxRequestHandler(context + "/cs/myticket", function(response) {
744
			$('#' + domId).html(response);
745
		});
24824 govind 746
	} else if (ticketSearchType == null) {
24699 govind 747
		doGetAjaxRequestHandler(context + "/cs/myticket?ticketStatus="
24824 govind 748
				+ ticketStatus + "&orderby=" + sortOrder, function(response) {
749
			$('#' + domId).html(response);
750
		});
751
	} else {
752
		doGetAjaxRequestHandler(context + "/cs/myticket?ticketStatus="
753
				+ ticketStatus + "&orderby=" + sortOrder + "&ticketSearchType="
24787 govind 754
				+ ticketSearchType + "&searchTerm=" + searchTerm, function(
24824 govind 755
				response) {
756
			$('#' + domId).html(response);
757
			if (ticketSearchType == "PARTNER_NAME") {
758
				$('.assigneebyPartnerName').css('display', 'inline-block');
759
				$('.assingeebyTicketId').css('display', 'none');
760
				$("#typeaheadpartnernameforassignee").val(searchValue);
761
				$("#assignee-partner-name-input").val(searchTerm);
762
			} else {
763
				$('.assigneebyPartnerName').css('display', 'none');
764
				$('.assigneebyTicketId').css('display', 'inline-block');
765
				$("#assignee-search-by-ticketId").val(searchTerm);
766
			}
24699 govind 767
		});
768
	}
24417 govind 769
}
770
 
771
function loadCreatePartnerRegion(domId) {
772
	doGetAjaxRequestHandler(context + "/cs/createPartnerRegion", function(
773
			response) {
774
		$('#' + domId).html(response);
775
	});
776
}
777
function loadCreatePosition(domId) {
778
	doGetAjaxRequestHandler(context + "/cs/createPosition", function(response) {
779
		$('#' + domId).html(response);
780
	});
781
}
782
function loadSubCategories(categoryId) {
783
	doGetAjaxRequestHandler(context
784
			+ "/cs/getSubCategoriesByCategoryId?categoryId=" + categoryId,
785
			function(response) {
786
				$('#' + "create-ticket-sub-categories").html(response);
787
			});
788
}
789
function createCategory(domId, name, description) {
790
	var params = {
791
		"name" : name,
792
		"description" : description
793
	}
794
	doPostAjaxRequestWithParamsHandler(context + "/cs/createCategory", params,
795
			function(response) {
796
				alert("Category created successfully");
797
				loadCreateCategory(domId);
798
			});
799
}
24534 govind 800
function changeTicket(ticketId, subCategoryId, authUserId, categoryId) {
24467 govind 801
	var params = {
24471 govind 802
		"ticketId" : ticketId,
803
		"subCategoryId" : subCategoryId,
24500 govind 804
		"authUserId" : authUserId,
24534 govind 805
		"categoryId" : categoryId
24471 govind 806
	}
807
	doPostAjaxRequestWithParamsHandler(context + "/cs/edit-ticket", params,
808
			function(response) {
809
				if (response == "true") {
810
					alert("Ticket changed successfully");
24824 govind 811
					loadManagerTicket("main-content", null, null, null, null,
812
							null);
24471 govind 813
				}
814
			});
24467 govind 815
}
24417 govind 816
function createRegion(domId, name, description) {
817
	var params = {
818
		"name" : name,
819
		"description" : description
820
	}
821
	doPostAjaxRequestWithParamsHandler(context + "/cs/createRegion", params,
822
			function(response) {
823
				if (response == "true") {
824
					alert("Region created successfully");
825
					loadCreateRegion(domId);
826
				}
827
			});
828
}
829
function loadCreateSubCategory(domId) {
830
	doGetAjaxRequestHandler(context + "/cs/createSubCategory", function(
831
			response) {
832
		$('#' + domId).html(response);
833
	});
834
}
24747 govind 835
function loadManagerTicket(domId, ticketStatus, sortOrder, ticketSearchType,
836
		searchTerm, searchValue) {
24751 govind 837
	if (ticketStatus == null && sortOrder == null) {
24747 govind 838
		doGetAjaxRequestHandler(context + "/cs/managerTicket", function(
839
				response) {
24699 govind 840
			$('#' + domId).html(response);
841
		});
24824 govind 842
	} else if (ticketSearchType == null) {
24747 govind 843
		doGetAjaxRequestHandler(context + "/cs/managerTicket?ticketStatus="
24824 govind 844
				+ ticketStatus + "&orderby=" + sortOrder, function(response) {
24751 govind 845
			$('#' + domId).html(response);
846
		});
24824 govind 847
	} else {
24751 govind 848
		doGetAjaxRequestHandler(context + "/cs/managerTicket?ticketStatus="
24747 govind 849
				+ ticketStatus + "&orderby=" + sortOrder + "&ticketSearchType="
850
				+ ticketSearchType + "&searchTerm=" + searchTerm, function(
851
				response) {
852
			$('#' + domId).html(response);
853
			if (ticketSearchType == "PARTNER_NAME") {
854
				$('.byPartnerName').css('display', 'inline-block');
855
				$('.byTicketId').css('display', 'none');
24748 govind 856
				$("#typeaheadpartnername").val(searchValue);
24747 govind 857
				$("#partner-name-input").val(searchTerm);
858
			} else {
859
				$('.byPartnerName').css('display', 'none');
860
				$('.byTicketId').css('display', 'inline-block');
861
				$("#search-by-ticketId").val(searchTerm);
862
			}
863
		});
864
	}
24439 govind 865
}
24417 govind 866
function loadCreateTicket(domId) {
867
	doGetAjaxRequestHandler(context + "/cs/createTicket", function(response) {
868
		$('#' + domId).html(response);
869
	});
870
}
871
function loadticketSubCategoryById(ticketCategoryId) {
872
	doGetAjaxRequestHandler(context
873
			+ "/cs/getSubCategoryByCategoryId?ticketCategoryId="
874
			+ ticketCategoryId, function(response) {
875
		$(".ticket-sub-category-container").html(response);
876
	});
877
}
878
function createPartnerRegion(domId, regionId, fofoIds) {
879
	doPostAjaxRequestWithJsonHandler(context
880
			+ "/cs/createPartnerRegion?regionId=" + regionId, JSON
881
			.stringify(fofoIds), function(response) {
882
		if (response == "true") {
883
			alert("added region to partner successfully");
884
			loadCreatePartnerRegion(domId);
885
		}
886
	});
887
}
888
function createSubCategory(domId, name, description, categoryId) {
889
	var params = {
890
		"categoryId" : categoryId,
891
		"name" : name,
892
		"description" : description
893
	}
894
	doPostAjaxRequestWithParamsHandler(context + "/cs/createSubCategory",
895
			params, function(response) {
896
				alert("Sub Category created successfully");
897
				loadCreateSubCategory(domId);
898
			});
899
}
24620 govind 900
function createLastActivity(ticketId, activity) {
901
	var params = {
902
		"ticketId" : ticketId,
903
		"lastactivity" : activity
904
	}
905
	doPostAjaxRequestWithParamsHandler(context + "/cs/create-last-activity",
906
			params, function(response) {
907
				if (response == "true") {
908
					alert("successfully mark last activity");
24699 govind 909
					loadMyTicket("main-content", null, null);
24620 govind 910
				}
911
			});
912
}
24439 govind 913
 
25570 tejbeer 914
function createPosition(domId, authUserId, categoryId, escalationType,
915
		regionId, fofoIds) {
916
 
917
	var createPositionModel = {};
918
	createPositionModel['authUserId'] = authUserId;
919
	createPositionModel['categoryId'] = categoryId
920
	createPositionModel['escalationType'] = escalationType;
921
	createPositionModel['regionId'] = regionId,
922
			createPositionModel['fofoIds'] = fofoIds
923
 
924
	console.log(createPositionModel);
925
	doPostAjaxRequestWithJsonHandler(context + "/cs/createPosition", JSON
926
			.stringify(createPositionModel), function(response) {
927
		if (response == "true") {
928
			alert("Position created successfully");
929
			loadCreatePosition(domId);
930
		}
931
	});
24417 govind 932
}
24824 govind 933
function createActivity(message, ticketId, assigneeId, internal, roleType) {
24417 govind 934
	var params = {
935
		"message" : message,
936
		"ticketId" : ticketId,
24534 govind 937
		"assigneeId" : assigneeId,
24824 govind 938
		"internal" : internal,
24417 govind 939
	}
940
	doPostAjaxRequestWithParamsHandler(context + "/cs/createActivity", params,
941
			function(response) {
942
				response = JSON.parse(response);
943
				var assigneeName = response.firstName;
24824 govind 944
				loadActivities(ticketId, assigneeName, internal, roleType)
24417 govind 945
			});
946
}
24471 govind 947
function loadEditTicket(ticketId) {
948
	doGetAjaxRequestHandler(context + "/cs/edit-ticket?ticketId=" + ticketId,
949
			function(response) {
27167 amit.gupta 950
				$("#theModal .modal-content").html(response);
951
 
24471 govind 952
			});
24467 govind 953
}
24557 govind 954
function loadPartnerForRegion(regionId) {
955
	doGetAjaxRequestHandler(context + "/cs/getPartners?regionId=" + regionId,
956
			function(response) {
957
				$("#partner-region-container").html(response);
958
			});
959
}
25570 tejbeer 960
 
961
function loadPartnerForRegionId(regionId) {
962
	doGetAjaxRequestHandler(context + "/cs/getPartnersByRegion?regionId="
963
			+ regionId, function(response) {
964
		$("#partner-subregion-container").html(response);
965
	});
966
}
967
 
26014 amit.gupta 968
function loadAccessManagement(domId) {
27141 amit.gupta 969
	doGetAjaxRequestHandler(context + "/admin/access-management", function(
970
			response) {
26014 amit.gupta 971
		$('#' + domId).html(response);
972
	});
973
}
974
 
24824 govind 975
function loadActivities(ticketId, assignee, internal, roleType) {
24417 govind 976
 
24469 govind 977
	$(".activity-container .modal-body").empty();
24417 govind 978
	$("#activityMessage").val("");
979
	$("#ticketIdforactivity").val(ticketId);
24824 govind 980
	$("#role").val(roleType);
27169 amit.gupta 981
	$(".activity-container .modal-title").html("Activity history for Ticket Id " + ticketId)
24417 govind 982
	console.log(ticketId);
983
	doGetAjaxRequestHandler(
984
			context + "/cs/getActivities?ticketId=" + ticketId,
985
			function(response) {
986
				response = JSON.parse(response);
987
				console.log(response);
988
				for (var i = 0; i < response.length; i++) {
27149 amit.gupta 989
					if (response[i].type == "OPENED" || response[i].type == "COMMUNICATION_IN") {
24417 govind 990
 
991
						var partnerMessage = "<div class=\"incoming_msg\">"
992
								+ "<div class=\"received_msg\">"
993
								+ "<div class=\"received_withd_msg\">" + "<p>"
994
								+ response[i].message + "</p>"
995
								+ "<span class=\"time_date\"> "
996
								+ response[i].createTimestamp.hour + ":"
997
								+ response[i].createTimestamp.minute + "|"
998
								+ response[i].createTimestamp.dayOfMonth + "/"
999
								+ response[i].createTimestamp.monthValue + "/"
1000
								+ response[i].createTimestamp.year
1001
								+ "</span></div>" + "</div>" + "</div>";
24471 govind 1002
						$(".activity-container .modal-body").append(
1003
								partnerMessage);
27149 amit.gupta 1004
					} else if (response[i].type == "COMMUNICATION_OUT") {
27141 amit.gupta 1005
						var assigneeMessage = "<div class=\"outgoing_msg\">"
1006
								+ "<div class=\"sent_msg\">"
1007
								+ "<span style=color:green>" + "~"
27165 amit.gupta 1008
								+ (response[i].name ? response[i].name : "Support") + "<p>"
27141 amit.gupta 1009
								+ response[i].message + "</span></p>"
1010
								+ "<span class=\"time_date\">"
1011
								+ response[i].createTimestamp.hour + ":"
1012
								+ response[i].createTimestamp.minute + "|"
1013
								+ response[i].createTimestamp.dayOfMonth + "/"
1014
								+ response[i].createTimestamp.monthValue + "/"
1015
								+ response[i].createTimestamp.year
1016
								+ "</span> </div>" + "</div>";
1017
					} else if (response[i].name
1018
							&& response[i].type == "COMMUNICATION_INTERNAL") {
1019
						var assigneeMessage = "<div class=\"outgoing_msg\">"
1020
								+ "<div class=\"sent_msg\">"
1021
								+ "<span style=color:green>"
1022
								+ "~"
1023
								+ response[i].name
1024
								+ "<p style=\"color: white;background: #b75454;\">"
1025
								+ response[i].message + "</span></p>"
1026
								+ "<span class=\"time_date\">"
1027
								+ response[i].createTimestamp.hour + ":"
1028
								+ response[i].createTimestamp.minute + "|"
1029
								+ response[i].createTimestamp.dayOfMonth + "/"
1030
								+ response[i].createTimestamp.monthValue + "/"
1031
								+ response[i].createTimestamp.year
1032
								+ "</span> </div>" + "</div>";
1033
					} else {
1034
						var assigneeMessage = "<div class=\"outgoing_msg\">"
1035
								+ "<div class=\"sent_msg\">" + "<p>"
1036
								+ response[i].message + "</span></p>"
1037
								+ "<span class=\"time_date\">"
1038
								+ response[i].createTimestamp.hour + ":"
1039
								+ response[i].createTimestamp.minute + "|"
1040
								+ response[i].createTimestamp.dayOfMonth + "/"
1041
								+ response[i].createTimestamp.monthValue + "/"
1042
								+ response[i].createTimestamp.year
1043
								+ "</span> </div>" + "</div>";
24417 govind 1044
					}
27141 amit.gupta 1045
					$(".activity-container .modal-body")
1046
							.append(assigneeMessage);
24417 govind 1047
				}
24824 govind 1048
				if (roleType == "true" || roleType == true) {
1049
					$('.internalCheckBox').css('display', 'block');
1050
					if (internal == true || internal == "true") {
1051
						$('#internalCommunication').prop('checked', true);
1052
					} else {
1053
						$('#internalCommunication').prop('checked', false);
1054
					}
1055
 
1056
				} else {
1057
					$('.internalCheckBox').css('display', 'none');
1058
				}
24417 govind 1059
			});
1060
}