Subversion Repositories SmartDukaan

Rev

Rev 31771 | Rev 33081 | 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
 
743
 
31771 tejbeer 744
			let ticketAssignee = $('#ticketAssignee').is(':checked');
745
 
746
 
747
			console.log(ticketAssignee);
31762 tejbeer 748
			var fofoIds = $("#partner").val();
749
			if (fofoIds.includes("0")) {
750
				fofoIds = [0];
751
				console.log(fofoIds);
752
			} else {
753
				console.log(fofoIds);
754
			}
755
			console.log(authUser, ticketCategoryPosition,
756
				escalationType, regionPosition);
757
			if (authUser == "" || authUser == null
758
				|| authUser == undefined) {
759
				alert("select appropriate authUser");
760
				return false;
761
			}
762
			if (ticketCategoryPosition == ""
763
				|| ticketCategoryPosition == null
764
				|| ticketCategoryPosition == undefined) {
765
				alert("select appropriate category");
766
				return false;
767
			}
768
			if (escalationType == "" || escalationType == null
769
				|| escalationType == undefined) {
770
				alert("select appropriate escalationType");
771
				return false;
772
			}
773
			if (regionPosition == "" || regionPosition == null
774
				|| regionPosition == undefined) {
775
				alert("select appropriate Region");
776
				return false;
777
			}
24417 govind 778
 
31762 tejbeer 779
			if (confirm("Are you sure you want to create Position!") == true) {
780
				createPosition("main-content", authUser,
781
					ticketCategoryPosition, escalationType,
31771 tejbeer 782
					regionPosition, fofoIds,
783
					ticketAssignee
784
				);
31762 tejbeer 785
			}
786
 
787
		});
788
 
27754 amit.gupta 789
	$(document).on('change', "#ticketCategory", function() {
24417 govind 790
		console.log("change ticket category clicked......");
791
		var ticketCategoryId = $(this).val();
792
		console.log(ticketCategoryId);
793
		loadticketSubCategoryById(ticketCategoryId);
794
	});
27754 amit.gupta 795
	$(document).on('click', ".create-ticket-sub-category", function() {
24417 govind 796
		console.log("create ticket category clicked......");
797
		loadCreateSubCategory("main-content");
798
	});
799
 
27755 amit.gupta 800
	$(document).on('click', ".create-ticket-sub-category-button",
31762 tejbeer 801
		function() {
802
			console
803
				.log("create-ticket-category-button clicked......");
804
			var name = $("#subcategoryName").val();
805
			var description = $("#subcategorydescription").val();
806
			var ticketCategoryId = $("#ticketCategory").val();
807
			console.log(name, description);
808
			if (name == "" || name == null || name == undefined) {
809
				alert("Name field can't be empty");
810
				return false;
811
			}
812
			if (description == "" || description == null
813
				|| description == undefined) {
814
				alert("Description field can't be empty");
815
				return false;
816
			}
817
			if (ticketCategoryId == "" || ticketCategoryId == null
818
				|| ticketCategoryId == undefined) {
819
				alert("select appropriate category name");
820
				return false;
821
			}
822
			if (confirm("Are you sure you want to create ticket category!") == true) {
823
				createSubCategory("main-content", name,
824
					description, ticketCategoryId);
825
			}
826
		});
27754 amit.gupta 827
	$(document).on('click', ".remove-position", function() {
24471 govind 828
		var positionId = $(this).data('positionid');
829
		if (confirm("Are you sure you want to remove position!") == true) {
24534 govind 830
			removePosition(positionId);
24471 govind 831
		}
832
	});
24417 govind 833
 
31762 tejbeer 834
 
835
	$(document).on('change', "#ticketAssign", function() {
836
		var positionId = $(this).data('positionid');
837
		if (confirm("Are you sure you want to change ticket Assignee !") == true) {
838
			doPostAjaxRequestHandler(context + "/cs/changeTicketAssignee?positionId="
839
				+ positionId, function(response) {
840
					if (response == "true") {
841
						alert("change successfully");
842
						loadCreatePosition("main-content");
843
					}
844
				});
845
		}
846
	});
847
 
848
 
849
 
850
 
