Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
27797 tejbeer 1
$(function() {
24125 govind 2
 
27797 tejbeer 3
	$(document).on('click', "#retailer-details-search-button", function() {
4
		searchContent = $("#retailer-details-search-text").val();
5
		if (typeof (searchContent) == "undefined" || !searchContent) {
6
			searchContent = "";
7
		}
8
		getRetailerDetailsByEmailIdOrMobileNumber(
9
			"retailer-details-container", searchContent);
10
	});
31860 tejbeer 11
 
28711 amit.gupta 12
	$(document).on('click', ".activate-store-temporary", function() {
13
		var row = $(this).closest("tr");
14
		var fofoId = $(this).data("fofoid");
31860 tejbeer 15
 
28711 amit.gupta 16
		var ActiveDays = $(row).find("td:eq(4) input[type='text']").val();
17
		console.log("ActiveDays" + ActiveDays);
18
		console.log("fofoId" + fofoId);
19
		var days = parseInt(ActiveDays);
28713 amit.gupta 20
		if (confirm("Are you sure you want to activate this store!") == true) {
31860 tejbeer 21
			doPostAjaxRequestHandler(context + "/activateStoreTemporary?fofoId=" + fofoId + "&days=" + days,
28711 amit.gupta 22
				function(response) {
23
					if (response == "true") {
24
						alert("successfully activated!");
25
						inactiveStoreInfo("main-content");
26
					}
24159 tejbeer 27
 
28711 amit.gupta 28
				});
31860 tejbeer 29
 
28713 amit.gupta 30
		}
28711 amit.gupta 31
 
31860 tejbeer 32
 
28711 amit.gupta 33
	});
31860 tejbeer 34
 
29268 manish 35
	$(document).on('click', ".partner-info", function() {
31860 tejbeer 36
		var userIds = {};
37
		userIds['userIds'] = $('#fofo-users').val();
38
		console.log(userIds)
39
		doPostAjaxRequestWithJsonHandler(context + "/getPartnerinfo", JSON.stringify(userIds), function(response) {
40
 
29268 manish 41
			$('.storePartnerInfo').html(response);
42
		});
31860 tejbeer 43
 
29268 manish 44
	});
27797 tejbeer 45
	$(document).on('click', ".active-store", function() {
29268 manish 46
		store("main-content");
47
	});
48
	$(document).on('click', ".allStoreInfo", function() {
27797 tejbeer 49
		storeInfo("main-content");
50
	});
31860 tejbeer 51
 
52
 
27797 tejbeer 53
	$(document).on('click', ".inactive-store", function() {
54
		inactiveStoreInfo("main-content");
55
	});
56
	$(document).on('click', ".retailer-info", function() {
57
		retailerInfo("main-content");
58
	});
24125 govind 59
 
27231 tejbeer 60
 
27797 tejbeer 61
	$(document).on('click', ".partner-readonly-info", function() {
62
		partnerInfo("main-content")
27171 tejbeer 63
 
64
 
27797 tejbeer 65
	});
28071 tejbeer 66
	$(document).on('click', ".block-brand-mapping", function() {
67
		blockBrandMapping("main-content")
27171 tejbeer 68
 
24125 govind 69
 
28071 tejbeer 70
	});
31860 tejbeer 71
 
28272 tejbeer 72
	$(document).on('click', ".brands-limit", function() {
73
		brandsLimit("main-content")
28071 tejbeer 74
 
75
 
28272 tejbeer 76
	});
31860 tejbeer 77
 
78
	$(document).on('click', ".add-partner-pincode", function() {
28381 tejbeer 79
		allPartnerPincode("main-content")
28272 tejbeer 80
 
81
 
28381 tejbeer 82
	});
28272 tejbeer 83
 
28381 tejbeer 84
 
27797 tejbeer 85
	$(document).on('click', ".partnerInfoReadOnly",
86
		function() {
24125 govind 87
 
27797 tejbeer 88
			var fofoId = $('#fofo-users').val();
89
			loginAsPartnerReadonly(fofoId);
90
		});
91
	$(document).on('change', "#retailerAddressPinCode",
92
		function() {
27171 tejbeer 93
 
27797 tejbeer 94
			var pincode = $('#retailerAddressPinCode').val();
24125 govind 95
 
27797 tejbeer 96
			if (undefined != pincode) {
97
				doGetAjaxRequestHandler(context + "/postOffice?pinCode="
98
					+ pincode,
99
					function(response) {
100
						console.log(response.response.state);
101
						$('#retailerAddressCity').find('option').not(':first').remove();
102
						$('#retailerAddressState').val("");
103
						$('#retailerAddressState').val(
104
							response.response.state);
105
						loadDistrictNames(response.response.state);
106
						for (let city of response.response.cities) {
107
							var opt = $("<option>").val(city).text(city);
108
							$('#retailerAddressCity').append(opt);
24349 amit.gupta 109
 
27797 tejbeer 110
						}
24159 tejbeer 111
 
27797 tejbeer 112
					});
113
			}
114
		});
24159 tejbeer 115
 
27797 tejbeer 116
	$(document).on("keyup", "#retailer-details-search-text", function(e) {
117
		var keyCode = e.keyCode || e.which;
118
		if (keyCode == 13) {
119
			$("#retailer-details-search-button").click();
120
		}
121
	});
24159 tejbeer 122
 
27797 tejbeer 123
	$(document).on('click', ".deactivate-store", function() {
124
		var fofoId = $(this).data("fofoid");
125
		console.log(fofoId);
126
		if (confirm("Are you sure you want to deactivate store!") == true) {
127
			deactivateStore("main-content", fofoId);
128
		}
27171 tejbeer 129
 
27797 tejbeer 130
	});
28711 amit.gupta 131
	$(document).on('click', ".activate-store-forever", function() {
132
		var fofoId = $(this).data("fofoid");
133
		console.log(fofoId);
134
		if (confirm("Are you sure you want to activate this store!") == true) {
135
			activateStoreForever("main-content", fofoId);
136
		}
137
 
138
	});
31860 tejbeer 139
 
27797 tejbeer 140
	$(document).on('click', ".login_as", function() {
141
		var fofoId = $('#partnerId').val();
142
		loginAsPartner(fofoId);
24159 tejbeer 143
 
27797 tejbeer 144
	});
31860 tejbeer 145
	$(document).on('click', ".partner-performance-access", function() {
24159 tejbeer 146
 
31860 tejbeer 147
 
148
		doGetAjaxRequestHandler(context + "/getPartnersForPerformance", function(response) {
149
			$('#' + "main-content").html(response);
150
		});
151
	});
152
 
153
	$(document).on('click', ".partnerPerformance", function() {
154
		var fofoId = $('#fofo-users').val();
155
 
31892 tejbeer 156
		//var url = context + "/partnerPerformance?fofoId=" + fofoId;
31860 tejbeer 157
 
158
 
31892 tejbeer 159
		//$('.partner-performance-container').html(`<iframe class="wrapper" src="${url}" style="width:100%;height:100vh"> </iframe>`); 
31860 tejbeer 160
 
31892 tejbeer 161
		doGetAjaxRequestHandler(context + "/partnerPerformance?fofoId=" + fofoId, function(response) {
162
			$('.partner-performance-container').html(response);
163
		});
164
 
31860 tejbeer 165
	});
31892 tejbeer 166
 
167
 
168
 
169
	$('#partnerSecondary').on('click', '.brandFocusedStock', function() {
170
		var fofoId = $(this).data('fofoid');
171
		var brand = $(this).data('brand');
172
 
173
		console.log(brand)
174
		console.log(fofoId)
175
 
176
		doGetAjaxRequestHandler(context + "/getPartnerShortageStock?brand=" + brand + "&fofoId="
177
			+ fofoId, function(response) {
178
 
179
				$('#itemWiseBrandStock .modal-content').html(response);
180
 
181
			});
182
	});
183
 
184
 
185
 
186
 
187
 
188
 
189
 
190
 
27797 tejbeer 191
	$(document).on('click', ".extend-billing", function() {
192
		var fofoId = $(this).data("fofoid");
193
		console.log(fofoId);
194
		if (confirm("Are you sure you want to extend Billing?")) {
195
			extendBilling($(this).parent(), fofoId);
196
		}
24159 tejbeer 197
 
27797 tejbeer 198
	});
24159 tejbeer 199
 
31860 tejbeer 200
	/*
201
	 * $(document).on('change', '#retailerAddressState', function() { var stateName =
202
	 * $(this).find('option:selected').text();
203
	 *
204
	 * loadDistrictNames(stateName); });
205
	 */
24159 tejbeer 206
 
207
 
27797 tejbeer 208
	$(document).on('click', "#location", function() {
209
		if ($(this).is(":checked")) {
27516 amit.gupta 210
 
27797 tejbeer 211
			$("#divLocation").show();
27516 amit.gupta 212
 
27797 tejbeer 213
		} else {
214
			$("#divLocation").hide();
215
		}
216
	});
27516 amit.gupta 217
 
218
 
27797 tejbeer 219
	$(document).on('click', ".changePartnerCategory", function() {
220
		$clickedElement = $(this);
221
		var fofoId = $clickedElement.data("id");
222
		$tdElement = $(this).closest('td');
223
		doGetAjaxRequestHandler(context + "/getPartnerCategory?fofoId=" + fofoId, function(response) {
27516 amit.gupta 224
 
27797 tejbeer 225
			$tdElement.html(response);
226
			$tdElement.find('.partnerCategory').multiselect({
227
				includeSelectAllOption: true,
228
				multiple: true,
229
				maxHeight: 200,
230
				buttonWidth: '180px',
231
				numberDisplayed: 1,
232
				nonSelectedText: 'Category',
233
				nSelectedText: ' - Category Selected',
234
				allSelectedText: 'All Category Selected',
235
				enableFiltering: true,
236
				enableCaseInsensitiveFiltering: true
237
			});
238
		});
239
	});
27516 amit.gupta 240
 
241
 
27797 tejbeer 242
	$(document).on('click', ".update-category",
243
		function() {
244
			var fofoId = $(this).data('fofoid');
245
			var partnerType = $('#partnerCategory').val();
27516 amit.gupta 246
 
27797 tejbeer 247
			if (confirm("Are you sure you want to update the partners!") == true) {
248
				doPostAjaxRequestHandler(context
249
					+ "/updatePartnerCategory?fofoId="
250
					+ fofoId + "&partnerType=" + partnerType, function(
251
						response) {
252
					if (response == "true") {
253
						alert("Update successfully");
254
						storeInfo("main-content");
255
					}
256
				});
257
			}
27516 amit.gupta 258
 
27797 tejbeer 259
		});
260
 
261
 
31860 tejbeer 262
 
263
 
27797 tejbeer 264
	$(document).on('click', ".addlocationbutton",
265
		function() {
266
			var userId = $('#retailerId').text();
267
			var name = $('#personName').val();
268
			var line1 = $('#line1').val();
269
			var line2 = $('#line2').val();
270
			var city = $('#city').val();
271
			var state = $('#state').val();
272
			var pin = $('#pinCode').val();
273
 
274
			if (name === "" && line1 === "" && city === "" && pin === "") {
275
				alert("Field can't be empty");
276
				return;
277
			}
278
			if (name === "") {
279
				alert("name is required");
280
				return;
281
			}
282
			if (line1 === "") {
283
				alert("line1 is required");
284
				return;
285
			}
286
			if (city === "") {
287
				alert("city is required");
288
				return;
289
			}
290
			if (pin === "") {
291
				alert("pin is required");
292
				return;
293
			}
294
 
295
			var locationData = {};
296
			locationData['userId'] = $('#retailerId').text();
297
			locationData['name'] = $('#personName').val();
298
			locationData['line1'] = $('#line1').val();
299
			locationData['line2'] = $('#line2').val();
300
			locationData['city'] = $('#city').val();
301
			locationData['state'] = $('#state').val();
302
			locationData['pin'] = $('#pinCode').val();
303
 
304
			if (confirm("Are you sure you want to add location!") == true) {
305
				doPostAjaxRequestWithJsonHandler(context + "/addLocation",
306
					JSON.stringify(locationData), function(response) {
307
						if (response == 'true') {
308
							alert("successfully Add");
309
							$("#addLocationModal").modal('hide');
310
 
311
						}
312
					});
313
 
314
				return false;
315
			}
316
		});
317
 
23347 ashik.ali 318
});
319
 
