Subversion Repositories SmartDukaan

Rev

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