' SummaryPage2_AccountInterestPayouts_ItemSummary
Option Explicit On
Option Strict On

' #################################################################
' Summary of an Interest Payout in the Process Interest Payouts wizard

' Version: 2.01 (14/05/2021)

' Usage: Process Interest Payouts wizard, Payments page.
' #################################################################

' Properties
Private mAccountInterestPayout As finAccountInterestPayout
Private mAccountInterestPayouts As finAccountInterestPayouts
Private mIndex As Integer

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
  mAccountInterestPayouts = DirectCast(source, finAccountInterestPayouts)
  mIndex = eventArgs.GetInteger("Index", -1)
  If mIndex <> -1 Then mAccountInterestPayout = mAccountInterestPayouts(mIndex)

  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 Ok As Boolean
  Dim sb As finHtmlSummaryPage2StringBuilder

  ' Assume Success
  Ok = True

  ' 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("50%")

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

  ' End Column 1
  sb.ColumnEnd()

  ' Begin Column 2
  sb.ColumnBegin()

  ' Payment Details
  sb.BlockBegin("Payment Details", "", isefinSummaryPageBlockHeadingStyle.Normal, True)
  sb.SummaryTablesAppend(finBL.SummaryPageStandardBlocks.BankingDetails_Summary2(ScriptInfo, mAccountInterestPayout.BankingDetails))
  sb.BlockEnd()

  ' End Column 2
  sb.ColumnEnd()

  ' End Section
  sb.SectionColumnsEnd()

  ' Finalise HTML
  sb.HtmlFinalise()

  ' Resolve Templates
  html = sb.ToString(True)

  Return Ok

End Function