Subversion Repositories SmartDukaan

Rev

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