<%@ LANGUAGE="VBSCRIPT" %>
<% Response.Buffer = True %>

<%
'***********************************************************************
'   System     :   ASPBanner Unlimited Version 8.0						
'   Author     :   Christopher Williams of CJWSoft www.CJWSoft.com		
'																		
'                         COPYRIGHT NOTICE								
'																		
'   See attached Software License Agreement								
'																		
'   (c) Copyright 2000 - 2005 by CJWSoft.			 All rights reserved
'***********************************************************************
%>

<!--#INCLUDE FILE="config_inc.asp"-->
<!--#INCLUDE FILE="check_user_inc.asp"-->

<%
' Done to fix an odd bug when you log into this page for the 1st time
' For some reason some of the data would not be displayed
If Session("BeenHere") <> "Yes" Then
	Session("BeenHere") = "Yes"
	Response.Redirect("bannerstats.asp")
End If
%>

<HTML>
<HEAD>
<TITLE><% =Application("App_Name") %></TITLE>

<script language="JavaScript">
<!--
function OpenPopup(URL, width, height) {
	var now = new Date();
	var remote = window.open(URL, "popup" + now.getTime(), "width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,resizable=1,status=1,menubar=0,scrollbars=0");
//	if(navigator.appVersion.indexOf("MSIE 3") < 0)
//		remote.focus();
}

function OpenScrollingPopup(URL, width, height) {
	var now = new Date();
	var remote = window.open(URL, "popup" + now.getTime(), "width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,resizable=1,status=1,menubar=0,scrollbars=yes");
//	if(navigator.appVersion.indexOf("MSIE 3") < 0)
//		remote.focus();
}

defaultStatus = "";
// -->
</script>

</HEAD>
<BODY <%=BodyTag%>>

<!--#INCLUDE FILE="header_inc.asp"-->

<br>

<%
Banner_ID = Request("Banner_ID")
User_ID = Session("User_ID")
RowCount = 0
	
If Session("Company_Name") <> "" Then
	NameDisplayed = Session("Company_Name")
Else
	NameDisplayed = Session("First_Name") & " " & Session("Last_Name")
End If
%>

<div align="center">
  <center>
  <table border="0" cellpadding="2" cellspacing="2">
    <tr>
      <td valign="top"><br>
	  <center><b><font face="Arial" size="3">Banner Statistics For<br><% =NameDisplayed %></font></b></center>
	  </td>
      <td valign="top">

<br>
<%
Function FileFound(FileName)
 Dim FileObj
 FileFound = True
 Set fs = CreateObject("Scripting.FileSystemObject")
 On Error Resume Next
 Set FileObj = fs.OpenTextFile(FileName, 1, False, 0)
 If Err.Number <> 0 Then
  Err.Clear
  FileFound = False
  Exit Function
 End If
 FileObj.Close
 Set fs = Nothing
End Function
	
Set ConnBanner = Server.CreateObject("ADODB.Connection")
ConnBanner.Open Application("BannerConnectionString")
Set CmdBannerTemp = Server.CreateObject("ADODB.Command")
Set CmdListBanners = Server.CreateObject("ADODB.Recordset")
	
CmdBannerTemp.CommandText = "SELECT Banners.* FROM Banners WHERE (User_ID = " & User_ID & ")"
CmdBannerTemp.CommandType = 1
Set CmdBannerTemp.ActiveConnection = ConnBanner
CmdListBanners.Open CmdBannerTemp, , 0, 1
%>

<% If CmdListBanners.EOF Then %>
<font size="2" face="Arial">
You Have No Banners In The System Under This Login
<a href="log_off.asp">Click Here</a> And Log Off...
<br>
Then Return To This Page As a Valid Banner User
</font>
<% Response.End %>
<% End If %>

<%
	If Not CmdListBanners.EOF Then
		ShowTableEnd = True
