| 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 |
});
|
|
|
13 |
$(".active-store").live('click', function() {
|
|
|
14 |
storeInfo("main-content");
|
|
|
15 |
});
|
|
|
16 |
|
| 23347 |
ashik.ali |
17 |
$(".retailer-info").live('click', function() {
|
|
|
18 |
retailerInfo("main-content");
|
|
|
19 |
});
|
| 24125 |
govind |
20 |
|
| 23347 |
ashik.ali |
21 |
$("#retailer-details-search-text").live("keyup", function(e) {
|
|
|
22 |
var keyCode = e.keyCode || e.which;
|
| 24125 |
govind |
23 |
if (keyCode == 13) {
|
|
|
24 |
$("#retailer-details-search-button").click();
|
|
|
25 |
}
|
| 23347 |
ashik.ali |
26 |
});
|
| 24125 |
govind |
27 |
|
|
|
28 |
$(".deactivate-store").live('click', function() {
|
|
|
29 |
var fofoId = $(this).data("fofoid");
|
|
|
30 |
console.log(fofoId);
|
|
|
31 |
if (confirm("Are you sure you want to deactivate store!") == true) {
|
|
|
32 |
deactivateStore("main-content", fofoId);
|
|
|
33 |
}
|
|
|
34 |
|
| 23347 |
ashik.ali |
35 |
});
|
| 24125 |
govind |
36 |
|
|
|
37 |
$('#retailerAddressState').live('change', function() {
|
|
|
38 |
var stateName = $(this).find('option:selected').text();
|
|
|
39 |
loadDistrictNames(stateName);
|
|
|
40 |
});
|
| 23347 |
ashik.ali |
41 |
});
|
|
|
42 |
|
| 23837 |
ashik.ali |
43 |
function getDistance(lat1, lon1, lat2, lon2) {
|
| 24125 |
govind |
44 |
var deg2rad = 0.017453292519943295; // === Math.PI / 180
|
|
|
45 |
var cos = Math.cos;
|
|
|
46 |
lat1 *= deg2rad;
|
|
|
47 |
lon1 *= deg2rad;
|
|
|
48 |
lat2 *= deg2rad;
|
|
|
49 |
lon2 *= deg2rad;
|
|
|
50 |
var diam = 12742; // Diameter of the earth in km (2 * 6371)
|
|
|
51 |
var dLat = lat2 - lat1;
|
|
|
52 |
var dLon = lon2 - lon1;
|
|
|
53 |
var a = ((1 - cos(dLat)) + (1 - cos(dLon)) * cos(lat1) * cos(lat2)) / 2;
|
| 23837 |
ashik.ali |
54 |
|
| 24125 |
govind |
55 |
return parseFloat(diam * Math.asin(Math.sqrt(a))).toFixed(2);
|
|
|
56 |
}
|
| 23837 |
ashik.ali |
57 |
|
| 24125 |
govind |
58 |
function getRetailerDetailsByEmailIdOrMobileNumber(domId, emailIdOrMobileNumber) {
|
|
|
59 |
doGetAjaxRequestHandler(context + "/retailerDetails?emailIdOrMobileNumber="
|
|
|
60 |
+ emailIdOrMobileNumber, function(response) {
|
| 23347 |
ashik.ali |
61 |
$('#' + domId).html(response);
|
|
|
62 |
});
|
|
|
63 |
}
|
|
|
64 |
|
| 24125 |
govind |
65 |
function updateRetailerDocument() {
|
|
|
66 |
// $("#updateRetailerShopDocument0").click( function() {
|
| 23347 |
ashik.ali |
67 |
console.log("Update Retailer Document Clicked");
|
| 24125 |
govind |
68 |
// console.log(ownerId);
|
| 23347 |
ashik.ali |
69 |
var emailIdOrMobileNumber = $('#retailer-details-search-text').val();
|
| 24125 |
govind |
70 |
console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);
|
| 23347 |
ashik.ali |
71 |
var file = $('#retailerDocument')[0].files[0];
|
| 24125 |
govind |
72 |
console.log("file : " + file.name);
|
|
|
73 |
uploadRetailerDocument("retailer-details-container", file,
|
|
|
74 |
emailIdOrMobileNumber);
|
| 23347 |
ashik.ali |
75 |
}
|
|
|
76 |
|
| 24125 |
govind |
77 |
function updateRetailerShopDocument(ownerId) {
|
|
|
78 |
// $("#updateRetailerShopDocument0").click( function() {
|
| 23347 |
ashik.ali |
79 |
console.log("Update Retailer Shop Document Clicked");
|
|
|
80 |
console.log(ownerId);
|
|
|
81 |
var shopSize = parseInt($("#shopDetailsSize").attr('size'));
|
| 24125 |
govind |
82 |
console.log("size : " + shopSize);
|
|
|
83 |
for (var index = 0; index < shopSize; index++) {
|
|
|
84 |
if ("updateRetailerShopDocument" + index == ownerId) {
|
|
|
85 |
var emailIdOrMobileNumber = $('#retailer-details-search-text')
|
|
|
86 |
.val();
|
|
|
87 |
console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);
|
|
|
88 |
var shopId = $('#retailerShopDocument' + index).attr("shopId");
|
|
|
89 |
console.log("shopId : " + shopId);
|
|
|
90 |
var file = $('#retailerShopDocument' + index)[0].files[0];
|
|
|
91 |
console.log("file : " + file.name);
|
|
|
92 |
uploadRetailerShopDocument("retailer-details-container", file,
|
|
|
93 |
emailIdOrMobileNumber, shopId);
|
| 23347 |
ashik.ali |
94 |
}
|
|
|
95 |
}
|
|
|
96 |
}
|
|
|
97 |
|
| 24125 |
govind |
98 |
function loadDistrictNames(stateName) {
|
|
|
99 |
if (undefined != $("#districtName")) {
|
|
|
100 |
doGetAjaxRequestHandler(
|
|
|
101 |
context + "/district/all/stateName?stateName=" + stateName,
|
|
|
102 |
function(response) {
|
|
|
103 |
console.log(response);
|
|
|
104 |
var districtMasters = response.response;
|
|
|
105 |
// districtMasters = districtMasters.response;
|
|
|
106 |
var districtNameElements = '<option value="" disabled selected>District Name</option>';
|
|
|
107 |
for (index = 0; index < districtMasters.length; index++) {
|
|
|
108 |
districtNameElements = districtNameElements
|
|
|
109 |
+ '<option value="'
|
|
|
110 |
+ districtMasters[index].name + '">'
|
|
|
111 |
+ districtMasters[index].name + '</option>';
|
|
|
112 |
}
|
|
|
113 |
$('#districtName').html(districtNameElements);
|
|
|
114 |
});
|
| 23347 |
ashik.ali |
115 |
}
|
|
|
116 |
}
|
|
|
117 |
|
| 24125 |
govind |
118 |
function retailerInfo(domId) {
|
|
|
119 |
doGetAjaxRequestHandler(context + "/retailerInfo", function(response) {
|
|
|
120 |
$('#' + domId).html(response);
|
| 23349 |
ashik.ali |
121 |
});
|
| 24125 |
govind |
122 |
}
|
|
|
123 |
function storeInfo(domId) {
|
|
|
124 |
doGetAjaxRequestHandler(context + "/getAllStores", function(response) {
|
|
|
125 |
$('#' + domId).html(response);
|
|
|
126 |
});
|
|
|
127 |
}
|
|
|
128 |
function deactivateStore(domId, fofoId) {
|
|
|
129 |
doPostAjaxRequestHandler(context + "/deactivateStore?fofoId=" + fofoId,
|
|
|
130 |
function(response) {
|
|
|
131 |
if (response == "true") {
|
|
|
132 |
alert("successfully deactivated!");
|
|
|
133 |
storeInfo(domId);
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
});
|
|
|
137 |
}
|