Subversion Repositories SmartDukaan

Rev

Rev 33814 | Rev 34088 | 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);
33124 ranu 106
						loadASTDetail(response.response.state);
27797 tejbeer 107
						for (let city of response.response.cities) {
108
							var opt = $("<option>").val(city).text(city);
109
							$('#retailerAddressCity').append(opt);
24349 amit.gupta 110
 
27797 tejbeer 111
						}
24159 tejbeer 112
 
27797 tejbeer 113
					});
114
			}
115
		});
24159 tejbeer 116
 
27797 tejbeer 117
	$(document).on("keyup", "#retailer-details-search-text", function(e) {
118
		var keyCode = e.keyCode || e.which;
119
		if (keyCode == 13) {
120
			$("#retailer-details-search-button").click();
121
		}
122
	});
24159 tejbeer 123
 
27797 tejbeer 124
	$(document).on('click', ".deactivate-store", function() {
125
		var fofoId = $(this).data("fofoid");
126
		console.log(fofoId);
127
		if (confirm("Are you sure you want to deactivate store!") == true) {
128
			deactivateStore("main-content", fofoId);
129
		}
27171 tejbeer 130
 
27797 tejbeer 131
	});
28711 amit.gupta 132
	$(document).on('click', ".activate-store-forever", function() {
133
		var fofoId = $(this).data("fofoid");
134
		console.log(fofoId);
135
		if (confirm("Are you sure you want to activate this store!") == true) {
136
			activateStoreForever("main-content", fofoId);
137
		}
138
 
139
	});
31860 tejbeer 140
 
27797 tejbeer 141
	$(document).on('click', ".login_as", function() {
142
		var fofoId = $('#partnerId').val();
143
		loginAsPartner(fofoId);
24159 tejbeer 144
 
27797 tejbeer 145
	});
24159 tejbeer 146
 
31860 tejbeer 147
 
31892 tejbeer 148
	$('#partnerSecondary').on('click', '.brandFocusedStock', function() {
34087 ranu 149
 
31892 tejbeer 150
		var fofoId = $(this).data('fofoid');
151
		var brand = $(this).data('brand');
152
 
31895 tejbeer 153
		doGetAjaxRequestHandler(
154
			"https://partners.smartdukaan.com" + "/getPartnerShortageStock?brand=" + brand + "&fofoId="
31892 tejbeer 155
			+ fofoId, function(response) {
156
 
157
				$('#itemWiseBrandStock .modal-content').html(response);
158
 
159
			});
160
	});
161
 
34087 ranu 162
	$(document).on('click', '.brandFocusedStockDetail', function () {
31892 tejbeer 163
 
34087 ranu 164
		var fofoId = $(this).data('fofoid');
165
		var brand = $(this).data('brand');
31892 tejbeer 166
 
34087 ranu 167
		doGetAjaxRequestHandler(
168
			"https://partners.smartdukaan.com" + "/getPartnerShortageStockDetail?brand=" + brand + "&fofoId="
169
			+ fofoId, function (response) {
170
 
171
				$('#itemWiseBrandStockDetail').html(response);
172
 
173
			});
174
	});
175
 
176
 
177
 
31932 tejbeer 178
	$(document).on('click', ".agingDataAfterNintyDays", function() {
179
		var fofoId = $(this).data('fofoid');
180
		console.log(fofoId)
181
 
182
		doPostAjaxRequestWithJsonHandler(
183
			"https://partners.smartdukaan.com" + "/getInventoryItemAgingByFofoId?fofoId="
184
			+ fofoId, JSON.stringify([90]),
185
			function(response) {
186
				$('#agingItemWiseBrandStock .modal-content').html(response);
187
			});
188
	});
189
 
190
 
191
 
27797 tejbeer 192
	$(document).on('click', ".extend-billing", function() {
193
		var fofoId = $(this).data("fofoid");
194
		console.log(fofoId);
195
		if (confirm("Are you sure you want to extend Billing?")) {
196
			extendBilling($(this).parent(), fofoId);
197
		}
24159 tejbeer 198
 
27797 tejbeer 199
	});
24159 tejbeer 200
 
31860 tejbeer 201
	/*
202
	 * $(document).on('change', '#retailerAddressState', function() { var stateName =
203
	 * $(this).find('option:selected').text();
204
	 *
205
	 * loadDistrictNames(stateName); });
206
	 */
