/* Bednář Libor    2026-02-18 21:14:51 */

if not exists (select * from lcs.noris_relations where cislo_vztahu = 25129 )
 and exists (select * from lcs.noris_classes where cislo_tridy=22412)
AND lcs.nf_is_archive() <> 'A'
begin
insert into lcs.noris_relations (cislo_vztahu, cislo_tridy, cislo_poradace, typ, statdyn, pocetnost_left, pocetnost_right, nutnost_zadani, prenositelnost, column_name, zobrazovat_column, zobrazovat_column_zprava, prenos_transformace, poradi, zakaz_hz, nereplikovat, transformace_l, transformace_r, zakazat_def, pouze_net, blokace_vymazu_l, blokace_vymazu_r, hide_left, hide_right, nezobrazovat_seznam_por, nezobrazovat_seznam_por_zprava, template_on_tab, skryty_udaj) 
values(
25129, 
22412, 
null,
'SS',
'D',
'N',
'1',
'N',
'N',
null,
'N',
'N',
'N',
'1',
'N',
'N',
'vychozi_pro_rip',
'vychozi_rastr',
'N',
'N',
'N',
'N',
'N',
'N',
'N',
'N',
null,
'N'
)
insert into lcs.repository_translate (cislo,cislo_tridy,langid,nazev,nazev2,popis,zkratka,code)
select 25129, 10, 'CZ', 'Výchozí pro RIP', 'Výchozí rastr', null, null, null
union
select 25129, 10, isnull ((select langid from lcs.repository_languages where isdefault = 'A'), 'CZ'), 'Výchozí pro RIP', 'Výchozí rastr', null, null, null
where  not exists (select * from lcs.repository_translate where cislo = 25129 and cislo_tridy = 10)

--Slave folders begin
DECLARE @vztahporadac TABLE (cislo_vztahu int, cislo_poradace int, UNIQUE NONCLUSTERED (cislo_poradace ASC, cislo_vztahu ASC));
 
if exists (select * from lcs.noris_folders where cislo_poradace =22356)
 and not exists (select * from lcs.vztahporadac where cislo_vztahu=25129 and cislo_poradace=22356)
AND lcs.nf_is_archive() <> 'A'
begin
 if not exists (select * from @vztahporadac where cislo_vztahu=25129 and cislo_poradace=22356)
  insert into @vztahporadac (cislo_vztahu, cislo_poradace)
  values(25129,22356)
end
IF lcs.nf_is_archive() <> 'A'
 and exists (select * from @vztahporadac)
begin
 MERGE lcs.vztahporadac  AS TARGET 
  USING @vztahporadac AS SOURCE  
  ON (TARGET.cislo_vztahu = SOURCE.cislo_vztahu and TARGET.cislo_poradace = SOURCE.cislo_poradace)  
  WHEN MATCHED  
  THEN UPDATE SET TARGET.list_folder = 'A' 
  WHEN NOT MATCHED BY TARGET  
  THEN INSERT (cislo_vztahu, cislo_poradace, list_folder) VALUES (SOURCE.cislo_vztahu, SOURCE.cislo_poradace, 'A');
end
--Slave folders end

if exists (select * from syscolumns where id = object_id('lcs.noris_relations') and name = 'index_fullsearch_rel') 
exec ('
   update lcs.noris_relations 
   set index_fullsearch_rel=''A''
   where cislo_vztahu = 25129
')

if exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'symbolic_name_left') 
   and exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'symbolic_name_right') 
exec ('
   update lcs.noris_relations 
   set symbolic_name_left = null, symbolic_name_right = null
   where cislo_vztahu = 25129;
');

if  exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'show_additional_system_texts_left') 
   and exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'sort_additional_system_texts_left') 
   and exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'show_additional_system_texts_right') 
   and exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'sort_additional_system_texts_right') 
   and exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'sort_column_left') 
   and exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'sort_column_order_left') 
   and exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'sort_column_right') 
   and exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'sort_column_order_right') 
