Subversion Repositories SmartDukaan

Rev

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