<!-- #INCLUDE FILE="bkitadovbs.inc" -->
<!-- #INCLUDE FILE="bkitutillib.asp" -->

<!-- #include file="bkitonline.asp" -->

<%
' If member ref not already present then call login
' page and stop rest of this page
ref 		= trim(request("ref"))
if ref = "" then
%>
	<!-- #include file="bkitlogin.asp" -->
<%
response.end
end if
%>

<%
' Open Database Connection
Set Con = Server.CreateObject( "ADODB.Connection" )
%>

<!-- #INCLUDE FILE="connection.inc" -->

<%
Set memberrs = Server.CreateObject( "ADODB.Recordset" )
memberrs.ActiveConnection = Con
sqlString = _
"SELECT 		ref, caddressee, cwebpass, cemail1, cemail2 " &_
"from 			bkitmembers " &_
"where 		ref = '" & request("ref") & "'"
memberrs.Open sqlString

Set carttotrs = Server.CreateObject( "ADODB.Recordset" )
carttotrs.ActiveConnection = Con
sqlString = _
"select 	 sum( slots1 * iif(cpaytype='D',depdue1,amtdue1))+" &_
	   		"sum( slots2 * iif(cpaytype='D',depdue2,amtdue2))+" &_
	   		"sum( slots3 * iif(cpaytype='D',depdue3,amtdue3))+" &_
	   		"sum( slots4 * iif(cpaytype='D',depdue4,amtdue4)) as paytoday," &_
	   		"sum( slots1 * amtdue1)+" &_
	   		"sum( slots2 * amtdue2)+" &_
	   		"sum( slots3 * amtdue3)+" &_
	   		"sum( slots4 * amtdue4) as paytotal " &_	   
"from 		 bkitcart " &_
"where 	 bkitcart.ref = '" & ref & "'"
carttotrs.Open sqlString

Set defaultsrs = Server.CreateObject( "ADODB.Recordset" )
defaultsrs.ActiveConnection = Con
sqlstring = "select * from bkitdefaults"
defaultsrs.open sqlstring

' ---------------------------------------------------------------
'    Calculate total due adding in credit card fee if applicable
' ---------------------------------------------------------------
lnpaytoday = clng(carttotrs("paytoday"))

'restore previous values in case error occurred
cremember = trim(request.form("cremember"))
ccardtype 	= trim(request.form("ccardtype"))
ccardno 	= trim(request.form("ccardno"))
cyexpires 	= trim(request.form("cyexpires"))
cmexpires 	= trim(request.form("cmexpires"))
cyfrom 	= trim(request.form("cyfrom"))
cmfrom 	= trim(request.form("cmfrom"))
cissue 	= trim(request.form("cissue"))
ccardname = trim(request.form("ccardname"))
ccredit	= trim(request.form("ccredit"))
ccreditdets = trim(request.form("ccreditdets"))

'if values blank then try to restore from cookies
if ccardtype = "" then
	ccardtype = request.cookies("ctype")
end if
if ccardno = "" then
	ccardno = request.cookies("cno")
end if
if cyexpires = "" then
	cyexpires = request.cookies("cyexp")
end if
if cmexpires = "" then
	cmexpires = request.cookies("cmexp")
end if
if cyfrom = "" then
	cyfrom = request.cookies("cyfrom")
end if
if cmfrom = "" then
	cmfrom = request.cookies("cmfrom")
end if
if cissue = "" then
	cissue = request.cookies("cissue")
end if
if ccardname = "" then
	ccardname = request.cookies("ccardname")
end if
%>
 
<head>
<title>Checkout</title>
<style><% defstyles %></style>
</head>

<center>
<h1>Checkout</h1>
<p>
<% if carttotrs.eof then %>
 <font color="#FF0000"><b>Your shopping basket is currently empty</b></font>&nbsp;
