Subversion Repositories SmartDukaan

Rev

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

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