Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
27410 tejbeer 1
var TEAM_ACTIVITY = ["COMMUNICATION_OUT", "COMMUNICATION_INTERNAL",
2
	"ESCALATED", "ASSIGNED", "CATEGORY_CHANGED"];
24417 govind 3
$(function() {
4
 
27754 amit.gupta 5
	$(document).on('click', ".create-ticket-category", function() {
24417 govind 6
		console.log("create ticket category clicked......");
7
		loadCreateCategory("main-content");
8
	});
27754 amit.gupta 9
	$(document).on('click', ".create-region", function() {
24417 govind 10
		loadCreateRegion("main-content");
11
	});
27755 amit.gupta 12
	$(document).on('click', "#manager-ticket-search-by-partner-name",
27410 tejbeer 13
		function() {
14
			var searchContent = $(this).data('id');
15
			var searchValue = $("#typeaheadpartnername").val();
16
			var searchType = $("#managersearchType").val();
17
			var managerTicketStatus = $("#managerTicketStatus").val();
18
			var managerTicketorderBy = $("#managerTicketorderBy").val();
19
			if (typeof (searchContent) == "undefined" || !searchContent) {
20
				searchContent = "";
21
			}
24747 govind 22
 
27410 tejbeer 23
			loadManagerTicket("main-content", managerTicketStatus,
24
				managerTicketorderBy, searchType, searchContent,
25
				searchValue);
24747 govind 26
 
27410 tejbeer 27
		});
27755 amit.gupta 28
	$(document).on('click', "#retailer-details-search-button-by-ticketId",
27410 tejbeer 29
		function() {
30
			var searchContent = $("#search-by-ticketId").val();
31
			var searchType = $("#managersearchType").val();
32
			var managerTicketStatus = $("#managerTicketStatus").val();
33
			var managerTicketorderBy = $("#managerTicketorderBy").val();
34
			if (typeof (searchContent) == "undefined" || !searchContent) {
35
				searchContent = "";
36
			}
37
			if (searchContent == "" || searchContent == undefined
38
				|| searchContent == null) {
39
				alert("Input field can't be empty");
40
				return false;
41
			}
42
			loadManagerTicket("main-content", managerTicketStatus,
43
				managerTicketorderBy, searchType, searchContent, null);
24747 govind 44
 
27410 tejbeer 45
		});
27755 amit.gupta 46
	$(document).on('click', "#assignee-ticket-search-by-partner-name",
27410 tejbeer 47
		function() {
48
			var searchContent = $(this).data('id');
49
			var searchValue = $("#typeaheadpartnernameforassignee").val();
50
			var searchType = $("#assigneesearchType").val();
51
			var ticketStatus = $("#ticketStatus").val();
52
			var ticketorderBy = $("#orderBy").val();
53
			console.log(ticketStatus);
54
			console.log(ticketorderBy);
55
			console.log(searchValue);
56
			if (typeof (searchContent) == "undefined" || !searchContent) {
57
				searchContent = "";
58
			}
24747 govind 59
 
27410 tejbeer 60
			loadMyTicket("main-content", ticketStatus, ticketorderBy,
61
				searchType, searchContent, searchValue);
24787 govind 62
 
27410 tejbeer 63
		});
27755 amit.gupta 64
	$(document).on('click', "#assignee-retailer-details-search-button-by-ticketId",
27410 tejbeer 65
		function() {
66
			var searchContent = $("#assignee-search-by-ticketId").val();
67
			var searchType = $("#assigneesearchType").val();
68
			var ticketStatus = $("#ticketStatus").val();
69
			var ticketorderBy = $("#orderBy").val();
70
			if (typeof (searchContent) == "undefined" || !searchContent) {
71
				searchContent = "";
72
			}
73
			if (searchContent == "" || searchContent == undefined
74
				|| searchContent == null) {
75
				alert("Input field can't be empty");
76
				return false;
77
			}
78
			console.log(ticketStatus);
79
			console.log(ticketorderBy);
80
			loadMyTicket("main-content", ticketStatus, ticketorderBy,
81
				searchType, searchContent, null);
24787 govind 82
 
27410 tejbeer 83
		});
24787 govind 84
 
27754 amit.gupta 85
	$(document).on('click', "#ticket-last-activity", function() {
24620 govind 86
		var ticketId = $(this).data('ticketid');
87
		var activity = $(this).data('activity');
88
		console.log(ticketId);
89
		console.log(activity);
24699 govind 90
		if (confirm("Are you sure!") == true) {
24620 govind 91
			createLastActivity(ticketId, activity);
92
		}
93
	});
24471 govind 94
 
27754 amit.gupta 95
	$(document).on('change', "#region", function() {
24620 govind 96
		var regionId = $("#region").val();
24557 govind 97
		console.log(regionId);
98
		loadPartnerForRegion(regionId);
99
	});
25570 tejbeer 100
 
27754 amit.gupta 101
	$(document).on('change', "#regionPosition", function() {
25570 tejbeer 102
		var regionId = $("#regionPosition").val();
103
		console.log(regionId);
104
		loadPartnerForRegionId(regionId);
105
	});
106
 
27754 amit.gupta 107
	$(document).on('change', "#managersearchType", function() {
24747 govind 108
		var searchType = $("#managersearchType").val();
109
		console.log(searchType);
110
		var html;
111
		if (searchType == "PARTNER_NAME") {
112
			$('.byPartnerName').css('display', 'inline-block');
113
			$('.byTicketId').css('display', 'none');
114
			$("#search-by-ticketId").val("");
115
		} else {
116
			$('.byPartnerName').css('display', 'none');
117
			$('.byTicketId').css('display', 'inline-block');
24824 govind 118
			$('#manager-ticket-search-by-partner-name').data('id', "");
24747 govind 119
		}
24557 govind 120
 
24747 govind 121
	});
27754 amit.gupta 122
	$(document).on('change', "#assigneesearchType", function() {
24787 govind 123
		var searchType = $("#assigneesearchType").val();
124
		console.log(searchType);
125
		var html;
126
		if (searchType == "PARTNER_NAME") {
127
			$('.assigneebyPartnerName').css('display', 'inline-block');
128
			$('.assigneebyTicketId').css('display', 'none');
129
			$("#assignee-search-by-ticketId").val("");
130
		} else {
131
			$('.assigneebyPartnerName').css('display', 'none');
132
			$('.assigneebyTicketId').css('display', 'inline-block');
24824 govind 133
			$("#assignee-ticket-search-by-partner-name").data('id', '');
24787 govind 134
		}
24747 govind 135
 
24787 govind 136
	});
137
 
31762 tejbeer 138
	$(document).on('click', ".change-ticket-auth-button",
139
		function() {
140
			var ticketId = $("#ticketId").val();
141
			var subCategory = $("#subCategory").val();
142
			var authUserId = $("#authUserCategory").val();
143
			var categoryId = $("#categoryAuth").val();
144
 
145
			var escalationType = $("#escalationType").val();
146
			console.log(ticketId);
147
			if (subCategory == null || subCategory == ""
148
				|| subCategory == undefined) {
149
				alert("Choose appropriate subCategory");
150
				return false;
151
			}
152
			console.log(subCategory);
153
			console.log(authUserId);
154
 
155
			console.log(categoryId);
156
 
157
			if (confirm("Are you sure you want to change ticket!") == true) {
158
				changeTicket(ticketId, subCategory, authUserId,
159
					categoryId, escalationType);
160
			}
161
		});
162
 
27755 amit.gupta 163
	$(document).on('click', ".change-ticket-button",
31762 tejbeer 164
		function() {
165
			var ticketId = $("#ticketId").val();
166
			var subCategory = $("#subCategory").val();
167
			var authUserId;
168
			var categoryId = $("#category").val();
169
 
170
			var escalationType = $("#escalationType").val();
171
			console.log(ticketId);
172
			if (subCategory == null || subCategory == ""
173
				|| subCategory == undefined) {
174
				alert("Choose appropriate subCategory");
175
				return false;
176
			}
177
 
178
			console.log(subCategory);
179
 
180
			console.log(categoryId);
181
			console.log(authUserId);
182
			if (confirm("Are you sure you want to change ticket!") == true) {
183
				changeTicket(ticketId, subCategory, authUserId,
184
					categoryId, escalationType);
185
			}
186
		});
27754 amit.gupta 187
	$(document).on('click', "#edit-ticket", function() {
24471 govind 188
		var ticketId = $(this).data('ticketid1');
24467 govind 189
		loadEditTicket(ticketId);
24439 govind 190
	});
27754 amit.gupta 191
	$(document).on('click', ".manager-ticket", function() {
24747 govind 192
		loadManagerTicket("main-content", null, null);
24439 govind 193
	});
27754 amit.gupta 194
	$(document).on('click', ".access-management", function() {
26014 amit.gupta 195
		loadAccessManagement("main-content", null, null);
196
	});
27754 amit.gupta 197
	$(document).on('click', ".ticketType", function() {
24534 govind 198
		console.log("create Region");
24417 govind 199
		loadCreateRegion("main-content");
200
	});
27754 amit.gupta 201
	$(document).on('click', "#activities", function() {
24417 govind 202
		var ticketId = $(this).data('ticketid');
203
		var assignee = $(this).data('assignee');
24824 govind 204
		var internal = $(this).data('internal');
205
		var roleType = $(this).data('role');
24417 govind 206
		console.log(assignee);
24824 govind 207
		loadActivities(ticketId, assignee, internal, roleType);
24417 govind 208
	});
27754 amit.gupta 209
	$(document).on('click', ".my-ticket", function() {
24824 govind 210
		loadMyTicket("main-content", null, null, null, null, null);
24417 govind 211
	});
27754 amit.gupta 212
	$(document).on('click', "#close-ticket", function() {
24417 govind 213
		var ticketId = $(this).data('ticketid');
24439 govind 214
		closeTicket(ticketId);
24417 govind 215
	});
27410 tejbeer 216
 
27754 amit.gupta 217
	$(document).on('change', '.partners', function() {
27410 tejbeer 218
		console.log("Hello");
219
	});
27270 tejbeer 220
	var documentIds = [];
221
	var count = 0;
222
 
27755 amit.gupta 223
	$(document).on('click', ".submit-message-button",
27410 tejbeer 224
		function() {
225
			var message = $("#activityMessage").val();
226
			var internal = $("#internalCommunication").prop("checked");
227
			if (message == "" || message == null || message == undefined) {
228
				alert("message field can't be empty");
229
				return false;
230
			}
231
			var ticketId = $("#ticketIdforactivity").val();
232
			var assignee = $("#assigneeUser").val();
233
			var roleType = $("#role").val();
234
			count = 0;
235
			console.log(message, ticketId, assignee);
27285 tejbeer 236
 
27410 tejbeer 237
			createActivity(message, ticketId, assignee, internal, roleType,
238
				documentIds);
239
		});
27270 tejbeer 240
 
27754 amit.gupta 241
	$(document).on('click', ".uploadFile", function() {
27270 tejbeer 242
		$("#file1").trigger('click');
24417 govind 243
	});
244
 
27755 amit.gupta 245
	$(document).on('change', "input[name=file1]",
31762 tejbeer 246
		function(evt) {
247
			var output = [];
248
			var fileBundle = [];
249
			for (var i = 0, f; f = evt.target.files[i]; i++) {
250
				count++;
251
				console.log(count);
252
				if (evt.target.files[i].size > 5000000) {
253
					alert("Size should be less than 5MB");
254
					return false;
255
				}
27270 tejbeer 256
 
31762 tejbeer 257
				if (count > "5") {
258
					alert("five files send at a time");
259
					var lilength = $('.fileList li').size();
260
					console.log(lilength);
261
					count = lilength;
262
					console.log(lilength)
263
					return false;
264
				}
27270 tejbeer 265
 
31762 tejbeer 266
				var file = evt.target.files[i];
267
				fileBundle.push(file);
268
				console.log(fileBundle);
27270 tejbeer 269
 
31762 tejbeer 270
				var removeLink = "<a class=\"removeFile\" href=\"#\" data-fileid=\""
271
					+ i + "\">Remove</a>";
27270 tejbeer 272
 
31762 tejbeer 273
				output.push("<li><strong>", file.name,
274
					"</strong> - ", "&nbsp; &nbsp; ",
275
					removeLink, "</li> ");
27270 tejbeer 276
 
31762 tejbeer 277
			}
27270 tejbeer 278
 
31762 tejbeer 279
			for (var j = 0; j < fileBundle.length; j++) {
280
				console.log(fileBundle[j])
281
				var url = context + '/document-upload';
282
				doAjaxUploadRequestHandler(
283
					url,
284
					'POST',
285
					fileBundle[j],
286
					function(response) {
287
						console.log(response);
288
						var documentId = response.response.document_id;
289
						console.log("documentId : "
290
							+ documentId);
291
						documentIds.push(documentId);
27270 tejbeer 292
 
31762 tejbeer 293
					});
27270 tejbeer 294
 
31762 tejbeer 295
			}
296
			console.log(documentIds);
297
			$(".fileList").append(output.join(""));
27270 tejbeer 298
 
31762 tejbeer 299
		});
27270 tejbeer 300
 
27754 amit.gupta 301
	$(document).on('click', ".removeFile", function(e) {
27270 tejbeer 302
		e.preventDefault();
27285 tejbeer 303
		console.log("Hello")
27270 tejbeer 304
		var fileId = $(this).parent().children("a").data("fileid");
27285 tejbeer 305
		for (var i = 0; i < documentIds.length; ++i) {
306
			if (documentIds[i].id === fileId)
307
				documentIds.splice(i, 1);
308
		}
309
		console.log(documentIds)
310
		$(this).parent().remove();
311
		var lilen = $('.fileList li').size();
27270 tejbeer 312
 
27285 tejbeer 313
		count = lilen;
314
		console.log(count)
315
		/*
316
		 * var lilength = $('.fileList li').size(); if (lilength == 1) {
317
		 * console.log(lilength) $(".fileList li").remove(); } else {
318
		 * console.log(lilength) $(".fileList li").eq(fileId).remove(); } var
319
		 * lilen = $('.fileList li').size();
320
		 * 
321
		 * count = lilen; console.log(count)
322
		 * 
323
		 * console.log(documentIds);
324
		 */
27270 tejbeer 325
 
326
	});
327
 
27755 amit.gupta 328
	$(document).on('click', "#tickets-paginated .next",
27410 tejbeer 329
		function() {
330
			var searchType = $("#assigneesearchType").val();
331
			var ticketStatus = $("#ticketStatus").val();
332
			var ticketStatus = $("#ticketStatus").val();
333
			var orderBy = $("#orderBy").val();
334
			var params;
335
			if (searchType == "" || searchType == undefined
336
				|| searchType == null || searchType == "TICKET_ID") {
337
				params = {
338
					"ticketStatus": ticketStatus,
339
					"orderby": orderBy
340
				};
341
			} else {
342
				var searchTerm = $("#assignee-partner-name-input").val();
343
				console.log(searchTerm);
344
				params = {
345
					"ticketStatus": ticketStatus,
346
					"orderby": orderBy,
347
					"ticketSearchType": searchType,
348
					"searchTerm": searchTerm
349
				};
350
			}
351
			loadPaginatedNextItems('/cs/myticketPaginated', params,
352
				'tickets-paginated', 'my-ticket-table',
353
				'ticket-details-container');
354
			$(this).blur();
355
		});
24417 govind 356
 
27755 amit.gupta 357
	$(document).on('click', "#manager-tickets-paginated .previous",
27410 tejbeer 358
		function() {
24747 govind 359
 
27410 tejbeer 360
			var ticketStatus = $("#managerTicketStatus").val();
361
			var orderBy = $("#managerTicketorderBy").val();
362
			var searchType = $("#managersearchType").val();
363
			var params;
364
			if (searchType == "" || searchType == undefined
365
				|| searchType == null || searchType == "TICKET_ID") {
366
				params = {
367
					"ticketStatus": ticketStatus,
368
					"orderby": orderBy
369
				};
370
			} else {
371
				var searchTerm = $("#partner-name-input").val();
372
				console.log(searchTerm);
373
				params = {
374
					"ticketStatus": ticketStatus,
375
					"orderby": orderBy,
376
					"ticketSearchType": searchType,
377
					"searchTerm": searchTerm
378
				};
379
			}
380
			loadPaginatedPreviousItems('/cs/managerTicket-paginated',
381
				params, 'manager-tickets-paginated',
382
				'manager-ticket-table',
383
				'manager-ticket-details-container');
384
			$(this).blur();
385
		});
27755 amit.gupta 386
	$(document).on('click', "#manager-tickets-paginated .next",
27410 tejbeer 387
		function() {
388
			var ticketStatus = $("#managerTicketStatus").val();
389
			var orderBy = $("#managerTicketorderBy").val();
390
			var searchType = $("#managersearchType").val();
391
			var params;
392
			if (searchType == "" || searchType == undefined
393
				|| searchType == null || searchType == "TICKET_ID") {
394
				params = {
395
					"ticketStatus": ticketStatus,
396
					"orderby": orderBy
397
				};
398
			} else {
399
				var searchTerm = $("#partner-name-input").val();
400
				console.log(searchTerm);
401
				params = {
402
					"ticketStatus": ticketStatus,
403
					"orderby": orderBy,
404
					"ticketSearchType": searchType,
405
					"searchTerm": searchTerm
406
				};
407
			}
24699 govind 408
 
27410 tejbeer 409
			loadPaginatedNextItems('/cs/managerTicket-paginated', params,
410
				'manager-tickets-paginated', 'manager-ticket-table',
411
				'manager-ticket-details-container');
412
			$(this).blur();
413
		});
24467 govind 414
 
27755 amit.gupta 415
	$(document).on('click', "#tickets-paginated .previous",
27410 tejbeer 416
		function() {
417
			var searchType = $("#assigneesearchType").val();
418
			var ticketStatus = $("#ticketStatus").val();
419
			var ticketStatus = $("#ticketStatus").val();
420
			var orderBy = $("#orderBy").val();
421
			var params;
422
			if (searchType == "" || searchType == undefined
423
				|| searchType == null || searchType == "TICKET_ID") {
424
				params = {
425
					"ticketStatus": ticketStatus,
426
					"orderby": orderBy
427
				};
428
			} else {
429
				var searchTerm = $("#assignee-partner-name-input").val();
430
				console.log(searchTerm);
431
				params = {
432
					"ticketStatus": ticketStatus,
433
					"orderby": orderBy,
434
					"ticketSearchType": searchType,
435
					"searchTerm": searchTerm
436
				};
437
			}
438
			loadPaginatedPreviousItems('/cs/myticketPaginated', params,
439
				'tickets-paginated', 'my-ticket-table',
440
				'ticket-details-container');
441
			$(this).blur();
442
		});
27755 amit.gupta 443
	$(document).on('click', "#positions-paginated .next",
27410 tejbeer 444
		function() {
445
			loadPaginatedNextItems('/cs/position-paginated', null,
446
				'positions-paginated', 'position-table',
447
				'position-details-container');
448
			$(this).blur();
449
		});
24417 govind 450
 
27755 amit.gupta 451
	$(document).on('click', "#positions-paginated .previous",
27410 tejbeer 452
		function() {
453
			loadPaginatedPreviousItems('/cs/position-paginated', null,
454
				'positions-paginated', 'position-table',
455
				'position-details-container');
456
			$(this).blur();
457
		});
24471 govind 458
 
27754 amit.gupta 459
	$(document).on('click', ".create-partner-region", function() {
24417 govind 460
		loadCreatePartnerRegion("main-content");
461
	});
27754 amit.gupta 462
	$(document).on('click', ".create-ticket", function() {
24417 govind 463
		loadCreateTicket("main-content");
464
	});
27755 amit.gupta 465
	$(document).on('click', ".create-ticket-button",
31762 tejbeer 466
		function() {
467
			var categoryId = $('#category').val();
468
			var subCategoryId = $('#subCategory').val();
469
			if (categoryId == "" || categoryId == null
470
				|| categoryId == undefined) {
471
				alert("select appropriate category");
472
				return false;
473
			}
474
			if (subCategoryId == "" || subCategoryId == null
475
				|| subCategoryId == undefined) {
476
				alert("select appropriate subCategoryId");
477
				return false;
478
			}
479
			var dialog = bootbox
480
				.dialog({
481
					title: "Are you sure want to change create ticket!",
482
					message: "<div class=form-inline'>"
483
						+ "<label for='message'>Message:</label>"
484
						+ "<textarea class='form-control' rows='2' id='message'></textarea>"
485
						+ "</div>",
486
					buttons: {
487
						cancel: {
488
							label: "cancel",
489
							className: 'btn-danger',
490
							callback: function() {
491
								loadCreateTicket("main-content");
492
							}
493
						},
494
						ok: {
495
							label: "ok",
496
							className: 'btn-info',
497
							callback: function() {
498
								message = $('#message').val();
499
								console.log(message);
500
								if (message == ""
501
									|| message == null
502
									|| message == undefined) {
503
									alert("message field can't be empty");
504
									return false;
27410 tejbeer 505
								}
31762 tejbeer 506
								var params = {
507
									"categoryId": categoryId,
508
									"subCategoryId": subCategoryId,
509
									"message": message
510
								}
511
								doPostAjaxRequestWithParamsHandler(
512
									context
513
									+ "/cs/createTicket",
514
									params,
515
									function(response) {
516
										if (response == "true") {
517
											alert("successfully created");
518
											loadCreateTicket("main-content");
519
										} else {
520
											alert("You have reached maximum number of tickets Resolved , pls click on Resolved for the resolved tickets to create new.");
521
										}
522
									});
24417 govind 523
 
27410 tejbeer 524
							}
525
						}
31762 tejbeer 526
					}
527
				});
24417 govind 528
 
31762 tejbeer 529
		});
27754 amit.gupta 530
	$(document).on('click', ".create-position", function() {
24417 govind 531
		loadCreatePosition("main-content");
532
	});
533
 
27754 amit.gupta 534
	$(document).on('click', ".positionPartnerView", function() {
27410 tejbeer 535
		$clickedElement = $(this);
536
		var positionId = $clickedElement.data("positionid");
537
		$tdElement = $(this).closest('td');
538
		doGetAjaxRequestHandler(context + "/cs/getPosition?positionId=" + positionId, function(response) {
31762 tejbeer 539
 
27410 tejbeer 540
			$tdElement.html(response);
541
			$tdElement.find('.partners').multiselect({
542
				includeSelectAllOption: true,
543
				multiple: true,
544
				maxHeight: 200,
545
				buttonWidth: '180px',
546
				numberDisplayed: 1,
547
				nonSelectedText: 'Partners',
548
				nSelectedText: ' - Users Selected',
549
				allSelectedText: 'All Users Selected',
550
				enableFiltering: true,
551
				enableCaseInsensitiveFiltering: true
552
			});
553
		});
554
	});
555
 
556
 
27755 amit.gupta 557
	$(document).on('change', "#ticketStatus",
27410 tejbeer 558
		function() {
559
			var ticketStatus = $("#ticketStatus").val();
560
			var orderBy = $("#orderBy").val();
561
			var searchType = $("#assigneesearchType").val();
562
			if (searchType == "" || searchType == undefined
563
				|| searchType == null) {
564
				loadMyTicket("main-content", ticketStatus, orderBy, null,
565
					null, null);
566
			} else {
567
				if (searchType == "PARTNER_NAME") {
568
					var searchTerm = $("#assignee-partner-name-input")
569
						.val();
570
					var searchValue = $("#typeaheadpartnernameforassignee")
571
						.val();
572
					loadMyTicket("main-content", ticketStatus, orderBy,
573
						searchType, searchTerm, searchValue);
24824 govind 574
				} else {
27410 tejbeer 575
					var searchTerm = $("#assignee-search-by-ticketId")
576
						.val();
577
					loadMyTicket("main-content", ticketStatus, orderBy,
578
						searchType, searchTerm, null);
24824 govind 579
				}
27410 tejbeer 580
			}
581
		});
27755 amit.gupta 582
	$(document).on('change', "#orderBy",
27410 tejbeer 583
		function() {
584
			var ticketStatus = $("#ticketStatus").val();
585
			var orderBy = $("#orderBy").val();
586
			var searchType = $("#assigneesearchType").val();
587
			if (searchType == "" || searchType == undefined
588
				|| searchType == null) {
589
				loadMyTicket("main-content", ticketStatus, orderBy, null,
590
					null, null);
591
			} else {
592
				if (searchType == "PARTNER_NAME") {
593
					var searchTerm = $("#assignee-partner-name-input")
594
						.val();
595
					var searchValue = $("#typeaheadpartnernameforassignee")
596
						.val();
597
					loadMyTicket("main-content", ticketStatus, orderBy,
598
						searchType, searchTerm, searchValue);
24824 govind 599
				} else {
27410 tejbeer 600
					var searchTerm = $("#assignee-search-by-ticketId")
601
						.val();
602
					loadMyTicket("main-content", ticketStatus, orderBy,
603
						searchType, searchTerm, null);
24824 govind 604
				}
27410 tejbeer 605
			}
606
		});
27755 amit.gupta 607
	$(document).on('change', "#managerTicketStatus",
27410 tejbeer 608
		function() {
609
			var ticketStatus = $("#managerTicketStatus").val();
610
			var orderBy = $("#managerTicketorderBy").val();
611
			var searchType = $("#managersearchType").val();
612
			if (searchType == "" || searchType == undefined
613
				|| searchType == null) {
614
				loadManagerTicket("main-content", ticketStatus, orderBy,
615
					null, null, null);
616
			} else {
617
				if (searchType == "PARTNER_NAME") {
618
					var searchTerm = $("#partner-name-input").val();
619
					var searchValue = $("#typeaheadpartnername").val();
620
					loadManagerTicket("main-content", ticketStatus,
621
						orderBy, searchType, searchTerm, searchValue);
24747 govind 622
				} else {
27410 tejbeer 623
					var searchTerm = $("#search-by-ticketId").val();
624
					loadManagerTicket("main-content", ticketStatus,
625
						orderBy, searchType, searchTerm, null);
24747 govind 626
				}
27410 tejbeer 627
			}
24747 govind 628
 
27410 tejbeer 629
		});
27755 amit.gupta 630
	$(document).on('change', "#managerTicketorderBy",
27410 tejbeer 631
		function() {
632
			var ticketStatus = $("#managerTicketStatus").val();
633
			var orderBy = $("#managerTicketorderBy").val();
634
			var searchType = $("#managersearchType").val();
635
			var searchType = $("#managersearchType").val();
636
			if (searchType == "" || searchType == undefined
637
				|| searchType == null) {
638
				loadManagerTicket("main-content", ticketStatus, orderBy,
639
					null, null, null);
640
			} else {
641
				if (searchType == "PARTNER_NAME") {
642
					var searchTerm = $("#partner-name-input").val();
643
					var searchValue = $("#typeaheadpartnername").val();
644
					loadManagerTicket("main-content", ticketStatus,
645
						orderBy, searchType, searchTerm, searchValue);
24747 govind 646
				} else {
27410 tejbeer 647
					var searchTerm = $("#search-by-ticketId").val();
648
					loadManagerTicket("main-content", ticketStatus,
649
						orderBy, searchType, searchTerm, null);
24747 govind 650
				}
27410 tejbeer 651
			}
24747 govind 652
 
27410 tejbeer 653
		});
27754 amit.gupta 654
	$(document).on('change', "#category", function() {
24417 govind 655
		var categoryId = $("#category").val();
31762 tejbeer 656
		//	$("#auth-user-for-category").hide();
24417 govind 657
		loadSubCategories(categoryId);
658
	});
31762 tejbeer 659
 
660
	$(document).on('change', "#authUserCategory", function() {
661
		var authId = $("#authUserCategory").val();
662
		console.log(authId)
663
		loadCategories(authId);
664
	});
665
 
666
	$(document).on('change', "#categoryAuth", function() {
667
		var categoryId = $("#categoryAuth").val();
668
		var authId = $("#authUserCategory").val();
669
 
670
		console.log(categoryId)
671
		loadAuthSubCategories(categoryId, authId);
672
	});
673
 
674
 
27755 amit.gupta 675
	$(document).on('click', ".create-ticket-category-button",
31762 tejbeer 676
		function() {
677
			console
678
				.log("create-ticket-category-button clicked......");
679
			var name = $("#categoryName").val();
680
			var description = $("#categorydescription").val();
681
			console.log(name, description);
682
			if (name == "" || name == null || name == undefined) {
683
				alert("Name field can't be empty");
684
				return false;
685
			}
686
			if (description == "" || description == null
687
				|| description == undefined) {
688
				alert("Description field can't be empty");
689
				return false;
690
			}
691
			if (confirm("Are you sure you want to create ticket category!") == true) {
692
				createCategory("main-content", name, description);
693
			}
694
		});
27755 amit.gupta 695
	$(document).on('click', ".create-region-button",
31762 tejbeer 696
		function() {
697
			var name = $("#regionName").val();
698
			var description = $("#regiondescription").val();
699
			if (name == "" || name == null || name == undefined) {
700
				alert("Name field can't be empty");
701
				return false;
702
			}
703
			if (description == "" || description == null
704
				|| description == undefined) {
705
				alert("Description field can't be empty");
706
				return false;
707
			}
708
			if (confirm("Are you sure you want to create region!") == true) {
709
				createRegion("main-content", name, description);
710
			}
711
		});
24417 govind 712
 
27755 amit.gupta 713
	$(document).on('click', ".create-partner-region-button",
31762 tejbeer 714
		function() {
24417 govind 715
 
31762 tejbeer 716
			var regionId = $("#region").val();
717
			var fofoIds = $("#partner").val();
718
			console.log(regionId, fofoIds);
719
			if (regionId == "" || regionId == null
720
				|| regionId == undefined) {
721
				alert("regionId field can't be empty");
722
				return false;
723
			}
724
			if (fofoIds == "" || fofoIds == null
725
				|| fofoIds == undefined) {
726
				alert("select appropriate partner");
727
				return false;
728
			}
729
			if (confirm("Are you sure you want to create partner region!") == true) {
730
				createPartnerRegion("main-content", regionId,
731
					fofoIds);
732
			}
733
		});
27755 amit.gupta 734
	$(document).on('click', ".create-position-button",
31762 tejbeer 735
		function() {
24417 govind 736
 
31762 tejbeer 737
			var authUser = $("#authUser").val();
738
			var ticketCategoryPosition = $(
739
				"#ticketCategoryPosition").val();
740
			var escalationType = $("#escalationType").val();
741
			var regionPosition = $("#regionPosition").val();
25570 tejbeer 742
 
31762 tejbeer 743
			var ticketAssignee = $("#ticketAssignee").val();
25570 tejbeer 744
 
31762 tejbeer 745
			var fofoIds = $("#partner").val();
746
			if (fofoIds.includes("0")) {
747
				fofoIds = [0];
748
				console.log(fofoIds);
749
			} else {
750
				console.log(fofoIds);
751
			}
752
			console.log(authUser, ticketCategoryPosition,
753
				escalationType, regionPosition);
754
			if (authUser == "" || authUser == null
755
				|| authUser == undefined) {
756
				alert("select appropriate authUser");
757
				return false;
758
			}
759
			if (ticketCategoryPosition == ""
760
				|| ticketCategoryPosition == null
761
				|| ticketCategoryPosition == undefined) {
762
				alert("select appropriate category");
763
				return false;
764
			}
765
			if (escalationType == "" || escalationType == null
766
				|| escalationType == undefined) {
767
				alert("select appropriate escalationType");
768
				return false;
769
			}
770
			if (regionPosition == "" || regionPosition == null
771
				|| regionPosition == undefined) {
772
				alert("select appropriate Region");
773
				return false;
774
			}
24417 govind 775
 
31762 tejbeer 776
			if (confirm("Are you sure you want to create Position!") == true) {
777
				createPosition("main-content", authUser,
778
					ticketCategoryPosition, escalationType,
779
					regionPosition, fofoIds, ticketAssignee);
780
			}
781
 
782
		});
783
 
27754 amit.gupta 784
	$(document).on('change', "#ticketCategory", function() {
24417 govind 785
		console.log("change ticket category clicked......");
786
		var ticketCategoryId = $(this).val();
787
		console.log(ticketCategoryId);
788
		loadticketSubCategoryById(ticketCategoryId);
789
	});
27754 amit.gupta 790
	$(document).on('click', ".create-ticket-sub-category", function() {
24417 govind 791
		console.log("create ticket category clicked......");
792
		loadCreateSubCategory("main-content");
793
	});
794
 
27755 amit.gupta 795
	$(document).on('click', ".create-ticket-sub-category-button",
31762 tejbeer 796
		function() {
797
			console
798
				.log("create-ticket-category-button clicked......");
799
			var name = $("#subcategoryName").val();
800
			var description = $("#subcategorydescription").val();
801
			var ticketCategoryId = $("#ticketCategory").val();
802
			console.log(name, description);
803
			if (name == "" || name == null || name == undefined) {
804
				alert("Name field can't be empty");
805
				return false;
806
			}
807
			if (description == "" || description == null
808
				|| description == undefined) {
809
				alert("Description field can't be empty");
810
				return false;
811
			}
812
			if (ticketCategoryId == "" || ticketCategoryId == null
813
				|| ticketCategoryId == undefined) {
814
				alert("select appropriate category name");
815
				return false;
816
			}
817
			if (confirm("Are you sure you want to create ticket category!") == true) {
818
				createSubCategory("main-content", name,
819
					description, ticketCategoryId);
820
			}
821
		});
27754 amit.gupta 822
	$(document).on('click', ".remove-position", function() {
24471 govind 823
		var positionId = $(this).data('positionid');
824
		if (confirm("Are you sure you want to remove position!") == true) {
24534 govind 825
			removePosition(positionId);
24471 govind 826
		}
827
	});
24417 govind 828
 
31762 tejbeer 829
 
830
	$(document).on('change', "#ticketAssign", function() {
831
		var positionId = $(this).data('positionid');
832
		if (confirm("Are you sure you want to change ticket Assignee !") == true) {
833
			doPostAjaxRequestHandler(context + "/cs/changeTicketAssignee?positionId="
834
				+ positionId, function(response) {
835
					if (response == "true") {
836
						alert("change successfully");
837
						loadCreatePosition("main-content");
838
					}
839
				});
840
		}
841
	});
842
 
843
 
844
 
845
 
27755 amit.gupta 846
	$(document).on('click', ".update-position",
31762 tejbeer 847
		function() {
848
			var positionId = $(this).data('positionid');
849
			var regionId = $(this).data('regionid');
850
			var row = $(this);
851
			var selectedFofoIds = $(this).closest("tr").find(
852
				'#partners').val();
853
			if (selectedFofoIds.includes("0")) {
854
				selectedFofoIds = [0];
855
				console.log(selectedFofoIds);
856
			} else {
857
				console.log(selectedFofoIds);
858
			}
859
			if (confirm("Are you sure you want to update the partners!") == true) {
860
				doPostAjaxRequestWithJsonHandler(context
861
					+ "/cs/updatePartnerPosition?regionId="
862
					+ regionId + "&positionId=" + positionId,
863
					JSON.stringify(selectedFofoIds), function(
864
						response) {
865
					if (response == "true") {
866
						alert("Update successfully");
867
						loadCreatePosition("main-content");
868
					}
869
				});
870
			}
25570 tejbeer 871
 
31762 tejbeer 872
		});
27410 tejbeer 873
 
24417 govind 874
});
875
 
