<?xml version="1.0" encoding="utf-8"?>
  <finScript version="1.00" exportedUtcDate="2024-08-19T01:16:12.0000000">
    <CreatedUserId>ADMIN</CreatedUserId>
    <CreatedUtcDate>2021-07-05T03:54:27.7200000</CreatedUtcDate>
    <UpdatedUserId>ADMIN</UpdatedUserId>
    <UpdatedUtcDate>2024-08-19T01:15:52.5930000</UpdatedUtcDate>
    <ScriptId>ACCOUNTSUSPENSION</ScriptId>
    <Description>Account Suspension Details</Description>
    <ScriptType>HtmlWidget</ScriptType>
    <Active>true</Active>
    <AllowUI>false</AllowUI>
    <Bookmarks />
    <Category />
    <Code>' HtmlWidget_AccountSuspensionDetails
Option Explicit On
Option Strict On

' #################################################################
' Account Suspension Details wizard HTML Widget
'
' Version: 1.06 (19/08/2024)
'
' Usage: System-defined HTML Widget
' #################################################################
' Version        Date  User     Job       Description
' -------  ----------  -------  --------  -------------------------
'    1.05  05/07/2021  ISS                Updated
'    1.06  19/08/2024  ISS      J033983   Added additional Suspension Permission Keys
' #################################################################

' Constants
Private Const FORM_KEY As String = "AccountSuspensionDetails"

' Common Parameters
Private mAccountId As String
Private mClear As Boolean

' Objects
Private mCombinedParameters As ISKeyValueList
Private mParameters As ISKeyValueList
Private mStartupParameters As ISKeyValueList

Public Function Main(eventId As String,
                     parametersJson As String,
                     startUpParametersJson As String,
                     hostingContext As isefinHtmlWidgetHostingContext,
                     requestInfo As finScriptRequestInfo,
                     ByRef returnValue As String) As Boolean

  ' Assume Success
  Main = True

  ' Get Parameters
  mParameters = finBL.CreateKeyValueList()
  mParameters.FromSimpleJsonString(parametersJson)
  mStartupParameters = finBL.CreateKeyValueList()
  mStartupParameters.FromSimpleJsonString(startUpParametersJson)

  ' Get Combined Parameters (Startup Parameters updated with event Parameters)
  mCombinedParameters = mStartupParameters.Clone()
  mCombinedParameters.UpdateFromKeyValueList(mParameters, True)

  ' Get Common Parameters
  With mCombinedParameters
    mAccountId = .GetString("AccountId")
    mClear = .GetBoolean("Clear")
  End With

  ' Handle Events
  Select Case eventId
    Case ""
      ' Main event, i.e., return initial HTML content (excluding html and body tags)
      returnValue = ScriptInfo.TemplateText

    Case "Finish"
      ' Finish wizard
      Main = Finish(parametersJson, requestInfo, returnValue)

    Case "GetInitialisationInfo"
      ' Get Initialisation Information required for this wizard
      Main = GetInitialisationInfo(returnValue)

    Case "WizardValidate"
      ' Validate wizard page
      Main = WizardValidate(parametersJson, returnValue)

    Case Else
      finBL.Error.ErrorBeginFormat("Unhandled event '{0}'.", eventId)
      Main = False
  End Select

End Function

