Subversion Repositories SmartDukaan

Rev

Rev 27755 | Rev 28071 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 27755 Rev 27797
Line 1... Line 1...
1
$(function () {
1
$(function() {
2
 
2
 
3
    $(document).on('click', "#retailer-details-search-button", function () {
3
	$(document).on('click', "#retailer-details-search-button", function() {
4
        searchContent = $("#retailer-details-search-text").val();
4
		searchContent = $("#retailer-details-search-text").val();
5
        if (typeof (searchContent) == "undefined" || !searchContent) {
5
		if (typeof (searchContent) == "undefined" || !searchContent) {
6
            searchContent = "";
6
			searchContent = "";
7
        }
7
		}
8
        getRetailerDetailsByEmailIdOrMobileNumber(
8
		getRetailerDetailsByEmailIdOrMobileNumber(
9
            "retailer-details-container", searchContent);
9
			"retailer-details-container", searchContent);
10
    });
10
	});
11
 
11
 
12
    $(document).on('click', ".active-store", function () {
12
	$(document).on('click', ".active-store", function() {
13
        storeInfo("main-content");
13
		storeInfo("main-content");
14
    });
14
	});
15
    $(document).on('click', ".inactive-store", function () {
15
	$(document).on('click', ".inactive-store", function() {
16
        inactiveStoreInfo("main-content");
16
		inactiveStoreInfo("main-content");
17
    });
17
	});
18
    $(document).on('click', ".retailer-info", function () {
18
	$(document).on('click', ".retailer-info", function() {
19
        retailerInfo("main-content");
19
		retailerInfo("main-content");
20
    });
20
	});
21
 
21
 
22
 
22
 
23
    $(document).on('click', ".partner-readonly-info", function () {
23
	$(document).on('click', ".partner-readonly-info", function() {
24
        partnerInfo("main-content")
24
		partnerInfo("main-content")
25
 
25
 
26
 
26
 
27
    });
27
	});
28
 
28
 
29
 
29
 
30
    $(document).on('click', ".partnerInfoReadOnly",
30
	$(document).on('click', ".partnerInfoReadOnly",
31
            function () {
31
		function() {
32
 
32
 
33
                var fofoId = $('#fofo-users').val();
33
			var fofoId = $('#fofo-users').val();
34
                loginAsPartnerReadonly(fofoId);
34
			loginAsPartnerReadonly(fofoId);
35
            });
35
		});
36
    $(document).on('change', "#retailerAddressPinCode",
36
	$(document).on('change', "#retailerAddressPinCode",
37
        function () {
37
		function() {
38
 
38
 
39
            var pincode = $('#retailerAddressPinCode').val();
39
			var pincode = $('#retailerAddressPinCode').val();
40
 
40
 
41
            if (undefined != pincode) {
41
			if (undefined != pincode) {
42
                doGetAjaxRequestHandler(context + "/postOffice?pinCode="
42
				doGetAjaxRequestHandler(context + "/postOffice?pinCode="
43
                    + pincode,
43
					+ pincode,
44
                    function (response) {
44
					function(response) {
45
                        console.log(response.response.state);
45
						console.log(response.response.state);
46
                        $('#retailerAddressCity').find('option').not(':first').remove();
46
						$('#retailerAddressCity').find('option').not(':first').remove();
47
                        $('#retailerAddressState').val("");
47
						$('#retailerAddressState').val("");
48
                        $('#retailerAddressState').val(
48
						$('#retailerAddressState').val(
49
                            response.response.state);
49
							response.response.state);
50
                        loadDistrictNames(response.response.state);
50
						loadDistrictNames(response.response.state);
51
                        for (let city of response.response.cities) {
51
						for (let city of response.response.cities) {
52
                            var opt = $("<option>").val(city).text(city);
52
							var opt = $("<option>").val(city).text(city);
53
                            $('#retailerAddressCity').append(opt);
53
							$('#retailerAddressCity').append(opt);
54
 
54
 
55
                        }
55
						}
56
 
56
 
57
                    });
57
					});
58
            }
58
			}
59
        });
59
		});
60
 
60
 
61
    $(document).on("keyup", "#retailer-details-search-text", function (e) {
61
	$(document).on("keyup", "#retailer-details-search-text", function(e) {
62
        var keyCode = e.keyCode || e.which;
62
		var keyCode = e.keyCode || e.which;
63
        if (keyCode == 13) {
63
		if (keyCode == 13) {
64
            $("#retailer-details-search-button").click();
64
			$("#retailer-details-search-button").click();
65
        }
65
		}
66
    });
66
	});
67
 
67
 
68
    $(document).on('click', ".deactivate-store", function () {
68
	$(document).on('click', ".deactivate-store", function() {
69
        var fofoId = $(this).data("fofoid");
69
		var fofoId = $(this).data("fofoid");
70
        console.log(fofoId);
70
		console.log(fofoId);
71
        if (confirm("Are you sure you want to deactivate store!") == true) {
71
		if (confirm("Are you sure you want to deactivate store!") == true) {
72
            deactivateStore("main-content", fofoId);
72
			deactivateStore("main-content", fofoId);
73
        }
73
		}
74
 
74
 
75
    });
75
	});
76
    $(document).on('click', ".login_as", function () {
76
	$(document).on('click', ".login_as", function() {
77
        var fofoId = $('#partnerId').val();
77
		var fofoId = $('#partnerId').val();
78
        loginAsPartner(fofoId);
78
		loginAsPartner(fofoId);
79
 
79
 
80
    });
80
	});
81
 
81
 
82
    $(document).on('click', ".extend-billing", function () {
82
	$(document).on('click', ".extend-billing", function() {
83
        var fofoId = $(this).data("fofoid");
83
		var fofoId = $(this).data("fofoid");
84
        console.log(fofoId);
84
		console.log(fofoId);
85
        if (confirm("Are you sure you want to extend Billing?")) {
85
		if (confirm("Are you sure you want to extend Billing?")) {
86
            extendBilling($(this).parent(), fofoId);
86
			extendBilling($(this).parent(), fofoId);
87
        }
87
		}
88
 
88
 
89
    });
89
	});
90
 
90
 
91
    /*
91
    /*
92
     * $(document).on('change', '#retailerAddressState', function() { var stateName =
92
     * $(document).on('change', '#retailerAddressState', function() { var stateName =
93
     * $(this).find('option:selected').text();
93
     * $(this).find('option:selected').text();
94
     *
94
     *
95
     * loadDistrictNames(stateName); });
95
     * loadDistrictNames(stateName); });
96
     */
96
     */
97
 
97
 
98
 
98
 
99
    $(document).on('click', "#location", function () {
99
	$(document).on('click', "#location", function() {
100
        if ($(this).is(":checked")) {
100
		if ($(this).is(":checked")) {
101
 
101
 
102
            $("#divLocation").show();
102
			$("#divLocation").show();
103
 
103
 
104
        } else {
104
		} else {
105
            $("#divLocation").hide();
105
			$("#divLocation").hide();
-
 
106
		}
-
 
107
	});
-
 
108
 
-
 
109
 
-
 
110
	$(document).on('click', ".changePartnerCategory", function() {
-
 
111
		$clickedElement = $(this);
-
 
112
		var fofoId = $clickedElement.data("id");
-
 
113
		$tdElement = $(this).closest('td');
-
 
114
		doGetAjaxRequestHandler(context + "/getPartnerCategory?fofoId=" + fofoId, function(response) {
-
 
115
 
-
 
116
			$tdElement.html(response);
-
 
117
			$tdElement.find('.partnerCategory').multiselect({
-
 
118
				includeSelectAllOption: true,
-
 
119
				multiple: true,
-
 
120
				maxHeight: 200,
-
 
121
				buttonWidth: '180px',
-
 
122
				numberDisplayed: 1,
-
 
123
				nonSelectedText: 'Category',
-
 
124
				nSelectedText: ' - Category Selected',
-
 
125
				allSelectedText: 'All Category Selected',
-
 
126
				enableFiltering: true,
-
 
127
				enableCaseInsensitiveFiltering: true
-
 
128
			});
-
 
129
		});
-
 
130
	});
-
 
131
 
-
 
132
 
-
 
133
	$(document).on('click', ".update-category",
-
 
134
		function() {
-
 
135
			var fofoId = $(this).data('fofoid');
-
 
136
			var partnerType = $('#partnerCategory').val();
-
 
137
 
-
 
138
			if (confirm("Are you sure you want to update the partners!") == true) {
-
 
139
				doPostAjaxRequestHandler(context
-
 
140
					+ "/updatePartnerCategory?fofoId="
-
 
141
					+ fofoId + "&partnerType=" + partnerType, function(
-
 
142
						response) {
-
 
143
					if (response == "true") {
-
 
144
						alert("Update successfully");
-
 
145
						storeInfo("main-content");
106
        }
146
					}
107
    });
147
				});
-
 
148
			}
-
 
149
 
-
 
150
		});
108
 
151
 
-
 
152
 
109
    $(document).on('click', ".addlocationbutton",
153
	$(document).on('click', ".addlocationbutton",
110
        function () {
154
		function() {
111
            var userId = $('#retailerId').text();
155
			var userId = $('#retailerId').text();
112
            var name = $('#personName').val();
156
			var name = $('#personName').val();
113
            var line1 = $('#line1').val();
157
			var line1 = $('#line1').val();
114
            var line2 = $('#line2').val();
158
			var line2 = $('#line2').val();
115
            var city = $('#city').val();
159
			var city = $('#city').val();
116
            var state = $('#state').val();
160
			var state = $('#state').val();
117
            var pin = $('#pinCode').val();
161
			var pin = $('#pinCode').val();
118
 
162
 
119
            if (name === "" && line1 === "" && city === "" && pin === "") {
163
			if (name === "" && line1 === "" && city === "" && pin === "") {
120
                alert("Field can't be empty");
164
				alert("Field can't be empty");
121
                return;
165
				return;
122
            }
166
			}
123
            if (name === "") {
167
			if (name === "") {
124
                alert("name is required");
168
				alert("name is required");
125
                return;
169
				return;
126
            }
170
			}
127
            if (line1 === "") {
171
			if (line1 === "") {
128
                alert("line1 is required");
172
				alert("line1 is required");
129
                return;
173
				return;
130
            }
174
			}
131
            if (city === "") {
175
			if (city === "") {
132
                alert("city is required");
176
				alert("city is required");
133
                return;
177
				return;
134
            }
178
			}
135
            if (pin === "") {
179
			if (pin === "") {
136
                alert("pin is required");
180
				alert("pin is required");
137
                return;
181
				return;
138
            }
182
			}
139
 
183
 
140
            var locationData = {};
184
			var locationData = {};
141
            locationData['userId'] = $('#retailerId').text();
185
			locationData['userId'] = $('#retailerId').text();
142
            locationData['name'] = $('#personName').val();
186
			locationData['name'] = $('#personName').val();
143
            locationData['line1'] = $('#line1').val();
187
			locationData['line1'] = $('#line1').val();
144
            locationData['line2'] = $('#line2').val();
188
			locationData['line2'] = $('#line2').val();
145
            locationData['city'] = $('#city').val();
189
			locationData['city'] = $('#city').val();
146
            locationData['state'] = $('#state').val();
190
			locationData['state'] = $('#state').val();
147
            locationData['pin'] = $('#pinCode').val();
191
			locationData['pin'] = $('#pinCode').val();
148
 
192
 
149
            if (confirm("Are you sure you want to add location!") == true) {
193
			if (confirm("Are you sure you want to add location!") == true) {
150
                doPostAjaxRequestWithJsonHandler(context + "/addLocation",
194
				doPostAjaxRequestWithJsonHandler(context + "/addLocation",
151
                    JSON.stringify(locationData), function (response) {
195
					JSON.stringify(locationData), function(response) {
152
                        if (response == 'true') {
196
						if (response == 'true') {
153
                            alert("successfully Add");
197
							alert("successfully Add");
154
                            $("#addLocationModal").modal('hide');
198
							$("#addLocationModal").modal('hide');
155
 
199
 
156
                        }
200
						}
157
                    });
201
					});
158
 
202
 
159
                return false;
203
				return false;
160
            }
204
			}
161
        });
205
		});
162
 
206
 
163
});
207
});
164
 
