PHP MySql calendar

I want to make a calendar that allows people to schedule appointments. This is for a friend that owns a dog wash. He wants no more then 4 appointment per day, two from 9am-Noon and two 1pm-4:30pm. I dont have anything going yet on this project, the whole thing is intimidating at the moment. If someone can point me in the right direction Id appreciate it.

This is what I’m thinking the table would consist of

id
customer
email
phone
member
dogsName
appointmentdate (am/pm)
confirmed
timestamp

I can make the form, sanitize and add to table. I have never made a calendar before. Ive googled it and have found a few things but not sure they would work for what i want to do.

So, the dog-owner visits the site and can see the free and booked slots over the next month then sends and email requesting a slot – is that how it will work?

ie only the site owner can actually book the slots?

Yes the dog-owner books the slot. After a slot is booked it will be a pending slot only after a call or email confirmation is done by an employee will it be a confirmed booking. When its pending i want the calendar to Show that someone has requested the slot but bas not been confirmed yet. I’m pretty sure I can get all that to work on my own. I will also make a admin booking page so people can call and book a time. I not sure how to go about the calendar part like it showing “1 morning slot available”. He also want the ability to block days Saturday Sunday and any other day for like a personal day off.

So is it the case that “dog-owner A” selects an empty slot, this causes an and email to be sent and shows that slot is now “pending”?

Yes, an email is sent to the dog owner wanting them to confirm the booking. He also wants to be able to confirm the slot with a phone call from an employee. If the slot is not confirmed in lets say two days he wants the slot to become available again.

As far as times go is it to be one of early am, late am, early pm, late pm for each day - or are you envisaging absolute times?

If it is absolute times then how is that going to work?

What if you get a booking for 10.00 and 11.00 - you have no idea of how long the job is going to take do you?

The times will just be am and pm. The owner will have to drop off the dog for an am appointment between like 9:00-9:15 and a pm appointment between 12:45-1:00. Two people will be working at most times so both dogs can be dropped off at the same time. However if someone needs a day off he wants the day to be limited to one slot in the am and one in the pm.

How about this idea:


table bookings (starts off empty, but filled up with blanks)
===========
date | am1 | am2 | pm1 pm 2 
----------------------------
2010-02-14 | null | null | null | null

Denzel Washington books a morning slot, he is client number 77.


table clients
==========
id | name | etc
----------------
77 | Denzel Washington | etc

Booking table becomes:


2010-02-14 | 77p | null | null | null 

Your man decides its not spoof and books him in


2010-02-14 | 77 | null | null | null 

GUI shows:

2010-02-14 | am : Only 1 place remaining | pm: Free for 2 bookings, book now!

Matt Damon books a morning slot, he is client number 78.


table clients
===========
id | name | etc
--------------
77 | Denzel Washington | etc
78 | Matt Damon | etc

Booking table becomes:


2010-02-14 | 77 | 78p | null | null 

GUI shows:

2010-02-14 | am : Only 1 place remaining which is only provisionally booked, you could try again later | pm: Free for 2 bookings, book now!

Your man decides its not spoof and books him in


2010-02-14 | 77 | 78 | null | null 

GUI shows:

2010-02-14 | am : Sorry all booked up for this morning | pm: Free for 2 bookings, book now!

Create special user #1 in your clients table


table clients
===========
id | name | etc
--------------
1 | Staff holidays
77 | Denzel Washington | etc
78 | Matt Damon | etc

When Jeff, the 2nd worker is on hols for 3 days do this beforehand:


2010-07-13 | 1 | null | 1 | null
2010-07-14 | 1 | null | 1 | null
2010-07-15 | 1 | null | 1 | null 

If you need help working out how PHP would format that then ask.

Would that work? Anyone else got any ideas?

that seems like it would work pretty well. If you don’t mind either showing me a quick calendar method or link to on you think would work for this, Id appreciate it. After I get the calendar part of it going. Is the booking table going to get the date only after some one clicks on the calendar date and books a slot? Or are the dates going to have to be entered before hand so it can show what is available?

In the booking table I will add a column to see if they are a member or not if the client is logged as an approved member, the slot will automatically be confirmed. Dose that seem like the way to go about that?

Whether the bookee is a client or not is not a concern of the booking table.

If your user is recognised and brings back their record (and their id) is another matter - for sure there are lots of benefits in recognising past paying customers, but do not concern yourself with that for now – and do not let that you get sidelined from the main issue.

Two things:

You would have to populate the table by creating all the empty rows for say, a year.

The calendar code can be very simple because your application is very simple.

Show next 7 days, show next 28 days

These can be sql driven options driven by GET arguments.

calendar.php?cal=7
calendar.php?cal=28

Which create sql statements such as:


SELECT `date`, am1, am2, pm1, pm2 
FROM bookings 
WHERE `date` > NOW() 
AND `date` < DATE_ADD(NOW(), INTERVAL 7 DAY)

That should get you going.

When you have something really basic working then start figuring out tricky calendars and stuff.