CREATE TABLE `clanok` (
	`id` INT(11) NOT NULL AUTO_INCREMENT,
	`jazyk_id` INT(11) NOT NULL,
	`nazov` VARCHAR(255) NULL DEFAULT NULL,
	`kratky_text` TEXT NULL,
	`text` TEXT NULL,
	`datum` DATE NULL DEFAULT NULL,
	`odkaz` VARCHAR(255) NULL DEFAULT NULL,
	`nove_okno` TINYINT(1) UNSIGNED NULL DEFAULT NULL,
	`title` VARCHAR(255) NULL DEFAULT NULL,
	`keywords` VARCHAR(255) NULL DEFAULT NULL,
	`description` VARCHAR(255) NULL DEFAULT NULL,
	`visibility_type` TINYINT(1) UNSIGNED NULL DEFAULT NULL,
	`zobrazit_subor` TINYINT(1) UNSIGNED NULL DEFAULT NULL,
	PRIMARY KEY (`id`),
	INDEX `clanok_FKIndex1` (`jazyk_id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=1;

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


CREATE TABLE `clanok_skupina_clanku` (
	`clanok_id` INT(11) NOT NULL,
	`skupina_clanku_id` INT(11) NOT NULL,
	PRIMARY KEY (`clanok_id`, `skupina_clanku_id`),
	INDEX `fk_clanok_has_skupina_clanku_skupina_clanku1_idx` (`skupina_clanku_id`),
	INDEX `fk_clanok_has_skupina_clanku_clanok1_idx` (`clanok_id`),
	CONSTRAINT `fk_clanok_has_skupina_clanku_clanok1` FOREIGN KEY (`clanok_id`) REFERENCES `clanok` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION,
	CONSTRAINT `fk_clanok_has_skupina_clanku_skupina_clanku1` FOREIGN KEY (`skupina_clanku_id`) REFERENCES `skupina_clanku` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;



INSERT INTO `form` (`id`, `nazov`, `code`) VALUES (30, 'Článok', 'clanok');

INSERT INTO `form_group` (`id`, `form_id`, `nazov`, `code`, `position`, `poznamka`) VALUES (3001, 30, 'Základné informácie', 'clanok_zakladne_informacie', 1, NULL);
INSERT INTO `form_group` (`id`, `form_id`, `nazov`, `code`, `position`, `poznamka`) VALUES (3002, 30, 'Metadata', 'clanok_metadata', 3, NULL);
INSERT INTO `form_group` (`id`, `form_id`, `nazov`, `code`, `position`, `poznamka`) VALUES (3003, 30, 'Rozšírené informácie', 'clanok_rozsirene_informacie', 2, NULL);

INSERT INTO `form_element` (`form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`, `db_multivalue_table`, `column_title`, `position`, `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`) VALUES (3001, 1, 'clanok', 'nazov', NULL, NULL, 'Názov', 1, NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `form_element` (`form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`, `db_multivalue_table`, `column_title`, `position`, `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`) VALUES (3001, 6, 'clanok', 'skupina_clanku_id', 'skupina_clanku', NULL, 'Skupina článku', 3, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `form_element` (`form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`, `db_multivalue_table`, `column_title`, `position`, `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`) VALUES (3001, 2, 'clanok', 'kratky_text', NULL, NULL, 'Krátky text', 4, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `form_element` (`form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`, `db_multivalue_table`, `column_title`, `position`, `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`) VALUES (3001, 10, 'clanok', 'text', NULL, NULL, 'Text', 5, 600, 300, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `form_element` (`form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`, `db_multivalue_table`, `column_title`, `position`, `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`) VALUES (3001, 4, 'clanok', 'datum', NULL, NULL, 'Dátum pridania', 2, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'NOW', NULL, NULL, NULL, NULL);
INSERT INTO `form_element` (`form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`, `db_multivalue_table`, `column_title`, `position`, `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`) VALUES (3002, 1, 'clanok', 'title', NULL, NULL, 'Title', 1, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `form_element` (`form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`, `db_multivalue_table`, `column_title`, `position`, `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`) VALUES (3002, 2, 'clanok', 'keywords', NULL, NULL, 'Keywords', 2, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `form_element` (`form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`, `db_multivalue_table`, `column_title`, `position`, `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`) VALUES (3002, 2, 'clanok', 'description', NULL, NULL, 'Description', 3, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `form_element` (`form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`, `db_multivalue_table`, `column_title`, `position`, `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`) VALUES (3003, 1, 'clanok', 'odkaz', NULL, NULL, 'Odkaz', 1, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `form_element` (`form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`, `db_multivalue_table`, `column_title`, `position`, `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`) VALUES (3003, 3, 'clanok', 'nove_okno', NULL, NULL, 'Otvoriť odkaz v novom okne', 2, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `form_element` (`form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`, `db_multivalue_table`, `column_title`, `position`, `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`) VALUES (3003, 3, 'clanok', 'zobrazit_subor', NULL, NULL, 'Zobraziť súbor', 3, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);


INSERT IGNORE INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES ('1999', null, 'CMS', 'cms', '50', '1', '1');
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (3000, 1999, 'Články', 'clanok_vypis', 2, 2, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (3001, 3000, 'Pridanie článku', 'clanok_pridaj', 0, 3, 0);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (3002, 3000, 'Detail článku', 'clanok_view', 1, 3, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (3003, 3000, 'Editovanie článku', 'clanok_edituj', 2, 3, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (3004, 3000, 'Zmazanie článku', 'clanok_zmaz', NULL, 3, NULL);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (3005, 3000, 'Fotografie článku', 'clanok_foto', 3, 3, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (3006, 3000, 'Súbory článku', 'clanok_subor', 4, 3, 1);

INSERT INTO `log_type` (`nazov`, `code`, `primary_table`) VALUES ('Pridanie článku', 'clanok_pridaj', 'clanok');
INSERT INTO `log_type` (`nazov`, `code`, `primary_table`) VALUES ('Editovanie článku', 'clanok_edituj', 'clanok');
INSERT INTO `log_type` (`nazov`, `code`, `primary_table`) VALUES ('Zmazanie článku', 'clanok_zmaz', 'clanok');

INSERT INTO `priradenie_suboru` (`id`, `nazov`, `code`) VALUES (3000, 'Článok', 'clanok');
