DROP PROCEDURE IF EXISTS uspGetAdatszotarById
GO
  CREATE PROCEDURE uspGetAdatszotarById
     @pId INT
    ,@pIntezmenyId INT
    ,@pTanevId INT
  AS
  BEGIN
    SET NOCOUNT ON;

    SELECT dib.ID AS ID
      ,dib.C_ORDER AS Sorszam
      ,dib.C_NAME AS Megnevezes
      ,dib.C_NAME_1 AS Megnevezes1
      ,dib.C_NAME_2 AS Megnevezes2
      ,dib.C_NAME_3 AS Megnevezes3
      ,dib.C_NAME_4 AS Megnevezes4
      ,dib.C_VISIBLE AS Lathato
      ,dib.C_PROTECTED AS Protected
      ,dib.C_TYPE AS Type
      ,dib.C_DICTIONARYTYPEID AS TypeId
      ,dib.C_COLOR AS Color
      ,ISNULL(dib.C_CODE, '') AS Code
      ,ISNULL(em.C_ISBOLD, 'F') AS IsBold
      ,ISNULL(em.C_SULY, 100) AS Suly
      ,ISNULL(nt.C_ISSORSZAMOZANDO, 'F') AS IsSorszamozando
      ,ISNULL(nt.C_ISTANORAI, 'F') AS IsTanorai
      ,ISNULL(nt.C_ISTANORANKIVULI, 'F') AS IsTanorankivuli
      ,ISNULL(nt.C_ISLENEMKOTOTTMUNKAIDO, 'F') AS IsLeNemKotottMunkaido
      ,ISNULL(so.C_ISBIZONYITVANYBANMEGJELENIK, 'F') AS IsBizonyitvanybanMegjelenik
      ,ISNULL(so.C_ISNAPLOBANMEGJELENIK, 'F') AS IsNaplobanMegjelenik
      ,ISNULL(so.C_ISTORZSLAPONMEGJELENIK, 'F') AS IsTorzslaponMegjelenik
    FROM T_DICTIONARYITEMBASE_OSSZES dib
    LEFT JOIN T_ERTEKELESMOD_OSSZES em ON em.ID = dib.ID
      AND em.TOROLT = 'F'
      AND em.C_ALINTEZMENYID = dib.C_INTEZMENYID
      AND em.C_ALTANEVID = dib.C_TANEVID
    LEFT JOIN T_NAPTIPUS_OSSZES nt ON nt.ID = dib.ID
      AND nt.TOROLT = 'F'
      AND nt.C_ALINTEZMENYID = dib.C_INTEZMENYID
      AND nt.C_ALTANEVID = dib.C_TANEVID
    LEFT JOIN T_SOROLASOKATIPUS_OSSZES so ON so.ID = dib.ID
      AND so.TOROLT = 'F'
      AND so.C_ALINTEZMENYID = dib.C_INTEZMENYID
      AND so.C_ALTANEVID = dib.C_TANEVID
    WHERE dib.TOROLT = 'F'
      AND dib.ID = @pId
      AND dib.C_INTEZMENYID = @pIntezmenyId
      AND dib.C_TANEVID = @pTanevId
  END
GO