208
 
165
function getDistance(lat1, lon1, lat2, lon2) {
209
function getDistance(lat1, lon1, lat2, lon2) {
166
    var deg2rad = 0.017453292519943295; // === Math.PI / 180
210
	var deg2rad = 0.017453292519943295; // === Math.PI / 180
167
    var cos = Math.cos;
211
	var cos = Math.cos;
168
    lat1 *= deg2rad;
212
	lat1 *= deg2rad;
169
    lon1 *= deg2rad;
213
	lon1 *= deg2rad;
170
    lat2 *= deg2rad;
214
	lat2 *= deg2rad;
171
    lon2 *= deg2rad;
215
	lon2 *= deg2rad;
172
    var diam = 12742; // Diameter of the earth in km (2 * 6371)
216
	var diam = 12742; // Diameter of the earth in km (2 * 6371)
173
    var dLat = lat2 - lat1;
217
	var dLat = lat2 - lat1;
174
    var dLon = lon2 - lon1;
218
	var dLon = lon2 - lon1;
175
    var a = ((1 - cos(dLat)) + (1 - cos(dLon)) * cos(lat1) * cos(lat2)) / 2;
219
	var a = ((1 - cos(dLat)) + (1 - cos(dLon)) * cos(lat1) * cos(lat2)) / 2;
176
 
220
 
177
    return parseFloat(diam * Math.asin(Math.sqrt(a))).toFixed(2);
221
	return parseFloat(diam * Math.asin(Math.sqrt(a))).toFixed(2);
178
}
222
}
179
 
