-- --------------------------------------------------------------------------------
-- _990_initScript Group Routines
-- --------------------------------------------------------------------------------
DELIMITER $$$


create procedure __initScript_010Root()
modifies sql data
begin
    set @1 = tag_CreateDef(null, 'rootgeo', null); -- all default values
    set @1 = tag_CreateDef(null, 'rootamenity', null);
    set @1 = tag_CreateDef(null, 'rootsubmission', null);
    set @1 = tag_CreateDef(null, 'rootuser', null);
    
    update nodeT n set
        n.isRoot = 'y'
    where n.forceSingleNode = 'y';
end$$$


create procedure __initScript_015Templates()
modifies sql data
begin
-- house numbers
    set @a1 = attribute_CreateText(
                                null,
                                'geoattribute',
                                'Номер будинку',
                                null,   -- sorter
                                null,   -- can_search
                                null,   -- display_in_object
                                null,   -- display_in_object_list
                                null,   -- factor
                                'y',    -- enabled
                                null,   -- code
                                'y',    -- required
                                'n',    -- sortable
                                '',     -- uofm_pre
                                '',     -- uofm_post
                                'n');   -- text_is_long
    set @1 = attribute_UpdateLocal(attribute_UpdateLocal(@a1, 'rus', 'Номер дома', null, null), 'eng', 'House Number', null, null);
    set @2 = template_Create(null, 'street', @a1);
    
end$$$


create procedure __initScript_020Users()
modifies sql data
begin
    set @1 = user_Create(
                    'Lazar Manager', '+380977907993', 'user@dev.adaptainc.com', 'lazar', '$2y$13$lNcXZwxiGH4nAXSpe6V63./22ZApYkLY48cFXlQnCTQzJLuPKiO82',
                    'user', 'y',
                    '1986-08-28',
                    'ukr',
                    null);
    set @1 = user_Create(
                    'Lazar Manager', null, 'manager@dev.adaptainc.com', 'lazar_manager', '$2y$13$lNcXZwxiGH4nAXSpe6V63./22ZApYkLY48cFXlQnCTQzJLuPKiO82',
                    'manager', 'y',
                    null,
                    'ukr',
                    null);
    set @1 = user_Create(
                    'Lazar Admin', null, 'admin@dev.adaptainc.com', 'lazar_admin', '$2y$13$lNcXZwxiGH4nAXSpe6V63./22ZApYkLY48cFXlQnCTQzJLuPKiO82',
                    'admin', 'y',
                    null,
                    'ukr',
                    null);
    set @u1 = user_Create(
                    'Борис Заїка', null, null, 'vkontakte_Borey', '$2y$13$gfU5gFaAQw0XOZ406XZ1TORd6UpOMHWh/sFflHQDrux1.le/TESDu',
                    'admin', 'y',
                    null,
                    null,
                    null);
    set @1 = user_SetOauth(@u1, 'vkontakte', 'http://vk.com/id14198259');
end$$$


create procedure __initScript_030Cities()
modifies sql data
begin
-- Ternopil
    set @city_id = tag_CreateDef(null, 'locality', 'Тернопіль');
    set @city_id = tag_UpdateLocal(tag_UpdateLocal(@city_id, 'rus', 'Тернополь'), 'eng', 'Ternopil');

    update externalDataSourceDatasetT set
        nodeId = @city_id
    where externalDataSourceId = 'osm'
        and code = 'ternopil';

