CREATE TABLE `den` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `nazov` VARCHAR(50) NOT NULL,
  PRIMARY KEY (`id`)
)
  COLLATE='utf8_general_ci'
  ENGINE=InnoDB
  AUTO_INCREMENT=8
;

INSERT INTO `den` (`id`, `nazov`) VALUES (1, 'Pondelok');
INSERT INTO `den` (`id`, `nazov`) VALUES (2, 'Utorok');
INSERT INTO `den` (`id`, `nazov`) VALUES (3, 'Streda');
INSERT INTO `den` (`id`, `nazov`) VALUES (4, 'Štvrtok');
INSERT INTO `den` (`id`, `nazov`) VALUES (5, 'Piatok');
INSERT INTO `den` (`id`, `nazov`) VALUES (6, 'Sobota');
INSERT INTO `den` (`id`, `nazov`) VALUES (7, 'Nedeľa');

INSERT INTO `form` (`id`, `nazov`, `code`) VALUES (331, 'Opakovanie úlohy', 'uloha_opakovanie');

INSERT INTO `form_group` (`id`, `form_id`, `nazov`, `code`, `position`, `poznamka`, `group_type`) VALUES (33100, 331, 'Spôsob opakovania', 'uloha_opakovanie_sposob', 10, NULL, 1);
INSERT INTO `form_group` (`id`, `form_id`, `nazov`, `code`, `position`, `poznamka`, `group_type`) VALUES (33101, 331, 'Rozsah opakovania', 'uloha_opakovanie_rozsah', 20, 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 (33100, 33100, 13, 'uloha_opakovanie', 'uloha_id', 'uloha', NULL, 'Úloha', 0, 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 (33101, 33100, 5, 'uloha_opakovanie', 'perioda_opakovania_id', 'perioda_opakovania', NULL, 'Perióda', 10, NULL, NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, NULL, NULL, 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 (33102, 33100, 1, 'uloha_opakovanie', 'interval_opakovania', NULL, NULL, 'Opakovať každý', 20, NULL, NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '1', NULL, NULL, '<span id="interval_opakovania_example"></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 (33103, 33100, 1, 'uloha_opakovanie', 'den_v_periode', NULL, NULL, 'Deň', 30, NULL, NULL, NULL, NULL, NULL, 1, NULL, 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 (33104, 33101, 1, 'uloha_opakovanie', 'pocet_opakovani', NULL, NULL, 'Ukončiť po', 10, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'opakovaniach', 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 (33105, 33101, 4, 'uloha_opakovanie', 'datum_platnosti_od', NULL, NULL, 'Začiatok opakovania', 20, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'NOW', 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 (33106, 33101, 4, 'uloha_opakovanie', 'datum_platnosti_do', NULL, NULL, 'Koniec opakovania', 30, NULL, NULL, NULL, NULL, NULL, 1, NULL, 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 (33107, 33100, 6, 'uloha_opakovanie', 'den_id', 'den', NULL, 'Deň v ťýždni', 40, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, 1, 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 (33108, 33100, 5, 'uloha_opakovanie', 'mesiac_id', 'mesiac', NULL, 'Mesiac v roku', 50, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, 1, NULL, NULL, NULL);

INSERT INTO `log_type` (`id`, `nazov`, `code`, `primary_table`) VALUES (33100, 'Pridania opakovania úlohy', 'uloha_opakovanie_pridaj', 'uloha_opakovanie');
INSERT INTO `log_type` (`id`, `nazov`, `code`, `primary_table`) VALUES (33101, 'Editovanie opakovania úlohy', 'uloha_opakovanie_edituj', 'uloha_opakovanie');
INSERT INTO `log_type` (`id`, `nazov`, `code`, `primary_table`) VALUES (33102, 'Zmazanie opakovania úlohy', 'uloha_opakovanie_zmaz', 'uloha_opakovanie');

INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (33100, 33002, 'Opakovanie úlohy', 'uloha_opakovanie_view', 50, 3, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (33101, 33002, 'Editovanie opakovania úlohy', 'uloha_opakovanie_edituj', NULL, 3, NULL);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (33102, 33002, 'Pridanie opakovania úlohy', 'uloha_opakovanie_pridaj', NULL, 3, NULL);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (33103, 33002, 'Zmazanie opakovania úlohy', 'uloha_opakovanie_zmaz', NULL, 3, NULL);

CREATE TABLE `mesiac` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `nazov` VARCHAR(50) NOT NULL,
  PRIMARY KEY (`id`)
)
  COLLATE='utf8_general_ci'
  ENGINE=InnoDB
  AUTO_INCREMENT=13
;

INSERT INTO `mesiac` (`id`, `nazov`) VALUES (1, 'Január');
INSERT INTO `mesiac` (`id`, `nazov`) VALUES (2, 'Február');
INSERT INTO `mesiac` (`id`, `nazov`) VALUES (3, 'Marec');
INSERT INTO `mesiac` (`id`, `nazov`) VALUES (4, 'Apríl');
INSERT INTO `mesiac` (`id`, `nazov`) VALUES (5, 'Máj');
INSERT INTO `mesiac` (`id`, `nazov`) VALUES (6, 'Jún');
INSERT INTO `mesiac` (`id`, `nazov`) VALUES (7, 'Júl');
INSERT INTO `mesiac` (`id`, `nazov`) VALUES (8, 'August');
INSERT INTO `mesiac` (`id`, `nazov`) VALUES (9, 'September');
INSERT INTO `mesiac` (`id`, `nazov`) VALUES (10, 'Október');
INSERT INTO `mesiac` (`id`, `nazov`) VALUES (11, 'November');
INSERT INTO `mesiac` (`id`, `nazov`) VALUES (12, 'December');

CREATE TABLE `perioda_opakovania` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `nazov` VARCHAR(50) NOT NULL,
  `code` VARCHAR(50) NOT NULL,
  PRIMARY KEY (`id`)
)
  COLLATE='utf8_general_ci'
  ENGINE=InnoDB
;

INSERT INTO `perioda_opakovania` (`id`, `nazov`, `code`) VALUES (1, 'Denne', 'den');
INSERT INTO `perioda_opakovania` (`id`, `nazov`, `code`) VALUES (2, 'Týždenne', 'tyzden');
INSERT INTO `perioda_opakovania` (`id`, `nazov`, `code`) VALUES (3, 'Mesačne', 'mesiac');
INSERT INTO `perioda_opakovania` (`id`, `nazov`, `code`) VALUES (4, 'Ročne', 'rok');

CREATE TABLE `uloha_opakovanie` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `visibility_type` INT(11) NOT NULL,
  `nazov` VARCHAR(50) NOT NULL,
  `uloha_id` INT(11) NOT NULL,
  `perioda_opakovania_id` INT(11) NOT NULL COMMENT 'denne, týždenne, mesačne, ročne',
  `interval_opakovania` INT(11) NOT NULL COMMENT 'každý 2. deň, každý 1. mesiac',
  `den_v_periode` INT(11) NOT NULL COMMENT '15. deň v mesiaci',
  `pocet_opakovani` INT(11) NULL DEFAULT NULL COMMENT 'opakovať 10x',
  `datum_platnosti_od` DATE NOT NULL,
  `datum_platnosti_do` DATE NULL DEFAULT NULL,
  `mesiac_id` INT(11) NULL DEFAULT NULL COMMENT 'pri ročnom opakovaní',
  PRIMARY KEY (`id`)
)
  COLLATE='utf8_general_ci'
  ENGINE=InnoDB
;

CREATE TABLE `uloha_opakovanie_den` (
  `uloha_opakovanie_id` INT(11) NOT NULL,
  `den_id` INT(11) NOT NULL,
  PRIMARY KEY (`uloha_opakovanie_id`, `den_id`)
)
  COLLATE='utf8_general_ci'
  ENGINE=InnoDB
;

