Subversion Repositories SmartDukaan

Rev

Rev 32044 | Rev 33124 | 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
 
32089 tejbeer 372
		console.log(JSON.stringify(retailerFilters));
373
 
32044 tejbeer 374
		doAjaxRequestWithJsonHandler(context + "/getFilteredRetailers", 'POST', JSON.stringify(retailerFilters), function(response) {
375
			$('.filtered-partner-performance-container').html(response);
376
 
377
		});
378
	});
379
 
380
 
381
 
382
	$(document).on('click', ".default-email-val", function() {
383
 
384
		var credit = $('#credit').is(':checked');
385
		var billing = $('#billing').is(':checked');
386
		var investment = $('#investment').is(':checked');
387
		var secondary = $('#secondary').is(':checked');
388
		var tertiary = $('#tertiary').is(':checked');
389
		var mtds = $('#mtds').is(':checked');
390
		var mtdt = $('#mtdt').is(':checked');
391
 
392
		var investmentPct = $('#investmentvalue').val();
393
		var secondaryDays = $('#secondaryvalue').val();
394
		var tertiaryDays = $('#tertiaryvalue').val();
395
		var mtdsPct = $('#mtdsvalue').val();
396
		var mtdtPct = $('#mtdtvalue').val();
397
 
398
		console.log(investmentPct)
399
 
400
 
401
 
402
		var retailerFilters = {};
403
		retailerFilters['credit'] = credit;
404
		retailerFilters['billing'] = billing
405
		retailerFilters['investmentPct'] = investmentPct
406
		retailerFilters['secondaryDays'] = secondaryDays
407
		retailerFilters['tertiaryDays'] = tertiaryDays
408
		retailerFilters['mtdsPct'] = mtdsPct
409
		retailerFilters['mtdtPct'] = mtdtPct
410
 
411
 
412
 
413
 
414
		doAjaxRequestWithJsonHandler(context + "/defaultFilterSetForEmail", 'POST', JSON.stringify(retailerFilters), function(response) {
415
			if (response == "true") {
416
				alert("Successfully Done")
417
			}
418
		});
419
	});
420
 
421
 
23347 ashik.ali 422
});
423
 
23837 ashik.ali 424
function getDistance(lat1, lon1, lat2, lon2) {
27797 tejbeer 425
	var deg2rad = 0.017453292519943295; // === Math.PI / 180
426
	var cos = Math.cos;
427
	lat1 *= deg2rad;
428
	lon1 *= deg2rad;
429
	lat2 *= deg2rad;
430
	lon2 *= deg2rad;
431
	var diam = 12742; // Diameter of the earth in km (2 * 6371)
432
	var dLat = lat2 - lat1;
433
	var dLon = lon2 - lon1;
434
	var a = ((1 - cos(dLat)) + (1 - cos(dLon)) * cos(lat1) * cos(lat2)) / 2;
23837 ashik.ali 435
 
27797 tejbeer 436
	return parseFloat(diam * Math.asin(Math.sqrt(a))).toFixed(2);
24125 govind 437
}
23837 ashik.ali 438
 
24125 govind 439
function getRetailerDetailsByEmailIdOrMobileNumber(domId, emailIdOrMobileNumber) {
27797 tejbeer 440
	doGetAjaxRequestHandler(context + "/retailerDetails?emailIdOrMobileNumber="
441
		+ emailIdOrMobileNumber, function(response) {
442
			$('#' + domId).html(response);
443
			if ($("#location").is(":checked")) {
27171 tejbeer 444
 
27797 tejbeer 445
				$("#divLocation").show();
446
			}
447
		});
23347 ashik.ali 448
}
449
 
24125 govind 450
function updateRetailerDocument() {
27797 tejbeer 451
	// $("#updateRetailerShopDocument0").click( function() {
452
	console.log("Update Retailer Document Clicked");
453
	// console.log(ownerId);
454
	var emailIdOrMobileNumber = $('#retailer-details-search-text').val();
455
	console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);
456
	var file = $('#retailerDocument')[0].files[0];
457
	console.log("file : " + file.name);
458
	uploadRetailerDocument("retailer-details-container", file,
459
		emailIdOrMobileNumber);
23347 ashik.ali 460
}
461
 
