/*1*/ UPDATE `form_element` SET `vdaemon`='<vlvalidator name="customZamestnanecLogin" type="custom" function="vdaemonZamestnanecLogin" />' WHERE  `id`=21007;

/*2*/ CREATE TABLE `stav_majetku` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `nazov` VARCHAR(50) NOT NULL,
  `poradie` INT(11) NULL DEFAULT NULL,
  `code` VARCHAR(50) NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
)
  COLLATE='utf8_general_ci'
  ENGINE=InnoDB
;
/*3*/ ALTER TABLE `stav_majetku`
CHANGE COLUMN `id` `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT FIRST;
/*4*/ ALTER TABLE `stav_majetku`
CHANGE COLUMN `id` `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT FIRST;
/*5*/ ALTER TABLE `majetok`
ADD COLUMN `stav_majetku_id` INT(10) UNSIGNED NULL DEFAULT NULL AFTER `typ_zariadenia_id`;
/*6*/ ALTER TABLE `majetok`
ADD CONSTRAINT `FK_majetok_stav_majetku` FOREIGN KEY (`stav_majetku_id`) REFERENCES `stav_majetku` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT;
/*7*/ INSERT INTO `stav_majetku` (`id`, `nazov`, `poradie`, `code`) VALUES (1, 'Aktívny', 10, 'aktivny');
/*8*/ INSERT INTO `stav_majetku` (`id`, `nazov`, `poradie`, `code`) VALUES (2, 'Vyradený', 20, 'vyradeny');
/*9*/ INSERT INTO `form_element` (`id`, `form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`, `column_title`, `position`, `direct_to_db`, `required`, `css_class`, `direct_multi_label`) VALUES (36006, 36000, 5, 'majetok', 'stav_majetku_id', 'stav_majetku', 'Stav majetku', 70, 1, 1, 'select2', 1);
/*10*/ UPDATE `form_element` SET `vdaemon`='<vlvalidator name="customStavMajetku" type="custom" function="vdaemonStavMajetku" />' WHERE  `id`=36006;

CREATE TABLE `kosik_majetok` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `zamestnanec_id` INT(10) UNSIGNED NOT NULL,
  `majetok_id` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE INDEX `majetok_zamestnanec_idx` (`majetok_id`, `zamestnanec_id`),
  INDEX `kosik_majetok_FKIndex1` (`majetok_id`),
  INDEX `kosik_majetok_FKIndex2` (`zamestnanec_id`)
)
  COLLATE='utf8_general_ci'
  ENGINE=MyISAM
;

UPDATE majetok SET stav_majetku_id = 1 WHERE visibility_type = 1;
/*281*/ INSERT INTO `form_group` (`id`, `form_id`, `nazov`, `code`, `position`) VALUES (33001, 330, 'Priradenie úlohy', 'uloha_priradenie', 20);
/*284*/ INSERT INTO `form_group` (`id`, `form_id`, `nazov`, `code`, `position`) VALUES (33002, 330, 'Rozšírené informácie', 'uloha_rozsirene', 30);
/*285*/ UPDATE `form_element` SET `form_group_id`=33002 WHERE  `id`=33009;

INSERT INTO `form_element` (`id`, `form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`, `db_multivalue_table`, `column_title`, `position`, `attribute`, `width`, `height`, `help`, `example`, `direct_to_db`, `required`, `number`, `float_number`, `email`, `css_style`, `css_class`, `javascript`, `direct_multi_label`, `direct_multi_data`, `default_val`, `vdaemon`, `add_empty_option`, `html`, `lang_code`, `read_only`) VALUES (33011, 33001, 9, 'uloha', 'majetok_id', 'majetok', NULL, 'Majetok', 20, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'select2', NULL, 1, 1, NULL, NULL, NULL, '<span class="kosik_load" data-entity="majetok" data-load_to_element="#element_majetok_id_33011"></span>', NULL, NULL);
INSERT INTO `form_element` (`id`, `form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`, `db_multivalue_table`, `column_title`, `position`, `attribute`, `width`, `height`, `help`, `example`, `direct_to_db`, `required`, `number`, `float_number`, `email`, `css_style`, `css_class`, `javascript`, `direct_multi_label`, `direct_multi_data`, `default_val`, `vdaemon`, `add_empty_option`, `html`, `lang_code`, `read_only`) VALUES (33012, 33001, 5, 'uloha', 'obchodny_partner_id', 'obchodny_partner', NULL, 'Obchodný partner', 10, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'select2', NULL, 1, NULL, NULL, NULL, 1, NULL, NULL, NULL);

/*297*/ ALTER TABLE `uloha`
	ADD COLUMN `obchodny_partner_id` INT(10) UNSIGNED NULL AFTER `typ_ulohy_id`;

