Business and ERP
ERPNext Checkin Attendance using GEO Location
How to add employee attendance with GEO Location This can be simply achieved. Go to DoctType ListLook for Document Type Employee CheckinCreate new field...
By Amjid Ali · · Updated · 1 min read

How to add employee attendance with GEO Location
This can be simply achieved.
- Go to DoctType List
- Look for Document Type Employee Checkin
- Create new fields longitude,latitude,area,city,state
- In Customization Section Locate the Client Script
- Replace existing script with below code
frappe.ui.form.on('Employee Checkin', {
onload(frm) {
function onPositionRecieved(position){
var longitude= position.coords.longitude;
var latitude= position.coords.latitude;
frm.set_value('longitude',longitude);
frm.set_value('latitude',latitude);
console.log(longitude);
console.log(latitude);
fetch('https://api.opencagedata.com/geocode/v1/json?q='+latitude+'+'+longitude+'&key=de1bf3be66b546b89645e500ec3a3a28')
.then(response => response.json())
.then(data => {
var city=data['results'][0].components.city;
var state=data['results'][0].components.state;
var area=data['results'][0].components.residential;
frm.set_value('city',city);
frm.set_value('state',state);
frm.set_value('area',area);
console.log(data);
})
.catch(err => console.log(err));
frm.set_df_property('my_location','options','<div class="mapouter"><div class="gmap_canvas"><iframe width=100% height="300" id="gmap_canvas" src="https://maps.google.com/maps?q='+latitude+','+longitude+'&t=&z=17&ie=UTF8&iwloc=&output=embed" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe><a href="https://yt2.org/youtube-to-mp3-ALeKk00qEW0sxByTDSpzaRvl8WxdMAeMytQ1611842368056QMMlSYKLwAsWUsAfLipqwCA2ahUKEwiikKDe5L7uAhVFCuwKHUuFBoYQ8tMDegUAQCSAQCYAQCqAQdnd3Mtd2l6"></a><br><style>.mapouter{position:relative;text-align:right;height:300px;width:100%;}</style><style>.gmap_canvas {overflow:hidden;background:none!important;height:300px;width:100%;}</style></div></div>');
frm.refresh_field('my_location');
}
function locationNotRecieved(positionError){
console.log(positionError);
}
if(frm.doc.longitude && frm.doc.latitude){
frm.set_df_property('my_location','options','<div class="mapouter"><div class="gmap_canvas"><iframe width=100% height="300" id="gmap_canvas" src="https://maps.google.com/maps?q='+frm.doc.latitude+','+frm.doc.longitude+'&t=&z=17&ie=UTF8&iwloc=&output=embed" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe><a href="https://yt2.org/youtube-to-mp3-ALeKk00qEW0sxByTDSpzaRvl8WxdMAeMytQ1611842368056QMMlSYKLwAsWUsAfLipqwCA2ahUKEwiikKDe5L7uAhVFCuwKHUuFBoYQ8tMDegUAQCSAQCYAQCqAQdnd3Mtd2l6"></a><br><style>.mapouter{position:relative;text-align:right;height:300px;width:100%;}</style><style>.gmap_canvas {overflow:hidden;background:none!important;height:300px;width:100%;}</style></div></div>');
frm.refresh_field('my_location');
} else {
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(onPositionRecieved,locationNotRecieved,{ enableHighAccuracy: true});
}
}
}
})
Now
Related videos
Video library- Business and ERP
ERPNext Frappe HR on Docker: Installation and Setup Guide
· 5:51 · 39.2K views
Watch on YouTube - Business and ERP
Attendance and Leave Management: A Comprehensive Guide to Employee Payment Day Calculation
· 5:27 · 3K views
Watch on YouTube
Keep reading
Business and ERPHiring a Technical Designer or Using Software: How Emerging Labels Are Splitting the Spec WorkAn ai tech pack generator has changed a decision that used to be simple for small apparel labels. A founder either paid a technical designer for every style · 3 min read
Business and ERPWhat Healthcare Providers Should Know About Electronic RecordsMissed lab results. Duplicate tests. Referrals that seem to disappear into thin air. In many practices, these issues point back to the same root problem: · 8 min read
Business and ERPHow Businesses Can Improve IT Support While Keeping Their Core Team FocusedImage source · 4 min read