24159 tejbeer 207
 
208
 
27797 tejbeer 209
	$(document).on('click', "#location", function() {
210
		if ($(this).is(":checked")) {
27516 amit.gupta 211
 
27797 tejbeer 212
			$("#divLocation").show();
27516 amit.gupta 213
 
27797 tejbeer 214
		} else {
215
			$("#divLocation").hide();
216
		}
217
	});
27516 amit.gupta 218
 
219
 
27797 tejbeer 220
	$(document).on('click', ".changePartnerCategory", function() {
221
		$clickedElement = $(this);
222
		var fofoId = $clickedElement.data("id");
223
		$tdElement = $(this).closest('td');
224
		doGetAjaxRequestHandler(context + "/getPartnerCategory?fofoId=" + fofoId, function(response) {
27516 amit.gupta 225
 
27797 tejbeer 226
			$tdElement.html(response);
227
			$tdElement.find('.partnerCategory').multiselect({
228
				includeSelectAllOption: true,
229
				multiple: true,
230
				maxHeight: 200,
231
				buttonWidth: '180px',
232
				numberDisplayed: 1,
233
				nonSelectedText: 'Category',
234
				nSelectedText: ' - Category Selected',
235
				allSelectedText: 'All Category Selected',
236
				enableFiltering: true,
237
				enableCaseInsensitiveFiltering: true
238
			});
239
		});
240
	});
27516 amit.gupta 241
 
242
 
27797 tejbeer 243
	$(document).on('click', ".update-category",
244
		function() {
245
			var fofoId = $(this).data('fofoid');
246
			var partnerType = $('#partnerCategory').val();
27516 amit.gupta 247
 
27797 tejbeer 248
			if (confirm("Are you sure you want to update the partners!") == true) {
249
				doPostAjaxRequestHandler(context
250
					+ "/updatePartnerCategory?fofoId="
251
					+ fofoId + "&partnerType=" + partnerType, function(
252
						response) {
253
					if (response == "true") {
254
						alert("Update successfully");
255
						storeInfo("main-content");
256
					}
257
				});
258
			}
27516 amit.gupta 259
 
27797 tejbeer 260
		});
261
 
262
 
31860 tejbeer 263
 
264
 
27797 tejbeer 265
	$(document).on('click', ".addlocationbutton",
266
		function() {
267
			var userId = $('#retailerId').text();
268
			var name = $('#personName').val();
269
			var line1 = $('#line1').val();
270
			var line2 = $('#line2').val();
271
			var city = $('#city').val();
272
			var state = $('#state').val();
273
			var pin = $('#pinCode').val();
274
 
275
			if (name === "" && line1 === "" && city === "" && pin === "") {
276
				alert("Field can't be empty");
277
				return;
278
			}
279
			if (name === "") {
280
				alert("name is required");
281
				return;
282
			}
283
			if (line1 === "") {
284
				alert("line1 is required");
285
				return;
286
			}
287
			if (city === "") {
288
				alert("city is required");
289
				return;
290
			}
291
			if (pin === "") {
292
				alert("pin is required");
293
				return;
294
			}
295
 
296
			var locationData = {};
297
			locationData['userId'] = $('#retailerId').text();
298
			locationData['name'] = $('#personName').val();
299
			locationData['line1'] = $('#line1').val();
300
			locationData['line2'] = $('#line2').val();
301
			locationData['city'] = $('#city').val();
302
			locationData['state'] = $('#state').val();
303
			locationData['pin'] = $('#pinCode').val();
304
 
305
			if (confirm("Are you sure you want to add location!") == true) {
306
				doPostAjaxRequestWithJsonHandler(context + "/addLocation",
307
					JSON.stringify(locationData), function(response) {
308
						if (response == 'true') {
309
							alert("successfully Add");
310
							$("#addLocationModal").modal('hide');
311
 
312
						}
313
					});
314
 
315
				return false;
316
			}
317
		});
318
 
32044 tejbeer 319
 
320
 
321
	//Performance
322
	$(document).on('click', ".partner-performance-access", function() {
323
		doGetAjaxRequestHandler(context + "/getPartnersForPerformance", function(response) {
324
			$('#' + "main-content").html(response);
325
		});
326
	});
327
 