27755 amit.gupta 851
	$(document).on('click', ".update-position",
31762 tejbeer 852
		function() {
853
			var positionId = $(this).data('positionid');
854
			var regionId = $(this).data('regionid');
855
			var row = $(this);
856
			var selectedFofoIds = $(this).closest("tr").find(
857
				'#partners').val();
858
			if (selectedFofoIds.includes("0")) {
859
				selectedFofoIds = [0];
860
				console.log(selectedFofoIds);
861
			} else {
862
				console.log(selectedFofoIds);
863
			}
864
			if (confirm("Are you sure you want to update the partners!") == true) {
865
				doPostAjaxRequestWithJsonHandler(context
866
					+ "/cs/updatePartnerPosition?regionId="
867
					+ regionId + "&positionId=" + positionId,
868
					JSON.stringify(selectedFofoIds), function(
869
						response) {
870
					if (response == "true") {
871
						alert("Update successfully");
32885 shampa 872
						//loadCreatePosition("main-content");
31762 tejbeer 873
					}
874
				});
875
			}
25570 tejbeer 876
 
31762 tejbeer 877
		});
27410 tejbeer 878
 
24417 govind 879
});
880
 
881
function loadCreateCategory(domId) {
882
	doGetAjaxRequestHandler(context + "/cs/createCategory", function(response) {
883
		$('#' + domId).html(response);
884
	});
885
}
24534 govind 886
function removePosition(positionId) {
887
	doDeleteAjaxRequestHandler(context + "/cs/removePosition?positionId="
27410 tejbeer 888
		+ positionId, function(response) {
889
			if (response == "true") {
890
				alert("Position removed successfully");
891
				loadCreatePosition("main-content");
892
			}
893
		});
24471 govind 894
}
24417 govind 895
 
896
function loadCreateRegion(domId) {
897
	doGetAjaxRequestHandler(context + "/cs/createRegion", function(response) {
898
		$('#' + domId).html(response);
899
	});
900
}
24824 govind 901
function loadMyTicket(domId, ticketStatus, sortOrder, ticketSearchType,
27410 tejbeer 902
	searchTerm, searchValue) {
24620 govind 903
 
24699 govind 904
	if (ticketStatus == null && sortOrder == null) {
905
		doGetAjaxRequestHandler(context + "/cs/myticket", function(response) {
906
			$('#' + domId).html(response);
907
		});
24824 govind 908
	} else if (ticketSearchType == null) {
24699 govind 909
		doGetAjaxRequestHandler(context + "/cs/myticket?ticketStatus="
27410 tejbeer 910
			+ ticketStatus + "&orderby=" + sortOrder, function(response) {
911
				$('#' + domId).html(response);
912
			});
24824 govind 913
	} else {
914
		doGetAjaxRequestHandler(context + "/cs/myticket?ticketStatus="
27410 tejbeer 915
			+ ticketStatus + "&orderby=" + sortOrder + "&ticketSearchType="
916
			+ ticketSearchType + "&searchTerm=" + searchTerm, function(
24824 govind 917
				response) {
918
			$('#' + domId).html(response);
919
			if (ticketSearchType == "PARTNER_NAME") {
920
				$('.assigneebyPartnerName').css('display', 'inline-block');
921
				$('.assingeebyTicketId').css('display', 'none');
922
				$("#typeaheadpartnernameforassignee").val(searchValue);
923
				$("#assignee-partner-name-input").val(searchTerm);
924
			} else {
925
				$('.assigneebyPartnerName').css('display', 'none');
926
				$('.assigneebyTicketId').css('display', 'inline-block');
927
				$("#assignee-search-by-ticketId").val(searchTerm);
928
			}
24699 govind 929
		});
930
	}
24417 govind 931
}
932
 
933
function loadCreatePartnerRegion(domId) {
934
	doGetAjaxRequestHandler(context + "/cs/createPartnerRegion", function(
27410 tejbeer 935
		response) {
24417 govind 936
		$('#' + domId).html(response);
937
	});
938
}
939
function loadCreatePosition(domId) {
940
	doGetAjaxRequestHandler(context + "/cs/createPosition", function(response) {
941
		$('#' + domId).html(response);
942
	});
943
}
944
function loadSubCategories(categoryId) {
945
	doGetAjaxRequestHandler(context
27410 tejbeer 946
		+ "/cs/getSubCategoriesByCategoryId?categoryId=" + categoryId,
947
		function(response) {
948
			$('#' + "create-ticket-sub-categories").html(response);
949
		});
24417 govind 950
}
31762 tejbeer 951
 
