Subversion Repositories SmartDukaan

Rev

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