-- Adminer 4.6.2 MySQL dump

SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';

CREATE TABLE `appVar` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(200) COLLATE utf8_czech_ci NOT NULL,
  `code` varchar(200) COLLATE utf8_czech_ci NOT NULL,
  `value` text COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

INSERT INTO `appVar` (`id`, `name`, `code`, `value`) VALUES
(1,	'',	'orderPaymentDelivery',	'18'),
(2,	'',	'menuRootEntityId',	'3583'),
(3,	'',	'startPageEntityId',	'3583'),
(4,	'Patička',	'footerEntityId',	'9123'),
(5,	'Email odesilatele',	'defaultEmailFrom',	'\"objednavky@bombadarky.com\"'),
(6,	'Eshop, číslo účtu',	'esAccountNumber',	'\"0000-123456789012/0123\"');

CREATE TABLE `attach` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `entityId` int(11) unsigned NOT NULL,
  `contentType` varchar(200) COLLATE utf8_czech_ci NOT NULL,
  `fileName` varchar(200) COLLATE utf8_czech_ci NOT NULL,
  `name` varchar(200) COLLATE utf8_czech_ci NOT NULL,
  `lastModified` bigint(20) NOT NULL,
  `numOrder` int(11) NOT NULL,
  `width` int(11) DEFAULT NULL,
  `height` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `entityId` (`entityId`),
  CONSTRAINT `attach_ibfk_1` FOREIGN KEY (`entityId`) REFERENCES `entity` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `attachType` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(200) COLLATE utf8_czech_ci NOT NULL,
  `name` varchar(200) COLLATE utf8_czech_ci NOT NULL,
  `multiple` bit(1) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `code` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `attachTypeRel` (
  `attachId` int(11) NOT NULL,
  `attachTypeId` int(11) NOT NULL,
  KEY `attachId` (`attachId`),
  KEY `attachTypeId` (`attachTypeId`),
  CONSTRAINT `attachTypeRel_ibfk_1` FOREIGN KEY (`attachId`) REFERENCES `attach` (`id`),
  CONSTRAINT `attachTypeRel_ibfk_2` FOREIGN KEY (`attachTypeId`) REFERENCES `attachType` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `entity` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(300) COLLATE utf8_czech_ci NOT NULL,
  `longName` varchar(500) COLLATE utf8_czech_ci DEFAULT NULL,
  `shortContent` text COLLATE utf8_czech_ci,
  `content` text COLLATE utf8_czech_ci,
  `entityTypeId` int(10) unsigned NOT NULL,
  `dateTime` datetime DEFAULT NULL,
  `opts` text COLLATE utf8_czech_ci,
  `optsSub` text COLLATE utf8_czech_ci,
  `recursiveLevel` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `entityTypeID` (`entityTypeId`),
  CONSTRAINT `entity_ibfk_2` FOREIGN KEY (`entityTypeId`) REFERENCES `entityType` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `entityRel` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `currentEntityId` int(11) unsigned NOT NULL,
  `parentEntityId` int(11) unsigned DEFAULT NULL,
  `dtFrom` datetime DEFAULT NULL,
  `dtTo` datetime DEFAULT NULL,
  `type` enum('primary','secondary','shortcut') COLLATE utf8_czech_ci NOT NULL,
  `numOrder` int(11) DEFAULT NULL,
  `inMenu` bit(1) NOT NULL DEFAULT b'0',
  `inList` bit(1) NOT NULL DEFAULT b'0',
  PRIMARY KEY (`id`),
  KEY `currentEntityId` (`currentEntityId`),
  KEY `parentEntityId` (`parentEntityId`),
  CONSTRAINT `entityRel_ibfk_1` FOREIGN KEY (`currentEntityId`) REFERENCES `entity` (`id`),
  CONSTRAINT `entityRel_ibfk_2` FOREIGN KEY (`parentEntityId`) REFERENCES `entity` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `entityType` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(300) COLLATE utf8_czech_ci NOT NULL,
  `code` varchar(200) COLLATE utf8_czech_ci NOT NULL,
  `className` varchar(200) COLLATE utf8_czech_ci NOT NULL,
  `hasEntities` tinyint(1) unsigned NOT NULL,
  `opts` text COLLATE utf8_czech_ci,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

INSERT INTO `entityType` (`id`, `name`, `code`, `className`, `hasEntities`, `opts`) VALUES
(1,	'Článek',	'article',	'Article',	0,	''),
(2,	'Kategorie',	'category',	'Category',	1,	''),
(3,	'Fotogalerie',	'category.photo',	'Category',	1,	'{\r\n  \"layout\": \"photo\"\r\n}'),
(4,	'Zboží',	'goods',	'Goods',	0,	''),
(5,	'Kategorie obchod',	'category.goods',	'GoodsCategory',	1,	NULL),
(6,	'Obrázek',	'image',	'Article',	0,	NULL),
(7,	'Článek, pouze text',	'article.plain',	'Article',	0,	'{\r\n\"onlyText\": true\r\n}'),
(8,	'Kategorie, jen titulek',	'category.title',	'Category',	1,	'{\r\n\"fields\": [\"title\"]\r\n}'),
(9,	'Novinky',	'category.news',	'Category',	1,	'{\r\n\"fields\": [\"title\"]\r\n}'),
(10,	'Doporučujeme',	'category.offers',	'Category',	1,	'{\r\n\"fields\": [\"title\"]\r\n}'),
(11,	'Blok textu',	'text',	'Article',	0,	'');

CREATE TABLE `entity_Goods` (
  `entityId` int(11) unsigned NOT NULL,
  `price` decimal(10,2) NOT NULL,
  `goodsPriceCalculatorId` int(11) DEFAULT NULL,
  `esFeedOpts` text COLLATE utf8_czech_ci,
  PRIMARY KEY (`entityId`),
  KEY `goodsPriceCalculatorId` (`goodsPriceCalculatorId`),
  CONSTRAINT `entity_Goods_ibfk_1` FOREIGN KEY (`entityId`) REFERENCES `entity` (`id`) ON DELETE CASCADE,
  CONSTRAINT `entity_Goods_ibfk_2` FOREIGN KEY (`goodsPriceCalculatorId`) REFERENCES `goodsPriceCalculator` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `esAddress` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `esCustomerId` int(11) NOT NULL,
  `street` varchar(100) COLLATE utf8_czech_ci NOT NULL,
  `numD` varchar(20) COLLATE utf8_czech_ci NOT NULL,
  `numO` varchar(20) COLLATE utf8_czech_ci DEFAULT NULL,
  `city` varchar(100) COLLATE utf8_czech_ci NOT NULL,
  `postalNum` varchar(10) COLLATE utf8_czech_ci NOT NULL,
  `note` varchar(200) COLLATE utf8_czech_ci DEFAULT NULL,
  `dtDeleted` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `esCustomerId` (`esCustomerId`),
  CONSTRAINT `esAddress_ibfk_1` FOREIGN KEY (`esCustomerId`) REFERENCES `esCustomer` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `esCart` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `dtLast` datetime NOT NULL,
  `esCustomerId` int(11) DEFAULT NULL,
  `cookieCode` varchar(32) COLLATE utf8_czech_ci NOT NULL,
  `content` text COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`id`),
  KEY `esCustomerId` (`esCustomerId`),
  CONSTRAINT `esCart_ibfk_1` FOREIGN KEY (`esCustomerId`) REFERENCES `esCustomer` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `esCustomerAddress` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `esCustomerId` int(11) NOT NULL,
  `street` varchar(100) COLLATE utf8_czech_ci DEFAULT NULL,
  `numD` varchar(10) COLLATE utf8_czech_ci NOT NULL,
  `numO` varchar(10) COLLATE utf8_czech_ci DEFAULT NULL,
  `city` varchar(100) COLLATE utf8_czech_ci DEFAULT NULL,
  `postalNum` varchar(10) COLLATE utf8_czech_ci NOT NULL,
  `note` varchar(200) COLLATE utf8_czech_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `esCustomerId` (`esCustomerId`),
  CONSTRAINT `esCustomerAddress_ibfk_1` FOREIGN KEY (`esCustomerId`) REFERENCES `esCustomer` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `esDeliveryPoint` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `shipper` enum('CposBnp','Zasilkovna') COLLATE utf8_czech_ci NOT NULL,
  `code` varchar(100) COLLATE utf8_czech_ci NOT NULL,
  `name` varchar(100) COLLATE utf8_czech_ci NOT NULL,
  `address` varchar(300) COLLATE utf8_czech_ci DEFAULT NULL,
  `info` text COLLATE utf8_czech_ci,
  PRIMARY KEY (`id`),
  UNIQUE KEY `type_code` (`shipper`,`code`),
  KEY `code` (`code`),
  KEY `type` (`shipper`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `esFeedCategory` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) COLLATE utf8_czech_ci NOT NULL,
  `zboziCz` varchar(200) COLLATE utf8_czech_ci NOT NULL,
  `heurekaCz` varchar(200) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `esOrder` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `billingAddressId` int(11) DEFAULT NULL,
  `deliveryAddressId` int(11) DEFAULT NULL,
  `esCustomerId` int(11) NOT NULL,
  `trackCode` varchar(200) COLLATE utf8_czech_ci NOT NULL,
  `dtCreated` datetime NOT NULL,
  `stateId` int(11) NOT NULL DEFAULT '1',
  `price` decimal(10,2) NOT NULL,
  `deliveryId` int(11) NOT NULL,
  `deliveryCode` varchar(100) COLLATE utf8_czech_ci DEFAULT NULL,
  `paymentId` int(11) NOT NULL,
  `authCode` varchar(64) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`id`),
  KEY `billingAddressId` (`billingAddressId`),
  KEY `deliveryAddressId` (`deliveryAddressId`),
  KEY `esCustomerId` (`esCustomerId`),
  KEY `esOrderStateId` (`stateId`),
  KEY `deliveryId` (`deliveryId`),
  KEY `paymentId` (`paymentId`),
  KEY `authCode` (`authCode`),
  CONSTRAINT `esOrder_ibfk_1` FOREIGN KEY (`billingAddressId`) REFERENCES `esAddress` (`id`),
  CONSTRAINT `esOrder_ibfk_2` FOREIGN KEY (`deliveryAddressId`) REFERENCES `esAddress` (`id`),
  CONSTRAINT `esOrder_ibfk_3` FOREIGN KEY (`esCustomerId`) REFERENCES `esCustomer` (`id`),
  CONSTRAINT `esOrder_ibfk_4` FOREIGN KEY (`stateId`) REFERENCES `esOrderState` (`id`),
  CONSTRAINT `esOrder_ibfk_5` FOREIGN KEY (`deliveryId`) REFERENCES `goodsParamItem` (`id`),
  CONSTRAINT `esOrder_ibfk_7` FOREIGN KEY (`paymentId`) REFERENCES `goodsParamItem` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `esOrderItem` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `esOrderId` int(11) NOT NULL,
  `entityId` int(11) unsigned DEFAULT NULL,
  `itemCount` int(11) NOT NULL,
  `itemPrice` decimal(10,2) NOT NULL,
  `totalPrice` decimal(10,2) NOT NULL,
  `goodsParams` text COLLATE utf8_czech_ci,
  `note` text COLLATE utf8_czech_ci,
  `common` enum('orderPaymentDelivery','discount','other') COLLATE utf8_czech_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `entityId` (`entityId`),
  KEY `esOrderId` (`esOrderId`),
  CONSTRAINT `esOrderItem_ibfk_2` FOREIGN KEY (`entityId`) REFERENCES `entity` (`id`),
  CONSTRAINT `esOrderItem_ibfk_3` FOREIGN KEY (`esOrderId`) REFERENCES `esOrder` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `esOrderState` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) COLLATE utf8_czech_ci NOT NULL,
  `code` varchar(20) COLLATE utf8_czech_ci DEFAULT NULL,
  `numOrder` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `fulltextIndex` (
  `entId` int(11) NOT NULL,
  `fieldName` enum('name','longName','shortContent','content') COLLATE utf8_czech_ci NOT NULL,
  `scoreCoeficient` decimal(6,3) NOT NULL,
  `content` text COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`entId`,`fieldName`),
  FULLTEXT KEY `content` (`content`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `goodsParam` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) COLLATE utf8_czech_ci NOT NULL,
  `adminNote` varchar(200) COLLATE utf8_czech_ci DEFAULT NULL,
  `numOrder` int(11) NOT NULL,
  `code` varchar(32) COLLATE utf8_czech_ci DEFAULT NULL,
  `nameZboziCz` varchar(200) COLLATE utf8_czech_ci DEFAULT NULL,
  `nameHeurekaCz` varchar(200) COLLATE utf8_czech_ci DEFAULT NULL,
  `showAs` enum('box','bySide') COLLATE utf8_czech_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