-- Ternopil neighborhoods
    set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Центр'));
    set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Центр'), 'eng', 'Central');

    set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Оболоня (базар)'));
    set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Оболоня (базар)'), 'eng', 'Obolonya (marketplace)');

    set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Березовиця'));
    set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Березовица'), 'eng', 'Berezovytsya');

    set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Дружба'));
    set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Дружба'), 'eng', 'Druzhba');

    set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Кутківці'));
    set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Кутковцы'), 'eng', 'Kutkivtsi');

    set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Пронятин'));
    set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Пронятин'), 'eng', 'Pronyatyn');

    set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Новий Світ'));
    set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Новый Свет'), 'eng', 'Novy Svit');

    set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Промисловий'));
    set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Промышленный'), 'eng', 'Industrial');

    set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Північний'));
    set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Северный'), 'eng', 'Northern (Pivnichny)');

    set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Аляска'));
    set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Аляска'), 'eng', 'Alaska');

    set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Сонячний (БАМ)'));
    set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Солнечный (БАМ)'), 'eng', 'Sonyachny (BAM)');

    set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Канада'));
    set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Канада'), 'eng', 'Canada');

    set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Східний масив'));
    set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Восточный массив'), 'eng', 'Eastern neighborhood');

    set @nbhd_id = nodeLink_Relink2(null, @city_id, tag_CreateDef(null, 'neighborhood', 'Старий Парк'));
    set @nbhd_id = tag_UpdateLocal(tag_UpdateLocal(@nbhd_id, 'rus', 'Старый Парк'), 'eng', 'Old Park (Stary Park)');

-- Kyiv
    set @city_id = tag_CreateDef(null, 'locality', 'Київ');
    set @city_id = tag_UpdateLocal(tag_UpdateLocal(@city_id, 'rus', 'Киев'), 'eng', 'Kyiv');

    update externalDataSourceDatasetT set
        nodeId = @city_id
    where externalDataSourceId = 'osm'
        and code = 'kyiv';
end$$$


create procedure __initScript_040Amenities()
modifies sql data
begin
-- estate types
    set @estate_apt = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'estatetype', 'Квартира'), 'rus', 'Квартира'), 'eng', 'Apartment');

    set @estate_cott = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'estatetype', 'Дім'), 'rus', 'Дом'), 'eng', 'Cottage');

    set @estate_ofc = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'estatetype', 'Офіс'), 'rus', 'Офис'), 'eng', 'Office');

    set @estate_com = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'estatetype', 'Комерційна нерухомість'), 'rus', 'Коммерческая недвижимость'), 'eng', 'Commercial Estate');

    set @estate_gar = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'estatetype', 'Гараж'), 'rus', 'Гараж'), 'eng', 'Garage');

-- submission types
    set @subm_buy = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'submissiontype', 'Купити'), 'rus', 'Купить'), 'eng', 'Buy');

    set @subm_rent1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'submissiontype', 'Оренда подобова'), 'rus', 'Аренда посуточная'), 'eng', 'Short-term Rent');

    set @subm_rentm = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'submissiontype', 'Оренда довгострокова'), 'rus', 'Аренда долгосрочная'), 'eng', 'Rent (Long-term)');

-- wall materials
    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'wallmaterial', 'Цегла'), 'rus', 'Кирпич'), 'eng', 'Brick');
    set @2 = nodeLink_Relink2(null, @estate_apt, @u1)
        and nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_ofc, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @estate_gar, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'wallmaterial', 'Силікатна цегла'), 'rus', 'Силикатный кирпич'), 'eng', 'Silicate Brick');
    set @2 = nodeLink_Relink2(null, @estate_apt, @u1)
        and nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_ofc, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @estate_gar, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'wallmaterial', 'Бетонна панель'), 'rus', 'Бетонная панель'), 'eng', 'Concrete Panel');
    set @2 = nodeLink_Relink2(null, @estate_apt, @u1)
        and nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_ofc, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @estate_gar, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'wallmaterial', 'Газобетонний блок'), 'rus', 'Газобетонный блок'), 'eng', 'Aerocrete Block');
    set @2 = nodeLink_Relink2(null, @estate_apt, @u1)
        and nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_ofc, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @estate_gar, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'wallmaterial', 'Сендвіч панель'), 'rus', 'Сендвич панель'), 'eng', 'Sandwich Panel');
    set @2 = nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1);

-- roofing materials
    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'roofmaterial', 'Металева'), 'rus', 'Металлическая'), 'eng', 'Metal');
    set @2 = nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @estate_gar, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'roofmaterial', 'Металочерепиця'), 'rus', 'Металочерепица'), 'eng', 'Metal Tiles');
    set @2 = nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @estate_gar, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'roofmaterial', 'Керамічна черепиця'), 'rus', 'Керамическая черепица'), 'eng', 'Ceramic Tiles');
    set @2 = nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'roofmaterial', 'Руберойд'), 'rus', 'Рубероид'), 'eng', 'Tar Roofing');
    set @2 = nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @estate_gar, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1);