23837 ashik.ali 320
function getDistance(lat1, lon1, lat2, lon2) {
27797 tejbeer 321
	var deg2rad = 0.017453292519943295; // === Math.PI / 180
322
	var cos = Math.cos;
323
	lat1 *= deg2rad;
324
	lon1 *= deg2rad;
325
	lat2 *= deg2rad;
326
	lon2 *= deg2rad;
327
	var diam = 12742; // Diameter of the earth in km (2 * 6371)
328
	var dLat = lat2 - lat1;
329
	var dLon = lon2 - lon1;
330
	var a = ((1 - cos(dLat)) + (1 - cos(dLon)) * cos(lat1) * cos(lat2)) / 2;
23837 ashik.ali 331
 
27797 tejbeer 332
	return parseFloat(diam * Math.asin(Math.sqrt(a))).toFixed(2);
24125 govind 333
}
23837 ashik.ali 334
 
24125 govind 335
function getRetailerDetailsByEmailIdOrMobileNumber(domId, emailIdOrMobileNumber) {
27797 tejbeer 336
	doGetAjaxRequestHandler(context + "/retailerDetails?emailIdOrMobileNumber="
337
		+ emailIdOrMobileNumber, function(response) {
338
			$('#' + domId).html(response);
339
			if ($("#location").is(":checked")) {
27171 tejbeer 340
 
27797 tejbeer 341
				$("#divLocation").show();
342
			}
343
		});
23347 ashik.ali 344
}
345
 