328
	$(document).on('click', ".partnerPerformance", function() {
329
		var fofoId = $('#fofo-users').val();
330
		var url = context + "/partnerPerformance?fofoId=" + fofoId;
331
		//$('.partner-performance-container').html(`<iframe class="wrapper" src="${url}" style="width:100%;height:100vh"> </iframe>`); 
332
		doGetAjaxRequestHandler(context + "/partnerPerformance?fofoId=" + fofoId, function(response) {
333
			$('.partner-performance-container').html(response);
334
		});
335
	});
336
 
337
	$(document).on('click', ".retailer-filter", function() {
338
		doGetAjaxRequestHandler(context + "/getFilters", function(response) {
339
			$('#' + "main-content").html(response);
340
		});
341
	});
342
 
343
 
344
	$(document).on('click', ".filters", function() {
345
 
346
		var credit = $('#credit').is(':checked');
347
		var billing = $('#billing').is(':checked');
348
		var investment = $('#investment').is(':checked');
349
		var secondary = $('#secondary').is(':checked');
350
		var tertiary = $('#tertiary').is(':checked');
351
		var mtds = $('#mtds').is(':checked');
352
		var mtdt = $('#mtdt').is(':checked');
353
 
354
		var investmentPct = $('#investmentvalue').val();
355
		var secondaryDays = $('#secondaryvalue').val();
356
		var tertiaryDays = $('#tertiaryvalue').val();
357
		var mtdsPct = $('#mtdsvalue').val();
358
		var mtdtPct = $('#mtdtvalue').val();
359
 
360
		console.log(investmentPct)
361
 
362
 
363
 
364
		var retailerFilters = {};
365
		retailerFilters['credit'] = credit;
366
		retailerFilters['billing'] = billing
367
		if (investment) {
368
			retailerFilters['investmentPct'] = investmentPct
369
		}
370
		if (secondary) {
371
			retailerFilters['secondaryDays'] = secondaryDays
372
		}
373
		if (tertiary) {
374
			retailerFilters['tertiaryDays'] = tertiaryDays
375
		}
376
 
377
		if (mtds) {
378
			retailerFilters['mtdsPct'] = mtdsPct
379
		}
380
 
381
		if (mtdt) {
382
			retailerFilters['mtdtPct'] = mtdtPct
383
		}
384
 
32089 tejbeer 385
		console.log(JSON.stringify(retailerFilters));
386
 
32044 tejbeer 387
		doAjaxRequestWithJsonHandler(context + "/getFilteredRetailers", 'POST', JSON.stringify(retailerFilters), function(response) {
388
			$('.filtered-partner-performance-container').html(response);
389
 
390
		});
391
	});
392
 
393
 
394
 
395
	$(document).on('click', ".default-email-val", function() {
396
 
397
		var credit = $('#credit').is(':checked');
398
		var billing = $('#billing').is(':checked');
399
		var investment = $('#investment').is(':checked');
400
		var secondary = $('#secondary').is(':checked');
401
		var tertiary = $('#tertiary').is(':checked');
402
		var mtds = $('#mtds').is(':checked');
403
		var mtdt = $('#mtdt').is(':checked');
404
 
405
		var investmentPct = $('#investmentvalue').val();
406
		var secondaryDays = $('#secondaryvalue').val();
407
		var tertiaryDays = $('#tertiaryvalue').val();
408
		var mtdsPct = $('#mtdsvalue').val();
409
		var mtdtPct = $('#mtdtvalue').val();
410
 
411
		console.log(investmentPct)
412
 
413
 
414
 
415
		var retailerFilters = {};
416
		retailerFilters['credit'] = credit;
417
		retailerFilters['billing'] = billing
418
		retailerFilters['investmentPct'] = investmentPct
419
		retailerFilters['secondaryDays'] = secondaryDays
420
		retailerFilters['tertiaryDays'] = tertiaryDays
421
		retailerFilters['mtdsPct'] = mtdsPct
422
		retailerFilters['mtdtPct'] = mtdtPct
423
 
424
 
425
 
426
 
427
		doAjaxRequestWithJsonHandler(context + "/defaultFilterSetForEmail", 'POST', JSON.stringify(retailerFilters), function(response) {
428
			if (response == "true") {
429
				alert("Successfully Done")
430
			}
431
		});
432
	});
433
 
434
 
23347 ashik.ali 435
});
436
 