-- supplies
    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'supply', 'Електрика'), 'rus', 'Электричество'), 'eng', 'Electricity');
    set @2 = nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @estate_gar, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1)
        and nodeLink_Relink2(null, @subm_rent1, @u1)
        and nodeLink_Relink2(null, @subm_rentm, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'supply', 'Газ'), 'rus', 'Газ'), 'eng', 'Natural Gas');
    set @2 = nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1)
        and nodeLink_Relink2(null, @subm_rent1, @u1)
        and nodeLink_Relink2(null, @subm_rentm, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'supply', 'Водогін'), 'rus', 'Водопровод'), 'eng', 'Water Supply');
    set @2 = nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1)
        and nodeLink_Relink2(null, @subm_rent1, @u1)
        and nodeLink_Relink2(null, @subm_rentm, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'supply', 'Каналізація'), 'rus', 'Канализация'), 'eng', 'Sewer');
    set @2 = nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1)
        and nodeLink_Relink2(null, @subm_rent1, @u1)
        and nodeLink_Relink2(null, @subm_rentm, @u1);

-- amenities
    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'amenity', 'Меблі'), 'rus', 'Мебель'), 'eng', 'Furniture');
    set @2 = nodeLink_Relink2(null, @estate_apt, @u1)
        and nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_ofc, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @subm_rent1, @u1)
        and nodeLink_Relink2(null, @subm_rentm, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'amenity', 'Холодильник'), 'rus', 'Холодильник'), 'eng', 'Refrigerator');
    set @2 = nodeLink_Relink2(null, @estate_apt, @u1)
        and nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_ofc, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @subm_rent1, @u1)
        and nodeLink_Relink2(null, @subm_rentm, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'amenity', 'Мікрохвильова піч'), 'rus', 'Микроволновая печь'), 'eng', 'Microwave Oven');
    set @2 = nodeLink_Relink2(null, @estate_apt, @u1)
        and nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_ofc, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @subm_rent1, @u1)
        and nodeLink_Relink2(null, @subm_rentm, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'amenity', 'Індивідуальне опалення'), 'rus', 'Индивидуальное отопление'), 'eng', 'Home heating');
    set @2 = nodeLink_Relink2(null, @estate_apt, @u1)
        and nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_ofc, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1)
        and nodeLink_Relink2(null, @subm_rent1, @u1)
        and nodeLink_Relink2(null, @subm_rentm, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'amenity', 'Інтернет/Wi-Fi'), 'rus', 'Интернет/Wi-Fi'), 'eng', 'Internet/Wi-Fi');
    set @2 = nodeLink_Relink2(null, @estate_apt, @u1)
        and nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_ofc, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1)
        and nodeLink_Relink2(null, @subm_rent1, @u1)
        and nodeLink_Relink2(null, @subm_rentm, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'amenity', 'Телефон (міський)'), 'rus', 'Телефон (городской)'), 'eng', 'Telephone (wired)');
    set @2 = nodeLink_Relink2(null, @estate_apt, @u1)
        and nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_ofc, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1)
        and nodeLink_Relink2(null, @subm_rent1, @u1)
        and nodeLink_Relink2(null, @subm_rentm, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'amenity', 'Сантехніка'), 'rus', 'Сантехника'), 'eng', 'Plumbing');
    set @2 = nodeLink_Relink2(null, @estate_apt, @u1)
        and nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_ofc, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1)
        and nodeLink_Relink2(null, @subm_rent1, @u1)
        and nodeLink_Relink2(null, @subm_rentm, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'amenity', 'Євроремонт'), 'rus', 'Евроремонт'), 'eng', 'Remodeled/Renovated');
    set @2 = nodeLink_Relink2(null, @estate_apt, @u1)
        and nodeLink_Relink2(null, @estate_cott, @u1)
        and nodeLink_Relink2(null, @estate_ofc, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1)
        and nodeLink_Relink2(null, @subm_rent1, @u1)
        and nodeLink_Relink2(null, @subm_rentm, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'amenity', 'Оглядова яма'), 'rus', 'Смотровая яма'), 'eng', 'Inspection Pit');
    set @2 = nodeLink_Relink2(null, @estate_gar, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1)
        and nodeLink_Relink2(null, @subm_rent1, @u1)
        and nodeLink_Relink2(null, @subm_rentm, @u1);

