Subversion Repositories SmartDukaan

Rev

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