#!/usr/bin/perl -T select( STDOUT ); $| = 1; print "Content-type: text/html\n\n"; require "./lib_cgi.pl"; &read_form; print &template_header(); &display_order_form; print &template_footer(); exit( 0 ); #---------------------------------------------------------------------- # USAGE: # &display_order_form(); # # DESCRIPTION: # Allow this routine to be called multiple times. Each time, the # internal CGI state is displayed. # sub display_order_form { print join( "\n", "
", ); $FORM{qty_tape_cardio} = $FORM{qty_tape_cardio} + 0; $FORM{qty_tape_essence1} = $FORM{qty_tape_essence1} + 0; $FORM{qty_tape_essence2} = $FORM{qty_tape_essence2} + 0; $FORM{qty_tape_essence12} = $FORM{qty_tape_essence12} + 0; $FORM{qty_poster} = $FORM{qty_poster} + 0; $FORM{qty_tshirts} = $FORM{qty_tshirts} + 0; $FORM{qty_book_shortform} = $FORM{qty_book_shortform} + 0; $FORM{qty_tape_shortform} = $FORM{qty_tape_shortform} + 0; $FORM{qty_tape_longform} = $FORM{qty_tape_longform} + 0; unless ($FORM{PRINT}) { print join( "\n", "

Instructions:

", "Please:", "
    ", "
  1. Fill out this form", "
  2. Press submit", "
  3. Print", "
  4. Send a check or money order (in US Dollars) to:", "
    ", "

    Dr. Weng's Kung Fu School

    ", " P.O. Box 1221
    ", " Cupertino, CA 95015
    ", " USA
    ", "
    ", "
", ); } else { print join( "\n", "

Instructions:

", "Please:", "
    ", ); if ($FORM{country} eq "United States" && $FORM{state} eq "") { print join( "\n", "
  1. Select a state", ); } if ($FORM{name} eq "" || $FORM{addr} eq "" || $FORM{city} eq "" || $FORM{country} eq "") { print join( "\n", "
  2. Complete order", "
  3. Recalculate totals", ); } print join( "\n", "
  4. Print", "
  5. Send a check or money order (in US Dollars) to:", "
    ", "

    Dr. Weng's Kung Fu School

    ", " P.O. Box 1221
    ", " Cupertino, CA 95015
    ", " USA
    ", "
    ", "
", ); } print join( "\n", "
", "", "", "", "", " ", " ", "", "", " ", " ", "", "", " ", " ", "", "", " ", " ", "", "", " ", " ", "", ); if ($FORM{country} eq "United States") { print join( "\n", "", " ", " ", "", ); } else { print join( "\n", "", " ", " ", "", ); } print join( "\n", "", " ", " ", "", " ", " ", "", "

Customer Shipping Information

Name:
Address 1:
Address 2:
Address 3:
City:
State/Province:", "", "
State/Province:
Country:", " ", "
Email:
", "", "", "", " ", " ", " ", " ", "", "", " ", " ", " ", " ", "", "", " ", " ", " ", " ", "", "", " ", " ", " ", " ", "", "", " ", " ", " ", " ", "", "", " ", " ", " ", " ", "", "", " ", " ", " ", " ", "", "", " ", " ", " ", " ", "", "", " ", " ", " ", " ", "", ); my( $subtotal ) = &subtotal( 0, 29.95, $FORM{qty_tape_cardio}, 29.95, $FORM{qty_tape_essence1}, 29.95, $FORM{qty_tape_essence2}, 54.95, $FORM{qty_tape_essence12}, 54.95, $FORM{qty_poster}, 54.95, $FORM{qty_tshirts}, 18.95, $FORM{qty_book_shortform}, 32.95, $FORM{qty_tape_shortform}, 29.95, $FORM{qty_tape_longform} ); my( $ca_tax ) = &ca_tax( $subtotal, $FORM{country}, $FORM{state} ); my( $shipping ) = &shipping( $subtotal, $FORM{country} ); my( $total ) = &total( $subtotal, $ca_tax, $shipping ); print join( "\n", "", " ", " ", "", ); if ($ca_tax > 0) { print join( "\n", "", " ", " ", "", ); } if ($FORM{country} eq "United States" || $FORM{country} eq "") { print join( "\n", "", " ", " ", "", ); } else { print join( "\n", "", " ", " ", "", ); } print join( "\n", "", " ", " ", "", "
ItemQuantityAmountTotal
Cardio Tai-Chi 101 VideotapeUS\$29.95" . &amount( 29.95, $FORM{qty_tape_cardio} ) . "
Essence of Practical Tai-Chi Vol. 1US\$29.95" . &amount( 29.95, $FORM{qty_tape_essence1} ) . "
Essence of Practical Tai-Chi Vol. 2US\$29.95" . &amount( 29.95, $FORM{qty_tape_essence2} ) . "
Set of Essence of Practical Tai-Chi (Vol. 1 & 2)US\$54.95" . &amount( 54.95, $FORM{qty_tape_essence12} ) . "
Tai-Chi Monkey Companion PosterUS\$7.95" . &amount( 7.95, $FORM{qty_poster} ) . "
Tai-Chi Monkey Workout ShirtsUS\$10.00" . &amount( 10.00, $FORM{qty_tshirts} ) . "
Chang Style T'ai-Chi Ch'uan Modified Short Form TextbookUS\$18.95" . &amount( 18.95, $FORM{qty_book_shortform} ) . "
Chang Style T'ai-Chi Ch'uan Modified Short Form VideotapeUS\$32.95" . &amount( 32.95, $FORM{qty_tape_shortform} ) . "
Chang Style T'ai-Chi Ch'uan Long Form VideotapeUS\$29.95" . &amount( 29.95, $FORM{qty_tape_longform} ) . "
Subtotal" . &amount( $subtotal, 1 ) . "
California Sales Tax (8.25%)" . &amount( $ca_tax, 1 ) . "
Shipping" . &amount( $shipping, 1 ) . "
Shipping (includes US\$10.00 for international shipping)" . &amount( $shipping, 1 ) . "
Grand Total US" . &amount( $total, 1 ) . "
", "", "
", "
\n", ); } sub amount { my( $amt ) = shift; my( $qty ) = shift || 0; my( $cents ) = sprintf( "%d", (100 * $qty * $amt) ); my( $retval ) = sprintf( "\$%3.2f", ($cents / 100) ); if ($retval =~ /\.\d$/) { $retval .= "0"; } return( $retval ); } sub subtotal { my( @items ) = @_; my( $subtotal ) = 0; my( $i ) = 0; my( $price ); my( $qty ); my( $even ) = 0; foreach $item (@items) { $even = ($even) ? 0 : 1; if ($even) { $qty = $item; $subtotal += $price * $qty; $qty = 0; $price = 0; } else { $price = $item; } } return( $subtotal ); } sub ca_tax { my( $subtotal ) = shift; my( $country ) = shift; my( $state ) = shift; my( $ca_tax ) = 0; if ($country eq "United States") { if ($state eq "California") { $ca_tax = $subtotal * 0.0825; } } return( $ca_tax ); } sub shipping { my( $subtotal ) = shift; my( $country ) = shift; my( $shipping ) = $subtotal * 0.1; unless ($country eq "United States") { if ($subtotal > 0) { $shipping += 10; } } return( $shipping ); } sub total { my( $subtotal ) = shift; my( $ca_tax ) = shift; my( $shipping ) = shift; my( $total ) = $subtotal + $ca_tax + $shipping; return( $total ); }