Subversion Repositories SmartDukaan

Rev

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