Subversion Repositories SmartDukaan

Rev

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