Subversion Repositories SmartDukaan

Rev

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