Subversion Repositories SmartDukaan

Rev

Rev 24471 | Rev 24534 | 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
	});
24471 govind 10
 
11
	$(".change-ticket-button")
12
			.live(
13
					'click',
14
					function() {
15
						var ticketId = $("#ticketId").val();
16
						var subCategory = $("#subCategory").val();
17
						var authUserId = $("#authUser").val();
24500 govind 18
						var categoryId= $("#category").val();
24471 govind 19
						console.log(ticketId);
20
						if (subCategory == null || subCategory == ""
21
								|| subCategory == undefined) {
22
							alert("Choose appropriate subCategory");
24500 govind 23
							return false;
24471 govind 24
						}
24500 govind 25
						console.log(authUserId);
24471 govind 26
						if (confirm("Are you sure you want to change ticket!") == true) {
24500 govind 27
							changeTicket(ticketId, subCategory, authUserId,categoryId);
24471 govind 28
						}
29
					});
24439 govind 30
	$("#edit-ticket").live('click', function() {
24471 govind 31
 
32
		var ticketId = $(this).data('ticketid1');
24467 govind 33
		console.log(ticketId);
34
		loadEditTicket(ticketId);
24439 govind 35
	});
36
	$(".manager-ticket").live('click', function() {
37
		loadManagerTicket("main-content");
38
	});
24417 govind 39
	$(".ticketType").live('click', function() {
40
		loadCreateRegion("main-content");
41
	});
24469 govind 42
	$("#activities").live('click', function() {
24417 govind 43
		var ticketId = $(this).data('ticketid');
44
		var assignee = $(this).data('assignee');
45
		console.log(assignee);
46
		loadActivities(ticketId, assignee);
47
	});
48
	$(".my-ticket").live('click', function() {
49
		loadMyTicket("main-content");
50
	});
51
	$("#close-ticket").live('click', function() {
52
		var ticketId = $(this).data('ticketid');
24439 govind 53
		closeTicket(ticketId);
24417 govind 54
	});
55
	$(".submit-message-button").live('click', function() {
56
		var message = $("#activityMessage").val();
57
		if (message == "" || message == null || message == undefined) {
58
			alert("message field can't be empty");
24500 govind 59
			return false;
24417 govind 60
		}
61
		var ticketId = $("#ticketIdforactivity").val();
62
		var assignee = $("#assigneeUser").val();
63
		console.log(message, ticketId, assignee);
64
		createActivity(message, ticketId, assignee);
65
	});
66
 
67
	$("#tickets-paginated .next").live(
68
			'click',
69
			function() {
70
				loadPaginatedNextItems('/cs/myticketPaginated', null,
71
						'tickets-paginated', 'my-ticket-table',
72
						'ticket-details-container');
73
				$(this).blur();
74
			});
75
 
24467 govind 76
	$("#manager-tickets-paginated .previous").live(
77
			'click',
78
			function() {
79
				loadPaginatedPreviousItems('/cs/managerTicket-paginated', null,
80
						'manager-tickets-paginated', 'manager-ticket-table',
81
						'manager-ticket-details-container');
82
				$(this).blur();
83
			});
84
	$("#manager-tickets-paginated .next").live(
85
			'click',
86
			function() {
87
				loadPaginatedNextItems('/cs/managerTicket-paginated', null,
88
						'manager-tickets-paginated', 'manager-ticket-table',
89
						'manager-ticket-details-container');
90
				$(this).blur();
91
			});
92
 
24417 govind 93
	$("#tickets-paginated .previous").live(
94
			'click',
95
			function() {
96
				loadPaginatedPreviousItems('/cs/myticketPaginated', null,
97
						'tickets-paginated', 'my-ticket-table',
98
						'ticket-details-container');
24467 govind 99
				$(this).blur();
24417 govind 100
			});
24471 govind 101
	$("#positions-paginated .next").live(
102
			'click',
103
			function() {
104
				loadPaginatedNextItems('/cs/position-paginated', null,
105
						'positions-paginated', 'position-table',
106
						'position-details-container');
107
				$(this).blur();
108
			});
24417 govind 109
 
24471 govind 110
	$("#positions-paginated .previous").live(
111
			'click',
112
			function() {
113
				loadPaginatedPreviousItems('/cs/position-paginated', null,
114
						'positions-paginated', 'position-table',
115
						'position-details-container');
116
				$(this).blur();
117
			});
118
 
