﻿<?xml version="1.0" encoding="utf-8"?>
<ReportsExport>
  <Reports>
    <Report id="5e6d625c-a4d4-4d7d-a964-19de3cf864ae" codekey="Qualification_FullExport" categoryCodekey="UserStats" name="Vollständiger Qualification Export" description="Dieser Report exportiert alle Punkte unabhängig von Qualifzierungsperioden in der GDV definierten CSV Struktur">
      <MetaData created="2014-08-19T17:34:35" createdBy="Administrator ERGO_e-Campus (Administrator)" createdBy_user_id="243" modified="2019-06-25T14:26:21" modifiedBy="Administrator ERGO_e-Campus" />
      <ExecutionDetails format="TableResult" commandType="SqlCommandOrQuery" exportHandler="" adminControl="" exportMultipleTablesToSheets="False" datesWithTime="True" extraParams="" />
      <Mandators mandatorMode="OnlyOwner" mandator_id="bfa70f6b-484c-49da-9ad7-1ccd8f0d684c" mandatorName="ERGO_e-Campus" isStandard="False" isUsedByMenu="False" />
      <Parameters>
        <Parameter id="7958af06-3e85-4dbe-b2ea-114699e66aa5" isRequired="True" allowMultiSelect="False" name="Qualification" contextName="Qualifizierung" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
      </Parameters>
      <Roles>
        <Role id="50" />
      </Roles>
      <command>
--DECLARE @qualification_id UNIQUEIDENTIFIER
--SET @qualification_id = 'F8C51362-998A-46A3-B46A-F96B3B599A40'

DECLARE @dateTimeFormat INT
SET @dateTimeFormat = 104

DECLARE @qualCodeKey NVARCHAR(20)
SELECT @qualCodeKey = referenceKey
FROM tblQualifications
WHERE id = @qualification_id

DECLARE @learningTypes TABLE
(codeKey NVARCHAR(100),
value   NVARCHAR(100)
)
DECLARE @learningContent TABLE
(codeKey NVARCHAR(100),
value   NVARCHAR(100)
)
DECLARE @table TABLE
(Name                 NVARCHAR(500),
Vorname              NVARCHAR(500),
Geburtsdatum         NVARCHAR(200),
VermittlerID         NVARCHAR(200),
Weiterbildung        NVARCHAR(500),
von                  DATETIME,
bis                  DATETIME,
Lernform              NVARCHAR(200),
Lerninhalt           NVARCHAR(200),
Bildungszeit         INT,
[interne BuchungsID] UNIQUEIDENTIFIER,
user_id              INT
)

/* 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'


/* this is related to the translations of the learningContent like it is done for the GDV system*/
INSERT INTO @learningContent
SELECT 'Insurance1',
'Privat-Vorsorge-Lebens-/Rentenversicherung'
UNION
SELECT 'Insurance2',
'Privat-Vorsorge-Kranken-/Pflegeversicherung'
UNION
SELECT 'Insurance3',
'Privat-Sach-/Schadenversicherung'
UNION
SELECT 'Insurance4',
'Firmenkunden-Sach-/Schadenversicherung'
UNION
SELECT 'Insurance5General',
'Mehrere versicherungsrelevante Themen'
UNION
SELECT 'Insurance6Business',
'Firmenkunden-Vorsorge (bAV/Personenversicherung)'
UNION
SELECT 'Consulting',
'Kundenorientierte Beratung im Versicherungsvertrieb'
UNION
SELECT 'Insurance7',
'Management einer Vertriebseinheit in der Versicherungswirtschaft'
UNION
SELECT 'Insurance8',
'Wirtschaftswissenschaften mit Bezug zur Versicherungsvermittlung/-beratung'
UNION
SELECT 'Insurance9',
'Personalführung mit Bezug zur Versicherungsvermittlung/-beratung'
UNION
SELECT 'Insurance10',
'Versicherungsspezifische Software'

