Views [dbo].[SafetySystemPersonnelStatus]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnNo
Created5:32:59 PM Wednesday, January 2, 2008
Last Modified8:54:39 AM Thursday, December 5, 2024
Columns
Name
SysuserFID
ColorCode
Permissions
TypeActionOwning Principal
GrantInsertMssExec
GrantDeleteMssExec
GrantSelectMssExec
GrantUpdateMssExec
SQL Script
SET QUOTED_IDENTIFIER OFF
GO
/**
*    
*    Description: This view calculates the status of Sysusers based on Safety System dates
*
*/


CREATE view [dbo].[SafetySystemPersonnelStatus]
(
    SysuserFID,
    ColorCode
)
as

select
    SysuserFID = Sysuser.SysUserID,
    ColorCode =
        case
            when SafetySystemPersonnel.AdministrativeHoldFlag = 1 then 'Black'
            when
            (
                SafetySystemPersonnel.NextPhysicalDate < GetDate() or
                SafetySystemPersonnel.LicenseExpiresDate < GetDate() or                
                SafetySystemPersonnel.NextMVRDate < GetDate() or
                SafetySystemPersonnel.NextBackgroundCheckDate < GetDate()                
            ) then 'Red'
            when
            (
                SafetySystemPersonnel.NextPhysicalDate - 30 < GetDate() or
                SafetySystemPersonnel.LicenseExpiresDate - 30 < GetDate() or            
                SafetySystemPersonnel.NextMVRDate - 30 < GetDate() or
                SafetySystemPersonnel.NextBackgroundCheckDate - 30 < GetDate()                
            ) then 'Yellow'
            else 'Green'
        end            
from Sysuser
inner join SafetySystemPersonnel on Sysuser.SysUserID = SafetySystemPersonnel.SysuserFID
GO
GRANT SELECT ON  [dbo].[SafetySystemPersonnelStatus] TO [MssExec]
GRANT INSERT ON  [dbo].[SafetySystemPersonnelStatus] TO [MssExec]
GRANT DELETE ON  [dbo].[SafetySystemPersonnelStatus] TO [MssExec]
GRANT UPDATE ON  [dbo].[SafetySystemPersonnelStatus] TO [MssExec]
GO
Uses