Good Friday is ";
//echo $GoodFriday;
$holidays[]=$GoodFriday;
/*
Victoria Day 4th or 3rd Mon if < 24
*/
$VictoriaMonts=ordinalDay(4, 'Mon', 5, $current_year);
$dayFourthMon=strftime("%d",$VictoriaMonts);
//echo $dayFourthMon;
if($dayFourthMon > 24)
{
$VictoriaMonts=ordinalDay(3, 'Mon', 5, $current_year);
}
$VictoriaDay=strftime("%Y-%m-%d" , $VictoriaMonts);
$holidays[]=$VictoriaDay;
$July1=$current_year;
$July1 .= "-07-01";
$holidays[]=$July1;
/*
BC day
*/
$BCDayts=ordinalDay(1, 'Mon', 8, $current_year);
$BCDay=strftime("%Y-%m-%d" , $BCDayts);
$holidays[]=$BCDay;
$LabourDayts=ordinalDay(1, 'Mon', 9, $current_year);
$LabourDay=strftime("%Y-%m-%d" , $LabourDayts);
$holidays[]=$LabourDay;
/*
Thanksgiving
*/
$Thanksgivingts=ordinalDay(2, 'Mon', 10, $current_year);
$Thanksgiving=strftime("%Y-%m-%d" , $Thanksgivingts);
$holidays[]=$Thanksgiving;
/*
Nov 11
*/
$RemembranceDay=$current_year;
$RemembranceDay .= "-11-11";
$holidays[]=$RemembranceDay;
/*
Dec 25 26
*/
$Christmas=$current_year;
$Christmas .= "-12-25";
$holidays[]=$Christmas;
$BoxingDay=$current_year;
$BoxingDay .= "-12-26";
$holidays[]=$BoxingDay;
$current_year++;
}/////end of for loop
return $holidays;
}/////end function get_holidays
function appointment_input($day_of_week, $counter)
{
global $Profession, $Profprovary, $Moncolor, $Tuescolor, $Wedcolor, $Thurscolor, $Fricolor, $Satcolor, $Suncolor;
echo "
";
echo "Location ";
echo "";
$Profp0=$Profprovary[0];
$Profp1=$Profprovary[1];
$Profp2=$Profprovary[2];
echo "" . $Profp0 . " ";
echo "" . $Profp1 . " ";
echo "" . $Profp2 . " ";
echo " ";
echo " ";
echo "";
echo "";
echo "--: ";
echo "AM 8: ";
echo "AM 9: ";
echo "AM10: ";
echo "AM11: ";
echo "PM12: ";
echo "PM1: ";
echo "PM 2: ";
echo "PM 3: ";
echo "PM 4: ";
echo "PM 5: ";
echo "PM 6: ";
echo "PM 7: ";
echo "PM 8: ";
echo " ";
echo "";
echo "00 ";
echo "05 ";
echo "10 ";
echo "15 ";
echo "20 ";
echo "25 ";
echo "30 ";
echo "35 ";
echo "40 ";
echo "45 ";
echo "50 ";
echo "55 ";
echo " ";
echo " ";
echo "";
echo "";
service_list($Profession);
echo " ";
echo " ";
echo " ";
}
function check_dupe_appointments($service_provider21, $day21, $time21)
{
global $dbhost, $apptdb;
$link_id = db_connect();
if(!$link_id) die(sql_error());
$query="SELECT appt_id, client_id, location, bill_to, lastaccess
FROM $apptdb WHERE Agent_id = '$service_provider21' AND day = '$day21' AND
time = '$time21'";
$result_id=mysql_query($query);
if(!mysql_num_rows($result_id)) {return 0;}////return zero if no prob
else {return 1;}////returns one if there is duplicate
}
//////////////////
function many_appts_one_day($start_time, $no_appts)
{
global $apptdb;
//global $Date1, $Date2, $Date3;
$Assmt1=0;
$return_zero=0;
$Date_in_func = $_POST['Date1'] . $_POST['Date2'] . $_POST['Date3'];
for ($counter=0; $counter < $no_appts; $counter++)
{
$time_to_add0=$counter * 10000;
$add_time0 = $start_time + $time_to_add0;
//////check_dupe_appointments($_POST['user_Pro_id2'], $day, $time_to_add0);
if( check_dupe_appointments($_POST['user_Pro_id2'], $Date_in_func, $add_time0)) error_message("Cannot book duplicate appointments.");///isnt working
}
for ($counter=0; $counter < $no_appts; $counter++)
{
$tempuserPro=$_POST['user_Pro_id2'];
$time_to_add=$counter * 10000;
$add_time = $start_time + $time_to_add;
$templocation=$_POST['location_input'];
$query="INSERT INTO $apptdb (appt_id, day, time, Assmt, Agent_id, client_id,
location, lastaccess, bill_to) VALUES (NULL, $Date_in_func, $add_time, $Assmt1, '$tempuserPro', NULL, '$templocation', NULL, NULL)";
mysql_query($query);
$result=mysql_affected_rows();
if(!$result) {$return_zero=1;}
}
if($return_zero) {return 0;}
else {return 1;}
}
/////////////////
function add_appt_form() {
global $PHP_SELF, $Profession, $noApps, $Moncolor, $Tuescolor, $Wedcolor, $Thurscolor, $Fricolor, $Satcolor, $Suncolor;
?>
Set your regular appointments (or add one appointment at a time here )!
Click here to go back to your appointments ";
?>
If there are not enough slots, you can use this page a number of times and set groups of appointments each time (for example, mornings and then afternoons).
";
echo " ";
echo"";
echo "";
echo "Appointment booking method Patent Pending ";
echo " LOGOUT
";
echo "";
//echo "";
echo " ";
echo "
This page will take some time to load ";
echo "
Back to zappointments.com home page ";
echo "
";
if($_POST['action']=="added_appt")
{
$DateFrom=$_POST['DateFrom1'] . "-" . $_POST['DateFrom2'] . "-" . $_POST['DateFrom3'];
$DateTo=$_POST['DateTo1'] . "-" . $_POST['DateTo2'] . "-" . $_POST['DateTo3'];
$start_day=strtotime($DateFrom);
$end_day=strtotime($DateTo);
$start_day_of_week = date( "D", $start_day);
if($start_day_of_week=='Mon'){$day_of_week_no=1;}
if($start_day_of_week=='Tue'){$day_of_week_no=2;}
if($start_day_of_week=='Wed'){$day_of_week_no=3;}
if($start_day_of_week=='Thu'){$day_of_week_no=4;}
if($start_day_of_week=='Fri'){$day_of_week_no=5;}
if($start_day_of_week=='Sat'){$day_of_week_no=6;}
if($start_day_of_week=='Sun'){$day_of_week_no=7;}
$yearone=$_POST['DateFrom1'];
$yearlast=$_POST['DateTo1'];
$holidays=get_holidays($yearone,$yearlast);
$num_of_appts_booked=0;
/*while(list(,$holiday_date)=each($holidays))
{
echo $holiday_date;
echo " ";
}*/
$tempuserPro=$_POST['user_Pro_id2'];
$Date_of_appts=$DateFrom;
$currentday=$start_day;
$dayflag=0;
$link_id = db_connect();
if(!$link_id) die(sql_error());
$Date_of_appts_array=array($Date_of_appts);
$end_day += 82800;
while($currentday <= $end_day)
{
$Date_of_appts_array=array($Date_of_appts);
$intersect_array=array_intersect($holidays, $Date_of_appts_array);
//echo "Intersect array is ";
//echo $intersect_array;
if(count($intersect_array)==0)
{
$Date_of_appts_array=array($Date_of_appts);
//echo "currentday is " . $currentday . " end_day is " . $end_day;
if($day_of_week_no==1){$dayflag=1;}
if(($dayflag==1)&&($day_of_week_no==1))
{
for($counting=0; $counting < $noApps; $counting++)
{
$arrayMontime1=$_POST['Montime1'];
$arrayMontime2=$_POST['Montime2'];
$arrayMonAssmt=$_POST['MonAssmt'];
$arrayMonlocation=$_POST['Monlocation_input'];
if($arrayMontime1[$counting]!='99')
{
$Montime=$arrayMontime1[$counting] . $arrayMontime2[$counting];
$MonAssmt=$arrayMonAssmt[$counting];
if($MonAssmt==14){$allowSameTime2=1;}
else if($MonAssmt==42){$allowSameTime2=1;}
else {$allowSameTime2=0;}
$templocation=$arrayMonlocation[$counting];
if(($allowSameTime==0) && ($allowSameTime2==0))
{
$Monquerypre="SELECT * FROM $apptdb where ((day='$Date_of_appts' && time='$Montime') && Agent_id='$tempuserPro')";
$Monresultpre=mysql_query($Monquerypre);
$Monresultpre1=mysql_num_rows($Monresultpre);
} else {$Monresultpre1=0;}
if($Monresultpre1==0)
{
$Monquery="INSERT INTO $apptdb (appt_id, day, time, Assmt, Agent_id, client_id,
location, lastaccess, bill_to) VALUES (NULL, '$Date_of_appts', '$Montime', '$MonAssmt', '$tempuserPro', NULL, '$templocation', NULL, NULL)";
$nowresult=mysql_query($Monquery);
if(!$nowresult) {echo "Error at ". $Montime . " on " . $Date_of_appts . " ";}
else {$num_of_appts_booked++;}
}else{echo "Already had an appointment at " . $Montime . " on " . $Date_of_appts . " ";}
}
}
}
if($day_of_week_no==2){$dayflag=1;}
if(($dayflag==1)&&($day_of_week_no==2))
{
for($counting=0; $counting < $noApps; $counting++)
{
$arrayTuestime1=$_POST['Tuestime1'];
$arrayTuestime2=$_POST['Tuestime2'];
$arrayTuesAssmt=$_POST['TuesAssmt'];
$arrayTueslocation=$_POST['Tueslocation_input'];
if($arrayTuestime1[$counting]!='99')
{
$Tuestime=$arrayTuestime1[$counting] . $arrayTuestime2[$counting];
$TuesAssmt=$arrayTuesAssmt[$counting];
if($TuesAssmt==14){$allowSameTime2=1;}
else if($TuesAssmt==42){$allowSameTime2=1;}
else {$allowSameTime2=0;}
$templocation=$arrayTueslocation[$counting];
if(($allowSameTime==0) && ($allowSameTime2==0))
{
$Tuesquerypre="SELECT * FROM $apptdb where ((day='$Date_of_appts' && time='$Tuestime') && Agent_id='$tempuserPro')";
$Tuesresultpre=mysql_query($Tuesquerypre);
$Tuesresultpre1=mysql_num_rows($Tuesresultpre);
} else {$Tuesresultpre1=0;}
if($Tuesresultpre1==0)
{
$Tuesquery="INSERT INTO $apptdb (appt_id, day, time, Assmt, Agent_id, client_id,
location, lastaccess, bill_to) VALUES (NULL, '$Date_of_appts', '$Tuestime', '$TuesAssmt', '$tempuserPro', NULL, '$templocation', NULL, NULL)";
$nowresult=mysql_query($Tuesquery);
if(!$nowresult) {echo "Error at ". $Tuestime . " on " . $Date_of_appts . " ";}
else {$num_of_appts_booked++;}
}else{echo "Already had an appointment at " . $Tuestime . " on " . $Date_of_appts . " ";}
}
}
}
if($day_of_week_no==3){$dayflag=1;}
if(($dayflag==1)&&($day_of_week_no==3))
{
for($counting=0; $counting < $noApps; $counting++)
{
$arrayWedtime1=$_POST['Wedtime1'];
$arrayWedtime2=$_POST['Wedtime2'];
$arrayWedAssmt=$_POST['WedAssmt'];
$arrayWedlocation=$_POST['Wedlocation_input'];
if($arrayWedtime1[$counting]!='99')
{
$Wedtime=$arrayWedtime1[$counting] . $arrayWedtime2[$counting];$WedAssmt=$arrayWedAssmt[$counting];
if($WedAssmt==14){$allowSameTime2=1;}
else if($WedAssmt==42){$allowSameTime2=1;}
else {$allowSameTime2=0;}
$templocation=$arrayWedlocation[$counting];
if(($allowSameTime==0) && ($allowSameTime2==0))
{
$Wedquerypre="SELECT * FROM $apptdb where ((day='$Date_of_appts' && time='$Wedtime') && Agent_id='$tempuserPro')";
$Wedresultpre=mysql_query($Wedquerypre);
$Wedresultpre1=mysql_num_rows($Wedresultpre);
} else {$Wedresultpre1=0;}
if($Wedresultpre1==0)
{$Wedquery="INSERT INTO $apptdb (appt_id, day, time, Assmt, Agent_id, client_id,
location, lastaccess, bill_to) VALUES (NULL, '$Date_of_appts', '$Wedtime', '$WedAssmt', '$tempuserPro', NULL, '$templocation', NULL, NULL)";
$nowresult=mysql_query($Wedquery);
if(!$nowresult) {echo "Error at ". $Wedtime . " on " . $Date_of_appts . " ";}
else {$num_of_appts_booked++;}
}else{echo "Already had an appointment at " . $Wedtime . " on " . $Date_of_appts . " ";}
}
}
}
if($day_of_week_no==4){$dayflag=1;}
if(($dayflag==1)&&($day_of_week_no==4))
{
for($counting=0; $counting < $noApps; $counting++)
{
$arrayThutime1=$_POST['Thutime1'];
$arrayThutime2=$_POST['Thutime2'];
$arrayThuAssmt=$_POST['ThuAssmt'];
$arrayThulocation=$_POST['Thulocation_input'];
if($arrayThutime1[$counting]!='99')
{
$Thutime=$arrayThutime1[$counting] . $arrayThutime2[$counting];$ThuAssmt=$arrayThuAssmt[$counting];
if($ThuAssmt==14){$allowSameTime2=1;}
else if($ThuAssmt==42){$allowSameTime2=1;}
else {$allowSameTime2=0;}
$templocation=$arrayThulocation[$counting];
if(($allowSameTime==0) && ($allowSameTime2==0))
{
$Thuquerypre="SELECT * FROM $apptdb where ((day='$Date_of_appts' && time='$Thutime') && Agent_id='$tempuserPro')";
$Thuresultpre=mysql_query($Thuquerypre);
$Thuresultpre1=mysql_num_rows($Thuresultpre);
} else{$Thuresultpre1=0;}
if($Thuresultpre1==0)
{$Thuquery="INSERT INTO $apptdb (appt_id, day, time, Assmt, Agent_id, client_id,
location, lastaccess, bill_to) VALUES (NULL, '$Date_of_appts', '$Thutime', '$ThuAssmt', '$tempuserPro', NULL, '$templocation', NULL, NULL)";
$nowresult=mysql_query($Thuquery);
if(!$nowresult) {echo "Error at ". $Thutime . " on " . $Date_of_appts . " ";}
else {$num_of_appts_booked++;}
}else{echo "Already had an appointment at " . $Thutime . " on " . $Date_of_appts . " ";}
}
}
}
if($day_of_week_no==5){$dayflag=1;}
if(($dayflag==1)&&($day_of_week_no==5))
{
for($counting=0; $counting < $noApps; $counting++)
{
$arrayFritime1=$_POST['Fritime1'];
$arrayFritime2=$_POST['Fritime2'];
$arrayFriAssmt=$_POST['FriAssmt'];
$arrayFrilocation=$_POST['Frilocation_input'];
if($arrayFritime1[$counting]!='99')
{
$Fritime=$arrayFritime1[$counting] . $arrayFritime2[$counting];$FriAssmt=$arrayFriAssmt[$counting];
if($FriAssmt==14){$allowSameTime2=1;}
else if($FriAssmt==42){$allowSameTime2=1;}
else {$allowSameTime2=0;}
$templocation=$arrayFrilocation[$counting];
if(($allowSameTime==0) && ($allowSameTime2==0))
{
$Friquerypre="SELECT * FROM $apptdb where ((day='$Date_of_appts' && time='$Fritime') && Agent_id='$tempuserPro')";
$Friresultpre=mysql_query($Friquerypre);
$Friresultpre1=mysql_num_rows($Friresultpre);
} else {$Friresultpre1=0;}
if($Friresultpre1==0)
{$Friquery="INSERT INTO $apptdb (appt_id, day, time, Assmt, Agent_id, client_id,
location, lastaccess, bill_to) VALUES (NULL, '$Date_of_appts', '$Fritime', '$FriAssmt', '$tempuserPro', NULL, '$templocation', NULL, NULL)";
$nowresult=mysql_query($Friquery);
if(!$nowresult) {echo "Error at ". $Fritime . " on " . $Date_of_appts . " ";}
else {$num_of_appts_booked++;}
}else{echo "Already had an appointment at " . $Fritime . " on " . $Date_of_appts . " ";}
}
}
}
if($day_of_week_no==6){$dayflag=1;}
if(($dayflag==1)&&($day_of_week_no==6))
{
for($counting=0; $counting < $noApps; $counting++)
{
$arraySattime1=$_POST['Sattime1'];
$arraySattime2=$_POST['Sattime2'];
$arraySatAssmt=$_POST['SatAssmt'];
$arraySatlocation=$_POST['Satlocation_input'];
if($arraySattime1[$counting]!='99')
{
$Sattime=$arraySattime1[$counting] . $arraySattime2[$counting];$SatAssmt=$arraySatAssmt[$counting];
if($SatAssmt==14){$allowSameTime2=1;}
else if($SatAssmt==42){$allowSameTime2=1;}
else {$allowSameTime2=0;}
$templocation=$arraySatlocation[$counting];
if(($allowSameTime==0) && ($allowSameTime2==0))
{
$Satquerypre="SELECT * FROM $apptdb where ((day='$Date_of_appts' && time='$Sattime') && Agent_id='$tempuserPro')";
$Satresultpre=mysql_query($Satquerypre);
$Satresultpre1=mysql_num_rows($Satresultpre);
} else {$Satresultpre1=0;}
if($Satresultpre1==0)
{$Satquery="INSERT INTO $apptdb (appt_id, day, time, Assmt, Agent_id, client_id,
location, lastaccess, bill_to) VALUES (NULL, '$Date_of_appts', '$Sattime', '$SatAssmt', '$tempuserPro', NULL, '$templocation', NULL, NULL)";
$nowresult=mysql_query($Satquery);
if(!$nowresult) {echo "Error at ". $Sattime . " on " . $Date_of_appts . " ";}
else {$num_of_appts_booked++;}
}else{echo "Already had an appointment at " . $Sattime . " on " . $Date_of_appts . " ";}
}
}
}
if($day_of_week_no==7){$dayflag=1;}
if(($dayflag==1)&&($day_of_week_no==7))
{
for($counting=0; $counting < $noApps; $counting++)
{
$arraySuntime1=$_POST['Suntime1'];
$arraySuntime2=$_POST['Suntime2'];
$arraySunAssmt=$_POST['SunAssmt'];
$arraySunlocation=$_POST['Sunlocation_input'];
if($arraySuntime1[$counting]!='99')
{
$Suntime=$arraySuntime1[$counting] . $arraySuntime2[$counting];$SunAssmt=$arraySunAssmt[$counting];
if($SunAssmt==14){$allowSameTime2=1;}
else if($SunAssmt==42){$allowSameTime2=1;}
else {$allowSameTime2=0;}
$templocation=$arraySunlocation[$counting];
if(($allowSameTime==0) && ($allowSameTime2==0))
{
$Sunquerypre="SELECT * FROM $apptdb where ((day='$Date_of_appts' && time='$Suntime') && Agent_id='$tempuserPro')";
$Sunresultpre=mysql_query($Sunquerypre);
$Sunresultpre1=mysql_num_rows($Sunresultpre);
} else {$Sunresultpre1=0;}
if($Sunresultpre1==0)
{$Sunquery="INSERT INTO $apptdb (appt_id, day, time, Assmt, Agent_id, client_id,
location, lastaccess, bill_to) VALUES (NULL, '$Date_of_appts', '$Suntime', '$SunAssmt', '$tempuserPro', NULL, '$templocation', NULL, NULL)";
$nowresult=mysql_query($Sunquery);
if(!$nowresult) {echo "Error at ". $Suntime . " on " . $Date_of_appts . " ";}
else {$num_of_appts_booked++;}
}else{echo "Already had an appointment at " . $Suntime . " on " . $Date_of_appts . " ";}
}
}
}//////end of if
}///////end of big if
else{
echo " Skipped holiday on " . $Date_of_appts;
}
$currentday=strtotime($Date_of_appts);
$dalightbefore = date('I', $currentday);
$currentday += 86400; ////this is one day
$dalightafter = date('I', $currentday);
if($dalightbefore - $dalightafter == 1) {$currentday += 3600;}
if($dalightbefore - $dalightafter == -1) {$currentday -=3600;}
$Date_of_appts = strftime("%Y-%m-%d", $currentday);
if($day_of_week_no < 7){$day_of_week_no++;}
else{$day_of_week_no=1;}
//echo "day of week number is " . $day_of_week_no;
}///////end of while
echo "";echo $num_of_appts_booked . " empty appointment(s) set! Use back button to set more! ";
//$result1=enter_new_appt();
}
else {
add_appt_form();
}
}///end of else
echo "Appointment booking method Patent Pending
";
echo "
zappointments.com: online booking for health professionals
";
echo "";
?>