/* let's find all scores from this qualification*/
INSERT INTO @table
SELECT DISTINCT
v_Users.Nachname AS 'lastname',
v_Users.Vorname AS 'firstname',
'',
ISNULL(v_Users.registernumber, '') AS 'registernumber',
COALESCE(tblItemVersions.titleForLearners, tblItemVersions.title) AS 'title',
#tmpScore.startDate AS startDate,
#tmpScore.endDate AS endDate,
tblLearningTypes.codekey AS 'learningType',
tblItemVersions.learningContent AS 'learningContent',
#tmpScore.educationTime,
#tmpScore.id AS 'scorebooking_id',
#tmpScore.user_id AS 'user_id'
FROM tblUserItemScores AS #tmpScore
INNER JOIN tblUserItemScoresQualifications ON tblUserItemScoresQualifications.useritemscore_id = #tmpScore.id
INNER JOIN tblVersionMap ON #tmpScore.item_id = tblVersionMap.id
INNER JOIN tblQualifications ON tblQualifications.id = @qualification_id
AND tblVersionMap.mainVersion = #tmpScore.item_version
AND tblVersionMap.tableName = 'tblItemVersions'
INNER JOIN tblItemVersions ON tblItemVersions.version = tblVersionMap.subVersion
AND tblItemVersions.id = #tmpScore.item_id
LEFT JOIN tblLearningTypes ON tblLearningTypes.id = tblItemVersions.learningType_id
LEFT JOIN v_Users ON v_Users.intUserCn = #tmpScore.user_id
LEFT JOIN tblUserGdvAttributes ON tblUserGdvAttributes.user_id = #tmpScore.user_id
WHERE 1 = 1
AND tblUserItemScoresQualifications.qualification_id = @qualification_id
ORDER BY #tmpScore.user_id

SELECT DISTINCT
Name,
selectTable.Vorname,
Geburtsdatum,
VermittlerID,
Weiterbildung,
CONVERT(NVARCHAR(10), von, @dateTimeFormat) AS 'von',
CONVERT(NVARCHAR(10), bis, @dateTimeFormat) AS 'bis',
ISNULL(ltp.value, Lernform) AS 'Lernform',
ISNULL(cto.value, Lerninhalt) AS 'Lerninhalt',
Bildungszeit AS 'Weiterbildungszeiten in Minuten',
[interne BuchungsID],
'' AS [Ansprechpartner Titel],
'' AS [Ansprechpartner Vorname],
'' AS [Ansprechpartner Nachname],
'' AS [Ansprechpartner Telefon],
'' AS [Ansprechpartner E-Mail],
tableUsers.descUserCn AS [PNR]
FROM @table AS selectTable
INNER JOIN tableUsers ON tableUsers.intUserCn = selectTable.user_id
LEFT JOIN @learningContent AS cto ON cto.codeKey = selectTable.Lerninhalt
LEFT JOIN @learningTypes AS ltp ON ltp.codeKey = selectTable.Lernform
WHERE not importer_id = 2
      </command>
    </Report>
  </Reports>
  <Parameters>
    <Parameter id="7958af06-3e85-4dbe-b2ea-114699e66aa5" isSystem="True" name="Qualification" reportParameterType_id="e629bb84-0db6-4d66-8009-b781cea6a13e" queryParameterName="@qualification_id" />
  </Parameters>
  <ParameterTypes>
    <ParameterType id="e629bb84-0db6-4d66-8009-b781cea6a13e" isSystem="True" name="Qualifications" datatype="StringDDL" dataValueField="id" dataTextField="title">
      <query>
        SELECT tblObjects.id, tblObjects.title
        FROM tblQualifications
        INNER JOIN tblObjects ON tblObjects.id = tblQualifications.id
        WHERE tblObjects .mandator_id = @current_mandator_id AND tblObjects .deleted IS NULL
        ORDER BY tblObjects.title
      </query>
    </ParameterType>
  </ParameterTypes>
</ReportsExport>