| 23347 |
ashik.ali |
1 |
$(function() {
|
| 24125 |
govind |
2 |
|
|
|
3 |
$("#retailer-details-search-button").live(
|
|
|
4 |
'click',
|
|
|
5 |
function() {
|
|
|
6 |
searchContent = $("#retailer-details-search-text").val();
|
|
|
7 |
if (typeof (searchContent) == "undefined" || !searchContent) {
|
|
|
8 |
searchContent = "";
|
|
|
9 |
}
|
|
|
10 |
getRetailerDetailsByEmailIdOrMobileNumber(
|
|
|
11 |
"retailer-details-container", searchContent);
|
|
|
12 |
});
|
| 24159 |
tejbeer |
13 |
|
| 24125 |
govind |
14 |
$(".active-store").live('click', function() {
|
|
|
15 |
storeInfo("main-content");
|
|
|
16 |
});
|
| 24680 |
govind |
17 |
$(".inactive-store").live('click', function() {
|
|
|
18 |
inactiveStoreInfo("main-content");
|
|
|
19 |
});
|
| 23347 |
ashik.ali |
20 |
$(".retailer-info").live('click', function() {
|
|
|
21 |
retailerInfo("main-content");
|
|
|
22 |
});
|
| 24125 |
govind |
23 |
|
| 27171 |
tejbeer |
24 |
$("#retailerAddressPinCode").live(
|
|
|
25 |
'change',
|
|
|
26 |
function() {
|
|
|
27 |
|
|
|
28 |
var pincode = $('#retailerAddressPinCode').val();
|
|
|
29 |
|
|
|
30 |
if (undefined != pincode) {
|
|
|
31 |
doGetAjaxRequestHandler(context + "/postOffice?pinCode="
|
|
|
32 |
+ pincode,
|
|
|
33 |
function(response) {
|
|
|
34 |
console.log(response.response.state);
|
|
|
35 |
|
|
|
36 |
$('#retailerAddressState').val(
|
|
|
37 |
response.response.state);
|
|
|
38 |
for(let city of response.response.cities){
|
|
|
39 |
var opt = $("<option>").val(city).text(city);
|
|
|
40 |
$('#retailerAddressCity').append(opt);
|
|
|
41 |
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
});
|
|
|
45 |
}
|
|
|
46 |
});
|
|
|
47 |
|
| 23347 |
ashik.ali |
48 |
$("#retailer-details-search-text").live("keyup", function(e) {
|
|
|
49 |
var keyCode = e.keyCode || e.which;
|
| 24125 |
govind |
50 |
if (keyCode == 13) {
|
|
|
51 |
$("#retailer-details-search-button").click();
|
|
|
52 |
}
|
| 23347 |
ashik.ali |
53 |
});
|
| 24125 |
govind |
54 |
|
|
|
55 |
$(".deactivate-store").live('click', function() {
|
|
|
56 |
var fofoId = $(this).data("fofoid");
|
|
|
57 |
console.log(fofoId);
|
|
|
58 |
if (confirm("Are you sure you want to deactivate store!") == true) {
|
|
|
59 |
deactivateStore("main-content", fofoId);
|
|
|
60 |
}
|
|
|
61 |
|
| 23347 |
ashik.ali |
62 |
});
|
| 24976 |
amit.gupta |
63 |
$(".login_as").live('click', function() {
|
| 25638 |
amit.gupta |
64 |
var fofoId = $('#partnerId').val();
|
| 24976 |
amit.gupta |
65 |
loginAsPartner(fofoId);
|
| 27171 |
tejbeer |
66 |
|
| 24976 |
amit.gupta |
67 |
});
|
| 24125 |
govind |
68 |
|
| 24349 |
amit.gupta |
69 |
$(".extend-billing").live('click', function() {
|
|
|
70 |
var fofoId = $(this).data("fofoid");
|
|
|
71 |
console.log(fofoId);
|
|
|
72 |
if (confirm("Are you sure you want to extend Billing?")) {
|
|
|
73 |
extendBilling($(this).parent(), fofoId);
|
|
|
74 |
}
|
|
|
75 |
|
| 24125 |
govind |
76 |
});
|
| 27171 |
tejbeer |
77 |
/*
|
|
|
78 |
* $('#retailerAddressState').live('change', function() { var stateName =
|
|
|
79 |
* $(this).find('option:selected').text(); loadDistrictNames(stateName); });
|
|
|
80 |
*
|
|
|
81 |
*/
|
| 24159 |
tejbeer |
82 |
|
| 27171 |
tejbeer |
83 |
$("#location").live('click', function() {
|
|
|
84 |
if ($(this).is(":checked")) {
|
| 24159 |
tejbeer |
85 |
|
| 27171 |
tejbeer |
86 |
$("#divLocation").show();
|
| 24159 |
tejbeer |
87 |
|
| 27171 |
tejbeer |
88 |
} else {
|
|
|
89 |
$("#divLocation").hide();
|
|
|
90 |
}
|
|
|
91 |
});
|
|
|
92 |
|
| 24159 |
tejbeer |
93 |
$(".addlocationbutton").live(
|
|
|
94 |
'click',
|
|
|
95 |
function() {
|
|
|
96 |
var userId = $('#retailerId').text();
|
|
|
97 |
var name = $('#personName').val();
|
|
|
98 |
var line1 = $('#line1').val();
|
|
|
99 |
var line2 = $('#line2').val();
|
|
|
100 |
var city = $('#city').val();
|
|
|
101 |
var state = $('#state').val();
|
|
|
102 |
var pin = $('#pinCode').val();
|
|
|
103 |
|
|
|
104 |
if (name === "" && line1 === "" && city === "" && pin === "") {
|
|
|
105 |
alert("Field can't be empty");
|
|
|
106 |
return;
|
|
|
107 |
}
|
|
|
108 |
if (name === "") {
|
|
|
109 |
alert("name is required");
|
|
|
110 |
return;
|
|
|
111 |
}
|
|
|
112 |
if (line1 === "") {
|
|
|
113 |
alert("line1 is required");
|
|
|
114 |
return;
|
|
|
115 |
}
|
|
|
116 |
if (city === "") {
|
|
|
117 |
alert("city is required");
|
|
|
118 |
return;
|
|
|
119 |
}
|
|
|
120 |
if (pin === "") {
|
|
|
121 |
alert("pin is required");
|
|
|
122 |
return;
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
var locationData = {};
|
|
|
126 |
locationData['userId'] = $('#retailerId').text();
|
|
|
127 |
locationData['name'] = $('#personName').val();
|
|
|
128 |
locationData['line1'] = $('#line1').val();
|
|
|
129 |
locationData['line2'] = $('#line2').val();
|
|
|
130 |
locationData['city'] = $('#city').val();
|
|
|
131 |
locationData['state'] = $('#state').val();
|
|
|
132 |
locationData['pin'] = $('#pinCode').val();
|
|
|
133 |
|
|
|
134 |
if (confirm("Are you sure you want to add location!") == true) {
|
|
|
135 |
doPostAjaxRequestWithJsonHandler(context + "/addLocation",
|
|
|
136 |
JSON.stringify(locationData), function(response) {
|
|
|
137 |
if (response == 'true') {
|
|
|
138 |
alert("successfully Add");
|
|
|
139 |
$("#addLocationModal").modal('hide');
|
|
|
140 |
|
|
|
141 |
}
|
|
|
142 |
});
|
|
|
143 |
|
|
|
144 |
return false;
|
|
|
145 |
}
|
|
|
146 |
});
|
|
|
147 |
|
| 23347 |
ashik.ali |
148 |
});
|
|
|
149 |
|
| 23837 |
ashik.ali |
150 |
function getDistance(lat1, lon1, lat2, lon2) {
|
| 24125 |
govind |
151 |
var deg2rad = 0.017453292519943295; // === Math.PI / 180
|
|
|
152 |
var cos = Math.cos;
|
|
|
153 |
lat1 *= deg2rad;
|
|
|
154 |
lon1 *= deg2rad;
|
|
|
155 |
lat2 *= deg2rad;
|
|
|
156 |
lon2 *= deg2rad;
|
|
|
157 |
var diam = 12742; // Diameter of the earth in km (2 * 6371)
|
|
|
158 |
var dLat = lat2 - lat1;
|
|
|
159 |
var dLon = lon2 - lon1;
|
|
|
160 |
var a = ((1 - cos(dLat)) + (1 - cos(dLon)) * cos(lat1) * cos(lat2)) / 2;
|
| 23837 |
ashik.ali |
161 |
|
| 24125 |
govind |
162 |
return parseFloat(diam * Math.asin(Math.sqrt(a))).toFixed(2);
|
|
|
163 |
}
|
| 23837 |
ashik.ali |
164 |
|
| 24125 |
govind |
165 |
function getRetailerDetailsByEmailIdOrMobileNumber(domId, emailIdOrMobileNumber) {
|
|
|
166 |
doGetAjaxRequestHandler(context + "/retailerDetails?emailIdOrMobileNumber="
|
|
|
167 |
+ emailIdOrMobileNumber, function(response) {
|
| 23347 |
ashik.ali |
168 |
$('#' + domId).html(response);
|
| 27171 |
tejbeer |
169 |
if ($("#location").is(":checked")) {
|
|
|
170 |
|
| 24159 |
tejbeer |
171 |
$("#divLocation").show();
|
|
|
172 |
}
|
| 23347 |
ashik.ali |
173 |
});
|
|
|
174 |
}
|
|
|
175 |
|
| 24125 |
govind |
176 |
function updateRetailerDocument() {
|
|
|
177 |
// $("#updateRetailerShopDocument0").click( function() {
|
| 23347 |
ashik.ali |
178 |
console.log("Update Retailer Document Clicked");
|
| 24125 |
govind |
179 |
// console.log(ownerId);
|
| 23347 |
ashik.ali |
180 |
var emailIdOrMobileNumber = $('#retailer-details-search-text').val();
|
| 24125 |
govind |
181 |
console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);
|
| 23347 |
ashik.ali |
182 |
var file = $('#retailerDocument')[0].files[0];
|
| 24125 |
govind |
183 |
console.log("file : " + file.name);
|
|
|
184 |
uploadRetailerDocument("retailer-details-container", file,
|
|
|
185 |
emailIdOrMobileNumber);
|
| 23347 |
ashik.ali |
186 |
}
|
|
|
187 |
|
| 24125 |
govind |
188 |
function updateRetailerShopDocument(ownerId) {
|
|
|
189 |
// $("#updateRetailerShopDocument0").click( function() {
|
| 23347 |
ashik.ali |
190 |
console.log("Update Retailer Shop Document Clicked");
|
|
|
191 |
console.log(ownerId);
|
|
|
192 |
var shopSize = parseInt($("#shopDetailsSize").attr('size'));
|
| 24125 |
govind |
193 |
console.log("size : " + shopSize);
|
|
|
194 |
for (var index = 0; index < shopSize; index++) {
|
|
|
195 |
if ("updateRetailerShopDocument" + index == ownerId) {
|
|
|
196 |
var emailIdOrMobileNumber = $('#retailer-details-search-text')
|
|
|
197 |
.val();
|
|
|
198 |
console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);
|
|
|
199 |
var shopId = $('#retailerShopDocument' + index).attr("shopId");
|
|
|
200 |
console.log("shopId : " + shopId);
|
|
|
201 |
var file = $('#retailerShopDocument' + index)[0].files[0];
|
|
|
202 |
console.log("file : " + file.name);
|
|
|
203 |
uploadRetailerShopDocument("retailer-details-container", file,
|
|
|
204 |
emailIdOrMobileNumber, shopId);
|
| 23347 |
ashik.ali |
205 |
}
|
|
|
206 |
}
|
|
|
207 |
}
|
|
|
208 |
|
| 24125 |
govind |
209 |
function loadDistrictNames(stateName) {
|
|
|
210 |
if (undefined != $("#districtName")) {
|
|
|
211 |
doGetAjaxRequestHandler(
|
|
|
212 |
context + "/district/all/stateName?stateName=" + stateName,
|
|
|
213 |
function(response) {
|
|
|
214 |
console.log(response);
|
|
|
215 |
var districtMasters = response.response;
|
|
|
216 |
// districtMasters = districtMasters.response;
|
|
|
217 |
var districtNameElements = '<option value="" disabled selected>District Name</option>';
|
|
|
218 |
for (index = 0; index < districtMasters.length; index++) {
|
|
|
219 |
districtNameElements = districtNameElements
|
|
|
220 |
+ '<option value="'
|
|
|
221 |
+ districtMasters[index].name + '">'
|
|
|
222 |
+ districtMasters[index].name + '</option>';
|
|
|
223 |
}
|
|
|
224 |
$('#districtName').html(districtNameElements);
|
|
|
225 |
});
|
| 23347 |
ashik.ali |
226 |
}
|
|
|
227 |
}
|
|
|
228 |
|
| 24125 |
govind |
229 |
function retailerInfo(domId) {
|
|
|
230 |
doGetAjaxRequestHandler(context + "/retailerInfo", function(response) {
|
|
|
231 |
$('#' + domId).html(response);
|
| 24159 |
tejbeer |
232 |
|
| 23349 |
ashik.ali |
233 |
});
|
| 24159 |
tejbeer |
234 |
|
| 24125 |
govind |
235 |
}
|
|
|
236 |
function storeInfo(domId) {
|
|
|
237 |
doGetAjaxRequestHandler(context + "/getAllStores", function(response) {
|
|
|
238 |
$('#' + domId).html(response);
|
|
|
239 |
});
|
|
|
240 |
}
|
| 24680 |
govind |
241 |
function inactiveStoreInfo(domId) {
|
| 27171 |
tejbeer |
242 |
doGetAjaxRequestHandler(context + "/getAllInactiveStores", function(
|
|
|
243 |
response) {
|
| 24680 |
govind |
244 |
$('#' + domId).html(response);
|
|
|
245 |
});
|
|
|
246 |
}
|
| 24125 |
govind |
247 |
function deactivateStore(domId, fofoId) {
|
|
|
248 |
doPostAjaxRequestHandler(context + "/deactivateStore?fofoId=" + fofoId,
|
|
|
249 |
function(response) {
|
|
|
250 |
if (response == "true") {
|
|
|
251 |
alert("successfully deactivated!");
|
|
|
252 |
storeInfo(domId);
|
|
|
253 |
}
|
| 24159 |
tejbeer |
254 |
|
| 24125 |
govind |
255 |
});
|
|
|
256 |
}
|
| 24976 |
amit.gupta |
257 |
function loginAsPartner(fofoId) {
|
| 27171 |
tejbeer |
258 |
doGetAjaxRequestHandler(context + "/login-as-partner?fofoId=" + fofoId,
|
|
|
259 |
function(response) {
|
|
|
260 |
window.create({
|
|
|
261 |
"url" : "/dashboard",
|
|
|
262 |
"incognito" : true
|
|
|
263 |
});
|
|
|
264 |
});
|
| 24976 |
amit.gupta |
265 |
}
|
| 24349 |
amit.gupta |
266 |
function extendBilling(container, fofoId) {
|
|
|
267 |
doPostAjaxRequestHandler(context + "/extendBilling?fofoId=" + fofoId,
|
|
|
268 |
function(response) {
|
| 27171 |
tejbeer |
269 |
if (isFinite(response)) {
|
|
|
270 |
alert("successfully deactivated!");
|
|
|
271 |
container.html("Billing extended upto "
|
|
|
272 |
+ moment().add(1, 'day').format("DD-MM-YY")
|
|
|
273 |
+ " Grace count(" + response + ")");
|
|
|
274 |
}
|
|
|
275 |
});
|
| 24349 |
amit.gupta |
276 |
}
|
| 24159 |
tejbeer |
277 |
|
|
|
278 |
function updateLocationButton(id) {
|
|
|
279 |
|
|
|
280 |
var userId = id;
|
|
|
281 |
var name = $('#personName').val();
|
|
|
282 |
var line1 = $('#line1').val();
|
|
|
283 |
var line2 = $('#line2').val();
|
|
|
284 |
var city = $('#city').val();
|
|
|
285 |
var state = $('#state').val();
|
|
|
286 |
var pin = $('#pinCode').val();
|
|
|
287 |
console.log(id);
|
|
|
288 |
if (name === "" && line1 === "" && city === "" && pin === "") {
|
|
|
289 |
alert("Field can't be empty");
|
|
|
290 |
return;
|
|
|
291 |
}
|
|
|
292 |
if (name === "") {
|
|
|
293 |
alert("name is required");
|
|
|
294 |
return;
|
|
|
295 |
}
|
|
|
296 |
if (line1 === "") {
|
|
|
297 |
alert("line1 is required");
|
|
|
298 |
return;
|
|
|
299 |
}
|
|
|
300 |
if (city === "") {
|
|
|
301 |
alert("city is required");
|
|
|
302 |
return;
|
|
|
303 |
}
|
|
|
304 |
if (pin === "") {
|
|
|
305 |
alert("pin is required");
|
|
|
306 |
return;
|
|
|
307 |
}
|
|
|
308 |
|
|
|
309 |
var changeLocationData = {};
|
|
|
310 |
|
|
|
311 |
changeLocationData['userId'] = id;
|
|
|
312 |
changeLocationData['name'] = $('#personName').val();
|
|
|
313 |
changeLocationData['line1'] = $('#line1').val();
|
|
|
314 |
changeLocationData['line2'] = $('#line2').val();
|
|
|
315 |
changeLocationData['city'] = $('#city').val();
|
|
|
316 |
changeLocationData['state'] = $('#state').val();
|
|
|
317 |
changeLocationData['pin'] = $('#pinCode').val();
|
|
|
318 |
|
|
|
319 |
console.log(changeLocationData);
|
|
|
320 |
|
|
|
321 |
if (confirm("Are you sure you want to add location!") == true) {
|
|
|
322 |
doPostAjaxRequestWithJsonHandler(context + "/updateLocation", JSON
|
|
|
323 |
.stringify(changeLocationData), function(response) {
|
|
|
324 |
if (response == 'true') {
|
|
|
325 |
alert("successfully Update");
|
|
|
326 |
|
|
|
327 |
$("#addLocationModal").modal('hide');
|
|
|
328 |
|
|
|
329 |
}
|
|
|
330 |
});
|
|
|
331 |
|
|
|
332 |
return false;
|
|
|
333 |
}
|
|
|
334 |
|
|
|
335 |
}
|