Subversion Repositories SmartDukaan

Rev

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

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