New-UDPage -Url "/ServerBuildRequestV1" -Name "ServerBuildRequestV1" -Content {

New-UDTypography -Text "`nServer Build Request request items (RITMs) submitted after 2024/06/25"

$ServerInstance = "itdintsql22p1.nd.gov\INTSQL22P1"
$Database = "ITD-Systems-Automation"
$Table = 'ServiceNow_RitmDump_ServerBuildRequestV1'

New-ITDServiceNowSession -Environment Production -Credential $Secret:snow_vmcred

$SqlQuery = "SELECT [RitmNum],
    [RitmSysId],
    [opened_at],
    [requested_for],
    [request_type],
    [environment]
      ,[host_name_ref]
      ,[host_name]
  FROM [ITD-Systems-Automation].[dbo].[ServiceNow_RitmDump_ServerBuildRequestV1]"
$SqlRecords = Invoke-Sqlcmd -ServerInstance $ServerInstance -Database $Database -Query $SqlQuery -Credential $Secret:sql_itdpsu1 -Verbose



New-UDTable -Dense -ShowPagination -PageSize 20 -Size small -Data ($SqlRecords | Sort-Object -Descending opened_at) -Columns @(
    New-UDTableColumn -Property 'RitmUrl' -Title 'RitmUrl' -Render {
        New-UDLink -Url ("https://northdakota.service-now.com/nav_to.do?uri=sc_req_item.do?sys_id=" + $EventData.RitmSysId) -Id "lnkRitm" -Content {
            New-UDImage -Url "https://psuniversal.nd.gov/PSUniversal_Extras/servicenow_logo_icon_168835.png" -Height 20 -Width 20
        }
    }

    New-UDTableColumn -Property 'RitmNum' -Title 'RitmNum' -ShowFilter
    New-UDTableColumn -Property 'opened_at' -Title 'opened_at' -ShowFilter
    New-UDTableColumn -Property 'host_name' -Title 'host_name' -ShowFilter        
    New-UDTableColumn -Property 'requested_for' -Title 'requested_for' -ShowFilter
    New-UDTableColumn -Property 'request_type' -Title 'request_type' -ShowFilter
    New-UDTableColumn -Property 'environment' -Title 'environment' -ShowFilter
    #New-UDTableColumn -Property 'additional_comments' -Title 'additional_comments' -ShowFilter
)
} -Icon @{
		id = '7d67b921-68aa-4085-84e8-025e92671771'
		type = 'icon'
	}