24125 govind 346
function updateRetailerDocument() {
27797 tejbeer 347
	// $("#updateRetailerShopDocument0").click( function() {
348
	console.log("Update Retailer Document Clicked");
349
	// console.log(ownerId);
350
	var emailIdOrMobileNumber = $('#retailer-details-search-text').val();
351
	console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);
352
	var file = $('#retailerDocument')[0].files[0];
353
	console.log("file : " + file.name);
354
	uploadRetailerDocument("retailer-details-container", file,
355
		emailIdOrMobileNumber);
23347 ashik.ali 356
}
357
 
24125 govind 358
function updateRetailerShopDocument(ownerId) {
27797 tejbeer 359
	// $("#updateRetailerShopDocument0").click( function() {
360
	console.log("Update Retailer Shop Document Clicked");
361
	console.log(ownerId);
362
	var shopSize = parseInt($("#shopDetailsSize").attr('size'));
363
	console.log("size : " + shopSize);
364
	for (var index = 0; index < shopSize; index++) {
365
		if ("updateRetailerShopDocument" + index == ownerId) {
366
			var emailIdOrMobileNumber = $('#retailer-details-search-text')
367
				.val();
368
			console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);
369
			var shopId = $('#retailerShopDocument' + index).attr("shopId");
370
			console.log("shopId : " + shopId);
371
			var file = $('#retailerShopDocument' + index)[0].files[0];
372
			console.log("file : " + file.name);
373
			uploadRetailerShopDocument("retailer-details-container", file,
374
				emailIdOrMobileNumber, shopId);
375
		}
376
	}
