Subversion Repositories SmartDukaan

Rev

Rev 24329 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
24317 govind 1
$(function() {
2
	$(".create-service").live('click', function() {
3
		loadService("main-content");
4
	});
5
	$(".add-brand").live('click', function() {
6
		loadaddBrandToService("main-content");
7
	});
8
 
9
	$(".notApplicableService").live(
10
			'click',
11
			function() {
12
				naCommentService = $(this).data('nacommentservice');
13
				console.log(naCommentService);
14
				var dialog = bootbox.dialog({
15
					message : "<h4 style='color:red'>NOTAPPLICABLE</h4><p>"
16
							+ naCommentService + "</p>",
17
					closeButton : true
18
				});
19
				dialog.modal('show');
20
 
21
			});
22
	$(".notApplicableBrandService").live(
23
			'click',
24
			function() {
25
				naCommentService = $(this).data('nacommentservice');
26
				console.log(naCommentService);
27
				var dialog = bootbox.dialog({
28
					message : "<h4 style='color:red'>NOTAPPLICABLE</h4><p>"
29
							+ naCommentService + "</p>",
30
					closeButton : true
31
				});
32
				dialog.modal('show');
33
 
34
			});
35
	$(".add-brand").live('click', function() {
36
		loadaddBrandToService("main-content");
37
	});
38
	$(".add-service-details-for-partner").live(
39
			'click',
40
			function() {
41
				fofoId = $("#partnerName").val();
42
				serviceId = $("#serviceName").val();
43
				applicableType = $("#applicableService").val();
44
				code = $("#code").val();
45
				partnerStatus = $("#partnerStatusTypeServices").val();
46
				na_comment = $("#na_comment_services").val();
47
				partnerCommentStatus = $("#partner_comment_status").val();
48
				 if (applicableType == "" || applicableType == null
49
							|| applicableType == undefined) {
50
						alert("select appropriate applicableType");
51
				 }
52
				 else if (applicableType == 'NO') {
53
					if (na_comment == "" || na_comment == undefined) {
54
						alert("Na_comment can't be empty");
55
						return;
56
					}
57
					if (fofoId == "" || fofoId == null || fofoId == undefined) {
58
						alert("select appropriate partnerName");
59
						return;
60
					}
61
					 if (serviceId == "" || serviceId == null
62
								|| serviceId == undefined) {
63
							alert("select appropriate serviceName");
64
							return;
65
					 }
66
				}
67
				 else
68
					 {
69
						if (fofoId == "" || fofoId == null || fofoId == undefined) {
70
							alert("select appropriate partnerName");
71
							return;
72
						}
73
						 if (serviceId == "" || serviceId == null
74
									|| serviceId == undefined) {
75
								alert("select appropriate serviceName");
76
								return;
77
						 }
78
				 if (code == "" || code == null
79
						|| code == undefined) {
80
					alert("enter appropriate code")
81
					return;
82
				} 
83
				 if (partnerStatus == "" || partnerStatus == null
84
						|| partnerStatus == undefined) {
85
					alert("select appropriate partnerStatus");
86
					return;
87
				} 
88
					 }
89
				 console.log(fofoId, serviceId, applicableType, code,
90
							partnerStatus);
91
					addPartnerServiceDetails(fofoId, serviceId, applicableType,
92
							code, partnerStatus, na_comment,
93
							partnerCommentStatus);
94
 
95
			});
96
	$(".add-brand-service-details-for-partner").live(
97
			'click',
98
			function() {
99
				fofoId = $("#partnerName").val();
100
				serviceId = $("#serviceName").val();
101
				serviceBrandId = $("#serviceBrandName").val();
102
				applicableType = $("#applicableService").val();
103
				active = $("#activeServiceBrand").val();
104
				partnerStatus = $("#partnerStatusTypeServices").val();
105
				na_comment = $("#na_comment_services").val();
106
				partnerCommentStatus = $("#partner_comment_status").val();
107
				if (applicableType == "NO") {
108
					if (na_comment == "" || na_comment == undefined) {
109
						alert("Na_comment can't be empty");
110
						return;
111
					}
112
				} 
113
				if (fofoId == "" || fofoId == null || fofoId == undefined) {
114
					alert("select appropriate partnerName");
115
					return;
116
				} else if (serviceBrandId == "" || serviceBrandId == null
117
						|| serviceBrandId == undefined) {
118
					alert("select appropriate serviceBrandId");
119
					return;
120
				} else if (applicableType == "" || applicableType == null
121
						|| applicableType == undefined) {
122
					alert("select appropriate applicableType");
123
				} else if (active == "" || active == null
124
						|| active == undefined) {
125
					alert("select appropriate active")
126
				} else if (partnerStatus == "" || partnerStatus == null
127
						|| partnerStatus == undefined) {
128
					alert("select appropriate partnerStatus");
129
				} else {
130
					console.log(fofoId, serviceBrandId, applicableType, active,
131
							partnerStatus);
132
					addPartnerServiceBrandDetails(fofoId, serviceId,
133
							serviceBrandId, applicableType, active,
134
							partnerStatus, na_comment, partnerCommentStatus);
135
				}
136
			});
137
	$(".partner-service").live('click', function() {
138
		loadpartnerService("main-content");
139
	});
140
	$(".admin-partner-service").live('click', function() {
141
		loadAdminPartnerService("main-content", 0);
142
	});
143
	$(".add-partner-service-details").live('click', function() {
144
		loadaddPartnerServiceDetails("main-content");
145
	});
146
	$(".add-partner-brand-service-details").live('click', function() {
147
		loadaddPartnerBrandServiceDetails("main-content");
148
	});
149
	$(".activate-service").live('click', function() {
150
		serviceId = $(this).data('serviceid');
151
		fofoId = $("#partnerName").val();
152
		console.log(fofoId);
153
		console.log(serviceId);
154
		activatePartnerService(fofoId, serviceId);
155
	});
156
	$(".deactivate-service").live('click', function() {
157
		serviceId = $(this).data('serviceid');
158
		fofoId = $("#partnerName").val();
159
		console.log(fofoId);
160
		console.log(serviceId);
161
		deActivatePartnerService(fofoId, serviceId);
162
	});
163
	$(".activate-brand-service").live('click', function() {
164
		console.log("activate-brand-service clicked");
165
		serviceId = $(this).data('serviceid');
166
		fofoId = $("#partnerName").val();
167
		serviceBrandId = $(this).data('servicebrandid');
168
		console.log(fofoId);
169
		console.log(serviceId);
170
		console.log(serviceBrandId);
171
		activatePartnerBrandService(fofoId, serviceId, serviceBrandId);
172
 
173
	});
174
	$(".deactivate-brand-service").live('click', function() {
175
		console.log("activate-brand-service clicked");
176
		serviceId = $(this).data('serviceid');
177
		fofoId = $("#partnerName").val();
178
		serviceBrandId = $(this).data('servicebrandid');
179
		console.log(fofoId);
180
		console.log(serviceId);
181
		console.log(serviceBrandId);
182
		deActivatePartnerBrandService(fofoId, serviceId, serviceBrandId);
183
 
184
	});
185
 
186
	$(".create-service-button")
187
			.live(
188
					'click',
189
					function() {
190
						console.log("create-service-button clicked");
191
						var serviceName = $('#createserviceName').val();
192
						if (serviceName === "" || serviceName === undefined
193
								|| serviceName == null) {
194
							alert("Input field can't be empty");
195
							return;
196
						}
197
						if (confirm("Are you sure you want to create Service!") == true) {
198
							createService("main-content", serviceName);
199
						}
200
					});
201
	$(".partner-service-search-button").live(
202
			'click',
203
			function() {
204
				var fofoId = $('#partnerName').val();
205
				if (fofoId === "" || fofoId === undefined || fofoId == null) {
206
					alert("select appropriate partner");
207
					return;
208
				}
209
				doGetAjaxRequestHandler(context + "/getPartnerServices?fofoId="
210
						+ fofoId, function(response) {
211
					$('#' + "partnerServicesByID").html(response);
212
				});
213
			});
214
	$("#remove-added-brand-button")
215
			.live(
216
					'click',
217
					function() {
218
						var serviceId = $(this).data('id');
219
						var brand = $(this).data('brand');
220
						console.log(serviceId);
221
						console.log(brand)
222
						if (confirm("Are you sure you want to remove brand from Service!") == true) {
223
							removeBrandFromService("main-content", serviceId,
224
									brand);
225
						}
226
					});
227
	$(".service-brand-button").live('click', function() {
228
		var brands = $('#tag-listing-brands').val();
229
		var serviceId = $('#serviceName').val();
230
		console.log(brands);
231
		console.log(serviceId);
232
		if (serviceId === "" || serviceId === undefined) {
233
			alert("service not selected");
234
			return;
235
		}
236
		if (!brands) {
237
			alert("select brand");
238
			return;
239
		}
240
		if (confirm("Are you sure you want to add brand!") == true) {
241
			addBrandToService("main-content", brands, serviceId);
242
		}
243
	});
244
	$('#serviceName').live('change', function() {
245
		// $('#tag-listing-brand-value').text($(this).text());
246
		loadBrandsByServiceId("service-container", $(this).val());
247
		loadaddedBrandsbyserviceId("added-brand-to-service", $(this).val())
248
	});
249
});
250
 
