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

	Command = Request.Querystring("Command")


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


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


	Sub TotalBalance()
		Dim r, s, h, b
%>
		<table border=0 align=center class=Header cellspacing=1 cellpadding=2 width=200>
		<tr>
			<td align=center colspan=2>
				Total Balance
			</td>
		</tr>
		<tr bgcolor=white class=PageText>
			<td>Cash received</td>
			<td align=right>
<%
			Set rs = DBC.Execute("SELECT SUM(Invest) FROM PayIns")

			If rs.EOF Then
				r = 0
			Else
				r = FormatNumber(Str2Float(rs(0)), 3)
			End If

			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(Payout) FROM Payouts WHERE BatchNumber > 0")

			If rs.EOF Then
				s = 0
			Else
				s = FormatNumber(Str2Float(rs(0)), 3)
			End If

			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(Payout) FROM Payouts WHERE BatchNumber <= 0")

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

			Response.Write "$" & h
			rs.Close
%>
			</td>
		</tr>
<%
		b = FormatNumber(r - s - h, 3)
%>
		<tr bgcolor=<%= IIf(b < 0, "FF8800", "00FF00") %> class=PageText>
			<td>Balance</td>
			<td align=right>
				$<%= b %>
			</td>
		</tr>
		</table>
<%
	End Sub
%>