Subversion Repositories SmartDukaan

Rev

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

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