24417 govind 119
	$(".create-partner-region").live('click', function() {
120
		loadCreatePartnerRegion("main-content");
121
	});
122
	$(".create-ticket").live('click', function() {
123
		loadCreateTicket("main-content");
124
	});
125
	$(".create-ticket-button")
126
			.live(
127
					'click',
128
					function() {
129
						var categoryId = $('#category').val();
130
						var subCategoryId = $('#subCategory').val();
131
						if (categoryId == "" || categoryId == null
132
								|| categoryId == undefined) {
133
							alert("select appropriate category");
134
							return false;
135
						}
136
						if (subCategoryId == "" || subCategoryId == null
137
								|| subCategoryId == undefined) {
138
							alert("select appropriate subCategoryId");
139
							return false;
140
						}
141
						var dialog = bootbox
142
								.dialog({
143
									title : "Are you sure want to change create ticket!",
144
									message : "<div class=form-inline'>"
145
											+ "<label for='message'>Message:</label>"
146
											+ "<textarea class='form-control' rows='2' id='message'></textarea>"
147
											+ "</div>",
148
									buttons : {
149
										cancel : {
150
											label : "cancel",
151
											className : 'btn-danger',
152
											callback : function() {
153
												loadCreateTicket("main-content");
154
											}
155
										},
156
										ok : {
157
											label : "ok",
158
											className : 'btn-info',
159
											callback : function() {
160
												message = $('#message').val();
161
												console.log(message);
162
												if (message == ""
163
														|| message == null
164
														|| message == undefined) {
165
													alert("message field can't be empty");
166
													return false;
167
												}
168
												var params = {
169
													"categoryId" : categoryId,
170
													"subCategoryId" : subCategoryId,
171
													"message" : message
172
												}
173
												doPostAjaxRequestWithParamsHandler(
174
														context
175
																+ "/cs/createTicket",
176
														params,
177
														function(response) {
178
															if (response == "true") {
179
																alert("successfully created");
180
																loadCreateTicket("main-content");
181
															}
182
														});
183
 
184
											}
185
										}
186
									}
187
								});
188
 
189
					});
190
	$(".create-position").live('click', function() {
191
		loadCreatePosition("main-content");
192
	});
193
 
194
	$("#category").live('change', function() {
195
		var categoryId = $("#category").val();
24500 govind 196
		$("#auth-user-for-category").hide();
24417 govind 197
		loadSubCategories(categoryId);
198
	});
199
	$(".create-ticket-category-button")
200
			.live(
201
					'click',
202
					function() {
203
						console
204
								.log("create-ticket-category-button clicked......");
205
						var name = $("#categoryName").val();
206
						var description = $("#categorydescription").val();
207
						console.log(name, description);
208
						if (name == "" || name == null || name == undefined) {
209
							alert("Name field can't be empty");
210
							return false;
211
						}
212
						if (description == "" || description == null
213
								|| description == undefined) {
214
							alert("Description field can't be empty");
215
							return false;
216
						}
217
						if (confirm("Are you sure you want to create ticket category!") == true) {
218
							createCategory("main-content", name, description);
219
						}
220
					});
221
	$(".create-region-button")
222
			.live(
223
					'click',
224
					function() {
225
						var name = $("#regionName").val();
226
						var description = $("#regiondescription").val();
227
						if (name == "" || name == null || name == undefined) {
228
							alert("Name field can't be empty");
229
							return false;
230
						}
231
						if (description == "" || description == null
232
								|| description == undefined) {
233
							alert("Description field can't be empty");
234
							return false;
235
						}
236
						if (confirm("Are you sure you want to create region!") == true) {
237
							createRegion("main-content", name, description);
238
						}
239
					});
240
 
241
	$(".create-partner-region-button")
242
			.live(
243
					'click',
244
					function() {
245
 
246
						var regionId = $("#region").val();
247
						var fofoIds = $("#partner").val();
248
						console.log(regionId, fofoIds);
249
						if (regionId == "" || regionId == null
250
								|| regionId == undefined) {
251
							alert("regionId field can't be empty");
252
							return false;
253
						}
254
						if (fofoIds == "" || fofoIds == null
255
								|| fofoIds == undefined) {
256
							alert("select appropriate partner");
257
							return false;
258
						}
259
						if (confirm("Are you sure you want to create partner region!") == true) {
260
							createPartnerRegion("main-content", regionId,
261
									fofoIds);
262
						}
263
					});
