Subversion Repositories SmartDukaan

Rev

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

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