Subversion Repositories SmartDukaan

Rev

Rev 31895 | Rev 32044 | 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
 
31895 tejbeer 176
		doGetAjaxRequestHandler(
177
			"https://partners.smartdukaan.com" + "/getPartnerShortageStock?brand=" + brand + "&fofoId="
31892 tejbeer 178
			+ fofoId, function(response) {
179
 
180
				$('#itemWiseBrandStock .modal-content').html(response);
181
 
182
			});
183
	});
184
 
185
 
186
 
31932 tejbeer 187
	$(document).on('click', ".agingDataAfterNintyDays", function() {
188
		var fofoId = $(this).data('fofoid');
189
		console.log(fofoId)
190
 
191
		doPostAjaxRequestWithJsonHandler(
192
			"https://partners.smartdukaan.com" + "/getInventoryItemAgingByFofoId?fofoId="
193
			+ fofoId, JSON.stringify([90]),
194
			function(response) {
195
				$('#agingItemWiseBrandStock .modal-content').html(response);
196
			});
197
	});
198
 
199
 
200
 
27797 tejbeer 201
	$(document).on('click', ".extend-billing", function() {
202
		var fofoId = $(this).data("fofoid");
203
		console.log(fofoId);
204
		if (confirm("Are you sure you want to extend Billing?")) {
205
			extendBilling($(this).parent(), fofoId);
206
		}
24159 tejbeer 207
 
27797 tejbeer 208
	});
24159 tejbeer 209
 
31860 tejbeer 210
	/*
211
	 * $(document).on('change', '#retailerAddressState', function() { var stateName =
212
	 * $(this).find('option:selected').text();
213
	 *
214
	 * loadDistrictNames(stateName); });
215
	 */
24159 tejbeer 216
 
217
 
27797 tejbeer 218
	$(document).on('click', "#location", function() {
219
		if ($(this).is(":checked")) {
27516 amit.gupta 220
 
27797 tejbeer 221
			$("#divLocation").show();
27516 amit.gupta 222
 
27797 tejbeer 223
		} else {
224
			$("#divLocation").hide();
225
		}
226
	});
27516 amit.gupta 227
 
228
 
27797 tejbeer 229
	$(document).on('click', ".changePartnerCategory", function() {
230
		$clickedElement = $(this);
231
		var fofoId = $clickedElement.data("id");
232
		$tdElement = $(this).closest('td');
233
		doGetAjaxRequestHandler(context + "/getPartnerCategory?fofoId=" + fofoId, function(response) {
27516 amit.gupta 234
 
27797 tejbeer 235
			$tdElement.html(response);
236
			$tdElement.find('.partnerCategory').multiselect({
237
				includeSelectAllOption: true,
238
				multiple: true,
239
				maxHeight: 200,
240
				buttonWidth: '180px',
241
				numberDisplayed: 1,
242
				nonSelectedText: 'Category',
243
				nSelectedText: ' - Category Selected',
244
				allSelectedText: 'All Category Selected',
245
				enableFiltering: true,
246
				enableCaseInsensitiveFiltering: true
247
			});
248
		});
249
	});
27516 amit.gupta 250
 
251
 
27797 tejbeer 252
	$(document).on('click', ".update-category",
253
		function() {
254
			var fofoId = $(this).data('fofoid');
255
			var partnerType = $('#partnerCategory').val();
27516 amit.gupta 256
 
27797 tejbeer 257
			if (confirm("Are you sure you want to update the partners!") == true) {
258
				doPostAjaxRequestHandler(context
259
					+ "/updatePartnerCategory?fofoId="
260
					+ fofoId + "&partnerType=" + partnerType, function(
261
						response) {
262
					if (response == "true") {
263
						alert("Update successfully");
264
						storeInfo("main-content");
265
					}
266
				});
267
			}
27516 amit.gupta 268
 
27797 tejbeer 269
		});
270
 
271
 
31860 tejbeer 272
 
273
 
