angular.module('kalgudiApp.profile').controller('subscriberProfileController', ["$scope", "profileService", "$rootScope", "$injector", "helpandlegalservice", "Upload", "$state", "$timeout", "kalgudiLiterals", "programsFactory", "S3UploadService", function($scope, profileService, $rootScope, $injector, helpandlegalservice, Upload, $state, $timeout, kalgudiLiterals, programsFactory, S3UploadService) { $rootScope.listOfAssets = [{"type":"LAND INFO","soilHealthCard":[{"name":"Screenshot from 2018-10-05 12-12-20.png","url":"devkalgudi.vasudhaika.net/data/gallery/M0004ja0PRFREG2017092545778793VSSPL1539674318.296.png","size":377438,"context":"","msgType":"IMAGE","$$hashKey":"object:646"},{"name":"adobe_reader_reference.pdf","url":"devkalgudi.vasudhaika.net/data/gallery/M0004ja0PRFREG2017092545778793VSSPL1539607886.683.pdf","size":960661,"context":"","msgType":"DOCUMENT"}],"name":"Land name","landInfo":{"name":"Land name","area":"50 acres","irrigation":"water pump","description":"Soil health cared not available"},"crop":{"productId":"000000019397","productName":"Paddy seeds","baseUnitId":"1","baseUnitName":"kg","commodityId":"101516114","commodityName":"Paddy seeds","varietyId":"101516114000","varietyName":"Not Applicable","groupId":"15","groupName":"Cereals","imageUrl":"https://s3.amazonaws.com/kalgudicontent/commodities/000000019397_1.jpg","productDescription":"","listofUnits":[],"localeName":"","company":"000000","crops":"1571","productType":"FARMERPRODUCT","brand":false,"isApproved":true,"isEdited":false,"skusList":[{"skuId":"07879316-2301-4557-82d1-c6e6ee03d659","brandId":"000000019397","imageUrl":"https://s3.amazonaws.com/kalgudicontent/commodities/000000019397_1.jpg","name":"Paddy seeds","unit":"kg","stock":23,"price":63,"approved":true,"entryDate":"2018-09-23","productName":"Paddy seeds","$$hashKey":"object:287","showSKUmenuFlag":true}],"allowed":false,"$$hashKey":"object:273","productlength":0,"alsoKnownAsList":[]},"geoFence":{"geoFencelatlngs":[{"lat":28.70204607019883,"lng":77.1378621005249},{"lat":28.70138732798779,"lng":77.13784064285278},{"lat":28.70140614925138,"lng":77.13884915344238}],"geoFencelatlngsArray":[[28.70204607019883,77.1378621005249],[28.70138732798779,77.13784064285278],[28.70140614925138,77.13884915344238]],"areaOfGeoFence":"0.892 acres","markerGeofence":[28.70171669909331,77.13834489814758],"locationOfGeoFence":"JD/141, Vaishali, Dakshini Pitampura, Pitampura, Delhi, 110034, India"},"$$hashKey":"object:77"},{"type":"LIVE STOCK","productInfo":{"productId":"000000000006","productName":"Hariana Cow","baseUnitId":"4","baseUnitName":"numbers","commodityId":"101015016","commodityName":"Cattle","varietyId":"10101501601N","varietyName":"Hariana","groupId":"1","groupName":"Livestock","imageUrl":"http://cdn.kalgudi.com/commodities/000000000001_1.jpg,http://cdn.kalgudi.com/commodities/000000000001_2.jpg","alsoKnownAs":"","productDescription":"It is the native of Rohtak, Karnal, Jind, Hissar and Gurgaon districts in the state of Haryana. The cattle are of medium to large size, and are generally of white to gray shades of body complexion. Haryanvi, also known as Hariana cattle, is a breed of oxen and cow cattle native to North India. Hariana breed, found in Haryana and eastern Punjab, is one of the 75 known breeds of Zebu (Bos indicus).","localeNames":[{"languageId":1,"languageName":"English","displayName":"Hariana Cow","$$hashKey":"object:866"},{"languageId":2,"languageName":"Hindi","displayName":"हरियाणा गाय","$$hashKey":"object:867"},{"languageId":3,"languageName":"Kannada","displayName":"ಹರಿಯಾಣ ಹಸು","$$hashKey":"object:868"},{"languageId":4,"languageName":"Marathi","displayName":"हरिआना गाय","$$hashKey":"object:869"},{"languageId":5,"languageName":"Tamil","displayName":"ஹரியான மாடு","$$hashKey":"object:870"},{"languageId":6,"languageName":"Telugu","displayName":"హరియాన ఆవు","$$hashKey":"object:871"},{"languageId":7,"languageName":"Malayalam","displayName":"ഹരിയാന പശു","$$hashKey":"object:872"},{"languageId":8,"languageName":"Gujarathi","displayName":"हरियाणा गाय","$$hashKey":"object:873"},{"languageId":9,"languageName":"Bengali","displayName":"হরিয়ানা গরু","$$hashKey":"object:874"},{"languageId":10,"languageName":"Punjabi","displayName":"हरियाणा गाय","$$hashKey":"object:875"},{"languageId":14,"languageName":"Assamese","displayName":"হৰিঅন গরু","$$hashKey":"object:876"},{"languageId":15,"languageName":"Manipuri","displayName":"हरियाणा गाय","$$hashKey":"object:877"},{"languageId":16,"languageName":"Oriya","displayName":"हरियाणा गाय","$$hashKey":"object:878"}],"listofUnits":[],"company":"Not Applicable","productType":"variety","brand":false,"isApproved":false,"isEdited":false,"allowed":false,"$$hashKey":"object:735"},"code":"GNT02FRM01ANI01","lactationStatus":true,"description":"My Cow","name":"Patanjali","birthYear":"2018-02-25T18:30:00.000Z","weight":"120 kgs"},{"type":"LIVE STOCK","productInfo":{"productId":"000000000006","productName":"Hariana Cow","baseUnitId":"4","baseUnitName":"numbers","commodityId":"101015016","commodityName":"Cattle","varietyId":"10101501601N","varietyName":"Hariana","groupId":"1","groupName":"Livestock","imageUrl":"http://cdn.kalgudi.com/commodities/000000000001_1.jpg,http://cdn.kalgudi.com/commodities/000000000001_2.jpg","alsoKnownAs":"","productDescription":"It is the native of Rohtak, Karnal, Jind, Hissar and Gurgaon districts in the state of Haryana. The cattle are of medium to large size, and are generally of white to gray shades of body complexion. Haryanvi, also known as Hariana cattle, is a breed of oxen and cow cattle native to North India. Hariana breed, found in Haryana and eastern Punjab, is one of the 75 known breeds of Zebu (Bos indicus).","localeNames":[{"languageId":1,"languageName":"English","displayName":"Hariana Cow","$$hashKey":"object:866"},{"languageId":2,"languageName":"Hindi","displayName":"हरियाणा गाय","$$hashKey":"object:867"},{"languageId":3,"languageName":"Kannada","displayName":"ಹರಿಯಾಣ ಹಸು","$$hashKey":"object:868"},{"languageId":4,"languageName":"Marathi","displayName":"हरिआना गाय","$$hashKey":"object:869"},{"languageId":5,"languageName":"Tamil","displayName":"ஹரியான மாடு","$$hashKey":"object:870"},{"languageId":6,"languageName":"Telugu","displayName":"హరియాన ఆవు","$$hashKey":"object:871"},{"languageId":7,"languageName":"Malayalam","displayName":"ഹരിയാന പശു","$$hashKey":"object:872"},{"languageId":8,"languageName":"Gujarathi","displayName":"हरियाणा गाय","$$hashKey":"object:873"},{"languageId":9,"languageName":"Bengali","displayName":"হরিয়ানা গরু","$$hashKey":"object:874"},{"languageId":10,"languageName":"Punjabi","displayName":"हरियाणा गाय","$$hashKey":"object:875"},{"languageId":14,"languageName":"Assamese","displayName":"হৰিঅন গরু","$$hashKey":"object:876"},{"languageId":15,"languageName":"Manipuri","displayName":"हरियाणा गाय","$$hashKey":"object:877"},{"languageId":16,"languageName":"Oriya","displayName":"हरियाणा गाय","$$hashKey":"object:878"}],"listofUnits":[],"company":"Not Applicable","productType":"variety","brand":false,"isApproved":false,"isEdited":false,"allowed":false,"$$hashKey":"object:735"},"code":"GNT02FRM01ANI01","lactationStatus":true,"description":"My Cow","name":"Lakshmi","birthYear":"2018-02-25T18:30:00.000Z","weight":"120 kgs"}]; $scope.showAsserts = function(){ $state.go('programs.asserts'); // if() { // } else { // //open add assert page // } } //Injection Ionic Model if(!IS_MOBILE_DEVICE) { $uibModal = $injector.get('$uibModal'); } else { $ionicModal = $injector.get("$ionicModal"); } $scope.crop = {}; $scope.profileLiterals = kalgudiLiterals ; $scope.request = { offset : 0, limit : 10 } $scope.location_picker_flag = true; $rootScope.openProduct=false; $scope.currentCommodity={}; $scope.modifyMobileFlag = false; $scope.isOTPTileRequired = false; $scope.isNameUpdated = false; $scope.isTitleUpdated = false; $scope.requestForOTPButton = "send verification code"; $scope.currentlocation={ locationName:'', geoLocation:{} } $scope.showEditFlagTitle = false; $scope.showEditFlagName = false; $scope.showEditFlagChange = function(input){ if(input == 'name'){ $scope.showEditFlagName = !$scope.showEditFlagName; }else if (input == 'title') { $scope.showEditFlagTitle = !$scope.showEditFlagTitle; } } // To show location picker directive $scope.locationpickerflag = function(){ $scope.location_picker_flag = true; } // To receive selected location object $scope.hideLocationModel = function(geoLocation){ $scope.selectedLocation = geoLocation; $scope.location_picker_flag = false; $rootScope.spinerisActive = true; $scope.updateSubscribersLocation(geoLocation); } // To call service and update the location of selected subscriber $scope.updateSubscribersLocation = function (geoLocation) { if(!geoLocation.zipcode){ geoLocation.zipcode = ""; } var request = { "entityId" : $rootScope.programId, "googleLocationTo" : geoLocation, "assistantDetails" : { "profileKey" : $rootScope.loggedInUserBusinessProfile.profileKey, "firstName" : $rootScope.loggedInUserBusinessProfile.firstName, "profilePicURL" : $rootScope.loggedInUserBusinessProfile.profilePicUrl } } var profileKey = $scope.selectedSubscriber.profileKey; var businessKey = $scope.selectedSubscriber.defaultBusinessKey; profileService.updateSubscribersLocation(profileKey, businessKey, request).then(function(response){ $rootScope.spinerisActive = false; if(response.code == 201){ profileService.getUserProfile(profileKey).then(function(response){ $scope.subscribersLocation.locationLong = response.lstOfUserBusinessDetailsInfo[0].locationTo.locationLong; if(detectmob()){ $state.go("programs.profileHome.profile"); }else{ $scope.closeProductPicker(); } }) } }, function(error){ $rootScope.spinerisActive = false; console.error("[ERROR]: ", error); }) } $scope.updateSubscriberProfiledata = function (data) { $rootScope.spinerisActive = true; var request = { "entityId" : $rootScope.programId, "data" : '', "assistantDetails" : { "profileKey" : $rootScope.loggedInUserBusinessProfile.profileKey, "firstName" : $rootScope.loggedInUserBusinessProfile.firstName, "profilePicURL" : $rootScope.loggedInUserBusinessProfile.profilePicUrl } } var profileKey = $scope.selectedSubscriber.profileKey; if(data == 'name'){ request.data = $scope.selectedSubscriber.firstName; profileService.updateSubscribersName(profileKey, request).then(function(response){ $rootScope.spinerisActive = false; if(response.code == 201){ profileService.getUserProfile(profileKey).then(function(response){ $scope.selectedSubscriber = response; if(detectmob()){ $state.go("programs.profileHome.profile"); }else{ $scope.closeProductPicker(); } }) } }, function(error){ $rootScope.spinerisActive = false; console.error("[ERROR]: ", error); }); } else if(data == 'title'){ request.data = $scope.selectedSubscriber.lstOfUserBusinessDetailsInfo[0].businessTypeName; profileService.updateSubscribersTitle(profileKey, request).then(function(response){ $rootScope.spinerisActive = false; if(response.code == 201){ profileService.getUserProfile(profileKey).then(function(response){ $scope.selectedSubscriber = response; if(detectmob()){ $state.go("programs.profileHome.profile"); }else{ $scope.closeProductPicker(); } }) } }, function(error){ $rootScope.spinerisActive = false; console.error("[ERROR]: ", error); }); } else if(data == 'defaultEntity'){ } } // To compress the selected image size /*$scope.compressFile=function(file,uploadedFiles) { // Create a file reader var reader = new FileReader(); // Load files into file reader reader.readAsDataURL(file); // Set the image once loaded into file reader reader.onload = function(e) { //Create an image var img = document.createElement("img"); var canvas = document.createElement("canvas"); var ctx = canvas.getContext("2d"); img.src = e.target.result; ctx.drawImage(img, 0, 0); var MAX_WIDTH = 720; var MAX_HEIGHT = 720; var width; var height; img.onload = function(){ width = img.width; height = img.height; if(width>0||height>0){ if (width > height) { if (width > MAX_WIDTH) { height *= MAX_WIDTH / width; width = MAX_WIDTH; } } else { if (height > MAX_HEIGHT) { width *= MAX_HEIGHT / height; height = MAX_HEIGHT; } } canvas.width = width; canvas.height = height; var ctx = canvas.getContext("2d"); ctx.drawImage(img, 0, 0, width, height); var dataurl = canvas.toDataURL("image/jpeg",0.8); var byteString; if (dataurl.split(',')[0].indexOf('base64') >= 0) byteString = atob(dataurl.split(',')[1]); else byteString = unescape(dataurl.split(',')[1]); // separate out the mime component var mimeString = dataurl.split(',')[0].split(':')[1].split(';')[0]; // write the bytes of the string to a typed array var ia = new Uint8Array(byteString.length); for (var i = 0; i < byteString.length; i++) { ia[i] = byteString.charCodeAt(i); } var tempBlob = new Blob([ia], {type:"image/jpeg"}); $scope.compressUploadProfilePic(tempBlob,uploadedFiles); } else { $scope.compressUploadProfilePic(file,uploadedFiles); } }; } }*/ // To receive selected image object for profile update of selected subscriber $scope.uploadProfilePic = function($files, $file, $newFiles, $duplicateFiles, $invalidFiles, $event) { helpandlegalservice.uploadS3Policy('profilepic',$file.type).then(function(result){ $scope.policyData= result; /*$scope.compressFile( $file,$files); */ S3UploadService.compressImage($file).then( function (compressedImage) { $scope.compressUploadProfilePic (compressedImage, $files); }); }); } // To upload the selected image into S3 bucket and call service to update profile picture of selected subscriber $scope.compressUploadProfilePic=function(tempFile,files) { var fileFormats=["jpg","JPG","jpeg","JPEG","png","PNG","gif","GIF"]; var checkfiletypes=""; var checkfilesize=""; var filename = false; if (files && files.length != 0) { for (index in files) { for (var i in fileFormats) { if(files[index].name.search(fileFormats[i])){ filename = true; break; } } if (!filename) { checkfiletypes = "notsupported"; } if(tempFile.size > 2097152){ checkfilesize = "notSupportedSize"; } } } if((checkfiletypes != "notsupported" && checkfilesize != "notSupportedSize")){ var fileExtension = ".png"; // Keeping static extension as '.png', otherwise profile Pic url will change /*if(tempFile && tempFile.name){ fileExtension = "." + tempFile.name.split('.').pop(); }*/ Upload.upload({ url: ATTACH_BUCKETNAME + (IS_DOCKER ? '' : ".s3.amazonaws.com/"), method: 'POST', data: { key: 'data/profilepics/' + $scope.selectedSubscriber.profileKey + fileExtension, // the key to store the file on S3, could be file name or customized AWSAccessKeyId: 'AKIAJPKIEGQPZLTARDXQ', acl: 'public-read', // sets the access to the uploaded file in the bucket: private, public-read, ... policy: $scope.policyData.policy, // base64-encoded json policy (see article below) signature: $scope.policyData.signature, // base64-encoded signature based on policy string (see article below)*/ "Content-Type": tempFile.type != '' ? tempFile.type : 'application/octet', // content type of the file (NotEmpty) // this is needed for Flash polyfill IE8-9 file: tempFile } }).progress(function (evt) { $scope.spinnerPicUpload = true; }).success(function (data, status, headers, config) { var request = { "attachmentType":'gallery', "attachmentStatus":true } $scope.uploadFileUrl = SERVER_IP + "/data/profilepics/" + $scope.selectedSubscriber.profileKey + fileExtension +"?" + new Date().getTime(); var request = { "entityId" : $rootScope.programId, "profilePicURL" : $scope.uploadFileUrl, "assistantDetails": { "profileKey" : $rootScope.loggedInUserBusinessProfile.profileKey, "firstName" : $rootScope.loggedInUserBusinessProfile.firstName, "profilePicURL" : $rootScope.loggedInUserBusinessProfile.profilePicUrl } } profileService.updateSubscribersProfilePic($scope.selectedSubscriber.profileKey,request).then(function(result) { if(result.code == 201) { $scope.selectedSubscriber.profilePicUrl = $scope.uploadFileUrl; $scope.spinnerPicUpload = false; } else { $rootScope.commonTopErrorAlert($scope.profileLiterals.searchByKey('KL_PR_0165')); } }); }).error(function (data, status, headers, config) { var request = { "attachmentType":'gallery', "attachmentStatus":false } //$scope.updateAttachmentOptions(request); }); }else{ $scope.spinnerPicUpload = false; if(checkfilesize == "notSupportedSize"){ $rootScope.commonTopErrorAlert($scope.profileLiterals.searchByKey('KL_upload_0005')); } if (checkfiletypes == "notsupported") { $rootScope.commonTopErrorAlert($scope.profileLiterals.searchByKey('KL_CNTS_0123')); } } } // To open product picker $scope.opencommodity_modalfun =function(){ $rootScope.openProduct=true; } // To close product picker $scope.closecommodityModal=function(){ $rootScope.openProduct=false; } // Will toggle mobile view to edit and update $scope.toggleModifyMobileFlag = function(){ $scope.modifyMobileFlag = !$scope.modifyMobileFlag; $scope.isOTPTileRequired = false; $scope.isMobileAlreadyRegistered = false; } // To add newly selected products into selected subscriber profile $scope.productToProfile = function(){ if($scope.currentCommodity.commodityName.hasOwnProperty('productId')) { $scope.lstOfProducts = []; $scope.lstOfProducts.push($scope.currentCommodity.commodityName); $scope.request = { "lstOfProducts" : $scope.lstOfProducts } $timeout(function(){$rootScope.spinerisActive = true;},500); profileService.addNewProducts($scope.request,$scope.selectedSubscriber.profileKey,$scope.selectedSubscriber.defaultBusinessKey).then(function(result) { if(result.code == 201) { profileService.getUserProfile($scope.selectedSubscriber.profileKey).then(function(result) { $timeout(function(){$rootScope.spinerisActive = false;},500); $scope.subscribersProducts = result.lstOfUserBusinessDetailsInfo[0].lstOfProducts; $scope.currentCommodity.commodityName={}; }); } }); } } // Will request for OTP to newly given mobile number to update mobile number in selected subscriber profile $scope.requestForOTP = function(){ $rootScope.spinerisActive = true; $scope.request = { "oldMobileNo" : $scope.selectedSubscriber.mobileNo, "newMobileNo" : $scope.selectedSubscriber.mobileCode + "" + $scope.selectedSubscriber.mobileNumber, "entityId" : $rootScope.programId, "mobileTelecomCode" : $scope.selectedSubscriber.mobileCode, "assistantDetails":{ "profileKey" : $rootScope.loggedInUserBusinessProfile.profileKey, "firstName" : $rootScope.loggedInUserBusinessProfile.firstName, "profilePicURL" : $rootScope.loggedInUserBusinessProfile.profilePicUrl } } profileService.getOTPtoUpdateMobileNumber($scope.selectedSubscriber.profileKey, $scope.request).then(function(response){ $rootScope.spinerisActive = false; if(typeof response == 'string' && response.includes("OTP generated and sent to new mobileNo")) { $scope.requestForOTPButton = "resend OTP"; $scope.isOTPTileRequired = true; $scope.isMobileAlreadyRegistered = false; } else if(response == 400) { $scope.errorMessage = $scope.selectedSubscriber.mobileCode + "-" + $scope.selectedSubscriber.mobileNumber + " is already registered with us"; $scope.isMobileAlreadyRegistered = true; } }); } // Will verify the given OTP and update mobile number in selected subscriber profile $scope.verifyOTPandUpdateMobileNumber = function(){ $rootScope.spinerisActive = true; profileService.verifyOTPtoUpdateMobileNumber($scope.selectedSubscriber.profileKey, $scope.request).then( function(response){ $rootScope.spinerisActive = false; //$scope.isOTPInvalid = true; $scope.toggleModifyMobileFlag(); }); } // To add new crop details to farmers profile $scope.addNewProduct = function () { $state.go('programs.profileHome.addProducts',{ programId : $rootScope.programId, userId : $scope.selectedSubscriber.profileKey } ); } // Will show the list of crop details added to the farmer's profile $scope.showCropList = function () { if($scope.subscribersCropList && $scope.subscribersCropList.length) { $state.go('programs.profileHome.cropDetails'); } else { $scope.addNewProduct(); } } var getSelectedSubscriber = function(){ var profileKey = window.localStorage.getItem("selectedSubscriberProfileKey"); window.localStorage.removeItem("selectedSubscriberProfileKey"); $rootScope.spinerisActive = true; profileService.getUserProfile(profileKey).then(function(response){ $rootScope.spinerisActive = false; $scope.selectedSubscriber = response; }); } $scope.openCompanyPage = function () { window.localStorage.setItem('selectedSubscriberProfileKey', $scope.selectedSubscriber.profileKey); $state.go('profile.viewMembershipshome.editCompanyInfo'); } $scope.getCropDetails = function (offset, limit) { if(!$scope.selectedSubscriber) { return false; } var programId = $rootScope.programId; var farmerId = $scope.selectedSubscriber.profileKey; var assistantId = $rootScope.loggedInUserBusinessProfile.profileKey; programsFactory.getCropDetails(programId, farmerId, assistantId, offset, limit). then ( function(response) { $scope.subscribersCropList = response; }); } // assigning the data from subscribersCropList to crop for the model $scope.shareData = function(index){ if($scope.subscribersCropList.length > 0){ $scope.crop = $scope.subscribersCropList[index]; } // $scope.closeAddAdminModal(); } //Model Start $scope.openAddAdminModal = function () { // Initialize add admin modal $scope.adminModal = $ionicModal.fromTemplateUrl($rootScope.themebasepathvalue + 'programs/updateProfile/cropDetails-fullView.html', { scope: $scope, animation: 'slide-in-up', }).then(function (modal) { $scope.adminModal = modal; $scope.adminModal.show(); }); } //Model Close $scope.closeAddAdminModal = function () { $scope.adminModal.hide(); } //Show and hide of Documents in fullview $scope.populateDocument = function(document) { document.populateDoc = !document.populateDoc; } function initializelocation() { function address_component_from_google_geocode(address_components) { var result = []; for (var i = address_components.length-1; i>=0; i--) { var component = address_components[i]; result[component.types[0]] = component.long_name; } return result; } var input = document.getElementById('LocationUpdate'); var autocomplete = new google.maps.places.Autocomplete(input); autocomplete.addListener('place_changed', function () { var place = autocomplete.getPlace(); // place variable will have all the information you are looking for. place.address_components=address_component_from_google_geocode(place.address_components); place.address_components["formatted_address"] = place.formatted_address; var location = document.getElementById("LocationUpdate"); $scope.currentlocation.geoLocation.invalid=false; var geoLocation = { googleLocationTo : { locality: place.address_components.locality, adminLevel2: place.address_components.administrative_area_level_2, adminLevel1: place.address_components.administrative_area_level_1, countryName: place.address_components.country, zipcode: place.address_components.postalCode, latitude: place.geometry['location'].lat().toString(), longitude: place.geometry['location'].lng().toString() }, formatted_address: place.address_components.formatted_address } // If didnt got any locality from google then check for other available addresses if(!geoLocation.googleLocationTo.locality) { geoLocation.googleLocationTo.locality = (place.address_components.sublocality) || (place.address_components.sublocality_level_1) || (place.address_components.sublocality_level_2) || (place.address_components.sublocality_level_3) || (place.address_components.sublocality_level_4) || (place.address_components.sublocality_level_5) } if(geoLocation.googleLocationTo.locality && !geoLocation.googleLocationTo.adminLevel2){ geoLocation.googleLocationTo.adminLevel2 = geoLocation.googleLocationTo.locality; } if(geoLocation.googleLocationTo.locality && geoLocation.googleLocationTo.adminLevel1 && geoLocation.googleLocationTo.countryName && geoLocation.googleLocationTo.adminLevel2){ $timeout(function() { $scope.currentlocation.geoLocation=geoLocation.googleLocationTo; $scope.currentlocation.geoLocation.invalid=false;},0); } else { $timeout(function() { $scope.currentlocation.geoLocation.invalid=true;},0); } }); } $rootScope.$on("subscriberDetails", function(event, subscriber) { $scope.selectedSubscriber = subscriber; $rootScope.selectedEmployee = {}; $scope.getCropDetails($scope.request.offset, $scope.request.limit); // Storing details for editing default company / organization for employee types if($scope.selectedSubscriber.additionalBizDetails && $scope.selectedSubscriber.additionalBizDetails.businessTypeId == 'BT000017'){ $rootScope.selectedEmployee = $scope.selectedSubscriber; $rootScope.selectedEmployee.digitalAssitanceFlag = true; } }); if($state.current.data.action == 'profileUpdate' || $state.current.data.action == 'showCropDetails' || $scope.programstate) { $scope.getCropDetails($scope.request.offset, $scope.request.limit); } //location picker to assistance members if(!detectmob()){ initializelocation(); } if(window.localStorage.getItem("selectedSubscriberProfileKey")){ getSelectedSubscriber(); } }]);