876
function loadCreateCategory(domId) {
877
	doGetAjaxRequestHandler(context + "/cs/createCategory", function(response) {
878
		$('#' + domId).html(response);
879
	});
880
}
24534 govind 881
function removePosition(positionId) {
882
	doDeleteAjaxRequestHandler(context + "/cs/removePosition?positionId="
27410 tejbeer 883
		+ positionId, function(response) {
884
			if (response == "true") {
885
				alert("Position removed successfully");
886
				loadCreatePosition("main-content");
887
			}
888
		});
24471 govind 889
}
24417 govind 890
 
891
function loadCreateRegion(domId) {
892
	doGetAjaxRequestHandler(context + "/cs/createRegion", function(response) {
893
		$('#' + domId).html(response);
894
	});
895
}
24824 govind 896
function loadMyTicket(domId, ticketStatus, sortOrder, ticketSearchType,
27410 tejbeer 897
	searchTerm, searchValue) {
24620 govind 898
 
24699 govind 899
	if (ticketStatus == null && sortOrder == null) {
900
		doGetAjaxRequestHandler(context + "/cs/myticket", function(response) {
901
			$('#' + domId).html(response);
902
		});
24824 govind 903
	} else if (ticketSearchType == null) {
24699 govind 904
		doGetAjaxRequestHandler(context + "/cs/myticket?ticketStatus="
27410 tejbeer 905
			+ ticketStatus + "&orderby=" + sortOrder, function(response) {
906
				$('#' + domId).html(response);
907
			});
24824 govind 908
	} else {
909
		doGetAjaxRequestHandler(context + "/cs/myticket?ticketStatus="
27410 tejbeer 910
			+ ticketStatus + "&orderby=" + sortOrder + "&ticketSearchType="
911
			+ ticketSearchType + "&searchTerm=" + searchTerm, function(
24824 govind 912
				response) {
913
			$('#' + domId).html(response);
914
			if (ticketSearchType == "PARTNER_NAME") {
915
				$('.assigneebyPartnerName').css('display', 'inline-block');
916
				$('.assingeebyTicketId').css('display', 'none');
917
				$("#typeaheadpartnernameforassignee").val(searchValue);
918
				$("#assignee-partner-name-input").val(searchTerm);
919
			} else {
920
				$('.assigneebyPartnerName').css('display', 'none');
921
				$('.assigneebyTicketId').css('display', 'inline-block');
922
				$("#assignee-search-by-ticketId").val(searchTerm);
923
			}
24699 govind 924
		});
925
	}
24417 govind 926
}
927
 