--

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'extamenity', 'Конс''єрж'), 'rus', 'Консьерж'), 'eng', 'Concierge');
    set @2 = nodeLink_Relink2(null, @estate_apt, @u1)
        and nodeLink_Relink2(null, @estate_ofc, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1)
        and nodeLink_Relink2(null, @subm_rent1, @u1)
        and nodeLink_Relink2(null, @subm_rentm, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'extamenity', 'Ліфт'), 'rus', 'Лифт'), 'eng', 'Elevator');
    set @2 = nodeLink_Relink2(null, @estate_apt, @u1)
        and nodeLink_Relink2(null, @estate_ofc, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1)
        and nodeLink_Relink2(null, @subm_rent1, @u1)
        and nodeLink_Relink2(null, @subm_rentm, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'extamenity', 'Парковка'), 'rus', 'Парковка'), 'eng', 'Parking Lot');
    set @2 = nodeLink_Relink2(null, @estate_apt, @u1)
        and nodeLink_Relink2(null, @estate_ofc, @u1)
        and nodeLink_Relink2(null, @estate_com, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1)
        and nodeLink_Relink2(null, @subm_rent1, @u1)
        and nodeLink_Relink2(null, @subm_rentm, @u1);

    set @u1 = tag_UpdateLocal(tag_UpdateLocal(tag_CreateDef(null, 'extamenity', 'Дитячий майданчик'), 'rus', 'Детская площадка'), 'eng', 'Playground');
    set @2 = nodeLink_Relink2(null, @estate_apt, @u1)
        and nodeLink_Relink2(null, @subm_buy, @u1)
        and nodeLink_Relink2(null, @subm_rentm, @u1);


end$$$


create procedure __initScript_050HiddenAttributes()
modifies sql data
begin
-- by rating sort
    set @1 = attribute_CreateNumeric(
                                    null,
                                    'hiddenattribute',
                                    'Рейтинг',
                                    -100000001,     -- sorter
                                    null,           -- can_search
                                    null,           -- display_in_object
                                    null,           -- display_in_object_list
                                    0,              -- factor
                                    'y',            -- enabled
                                    '__byrating',   -- code
                                    'n',            -- required
                                    'y',            -- sortable
                                    '',             -- uofm_pre
                                    '',             -- uofm_post
                                    0,              -- decimal_min
                                    0,              -- decimal_max
                                    0);             -- decimal_round
    set @2 = attribute_UpdateLocal(attribute_UpdateLocal(@1, 'rus', 'Рейтинг', null, null), 'eng', 'Rating', null, null);

-- by changed sort
    set @1 = attribute_CreateNumeric(
                                    null,
                                    'hiddenattribute',
                                    'Дата оновлення',
                                    -100000000,     -- sorter
                                    null,           -- can_search
                                    null,           -- display_in_object
                                    null,           -- display_in_object_list
                                    0,              -- factor
                                    'y',            -- enabled
                                    '__bychanged',  -- code
                                    'n',            -- required
                                    'y',            -- sortable
                                    '',             -- uofm_pre
                                    '',             -- uofm_post
                                    0,              -- decimal_min
                                    0,              -- decimal_max
                                    0);             -- decimal_round
    set @2 = attribute_UpdateLocal(attribute_UpdateLocal(@1, 'rus', 'Дата обновления', null, null), 'eng', 'Date', null, null);

end$$$


create procedure initScript_Start()
modifies sql data
begin
    start transaction;

    call __initScript_010Root();
    call __initScript_015Templates();
    call __initScript_020Users();
    call __initScript_030Cities();
    call __initScript_040Amenities();
    call __initScript_050HiddenAttributes();

    commit;
end$$$


