Subversion Repositories SmartDukaan

Rev

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