23837 ashik.ali 437
function getDistance(lat1, lon1, lat2, lon2) {
27797 tejbeer 438
	var deg2rad = 0.017453292519943295; // === Math.PI / 180
439
	var cos = Math.cos;
440
	lat1 *= deg2rad;
441
	lon1 *= deg2rad;
442
	lat2 *= deg2rad;
443
	lon2 *= deg2rad;
444
	var diam = 12742; // Diameter of the earth in km (2 * 6371)
445
	var dLat = lat2 - lat1;
446
	var dLon = lon2 - lon1;
447
	var a = ((1 - cos(dLat)) + (1 - cos(dLon)) * cos(lat1) * cos(lat2)) / 2;
23837 ashik.ali 448
 
27797 tejbeer 449
	return parseFloat(diam * Math.asin(Math.sqrt(a))).toFixed(2);
24125 govind 450
}
23837 ashik.ali 451
 
24125 govind 452
function getRetailerDetailsByEmailIdOrMobileNumber(domId, emailIdOrMobileNumber) {
27797 tejbeer 453
	doGetAjaxRequestHandler(context + "/retailerDetails?emailIdOrMobileNumber="
454
		+ emailIdOrMobileNumber, function(response) {
455
			$('#' + domId).html(response);
456
			if ($("#location").is(":checked")) {
27171 tejbeer 457
 
27797 tejbeer 458
				$("#divLocation").show();
459
			}
460
		});
23347 ashik.ali 461
}
462
 
24125 govind 463
function updateRetailerDocument() {
27797 tejbeer 464
	// $("#updateRetailerShopDocument0").click( function() {
465
	console.log("Update Retailer Document Clicked");
466
	// console.log(ownerId);
467
	var emailIdOrMobileNumber = $('#retailer-details-search-text').val();
468
	console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);
469
	var file = $('#retailerDocument')[0].files[0];
470
	console.log("file : " + file.name);
471
	uploadRetailerDocument("retailer-details-container", file,
472
		emailIdOrMobileNumber);
23347 ashik.ali 473
}
474
 
24125 govind 475
function updateRetailerShopDocument(ownerId) {
27797 tejbeer 476
	// $("#updateRetailerShopDocument0").click( function() {
477
	console.log("Update Retailer Shop Document Clicked");
478
	console.log(ownerId);
479
	var shopSize = parseInt($("#shopDetailsSize").attr('size'));
480
	console.log("size : " + shopSize);
481
	for (var index = 0; index < shopSize; index++) {
482
		if ("updateRetailerShopDocument" + index == ownerId) {
483
			var emailIdOrMobileNumber = $('#retailer-details-search-text')
484
				.val();
485
			console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);
486
			var shopId = $('#retailerShopDocument' + index).attr("shopId");
487
			console.log("shopId : " + shopId);
488
			var file = $('#retailerShopDocument' + index)[0].files[0];
489
			console.log("file : " + file.name);
490
			uploadRetailerShopDocument("retailer-details-container", file,
491
				emailIdOrMobileNumber, shopId);
492
		}
493
	}
23347 ashik.ali 494
}
495
 
24125 govind 496
function loadDistrictNames(stateName) {
27797 tejbeer 497
	if (undefined != $("#districtName")) {
498
		doGetAjaxRequestHandler(
499
			context + "/district/all/stateName?stateName=" + stateName,
500
			function(response) {
501
				console.log(response);
502
				var districtMasters = response.response;
503
				// districtMasters = districtMasters.response;
504
				var districtNameElements = '<option value="" disabled selected>District Name</option>';
505
				for (index = 0; index < districtMasters.length; index++) {
506
					districtNameElements = districtNameElements
507
						+ '<option value="'
508
						+ districtMasters[index].name + '">'
509
						+ districtMasters[index].name + '</option>';
510
				}
511
				$('#districtName').html(districtNameElements);
512
			});
513
	}
23347 ashik.ali 514
}
515
 
33124 ranu 516
function loadASTDetail(stateName) {
517
	doGetAjaxRequestHandler(
518
		context + "/astDetail?stateName=" + stateName,
33128 amit.gupta 519
		function (asts) {
33124 ranu 520
			$('#retailerAstId').find('option').not(':first').remove();
33128 amit.gupta 521
			for (let ast of asts) {
522
				var opt = $("<option>").val(ast.id).text(ast.area + "(" + ast.areaDescription + ")" + " - " + ast.territory + "(" + ast.territoryDescription + ")");
33124 ranu 523
				$('#retailerAstId').append(opt);
524
			}
525
		}
526
	);
527
}
528
 
