Subversion Repositories SmartDukaan

Rev

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