INSERT INTO `goodsParam` (`id`, `name`, `adminNote`, `numOrder`, `code`, `nameZboziCz`, `nameHeurekaCz`, `showAs`) VALUES
(1030,	'Způsob platby',	'',	1000,	'payment',	'',	'',	'bySide'),
(1031,	'Způsob doručení',	'',	1001,	'delivery',	'',	'',	'bySide');

CREATE TABLE `goodsParamItem` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `goodsParamId` int(11) NOT NULL,
  `name` varchar(200) COLLATE utf8_czech_ci NOT NULL,
  `code` varchar(200) COLLATE utf8_czech_ci DEFAULT NULL,
  `numOrder` int(11) NOT NULL,
  `lastModified` bigint(20) DEFAULT NULL,
  `contentType` varchar(200) COLLATE utf8_czech_ci DEFAULT NULL,
  `fileName` varchar(200) COLLATE utf8_czech_ci DEFAULT NULL,
  `nameZboziCz` varchar(200) COLLATE utf8_czech_ci DEFAULT NULL,
  `nameHeurekaCz` varchar(200) COLLATE utf8_czech_ci DEFAULT NULL,
  `opts` text COLLATE utf8_czech_ci,
  PRIMARY KEY (`id`),
  KEY `goodsParamId` (`goodsParamId`),
  CONSTRAINT `goodsParamItem_ibfk_2` FOREIGN KEY (`goodsParamId`) REFERENCES `goodsParam` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