251
function addPartnerServiceDetails(fofoId, serviceId, applicableType, code,
252
		partnerStatus, na_comment, partnerCommentStatus) {
253
	if (confirm("Are you sure you want to add services details!") == true) {
254
		var params = {
255
			"serviceId" : serviceId,
256
			"fofoId" : fofoId,
257
			"applicableType" : applicableType,
258
			"partnerStatus" : partnerStatus,
259
			"na_comment" : na_comment,
260
			"partnerCommentStatus" : partnerCommentStatus,
261
			"code" : code
262
		}
263
		doPostAjaxRequestWithParamsHandler(context
264
				+ "/addPartnerServicesDetails", params, function(response) {
265
			if (response == "true") {
266
				alert("successfully added partner Service Details");
267
				loadaddPartnerServiceDetails("main-content");
268
			}
269
		});
270
	}
271
}
272
function addPartnerServiceBrandDetails(fofoId, serviceId, serviceBrandId,
273
		applicableType, active, partnerStatus, na_comment,
274
		partnerCommentStatus, code) {
275
	if (confirm("Are you sure you want to add service brand details!") == true) {
276
		var params = {
277
			"serviceId" : serviceId,
278
			"serviceBrandId" : serviceBrandId,
279
			"fofoId" : fofoId,
280
			"applicableType" : applicableType,
281
			"active" : active,
282
			"partnerStatus" : partnerStatus,
283
			"na_comment" : na_comment,
284
			"partnerCommentStatus" : partnerCommentStatus,
285
 
286
		}
287
		doPostAjaxRequestWithParamsHandler(context
288
				+ "/addPartnerServiceBrandDetails", params, function(response) {
289
			if (response == "true") {
290
				alert("successfully added partner Service Brand Details");
291
				loadaddPartnerBrandServiceDetails("main-content");
292
			}
293
		});
294
	}
295
}
296
function configureBrandsDropDown() {
297
	$(document).ready(function() {
298
		$('#tag-listing-brands').multiselect({
299
			includeSelectAllOption : true,
300
			multiple : true,
301
			maxHeight : 200,
302
			buttonWidth : '180px',
303
			numberDisplayed : 1,
304
			nonSelectedText : 'Brands',
305
			nSelectedText : ' - Brands Selected',
306
			allSelectedText : 'All Brands Selected',
307
			enableFiltering : true,
308
			enableCaseInsensitiveFiltering : true
309
		});
310
	});
311
}
312
 
