﻿<?xml version="1.0" encoding="utf-8"?>
<ReportsExport>
  <Reports>
    <Report id="628c4c12-a473-49f1-8ab8-1112110a17fc" codekey="ReCertification_Overview" categoryCodekey="UserStats" name="Re-Qualifizierung und Re-Zertifizierung: Übersicht " description="Liste mit Usern, denen Bausteine zugeordnet sind, die in der Re-Zertifizierung liegen, und Zuweisungs-, Benachrichtigungs- und Ablaufdatum dieser Bausteine.">
      <MetaData created="2011-12-14T16:48:54" createdBy="VIWIS, Administrator (Administrator)" createdBy_user_id="242" modified="2021-01-21T15:58:41" modifiedBy="OnlineLernen, Administrator (Administrator)" modifiedBy_user_id="570" />
      <ExecutionDetails format="TableResult" commandType="SqlCommandOrQuery" exportHandler="" adminControl="" exportMultipleTablesToSheets="False" datesWithTime="False" extraParams="" />
      <Mandators mandatorMode="ExcludeMandators" mandator_id="43426d00-0316-4a94-a703-970f81e29f06" isStandard="False" isUsedByMenu="True" />
      <Parameters>
        <Parameter id="a5485539-67e0-4912-8255-8081a54efb3c" isRequired="False" allowMultiSelect="False" name="Zielgruppe" contextName=":AdminTool.General.Caption.TargetGroups" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="8f8d8125-59de-482e-b14a-607eea600037" isRequired="False" allowMultiSelect="False" name="Benutzer abhängig von Zielgruppe" contextName=":AdminTool.AdminReports.ParameterType.Dynamic.User" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="43fd0f19-d5d6-4283-9343-d1d43c197082" isRequired="False" allowMultiSelect="False" name="Bildungsangebot abhängig von Zielgruppe und User" contextName=":AdminTool.AdminReports.ParameterType.Dynamic.EduOffer" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="82d7d027-a21f-4f17-9c05-afa5bdcecadd" isRequired="False" allowMultiSelect="False" name="Modul abhängig von User, ZG, BA" contextName=":AdminTool.AdminReports.ParameterType.Dynamic.Module" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="aee9472c-2d96-4e67-b86b-e4c2cbff8ca3" isRequired="False" allowMultiSelect="False" name="BausteinTyp (nur mit Status, schöne Namen)" contextName=":AdminTool.AdminReports.ParameterType.Dynamic.Bausteintyp" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="9bb714ff-d31b-46a0-aaa1-b756d429fce5" isRequired="False" allowMultiSelect="False" name="ReZertiQuali" contextName=":AdminTool.AdminReports.ParameterType.Dynamic.RecertRequalif" defaultValue="Both" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="0be4084e-cfa6-4fb9-8bd4-c873259ab0d1" isRequired="False" allowMultiSelect="False" name="Baustein abh. von User, ZG, BA, Module, Typ" contextName=":AdminTool.AdminReports.ParameterType.Dynamic.Baustein" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
      </Parameters>
      <Roles>
        <Role id="90" />
      </Roles>
      <command> --       DECLARE @current_mandator_id UNIQUEIDENTIFIER
 --       DECLARE @targetGroup_id INT
 --       DECLARE @user_id INT
 --       DECLARE @eduOffer_id UNIQUEIDENTIFIER
 --       DECLARE @module_id UNIQUEIDENTIFIER
 --       DECLARE @itemType NVARCHAR(50)
 --       DECLARE @item_id UNIQUEIDENTIFIER
 --       DECLARE @reCertiQuali NVARCHAR(50)

	--SET @targetGroup_id = 2052
 --   SET @current_mandator_id = '43426D00-0316-4A94-A703-970F81E29F06'
	--SET @reCertiQuali = 'OnlyQuali'

		CREATE TABLE #itemMainVersion
		(
			item_id UNIQUEIDENTIFIER,
			mainVersion INT
		)