928
function loadCreatePartnerRegion(domId) {
929
	doGetAjaxRequestHandler(context + "/cs/createPartnerRegion", function(
27410 tejbeer 930
		response) {
24417 govind 931
		$('#' + domId).html(response);
932
	});
933
}
934
function loadCreatePosition(domId) {
935
	doGetAjaxRequestHandler(context + "/cs/createPosition", function(response) {
936
		$('#' + domId).html(response);
937
	});
938
}
939
function loadSubCategories(categoryId) {
940
	doGetAjaxRequestHandler(context
27410 tejbeer 941
		+ "/cs/getSubCategoriesByCategoryId?categoryId=" + categoryId,
942
		function(response) {
943
			$('#' + "create-ticket-sub-categories").html(response);
944
		});
24417 govind 945
}
31762 tejbeer 946
 
947
function loadCategories(authId) {
948
	doGetAjaxRequestHandler(context
949
		+ "/cs/getCategoriesByAuthId?authId=" + authId,
950
		function(response) {
951
			$('#' + "create-tickets-categories-for-auth").html(response);
952
		});
953
}
954
 
955
function loadAuthSubCategories(categoryId, authId) {
956
	doGetAjaxRequestHandler(context
957
		+ "/cs/getSubCategoriesByCategoryId?categoryId=" + categoryId,
958
		function(response) {
959
			$('#' + "create-ticket-sub-categories-for-auth").html(response);
960
		});
961
 
962
 
963
	doGetAjaxRequestHandler(context
964
		+ "/cs/getEscalationTypeByCategoryId?categoryId=" + categoryId + "&authId=" + authId,
965
		function(response) {
966
			$('#' + "create-ticket-escalationType-for-auth").html(response);
967
		});
968
 
969
 
970
}
971
 
