Jump to content

appointment system - how to store my working time?


gunter
 Share

Recommended Posts

I want program an appointment system...
I am thinking about how I can do this.

At first, how would be the most elegant way to store the data from the picture?
these are 15 minutes slots for the general working hours for each day (of the week and for special days)

 

screenshot.JPG

Link to comment
Share on other sites

How about using bits? You have 24 × 4 = 96 slots, the state of these can be stored in an 2^96 integer in theory. Since PHP does not support such a large integer you might want to break it up into two: 2^48 + 2^48 (a.m. + p.m.)

You can get an idea of how to check bits and/or turn them on/off by googling a bit: https://www.google.hu/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=php+bit+flag+check

The drawback of this simple storage method is that if you need to adjust the timeframes in the future (say your client wants every 10 minutes instead), you will need to implement a conversion algorithm to change all the already stored values. But if things does not change at all, or highly unlikely to change in the future, then it is simple and efficient way of storing data.

Link to comment
Share on other sites

Interesting solution! ;-) A possible way then would be to see this xy array as image and use pixel manipulation functions :-)
bool
imagesetpixel ( resource $image , int $x , int $y , int $color )
But I´m not sure if this ist the best solution... to use different "time systems" because,
I have my google calendar events, that block my availibility.
I have already booked events, that block my availibilitiy, too...
Then I can offer the visitors timeslots that they can book...

 

  • Like 1
Link to comment
Share on other sites

In something similar, I stored this in a sort of "availability" custom database table. It was quite simple though, with two columns:

day_of_week (int)
time (time)

The UI wasn't quite like yours - it was day of week, and then add multiple time ranges (e.g. 9am-12pm and another could be 2pm-5pm). The end result was the same as what you are wanting to achieve though.

You could add an ID and/or date field as well depending on how you set up your schedule too.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...