Add fis_wdg_* table functions for dashboard widgets and wire them into FuchsDatabase.sqlproj; update the invoice list procs accordingly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
-- =============================================
|
||||
-- Description: Dashboard widget 'wdg_requests_today' (Aufträge terminiert für heute).
|
||||
-- Called from [dbo].[fis_widgets].[sql] as: SELECT * FROM [dbo].[fis_wdg_requests_today]()
|
||||
-- =============================================
|
||||
CREATE FUNCTION [dbo].[fis_wdg_requests_today]()
|
||||
RETURNS TABLE
|
||||
AS
|
||||
RETURN
|
||||
(
|
||||
WITH osrq AS (
|
||||
SELECT s.[id], s.[name], s.[externalid], s.[customerId]
|
||||
, [last_appointment] = MAX(CAST(a.[startdatetime] as date)), [#a] = COUNT(*)
|
||||
FROM [dbo].[mfr__servicerequests] AS s
|
||||
JOIN [dbo].[mfr__appointments] AS a ON s.[id] = a.[ServiceRequestId]
|
||||
WHERE s.[state] IN ('Scheduled', 'Released', 'InProgress')
|
||||
GROUP BY s.[id], s.[name], s.[externalid], s.[customerId])
|
||||
SELECT [Nummer] = [externalid], [Auftrag] = [name], [Kunde] = [dbo].[fds__getCompanyName]([customerId])
|
||||
FROM osrq
|
||||
WHERE [last_appointment] = CAST(GETDATE() as date)
|
||||
);
|
||||
Reference in New Issue
Block a user