''' &lt;summary&gt;
'''  Get Initialisation Information required for this wizard.
''' &lt;/summary&gt;
Public Function GetInitialisationInfo(ByRef response As String) As Boolean

  Dim AccountSuspensionUpdate As finAccountSuspensionUpdate
  Dim FormInitialisationInfo As FormInitialisationInfo
  Dim Message As String
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Validate
  If Len(mAccountId) = 0 Then
    Success = False
    finBL.Error.ErrorBegin("Account Id not specified.")
  ElseIf finBL.CurrentUserInformation.IsAccountFilteredOut(mAccountId) Then
    Success = False
    finBL.Error.ErrorBegin("You do not have permission to view this record.")
  ElseIf finBL.Database.IsReadOnly Then
    Success = False
    finBL.Error.ErrorBegin("Access denied. Database is Read-Only.")
  End If

  ' Create Account Suspension Update object
  If Success Then
    Success = CreateAccountSuspensionUpdate(mAccountId, Nothing, AccountSuspensionUpdate)
  End If

  ' Further Validations
  If Success Then
    If Not AccountSuspensionUpdate.Account.CanUpdateSuspensions(Message) Then
      Success = False
      finBL.Error.ErrorBegin(Message)
    End If
  End If
  
  ' Get Initialisation Info
  If Success Then
    FormInitialisationInfo = New FormInitialisationInfo()
    With FormInitialisationInfo
      ' Record
      .RecordId = AccountSuspensionUpdate.Account.AccountId
      .RecordDescription = AccountSuspensionUpdate.Account.Name

      ' General
      .DateReview = finBL.HtmlWidgetUtilities.GetNullableJsonUtcDateFromDatabaseDate(AccountSuspensionUpdate.DateReview)

      .SuspendCreditReporting = AccountSuspensionUpdate.SuspendCreditReporting
      .SuspendDefaultInterest = AccountSuspensionUpdate.SuspendDefaultInterest
      .SuspendDefaultFees = AccountSuspensionUpdate.SuspendDefaultFees
      .SuspendDocuments = AccountSuspensionUpdate.SuspendDocuments
      .SuspendFacilityFee = AccountSuspensionUpdate.SuspendFacilityFee
      .SuspendInterest = AccountSuspensionUpdate.SuspendInterest
      .SuspendOther = AccountSuspensionUpdate.SuspendOther
      .SuspendOtherCaption = finBL.Settings.AccountSuspendOtherCaptionResolved
      .SuspendOverdueRules = AccountSuspensionUpdate.SuspendOverdueRules
      .SuspendStandardTransactions = AccountSuspensionUpdate.SuspendStandardTransactions
      .SuspendWithdrawals = AccountSuspensionUpdate.SuspendWithdrawals

      ' Initialise Controls             
      .ShowSuspendCreditReporting = finBL.CurrentUser.Permissions.Allow("Account.SuspensionUpdate.CreditReporting") AndAlso finBL.Settings.AddOns.CreditReporting      
      .ShowSuspendDefaultFees = finBL.CurrentUser.Permissions.Allow("Account.SuspensionUpdate.Interest")
      .ShowSuspendDefaultInterest = finBL.CurrentUser.Permissions.Allow("Account.SuspensionUpdate.Interest")
      .ShowSuspendDocuments = finBL.CurrentUser.Permissions.Allow("Account.SuspensionUpdate.Documents")
      .ShowSuspendFacilityFee = finBL.CurrentUser.Permissions.Allow("Account.SuspensionUpdate.Interest") AndAlso AccountSuspensionUpdate.Account.AccountType.FacilityFeeChargeBasis &lt;&gt; isefinFacilityFeeChargeBasis.None      
      .ShowSuspendInterest = finBL.CurrentUser.Permissions.Allow("Account.SuspensionUpdate.Interest")
      .ShowSuspendOther = finBL.CurrentUser.Permissions.Allow("Account.SuspensionUpdate.Other")
      .ShowSuspendOverdueRules = finBL.CurrentUser.Permissions.Allow("Account.SuspensionUpdate.OverdueRules")
      .ShowSuspendStandardTransactions = finBL.CurrentUser.Permissions.Allow("Account.SuspensionUpdate.StandardTransactions")
      .ShowSuspendWithdrawals = finBL.CurrentUser.Permissions.Allow("Account.SuspensionUpdate.Withdrawals")      
      
      .ShowInterestRestartDate = .ShowSuspendInterest AndAlso AccountSuspensionUpdate.OriginalSuspendInterest     
      .ShowStandardTransactionsRestartFromDate = .ShowSuspendStandardTransactions AndAlso AccountSuspensionUpdate.OriginalSuspendStandardTransactions
      .EnableSuspendWithdrawals = .ShowSuspendWithdrawals AndAlso (AccountSuspensionUpdate.SuspendWithdrawals OrElse finBL.AccountTypes(AccountSuspensionUpdate.Account.AccountTypeId).OptionAllowWithdrawals)
      
      ' Set Controls
      Select Case AccountSuspensionUpdate.Account.AccountClass
        Case isefinAccountClass.Deposit
          .ShowSuspendDefaultInterest = False
          .ShowSuspendDefaultFees = False
          .ShowSuspendFacilityFee = False
          .ShowSuspendOverdueRules = False
          .ShowSuspendCreditReporting = False

        Case isefinAccountClass.Disbursement
          .ShowSuspendInterest = False
          .ShowInterestRestartDate = False
          .ShowSuspendDefaultInterest = False
          .ShowSuspendDefaultFees = False
          .ShowSuspendFacilityFee = False
          .ShowSuspendOverdueRules = False
          .ShowSuspendCreditReporting = False

        Case isefinAccountClass.LoanFR, isefinAccountClass.LoanFT, isefinAccountClass.LoanRC
          If AccountSuspensionUpdate.Account.AccountType.OverLimitFeeChargeBasis = isefinOverLimitFeeChargeBasis.None Then
            .SuspendDefaultFeesCaption = "Default Fees"
          Else
            .SuspendDefaultFeesCaption = "Default and Over Limit Fees"
          End If

        Case Else
          Success = False
          finBL.Error.ErrorBeginFormat("Unhandled Account Class '{0}'", AccountSuspensionUpdate.Account.AccountClassText)
      End Select

      ' Clear?
      .Clear = mClear

      ' Configuration
      .PromptOnCommit = finBL.CloudConnectFunctions.CloudConnectSettings.PromptOnCommit
    End With
  End If

  ' Response
  If Success Then
    Success = finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(FormInitialisationInfo, response)
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Create a finAccountSuspensionUpdate object from Web Service properties.
''' &lt;/summary&gt;
''' &lt;returns&gt;
'''  A Boolean value indicating success.
''' &lt;/returns&gt;
Private Function CreateAccountSuspensionUpdate(accountId As String,
                                               parameters As WizardFinishParameters,
                                               ByRef accountSuspensionUpdate As finAccountSuspensionUpdate) As Boolean

  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Initialise
  accountSuspensionUpdate = finBL.CreateAccountSuspensionUpdate()

  ' Load Account
  Success = accountSuspensionUpdate.AccountLoad(accountId)

  ' Update
  If Success AndAlso parameters IsNot Nothing Then
    With accountSuspensionUpdate
      .SuspendDocuments = parameters.SuspendDocuments
      .SuspendOther = parameters.SuspendOther
      .SuspendStandardTransactions = parameters.SuspendStandardTransactions
      .SuspendWithdrawals = parameters.SuspendWithdrawals

      ' Date Review
      .DateReview = finBL.HtmlWidgetUtilities.GetDatabaseDateFromJsonUtcDate(parameters.DateReview)

      ' Date Restart Standard Transactions
      If accountSuspensionUpdate.OriginalSuspendStandardTransactions Then
        .StandardTransactionsRestartFromDate = finBL.HtmlWidgetUtilities.GetDatabaseDateFromJsonUtcDate(parameters.StandardTransactionsRestartFromDate)
      End If

      Select Case AccountSuspensionUpdate.Account.AccountClass
        Case isefinAccountClass.Deposit
          .SuspendInterest = parameters.SuspendInterest

          ' Date Restart Interest
          If accountSuspensionUpdate.OriginalSuspendInterest Then
            .InterestRestartFromDate = finBL.HtmlWidgetUtilities.GetDatabaseDateFromJsonUtcDate(parameters.InterestRestartFromDate)
          End If

        Case isefinAccountClass.Disbursement

        Case isefinAccountClass.LoanFR, isefinAccountClass.LoanFT, isefinAccountClass.LoanRC
          .SuspendDefaultInterest = parameters.SuspendDefaultInterest
          .SuspendDefaultFees = parameters.SuspendDefaultFees
          .SuspendInterest = parameters.SuspendInterest
          .SuspendOverdueRules = parameters.SuspendOverdueRules

          If finBL.Settings.AddOns.CreditReporting Then
            .SuspendCreditReporting = parameters.SuspendCreditReporting
          End If
          If AccountSuspensionUpdate.Account.AccountType.FacilityFeeChargeBasis &lt;&gt; isefinFacilityFeeChargeBasis.None Then
            .SuspendFacilityFee = parameters.SuspendFacilityFee
          End If

          ' Date Restart Interest
          If accountSuspensionUpdate.OriginalSuspendInterest Then
            .InterestRestartFromDate = finBL.HtmlWidgetUtilities.GetDatabaseDateFromJsonUtcDate(parameters.InterestRestartFromDate)
          End If

        Case Else
          Success = False
          finBL.Error.ErrorBeginFormat("Unhandled Account Class '{0}'", AccountSuspensionUpdate.Account.AccountClassText)
      End Select
    End With
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Finish, i.e., Update.
''' &lt;/summary&gt;
''' &lt;param name="parametersJson"&gt;
'''  A JSON formatted WizardFinishDetails object.
''' &lt;/param&gt;
Private Function Finish(parametersJson As String,
                        requestInfo As finScriptRequestInfo,
                        ByRef returnValue As String) As Boolean

  Dim AccountSuspensionUpdate As finAccountSuspensionUpdate
  Dim obj As Object
  Dim Success As Boolean
  Dim Warning As String
  Dim WizardFinishParameters As WizardFinishParameters

  ' Assume Success
  Success = True

  ' Parse Parameters
  If finBL.Runtime.WebUtilities.DeserialiseJsonStringToObject(parametersJson, GetType(WizardFinishParameters), obj) Then
    WizardFinishParameters = DirectCast(obj, WizardFinishParameters)
  Else
    Success = False
  End If

  ' Create Account Suspension Update object
  If Success Then
    Success = CreateAccountSuspensionUpdate(mAccountId, WizardFinishParameters, AccountSuspensionUpdate)
  End If
  
  ' Execute
  If Success Then
    If WizardFinishParameters.Clear Then
      Success = AccountSuspensionUpdate.ExecuteClear(Warning)
    Else 
      Success = AccountSuspensionUpdate.ExecuteSet()
    End If    
  End If

  ' Finalise
  If Success Then
    Success = finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(New WizardFinishDetails(Warning), returnValue)
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Validate a Wizard page.
''' &lt;/summary&gt;
''' &lt;param name="parametersJson"&gt;
'''  A JSON formatted object containing information required to validate a Wizard page.
''' &lt;/param&gt;
''' &lt;param name="returnValue"&gt;
'''  A JSON object; "true" if validation passed, otherwise, information as to why validation failed.
''' &lt;/param&gt;
Private Function WizardValidate(parametersJson As String,
                                ByRef returnValue As String) As Boolean

  Dim Data As Object
  Dim DateReview As Date
  Dim FailedControlId As String
  Dim FailedMessage As String
  Dim PageId As String
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Get Parameters
  ' NOTE: Use the module mCombinedParameters since this contains Startup and event Parameters in a single Key/Value List
  With mCombinedParameters
    PageId = .GetString("PageId")
  End With

  ' Validate Page
  Select Case PageId
    Case "General"
      ' General      
      If mCombinedParameters.Exists("DateReview") Then
        DateReview = mCombinedParameters.GetDatabaseDateFromJsonUtcDate("DateReview")
        If DateReview &lt;&gt; Nothing AndAlso DateReview &lt; finBL.TimeZoneFunctions.GetCurrentDatabaseDate() Then
          FailedMessage = String.Format("Date must be on or after {0}", finBL.FormatDateLong(finBL.TimeZoneFunctions.GetCurrentDatabaseDate()))
          FailedControlId = "dateReview"
        End If
      End If
  End Select

  ' Finalise
  If Success Then
    Success = finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(New WizardValidateResponse(Data, FailedMessage, FailedControlId), returnValue)
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Wizard Initialisation Information.
''' &lt;/summary&gt;
Public Class FormInitialisationInfo

  ' Record
  Public RecordId As String
  Public RecordDescription As String

  ' Enable Controls
  Public EnableSuspendWithdrawals As Boolean

  ' Show Controls
  Public ShowInterestRestartDate As Boolean
  Public ShowStandardTransactionsRestartFromDate As Boolean
  Public ShowSuspendCreditReporting As Boolean
  Public ShowSuspendDefaultFees As Boolean
  Public ShowSuspendDefaultInterest As Boolean
  Public ShowSuspendDocuments As Boolean
  Public ShowSuspendFacilityFee As Boolean
  Public ShowSuspendInterest As Boolean
  Public ShowSuspendOther As Boolean
  Public ShowSuspendOverdueRules As Boolean
  Public ShowSuspendStandardTransactions As Boolean
  Public ShowSuspendWithdrawals As Boolean

  ' Suspension Items
  Public SuspendCreditReporting As Boolean
  Public SuspendDefaultFees As Boolean
  Public SuspendDefaultFeesCaption As String
  Public SuspendDefaultInterest As Boolean
  Public SuspendDocuments As Boolean
  Public SuspendFacilityFee As Boolean
  Public SuspendInterest As Boolean
  Public SuspendOther As Boolean
  Public SuspendOtherCaption As String
  Public SuspendOverdueRules As Boolean
  Public SuspendStandardTransactions As Boolean
  Public SuspendWithdrawals As Boolean

  ' Dates
  Public DateReview As Date?

  ' Configuration
  Public PromptOnCommit As Boolean
  Public Clear As Boolean

End Class

''' &lt;summary&gt;
'''  Validation details.
''' &lt;/summary&gt;
Public Class WizardValidateResponse

  Public Data As Object
  Public FailedMessage As String
  Public FailedControlId As String

  Public Sub New(data As Object,
                 failedMessage As String,
                 failedControlId As String)

    Me.Data = data
    Me.FailedMessage = failedMessage
    Me.FailedControlId = failedControlId

  End Sub