313
function loadService(domId) {
314
	doGetAjaxRequestHandler(context + "/getcreateService", function(response) {
315
		$('#' + domId).html(response);
316
	});
317
}
318
function loadaddedBrandsbyserviceId(domId, serviceId) {
319
	doGetAjaxRequestHandler(context + "/getAddedbrands?serviceId=" + serviceId,
320
			function(response) {
321
				$('#' + domId).html(response);
322
			});
323
}
324
function loadBrandsByServiceId(domId, serviceId) {
325
	doGetAjaxRequestHandler(context + "/getbrands?serviceId=" + serviceId,
326
			function(response) {
327
				$('#' + domId).html(response);
328
				configureBrandsDropDown();
329
			});
330
 
331
}
332
function createService(domId, serviceName) {
333
	console.log(serviceName);
334
	doPostAjaxRequestHandler(context + "/createService?serviceName="
335
			+ serviceName, function(response) {
336
		alert("Service Successfully Created");
337
		$('#' + domId).html(response);
338
	});
339
}
340
function loadaddBrandToService(domId) {
341
	doGetAjaxRequestHandler(context + "/addBrandsToService",
342
			function(response) {
343
				$('#' + domId).html(response);
344
			});
345
}
346
function addBrandToService(domId, brands, serviceId) {
347
	doPostAjaxRequestWithJsonHandler(context + "/addBrandsService?serviceId="
348
			+ serviceId, JSON.stringify(brands), function(response) {
349
		alert("Brands added successfully");
350
		loadBrandsByServiceId("service-container", serviceId);
351
		loadaddedBrandsbyserviceId("added-brand-to-service", serviceId)
352
		$('#' + domId).html(response);
353
	});
354
}
355
function removeBrandFromService(domId, serviceId, brand) {
356
 
357
	doDeleteAjaxRequestHandler(context + "/removeBrandfromService?serviceId="
358
			+ serviceId + "&brand=" + brand, function(response) {
359
		alert("Brand removed from service successfully");
360
		loadBrandsByServiceId("service-container", serviceId);
361
		loadaddedBrandsbyserviceId("added-brand-to-service", serviceId)
362
		$('#' + domId).html(response);
363
	});
364
}
365
function changeServices(partnerServiceId) {
366
	var serviceId = partnerServiceId.value;
367
	var fofoId = $("#partnerName").val();
368
	console.log(fofoId);
369
	console.log(serviceId);
370
	if (fofoId == "" || fofoId == 0 || fofoId == undefined) {
371
		var dialog = bootbox
372
				.dialog({
373
					title : "Are you sure want to change state of service!",
374
					message : "<div class=form-inline'>"
375
							+ "<label for='reason'>Reason:</label>"
376
							+ "<textarea class='form-control' rows='1' id='reason'></textarea>"
377
							+ "</div>",
378
					buttons : {
379
						cancel : {
380
							label : "cancel",
381
							className : 'btn-danger',
382
							callback : function() {
383
								loadpartnerService("main-content");
384
							}
385
						},
386
						ok : {
387
							label : "ok",
388
							className : 'btn-info',
389
							callback : function() {
390
								partnerStatusComment = $('#reason').val();
391
								console.log(partnerStatusComment);
392
								var params = {
393
									"serviceId" : serviceId,
394
									"partnerStatusComment" : partnerStatusComment
395
								}
396
								doPostAjaxRequestWithParamsHandler(
397
										context + "/changeStatePartnerService",
398
										params,
399
										function(response) {
400
											if (response == "true") {
401
												alert("successfully changed");
402
												loadpartnerService("main-content");
403
											}
404
										});
405
 
406
							}
407
						}
408
					}
409
				});
410
 
411
	} else {
412
		if (confirm("Are you sure you want to change!") == true) {
413
			var params = {
414
				"serviceId" : serviceId,
415
				"fofoId" : fofoId
416
 
417
			}
418
			doPostAjaxRequestWithParamsHandler(context
419
					+ "/changeStatePartnerService", params, function(response) {
420
				if (response == "true") {
421
					alert("successfully changed");
422
					loadAdminPartnerService("main-content", fofoId);
423
				}
424
			});
425
		}
426
		else
427
			{
428
			loadAdminPartnerService("main-content", fofoId);			
429
			}
430
	}
431
}
432
function changeServiceNameForServiceBrand() {
433
 
434
	serviceId = $("#serviceName").val();
435
	console.log(serviceId);
436
	doGetAjaxRequestHandler(context + "/selectAddedbrands?serviceId="
437
			+ serviceId, function(response) {
438
		$('#' + "serviceBrandNameContainer").html(response);
439
	});
440
}
441
function configureAllPartnerName() {
442
	$(document).ready(function() {
443
		$('#partnerName').multiselect({
444
			includeSelectAllOption : true,
445
			maxHeight : 200,
446
			buttonWidth : '200px',
447
			numberDisplayed : 1,
448
			nonSelectedText : 'Partners',
449
			nSelectedText : ' - Partners Selected',
450
			allSelectedText : 'All Partners Selected',
451
			enableFiltering : true,
452
			enableCaseInsensitiveFiltering : true
453
 
454
		});
455
	});
456
}
457
function onChangeStateServiceBrand(partnerServiceBrandId, partnerServiceId) {
458
	var brandServiceId = partnerServiceBrandId.value;
459
	var fofoId = $("#partnerName").val();
460
	console.log(brandServiceId, partnerServiceId);
461
	if (fofoId == "" || fofoId == 0 || fofoId == undefined) {
462
		var dialog = bootbox
463
				.dialog({
464
					title : "Are you sure want to change state of service!",
465
					message : "<div class=form-inline'>"
466
							+ "<label for='reason'>Reason:</label>"
467
							+ "<textarea class='form-control' rows='1' id='reason'></textarea>"
468
							+ "</div>",
469
					buttons : {
470
						cancel : {
471
							label : "cancel",
472
							className : 'btn-danger',
473
							callback : function() {
474
								loadpartnerService("main-content");
475
							}
476
						},
477
						ok : {
478
							label : "ok",
479
							className : 'btn-info',
480
							callback : function() {
481
								partnerStatusComment = $('#reason').val();
482
								console.log(partnerStatusComment);
483
								var params = {
484
									"brandServiceId" : brandServiceId,
485
									"serviceId" : partnerServiceId,
486
									"partnerStatusComment" : partnerStatusComment
487
								}
488
								doPostAjaxRequestWithParamsHandler(
489
										context
490
												+ "/changeStatePartnerServiceBrand",
491
										params,
492
										function(response) {
493
											if (response == "true") {
494
												alert("successfully changed");
495
												loadpartnerService("main-content");
496
											}
497
 
498
										});
499
 
500
							}
501
						}
502
					}
503
				});
504
	} else {
505
		if (confirm("Are you sure you want to change!") == true) {
506
 
507
			var params = {
508
				"brandServiceId" : brandServiceId,
509
				"serviceId" : partnerServiceId,
510
				"fofoId" : fofoId
511
			}
512
			doPostAjaxRequestWithParamsHandler(context
513
					+ "/changeStatePartnerServiceBrand", params, function(
514
					response) {
515
				if (response == "true") {
516
					alert("successfully changed");
517
					loadAdminPartnerService("main-content", fofoId);
518
				}
519
			});
520
 
521
		} else {
522
			loadAdminPartnerService("main-content", fofoId);
523
		}
524
	}
525
}
526
function loadpartnerService(domId) {
527
	doGetAjaxRequestHandler(context + "/getPartnerServices",
528
			function(response) {
529
				$('#' + domId).html(response);
530
			});
531
 
532
}
533
function loadAdminPartnerService(domId, fofoId) {
534
	doGetAjaxRequestHandler(context
535
			+ "/getAdminPanelForPartnerServices?fofoId=" + fofoId, function(
536
			response) {
537
		$('#' + domId).html(response);
538
		if (fofoId != 0 || fofoId) {
539
			doGetAjaxRequestHandler(context + "/getPartnerServices?fofoId="
540
					+ fofoId, function(response) {
541
				$('#' + "partnerServicesByID").html(response);
542
			});
543
		}
544
 
545
	});
546
}
547
function activatePartnerService(fofoId, serviceId) {
548
	console.log(fofoId);
549
	var dialog = bootbox
550
	.dialog({
551
		title : "Are you sure you want to activate services!",
552
		message : "<div class=form-inline'>"
553
				+ "<label for='code'>Code:</label>"
554
				+ "<input class='form-control' type='text' id='code'/>"
555
				+ "</div>",
556
		buttons : {
557
			cancel : {
558
				label : "cancel",
559
				className : 'btn-danger',
560
				callback : function() {
561
					loadAdminPartnerService("main-content", fofoId);
562
				}
563
			},
564
			ok : {
565
				label : "ok",
566
				className : 'btn-info',
567
				callback : function() {
568
					code = $('#code').val();
569
					//console.log(partnerStatusComment);
570
					if(code==""||code==undefined||code==null)
571
						{
572
							alert("code can't be empty");
573
							activatePartnerService(fofoId, serviceId);
574
							return;
575
						}
576
					var params = {
577
							"serviceId" : serviceId,
578
							"fofoId" : fofoId,
579
							"code":code
580
						}
581
						doPostAjaxRequestWithParamsHandler(context + "/activatePartnerService",
582
								params, function(response) {
583
									if (response == "true") {
584
										alert("successfully activate");
585
										loadAdminPartnerService("main-content", fofoId);
586
									}
587
								});
588
				}
589
			}
590
		}
591
	});
592
}
593
function deActivatePartnerService(fofoId, serviceId) {
594
	if (confirm("Are you sure you want to deactivate services!") == true) {
595
		var params = {
596
			"serviceId" : serviceId,
597
			"fofoId" : fofoId
598
 
599
		}
600
		doPostAjaxRequestWithParamsHandler(context
601
				+ "/deActivatePartnerService", params, function(response) {
602
			if (response == "true") {
603
				alert("successfully deactivate");
604
				loadAdminPartnerService("main-content", fofoId);
605
			}
606
		});
607
	}
608
}
609
function activatePartnerBrandService(fofoId, serviceId, serviceBrandId) {
610
	if (confirm("Are you sure you want to activate brand service!") == true) {
611
		var params = {
612
			"serviceId" : serviceId,
613
			"fofoId" : fofoId,
614
			"serviceBrandId" : serviceBrandId
615
 
616
		}
617
		doPostAjaxRequestWithParamsHandler(context
618
				+ "/activatePartnerbrandService", params, function(response) {
619
			if (response == "true") {
620
				alert("successfully activate");
621
				loadAdminPartnerService("main-content", fofoId);
622
			}
623
		});
624
	}
625
}
626
function deActivatePartnerBrandService(fofoId, serviceId, serviceBrandId) {
627
	if (confirm("Are you sure you want to deactivate brand service!") == true) {
628
		var params = {
629
			"serviceId" : serviceId,
630
			"fofoId" : fofoId,
631
			"serviceBrandId" : serviceBrandId
632
 
633
		}
634
		doPostAjaxRequestWithParamsHandler(context
635
				+ "/deActivatePartnerbrandService", params, function(response) {
636
			if (response == "true") {
637
				alert("successfully deactivate");
638
				loadAdminPartnerService("main-content", fofoId);
639
			}
640
		});
641
	}
642
}
643
 
644
function loadaddPartnerServiceDetails(domId) {
645
	doGetAjaxRequestHandler(context + "/getAddPartnerServicesDetails",
646
			function(response) {
647
				$('#' + domId).html(response);
648
			});
649
}
650
function loadaddPartnerBrandServiceDetails(domId) {
651
	doGetAjaxRequestHandler(context + "/getAddPartnerBrandServiceDetails",
652
			function(response) {
653
				$('#' + domId).html(response);
654
			});
655
}