﻿<?xml version="1.0" encoding="utf-8"?>
<ReportsExport>
  <Reports>
    <Report id="234ac03a-0de1-4d34-b89c-f0b3d39cb2ba" codekey="CPL_Helper_BereichsleiterGruppenleiter" categoryCodekey="Testing" name="CPL Helper Bereichs- und Gruppenleiter" description="Lists all OUs of the given Nodelevel and all users with position 1 in the OU">
      <MetaData created="2022-09-15T16:53:35" createdBy="Kaiser, Jan-Patrick (245527)" createdBy_user_id="101393" modified="2023-07-06T15:53:32" modifiedBy="ERGO_e-Campus, Administrator (Administrator)" modifiedBy_user_id="243" />
      <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="8a788b48-9545-44e3-a700-678759456e6a" isRequired="False" allowMultiSelect="False" name="Ganze Zahl" contextName="Berichtsebene" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
      </Parameters>
      <Roles />
      <command>/*DECLARE @mandator_name NVARCHAR(64)= 'ERGO_e-Campus'
DECLARE @current_mandator_id UNIQUEIDENTIFIER = (SELECT id FROM tblMandators WHERE name = @mandator_name)
DECLARE @nodeLevel typeIntList
INSERT INTO @nodeLevel VALUES	--(2) -- 1.BE
								--(3) -- 2.BE
								--(4)  -- 3.BE
*/
--SELECT 
--id,
--RTRIM(LTRIM(title)),
--ISNULL(STUFF((
--SELECT ', ' + uwd.descUserCn
--FROM tblUsersOrganisationUnits uo
--INNER JOIN v_UsersWithData uwd ON uwd.user_id = uo.user_id
--WHERE uo.organisationUnit_id = ou.id and position = 1
--ORDER BY title
--FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 1, ''), '') AS "Org. Einheit FK"
--FROM tblOrganisationUnits ou
--WHERE mandator_id = @current_mandator_id
--AND deleted IS NULL
--AND nodeLevel in (SELECT * FROM @nodeLevel)

SELECT	ou.id AS ou_id,
		RTRIM(LTRIM(ou.title)) AS ou_title,
		FK.DescUserCn,
		FK.Nachname,
		FK.Vorname,
		FK.email,
		ou.nodeLevel
FROM	tblOrganisationUnits ou
OUTER APPLY(
	SELECT	uwd.DescUserCn,
			uwd.Nachname,
			uwd.Vorname,
			uwd.email
	FROM	tblUsersOrganisationUnits uou
	JOIN	v_UsersWithData uwd
				ON uwd.intUserCn = uou.user_id
	WHERE	uou.organisationUnit_id = ou.id
	AND		uou.position = 1
) FK
WHERE	ou.mandator_id = @current_mandator_id
AND		ou.deleted IS NULL
AND		ou.nodeLevel = @integer

ORDER BY ou.nodeLevel ASC</command>
    </Report>
  </Reports>
  <Parameters>
    <Parameter id="8a788b48-9545-44e3-a700-678759456e6a" isSystem="True" name="Ganze Zahl" reportParameterType_id="51b6166f-7a5a-4db3-b4ae-d9b9632dc129" queryParameterName="@integer" />
  </Parameters>
  <ParameterTypes>
    <ParameterType id="51b6166f-7a5a-4db3-b4ae-d9b9632dc129" isSystem="True" name="Integer" datatype="Integer" dataValueField="" dataTextField="" />
  </ParameterTypes>
</ReportsExport>