End Class


''' &lt;summary&gt;
'''  Finish Parameters.
''' &lt;/summary&gt;
Public Class WizardFinishParameters

  ' Suspension Items
  Public SuspendCreditReporting As Boolean
  Public SuspendDefaultFees As Boolean
  Public SuspendDefaultInterest As Boolean
  Public SuspendDocuments As Boolean
  Public SuspendFacilityFee As Boolean
  Public SuspendInterest As Boolean
  Public SuspendOther As Boolean
  Public SuspendOverdueRules As Boolean
  Public SuspendStandardTransactions As Boolean
  Public SuspendWithdrawals As Boolean

  ' Dates
  Public DateReview As Date?
  Public InterestRestartFromDate As Date?
  Public StandardTransactionsRestartFromDate As Date?

  ' Other
  Public Clear As Boolean
  
End Class


''' &lt;summary&gt;
'''  Finish details.
''' &lt;/summary&gt;
Public Class WizardFinishDetails

  Public Warning As String
  
  Public Sub New(warning As String)
    
    Me.Warning = warning
    
  End Sub

End Class</Code>
    <Language>VisualBasic</Language>
    <Notes>System defined HTML Widget.

Used as a finPOWER Connect Cloud compatible version of the form "AccountSuspensionDetails".</Notes>
    <PermissionKeyExecute />
    <ReferenceLinq>false</ReferenceLinq>
    <RunWithoutPrompts>false</RunWithoutPrompts>
    <TemplateText>&lt;div id="frmMain" class="is-widget-content" style="visibility:hidden"&gt;

  &lt;style&gt;
    .original label { color:darkorange; font-weight:bold; }
  &lt;/style&gt;

  &lt;!-- Form Header --&gt;
  &lt;header&gt;
    &lt;div class="header"&gt;&lt;/div&gt;
    &lt;div class="summary"&gt;&lt;/div&gt;
    &lt;!-- Tabs --&gt;
    &lt;div id="tabWizard" class="is-tabs"&gt;
      &lt;ul&gt;
        &lt;li tabId="General" tooltipText="Enter Suspension Details for the Account."&gt;Account Suspension Details&lt;/li&gt;
      &lt;ul&gt;
    &lt;/div&gt;
  &lt;/header&gt;

  &lt;!-- Pages --&gt;
  &lt;div class="is-widget-form-body"&gt;
    &lt;!-- General --&gt;
    &lt;div id="pageGeneral"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:6em" /&gt;
          &lt;col/&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblAccount"&gt;Account&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboRecord"&gt;Account:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboRecord" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblItemsToSuspend"&gt;Select the items to Suspend&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkInterest" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td class="indent1" colspan="2"&gt;&lt;label for="dateInterestRestartDate"&gt;Restart charging from:&lt;/label&gt; &lt;input id="dateInterestRestartDate"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th class="indent1" colspan="2"&gt;&lt;input id="chkDefaultInterest" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th class="indent1" colspan="2"&gt;&lt;input id="chkDefaultFees" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th class="indent1" colspan="2"&gt;&lt;input id="chkFacilityFee" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkStandardTransactions" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td class="indent1" colspan="2"&gt;&lt;label for="dateStandardTransactionsRestartFromDate"&gt;Restart from:&lt;/label&gt; &lt;input id="dateStandardTransactionsRestartFromDate"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkWithdrawals" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkDocuments" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOverdueRules" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkCreditReporting" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkSuspendOther" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblReview"&gt;Enter a Review Date for the Suspended items&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="dateReview"&gt;Review:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="dateReview"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;

  &lt;/div&gt;


  &lt;!-- Form Footer --&gt;
  &lt;footer&gt;
    &lt;button id="cmdCancel" class="is-button"&gt;Cancel&lt;/button&gt;
    &lt;button id="cmdBack" class="is-button"&gt;&amp;lt; Back&lt;/button&gt;
    &lt;button id="cmdNext" class="is-button"&gt;Next &amp;gt;&lt;/button&gt;
    &lt;button id="cmdFinish" class="is-button ok"&gt;Finish&lt;/button&gt;
  &lt;/footer&gt;

