Subversion Repositories SmartDukaan

Rev

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