#!/afs/athena/contrib/perl/perl

require '/mit/mkgray/perl/io.pl';

%scolor = 
	(
	"1", "Red",
	"2", "Green",
	"3", "Blue",
	);
%sizz =
	(
	"1", "XL",
	"2", "L",
	"3", "M",
	);

# Actual shirt price will be $8 or $10
print(`clear`);
print("Welcome to the\n");
print("Our Lady of the All Night Tool\n");
print("Automatic Ordering Script\n\n");
print("This script will allow you to reserve an all new,\n");
print("way spiffy, cooler than mortals deserve, t-shirt.\n");
print("The shirts have \"The Cathedral of Our Lady of the All Night Tool\"\n");
print("on the front...\n");
print("and the 0x10 commandments on the back.\n");
print("You will be need to pick it up and pay for it from someone...\n");
print("\n");
print("Options...\n");
print("The print is black.  Sorry, no options on that.\n");
print("If you really want a white on black shirt, say so in the comments\n");
print("section, and here specify your second choice.\n");
print("\nMake sure you type the number of the option, ie 1, not Red\n");
print("\nWhat color shirt would you like?\n");
print("1) Red\n");
print("2) Green\n");
print("3) Blue\n");
$shirtc = int(&io'input());
print("\nWhat size shirt would you like?\n");
print("1) XL\n");
print("2) L\n");
print("3) M\n");
$size = int(&io'input());
print("\nHow much would you like to pay?\n");
print("1) \$10\n");
print("2) \$12\n");
print("3) \$20\n");
print("4) \$40\n");
$p = int(&io'input());
if($p != 1)
{
	print("Really?  Coolness.\n");
	open(MAILOUT, "|mhmail mkgray autumn -subject T-Shirt_Order");
	print MAILOUT "This person says they are willing to pay more\n";
	print MAILOUT "than ten bucks for the shirt...  Hold them to it... :-)\n";
	close(MAILOUT);
}
print("\n\nOk, other relevant details...\n");
print("What's your name?\n");
$name = &io'input();
print("What's your phone number(s)?\n");
$numb = &io'input();
print("Hmmm.  Now, you need to pick it up from someone and give someone money.\n");
print("First choice would be Barbara Magnanis <autumn>, but otherwise\n");
print("Matthew Gray, Terri Iuzzolino, and Anca Mosoiu are also OK.\n");
print("If you want it mailed to you, there is a \$3 surcharge.  Please include\n");
print("your address and desire to have it mailed to you if this is the case.\n");
print("Please include any relevant comments here.\nI suppose irrelevant comments are Ok too.\n");
$comments = &io'gettext();
print("\n\nChecks should be made out to Barbara Magnanis.  Shirts will be\n");
print("available over IAP.\n");

print("\n\nOk, lets confirm this.  You want a shirt with the following specs:\n");
print("Shirt Color:  $scolor{$shirtc}\n");
print("Shirt Size :  $sizz{$size}\n");
print("Your Name  :  $name\n");
print("Your Phone :  $numb\n");
print("Is this correct?  ");
$yes = &io'input();
if($yes =~ /y/){
print("Placing order...\n");
open(MAILOUT, "|mhmail mkgray autumn -subject T-Shirt_Order");
$msg = "Name: $name\n";
$msg .= "Phone: $numb\n";
$msg .= "Shirt: $scolor{$shirtc} $sizz{$size}\n";
$msg .= "\nComments:\n";
$msg .= $comments;
	print MAILOUT "$msg";
	close(MAILOUT);
exit(0);
}
else{
	print("Oops.  Run it again.\n");
	exit(0);
}

sub sendit {
	print(STDERR "Sending...");
	open(MAILOUT, "|mhmail mkgray autumn -subject T-Shirt_Order");
	print MAILOUT "$msg";
	close(MAILOUT);
	print(STDERR "done.\n");
}
sub userdone {
	print("Enjoy looking around!\n\n");
	exit(0);
}

