
<%
sqlString = _
"SELECT 		ref, caddressee, cwebpass " &_
"from 			bkitmembers " &_
"where 		ref = '" & request("ref") & "'"
memberrs.Open sqlString

sqlString = _
"SELECT 		bkitcart.ref, bkitcart.eventno, cpaytype, slots1, slots2, " &_
"				slots3, slots4, book1name, book2name, book3name, book4name, " &_
"				amtdue1, amtdue2, amtdue3, amtdue4, depdue1, depdue2, depdue3, " &_
"				depdue4, bkitevents.desc, bkitevents.location, " &_
"				bkitevents.fromdate " &_
"FROM 			bkitcart " &_
"left join 	bkitevents on bkitevents.eventno = bkitcart.eventno " &_
"WHERE 		bkitcart.ref = '" & ref & "'"
cartrs.Open sqlString

topaytotal = 0
topaytoday = 0
%>

<head>
<title>Shopping Cart</title>
<style><% defstyles %></style>
</head>

<center>
<h1>Shopping Basket</h1>
<p>

<table width="100%" border=1 cellspacing=0>
<tr>
  <td bgcolor="#6BB6B6" width="90%" colspan="5" align="center">
  <b><%= trim(memberrs("caddressee")) %></b></td>
</tr>

<tr>
  <td bgcolor="#000080" width="40%"><font color="#FFFFFF"><b>Event</b></font></td>
  <td bgcolor="#000080" width="10%"><font color="#FFFFFF"><b>Date</b></font></td>
  <td bgcolor="#000080" width="20%"><font color="#FFFFFF"><b>Slots</b></font></td>
  <td bgcolor="#000080" width="10%" align="right"><font color="#FFFFFF"><b>Cost</b></font></td>
  <td bgcolor="#000080" width="10%">&nbsp;</td>
</tr>

<%
WHILE NOT cartrs.EOF 
	'detail all slots for event
	slotsall = ""
	if cartrs("slots1") > 0 then slotsall = slotsall & cartrs("slots1") & " " & trim(cartrs("book1name")) & ", "
	if cartrs("slots2") > 0 then slotsall = slotsall & cartrs("slots2") & " " & trim(cartrs("book2name")) & ", "
	if cartrs("slots3") > 0 then slotsall = slotsall & cartrs("slots3") & " " & trim(cartrs("book3name")) & ", "
	if cartrs("slots4") > 0 then slotsall = slotsall & cartrs("slots4") & " " & trim(cartrs("book4name")) & ", "
	' remove last comma and space
	slotsall = left(slotsall, len(slotsall)-2)
	
	'add up all total cost for event
	costall = (clng(cartrs("slots1")) * clng(cartrs("amtdue1"))) + _
				(clng(cartrs("slots2")) * clng(cartrs("amtdue2"))) + _
				(clng(cartrs("slots3")) * clng(cartrs("amtdue3"))) + _
				(clng(cartrs("slots4")) * clng(cartrs("amtdue4")))
				
	'add up what paying today for each event
	if cartrs("cpaytype") = "D" then
		costtoday = 	(clng(cartrs("slots1")) * clng(cartrs("depdue1"))) + _
						(clng(cartrs("slots2")) * clng(cartrs("depdue2"))) + _
						(clng(cartrs("slots3")) * clng(cartrs("depdue3"))) + _
						(clng(cartrs("slots4")) * clng(cartrs("depdue4")))
	else
		costtoday = costall
	end if
	
	'maintain grand payment totals
	topaytotal = topaytotal + costall
	topaytoday = topaytoday + costtoday
	%>

	<tr>
	  <td width="40%" bgcolor="#FFF0E1">
	  <%= trim(cartrs("desc")) %>
	  <% if len(trim(cartrs("location"))) > 0 then %>
			<%= ", " & cartrs("location") %>
	  <% end if %>  	
	  </td>
	  <td width="10%" bgcolor="#FFF0E1"><%= trim(cartrs("fromdate")) %></td>
	  <td width="20%" bgcolor="#FFF0E1"><%= slotsall %></td>
	  <td width="10%" bgcolor="#FFF0E1" align="right"><%= formatcurrency(costall,2) %></td>
	  <td width="10%" bgcolor="#FFF0E1" valign="middle" align="center">

      <form method="POST" action=<%= "bkitaddcart.asp?ref=" & cartrs("ref") & "&eventno=" & cartrs("eventno") %>><p>
        <input type="submit" value="Delete" name="B1">
		 <input name="ref"     type="hidden" value=<%= ref %> >
      </form>
	  </td>
	</tr>

	<%
	cartrs.MoveNext
WEND
%>

</table><p>
&nbsp;

<table border="1" cellspacing=0 width="60%" cellpadding="3">
   <tr>
     <td width="25%" bgcolor="#000080">
     	<p align="center"><font color="#FFFFFF"><b>Total To Pay</b></font></p></td>
     <td width="25%" bgcolor="#FFF0E1" align="right"><%= formatcurrency(topaytotal,2) %></td>
     <td width="25%" bgcolor="#000080" align="left">  
       <p align="center"><font color="#FFFFFF"><b>Pay Today</b></font></p></td>
     <td width="25%" bgcolor="#FFF0E1" align="right">  <%= formatcurrency(topaytoday,2) %></td>
    </tr>
</table>

<p>
&nbsp;

<table border="0" width="60%">
  <tr>
    <td width="33%"><% showbutton "Book Another", 	getpath("web") + "/bkiteventavail.asp" %></td>
    <td width="33%"><% showbutton "Go To Checkout",	getpath("ssl") + "/bkitcheckout.asp" %></td>
    <td width="33%"><% showbutton "Home", 			getpath("home") %></td>
  </tr>
</table>
</center>

<% pagefooter %>