=$DepartDate){ $Dates='Wrong'; include('IndStuBookAdd.php'); exit; }else{ $Dates='OK'; } include('datediff.inc'); $AD=explode("-",$ArrivalDate); $AD2=mktime(0,0,0,$AD[1],$AD[2],$AD[0]); $DD=explode("-",$DepartDate); $DD2=mktime(0,0,0,$DD[1],$DD[2],$DD[0]); $temptime = DateDiff ("d" ,$AD2,$DD2); $DurationID= DateDiff ("w" ,$AD2,$DD2); if ($temptime<14){ $TimeD='Wrong'; $righttime=14-$temptime; include('IndStuBookAdd.php'); exit; }else{ $TimeD='OK'; } $Today=strftime ("%Y-%m-%d" ,time()); include('DateAdd.inc'); $GEDate=$GEYear."-".$GEMonth."-".$GEDay; $GEDate1=$GEYear."-".$GEMonth."-".$GEDay; $GED1=explode("-",$GEDate1); $GED2=mktime(0,0,0,$GED1[1],$GED1[2],$GED1[0]); $GEDepartDate2 = DateAdd ("ww" ,$GEDurationID,$GED2); $GEDepartDate=strftime ("%Y-%m-%d" ,$GEDepartDate2); if ($GEDate<$ArrivalDate){ $CourseTime='Wrong'; include('IndStuBookAdd.php'); exit; }else{ $CourseTime='OK'; } if ($GEDate>$DepartDate){ $CourseTime='Wrong'; include('IndStuBookAdd.php'); exit; }else{ $CourseTime='OK'; } if ($GEDepartDate<$ArrivalDate){ $CourseTime='Wrong'; include('IndStuBookAdd.php'); exit; }else{ $CourseTime='OK'; } if ($GEDepartDate>$DepartDate){ $CourseTime='Wrong'; include('IndStuBookAdd.php'); exit; }else{ $CourseTime='OK'; } $StartDate=$SCYear."-".$SCMonth."-".$SCDay; $StartDate1=$SCYear."-".$SCMonth."-".$SCDay; $SD1=explode("-",$StartDate1); $SD2=mktime(0,0,0,$SD1[1],$SD1[2],$SD1[0]); $SDepartDate2 = DateAdd ("ww" ,$SDurationID,$SD2); $SDepartDate=strftime ("%Y-%m-%d" ,$SDepartDate2); if ($StartDate<$ArrivalDate){ $CourseTime='Wrong'; include('IndStuBookAdd.php'); exit; }else{ $CourseTime='OK'; } if ($StartDate>$DepartDate){ $CourseTime='Wrong'; include('IndStuBookAdd.php'); exit; }else{ $CourseTime='OK'; } if ($SDepartDate<$ArrivalDate){ $CourseTime='Wrong'; include('IndStuBookAdd.php'); exit; }else{ $CourseTime='OK'; } if ($SDepartDate>$DepartDate){ $CourseTime='Wrong'; include('IndStuBookAdd.php'); exit; }else{ $CourseTime='OK'; } include('config.php'); $connection = mysql_connect($server, $user, $pass); //check general english course avail //get num there already during time do{ $query2="Select Booking from CourseAvailability where CourseCode='GE' and Date='$GEDate1'"; $result2 = mysql_db_query($db,$query2 ,$connection); $num = mysql_num_rows($result2); if ( $num != 0 ) { while ($r = mysql_fetch_array($result2)) { $TotBook= $r["Booking"]; } $query = "select Count(ID) from Teacher"; $result = mysql_db_query($db,$query ,$connection); while ($r = mysql_fetch_array($result)) { $NumTeacher= $r["Count(ID)"]; } $query="select MaxStudents from Course where Code='GE'"; $result = mysql_db_query($db,$query ,$connection); while ($r = mysql_fetch_array($result)) { $MaxStu= $r["MaxStudents"]; } $TotStuAccomodable=$MaxStu * $NumTeacher; if ($TotBook<$TotStuAccomodable){ //space avail $NoSpace='False'; $TotBook=$TotBook+1; $query8="Update CourseAvailability set Booking='$TotBook' where Date='$GEDate1' and CourseCode='GE'"; $result8 = mysql_db_query($db,$query8 ,$connection); }else{ $NoSpace='True'; do{ $AD=explode("-",$GEDate1); $AD2=mktime(0,0,0,$AD[1],$AD[2],$AD[0]); $ArrivalDate2 = DateAdd ("d" ,-1,$AD2); $GEDate1=strftime ("%Y-%m-%d" ,$ArrivalDate2); $query2="Select Booking from CourseAvailability where CourseCode='GE' and Date='$GEDate1'"; $result2 = mysql_db_query($db,$query2 ,$connection); while ($r = mysql_fetch_array($result2)) { $TotBook= $r["Booking"]; } $TotBook=$TotBook-1; $query8="Update CourseAvailability set Booking='$TotBook' where Date='$GEDate1' and CourseCode='GE'"; $result8 = mysql_db_query($db,$query8 ,$connection); }while($GEDate1>$GEDate); include('IndStuBookAdd.php'); exit; } }else{ $query2="Insert into CourseAvailability values('GE','$GEDate1',1)"; $result3 = mysql_db_query($db,$query2 ,$connection); $TotBook=0 ; } $AD=explode("-",$GEDate1); $AD2=mktime(0,0,0,$AD[1],$AD[2],$AD[0]); $ArrivalDate2 = DateAdd ("d" ,1,$AD2); $GEDate1=strftime ("%Y-%m-%d" ,$ArrivalDate2); }while($GEDate1<=$GEDepartDate); $query = "SELECT MAX(ID) FROM Booking"; $result = mysql_db_query($db,$query ,$connection); while ($r= mysql_fetch_array($result)) { $BookingID= $r["MAX(ID)"]; } $BookingID=$BookingID + 1; $query = "SELECT MAX(AccountID) FROM Student"; $result = mysql_db_query($db,$query ,$connection); while ($r= mysql_fetch_array($result)) { $StuAccID= $r["MAX(AccountID)"]; } $StuAccID=$StuAccID + 1; $DOB=$Year."-".$Month."-".$Day; $StartDate=$SCYear."-".$SCMonth."-".$SCDay; $ArrivalTime = $Ahh . ":" . $Amm . ":00"; $DepartTime = $Dhh . ":" . $Dmm . ":00"; $query = "insert into Booking values ('$BookingID',4,'$Today')"; $result = mysql_db_query($db,$query ,$connection); $query = "insert into IndividualBooking values ('$BookingID',null,'$ArrivalDate','$ArrivalTime','$FlightNum','$Transfer','$DurationID','$Note','$StudentID','$TransferD','$DepartDate','$DepartTime','$FlightNumD',NULL,null,null,'$ArrivalAP','$DepartAP')"; $result = mysql_db_query($db,$query ,$connection); $q = "insert into Student values ('$LastName','$FirstName','$Address1','$Address2','$City','$Province','$Country','$PostCode','$Nationality','$Telephone','$Fax','$Cell','$Email','1','$Gender','$Diet','$Smoker','$Allergy','$LLevel','2','$StudentID',null,'$Title','$DOB','$COB','$StuAccID')"; $r = mysql_db_query($db,$q ,$connection); $query2="Insert into IndividualCourseBooking values('$BookingID','$StudentID', 'GE','$GEDate','$GEDepartDate',null,'$GEDurationID')"; $result2 = mysql_db_query($db,$query2 ,$connection); if ($CourseCode !="None"){ echo "$CourseCode"; $StartDate=$SCYear."-".$SCMonth."-".$SCDay; $StartDate1=$SCYear."-".$SCMonth."-".$SCDay; $SD1=explode("-",$StartDate1); $SD2=mktime(0,0,0,$SD1[1],$SD1[2],$SD1[0]); $SDepartDate2 = DateAdd ("ww" ,$SDurationID,$SD2); $SDepartDate=strftime ("%Y-%m-%d" ,$SDepartDate2); //get num there already during time do{ $query2="Select Booking from CourseAvailability where CourseCode='$CourseCode' and Date='$StartDate1'"; $result2 = mysql_db_query($db,$query2 ,$connection); $num = mysql_num_rows($result2); if ( $num != 0 ) { while ($r = mysql_fetch_array($result2)) { $TotSBook= $r["Booking"]; echo "

