<?xml version="1.0" encoding="utf-8"?>
  <finScript version="1.00" exportedUtcDate="2026-04-29T00:00:00.0000000">
    <CreatedUserId>Admin</CreatedUserId>
    <CreatedUtcDate>2026-04-29T00:00:00.0000000</CreatedUtcDate>
    <UpdatedUserId>Admin</UpdatedUserId>
    <UpdatedUtcDate>2026-04-29T00:00:00.0000000</UpdatedUtcDate>
    <ScriptId>FINUSWID</ScriptId>
    <Description>User Preferences</Description>
    <ScriptType>HtmlWidget</ScriptType>
    <Active>true</Active>
    <AllowUI>false</AllowUI>
    <Bookmarks />
    <Category />
    <Code>' HtmlWidget_SettingsUserEdit
Option Explicit On
Option Strict On

' #################################################################
' User Preferences form HTML Widget
'
' Copyright (C) Intersoft Systems Limited 2026
'
' Version: 1.00 (02/06/2026)
'
' Usage: System-supplied HTML Widget to edit User Preferences
' #################################################################
' Version        Date  User     Job       Description
' -------  ----------  -------  --------  -------------------------
'    1.00  02/06/2026  ISS      J036837   Created (replaces SettingsUserEdit.ts/.htm and ISFormSettingsUserEditController.vb)
' #################################################################

' Constants
Private Const FORM_KEY As String = "SettingsUser"

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

' Standard Parameters
Private mPage As String
Private mReadOnly As Boolean
Private mUserId As String

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 Standard Parameters
  ' NOTE: Cloud caller passes "id" (User Id) and "page" (lowercase); also accept "PageId" for desktop/script callers
  With mCombinedParameters
    mUserId = .GetString("id")
    If Len(mUserId) = 0 Then mUserId = .GetString("UserId")
    mPage = .GetString("PageId")
    If Len(mPage) = 0 Then mPage = .GetString("page")
    mReadOnly = .GetBoolean("ReadOnly")
  End With

  ' Default to Current User if no User Id supplied
  If Len(mUserId) = 0 Then
    mUserId = finBL.CurrentUser.UserId
  End If

  ' Validate
  Main = finBL.HtmlWidgetUtilities.HasPermissionToViewFormKey(FORM_KEY)

  ' Handle Events
  If Main Then
    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 Else
        Main = False
        finBL.Error.ErrorBeginFormat("Unhandled event '{0}'", eventId)
    End Select
  End If

End Function

