' SummaryPage2_AccountClose_LogSummary
Option Explicit On
Option Strict On

' #################################################################
' Account Log Close Summary
'
' Version: 2.00 (2/09/2016)
'
' Usage: Account Close Summary for Account Log
' #################################################################

'#const "ShowOriginalValues",Boolean,True,"Show Original values column?"
'#const "ShowPostScriptValues",Boolean,False,"Show Post Script values column?"

' Constants
Private ShowOriginalValues As Boolean = True
Private ShowPostScriptValues As Boolean = False

' Objects
Private mAccountLog As finAccountLog

Public Function Main(source As Object,
                     eventId As String,
                     eventArgs As ISKeyValueList,
                     ByRef handled As Boolean,
                     ByRef returnValues As ISKeyValueList,
                     ByRef text As String) As Boolean

  ' Assume Success
  Main = True

  ' Initialise
  mAccountLog = DirectCast(source, finAccountLog)

  ' Get Event Args
  With eventArgs
  End With

  ' Get Constants
  With ScriptInfo.Constants
    ShowOriginalValues = .GetBoolean("ShowOriginalValues", ShowOriginalValues)
    ShowPostScriptValues = .GetBoolean("ShowPostScriptValues", ShowPostScriptValues)
  End With

  Select Case eventId
    Case ""
      ' Main event, i.e., return main page content
      Main = CreatePage(text)
  End Select

End Function

Private Function CreatePage(ByRef html As String) As Boolean

  Dim AccountClose As finAccountClose
  Dim sb As finHtmlSummaryPage2StringBuilder
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Get Account Close
  Success = mAccountLog.GetAccountCloseObjectFromExtendedData(AccountClose)

  If Success Then
    ' Initialise
    sb = finBL.CreateHtmlSummaryPage2StringBuilder()

    ' Initialise HTML
    With sb
      .Initialise(ScriptInfo)
      .HtmlHeaderBegin("", isefinSummaryPageStyle.Blocks)
      .HtmlHeaderEnd()
    End With

    ' Begin Section
    sb.SectionColumnsBegin()

    ' Begin Column 1
    sb.ColumnBegin("40%")

    ' Summary
    sb.BlockBegin("Summary", "", isefinSummaryPageBlockHeadingStyle.Main, False)
    sb.SummaryTablesAppend(finBL.SummaryPageStandardBlocks.AccountCloseLog_Summary(ScriptInfo, mAccountLog))
    sb.BlockEnd()

    ' End Column 1
    sb.ColumnEnd()

    ' Begin Column 2
    sb.ColumnBegin("60%")

    ' Financial Summary
    sb.BlockBegin("Financial Summary")
    sb.SummaryTablesAppend(finBL.SummaryPageStandardBlocks.AccountClose_FinancialSummary(ScriptInfo, AccountClose, ShowOriginalValues, ShowPostScriptValues))
    sb.BlockEnd()

    ' End Section
    sb.SectionColumnsEnd()

    ' Finalise HTML
    sb.HtmlFinalise()

    ' Resolve Templates
    html = sb.ToString(True)
  End If

  Return Success

End Function