INSERT INTO `goodsParamItem` (`id`, `goodsParamId`, `name`, `code`, `numOrder`, `lastModified`, `contentType`, `fileName`, `nameZboziCz`, `nameHeurekaCz`, `opts`) VALUES
(1131,	1030,	'Při převzetí / dobírka',	NULL,	2,	NULL,	NULL,	NULL,	'',	'',	NULL),
(1132,	1030,	'Předem na ůčet',	'PaymentAccount',	1,	NULL,	NULL,	NULL,	'',	'',	NULL),
(1133,	1031,	'Pošta: Balík do ruky',	NULL,	1,	NULL,	NULL,	NULL,	'',	'',	'{\"deliveryTarget\":\"address\"}'),
(1134,	1031,	'Pošta: Balík na poštu',	'CposBnp',	2,	NULL,	NULL,	NULL,	'',	'',	'{\"deliveryTarget\":\"postal\", \"codeField\": \"deliveryCode_CposBnp\"}');

CREATE TABLE `goodsPriceCalculator` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) COLLATE utf8_czech_ci NOT NULL,
  `rules` text COLLATE utf8_czech_ci NOT NULL,
  `goodsParamIds` text COLLATE utf8_czech_ci NOT NULL,
  `minPriceAbs` decimal(10,0) DEFAULT NULL,
  `minPriceRel` decimal(10,0) DEFAULT NULL,
  `maxPriceAbs` decimal(10,0) DEFAULT NULL,
  `maxPriceRel` decimal(10,0) DEFAULT NULL,
  `code` varchar(20) COLLATE utf8_czech_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

