#!/usr/bin/perl
####
#### Business Website Price Calculator
#### Designed by Paul Dupuy, Jr.
####

# Use cgi-lib parser
require "cgi-lib.pl";
&ReadParse(*input);

# Who gets the death message?
$mailerrorto = 'paul@hiwaay.net';



###
### Write the price log
###

# Open price log
open (PRICE, ">>websitepricelog") || &death("Could not open websitepricelog: $!");

# Time
$now = localtime(time);
print PRICE "$now\n";

# Print items
for $key (keys %input)
{
	print PRICE "$key $input{$key}\n";
}

print PRICE "\n";

# Close price log
close (PRICE) || &death("Could not close websitepricelog: $!");





###
### Output the Results page
###

# Print the header
&header;

# Price per hour
$hour = 50;

# Base design time
$designtime = 1;

# Printing strings
$left = '<TR><TD><B>&#167;</B>&nbsp;';
$hide = '<INPUT TYPE="hidden" ';
$right = qq!</TD></TR><TR><TD HEIGHT="11"> </TD></TR>\n!;





##
## Print list of items while calculating price
##

if ($input{'logo'} eq 'existing') 
{
	print "$left Your current logo$hide";
	print qq!NAME="logo" VALUE="existing">$right!;
	$designtime += 1;
}
else
{
	print "$left A newly designed logo$hide";
	print qq!NAME="logo" VALUE="design">$right!;
	$designtime += 4;
}


if($input{'cobrief'}) 
{
	print "$left Brief information about your Company$hide";
	print qq!NAME="cobrief" VALUE="1">$right!;
	$designtime += .5;
}


if($input{'codetail'}) 
{
	print "$left Detailed information about your Company$hide";
	print qq!NAME="codetail" VALUE="1">$right!;
	$designtime += .75;
}


if($input{'coimage'}) 
{
	print "$left $input{'coimagenumber'} image";
	if ($input{'coimagenumber'} > 1) {print "s"}
	print " of your Company$hide";
	print qq!NAME="coimage" VALUE="1">$hide!;
	print qq!NAME="coimagenumber" VALUE="$input{'coimagenumber'}">$right!;
	$designtime += ($input{'coimagenumber'} * .5);
}


if($input{'map'}) 
{
	print "$left A map of your Company's location$hide";
	print qq!NAME="map" VALUE="1">$right!;
	$designtime += .75;
}


if($input{'directions'}) 
{
	print "$left Directions to your Company's location$hide";
	print qq!NAME="directions" VALUE="1">$right!;
	$designtime += .5;
}


if($input{'progeneral'}) 
{
	print "$left General information about your Company's Products/Services$hide";
	print qq!NAME="progeneral" VALUE="1">$right!;
	$designtime += .75;
}


if($input{'probrief'}) 
{
	print "$left $input{'probriefnumber'} brief descriptions of your Company's Products/Services$hide";
	print qq!NAME="probrief" VALUE="1">$hide!;
	print qq!NAME="probriefnumber" VALUE="$input{'probriefnumber'}">$right!;
	
	# change range string to upper value
	$input{'probriefnumber'} =~ s/\d+-//;	
	$designtime += ($input{'probriefnumber'} * .1);
}


if($input{'prodetail'}) 
{
	print "$left $input{'prodetailnumber'} detailed descriptions of your Company's Products/Services$hide";
	print qq!NAME="prodetail" VALUE="1">$hide!;
	print qq!NAME="prodetailnumber" VALUE="$input{'prodetailnumber'}">$right!;
	
	# change range string to upper value
	$input{'prodetailnumber'} =~ s/\d+-//;	
	$designtime += ($input{'prodetailnumber'} * .2);
}


if($input{'proimage'}) 
{
	print "$left $input{'proimagenumber'} images of your Company's Products/Services$hide";
	print qq!NAME="proimage" VALUE="1">$hide!;
	print qq!NAME="proimagenumber" VALUE="$input{'proimagenumber'}">$right!;
	
	# change range string to upper value
	$input{'proimagenumber'} =~ s/\d+-//;	
	$designtime += ($input{'proimagenumber'} * .3);
}


