<!-- #INCLUDE FILE="adminfuncs.asp" -->
<%

' Get Variables

customer = TRIM(Request ("customer"))
firstname = TRIM(Request ("firstn"))
lastname = TRIM(Request ("lastn"))

'This is so a user can access there invoice without login in 
If NOT customer = "" THEN
  userID = customer
  username = firstname
End If

' Open the Database Connection
Set Con = Server.CreateObject( "ADODB.Connection" )
Con.Open "webcaddy"
%>
<html>
<head><title>Order Confirmation and Status</title><meta name="Microsoft Border" content="b, default">
</head>
<body>
<%
' Retrieve Orders
   sqlString = "SELECT * " &_
" FROM (orders INNER JOIN (users INNER JOIN ship ON users.user_id = ship.ship_userID) " &_
" ON orders.order_shipID = ship.ship_shipID) " &_
" INNER JOIN Products ON orders.order_productID = Products.product_id " &_
" WHERE (((users.user_id)= " & userID & " )) " &_
" ORDER BY ship.ship_shipID , orders.order_productID DESC"

 IF session( "iDebugLevel" ) > 0 THEN %>
    Session Debug Level Set to:<%=session( "iDebugLevel" )%> <BR>
    sqlString: <%=sqlstring%><BR>
 <%END IF%>
<%
SET RS = Server.CreateObject( "ADODB.Recordset" )
RS.CursorType = adOpenStatic
RS.ActiveConnection = Con
RS.Open sqlString

username = TRIM( Request ( "username" ) )
%>

<form action="initial_mainpage.htm">
<table width="100%" border=0>
<tr>
  <td>
  <%If customer = "" THEN%>
    <font face="Arial" size="4"><b>Order Confirmation and Status for:   <%=username%></b>
  <%End If%>
  <p>Print for Invoice</p>
  </font>
  </td>
</tr>
</table>
</form>

<%
IF RS.EOF THEN %>


<p>&nbsp;</p>
<table border="1" width="100%">
  <tr>
    <td width="100%" bgcolor="#FFFF00">
      <p align="center">No ACTIVE Orders at this time&nbsp;</td>
  </tr>
</table>
<p></p>
<%END IF

WHILE NOT RS.EOF   %>
<%IF session( "iDebugLevel" ) > 0 THEN %>
   Session Debug Level Set to: <%=session( "iDebugLevel" )%> <BR>
   User ID: <%=userID%> <BR>
   username: <%=username%> <BR>
   firstname: <%=RS( "user_firstname" )%> <BR>
   lastname: <%=RS( "user_lastname" )%> <BR>
   discount: <%=RS( "user_discount" )%> <BR>
   username cookie: <%=Request ( "username")%> <BR>
   password: <%=password%> <BR>
   email: <%=email%> <BR>
   error: <%=error%> <BR>
   register: <%=register%> <BR>
   login: <%=login%> <BR>
   Status Code Test 3: <%=shipmentStatus(3)%> <BR>
   shipStatus = <%=RS( "ship_status")%> <BR>
   shipCharge = <%=RS( "ship_charge")%> <BR>
   paymentMethod = <%=RS( "ship_paymethod" )%> <BR>
   shipPayment = <%=RS( "ship_payment")%> <BR>
   shipPayDate = <%=RS( "ship_paydate")%> <BR>
   <%FOR EACH cookie IN request.Cookies
   Response.Write cookie & " - " & Request ( cookie ) & "<BR>"
   NEXT%>