24125 govind 462
function updateRetailerShopDocument(ownerId) {
27797 tejbeer 463
	// $("#updateRetailerShopDocument0").click( function() {
464
	console.log("Update Retailer Shop Document Clicked");
465
	console.log(ownerId);
466
	var shopSize = parseInt($("#shopDetailsSize").attr('size'));
467
	console.log("size : " + shopSize);
468
	for (var index = 0; index < shopSize; index++) {
469
		if ("updateRetailerShopDocument" + index == ownerId) {
470
			var emailIdOrMobileNumber = $('#retailer-details-search-text')
471
				.val();
472
			console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);
473
			var shopId = $('#retailerShopDocument' + index).attr("shopId");
474
			console.log("shopId : " + shopId);
475
			var file = $('#retailerShopDocument' + index)[0].files[0];
476
			console.log("file : " + file.name);
477
			uploadRetailerShopDocument("retailer-details-container", file,
478
				emailIdOrMobileNumber, shopId);
479
		}
480
	}
23347 ashik.ali 481
}
482
 
24125 govind 483
function loadDistrictNames(stateName) {
27797 tejbeer 484
	if (undefined != $("#districtName")) {
485
		doGetAjaxRequestHandler(
486
			context + "/district/all/stateName?stateName=" + stateName,
487
			function(response) {
488
				console.log(response);
489
				var districtMasters = response.response;
490
				// districtMasters = districtMasters.response;
491
				var districtNameElements = '<option value="" disabled selected>District Name</option>';
492
				for (index = 0; index < districtMasters.length; index++) {
493
					districtNameElements = districtNameElements
494
						+ '<option value="'
495
						+ districtMasters[index].name + '">'
496
						+ districtMasters[index].name + '</option>';
497
				}
498
				$('#districtName').html(districtNameElements);
499
			});
500
	}
23347 ashik.ali 501
}
502
 
24125 govind 503
function retailerInfo(domId) {
27797 tejbeer 504
	doGetAjaxRequestHandler(context + "/retailerInfo", function(response) {
505
		$('#' + domId).html(response);
24159 tejbeer 506
 
27797 tejbeer 507
	});
24159 tejbeer 508
 
24125 govind 509
}
27231 tejbeer 510
 
27516 amit.gupta 511
function partnerInfo(domId) {
27797 tejbeer 512
	doGetAjaxRequestHandler(context + "/getPartnerReadonlyInfo", function(response) {
513
		$('#' + domId).html(response);
27516 amit.gupta 514
 
27797 tejbeer 515
	});
27231 tejbeer 516
}
28071 tejbeer 517
function blockBrandMapping(domId) {
518
	doGetAjaxRequestHandler(context + "/getBlockBrandMapping", function(response) {
519
		$('#' + domId).html(response);
27516 amit.gupta 520
 
28071 tejbeer 521
	});
522
}
28272 tejbeer 523
function brandsLimit(domId) {
524
	doGetAjaxRequestHandler(context + "/getBrandslimit", function(response) {
525
		$('#' + domId).html(response);
28071 tejbeer 526
 
28272 tejbeer 527
	});
528
}
24125 govind 529
function storeInfo(domId) {
27797 tejbeer 530
	doGetAjaxRequestHandler(context + "/getAllStores", function(response) {
531
		$('#' + domId).html(response);
532
	});
24125 govind 533
}
27516 amit.gupta 534
 
29268 manish 535
function store(domId) {
536
	doGetAjaxRequestHandler(context + "/getstore", function(response) {
537
		$('#' + domId).html(response);
538
	});
539
}
24680 govind 540
function inactiveStoreInfo(domId) {
27797 tejbeer 541
	doGetAjaxRequestHandler(context + "/getAllInactiveStores", function(
542
		response) {
543
		$('#' + domId).html(response);
544
	});
24680 govind 545
}
27516 amit.gupta 546
 
28381 tejbeer 547
function allPartnerPincode(domId) {
548
	doGetAjaxRequestHandler(context + "/getAllPartnerPincode", function(
549
		response) {
550
		$('#' + domId).html(response);
551
	});
552
}
553
 
