((Trn_GIDTyp IN (2041,2009,2045,2013) AND TrN_MagDNumer=1) OR 1=1) AND ((TrN_MagZNumer IN (1,19)) OR (TrN_MagDNumer IN (1,19))) AND( (??brak=1 AND (TrN_GIDNumer NOT IN (SELECT Atr_ObiNumer FROM CDN.Atrybuty WHERE Atr_ObiNumer=TrN_GIDNumer AND Atr_AtkId=220) OR TrN_GIDNumer IN (SELECT Atr_ObiNumer FROM CDN.Atrybuty WHERE Atr_ObiNumer=TrN_GIDNumer AND Atr_AtkId=220 AND Atr_Wartosc LIKE ''))) OR (??do_realizacji=1 AND TrN_GIDNumer IN (SELECT Atr_ObiNumer FROM CDN.Atrybuty WHERE Atr_ObiNumer=TrN_GIDNumer AND Atr_AtkId=220 AND Atr_Wartosc LIKE 'do realizacji')) OR (??w_realizacji=1 AND TrN_GIDNumer IN (SELECT Atr_ObiNumer FROM CDN.Atrybuty WHERE Atr_ObiNumer=TrN_GIDNumer AND Atr_AtkId=220 AND Atr_Wartosc LIKE 'w realizacji')) OR (??zamkniete_z_brakami=1 AND TrN_GIDNumer IN (SELECT Atr_ObiNumer FROM CDN.Atrybuty WHERE Atr_ObiNumer=TrN_GIDNumer AND Atr_AtkId=220 AND Atr_Wartosc LIKE 'zamkniete z brakami')) OR (??zrealizowane=1 AND TrN_GIDNumer IN (SELECT Atr_ObiNumer FROM CDN.Atrybuty WHERE Atr_ObiNumer=TrN_GIDNumer AND Atr_AtkId=220 AND Atr_Wartosc LIKE 'zrealizowane')) OR (??zrealizowane_z_brakami=1 AND TrN_GIDNumer IN (SELECT Atr_ObiNumer FROM CDN.Atrybuty WHERE Atr_ObiNumer=TrN_GIDNumer AND Atr_AtkId=220 AND Atr_Wartosc LIKE 'zrealizowane z brakami')) )