INSERT INTO `goodsPriceCalculator` (`id`, `name`, `rules`, `goodsParamIds`, `minPriceAbs`, `minPriceRel`, `maxPriceAbs`, `maxPriceRel`, `code`) VALUES
(44,	'Platba a doručení',	'[{\"param\":{\"1030\":[null],\"1031\":[null]},\"priceRel\":false,\"price\":50,\"disabled\":false}]',	'[1030,1031]',	50,	NULL,	50,	NULL,	'delivery');

CREATE TABLE `token` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(32) COLLATE utf8_czech_ci NOT NULL,
  `dtCreated` datetime NOT NULL,
  `operation` varchar(64) COLLATE utf8_czech_ci NOT NULL,
  `data` text COLLATE utf8_czech_ci NOT NULL,
  `ttl` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `code` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

INSERT INTO `attachType` (`id`, `code`, `name`, `multiple`) VALUES
(1,	'image',	'Obrázek',	CONV('0', 2, 10) + 0),
(2,	'imageSlideShow',	'Obr. kolotoč',	CONV('1', 2, 10) + 0),
(3,	'imageGalery',	'Obr. galerie',	CONV('1', 2, 10) + 0),
(4,	'imageEsFeedPrimary',	'Obr. pro Zbozi/Heureka - hlavní',	CONV('0', 2, 10) + 0),
(6,	'imageEsFeed',	'Obr. pro Zbozi/Heureka - další',	CONV('1', 2, 10) + 0);

-- 2018-06-02 15:27:00

/*
/import/import-goods-params
/import/import-entities
/import/categories
*/