if($input{'order'} eq 'secure') 
{
	print "$left Product/Service ordering, including secure credit card transactions$hide";
	print qq!NAME="order" VALUE="secure">$right!;
	$designtime += 10;
}


if($input{'order'} eq 'without') 
{
	print "$left Product/Service ordering, without credit card transactions$hide";
	print qq!NAME="order" VALUE="without">$right!;
	$designtime += 5;
}


if($input{'order'} eq 'none') 
{
	print "$left No online Product/Service ordering$hide";
	print qq!NAME="order" VALUE="none">$right!;
	$designtime += 5;
}


if ($input{'navigation'} eq 'text') 
{
	print "$left Navigation using only text$hide";
	print qq!NAME="navigation" VALUE="text">$right!;
	$designtime += 1;
}
else
{
	print "$left Navigation using images and text$hide";
	print qq!NAME="navigation" VALUE="image">$right!;
	$designtime += 7;
}


if ($input{'newsletter'}) 
{
	print "$left Newsletter request button$hide";
	print qq!NAME="newsletter" VALUE="1">$right!;
	$designtime += .5;
}


if($input{'information'}) 
{
	print "$left Information submission form$hide";
	print qq!NAME="information" VALUE="1">$right!;
	$designtime += 1;
}


if($input{'promotion'}) 
{
	print "$left Search Engine Website submissions$hide";
	print qq!NAME="promotion" VALUE="1">$right!;
	$designtime += 1;
}


if ($input{'counter'}) 
{
	print "$left Webpage visit counter$hide";
	print qq!NAME="counter" VALUE="1">$right!;
	$designtime += .25;	
}


if($input{'background'}) 
{
	print "$left Background image$hide";
	print qq!NAME="background" VALUE="1">$right!;
	$designtime += .5;
}


if($input{'addtext'}) 
{	
	print "$left $input{'addtextnumber'} additional words of text$hide";
	print qq!NAME="addtext" VALUE="1">$hide!;
	print qq!NAME="addtextnumber" VALUE="$input{'addtextnumber'}">$right!;
	
	# change range string to upper value
	$input{'addtextnumber'} =~ s/\d+-//;	
	$designtime += ($input{'addtextnumber'} * .002);
}


if($input{'addimage'}) 
{
	print "$left $input{'addimagenumber'} additional images$hide";
	print qq!NAME="addimage" VALUE="1">$hide!;
	print qq!NAME="addimagenumber" VALUE="$input{'addimagenumber'}">$right!;
	
	# change range string to upper value
	$input{'addimagenumber'} =~ s/\d+-//;	
	$designtime += ($input{'addimagenumber'} * .3);
}


if($input{'host'} eq 'dial') 
{
	print "$left Hosting with dial-up ";
	if ($input{'dialtype'} =~ /Modem/)
	{
		print "modem access$hide";
	}
	else
	{
		print "$input{'dialtype'} access$hide";
	}
	print qq!NAME="host" VALUE="dial">$hide!;
	print qq!NAME="dialtype" VALUE="$input{'dialtype'}">$right!;
	
	# Charge is the same for all types
	$servicecharge += 50;
}
elsif ($input{'host'} eq 'dedicated') 
{
	print "$left Hosting with dedicated $input{'dedicatedtype'} access$hide";
	print qq!NAME="host" VALUE="dedicated">$hide!;
	print qq!NAME="dedicatedtype" VALUE="$input{'dedicatedtype'}">$right!;
	
	if ($input{'dedicatedtype'} =~ /Modem/)
	{
		$servicecharge += 225;
	}
	elsif ($input{'dedicatedtype'} =~ /64/)
	{
		$servicecharge += 375;
	}
	else	#dedicatedtype = 128
	{
		$servicecharge += 525;
	}
}
else
{
	print "$left Hosting without access$hide";
	print qq!NAME="host" VALUE="without">$right!;
	$servicecharge += 25;
}


if($input{'registerdomain'}) 
{
	print "$left Domain name registration$hide";
	print qq!NAME="registerdomain" VALUE="1">$right!;
	$designtime += 2.3;
}


