﻿<?xml version="1.0" encoding="utf-8"?>
<ReportsExport>
  <Reports>
    <Report id="266bffab-a9e8-41cc-b0d7-fdea3b95f331" codekey="LearningProgramEvaluationTGM" categoryCodekey="UserStats" name="Statusreport Lernprogramme" description="Lerner nach Lernstand und Zertifikat">
      <MetaData created="2014-09-11T13:35:26" createdBy="Administrator adidas01 (Administrator)" createdBy_user_id="2008" modified="2014-09-23T09:54:34" modifiedBy="Administrator adidas01" />
      <ExecutionDetails format="TableResult" commandType="SqlCommandOrQuery" exportHandler="" adminControl="" exportMultipleTablesToSheets="False" datesWithTime="False" extraParams="" />
      <Mandators mandatorMode="IncludeMandators" mandator_id="cd0bfa6a-8871-4dfd-84b7-205dee51434e" isStandard="False" isUsedByMenu="False">
        <Mandator mandatorName="adidas01" />
        <Mandator mandatorName="WEKA" />
      </Mandators>
      <Parameters>
        <Parameter id="51048431-df30-44f7-9352-5eabc7343903" isRequired="False" name="Nachname" contextName="Nachname" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="016bcbc3-58e0-462c-a4b9-a2a8864909a3" isRequired="True" name="ZGVlernprogramm" contextName="Lernprogramm" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="720dc59a-21f9-40d0-910b-d878bf1caca1" isRequired="False" name="Zertifikat erhalten" contextName="Zertifikat erhalten" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
      </Parameters>
      <Roles>
        <Role id="30" />
        <Role id="90" />
      </Roles>
      <command>select title as 'Lernprogramm',
COALESCE(titleForLearners, title) as 'Titel für Lerner'
from tblItems where id = @theme_id

-- list all users, which have the selected theme assigned via some targegroup/ Eduoffer with the following data
select v_Users.Nachname,
            v_Users.Vorname,
            case when tblStatusUserCourse.bestComplete is null then '' 
            else CAST(round(tblStatusUserCourse.bestComplete, 2) AS NVARCHAR) + '%' end as 'Bester Bearbeitungsstand',
--            tblStatusUserCourse.bestComplete as 'Bester Bearbeitungsstand',
            tblStatusUserCourse.bestCompleteDate as 'Datum',
            tblUserItemCertificate.received as 'Zertifikat erhalten'
from v_Users 
	inner join tblUsersTargetGroups on tblUsersTargetGroups.UserCn = v_Users.intUserCn 
        inner join tblTargetGroupManagers on tblTargetGroupManagers.targetGroup_id = tblUsersTargetGroups.targetGroup_id 
                       and tblTargetGroupManagers.user_id = @current_user_id 
	left join tblStatusUserCourse on v_Users.intUserCn = tblStatusUserCourse.userId
			and tblStatusUserCourse.theme_id = @theme_id
	left join tblUserItemCertificate on v_Users.intUserCn = tblUserItemCertificate.user_id 
			and tblUserItemCertificate.item_id = @theme_id
where (@nachname is null or v_Users.Nachname like '%' + @nachname + '%')
             and (@certificateReceived is null or 
                      @certificateReceived = 0 and tblUserItemCertificate.received is null or
                      @certificateReceived = 1 and tblUserItemCertificate.received is not null)</command>
    </Report>
  </Reports>
  <Parameters>
    <Parameter id="51048431-df30-44f7-9352-5eabc7343903" mandator_id="7eeb6e0d-a451-4adb-9497-903debf6efe7" isSystem="False" name="Nachname" reportParameterType_id="6e221a70-58e9-46eb-b028-181b9983b2f6" queryParameterName="@nachname" />
    <Parameter id="016bcbc3-58e0-462c-a4b9-a2a8864909a3" mandator_id="7eeb6e0d-a451-4adb-9497-903debf6efe7" isSystem="False" name="ZGVlernprogramm" reportParameterType_id="c14c191e-64e2-4f07-a9fb-7e8c5cd9f15b" queryParameterName="@theme_id" />
    <Parameter id="720dc59a-21f9-40d0-910b-d878bf1caca1" mandator_id="7eeb6e0d-a451-4adb-9497-903debf6efe7" isSystem="False" name="Zertifikat erhalten" reportParameterType_id="63c946da-b479-4a42-a95b-9e8ee796f391" queryParameterName="@certificateReceived" />
  </Parameters>
  <ParameterTypes>
    <ParameterType id="6e221a70-58e9-46eb-b028-181b9983b2f6" isSystem="True" name="String" datatype="String" dataValueField="" dataTextField="" />
    <ParameterType id="c14c191e-64e2-4f07-a9fb-7e8c5cd9f15b" mandator_id="7eeb6e0d-a451-4adb-9497-903debf6efe7" isSystem="False" name="ZGVlearningProgramme" datatype="GuidDDL" dataValueField="id" dataTextField="title">
      <query>select distinct tblThemes.id, tblItems.title
  from tblThemes inner join tblItems on tblThemes.id = tblItems.id
                                inner join tblModuleItems on tblThemes.id = tblModuleItems.item_id
				 inner join tblEduOffersModules on tblEduOffersModules.module_id = tblModuleItems.module_id
				 inner join tblEduOffersTargetGroups on tblEduOffersModules.eduOffer_id = tblEduOffersTargetGroups.eduOffer_id
				 inner join tblUsersTargetGroups tg1 on tblEduOffersTargetGroups.targetGroup_id = tg1.targetGroup_id
				 inner join tblUsersTargetGroups tg2 on tg2.UserCn = tg1.UserCn
				 inner join tblTargetGroupManagers on tblTargetGroupManagers.targetGroup_id = tg2.targetGroup_id
 where tblTargetGroupManagers.user_id = @current_user_id
     and tblItems.deleted is null
  order by tblItems.title, tblThemes.id</query>
    </ParameterType>
    <ParameterType id="63c946da-b479-4a42-a95b-9e8ee796f391" 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>