Page 1 of 2
Employee time recording - possible with nuBuilder?
Posted: Fri Mar 12, 2021 7:51 pm
by Olikun
Hello,
does anyone know if it is possible to do employee time tracking with nuBuilder?
Employee comes to work and logs in => date and time is saved
When the work is over, the employee logs out => date and time are saved
No matter how. I am grateful for every idea.
I only have 2 employees
It can be a separate form with all the names of the employees and each employee clicks on his name at login / logout
Many greetings

Re: Employee time recording - possible with nuBuilder?
Posted: Sat Mar 13, 2021 7:33 am
by kev1n
Hi,
You can define data type TIMESTAMP and set default value to CURRENT_TIMESTAMP. So when the record is saved for the first time, the start date/time is set automatically.
When the form is saved the 2nd time, a AS PHP script can set the end daate/time using an Update statement.
Code: Select all
UPDATE `table_name`SET end_time = now() WHERE table_name_id = '#RECORD_ID'
You can also use separate start and end button and show/hide them accordingly .
Re: Employee time recording - possible with nuBuilder?
Posted: Sat Mar 13, 2021 11:09 am
by Janusz
Hi Olikun,
I prepared short example/demo how to implement time recording with nuBuilder.
And some calculation example on the form - for the spices calculation
You can find video with explanation on youtube:
https://youtu.be/LJmKrOQ-AP8
This demo is available on our server:
https://test.nubuilder.cloud/
you can log with:
login: test
psw: nutest
This is in demo mode so you can have access to the used code - but if you implement some changes it will not be finally saved.
If you would have some questions please let me know.
Re: Employee time recording - possible with nuBuilder?
Posted: Sat Mar 13, 2021 12:01 pm
by Dalkeith
Janusz's solution is better - I would probably do it through the default setting of the field in the database as well but implementing a field that is updated with the date everytime it is edited was my first step into understanding how Nubuilder worked..
Here's some Javascript that can be used widely to update a field to show when a record was updated. It could be adapted to include the time...
To be placed
Forms / Form of choice / Custom Code / Javascript
Code: Select all
function GetTodayDate() {
var tdate = new Date();
var dd = tdate.getDate(); //yields day
var MM = tdate.getMonth(); //yields month
var yyyy = tdate.getFullYear(); //yields year
var currdate = dd + "-" + MM + "-" + yyyy;
return currdate;
}
Function to update field called “DateUpdated” on edit- to be used with the GetTodayDate() function
Code: Select all
function nuOnSave() {
if (nuFORM.edited == true)
{
$( "#DateUpdated" ).val( GetTodayDate() );
}
return true;
}
and from Stack overflow here is a Javascipt version that does time = its useful to compare the function that I have and the function listed on stack overflow.
Code: Select all
function timeNow(i) {
var d = new Date(),
h = (d.getHours()<10?'0':'') + d.getHours(),
m = (d.getMinutes()<10?'0':'') + d.getMinutes();
i.value = h + ':' + m;
}
Re: Employee time recording - possible with nuBuilder?
Posted: Sat Mar 13, 2021 12:12 pm
by Dalkeith
Also I once built a timing system in MS Access and hooked it up to an RFID antennae so I could pick up the times from the box and then do all the calculations for the racers
The core SQL was this - This was MS Access SQL no idea whether it would work in MYSQL but expect it would just need some tweaks.
Code: Select all
SELECT T1.*
FROM MyTable T1
WHERE EXISTS
(SELECT T2.*
FROM MyTable T2
WHERE T2.RFIDtag = T1.RFIDtag
AND T2.ID < T1.ID
AND T2.Time <= T1.Time
AND T2.Time >= T1.Time - TimeSerial(0, 0, 20));
And an explanation of the above.
https://cloudydatablog.net/?p=519
and here is a wider view
https://cloudydatablog.net/?p=156
Re: Employee time recording - possible with nuBuilder?
Posted: Sat Mar 13, 2021 1:30 pm
by apmuthu
There appears to be some error in function GetTodayDate() for the computation of the value of twoDigitMonth.
Re: Employee time recording - possible with nuBuilder?
Posted: Sun Mar 14, 2021 7:52 am
by Olikun
Janusz wrote:Hi Olikun,
I prepared short example/demo how to implement time recording with nuBuilder.
And some calculation example on the form - for the spices calculation
You can find video with explanation on youtube:
https://youtu.be/LJmKrOQ-AP8
This demo is available on our server:
https://test.nubuilder.cloud/
you can log with:
login: test
psw: nutest
This is in demo mode so you can have access to the used code - but if you implement some changes it will not be finally saved.
If you would have some questions please let me know.
Hello Janusz,
thank you so much, you are great.
I'm trying the spice tool right now.
I left you an answer in the original post.
https://forums.nubuilder.cloud/viewtopic.php?f=19&t=10890
It works, but unfortunately I cannot save it.
I'll try the time tool later

Re: Employee time recording - possible with nuBuilder?
Posted: Sun Mar 14, 2021 9:12 am
by Janusz
You are welcome,
You can try as well how it looks like when employee will log - just use:
log: guest
psw: nuguest
and here the download link to that test DB - so you can test with save on your computer directly (ver 2.2).
https://drive.google.com/file/d/10wu_u- ... sp=sharing
Re: Employee time recording - possible with nuBuilder?
Posted: Sun Mar 14, 2021 9:27 am
by Dalkeith
apmuthu wrote:There appears to be some error in function GetTodayDate() for the computation of the value of twoDigitMonth.
Thanks apmuthu I've edited and removed that whole variable.
Re: Employee time recording - possible with nuBuilder?
Posted: Sun Mar 14, 2021 10:19 am
by Janusz
Please note that saving mode is now allowed for the Spices form:
https://test.nubuilder.cloud/
you can log with (globeadmin type account).
login: test
psw: nutest
(standard user type account)
log: guest
psw: nuguest
(browser restart might be needed if you have previous version opened recently)