INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (180, NULL, 'BTS', 'bts', 220, 1, 1);

INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (181, 180, 'Zákony', 'zakon_vypis', 10, 2, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (182, 180, 'Pridanie', 'zakon_pridaj', NULL, 2, 0);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (183, 181, 'Editovanie', 'zakon_edituj', 2, 3, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (184, 181, 'Zmazanie', 'zakon_zmaz', NULL, 3, 0);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (185, 181, 'Detail', 'zakon_view', 1, 3, 1);

-- Exportování struktury pro tabulka gmspider.druh_zakona
CREATE TABLE IF NOT EXISTS `druh_zakona` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `nazov` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

-- Exportování dat pro tabulku gmspider.druh_zakona: ~5 rows (přibližně)
/*!40000 ALTER TABLE `druh_zakona` DISABLE KEYS */;
INSERT INTO `druh_zakona` (`id`, `nazov`) VALUES
	(1, 'Zákon'),
	(2, 'Vyhláška'),
	(3, 'Nariadenie vlády'),
	(4, 'Smernica a opatrenia'),
	(5, 'Iné');
/*!40000 ALTER TABLE `druh_zakona` ENABLE KEYS */;

-- Exportování struktury pro tabulka gmspider.stav_zakona
CREATE TABLE IF NOT EXISTS `stav_zakona` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `nazov` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

-- Exportování dat pro tabulku gmspider.stav_zakona: ~2 rows (přibližně)
/*!40000 ALTER TABLE `stav_zakona` DISABLE KEYS */;
INSERT INTO `stav_zakona` (`id`, `nazov`) VALUES
	(1, 'Platné'),
	(2, 'Zrušené');
/*!40000 ALTER TABLE `stav_zakona` ENABLE KEYS */;

-- Exportování struktury pro tabulka gmspider.zakon
CREATE TABLE IF NOT EXISTS `zakon` (
  `id` int(10) unsigned DEFAULT NULL,
  `visibility_type` int(10) unsigned DEFAULT NULL,
  `cislo` varchar(255) DEFAULT NULL,
  `nazov` varchar(255) DEFAULT NULL,
  `druh_zakona_id` int(10) unsigned DEFAULT NULL,
  `stav_zakona_id` int(10) unsigned DEFAULT NULL,
  `sluzba_id` int(10) unsigned DEFAULT NULL,
  KEY `zakon_druh_zakona` (`druh_zakona_id`),
  KEY `zakon_stav_zakona` (`stav_zakona_id`),
  KEY `zakon_sluzba` (`sluzba_id`),
  CONSTRAINT `zakon_druh_zakona` FOREIGN KEY (`druh_zakona_id`) REFERENCES `druh_zakona` (`id`),
  CONSTRAINT `zakon_sluzba` FOREIGN KEY (`sluzba_id`) REFERENCES `sluzba` (`id`),
  CONSTRAINT `zakon_stav_zakona` FOREIGN KEY (`stav_zakona_id`) REFERENCES `stav_zakona` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `zakon`
	CHANGE COLUMN `id` `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT FIRST,
	ADD PRIMARY KEY (`id`);

INSERT INTO `form` (`id`, `nazov`, `code`) VALUES (18, 'Zákon', 'zakon');
INSERT INTO `form_group` (`id`, `form_id`, `nazov`, `code`, `position`, `poznamka`, `group_type`) VALUES (180, 18, 'Základné informácie', 'zakon_zakladne_informacie', 10, NULL, 1);
INSERT INTO `log_type` (`id`, `nazov`, `code`, `primary_table`) VALUES (180, 'Pridanie zákona', 'zakon_pridaj', 'zakon');
INSERT INTO `log_type` (`id`, `nazov`, `code`, `primary_table`) VALUES (181, 'Editovanie zákona', 'zakon_edituj', 'zakon');
INSERT INTO `log_type` (`id`, `nazov`, `code`, `primary_table`) VALUES (182, 'Zmazanie zákona', 'zakon_zmaz', 'zakon');

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 (180, 180, 1, 'zakon', 'cislo', NULL, NULL, 'Číslo', 10, NULL, NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 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 (181, 180, 1, 'zakon', 'nazov', NULL, NULL, 'Názov', 20, NULL, NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 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 (182, 180, 5, 'zakon', 'druh_zakona_id', 'druh_zakona', NULL, 'Druh zákona', 30, NULL, NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, NULL, 'select2', NULL, 1, NULL, NULL, NULL, 1, NULL, 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 (183, 180, 5, 'zakon', 'stav_zakona_id', 'stav_zakona', NULL, 'Stav zákona', 40, NULL, NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, NULL, 'select2', NULL, 1, NULL, NULL, NULL, NULL, NULL, 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 (184, 180, 5, 'zakon', 'sluzba_id', 'sluzba', NULL, 'Služba', 50, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'select2', NULL, 1, NULL, NULL, NULL, 1, NULL, NULL, NULL);

ALTER TABLE `stav_zakona`
	ADD COLUMN `code` VARCHAR(50) NULL DEFAULT NULL AFTER `nazov`;

UPDATE `stav_zakona` SET `code`='platne' WHERE  `id`=1;
UPDATE `stav_zakona` SET `code`='zrusene' WHERE  `id`=2;