27797 tejbeer 274
	$(document).on('click', ".addlocationbutton",
275
		function() {
276
			var userId = $('#retailerId').text();
277
			var name = $('#personName').val();
278
			var line1 = $('#line1').val();
279
			var line2 = $('#line2').val();
280
			var city = $('#city').val();
281
			var state = $('#state').val();
282
			var pin = $('#pinCode').val();
283
 
284
			if (name === "" && line1 === "" && city === "" && pin === "") {
285
				alert("Field can't be empty");
286
				return;
287
			}
288
			if (name === "") {
289
				alert("name is required");
290
				return;
291
			}
292
			if (line1 === "") {
293
				alert("line1 is required");
294
				return;
295
			}
296
			if (city === "") {
297
				alert("city is required");
298
				return;
299
			}
300
			if (pin === "") {
301
				alert("pin is required");
302
				return;
303
			}
304
 
305
			var locationData = {};
306
			locationData['userId'] = $('#retailerId').text();
307
			locationData['name'] = $('#personName').val();
308
			locationData['line1'] = $('#line1').val();
309
			locationData['line2'] = $('#line2').val();
310
			locationData['city'] = $('#city').val();
311
			locationData['state'] = $('#state').val();
312
			locationData['pin'] = $('#pinCode').val();
313
 
314
			if (confirm("Are you sure you want to add location!") == true) {
315
				doPostAjaxRequestWithJsonHandler(context + "/addLocation",
316
					JSON.stringify(locationData), function(response) {
317
						if (response == 'true') {
318
							alert("successfully Add");
319
							$("#addLocationModal").modal('hide');
320
 
321
						}
322
					});
323
 
324
				return false;
325
			}
326
		});
327
 
23347 ashik.ali 328
});
329
 
23837 ashik.ali 330
function getDistance(lat1, lon1, lat2, lon2) {
27797 tejbeer 331
	var deg2rad = 0.017453292519943295; // === Math.PI / 180
332
	var cos = Math.cos;
333
	lat1 *= deg2rad;
334
	lon1 *= deg2rad;
335
	lat2 *= deg2rad;
336
	lon2 *= deg2rad;
337
	var diam = 12742; // Diameter of the earth in km (2 * 6371)
338
	var dLat = lat2 - lat1;
339
	var dLon = lon2 - lon1;
340
	var a = ((1 - cos(dLat)) + (1 - cos(dLon)) * cos(lat1) * cos(lat2)) / 2;
23837 ashik.ali 341
 
27797 tejbeer 342
	return parseFloat(diam * Math.asin(Math.sqrt(a))).toFixed(2);
24125 govind 343
}
23837 ashik.ali 344
 
24125 govind 345
function getRetailerDetailsByEmailIdOrMobileNumber(domId, emailIdOrMobileNumber) {
27797 tejbeer 346
	doGetAjaxRequestHandler(context + "/retailerDetails?emailIdOrMobileNumber="
347
		+ emailIdOrMobileNumber, function(response) {
348
			$('#' + domId).html(response);
349
			if ($("#location").is(":checked")) {
27171 tejbeer 350
 
27797 tejbeer 351
				$("#divLocation").show();
352
			}
353
		});
23347 ashik.ali 354
}
355
 
24125 govind 356
function updateRetailerDocument() {
27797 tejbeer 357
	// $("#updateRetailerShopDocument0").click( function() {
358
	console.log("Update Retailer Document Clicked");
359
	// console.log(ownerId);
360
	var emailIdOrMobileNumber = $('#retailer-details-search-text').val();
361
	console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);
362
	var file = $('#retailerDocument')[0].files[0];
363
	console.log("file : " + file.name);
364
	uploadRetailerDocument("retailer-details-container", file,
365
		emailIdOrMobileNumber);
23347 ashik.ali 366
}
367
 
