#!/usr/bin/perl # query.html # see README.txt in docs directory for booking rules. Mel use Mysql; # mSQL database routines require "OLconfig.pl"; require "SQLconfig.pl"; require "custom/vdslib.pl"; # Initialize CGI environment use CGI qw/:standard/; use Date::Calc qw ( Date_to_Days Day_of_Week Add_Delta_Days Today Now ); ($yy, $mm, $dd) = Today(); $mmOut = $mm-1; $dayofweek = Day_of_Week($yy,$mm,$dd); if( $dayofweek < 6 ){ # Add whatever it takes to get to this Saturday $days_offset = 6 + (7 - $dayofweek); } else { # Add whatever it takes to get to next Saturday $days_offset = 6+(6 + (7 - $dayofweek )); } ($Nyear,$Nmm,$Ndd) = Add_Delta_Days ( $yy,$mm,$dd,$days_offset ); $nextYear = $Nyear+1; print header; $top = &VDS::readFile('top.html'); $top =~ s/BROWSERTITLE/$clientName $clientLocation Property Search/; $top =~ s/PAGETITLE/Property Search/; $top =~ s#BANNER#Rental Search#; print $top; ########## Get end range. This is used for cutoff & for the date checking too. ########## No reservations past this date allowed. $endRange = getEndRange(); ($erY, $erM, $erD) = Add_Delta_Days(1,1,1, $endRange-1); $endRange = "$erY-$erM-$erD"; #print "ER: $endRange"; ########################################################################### print qq {

Please select the features you're looking for in your vacation rental. When you have entered all your requirements, press the Submit button and we will display a list of properties that meet your needs.

If you already know the rental property you wish to view, either by Property Number or Property Name, click the appropriate link.

New, view our property Maps.

Property Availability:

Arrival Date:
Departure Date:

If you want to stay more than 14 nights or arrive within 14 days, please call us at (910) 579-3515 for availability and to book a property. Partial stay reservations are only allowed during September through May and can be booked 45 days in advance or less.

); print qq(

Property Features:

Location: ); # Connect to database in order to do upcoming searches: my $conn = Mysql->Connect($dbserver, $db) or print qq {"Sorry, we are temporarily unable to process your search request. Please try again in a little while.

$Mysql::db_errstr"}; # get Sleeps drop-down list: $result = $conn->Query(qq{SELECT DISTINCT Location FROM $dbtable WHERE Location >= 'A' ORDER BY Location}) or print qq {query.html Select Location: Sorry, we are temporarily unable to process your search request. Try resubmitting your search request in a couple of minutes.
$Mysql::db_errstr}; if ($result->numrows() != 0) { print "); } # end-if there are properties in database print qq (

Type: ); # get Sleeps drop-down list: $result = $conn->Query(qq{SELECT DISTINCT Type FROM $dbtable ORDER BY Type}) or print qq {query.html Select Type: Sorry, we are temporarily unable to process your search request. Try resubmitting your search request in a couple of minutes.
$Mysql::db_errstr}; if ($result->numrows() != 0) { print ""; } # end-if there are properties in database print qq (
Minimum Bedrooms: ); # get Bedrooms drop-down list: $result = $conn->Query(qq{SELECT DISTINCT Bedrooms FROM $dbtable ORDER BY Bedrooms}) or print qq {query.html Select Bedrooms: Sorry, we are temporarily unable to process your search request. Try resubmitting your search request in a couple of minutes.
$Mysql::db_errstr}; if ($result->numrows() != 0) { print ""; } # end-if there are properties in database print qq (
Minimum Full Baths: ); # get FullBaths drop-down list: $result = $conn->Query(qq{SELECT DISTINCT FullBaths FROM $dbtable ORDER BY FullBaths}) or print qq {query.html Select FullBaths: Sorry, we are temporarily unable to process your search request. Try resubmitting your search request in a couple of minutes.
$Mysql::db_errstr}; if ($result->numrows() != 0) { print ""; } # end-if there are properties in database print qq (
); ################################### # get Number of properties having each amenity: $result = $conn->Query(qq{SELECT Count(*) FROM $dbtable WHERE upper(ScreenedPorch)='Y'}) or print qq {query.html Count Screened Porch: Sorry, we are temporarily unable to process your search request. Try resubmitting your search request in a couple of minutes.
$Mysql::db_errstr}; $NumPorch = $result->fetchrow(); $result = $conn->Query(qq{SELECT Count(*) FROM $dbtable WHERE upper(SunDeck)='Y'}) or print qq {query.html Count Sundeck: Sorry, we are temporarily unable to process your search request. Try resubmitting your search request in a couple of minutes.
$Mysql::db_errstr}; $NumSunDeck = $result->fetchrow(); $result = $conn->Query(qq{SELECT Count(*) FROM $dbtable WHERE NonSmoking='Y'}) or print qq {query.html Count NonSmoking: Sorry, we are temporarily unable to process your search request. Try resubmitting your search request in a couple of minutes.
$Mysql::db_errstr}; $NumNonSmoking = $result->fetchrow(); $result = $conn->Query(qq{SELECT Count(*) FROM $dbtable WHERE Special='Y'}) or print qq {query.html Count Specials: Sorry, we are temporarily unable to process your search request. Try resubmitting your search request in a couple of minutes.
$Mysql::db_errstr}; $NumSpecials = $result->fetchrow(); $result = $conn->Query(qq{SELECT Count(*) FROM $dbtable WHERE upper(EastSide)='Y'}) or print qq {query.html Count East Side: Sorry, we are temporarily unable to process your search request. Try resubmitting your search request in a couple of minutes.
$Mysql::db_errstr}; $NumEastSide = $result->fetchrow(); $result = $conn->Query(qq{SELECT Count(*) FROM $dbtable WHERE upper(WestSide)='Y'}) or print qq {query.html Count West Side: Sorry, we are temporarily unable to process your search request. Try resubmitting your search request in a couple of minutes.
$Mysql::db_errstr}; $NumWestSide = $result->fetchrow(); $result = $conn->Query(qq{SELECT Count(*) FROM $dbtable WHERE upper(Canal)='Y'}) or print qq {query.html Count Canal: Sorry, we are temporarily unable to process your search request. Try resubmitting your search request in a couple of minutes.
$Mysql::db_errstr}; $NumCanal = $result->fetchrow(); ################################### print qq (

Amenities: (The number of properties that match the amenity is shown in parentheses next to it.)
Non-Smoking ($NumNonSmoking) Screened Porch ($NumPorch)
Sundeck ($NumSunDeck) Special Properties ($NumSpecials)
East Side of Island ($NumEastSide) West Side of Island ($NumWestSide)
On Canal ($NumCanal)  
Results:
How would you like the results sorted?

); $bottom = &VDS::readFile('bottom.html'); print $bottom; ############################################ # Get the end range date for the allowable # dates on the search. No reservations are allowed # for dates beyond this date. sub getEndRange{ $StartDay = 6; #SAT # Generate the weekend dates my ($todayyear, $todaymm, $todaydd) = Today(); $dow = Day_of_Week($todayyear,$todaymm,$todaydd); # if thurs. or greater if($dow > 1){ $weeks = 51; } else{ # if < thurs. $weeks = 50; } $days = 7 * $weeks; ### Next years week my $NYdate = Date_to_Days($todayyear, $todaymm, $todaydd) + $days; if ($dow != $StartDay ){ if ($dow < $StartDay){ $deltadiff = $StartDay - $dow; $NYdate += $deltadiff; } elsif ($dow > $StartDay){ $deltadiff = $dow - $StartDay; $NYdate = $NYdate - $deltadiff; } } return $NYdate; }