264
	$(".create-position-button")
265
			.live(
266
					'click',
267
					function() {
268
 
269
						var authUser = $("#authUser").val();
270
						var ticketCategoryPosition = $(
271
								"#ticketCategoryPosition").val();
272
						var escalationType = $("#escalationType").val();
273
						var regionPosition = $("#regionPosition").val();
274
						console.log(authUser, ticketCategoryPosition,
275
								escalationType, regionPosition);
276
						if (authUser == "" || authUser == null
277
								|| authUser == undefined) {
278
							alert("select appropriate authUser");
279
							return false;
280
						}
281
						if (ticketCategoryPosition == ""
282
								|| ticketCategoryPosition == null
283
								|| ticketCategoryPosition == undefined) {
284
							alert("select appropriate category");
285
							return false;
286
						}
287
						if (escalationType == "" || escalationType == null
288
								|| escalationType == undefined) {
289
							alert("select appropriate escalationType");
290
							return false;
291
						}
292
						if (regionPosition == "" || regionPosition == null
293
								|| regionPosition == undefined) {
294
							alert("select appropriate Region");
295
							return false;
296
						}
297
						if (confirm("Are you sure you want to create Position!") == true) {
298
							createPosition("main-content", authUser,
299
									ticketCategoryPosition, escalationType,
300
									regionPosition);
301
						}
302
					});
303
 
304
	$("#ticketCategory").live('change', function() {
305
		console.log("change ticket category clicked......");
306
		var ticketCategoryId = $(this).val();
307
		console.log(ticketCategoryId);
308
		loadticketSubCategoryById(ticketCategoryId);
309
	});
310
	$(".create-ticket-sub-category").live('click', function() {
311
		console.log("create ticket category clicked......");
312
		loadCreateSubCategory("main-content");
313
	});
314
 
315
	$(".create-ticket-sub-category-button")
316
			.live(
317
					'click',
318
					function() {
319
						console
320
								.log("create-ticket-category-button clicked......");
321
						var name = $("#subcategoryName").val();
322
						var description = $("#subcategorydescription").val();
323
						var ticketCategoryId = $("#ticketCategory").val();
324
						console.log(name, description);
325
						if (name == "" || name == null || name == undefined) {
326
							alert("Name field can't be empty");
327
							return false;
328
						}
329
						if (description == "" || description == null
330
								|| description == undefined) {
331
							alert("Description field can't be empty");
332
							return false;
333
						}
334
						if (ticketCategoryId == "" || ticketCategoryId == null
335
								|| ticketCategoryId == undefined) {
336
							alert("select appropriate category name");
337
							return false;
338
						}
339
						if (confirm("Are you sure you want to create ticket category!") == true) {
340
							createSubCategory("main-content", name,
341
									description, ticketCategoryId);
342
						}
343
					});
24471 govind 344
	$(".remove-position").live('click', function() {
345
		var positionId = $(this).data('positionid');
346
		if (confirm("Are you sure you want to remove position!") == true) {
347
		removePosition(positionId);
348
		}
349
	});
24417 govind 350
 
351
});
352
 
353
function loadCreateCategory(domId) {
354
	doGetAjaxRequestHandler(context + "/cs/createCategory", function(response) {
355
		$('#' + domId).html(response);
356
	});
357
}
24471 govind 358
function removePosition(positionId)
359
{
360
	doDeleteAjaxRequestHandler(context + "/cs/removePosition?positionId="+positionId, function(response) {
361
		if (response == "true") {
362
			alert("Position removed successfully");
363
			loadCreatePosition("main-content");
364
		}
365
	});
366
}
24417 govind 367
 
368
function loadCreateRegion(domId) {
369
	doGetAjaxRequestHandler(context + "/cs/createRegion", function(response) {
370
		$('#' + domId).html(response);
371
	});
372
}
373
function loadMyTicket(domId) {
374
	doGetAjaxRequestHandler(context + "/cs/myticket", function(response) {
375
		$('#' + domId).html(response);
376
	});
377
}
378
 