if($input{'DNS'}) 
{
	print "$left Domain name service$hide";
	print qq!NAME="DNS" VALUE="1">$right!;
	$servicecharge += 15;
}


if($input{'addemail'}) 
{
	print "$left $input{'addemailnumber'} additional email addresses$hide";
	print qq!NAME="addemail" VALUE="1">$hide!;
	print qq!NAME="addemailnumber" VALUE="$input{'addemailnumber'}">$right!;
	
	if ($input{'addemailnumber'} =~ /5/)
	{
		$servicecharge += 10;
	}
	else	# addemailnumber = 11-20
	{
		$servicecharge += 20;
	}
	
}


if($input{'mailinglist'}) 
{
	print "$left Email mailing list$hide";
	print qq!NAME="mailinglist" VALUE="1">$right!;
	$servicecharge += 10;
}


if($input{'autorespond'}) 
{
	print "$left Email auto-responder$hide";
	print qq!NAME="autorespond" VALUE="1">$right!;
	$servicecharge += 3;
}



##
## Calculate the design cost
##

$designcost = int($designtime * $hour);
$designcost .= '.00';




##
## Output top of the returned page
##

print <<"AAA";
</TABLE>

<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" ALIGN="CENTER"><TR><TD COLSPAN="3" 
HEIGHT="6"> </TD></TR><TR><TD ALIGN="LEFT"><FONT 
SIZE="+1" FACE="Arial, Helvetica">Estimated design cost:</FONT></TD><TD 
WIDTH="6"> </TD><TD ALIGN="RIGHT"><FONT SIZE="+1" FACE="Arial, 
Helvetica">\$${designcost}</FONT></TD></TR>

<TR><TD COLSPAN="3" HEIGHT="6"> </TD></TR>

<TR><TD ALIGN="LEFT"><FONT SIZE="+1" FACE="Arial, 
Helvetica">Monthly service charge:</FONT></TD><TD 
WIDTH="6"> </TD><TD ALIGN="RIGHT"><FONT SIZE="+1" FACE="Arial, 
Helvetica">\$${servicecharge}.00</FONT></TD></TR><TR><TD COLSPAN="3" 
HEIGHT="33"> </TD></TR><TR></TABLE>

<INPUT TYPE="hidden" NAME="designcost" VALUE="$designcost">
<INPUT TYPE="hidden" NAME="servicecharge" VALUE="$servicecharge">

<FONT SIZE="+1">If you would like us to contact you to discuss your Website,<BR>
please submit the following information:</FONT><BR><TABLE 

BORDER="0" CELLPADDING="0" CELLSPACING="0" ALIGN="CENTER"><TR><TD COLSPAN="2" 
HEIGHT="18"> </TD></TR><TR><TD 
ALIGN="RIGHT">Name:&nbsp;</TD><TD ALIGN="LEFT"><INPUT TYPE="TEXT"
NAME="contactname" SIZE="33" MAXLENGTH="33"></TD></TR><TR><TD COLSPAN="2" 
HEIGHT="8"> </TD></TR>

<TR><TD ALIGN="RIGHT">Email:&nbsp;</TD><TD ALIGN="LEFT"><INPUT TYPE="TEXT"
NAME="contactemail" SIZE="33" MAXLENGTH="33"></TD></TR><TR><TD COLSPAN="2" 
HEIGHT="8"> </TD></TR>

<TR><TD ALIGN="RIGHT">Phone:&nbsp;</TD><TD ALIGN="LEFT"><INPUT TYPE="TEXT"
NAME="contactphone" SIZE="14" MAXLENGTH="14"></TD></TR><TR><TD COLSPAN="2" 
HEIGHT="18"> </TD></TR>

<TR><TD COLSPAN="2" ALIGN="CENTER"><CENTER><INPUT 
TYPE="SUBMIT" VALUE="Contact Me" NAME="SUBMIT"></FORM></CENTER></TD></TR><TR><TD COLSPAN="2" 

HEIGHT="23"> </TD></TR><TR></TABLE><TABLE 

BORDER="0" CELLPADDING="0" CELLSPACING="0" ALIGN="CENTER"><TR><TD 
ALIGN="CENTER"><CENTER><FONT 
SIZE="+1">Our Design Staff can be reached at<BR>(256) 882-7320 and 
<A HREF="mailto:Paul\@hiwaay.net">Paul\@hiwaay.net</A></FONT><P><BR>