$TotSBook"; } $query = "select Count(ID) from Teacher"; $result = mysql_db_query($db,$query ,$connection); while ($r = mysql_fetch_array($result)) { $NumTeacher= $r["Count(ID)"]; } $query="select MaxStudents from Course where Code='$CourseCode'"; $result = mysql_db_query($db,$query ,$connection); while ($r = mysql_fetch_array($result)) { $MaxSStu= $r["MaxStudents"]; } $TotSStuAccomodable=$MaxSStu * $NumTeacher; if ($TotSBook<$TotSStuAccomodable){ //space avail $NoSSpace="False"; $TotSBook=$TotSBook+1; $query8="Update CourseAvailability set Booking='$TotSBook' where Date='$StartDate1' and CourseCode='$CourseCode'"; $result8 = mysql_db_query($db,$query8 ,$connection); }else{ $NoSSpace="True"; do{ $SAD=explode("-",$StartDate1); $SAD2=mktime(0,0,0,$SAD[1],$SAD[2],$SAD[0]); $SArrivalDate2 = DateAdd ("d" ,-1,$SAD2); $StartDate1=strftime ("%Y-%m-%d" ,$SArrivalDate2); $query2="Select Booking from CourseAvailability where CourseCode='$CourseCode' and Date='$StartDate1'"; $result2 = mysql_db_query($db,$query2 ,$connection); while ($r = mysql_fetch_array($result2)) { $TotSBook= $r["Booking"]; } $TotSBook=$TotSBook-1; $query8="Update CourseAvailability set Booking='$TotSBook' where Date='$StartDate1' and CourseCode='$CourseCode'"; $result8 = mysql_db_query($db,$query8 ,$connection); }while($StartDate1>$StartDate); include('AccomChoice.php'); exit; } }else{ $query2="Insert into CourseAvailability values('$CourseCode','$StartDate1',1)"; $result3 = mysql_db_query($db,$query2 ,$connection); $TotSBook=0 ; } $SAD=explode("-",$StartDate1); $SAD2=mktime(0,0,0,$SAD[1],$SAD[2],$SAD[0]); $SArrivalDate2 = DateAdd ("d" ,1,$SAD2); $StartDate1=strftime ("%Y-%m-%d" ,$SArrivalDate2); }while($StartDate1<=$SDepartDate); $query9="Select Rate from Course where Code='$CourseCode'"; $result9 = mysql_db_query($db,$query9 ,$connection); while ($r9= mysql_fetch_array($result9)) { $Rate= $r9["Rate"]; } $query2="Insert into IndividualCourseBooking values('$BookingID','$StudentID', '$CourseCode','$StartDate','$SDepartDate','$Rate','$SDurationID')"; $result2 = mysql_db_query($db,$query2 ,$connection); } include('AccomChoice.php'); ?>