379
function loadCreatePartnerRegion(domId) {
380
	doGetAjaxRequestHandler(context + "/cs/createPartnerRegion", function(
381
			response) {
382
		$('#' + domId).html(response);
383
	});
384
}
385
function loadCreatePosition(domId) {
386
	doGetAjaxRequestHandler(context + "/cs/createPosition", function(response) {
387
		$('#' + domId).html(response);
388
	});
389
}
390
function loadSubCategories(categoryId) {
391
	doGetAjaxRequestHandler(context
392
			+ "/cs/getSubCategoriesByCategoryId?categoryId=" + categoryId,
393
			function(response) {
394
				$('#' + "create-ticket-sub-categories").html(response);
395
			});
396
}
397
function createCategory(domId, name, description) {
398
	var params = {
399
		"name" : name,
400
		"description" : description
401
	}
402
	doPostAjaxRequestWithParamsHandler(context + "/cs/createCategory", params,
403
			function(response) {
404
				alert("Category created successfully");
405
				loadCreateCategory(domId);
406
			});
407
}
24500 govind 408
function changeTicket(ticketId, subCategoryId, authUserId,categoryId) {
24467 govind 409
	var params = {
24471 govind 410
		"ticketId" : ticketId,
411
		"subCategoryId" : subCategoryId,
24500 govind 412
		"authUserId" : authUserId,
413
		"categoryId":categoryId
24471 govind 414
	}
415
	doPostAjaxRequestWithParamsHandler(context + "/cs/edit-ticket", params,
416
			function(response) {
417
				if (response == "true") {
418
					alert("Ticket changed successfully");
419
					loadManagerTicket("main-content");
420
				}
421
			});
24467 govind 422
}
24417 govind 423
function createRegion(domId, name, description) {
424
	var params = {
425
		"name" : name,
426
		"description" : description
427
	}
428
	doPostAjaxRequestWithParamsHandler(context + "/cs/createRegion", params,
429
			function(response) {
430
				if (response == "true") {
431
					alert("Region created successfully");
432
					loadCreateRegion(domId);
433
				}
434
			});
435
}
436
function loadCreateSubCategory(domId) {
437
	doGetAjaxRequestHandler(context + "/cs/createSubCategory", function(
438
			response) {
439
		$('#' + domId).html(response);
440
	});
441
}
24471 govind 442
function loadManagerTicket(domId) {
443
	doGetAjaxRequestHandler(context + "/cs/managerTicket", function(response) {
24439 govind 444
		$('#' + domId).html(response);
445
	});
446
}
24417 govind 447
function loadCreateTicket(domId) {
448
	doGetAjaxRequestHandler(context + "/cs/createTicket", function(response) {
449
		$('#' + domId).html(response);
450
	});
451
}
452
function loadticketSubCategoryById(ticketCategoryId) {
453
	doGetAjaxRequestHandler(context
454
			+ "/cs/getSubCategoryByCategoryId?ticketCategoryId="
455
			+ ticketCategoryId, function(response) {
456
		$(".ticket-sub-category-container").html(response);
457
	});
458
}
459
function createPartnerRegion(domId, regionId, fofoIds) {
460
	doPostAjaxRequestWithJsonHandler(context
461
			+ "/cs/createPartnerRegion?regionId=" + regionId, JSON
462
			.stringify(fofoIds), function(response) {
463
		if (response == "true") {
464
			alert("added region to partner successfully");
465
			loadCreatePartnerRegion(domId);
466
		}
467
	});
468
}
469
function createSubCategory(domId, name, description, categoryId) {
470
	var params = {
471
		"categoryId" : categoryId,
472
		"name" : name,
473
		"description" : description
474
	}
475
	doPostAjaxRequestWithParamsHandler(context + "/cs/createSubCategory",
476
			params, function(response) {
477
				alert("Sub Category created successfully");
478
				loadCreateSubCategory(domId);
479
			});
480
}
481
function closeTicket(ticketId) {
24439 govind 482
	var dialog = bootbox
483
			.dialog({
484
				title : "Are you sure want to close ticket!",
485
				message : "<div class=\"col-lg-6 form-group\">"
486
						+ "<input placeholder=\"Happy Code\" id=\"happyCode\" name=\"happyCode\" type=\"text\"  class=\"form-control input-sm\">"
487
						+ "</div>",
488
				buttons : {
489
					cancel : {
490
						label : "cancel",
491
						className : 'btn-danger',
492
						callback : function() {
493
							loadMyTicket("main-content");
494
						}
495
					},
496
					ok : {
497
						label : "ok",
498
						className : 'btn-info',
499
						callback : function() {
500
							happyCode = $('#happyCode').val();
501
							console.log(happyCode);
502
							if (happyCode == "" || happyCode == null
503
									|| happyCode == undefined) {
504
								alert("happyCode field can't be empty");
505
								return false;
506
							}
507
							var params = {
508
								"ticketId" : ticketId,
509
								"happyCode" : happyCode
510
							}
511
							doPostAjaxRequestWithParamsHandler(context
512
									+ "/cs/closeTicket", params, function(
513
									response) {
514
								alert("Ticket close successfully");
515
								loadMyTicket("main-content");
516
							});
517
						}
518
					}
519
				}
24417 govind 520
			});
24439 govind 521
 
24417 govind 522
}
523
function createPosition(domId, authUserId, categoryId, escalationType, regionId) {
524
	var params = {
525
		"authUserId" : authUserId,
526
		"categoryId" : categoryId,
527
		"escalationType" : escalationType,
528
		"regionId" : regionId
529
	}
530
	doPostAjaxRequestWithParamsHandler(context + "/cs/createPosition", params,
531
			function(response) {
532
				if (response == "true") {
533
					alert("Position created successfully");
534
					loadCreatePosition(domId);
535
				}
536
			});
537
}
538
function createActivity(message, ticketId, assigneeId) {
539
	var params = {
540
		"message" : message,
541
		"ticketId" : ticketId,
24500 govind 542
		"assigneeId":assigneeId,
24417 govind 543
	}
544
	doPostAjaxRequestWithParamsHandler(context + "/cs/createActivity", params,
545
			function(response) {
546
				response = JSON.parse(response);
547
				var assigneeName = response.firstName;
548
				loadActivities(ticketId, assigneeName)
549
			});
550
}
24471 govind 551
function loadEditTicket(ticketId) {
552
	doGetAjaxRequestHandler(context + "/cs/edit-ticket?ticketId=" + ticketId,
553
			function(response) {
554
				$(".modal-content").html(response);
555
			});
24467 govind 556
}
24417 govind 557
function loadActivities(ticketId, assignee) {
558
 
24469 govind 559
	$(".activity-container .modal-body").empty();
24417 govind 560
	$("#activityMessage").val("");
561
	$("#ticketIdforactivity").val(ticketId);
562
	var assigned = "<div class=\"white_box\"><span>AssignedTo:-" + assignee
563
			+ "</span></div>";
24469 govind 564
	$(".activity-container .modal-body").append(assigned);
24417 govind 565
	console.log(ticketId);
566
	doGetAjaxRequestHandler(
567
			context + "/cs/getActivities?ticketId=" + ticketId,
568
			function(response) {
569
				response = JSON.parse(response);
570
				console.log(response);
571
				for (var i = 0; i < response.length; i++) {
572
					if ((response[i].type == "OPENED" || response[i].type == "COMMUNICATION_IN")
573
							&& response[i].createdBy == 0) {
574
 
575
						var partnerMessage = "<div class=\"incoming_msg\">"
576
								+ "<div class=\"received_msg\">"
577
								+ "<div class=\"received_withd_msg\">" + "<p>"
578
								+ response[i].message + "</p>"
579
								+ "<span class=\"time_date\"> "
580
								+ response[i].createTimestamp.hour + ":"
581
								+ response[i].createTimestamp.minute + "|"
582
								+ response[i].createTimestamp.dayOfMonth + "/"
583
								+ response[i].createTimestamp.monthValue + "/"
584
								+ response[i].createTimestamp.year
585
								+ "</span></div>" + "</div>" + "</div>";
24471 govind 586
						$(".activity-container .modal-body").append(
587
								partnerMessage);
24417 govind 588
					}
589
					if (response[i].type = "COMMUNICATION_OUT"
590
							&& response[i].createdBy > 0) {
591
 
592
						var assigneeMessage = "<div class=\"outgoing_msg\">"
593
								+ "<div class=\"sent_msg\">" + "<p>"
594
								+ response[i].message + "</p>"
595
								+ "<span class=\"time_date\">"
596
								+ response[i].createTimestamp.hour + ":"
597
								+ response[i].createTimestamp.minute + "|"
598
								+ response[i].createTimestamp.dayOfMonth + "/"
599
								+ response[i].createTimestamp.monthValue + "/"
600
								+ response[i].createTimestamp.year
601
								+ "</span> </div>" + "</div>";
24471 govind 602
 
603
						$(".activity-container .modal-body").append(
604
								assigneeMessage);
24417 govind 605
					}
606
				}
607
			});
608
}