<A HREF="http://home.hiwaay.net/~paul/resume/price/websiteprice.html">Return 
to the Business Website Pricing 
Form</A><P>&nbsp;</CENTER></TD></TR></TABLE></CENTER>

<!-- Love is the Law. -->

</BODY></HTML>
AAA








###
### Subroutines
###


##
## HTML Page Header
##
sub header
{
	print "Content-type: text/html\n\n";
			
	print <<"AAA";
<HTML><HEAD><TITLE>Business Website Price</TITLE></HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" 
ALINK="#C900D9" VLINK="#660099">

<!--Created by Paul Dupuy, Jr. @ Valley Internet-->

<FORM METHOD="POST" ACTION="http://fly.hiwaay.net:8000/~paul/cgi/websitecontact.cgi">

<CENTER><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" ALIGN="CENTER"><TR><TR><TD 
COLSPAN="3" HEIGHT="4"> </TD></TR><TD><IMG 
SRC="http://home.hiwaay.net/~paul/resume/price/head1.gif" WIDTH="133" 
HEIGHT="34" BORDER="0"
ALIGN="MIDDLE" ALT="Valley"></TD><TD WIDTH="13"></TD><TD><IMG
SRC="http://home.hiwaay.net/~paul/resume/price/head2.gif" WIDTH="179" 
HEIGHT="34" BORDER="0" 
ALIGN="MIDDLE" ALT="Internet"></TD></TR></TABLE>
<P>

<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" 
ALIGN="CENTER"><TR><TD ALIGN="CENTER"><CENTER><FONT 
SIZE="+2">Business Website Price</FONT></CENTER></TD></TR><TR><TD HEIGHT="23"> 
</TD></TR><TR><TD ALIGN="CENTER"><CENTER><FONT 
SIZE="+1" FACE="Arial, Helvetica">Your Website will 
include:</FONT></CENTER></TD></TR></TABLE><TABLE 

BORDER="0" CELLPADDING="0" CELLSPACING="0" 
ALIGN="CENTER"><TR><TD HEIGHT="16"> </TD></TR>
AAA

} #endsub header



##
## Handle system errors
##
sub death 
{
	$message = @_[0];
	
	#
	# Output an Error Page
	#
	print "Content-type: text/html\n\n";
		
	print <<"AAA";
<HTML><HEAD><TITLE>Business Website Pricing Not Available</TITLE></HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" 
ALINK="#C900D9" VLINK="#660099">

<!--Created by Paul Dupuy, Jr. @ Valley Internet-->

<CENTER><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" ALIGN="CENTER"><TR><TR><TD 
COLSPAN="3" HEIGHT="4"> </TD></TR><TD><IMG 
SRC="http://home.hiwaay.net/~paul/resume/price/head1.gif" WIDTH="133" 
HEIGHT="34" BORDER="0"
ALIGN="MIDDLE" ALT="Valley"></TD><TD WIDTH="13"></TD><TD><IMG
SRC="http://home.hiwaay.net/~paul/resume/price/head2.gif" WIDTH="179" 
HEIGHT="34" BORDER="0" 
ALIGN="MIDDLE" ALT="Internet"></TD></TR></TABLE>
<P>

<FONT SIZE="+2">Business Website Pricing is Not Available</FONT>
<P><BR>

<FONT SIZE="+1" FACE="Arial, Helvetica">Sorry, the Business Website Price program is not available right now.<P>
Please try again later.</FONT><P><BR>

</BODY></HTML>
AAA
	

	#
	# Mail an Error Message
	#
	open(MAIL, "|/usr/lib/sendmail -oi -t") || die ("Unable to open mail program.\n");

	print MAIL <<"AAA";
Subject: Business Website Price Error
From: price.pl
To: $mailerrorto


     An error occurred during the execution of price.pl:

$message

price.pl
AAA

	close(MAIL) || die ("Unable to close mail program.\n");

	# Quit
	exit;
	
} #endsub death



##
## Love is the Law.

1;