24125 govind 368
function updateRetailerShopDocument(ownerId) {
27797 tejbeer 369
	// $("#updateRetailerShopDocument0").click( function() {
370
	console.log("Update Retailer Shop Document Clicked");
371
	console.log(ownerId);
372
	var shopSize = parseInt($("#shopDetailsSize").attr('size'));
373
	console.log("size : " + shopSize);
374
	for (var index = 0; index < shopSize; index++) {
375
		if ("updateRetailerShopDocument" + index == ownerId) {
376
			var emailIdOrMobileNumber = $('#retailer-details-search-text')
377
				.val();
378
			console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);
379
			var shopId = $('#retailerShopDocument' + index).attr("shopId");
380
			console.log("shopId : " + shopId);
381
			var file = $('#retailerShopDocument' + index)[0].files[0];
382
			console.log("file : " + file.name);
383
			uploadRetailerShopDocument("retailer-details-container", file,
384
				emailIdOrMobileNumber, shopId);
385
		}
386
	}
23347 ashik.ali 387
}
388
 
24125 govind 389
function loadDistrictNames(stateName) {
27797 tejbeer 390
	if (undefined != $("#districtName")) {
391
		doGetAjaxRequestHandler(
392
			context + "/district/all/stateName?stateName=" + stateName,
393
			function(response) {
394
				console.log(response);
395
				var districtMasters = response.response;
396
				// districtMasters = districtMasters.response;
397
				var districtNameElements = '<option value="" disabled selected>District Name</option>';
398
				for (index = 0; index < districtMasters.length; index++) {
399
					districtNameElements = districtNameElements
400
						+ '<option value="'
401
						+ districtMasters[index].name + '">'
402
						+ districtMasters[index].name + '</option>';
403
				}
404
				$('#districtName').html(districtNameElements);
405
			});
406
	}
23347 ashik.ali 407
}
408
 
24125 govind 409
function retailerInfo(domId) {
27797 tejbeer 410
	doGetAjaxRequestHandler(context + "/retailerInfo", function(response) {
411
		$('#' + domId).html(response);
24159 tejbeer 412
 
27797 tejbeer 413
	});
24159 tejbeer 414
 
24125 govind 415
}
27231 tejbeer 416
 
27516 amit.gupta 417
function partnerInfo(domId) {
27797 tejbeer 418
	doGetAjaxRequestHandler(context + "/getPartnerReadonlyInfo", function(response) {
419
		$('#' + domId).html(response);
27516 amit.gupta 420
 
27797 tejbeer 421
	});
27231 tejbeer 422
}
28071 tejbeer 423
function blockBrandMapping(domId) {
424
	doGetAjaxRequestHandler(context + "/getBlockBrandMapping", function(response) {
425
		$('#' + domId).html(response);
27516 amit.gupta 426
 
28071 tejbeer 427
	});
428
}
28272 tejbeer 429
function brandsLimit(domId) {
430
	doGetAjaxRequestHandler(context + "/getBrandslimit", function(response) {
431
		$('#' + domId).html(response);
28071 tejbeer 432
 
28272 tejbeer 433
	});
434
}
24125 govind 435
function storeInfo(domId) {
27797 tejbeer 436
	doGetAjaxRequestHandler(context + "/getAllStores", function(response) {
437
		$('#' + domId).html(response);
438
	});
24125 govind 439
}
27516 amit.gupta 440
 
29268 manish 441
function store(domId) {
442
	doGetAjaxRequestHandler(context + "/getstore", function(response) {
443
		$('#' + domId).html(response);
444
	});
445
}
24680 govind 446
function inactiveStoreInfo(domId) {
27797 tejbeer 447
	doGetAjaxRequestHandler(context + "/getAllInactiveStores", function(
448
		response) {
449
		$('#' + domId).html(response);
450
	});
24680 govind 451
}
27516 amit.gupta 452
 
28381 tejbeer 453
function allPartnerPincode(domId) {
454
	doGetAjaxRequestHandler(context + "/getAllPartnerPincode", function(
455
		response) {
456
		$('#' + domId).html(response);
457
	});
458
}
459
 
