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

-- Exportování dat pro tabulku gmspider_test.typ_formulara: ~2 rows (přibližně)
/*!40000 ALTER TABLE `typ_formulara` DISABLE KEYS */;
INSERT INTO `typ_formulara` (`id`, `nazov`) VALUES
	(1, 'Záznam o registrovanom pracovnom úraze'),
	(2, 'F1_S9 Vstupná analýza BOZP');
/*!40000 ALTER TABLE `typ_formulara` ENABLE KEYS */;

-- Exportování struktury pro tabulka gmspider_test.formular
CREATE TABLE IF NOT EXISTS `formular` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `visibility_type` int(11) DEFAULT NULL,
  `nazov` varchar(255) DEFAULT NULL,
  `sluzva_id` int(11) DEFAULT NULL,
  `obchodny_partner_id` int(11) DEFAULT NULL,
  `datum_vytvorenia` timestamp NULL DEFAULT NULL,
  `poznamka` text,
  `typ_formulara_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `FK_formular_typ-formulara` (`typ_formulara_id`),
  CONSTRAINT `FK_formular_typ_formulara` FOREIGN KEY (`typ_formulara_id`) REFERENCES `typ_formulara` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `formular`
	CHANGE COLUMN `sluzva_id` `sluzba_id` INT(11) NULL DEFAULT NULL AFTER `nazov`;

INSERT INTO `form` (`id`, `nazov`, `code`) VALUES (80, 'Formulár', 'formular');
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (80, 180, 'Formuláre', 'formular_vypis', 10, 2, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (81, 180, 'Pridanie formulára', 'formular_pridaj', 20, 2, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (82, 80, 'Detail formulára', 'formular_view', 10, 3, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (83, 80, 'Editovanie formulára', 'formular_edituj', 20, 3, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (84, 80, 'Zmazanie formulára', 'formular_zmaz', NULL, 3, 0);

INSERT INTO `form_group` (`id`, `form_id`, `nazov`, `code`, `position`, `poznamka`, `group_type`) VALUES (80, 80, 'Základné informácie', 'formular_zakladne_informacie', 10, NULL, 1);
ALTER TABLE `formular`
	CHANGE COLUMN `datum_vytvorenia` `datum_vytvorenia` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP() AFTER `obchodny_partner_id`;

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 (232, 80, 1, 'formular', 'nazov', NULL, NULL, 'Názov', 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 (234, 80, 5, 'formular', 'sluzba_id', 'sluzba', NULL, 'Služba', 20, 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 (235, 80, 5, 'formular', 'obchodny_partner_id', 'obchodny_partner', NULL, 'Obchodný partner', 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 (236, 80, 11, 'formular', 'datum_vytvorenia', NULL, NULL, 'Dátum vytvorenia', 1, '{"datetime_format":"d.m.Y H:i:s","step":1}', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'NOW', NULL, NULL, NULL, NULL, 1);
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 (237, 80, 5, 'formular', 'typ_formulara_id', 'typ_formulara', NULL, 'Typ', 40, 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 (238, 80, 2, 'formular', 'poznamka', NULL, NULL, 'Poznámka', 50, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

INSERT INTO `log_type` (`nazov`, `code`, `primary_table`) VALUES ('Pridanie formulára', 'formular_pridaj', 'formular');
INSERT INTO `log_type` (`nazov`, `code`, `primary_table`) VALUES ('Editovanie formulára', 'formular_edituj', 'formular');
INSERT INTO `log_type` (`nazov`, `code`, `primary_table`) VALUES ('Zmazanie formulára', 'formular_zmaz', 'formular');