24417 govind 972
function createCategory(domId, name, description) {
973
	var params = {
27410 tejbeer 974
		"name": name,
975
		"description": description
24417 govind 976
	}
977
	doPostAjaxRequestWithParamsHandler(context + "/cs/createCategory", params,
27410 tejbeer 978
		function(response) {
979
			alert("Category created successfully");
980
			loadCreateCategory(domId);
981
		});
24417 govind 982
}
31762 tejbeer 983
function changeTicket(ticketId, subCategoryId, authUserId, categoryId, escalationType) {
24467 govind 984
	var params = {
27410 tejbeer 985
		"ticketId": ticketId,
986
		"subCategoryId": subCategoryId,
987
		"authUserId": authUserId,
31762 tejbeer 988
		"categoryId": categoryId,
989
		"escalationType": escalationType
24471 govind 990
	}
991
	doPostAjaxRequestWithParamsHandler(context + "/cs/edit-ticket", params,
27410 tejbeer 992
		function(response) {
993
			if (response == "true") {
994
				alert("Ticket changed successfully");
995
				loadManagerTicket("main-content", null, null, null, null,
996
					null);
997
			}
998
		});
24467 govind 999
}
24417 govind 1000
function createRegion(domId, name, description) {
1001
	var params = {
27410 tejbeer 1002
		"name": name,
1003
		"description": description
24417 govind 1004
	}
1005
	doPostAjaxRequestWithParamsHandler(context + "/cs/createRegion", params,
27410 tejbeer 1006
		function(response) {
1007
			if (response == "true") {
1008
				alert("Region created successfully");
1009
				loadCreateRegion(domId);
1010
			}
1011
		});
24417 govind 1012
}
1013
function loadCreateSubCategory(domId) {
1014
	doGetAjaxRequestHandler(context + "/cs/createSubCategory", function(
27410 tejbeer 1015
		response) {
24417 govind 1016
		$('#' + domId).html(response);
1017
	});
1018
}
24747 govind 1019
function loadManagerTicket(domId, ticketStatus, sortOrder, ticketSearchType,
27410 tejbeer 1020
	searchTerm, searchValue) {
24751 govind 1021
	if (ticketStatus == null && sortOrder == null) {
24747 govind 1022
		doGetAjaxRequestHandler(context + "/cs/managerTicket", function(
27410 tejbeer 1023
			response) {
24699 govind 1024
			$('#' + domId).html(response);
1025
		});
24824 govind 1026
	} else if (ticketSearchType == null) {
24747 govind 1027
		doGetAjaxRequestHandler(context + "/cs/managerTicket?ticketStatus="
27410 tejbeer 1028
			+ ticketStatus + "&orderby=" + sortOrder, function(response) {
1029
				$('#' + domId).html(response);
1030
			});
24824 govind 1031
	} else {
24751 govind 1032
		doGetAjaxRequestHandler(context + "/cs/managerTicket?ticketStatus="
27410 tejbeer 1033
			+ ticketStatus + "&orderby=" + sortOrder + "&ticketSearchType="
1034
			+ ticketSearchType + "&searchTerm=" + searchTerm, function(
24747 govind 1035
				response) {
1036
			$('#' + domId).html(response);
1037
			if (ticketSearchType == "PARTNER_NAME") {
1038
				$('.byPartnerName').css('display', 'inline-block');
1039
				$('.byTicketId').css('display', 'none');
24748 govind 1040
				$("#typeaheadpartnername").val(searchValue);
24747 govind 1041
				$("#partner-name-input").val(searchTerm);
1042
			} else {
1043
				$('.byPartnerName').css('display', 'none');
1044
				$('.byTicketId').css('display', 'inline-block');
1045
				$("#search-by-ticketId").val(searchTerm);
1046
			}
1047
		});
1048
	}
24439 govind 1049
}
24417 govind 1050
function loadCreateTicket(domId) {
1051
	doGetAjaxRequestHandler(context + "/cs/createTicket", function(response) {
1052
		$('#' + domId).html(response);
1053
	});
1054
}
1055
function loadticketSubCategoryById(ticketCategoryId) {
1056
	doGetAjaxRequestHandler(context
27410 tejbeer 1057
		+ "/cs/getSubCategoryByCategoryId?ticketCategoryId="
1058
		+ ticketCategoryId, function(response) {
1059
			$(".ticket-sub-category-container").html(response);
1060
		});
24417 govind 1061
}
1062
function createPartnerRegion(domId, regionId, fofoIds) {
1063
	doPostAjaxRequestWithJsonHandler(context
27410 tejbeer 1064
		+ "/cs/createPartnerRegion?regionId=" + regionId, JSON
24417 govind 1065
			.stringify(fofoIds), function(response) {
27410 tejbeer 1066
				if (response == "true") {
1067
					alert("added region to partner successfully");
1068
					loadCreatePartnerRegion(domId);
1069
				}
1070
			});
24417 govind 1071
}
1072
function createSubCategory(domId, name, description, categoryId) {
1073
	var params = {
27410 tejbeer 1074
		"categoryId": categoryId,
1075
		"name": name,
1076
		"description": description
24417 govind 1077
	}
1078
	doPostAjaxRequestWithParamsHandler(context + "/cs/createSubCategory",
27410 tejbeer 1079
		params, function(response) {
1080
			alert("Sub Category created successfully");
1081
			loadCreateSubCategory(domId);
1082
		});
24417 govind 1083
}
24620 govind 1084
function createLastActivity(ticketId, activity) {
1085
	var params = {
27410 tejbeer 1086
		"ticketId": ticketId,
1087
		"lastactivity": activity
24620 govind 1088
	}
1089
	doPostAjaxRequestWithParamsHandler(context + "/cs/create-last-activity",
27410 tejbeer 1090
		params, function(response) {
1091
			if (response == "true") {
1092
				alert("successfully mark last activity");
1093
				loadMyTicket("main-content", null, null);
1094
			}
1095
		});
24620 govind 1096
}
24439 govind 1097
 