223
 
180
function getRetailerDetailsByEmailIdOrMobileNumber(domId, emailIdOrMobileNumber) {
224
function getRetailerDetailsByEmailIdOrMobileNumber(domId, emailIdOrMobileNumber) {
181
    doGetAjaxRequestHandler(context + "/retailerDetails?emailIdOrMobileNumber="
225
	doGetAjaxRequestHandler(context + "/retailerDetails?emailIdOrMobileNumber="
182
        + emailIdOrMobileNumber, function (response) {
226
		+ emailIdOrMobileNumber, function(response) {
183
        $('#' + domId).html(response);
227
			$('#' + domId).html(response);
184
        if ($("#location").is(":checked")) {
228
			if ($("#location").is(":checked")) {
185
 
229
 
186
            $("#divLocation").show();
230
				$("#divLocation").show();
187
        }
231
			}
188
    });
232
		});
189
}
233
}
190
 
234
 
191
function updateRetailerDocument() {
235
function updateRetailerDocument() {
192
    // $("#updateRetailerShopDocument0").click( function() {
236
	// $("#updateRetailerShopDocument0").click( function() {
193
    console.log("Update Retailer Document Clicked");
237
	console.log("Update Retailer Document Clicked");
194
    // console.log(ownerId);
238
	// console.log(ownerId);
195
    var emailIdOrMobileNumber = $('#retailer-details-search-text').val();
239
	var emailIdOrMobileNumber = $('#retailer-details-search-text').val();
196
    console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);
240
	console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);
