CREATE TABLE `priorita_ulohy` (
  `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
  AUTO_INCREMENT=5
;

INSERT INTO `priorita_ulohy` (`id`, `nazov`, `poradie`, `code`) VALUES (1, 'Kritická', 10, 'kriticka');
INSERT INTO `priorita_ulohy` (`id`, `nazov`, `poradie`, `code`) VALUES (2, 'Vysoká', 20, 'vysoka');
INSERT INTO `priorita_ulohy` (`id`, `nazov`, `poradie`, `code`) VALUES (3, 'Stredná', 30, 'stredna');
INSERT INTO `priorita_ulohy` (`id`, `nazov`, `poradie`, `code`) VALUES (4, 'Nízka', 40, 'nizka');

CREATE TABLE `stav_ulohy` (
  `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
  AUTO_INCREMENT=4
;

INSERT INTO `stav_ulohy` (`id`, `nazov`, `poradie`, `code`) VALUES (1, 'Otvorená', 10, 'open');
INSERT INTO `stav_ulohy` (`id`, `nazov`, `poradie`, `code`) VALUES (2, 'Rozpracovaná', 20, 'in_progress');
INSERT INTO `stav_ulohy` (`id`, `nazov`, `poradie`, `code`) VALUES (3, 'Vyriešená', 30, 'resolved');

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


CREATE TABLE `uloha` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `visibility_type` INT(11) NOT NULL,
  `nazov` VARCHAR(50) NOT NULL,
  `vytvoril_id` INT(11) NOT NULL,
  `priradene_id` INT(11) NOT NULL,
  `popis` TEXT NOT NULL,
  `datum_vytvorenia` DATETIME NOT NULL,
  `datum_aktualizacie` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `pozadovany_datum_vyriesenia` DATE NOT NULL,
  `priorita_ulohy_id` INT(11) NOT NULL,
  `stav_ulohy_id` INT(11) NOT NULL,
  `uloha_id` INT(11) NULL DEFAULT NULL,
  `pripomenutie` DATETIME NULL DEFAULT NULL,
  `typ_ulohy_id` INT(11) NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
)
  COLLATE='utf8_general_ci'
  ENGINE=InnoDB
;

INSERT INTO `form` (`id`, `nazov`, `code`) VALUES (330, 'Úlohy', 'uloha');
INSERT INTO `form_group` (`id`, `form_id`, `nazov`, `code`, `position`, `poznamka`, `group_type`) VALUES (33000, 330, 'Základné informácie', 'uloha_zakladne_informacie', 10, 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 (33000, 33000, 13, 'uloha', 'uloha_id', 'uloha', NULL, 'Nadradená úloha', 5, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, 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 (33001, 33000, 1, 'uloha', '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 (33002, 33000, 5, 'uloha', 'vytvoril_id', 'zamestnanec', NULL, 'Vytvoril', 20, NULL, NULL, NULL, NULL, NULL, 1, NULL, 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 (33003, 33000, 5, 'uloha', 'priradene_id', 'zamestnanec', NULL, 'Priradené', 30, NULL, NULL, NULL, NULL, NULL, 1, NULL, 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 (33004, 33000, 5, 'uloha', 'stav_ulohy_id', 'stav_ulohy', NULL, 'Stav úlohy', 40, NULL, NULL, NULL, NULL, NULL, 1, NULL, 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 (33005, 33000, 5, 'uloha', 'priorita_ulohy_id', 'priorita_ulohy', NULL, 'Priorita úlohy', 50, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'select2', NULL, 1, NULL, '2', 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 (33006, 33000, 11, 'uloha', 'datum_vytvorenia', NULL, NULL, 'Dátum vytvorenia', 60, '{"datetime_format":"d.m.Y H:i:s","step":1}', NULL, NULL, NULL, NULL, 0, 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 (33007, 33000, 11, 'uloha', 'datum_aktualizacie', NULL, NULL, 'Posledná aktualizácia', 70, '{"datetime_format":"d.m.Y H:i:s","step":1}', NULL, NULL, NULL, NULL, 0, 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 (33008, 33000, 4, 'uloha', 'pozadovany_datum_vyriesenia', NULL, NULL, 'Požadovaný dátum vyriešenia', 80, 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 (33009, 33000, 10, 'uloha', 'popis', NULL, NULL, 'Popis', 90, NULL, 600, 300, 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 (33010, 33000, 5, 'uloha', 'typ_ulohy_id', 'typ_ulohy', NULL, 'Typ úlohy', 5, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'select2', NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (33000, NULL, 'Úlohy', 'uloha', 60, 1, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (33001, 33000, 'Pridanie úlohy', 'uloha_pridaj', 2, 2, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (33002, 33000, 'Výpis úloh', 'uloha_vypis', 1, 2, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (33003, 33002, 'Detail úlohy', 'uloha_view', 1, 3, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (33004, 33002, 'Editovanie úlohy', 'uloha_edituj', 2, 3, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (33005, 33002, 'Zmazanie úlohy', 'uloha_zmaz', NULL, 3, 0);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (33006, 33002, 'Súbory úlohy', 'uloha_subor', 4, 3, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (33007, 33002, 'Fotky úlohy', 'uloha_foto', 3, 3, 1);

INSERT INTO `log_type` (`id`, `nazov`, `code`, `primary_table`) VALUES (33000, 'Pridanie úlohy', 'uloha_pridaj', 'uloha');
INSERT INTO `log_type` (`id`, `nazov`, `code`, `primary_table`) VALUES (33001, 'Editovanie úlohy', 'uloha_edituj', 'uloha');
INSERT INTO `log_type` (`id`, `nazov`, `code`, `primary_table`) VALUES (33002, 'Zmazanie úlohy', 'uloha_zmaz', 'uloha');