%>
<div align="center">
  <center>
  <table cellPadding="2" border="0" bgcolor="#C0C0C0">

      <tr>
        <td align="center" colspan ="6" bgcolor="#FFFFFF"><font size="2" face="Arial">Click on Banner Name for detailed stats.</font></td>
      </tr>

      <tr>
        <td bgcolor="#FFFFFF"><font size="2" face="Arial"><b>Banner Name</b></font></td>
        <td bgcolor="#FFFFFF"><font size="2" face="Arial"><b>End Date</b></font></td>
        <td bgcolor="#FFFFFF"><font size="2" face="Arial"><b>Imp Limit</b></font></td>
	    <td bgcolor="#FFFFFF"><font size="2" face="Arial"><b>Impressions</b></font></td>
	    <td bgcolor="#FFFFFF"><font size="2" face="Arial"><b>Clicks</b></font></td>
	    <td bgcolor="#FFFFFF"><font size="2" face="Arial"><b>ClickThru</b></font></td>
      </tr>

<%	Else %>
	<p align="center"><b><font color="#FF0000" face="Arial" size="3">None</font></b></p>
<%	End If %>





<% While Not CmdListBanners.EOF %>

<%
If RowCount = 2 Then
RowCount = 0
End If
	
If RowCount = 0 Then
	Cellbgcolor = "#F3F3EB"
Else
	Cellbgcolor = "#FFFFFF"
End If
	
RowCount = RowCount + 1
	

	Set ASPBannerDBConn = Server.CreateObject("ADODB.Connection")
	ASPBannerDBConn.Open Application("BannerConnectionString")
		
	ImpressionsSQL = "SELECT SUM(Banner_Impressions) AS TotalImpressions, SUM(Banner_Clicks) AS TotalClicks FROM Banner_Stats WHERE (Banner_ID = " & CmdListBanners("Banner_ID") & ")"
	Set CmdRetrieveImpressions = ASPBannerDBConn.Execute(ImpressionsSQL)
		

		

%>

      <tr>
        <td valign="top" bgcolor="<% = Cellbgcolor %>"><font size="1" face="Arial"><a href ="#" onClick="OpenScrollingPopup('stats_window_user.asp?Banner_ID=<% =CmdListBanners("Banner_ID") %>&TotalImpressions=<% =CmdRetrieveImpressions("TotalImpressions") %>&TotalClicks=<% =CmdRetrieveImpressions("TotalClicks") %>', 600, 600)"><% =CmdListBanners("Banner_Name") %></a></font></td>
		<td valign="top" bgcolor="<% = Cellbgcolor %>"><font size="1" face="Arial"><%= CmdListBanners("Banner_End_Date") %></font></td>
		<td valign="top" bgcolor="<% = Cellbgcolor %>"><font size="1" face="Arial"><%= CmdListBanners("Banner_Impressions_Purchased") %></font></td>
		<td valign="top" bgcolor="<% = Cellbgcolor %>"><font size="1" face="Arial"><%= CmdRetrieveImpressions("TotalImpressions") %></font></td>
		<td valign="top" bgcolor="<% = Cellbgcolor %>"><font size="1" face="Arial"><%= CmdRetrieveImpressions("TotalClicks") %></font></td>

		<td valign="top" bgcolor="<% = Cellbgcolor %>"><font size="1" face="Arial">
		<% If CmdRetrieveImpressions("TotalImpressions") > 0 AND CmdRetrieveImpressions("TotalClicks") > 0 then Response.Write(FormatPercent((CmdRetrieveImpressions("TotalClicks")/CmdRetrieveImpressions("TotalImpressions")),1)) %>
		</font></td>

      </tr>

<% CmdListBanners.MoveNext %>
<% Wend

	CmdRetrieveImpressions.Close
	Set CmdRetrieveImpressions = Nothing

%>

<% If ShowTableEnd Then %>
  </table>
  </center>
</div>
<% End If%>



	  </td>
    </tr>
  </table>
  </center>
</div>

<br><br><br><br><br><br><br><br>
<!--#INCLUDE FILE="footer_inc.asp"-->

</BODY>
</HTML>