﻿<?xml version="1.0" encoding="utf-8"?>
<ReportsExport>
  <Reports>
    <Report id="0db0b901-d8d0-499e-bb39-753a13e72e8d" codekey="ERGO_e-campus_TrainingValidation" categoryCodekey="Trainings" name="Seminarteilnahme_Validierung" description="Listet die Bildungszeiten für Seminare in einem bestimmten Zeitraum und ob eine Einladung versendet wurde">
      <MetaData created="2022-03-31T11:32:47" createdBy="Kaiser, Jan-Patrick (245527)" createdBy_user_id="101393" modified="2022-04-05T12:42:22" modifiedBy="Kaiser, Jan-Patrick (245527)" modifiedBy_user_id="101393" />
      <ExecutionDetails format="TableResult" commandType="SqlCommandOrQuery" exportHandler="" adminControl="" exportMultipleTablesToSheets="False" datesWithTime="False" extraParams="" />
      <Mandators mandatorMode="OnlyOwner" mandator_id="bfa70f6b-484c-49da-9ad7-1ccd8f0d684c" mandatorName="ERGO_e-Campus" isStandard="False" isUsedByMenu="False" />
      <Parameters>
        <Parameter id="d8e4595f-8bdd-4a54-9298-8f378450e6a0" isRequired="True" allowMultiSelect="False" name="Zeitraum" contextName="Zeitraum" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
      </Parameters>
      <Roles>
        <Role id="60" />
        <Role id="70" />
        <Role id="80" />
        <Role id="90" />
      </Roles>
      <command>/*
DECLARE @dateRange_start DATETIME = '2021-01-01 00:00:00.000'
DECLARE @dateRange_end DATETIME = '2022-12-31 00:00:00.000'
*/
DECLARE @learningTypes TABLE
(codeKey NVARCHAR(100),
value   NVARCHAR(100)
)

/* this is related to the translations of the learningTypes like it is done for the GDV system*/
INSERT INTO @learningTypes
SELECT 'Presence',
'Präsenzveranstaltung'
UNION
SELECT 'Single',
'Einzeltraining'
UNION
SELECT 'BlendedLearning',
'Blended Learning'
UNION
SELECT 'GuidedELearning',
'Gesteuertes E-Learning'
UNION
SELECT 'SelfDirectedElearning',
'Selbstgesteuertes E-Learning/Lernen'
UNION
SELECT 'LearningAtWorkplace',
'Lernen am Arbeitsplatz'

SELECT
tu.descUserCn AS "User",
tu.Nachname,
tu.Vorname,
i.title + ' (' + FORMAT(uis.endDate ,'dd.MM.yyyy') + ')' AS "Seminartermin (abgeschlossen)",
ISNULL((SELECT value FROM @learningTypes WHERE codekey = lt.codekey),lt.codekey) AS "Lernform",
uis.educationTime AS "BZ",
CASE
WHEN EXISTS(SELECT * FROM tblUserTrainingActions WHERE user_id = uis.user_id AND training_id = uis.item_id AND actionclass_id = 30 ) THEN 'Ja ' + '(' + FORMAT((SELECT TOP 1 actionTime FROM tblUserTrainingActions WHERE user_id = uis.user_id AND training_id = uis.item_id AND actionclass_id = 30 ORDER BY actionTime DESC),'dd.MM.yyyy') + ')'
ELSE 'Nein'
END AS "Einladung im Vorfeld versandt ja/nein"
INTO #allBz
FROM tblUserItemScores uis
INNER JOIN tblTrainings t ON t.id = uis.item_id
INNER JOIN tableUsers tu ON tu.intUserCn = uis.user_id
INNER JOIN tblItems i ON i.id = t.id
INNER JOIN tblLearningTypes lt ON lt.id = i.learningType_id
WHERE uis.startDate &gt;= @dateRange_start
AND uis.endDate &lt;= @dateRange_end

SELECT
[User],[Nachname],[Vorname],[Seminartermin (abgeschlossen)],[Lernform],
dbo.fn_GetEducationTimeString(SUM(BZ)) AS "BZ erhalten",
[Einladung im Vorfeld versandt ja/nein]
FROM #allBz
GROUP BY [User],[Nachname],[Vorname],[Seminartermin (abgeschlossen)],[Lernform],[Einladung im Vorfeld versandt ja/nein]
Order by Nachname

IF OBJECT_ID('tempdb..#allBz') IS NOT NULL
	DROP TABLE #allBz
</command>
    </Report>
  </Reports>
  <Parameters>
    <Parameter id="d8e4595f-8bdd-4a54-9298-8f378450e6a0" isSystem="True" name="Zeitraum" reportParameterType_id="abff13be-91c3-4ee1-93a3-7292f8e013ba" queryParameterName="@dateRange" />
  </Parameters>
  <ParameterTypes>
    <ParameterType id="abff13be-91c3-4ee1-93a3-7292f8e013ba" isSystem="True" name="DateRange" datatype="DateRange" dataValueField="" dataTextField="" />
  </ParameterTypes>
</ReportsExport>