24125 govind 529
function retailerInfo(domId) {
27797 tejbeer 530
	doGetAjaxRequestHandler(context + "/retailerInfo", function(response) {
531
		$('#' + domId).html(response);
24159 tejbeer 532
 
27797 tejbeer 533
	});
24159 tejbeer 534
 
24125 govind 535
}
27231 tejbeer 536
 
27516 amit.gupta 537
function partnerInfo(domId) {
27797 tejbeer 538
	doGetAjaxRequestHandler(context + "/getPartnerReadonlyInfo", function(response) {
539
		$('#' + domId).html(response);
27516 amit.gupta 540
 
27797 tejbeer 541
	});
27231 tejbeer 542
}
28071 tejbeer 543
function blockBrandMapping(domId) {
544
	doGetAjaxRequestHandler(context + "/getBlockBrandMapping", function(response) {
545
		$('#' + domId).html(response);
27516 amit.gupta 546
 
28071 tejbeer 547
	});
548
}
28272 tejbeer 549
function brandsLimit(domId) {
550
	doGetAjaxRequestHandler(context + "/getBrandslimit", function(response) {
551
		$('#' + domId).html(response);
28071 tejbeer 552
 
28272 tejbeer 553
	});
554
}
24125 govind 555
function storeInfo(domId) {
27797 tejbeer 556
	doGetAjaxRequestHandler(context + "/getAllStores", function(response) {
557
		$('#' + domId).html(response);
558
	});
24125 govind 559
}
27516 amit.gupta 560
 
29268 manish 561
function store(domId) {
562
	doGetAjaxRequestHandler(context + "/getstore", function(response) {
563
		$('#' + domId).html(response);
564
	});
565
}
24680 govind 566
function inactiveStoreInfo(domId) {
27797 tejbeer 567
	doGetAjaxRequestHandler(context + "/getAllInactiveStores", function(
568
		response) {
569
		$('#' + domId).html(response);
570
	});
24680 govind 571
}
27516 amit.gupta 572
 
28381 tejbeer 573
function allPartnerPincode(domId) {
574
	doGetAjaxRequestHandler(context + "/getAllPartnerPincode", function(
575
		response) {
576
		$('#' + domId).html(response);
577
	});
578
}
579
 
24125 govind 580
function deactivateStore(domId, fofoId) {
27797 tejbeer 581
	doPostAjaxRequestHandler(context + "/deactivateStore?fofoId=" + fofoId,
582
		function(response) {
583
			if (response == "true") {
584
				alert("successfully deactivated!");
585
				storeInfo(domId);
586
			}
24159 tejbeer 587
 
27797 tejbeer 588
		});
24125 govind 589
}
28711 amit.gupta 590
function activateStoreForever(domId, fofoId) {
591
	doPostAjaxRequestHandler(context + "/activateStoreForever?fofoId=" + fofoId,
592
		function(response) {
593
			if (response == "true") {
594
				alert("successfully activated!");
595
				inactiveStoreInfo(domId);
596
			}
27516 amit.gupta 597
 
28711 amit.gupta 598
		});
599
}
600
 
24976 amit.gupta 601
function loginAsPartner(fofoId) {
27797 tejbeer 602
	doGetAjaxRequestHandler(context + "/login-as-partner?fofoId=" + fofoId,
603
		function(response) {
604
			window.create({
605
				"url": "/dashboard",
606
				"incognito": true
607
			});
31860 tejbeer 608
 
27797 tejbeer 609
		});
24976 amit.gupta 610
}
27231 tejbeer 611
 
612
function loginAsPartnerReadonly(fofoId) {
27797 tejbeer 613
	doGetAjaxRequestHandler(context + "/login-as-partner-readonly?fofoId=" + fofoId,
614
		function(response) {
615
			window.create({
616
				"url": "/dashboard",
617
				"incognito": true
618
			});
619
		});
27231 tejbeer 620
}
27516 amit.gupta 621
 
