﻿<?xml version="1.0" encoding="utf-8"?>
<ReportsExport>
  <Reports>
    <Report id="5e6d625c-a4d4-4d7d-a964-19de3cf864af" codekey="Qualification_Export_GDV" categoryCodekey="UserStats" name="Qualification Export" description="this report exports the existing points (all points) for the requested qualification in a GDV structured table">
      <MetaData created="2014-08-19T17:34:35" createdBy="Administrator ERGO_e-Campus (Administrator)" createdBy_user_id="1" modified="2018-06-04T12:17:11" 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" />
        <Parameter id="7a721121-2d2e-4a3d-b9e6-c6aa238e7ab2" isRequired="True" allowMultiSelect="False" name="Auswahl (ja/nein)" contextName="Starttermin berücksichtigen" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
      </Parameters>
      <Roles>
        <Role id="50" />
      </Roles>
      <command>
--DECLARE @qualification_id UNIQUEIDENTIFIER
--DECLARE @selection_yesno INT
--SET @qualification_id = 'F8C51362-998A-46A3-B46A-F96B3B599A40'
--SET @selection_yesno = 1 -- yes = 1 / no = 0

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'

/* 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
--AND (tblItemVersions.itemType_id &lt;&gt; 50)
AND (tblQualifications.periodBeginning = 0   -- @qualCodeKey = 'Kodex2014'
OR (NULLIF(LTRIM(RTRIM(v_Users.registernumber)), '') IS NOT NULL
AND tblUserGdvAttributes.user_id IS NOT NULL
AND tblUserGdvAttributes.isBDL = 1))
AND (@selection_yesno = 0
OR (@selection_yesno = 1
AND (#tmpScore.created &gt;=
        (
        -- checking for qualification periode for the user
        SELECT TOP 1 startDate
        FROM tblUserQualificationPeriods AS uqp
        WHERE uqp.user_id = #tmpScore.user_id
        AND uqp.qualification_id = tblUserItemScoresQualifications.qualification_id
        AND uqp.endDate IS NULL
        ))))
        ORDER BY #tmpScore.user_id
        SELECT DISTINCT
        selectTable.Name,
        selectTable.Vorname,
        selectTable.Geburtsdatum,
        selectTable.VermittlerID,
        selectTable.Weiterbildung,
        CONVERT(NVARCHAR(10), selectTable.von, @dateTimeFormat) AS 'von',
        CONVERT(NVARCHAR(10), selectTable.bis, @dateTimeFormat) AS 'bis',
        ISNULL(ltp.value, Lernform) AS 'Lernform',
        ISNULL(cto.value, Lerninhalt) AS 'Lerninhalt',
        selectTable.Bildungszeit AS 'Weiterbildungszeiten in Minuten',
        selectTable.[interne BuchungsID],
        '' AS [Ansprechpartner Titel],
        '' AS [Ansprechpartner Vorname],
        '' AS [Ansprechpartner Nachname],
        '' AS [Ansprechpartner Telefon],
        '' AS [Ansprechpartner E-Mail],
        v_Users.descUserCn AS [PNR]
        FROM @table AS selectTable
        INNER JOIN v_Users ON v_Users.intUserCn = selectTable.user_id
        LEFT JOIN @learningContent AS cto ON cto.codeKey = selectTable.Lerninhalt
        LEFT JOIN @learningTypes AS ltp ON ltp.codeKey = selectTable.Lernform
      </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" />
    <Parameter id="7a721121-2d2e-4a3d-b9e6-c6aa238e7ab2" isSystem="True" name="Auswahl (ja/nein)" reportParameterType_id="411ec93b-ab23-41ba-91d6-e7dc0235b5af" queryParameterName="@selection_yesno" />
  </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>
    <ParameterType id="411ec93b-ab23-41ba-91d6-e7dc0235b5af" isSystem="True" name="Boolean" datatype="StringDDL" dataValueField="Value" dataTextField="Text">
      <query>
        SELECT 0 AS Value, 'Nein' AS Text
        UNION
        SELECT 1 AS Value, 'Ja' AS Text
      </query>
    </ParameterType>
  </ParameterTypes>
</ReportsExport>