952
function loadCategories(authId) {
953
	doGetAjaxRequestHandler(context
954
		+ "/cs/getCategoriesByAuthId?authId=" + authId,
955
		function(response) {
956
			$('#' + "create-tickets-categories-for-auth").html(response);
957
		});
958
}
959
 
960
function loadAuthSubCategories(categoryId, authId) {
961
	doGetAjaxRequestHandler(context
962
		+ "/cs/getSubCategoriesByCategoryId?categoryId=" + categoryId,
963
		function(response) {
964
			$('#' + "create-ticket-sub-categories-for-auth").html(response);
965
		});
966
 
967
 
968
	doGetAjaxRequestHandler(context
969
		+ "/cs/getEscalationTypeByCategoryId?categoryId=" + categoryId + "&authId=" + authId,
970
		function(response) {
971
			$('#' + "create-ticket-escalationType-for-auth").html(response);
972
		});
973
 
974
 
975
}
976
 
24417 govind 977
function createCategory(domId, name, description) {
978
	var params = {
27410 tejbeer 979
		"name": name,
980
		"description": description
24417 govind 981
	}
982
	doPostAjaxRequestWithParamsHandler(context + "/cs/createCategory", params,
27410 tejbeer 983
		function(response) {
984
			alert("Category created successfully");
985
			loadCreateCategory(domId);
986
		});
24417 govind 987
}
31762 tejbeer 988
function changeTicket(ticketId, subCategoryId, authUserId, categoryId, escalationType) {
24467 govind 989
	var params = {
27410 tejbeer 990
		"ticketId": ticketId,
991
		"subCategoryId": subCategoryId,
992
		"authUserId": authUserId,
31762 tejbeer 993
		"categoryId": categoryId,
994
		"escalationType": escalationType
24471 govind 995
	}
996
	doPostAjaxRequestWithParamsHandler(context + "/cs/edit-ticket", params,
27410 tejbeer 997
		function(response) {
998
			if (response == "true") {
999
				alert("Ticket changed successfully");
1000
				loadManagerTicket("main-content", null, null, null, null,
1001
					null);
1002
			}
1003
		});
24467 govind 1004
}
24417 govind 1005
function createRegion(domId, name, description) {
1006
	var params = {
27410 tejbeer 1007
		"name": name,
1008
		"description": description
24417 govind 1009
	}
1010
	doPostAjaxRequestWithParamsHandler(context + "/cs/createRegion", params,
27410 tejbeer 1011
		function(response) {
1012
			if (response == "true") {
1013
				alert("Region created successfully");
1014
				loadCreateRegion(domId);
1015
			}
1016
		});
24417 govind 1017
}
1018
function loadCreateSubCategory(domId) {
1019
	doGetAjaxRequestHandler(context + "/cs/createSubCategory", function(
27410 tejbeer 1020
		response) {
24417 govind 1021
		$('#' + domId).html(response);
1022
	});
1023
}
24747 govind 1024
function loadManagerTicket(domId, ticketStatus, sortOrder, ticketSearchType,
27410 tejbeer 1025
	searchTerm, searchValue) {
24751 govind 1026
	if (ticketStatus == null && sortOrder == null) {
24747 govind 1027
		doGetAjaxRequestHandler(context + "/cs/managerTicket", function(
27410 tejbeer 1028
			response) {
24699 govind 1029
			$('#' + domId).html(response);
1030
		});
24824 govind 1031
	} else if (ticketSearchType == null) {
24747 govind 1032
		doGetAjaxRequestHandler(context + "/cs/managerTicket?ticketStatus="
27410 tejbeer 1033
			+ ticketStatus + "&orderby=" + sortOrder, function(response) {
1034
				$('#' + domId).html(response);
1035
			});
24824 govind 1036
	} else {
24751 govind 1037
		doGetAjaxRequestHandler(context + "/cs/managerTicket?ticketStatus="
27410 tejbeer 1038
			+ ticketStatus + "&orderby=" + sortOrder + "&ticketSearchType="
1039
			+ ticketSearchType + "&searchTerm=" + searchTerm, function(
24747 govind 1040
				response) {
1041
			$('#' + domId).html(response);
1042
			if (ticketSearchType == "PARTNER_NAME") {
1043
				$('.byPartnerName').css('display', 'inline-block');
1044
				$('.byTicketId').css('display', 'none');
24748 govind 1045
				$("#typeaheadpartnername").val(searchValue);
24747 govind 1046
				$("#partner-name-input").val(searchTerm);
1047
			} else {
1048
				$('.byPartnerName').css('display', 'none');
1049
				$('.byTicketId').css('display', 'inline-block');
1050
				$("#search-by-ticketId").val(searchTerm);
1051
			}
1052
		});
1053
	}
24439 govind 1054
}
24417 govind 1055
function loadCreateTicket(domId) {
1056
	doGetAjaxRequestHandler(context + "/cs/createTicket", function(response) {
1057
		$('#' + domId).html(response);
1058
	});
1059
}
1060
function loadticketSubCategoryById(ticketCategoryId) {
1061
	doGetAjaxRequestHandler(context
27410 tejbeer 1062
		+ "/cs/getSubCategoryByCategoryId?ticketCategoryId="
1063
		+ ticketCategoryId, function(response) {
1064
			$(".ticket-sub-category-container").html(response);
1065
		});
24417 govind 1066
}
1067
function createPartnerRegion(domId, regionId, fofoIds) {
1068
	doPostAjaxRequestWithJsonHandler(context
27410 tejbeer 1069
		+ "/cs/createPartnerRegion?regionId=" + regionId, JSON
24417 govind 1070
			.stringify(fofoIds), function(response) {
27410 tejbeer 1071
				if (response == "true") {
1072
					alert("added region to partner successfully");
1073
					loadCreatePartnerRegion(domId);
1074
				}
1075
			});
24417 govind 1076
}
1077
function createSubCategory(domId, name, description, categoryId) {
1078
	var params = {
27410 tejbeer 1079
		"categoryId": categoryId,
1080
		"name": name,
1081
		"description": description
24417 govind 1082
	}
1083
	doPostAjaxRequestWithParamsHandler(context + "/cs/createSubCategory",
27410 tejbeer 1084
		params, function(response) {
1085
			alert("Sub Category created successfully");
1086
			loadCreateSubCategory(domId);
1087
		});
24417 govind 1088
}
24620 govind 1089
function createLastActivity(ticketId, activity) {
1090
	var params = {
27410 tejbeer 1091
		"ticketId": ticketId,
1092
		"lastactivity": activity
24620 govind 1093
	}
1094
	doPostAjaxRequestWithParamsHandler(context + "/cs/create-last-activity",
27410 tejbeer 1095
		params, function(response) {
1096
			if (response == "true") {
1097
				alert("successfully mark last activity");
1098
				loadMyTicket("main-content", null, null);
1099
			}
1100
		});
24620 govind 1101
}
24439 govind 1102
 
