Add firma flag to availability and show office/home label

Server query gets the last stamp's BU_TERM in the same OUTER APPLY
as LAST_STAMP, exposing FIRMA (1 = Zeiterfassung/Büro). Three OUTER
APPLYs reduced to two by combining MAX(BU_BU) with TOP 1 ORDER BY.

Client model gains a firma boolean and the people-tile indicator
appends "· Büro" or "· Home" next to the timestamp, but only when
the user is logged in.
This commit is contained in:
2026-04-13 12:55:51 +02:00
parent 74992a020f
commit 523477ffba
5 changed files with 25 additions and 11 deletions
@@ -11,21 +11,24 @@ internal class ZeitConsensRepository(IConfiguration config) : Repository(config)
ma.MA_USER_NAME
,bu.LOGGED_IN
,us.US_EXTENSION
,buLastStamp.LAST_STAMP
,buLast.LAST_STAMP
,buLast.FIRMA
FROM dbo.MA_DATEN ma
INNER JOIN projectmanagement.dbo.CP_USER us on us.US_LOGINNAME = ma.MA_USER_NAME
INNER JOIN projectmanagement.dbo.CP_USER us ON us.US_LOGINNAME = ma.MA_USER_NAME
OUTER APPLY (
SELECT count(*) % 2 AS LOGGED_IN
FROM dbo.BU
SELECT COUNT(*) % 2 AS LOGGED_IN
FROM dbo.BU bu
WHERE bu.BU_MA_NR = ma.MA_NR
AND
BU_BU >= @from AND BU_BU < @to
AND bu.BU_BU >= @from AND bu.BU_BU < @to
) bu
OUTER APPLY (
SELECT MAX(BU_BU) AS LAST_STAMP
FROM dbo.BU
SELECT TOP 1
bu.BU_BU AS LAST_STAMP
,CASE WHEN bu.BU_TERM = 'Zeiterfassung' THEN 1 ELSE 0 END AS FIRMA
FROM dbo.BU bu
WHERE bu.BU_MA_NR = ma.MA_NR
) buLastStamp
ORDER BY bu.BU_BU DESC
) buLast
WHERE
ma.MA_USER_AKTIV = 1
""";