CREATE TABLE `poziadavka_na_cenovu_ponuku` (
                                               `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
                                               `visibility_type` int(11) DEFAULT NULL,
                                               `cislo` varchar(255) DEFAULT NULL,
                                               `nazov` varchar(255) DEFAULT NULL,
                                               `hash` varchar(255) DEFAULT NULL,
                                               `interna_poznamka` text DEFAULT NULL,
                                               `text_pre_zakaznika` text DEFAULT NULL,
                                               `obchodny_partner_id` int(10) unsigned DEFAULT NULL,
                                               `osoba_id` int(10) unsigned DEFAULT NULL,
                                               `vytvoril_id` int(10) unsigned DEFAULT NULL,
                                               `datum_odoslania` datetime DEFAULT NULL,
                                               `datum_vytvorenia` timestamp NULL DEFAULT current_timestamp(),
                                               `schvalovatel_id` int(10) unsigned DEFAULT NULL,
                                               `stav_poziadavky_na_cenovu_ponuku_id` int(10) unsigned DEFAULT NULL,
                                               PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

CREATE TABLE `polozka_poziadavky_na_cenovu_ponuku` (
                                                       `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
                                                       `visibility_type` int(11) DEFAULT NULL,
                                                       `poziadavka_na_cenovu_ponuku_id` int(10) unsigned DEFAULT NULL,
                                                       `nazov` varchar(255) DEFAULT NULL,
                                                       `kategoria_produktu_id` int(10) unsigned DEFAULT NULL,
                                                       `produkt_id` int(10) DEFAULT NULL,
                                                       `cena_bez_dph` double(10,2) DEFAULT NULL,
                                                       `cena_info` varchar(255) DEFAULT NULL,
                                                       `mnozstvo` double(8,2) DEFAULT NULL,
                                                       `popis` text DEFAULT NULL,
                                                       `merna_jednotka_id` int(10) unsigned DEFAULT NULL,
                                                       `poradie` int(11) DEFAULT NULL,
                                                       `skupina` varchar(255) DEFAULT NULL,
                                                       PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`)
VALUES
    (435, 180, 'Požiadavky na cenovú ponuku', 'poziadavka_na_cenovu_ponuku_vypis', 70, 2, 1),
    (436, 180, 'Pridanie požiadavky na cenovú ponuku', 'poziadavka_na_cenovu_ponuku_pridaj', 60, 2, 0),
    (437, 435, 'Detail požiadavky na cenovú ponuku', 'poziadavka_na_cenovu_ponuku_view', 10, 3, 1),
    (438, 435, 'Editovanie požiadavky na cenovú ponuku', 'poziadavka_na_cenovu_ponuku_edituj', 20, 3, 1),
    (439, 435, 'Zmazanie požiadavky na cenovú ponuku', 'poziadavka_na_cenovu_ponuku_zmaz', NULL, 3, NULL),
    (440, 435, 'Súbory požiadavky na cenovú ponuku', 'poziadavka_na_cenovu_ponuku_subor', 40, 3, 1),
    (441, 435, 'Foto k požiadavke na cenovú ponuku', 'poziadavka_na_cenovu_ponuku_foto', 30, 3, 1),
    (442, 435, 'Pridanie položky požiadavky na cenovú ponuku', 'polozka_poziadavky_na_cenovu_ponuku_pridaj', NULL, 3, NULL),
    (443, 435, 'Editovanie položky požiadavky na cenovú ponuku', 'polozka_poziadavky_na_cenovu_ponuku_edituj', NULL, 3, NULL),
    (444, 435, 'Zmazanie položky požiadavky na cenovú ponuku', 'polozka_poziadavky_na_cenovu_ponuku_zmaz', NULL, 3, NULL);

INSERT INTO `log_type` (`id`, `nazov`, `code`, `primary_table`)
VALUES
    (81, 'Pridanie požiadavky na cenovú ponukuy', 'poziadavka_na_cenovu_ponuku_pridaj', NULL),
    (82, 'Editovanie požiadavky na cenovú ponukuy', 'poziadavka_na_cenovu_ponuku_edituj', NULL),
    (83, 'Zmazanie požiadavky na cenovú ponukuy', 'poziadavka_na_cenovu_ponuku_zmaz', NULL),
    (84, 'Pridanie položky požiadavky na cenovú ponukuy', 'polozka_poziadavky_na_cenovu_ponuku_pridaj', NULL),
    (85, 'Editovanie položky požiadavky na cenovú ponukuy', 'polozka_poziadavky_na_cenovu_ponuku_edituj', NULL),
    (86, 'Zmazanie položky požiadavky na cenovú ponukuy', 'polozka_poziadavky_na_cenovu_ponuku_zmaz', NULL);

INSERT INTO `form` (`id`, `nazov`, `code`)
VALUES
    (74, 'Požiadavka na cenovú ponuku', 'poziadavka_na_cenovu_ponuku'),
    (75, 'Položka požiadavky na cenovú ponuku', 'polozka_poziadavky_na_cenovu_ponuku');

/* 22:17:18 gmspider */ ALTER TABLE `form_group` CHANGE `code` `code` VARCHAR(255)  CHARACTER SET utf8mb3  NULL  DEFAULT NULL;
/* 22:17:22 gmspider */ ALTER TABLE `form_group` CHANGE `nazov` `nazov` VARCHAR(255)  CHARACTER SET utf8mb3  NULL  DEFAULT NULL;

INSERT INTO `form_group` (`id`, `form_id`, `nazov`, `code`, `position`, `poznamka`, `group_type`)
VALUES
    (33, 74, 'Základné informácie', 'poziadavka_na_cenovu_ponuku_zakladne_informacie', 10, NULL, 1),
    (34, 74, 'Texty', 'poziadavka_na_cenovu_ponuku_texty', 30, NULL, 1),
    (35, 75, 'Základné informácie', 'polozka_poziadavky_na_cenovu_ponuku_zakladne_informac', 10, NULL, 1);

/* 08:25:47 gmspider */ INSERT INTO `priradenie_suboru` (`id`, `nazov`, `code`) VALUES ('5', 'Požiadavka na cenovú ponuku', 'poziadavka_na_cenovu_ponuku');
/* 08:47:59 gmspider */ ALTER TABLE `cenova_ponuka` ADD `poziadavka_na_cenovu_ponuku_id` INT(11)  NULL  DEFAULT NULL  AFTER `typ_cenovej_ponuky_id`;
/* 08:58:34 gmspider */ CREATE TABLE `stav_poziadavky_na_cenovu_ponuku` (   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,   `nazov` varchar(255) NOT NULL,   `code` varchar(255) NOT NULL,   `poradie` int(11) NOT NULL,   PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

INSERT INTO `stav_poziadavky_na_cenovu_ponuku` (`id`, `nazov`, `code`, `poradie`)
VALUES
    (1, 'Rozpracovaná', 'rozpracovana', 10),
    (2, 'Rozpracovaná (čaká sa na schvaľovateľa)', 'rozpravcovana_schvalovatel', 20),
    (3, 'Odložená', 'odlozena', 40),
    (4, 'Úspešná', 'uspesna', 50),
    (5, 'Neúspešná', 'neuspesna', 60),
    (7, 'Archív', 'archiv', 70);

/* 22:06:24 gmspider */ INSERT INTO `priradenie_komunikacie` (`id`, `nazov`, `code`) VALUES ('420', 'Požiadavka na cenovú ponuku', 'polozka_na_cenovu_ponuku');
/* 22:07:11 gmspider */ UPDATE `priradenie_komunikacie` SET `code` = 'poziadavka_na_cenovu_ponuku' WHERE `id` = '420';
/* 22:13:04 gmspider */ INSERT INTO `permission` (`id`, `nazov`) VALUES ('203', 'poziadavka_na_cenovu_ponuku_all');
/* 22:13:14 gmspider */ INSERT INTO `permission` (`id`, `nazov`) VALUES ('204', 'polozka_poziadavky_na_cenovu_ponuku_all');
/* 22:13:26 gmspider */ INSERT INTO `role_permission` (`role_id`, `permission_id`) VALUES 	(3, 203), 	(3, 204);
/* 22:14:03 gmspider */ INSERT INTO `role_permission` (`role_id`, `permission_id`) VALUES 	(2, 203), 	(2, 204);
/* 22:14:06 gmspider */ INSERT INTO `role_permission` (`role_id`, `permission_id`) VALUES 	(5, 203), 	(5, 204);
/* 22:14:09 gmspider */ INSERT INTO `role_permission` (`role_id`, `permission_id`) VALUES 	(9, 203), 	(9, 204);

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
    (468, 33, 1, 'poziadavka_na_cenovu_ponuku', 'cislo', NULL, NULL, 'Číslo', 10, NULL, NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '<vlvalidator name=\"customCislo\" type=\"custom\" function=\"vdaemonCislo\">', NULL, NULL, NULL, NULL),
    (469, 33, 11, 'poziadavka_na_cenovu_ponuku', 'datum_vytvorenia', NULL, NULL, 'Dátum vytvorenia', 20, '{\"datetime_format\":\"d.m.Y H:i:s\",\"step\":1}', NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'NOW', NULL, NULL, NULL, NULL, NULL),
    (470, 33, 5, 'poziadavka_na_cenovu_ponuku', 'osoba_id', 'osoba', NULL, 'Kontaktná osoba', 50, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'select2', NULL, NULL, NULL, NULL, NULL, 1, '<a class=\"btn btn-primary get-ajax-form\" href=\"osoba_pridaj_modal.php\" title=\"Pridanie osoby\" data-before-load=\"osoba.beforeLoad\" data-parent=\"osoba_id\"> <i class=\"fa fa-plus\"></i></a>', NULL, NULL),
    (471, 33, 5, 'poziadavka_na_cenovu_ponuku', 'vytvoril_id', 'zamestnanec', NULL, 'Vytvoril', 30, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, 'select2', NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, 1),
    (472, 33, 5, 'poziadavka_na_cenovu_ponuku', 'obchodny_partner_id', 'obchodny_partner', NULL, 'Obchodný partner', 40, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'select2', NULL, 1, NULL, NULL, NULL, 1, '<a class=\"btn btn-primary get-ajax-form\" href=\"obchodny_partner_pridaj_modal.php\" title=\"Pridanie obchodného partnera\" data-after_load=\"obchodnyPartner.afterLoad\" data-parent=\"obchodny_partner_id\"><i class=\"fa fa-plus\"></i></a>', NULL, NULL),
    (473, 34, 10, 'poziadavka_na_cenovu_ponuku', 'interna_poznamka', NULL, NULL, 'Interná poznámka', 40, NULL, 600, 300, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
    (474, 34, 10, 'poziadavka_na_cenovu_ponuku', 'text_pre_zakaznika', NULL, NULL, 'Text pre zákazníka', 10, NULL, 600, 300, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
    (483, 33, 5, 'poziadavka_na_cenovu_ponuku', 'schvalovatel_id', 'zamestnanec', NULL, 'Schvaľovateľ', 60, NULL, NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, NULL, 'select2', NULL, 1, NULL, NULL, NULL, 1, NULL, NULL, NULL),
    (484, 33, 5, 'poziadavka_na_cenovu_ponuku', 'stav_poziadavky_na_cenovu_ponuku_id', 'stav_poziadavky_na_cenovu_ponuku', NULL, 'Stav', 70, NULL, NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, NULL, 'select2', NULL, 1, NULL, '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`, `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
    (485, 35, 1, 'polozka_poziadavky_na_cenovu_ponuku', 'nazov', NULL, NULL, 'Názov', 40, NULL, 400, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
    (486, 35, 13, 'polozka_poziadavky_na_cenovu_ponuku', 'poziadavka_na_cenovu_ponuku_id', 'poziadavka_na_cenovu_ponuku', NULL, 'Požiadavka na cenovú ponuku', 1, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
    (487, 35, 5, 'polozka_poziadavky_na_cenovu_ponuku', '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),
    (488, 35, 5, 'polozka_poziadavky_na_cenovu_ponuku', 'produkt_id', 'produkt', NULL, 'Produkt', 20, NULL, 400, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'select2', NULL, 1, NULL, NULL, NULL, 1, NULL, NULL, NULL),
    (489, 35, 1, 'polozka_poziadavky_na_cenovu_ponuku', 'cena_bez_dph', NULL, NULL, 'Cena bez DPH', 50, NULL, NULL, NULL, NULL, NULL, 1, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
    (490, 35, 1, 'polozka_poziadavky_na_cenovu_ponuku', 'mnozstvo', NULL, NULL, 'Množstvo', 70, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, '1', NULL, NULL, NULL, NULL, NULL),
    (491, 35, 2, 'polozka_poziadavky_na_cenovu_ponuku', 'popis', NULL, NULL, 'Popis', 100, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
    (492, 35, 5, 'polozka_poziadavky_na_cenovu_ponuku', 'merna_jednotka_id', 'merna_jednotka', NULL, 'Merná jednotka', 80, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'select2', NULL, 1, NULL, NULL, NULL, 1, NULL, NULL, NULL),
    (493, 35, 1, 'polozka_poziadavky_na_cenovu_ponuku', 'poradie', NULL, NULL, 'Poradie', 120, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
    (494, 35, 1, 'polozka_poziadavky_na_cenovu_ponuku', 'skupina', NULL, NULL, 'Skupina', 130, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
    (495, 35, 1, 'polozka_poziadavky_na_cenovu_ponuku', 'cena_info', NULL, NULL, 'Informácia k cene', 60, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
