Subversion Repositories SmartDukaan

Rev

Rev 24329 | Rev 27755 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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