I need help to calculate the hours worked

Hello everyone !
I’m creating an app to point the workers when they work. I have two buttons : one for the start and one for the end of work. The problem is that every date (start and end) is on a different row, so, I don’t know how to do to calculate the hours worked. I have screenshots of the actual data and the layout ! Thanks in advance !
Capture d’écran 2023-07-22 154814

Why are they on separate rows?
Wouldn’t it make more sense to record start and end in the same row?

Maybe for start time add row is ok but for end time you could set column value to the existing row

They are on separate rows because there are two buttons. It makes absolutely more sense to record the values of start and end in the same row, but I don’t know how to do it.

How can I do it ???

First you create a button and in it define that it will only be visible if the start column is empty or false, and in this button define an action to add a line with the initial data.

then create another Button that should only be visible, if the start column is filled in and in this button you define an action to change the value of the end of work column.

the problem is that everytime they click on a button, I have the to know their location. So, I’ve got a form in the start and end button. I have “Localisation1” and “Localisation2”. Also, when I put the visibility of the start button on “only visible if start column is empty”, I don’t see it.

the button visible only if the column is empty is hiding the button even when the record is empty?

about the location, you can define an action for button 1 to save the current location in the field “location 1” and another action for button 2 to save the “location 2”

The start button will add a row. Then you need a way to display that same row you just added. On that screen, you have your end button which would open an Edit form instead of a Form. The Edit form will edit the existing row.

1 Like

I have a similar case here where I have a button “mark class as completed” it is displayed when the class completed column is not filled in or is set to false. when I click on it, and the column value is filled with True, the button mentioned above disappears and another appears with the option to uncheck class, in both buttons I add an action to add a line in the first and in the second to change the value in the line.

1 Like

Veja neste video:

3 Likes

And how can I create an edit form ?

When I put the action on show an edit form, I doesn’t edit the previous row

I really need help because I really don’t know how to do to achieve this project. I have the first form in the “start” button. In the form, the user must choose a site and then, he clicks in the localization button. It records the name of the user and the date/time when he began his work.

For the “end” button, this is exactly the same thing for the moment.

What I want to do is just that when he clicks on this “end” button, it records automatically the date/time, his name, the localization (maybe a form with the localization button) and the site. I want like a way to “complete” the row where he started his work.

Maybe can I give you access to the project ? I really need help plz !

Assuming the user would never have to actually see the row they’re logging, I would build it like this.

Have a tab called “Check in/Check out” that is built on top of your user profiles table, filter the tab to the signed-in user’s row using the user’s email or rowID.

In your User Profiles table, create a Query column to the Logs table, filter by the log’s rowID/email (you have to collect this using the form) is this row > user’s rowID/email and the logged date is within today.

Create a single value column to target whole row > first from the query.

Create a single value column to retrieve first > check out timestmap from the query.

Now, on the front end, show a “Check in” form with the choice component for the site, and the location component to log the coordinates to the “Check in location” column. This will only be shown when the query’s empty (meaning the user hasn’t checked in for the date). You would also log the current date/time to the “Start” column, and the user’s rowID/email.

On that same screen, show a “Check out” form with a “show edit screen > single value whole row” action that would edit the logged row for the current date. Only show this when the query is not empty, and the single value > checkout timestamp is not empty (so that the user won’t see the check out button if he/she already checked out).

On that edit screen, show a location component pointing to the “Check out location” column, and write the current date/time to the “Check out timestamp” using a special value.

I think that should be it.

3 Likes

May you take a look on the app ?

I have given the steps for you above, please try and if you get stuck, let us know. I don’t believe doing it in place of you would be the best way going forward. You should understand the build so that you can make changes/fix bugs in the future.