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