25570 tejbeer 1103
function createPosition(domId, authUserId, categoryId, escalationType,
31762 tejbeer 1104
	regionId, fofoIds, ticketAssignee) {
25570 tejbeer 1105
 
1106
	var createPositionModel = {};
1107
	createPositionModel['authUserId'] = authUserId;
1108
	createPositionModel['categoryId'] = categoryId
1109
	createPositionModel['escalationType'] = escalationType;
1110
	createPositionModel['regionId'] = regionId,
31762 tejbeer 1111
 
1112
		createPositionModel['ticketAssigned'] = ticketAssignee,
27410 tejbeer 1113
		createPositionModel['fofoIds'] = fofoIds
25570 tejbeer 1114
 
1115
	console.log(createPositionModel);
1116
	doPostAjaxRequestWithJsonHandler(context + "/cs/createPosition", JSON
27410 tejbeer 1117
		.stringify(createPositionModel), function(response) {
1118
			if (response == "true") {
1119
				alert("Position created successfully");
1120
				loadCreatePosition(domId);
1121
			}
1122
		});
24417 govind 1123
}
27270 tejbeer 1124
function createActivity(message, ticketId, assigneeId, internal, roleType,
27410 tejbeer 1125
	documentIds) {
27270 tejbeer 1126
 
24417 govind 1127
	var params = {
27410 tejbeer 1128
		"message": message,
1129
		"ticketId": ticketId,
1130
		"assigneeId": assigneeId,
1131
		"internal": internal,
1132
		"documentIds": documentIds,
24417 govind 1133
	}
27270 tejbeer 1134
	if (documentIds.includes("0")) {
27410 tejbeer 1135
		documentIds = [0];
27270 tejbeer 1136
		console.log(documentIds);
1137
	} else {
1138
		console.log(documentIds);
1139
	}
1140
	console.log(JSON.stringify(documentIds))
1141
	doPostAjaxRequestWithJsonHandler(context + "/cs/createActivity?message="
27410 tejbeer 1142
		+ message + "&ticketId=" + ticketId + "&assigneeId=" + assigneeId
1143
		+ "&internal=" + internal, JSON.stringify(documentIds), function(
27270 tejbeer 1144
			response) {
1145
		response = JSON.parse(response);
1146
 
1147
		documentIds.splice(0, documentIds.length);
27285 tejbeer 1148
 
27270 tejbeer 1149
		console.log(documentIds)
27285 tejbeer 1150
		$(".fileList li").remove();
27270 tejbeer 1151
		var assigneeName = response.firstName;
1152
		loadActivities(ticketId, assigneeName, internal, roleType)
1153
	});
24417 govind 1154
}
24471 govind 1155
function loadEditTicket(ticketId) {
1156
	doGetAjaxRequestHandler(context + "/cs/edit-ticket?ticketId=" + ticketId,
27410 tejbeer 1157
		function(response) {
1158
			$("#theModal .modal-content").html(response);
27270 tejbeer 1159
 
27410 tejbeer 1160
		});
24467 govind 1161
}
24557 govind 1162
function loadPartnerForRegion(regionId) {
1163
	doGetAjaxRequestHandler(context + "/cs/getPartners?regionId=" + regionId,
27410 tejbeer 1164
		function(response) {
1165
			$("#partner-region-container").html(response);
1166
		});
24557 govind 1167
}
25570 tejbeer 1168
 
