Subversion Repositories SmartDukaan

Rev

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