&lt;/div&gt;


&lt;script&gt;
// Properties
var mRecord;

// Controls
var C = {
  // General
  lblAccount: null,
  cboRecord: null,

  chkInterest: null,
  dateInterestRestartDate: null,
  chkDefaultInterest: null,
  chkDefaultFees: null,
  chkFacilityFee: null,
  chkStandardTransactions: null,
  dateStandardTransactionsRestartFromDate: null,
  chkWithdrawals: null,
  chkDocuments: null,
  chkOverdueRules: null,
  chkCreditReporting: null,
  chkSuspendOther: null,

  dateReview: null
}

// Form
var frmMain;
var tabWizard;

// Wizard Buttons
var cmdCancel;
var cmdBack;
var cmdNext;
var cmdFinish;

// ==========
// Initialise
// ==========
$(function () {

  // --------
  // Controls
  // --------
  // General
  C.lblAccount = widget.UI.Label("lblAccount", {});
  C.cboRecord = widget.UI.DBCombo("cboRecord", {
    autoReadOnly: false,
    readOnly: true,
    showDropdown: false,
    width: widget.UI.FIELD_WIDTH_CODE_10
  });

  C.chkInterest= widget.UI.CheckBox("chkInterest", {
    caption: "Interest",
    onChange: chkInterest_Change,
  });
  C.dateInterestRestartDate = widget.UI.DateBox("dateInterestRestartDate", {});
  C.chkDefaultInterest = widget.UI.CheckBox("chkDefaultInterest", {
    caption: "Default Interest",
    onChange: pageGeneral_Refresh,
  });
  C.chkDefaultFees = widget.UI.CheckBox("chkDefaultFees", {
    caption: "Default and Over Limit Fees",
    onChange: pageGeneral_Refresh,
  });
  C.chkFacilityFee = widget.UI.CheckBox("chkFacilityFee", {
    caption: "Facility Fee",
    onChange: pageGeneral_Refresh,
  });
  C.chkStandardTransactions = widget.UI.CheckBox("chkStandardTransactions", {
    caption: "Standard Transactions",
    onChange: pageGeneral_Refresh,
  });
  C.dateStandardTransactionsRestartFromDate = widget.UI.DateBox("dateStandardTransactionsRestartFromDate", {});
  C.chkWithdrawals = widget.UI.CheckBox("chkWithdrawals", {
    caption: "Withdrawals (including Transfers)",
    onChange: pageGeneral_Refresh,
  });
  C.chkDocuments = widget.UI.CheckBox("chkDocuments", {
    caption: "Documents",
    onChange: pageGeneral_Refresh,
  });
  C.chkOverdueRules = widget.UI.CheckBox("chkOverdueRules", {
    caption: "Overdue Rules",
    onChange: pageGeneral_Refresh,
  });
  C.chkCreditReporting = widget.UI.CheckBox("chkCreditReporting", {
    caption: "Comprehensive Credit Reporting",
    onChange: pageGeneral_Refresh,
  });
  C.chkSuspendOther = widget.UI.CheckBox("chkSuspendOther", {
    caption: "Other",
    onChange: pageGeneral_Refresh,
  });

  C.lblReview = widget.UI.Label("lblReview", {});
  C.dateReview = widget.UI.DateBox("dateReview", {
    allowBlank: false,
  });

  // Create Widget form
  // NOTE: Hide by default for a cleaner startup
  frmMain = new widget.UI.Form("frmMain", { captionWidth: "9em", textboxWidth: "20em", visible: false });

  // Create Tabs
  tabWizard = new widget.UI.Tabs("tabWizard", { style: "wizard" });

  // Handle Wizard Buttons
  cmdCancel = $("#cmdCancel");
  cmdBack = $("#cmdBack");
  cmdNext = $("#cmdNext");
  cmdFinish = $("#cmdFinish");
  cmdCancel.click(tabWizard_Cancel);
  cmdBack.click(function() { tabWizard_Move(-1); });
  cmdNext.click(function() { tabWizard_Move(1); });
  cmdFinish.click(function() { Form_ExecuteAction("Finish"); });

  // Reset
  Form_Reset();
});

