CREATE TABLE `kategoria_produktu` (
                                      `id` INT(11) NOT NULL AUTO_INCREMENT,
                                      `nazov` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
                                      PRIMARY KEY (`id`) USING BTREE
)
    COLLATE='utf8_general_ci'
ENGINE=InnoDB
;

INSERT INTO `kategoria_produktu` (`id`, `nazov`) VALUES (1, 'Školenia');
INSERT INTO `kategoria_produktu` (`id`, `nazov`) VALUES (2, 'Revízie');
INSERT INTO `kategoria_produktu` (`id`, `nazov`) VALUES (3, 'Služby');
INSERT INTO `kategoria_produktu` (`id`, `nazov`) VALUES (4, 'Materiály OPP');
INSERT INTO `kategoria_produktu` (`id`, `nazov`) VALUES (5, 'Bezpečnostné značenia');
INSERT INTO `kategoria_produktu` (`id`, `nazov`) VALUES (6, 'Pracovná zdravotná služba');
INSERT INTO `kategoria_produktu` (`id`, `nazov`) VALUES (7, 'Lekárske prehliadky');
INSERT INTO `kategoria_produktu` (`id`, `nazov`) VALUES (8, 'Kontrola');
INSERT INTO `kategoria_produktu` (`id`, `nazov`) VALUES (9, 'Tovar');

ALTER TABLE `produkt`
    ADD COLUMN `kod` VARCHAR(255) NULL DEFAULT NULL AFTER `produkt_id`,
	ADD COLUMN `cena_bez_dph` FLOAT NULL DEFAULT NULL AFTER `kod`;

INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (420, 36, 'Produkty', 'produkt_vypis', 50, 2, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (421, 36, 'Pridanie produktu', 'produkt_pridaj', 20, 2, 3);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (422, 420, 'Detail produktu', 'produkt_view', 10, 3, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (423, 420, 'Editovanie produktu', 'produkt_edituj', 20, 3, 1);
INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (424, 420, 'Zmazanie produktu', 'produkt_zmaz', NULL, 3, NULL);

INSERT INTO `form` (`id`, `nazov`, `code`) VALUES (420, 'Produkt', 'produkt');
INSERT INTO `form_group` (`id`, `form_id`, `nazov`, `code`, `position`, `poznamka`, `group_type`) VALUES (420, 420, 'Základné informácie', 'produkt_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 (440, 420, 5, 'produkt', 'kategoria_produktu_id', 'kategoria_produktu', NULL, 'Kategória', 10, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'select2', 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 (441, 420, 1, 'produkt', 'nazov', NULL, NULL, 'Názov', 20, 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 (442, 420, 1, 'produkt', 'kod', NULL, NULL, 'Kód', 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 (443, 420, 5, 'produkt', 'merna_jednotka_id', 'merna_jednotka', NULL, 'Merná jednotka', 40, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'select2', 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 (444, 420, 1, 'produkt', 'cena_bez_dph', NULL, NULL, 'Cena bez DPH', 50, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 1, 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 (445, 420, 2, 'produkt', 'text', NULL, NULL, 'Popis', 60, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);


INSERT INTO `log_type` (`id`, `nazov`, `code`, `primary_table`) VALUES (420, 'Pridanie produktu', 'produkt_pridaj', NULL);
INSERT INTO `log_type` (`id`, `nazov`, `code`, `primary_table`) VALUES (421, 'Editovanie produktu', 'produkt_edituj', NULL);
INSERT INTO `log_type` (`id`, `nazov`, `code`, `primary_table`) VALUES (422, 'Zmazanie produktu', 'produkt_zmaz', 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 (28102, 28100, 5, 'polozka_cenovej_ponuky', 'kategoria_produktu_id', 'kategoria_produktu', NULL, 'Kategória produktu', 10, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'select2', 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 (28103, 28100, 5, 'polozka_cenovej_ponuky', 'produkt_id', 'produkt', NULL, 'Produkt', 20, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'select2', NULL, 1, NULL, NULL, NULL, 1, NULL, NULL, NULL);

ALTER TABLE `polozka_objednavky`
    ADD COLUMN `kategoria_produktu_id` INT NULL DEFAULT NULL AFTER `skupina`,
	ADD COLUMN `produkt_id` INT NULL DEFAULT NULL AFTER `kategoria_produktu_id`;

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 (40102, 40100, 5, 'polozka_objednavky', 'kategoria_produktu_id', 'kategoria_produktu', NULL, 'Kategória produktu', 10, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'select2', 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 (40103, 40100, 5, 'polozka_objednavky', 'produkt_id', 'produkt', NULL, 'Produkt', 20, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'select2', NULL, 1, NULL, NULL, NULL, 1, NULL, NULL, NULL);

UPDATE `form_element` SET `required`=1 WHERE  `id`=441;
UPDATE `form_element` SET `required`=1 WHERE  `id`=442;
UPDATE `form_element` SET `vdaemon`='<vlvalidator name="customProduktKod" type="custom" function="vdaemonProduktKod" />' WHERE  `id`=442;