''' &lt;summary&gt;
'''  Load the specified User's preferences.
''' &lt;/summary&gt;
Private Function GetSettingsUser(ByRef settingsUser As finSettingsUser) As Boolean

  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Validate
  If Len(mUserId) = 0 Then
    Success = False
    finBL.Error.ErrorBegin("User Id not specified.")
  End If

  ' Create and Load
  If Success Then
    settingsUser = finBL.CreateSettingsUser()
    Success = settingsUser.Load(mUserId)
  End If

  Return Success

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 FormInitialisationInfo As FormInitialisationInfo
  Dim SettingsUser As finSettingsUser
  Dim SmsProvider As String
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Load User Preferences
  If Success Then
    Success = GetSettingsUser(SettingsUser)
  End If

  ' Get Initialisation Info
  If Success Then
    FormInitialisationInfo = New FormInitialisationInfo()
    With FormInitialisationInfo
      ' Form
      .PageId = mPage
      If finBL.Database.IsReadOnly OrElse mReadOnly Then
        .ReadOnly = True
      ElseIf finBL.CurrentUser.IsAdministrator OrElse finBL.CurrentUser.IsUserAdministrator Then
        .ReadOnly = False
      ElseIf finBL.CurrentUser.UserId = SettingsUser.UserId AndAlso finBL.CurrentUser.Permissions.Allow("UserSettings") Then
        .ReadOnly = False
      Else
        .ReadOnly = True
      End If

      ' Configuration
      .DatabaseName = finBL.Settings.DatabaseName
      .PromptOnSave = False

      ' Record
      .Timestamp = SettingsUser.Timestamp
      .UserId = SettingsUser.UserId
      .UserPk = SettingsUser.UserPk

      ' Add-On flags (used to hide irrelevant fields)
      .AddOnsExternalParty = finBL.Settings.AddOns.ExternalParty
      .AddOnsSecurityRegisterPPSR = finBL.Settings.AddOns.SecurityRegisterPPSR
      .AddOnsWorkflow = finBL.Settings.AddOns.Workflow

      ' -------
      ' General
      ' -------
      If finBL.CurrentUser.Permissions.Allow("UserSettings.General") Then
        .IncludeSettingsGeneral = True

        ' General.Database
        .DatabaseOpenMessage = SettingsUser.DatabaseOpenMessage
        .DatabaseOpenMessageUseGlobal = SettingsUser.DatabaseOpenMessageUseGlobal

        ' General.Formatting
        .DateFormatGrids = SettingsUser.DateFormatGrids
        .DateFormatLong = SettingsUser.DateFormatLong
        .DateFormatShort = SettingsUser.DateFormatShort
        .TimeFormatGrids = SettingsUser.TimeFormatGrids
        .TimeFormatGridsLong = SettingsUser.TimeFormatGridsLong
        .TimeFormatLong = SettingsUser.TimeFormatLong
        .TimeFormatShort = SettingsUser.TimeFormatShort

        ' General.Performance
        .PerformanceShowIncompleteAccountCount = SettingsUser.PerformanceShowIncompleteAccountCount
        .PerformanceShowOpenWorkflowCount = SettingsUser.PerformanceShowOpenWorkflowCount
        .PerformanceShowUnactionedLogCount = SettingsUser.PerformanceShowUnactionedLogCount
        .PerformanceShowUnpublishedLogCount = SettingsUser.PerformanceShowUnpublishedLogCount
        .PerformanceUseGlobalSettings = SettingsUser.PerformanceUseGlobalSettings

        ' General.Reporting
        .DefaultReportRangeAccountLedgers = SettingsUser.DefaultReportRangeAccountLedgers
        .DefaultReportRangeBranches = SettingsUser.DefaultReportRangeBranches
        .DefaultReportRangeEntities = SettingsUser.DefaultReportRangeEntities
        .ReportGreenBarColour = SettingsUser.ReportGreenBarColour

        ' General.UserInterface
        .ColourFormHeadings = SettingsUser.ColourFormHeadings
      End If

      ' --------
      ' Accounts
      ' --------
      If finBL.CurrentUser.Permissions.Allow("UserSettings.Accounts") Then
        .IncludeSettingsAccounts = True

        ' Accounts.General
        .AccountShowExternalId = SettingsUser.AccountShowExternalId
        .DefaultAccountDealerExternalPartyId = SettingsUser.DefaultAccountDealerExternalPartyId
        .DefaultAccountDepartmentId = SettingsUser.DefaultAccountDepartmentId
        .DefaultAccountProductTypeId = SettingsUser.DefaultAccountProductTypeId
        .DefaultAccountRegion = SettingsUser.DefaultAccountRegion
      End If

      ' --------------------
      ' Account Applications
      ' --------------------
      If finBL.CurrentUser.Permissions.Allow("UserSettings.AccountApplications") Then
        .IncludeSettingsAccountApps = True

        ' AccountApps.General
        .AccountAppShowExternalId = SettingsUser.AccountAppShowExternalId
      End If

      ' -------
      ' Clients
      ' -------
      If finBL.CurrentUser.Permissions.Allow("UserSettings.Clients") Then
        .IncludeSettingsClients = True

        ' Clients.General
        .ClientShowCrossReference = SettingsUser.ClientShowCrossReference
        .ClientShowExternalId = SettingsUser.ClientShowExternalId
        .DefaultClientBranchId = SettingsUser.DefaultClientBranchId
        .DefaultClientGroupId = SettingsUser.DefaultClientGroupId
        .DefaultClientManagerUserId = SettingsUser.DefaultClientManagerUserId
        .DefaultClientTypeId = SettingsUser.DefaultClientTypeId
      End If

      ' ---------
      ' Messaging
      ' ---------
      If finBL.CurrentUser.Permissions.Allow("UserSettings.Messaging") Then
        .IncludeSettingsMessaging = True
        .IncludeSettingsMessagingSms = Not finBL.Settings.SmsUseNewInterface

        ' Messaging.Email
        .EmailSignature = SettingsUser.EmailSignature

        ' Messaging.SMS
        .SmsUseGlobalSettings = SettingsUser.SmsUseGlobalSettings
        SmsProvider = SettingsUser.SmsProvider
        If Len(SmsProvider) = 0 OrElse Not finBL.MessageProviders.Exists(SmsProvider) Then
          .SmsProvider = ""
        Else
          .SmsProvider = finBL.MessageProviders(SmsProvider).FriendlyName
        End If
        .SmsUserId = SettingsUser.SmsUserId
        .SmsReplyToEmailAddress = SettingsUser.SmsReplyToEmailAddress
        .SmsReplyToName = SettingsUser.SmsReplyToName
      End If

      ' ----------
      ' Securities
      ' ----------
      If finBL.CurrentUser.Permissions.Allow("UserSettings.Securities") Then
        .IncludeSettingsSecurities = True

        ' Securities.General
        .SecurityShowExternalId = SettingsUser.SecurityShowExternalId
      End If

      ' -----
      ' Tasks
      ' -----
      If finBL.CurrentUser.Permissions.Allow("UserSettings.TasksAndWorkflows") Then
        .IncludeSettingsTasks = True

        ' Tasks.General
        .StartUpShowTaskManager = SettingsUser.StartUpShowTaskManager
        .TaskManagerIncludePendingPPSRG2BTransactions = SettingsUser.TaskManagerIncludePendingPPSRG2BTransactions
        .TaskManagerQuotedDays = SettingsUser.TaskManagerQuotedDays
        .TaskManagerShowSystemFolderAccountApps = SettingsUser.TaskManagerShowSystemFolderAccountApps
        .TaskManagerShowSystemFolderMonitoredAccounts = SettingsUser.TaskManagerShowSystemFolderMonitoredAccounts
        .TaskManagerShowSystemFolderRecordsBookmarked = SettingsUser.TaskManagerShowSystemFolderRecordsBookmarked
        .TaskManagerShowSystemFolderRecordsRecent = SettingsUser.TaskManagerShowSystemFolderRecordsRecent
        .TaskManagerShowSystemFolderTasks = SettingsUser.TaskManagerShowSystemFolderTasks
        .TaskManagerShowSystemFolderWorkflows = SettingsUser.TaskManagerShowSystemFolderWorkflows
      End If

      ' Edit Information (Lists)
      .SmsProvidersList = finBL.MessageProviders.GetProviderFriendlyNamesList(iseMessageProviderMessageClass.Sms)
    End With
  End If

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

  Return Success

End Function

''' &lt;summary&gt;
'''  Finish, i.e., Save the User's preferences.
''' &lt;/summary&gt;
''' &lt;param name="parametersJson"&gt;
'''  A JSON formatted record (FormInitialisationInfo) object.
''' &lt;/param&gt;
Private Function Finish(parametersJson As String,
                        requestInfo As finScriptRequestInfo,
                        ByRef returnValue As String) As Boolean

  Dim CurrentUser As ISCurrentUser
  Dim obj As Object
  Dim Record As FormInitialisationInfo
  Dim SettingsUser As finSettingsUser
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Parse Parameters
  If finBL.Runtime.WebUtilities.DeserialiseJsonStringToObject(parametersJson, GetType(FormInitialisationInfo), obj) Then
    Record = DirectCast(obj, FormInitialisationInfo)
  Else
    Success = False
    finBL.Error.ErrorBegin("Failed to deserialise User Preferences parameters.")
  End If

  ' Validate Permission
  If Success Then
    CurrentUser = finBL.CurrentUser
    If CurrentUser.IsAdministrator OrElse CurrentUser.IsUserAdministrator Then
      ' OK
    ElseIf CurrentUser.UserPk = Record.UserPk AndAlso CurrentUser.Permissions.Allow("UserSettings") Then
      ' OK
    Else
      Success = False
      finBL.Error.ErrorBegin("You do not have permission to update this User. Only Administrator Users and User Administrator Users can update another User's preferences.")
    End If
  End If

  ' Load User
  If Success Then
    SettingsUser = finBL.CreateSettingsUser()
    Success = SettingsUser.LoadPk(Record.UserPk)
  End If

  ' Validate Timestamp
  If Success Then
    If Record.Timestamp = -1 Then
      ' Ignore
    ElseIf Record.Timestamp &lt;&gt; SettingsUser.Timestamp Then
      Success = False
      finBL.Error.ErrorBeginFormat("The specified timestamp {0} does not match the database timestamp of {1}. This indicates that another User may have updated this record.", Record.Timestamp, SettingsUser.Timestamp)
    End If
  End If

  ' Update User Preferences
  ' NOTE: Do not wrap SettingsUser.Save() in an external Transaction - Save() manages its own Transaction internally and a nested Transaction left open here causes the script host to fail with "uncommitted Database Transaction".
  If Success Then
    With SettingsUser
      ' -------
      ' General
      ' -------
      If Record.IncludeSettingsGeneral AndAlso finBL.CurrentUser.Permissions.Allow("UserSettings.General") Then
        ' General.Database
        .DatabaseOpenMessageUseGlobal = Record.DatabaseOpenMessageUseGlobal
        .DatabaseOpenMessage = finBL.Runtime.Validation.ValidateString(Record.DatabaseOpenMessage)

        ' General.Formatting
        .DateFormatShort = Record.DateFormatShort
        .DateFormatLong = Record.DateFormatLong
        .TimeFormatShort = Record.TimeFormatShort
        .TimeFormatLong = Record.TimeFormatLong
        .DateFormatGrids = Record.DateFormatGrids
        .TimeFormatGrids = Record.TimeFormatGrids
        .TimeFormatGridsLong = Record.TimeFormatGridsLong

        ' General.Performance
        .PerformanceUseGlobalSettings = Record.PerformanceUseGlobalSettings
        .PerformanceShowUnactionedLogCount = Record.PerformanceShowUnactionedLogCount
        .PerformanceShowUnpublishedLogCount = Record.PerformanceShowUnpublishedLogCount
        .PerformanceShowOpenWorkflowCount = Record.PerformanceShowOpenWorkflowCount
        .PerformanceShowIncompleteAccountCount = Record.PerformanceShowIncompleteAccountCount

        ' General.Reporting
        .ReportGreenBarColour = Record.ReportGreenBarColour
        .DefaultReportRangeAccountLedgers = Record.DefaultReportRangeAccountLedgers
        .DefaultReportRangeBranches = Record.DefaultReportRangeBranches
        .DefaultReportRangeEntities = Record.DefaultReportRangeEntities

        ' General.UserInterface
        .ColourFormHeadings = Record.ColourFormHeadings
      End If

      ' --------
      ' Accounts
      ' --------
      If Record.IncludeSettingsAccounts AndAlso finBL.CurrentUser.Permissions.Allow("UserSettings.Accounts") Then
        ' Accounts.General
        .DefaultAccountProductTypeId = Record.DefaultAccountProductTypeId
        .DefaultAccountDepartmentId = Record.DefaultAccountDepartmentId
        .DefaultAccountDealerExternalPartyId = Record.DefaultAccountDealerExternalPartyId
        .DefaultAccountRegion = Record.DefaultAccountRegion
        .AccountShowExternalId = Record.AccountShowExternalId
      End If

      ' --------------------
      ' Account Applications
      ' --------------------
      If Record.IncludeSettingsAccountApps AndAlso finBL.CurrentUser.Permissions.Allow("UserSettings.AccountApplications") Then
        ' AccountApps.General
        .AccountAppShowExternalId = Record.AccountAppShowExternalId
      End If

      ' -------
      ' Clients
      ' -------
      If Record.IncludeSettingsClients AndAlso finBL.CurrentUser.Permissions.Allow("UserSettings.Clients") Then
        ' Clients.General
        .DefaultClientTypeId = Record.DefaultClientTypeId
        .DefaultClientGroupId = Record.DefaultClientGroupId
        .DefaultClientBranchId = Record.DefaultClientBranchId
        .DefaultClientManagerUserId = Record.DefaultClientManagerUserId
        .ClientShowExternalId = Record.ClientShowExternalId
        .ClientShowCrossReference = Record.ClientShowCrossReference
      End If

      ' ---------
      ' Messaging
      ' ---------
      If Record.IncludeSettingsMessaging AndAlso finBL.CurrentUser.Permissions.Allow("UserSettings.Messaging") Then
        ' Messaging.Email
        .EmailSignature = Record.EmailSignature

        ' Messaging.SMS
        If Record.IncludeSettingsMessagingSms Then
          .SmsUseGlobalSettings = Record.SmsUseGlobalSettings
          If Len(Record.SmsProvider) = 0 OrElse finBL.MessageProviders.ItemByFriendlyName(Record.SmsProvider) Is Nothing Then
            .SmsProvider = ""
          Else
            .SmsProvider = finBL.MessageProviders.ItemByFriendlyName(Record.SmsProvider).Name
          End If
          .SmsUserId = Record.SmsUserId
          If Len(Record.SmsPassword) &lt;&gt; 0 Then
            If Record.SmsPassword = "-" Then
              ' Clear password
              .SmsPassword = ""
            Else
              .SmsPassword = Record.SmsPassword
            End If
          End If
          .SmsReplyToName = Record.SmsReplyToName
          .SmsReplyToEmailAddress = Record.SmsReplyToEmailAddress
        End If
      End If

      ' ----------
      ' Securities
      ' ----------
      If Record.IncludeSettingsSecurities AndAlso finBL.CurrentUser.Permissions.Allow("UserSettings.Securities") Then
        ' Securities.General
        .SecurityShowExternalId = Record.SecurityShowExternalId
      End If

      ' -----
      ' Tasks
      ' -----
      If Record.IncludeSettingsTasks AndAlso finBL.CurrentUser.Permissions.Allow("UserSettings.TasksAndWorkflows") Then
        ' Tasks.General
        .StartUpShowTaskManager = Record.StartUpShowTaskManager
        .TaskManagerQuotedDays = Record.TaskManagerQuotedDays
        .TaskManagerShowSystemFolderTasks = Record.TaskManagerShowSystemFolderTasks
        .TaskManagerShowSystemFolderWorkflows = Record.TaskManagerShowSystemFolderWorkflows
        .TaskManagerShowSystemFolderMonitoredAccounts = Record.TaskManagerShowSystemFolderMonitoredAccounts
        .TaskManagerShowSystemFolderAccountApps = Record.TaskManagerShowSystemFolderAccountApps
        .TaskManagerShowSystemFolderRecordsBookmarked = Record.TaskManagerShowSystemFolderRecordsBookmarked
        .TaskManagerShowSystemFolderRecordsRecent = Record.TaskManagerShowSystemFolderRecordsRecent
        .TaskManagerIncludePendingPPSRG2BTransactions = Record.TaskManagerIncludePendingPPSRG2BTransactions
      End If
    End With
  End If

  ' Save
  If Success Then
    Success = SettingsUser.Save()
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Wizard Initialisation Information.
''' &lt;/summary&gt;
''' &lt;remarks&gt;
'''  This object is also used to save the User's settings.
''' &lt;/remarks&gt;
Public Class FormInitialisationInfo

  ' Form
  Public PageId As String
  Public [ReadOnly] As Boolean

  ' User
  Public Timestamp As Integer
  Public UserId As String
  Public UserPk As Integer

  ' Configuration
  Public DatabaseName As String
  Public PromptOnSave As Boolean

  ' Add-On flags
  Public AddOnsExternalParty As Boolean
  Public AddOnsSecurityRegisterPPSR As Boolean
  Public AddOnsWorkflow As Boolean

  ' -------
  ' General
  ' -------
  Public IncludeSettingsGeneral As Boolean

  ' General.Database
  Public DatabaseOpenMessage As String
  Public DatabaseOpenMessageUseGlobal As Boolean

  ' General.Formatting
  Public DateFormatGrids As String
  Public DateFormatLong As String
  Public DateFormatShort As String
  Public TimeFormatGrids As String
  Public TimeFormatGridsLong As String
  Public TimeFormatLong As String
  Public TimeFormatShort As String

  ' General.Performance
  Public PerformanceShowIncompleteAccountCount As Boolean
  Public PerformanceShowOpenWorkflowCount As Boolean
  Public PerformanceShowUnactionedLogCount As Boolean
  Public PerformanceShowUnpublishedLogCount As Boolean
  Public PerformanceUseGlobalSettings As Boolean

  ' General.Reporting
  Public DefaultReportRangeAccountLedgers As String
  Public DefaultReportRangeBranches As String
  Public DefaultReportRangeEntities As String
  Public ReportGreenBarColour As String

  ' General.UserInterface
  Public ColourFormHeadings As Boolean

  ' --------
  ' Accounts
  ' --------
  Public IncludeSettingsAccounts As Boolean

  ' Accounts.General
  Public AccountShowExternalId As Boolean
  Public DefaultAccountDealerExternalPartyId As String
  Public DefaultAccountDepartmentId As String
  Public DefaultAccountProductTypeId As String
  Public DefaultAccountRegion As String

  ' --------------------
  ' Account Applications
  ' --------------------
  Public IncludeSettingsAccountApps As Boolean

  ' AccountApps.General
  Public AccountAppShowExternalId As Boolean

  ' -------
  ' Clients
  ' -------
  Public IncludeSettingsClients As Boolean

  ' Clients.General
  Public ClientShowCrossReference As Boolean
  Public ClientShowExternalId As Boolean
  Public DefaultClientBranchId As String
  Public DefaultClientGroupId As String
  Public DefaultClientManagerUserId As String
  Public DefaultClientTypeId As String

  ' ---------
  ' Messaging
  ' ---------
  Public IncludeSettingsMessaging As Boolean
  Public IncludeSettingsMessagingSms As Boolean

  ' Messaging.Email
  Public EmailSignature As String

  ' Messaging.SMS
  Public SmsPassword As String
  Public SmsProvider As String
  Public SmsReplyToEmailAddress As String
  Public SmsReplyToName As String
  Public SmsUseGlobalSettings As Boolean
  Public SmsUserId As String

  ' ----------
  ' Securities
  ' ----------
  Public IncludeSettingsSecurities As Boolean

  ' Securities.General
  Public SecurityShowExternalId As Boolean

  ' -----
  ' Tasks
  ' -----
  Public IncludeSettingsTasks As Boolean

  ' Tasks.General
  Public StartUpShowTaskManager As Boolean
  Public TaskManagerIncludePendingPPSRG2BTransactions As Boolean
  Public TaskManagerQuotedDays As Integer
  Public TaskManagerShowSystemFolderAccountApps As Boolean
  Public TaskManagerShowSystemFolderMonitoredAccounts As Boolean
  Public TaskManagerShowSystemFolderRecordsBookmarked As Boolean
  Public TaskManagerShowSystemFolderRecordsRecent As Boolean
  Public TaskManagerShowSystemFolderTasks As Boolean
  Public TaskManagerShowSystemFolderWorkflows As Boolean

  ' Edit Information (Lists)
  Public SmsProvidersList As String

End Class</Code>
    <Language>VisualBasic</Language>
    <Notes>System-supplied HTML Widget to edit User Preferences.</Notes>
    <PermissionKeyExecute />
    <RunWithoutPrompts>false</RunWithoutPrompts>
    <TemplateText>&lt;div id="frmMain" class="is-widget-content" style="visibility:hidden"&gt;

  &lt;!-- Form Header --&gt;
  &lt;header&gt;
    &lt;!-- Tabs --&gt;
    &lt;div id="tabDetails" class="is-tabs"&gt;
      &lt;ul&gt;
        &lt;!-- General --&gt;
        &lt;li tabId="General_Database"&gt;Database&lt;/li&gt;
        &lt;li tabId="General_Formatting"&gt;Formatting&lt;/li&gt;
        &lt;li tabId="General_Performance"&gt;Performance&lt;/li&gt;
        &lt;li tabId="General_Reporting"&gt;Reporting&lt;/li&gt;
        &lt;li tabId="General_UserInterface"&gt;User Interface&lt;/li&gt;

        &lt;!-- Accounts --&gt;
        &lt;li tabId="Accounts_General"&gt;General&lt;/li&gt;

        &lt;!-- Account Applications --&gt;
        &lt;li tabId="AccountApps_General"&gt;General&lt;/li&gt;

        &lt;!-- Clients --&gt;
        &lt;li tabId="Clients_General"&gt;General&lt;/li&gt;

        &lt;!-- Messaging --&gt;
        &lt;li tabId="Messaging_Email"&gt;Email&lt;/li&gt;
        &lt;li tabId="Messaging_SMS"&gt;SMS&lt;/li&gt;

        &lt;!-- Securities --&gt;
        &lt;li tabId="Securities_General"&gt;General&lt;/li&gt;

        &lt;!-- Tasks --&gt;
        &lt;li tabId="Tasks_General"&gt;General&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;!-- General.Database --&gt;
    &lt;div id="pageGeneral_Database"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblDatabaseOpenMessage"&gt;Message to display upon signing in&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkDatabaseOpenMessageUseGlobal" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="txtDatabaseOpenMessage" /&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;

    &lt;!-- General.Formatting --&gt;
    &lt;div id="pageGeneral_Formatting"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblDateAndTimeFormats"&gt;Date and Time formats&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDateFormatShort"&gt;Short Date:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDateFormatShort" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDateFormatLong"&gt;Long Date:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDateFormatLong" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboTimeFormatShort"&gt;Short Time:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboTimeFormatShort" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboTimeFormatLong"&gt;Long Time:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboTimeFormatLong" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblDateAndTimeFormatsGrid"&gt;Date and Time formats for grids or where a fixed width is desirable&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDateFormatGrids"&gt;Grid Date:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDateFormatGrids" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboTimeFormatGrids"&gt;Short Time:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboTimeFormatGrids" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboTimeFormatGridsLong"&gt;Long Time:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboTimeFormatGridsLong" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;

    &lt;!-- General.Performance --&gt;
    &lt;div id="pageGeneral_Performance"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblPerformanceUseGlobal"&gt;Use Performance settings defined under Global Settings&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkPerformanceUseGlobalSettings" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblPerformanceOtherOptions"&gt;Other performance-related options&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkPerformanceShowUnactionedLogCount" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkPerformanceShowUnpublishedLogCount" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkPerformanceShowOpenWorkflowCount" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkPerformanceShowIncompleteAccountCount" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;

    &lt;!-- General.Reporting --&gt;
    &lt;div id="pageGeneral_Reporting"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblReportDefaultOptions"&gt;Default Report formatting options&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboReportGreenBarColour"&gt;&lt;nobr&gt;Green-Line Colour:&lt;/nobr&gt;&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboReportGreenBarColour" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblReportDefaultRanges"&gt;Default Ranges for Reports&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtDefaultReportRangeBranches"&gt;Branches:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtDefaultReportRangeBranches" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtDefaultReportRangeEntities"&gt;Entities:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtDefaultReportRangeEntities" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtDefaultReportRangeAccountLedgers"&gt;Ledgers:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtDefaultReportRangeAccountLedgers" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;

    &lt;!-- General.UserInterface --&gt;
    &lt;div id="pageGeneral_UserInterface"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblUIOtherOptions"&gt;Other options&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkColourFormHeadings" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;


    &lt;!--
      --------
      Accounts
      --------
    --&gt;
    &lt;!-- Accounts.General --&gt;
    &lt;div id="pageAccounts_General"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblNewAccountDefaults"&gt;Defaults for new Accounts&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultAccountProductTypeId"&gt;Product&amp;nbsp;Type:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultAccountProductTypeId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultAccountDepartmentId"&gt;Department:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultAccountDepartmentId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultAccountDealerExternalPartyId"&gt;Dealer:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultAccountDealerExternalPartyId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultAccountRegion"&gt;Region:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultAccountRegion" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblAccountsForm"&gt;Options for the Accounts form&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkAccountShowExternalId" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;


    &lt;!--
      --------------------
      Account Applications
      --------------------
    --&gt;
    &lt;!-- AccountApps.General --&gt;
    &lt;div id="pageAccountApps_General"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblAccountAppsForm"&gt;Options for the Account Applications form&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkAccountAppShowExternalId" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;


    &lt;!--
      -------
      Clients
      -------
    --&gt;
    &lt;!-- Clients.General --&gt;
    &lt;div id="pageClients_General"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblNewClientDefaults"&gt;Defaults for new Clients&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultClientTypeId"&gt;Client&amp;nbsp;Type:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultClientTypeId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultClientGroupId"&gt;Client&amp;nbsp;Group:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultClientGroupId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultClientBranchId"&gt;Branch:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultClientBranchId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultClientManagerUserId"&gt;Manager:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultClientManagerUserId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblClientsForm"&gt;Options for the Clients form&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkClientShowExternalId" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkClientShowCrossReference" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;


    &lt;!--
      ---------
      Messaging
      ---------
    --&gt;
    &lt;!-- Messaging.Email --&gt;
    &lt;div id="pageMessaging_Email"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblEmailSignature"&gt;Signature to appear on Emails&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="txtEmailSignature" /&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;

    &lt;!-- Messaging.SMS --&gt;
    &lt;div id="pageMessaging_SMS"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblSmsService"&gt;SMS Service Provider&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkSmsUseGlobalSettings" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;

        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboSmsProvider"&gt;Service:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboSmsProvider" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtSmsUserId"&gt;&lt;nobr&gt;User Id:&lt;/nobr&gt;&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtSmsUserId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtSmsPassword"&gt;New&amp;nbsp;Password:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtSmsPassword" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblSmsReply"&gt;Reply details&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtSmsReplyToName"&gt;Display&amp;nbsp;Name:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtSmsReplyToName" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtSmsReplyToEmailAddress"&gt;Email&amp;nbsp;Address:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtSmsReplyToEmailAddress" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;


    &lt;!--
      ----------
      Securities
      ----------
    --&gt;
    &lt;!-- Securities.General --&gt;
    &lt;div id="pageSecurities_General"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:7em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblSecuritiesForm"&gt;Options for the Security Statements form&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkSecurityShowExternalId" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;


    &lt;!--
      -----
      Tasks
      -----
    --&gt;
    &lt;!-- Tasks.General --&gt;
    &lt;div id="pageTasks_General"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:4em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblStartUpShowTaskManager"&gt;Show the Task Manager upon signing in?&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkStartUpShowTaskManager" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblTasksQuotes"&gt;Number of days before an outstanding Quote appears as a Task&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkTasksQuouteAccounts" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th class="is-indent-1"&gt;&lt;label for="numTaskManagerQuotedDays"&gt;Days:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numTaskManagerQuotedDays" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblTaskManagerDisplayOptions"&gt;Task Manager display options&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkTaskManagerShowSystemFolderTasks" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkTaskManagerShowSystemFolderWorkflows" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkTaskManagerShowSystemFolderMonitoredAccounts" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkTaskManagerShowSystemFolderAccountApps" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkTaskManagerShowSystemFolderRecordsBookmarked" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkTaskManagerShowSystemFolderRecordsRecent" type="checkbox" /&gt;&lt;/th&gt;&lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblTasksOptionalTypes"&gt;Optional Task types to include&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;input id="chkTaskManagerIncludePendingPPSRG2BTransactions" type="checkbox" /&gt;&lt;/th&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="cmdFinish" class="is-button ok"&gt;Save&lt;/button&gt;
  &lt;/footer&gt;

&lt;/div&gt;


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

// Controls
var C = {
  // -------
  // General
  // -------
  //   General.Database
  lblDatabaseOpenMessage: null,
  chkDatabaseOpenMessageUseGlobal: null,
  txtDatabaseOpenMessage: null,

  //   General.Formatting
  lblDateAndTimeFormats: null,
  cboDateFormatShort: null,
  cboDateFormatLong: null,
  cboTimeFormatShort: null,
  cboTimeFormatLong: null,
  lblDateAndTimeFormatsGrid: null,
  cboDateFormatGrids: null,
  cboTimeFormatGrids: null,
  cboTimeFormatGridsLong: null,

  //   General.Performance
  lblPerformanceUseGlobal: null,
  chkPerformanceUseGlobalSettings: null,
  lblPerformanceOtherOptions: null,
  chkPerformanceShowUnactionedLogCount: null,
  chkPerformanceShowUnpublishedLogCount: null,
  chkPerformanceShowOpenWorkflowCount: null,
  chkPerformanceShowIncompleteAccountCount: null,

  //   General.Reporting
  lblReportDefaultOptions: null,
  cboReportGreenBarColour: null,
  lblReportDefaultRanges: null,
  txtDefaultReportRangeBranches: null,
  txtDefaultReportRangeEntities: null,
  txtDefaultReportRangeAccountLedgers: null,

  //   General.UserInterface
  lblUIOtherOptions: null,
  chkColourFormHeadings: null,

  // --------
  // Accounts
  // --------
  //   Accounts.General
  lblNewAccountDefaults: null,
  cboDefaultAccountProductTypeId: null,
  cboDefaultAccountDepartmentId: null,
  cboDefaultAccountDealerExternalPartyId: null,
  cboDefaultAccountRegion: null,
  lblAccountsForm: null,
  chkAccountShowExternalId: null,

  // --------------------
  // Account Applications
  // --------------------
  //   AccountApps.General
  lblAccountAppsForm: null,
  chkAccountAppShowExternalId: null,

  // -------
  // Clients
  // -------
  //   Clients.General
  lblNewClientDefaults: null,
  cboDefaultClientTypeId: null,
  cboDefaultClientGroupId: null,
  cboDefaultClientBranchId: null,
  cboDefaultClientManagerUserId: null,
  lblClientsForm: null,
  chkClientShowExternalId: null,
  chkClientShowCrossReference: null,

  // ---------
  // Messaging
  // ---------
  //   Messaging.Email
  lblEmailSignature: null,
  txtEmailSignature: null,

  //   Messaging.SMS
  lblSmsService: null,
  chkSmsUseGlobalSettings: null,
  cboSmsProvider: null,
  txtSmsUserId: null,
  txtSmsPassword: null,
  lblSmsReply: null,
  txtSmsReplyToName: null,
  txtSmsReplyToEmailAddress: null,

  // ----------
  // Securities
  // ----------
  //   Securities.General
  lblSecuritiesForm: null,
  chkSecurityShowExternalId: null,

  // -----
  // Tasks
  // -----
  //   Tasks.General
  lblStartUpShowTaskManager: null,
  chkStartUpShowTaskManager: null,
  lblTasksQuotes: null,
  chkTasksQuouteAccounts: null,
  numTaskManagerQuotedDays: null,
  lblTaskManagerDisplayOptions: null,
  chkTaskManagerShowSystemFolderTasks: null,
  chkTaskManagerShowSystemFolderWorkflows: null,
  chkTaskManagerShowSystemFolderMonitoredAccounts: null,
  chkTaskManagerShowSystemFolderAccountApps: null,
  chkTaskManagerShowSystemFolderRecordsBookmarked: null,
  chkTaskManagerShowSystemFolderRecordsRecent: null,
  lblTasksOptionalTypes: null,
  chkTaskManagerIncludePendingPPSRG2BTransactions: null
};

// Form
var frmMain;
var tabDetails;

// Buttons
var cmdCancel;
var cmdFinish;

// ==========
// Initialise
// ==========
$(function () {
  // -------
  // General
  // -------
  //   General.Database
  C.lblDatabaseOpenMessage = widget.UI.Label("lblDatabaseOpenMessage", {});
  C.chkDatabaseOpenMessageUseGlobal = widget.UI.CheckBox("chkDatabaseOpenMessageUseGlobal", {
    caption: "Show Global message upon signing in?",

    onChange: chkDatabaseOpenMessageUseGlobal_Change,
  });
  C.txtDatabaseOpenMessage = widget.UI.TextBox("txtDatabaseOpenMessage", {
    allowBlank: true,
    maxLength: 32767,
    multiLine: true,
    rows: 12,
  });

  //   General.Formatting
  C.lblDateAndTimeFormats = widget.UI.Label("lblDateAndTimeFormats", {});
  C.cboDateFormatShort = widget.UI.ComboBox("cboDateFormatShort", {
    allowBlank: true,
    limitToList: false,
    maxLength: 20,
  });
  C.cboDateFormatLong = widget.UI.ComboBox("cboDateFormatLong", {
    allowBlank: true,
    limitToList: false,
    maxLength: 20,
  });
  C.cboTimeFormatShort = widget.UI.ComboBox("cboTimeFormatShort", {
    allowBlank: true,
    limitToList: false,
    maxLength: 20,
  });
  C.cboTimeFormatLong = widget.UI.ComboBox("cboTimeFormatLong", {
    allowBlank: true,
    limitToList: false,
    maxLength: 20,
  });

  C.lblDateAndTimeFormatsGrid = widget.UI.Label("lblDateAndTimeFormatsGrid", {});
  C.cboDateFormatGrids = widget.UI.ComboBox("cboDateFormatGrids", {
    allowBlank: true,
    limitToList: false,
    maxLength: 20,
  });
  C.cboTimeFormatGrids = widget.UI.ComboBox("cboTimeFormatGrids", {
    allowBlank: true,
    limitToList: false,
    maxLength: 20,
  });
  C.cboTimeFormatGridsLong = widget.UI.ComboBox("cboTimeFormatGridsLong", {
    allowBlank: true,
    limitToList: false,
    maxLength: 20,
  });

  //   General.Performance
  C.lblPerformanceUseGlobal = widget.UI.Label("lblPerformanceUseGlobal", {});
  C.chkPerformanceUseGlobalSettings = widget.UI.CheckBox("chkPerformanceUseGlobalSettings", {
    caption: "Use Global Performance Settings?",

    onChange: chkPerformanceUseGlobalSettings_Change,
  });

  C.lblPerformanceOtherOptions = widget.UI.Label("lblPerformanceOtherOptions", {});
  C.chkPerformanceShowUnactionedLogCount = widget.UI.CheckBox("chkPerformanceShowUnactionedLogCount", {
    caption: "Show Unactioned Log counts?",
  });
  C.chkPerformanceShowUnpublishedLogCount = widget.UI.CheckBox("chkPerformanceShowUnpublishedLogCount", {
    caption: "Show Unpublished Log counts?",
  });
  C.chkPerformanceShowOpenWorkflowCount = widget.UI.CheckBox("chkPerformanceShowOpenWorkflowCount", {
    caption: "Show Open Workflow count?",
  });
  C.chkPerformanceShowIncompleteAccountCount = widget.UI.CheckBox("chkPerformanceShowIncompleteAccountCount", {
    caption: "Show Incomplete Account count?",
  });

  //   General.Reporting
  C.lblReportDefaultOptions = widget.UI.Label("lblReportDefaultOptions", {});
  C.cboReportGreenBarColour = widget.UI.ColourChooserComboBox("cboReportGreenBarColour", {
    blankTip: "#DCFFDC",
    width: "12em",
  });

  C.lblReportDefaultRanges = widget.UI.Label("lblReportDefaultRanges", {
    tooltipText: "Any reports that have either 'Account Ledgers', 'Branches' or 'Entities' ranges can have the value '[Default]' entered into them and they will use the settings defined below.",
  });
  C.txtDefaultReportRangeBranches = widget.UI.TextBox("txtDefaultReportRangeBranches", {
    allowBlank: true,
    maxLength: 100,
  });
  C.txtDefaultReportRangeEntities = widget.UI.TextBox("txtDefaultReportRangeEntities", {
    allowBlank: true,
    maxLength: 100,
  });
  C.txtDefaultReportRangeAccountLedgers = widget.UI.TextBox("txtDefaultReportRangeAccountLedgers", {
    allowBlank: true,
    maxLength: 100,
  });

  //   General.UserInterface
  C.lblUIOtherOptions = widget.UI.Label("lblUIOtherOptions", {
    tooltipText: "Form headings such as Accounts and Clients can be coloured to highlight the Client's Status.",
  });
  C.chkColourFormHeadings = widget.UI.CheckBox("chkColourFormHeadings", {
    caption: "Colour Form headings?",
  });

  // --------
  // Accounts
  // --------
  //   Accounts.General
  C.lblNewAccountDefaults = widget.UI.Label("lblNewAccountDefaults", {});
  C.cboDefaultAccountProductTypeId = widget.UI.DBCombo("cboDefaultAccountProductTypeId", {
    allowBlank: true,
    maxLength: 10,
    width: widget.UI.FIELD_WIDTH_CODE_10,
  });
  C.cboDefaultAccountDepartmentId = widget.UI.DBCombo("cboDefaultAccountDepartmentId", {
    allowBlank: true,
    maxLength: 10,
    width: widget.UI.FIELD_WIDTH_CODE_10,
  });
  C.cboDefaultAccountDealerExternalPartyId = widget.UI.DBCombo("cboDefaultAccountDealerExternalPartyId", {
    allowBlank: true,
    maxLength: 10,
    width: widget.UI.FIELD_WIDTH_CODE_10,
  });
  C.cboDefaultAccountRegion = widget.UI.InformationListComboBox("cboDefaultAccountRegion", {
    allowBlank: true,
    maxLength: 50,
  });

  C.lblAccountsForm = widget.UI.Label("lblAccountsForm", {});
  C.chkAccountShowExternalId = widget.UI.CheckBox("chkAccountShowExternalId", {
    caption: "Show the External Id field?",
  });

  // --------------------
  // Account Applications
  // --------------------
  //   AccountApps.General
  C.lblAccountAppsForm = widget.UI.Label("lblAccountAppsForm", {});
  C.chkAccountAppShowExternalId = widget.UI.CheckBox("chkAccountAppShowExternalId", {
    caption: "Show the External Id field?",
  });

  // -------
  // Clients
  // -------
  //   Clients.General
  C.lblNewClientDefaults = widget.UI.Label("lblNewClientDefaults", {});
  C.cboDefaultClientTypeId = widget.UI.DBCombo("cboDefaultClientTypeId", {
    allowBlank: true,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.cboDefaultClientGroupId = widget.UI.DBCombo("cboDefaultClientGroupId", {
    allowBlank: true,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.cboDefaultClientBranchId = widget.UI.DBCombo("cboDefaultClientBranchId", {
    allowBlank: true,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.cboDefaultClientManagerUserId = widget.UI.DBCombo("cboDefaultClientManagerUserId", {
    allowBlank: true,
    maxLength: 20,
    width: widget.UI.FIELD_WIDTH_CODE_20,
  });

  C.lblClientsForm = widget.UI.Label("lblClientsForm", {});
  C.chkClientShowExternalId = widget.UI.CheckBox("chkClientShowExternalId", {
    caption: "Show the External Id field?",
  });
  C.chkClientShowCrossReference = widget.UI.CheckBox("chkClientShowCrossReference", {
    caption: "Show the Cross Reference field?",
  });

  // ---------
  // Messaging
  // ---------
  //   Messaging.Email
  C.lblEmailSignature = widget.UI.Label("lblEmailSignature", {});
  C.txtEmailSignature = widget.UI.TextBox("txtEmailSignature", {
    allowBlank: true,
    maxLength: 8192,
    multiLine: true,
    rows: 12,
  });

  //   Messaging.SMS
  C.lblSmsService = widget.UI.Label("lblSmsService", {});
  C.chkSmsUseGlobalSettings = widget.UI.CheckBox("chkSmsUseGlobalSettings", {
    caption: "Use details defined under Global Settings?",

    onChange: chkSmsUseGlobalSettings_Change,
  });
  C.cboSmsProvider = widget.UI.ComboBox("cboSmsProvider", {
    allowBlank: true,
    limitToList: true,
    maxLength: 50,

    onChange: cboSmsProvider_Change,
  });
  C.txtSmsUserId = widget.UI.TextBox("txtSmsUserId", {
    allowBlank: false,
    maxLength: 50,
  });
  C.txtSmsPassword = widget.UI.TextBox("txtSmsPassword", {
    blankTip: "Enter a new password",
    maxLength: 100,
    password: true,
  });

  C.lblSmsReply = widget.UI.Label("lblSmsReply", {});
  C.txtSmsReplyToName = widget.UI.TextBox("txtSmsReplyToName", {
    maxLength: 100,
  });
  C.txtSmsReplyToEmailAddress = widget.UI.TextBox("txtSmsReplyToEmailAddress", {
    maxLength: 100,
  });

  // ----------
  // Securities
  // ----------
  //   Securities.General
  C.lblSecuritiesForm = widget.UI.Label("lblSecuritiesForm", {});
  C.chkSecurityShowExternalId = widget.UI.CheckBox("chkSecurityShowExternalId", {
    caption: "Show the External Id field?",
  });

  // -----
  // Tasks
  // -----
  //   Tasks.General
  C.lblStartUpShowTaskManager = widget.UI.Label("lblStartUpShowTaskManager", {});
  C.chkStartUpShowTaskManager = widget.UI.CheckBox("chkStartUpShowTaskManager", {
    caption: "Show the Task Manager upon signing in?",
  });

  C.lblTasksQuotes = widget.UI.Label("lblTasksQuotes", {});
  C.chkTasksQuouteAccounts = widget.UI.CheckBox("chkTasksQuouteAccounts", {
    caption: "Show 'Account Quotes Outstanding' Tasks?",

    onChange: chkTasksQuouteAccounts_Change,
  });
  C.numTaskManagerQuotedDays = widget.UI.NumberBox("numTaskManagerQuotedDays", {
    allowBlank: false,
    decimals: 0,
    width: "3em",
  });

  C.lblTaskManagerDisplayOptions = widget.UI.Label("lblTaskManagerDisplayOptions", {});
  C.chkTaskManagerShowSystemFolderTasks = widget.UI.CheckBox("chkTaskManagerShowSystemFolderTasks", {
    caption: "Tasks",
  });
  C.chkTaskManagerShowSystemFolderWorkflows = widget.UI.CheckBox("chkTaskManagerShowSystemFolderWorkflows", {
    caption: "Workflows",
  });
  C.chkTaskManagerShowSystemFolderMonitoredAccounts = widget.UI.CheckBox("chkTaskManagerShowSystemFolderMonitoredAccounts", {
    caption: "Monitored Accounts",
  });
  C.chkTaskManagerShowSystemFolderAccountApps = widget.UI.CheckBox("chkTaskManagerShowSystemFolderAccountApps", {
    caption: "Account Applications",
  });
  C.chkTaskManagerShowSystemFolderRecordsBookmarked = widget.UI.CheckBox("chkTaskManagerShowSystemFolderRecordsBookmarked", {
    caption: "Bookmarked Records",
  });
  C.chkTaskManagerShowSystemFolderRecordsRecent = widget.UI.CheckBox("chkTaskManagerShowSystemFolderRecordsRecent", {
    caption: "Recent Records",
  });

  C.lblTasksOptionalTypes = widget.UI.Label("lblTasksOptionalTypes", {});
  C.chkTaskManagerIncludePendingPPSRG2BTransactions = widget.UI.CheckBox("chkTaskManagerIncludePendingPPSRG2BTransactions", {
    caption: "Pending PPSR G2B Transactions",
  });

  // Date Format Lists
  switch (widget.DayMonthYearOrder ? widget.DayMonthYearOrder() : "DMY") {
    case "MDY":
      C.cboDateFormatShort.ListFromCsvString("MM/d/yyyy,MMddyy,MM/dd/yy,ddMMMyy");
      C.cboDateFormatLong.ListFromCsvString("MMMM d yyyy,MMddyyyy,MM/dd/yyyy,dd MMM yyyy");
      C.cboDateFormatGrids.ListFromCsvString("MM/d/yyyy,MMddyy,MM/dd/yy,ddMMMyy");
      break;
    case "YMD":
      C.cboDateFormatShort.ListFromCsvString("yyyy/MM/d,yyMMdd,yy/MM/dd,ddMMMyy");
      C.cboDateFormatLong.ListFromCsvString("yyyy MMMM d,yyyyMMdd,yyyy/MM/dd,dd MMM yyyy");
      C.cboDateFormatGrids.ListFromCsvString("yyyy/MM/d,yyMMdd,yy/MM/dd,ddMMMyy");
      break;
    default:
      C.cboDateFormatShort.ListFromCsvString("d/MM/yyyy,ddMMyy,dd/MM/yy,ddMMMyy");
      C.cboDateFormatLong.ListFromCsvString("d MMMM yyyy,ddMMyyyy,dd/MM/yyyy,dd MMM yyyy");
      C.cboDateFormatGrids.ListFromCsvString("d/MM/yyyy,ddMMyy,dd/MM/yy,ddMMMyy");
      break;
  }
  C.cboTimeFormatShort.ListFromCsvString("h:mm tt,HH:mm");
  C.cboTimeFormatLong.ListFromCsvString("h:mm:ss tt,HH:mm:ss");
  C.cboTimeFormatGrids.ListFromCsvString("h:mm tt,HH:mm");
  C.cboTimeFormatGridsLong.ListFromCsvString("h:mm:ss tt,HH:mm:ss");

  // Create Widget form
  frmMain = new widget.UI.Form("frmMain", { visible: false });

  // Create Tabs
  tabDetails = new widget.UI.Tabs("tabDetails", {
    style: "normal",
    onSelectedTabChanged: tabDetails_Refresh,
  });

  // Handle resize
  $(window).resize(Form_Resize);

  // Disable Close Button (this causes the 'FormClose' notification action to be invoked instead)
  widget.DisableCloseButton();
  widget.ActionNotificationHandle(Widget_NotificationHandler);

  // Handle Wizard Buttons
  cmdCancel = $("#cmdCancel");
  cmdFinish = $("#cmdFinish");
  cmdCancel.click(tabDetails_Cancel);
  cmdFinish.click(Form_ExecuteAction_Finish);

  // Reset
  Form_Reset();
});

// ==========
// Reset Form
// ==========
function Form_Reset() {
  Form_Resize();
  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", {},
    Record_Load_Done,
    function (message) {
      widget.UI.MsgBoxAlert("fail: " + message);
      Fields_Load();
    }
  );
}

function Record_Load_Done(data) {
  mRecord = JSON.parse(data);

  // Tabs filtered by section (e.g., only General_* visible if section is General)
  if (mRecord &amp;&amp; mRecord.PageId) {
    tabDetails.SelectedTabId(mRecord.PageId);
    var n = mRecord.PageId.indexOf("_");
    mSection = (n &gt;= 0) ? mRecord.PageId.substr(0, n) : mRecord.PageId;
    for (var i = 0; i &lt; tabDetails.TabCount(); i++) {
      var tab = tabDetails.GetTabByIndex(i);
      tabDetails.TabVisible(tab.tabId, tab.tabId.substr(0, mSection.length + 1) == mSection + "_");
    }
  }
  else {
    mSection = "General";
    tabDetails.SelectedTabId("General_Database");
  }

  // Hide tabs the user isn't permitted to see
  if (!mRecord.IncludeSettingsGeneral) {
    tabDetails.TabVisible("General_Database", false);
    tabDetails.TabVisible("General_Formatting", false);
    tabDetails.TabVisible("General_Performance", false);
    tabDetails.TabVisible("General_Reporting", false);
    tabDetails.TabVisible("General_UserInterface", false);
  }
  if (!mRecord.IncludeSettingsAccounts) tabDetails.TabVisible("Accounts_General", false);
  if (!mRecord.IncludeSettingsAccountApps) tabDetails.TabVisible("AccountApps_General", false);
  if (!mRecord.IncludeSettingsClients) tabDetails.TabVisible("Clients_General", false);
  if (!mRecord.IncludeSettingsMessaging) {
    tabDetails.TabVisible("Messaging_Email", false);
    tabDetails.TabVisible("Messaging_SMS", false);
  }
  else if (!mRecord.IncludeSettingsMessagingSms) {
    tabDetails.TabVisible("Messaging_SMS", false);
  }
  if (!mRecord.IncludeSettingsSecurities) tabDetails.TabVisible("Securities_General", false);
  if (!mRecord.IncludeSettingsTasks) tabDetails.TabVisible("Tasks_General", false);

  // Add-On row visibility
  if (!mRecord.AddOnsWorkflow) {
    C.chkPerformanceShowOpenWorkflowCount.VisibleRow(false);
    C.chkTaskManagerShowSystemFolderWorkflows.VisibleRow(false);
  }
  if (!mRecord.AddOnsExternalParty) {
    C.cboDefaultAccountDealerExternalPartyId.VisibleRow(false);
  }
  if (!mRecord.AddOnsSecurityRegisterPPSR) {
    C.lblTasksOptionalTypes.VisibleRow(false);
    C.chkTaskManagerIncludePendingPPSRG2BTransactions.VisibleRow(false);
  }

  // Load Fields
  Fields_Load();

  // Save Fields (so values are in correct format for mOriginalJson)
  Fields_Save();

  // Save original JSON for Form_IsDirty
  mOriginalJson = JSON.stringify(mRecord);
}

// ===========
// Load Fields
// ===========
function Fields_Load() {
  if (mRecord) {
    // -------
    // General
    // -------
    if (mRecord.IncludeSettingsGeneral) {
      // General.Database
      C.chkDatabaseOpenMessageUseGlobal.Value(mRecord.DatabaseOpenMessageUseGlobal);
      C.txtDatabaseOpenMessage.Text(mRecord.DatabaseOpenMessage);

      // General.Formatting
      C.cboDateFormatShort.Text(mRecord.DateFormatShort);
      C.cboDateFormatLong.Text(mRecord.DateFormatLong);
      C.cboTimeFormatShort.Text(mRecord.TimeFormatShort);
      C.cboTimeFormatLong.Text(mRecord.TimeFormatLong);
      C.cboDateFormatGrids.Text(mRecord.DateFormatGrids);
      C.cboTimeFormatGrids.Text(mRecord.TimeFormatGrids);
      C.cboTimeFormatGridsLong.Text(mRecord.TimeFormatGridsLong);

      // General.Performance
      C.chkPerformanceUseGlobalSettings.Value(mRecord.PerformanceUseGlobalSettings);
      C.chkPerformanceShowUnactionedLogCount.Value(mRecord.PerformanceShowUnactionedLogCount);
      C.chkPerformanceShowUnpublishedLogCount.Value(mRecord.PerformanceShowUnpublishedLogCount);
      C.chkPerformanceShowOpenWorkflowCount.Value(mRecord.PerformanceShowOpenWorkflowCount);
      C.chkPerformanceShowIncompleteAccountCount.Value(mRecord.PerformanceShowIncompleteAccountCount);

      // General.Reporting
      C.cboReportGreenBarColour.Text(mRecord.ReportGreenBarColour);
      C.txtDefaultReportRangeBranches.Text(mRecord.DefaultReportRangeBranches);
      C.txtDefaultReportRangeEntities.Text(mRecord.DefaultReportRangeEntities);
      C.txtDefaultReportRangeAccountLedgers.Text(mRecord.DefaultReportRangeAccountLedgers);

      // General.UserInterface
      C.chkColourFormHeadings.Value(mRecord.ColourFormHeadings);
    }

    // --------
    // Accounts
    // --------
    if (mRecord.IncludeSettingsAccounts) {
      C.cboDefaultAccountProductTypeId.Text(mRecord.DefaultAccountProductTypeId);
      C.cboDefaultAccountDepartmentId.Text(mRecord.DefaultAccountDepartmentId);
      C.cboDefaultAccountDealerExternalPartyId.Text(mRecord.DefaultAccountDealerExternalPartyId);
      C.cboDefaultAccountRegion.Text(mRecord.DefaultAccountRegion);
      C.chkAccountShowExternalId.Value(mRecord.AccountShowExternalId);
    }

    // --------------------
    // Account Applications
    // --------------------
    if (mRecord.IncludeSettingsAccountApps) {
      C.chkAccountAppShowExternalId.Value(mRecord.AccountAppShowExternalId);
    }

    // -------
    // Clients
    // -------
    if (mRecord.IncludeSettingsClients) {
      C.cboDefaultClientTypeId.Text(mRecord.DefaultClientTypeId);
      C.cboDefaultClientGroupId.Text(mRecord.DefaultClientGroupId);
      C.cboDefaultClientBranchId.Text(mRecord.DefaultClientBranchId);
      C.cboDefaultClientManagerUserId.Text(mRecord.DefaultClientManagerUserId);
      C.chkClientShowExternalId.Value(mRecord.ClientShowExternalId);
      C.chkClientShowCrossReference.Value(mRecord.ClientShowCrossReference);
    }

    // ---------
    // Messaging
    // ---------
    if (mRecord.IncludeSettingsMessaging) {
      C.txtEmailSignature.Text(mRecord.EmailSignature);

      if (mRecord.IncludeSettingsMessagingSms) {
        C.chkSmsUseGlobalSettings.Value(mRecord.SmsUseGlobalSettings);
        C.cboSmsProvider.Text(mRecord.SmsProvider);
        C.txtSmsUserId.Text(mRecord.SmsUserId);
        C.txtSmsReplyToName.Text(mRecord.SmsReplyToName);
        C.txtSmsReplyToEmailAddress.Text(mRecord.SmsReplyToEmailAddress);
      }
    }

    // ----------
    // Securities
    // ----------
    if (mRecord.IncludeSettingsSecurities) {
      C.chkSecurityShowExternalId.Value(mRecord.SecurityShowExternalId);
    }

    // -----
    // Tasks
    // -----
    if (mRecord.IncludeSettingsTasks) {
      C.chkStartUpShowTaskManager.Value(mRecord.StartUpShowTaskManager);
      if (mRecord.TaskManagerQuotedDays == -1) {
        C.chkTasksQuouteAccounts.Value(false);
      }
      else {
        C.chkTasksQuouteAccounts.Value(true);
        C.numTaskManagerQuotedDays.Value(mRecord.TaskManagerQuotedDays);
      }
      C.chkTaskManagerShowSystemFolderTasks.Value(mRecord.TaskManagerShowSystemFolderTasks);
      C.chkTaskManagerShowSystemFolderWorkflows.Value(mRecord.TaskManagerShowSystemFolderWorkflows);
      C.chkTaskManagerShowSystemFolderMonitoredAccounts.Value(mRecord.TaskManagerShowSystemFolderMonitoredAccounts);
      C.chkTaskManagerShowSystemFolderAccountApps.Value(mRecord.TaskManagerShowSystemFolderAccountApps);
      C.chkTaskManagerShowSystemFolderRecordsBookmarked.Value(mRecord.TaskManagerShowSystemFolderRecordsBookmarked);
      C.chkTaskManagerShowSystemFolderRecordsRecent.Value(mRecord.TaskManagerShowSystemFolderRecordsRecent);
      C.chkTaskManagerIncludePendingPPSRG2BTransactions.Value(mRecord.TaskManagerIncludePendingPPSRG2BTransactions);
    }
  }

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

  // Update fields
  Fields_Update();

  // Refresh Tab
  tabDetails_Refresh();
  tabDetails_Resize();
}

// ===========
// Save Fields
// ===========
function Fields_Save() {
  if (!mRecord) return;

  if (mRecord.IncludeSettingsGeneral) {
    mRecord.DatabaseOpenMessageUseGlobal = C.chkDatabaseOpenMessageUseGlobal.Value();
    mRecord.DatabaseOpenMessage = C.txtDatabaseOpenMessage.Text();

    mRecord.DateFormatShort = C.cboDateFormatShort.Text();
    mRecord.DateFormatLong = C.cboDateFormatLong.Text();
    mRecord.TimeFormatShort = C.cboTimeFormatShort.Text();
    mRecord.TimeFormatLong = C.cboTimeFormatLong.Text();
    mRecord.DateFormatGrids = C.cboDateFormatGrids.Text();
    mRecord.TimeFormatGrids = C.cboTimeFormatGrids.Text();
    mRecord.TimeFormatGridsLong = C.cboTimeFormatGridsLong.Text();

    mRecord.PerformanceUseGlobalSettings = C.chkPerformanceUseGlobalSettings.Value();
    mRecord.PerformanceShowUnactionedLogCount = C.chkPerformanceShowUnactionedLogCount.Value();
    mRecord.PerformanceShowUnpublishedLogCount = C.chkPerformanceShowUnpublishedLogCount.Value();
    mRecord.PerformanceShowOpenWorkflowCount = C.chkPerformanceShowOpenWorkflowCount.Value();
    mRecord.PerformanceShowIncompleteAccountCount = C.chkPerformanceShowIncompleteAccountCount.Value();

    mRecord.ReportGreenBarColour = C.cboReportGreenBarColour.Text();
    mRecord.DefaultReportRangeBranches = C.txtDefaultReportRangeBranches.Text();
    mRecord.DefaultReportRangeEntities = C.txtDefaultReportRangeEntities.Text();
    mRecord.DefaultReportRangeAccountLedgers = C.txtDefaultReportRangeAccountLedgers.Text();

    mRecord.ColourFormHeadings = C.chkColourFormHeadings.Value();
  }

  if (mRecord.IncludeSettingsAccounts) {
    mRecord.DefaultAccountProductTypeId = C.cboDefaultAccountProductTypeId.Text();
    mRecord.DefaultAccountDepartmentId = C.cboDefaultAccountDepartmentId.Text();
    mRecord.DefaultAccountDealerExternalPartyId = C.cboDefaultAccountDealerExternalPartyId.Text();
    mRecord.DefaultAccountRegion = C.cboDefaultAccountRegion.Text();
    mRecord.AccountShowExternalId = C.chkAccountShowExternalId.Value();
  }

  if (mRecord.IncludeSettingsAccountApps) {
    mRecord.AccountAppShowExternalId = C.chkAccountAppShowExternalId.Value();
  }

  if (mRecord.IncludeSettingsClients) {
    mRecord.DefaultClientTypeId = C.cboDefaultClientTypeId.Text();
    mRecord.DefaultClientGroupId = C.cboDefaultClientGroupId.Text();
    mRecord.DefaultClientBranchId = C.cboDefaultClientBranchId.Text();
    mRecord.DefaultClientManagerUserId = C.cboDefaultClientManagerUserId.Text();
    mRecord.ClientShowExternalId = C.chkClientShowExternalId.Value();
    mRecord.ClientShowCrossReference = C.chkClientShowCrossReference.Value();
  }

  if (mRecord.IncludeSettingsMessaging) {
    mRecord.EmailSignature = C.txtEmailSignature.Text();

    if (mRecord.IncludeSettingsMessagingSms) {
      mRecord.SmsUseGlobalSettings = C.chkSmsUseGlobalSettings.Value();
      mRecord.SmsProvider = C.cboSmsProvider.Text();
      mRecord.SmsUserId = C.txtSmsUserId.Text();
      if (C.txtSmsPassword.Text()) {
        mRecord.SmsPassword = C.txtSmsPassword.Text();
      }
      else {
        mRecord.SmsPassword = "";
      }
      mRecord.SmsReplyToName = C.txtSmsReplyToName.Text();
      mRecord.SmsReplyToEmailAddress = C.txtSmsReplyToEmailAddress.Text();
    }
  }

  if (mRecord.IncludeSettingsSecurities) {
    mRecord.SecurityShowExternalId = C.chkSecurityShowExternalId.Value();
  }

  if (mRecord.IncludeSettingsTasks) {
    mRecord.StartUpShowTaskManager = C.chkStartUpShowTaskManager.Value();
    if (C.chkTasksQuouteAccounts.Value()) {
      mRecord.TaskManagerQuotedDays = C.numTaskManagerQuotedDays.Value();
    }
    else {
      mRecord.TaskManagerQuotedDays = -1;
    }
    mRecord.TaskManagerShowSystemFolderTasks = C.chkTaskManagerShowSystemFolderTasks.Value();
    mRecord.TaskManagerShowSystemFolderWorkflows = C.chkTaskManagerShowSystemFolderWorkflows.Value();
    mRecord.TaskManagerShowSystemFolderMonitoredAccounts = C.chkTaskManagerShowSystemFolderMonitoredAccounts.Value();
    mRecord.TaskManagerShowSystemFolderAccountApps = C.chkTaskManagerShowSystemFolderAccountApps.Value();
    mRecord.TaskManagerShowSystemFolderRecordsBookmarked = C.chkTaskManagerShowSystemFolderRecordsBookmarked.Value();
    mRecord.TaskManagerShowSystemFolderRecordsRecent = C.chkTaskManagerShowSystemFolderRecordsRecent.Value();
    mRecord.TaskManagerIncludePendingPPSRG2BTransactions = C.chkTaskManagerIncludePendingPPSRG2BTransactions.Value();
  }
}

// =============
// Update Fields
// =============
function Fields_Update() {
  // Heading
  if (mRecord) {
    var section = mSection;
    switch (section) {
      case "AccountApps":
        section = "Account Applications";
        break;

      case "Tasks":
        if (mRecord.AddOnsWorkflow) section = "Tasks &amp; Workflows";
        break;
    }
    widget.SetHeading("&lt;HTML&gt;&lt;b&gt;" + section + ":&lt;/b&gt; User Preferences - " + mRecord.UserId);
  }

  // Other change handlers
  if (mRecord) {
    chkDatabaseOpenMessageUseGlobal_Change(null, null);
    chkPerformanceUseGlobalSettings_Change(null, null);
    chkSmsUseGlobalSettings_Change();
    cboSmsProvider_Change(null, null);
    chkTasksQuouteAccounts_Change();
  }

  // Lists / Standard Ranges
  if (mRecord) {
    if (mRecord.IncludeSettingsAccounts) {
      C.cboDefaultAccountProductTypeId.RefreshFromStandardRange("ProductTypes");
      C.cboDefaultAccountDepartmentId.RefreshFromStandardRange("Departments");
      if (mRecord.AddOnsExternalParty) C.cboDefaultAccountDealerExternalPartyId.RefreshFromStandardRange("ExternalPartiesDealers");
      C.cboDefaultAccountRegion.SetComboFromInformationList("AccountRegion");
    }

    if (mRecord.IncludeSettingsClients) {
      C.cboDefaultClientTypeId.RefreshFromStandardRange("ClientTypes");
      C.cboDefaultClientGroupId.RefreshFromStandardRange("ClientGroups");
      C.cboDefaultClientBranchId.RefreshFromStandardRange("Branches");
      C.cboDefaultClientManagerUserId.RefreshFromStandardRange("Users");
    }

    if (mRecord.IncludeSettingsMessaging) {
      C.txtEmailSignature.TagsListDefine([
        { caption: "User ID", value: "[User.UserId]" },
        { caption: "User Name", value: "[User.Name]" },
        { caption: "User Job Title", value: "[User.JobTitle]" },
        { caption: "User Email", value: "[User.Email]" },
        { caption: "User Mobile", value: "[User.Mobile]" },
        { caption: "User Phone", value: "[User.Phone]" },
      ]);

      if (mRecord.IncludeSettingsMessagingSms) {
        C.cboSmsProvider.ListFromCsvString(mRecord.SmsProvidersList);
      }
    }
  }

  // Read-Only?
  if (mRecord &amp;&amp; mRecord.ReadOnly) {
    cmdFinish.prop("disabled", true);
    frmMain.FormReadOnly(C, true);
  }

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

  // Resize Tab
  tabDetails_Resize();
}

// ===========
// Resize Form
// ===========
function Form_Resize() {
  tabDetails_Resize();
}

// ========
// Is Dirty
// ========
function Form_IsDirty() {
  if (mRecord) {
    Fields_Save();
    return mOriginalJson != JSON.stringify(mRecord);
  }
  return false;
}

// ==============
// Wizard Buttons
// ==============
function tabDetails_Cancel() {
  if (Form_IsDirty()) {
    widget.UI.MsgBoxConfirm("Are you sure you want to close this form without saving your changes?", { heading: "Close Form" }, tabDetails_Cancel_Finalise);
  }
  else {
    tabDetails_Cancel_Finalise();
  }
}

function tabDetails_Cancel_Finalise() {
  if (widget.CanClose()) {
    widget.Close();
  }
  else {
    widget.Reset();
  }
}

// =====================================
// chkDatabaseOpenMessageUseGlobal_Change
// =====================================
function chkDatabaseOpenMessageUseGlobal_Change(sender, e) {
  if (e) e.ChangeHandled = true;
  if (C.txtDatabaseOpenMessage &amp;&amp; C.chkDatabaseOpenMessageUseGlobal) {
    C.txtDatabaseOpenMessage.VisibleRow(!C.chkDatabaseOpenMessageUseGlobal.Value());
  }
}

// ====================================
// chkPerformanceUseGlobalSettings_Change
// ====================================
function chkPerformanceUseGlobalSettings_Change(sender, e) {
  if (e) e.ChangeHandled = true;
  if (!mRecord) return;
  var useGlobal = C.chkPerformanceUseGlobalSettings.Value();
  C.lblPerformanceOtherOptions.VisibleRow(!useGlobal);
  C.chkPerformanceShowUnactionedLogCount.VisibleRow(!useGlobal);
  C.chkPerformanceShowUnpublishedLogCount.VisibleRow(!useGlobal);
  C.chkPerformanceShowOpenWorkflowCount.VisibleRow(!useGlobal &amp;&amp; mRecord.AddOnsWorkflow);
  C.chkPerformanceShowIncompleteAccountCount.VisibleRow(!useGlobal);
}

// ==============
// cboSmsProvider
// ==============
function cboSmsProvider_Change(sender, e) {
  if (e) e.ChangeHandled = true;
  chkSmsUseGlobalSettings_Change();
}

// =======================
// chkSmsUseGlobalSettings
// =======================
function chkSmsUseGlobalSettings_Change() {
  if (!mRecord || !mRecord.IncludeSettingsMessagingSms) return;
  C.cboSmsProvider.VisibleRow(!C.chkSmsUseGlobalSettings.Value());
  C.txtSmsUserId.VisibleRow(C.cboSmsProvider.Text() &amp;&amp; !C.chkSmsUseGlobalSettings.Value());
  C.txtSmsPassword.VisibleRow(C.cboSmsProvider.Text() &amp;&amp; !C.chkSmsUseGlobalSettings.Value());
}

// ======================
// chkTasksQuouteAccounts
// ======================
function chkTasksQuouteAccounts_Change() {
  if (C.chkTasksQuouteAccounts &amp;&amp; C.numTaskManagerQuotedDays) {
    C.numTaskManagerQuotedDays.VisibleRow(C.chkTasksQuouteAccounts.Value());
  }
}

// ==========
// Resize Tab
// ==========
function tabDetails_Resize() {
  switch (tabDetails.SelectedTabId()) {
    case "General_Formatting":
      C.cboDateFormatShort.WidthResizeFromParent();
      C.cboDateFormatLong.WidthResizeFromParent();
      C.cboTimeFormatShort.WidthResizeFromParent();
      C.cboTimeFormatLong.WidthResizeFromParent();
      C.cboDateFormatGrids.WidthResizeFromParent();
      C.cboTimeFormatGrids.WidthResizeFromParent();
      C.cboTimeFormatGridsLong.WidthResizeFromParent();
      break;

    case "General_Reporting":
      C.txtDefaultReportRangeBranches.WidthResizeFromParent();
      C.txtDefaultReportRangeEntities.WidthResizeFromParent();
      C.txtDefaultReportRangeAccountLedgers.WidthResizeFromParent();
      break;

    case "Accounts_General":
      C.cboDefaultAccountRegion.WidthResizeFromParent();
      break;

    case "Messaging_Email":
      C.txtEmailSignature.WidthResizeFromParent();
      break;

    case "Messaging_SMS":
      C.cboSmsProvider.WidthResizeFromParent();
      C.txtSmsUserId.WidthResizeFromParent();
      C.txtSmsPassword.WidthResizeFromParent();
      break;
  }
}

// ===========
// Refresh Tab
// ===========
function tabDetails_Refresh() {
  tabDetails_Resize();
  if (tabDetails.FocusFirst) tabDetails.FocusFirst();
}

// =============
// Finish Action
// =============
function Form_ExecuteAction_Finish() {
  if (!tabDetails.Validate()) return;

  if (mRecord.PromptOnSave) {
    widget.UI.MsgBoxConfirm("Save changes to User Preferences?",
                            { heading: "Save User Preferences" },
                            Form_ExecuteAction_FinishPost);
  }
  else {
    Form_ExecuteAction_FinishPost();
  }
}

function Form_ExecuteAction_FinishPost() {
  widget.UI.Block("Saving, please wait...");

  Fields_Save();
  var params = JSON.parse(JSON.stringify(mRecord));

  widget.GetString("Finish", params,
    function (data) {
      widget.Close();
      widget.RefreshParent();
    },
    function (data) {
      widget.UI.MsgBoxAlert(data);
      widget.UI.Unblock();
    }
  );
}

// ====================
// Notification Handler
// ====================
function Widget_NotificationHandler(actionId, data) {
  switch (actionId) {
    case "FormClose":
      tabDetails_Cancel();
      break;
  }
}
&lt;/script&gt;</TemplateText>
    <TemplateTextBookmarks />
    <TimeoutSeconds>60</TimeoutSeconds>
    <UniqueId>FINUSWID-W2026-A</UniqueId>
    <AllowRefresh>true</AllowRefresh>
    <Caption>User Preferences</Caption>
    <HtmlWidgetMaxHeight>2048</HtmlWidgetMaxHeight>
    <HtmlWidgetMaxWidth>1024</HtmlWidgetMaxWidth>
    <HtmlWidgetNeverApplyStyling>false</HtmlWidgetNeverApplyStyling>
    <HtmlWidgetResourceChartsApex>false</HtmlWidgetResourceChartsApex>
    <HtmlWidgetResourceCssSummaryPage2>false</HtmlWidgetResourceCssSummaryPage2>
    <HtmlWidgetResourceCssWidget>true</HtmlWidgetResourceCssWidget>
    <HtmlWidgetResourceJQuery>true</HtmlWidgetResourceJQuery>
    <HtmlWidgetResourceJQueryVersion />
    <HtmlWidgetSpecialEventGetFolderCount>false</HtmlWidgetSpecialEventGetFolderCount>
    <Icon>Settings_User</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="UserId" type="Text">
            <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>
            <MaxLength>20</MaxLength>
            <Multiline>false</Multiline>
          </Parameter>
          <Parameter name="PageId" 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>General_Database,General_Formatting,General_Performance,General_Reporting,General_UserInterface,Accounts_General,AccountApps_General,Clients_General,Messaging_Email,Messaging_SMS,Securities_General,Tasks_General</List>
            <LimitToList>false</LimitToList>
            <MaxLength>0</MaxLength>
            <Rows>1</Rows>
          </Parameter>
          <Parameter name="ReadOnly" 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>