// ==========
// Reset Form
// ==========
function Form_Reset() {
  // Defaults

  // Set Tab
  tabWizard.SelectedTabId("General");

  // Resize
  Form_Resize();

  // Load Record (i.e., initialise wizard)
  Record_Load();
}

// ===========
// Load Record
// ===========
function Record_Load() {
  // Initialise
  mRecord = null;

  // Hide content
  frmMain.Visible(false);

  // Block UI
  widget.UI.Block("Initialising, please wait...");

  // Load Initialisation details
  widget.GetString("GetInitialisationInfo", {},
    // Success
    function (data) {
      mRecord = JSON.parse(data);
      Fields_Load();

      // Clear
      if (mRecord.Clear) {
        var message = "Are you sure you want to clear Suspension Details for this Account?\n\nNOTE: Click 'Cancel' to enter other information prior to clearing.";
        widget.UI.MsgBoxConfirm(message, { heading: "Clear Suspension Details" }, Form_ExecuteAction_FinishPost, function() { mRecord.Clear = false; });
      }
    },

    // Fail
    function (message) {
      widget.UI.MsgBoxAlert("fail: " + message);
      Fields_Load();
    }
  );
}

// ===========
// Load Fields
// ===========
function Fields_Load() {
  if (mRecord) {
    // General
    C.cboRecord.RefreshUnbound(mRecord.RecordId, mRecord.RecordDescription);

    C.chkInterest.Value(mRecord.SuspendInterest);
    C.chkInterest.VisibleRow(mRecord.ShowSuspendInterest);
    C.dateInterestRestartDate.VisibleRow(mRecord.ShowInterestRestartDate);
    C.chkDefaultInterest.Value(mRecord.SuspendDefaultInterest);
    C.chkDefaultInterest.VisibleRow(mRecord.ShowSuspendDefaultInterest);
    C.chkDefaultFees.Value(mRecord.SuspendDefaultFees);
    C.chkDefaultFees.VisibleRow(mRecord.ShowSuspendDefaultFees);
    C.chkFacilityFee.Value(mRecord.SuspendFacilityFee);
    C.chkFacilityFee.VisibleRow(mRecord.ShowSuspendFacilityFee);
    C.chkStandardTransactions.Value(mRecord.SuspendStandardTransactions);
    C.chkStandardTransactions.VisibleRow(mRecord.ShowSuspendStandardTransactions)
    C.dateStandardTransactionsRestartFromDate.VisibleRow(mRecord.ShowStandardTransactionsRestartFromDate)
    C.chkWithdrawals.Value(mRecord.SuspendWithdrawals);
    C.chkWithdrawals.ReadOnly(!mRecord.EnableSuspendWithdrawals);
    C.chkWithdrawals.VisibleRow(mRecord.ShowSuspendWithdrawals);
    C.chkDocuments.Value(mRecord.SuspendDocuments);
    C.chkOverdueRules.Value(mRecord.SuspendOverdueRules);
    C.chkOverdueRules.VisibleRow(mRecord.ShowSuspendOverdueRules);
    C.chkCreditReporting.Value(mRecord.SuspendCreditReporting);
    C.chkCreditReporting.VisibleRow(mRecord.ShowSuspendCreditReporting);
    C.chkSuspendOther.Value(mRecord.SuspendOther);
    C.chkSuspendOther.Caption(mRecord.SuspendOtherCaption);
    C.chkSuspendOther.VisibleRow(mRecord.ShowSuspendOther);
    C.chkDocuments.VisibleRow(mRecord.ShowSuspendDocuments);

    if (mRecord.DateReview) C.dateReview.Value(mRecord.DateReview);
  }

  // Update Controls
  C.chkDefaultInterest.ReadOnly(C.chkInterest.Value());
  C.chkDefaultFees.ReadOnly(C.chkInterest.Value());
  C.chkFacilityFee.ReadOnly(C.chkInterest.Value());
  C.dateInterestRestartDate.ReadOnly(C.chkInterest.Value());

  // Unblock UI
  widget.UI.Unblock();

  // Update fields
  Fields_Update();

  // Refresh Tab
  tabWizard_Refresh();
}

