Page 1 of 1
appointment booking system
Posted: Tue Aug 30, 2005 11:18 am
by gurjit
Hi,
has anyone ever written an appointment booking system.
where you select a date from a calendar and 1 hour time slots for available times are shown. The user picks the time that they want.
I will have a client list of people who have there opening days and times. The calendar will show the times and days as recorded in the database for availability. Users will login and book appointments.
Has anyone done this before?
I have not started this yet but am planning, any help will be appreciated.
Posted: Tue Aug 30, 2005 1:30 pm
by Burrito
I have done exactly that.
I set it up so that the people who are looking to schedule an appointment can schedule within half hour intervals. They simply click the table cell with the available time and they are redirected to a page confirming their appointment request. If they are not logged in however, they are required to log in at which point they are taken right back to the confirmation page. If they confirm, they are taken back to the calendar with that slot now "full".
My system was for a dentist's office that was offsite from their web site so it had to email them the appointment request which they had to then manually enter to their scheduling system.
It'd be easy enough though (if it's all in one location) to just block out the time on their database.... I wish I could revisit that and do it properly for them.
but yes, I've done exactly what you're trying to do and would be more than happy to shed any light I can in helping you devlop it.
Posted: Tue Aug 30, 2005 5:10 pm
by raghavan20
I think Burrito's idea should be the simplest of all.
You have a table for a day with a td having a half an hour slots.
You just have retrieve the timings when a client is available and make that half an hour slot as an hyperlink
on click of the hyperlink you proceed to confirm appointment.
you should have next and prev pointer above the table to move dates, the next and previous days resp.
or
you should check an availability for the user input.
that would having a select control for week days or dates
another select control for every one/half- an hour slots.
you have to use these two values to query the db and echo for availability.
I am wondering how the database tables should be:
clients:(simplified)
clientId
clientName
...
clientAvailability:
clientId
Date
HourSlot
Code: Select all
select `clientName`, `Date`, `HourSlot`
from `clients`, `clientAvailability` where
`clients`.`clientId` = `clientAvailability`.`clientId` and
`Date` = '$date' and `HourSlot`='$hourSlot'
Posted: Wed Aug 31, 2005 6:50 am
by gurjit
Hi Burrito,
I will have a calendar for each different client because they will not be based at the same buliding.
I have lets say 10 different doctors - who are located at different buildings and they open at different times and days, so i will need to record there opening days and times including any bank holidays and christmas or annual leave they may take, which means those dates are unavailable on the calendar. Each client will need there own calendar.
How do you think I should lay my tables out to take care of this type of scenario?
Posted: Wed Aug 31, 2005 7:30 am
by raghavan20
I dont think having too many calendars is a good idea. keeping things simpler is the best interface.
You can have a single calendar and have links for those where atleast one doctor is available.
When an user clicks on it, list the doctors who are available for that particular time and let the user choose the doctor to his/her discretion.
Posted: Wed Aug 31, 2005 8:08 am
by gurjit
Soon there may be like 300 doctors and that will be annoying to the user to pick from a drop down.
May be the user clicks the doctors name and points into a single calendar and I use a query to see the doctors schedule. That way I can use one calendar with many doctor dates.
How the table layout will be is going to be difficult..... ANY IDEAS
Posted: Wed Aug 31, 2005 8:12 am
by raghavan20
so do you say that the user knows the name of the doctor he/she wants from the 300 doctors???
if no,
you search availability of doctors for a particular date and paginate or let them search for their doctor from the result(set of doctors available on a particular date)
Posted: Wed Aug 31, 2005 8:23 am
by gurjit
he user will look at the doctors list for what they specialise in and depending on the persons problem they will pick the suitable doctor. Each doctor will write something about themselves, its up to the user which doctor to pick.
So how do i lay the table out so that each doctor has there:
available dates and holidays on the database
opening times
a patient can login and pick the date and time desirable for a particular doctor
Posted: Wed Aug 31, 2005 9:13 am
by raghavan20
i think may be you can have two searches
1. by doctor
2. by date
if by doctor,
allow them to search by line of practise, ortho, psychiatry...
allow them to search by last name
display results
when they click view more information on the doctor
you have a separate page where you display about the doctor and a calendar to list his available appointments and the user can click the calendar item to book the appointment.
if by date,
you display the current date with every time slot and the highlight the ones where atleast one doctor is available.
on click, display all the available doctors.
let the user see more information about the doctor and provide link to book appointment as well.
you should have next and previous to see availability for other dates.
Posted: Wed Aug 31, 2005 9:16 am
by gurjit
That sounds like exactly what I had in mind.
Trouble is table layouts and getting a calendar running. Any ideas on how I can get help???
Posted: Wed Aug 31, 2005 1:45 pm
by raghavan20
this is a calendar class i wrote.
you have to give a year and month in numbers as input and it displays the calendar.
you have to customize this to your needs.
in the renderCalendar function, you can run your query to get dates of availability for a doctor and make those dates as hyperlinks and leaving others intact.
you can see this working at
http://raghavan20.allhyper.com/Calendar.class.php
Code: Select all
<style type="text/css">
<!--
span {
height:10px;
width:40px;
float:left;
margin:1px;
text-align:center;
background-color:#333333;
color:#FFFFFF;
font-size:.8em;
font-weight:900;
line-height:1.2em;
border:1px solid #996666;
}
.mainDiv{
border:2px solid #000000;
padding:2px;
width:300px;
background-color:#CCCCCC;
}
.calendarTitle{
width:300px;
text-align:center;
font-weight:bold;
}
-->
</style>
<?php
class Calendar{
var $month;
var $year;
var $day;
var $date;
function Calendar($year, $month){
$this->year = $year;
$this->month = $month;
}
function renderCalendar(){
$weekDay = $this->getWeekDay(1, $this->month, $this->year);//get the first weekday of the month
$daysOfMonth = $this->findDaysOfMonth(1, $this->month,$this->year); //get number of days in a year
?>
<div class="calendarTitle">
<?php echo strtoupper($this->findMonth(1, $this->month, $this->year));?>
<?php echo $this->year; ?>
</div>
<div class = "mainDiv">
<div><span>SUN</span><span>MON</span><span>TUE</span><span>WED</span>
<span>THU</span><span>FRI</span><span>SAT</span></div>
<div>
<?php
//display blanks spans
for ($i = 1; $i <= $weekDay; $i++){
echo "<span></span>";
}
$counter = $weekDay;//set the counter
//display all days of the month;
for ($i = 1; $i <= $daysOfMonth; $i++){
echo "<span>$i</span>";
$counter++;
if ($counter%7 == 0){
echo "<br />";
}
}
?>
</div></div>
<?php
}
function getWeekDay($day, $month, $year){
$timestamp = mktime(0, 0, 0, $month, $day, $year);
$date = getdate($timestamp);
return $date["wday"];
}
function findDaysOfMonth($day=1, $month, $year){
$timestamp = mktime(0, 0, 0, $month, $day, $year);
return date("t", $timestamp);
}
function findMonth($day=1, $month, $year){
$timestamp = mktime(0, 0, 0, $month, $day, $year);
return date("F", $timestamp);
}
function __destructor(){
}
}
?>
<?php
$calendar = new Calendar(2006, 11);
echo $calendar->renderCalendar();
?>
Posted: Wed Aug 31, 2005 2:25 pm
by raghavan20
alright, i have digged down deep into your situation itself
this is a class for which you have to pass a query that would return date as the first or only field in the result
ex:
I have a sample Dates_tbl
field: date
values or records:
1
2
3
15
28
The query you pass would be executed and a date array would be returned which contains the dates only
say $tempArray holds {1,2,3,15,28}
I display these dates with a hyperlink; in the example below i have given an alert stmt with the current value which you can change to the link you like.
Remember to give you hostname, username and password in executeQuery function
you can see how it works at
http://raghavan20.allhyper.com/Calendar1.class.php
Code: Select all
<style type="text/css">
<!--
span {
height:10px;
width:40px;
float:left;
margin:1px;
text-align:center;
background-color:#333333;
color:#FFFFFF;
font-size:.8em;
font-weight:900;
line-height:1.2em;
border:1px solid #996666;
}
.mainDiv{
border:2px solid #000000;
padding:2px;
width:300px;
background-color:#CCCCCC;
}
.calendarTitle{
width:300px;
text-align:center;
font-weight:bold;
}
.links{
color:white;
text-decoration:underline;
}
-->
</style>
<?php
class Calendar{
var $month;
var $year;
var $day;
var $date;
function Calendar($year, $month){
$this->year = $year;
$this->month = $month;
}
function renderCalendar($query="", $redirectLink=""){
$result = $this->executeQuery($query);
if ($result){
$tempArray = $this->getDatesArray($result);
}
//print_r($tempArray);
$weekDay = $this->getWeekDay(1, $this->month, $this->year);//get the first weekday of the month
$daysOfMonth = $this->findDaysOfMonth(1, $this->month,$this->year); //get number of days in a year
?>
<div class="calendarTitle">
<?php echo strtoupper($this->findMonth(1, $this->month, $this->year));?>
<?php echo $this->year; ?>
</div>
<div class = "mainDiv">
<div><span>SUN</span><span>MON</span><span>TUE</span><span>WED</span>
<span>THU</span><span>FRI</span><span>SAT</span></div>
<div>
<?php
//display blank spans
for ($i = 1; $i <= $weekDay; $i++){
echo "<span></span>";
}
$counter = $weekDay;//set the counter
//display all days of the month;
for ($i = 1; $i <= $daysOfMonth; $i++){
if (in_array($i, $tempArray)){//$tempArray holds all the dates
echo "<span><a href='$redirectLink{$i}' onclick='alert($i);' class='links'>$i</a></span>";
}else{
echo "<span>$i</span>";
}
$counter++;
if ($counter%7 == 0){
echo "<br />";
}
}
?>
</div></div>
<?php
}
function getWeekDay($day, $month, $year){
$timestamp = mktime(0, 0, 0, $month, $day, $year);
$date = getdate($timestamp);
return $date["wday"];
}
function findDaysOfMonth($day=1, $month, $year){
$timestamp = mktime(0, 0, 0, $month, $day, $year);
return date("t", $timestamp);
}
function findMonth($day=1, $month, $year){
$timestamp = mktime(0, 0, 0, $month, $day, $year);
return date("F", $timestamp);
}
function executeQuery($query){
@mysql_connect("hostname", "username", "password");//you have to provide you db connection values here
@mysql_select_db("yourdatabase");//your database name
$result = mysql_query($query);
if (is_resource($result)){
return $result;
}else{
return FALSE;
}
}
function getDatesArray($result){
if (is_resource($result)){
$tempArray = array();
while($row = mysql_fetch_row($result)){
array_push($tempArray, $row[0]); //$row[0] assumed to be an individual date
}
}
if (is_array($tempArray) && !empty($tempArray)){
return $tempArray;
}else{
return FALSE;
}
}
function __destructor(){
}
}
?>
<?php
$calendar = new Calendar(2006, 11);
echo $calendar->renderCalendar("select * from Dates_tbl", "Calendar1.class.php?action=nothing&id=");
?>
Posted: Mon Sep 05, 2005 3:07 am
by gurjit
Thanks raghavan20 - I will give this a shot and if i have any problems get back to you. Your a star......