197
    var file = $('#retailerDocument')[0].files[0];
241
	var file = $('#retailerDocument')[0].files[0];
198
    console.log("file : " + file.name);
242
	console.log("file : " + file.name);
199
    uploadRetailerDocument("retailer-details-container", file,
243
	uploadRetailerDocument("retailer-details-container", file,
200
        emailIdOrMobileNumber);
244
		emailIdOrMobileNumber);
201
}
245
}
202
 
246
 
203
function updateRetailerShopDocument(ownerId) {
247
function updateRetailerShopDocument(ownerId) {
204
    // $("#updateRetailerShopDocument0").click( function() {
248
	// $("#updateRetailerShopDocument0").click( function() {
205
    console.log("Update Retailer Shop Document Clicked");
249
	console.log("Update Retailer Shop Document Clicked");
206
    console.log(ownerId);
250
	console.log(ownerId);
207
    var shopSize = parseInt($("#shopDetailsSize").attr('size'));
251
	var shopSize = parseInt($("#shopDetailsSize").attr('size'));
208
    console.log("size : " + shopSize);
252
	console.log("size : " + shopSize);
209
    for (var index = 0; index < shopSize; index++) {
253
	for (var index = 0; index < shopSize; index++) {
210
        if ("updateRetailerShopDocument" + index == ownerId) {
254
		if ("updateRetailerShopDocument" + index == ownerId) {
211
            var emailIdOrMobileNumber = $('#retailer-details-search-text')
255
			var emailIdOrMobileNumber = $('#retailer-details-search-text')
212
                .val();
256
				.val();
213
            console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);
257
			console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);
214
            var shopId = $('#retailerShopDocument' + index).attr("shopId");
258
			var shopId = $('#retailerShopDocument' + index).attr("shopId");
215
            console.log("shopId : " + shopId);
259
			console.log("shopId : " + shopId);
216
            var file = $('#retailerShopDocument' + index)[0].files[0];
260
			var file = $('#retailerShopDocument' + index)[0].files[0];
217
            console.log("file : " + file.name);
261
			console.log("file : " + file.name);
218
            uploadRetailerShopDocument("retailer-details-container", file,
262
			uploadRetailerShopDocument("retailer-details-container", file,
219
                emailIdOrMobileNumber, shopId);
263
				emailIdOrMobileNumber, shopId);
220
        }
264
		}
221
    }
265
	}
222
}
266
}
223
 
267
 
224
function loadDistrictNames(stateName) {
268
function loadDistrictNames(stateName) {
225
    if (undefined != $("#districtName")) {
269
	if (undefined != $("#districtName")) {
226
        doGetAjaxRequestHandler(
270
		doGetAjaxRequestHandler(
227
            context + "/district/all/stateName?stateName=" + stateName,
271
			context + "/district/all/stateName?stateName=" + stateName,
228
            function (response) {
272
			function(response) {
229
                console.log(response);
273
				console.log(response);
230
                var districtMasters = response.response;
274
				var districtMasters = response.response;
231
                // districtMasters = districtMasters.response;
275
				// districtMasters = districtMasters.response;
232
                var districtNameElements = '<option value="" disabled selected>District Name</option>';
276
				var districtNameElements = '<option value="" disabled selected>District Name</option>';
233
                for (index = 0; index < districtMasters.length; index++) {
277
				for (index = 0; index < districtMasters.length; index++) {
234
                    districtNameElements = districtNameElements
278
					districtNameElements = districtNameElements
235
                        + '<option value="'
279
						+ '<option value="'
236
                        + districtMasters[index].name + '">'
280
						+ districtMasters[index].name + '">'
237
                        + districtMasters[index].name + '</option>';
281
						+ districtMasters[index].name + '</option>';
238
                }
282
				}
239
                $('#districtName').html(districtNameElements);
283
				$('#districtName').html(districtNameElements);
240
            });
284
			});
241
    }
285
	}
242
}
286
}
243
 
287
 