<%END IF%>
  <p>
  <table border=1 
   cellpadding=4 cellspacing=0>
  <tr>
    <td width="757">
    <table border="1" width="100%">
      <tr>
        <td width="17%"><b>Name:</b></td>
        <td width="32%"><%=RS( "user_username" )%>&nbsp;</td>
        <td width="51%"><b>Address:</b></td>
      </tr>
      <tr>
        <td width="17%"><b>Order Date:</b></td>
        <td width="32%"><%=RS( "order_entrydate" )%>&nbsp;</td>
        <td width="51%" rowspan="5">
        	<%=RS( "user_username" )%><br>
          <%=RS( "user_street" )%><br>
	       <%=RS( "user_city" )%> ,  <%=RS( "user_State" )%>       <%=RS( "user_zip" )%><br>
          <b><%=RS( "user_country" )%></b></td>
      </tr>
      <tr>
        <td width="17%"><b>Pay Date:</b></td>
        <td width="32%">
           <% IF isDATE( RS( "ship_paydate" ) ) THEN %>
	        <%=RS( "ship_paydate" )%>
	        <% ELSE %>NOT Payed<% END IF %>
        </td>
      </tr>
      <tr>
        <td width="17%"><b>Ship Date:</b></td>
        <td width="32%">	
           <% IF isDATE( RS( "ship_shipped" ) ) THEN %>
	        <%=RS( "ship_shipped" )%>
	        <% ELSE %>NOT Shipped<% END IF %>
        </td>
      </tr>
      <tr>
        <td width="17%">&nbsp;<b>Email:</b></td>
        <td width="32%"><%=RS( "user_email" )%>&nbsp;</td>
      </tr>
      <tr>
        <td width="17%"><b>STATUS:</b></td>
        <td width="32%"><b><%=shipmentStatus(RS( "ship_status"))%></b>&nbsp;</td>
      </tr>
    </table>
  </tr>
  <tr>
    <td width="757">
    <table border="1" width="100%">
      <tr>
        <td width="25%"><b>Product:</b></td>
        <td width="25%"><b>Qty</b></td>
        <td width="25%"><b>Price</b></td>
        <td width="25%"><b>Total</b></td>
      </tr>
      <%currentShipment=RS( "ship_shipID" )
      orderTotal=0
      nextShipment = "FALSE"
      shipStatus = RS( "ship_status")
      shipCharge = RS( "ship_charge")
      payment = RS( "ship_payment" )
      paymentMethod = RS( "ship_paymethod" )
      shipPayment = RS( "ship_payment")
      shipNotes = RS( "ship_notes")
      shipPayDate = RS( "ship_paydate")%>
<!-- Begin PayPal Data Collection - Stops EOF Error -->
    <%first_name = RS( "user_firstname")
      last_name  = RS( "user_lastname")
      address1   = RS( "user_street")
      address2   = ""
      city       = RS( "user_city")
      state      = RS( "user_state")
      zip        = RS( "user_zip")
      discount   = RS( "user_discount") %>