25570 tejbeer 1098
function createPosition(domId, authUserId, categoryId, escalationType,
31762 tejbeer 1099
	regionId, fofoIds, ticketAssignee) {
25570 tejbeer 1100
 
1101
	var createPositionModel = {};
1102
	createPositionModel['authUserId'] = authUserId;
1103
	createPositionModel['categoryId'] = categoryId
1104
	createPositionModel['escalationType'] = escalationType;
1105
	createPositionModel['regionId'] = regionId,
31762 tejbeer 1106
 
1107
		createPositionModel['ticketAssigned'] = ticketAssignee,
27410 tejbeer 1108
		createPositionModel['fofoIds'] = fofoIds
25570 tejbeer 1109
 
1110
	console.log(createPositionModel);
1111
	doPostAjaxRequestWithJsonHandler(context + "/cs/createPosition", JSON
27410 tejbeer 1112
		.stringify(createPositionModel), function(response) {
1113
			if (response == "true") {
1114
				alert("Position created successfully");
1115
				loadCreatePosition(domId);
1116
			}
1117
		});
24417 govind 1118
}
27270 tejbeer 1119
function createActivity(message, ticketId, assigneeId, internal, roleType,
27410 tejbeer 1120
	documentIds) {
27270 tejbeer 1121
 
24417 govind 1122
	var params = {
27410 tejbeer 1123
		"message": message,
1124
		"ticketId": ticketId,
1125
		"assigneeId": assigneeId,
1126
		"internal": internal,
1127
		"documentIds": documentIds,
24417 govind 1128
	}
27270 tejbeer 1129
	if (documentIds.includes("0")) {
27410 tejbeer 1130
		documentIds = [0];
27270 tejbeer 1131
		console.log(documentIds);
1132
	} else {
1133
		console.log(documentIds);
1134
	}
1135
	console.log(JSON.stringify(documentIds))
1136
	doPostAjaxRequestWithJsonHandler(context + "/cs/createActivity?message="
27410 tejbeer 1137
		+ message + "&ticketId=" + ticketId + "&assigneeId=" + assigneeId
1138
		+ "&internal=" + internal, JSON.stringify(documentIds), function(
27270 tejbeer 1139
			response) {
1140
		response = JSON.parse(response);
1141
 
1142
		documentIds.splice(0, documentIds.length);
27285 tejbeer 1143
 
27270 tejbeer 1144
		console.log(documentIds)
27285 tejbeer 1145
		$(".fileList li").remove();
27270 tejbeer 1146
		var assigneeName = response.firstName;
1147
		loadActivities(ticketId, assigneeName, internal, roleType)
1148
	});
24417 govind 1149
}
24471 govind 1150
function loadEditTicket(ticketId) {
1151
	doGetAjaxRequestHandler(context + "/cs/edit-ticket?ticketId=" + ticketId,
27410 tejbeer 1152
		function(response) {
1153
			$("#theModal .modal-content").html(response);
27270 tejbeer 1154
 
27410 tejbeer 1155
		});
24467 govind 1156
}
24557 govind 1157
function loadPartnerForRegion(regionId) {
1158
	doGetAjaxRequestHandler(context + "/cs/getPartners?regionId=" + regionId,
27410 tejbeer 1159
		function(response) {
1160
			$("#partner-region-container").html(response);
1161
		});
24557 govind 1162
}
25570 tejbeer 1163
 