244
function retailerInfo(domId) {
288
function retailerInfo(domId) {
245
    doGetAjaxRequestHandler(context + "/retailerInfo", function (response) {
289
	doGetAjaxRequestHandler(context + "/retailerInfo", function(response) {
246
        $('#' + domId).html(response);
290
		$('#' + domId).html(response);
247
 
291
 
248
    });
292
	});
249
 
293
 
250
}
294
}
251
 
295
 
252
function partnerInfo(domId) {
296
function partnerInfo(domId) {
253
    doGetAjaxRequestHandler(context + "/getPartnerReadonlyInfo", function (response) {
297
	doGetAjaxRequestHandler(context + "/getPartnerReadonlyInfo", function(response) {
254
        $('#' + domId).html(response);
298
		$('#' + domId).html(response);
255
 
299
 
256
    });
300
	});
257
}
301
}
258
 
302
 
259
function storeInfo(domId) {
303
function storeInfo(domId) {
260
    doGetAjaxRequestHandler(context + "/getAllStores", function (response) {
304
	doGetAjaxRequestHandler(context + "/getAllStores", function(response) {
261
        $('#' + domId).html(response);
305
		$('#' + domId).html(response);
262
    });
306
	});
263
}
307
}
264
 
308
 
265
function inactiveStoreInfo(domId) {
309
function inactiveStoreInfo(domId) {
266
    doGetAjaxRequestHandler(context + "/getAllInactiveStores", function (
310
	doGetAjaxRequestHandler(context + "/getAllInactiveStores", function(
267
        response) {
311
		response) {
268
        $('#' + domId).html(response);
312
		$('#' + domId).html(response);
269
    });
313
	});
270
}
314
}
271
 
315
 
272
function deactivateStore(domId, fofoId) {
316
function deactivateStore(domId, fofoId) {
273
    doPostAjaxRequestHandler(context + "/deactivateStore?fofoId=" + fofoId,
317
	doPostAjaxRequestHandler(context + "/deactivateStore?fofoId=" + fofoId,
274
        function (response) {
318
		function(response) {
275
            if (response == "true") {
319
			if (response == "true") {
276
                alert("successfully deactivated!");
320
				alert("successfully deactivated!");
277
                storeInfo(domId);
321
				storeInfo(domId);
278
            }
322
			}
279
 
323
 
280
        });
324
		});
281
}
325
}
282
 
326
 
283
function loginAsPartner(fofoId) {
327
function loginAsPartner(fofoId) {
284
    doGetAjaxRequestHandler(context + "/login-as-partner?fofoId=" + fofoId,
328
	doGetAjaxRequestHandler(context + "/login-as-partner?fofoId=" + fofoId,
285
        function (response) {
329
		function(response) {
286
            window.create({
330
			window.create({
287
                "url": "/dashboard",
331
				"url": "/dashboard",
288
                "incognito": true
332
				"incognito": true
289
            });
333
			});
290
        });
334
		});
291
}
335
}
292
 
336
 
293
function loginAsPartnerReadonly(fofoId) {
337
function loginAsPartnerReadonly(fofoId) {
294
    doGetAjaxRequestHandler(context + "/login-as-partner-readonly?fofoId=" + fofoId,
338
	doGetAjaxRequestHandler(context + "/login-as-partner-readonly?fofoId=" + fofoId,
295
        function (response) {
339
		function(response) {
296
            window.create({
340
			window.create({
297
                "url": "/dashboard",
341
				"url": "/dashboard",
298
                "incognito": true
342
				"incognito": true
299
            });
343
			});
300
        });
344
		});
301
}
345
}
302
 
346
 
303
function extendBilling(container, fofoId) {
347
function extendBilling(container, fofoId) {
304
    doPostAjaxRequestHandler(context + "/extendBilling?fofoId=" + fofoId,
348
	doPostAjaxRequestHandler(context + "/extendBilling?fofoId=" + fofoId,
305
        function (response) {
349
		function(response) {
306
            if (isFinite(response)) {
350
			if (isFinite(response)) {
307
                alert("successfully deactivated!");
351
				alert("successfully deactivated!");
308
                container.html("Billing extended upto "
352
				container.html("Billing extended upto "
309
                    + moment().add(1, 'day').format("DD-MM-YY")
353
					+ moment().add(1, 'day').format("DD-MM-YY")
310
                    + " Grace count(" + response + ")");
354
					+ " Grace count(" + response + ")");
311
            }
355
			}
312
        });
356
		});
313
}
357
}
314
 