<!-- End PayPal Data Collection - Stops EOF Error -->
 
      <%WHILE NOT RS.EOF AND nextShipment = "FALSE" %>
        <%IF currentShipment = RS( "ship_shipID" ) THEN %>
            <tr>
              <td width="25%"><%=RS( "product_name" )%>&nbsp;</td>
              <td width="25%"><%=RS( "order_quantity" )%>&nbsp;</td>
              <td width="25%"><%=FormatCurrency( RS( "product_price" ) )%>&nbsp;</td>
              <td width="25%"><%=FormatCurrency( RS( "order_quantity" ) * RS( "order_price" ) )%>&nbsp;</td>
            </tr>
            <%orderTotal = orderTotal + ( RS( "order_quantity" ) * RS( "order_price" ) )
            RS.MoveNext
        ELSE
            nextShipment = "TRUE"
        END IF
      WEND
        discountAmount = orderTotal * discount / 100
        orderTotal = orderTotal + charge - discountAmount
        balance = orderTotal - payment
        %>
      <%If discount > 0 then%>
      <tr>
       <td width="25%"><b>Discount  %</b></td>
        <td width="25%"><%=discount%>&nbsp;</td>
        <td width="25%"><b>Discount</b></td>
        <td width="25%"><%=FormatCurrency( discountAmount)%>&nbsp;</td>
      </tr>
      <%end if%>
        <tr>
        <td width="25%" rowspan="2"><b>Payment Method:</b></td>
        <td width="25%" rowspan="2">
        <% If balance <= 0 THEN %>
           Thanks for Payment via <%=paymentMethod%>           
        <%ELSE%>
          <%IF paymentMethod = "PayPal" THEN	%>
            <!-- Begin PayPal Logo -->
           <form action="https://www.paypal.com/cgi-bin/webscr" methd="post">
            <p align="center">
            <INPUT TYPE="hidden" NAME="cmd" VALUE="_ext-enter">
            <INPUT TYPE="hidden" NAME="redirect_cmd" VALUE="_xclick">
            <input type="hidden" name="business" value="paypal@webcaddy.com.au">
            <input type="hidden" name="item_name" value="WebCaddy - Webcam Adapter's">
            <input type="hidden" name="amount" value=<%=balance%>>
            <INPUT TYPE="hidden" NAME="first_name" VALUE="<%=first_name%>">
            <INPUT TYPE="hidden" NAME="last_name" VALUE="<%=last_name%>">
            <INPUT TYPE="hidden" NAME="address1" VALUE="<%=address1%>">
            <INPUT TYPE="hidden" NAME="address2" VALUE="<%=address2%>">
            <INPUT TYPE="hidden" NAME="city" VALUE="<%=city%>">
            <INPUT TYPE="hidden" NAME="state" VALUE="<%=state%>">
            <INPUT TYPE="hidden" NAME="zip" VALUE="<%=zip%>">
            <input type="hidden" name="return"
             value="http://webcaddy.com.au/astronew/successful_paypal.htm?shipID=<%=currentShipment%>&tab=<%=orderTotal%>">
            <input type="hidden" name="cancel_return" value="http://webcaddy.com.au/astronew/cancelled_paypal.htm">
            <input type="image" src="http://images.paypal.com/images/x-click-but02.gif" border="0" 
            name="submit" alt="Make payments with PayPal - it's fast, free and secure!" width="64" height="35" align="left">
            Click Logo to make Payment
           </form>
           <!-- End PayPal Logo -->
          <%ELSE%>
            <%IF paymentMethod = "BillPoint" THEN	%>
               A Bill Point Invoice will be emailed to you shortly
            <%ELSE%>
               Please print this page
               Then mail with your 
               check to address below.
            <%END IF%>
          <%END IF%>
        <%END IF%>
        </td>
        <td width="25%"><b>Shipping:</b></td>
        <td width="25%">
       
        <%=FormatCurrency( shipCharge)%> &nbsp;</td>
        </tr>
        <tr>
        <td width="25%"><b>Total:</b></td>
        <td width="25%"><%=FormatCurrency( orderTotal)%>&nbsp;</td>
      </tr>
        <tr>
        <td width="50%" rowspan="2" colspan="2">&nbsp;</td>
        <td width="25%">Payment</td>
        <td width="25%"><%=FormatCurrency( payment )%>&nbsp;</td>
      </tr>
        <tr>
        <td width="25%">Balance</td>
        <td width="25%"><%=FormatCurrency( balance )%>&nbsp;</td>
      </tr>
     </table>
     </tr>
	 </table>
	 <p>
     <b>     Shipping Notes:</b> <%=shipNotes%></p> <br>

     <%If NOT customer = "" THEN%>
       <br>
       Thanks for ordering from us. We hope <span lang="en-au">you </span>enjoy using our products<br><br>
       Regards,<br>
       Steven<br>
     <%Else
       IF paymentMethod = "Check" THEN	%>
         <p>
         <b>     Mail Check to:</b></p>
         <p>&nbsp;&nbsp;&nbsp; Mogg Adapter<br>
         &nbsp;&nbsp;&nbsp; P.O. Box 594<br>
         &nbsp;&nbsp;&nbsp; Kaysville  UT  84037<br>
         &nbsp;&nbsp;&nbsp; USA</p>
         <p>&nbsp;&nbsp;&nbsp; Email: Steven@webcaddy.com.au
       <%END IF%>
     <%End If%>
<%WEND%>
     &nbsp;
</p>
<hr>

<!--webbot bot="Include" U-Include="footer.htm" TAG="BODY" -->