// ===========
// Save Fields
// ===========
function Fields_Save() {
  // Not used by this wizard since there is no concept of updating an object behind the wizard
}

// =============
// Update Fields
// =============
function Fields_Update() {
  // Controls

  // Update Checkbox styles to indicate initial values
  if (C.chkInterest.Value()) C.chkInterest.AddClass("original");
  if (C.chkDefaultInterest.Value()) C.chkDefaultInterest.AddClass("original");
  if (C.chkDefaultFees.Value()) C.chkDefaultFees.AddClass("original");
  if (C.chkFacilityFee.Value()) C.chkFacilityFee.AddClass("original");
  if (C.chkStandardTransactions.Value()) C.chkStandardTransactions.AddClass("original");
  if (C.chkWithdrawals.Value()) C.chkWithdrawals.AddClass("original");
  if (C.chkDocuments.Value()) C.chkDocuments.AddClass("original");
  if (C.chkOverdueRules.Value()) C.chkOverdueRules.AddClass("original");
  if (C.chkCreditReporting.Value()) C.chkCreditReporting.AddClass("original");
  if (C.chkSuspendOther.Value()) C.chkSuspendOther.AddClass("original");

  // Update Buttons
  pageGeneral_Refresh();
  tabWizard_UpdateButtons();

  // Show content
  frmMain.Visible(mRecord != null);

  // Resize Tab
  tabWizard_Resize();
}

// ===========
// Resize Form
// ===========
function Form_Resize() {
  // General

  // Tab
  tabWizard_Resize();
}

// ==============
// Wizard Buttons
// ==============
function tabWizard_Cancel() {
  if (widget.CanClose()) {
    widget.Close();
  }
  else {
    widget.Reset();
  }
}

function tabWizard_UpdateButtons() {
  // Back and Next Buttons?
  if (tabWizard.TabCount() == 1) {
    cmdBack.hide();
    cmdNext.hide();
  }
  else {
    var tabIndex = tabWizard.SelectedTabIndex();
    cmdBack.prop("disabled", tabIndex &lt;= 0);
    cmdNext.prop("disabled", tabIndex &gt;= tabWizard.TabCount() - 1);
  }

  // Finish Button
  if (tabWizard.TabCount() != 1) cmdFinish.prop("disabled", !cmdNext.prop("disabled"));
}

// ==========
// Resize Tab
// ==========
function tabWizard_Resize() {
  switch (tabWizard.SelectedTabId()) {
    case "General":
      break;

    default:
      break;
  }
}

// ===========
// Wizard Move
// ===========
function tabWizard_Move(direction) {
  var Ok;

  // Validate
  if (direction &gt; 0) {
    tabWizard_Validate(function () { tabWizard_MovePost(direction); });
  }
  else {
    // Can always move backwards
    tabWizard_MovePost(direction);
  }
}