24125 govind 460
function deactivateStore(domId, fofoId) {
27797 tejbeer 461
	doPostAjaxRequestHandler(context + "/deactivateStore?fofoId=" + fofoId,
462
		function(response) {
463
			if (response == "true") {
464
				alert("successfully deactivated!");
465
				storeInfo(domId);
466
			}
24159 tejbeer 467
 
27797 tejbeer 468
		});
24125 govind 469
}
28711 amit.gupta 470
function activateStoreForever(domId, fofoId) {
471
	doPostAjaxRequestHandler(context + "/activateStoreForever?fofoId=" + fofoId,
472
		function(response) {
473
			if (response == "true") {
474
				alert("successfully activated!");
475
				inactiveStoreInfo(domId);
476
			}
27516 amit.gupta 477
 
28711 amit.gupta 478
		});
479
}
480
 
24976 amit.gupta 481
function loginAsPartner(fofoId) {
27797 tejbeer 482
	doGetAjaxRequestHandler(context + "/login-as-partner?fofoId=" + fofoId,
483
		function(response) {
484
			window.create({
485
				"url": "/dashboard",
486
				"incognito": true
487
			});
31860 tejbeer 488
 
27797 tejbeer 489
		});
24976 amit.gupta 490
}
27231 tejbeer 491
 
492
function loginAsPartnerReadonly(fofoId) {
27797 tejbeer 493
	doGetAjaxRequestHandler(context + "/login-as-partner-readonly?fofoId=" + fofoId,
494
		function(response) {
495
			window.create({
496
				"url": "/dashboard",
497
				"incognito": true
498
			});
499
		});
27231 tejbeer 500
}
27516 amit.gupta 501
 
24349 amit.gupta 502
function extendBilling(container, fofoId) {
27797 tejbeer 503
	doPostAjaxRequestHandler(context + "/extendBilling?fofoId=" + fofoId,
504
		function(response) {
505
			if (isFinite(response)) {
506
				alert("successfully deactivated!");
507
				container.html("Billing extended upto "
508
					+ moment().add(1, 'day').format("DD-MM-YY")
509
					+ " Grace count(" + response + ")");
510
			}
511
		});
24349 amit.gupta 512
}
24159 tejbeer 513
 
514
function updateLocationButton(id) {
515
 
27797 tejbeer 516
	var userId = id;
517
	var name = $('#personName').val();
518
	var line1 = $('#line1').val();
519
	var line2 = $('#line2').val();
520
	var city = $('#city').val();
521
	var state = $('#state').val();
522
	var pin = $('#pinCode').val();
523
	console.log(id);
524
	if (name === "" && line1 === "" && city === "" && pin === "") {
525
		alert("Field can't be empty");
526
		return;
527
	}
528
	if (name === "") {
529
		alert("name is required");
530
		return;
531
	}
532
	if (line1 === "") {
533
		alert("line1 is required");
534
		return;
535
	}
536
	if (city === "") {
537
		alert("city is required");
538
		return;
539
	}
540
	if (pin === "") {
541
		alert("pin is required");
542
		return;
543
	}
24159 tejbeer 544
 
27797 tejbeer 545
	var changeLocationData = {};
24159 tejbeer 546
 
27797 tejbeer 547
	changeLocationData['userId'] = id;
548
	changeLocationData['name'] = $('#personName').val();
549
	changeLocationData['line1'] = $('#line1').val();
550
	changeLocationData['line2'] = $('#line2').val();
551
	changeLocationData['city'] = $('#city').val();
552
	changeLocationData['state'] = $('#state').val();
553
	changeLocationData['pin'] = $('#pinCode').val();
24159 tejbeer 554
 
27797 tejbeer 555
	console.log(changeLocationData);
24159 tejbeer 556
 
27797 tejbeer 557
	if (confirm("Are you sure you want to add location!") == true) {
558
		doPostAjaxRequestWithJsonHandler(context + "/updateLocation", JSON
559
			.stringify(changeLocationData), function(response) {
560
				if (response == 'true') {
561
					alert("successfully Update");
24159 tejbeer 562
 
27797 tejbeer 563
					$("#addLocationModal").modal('hide');
24159 tejbeer 564
 
27797 tejbeer 565
				}
566
			});
24159 tejbeer 567
 
27797 tejbeer 568
		return false;
569
	}
24159 tejbeer 570
 
571
}