#!/usr/bin/perl
##############################################################################
# Weekly Holiday Home Booking Calendar Version 2.50 #
# Copyright 2001 John Plaxton john@availcheck.com #
# First Created June 2001 Last Modified 15 November 2003 #
# Scripts Archive at: http://www.availcheck.com #
##############################################################################
# COPYRIGHT NOTICE #
# Copyright 2001 John H K Plaxton All Rights Reserved. #
# #
# Availcheck Weekly Availability Calendar may NOT be used or modified or #
# changed by anyone without my expressed permission. The coding should #
# remain intact and unchanged. #
# #
# Selling the code for this program without prior written consent is #
# expressly forbidden. In other words, please ask first before you try and #
# make money off my program. This coding has taken hundreds of man hours. #
# #
##############################################################################
use CGI qw(:standard);use CGI::Carp qw(fatalsToBrowser);
use Time::localtime;
use Time::Local;
$q = new CGI; print $q->header;
$VERSION = "v 2.50";
require "/home/gar10848/public_html/calendars/cal1/config.pl";
require "/home/gar10848/public_html/calendars/cal1/codebank.pl";
foreach $field ($q->param()) {
${$field} = $q->param($field);
${$field} =~ s/'\<\>//g;
#print"$field - ${$field} ";
}
$Bin = &getpath;
my $self_url = $q->url;
my $headerdata = &get_header_details();
my ($contactname,$propname,$userid,$pword,$propaddr,$proppostcode,$proptel,$propemail,$headertext,$curr,$currphrase,$lastupdated,$showhist,$pcounter,$showpricecol,$showavail,$deposit) = split(/\|/,$headerdata);
my $link = &emaillink($propemail);
$propaddr =~ s/¬/ /g;
$headertext =~ s/¬/ /g;
######################################################################################
# If you are translating the calendars then change these lines to your chosen language
my $contactline = "For Further Details ".$proptel.' '.$link;
my $lastupdtext = &createlongdatestr($lastupdated,$lastupdated);
$lastupdtext = "Calendar Last Updated ".$lastupdtext;
$ret_menu_text = "
";
}
$details_hash{'xx--grid_main1--xx'} = $grid_text;
####################################################################################
# template header_html printed
if (-e $header_html) {send_html( $header_html, \%details_hash);}
else {print"HTML File " . $header_html ." Not found ";}
####################################################################################
} # end print_yearly_calendarrows
####################################################################################
sub send_client_email {
my $todaysdate = &get_date;
my @bookingrecs = &get_booking_records();my $pricec = 0;my $longdatestr;
open(MAIL,"|$mailprog -t") or die "Error opening email gateway system file: $!\n";
print MAIL "To: $email\n";
print MAIL "From: $propemail\n";
print MAIL "Subject: Booking Enquiry for $propname\n\n";
print MAIL "Thank you for making a booking enquiry for $propname. It was submitted by\n";
print MAIL "$booker_name [ $email ] on $todaysdate\n";
print MAIL "-" x 80 . "\n\n";
print MAIL "Here are the details of Your booking enquiry\n";
print MAIL "\n";
print MAIL "Booking for: $propname\n";
print MAIL "Date\(s\) Interested In: \n";
if (! $showpricecol){
print MAIL "DATE(S)\n";
print MAIL "==============\n";
foreach my $row (@bookingrecs){
my ($aut,$date,$avail,$price,$paidfor) = split(/\|/, $row);
$pricec = 0;
my $tempd = &createlongdatestr($date);
$longdatestr .= $tempd;
print MAIL "$tempd \n";
}
}
else {
print MAIL "DATE(S) PRICE(S)\n";
print MAIL "=================================================\n";
foreach my $row (@bookingrecs){
my ($aut,$date,$avail,$price,$paidfor) = split(/\|/, $row);
$pricec += $price;
my $tempp = &createpricestr($curr,$price);
my $tempd = &createlongdatestr($date);
$longdatestr .= $tempd;
print MAIL "$tempd $tempp \n";
}
my $temptot = &createpricestr($curr,$pricec);
print MAIL "-" x 80 . "\n";
print MAIL "Total: $temptot\n\n\n";
}
chomp($deposit);
if ($deposit){
$dep = &calculate_deposit($deposit,$pricec);
$dep_text = &createpricestr($curr,$dep);
print MAIL "We require a deposit of $dep_text to secure this booking. If it is less than 1 month until the booking date then please send full payment.\n\n";
print MAIL "-" x 80 . "\n\n";
print MAIL "Please send cheques payable to:\n$contactname\n$propaddr\n$proppostcode\n\n";
if (-e "paypal_plugin.pl"){
require "paypal_plugin.pl";
my $prop_str = $propname . " " .$longdatestr;$prop_str =~ s/ /\%20/g;
my $item_str = $propname . "/" . time; $item_str =~ s/ /\%20/g;
$pricetot =~ s/$curr//g;chomp($deposit);
$paypal_depositstr = &create_paypal_str_deposit($dep,$prop_str. "%20Deposit%20Payment",$item_str,$currphrase);
$paypal_fullstr = &create_paypal_str_full($pricec,$prop_str. "%20Full%20Payment",$item_str,$currphrase);
if ($deposit){print MAIL "$paypal_depositstr\n";}
print MAIL "$paypal_fullstr\n";
}
}
else {
print MAIL "We shall Try to contact you as soon as possible to confirm this booking.\n\n";
}
print MAIL "No. Adults $no_adults\n";
print MAIL "No. Children $no_children\n";
print MAIL "For any further queries please ring us on $proptel\n\n";
print MAIL "-" x 80 . "\n\n";
print MAIL "Thank You. \n";
print MAIL "Availcheck Calendars http://www.availcheck.com\n";
print MAIL "-" x 80 . "\n\n";
close (MAIL);
} # end send_email
####################################################################################
sub send_email_to_hr {
my $todaysdate = &get_date;
my @bookingrecs = &get_booking_records();
my $startdate=0;my $enddate=0;my $datediff=0;my $atemp=0;my $init=1;$pricec=0;my $pricetot=0;my $datesstr;
open(MAIL,"|$mailprog -t") or die "Error opening email gateway system file: $!\n";
print MAIL "To: $propemail\n";
print MAIL "From: $email\n";
print MAIL "Subject: Booking Enquiry for $propname\n\n";
print MAIL "You have received a booking enquiry from your website posted by\n";
print MAIL "$booker_name [ $email ] on $todaysdate\n";
print MAIL "-" x 80 . "\n\n";
print MAIL "Here are the details of the booking enquiry\n";
print MAIL "\n";
print MAIL "Booking for: $propname\n";
print MAIL "Date\(s\) Interested In: \n";
print MAIL "DATE(S) Availability\n";
print MAIL "=============================================\n";
if (! $showpricecol){
print MAIL "DATE(S)\n";
print MAIL "==============\n";
foreach my $row (@bookingrecs){
my ($aut,$date,$avail,$price,$paidfor) = split(/\|/, $row);
my $tempd = &createlongdatestr($date);
print MAIL "$tempd \n";
}
}
else {
print MAIL "DATE(S) PRICE(S)\n";
print MAIL "=================================================\n";
foreach my $row (@bookingrecs){
my ($aut,$date,$avail,$price,$paidfor) = split(/\|/, $row);
$pricec += $price;
my $tempp = &createpricestr($curr,$price);
my $tempd = &createlongdatestr($date);
print MAIL "$tempd - $tempp \n";
}
my $temptot = &createpricestr($curr,$pricec);
print MAIL "-" x 80 . "\n";
print MAIL "Total: $temptot\n\n\n";
}
(my $menu_url = $self_url) =~ s/index.cgi/menu.cgi/g;
$postaddress =~ s/\r\n/ /g;
print MAIL "=============================================\n\n";
print MAIL "Estimated time of arrival: $arrival_time\n\n";
if (($showprices)&&($pricetot > 0)){
$pricetot_text = &createpricestr($curr,$pricetot);
print MAIL "Total Price for this booking: $pricetot_text\n";}
chomp($deposit);
if ($deposit){
$dep = &calculate_deposit($deposit,$pricec);
$dep = &createpricestr($curr,$dep);
print MAIL "An email has been sent to $booker_name requesting payment ( Deposit : $dep )\n\n";
}
else {print MAIL "An email has been sent to $booker_name $email\n\n";}
print MAIL "Address Details\n";
print MAIL "===============\n";
print MAIL "$booker_name\n";
print MAIL "$postaddress\n$country\n Tel: $phone\n\n";
print MAIL "No. Adults $no_adults\n";
print MAIL "No. Children $no_children\n";
print MAIL "Other requests: $enquiry\n\n";
##
# If you change your booking form elements then you can have the email send
# these details back to you like so:
# print MAIL "$name_of_form_element\n"; # noting the \$ sign at the start of the form name element.
##
print MAIL "=============================================\n";
print MAIL "By clicking on the link below you can automatically update your calendar to make the dates in this booking taken. Only do this if these dates are now fully booked.\n";
my $urlstr = "?action=autoupdatecal&u=$userid&p=$pword";
foreach (@bookingrecs){
my ($aut,@a) = split(/\|/, $_);
$urlstr .= "&aut|$aut=on";
}
print MAIL "$menu_url$urlstr\n\n";
print MAIL "=============================================\n\n";
print MAIL "Availcheck Calendars http://www.availcheck.com\n";
print MAIL "-" x 80 . "\n\n";
close (MAIL);
} # end send_email
####################################################################################
sub printbookingpage {
my $atemp=0;$init=1;my $allavail=0; my $grid_text = "";my $pricec = 0;
my @bookingrecs = &get_booking_records();my $rowcount = @bookingrecs;
foreach my $field ($q->param()) {if($field ne 'action'){$grid_text .= "\n";}}
$grid_text .= "
";}
} # end foreach
if ($allavail == 0){if ($rowcount > 1){
if ($showpricecol==1){$temptot = &createpricestr($curr,$pricec);
$grid_text .= "
 
\n";
$grid_text .= "
Total:
$temptot
";}}}
$grid_text .= "
 
\n";
if ($deposit =~ /\%/){$deposit = sprintf("%.2f", (($deposit * $pricec)/100));}
$tempd = &createlongdatestr($startdate,$enddate);
if ($pricec > 0){$pricec = &createpricestr($curr,$pricec);}
else {$pricec = "---";}
chomp($deposit);
if ($deposit and ! $allavail and $rowcount){
$deposit = &createpricestr($curr,$deposit);
$grid_text .= "
 
\n";
$grid_text .= "
Total Deposit required to secure this booking:
$deposit
\n";
}
$grid_text .= "
\n";
# inserts details of selected dates into HASH which appears at top of booking form in xx--grid_main1--xx position
$details_hash{'xx--grid_main1--xx'} = $grid_text;
# inserts details of selected dates into HASH which appears at top of booking form in xx--grid_main1--xx position
$grid_text =
"
";
if (! $rowcount) {$grid_text .= "Please select dates you are interested in. ";}
elsif ($allavail){$grid_text .= "Sorry, some of your select dates are taken. Please reselect. ";}
if ($rowcount and ! $allavail){$grid_text .= "";}
$grid_text .= "
";
$grid_text .= "
";
####################################################################################
# inserts buttons and/or error message into HASH which appears at bottom of booking form in xx--grid_main2--xx position
$details_hash{'xx--grid_main2--xx'} = $grid_text;
# inserts buttons and/or error message into HASH which appears at bottom of booking form in xx--grid_main2--xx position
####################################################################################
# template booking_form_html printed
if (-e $booking_form_html) {send_html( $booking_form_html, \%details_hash);}
else {print"HTML File " . $booking_form_html ." Not found ";}
####################################################################################
} # end printbookingpage