Subversion Repositories SmartDukaan

Rev

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

Rev 24125 Rev 24159
Line 8... Line 8...
8
					searchContent = "";
8
					searchContent = "";
9
				}
9
				}
10
				getRetailerDetailsByEmailIdOrMobileNumber(
10
				getRetailerDetailsByEmailIdOrMobileNumber(
11
						"retailer-details-container", searchContent);
11
						"retailer-details-container", searchContent);
12
			});
12
			});
-
 
13
 
13
	$(".active-store").live('click', function() {
14
	$(".active-store").live('click', function() {
14
		storeInfo("main-content");
15
		storeInfo("main-content");
15
	});
16
	});
16
 
-
 
17
	$(".retailer-info").live('click', function() {
17
	$(".retailer-info").live('click', function() {
18
		retailerInfo("main-content");
18
		retailerInfo("main-content");
19
	});
19
	});
20
 
20
 
21
	$("#retailer-details-search-text").live("keyup", function(e) {
21
	$("#retailer-details-search-text").live("keyup", function(e) {
Line 36... Line 36...
36
 
36
 
37
	$('#retailerAddressState').live('change', function() {
37
	$('#retailerAddressState').live('change', function() {
38
		var stateName = $(this).find('option:selected').text();
38
		var stateName = $(this).find('option:selected').text();
39
		loadDistrictNames(stateName);
39
		loadDistrictNames(stateName);
40
	});
40
	});
-
 
41
 
-
 
42
	$("#location").live(
-
 
43
			'click',
-
 
44
			function() {
-
 
45
				if ($(this).is(":checked")) {
-
 
46
					var emailIdOrMobileNumber = $(
-
 
47
							'#retailer-details-search-text').val();
-
 
48
					var email = $('#emailId').val();
-
 
49
					doGetAjaxRequestHandler(context
-
 
50
							+ "/userDetails?emailIdOrMobileNumber="
-
 
51
							+ emailIdOrMobileNumber, function(response) {
-
 
52
						if (response == "true") {
-
 
53
							$("#divLocation").show();
-
 
54
						} else {
-
 
55
							alert("user can not Exist")
-
 
56
							$("#location").prop("checked", false);
-
 
57
						}
-
 
58
					});
-
 
59
 
-
 
60
				} else {
-
 
61
					$("#divLocation").hide();
-
 
62
				}
-
 
63
			});
-
 
64
 
-
 
65
	$(".addlocationbutton").live(
-
 
66
			'click',
-
 
67
			function() {
-
 
68
				var userId = $('#retailerId').text();
-
 
69
				var name = $('#personName').val();
-
 
70
				var line1 = $('#line1').val();
-
 
71
				var line2 = $('#line2').val();
-
 
72
				var city = $('#city').val();
-
 
73
				var state = $('#state').val();
-
 
74
				var pin = $('#pinCode').val();
-
 
75
 
-
 
76
				if (name === "" && line1 === "" && city === "" && pin === "") {
-
 
77
					alert("Field can't be empty");
-
 
78
					return;
-
 
79
				}
-
 
80
				if (name === "") {
-
 
81
					alert("name is required");
-
 
82
					return;
-
 
83
				}
-
 
84
				if (line1 === "") {
-
 
85
					alert("line1 is required");
-
 
86
					return;
-
 
87
				}
-
 
88
				if (city === "") {
-
 
89
					alert("city is required");
-
 
90
					return;
-
 
91
				}
-
 
92
				if (pin === "") {
-
 
93
					alert("pin is required");
-
 
94
					return;
-
 
95
				}
-
 
96
 
-
 
97
				var locationData = {};
-
 
98
				locationData['userId'] = $('#retailerId').text();
-
 
99
				locationData['name'] = $('#personName').val();
-
 
100
				locationData['line1'] = $('#line1').val();
-
 
101
				locationData['line2'] = $('#line2').val();
-
 
102
				locationData['city'] = $('#city').val();
-
 
103
				locationData['state'] = $('#state').val();
-
 
104
				locationData['pin'] = $('#pinCode').val();
-
 
105
 
-
 
106
				if (confirm("Are you sure you want to add location!") == true) {
-
 
107
					doPostAjaxRequestWithJsonHandler(context + "/addLocation",
-
 
108
							JSON.stringify(locationData), function(response) {
-
 
109
								if (response == 'true') {
-
 
110
									alert("successfully Add");
-
 
111
									$("#addLocationModal").modal('hide');
-
 
112
 
-
 
113
								}
-
 
114
							});
-
 
115
 
-
 
116
					return false;
-
 
117
				}
-
 
118
			});
-
 
119
 
41
});
120
});
42
 
121
 
