The users() function only calls a list of all users from sambapos.
function users(){
var query = “SELECT [Name] FROM [MB].[dbo].[Users]”;
var result = sql.Query(query).Join(‘|’);
return result;
}
Then there is User:X which checks for every user if there is data in the Program setting column.
declare @Test varchar(20) = [at]1
SELECT SUBSTRING([Value], 0, CHARINDEX(‘;’, [VALUE]) ) as Name
,SUBSTRING([Value], CHARINDEX(‘;’, [VALUE])+1, 10 ) as DateBegin
,SUBSTRING([Value], CHARINDEX(‘;’, [VALUE])+11, 6 ) as TimeBegin
,SUBSTRING([Value], CHARINDEX(‘;’, [VALUE])+25, 10 ) as DateEnd
,SUBSTRING([Value], CHARINDEX(‘;’, [VALUE])+35, 6 ) as TimeEnd
,CASE WHEN SUBSTRING([Value], CHARINDEX(‘;’, [VALUE])+25, 10 ) = ‘’ THEN NULL ELSE CONVERT(varchar(10),DATEDIFF(minute,CONVERT(DATETIME,SUBSTRING([Value], CHARINDEX(‘;’, [VALUE])+1, 10 )+SUBSTRING([Value], CHARINDEX(‘;’, [VALUE])+11, 13 ),105),CONVERT(DATETIME,SUBSTRING([Value], CHARINDEX(‘;’, [VALUE])+25, 10 )+SUBSTRING([Value], CHARINDEX(‘;’, [VALUE])+35, 13 ),105))/60)+‘H’+ CONVERT(varchar(10),DATEDIFF(minute,CONVERT(DATETIME,SUBSTRING([Value], CHARINDEX(‘;’, [VALUE])+1, 10 )+SUBSTRING([Value], CHARINDEX(‘;’, [VALUE])+11, 13 ),105),CONVERT(DATETIME,SUBSTRING([Value], CHARINDEX(‘;’, [VALUE])+25, 10 )+SUBSTRING([Value], CHARINDEX(‘;’, [VALUE])+35, 13 ),105)) % 60)+‘min’ END AS ‘Temps’
FROM [MB].[dbo].[ProgramSettingValues]
Where SUBSTRING([Value], 0, CHARINDEX(‘;’, [VALUE]) ) = @Test
I think this is quite messy and could be made nicer with functions and variables…
Here is the example of one record:
Administrator;04-11-2019 08:52:42.020;04-11-2019 08:54:20.405