1164
function loadPartnerForRegionId(regionId) {
1165
	doGetAjaxRequestHandler(context + "/cs/getPartnersByRegion?regionId="
27410 tejbeer 1166
		+ regionId, function(response) {
1167
			$("#partner-subregion-container").html(response);
1168
		});
25570 tejbeer 1169
}
1170
 
26014 amit.gupta 1171
function loadAccessManagement(domId) {
27141 amit.gupta 1172
	doGetAjaxRequestHandler(context + "/admin/access-management", function(
27410 tejbeer 1173
		response) {
26014 amit.gupta 1174
		$('#' + domId).html(response);
1175
	});
1176
}
1177
 
24824 govind 1178
function loadActivities(ticketId, assignee, internal, roleType) {
24417 govind 1179
 
24469 govind 1180
	$(".activity-container .modal-body").empty();
24417 govind 1181
	$("#activityMessage").val("");
1182
	$("#ticketIdforactivity").val(ticketId);
24824 govind 1183
	$("#role").val(roleType);
27270 tejbeer 1184
	$(".activity-container .modal-title").html(
27410 tejbeer 1185
		"Activity history for Ticket Id " + ticketId)
24417 govind 1186
	console.log(ticketId);
1187
	doGetAjaxRequestHandler(
27410 tejbeer 1188
		context + "/cs/getActivities?ticketId=" + ticketId,
1189
		function(response) {
1190
			response = JSON.parse(response);
1191
			console.log(response);
27270 tejbeer 1192
 
27410 tejbeer 1193
			for (var i = 0; i < response.length; i++) {
1194
				console.log(response[i].activityAttachment.length);
1195
				var activityAttachment = []
1196
				var attachments = "";
1197
				if (response[i].activityAttachment.length > 0) {
31412 amit.gupta 1198
					response
27410 tejbeer 1199
					for (var j = 0; j < response[i].activityAttachment.length; j++) {
1200
						var assigneeAttachment = "<a href=\"javascript:void(0)\" style=\"color:#337ab7;float:right;\"onclick=\"downloadDocument("
1201
							+ response[i].activityAttachment[j].documentId
1202
							+ ",\`"
1203
							+ response[i].activityAttachment[j].documentName
1204
							+ "\`)\">"
1205
							+ response[i].activityAttachment[j].documentName
1206
							+ "&nbsp;<i class=\"fa fa-download\"></i>"
1207
							+ "</a>"
1208
						activityAttachment.push(assigneeAttachment);
27270 tejbeer 1209
					}
27410 tejbeer 1210
					attachments = activityAttachment.join("");
1211
					console.log(attachments);
1212
				}
1213
				if (response[i].type == "OPENED"
1214
					|| response[i].type == "COMMUNICATION_IN") {
24417 govind 1215
 
27410 tejbeer 1216
					var partnerMessage = "<div class=\"incoming_msg\">"
1217
						+ "<div class=\"received_msg\">"
1218
						+ "<div class=\"received_withd_msg\">" + "<p>"
1219
						+ response[i].message + "</p><div>"
1220
						+ `${attachments}`
1221
						+ "</div> <span class=\"time_date\"> "
31412 amit.gupta 1222
						+ moment(response[i].createTimestamp).format('DD/MM/YYYY, h:mm:ss a')
27410 tejbeer 1223
						+ "</span></div>" + "</div>" + "</div>";
1224
					$(".activity-container .modal-body").append(
1225
						partnerMessage);
27270 tejbeer 1226
 
27410 tejbeer 1227
				} else if (response[i].type == "COMMUNICATION_OUT") {
1228
					var assigneeMessage = "<div class=\"outgoing_msg\">"
1229
						+ "<div class=\"sent_msg\">"
1230
						+ "<span style=color:green>"
1231
						+ "~"
1232
						+ (response[i].name ? response[i].name
1233
							: "Support") + "<p>"
1234
						+ response[i].message + "</span> </p><div>"
1235
						+ `${attachments}`
1236
						+ "</div> <span class=\"time_date\">"
31412 amit.gupta 1237
						+ moment(response[i].createTimestamp).format('DD/MM/YYYY, h:mm:ss a')
27410 tejbeer 1238
						+ "</span> </div>" + "</div>";
1239
					$(".activity-container .modal-body").append(
1240
						assigneeMessage);
27270 tejbeer 1241
 
27410 tejbeer 1242
				} else if (response[i].name
1243
					&& response[i].type == "COMMUNICATION_INTERNAL") {
1244
					var assigneeMessage = "<div class=\"outgoing_msg\">"
1245
						+ "<div class=\"sent_msg\">"
1246
						+ "<span style=color:green>"
1247
						+ "~"
1248
						+ response[i].name
1249
						+ "<p style=\"color: white;background: #b75454;\">"
1250
						+ response[i].message + "</span> </p> <div>"
1251
						+ `${attachments}`
1252
						+ "</div> <span class=\"time_date\">"
31414 amit.gupta 1253
						+ moment(response[i].createTimestamp).format('DD/MM/YYYY, h:mm:ss a')
27410 tejbeer 1254
						+ "</span> </div>" + "</div>";
1255
					$(".activity-container .modal-body").append(
1256
						assigneeMessage);
27270 tejbeer 1257
 
27410 tejbeer 1258
				} else {
1259
					var assigneeMessage = "<div class=\"outgoing_msg\">"
1260
						+ "<div class=\"sent_msg\">" + "<p>"
1261
						+ response[i].message + "</span> </p> <div>"
1262
						+ `${attachments}`
1263
						+ "</div> <span class=\"time_date\">"
31414 amit.gupta 1264
						+ moment(response[i].createTimestamp).format('DD/MM/YYYY, h:mm:ss a')
27410 tejbeer 1265
						+ "</span> </div>" + "</div>";
1266
					$(".activity-container .modal-body").append(
1267
						assigneeMessage);
27270 tejbeer 1268
 
24417 govind 1269
				}
24824 govind 1270
 
27410 tejbeer 1271
			}
1272
			if (roleType == "true" || roleType == true) {
1273
				$('.internalCheckBox').css('display', 'block');
1274
				if (internal == true || internal == "true") {
1275
					$('#internalCommunication').prop('checked', true);
24824 govind 1276
				} else {
27410 tejbeer 1277
					$('#internalCommunication').prop('checked', false);
24824 govind 1278
				}
27410 tejbeer 1279
 
1280
			} else {
1281
				$('.internalCheckBox').css('display', 'none');
1282
			}
1283
		});
24417 govind 1284
}
27270 tejbeer 1285
 
1286
function downloadDocument(documentId, documentName) {
1287
	console.log(documentName)
1288
	doAjaxGetDownload(context + "/download?documentId=" + documentId,
27410 tejbeer 1289
		documentName);
27270 tejbeer 1290
}