Prices shown do not include ferries but we can arrange substantial discounts on Wightlink Ferries.
";
//// CHECK IT'S NOT IN THE PAST
$todayday = $day;
$todaymonth = date("M",mktime(0, 0, 0, $month, $day, $year));
$todaymonthn = $month;
$todayyear = $year;
$thisyear = date("Y");
$chosen_start_day = date("U",mktime(23, 59, 59, $todaymonthn, $day, $year)); // seconds since epoch
$nowU = date("U");
// PUT TODAY'S DATE IF IT IS IN THE PAST
IF ($nowU>$chosen_start_day) {
echo "
The date you chose is in the past. Have selected next Friday as an alternative.
Available accommodation starting around ".date("l, jS F Y", mktime(0, 0, 0, $month, $day, $year))." for $nights $shownights with room for $partysize.
";
////////////////is it divisible by 7
if ( ($nights / 7) - (intval($nights/7)) != 0 )
{
$noSC = "";
/////////////////CHECK SHORT BREAKS ARE AVAILABLE
$sb = "no";
$query = "SELECT * from `shortbreaks_dates` ";
$result = mysqli_query( $link, $query );
$rows=mysqli_num_rows($result);
while ($row = mysqli_fetch_array($result))
{
foreach($row as $var => $value) { $$var = $value; }
$start = date("U",mktime(0, 0, 0, $sb_month, $sb_day, $sb_year));
$finish = date("U",mktime(0, 0, 0, $sb_month_end, $sb_day_end, $sb_year_end));
IF (($chosen_start_day>=$start)&& ($chosen_start_day<=$finish)) { $sb = "yes";
}
}
echo "
The bed and breakfast accommodation can be let for any period.
";
IF ($sb=="yes") {
// `numbernights`='$nights'
/////////////SHORT BREAK PERCENTAGE PER DAY
$query = "SELECT `percentage` from `shortbreaks` WHERE `numbernights`='3'
AND `percentage` !='' " ;
$result = mysqli_query( $link, $query );
$rows3=mysqli_num_rows($result);
$c=0;
while ($row = mysqli_fetch_array($result))
{
foreach($row as $var => $value) { $$var = $value; }
}
IF ( $rows3>0) {
echo "
Short breaks for self catering are available at $percentage% of weekly rate for 3 or 4 nights.
Self catering changeover days are Mondays (4 nights) and Fridays (3 nights) only.
";
$noSC = "false";
}
ELSE { echo "
Self catering short breaks are not available at this date. You are very welcome to book for the whole week if there is availability.
Alternatively get in contact with us and we will see if we can accommodate you.
";
$noSC = "true";
}
}
} // divisible by 7
echo "
";
///GET FIRST ID NUMBER OF CALENDAR TABLE
/// short break just get first day
IF (empty($sb)) { $sb = "no"; }
IF ($sb=="yes") {
$query = " SELECT `day_id` FROM `calendar` WHERE `day` = '$day' AND `month` = '$todaymonth' AND `year` = '$year'"; // echo $query;
$startd = $day;
$startm = $todaymonth;
$startn = $todaymonthn;
$starty = $year;
$startd1 = $day;
$startm1 = $todaymonth;
$startn1 = $todaymonthn;
$starty1 = $year;
///// short breaks tues and fri
// already a Friday
IF (date("l", mktime(0, 0, 0, $todaymonthn, $day, $year))=="Friday") {
$SBstartd = $day;
$SBstartm = $todaymonth;
$SBstartn = $todaymonthn;
$SBstarty = $year;
$SBnights = 3;
//echo "sat $SBstartd- $SBstartm- $SBstarty";
}
ELSEIF (date("l", mktime(0, 0, 0, $todaymonthn, $day, $year))=="Monday") {
$date = "$year-$todaymonthn-$day";
$d = new DateTime( $date );
$d->modify( 'next Monday' );
$SBstartd= $d->format( 'j' );
$SBstartm= $d->format( 'M' );
$SBstartn= $d->format( 'n' );
$SBstarty= $d->format( 'Y' );
$SBnights = 4;
//echo "sun $SBstartd- $SBstartm- $SBstarty";
}
ELSE {
// not a Friday - get next one
$date = "$year-$todaymonthn-$day";
$d = new DateTime( $date );
$d->modify( 'next Friday' );
$SBstartd= $d->format( 'j' );
$SBstartm= $d->format( 'M' );
$SBstartn= $d->format( 'n' );
$SBstarty= $d->format( 'Y' );
$SBnights = 3;
//echo "$SBstartd- $SBstartm- $SBstarty";
}
$querySB = " SELECT `day_id` FROM `calendar` WHERE `day` = '$SBstartd' AND `month` = '$SBstartm' AND `year` = '$SBstarty'";
$result = mysqli_query( $link, $querySB );
while ($row = mysqli_fetch_array($result))
{
$SBstart_day_id = $row['day_id'];
}
} ELSE {
// next Friday/////////////
// already a Friday
IF (date("l", mktime(0, 0, 0, $todaymonthn, $day, $year))=="Friday") {
$startd = $day;
$startm = $todaymonth;
$startn = $todaymonthn;
$starty = $year;
//echo "sat $startd- $startm- $starty";
}
ELSEIF (date("l", mktime(0, 0, 0, $todaymonthn, $day, $year))=="Saturday") {
$date = "$year-$todaymonthn-$day";
$d = new DateTime( $date );
$d->modify( 'last Friday' );
$startd= $d->format( 'j' );
$startm= $d->format( 'M' );
$startn= $d->format( 'n' );
$starty= $d->format( 'Y' );
//echo "sun $startd- $startm- $starty";
}
ELSE {
// not a Friday - get next one
$date = "$year-$todaymonthn-$day";
$d = new DateTime( $date );
$d->modify( 'next Friday' );
$startd= $d->format( 'j' );
$startm= $d->format( 'M' );
$startn= $d->format( 'n' );
$starty= $d->format( 'Y' );
//echo "$startd- $startm- $starty";
}
/////////ADD A DAY FOR THE SUNDAY STARTS
$startd1 = date("j",mktime(0, 0, 0, $startn, $startd+1, $starty));;
$startn1 = date("n",mktime(0, 0, 0, $startn, $startd+1, $starty));;
$starty1 = date("Y",mktime(0, 0, 0, $startn, $startd+1, $starty));;
// echo "$startd / $startn / $starty";
$query = " SELECT `day_id` FROM `calendar` WHERE `day` = '$startd' AND `month` = '$startm' AND `year` = '$starty'";
}
$result = mysqli_query( $link, $query );
while ($row = mysqli_fetch_array($result))
{
$start_day_id = $row['day_id'];
}
// echo "
$start_day_id
";
////////////////GET INFORMATION FROM USERS TABLE/////////////////////////////////////
$usertable = "users" ;
$query = "SELECT * from $usertable WHERE `Sleeps` >='$partysize' AND `user_type` !='s' ";
IF ($noSC=="true") { $query .= " AND `username` = 'bb' "; }
$query .= " ORDER BY `sortcode`, contact_name" ;
$result = mysqli_query( $link, $query );
$rows=mysqli_num_rows($result);
//echo $query;
$c=0;
while ($row = mysqli_fetch_array($result))
{
$cottage_user=$row["username"];
$contact_name[$cottage_user]=$row["contact_name"];
$thumbnail1[$cottage_user]=$row["thumbnail1"];
$size[$cottage_user]=$row["size"];
$beginon[$cottage_user]=$row["beginon"];
$Sleeps[$cottage_user]=$row["Sleeps"];
$dogs[$cottage_user]=$row["dogs"];
$wifi[$cottage_user]=$row["wifi"];
$shorts[$cottage_user]=$row["shorts"];
$user_type[$cottage_user]=$row["user_type"];
$floors[$cottage_user]=$row["floors"];
$bedrooms[$cottage_user]=$row["bedrooms"];
$ferry[$cottage_user]=$row["ferry"];
$balcony[$cottage_user]=$row["balcony"];
$bathroom[$cottage_user]=$row["bathroom"];
}
foreach ($contact_name as $key => $value) {
IF (($noSC=="true") && ($key!="bb")){ $style = "fade"; } ELSE { $style = ""; }
$cottagelink = "/cottage-".$key."/";
echo "
".$contact_name[$key]."
";
IF ($user_type[$key]=="u") {
IF ($key=="bb") { echo "
".$contact_name[$key]." can be booked at cottages.com
check dates
";
}
ELSE {
//////////// GET A PRICE ////////////////////////////
/// NB tariffsat is for Sunday and tariff is for Friday start !!!!!!!!!!
// IF ($beginon[$key]=="Saturday" ) { //$tarifftable = "tariffsat";
// $searchday = $startd1 ; $searchmonth = $startn1; $searchyear = $starty1 ; //// add a day
// } ELSE {// $tarifftable = "tariff";
IF (($key =="bb" ) || ($sb!="yes") ) {
$searchday = $startd ; $searchmonth = $startn; $searchyear = $starty ; //// don't add day
}
ELSE {
$searchday = $SBstartd ; $searchmonth = $SBstartn; $searchyear = $SBstarty ;
}
//}
$tarifftable = "tariff";
//echo $key;
//////////////////GET THE RIGHT COLUMN TO SEARCH PRICE//////////////
// IF (($key=="churchmews1") OR ($key=="churchmews4") OR ($key=="churchmews")) { $column="church"; }
// ELSEIF (($key=="churchmews2") OR ($key=="orchard1") OR ($key=="orchard2") OR ($key=="orchard3")
// ) { $column="church2"; }
// ELSEIF ($key=="foxesden") { $column="appletree"; }
// ELSEIF ($key=="badgersset") { $column="badgersset"; }
// ELSEIF ($key=="mallardsview") { $column="mallardsview"; }
// ELSEIF ($key=="squirrelsdrey") { $column="squirrel"; }
// ELSE { $column=$sleeps[$key]; }
// IF ($column=="sleepsjustfive") { $column="sleepsfive"; }
$query = "SELECT `$key` from `$tarifftable`
WHERE ((`year`< '$searchyear')
OR (`year`= '$searchyear' AND `month` < '$searchmonth')
OR (`year`= '$searchyear' AND `month` = '$searchmonth' AND `day` <= '$searchday'))
AND ((`yearto`> '$searchyear')
OR (`yearto`= '$searchyear' AND `monthto` > '$searchmonth')
OR (`yearto`= '$searchyear' AND `monthto` = '$searchmonth' AND `dayto` >= '$searchday')
)
ORDER BY day DESC, month DESC, year DESC LIMIT 1" ; // echo "$query";
$result = mysqli_query( $link, $query );
$rows=mysqli_num_rows($result);
IF ($rows>0) { $status[$key] = "ok";
while ($row = mysqli_fetch_array($result))
{
IF ($key=="bb") { $costweek[$key] = ($row[$key]) * 7; } ELSE { $costweek[$key] = $row[$key]; }
IF ($nights=="14") { echo "£".$costweek[$key]." for first week"; }
ELSEIF ($key=="bb") { echo "£".$row[$key]."per room per night "; }
ELSE { echo "£".$costweek[$key]." per week"; }
//IF (($sb=="yes")&&($nights==6)) { echo " £".$costweek[$key]." for 6 $shownights"; }
IF ($nights=="14") {
////////////////////////////////////TWO WEEKS
// GET DATES OF FOLLOWING WEEK.
$dayplus7 = $searchday+7;
$day7 = date("j",mktime(0, 0, 0, $searchmonth, $dayplus7, $searchyear));;
$todaymonthn7 = date("n",mktime(0, 0, 0, $searchmonth, $dayplus7, $searchyear));;
$year7 = date("Y",mktime(0, 0, 0, $searchmonth, $dayplus7, $searchyear));;
$query = "SELECT `$key` from `$tarifftable`
WHERE ((`year`< '$year7')
OR (`year`= '$year7' AND `month` < '$todaymonthn7')
OR (`year`= '$year7' AND `month` = '$todaymonthn7' AND `day` <= '$day7'))
AND ((`yearto`> '$year7')
OR (`yearto`= '$year7' AND `monthto` > '$todaymonthn7')
OR (`yearto`= '$year7' AND `monthto` = '$todaymonthn7' AND `dayto` >= '$day7'))
AND `$key`>'0'
ORDER BY day DESC, month DESC, year DESC LIMIT 1" ; // echo $query;
$result = mysqli_query( $link, $query );
$rows=mysqli_num_rows($result);
IF ($rows>0) { $status7[$key] = "ok";
while ($row = mysqli_fetch_array($result))
{
IF ($key=="bb") { $costweek7[$key] = ($row[$key]) * 7; } ELSE { $costweek7[$key] = $row[$key]; }
}
} ELSE {$costweek7[$key] = $costweek[$key]; }
echo " £".$costweek7[$key]." for second week";
$costsb[$key] = $costweek[$key]+$costweek7[$key];
echo " £".number_format($costsb[$key])." for 2 weeks"; }
//// end 14 nights
ELSEIF (($shorts[$key]=="n")&&($sb=="yes")) {
echo "
Short breaks are available for this property. Please contact us on 01983 867900 to arrange your booking.";
$status[$key]="no price";
}
ELSEIF ($sb=="yes") {
IF ($key=="bb") { $costsb[$key] = $costweek[$key] * $nights / 7;
echo " £".number_format($costsb[$key],2)." for $nights $shownights";
}
ELSEIF ($noSC!="true") { $costsb[$key] = $costweek[$key] * $percentage /100;
echo " £".number_format($costsb[$key],2)." for $SBnights $shownights";
}
ELSEIF ($noSC=="true") {
$status[$key]="short breaks not available";
}
} // if sb
} // while
} // rows
ELSE {
echo "
No prices are available for these dates yet.";
$status[$key]="no price";
}
$booked[$key]='';
////////////// CHECK AVAILABILITY//////////////////////////////////////
//// START FROM $start_day_id OR 1 DAY AFTER ////
//// IF SHORT BREAK GO WITH $nights else round up
IF ($sb=="yes") {
IF ($key=="bb") { $numnights = $nights;}
ELSEIF ($noSC!="true") { $numnights = $SBnights;}
$starton = $start_day_id;
$SBstarton = $SBstart_day_id;
}
ELSE { $numnights = (ceil($nights/7))*7;
$starton = $start_day_id;
// IF ($beginon[$key]=="Saturday" ) {$starton = $start_day_id+1;} ELSE {$starton = $start_day_id;}
}
IF (($key=="bb") || ($sb!="yes")) {
$query = " SELECT `$key` FROM `calendar` WHERE `day_id`>='$starton' ORDER BY `day_id` ASC LIMIT $numnights
";
}
ELSE
{
$query = " SELECT `$key` FROM `calendar` WHERE `day_id`>='$SBstarton' ORDER BY `day_id` ASC LIMIT $numnights
";
}
// echo $query;
$result = mysqli_query( $link, $query );
while ($row = mysqli_fetch_array($result))
{
IF ($row[$key]=="b") { $booked[$key]="yes"; }
}
/////////////////////////// IS BOOKED
IF (($booked[$key]=="yes")&&($key!="foxesden") && ($key!="churchmews1") && ($key!="badgersset")) { echo "
$value is booked for these dates
"; }
///////////////////////AVAILABLE - SHOW LINK TO NEXT PAGE
ELSEIF ($status[$key] == "ok") {
//// GET THE PROPER START DAY - limit 1 this time////
IF (($key=="bb") || ($sb!="yes")) {
$query = " SELECT `$key`, `day`, `month`, `year` FROM `calendar` WHERE `day_id`>='$starton' ORDER BY `day_id` ASC LIMIT 1
";
}
ELSE
{
$query = " SELECT `$key`, `day`, `month`, `year` FROM `calendar` WHERE `day_id`>='$SBstarton' ORDER BY `day_id` ASC LIMIT 1
";
}
// $query = " SELECT * FROM `calendar` WHERE `day_id`='$starton' ORDER BY `day_id` ASC LIMIT 1
// ";
$result = mysqli_query( $link, $query );
// echo "