Solutions are there for small hotels
The table has two fields for dates and I can indicate from what day and on what day to occupy a hotel room. But you also need to count those days when he is not busy for the last two months, then from today and two months in advance. Can you tell me how to solve this? What solutions are there for small hotels?
10 replies
-
The first part is an interesting question.
Here is one way. I have two tables (Rooms and Reservations) and a Dashboard. On the Dashboard there is a reference field to Rooms called 'Select a Room'. I put the following in a field called: 'Days Empty (Last 60 Days)'
let roomNum := record(Rooms,number('Select a Room')); let getPast2MonthResv := roomNum.Reservations[var d := SDate; d > today() - 60 and d < today()]; let getActiveResvDays := for loop1 in getPast2MonthResv do days(loop1.SDate, loop1.EDate) end; 60 - sum(getActiveResvDays)
Line 1: uses the record() command to get the record Id of the selected room.
Line 2-3: finds all related records in Reservations that have a SDate that is greater than today - 60 days and less than today.
Line 4-6: takes the records found above and figures out how many days each reservation was and creates an array
Line 7: then subtracts the sum of the days reserved from 60
-
Sorry to keep posting, but here is a simpler code:
let getPast2MonthResv := 'Select a Room'.Reservations[var d := SDate; d > today() - 60 and d < today()]; let getActiveResvDays := for loop1 in getPast2MonthResv do days(loop1.SDate, loop1.EDate) end; 60 - sum(getActiveResvDays)
Silly me forgot that 'Select a Room' is a reference field so it is a direct link to the record. No need to use the record() command to get the record again.
If 'Select a Room' was a dynamic choice field then you would need the record() command, but since it isn't in my test I don't need it.
-
said:
Do we need another table where all the data will be shown? or will everything be here?Take a look at my first comment. There are two data tables (Rooms and Reservations). The Dashboard has a button to create Reservations for a selected Room.
You can add a view in the Dashboard that will bring up the Reservations for the selected Room.
-
said:
That's why we decided to create it ourselves, and it will do what we need.But all of the skills learned in your casino DB carries over to the hotel DB.
Anyways, I've had a few moments so I've created a test DB you can look at.
Content aside
-
1
Likes
- 1 yr agoLast active
- 10Replies
- 121Views
-
3
Following