1. Description
For most employees of the enterprise, because of the fixed position of their work, there can be many ways to clock in to check in to ensure that the employee to work on time and normal, but for frequent travel, to the customer site staff, there is no guarantee that they have to work, So hope to be able to position the mobile phone location to ensure that employees have normal work. Take the report development tool Finereport Mobile as an example to demonstrate how the enterprise can solve this problem perfectly.
2. Solution Ideas
You can add a button control through the Finereport template, click the button, get the current location, and copy the location information to a cell, and finally the employee fills in the current template.
3. Example
To achieve the effect shown, click the Location button to get the current position and current time, and display it in the corresponding cell below:
3.1 Template Making
Open the designer, create a new template, design the template as shown in, where E2 is a button control, the control name is a geographic location, C5 is a drop-down box control, E5 is a Time control:
3.2 Getting the current location
There are two ways to get the current location, one is to click the button to get a location, one is to open the template directly when the location is obtained, in the example, we want to achieve by clicking the button to obtain the geographical location.
· Get a location by clicking the button
Open the control settings for the button and add a click event for the control, such as:
JS as follows:
1. Fr.location (status, message) {//Get geo-location
2. If (status== "success") {
3.//Location successful, message returns latitude and longitude value
4. FR. Msg.alert ("Current position is" + message);
5. Contentpane.setcellvalue (2, 3, message);
6.} else {
7.//Location failed, message returned corresponding error message
8. FR. Msg.alert (message); Failed to locate
9.}
10.});
Finereport gets the current position through the Fr.location method, or if the status value is success, the acquisition is successful, otherwise the location fails, and if the location is successful, the returned geo-location information is assigned to the C4 cell.
Note: This method is only useful on the mobile side, if you click the button event in the Web to obtain a geographic location, the direct prompt to locate failed.
· Get the current location after loading ends
If you want to get to the current location after the template is loaded, simply add the above code to the post-load event, open the template, click Templates > Templates Web properties > Fill in the page settings, add a load end event such as:
3.3 Getting the current time
The current check-in time in the template also needs to be assigned to the past, so you also need to get the current time in the button's click event, and assign the value to E4 cell, JS as follows:
1. var mydate = new Date ();
2. var mytime=mydate.getfullyear () + "-" +mydate.getmonth () +1+ "-" +mydate.getdate () + "" +mydate.gethours () + ":" + Mydate.getminutes () + ":" +mydate.getseconds (); Get current time
3. Contentpane.setcellvalue (4, 3, mytime);
button click event All JS as follows:
1. Fr.location (status, message) {//Get geo-location
2. If (status== "success") {
3.//Location successful, message returns latitude and longitude value
4. FR. Msg.alert ("Current position is" + message);
5. Contentpane.setcellvalue (2, 3, message);
6. var mydate = new Date ();
7. Var mytime=mydate.getfullyear () + "-" +mydate.getmonth () +1+ "-" +mydate.getdate () + "" +mydate.gethours () + ":" + Mydate.getminutes () + ":" +mydate.getseconds (); Get current time
8. Contentpane.setcellvalue (4, 3, mytime);
9.
Ten.} else {
11.//Location failed, message returned corresponding error message
. FR. Msg.alert (message); Failed to locate
13.}
14.});
3.4 Effect View
Add the template to the tree of nodes in your data decision system, and how to do this by looking at the Add template, where the template is previewed, such as:
Based on the steps described in adding a server section, log in to the system with the mobile side, access the template, click the Location button to get the current location and current time, such as:
Note: The geographic location acquired by Finereport is longitude and latitude, and needs to be converted if it needs to determine its exact location.
How mobile reports get the current location