/* 20:55:34 obcanlm */ ALTER TABLE `clanok` ADD `static_template` VARCHAR(255)  NULL  DEFAULT NULL  AFTER `zobrazit_subor`;
/* 20:56:10 obcanlm */ ALTER TABLE `clanok` ADD `clanok_id` INT(11)  NULL  DEFAULT NULL  AFTER `static_template`;

CREATE TABLE `zobrazenie_clanku` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nazov` varchar(255) DEFAULT NULL,
  `code` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `clanok_zobrazenie_clanku` (
  `clanok_id` int(11) NOT NULL,
  `zobrazenie_clanku_id` int(11) NOT NULL,
  PRIMARY KEY (`clanok_id`,`zobrazenie_clanku_id`),
  KEY `fk_clanok_has_zobrazenie_clanku_zobrazenie_clanku1_idx` (`zobrazenie_clanku_id`),
  KEY `fk_clanok_has_zobrazenie_clanku_clanok1_idx` (`clanok_id`),
  CONSTRAINT `fk_clanok_has_zobrazenie_clanku_clanok1` FOREIGN KEY (`clanok_id`) REFERENCES `clanok` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_clanok_has_zobrazenie_clanku_zobrazenie_clanku1` FOREIGN KEY (`zobrazenie_clanku_id`) REFERENCES `zobrazenie_clanku` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `typ_clanku` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nazov` varchar(255) DEFAULT NULL,
  `code` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `clanok_typ_clanku` (
  `clanok_id` int(11) NOT NULL,
  `typ_clanku_id` int(11) NOT NULL,
  PRIMARY KEY (`clanok_id`,`typ_clanku_id`),
  KEY `fk_clanok_has_typ_clanku_typ_clanku1_idx` (`typ_clanku_id`),
  KEY `fk_clanok_has_typ_clanku_clanok1_idx` (`clanok_id`),
  CONSTRAINT `fk_clanok_has_typ_clanku_clanok1` FOREIGN KEY (`clanok_id`) REFERENCES `clanok` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_clanok_has_typ_clanku_typ_clanku1` FOREIGN KEY (`typ_clanku_id`) REFERENCES `typ_clanku` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `zobrazenie_clanku` (`id`, `nazov`, `code`)
  VALUES
  (1, 'Zobraziť fotku po kliknutí na odkaz', 'zobrazit_fotku'),
  (2, 'Zobraziť súbor po kliknutí na odkaz', 'zobrazit_subor'),
  (3, 'Zobraziť dátum', 'zobrazit_datum');

DELETE FROM `form_element` WHERE db_column = "zobrazit_subor" AND form_group_id = 3003;
/* 22:49:15 obcanlm */ ALTER TABLE `clanok` DROP `zobrazit_subor`;

UPDATE form_element SET position = position *10 WHERE db_table = "clanok";
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`, `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 (NULL, '3003', '6', 'clanok', 'zobrazenie_clanku_id', 'zobrazenie_clanku', NULL, 'Zobrazenie článku', '40', NULL, NULL, NULL, NULL, '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '1', '1', 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`, `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 (NULL, '3003', '6', 'clanok', 'typ_clanku_id', 'typ_clanku', NULL, 'Typ článku', '50', NULL, NULL, NULL, NULL, '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '1', '1', 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`, `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
  (NULL, 3003, 1, 'clanok', 'static_template', NULL, NULL, 'Statická šablona', 60, NULL, NULL, NULL, '.tpl', 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  (NULL, 3003, 5, 'clanok', 'clanok_id', 'clanok', NULL, 'Nadradený článok', 70, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'chzn-select', NULL, 1, NULL, NULL, NULL, 1, NULL, NULL);