function tabWizard_MovePost(direction) {
  var Ok = true;

  // Find Next Tab to Move To
  if (Ok) {
    var found = false;
    var newTab = tabWizard.SelectedTabIndex();

    do {
      newTab += direction;

      switch (tabWizard.GetTabIdByIndex(newTab)) {
        default:
          found = true;
          break;
      }

      // Found?
      if (found) {
        break;
      }
      else if (newTab == tabWizard.TabCount() - 1) {
        // Just in case!
        widget.UI.MsgBoxAlert("tabWizard_MovePost: Tab not handled!");
        break;
      }
    }
    while (true);

    // Refresh the New Tab
    tabWizard_Refresh(newTab);
  }
}

// ===========
// Refresh Tab
// ===========
function tabWizard_Refresh(newTab) {
  // Moving forward onto tab, so Load information
  if (newTab &gt;= tabWizard.SelectedTabIndex()) {
    switch (tabWizard.GetTabIdByIndex(newTab)) {
      default:
        break;
    }
  }

  // Make Tab it
  tabWizard.SelectedTabIndex(newTab);

  // Tweak fields

  // Update Heading
  switch (tabWizard.SelectedTabId()) {
    default:
      frmMain.RefreshHeading(tabWizard.TabCaption(tabWizard.SelectedTabId()), tabWizard.TabTooltipText(tabWizard.SelectedTabId()));
      break;
  }

  // Back, Next command buttons valid?
  tabWizard_UpdateButtons();

  // Resize Wizard
  tabWizard_Resize();

  // Focus
  switch (tabWizard.SelectedTabId()) {
    default:
      tabWizard.FocusFirst();
      break;
  }
}

// ===============
// Validate Wizard
// ===============
function tabWizard_Validate(validCallback) {
  // Validate
  var Ok = tabWizard.Validate(true);

  // Other client-side validation
  if (Ok) {
    switch (tabWizard.SelectedTabId()) {
      case "General":
        // Validate server side
      break;

      default:
        // No validation
        validCallback();
        return;
    }
  }

  // Server-side validation
  if (Ok) {
    var params;

    switch (tabWizard.SelectedTabId()) {
      case "General":
        if (!C.dateReview.ReadOnly()) {
          params = {DateReview:C.dateReview.Value()}
        }
      break;
    }

    if (params) {
      // Disable Form
      frmMain.FormDisable("Validating");

      // Extend parameters
      params.pageId = tabWizard.SelectedTabId();

      // Call WizardValidate method in Script
      widget.GetString("WizardValidate",
                       params,
                       function (data) { tabWizard_ValidatePost(validCallback, data); },
                       tabWizard_ValidateFail);
    }
    else {
      // No server-side validation
      validCallback();
    }
  }
}

function tabWizard_ValidatePost(validCallback, data) {
  // Enable form
  frmMain.FormEnable();

  // Parse Data
  var o = {};
  if (data) o = JSON.parse(data);

  if (o.FailedMessage) {
    // -----------------
    // Validation failed
    // -----------------
    var o = JSON.parse(data);
    widget.UI.MsgBoxAlert(o.FailedMessage);
    if (o.FailedControlId) $("#" + o.FailedControlId).focus();
  }
  else {
    // ---------------------
    // Validation successful
    // ---------------------
    // Validation could pass back additional information, e.g., to use in tabWizard_Refresh
    switch (tabWizard.SelectedTabId()) {
    }

    // Callback
    validCallback();
  }
}

function tabWizard_ValidateFail(errorMessage) {
  widget.UI.MsgBoxAlert(errorMessage);

  // Enable form
  frmMain.FormEnable();
}

// =================
// Execute an Action
// =================
function Form_ExecuteAction(actionId) {
  switch (actionId.toUpperCase()) {
    case "FINISH":
      // Finish
      Form_ExecuteAction_Finish();
      break;

    default:
      window.alert(mViewName + ".Form_ExecuteAction: Unhandled action '" + actionId + "'");
      break;
  }
}

// =============
// Finish Action
// =============
function Form_ExecuteAction_Finish() {
  // Validate
  tabWizard_Validate(function () {
    if (mRecord.PromptOnCommit) {
      // Confirm
      var heading = "Update Suspension Details";
      var message = "Are you sure you want to suspend the selected items for Account " + mRecord.RecordId + ", " + mRecord.RecordDescription + "?";
      if (C.dateInterestRestartDate.Value()) message += "\n\n Update Interest to restart from " + widget.FormatDate(C.dateInterestRestartDate.Value()) + "?";
      if (C.dateStandardTransactionsRestartFromDate.Value()) message += "\n\n Update Standard Transaction Next Date to restart on or after " + widget.FormatDate(C.dateStandardTransactionsRestartFromDate.Value()) + "?";

      widget.UI.MsgBoxConfirm(message, { heading: heading }, function () { Form_ExecuteAction_FinishPost(); }, null);
    }
    else {
      // Commit without prompting
      Form_ExecuteAction_FinishPost();
    }
  });
}

