/*1*/ CREATE TABLE `smernica` (
	`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	`nazov` VARCHAR(250) NULL,
	`obchodny_partner_id` INT(10) UNSIGNED NULL,
	`visibility_type_id` TINYINT UNSIGNED NOT NULL,
	PRIMARY KEY (`id`)
)
COLLATE='utf8_bin'
ENGINE=InnoDB
;
/*2*/ INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (107, 104, 'Výpis smerníc', 'smernica_vypis', 30, 2, 1);
/*3*/ INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (108, 104, 'Pridaj smernicu', 'smernica_pridaj', 40, 2, 1);
/*4*/ UPDATE `menu` SET `page`='vzorova_smernica_vypis' WHERE  `id`=107;
/*5*/ UPDATE `menu` SET `page`='vzorova_smernica_pridaj' WHERE  `id`=108;
/*6*/ ALTER TABLE `smernica`
	ADD COLUMN `typ_sluzby_id` INT(11) UNSIGNED NULL DEFAULT NULL AFTER `obchodny_partner_id`;
/*7*/ ALTER TABLE `smernica`
	ADD CONSTRAINT `FK_smernica_obchodny_partner` FOREIGN KEY (`obchodny_partner_id`) REFERENCES `obchodny_partner` (`id`) ON UPDATE RESTRICT,
	ADD CONSTRAINT `FK_smernica_typ_sluzby` FOREIGN KEY (`typ_sluzby_id`) REFERENCES `typ_sluzby` (`id`);
/*8*/ INSERT INTO `form` (`id`, `nazov`, `code`) VALUES (50, 'Smernica', 'smernica');
/*9*/ ALTER TABLE `smernica`
	ALTER `visibility_type_id` DROP DEFAULT;
/*10*/ ALTER TABLE `smernica`
	CHANGE COLUMN `visibility_type_id` `visibility_type` TINYINT(3) UNSIGNED NOT NULL AFTER `typ_sluzby_id`;
/*11*/ INSERT INTO `form_group` (`id`, `form_id`, `nazov`, `code`, `position`) VALUES (4, 50, 'Základné informácie', 'smernica_zakladne_informacie', 10);
/*12*/ INSERT INTO `form_element` (`id`, `form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `column_title`, `position`, `direct_to_db`, `required`) VALUES (8, 4, 1, 'smernica', 'nazov', 'Názov', 10, 1, 1);
/*13*/ INSERT INTO `form_element` (`id`, `form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`, `column_title`, `position`, `direct_to_db`, `required`, `css_class`) VALUES (9, 4, 5, 'smernica', 'typ_sluzby_id', 'typ_sluzby', 'Typ služby', 20, 1, 1, 'select2');
/*14*/ UPDATE `form_element` SET `direct_multi_label`=1, `add_empty_option`=1 WHERE  `id`=9;
/*15*/ INSERT INTO `form_element` (`id`, `form_group_id`, `form_element_type_id`, `db_table`, `db_column`, `db_multi_table`, `column_title`, `position`, `direct_to_db`, `required`, `css_class`, `direct_multi_label`, `add_empty_option`) VALUES (10, 4, 5, 'smernica', 'obchodny_partner_id', 'obchodny_partner', 'Obchodný partner', 30, 1, 1, 'select2', 1, 1);
/*16*/ UPDATE `log_type` SET `code`='vzorova_smernica_pridaj' WHERE  `id`=7;
/*17*/ UPDATE `log_type` SET `code`='vzorova_smernica_edituj' WHERE  `id`=8;
/*18*/ UPDATE `log_type` SET `code`='vzorova_smernica_zmaz' WHERE  `id`=9;
/*19*/ INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (109, 107, 'Detail smernice', 'vzorova_smernica_view', 10, 3, 1);
/*20*/ INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (110, 107, 'Editovanie smernice', 'vzorova_smernica_edituj', 20, 3, 1);

INSERT INTO `log_type` (`id`, `nazov`, `code`, `primary_table`)
VALUES
	(7, 'Pridanie vzorovej smernice', 'vzorova_smernica_pridaj', 'vzorova_dokumentacia'),
	(8, 'Editovanie vzorovej smernice', 'vzorova_smernica_edituj', 'vzorova_dokumentacia'),
	(9, 'Zmazanie vzorovej smernice', 'vzorova_smernica_zmaz', 'vzorova_dokumentacia');
