Subversion Repositories SmartDukaan

Rev

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