﻿<?xml version="1.0" encoding="utf-8"?>
<ReportsExport>
  <Reports>
    <Report id="32E7E95B-8A6E-4708-A90E-498D8B51E263" codekey="Debeka_Export_Trainingdata" categoryCodekey="Trainings" name="Exporte für Workday - Seminardaten" description="">
      <MetaData created="2023-12-15T11:13:07" createdBy="Administrator VIWIS" modified="2023-12-15T17:15:35" modifiedBy="Administrator Debeka" />
      <ExecutionDetails format="TableResult" commandType="SqlCommandOrQuery" exportHandler="" adminControl="" exportMultipleTablesToSheets="False" datesWithTime="False" extraParams="" />
      <Mandators mandatorMode="OnlyOwner" mandator_id="6279bb24-f218-49e0-9155-7c1cb1dba226" mandatorName="Debeka" isStandard="False" isUsedByMenu="False" />
      <Parameters>
        <Parameter id="484671FD-6FAE-4FE5-B95A-201687273C39" isRequired="True" allowMultiSelect="False" name="Begin Jahr" contextName="Begin Jahr" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="C6703A6E-C27F-4EFD-8E60-C9D7883C10EC" isRequired="True" allowMultiSelect="False" name="Ende Jahr" contextName="Ende Jahr" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
      </Parameters>
      <Roles>
        <Role id="90" />
      </Roles>
      <command>
		  --DECLARE @startYearDefault INT = 2020
		  --DECLARE @endYearDefault INT = 2023
		  --SET @startYear = ISNULL(@startYear, @startYearDefault)
		  --SET @endYear = ISNULL(@endYear, @endYearDefault)

		  SELECT
			  tti.id as 'SeminartitelId',
			  tti.title as 'Titel',
			  tti.titleForLearners as 'Titel für Lerner',
			  REPLACE(REPLACE(tti.description, CHAR(13), ''), CHAR(10), '') as 'Beschreibung',
			  REPLACE(REPLACE(CONVERT(VARCHAR(MAX), tt.contents), CHAR(13), ''), CHAR(10), '') as 'Inhalte',				-- ??? in one column with description
			  REPLACE(REPLACE(CONVERT(VARCHAR(MAX), tt.target), CHAR(13), ''), CHAR(10), '') as 'Lernziele',
			  REPLACE(REPLACE(CONVERT(VARCHAR(MAX), tt.participants), CHAR(13), ''), CHAR(10), '') as 'Teilnehmer',
			  te.id as 'SeminarterminId',
			  tti.title as 'Seminartitel',
			  tei.title as 'Titel',
			  tei.titleForLearners as 'Titel für Lerner',
			  tei.tag as 'Kennzeichen',
			  REPLACE(REPLACE(dbo.fn_GetTrainersForTrainingEvent(te.id, -1, 'Anonym (gelöscht)'), CHAR(13), ''), CHAR(10), '') as 'Trainer-Kennungen',
			  convert(date, te.startDate) as 'Startdatum',
			  format(te.startDate, 'HH:mm') as 'Startzeit',
			  convert(date, te.endDate) as 'Endedatum',
			  format(te.endDate, 'HH:mm') as 'Endezeit',
			  COALESCE(NULLIF(tl.titleForLearners,''), tl.title) as 'Veranstaltungsort',
			  te.location as 'Ort',
			  REPLACE(REPLACE(STUFF((
			  select ', ' + COALESCE(NULLIF(h.titleForLearners,''), h.title)
			  from tblHotels h inner join tblTrainingHotels th on h.id=th.hotel_id
			  where th.training_id=te.id
			  FOR XML PATH(''),TYPE).value('.','NVARCHAR(MAX)'), 1, 2, ''), CHAR(13), ''), CHAR(10), '') as 'Hotel',
			  REPLACE(REPLACE(STUFF((
			  select ', ' + a.title
			  from tblAnnotations a inner join tblObjectsAnnotations oa on a.id=oa.annotation_id
			  where oa.object_id=te.id
			  FOR XML PATH(''),TYPE).value('.','NVARCHAR(MAX)'), 1, 2, ''), CHAR(13), ''), CHAR(10), '') as 'Dateien/Annotationen',
			  tei.educationTime as 'BZ',
			  CASE
				WHEN tei.learningType_id = 1 THEN 'Präsenzveranstaltung'
				WHEN tei.learningType_id = 2 THEN 'Einzeltraining'
				WHEN tei.learningType_id = 3 THEN 'Blended Learning'
				WHEN tei.learningType_id = 4 THEN 'gesteuertes E-Learning'
				WHEN tei.learningType_id = 5 THEN 'selbstgesteuertes E-Learning'
				WHEN tei.learningType_id = 6 THEN 'Lernen am Arbeitsplatz'
				ELSE '-'
			  END as 'Lernform',
			  CASE
				WHEN tei.learningContent = 'Insurance1' THEN 'Privat-Vorsorge-Lebens-/Rentenversicherung'
				WHEN tei.learningContent = 'Insurance2' THEN 'Privat-Vorsorge-Kranken-/Pflegeversicherung'
				WHEN tei.learningContent = 'Insurance3' THEN 'Privat-Sach-/Schadenversicherung'
				WHEN tei.learningContent = 'Insurance4' THEN 'Firmenkunden-Sach-/Schadenversicherung'
				WHEN tei.learningContent = 'Insurance5General' THEN 'Spartenübergreifend'
				WHEN tei.learningContent = 'Insurance6Business' THEN 'Firmenkunden-Vorsorge (bAV/Personenversicherung)'
				WHEN tei.learningContent = 'Consulting' THEN 'Beratungskompetenz'
				ELSE '-'
			  END as 'Lerninhalt',
			  u.office as 'Dienststelle',
			  u.division as 'Abteilung',
			  u.descUserCn as 'Kennung',
			  u.Nachname as 'Name',
			  u.Vorname as 'Vorname',
			  (select customAttribute1 from tblUserCustomAttributes where user_id = u.intUserCn) as 'Funktion',
			  CASE uts.actionclass_id
			  WHEN 10 THEN 'Auf Warteliste'
			  WHEN 20 THEN 'Gebucht'
			  WHEN 30 THEN 'Eingeladen'
			  WHEN 40 THEN 'Storniert'
			  WHEN 50 THEN 'Zurückgesetzt'
			  WHEN 60 THEN 'Einladung bestätigt'
			  WHEN 65 THEN 'Abgesagt'
			  WHEN 70 THEN 'Anwesenheit bestätigt'
			  WHEN 80 THEN 'Teilnahme bestätigt'
			  WHEN 85 THEN 'Teilnahme bestätigt (nicht alle Feedbackbögen ausgeführt)'
			  END as 'Buchungsstatus'
		  FROM tblTrainingTitles tt
			  inner join tblItems tti on tti.id = tt.id
			  inner join tblTrainings te on tt.id = te.trainingTitle_id
			  inner join tblItems tei on tei.id = te.id
			  inner join tblUserTrainingStatus uts on uts.training_id = te.id
			  inner join v_Users u on u.intUserCn = uts.user_id
			  left join tblTrainingLocations tl ON tl.id = te.trainingLocation_id
		  WHERE year(endDate) &gt;= @startYear and year(endDate) &lt;= @endYear
			and uts.actionclass_id &gt;= 80
			and u.mandator_id = @current_mandator_id
		  ORDER BY tti.id, te.endDate, u.Nachname
	  </command>
    </Report>
  </Reports>
  <Parameters>
    <Parameter id="484671FD-6FAE-4FE5-B95A-201687273C39" isSystem="False" name="Begin Jahr" reportParameterType_id="0DC63A9E-0CC5-43B7-B260-DEDFBF962D90" queryParameterName="@startYear" />
    <Parameter id="C6703A6E-C27F-4EFD-8E60-C9D7883C10EC" isSystem="False" name="Ende Jahr" reportParameterType_id="0DC63A9E-0CC5-43B7-B260-DEDFBF962D90" queryParameterName="@endYear" />
  </Parameters>
  <ParameterTypes>
    <ParameterType id="0DC63A9E-0CC5-43B7-B260-DEDFBF962D90" isSystem="False" name="Jahr" datatype="IntegerDDL" dataValueField="year_id" dataTextField="year_name">
      <query>
        ; WITH yearsCTE AS
        (
        SELECT YEAR('2013-01-01') as year
        UNION ALL
        SELECT year + 1
        FROM yearsCTE
        WHERE year &lt; YEAR(GETDATE())
        )
        SELECT year AS year_id, cast(year as nvarchar(64)) AS year_name
        FROM yearsCTE
      </query>
    </ParameterType>
  </ParameterTypes>
</ReportsExport>