CREATE TABLE `komunikacia` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nazov` varchar(255) DEFAULT NULL,
  `datum` datetime DEFAULT NULL,
  `zamestnanec_id` int(11) unsigned DEFAULT NULL,
  `text` text,
  `priradenie_komunikacie_id` int(11) unsigned DEFAULT NULL,
  `primary_id` int(11) unsigned DEFAULT NULL,
  `typ_komunikacie_id` int(11) unsigned DEFAULT NULL,
  `komunikacia_id` int(11) unsigned DEFAULT NULL,
  `visibility_type` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

INSERT INTO `priradenie_komunikacie` (`id`, `nazov`, `code`)
VALUES
	(330, 'Úloha', 'uloha');

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

INSERT INTO `typ_komunikacie` (`id`, `nazov`, `code`)
VALUES
	(1, 'E-mail', 'email'),
	(2, 'Telefonicky', 'tel'),
	(3, 'Osobne', 'osobne');

INSERT INTO `form` (`id`, `nazov`, `code`)
VALUES
	(380, 'Komunikácia', 'komunikacia');

INSERT INTO `form_group` (`id`, `form_id`, `nazov`, `code`, `position`, `poznamka`, `group_type`)
VALUES
	(38000, 380, 'Komunikácia', 'komunikacia', 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
	(38000, 38000, 11, 'komunikacia', 'datum', NULL, NULL, 'Dátum', 10, '{\"datetime_format\":\"d.m.Y H:i\",\"step\":1}', NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'NOW', NULL, NULL, NULL, NULL, NULL),
	(38001, 38000, 5, 'komunikacia', 'typ_komunikacie_id', 'typ_komunikacie', NULL, 'Typ komunikácie', 30, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'select2', NULL, 1, NULL, NULL, NULL, 1, NULL, NULL, NULL),
	(38002, 38000, 10, 'komunikacia', 'text', NULL, NULL, 'Text', 40, NULL, 600, 300, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL),
	(38003, 38000, 5, 'komunikacia', 'zamestnanec_id', 'zamestnanec', NULL, 'Vytvoril', 20, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, 1);

INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`)
VALUES
  (38000, NULL, 'Komunikácia', 'komunikacia', 20, 1, 3),
  (38001, 38000, 'Výpis komunikácie', 'komunikacia_vypis', 10, 2, 1),
  (38002, 38000, 'Pridanie komunikácie', 'komunikacia_pridaj', 20, 2, 1),
  (38003, 38001, 'Detail komunikácie', 'komunikacia_view', 10, 3, 1),
  (38004, 38001, 'Editovanie komunikácie', 'komunikacia_edituj', 20, 3, 1),
  (38005, 38001, 'Zmazanie komunikácie', 'komunikacia_zmaz', 30, 3, 0);

INSERT INTO `log_type` (`id`, `nazov`, `code`, `primary_table`)
VALUES
  (38000, 'Pridanie komunikácie', 'komunikacia_pridaj', NULL),
  (38001, 'Editovanie komunikácie', 'komunikacia_edituj', NULL),
  (38002, 'Zmazanie komunikácie', 'komunikacia_zmaz', NULL);