24125 govind 554
function deactivateStore(domId, fofoId) {
27797 tejbeer 555
	doPostAjaxRequestHandler(context + "/deactivateStore?fofoId=" + fofoId,
556
		function(response) {
557
			if (response == "true") {
558
				alert("successfully deactivated!");
559
				storeInfo(domId);
560
			}
24159 tejbeer 561
 
27797 tejbeer 562
		});
24125 govind 563
}
28711 amit.gupta 564
function activateStoreForever(domId, fofoId) {
565
	doPostAjaxRequestHandler(context + "/activateStoreForever?fofoId=" + fofoId,
566
		function(response) {
567
			if (response == "true") {
568
				alert("successfully activated!");
569
				inactiveStoreInfo(domId);
570
			}
27516 amit.gupta 571
 
28711 amit.gupta 572
		});
573
}
574
 
24976 amit.gupta 575
function loginAsPartner(fofoId) {
27797 tejbeer 576
	doGetAjaxRequestHandler(context + "/login-as-partner?fofoId=" + fofoId,
577
		function(response) {
578
			window.create({
579
				"url": "/dashboard",
580
				"incognito": true
581
			});
31860 tejbeer 582
 
27797 tejbeer 583
		});
24976 amit.gupta 584
}
27231 tejbeer 585
 
586
function loginAsPartnerReadonly(fofoId) {
27797 tejbeer 587
	doGetAjaxRequestHandler(context + "/login-as-partner-readonly?fofoId=" + fofoId,
588
		function(response) {
589
			window.create({
590
				"url": "/dashboard",
591
				"incognito": true
592
			});
593
		});
27231 tejbeer 594
}
27516 amit.gupta 595
 
24349 amit.gupta 596
function extendBilling(container, fofoId) {
27797 tejbeer 597
	doPostAjaxRequestHandler(context + "/extendBilling?fofoId=" + fofoId,
598
		function(response) {
599
			if (isFinite(response)) {
600
				alert("successfully deactivated!");
601
				container.html("Billing extended upto "
602
					+ moment().add(1, 'day').format("DD-MM-YY")
603
					+ " Grace count(" + response + ")");
604
			}
605
		});
24349 amit.gupta 606
}
24159 tejbeer 607
 
608
function updateLocationButton(id) {
609
 
27797 tejbeer 610
	var userId = id;
611
	var name = $('#personName').val();
612
	var line1 = $('#line1').val();
613
	var line2 = $('#line2').val();
614
	var city = $('#city').val();
615
	var state = $('#state').val();
616
	var pin = $('#pinCode').val();
617
	console.log(id);
618
	if (name === "" && line1 === "" && city === "" && pin === "") {
619
		alert("Field can't be empty");
620
		return;
621
	}
622
	if (name === "") {
623
		alert("name is required");
624
		return;
625
	}
626
	if (line1 === "") {
627
		alert("line1 is required");
628
		return;
629
	}
630
	if (city === "") {
631
		alert("city is required");
632
		return;
633
	}
634
	if (pin === "") {
635
		alert("pin is required");
636
		return;
637
	}
24159 tejbeer 638
 
27797 tejbeer 639
	var changeLocationData = {};
24159 tejbeer 640
 
27797 tejbeer 641
	changeLocationData['userId'] = id;
642
	changeLocationData['name'] = $('#personName').val();
643
	changeLocationData['line1'] = $('#line1').val();
644
	changeLocationData['line2'] = $('#line2').val();
645
	changeLocationData['city'] = $('#city').val();
646
	changeLocationData['state'] = $('#state').val();
647
	changeLocationData['pin'] = $('#pinCode').val();
24159 tejbeer 648
 
27797 tejbeer 649
	console.log(changeLocationData);
24159 tejbeer 650
 
27797 tejbeer 651
	if (confirm("Are you sure you want to add location!") == true) {
652
		doPostAjaxRequestWithJsonHandler(context + "/updateLocation", JSON
653
			.stringify(changeLocationData), function(response) {
654
				if (response == 'true') {
655
					alert("successfully Update");
24159 tejbeer 656
 
27797 tejbeer 657
					$("#addLocationModal").modal('hide');
24159 tejbeer 658
 
27797 tejbeer 659
				}
660
			});
24159 tejbeer 661
 
27797 tejbeer 662
		return false;
663
	}
24159 tejbeer 664
 
665
}