<% Option Explicit %> <% ' Opens a new connection to the database Function OpenDatabaseConnection( _ ) ' New connection object Dim NewDatabaseConnection ' Connect to the database Set NewDatabaseConnection = Server.CreateObject( "ADODB.Connection" ) NewDatabaseConnection.ConnectionString = Application( "CenturionCounsel_ConnectionString" ) NewDatabaseConnection.Open Set OpenDatabaseConnection = NewDatabaseConnection End Function %> <% ' Names of roles users may log in as Const AdvisorRoleName = "Advisor" Const GuestRoleName = "Guest" Const TeleconferenceRoleName = "Teleconference" Const AdminRoleName = "Admin" ' Returns the user name of the current user. Function GetCurrentUserName( _ ) GetCurrentUserName = Session( "MM_Username" ) End Function ' Returns the role name of the current user. Function GetCurrentRoleName( _ ) GetCurrentRoleName = Session( "MM_RoleName" ) End Function ' Validates that the current user is logged in and in the correct role. If the user is not logged ' in or not in the correct role, he/she is redirected to a login page. Sub AuthorizeCurrentUser( _ RoleName, _ LoginPage _ ) Dim MM_grantAccess Dim MM_qsChar Dim MM_referrer ' *** Restrict Access To Page: Grant or deny access to this page MM_grantAccess=false ' If the user is logged in, If GetCurrentUserName( ) <> "" Then ' and if the user is in the correct role for this page, If GetCurrentRoleName( ) = RoleName Then ' The user is grnated access MM_grantAccess = true End If End If ' If the user is not allowed to view this page, If Not MM_grantAccess Then ' Redirect the user to the appropriate login page MM_qsChar = "?" If (InStr(1,LoginPage,"?") >= 1) Then MM_qsChar = "&" MM_referrer = Request.ServerVariables("URL") if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString() LoginPage = LoginPage & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer) Response.Redirect(LoginPage) End If End Sub %> <% ' This file contains all the code needed to access the client statements on the web site. ' Base directory under which all advisor's directories can be found Const BaseAdvisorVirtualDirectory = "advisor_central/advisors" ' Gets the statements for the current user Function GetStatementsForCurrentUser( _ ) GetStatementsForCurrentUser = GetStatementsForUser( GetCurrentUserName( ) ) End Function ' Gets the statement for a particular user Function GetStatementsForUser( _ Username _ ) ' Database connection Dim DatabaseConnection ' Command to get the user's directory name Dim GetDirectoryCommand ' Recordset that contains the user's directory name Dim UserDirectoryRecordset ' Virtual directory for the current user Dim AdvisorVirtualDirectory ' File system object Dim FileSystem ' File system folder that contains the advisor's files Dim AdvisorFileFolder ' Statement array to return Dim Statements( ) ' Current number of statements in the array Dim StatementCount ' Statement file Dim StatementFile ' New statement data object Dim NewStatement ' Index into the statement array Dim StatementIndex ' Get the user's virtual directory that holds the files Set DatabaseConnection = OpenDatabaseConnection( ) Set GetDirectoryCommand = Server.CreateObject( "ADODB.Command" ) GetDirectoryCommand.ActiveConnection = DatabaseConnection GetDirectoryCommand.CommandType = adCmdText GetDirectoryCommand.CommandText = "SELECT directory " & _ "FROM advisors " & _ "WHERE username = ?" Set UserDirectoryRecordset = GetDirectoryCommand.Execute( , Array( Username ) ) AdvisorVirtualDirectory = BaseAdvisorVirtualDirectory & "/" & UserDirectoryRecordset( "directory" ) UserDirectoryRecordset.Close DatabaseConnection.Close ' Find the directory that contains all the user's files Set FileSystem = Server.CreateObject( "Scripting.FileSystemObject" ) Set AdvisorFileFolder = FileSystem.GetFolder( Server.MapPath( AdvisorVirtualDirectory ) ) ' Loop through all the files StatementCount = 0 For Each StatementFile In AdvisorFileFolder.Files ' Create a new statement object for the file Set NewStatement = New Statement NewStatement.Name = StatementFile.Name NewStatement.VirtualPath = AdvisorVirtualDirectory & "/" & StatementFile.Name NewStatement.Date = GetStatementDate( StatementFile ) ' This sets the size to the next highest KB size NewStatement.SizeKb = -Int( -StatementFile.Size / 1024 ) ' Add the statement to the array ReDim Preserve Statements( StatementCount ) 'Set Statements( StatementCount ) = NewStatement ' Loop through the elements already in the sorted array For StatementIndex = StatementCount To 0 Step -1 ' If we are at the beginning of the array, If StatementIndex = 0 Then ' Put the new statement there Set Statements( StatementIndex ) = NewStatement ' If the new statement is older than the next one in the sorted array, ElseIf NewStatement.Date < Statements( StatementIndex - 1 ).Date Then ' Place the new statement after it Set Statements( StatementIndex ) = NewStatement Exit For ' If the new statement is newer than the next one, Else ' Shift the next one up a position Set Statements( StatementIndex ) = Statements( StatementIndex - 1 ) End If Next StatementCount = StatementCount + 1 Next ' Clean up Set AdvisorFileFolder = Nothing Set FileSystem = Nothing Set UserDirectoryRecordset = Nothing Set GetDirectoryCommand = Nothing Set DatabaseConnection = Nothing GetStatementsForUser = Statements End Function ' Determines the date of the statement file Function GetStatementDate( _ StatementFile _ ) ' Regular expression to parse the file names Dim FileNameParser ' Values parsed from the filename Dim CapturedValues ' Year parsed from the file name Dim StatementYear ' Quarter parsed from the file name Dim StatementQuarter ' Month parsed from the file name Dim StatementMonth ' Day parsed from the file name Dim StatementDay Set FileNameParser = New RegExp ' Looking for files in the format "__QTR_*.pdf" FileNameParser.Pattern = "^.*(1ST|2ND|3RD|4TH).*(\d{4}).*$" If FileNameParser.Test( StatementFile.Name ) Then Set CapturedValues = FileNameParser.Execute( StatementFile.Name ) StatementYear = CapturedValues.Item( 0 ).SubMatches.Item( 1 ) StatementQuarter = CInt( Left( CapturedValues.Item( 0 ).SubMatches( 0 ), 1 ) ) GetStatementDate = DateAdd( "d", -1, DateSerial( StatementYear, StatementQuarter * 3 + 1, 1 ) ) Else ' Looking for files in the format "_--.pdf" FileNameParser.Pattern = "^.*(\d{4})\-(\d{2})\-(\d{2}).*$" If FileNameParser.Test( StatementFile.Name ) Then Set CapturedValues = FileNameParser.Execute( StatementFile.Name ) StatementYear = CapturedValues.Item( 0 ).SubMatches.Item( 0 ) StatementMonth = CapturedValues.Item( 0 ).SubMatches.Item( 1 ) StatementDay = CapturedValues.Item( 0 ).SubMatches.Item( 2 ) GetStatementDate = DateSerial( StatementYear, StatementMonth, StatementDay ) Else ' Default to the date the file was uploaded GetStatementDate = StatementFile.DateCreated End If End If ' Clean up Set CapturedValues = Nothing Set FileNameParser = Nothing End Function ' Creates a new statement directory for a user Function CreateStatementDirectory( _ UserName _ ) ' File system object Dim FileSystem ' Base bile system folder that contains the advisor's files Dim BaseAdvisorFileFolder ' Name of the new directory Dim DirectoryName ' Number used to make the directory name unique Dim DirectoryNumber ' Unexpected error information Dim ErrorNumber Dim ErrorSource Dim ErrorDescription Dim ErrorHelpFile Dim ErrorHelpContext ' Find the directory that contains the advisors' directories Set FileSystem = Server.CreateObject( "Scripting.FileSystemObject" ) Set BaseAdvisorFileFolder = FileSystem.GetFolder( Server.MapPath( BaseAdvisorVirtualDirectory ) ) ' Start with a directory the same name as the user name DirectoryName = UserName DirectoryNumber = 0 ' Don't exit when there are errors creating the directory On Error Resume Next ' While the directory cannot be created, BaseAdvisorFileFolder.SubFolders.Add( DirectoryName ) While Err.Number = 58 ' Try a different directory name DirectoryNumber = DirectoryNumber + 1 DirectoryName = UserName & DirectoryNumber Err.Clear BaseAdvisorFileFolder.SubFolders.Add( DirectoryName ) WEnd ' If there was an error besides the directory not being created, If Err.Number <> 0 Then ' Save the error information ErrorNumber = Err.Number ErrorSource = Err.Source ErrorDescription = Err.Description ErrorHelpFile = Err.HelpFile ErrorHelpContext = Err.HelpContext Else ErrorNumber = 0 End If On Error GoTo 0 ' If there was an unexpected error while error trapping was turned off, If ErrorNumber <> 0 Then ' Re-raise the error Err.Raise ErrorNumber, ErrorSource, ErrorDescription, ErrorHelpFile, ErrorHelpContext End If ' Clean up Set BaseAdvisorFileFolder = Nothing Set FileSystem = Nothing CreateStatementDirectory = DirectoryName End Function ' Data about each statement Class Statement ' Name of the file Public Name ' Web path to the file Public VirtualPath ' Date/time the statement was created Public Date ' Size of the statement Public SizeKb ' Returns the HTML of a link to this statement Public Function ToLink( _ ) ToLink = "" & Server.HTMLEncode( Name ) & " (" & SizeKb & "Kb)" End Function End Class %> <% ' Statement for the current user Dim ClientStatements ' Next statement in the list Dim ClientStatement ' Current year that statements are being listed for Dim CurrentYear AuthorizeCurrentUser AdvisorRoleName, "advisoradvantage.htm" ClientStatements = GetStatementsForCurrentUser( ) %> Welcome to Centurion Counsel, Inc.
Log Out WelcomeOur CompanyOur ServicesOur CommitmentOur PublicationsContact Us
For more information:

 

Client Statements

Important: In order to view your statements, you must have the most current Adobe Acrobat Reader software installed. This software is free, and can be downloaded by clicking here.

<% ' Initialize to "no years displayed" CurrentYear = 0 ' Loop through all the statements For Each ClientStatement In ClientStatements ' If this statement's year is not the current year being displayed, If Year( ClientStatement.Date) <> CurrentYear Then ' If there is a year before this one, If CurrentYear <> 0 Then ' End its paragraph %>

<% End If ' Set the year begin displayed CurrentYear = Year( ClientStatement.Date) ' Start a new paragraph with a year header graphic %>

<% End If ' Display a link to the statement %>
<%= ClientStatement.ToLink( ) %> <% Next ' If there were years displayed, If CurrentYear <> 0 Then ' End the last year's paragraph %>

<% End If %>

 


If you are having problems viewing your files, you can try downloading them to your computer by Right-Clicking on the file, and choosing "Save Target as", and saving the file to your hard drive. You can then locate the file on your hard drive, and double click on it to open it. You will still need Adobe Acrobat Reader to view the file. If you still continue to have problems, please click here to email us, and a representative will respond promptly.


Back To Advisor Central