1169
function loadPartnerForRegionId(regionId) {
1170
	doGetAjaxRequestHandler(context + "/cs/getPartnersByRegion?regionId="
27410 tejbeer 1171
		+ regionId, function(response) {
1172
			$("#partner-subregion-container").html(response);
1173
		});
25570 tejbeer 1174
}
1175
 
26014 amit.gupta 1176
function loadAccessManagement(domId) {
27141 amit.gupta 1177
	doGetAjaxRequestHandler(context + "/admin/access-management", function(
27410 tejbeer 1178
		response) {
26014 amit.gupta 1179
		$('#' + domId).html(response);
1180
	});
1181
}
1182
 
24824 govind 1183
function loadActivities(ticketId, assignee, internal, roleType) {
24417 govind 1184
 
24469 govind 1185
	$(".activity-container .modal-body").empty();
24417 govind 1186
	$("#activityMessage").val("");
1187
	$("#ticketIdforactivity").val(ticketId);
24824 govind 1188
	$("#role").val(roleType);
27270 tejbeer 1189
	$(".activity-container .modal-title").html(
27410 tejbeer 1190
		"Activity history for Ticket Id " + ticketId)
24417 govind 1191
	console.log(ticketId);
1192
	doGetAjaxRequestHandler(
27410 tejbeer 1193
		context + "/cs/getActivities?ticketId=" + ticketId,
1194
		function(response) {
1195
			response = JSON.parse(response);
1196
			console.log(response);
27270 tejbeer 1197
 
27410 tejbeer 1198
			for (var i = 0; i < response.length; i++) {
1199
				console.log(response[i].activityAttachment.length);
1200
				var activityAttachment = []
1201
				var attachments = "";
1202
				if (response[i].activityAttachment.length > 0) {
31412 amit.gupta 1203
					response
27410 tejbeer 1204
					for (var j = 0; j < response[i].activityAttachment.length; j++) {
1205
						var assigneeAttachment = "<a href=\"javascript:void(0)\" style=\"color:#337ab7;float:right;\"onclick=\"downloadDocument("
1206
							+ response[i].activityAttachment[j].documentId
1207
							+ ",\`"
1208
							+ response[i].activityAttachment[j].documentName
1209
							+ "\`)\">"
1210
							+ response[i].activityAttachment[j].documentName
1211
							+ "&nbsp;<i class=\"fa fa-download\"></i>"
1212
							+ "</a>"
1213
						activityAttachment.push(assigneeAttachment);
27270 tejbeer 1214
					}
27410 tejbeer 1215
					attachments = activityAttachment.join("");
1216
					console.log(attachments);
1217
				}
1218
				if (response[i].type == "OPENED"
1219
					|| response[i].type == "COMMUNICATION_IN") {
24417 govind 1220
 
27410 tejbeer 1221
					var partnerMessage = "<div class=\"incoming_msg\">"
1222
						+ "<div class=\"received_msg\">"
1223
						+ "<div class=\"received_withd_msg\">" + "<p>"
1224
						+ response[i].message + "</p><div>"
1225
						+ `${attachments}`
1226
						+ "</div> <span class=\"time_date\"> "
31412 amit.gupta 1227
						+ moment(response[i].createTimestamp).format('DD/MM/YYYY, h:mm:ss a')
27410 tejbeer 1228
						+ "</span></div>" + "</div>" + "</div>";
1229
					$(".activity-container .modal-body").append(
1230
						partnerMessage);
27270 tejbeer 1231
 
27410 tejbeer 1232
				} else if (response[i].type == "COMMUNICATION_OUT") {
1233
					var assigneeMessage = "<div class=\"outgoing_msg\">"
1234
						+ "<div class=\"sent_msg\">"
1235
						+ "<span style=color:green>"
1236
						+ "~"
1237
						+ (response[i].name ? response[i].name
1238
							: "Support") + "<p>"
1239
						+ response[i].message + "</span> </p><div>"
1240
						+ `${attachments}`
1241
						+ "</div> <span class=\"time_date\">"
31412 amit.gupta 1242
						+ moment(response[i].createTimestamp).format('DD/MM/YYYY, h:mm:ss a')
27410 tejbeer 1243
						+ "</span> </div>" + "</div>";
1244
					$(".activity-container .modal-body").append(
1245
						assigneeMessage);
27270 tejbeer 1246
 
27410 tejbeer 1247
				} else if (response[i].name
1248
					&& response[i].type == "COMMUNICATION_INTERNAL") {
1249
					var assigneeMessage = "<div class=\"outgoing_msg\">"
1250
						+ "<div class=\"sent_msg\">"
1251
						+ "<span style=color:green>"
1252
						+ "~"
1253
						+ response[i].name
1254
						+ "<p style=\"color: white;background: #b75454;\">"
1255
						+ response[i].message + "</span> </p> <div>"
1256
						+ `${attachments}`
1257
						+ "</div> <span class=\"time_date\">"
31414 amit.gupta 1258
						+ moment(response[i].createTimestamp).format('DD/MM/YYYY, h:mm:ss a')
27410 tejbeer 1259
						+ "</span> </div>" + "</div>";
1260
					$(".activity-container .modal-body").append(
1261
						assigneeMessage);
27270 tejbeer 1262
 
27410 tejbeer 1263
				} else {
1264
					var assigneeMessage = "<div class=\"outgoing_msg\">"
1265
						+ "<div class=\"sent_msg\">" + "<p>"
1266
						+ response[i].message + "</span> </p> <div>"
1267
						+ `${attachments}`
1268
						+ "</div> <span class=\"time_date\">"
31414 amit.gupta 1269
						+ moment(response[i].createTimestamp).format('DD/MM/YYYY, h:mm:ss a')
27410 tejbeer 1270
						+ "</span> </div>" + "</div>";
1271
					$(".activity-container .modal-body").append(
1272
						assigneeMessage);
27270 tejbeer 1273
 
24417 govind 1274
				}
24824 govind 1275
 
27410 tejbeer 1276
			}
1277
			if (roleType == "true" || roleType == true) {
1278
				$('.internalCheckBox').css('display', 'block');
1279
				if (internal == true || internal == "true") {
1280
					$('#internalCommunication').prop('checked', true);
24824 govind 1281
				} else {
27410 tejbeer 1282
					$('#internalCommunication').prop('checked', false);
24824 govind 1283
				}
27410 tejbeer 1284
 
1285
			} else {
1286
				$('.internalCheckBox').css('display', 'none');
1287
			}
1288
		});
24417 govind 1289
}
27270 tejbeer 1290
 
1291
function downloadDocument(documentId, documentName) {
1292
	console.log(documentName)
1293
	doAjaxGetDownload(context + "/download?documentId=" + documentId,
27410 tejbeer 1294
		documentName);
27270 tejbeer 1295
}