#!/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 {
); $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; }