/*298*/ CREATE TABLE `uloha_majetok` (
	`uloha_id` INT(11) UNSIGNED NOT NULL,
	`majetok_id` INT(11) UNSIGNED NOT NULL,
	PRIMARY KEY (`uloha_id`, `majetok_id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
;

/*2*/ ALTER TABLE `zamestnanec_obchodny_partner`
ADD COLUMN `id` INT(10) UNSIGNED NULL AFTER `obchodny_partner_id`,
ADD COLUMN `typ_sluzby_id` INT(11) UNSIGNED NULL AFTER `id`,
ADD COLUMN `permission_id` INT(10) UNSIGNED NULL AFTER `typ_sluzby_id`;
/*4*/ ALTER TABLE `zamestnanec_obchodny_partner`
CHANGE COLUMN `id` `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT FIRST,
DROP PRIMARY KEY,
ADD PRIMARY KEY (`id`);
/*5*/ INSERT INTO `permission` (`id`, `nazov`) VALUES (2, 'Pridanie');
/*6*/ INSERT INTO `permission` (`id`, `nazov`) VALUES (3, 'Zobrazenie');

/*9*/ DELETE FROM `form_element` WHERE  `id`=7;
/*10*/ INSERT INTO `form` (`id`, `nazov`, `code`) VALUES (1, 'Práva zamestnanca', 'zamestnanec_prava');
/*11*/ RENAME TABLE `zamestnanec_obchodny_partner` TO `zamestnanec_prava`;
/*12*/ INSERT INTO `form_group` (`id`, `form_id`, `nazov`, `code`, `position`) VALUES (6, 1, 'Práva zamestnanca', 'zamestnanec_prava', 10);
/*13*/ DELETE FROM `form_group` WHERE  `id`=3;
/*14*/ INSERT INTO `form_element` (`id`, `form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `column_title`, `position`, `direct_to_db`) VALUES (16, 6, 13, 'zamestnanec_prava', 'zamestnanec_id', 'Zamestnanec', 10, 1);
/*15*/ INSERT INTO `form_element` (`id`, `form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`, `column_title`, `position`, `direct_to_db`, `css_class`, `direct_multi_label`) VALUES (17, 6, 5, 'obchodny_partner', 'obchodny_partner_id', 'obchodny_partner', 'Obchodný partner', 20, 1, 'select2', 1);
/*16*/ UPDATE `form_element` SET `required`=1 WHERE  `id`=17;
/*17*/ INSERT INTO `form_element` (`id`, `form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`) VALUES (18, 6, 5, 'zamestnanec_prava', 'typ_sluzby_id', 'typ_sluzby');
/*18*/ UPDATE `form_element` SET `db_table`='zamestnanec_prava' WHERE  `id`=17;
/*19*/ UPDATE `form_element` SET `column_title`='Typ služby', `position`=30, `direct_to_db`=1, `required`=1, `css_class`='select2' WHERE  `id`=18;
/*20*/ INSERT INTO `form_element` (`id`, `form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`, `column_title`, `position`, `direct_to_db`, `required`, `css_class`, `direct_multi_label`) VALUES (19, 6, 5, 'zamestnanec_prava', 'permission_id', 'permission', 'Práva', 40, 1, 1, 'select2', 1);
/*21*/ UPDATE `form_element` SET `direct_multi_label`=1 WHERE  `id`=18;
/*22*/ UPDATE `form_element` SET `add_empty_option`=1 WHERE  `id`=19;
/*23*/ UPDATE `form_element` SET `add_empty_option`=1 WHERE  `id`=18;
/*24*/ UPDATE `form_element` SET `add_empty_option`=1 WHERE  `id`=17;
/*25*/ INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (1, 21002, 'Práva zamestnanca', 'zamestnanec_obchodny_partner', 30, 3, 1);
/*26*/ UPDATE `menu` SET `id`=113, `page`='zamestnanec_obchodny_partner_vypis' WHERE  `id`=1;
/*27*/ UPDATE `form` SET `code`='zamestnanec_obchodny_partner' WHERE  `id`=1;
/*28*/ RENAME TABLE `zamestnanec_prava` TO `zamestnanec_obchodny_partner`;
/*29*/ ALTER TABLE `zamestnanec_obchodny_partner`
ADD COLUMN `visibility_type` TINYINT(1) UNSIGNED NULL DEFAULT NULL AFTER `permission_id`;
/*30*/ UPDATE `form_element` SET `db_table`='zamestnanec_obchodny_partner' WHERE  `id`=16;
/*31*/ UPDATE `form_element` SET `db_table`='zamestnanec_obchodny_partner' WHERE  `id`=17;
/*32*/ UPDATE `form_element` SET `db_table`='zamestnanec_obchodny_partner' WHERE  `id`=18;
/*33*/ UPDATE `form_element` SET `db_table`='zamestnanec_obchodny_partner' WHERE  `id`=19;
/*34*/ DELETE FROM `form_element` WHERE  `id`=16;
/*35*/ INSERT INTO `log_type` (`id`, `nazov`, `code`) VALUES (15, 'Pridanie práv pre zamestnanca', 'zamestnanec_obchodny_partner_pridaj');
/*36*/ INSERT INTO `log_type` (`id`, `nazov`, `code`) VALUES (16, 'Editovanie práv pre zamestnanca', 'zamestnanec_obchodny_partner_edituj');
/*37*/ INSERT INTO `log_type` (`id`, `nazov`, `code`) VALUES (17, 'Zmazanie práv pre zamestnanca', 'zamestnanec_obchodny_partner_zmaz');
/*38*/ INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `level`) VALUES (114, 21002, 'Editovanie práv zamestnanca', 'zamestnanec_obchodny_partner_edituj', 3);
/*39*/ INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `level`) VALUES (115, 21002, 'Zmazanie práv zamestnanca', 'zamestnanec_obchodny_partner_zmaz', 3);
/*40*/ INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `level`) VALUES (116, 21002, 'Pridanie práv zamestnanca', 'zamestnanec_obchodny_partner_pridaj', 3);
/*41*/ UPDATE `permission` SET `nazov`='Pridávanie, editovanie, zmazanie, zobrazenie' WHERE  `id`=2;
/*42*/ UPDATE `permission` SET `nazov`='Pridávanie, zobrazenie' WHERE  `id`=2;
/*43*/ UPDATE `permission` SET `nazov`='Pridanie, zobrazenie' WHERE  `id`=2;