<p>
<% else %>

	<form method="POST" action="bkitcheckout2.asp" >
	  <table border=1 cellpadding=4 cellspacing=0 width="60%" height="281">
	    <tr>
	      <td width="100%" bgcolor="#6BB6B6" colspan="2" align="center" height="19"><b><%= trim(memberrs("caddressee")) %></b></td>
	    </tr>
		    <tr>
	   		  	<td width="30%" bgcolor="#FFF0E1" height="19"><b>Email(s)</b></td>
		      	<td width="70%" bgcolor="#FFF0E1" height="19"><%= memberrs("cemail1") %>
					<% if len(trim(memberrs("cemail2"))) > 0 then %>, <%= memberrs("cemail2") %><% end if%></td>
		    </tr>

		    <tr>
	   		   	<td width="30%" bgcolor="#FFF0E1" height="19"><b>Pay Today</b></td>
		    	<td width="70%" bgcolor="#FFF0E1" height="19"><b><%= formatcurrency(lnpaytoday,2) %></b>
		    	<% if csng(defaultsrs("ycardfee")) > 0 then %> (plus <%= formatcurrency(defaultsrs("ycardfee")) %> for card payments)<% end if %></td>
		    </tr>

		    <tr>
	   		   	<td width="30%" bgcolor="#FFF0E1" height="19"><b>Amt By Credit Note / Voucher</b></td>
		    	<td width="70%" bgcolor="#FFF0E1" height="19"><b><input type="text" name="ccredit" size="8" value="<%= server.htmlencode(ccredit)%>"> Details <input type="text" name="ccreditdets" size="20" value="<%= server.htmlencode(ccreditdets)%>"></b></td>
		    </tr>

		    
		    <tr>
	   		   <td width="30%" bgcolor="#FFF0E1" height="23"><b>Card Type</b></td>
	      		<td width="70%" bgcolor="#FFF0E1" height="23"><select size="1" name="ccardtype" value="<%= server.htmlencode(ccardtype)%>">
	          <option <%if server.htmlencode(ccardtype) = "Visa" then%>selected<%end if%>>Visa</option>
	          <option <%if server.htmlencode(ccardtype) = "Mastercard" then%>selected<%end if%>>Mastercard</option>
	          <option <%if server.htmlencode(ccardtype) = "Switch" then%>selected<%end if%>>Switch</option>
	              </select></td>
		    </tr>
		    <tr>
	   		   <td width="30%" bgcolor="#FFF0E1" height="23"><b>Card No</b></td>
		      <td width="70%" bgcolor="#FFF0E1" height="23"><input type="text" name="ccardno" size="19" value="<%= server.htmlencode(ccardno)%>"></td>
	   		 </tr>
		    <tr>
	   		   <td width="30%" bgcolor="#FFF0E1" height="23"><b>Expires</b></td>
	      		<td width="70%" bgcolor="#FFF0E1" height="23"><input type="text" name="cmexpires" size="2" value="<%= server.htmlencode(cmexpires)%>">/
	              <input type="text" name="cyexpires" size="2" value="<%= server.htmlencode(cyexpires)%>"></td>
		    </tr>
	    <tr>
	      <td width="30%" bgcolor="#FFF0E1" height="23"><b>Issue No</b></td>
	      <td width="70%" bgcolor="#FFF0E1" height="23"><input type="text" name="cissue" size="2" value="<%= server.htmlencode(cissue)%>">
	        <font color="#FF0000">(Switch Only)</font></td>
	    </tr>
	    <tr>
	      <td width="30%" bgcolor="#FFF0E1" height="23"><b>From Date</b></td>
	      <td width="70%" bgcolor="#FFF0E1" height="23"><input type="text" name="cmfrom" size="2" value="<%= server.htmlencode(cmfrom)%>">/
	        <input type="text" name="cyfrom" size="2" value="<%= server.htmlencode(cyfrom)%>">  <font color="#FF0000">(Switch Only)</font></td>
	    </tr>
	    <tr>
	      <td width="30%" bgcolor="#FFF0E1" height="23"><b>Name On Card</b></td>
	      <td width="70%" bgcolor="#FFF0E1" height="23"><input type="text" name="ccardname" size="19" value="<%= server.htmlencode(ccardname)%>"></td>
	    </tr>
	    <tr>
	      <td width="100%" bgcolor="#FFF0E1" height="23" colspan="2">
		      <p align="center"><input type="checkbox" name="cremember" value="ON">Remember
              Details
              <p align="center">
              <input type="submit" value="Confirm Booking(s)" name="B1">
              </p>
		   </td>
	    </tr>
	  </table>
		<input name="namttoday" type="hidden" value=<%= carttotrs("paytoday") %> >
		<input name="ref"     	type="hidden" value=<%= ref %> >
	</form>
	
<% end if %>

<table border="0" width="40%">
    <tr>
    <td width="33%"><% showbutton "Show Basket", 	getpath("web") + "/bkitaddcart.asp" %></td>
    <td width="34%"><% showbutton "Home", 			getpath("home") %></td>
    </tr>
</table>
</center>

<% pagefooter %>
<% Con.Close %>