function Form_ExecuteAction_FinishPost() {
  // Disable Form
  widget.UI.Block("Completing, please wait...");

  // Create Parameters
  var params = {
    // General
    Clear: mRecord.Clear,
    
    SuspendInterest: C.chkInterest.Value(),
    SuspendDefaultInterest: C.chkDefaultInterest.Value(),
    SuspendDefaultFees: C.chkDefaultFees.Value(),
    SuspendFacilityFee: C.chkFacilityFee.Value(),
    SuspendStandardTransactions: C.chkStandardTransactions.Value(),
    SuspendWithdrawals: C.chkWithdrawals.Value(),
    SuspendDocuments: C.chkDocuments.Value(),
    SuspendOverdueRules: C.chkOverdueRules.Value(),
    SuspendCreditReporting: C.chkCreditReporting.Value(),
    SuspendOther: C.chkSuspendOther.Value(),

    DateReview: C.dateReview.Value()
  };

  // Interest Restart Date
  if (params.SuspendInterest || C.dateInterestRestartDate.Value() == null) {
    params.InterestRestartFromDate = null;
  }
  else {
    params.InterestRestartFromDate = C.dateInterestRestartDate.Value();
  }

  // Standard Transactions Restart Date
  if (params.SuspendStandardTransactions || C.dateStandardTransactionsRestartFromDate.Value() == null) {
    params.StandardTransactionsRestartFromDate = null;
  }
  else {
    params.StandardTransactionsRestartFromDate = C.dateStandardTransactionsRestartFromDate.Value();
  }

  // Finish
  widget.GetString("Finish", params,
    function (data) {
      data = JSON.parse(data);

      if (data.Warning) {
        widget.UI.MsgBoxInfo(data.Warning, {}, Form_ExecuteAction_FinishPost_Done);
      }
      else {
        Form_ExecuteAction_FinishPost_Done();
      }
    },

    function (data) {
      // Do not treat as a 'clear' any longer
      mRecord.Clear = false;
    
      // Show Error
      widget.UI.MsgBoxAlert(data);

      // Enable Form
      widget.UI.Unblock();
    }
  );
}

function Form_ExecuteAction_FinishPost_Done() {
  // Close Form
  widget.Close();

  // Refresh Parent (to show updated details)
  widget.RefreshParent();
}

// ===========
// pageGeneral
// ===========
function pageGeneral_Refresh() {
  // Show Review Date?
  var showDate = C.chkCreditReporting.Value() || C.chkDefaultFees.Value() || C.chkDefaultInterest.Value() || C.chkDocuments.Value() || C.chkFacilityFee.Value() || C.chkInterest.Value() || C.chkOverdueRules.Value() || C.chkStandardTransactions.Value() || C.chkSuspendOther.Value() || C.chkWithdrawals.Value();

  C.dateReview.ReadOnly(!showDate);
  if (mRecord.ShowStandardTransactionsRestartFromDate) C.dateStandardTransactionsRestartFromDate.ReadOnly(C.chkStandardTransactions.Value());
}

// ===========
// chkInterest
// ===========
function chkInterest_Change(sender, e) {
  C.chkDefaultInterest.Value(C.chkInterest.Value());
  C.chkDefaultInterest.ReadOnly(C.chkInterest.Value());
  C.chkDefaultFees.Value(C.chkInterest.Value());
  C.chkDefaultFees.ReadOnly(C.chkInterest.Value());
  C.chkFacilityFee.Value(C.chkInterest.Value());
  C.chkFacilityFee.ReadOnly(C.chkInterest.Value());
  C.dateInterestRestartDate.ReadOnly(C.chkInterest.Value());

  pageGeneral_Refresh();
}
&lt;/script&gt;</TemplateText>
    <TemplateTextBookmarks />
    <TimeoutSeconds>60</TimeoutSeconds>
    <UniqueId>iKKQ6WAm5UKazSHuBHJ+Cg</UniqueId>
    <AllowRefresh>true</AllowRefresh>
    <Caption />
    <HtmlWidgetAllowInitialEventCaching>false</HtmlWidgetAllowInitialEventCaching>
    <HtmlWidgetMaxHeight>1200</HtmlWidgetMaxHeight>
    <HtmlWidgetMaxWidth>800</HtmlWidgetMaxWidth>
    <HtmlWidgetNeverApplyStyling>false</HtmlWidgetNeverApplyStyling>
    <HtmlWidgetResourceChartsApex>false</HtmlWidgetResourceChartsApex>
    <HtmlWidgetResourceCssSummaryPage2>false</HtmlWidgetResourceCssSummaryPage2>
    <HtmlWidgetResourceCssWidget>true</HtmlWidgetResourceCssWidget>
    <HtmlWidgetResourceJQuery>true</HtmlWidgetResourceJQuery>
    <HtmlWidgetResourceJQueryVersion />
    <HtmlWidgetSpecialEventGetFolderCount>false</HtmlWidgetSpecialEventGetFolderCount>
    <HtmlWidgetSpecialEventShowAsSummaryPage>false</HtmlWidgetSpecialEventShowAsSummaryPage>
    <HtmlWidgetSummaryPageObjectType>None</HtmlWidgetSummaryPageObjectType>
    <Icon />
    <RestrictedOriginsListEnabled>false</RestrictedOriginsListEnabled>
    <RunAsAdministrator>false</RunAsAdministrator>
    <WebServiceName />
    <WebServiceAllowAnonymous>false</WebServiceAllowAnonymous>
    <WebServiceSendDebugInformation>false</WebServiceSendDebugInformation>
    <ShowInMenu>None</ShowInMenu>
    <ParametersType>Custom</ParametersType>
    <Parameters>
      <ISParameterDefs version="1.00">
        <Parameters>
          <Parameter name="" type="SectionStart">
            <BlankTip />
            <Caption>TESTING</Caption>
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText>These are the Parameters required by this HTML Widget to function correctly.
They are listed here for testing purposes only.</TooltipText>
            <SectionColumns>1</SectionColumns>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="AccountId" type="List">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <Mandatory>false</Mandatory>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value />
            <Visible>true</Visible>
            <List>RANGE.Accounts</List>
            <LimitToList>false</LimitToList>
            <MaxLength>0</MaxLength>
            <Rows>1</Rows>
          </Parameter>
          <Parameter name="Clear" type="Boolean">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value>False</Value>
            <Visible>true</Visible>
          </Parameter>
        </Parameters>
      </ISParameterDefs>
    </Parameters>
  </finScript>