43
function getDistance(lat1, lon1, lat2, lon2) {
122
function getDistance(lat1, lon1, lat2, lon2) {
44
	var deg2rad = 0.017453292519943295; // === Math.PI / 180
123
	var deg2rad = 0.017453292519943295; // === Math.PI / 180
45
	var cos = Math.cos;
124
	var cos = Math.cos;
Line 57... Line 136...
57
 
136
 
58
function getRetailerDetailsByEmailIdOrMobileNumber(domId, emailIdOrMobileNumber) {
137
function getRetailerDetailsByEmailIdOrMobileNumber(domId, emailIdOrMobileNumber) {
59
	doGetAjaxRequestHandler(context + "/retailerDetails?emailIdOrMobileNumber="
138
	doGetAjaxRequestHandler(context + "/retailerDetails?emailIdOrMobileNumber="
60
			+ emailIdOrMobileNumber, function(response) {
139
			+ emailIdOrMobileNumber, function(response) {
61
		$('#' + domId).html(response);
140
		$('#' + domId).html(response);
-
 
141
		if ($("#location").is(":checked")){ 
-
 
142
			
-
 
143
			$("#divLocation").show();
-
 
144
		}
62
	});
145
	});
63
}
146
}
64
 
147
 
65
function updateRetailerDocument() {
148
function updateRetailerDocument() {
66
	// $("#updateRetailerShopDocument0").click( function() {
149
	// $("#updateRetailerShopDocument0").click( function() {
Line 116... Line 199...
116
}
199
}
117
 
200
 
118
function retailerInfo(domId) {
201
function retailerInfo(domId) {
119
	doGetAjaxRequestHandler(context + "/retailerInfo", function(response) {
202
	doGetAjaxRequestHandler(context + "/retailerInfo", function(response) {
120
		$('#' + domId).html(response);
203
		$('#' + domId).html(response);
-
 
204
 
121
	});
205
	});
-
 
206
 
122
}
207
}
123
function storeInfo(domId) {
208
function storeInfo(domId) {
124
	doGetAjaxRequestHandler(context + "/getAllStores", function(response) {
209
	doGetAjaxRequestHandler(context + "/getAllStores", function(response) {
125
		$('#' + domId).html(response);
210
		$('#' + domId).html(response);
126
	});
211
	});
Line 130... Line 215...
130
			function(response) {
215
			function(response) {
131
				if (response == "true") {
216
				if (response == "true") {
132
					alert("successfully deactivated!");
217
					alert("successfully deactivated!");
133
					storeInfo(domId);
218
					storeInfo(domId);
134
				}
219
				}
135
				
220
 
136
			});
221
			});
137
}
222
}
-
 
223
 
-
 
224
function updateLocationButton(id) {
-
 
225
 
-
 
226
	var userId = id;
-
 
227
	var name = $('#personName').val();
-
 
228
	var line1 = $('#line1').val();
-
 
229
	var line2 = $('#line2').val();
-
 
230
	var city = $('#city').val();
-
 
231
	var state = $('#state').val();
-
 
232
	var pin = $('#pinCode').val();
-
 
233
	console.log(id);
-
 
234
	if (name === "" && line1 === "" && city === "" && pin === "") {
-
 
235
		alert("Field can't be empty");
-
 
236
		return;
-
 
237
	}
-
 
238
	if (name === "") {
-
 
239
		alert("name is required");
-
 
240
		return;
-
 
241
	}
-
 
242
	if (line1 === "") {
-
 
243
		alert("line1 is required");
-
 
244
		return;
-
 
245
	}
-
 
246
	if (city === "") {
-
 
247
		alert("city is required");
-
 
248
		return;
-
 
249
	}
-
 
250
	if (pin === "") {
-
 
251
		alert("pin is required");
-
 
252
		return;
-
 
253
	}
-
 
254
 
-
 
255
	var changeLocationData = {};
-
 
256
 
-
 
257
	changeLocationData['userId'] = id;
-
 
258
	changeLocationData['name'] = $('#personName').val();
-
 
259
	changeLocationData['line1'] = $('#line1').val();
-
 
260
	changeLocationData['line2'] = $('#line2').val();
-
 
261
	changeLocationData['city'] = $('#city').val();
-
 
262
	changeLocationData['state'] = $('#state').val();
-
 
263
	changeLocationData['pin'] = $('#pinCode').val();
-
 
264
 
-
 
265
	console.log(changeLocationData);
-
 
266
 
-
 
267
	if (confirm("Are you sure you want to add location!") == true) {
-
 
268
		doPostAjaxRequestWithJsonHandler(context + "/updateLocation", JSON
-
 
269
				.stringify(changeLocationData), function(response) {
-
 
270
			if (response == 'true') {
-
 
271
				alert("successfully Update");
-
 
272
 
-
 
273
				$("#addLocationModal").modal('hide');
-
 
274
 
-
 
275
			}
-
 
276
		});
-
 
277
 
-
 
278
		return false;
-
 
279
	}
-
 
280
 
-
 
281
}
138
282