Skip to content

Instantly share code, notes, and snippets.

@Lokutus
Last active December 12, 2015 00:38
Show Gist options
  • Save Lokutus/4684710 to your computer and use it in GitHub Desktop.
Save Lokutus/4684710 to your computer and use it in GitHub Desktop.
%REM
Class UserProfile
Container object for one User profile document
@author Jiri Krakora
@date 31.1.2013
@uses User
@extends User
@revision 31.1.2013 1.0 Relesase
%END REM
Public Class UserProfile As User
Private oSubstitute As User
Private oFrom As NotesDateTime
Private oTo As NotesDateTime
Public Property Get IsSubstitutionEnabled As Boolean
Let IsSubstitutionEnabled = Me.GetSubstitutionStatus
End Property
Public Property Get Substitute As User
Set Substitute = Me.oSubstitute
End Property
Public Sub New
Set Me.oSubstitute = New User
End Sub
%REM
Set user profile document and wrap it
@param NotesDocument object
%END REM
Public Sub SetDocument(document As NotesDocument)
If Not document Is Nothing Then
Let Me.NameValue = document.GetItemValue("UsrName")(0)
Let Me.oSubstitute.NameValue = document.GetItemValue("UsrSubstituteName")(0)
Set Me.oFrom = New NotesDateTime(document.GetItemValue("UsrSubstitutionFrom")(0))
Set Me.oTo = New NotesDateTime(document.GetItemValue("UsrSubstitutionTo")(0))
Let Me.oId = LCase(Me.oName.Abbreviated)
End If
End Sub
%REM
Return substitute status based on From and To values
@return True/False
%END REM
Private Function GetSubstitutionStatus As Boolean
Dim todayDate As New NotesDateTime(Today)
Dim fromDiff As Double
Dim toDiff As Double
Let fromDiff = todayDate.TimeDifferenceDouble(Me.oFrom)
Let toDiff = todayDate.TimeDifferenceDouble(Me.oTo)
If fromDiff > 0 And toDiff < 0 Then
Let GetSubstitutionStatus = True
End If
End Function
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment