Subversion Repositories SmartDukaan

Rev

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