<% Option Explicit %>
<!--#include file="config.asp"-->
<!--#include file="common.asp"-->
<%
	PageHeader

	If Session("IsAdminLogin") Then
		AdminMenu
	Else
		UserLogin
		Response.End
	End If


	Command = Request.Querystring("Command")

	Response.Write "<br>"
	Balance
	Response.Write "<br>"
	PreferedBets

	Response.Write "</body>"
	Response.Write "</html>"


	Sub Balance()
		Dim r, s, h, b
%>
		<table border=0 align=center bgcolor=FFEFB2 cellspacing=1 cellpadding=2 width=200>
		<tr class=PageText>
			<td align=center colspan=2>
				<font color=black>Balance</font>
			</td>
		</tr>
		<tr bgcolor=white class=PageText>
			<td>
				Cash Received
			</td>
			<td align=right>
<%
			Set rs = DBC.Execute("SELECT SUM(Cash) FROM Payments WHERE To = " & MyEGold)

			r = FormatNumber(Str2Float(rs(0)), 2)

			Response.Write "$" & r
			rs.Close
%>
			</td>
		</tr>
		<tr bgcolor=white class=PageText>
			<td>
				Cash Sent
			</td>
			<td align=right>
<%
			Set rs = DBC.Execute("SELECT SUM(Cash) FROM Payments WHERE BatchNumber > 0 AND [From] = " & MyEGold)

			s = FormatNumber(Str2Float(rs(0)), 2)

			Response.Write "$" & s
			rs.Close
%>
			</td>
		</tr>
		<tr bgcolor=white class=PageText>
			<td>
				Have to send
			</td>
			<td align=right>
<%
			Set rs = DBC.Execute("SELECT SUM(Cash) FROM Payments WHERE BatchNumber = 0 AND [From] = " & MyEGold)

			h = FormatNumber(Str2Float(rs(0)), 2)

			Response.Write "$" & h
			rs.Close
%>
			</td>
		</tr>
		<tr bgcolor=white class=PageText>
			<td>
				<font size=4>Balance</font>
			</td>
			<td align=right>
<%
			b = FormatNumber(r - s - h, 2)

			If b < 0 Then
				Response.Write "<font size=4 color=red>"
			Else
				Response.Write "<font size=4 color=green>"
			End If

			Response.Write "$" & b
			Response.Write "</font>"
%>
			</td>
		</tr>
		</table>
<%
	End Sub


	Sub PreferedBets()
%>
		<table border=0 align=center bgcolor=FFEFB2 cellspacing=1 cellpadding=2 width=200>
		<tr class=PageText>
			<td align=center colspan=2>
				<font color=black>Prefered Bets</font>
			</td>
		</tr>
<%
		Set rs = DBC.Execute("SELECT Bets.Bet, COUNT(*) AS Count " & _
				"FROM Bets INNER JOIN Payments ON Bets.Bet = Payments.Cash " & _
				"GROUP BY Bets.Bet")

		Do While Not rs.EOF
%>
		<tr bgcolor=white class=PageText>
			<td align=right>
				$ <%= FormatNumber(rs("Bet"), 4) %>
			</td>
			<td align=right>
				<%= rs("Count") %> time(s)
			</td>
		</tr>
<%
			rs.MoveNext
		Loop
%>
		</table>
<%
	End Sub
%>