exec ('
   update lcs.noris_relations 
 set    show_additional_system_texts_left = null, sort_additional_system_texts_left = null, 
   show_additional_system_texts_right = null, sort_additional_system_texts_right = null, 
   sort_column_left = ''N'', sort_column_order_left = ''A'', 
   sort_column_right = ''N'', sort_column_order_right = ''A''
   where cislo_vztahu = 25129;
');

end


GO
/* Bednář Libor    2026-02-18 21:24:40 */

if not exists (select * from lcs.noris_relations where cislo_vztahu = 25130 )
 and exists (select * from lcs.noris_classes where cislo_tridy=22412)
AND lcs.nf_is_archive() <> 'A'
begin
insert into lcs.noris_relations (cislo_vztahu, cislo_tridy, cislo_poradace, typ, statdyn, pocetnost_left, pocetnost_right, nutnost_zadani, prenositelnost, column_name, zobrazovat_column, zobrazovat_column_zprava, prenos_transformace, poradi, zakaz_hz, nereplikovat, transformace_l, transformace_r, zakazat_def, pouze_net, blokace_vymazu_l, blokace_vymazu_r, hide_left, hide_right, nezobrazovat_seznam_por, nezobrazovat_seznam_por_zprava, template_on_tab, skryty_udaj) 
values(
25130, 
22412, 
null,
'SS',
'D',
'N',
'N',
'N',
'N',
null,
'N',
'N',
'N',
'2',
'N',
'N',
'povoleno_pro_rip',
'povolene_rastry',
'N',
'N',
'N',
'N',
'N',
'N',
'N',
'N',
null,
'N'
)
insert into lcs.repository_translate (cislo,cislo_tridy,langid,nazev,nazev2,popis,zkratka,code)
select 25130, 10, 'CZ', 'Povoleno pro RIP', 'Povolené rastry', null, null, null
union
select 25130, 10, isnull ((select langid from lcs.repository_languages where isdefault = 'A'), 'CZ'), 'Povoleno pro RIP', 'Povolené rastry', null, null, null
where  not exists (select * from lcs.repository_translate where cislo = 25130 and cislo_tridy = 10)

--Slave folders begin
DECLARE @vztahporadac TABLE (cislo_vztahu int, cislo_poradace int, UNIQUE NONCLUSTERED (cislo_poradace ASC, cislo_vztahu ASC));
 
if exists (select * from lcs.noris_folders where cislo_poradace =22356)
 and not exists (select * from lcs.vztahporadac where cislo_vztahu=25130 and cislo_poradace=22356)
AND lcs.nf_is_archive() <> 'A'
begin
 if not exists (select * from @vztahporadac where cislo_vztahu=25130 and cislo_poradace=22356)
  insert into @vztahporadac (cislo_vztahu, cislo_poradace)
  values(25130,22356)
end
IF lcs.nf_is_archive() <> 'A'
 and exists (select * from @vztahporadac)
begin
 MERGE lcs.vztahporadac  AS TARGET 
  USING @vztahporadac AS SOURCE  
  ON (TARGET.cislo_vztahu = SOURCE.cislo_vztahu and TARGET.cislo_poradace = SOURCE.cislo_poradace)  
  WHEN MATCHED  
  THEN UPDATE SET TARGET.list_folder = 'A' 
  WHEN NOT MATCHED BY TARGET  
  THEN INSERT (cislo_vztahu, cislo_poradace, list_folder) VALUES (SOURCE.cislo_vztahu, SOURCE.cislo_poradace, 'A');
end
--Slave folders end

if exists (select * from syscolumns where id = object_id('lcs.noris_relations') and name = 'index_fullsearch_rel') 
exec ('
   update lcs.noris_relations 
   set index_fullsearch_rel=''A''
   where cislo_vztahu = 25130
')

if exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'symbolic_name_left') 
   and exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'symbolic_name_right') 
exec ('
   update lcs.noris_relations 
   set symbolic_name_left = null, symbolic_name_right = null
   where cislo_vztahu = 25130;
');

if  exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'show_additional_system_texts_left') 
   and exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'sort_additional_system_texts_left') 
   and exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'show_additional_system_texts_right') 
   and exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'sort_additional_system_texts_right') 
   and exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'sort_column_left') 
   and exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'sort_column_order_left') 
   and exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'sort_column_right') 
   and exists (select * from sys.columns where object_id = object_id('lcs.noris_relations') and name = 'sort_column_order_right') 
exec ('
   update lcs.noris_relations 
 set    show_additional_system_texts_left = null, sort_additional_system_texts_left = null, 
   show_additional_system_texts_right = null, sort_additional_system_texts_right = null, 
   sort_column_left = ''N'', sort_column_order_left = ''A'', 
   sort_column_right = ''N'', sort_column_order_right = ''A''
   where cislo_vztahu = 25130;
');

end


GO



GO


update lcs.separace_22
set rastr = vs.cislo_subjektu
from lcs.separace_22 s 
join lcs.produkt_hlavicka p on s.cislo_nonsubjektu in (separace_1, separace_10, separace_2, separace_3, separace_4, separace_5, separace_6, separace_7, separace_8, separace_9)
join lcs.vztahysubjektu vs on vs.cislo_vztahu = 25129 and vs.cislo_vztaz_subjektu = p.rip
where s.rastr is null

GO