358
 
315
function updateLocationButton(id) {
359
function updateLocationButton(id) {
316
 
360
 
317
    var userId = id;
361
	var userId = id;
318
    var name = $('#personName').val();
362
	var name = $('#personName').val();
319
    var line1 = $('#line1').val();
363
	var line1 = $('#line1').val();
320
    var line2 = $('#line2').val();
364
	var line2 = $('#line2').val();
321
    var city = $('#city').val();
365
	var city = $('#city').val();
322
    var state = $('#state').val();
366
	var state = $('#state').val();
323
    var pin = $('#pinCode').val();
367
	var pin = $('#pinCode').val();
324
    console.log(id);
368
	console.log(id);
325
    if (name === "" && line1 === "" && city === "" && pin === "") {
369
	if (name === "" && line1 === "" && city === "" && pin === "") {
326
        alert("Field can't be empty");
370
		alert("Field can't be empty");
327
        return;
371
		return;
328
    }
372
	}
329
    if (name === "") {
373
	if (name === "") {
330
        alert("name is required");
374
		alert("name is required");
331
        return;
375
		return;
332
    }
376
	}
333
    if (line1 === "") {
377
	if (line1 === "") {
334
        alert("line1 is required");
378
		alert("line1 is required");
335
        return;
379
		return;
336
    }
380
	}
337
    if (city === "") {
381
	if (city === "") {
338
        alert("city is required");
382
		alert("city is required");
339
        return;
383
		return;
340
    }
384
	}
341
    if (pin === "") {
385
	if (pin === "") {
342
        alert("pin is required");
386
		alert("pin is required");
343
        return;
387
		return;
344
    }
388
	}
345
 
389
 
346
    var changeLocationData = {};
390
	var changeLocationData = {};
347
 
391
 
348
    changeLocationData['userId'] = id;
392
	changeLocationData['userId'] = id;
349
    changeLocationData['name'] = $('#personName').val();
393
	changeLocationData['name'] = $('#personName').val();
350
    changeLocationData['line1'] = $('#line1').val();
394
	changeLocationData['line1'] = $('#line1').val();
351
    changeLocationData['line2'] = $('#line2').val();
395
	changeLocationData['line2'] = $('#line2').val();
352
    changeLocationData['city'] = $('#city').val();
396
	changeLocationData['city'] = $('#city').val();
353
    changeLocationData['state'] = $('#state').val();
397
	changeLocationData['state'] = $('#state').val();
354
    changeLocationData['pin'] = $('#pinCode').val();
398
	changeLocationData['pin'] = $('#pinCode').val();
355
 
399
 
356
    console.log(changeLocationData);
400
	console.log(changeLocationData);
357
 
401
 
358
    if (confirm("Are you sure you want to add location!") == true) {
402
	if (confirm("Are you sure you want to add location!") == true) {
359
        doPostAjaxRequestWithJsonHandler(context + "/updateLocation", JSON
403
		doPostAjaxRequestWithJsonHandler(context + "/updateLocation", JSON
360
            .stringify(changeLocationData), function (response) {
404
			.stringify(changeLocationData), function(response) {
361
            if (response == 'true') {
405
				if (response == 'true') {
362
                alert("successfully Update");
406
					alert("successfully Update");
363
 
407
 
364
                $("#addLocationModal").modal('hide');
408
					$("#addLocationModal").modal('hide');
365
 
409
 
366
            }
410
				}
367
        });
411
			});
368
 
412
 
369
        return false;
413
		return false;
370
    }
414
	}
371
 
415
 
372
}
416
}
373
417