Hi, I’m working on the logic to develop a scheduling system in PHP, it consists of saving the available hours that a company can work in the bank,
For example, certain days of the week may or may not have free time, as well as certain days, these periods in each time range can have different amounts of customers who can schedule according to the amount of time.
For example, in company 1 = from Monday to Friday from 7:00 am to 10:00 pm there are closed Saturday and Sunday hours
For example in company 2 = It only serves Saturday and Sunday from 1:00 pm to 0:00 am and is closed on other days
At each of these times I have to save the amount of people that can be served, for example
Company 1 = Monday 7:00 am = 4 vacancies
Company 1 = Tuesday 18:00h = 2 vacancies
Company 1 = Friday 19:00h = 0 vacancies - unavailable
Company 2 = Saturday 5:00 pm = 0 vacancies - unavailable
Company 2 = Saturday 18:00h = 5 vacancies
Company 2 = Sunday 20:00h = 6 vacancies
Thinking in a way that I find unconventional and illogical, I would create a form with several and several fields every day of the week with all available times and quantities to be placed as in the attached image, and would save in json format in the database like this for example
Column: scheduleDaysWeeksTimes
{"1":{"ativo":"0","horarios":{"07:00":7,"07:30":0,"08:00":0,"08:30":0,"09:00":0,"09:30":0,"10:00":0,"10:30":0,"11:00":0,"11:30":0,"12:00":0,"12:30":0,"13:00":0,"13:30":0,"14:00":0,"14:30":0,"15:00":0,"15:30":0,"16:00":0,"16:30":0,"17:00":0,"17:30":0,"18:00":0,"18:30":0,"19:00":0,"19:30":0,"20:00":0,"20:30":0,"21:00":0,"21:30":0,"22:00":0,"22:30":0}},"2":{"ativo":"0","horarios":{"07:00":0,"07:30":0,"08:00":0,"08:30":0,"09:00":0,"09:30":0,"10:00":0,"10:30":0,"11:00":0,"11:30":0,"12:00":0,"12:30":0,"13:00":0,"13:30":0,"14:00":0,"14:30":0,"15:00":0,"15:30":0,"16:00":0,"16:30":0,"17:00":0,"17:30":0,"18:00":0,"18:30":0,"19:00":0,"19:30":0,"20:00":0,"20:30":0,"21:00":0,"21:30":0,"22:00":0,"22:30":0}},"3":{"ativo":"0","horarios":{"07:00":0,"07:30":0,"08:00":0,"08:30":0,"09:00":0,"09:30":0,"10:00":0,"10:30":0,"11:00":0,"11:30":0,"12:00":0,"12:30":0,"13:00":0,"13:30":0,"14:00":0,"14:30":0,"15:00":0,"15:30":0,"16:00":0,"16:30":0,"17:00":0,"17:30":0,"18:00":0,"18:30":0,"19:00":0,"19:30":0,"20:00":0,"20:30":0,"21:00":0,"21:30":0,"22:00":0,"22:30":0}},"4":{"ativo":"0","horarios":{"07:00":0,"07:30":0,"08:00":0,"08:30":0,"09:00":0,"09:30":0,"10:00":0,"10:30":0,"11:00":0,"11:30":0,"12:00":0,"12:30":0,"13:00":0,"13:30":0,"14:00":0,"14:30":0,"15:00":0,"15:30":0,"16:00":0,"16:30":0,"17:00":0,"17:30":0,"18:00":0,"18:30":0,"19:00":0,"19:30":0,"20:00":0,"20:30":0,"21:00":0,"21:30":0,"22:00":0,"22:30":0}},"5":{"ativo":"0","horarios":{"07:00":0,"07:30":0,"08:00":0,"08:30":0,"09:00":0,"09:30":0,"10:00":0,"10:30":0,"11:00":0,"11:30":0,"12:00":0,"12:30":0,"13:00":0,"13:30":0,"14:00":0,"14:30":0,"15:00":0,"15:30":0,"16:00":0,"16:30":0,"17:00":0,"17:30":0,"18:00":0,"18:30":0,"19:00":0,"19:30":0,"20:00":0,"20:30":0,"21:00":0,"21:30":0,"22:00":0,"22:30":0}},"6":{"ativo":"0","horarios":{"07:00":0,"07:30":0,"08:00":0,"08:30":0,"09:00":0,"09:30":0,"10:00":0,"10:30":0,"11:00":0,"11:30":0,"12:00":0,"12:30":0,"13:00":0,"13:30":0,"14:00":0,"14:30":0,"15:00":0,"15:30":0,"16:00":0,"16:30":0,"17:00":0,"17:30":0,"18:00":0,"18:30":0,"19:00":0,"19:30":0,"20:00":0,"20:30":0,"21:00":0,"21:30":0,"22:00":0,"22:30":0}},"7":{"ativo":"0","horarios":{"07:00":0,"07:30":0,"08:00":0,"08:30":0,"09:00":0,"09:30":0,"10:00":0,"10:30":0,"11:00":0,"11:30":0,"12:00":0,"12:30":0,"13:00":0,"13:30":0,"14:00":0,"14:30":0,"15:00":0,"15:30":0,"16:00":0,"16:30":0,"17:00":0,"17:30":0,"18:00":0,"18:30":0,"19:00":0,"19:30":0,"20:00":0,"20:30":0,"21:00":0,"21:30":0,"22:00":0,"22:30":0}}}
So in the case if 1 active means that Monday may have scheduled times, here comes the giant list of times, example 07:00 and then the number of people in case 7
I’m having trouble coming up with a simpler logic that works, If anyone has an idea and can help, an opinion on how to do it, I’m very grateful.