Subversion Repositories SmartDukaan

Rev

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