23347 ashik.ali 377
}
378
 
24125 govind 379
function loadDistrictNames(stateName) {
27797 tejbeer 380
	if (undefined != $("#districtName")) {
381
		doGetAjaxRequestHandler(
382
			context + "/district/all/stateName?stateName=" + stateName,
383
			function(response) {
384
				console.log(response);
385
				var districtMasters = response.response;
386
				// districtMasters = districtMasters.response;
387
				var districtNameElements = '<option value="" disabled selected>District Name</option>';
388
				for (index = 0; index < districtMasters.length; index++) {
389
					districtNameElements = districtNameElements
390
						+ '<option value="'
391
						+ districtMasters[index].name + '">'
392
						+ districtMasters[index].name + '</option>';
393
				}
394
				$('#districtName').html(districtNameElements);
395
			});
396
	}
23347 ashik.ali 397
}
398
 
24125 govind 399
function retailerInfo(domId) {
27797 tejbeer 400
	doGetAjaxRequestHandler(context + "/retailerInfo", function(response) {
401
		$('#' + domId).html(response);
24159 tejbeer 402
 
27797 tejbeer 403
	});
24159 tejbeer 404
 
24125 govind 405
}
27231 tejbeer 406
 
27516 amit.gupta 407
function partnerInfo(domId) {
27797 tejbeer 408
	doGetAjaxRequestHandler(context + "/getPartnerReadonlyInfo", function(response) {
409
		$('#' + domId).html(response);
27516 amit.gupta 410
 
27797 tejbeer 411
	});
27231 tejbeer 412
}
28071 tejbeer 413
function blockBrandMapping(domId) {
414
	doGetAjaxRequestHandler(context + "/getBlockBrandMapping", function(response) {
415
		$('#' + domId).html(response);
27516 amit.gupta 416
 
28071 tejbeer 417
	});
418
}
28272 tejbeer 419
function brandsLimit(domId) {
420
	doGetAjaxRequestHandler(context + "/getBrandslimit", function(response) {
421
		$('#' + domId).html(response);
28071 tejbeer 422
 
28272 tejbeer 423
	});
424
}
24125 govind 425
function storeInfo(domId) {
27797 tejbeer 426
	doGetAjaxRequestHandler(context + "/getAllStores", function(response) {
427
		$('#' + domId).html(response);
428
	});
24125 govind 429
}
27516 amit.gupta 430
 
29268 manish 431
function store(domId) {
432
	doGetAjaxRequestHandler(context + "/getstore", function(response) {
433
		$('#' + domId).html(response);
434
	});
435
}
24680 govind 436
function inactiveStoreInfo(domId) {
27797 tejbeer 437
	doGetAjaxRequestHandler(context + "/getAllInactiveStores", function(
438
		response) {
439
		$('#' + domId).html(response);
440
	});
24680 govind 441
}
27516 amit.gupta 442
 
