Good day to all,
I am struggling with the following for weeks now! It’s just stumbles me I can’t figure it out.
I would like to create a small repeating group per weekday, that can divide the day in multiple segments… with each segment having a different percentage and description (beschrijving)
Goals is to create a template for a week, where users can fill in different surchages per segment of the day.
I can later use this info for when a user creates a shift, and check which hours of the shift end up in which segment of the day… so I can calculate his basic hourly rate and multiply it by the correct surcharge percentage. Hope that makes sense.
So I have 2 RG’s:
Surcharge
with fields:
- name (text) (this is the ORT-naam input)
- surcharge rules (list of Surcharge Rules)
Surcharges Rule
with fields:
- weekday (number) (from 1 till 7)
- starting time (number) (I calculate this by multiplying input hours * 60 + adding the input minutes)
- surcharge percentage (number)
- description (text)
So when a user presses the button: + Nieuwe ORT,
for the monday (and every other day of the week), standard info a user sees is:
Start-time: 00:00
End-time: 24:00
Surcharge: 100% (user can change this)
Description: (they can fill in themselves)
When the user presses the button: + Regel, a new row is added,
and the End-time on the first row will be changed to 07:00 (user can change this)
and the Start-time on the new rule will be the same as the End-time on the first row. The End-time on the new row will change to 24:00.
A user can only change the end-time. When the user changes the end-time on the first row, the start-time on the second row has to change to the exact same time.
The user can press the button: + regel, as many times as he wants.
Final result could look like:
Start-time, End-time, Surcharge, Description
00:00 - 07:00, 125%, night
07:00 - 18:00, 100%, day
18:00 - 24:00, 115%, evening
The user can do this for every day of the week, and as well for holidays.
Of course a row can as well be deleted…
When the user presses the button: SAVE (not visible on the screenshots), a new thing Surcharge will be created, with the ORT-naam, and all the Surcharge-Rules need to be added.
I know the best solution would be to use custom states, and only after pressing SAVE, all info should be stored in the database. But I have tried that, but not working at the moment (for me). Can’t solve it.
I have seen the topic of:
Add dynamic rows…
Which is pretty awesome, but not doing exactly what I need and I can’t get it to work like I would like it to.
In the end I would not even need to store the “Start-time”… because it’s either 0, when current cell index = 1, and else it needs to be the end-time of the previous row.
Can some one please give me some guidelines… I have tried it with Chat GPT as well, still not getting to the proper solution.
Thanks in advance!