Rev 24125 | Rev 24161 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
$(function() {$("#retailer-details-search-button").live('click',function() {searchContent = $("#retailer-details-search-text").val();if (typeof (searchContent) == "undefined" || !searchContent) {searchContent = "";}getRetailerDetailsByEmailIdOrMobileNumber("retailer-details-container", searchContent);});$(".active-store").live('click', function() {storeInfo("main-content");});$(".retailer-info").live('click', function() {retailerInfo("main-content");});$("#retailer-details-search-text").live("keyup", function(e) {var keyCode = e.keyCode || e.which;if (keyCode == 13) {$("#retailer-details-search-button").click();}});$(".deactivate-store").live('click', function() {var fofoId = $(this).data("fofoid");console.log(fofoId);if (confirm("Are you sure you want to deactivate store!") == true) {deactivateStore("main-content", fofoId);}});$('#retailerAddressState').live('change', function() {var stateName = $(this).find('option:selected').text();loadDistrictNames(stateName);});$("#location").live('click',function() {if ($(this).is(":checked")) {var emailIdOrMobileNumber = $('#retailer-details-search-text').val();var email = $('#emailId').val();doGetAjaxRequestHandler(context+ "/userDetails?emailIdOrMobileNumber="+ emailIdOrMobileNumber, function(response) {if (response == "true") {$("#divLocation").show();} else {alert("user can not Exist")$("#location").prop("checked", false);}});} else {$("#divLocation").hide();}});$(".addlocationbutton").live('click',function() {var userId = $('#retailerId').text();var name = $('#personName').val();var line1 = $('#line1').val();var line2 = $('#line2').val();var city = $('#city').val();var state = $('#state').val();var pin = $('#pinCode').val();if (name === "" && line1 === "" && city === "" && pin === "") {alert("Field can't be empty");return;}if (name === "") {alert("name is required");return;}if (line1 === "") {alert("line1 is required");return;}if (city === "") {alert("city is required");return;}if (pin === "") {alert("pin is required");return;}var locationData = {};locationData['userId'] = $('#retailerId').text();locationData['name'] = $('#personName').val();locationData['line1'] = $('#line1').val();locationData['line2'] = $('#line2').val();locationData['city'] = $('#city').val();locationData['state'] = $('#state').val();locationData['pin'] = $('#pinCode').val();if (confirm("Are you sure you want to add location!") == true) {doPostAjaxRequestWithJsonHandler(context + "/addLocation",JSON.stringify(locationData), function(response) {if (response == 'true') {alert("successfully Add");$("#addLocationModal").modal('hide');}});return false;}});});function getDistance(lat1, lon1, lat2, lon2) {var deg2rad = 0.017453292519943295; // === Math.PI / 180var cos = Math.cos;lat1 *= deg2rad;lon1 *= deg2rad;lat2 *= deg2rad;lon2 *= deg2rad;var diam = 12742; // Diameter of the earth in km (2 * 6371)var dLat = lat2 - lat1;var dLon = lon2 - lon1;var a = ((1 - cos(dLat)) + (1 - cos(dLon)) * cos(lat1) * cos(lat2)) / 2;return parseFloat(diam * Math.asin(Math.sqrt(a))).toFixed(2);}function getRetailerDetailsByEmailIdOrMobileNumber(domId, emailIdOrMobileNumber) {doGetAjaxRequestHandler(context + "/retailerDetails?emailIdOrMobileNumber="+ emailIdOrMobileNumber, function(response) {$('#' + domId).html(response);if ($("#location").is(":checked")){$("#divLocation").show();}});}function updateRetailerDocument() {// $("#updateRetailerShopDocument0").click( function() {console.log("Update Retailer Document Clicked");// console.log(ownerId);var emailIdOrMobileNumber = $('#retailer-details-search-text').val();console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);var file = $('#retailerDocument')[0].files[0];console.log("file : " + file.name);uploadRetailerDocument("retailer-details-container", file,emailIdOrMobileNumber);}function updateRetailerShopDocument(ownerId) {// $("#updateRetailerShopDocument0").click( function() {console.log("Update Retailer Shop Document Clicked");console.log(ownerId);var shopSize = parseInt($("#shopDetailsSize").attr('size'));console.log("size : " + shopSize);for (var index = 0; index < shopSize; index++) {if ("updateRetailerShopDocument" + index == ownerId) {var emailIdOrMobileNumber = $('#retailer-details-search-text').val();console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);var shopId = $('#retailerShopDocument' + index).attr("shopId");console.log("shopId : " + shopId);var file = $('#retailerShopDocument' + index)[0].files[0];console.log("file : " + file.name);uploadRetailerShopDocument("retailer-details-container", file,emailIdOrMobileNumber, shopId);}}}function loadDistrictNames(stateName) {if (undefined != $("#districtName")) {doGetAjaxRequestHandler(context + "/district/all/stateName?stateName=" + stateName,function(response) {console.log(response);var districtMasters = response.response;// districtMasters = districtMasters.response;var districtNameElements = '<option value="" disabled selected>District Name</option>';for (index = 0; index < districtMasters.length; index++) {districtNameElements = districtNameElements+ '<option value="'+ districtMasters[index].name + '">'+ districtMasters[index].name + '</option>';}$('#districtName').html(districtNameElements);});}}function retailerInfo(domId) {doGetAjaxRequestHandler(context + "/retailerInfo", function(response) {$('#' + domId).html(response);});}function storeInfo(domId) {doGetAjaxRequestHandler(context + "/getAllStores", function(response) {$('#' + domId).html(response);});}function deactivateStore(domId, fofoId) {doPostAjaxRequestHandler(context + "/deactivateStore?fofoId=" + fofoId,function(response) {if (response == "true") {alert("successfully deactivated!");storeInfo(domId);}});}function updateLocationButton(id) {var userId = id;var name = $('#personName').val();var line1 = $('#line1').val();var line2 = $('#line2').val();var city = $('#city').val();var state = $('#state').val();var pin = $('#pinCode').val();console.log(id);if (name === "" && line1 === "" && city === "" && pin === "") {alert("Field can't be empty");return;}if (name === "") {alert("name is required");return;}if (line1 === "") {alert("line1 is required");return;}if (city === "") {alert("city is required");return;}if (pin === "") {alert("pin is required");return;}var changeLocationData = {};changeLocationData['userId'] = id;changeLocationData['name'] = $('#personName').val();changeLocationData['line1'] = $('#line1').val();changeLocationData['line2'] = $('#line2').val();changeLocationData['city'] = $('#city').val();changeLocationData['state'] = $('#state').val();changeLocationData['pin'] = $('#pinCode').val();console.log(changeLocationData);if (confirm("Are you sure you want to add location!") == true) {doPostAjaxRequestWithJsonHandler(context + "/updateLocation", JSON.stringify(changeLocationData), function(response) {if (response == 'true') {alert("successfully Update");$("#addLocationModal").modal('hide');}});return false;}}