28381 tejbeer 443
function allPartnerPincode(domId) {
444
	doGetAjaxRequestHandler(context + "/getAllPartnerPincode", function(
445
		response) {
446
		$('#' + domId).html(response);
447
	});
448
}
449
 
24125 govind 450
function deactivateStore(domId, fofoId) {
27797 tejbeer 451
	doPostAjaxRequestHandler(context + "/deactivateStore?fofoId=" + fofoId,
452
		function(response) {
453
			if (response == "true") {
454
				alert("successfully deactivated!");
455
				storeInfo(domId);
456
			}
24159 tejbeer 457
 
27797 tejbeer 458
		});
24125 govind 459
}
28711 amit.gupta 460
function activateStoreForever(domId, fofoId) {
461
	doPostAjaxRequestHandler(context + "/activateStoreForever?fofoId=" + fofoId,
462
		function(response) {
463
			if (response == "true") {
464
				alert("successfully activated!");
465
				inactiveStoreInfo(domId);
466
			}
27516 amit.gupta 467
 
28711 amit.gupta 468
		});
469
}
470
 
24976 amit.gupta 471
function loginAsPartner(fofoId) {
27797 tejbeer 472
	doGetAjaxRequestHandler(context + "/login-as-partner?fofoId=" + fofoId,
473
		function(response) {
474
			window.create({
475
				"url": "/dashboard",
476
				"incognito": true
477
			});
31860 tejbeer 478
 
27797 tejbeer 479
		});
24976 amit.gupta 480
}
27231 tejbeer 481
 
482
function loginAsPartnerReadonly(fofoId) {
27797 tejbeer 483
	doGetAjaxRequestHandler(context + "/login-as-partner-readonly?fofoId=" + fofoId,
484
		function(response) {
485
			window.create({
486
				"url": "/dashboard",
487
				"incognito": true
488
			});
489
		});
27231 tejbeer 490
}
27516 amit.gupta 491
 
24349 amit.gupta 492
function extendBilling(container, fofoId) {
27797 tejbeer 493
	doPostAjaxRequestHandler(context + "/extendBilling?fofoId=" + fofoId,
494
		function(response) {
495
			if (isFinite(response)) {
496
				alert("successfully deactivated!");
497
				container.html("Billing extended upto "
498
					+ moment().add(1, 'day').format("DD-MM-YY")
499
					+ " Grace count(" + response + ")");
500
			}
501
		});
24349 amit.gupta 502
}
24159 tejbeer 503
 
504
function updateLocationButton(id) {
505
 
27797 tejbeer 506
	var userId = id;
507
	var name = $('#personName').val();
508
	var line1 = $('#line1').val();
509
	var line2 = $('#line2').val();
510
	var city = $('#city').val();
511
	var state = $('#state').val();
512
	var pin = $('#pinCode').val();
513
	console.log(id);
514
	if (name === "" && line1 === "" && city === "" && pin === "") {
515
		alert("Field can't be empty");
516
		return;
517
	}
518
	if (name === "") {
519
		alert("name is required");
520
		return;
521
	}
522
	if (line1 === "") {
523
		alert("line1 is required");
524
		return;
525
	}
526
	if (city === "") {
527
		alert("city is required");
528
		return;
529
	}
530
	if (pin === "") {
531
		alert("pin is required");
532
		return;
533
	}
24159 tejbeer 534
 
27797 tejbeer 535
	var changeLocationData = {};
24159 tejbeer 536
 
27797 tejbeer 537
	changeLocationData['userId'] = id;
538
	changeLocationData['name'] = $('#personName').val();
539
	changeLocationData['line1'] = $('#line1').val();
540
	changeLocationData['line2'] = $('#line2').val();
541
	changeLocationData['city'] = $('#city').val();
542
	changeLocationData['state'] = $('#state').val();
543
	changeLocationData['pin'] = $('#pinCode').val();
24159 tejbeer 544
 
27797 tejbeer 545
	console.log(changeLocationData);
24159 tejbeer 546
 
27797 tejbeer 547
	if (confirm("Are you sure you want to add location!") == true) {
548
		doPostAjaxRequestWithJsonHandler(context + "/updateLocation", JSON
549
			.stringify(changeLocationData), function(response) {
550
				if (response == 'true') {
551
					alert("successfully Update");
24159 tejbeer 552
 
27797 tejbeer 553
					$("#addLocationModal").modal('hide');
24159 tejbeer 554
 
27797 tejbeer 555
				}
556
			});
24159 tejbeer 557
 
27797 tejbeer 558
		return false;
559
	}
24159 tejbeer 560
 
561
}