24349 amit.gupta 622
function extendBilling(container, fofoId) {
27797 tejbeer 623
	doPostAjaxRequestHandler(context + "/extendBilling?fofoId=" + fofoId,
624
		function(response) {
625
			if (isFinite(response)) {
626
				alert("successfully deactivated!");
627
				container.html("Billing extended upto "
628
					+ moment().add(1, 'day').format("DD-MM-YY")
629
					+ " Grace count(" + response + ")");
630
			}
631
		});
24349 amit.gupta 632
}
24159 tejbeer 633
 
634
function updateLocationButton(id) {
635
 
27797 tejbeer 636
	var userId = id;
637
	var name = $('#personName').val();
638
	var line1 = $('#line1').val();
639
	var line2 = $('#line2').val();
640
	var city = $('#city').val();
641
	var state = $('#state').val();
642
	var pin = $('#pinCode').val();
643
	console.log(id);
644
	if (name === "" && line1 === "" && city === "" && pin === "") {
645
		alert("Field can't be empty");
646
		return;
647
	}
648
	if (name === "") {
649
		alert("name is required");
650
		return;
651
	}
652
	if (line1 === "") {
653
		alert("line1 is required");
654
		return;
655
	}
656
	if (city === "") {
657
		alert("city is required");
658
		return;
659
	}
660
	if (pin === "") {
661
		alert("pin is required");
662
		return;
663
	}
24159 tejbeer 664
 
27797 tejbeer 665
	var changeLocationData = {};
24159 tejbeer 666
 
27797 tejbeer 667
	changeLocationData['userId'] = id;
668
	changeLocationData['name'] = $('#personName').val();
669
	changeLocationData['line1'] = $('#line1').val();
670
	changeLocationData['line2'] = $('#line2').val();
671
	changeLocationData['city'] = $('#city').val();
672
	changeLocationData['state'] = $('#state').val();
673
	changeLocationData['pin'] = $('#pinCode').val();
24159 tejbeer 674
 
27797 tejbeer 675
	console.log(changeLocationData);
24159 tejbeer 676
 
27797 tejbeer 677
	if (confirm("Are you sure you want to add location!") == true) {
678
		doPostAjaxRequestWithJsonHandler(context + "/updateLocation", JSON
679
			.stringify(changeLocationData), function(response) {
680
				if (response == 'true') {
681
					alert("successfully Update");
24159 tejbeer 682
 
27797 tejbeer 683
					$("#addLocationModal").modal('hide');
24159 tejbeer 684
 
27797 tejbeer 685
				}
686
			});
24159 tejbeer 687
 
27797 tejbeer 688
		return false;
689
	}
24159 tejbeer 690
 
33814 ranu 691
}
692
 
693
$(document).on('click', ".retailer_contacts", function () {
694
	doGetAjaxRequestHandler(context + "/alternateRetailerContacts",
695
		function (response) {
696
			$('#' + 'main-content').html(response);
697
		});
698
});
699
 
700
$(document).on('click', '.get-retailer-contacts', function () {
701
 
702
	if (typeof partnerId != "undefined") {
703
		doGetAjaxRequestHandler(context + "/retailer-contact-list?fofoId=" + partnerId,
704
			function (response) {
705
				$('.retailer-contacts-container').html(response);
706
			});
707
	}
708
 
709
});
710
 
711
$(document).on('click', '.retailer-contact-submit', function () {
712
	var contactName = $('#retailer-contact-name').val();
713
	var contactNumber = $('#retailer-contact-number').val();
714
 
715
	if (typeof partnerId != "undefined") {
716
		doGetAjaxRequestHandler(context + "/add-retailer-contact-list?contactName=" + contactName + "&contactNumber=" + contactNumber + "&fofoId=" + partnerId,
717
			function (response) {
718
				$('#update-retailer-contact-modal').modal('toggle');
719
				$('.retailer-contacts-container').html(response);
720
			});
721
	}
722
 
723
});
724
 
725
$(document).on('click', '.update-contact-status', function () {
726
	var contactId = $(this).data('contactid');
727
	var active = $(this).data('status');
728
 
729
	if (typeof partnerId != "undefined") {
730
		doGetAjaxRequestHandler(context + "/update-contact-status?contactId=" + contactId + "&fofoId=" + partnerId + "&active=" + active,
731
			function (response) {
732
				$('.retailer-contacts-container').html(response);
733
			});
734
	}
735
 
736
});