USP_SIMPLEDATALIST_PDACCOUNTSYSTEM_BYUSERFOREPORTS

Returns a list of accounting systems for a given user for reports.

Parameters

Parameter Parameter Type Mode Description
@REPORTUSERID uniqueidentifier IN

Definition

Copy


create procedure dbo.USP_SIMPLEDATALIST_PDACCOUNTSYSTEM_BYUSERFOREPORTS 
            (
                @REPORTUSERID uniqueidentifier
            )
as
      --exec dbo.USP_SIMPLEDATALIST_PDACCOUNTSYSTEM_BYUSER  @REPORTUSERID

    select 
                T1.ID as VALUE
                T1.NAME as LABEL
            from dbo.PDACCOUNTSYSTEM as T1
            inner join dbo.PDACCOUNTSYSTEMSITE as T2 on T1.ID = T2.PDACCOUNTSYSTEMID
            inner join dbo.UFN_SITESFORUSER(@REPORTUSERID) as T3 ON T3.SITEID=T2.SITEID
            where T1.ISBASICGL = 1  

            union 

            select 
                ID as VALUE
                NAME as LABEL
            from dbo.PDACCOUNTSYSTEM
            where ISBASICGL = 1 and ISDEFAULT = 1 and (select count(*) from dbo.UFN_SITESFORUSER(@REPORTUSERID)) = 0

            union 

            select 
                ID as VALUE
                NAME as LABEL
            from dbo.PDACCOUNTSYSTEM
            where ISBASICGL = 1 and dbo.UFN_APPUSER_ISSYSADMIN(@REPORTUSERID) = 1

            union 

            select 
                ID as VALUE
                NAME as LABEL
            from dbo.PDACCOUNTSYSTEM
            where ((select count(id) from SYSTEMROLEAPPUSER where SECURITYMODECODE = 0 and APPUSERID = @REPORTUSERID) > 0)        

            union

            select 
                ID as VALUE,
                NAME as LABEL
            from dbo.PDACCOUNTSYSTEM
            where ISBASICGL = 0 and dbo.UFN_INSTALLEDPRODUCTS_PRODUCTIS('F5138EB6-6666-497A-8FB2-BAE24389AAE4') = 1                            

            order by NAME