CREATE TABLE #Result ([User] varchar(128), 
user_id INT,
								Nachname varchar(128), 
								Vorname varchar(128), 
								division varchar(128), 
								office varchar(128), 
								item_id UNIQUEIDENTIFIER,
								itemType_id INT,
								codekey varchar(128), 
								itemTitle varchar(256), 
								itemTfl varchar(256), 
								tag varchar(256), 
								excluded INT,
								overrideInitialMonths int, 
								overrideSpanMonths int, 
								overrideAlertSpanMonths int, 
								assignedDate datetime, 
								periodStart date, 
								alertSentDate datetime, 
								finalAlertSentDate datetime, 
								overrideDate datetime, 
								requalificationPeriodType INT, 
								newCreditPointsSpanMonths int, 
								readyForNewCreditPointsDate datetime, 
								voluntaryOverrideDate datetime,
								status INT NULL,
								lastPassedEver datetime NULL,
								version INT NULL,
								userStatus INT
								)
		INSERT INTO #Result 
			SELECT tableUsers.descUserCn AS [User],
			tableUsers.intUserCn,
			tableUsers.Nachname,
			tableUsers.Vorname,
			tableUsers.division,
			tableUsers.office,
			tblItems.id,
			tblItems.itemType_id,
			tblItemTypes.codekey,
			tblItems.title AS itemTitle,
			tblItems.titleForLearners AS itemTfl,
			tblItems.tag,
			dbo.fn_IsUserExcludedFromRecertification(tableUsers.intUserCn, tblItems.id),
			tblItems.overrideInitialMonths,
			tblItems.overrideSpanMonths,
			tblItems.overrideAlertSpanMonths,
			tblStatusUserItemOverride.assignedDate,
			tblStatusUserItemOverride.periodStart,
			tblStatusUserItemOverride.overrideAlertSentDate AS alertSentDate,
			tblStatusUserItemOverride.overrideFinalAlertSentDate AS finalAlertSentDate,
			tblStatusUserItemOverride.overrideDate,
			tblItems.requalificationPeriodType,
			tblItems.newCreditPointsSpanMonths,
			tblStatusUserItemOverride.readyForNewCreditPointsDate,
			tblStatusUserItemOverride.voluntaryOverrideDate,
			NULL,
			NULL,
			NULL,
			tableUsers.userStatus
			FROM tableUsers,
			tblItems
			INNER JOIN tblItemTypes ON tblItems.itemType_id = tblItemTypes.id,
			tblStatusUserItemOverride
			WHERE tableUsers.mandator_id = @current_mandator_id
			AND tableUsers.intUserCn = tblStatusUserItemOverride.user_id
			AND tblItems.id = tblStatusUserItemOverride.item_id
			AND tblItems.deleted IS NULL
			AND tableUsers.deleted IS NULL
			AND (@reCertiQuali IS NULL OR NOT @reCertiQuali = 'OnlyCerti' OR (tblItems.overrideSpanMonths IS NOT NULL AND ISNULL(tblItems.requalificationPeriodType, 0) = 0))
			AND (@reCertiQuali IS NULL OR NOT @reCertiQuali = 'OnlyQuali' OR (ISNULL(tblItems.requalificationPeriodType, 0) &gt; 0 AND tblItems.overrideSpanMonths IS NULL))
			AND (@reCertiQuali IS NULL OR NOT @reCertiQuali = 'Both' OR tblItems.overrideSpanMonths IS NOT NULL OR ISNULL(tblItems.requalificationPeriodType, 0) &gt; 0)
        AND (@user_id IS NULL OR tableUsers.intUserCn = @user_id)
        AND (@targetGroup_id IS NULL OR (tableUsers.intUserCn IN (SELECT UserCn FROM tblUsersTargetGroups WHERE targetGroup_id = @targetGroup_id)
        AND EXISTS (SELECT * FROM tblEduOffersTargetGroups WHERE targetGroup_id = @targetGroup_id)))
        AND (@module_id IS NULL
        OR tblItems.id = @module_id
        OR tblItems.id IN (
        SELECT item_id
        FROM tblModuleItems
        WHERE module_id = @module_id))
        AND (@eduOffer_id IS NULL
        OR tblItems.id IN (SELECT module_id FROM tblEduOffersModules WHERE eduOffer_id = @eduOffer_id)
        OR tblItems.id IN (
        SELECT item_id
        FROM tblModuleItems
        WHERE module_id IN (SELECT module_id FROM tblEduOffersModules WHERE eduOffer_id = @eduOffer_id)))
        AND (@itemType IS NULL OR tblItems.itemType_id = (SELECT id FROM tblItemTypes WHERE codekey = @itemType))
        AND (@item_id IS NULL OR tblItems.id = @item_id)

		PRINT 'GETTING MAINVERSIONS'
		INSERT INTO #itemMainVersion
		SELECT item_id, (SELECT MAX(mainVersion) FROM tblVersionMap WHERE id = #Result.item_id) FROM #Result GROUP BY item_id

		-- for all users which don't have any status we know there is no status or lastpastdate
		PRINT 'SETTIG NONE VERSIONS'
		UPDATE #Result SET status = -1, lastPassedEver = NULL, version = innerQuery.mainVersion
		FROM #Result
		INNER JOIN #itemMainVersion AS innerQuery ON innerQuery.item_id = #Result.item_id
		WHERE NOT EXISTS(SELECT * FROM tblStatusUserItemHistory WHERE user_id = #Result.user_id AND item_id = #Result.item_id)
		
		-- checking for last status information for the users with endDate NULL and not overwritten
		-- so we also get the lastPassedDate
		PRINT 'GETTING GREEN STATUS AND LAST PASSED EVER'
		UPDATE #Result
		SET status = suih.status, lastPassedEver = suih.startDate, version = suih.item_version
		FROM #Result
		INNER JOIN tblStatusUserItemHistory suih ON suih.user_id = #Result.user_id AND suih.item_id = #Result.item_id AND suih.endDate IS NULL AND suih.status = 2
		AND suih.overrideDate IS NULL AND suih.voluntaryOverrideDate IS NULL

		-- if there are not entries with status available get them via status calculation
		IF EXISTS(SELECT * FROM #Result WHERE #Result.status IS NULL)
		BEGIN
			-- for those entries without status we have to take the mainversion of the item
			PRINT 'GETTIG MISSING STATUSES'
			UPDATE #Result SET status = ISNULL(dbo.fn_GetUserItemStatus(user_id, #Result.item_id),0),
			version = innerQuery.mainVersion 
			FROM #Result INNER JOIN #itemMainVersion AS innerQuery ON innerQuery.item_id = #Result.item_id
			WHERE #Result.status IS NULL
		END

		;WITH CTE
		AS
		(
        SELECT *,
        CASE WHEN status = -1 THEN NULL ELSE 
		CASE WHEN lastPassedEver IS NULL THEN
			dbo.fn_GetUserPlainModuleItemLastPassedEver(#Result.user_id, #Result.item_id)
		ELSE
		lastPassedEver
		END 
		END AS lastPassedEverCalculated
        FROM #Result)
SELECT [User],
        Nachname,
        Vorname,
        division AS Abteilung,
        office AS Dienststelle,
        codekey AS BausteinTyp,
        itemTitle AS Baustein,
        itemTfl AS BausteinTfL,
        tag AS 'Kennzeichen',
        version AS 'Version',
        CASE excluded
			WHEN 0 THEN 'Nein'
			ELSE 'Ja'
			END AS 'ReZertiAusgeschlossen',
        CASE WHEN excluded = 0 THEN overrideInitialMonths ELSE NULL END AS ReZertiErstMonate,
        CASE WHEN excluded = 0 THEN overrideSpanMonths ELSE NULL END AS ReZertiMonate,
        CASE WHEN excluded = 0 THEN overrideAlertSpanMonths ELSE NULL END AS ReZertiBenachrichtigung,
        assignedDate AS Zugewiesen,
        lastPassedEver AS 'Zuletzt erfolgreich durchgeführt',
        dbo.fn_GetUserItemStatusWillOverrideDate(user_id, item_id) AS 'Gültig bis',
        CASE ISNULL(NULLIF(status,-1),0)
			WHEN 0 THEN
			CASE itemType_id
			WHEN 8 THEN 'nicht teilgenommen'
			ELSE 'nicht bearbeitet'
			END
			WHEN 1 THEN 'in Bearbeitung'
			WHEN 2 THEN
			CASE itemType_id
			WHEN 0 THEN 'bestanden'
			WHEN 8 THEN 'teilgenommen'
			ELSE 'vollständig bearbeitet'
			END
			WHEN 3 THEN 'nicht bestanden'
			END AS 'Status (Text)',
        alertSentDate AS '1. Mail',
        finalAlertSentDate AS '2. Mail',
        overrideDate AS 'Abgelaufen am',
        requalificationPeriodType AS ReQualiType,
        newCreditPointsSpanMonths AS ReQualiMonate,
        readyForNewCreditPointsDate AS 'Bereit für neue BZ',
        voluntaryOverrideDate AS 'Freiwillig zurückgesetzt',
		CASE 
			WHEN userStatus = 0 THEN 'Unbekannt' 
			WHEN userStatus = 1 THEN 'Aktiv' 
			WHEN userStatus = 2 THEN 'Ausgeschieden'
			WHEN userStatus = 3 THEN 'Abwesend'
			WHEN userStatus = 4 THEN 'Neueinstellung'
		END AS UserStatus
		FROM CTE


        DROP TABLE #Result
		DROP TABLE #itemMainVersion

</command>
    </Report>
  </Reports>
  <Parameters>
    <Parameter id="a5485539-67e0-4912-8255-8081a54efb3c" isSystem="True" name="Zielgruppe" reportParameterType_id="9ae252e1-18b4-4b71-982c-e27b2d3a5287" queryParameterName="@targetGroup_id" />
    <Parameter id="8f8d8125-59de-482e-b14a-607eea600037" isSystem="False" name="Benutzer abhängig von Zielgruppe" reportParameterType_id="c955aa52-5595-486a-b3d0-85ba18e0f87b" queryParameterName="@user_id" />
    <Parameter id="43fd0f19-d5d6-4283-9343-d1d43c197082" isSystem="True" name="Bildungsangebot abhängig von Zielgruppe und User" reportParameterType_id="b0c145d9-bff0-420a-ac70-8ca5bd1938db" queryParameterName="@eduOffer_id" />
    <Parameter id="82d7d027-a21f-4f17-9c05-afa5bdcecadd" isSystem="True" name="Modul abhängig von User, ZG, BA" reportParameterType_id="3affdc00-a5e0-42bc-b746-66ffe9c691ee" queryParameterName="@module_id" />
    <Parameter id="aee9472c-2d96-4e67-b86b-e4c2cbff8ca3" isSystem="True" name="BausteinTyp (nur mit Status, schöne Namen)" reportParameterType_id="32872b47-da0f-49d9-8853-0aa4760c5a11" queryParameterName="@itemType" />
    <Parameter id="9bb714ff-d31b-46a0-aaa1-b756d429fce5" isSystem="True" name="ReZertiQuali" reportParameterType_id="adc4118a-697d-47f5-abc3-8e31129550af" queryParameterName="@reCertiQuali" />
    <Parameter id="0be4084e-cfa6-4fb9-8bd4-c873259ab0d1" isSystem="True" name="Baustein abh. von User, ZG, BA, Module, Typ" reportParameterType_id="fdb7c25a-2c8d-4168-801d-da05d8d41c7f" queryParameterName="@item_id" />
  </Parameters>
  <ParameterTypes>
    <ParameterType id="9ae252e1-18b4-4b71-982c-e27b2d3a5287" isSystem="True" name="TargetGroup" datatype="TargetGroup" dataValueField="" dataTextField="" />
    <ParameterType id="c955aa52-5595-486a-b3d0-85ba18e0f87b" isSystem="True" name="Benutzer abhängig von Zielgruppe" datatype="IntegerDDL" dataValueField="user_id" dataTextField="name">
      <query>SELECT intUserCn AS user_id,
       nachname + ', ' + vorname + ' (' + descUserCn + ')' AS name
  FROM tableUsers
 WHERE mandator_id = @current_mandator_id
   AND deleted IS NULL
   AND (@targetGroup_id IS NULL 
        OR EXISTS (SELECT * FROM tblUsersTargetGroups 
                    WHERE tblUsersTargetGroups.targetGroup_id = @targetGroup_id
                      AND tblUsersTargetGroups.UserCn = tableUsers.intUserCn
                  )
       )
ORDER BY nachname
</query>
      <Parameters>
        <Parameter id="a5485539-67e0-4912-8255-8081a54efb3c" isRequired="False" allowMultiSelect="False" name="Zielgruppe" contextName="Zielgruppe" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
      </Parameters>
    </ParameterType>
    <ParameterType id="b0c145d9-bff0-420a-ac70-8ca5bd1938db" isSystem="True" name="Bildungsangebot abhängig von Zielgruppe und User" datatype="GuidDDL" dataValueField="id" dataTextField="title">
      <query>SELECT tblItems.id,
       tblItems.title
  FROM tblItems 
 WHERE tblItems.mandator_id = @current_mandator_id
   AND tblItems.deleted IS NULL
   AND tblItems.itemType_id = (SELECT id FROM tblItemTypes WHERE codekey = 'EduOffer')
   AND (@user_id IS NULL 
        OR EXISTS (SELECT * 
                     FROM tblUsersTargetGroups
                          INNER JOIN tblEduOffersTargetGroups ON tblEduOffersTargetGroups.targetGroup_id = tblUsersTargetGroups.targetGroup_id
                    WHERE tblUsersTargetGroups.UserCn = @user_id
                      AND tblEduOffersTargetGroups.eduOffer_id = tblItems.id
                  )
       )
   AND (@targetGroup_id IS NULL 
        OR EXISTS (SELECT * 
                     FROM tblEduOffersTargetGroups 
                    WHERE tblEduOffersTargetGroups.targetGroup_id = @targetGroup_id
                      AND tblEduOffersTargetGroups.eduOffer_id = tblItems.id
                  )
       )
ORDER BY tblItems.title</query>
      <Parameters>
        <Parameter id="a5485539-67e0-4912-8255-8081a54efb3c" isRequired="False" allowMultiSelect="False" name="Zielgruppe" contextName="Zielgruppe" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="8f8d8125-59de-482e-b14a-607eea600037" isRequired="False" allowMultiSelect="False" name="Benutzer abhängig von Zielgruppe" contextName="Benutzer abhängig von Zielgruppe" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
      </Parameters>
    </ParameterType>
    <ParameterType id="3affdc00-a5e0-42bc-b746-66ffe9c691ee" isSystem="True" name="Modul abhängig von User, ZG, BA" datatype="GuidDDL" dataValueField="id" dataTextField="title">
      <query>SELECT tblItems.id,
       tblItems.title
  FROM tblItems
 WHERE tblItems.mandator_id = @current_mandator_id
   AND tblItems.deleted IS NULL
   AND tblItems.itemType_id = (SELECT id FROM tblItemTypes WHERE codekey = 'Module')
   AND (@user_id IS NULL 
        OR EXISTS (SELECT * 
                     FROM tblUsersTargetGroups
                          INNER JOIN tblEduOffersTargetGroups ON tblEduOffersTargetGroups.targetGroup_id = tblUsersTargetGroups.targetGroup_id
                          INNER JOIN tblEduOffersModules ON tblEduOffersModules.eduOffer_id = tblEduOffersTargetGroups.eduOffer_id
                    WHERE tblUsersTargetGroups.UserCn = @user_id
                      AND tblEduOffersModules.module_id = tblItems.id
                  )
       )
   AND (@targetGroup_id IS NULL 
        OR EXISTS (SELECT * 
                     FROM tblEduOffersTargetGroups
                          INNER JOIN tblEduOffersModules ON tblEduOffersModules.eduOffer_id = tblEduOffersTargetGroups.eduOffer_id
                    WHERE tblEduOffersTargetGroups.targetGroup_id = @targetGroup_id
                      AND tblEduOffersModules.module_id = tblItems.id
                  )
       )
   AND (@eduOffer_id IS NULL 
        OR EXISTS (SELECT * 
                     FROM tblEduOffersModules 
                    WHERE tblEduOffersModules.eduOffer_id = @eduOffer_id
                      AND tblEduOffersModules.module_id = tblItems.id
                  )
       )
ORDER BY tblItems.title</query>
      <Parameters>
        <Parameter id="8f8d8125-59de-482e-b14a-607eea600037" isRequired="False" allowMultiSelect="False" name="Benutzer abhängig von Zielgruppe" contextName="Benutzer abhängig von Zielgruppe" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="a5485539-67e0-4912-8255-8081a54efb3c" isRequired="False" allowMultiSelect="False" name="Zielgruppe" contextName="Zielgruppe" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="43fd0f19-d5d6-4283-9343-d1d43c197082" isRequired="False" allowMultiSelect="False" name="Bildungsangebot abhängig von Zielgruppe und User" contextName="Bildungsangebot abhängig von Zielgruppe und User" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
      </Parameters>
    </ParameterType>
    <ParameterType id="32872b47-da0f-49d9-8853-0aa4760c5a11" isSystem="True" name="ItemType (with Status, nice names)" datatype="StringDDL" dataValueField="codekey" dataTextField="text">
      <query>DECLARE @itemTypes AS TABLE (
    codekey NVARCHAR(50),
    text NVARCHAR(50)
)

INSERT INTO @itemTypes VALUES ('Theme', 'Lernprogramm')
INSERT INTO @itemTypes VALUES ('Test', 'Test')
INSERT INTO @itemTypes VALUES ('TrainingTitle', 'Seminartitel')
INSERT INTO @itemTypes VALUES ('Document', 'Dokument')

SELECT codekey, text FROM @itemTypes ORDER BY text</query>
    </ParameterType>
    <ParameterType id="adc4118a-697d-47f5-abc3-8e31129550af" isSystem="True" name="ReZertiQuali" datatype="StringDDL" dataValueField="codekey" dataTextField="text">
      <query>DECLARE @reCertiQuali AS TABLE (
    codekey NVARCHAR(50),
    text NVARCHAR(50)
)

INSERT INTO @reCertiQuali VALUES ('OnlyCerti', 'Nur Re-Zertifizierung')
INSERT INTO @reCertiQuali VALUES ('OnlyQuali', 'Nur Re-Qualifizierung')
INSERT INTO @reCertiQuali VALUES ('Both', 'Re-Zertifizierung und/oder Re-Qualifizierung')

SELECT codekey, text FROM @reCertiQuali 
</query>
    </ParameterType>
    <ParameterType id="fdb7c25a-2c8d-4168-801d-da05d8d41c7f" isSystem="True" name="Baustein abh. von User, ZG, BA, Modul, Typ" datatype="GuidDDL" dataValueField="id" dataTextField="title">
      <query>
        SELECT tblItems.id,
        tblItems.title
        FROM tblItems
        WHERE tblItems.mandator_id = @current_mandator_id
        AND tblItems.deleted IS NULL
        AND (@itemType IS NULL OR tblItems.itemType_id = (SELECT id FROM tblItemTypes WHERE codekey = @itemType))
        AND (@user_id IS NULL
        OR EXISTS (SELECT *
        FROM tblUsersTargetGroups
        INNER JOIN tblEduOffersTargetGroups ON tblEduOffersTargetGroups.targetGroup_id = tblUsersTargetGroups.targetGroup_id
        INNER JOIN tblEduOffersModules ON tblEduOffersModules.eduOffer_id = tblEduOffersTargetGroups.eduOffer_id
        INNER JOIN tblModuleItems ON tblModuleItems.module_id = tblEduOffersModules.module_id
        WHERE tblUsersTargetGroups.UserCn = @user_id
        AND tblModuleItems.item_id = tblItems.id
        )
        )
        AND (@targetGroup_id IS NULL
        OR EXISTS (SELECT *
        FROM tblEduOffersTargetGroups
        INNER JOIN tblEduOffersModules ON tblEduOffersModules.eduOffer_id = tblEduOffersTargetGroups.eduOffer_id
        INNER JOIN tblModuleItems ON tblModuleItems.module_id = tblEduOffersModules.module_id
        WHERE tblEduOffersTargetGroups.targetGroup_id = @targetGroup_id
        AND tblModuleItems.item_id = tblItems.id
        )
        )
        AND (@eduOffer_id IS NULL
        OR EXISTS (SELECT *
        FROM tblEduOffersModules
        INNER JOIN tblModuleItems ON tblModuleItems.module_id = tblEduOffersModules.module_id
        WHERE tblEduOffersModules.eduOffer_id = @eduOffer_id
        AND tblModuleItems.item_id = tblItems.id
        )
        )
        AND (@module_id IS NULL
        OR EXISTS (SELECT *
        FROM tblModuleItems
        WHERE tblModuleItems.module_id = @module_id
        AND tblModuleItems.item_id = tblItems.id
        )
        )
        AND (@reCertiQuali IS NULL OR NOT @reCertiQuali = 'OnlyCerti' OR (tblItems.overrideSpanMonths IS NOT NULL AND ISNULL(tblItems.requalificationPeriodType, 0) &lt;&gt; 2))
        AND (@reCertiQuali IS NULL OR NOT @reCertiQuali = 'OnlyQuali' OR ((tblItems.newCreditPointsSpanMonths IS NOT NULL OR tblItems.requalificationPeriodType = 1) AND tblItems.overrideSpanMonths IS NULL))
        AND (@reCertiQuali IS NULL OR NOT @reCertiQuali = 'Both' OR tblItems.overrideSpanMonths IS NOT NULL OR (tblItems.newCreditPointsSpanMonths IS NOT NULL OR tblItems.requalificationPeriodType = 1))

        ORDER BY tblItems.title
      </query>
      <Parameters>
        <Parameter id="a5485539-67e0-4912-8255-8081a54efb3c" isRequired="False" allowMultiSelect="False" name="Zielgruppe" contextName="Zielgruppe" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="aee9472c-2d96-4e67-b86b-e4c2cbff8ca3" isRequired="False" allowMultiSelect="False" name="BausteinTyp (nur mit Status, schöne Namen)" contextName="BausteinTyp" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="8f8d8125-59de-482e-b14a-607eea600037" isRequired="False" allowMultiSelect="False" name="Benutzer abhängig von Zielgruppe" contextName="Benutzer abhängig von Zielgruppe" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="43fd0f19-d5d6-4283-9343-d1d43c197082" isRequired="False" allowMultiSelect="False" name="Bildungsangebot abhängig von Zielgruppe und User" contextName="Bildungsangebot abhängig von Zielgruppe und User" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="82d7d027-a21f-4f17-9c05-afa5bdcecadd" isRequired="False" allowMultiSelect="False" name="Modul abhängig von User, ZG, BA" contextName="Modul abhängig von User, ZG, BA" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="9bb714ff-d31b-46a0-aaa1-b756d429fce5" isRequired="False" allowMultiSelect="False" name="ReZertiQuali" contextName="ReZertiQuali" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
      </Parameters>
    </ParameterType>
  </ParameterTypes>
</ReportsExport>