Execute("ALTER TABLE `UserOnline` CHANGE `User` `User` INT( 11 ) NULL DEFAULT NULL COMMENT 'User.Id'"); } function UpdateTo494(UpdateManager $Manager): void { $Manager->Execute("ALTER TABLE `FinanceOperation` DROP FOREIGN KEY `FinanceOperation_ibfk_2` ;\n". "ALTER TABLE `FinanceOperation` CHANGE `Bill` `File` INT( 11 ) NULL DEFAULT NULL;\n". "ALTER TABLE `FinanceOperation` ADD FOREIGN KEY ( `File` ) REFERENCES `File` (`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;"); } function UpdateTo495(UpdateManager $Manager): void { $Manager->Execute("INSERT INTO `MapPosition` (SELECT NULL AS `Id`, `Name`, `MapPositionX` AS `Latitude`, `MapPositionY` AS `Longitude` FROM `Subject`)"); $Manager->Execute("ALTER TABLE `Subject` ADD `MapPosition` INT NULL AFTER `PayVAT`"); $Manager->Execute("UPDATE `Subject` SET `MapPosition` = (SELECT `MapPosition`.`Id` FROM `MapPosition` WHERE `MapPosition`.`Name` = `Subject`.`Name` LIMIT 1)"); $Manager->Execute("ALTER TABLE `Subject` DROP `MapPositionX`, DROP `MapPositionY`;"); $Manager->Execute("ALTER TABLE `Subject` ADD INDEX ( `MapPosition` ) "); $Manager->Execute("ALTER TABLE `Subject` ADD FOREIGN KEY ( `MapPosition` ) REFERENCES `MapPosition` (". "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;"); } function UpdateTo497(UpdateManager $Manager): void { $Manager->Execute("ALTER TABLE `FinanceCharge` ADD `Id` INT NOT NULL AUTO_INCREMENT FIRST , ADD PRIMARY KEY ( `Id` ) "); $Manager->Execute("ALTER TABLE `FinanceCharge` ADD `ReplaceId` INT NULL ,ADD INDEX ( `ReplaceId` ) "); $Manager->Execute("DELETE FROM `FinanceCharge` WHERE `FinanceCharge`.`Period` = 1"); $Manager->Execute("ALTER TABLE `FinanceCharge` DROP `Period`"); $Manager->Execute("ALTER TABLE `FinanceCharge` ADD `Action` ENUM( 'add', 'modify', 'remove' ) NULL AFTER `TopTariffPrice` "); $Manager->Execute("ALTER TABLE `FinanceCharge` ADD FOREIGN KEY ( `ReplaceId` ) REFERENCES `FinanceCharge` (". "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;"); $Manager->Execute("ALTER TABLE `FinanceCharge` ADD INDEX ( `Action` )"); $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ". "VALUES (NULL , 'Parametry účtování', '2', 'FinanceCharge', '');"); $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ". "VALUES (NULL , 'Úseky sítě', '2', 'NetworkSegment', '');"); $Manager->Execute("ALTER TABLE `ServiceCustomerRel` ADD `Action` ENUM( 'add', 'modify', 'remove' ) NULL , ". "ADD `ReplaceId` INT NULL"); $Manager->Execute("DELETE FROM `ServiceCustomerRel` WHERE `Period`=1"); $Manager->Execute("ALTER TABLE `ServiceCustomerRel` DROP `Period`"); $Manager->Execute("ALTER TABLE `ServiceCustomerRel` ADD INDEX ( `Action` )"); $Manager->Execute("ALTER TABLE `ServiceCustomerRel` ADD INDEX ( `ReplaceId` ) "); $Manager->Execute("ALTER TABLE `ServiceCustomerRel` ADD FOREIGN KEY ( `ReplaceId` ) REFERENCES `ServiceCustomerRel` (". "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;"); $Manager->Execute("ALTER TABLE `Service` ADD `Action` ENUM( 'add', 'modify', 'remove' ) NULL AFTER `CustomerCount`"); $Manager->Execute("ALTER TABLE `Service` ADD INDEX ( `Action` )"); $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ". "VALUES (NULL , 'Placení zákazníků', '2', 'MemberPayment', '');"); } function UpdateTo498(UpdateManager $Manager): void { $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ". "VALUES (NULL , 'Síťové služby', '1', 'NetworkConfiguration', '');"); $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ". "VALUES (NULL , 'Fronta e-mailů', '23', 'EmailQueue', '');"); $Manager->Execute("CREATE TABLE IF NOT EXISTS `FinanceVAT` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `ValidFrom` date NOT NULL, `Value` int(11) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; INSERT INTO `FinanceVAT` (`Id`, `Name`, `ValidFrom`, `Value`) VALUES (1, 'DPH snížená sazba', '2013-01-01', 15), (2, 'DPH běžná sazba', '2013-01-01', 21);"); $Manager->Execute("ALTER TABLE `Service` ADD `VAT` INT NOT NULL AFTER `Price`"); $Manager->Execute("ALTER TABLE `Service` ADD INDEX ( `VAT` ) "); $Manager->Execute("UPDATE `Service` SET `VAT` = 2;"); $Manager->Execute("ALTER TABLE `Service` ADD FOREIGN KEY ( `VAT` ) REFERENCES `FinanceVAT` (". "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;"); $Manager->Execute("ALTER TABLE `FinanceInvoice` ADD `Cash` INT NOT NULL DEFAULT '0'"); } function UpdateTo499(UpdateManager $Manager): void { $Manager->Execute("CREATE TABLE IF NOT EXISTS `Currency` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Code` varchar(3) NOT NULL, `Name` varchar(255) NOT NULL, `Symbol` varchar(255) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ; INSERT INTO `Currency` (`Id`, `Code`, `Name`, `Symbol`) VALUES (1, 'CZK', 'Česká koruna', 'Kč'), (2, 'EUR', 'Euro', '€'), (3, 'USD', 'Americký dolar', '$'), (4, 'CNY', 'Čínský jüan', '¥');"); $Manager->Execute("CREATE TABLE IF NOT EXISTS `FinanceBankImport` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `BankAccount` int(11) NOT NULL, `Time` date NOT NULL, `Identification` varchar(255) NOT NULL, `AccountNumber` varchar(255) NOT NULL, `VariableSymbol` varchar(255) NOT NULL, `ConstantSymbol` varchar(255) NOT NULL, `SpecificSymbol` varchar(255) NOT NULL, `Value` decimal(10,0) NOT NULL, `Currency` int(11) NOT NULL, `Description` varchar(255) NOT NULL, `OffsetAccountName` varchar(255) NOT NULL, `FinanceOperation` int(11) DEFAULT NULL, PRIMARY KEY (`Id`), KEY `FinanceOperation` (`FinanceOperation`), KEY `Currency` (`Currency`), KEY `BankAccount` (`BankAccount`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; ALTER TABLE `FinanceBankImport` ADD CONSTRAINT `FinanceBankImport_ibfk_3` FOREIGN KEY (`FinanceOperation`) REFERENCES `FinanceOperation` (`Id`), ADD CONSTRAINT `FinanceBankImport_ibfk_1` FOREIGN KEY (`BankAccount`) REFERENCES `FinanceBankAccount` (`Id`), ADD CONSTRAINT `FinanceBankImport_ibfk_2` FOREIGN KEY (`Currency`) REFERENCES `Currency` (`Id`);"); $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`)". "VALUES (NULL , 'Měny', '2', 'Currency', '');"); $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ". "VALUES (NULL , 'Import z účtu', '2', 'FinanceBankImport', '');"); } function UpdateTo500(UpdateManager $Manager): void { $Manager->Execute("CREATE TABLE IF NOT EXISTS `FinanceBank` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `Code` varchar(4) NOT NULL, `BIC` varchar(255) NOT NULL, `Country` int(11) NOT NULL, PRIMARY KEY (`Id`), KEY `Country` (`Country`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); $Manager->Execute("ALTER TABLE `FinanceBank` ADD CONSTRAINT `FinanceBank_ibfk_1` FOREIGN KEY (`Country`) REFERENCES `Country` (`Id`);"); $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD `Bank` INT NOT NULL AFTER `Number` ,". " ADD INDEX ( `Bank` )"); $Manager->Execute("INSERT INTO `FinanceBank` (`Id`, `Name`, `Code`, `BIC`, `Country`) VALUES (1, 'Neznámá banka', '', '', 1);"); $Manager->Execute("UPDATE `FinanceBankAccount` SET `Bank` = 1 WHERE `Bank` = 0"); $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD FOREIGN KEY ( `Bank` ) REFERENCES `FinanceBank` (". "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;"); $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ". "VALUES (NULL , 'Banky', '2', 'FinanceBank', '');"); } function UpdateTo502(UpdateManager $Manager): void { $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD `LoginName` VARCHAR( 255 ) NOT NULL "); $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD `LoginPassword` VARCHAR( 255 ) NOT NULL"); $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD `Currency` INT NOT NULL AFTER `Use` ,". "ADD INDEX ( `Currency` ) "); $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ". "VALUES (NULL , 'Banka', '2', '', '');"); $Id = $Manager->Database->insert_id; $Manager->Execute("UPDATE `ISMenuItem` SET `Parent` = '".$Id."' WHERE `ISMenuItem`.`Id` ='Bankovní účty'; ". "UPDATE `ISMenuItem` SET `Parent` = '".$Id."' WHERE `ISMenuItem`.`Id` ='Import z účtu';". "UPDATE `ISMenuItem` SET `Parent` = '".$Id."' WHERE `ISMenuItem`.`Name` ='Banky';"); } function UpdateTo505(UpdateManager $Manager): void { $Manager->Execute("UPDATE `ISMenuItem` SET `Name` = 'Služby', `Table` = 'Service' WHERE `ISMenuItem`.`Name` ='Tarify';"); $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ". "VALUES (NULL , 'Kategorie služeb', '2', 'ServiceCategory', '');"); $Manager->Execute("CREATE TABLE IF NOT EXISTS `NetworkShareItem` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL DEFAULT '', `Parent` int(11) NOT NULL DEFAULT '0', `Host` int(11) NOT NULL DEFAULT '0', `Size` bigint(20) NOT NULL DEFAULT '0', `Ext` varchar(64) NOT NULL DEFAULT '', `Date` date NOT NULL DEFAULT '0000-00-00', `Type` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`Id`), KEY `Parent` (`Parent`), KEY `Search` (`Name`,`Size`), KEY `Name` (`Name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); $Manager->Execute("CREATE TABLE IF NOT EXISTS `NetworkShareError` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Host` varchar(16) NOT NULL DEFAULT '', `Message` varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); } function UpdateTo507(UpdateManager $Manager): void { $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ". "VALUES (NULL , 'Aktuality', NULL, '', '');"); $Id = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ". "VALUES (NULL , 'Aktuality', '".$Id."', 'News', '');"); $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ". "VALUES (NULL , 'Kategorie aktualit', '".$Id."', 'NewsCategory', '');"); $Manager->Execute("INSERT INTO `FileDirectory` (`Id` ,`Name` ,`Parent`". ") VALUES (NULL , 'news', NULL);"); $Manager->Execute("ALTER TABLE `File` ADD `Time` DATETIME NOT NULL "); // Convert Hire column to Service item $Manager->Execute("INSERT INTO `ServiceCategory` ( `Id` ,`Name`) VALUES (NULL , 'Pevný nájem');"); $ServiceCategoryHire = $Manager->Database->insert_id; $DbResult = $Manager->Execute("SELECT * FROM Member WHERE Hire>0"); while ($Member = $DbResult->fetch_assoc()) { $Manager->Execute("INSERT INTO `Service` ( `Id` ,`Name` ,`Category` ,`Price` ,`VAT` ,`CustomerCount` ,`Action` ,`ReplaceId` , `Public` ,`InternetSpeedMin` ,`InternetSpeedMax` ,`UploadAsymmetry` ,`Memory` ,`MemorySwap` ,`Storage` ,`CPUCount`) VALUES ( NULL , 'Nájem', '".$ServiceCategoryHire."', '-".$Member['Hire']."', '2', '', NULL , NULL , '', '', '', '', '', '', '', '' );"); $ServiceHire = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `ServiceCustomerRel` (`Service`, `Customer`) VALUES ". "(".$ServiceHire.",".$Member['Id'].")"); } $Manager->Execute("ALTER TABLE `Member` DROP `Hire`"); // Each device and subnet have to be assigned to payed service to determine service parameters $Manager->Execute("ALTER TABLE `NetworkDevice` ADD `Service` INT NULL AFTER `Location` , ADD INDEX ( `Service` )"); $Manager->Execute("ALTER TABLE `NetworkDevice` ADD FOREIGN KEY ( `Service` ) REFERENCES `ServiceCustomerRel` ( `Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;"); $Manager->Execute("UPDATE `NetworkDevice` SET `Service` = (SELECT `Id` FROM `ServiceCustomerRel` WHERE `ServiceCustomerRel`.`Customer` = `NetworkDevice`.`Member` LIMIT 1)"); $Manager->Execute("ALTER TABLE `NetworkSubnet` ADD `Service` INT NULL AFTER `Member` , ADD INDEX ( `Service` ) "); $Manager->Execute("ALTER TABLE `NetworkSubnet` ADD FOREIGN KEY ( `Service` ) REFERENCES `ServiceCustomerRel` ( `Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;"); $Manager->Execute("UPDATE `NetworkSubnet` SET `Service` = (SELECT `Id` FROM `ServiceCustomerRel` WHERE `ServiceCustomerRel`.`Customer` = `NetworkSubnet`.`Member` LIMIT 1)"); } function UpdateTo515(UpdateManager $Manager): void { $Manager->Execute("ALTER TABLE `PermissionUserAssignment` CHANGE `User` `User` INT( 11 ) NULL"); } function UpdateTo517(UpdateManager $Manager): void { $Manager->Execute("ALTER TABLE `Log` ADD `IPAddress` VARCHAR( 16 ) NOT NULL"); } function UpdateTo526(UpdateManager $Manager): void { $Manager->Execute("ALTER TABLE `Hyperlink` CHANGE `Name` `Title` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL"); $Manager->Execute("ALTER TABLE `Hyperlink` ADD `Name` VARCHAR( 255 ) NOT NULL AFTER `Id`"); //$Manager->Execute("ALTER TABLE `Hyperlink` ADD UNIQUE ( `Name` )"); $Manager->Execute("ALTER TABLE `Hyperlink` ADD `Type` INT NOT NULL AFTER `Title` , ADD INDEX ( `Type` )"); $Manager->Execute("RENAME TABLE `Hyperlink` TO `Action` ;"); $Manager->Execute("RENAME TABLE `HyperlinkGroup` TO `ActionGroup` ;"); $Manager->Execute("CREATE TABLE IF NOT EXISTS `ActionType` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; INSERT INTO `ActionType` (`Id`, `Name`) VALUES (1, 'Odkaz'), (2, 'Obrázek');"); $Manager->Execute("UPDATE `Action` SET `Type` = 1;"); $Manager->Execute("ALTER TABLE `Action` ADD FOREIGN KEY ( `Type` ) REFERENCES `ActionType` (". "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;"); $Manager->Execute("UPDATE `Panel` SET `Module` = 'ActionGroup' WHERE `Module` = 'HyperlinkGroup'"); $Manager->Execute("CREATE TABLE IF NOT EXISTS `ActionIcon` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); $Manager->Execute("INSERT INTO `ActionIcon` (SELECT NULL AS `Id`, `IconFile` AS `Name` FROM `Action` WHERE `IconFile` != '' GROUP BY `IconFile`)"); $Manager->Execute("ALTER TABLE `Action` CHANGE `IconFile` `IconFile` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL"); $Manager->Execute("UPDATE `Action` SET `IconFile` = (SELECT `Id` FROM `ActionIcon` WHERE `ActionIcon`.`Name` = `Action`.`IconFile`) "); $Manager->Execute("ALTER TABLE `Action` CHANGE `IconFile` `Icon` INT NULL "); $Manager->Execute("UPDATE `Action` SET `Icon` = NULL WHERE `Icon` = 0"); $Manager->Execute("ALTER TABLE `Action` ADD INDEX ( `Icon` ) "); $Manager->Execute("ALTER TABLE `Action` ADD FOREIGN KEY ( `Icon` ) REFERENCES `ActionIcon` (`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;"); $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ". "VALUES (NULL , 'Akce', '23', 'Action', '');"); } function UpdateTo527(UpdateManager $Manager): void { $Manager->Execute("RENAME TABLE `ISMenuItem` TO `MenuItem` ;"); $Manager->Execute("CREATE TABLE IF NOT EXISTS `Menu` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); $Manager->Execute("INSERT INTO `Menu` (`Id` ,`Name`)VALUES (NULL , 'IS');"); $Manager->Execute("ALTER TABLE `MenuItem` ADD `Menu` INT NOT NULL , ADD INDEX ( `Menu` )"); $Manager->Execute("UPDATE `MenuItem` SET `Menu` = 1"); $Manager->Execute("ALTER TABLE `MenuItem` ADD FOREIGN KEY ( `Menu` ) REFERENCES `Menu` (". "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;"); $Manager->Execute("ALTER TABLE `Action` CHANGE `Group` `Group` INT( 11 ) NULL "); $Manager->Execute("INSERT INTO `Action` (SELECT NULL AS `Id`, '' AS `Name`, `Name` AS `Title`, 1 AS `Type`, CONCAT('/is/?t=', `Table`, '&a=list') AS `URL`, NULL AS `Group`, NULL AS `Icon`, NULL AS `PermisionModule`, NULL AS `PermissionOperation`, 1 AS `Enable` FROM `MenuItem` WHERE `Parent` IS NOT NULL)"); $Manager->Execute("ALTER TABLE `MenuItem` DROP `IconName`"); $Manager->Execute("UPDATE `MenuItem` SET `Table` = (SELECT `Id` FROM `Action` WHERE `Action`.`URL` = CONCAT('/is/?t=', `MenuItem`.`Table`, '&a=list')) WHERE `MenuItem`.`Table` != ''"); $Manager->Execute("ALTER TABLE `MenuItem` CHANGE `Table` `Action` INT NULL"); $Manager->Execute("UPDATE `MenuItem` SET `Action` = NULL WHERE `Action` = 0"); $Manager->Execute("ALTER TABLE `MenuItem` ADD INDEX ( `Action` ) "); $Manager->Execute("ALTER TABLE `MenuItem` ADD FOREIGN KEY ( `Action` ) REFERENCES `Action` (`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;"); $Manager->Execute("INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionModule` ,`PermissionOperation` ,`Enable`)". "VALUES (NULL , '', 'Nabídky', '1', '/is/?t=Menu&a=list', NULL , NULL , '', '', '1');"); $ActionId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Nabídky', '23', '".$ActionId."', '1');"); } function UpdateTo535(UpdateManager $Manager): void { // Set all string collation to utf8 general $DbResult = $Manager->Execute("SHOW TABLES"); while ($DbRow = $DbResult->fetch_row()) { $Manager->Execute("ALTER TABLE `".$DbRow[0]."` CONVERT TO CHARACTER SET utf8"); } } function UpdateTo549(UpdateManager $Manager): void { $Manager->Execute("ALTER TABLE `FinanceOperation` ADD `Generate` INT NOT NULL DEFAULT '0', ADD INDEX ( `Generate` ) ;"); $Manager->Execute("ALTER TABLE `FinanceInvoice` ADD `Generate` INT NOT NULL DEFAULT '0', ADD INDEX ( `Generate` ) ;"); } function UpdateTo550(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `FinanceBankAccount` ADD `LastImportId` VARCHAR( 255 ) NOT NULL ;'); $Manager->Execute('ALTER TABLE `FinanceBankAccount` ADD `LastImportDate` DATE NULL ;'); $Manager->Execute('ALTER TABLE `FinanceBankImport` ADD `BankCode` VARCHAR( 255 ) NOT NULL AFTER `AccountNumber` ;'); } function UpdateTo551(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `DocumentLine` INT NULL AFTER `Value` , ADD INDEX ( `DocumentLine` ) ;'); $Manager->Execute('ALTER TABLE `FinanceOperation` ADD FOREIGN KEY ( `DocumentLine` ) REFERENCES `DocumentLine` ( `Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;'); $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `DocumentLine` INT NULL AFTER `Id` , ADD INDEX ( `DocumentLine` ) ;'); $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD FOREIGN KEY ( `DocumentLine` ) REFERENCES `DocumentLine` ( `Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;'); $Manager->Execute('DROP TABLE `FinanceBillsItemsOld`'); $Manager->Execute('DROP TABLE `FinanceBillsOld`'); } function UpdateTo565(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `WikiPage` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `NormalizedName` varchar(255) NOT NULL, `VisibleInMenu` int(11) NOT NULL, PRIMARY KEY (`Id`), UNIQUE KEY `Name` (`Name`), KEY `VisibleInMenu` (`VisibleInMenu`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('CREATE TABLE IF NOT EXISTS `WikiPageContent` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Page` int(11) NOT NULL, `Time` datetime NOT NULL, `Content` text NOT NULL, `User` int(11) NOT NULL, PRIMARY KEY (`Id`), KEY `User` (`User`), KEY `Page` (`Page`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `WikiPageContent` ADD CONSTRAINT `WikiPageContent_ibfk_2` FOREIGN KEY (`Page`) REFERENCES `WikiPage` (`Id`), ADD CONSTRAINT `WikiPageContent_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`ID`);'); } function UpdateTo571(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkDevice` ADD `LoginName` VARCHAR( 255 ) NOT NULL , ADD `LoginPassword` VARCHAR( 255 ) NOT NULL ;'); } function UpdateTo574(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `MapPosition` ADD `Pos` VARCHAR( 255 ) NOT NULL ;'); $Manager->Execute('UPDATE `MapPosition` SET `Pos`=CONCAT(`Latitude`, ";", `Longitude`)'); $Manager->Execute('ALTER TABLE `MapPosition` DROP `Latitude`'); $Manager->Execute('ALTER TABLE `MapPosition` DROP `Longitude`'); } function UpdateTo584(UpdateManager $Manager): void { $Manager->Execute("CREATE TABLE IF NOT EXISTS `Module` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `Title` varchar(255) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=33 ;"); $Manager->Execute("INSERT INTO `Module` (`Id`, `Name`, `Title`) VALUES (1, 'Customer', 'Zákazník'), (2, 'EmailQueue', 'Fronta emailů'), (3, 'Error', 'Obsluha chyb'), (4, 'File', 'Správa souborů'), (5, 'Finance', 'Finance'), (6, 'FinanceBankAPI', 'Rozhraní pro bankovní účty'), (7, 'Chat', 'Pokec'), (8, 'IS', 'Informační systém'), (9, 'Log', 'Záznam událostí'), (10, 'Map', 'Mapa'), (11, 'Meals', 'Jídelníček'), (12, 'Meteostation', 'Meteostanice'), (13, 'Network', 'Síť'), (14, 'NetworkConfig', 'Nastavení sítě'), (15, 'NetworkConfigLinux', 'Nastavení linuxových zařízení'), (16, 'NetworkConfigRouterOS', 'Nastavení RouterOS zařízení'), (17, 'NetworkShare', 'Síťové sdílení'), (18, 'NetworkTopology', 'Síťová topologie'), (19, 'News', 'Aktuality'), (20, 'OpeningHours', 'Otvírací doby'), (21, 'Portal', 'Portál'), (22, 'Search', 'Vyhledávání'), (23, 'Setup', 'Instalace systému'), (24, 'SpeedTest', 'Měření rychlosti'), (25, 'Stock', 'Sklad'), (26, 'System', 'Systém'), (27, 'Task', 'Úlohy'), (28, 'TimeMeasure', 'Časové průběhy'), (29, 'TV', 'Televize'), (30, 'User', 'Uživatelé'), (31, 'WebCam', 'Web kamery'), (32, 'Wiki', 'Wiki');"); $Manager->Execute("UPDATE `PermissionOperation` SET `Module` = 'Meals' WHERE `PermissionOperation`.`Module` ='EatingPlace';"); $Manager->Execute("UPDATE `PermissionOperation` SET `Module` = 'NetworkShare' WHERE `PermissionOperation`.`Module` ='Share';"); $Manager->Execute("UPDATE `PermissionOperation` SET `Module` = 'OpeningHours' WHERE `PermissionOperation`.`Module` ='SubjectOpenTime';"); $Manager->Execute("UPDATE `PermissionOperation` SET `Module`=(SELECT `Id` FROM `Module` WHERE `Module`.`Name` = `PermissionOperation`.`Module`)"); $Manager->Execute("ALTER TABLE `PermissionOperation` CHANGE `Module` `Module` INT( 11 ) NOT NULL ;"); $Manager->Execute("ALTER TABLE `PermissionOperation` ADD FOREIGN KEY ( `Module` ) REFERENCES `Module` ( `Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;"); $Manager->Execute("UPDATE `Action` SET `Action`.`PermissionOperation` =(SELECT Id FROM `PermissionOperation` WHERE `PermissionOperation`.`Operation`=`Action`.`PermissionOperation` AND `PermissionOperation`.`Module` = (SELECT Id FROM `Module` WHERE `Module`.`Name`=`Action`.`PermissionModule`))"); $Manager->Execute("ALTER TABLE `Action` CHANGE `PermissionOperation` `PermissionOperation` INT( 11 ) NULL ;"); $Manager->Execute("ALTER TABLE `Action` DROP `PermissionModule` ;"); $Manager->Execute("UPDATE `Action` SET `PermissionOperation`=NULL WHERE `PermissionOperation`=0"); $Manager->Execute("ALTER TABLE `Action` ADD INDEX (`PermissionOperation`);"); $Manager->Execute("ALTER TABLE `Action` ADD FOREIGN KEY ( `PermissionOperation` ) REFERENCES `PermissionOperation` ( `Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;"); } function UpdateTo591(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `StockItem` ADD `Esemble` INT NULL , ADD INDEX ( `Esemble` ) ;'); $Manager->Execute('ALTER TABLE `StockItem` ADD FOREIGN KEY ( `Esemble` ) REFERENCES `StockItem` ( `Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;'); } function UpdateTo597(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `Model` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `Module` int(11) NOT NULL, PRIMARY KEY (`Id`), KEY `Module` (`Module`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `Model` ADD CONSTRAINT `Model_ibfk_1` FOREIGN KEY (`Module`) REFERENCES `Module` (`Id`);'); } function UpdateTo601(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkInterfaceWireless` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `NetworkInterface` int(11) NOT NULL, `TxPower` int(11) NOT NULL, `CableAttenuation` int(11) NOT NULL, `AntenaGain` int(11) NOT NULL, `Frequency` float NOT NULL, `ChannelWidth` int(11) NOT NULL, `SSID` varchar(255) NOT NULL, PRIMARY KEY (`Id`), KEY `NetworkInterface` (`NetworkInterface`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD CONSTRAINT `NetworkInterfaceWireless_ibfk_1` FOREIGN KEY (`NetworkInterface`) REFERENCES `NetworkInterface` (`Id`);'); $Manager->Execute("INSERT INTO `Action` ( `Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` , `Enable`) VALUES (NULL , '', 'Wifi rozhraní', '1', '/is/?t=NetworkInterfaceWireless&a=list', NULL , NULL , NULL , '1' );"); $ActionId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Bezdrátové rozhraní', '1', '".$ActionId."', '1');"); } function UpdateTo615(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `AntennaPolarity` INT NOT NULL , ADD `Description` VARCHAR( 255 ) NOT NULL ;'); $Manager->Execute('CREATE TABLE IF NOT EXISTS `NewsImport` ( `Id` int(11) NOT NULL, `Name` varchar(255) NOT NULL, `Enabled` int(11) NOT NULL, `Source` varchar(255) NOT NULL, `Category` int(11) NOT NULL, `BlockStart` varchar(255) NOT NULL, `BlockEnd` varchar(255) NOT NULL, `ItemStart` varchar(255) NOT NULL, `ItemEnd` varchar(255) NOT NULL, `TitleStart` varchar(255) NOT NULL, `TitleEnd` varchar(255) NOT NULL, `ContentStart` varchar(255) NOT NULL, `ContentEnd` varchar(255) NOT NULL, `LinkStart` varchar(255) NOT NULL, `LinkEnd` varchar(255) NOT NULL, `DateStart` varchar(255) NOT NULL, `DateEnd` varchar(255) NOT NULL, KEY `Category` (`Category`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); $Manager->Execute('ALTER TABLE `NewsImport` '. 'ADD CONSTRAINT `NewsImport_ibfk_1` FOREIGN KEY (`Category`) '. ' REFERENCES `NewsCategory` (`Id`);'); $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `Antenna` INT NULL AFTER `AntennaPolarity` , ADD INDEX ( `Product` ) ;'); $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD FOREIGN KEY ( `Antenna` ) REFERENCES `Product` ( `Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;'); $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `MAC` VARCHAR( 17 ) NOT NULL ;'); } function UpdateTo619(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `UserOnline` ADD `StayLogged` INT NOT NULL ;'); } function UpdateTo620(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `ChannelWidthLower` INT NOT NULL , ADD `ChannelWidthUpper` INT NOT NULL ;'); $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `Mode` INT NOT NULL ;'); $Manager->Execute('DROP TABLE `NetworkAP`'); } function UpdateTo627(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `FinanceInvoice` CHANGE `TimeCreation` `Time` DATETIME NOT NULL DEFAULT "0000-00-00 00:00:00";'); $Manager->Execute('ALTER TABLE `FinanceYear` ADD `Closed` INT NOT NULL ;'); } function UpdateTo632(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceInvoiceOperationRel` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Invoice` int(11) NOT NULL, `Operation` int(11) NOT NULL, PRIMARY KEY (`Id`), KEY `Invoice` (`Invoice`), KEY `Operation` (`Operation`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `FinanceInvoiceOperationRel` ADD CONSTRAINT `FinanceInvoiceOperationRel_ibfk_2` FOREIGN KEY (`Operation`) REFERENCES `FinanceOperation` (`Id`), ADD CONSTRAINT `FinanceInvoiceOperationRel_ibfk_1` FOREIGN KEY (`Invoice`) REFERENCES `FinanceInvoice` (`Id`);'); } function UpdateTo633(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `UserOnline` ADD `StayLoggedHash` VARCHAR( 40 ) NOT NULL ;'); } function UpdateTo645(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceVATType` ( `Id` int(11) NOT NULL, `Name` varchar(255) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); $Manager->Execute('INSERT INTO `FinanceVATType` (SELECT Id, Name FROM `FinanceVAT`)'); $Manager->Execute('ALTER TABLE `FinanceVAT` ADD `ValidTo` DATE NULL , ADD `Type` INT NOT NULL ;'); $Manager->Execute('UPDATE `FinanceVAT` SET `Type`=(SELECT `Id` FROM `FinanceVATType` WHERE `FinanceVATType`.`Name`=`FinanceVAT`.`Name`)'); $Manager->Execute('ALTER TABLE `FinanceVAT` DROP `Name`'); } function UpdateTo646(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `Contract` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `BillCode` varchar(255) NOT NULL, `Subject` int(11) NOT NULL, `DocumentLine` int(11) NOT NULL, `ValidFrom` date NOT NULL, `ValidTo` date DEFAULT NULL, `File` int(11) DEFAULT NULL, PRIMARY KEY (`Id`), KEY `Subject` (`Subject`), KEY `DocumentLine` (`DocumentLine`), KEY `File` (`File`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `Contract` ADD CONSTRAINT `Contract_ibfk_3` FOREIGN KEY (`File`) REFERENCES `File` (`Id`), ADD CONSTRAINT `Contract_ibfk_1` FOREIGN KEY (`Subject`) REFERENCES `Subject` (`Id`), ADD CONSTRAINT `Contract_ibfk_2` FOREIGN KEY (`DocumentLine`) REFERENCES `DocumentLine` (`Id`); '); $Manager->Execute("INSERT INTO `Action` ( `Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` , `Enable`) VALUES (NULL , '', 'Smlouvy', '1', '/is/?t=Contract&a=list', NULL , NULL , NULL , '1' );"); $ActionId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Smlouvy', '2', '".$ActionId."', '1');"); $Manager->Execute("INSERT INTO `Action` ( `Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` , `Enable`) VALUES (NULL , '', 'Sazby DPH', '1', '/is/?t=FinanceVAT&a=list', NULL , NULL , NULL , '1' );"); $ActionId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Sazby DPH', '2', '".$ActionId."', '1');"); } function UpdateTo647(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `EmployeeSalary` ADD FOREIGN KEY ( `Employee` ) REFERENCES `Employee` ( `Id` ) ON DELETE RESTRICT ON UPDATE RESTRICT ;'); $Manager->Execute('ALTER TABLE `EmployeeSalary` ADD `Contract` INT NULL , ADD INDEX ( `Contract` ) ;'); $Manager->Execute('ALTER TABLE `EmployeeSalary` ADD FOREIGN KEY ( `Contract` ) REFERENCES `Contract` ( `Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;'); $Manager->Execute("INSERT INTO `Action` ( `Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` , `Enable`) VALUES (NULL , '', 'Zaměstnanci', '1', '/is/?t=Employee&a=list', NULL , NULL , NULL , '1' );"); $ActionId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Zaměstnanci', '2', '".$ActionId."', '1');"); $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Roční výkazy', '2', NULL, '1');"); $MenuId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `Action` ( `Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` , `Enable`) VALUES (NULL , '', 'Roční přehled', '1', '/is/?t=FinanceYearReport&a=list', NULL , NULL , NULL , '1' );"); $ActionId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Roční přehled', '".$MenuId."', '".$ActionId."', '1');"); $Manager->Execute("INSERT INTO `Action` ( `Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` , `Enable`) VALUES (NULL , '', 'Výkaz subjektů', '1', '/is/?t=SubjectReport&a=list', NULL , NULL , NULL , '1' );"); $ActionId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Výkaz subjektů', '".$MenuId."', '".$ActionId."', '1');"); } function UpdateTo656(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `Measure` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `Method` int(11) NOT NULL, `Continuity` int(11) NOT NULL, `Period` int(11) NOT NULL, `Enabled` int(11) NOT NULL, `Description` text NOT NULL, `DataType` varchar(255) NOT NULL, `DataTable` varchar(255) NOT NULL, `Group` int(11) DEFAULT NULL, `Cumulative` int(11) NOT NULL DEFAULT "0", PRIMARY KEY (`Id`), KEY `Group` (`Group`), KEY `Method` (`Method`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('CREATE TABLE IF NOT EXISTS `MeasureData` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Time` datetime NOT NULL, `Level` int(11) NOT NULL, `Measure` int(11) NOT NULL, `Continuity` int(11) NOT NULL, `Min` int(11) NOT NULL, `Avg` int(11) NOT NULL, `Max` int(11) NOT NULL, PRIMARY KEY (`Id`), KEY `Time` (`Time`), KEY `Measure` (`Measure`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('CREATE TABLE IF NOT EXISTS `MeasureGroup` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `Parent` int(11) DEFAULT NULL, PRIMARY KEY (`Id`), KEY `Parent` (`Parent`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('CREATE TABLE IF NOT EXISTS `MeasureMethod` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `Unit` varchar(255) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `Measure` ADD CONSTRAINT `Measure_ibfk_1` FOREIGN KEY (`Group`) REFERENCES `MeasureGroup` (`Id`), ADD CONSTRAINT `Measure_ibfk_2` FOREIGN KEY (`Method`) REFERENCES `MeasureMethod` (`Id`);'); $Manager->Execute('ALTER TABLE `MeasureData` ADD CONSTRAINT `MeasureData_ibfk_1` FOREIGN KEY (`Measure`) REFERENCES `Measure` (`Id`);'); $Manager->Execute('ALTER TABLE `MeasureGroup` ADD CONSTRAINT `MeasureGroup_ibfk_1` FOREIGN KEY (`Parent`) REFERENCES `MeasureGroup` (`Id`);'); } function UpdateTo657(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkInterfaceUpDown` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Time` datetime NOT NULL, `Interface` int(11) NOT NULL, `State` int(11) NOT NULL, PRIMARY KEY (`Id`), KEY `Interface` (`Interface`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD CONSTRAINT `NetworkInterfaceUpDown_ibfk_1` FOREIGN KEY (`Interface`) REFERENCES `NetworkInterface` (`Id`);'); $Manager->Execute("INSERT INTO `Action` ( `Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` , `Enable`) VALUES (NULL , '', 'Změny stavu rozhraní', '1', '/is/?t=NetworkInterfaceUpDown&a=list', NULL , NULL , NULL , '1' );"); $ActionId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Změny stavu rozhraní', 4, '".$ActionId."', '1');"); } function UpdateTo661(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `Contact` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Category` int(11) NOT NULL, `Value` varchar(255) NOT NULL, `Subject` int(11) DEFAULT NULL, `User` int(11) DEFAULT NULL, PRIMARY KEY (`Id`), KEY `Category` (`Category`), KEY `User` (`User`), KEY `Subject` (`Subject`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('CREATE TABLE IF NOT EXISTS `ContactCategory` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `Contact` ADD CONSTRAINT `Contact_ibfk_3` FOREIGN KEY (`User`) REFERENCES `User` (`Id`), ADD CONSTRAINT `Contact_ibfk_1` FOREIGN KEY (`Category`) REFERENCES `ContactCategory` (`Id`), ADD CONSTRAINT `Contact_ibfk_2` FOREIGN KEY (`Subject`) REFERENCES `Subject` (`Id`);'); $Manager->Execute("INSERT INTO `Action` ( `Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` , `Enable`) VALUES (NULL , '', 'Kontakty', '1', '/is/?t=Contact&a=list', NULL , NULL , NULL , '1' );"); $ActionId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Kontakty', '12', '".$ActionId."', '1');"); $ContactMenuId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `Action` ( `Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` , `Enable`) VALUES (NULL , '', 'Druhy kontakty', '1', '/is/?t=ContactCategory&a=list', NULL , NULL , NULL , '1' );"); $ActionId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Druhy kontaktů', ".$ContactMenuId.", '".$ActionId."', '1');"); $Manager->Execute("INSERT INTO `ContactCategory` (`Id` ,`Name`) VALUES (NULL , 'Telefón'), (NULL , 'ICQ'), (NULL , 'Jabber'), (NULL , 'Email'), (NULL , 'Skype');"); } function UpdateTo662(UpdateManager $Manager): void { $Manager->Execute('INSERT INTO `Contact` (SELECT NULL AS `Id`, 2 AS `Category`, `ICQ` AS `Value`, NULL AS `Subject`, `Id` AS `User` FROM `User` WHERE (`ICQ` != "") AND (`ICQ` != 0))'); $Manager->Execute('ALTER TABLE `User` DROP `ICQ`;'); $Manager->Execute('INSERT INTO `ActionIcon` (`Id`, `Name`) VALUES (NULL, "Contact.png");'); $IconId = $Manager->Database->insert_id; $Manager->Execute('UPDATE `Action` SET `Icon` = '.$IconId.' WHERE `Title`="Kontakty"'); } function UpdateTo668(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `APIToken` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `User` int(11) NOT NULL, `Token` varchar(255) NOT NULL, PRIMARY KEY (`Id`), KEY `User` (`User`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `APIToken` ADD CONSTRAINT `APIToken_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);'); $Manager->Execute('INSERT INTO `Module` (`Id` ,`Name` ,`Title`) VALUES (NULL , "RSS", "RSS kanály");'); } function UpdateTo671(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkSignal` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Time` datetime NOT NULL, `MAC` varchar(17) NOT NULL, `Interface` int(11) DEFAULT NULL, `Value` int(11) NOT NULL, PRIMARY KEY (`Id`), KEY `Interface` (`Interface`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `NetworkSignal` ADD CONSTRAINT `NetworkSignal_ibfk_1` FOREIGN KEY (`Interface`) REFERENCES `NetworkInterface` (`Id`);'); $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` , `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES ( NULL , "", "Signál rozhraní", "1", "/is/?t=NetworkSignal&a=list", NULL , NULL , NULL , "1");'); $ActionId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Signál rozhraní', 4, '".$ActionId."', '1');"); $Manager->Execute('ALTER TABLE `NetworkDevice` ADD `API` INT NULL ,ADD INDEX ( `API` ) ;'); $Manager->Execute('CREATE TABLE IF NOT EXISTS `DeviceAPIType` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;'); $Manager->Execute('INSERT INTO `DeviceAPIType` (`Id`, `Name`) VALUES (1, "RouterOS API"), (2, "AirOS");'); $Manager->Execute('ALTER TABLE `NetworkDevice` ADD FOREIGN KEY ( `API` ) REFERENCES `DeviceAPIType` ( `Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;'); } function UpdateTo674(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `RateRx` INT NOT NULL ;'); $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `RateTx` INT NOT NULL ;'); } function UpdateTo676(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `Device` INT NULL , ADD INDEX ( `Device` ) ;'); $Manager->Execute('ALTER TABLE `NetworkSignal` ADD FOREIGN KEY ( `Device` ) REFERENCES `NetworkDevice` ( `Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;'); } function UpdateTo678(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `Contact` ADD `Description` VARCHAR( 255 ) NOT NULL ;'); $Manager->Execute('ALTER TABLE `Contact` ADD `Receive` BOOLEAN NOT NULL ;'); $Manager->Execute('CREATE TABLE IF NOT EXISTS `MenuItemFavorite` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `User` int(11) NOT NULL, `MenuItem` int(11) NOT NULL, PRIMARY KEY (`Id`), KEY `User` (`User`), KEY `MenuItem` (`MenuItem`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `MenuItemFavorite` ADD CONSTRAINT `MenuItemFavorite_ibfk_2` FOREIGN KEY (`MenuItem`) REFERENCES `MenuItem` (`Id`), ADD CONSTRAINT `MenuItemFavorite_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);'); $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` , `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES ( NULL , "", "Oblíbené položky nabídky", "1", "/is/?t=MenuItemFavorite&a=list", NULL , NULL , NULL , "1");'); $ActionId = $Manager->Database->insert_id; $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Nabídky"'); if ($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Oblíbené položky nabídky', ".$DbRow['Id'].", '".$ActionId."', '1');"); } } function UpdateTo679(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkDevice` ADD `Product` INT NOT NULL AFTER `Id` , ADD INDEX ( `Product` ) ;'); } function UpdateTo688(UpdateManager $Manager): void { // Convert monthly plus payment for consumption to regular service $DbResult = $Manager->Execute('SELECT `MonthlyPlus`, `Member` FROM `MemberPayment` WHERE `MonthlyPlus` > 0'); while ($DbRow = $DbResult->fetch_assoc()) { $Manager->Execute("INSERT INTO `Service` (`Id` ,`Name` ,`Category` ,`Price` ,`VAT`) ". "VALUES (NULL , 'Spotřeba energie', 3, -".$DbRow['MonthlyPlus'].", 2);"); $ServiceId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `ServiceCustomerRel` (`Id` ,`Service` ,`Customer`) ". "VALUES (NULL , ".$ServiceId.', '.$DbRow['Member'].");"); } } function UpdateTo692(UpdateManager $Manager): void { // Convert user emails to contacts $DbResult = $Manager->Execute('SELECT `Id` FROM `ContactCategory` WHERE `Name` = "Telefón"'); $DbRow = $DbResult->fetch_assoc(); $ContactCategoryId = $DbRow['Id']; $Manager->Execute('INSERT INTO `Contact` (SELECT NULL AS `Id`, '.$ContactCategoryId.' AS `Category`, '. '`PhoneNumber` AS `Value`, NULL AS `Subject`, `Id` AS `User`, "" AS `Descriptions`, 1 AS `Receive` FROM `User` WHERE (`PhoneNumber` != "") AND (`PhoneNumber` != 0))'); $Manager->Execute('ALTER TABLE `User` DROP `PhoneNumber`;'); } function UpdateTo696(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD `Duration` INT NOT NULL ;'); $Manager->Execute('UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = IFNULL(TIMESTAMPDIFF(SECOND, (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` < `TM`.`Time`) AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` DESC LIMIT 1), `TM`.`Time`), 0)'); } function UpdateTo697(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` CHANGE `Duration` `Duration` INT( 11 ) NULL ;'); $Manager->Execute('UPDATE `NetworkInterfaceUpDown` SET `Duration` = NULL'); $Manager->Execute('UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = TIMESTAMPDIFF(SECOND, `TM`.`Time`, (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` > `TM`.`Time`) AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` ASC LIMIT 1))'); } function UpdateTo707(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkDevice` CHANGE `Product` `Product` INT(11) NULL;'); } function UpdateTo710(UpdateManager $Manager): void { $Manager->Execute('RENAME TABLE `StockItem` TO `StockSerialNumber`;'); $Manager->Execute('UPDATE `Action` SET `URL`="/is/?t=StockSerialNumber&a=list",`Title`="Sériová čísla" WHERE `URL`="/is/?t=StockItem&a=list";'); // StockMove $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockMove` ( `Id` int(11) NOT NULL, `Time` datetime NOT NULL, `StockFrom` int(11) DEFAULT NULL, `StockTo` int(11) DEFAULT NULL, `BillCode` varchar(255) NOT NULL, `DocumentLine` int(11) NOT NULL, `File` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `StockMove` ADD PRIMARY KEY (`Id`), ADD KEY `DocumentLine` (`DocumentLine`), ADD KEY `StockFrom` (`StockFrom`), ADD KEY `StockTo` (`StockTo`), ADD KEY `File` (`File`);'); $Manager->Execute('ALTER TABLE `StockMove` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;'); $Manager->Execute('ALTER TABLE `StockMove` ADD CONSTRAINT `StockMove_ibfk_1` FOREIGN KEY (`StockFrom`) REFERENCES `Stock` (`Id`), ADD CONSTRAINT `StockMove_ibfk_2` FOREIGN KEY (`StockTo`) REFERENCES `Stock` (`Id`), ADD CONSTRAINT `StockMove_ibfk_3` FOREIGN KEY (`DocumentLine`) REFERENCES `DocumentLine` (`Id`);'); // StockMoveItem $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockMoveItem` ( `Id` int(11) NOT NULL, `StockMove` int(11) NOT NULL, `Product` int(11) NOT NULL, `Amount` int(11) NOT NULL, `Text` varchar(255) NOT NULL, `UnitPrice` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `StockMoveItem` ADD PRIMARY KEY (`Id`), ADD KEY `Product` (`Product`), ADD KEY `StockMove` (`StockMove`);'); $Manager->Execute('ALTER TABLE `StockMoveItem` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;'); $Manager->Execute('ALTER TABLE `StockMoveItem` ADD CONSTRAINT `StockMoveItem_ibfk_2` FOREIGN KEY (`Product`) REFERENCES `Product` (`Id`), ADD CONSTRAINT `StockMoveItem_ibfk_1` FOREIGN KEY (`StockMove`) REFERENCES `StockMove` (`Id`);'); // IS menu item $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` , `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES ( NULL , "", "Skladové pohyby", "1", "/is/?t=StockMove&a=list", NULL , NULL , NULL , "1");'); $ActionId = $Manager->Database->insert_id; $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Sklad"'); if ($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Skladové pohyby', ".$DbRow['Id'].", '".$ActionId."', '1');"); } } function UpdateTo715(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `StockSerialNumber` DROP FOREIGN KEY `StockSerialNumber_ibfk_6`;'); $Manager->Execute('ALTER TABLE `StockSerialNumber` DROP `Segment`'); $Manager->Execute('ALTER TABLE `Member` DROP `NetworkSegment`'); $Manager->Execute('DROP TABLE `NetworkSegment`'); $Manager->Execute('DELETE FROM `MenuItem` WHERE `Name`="Úseky sítě"'); $Manager->Execute('DELETE FROM `Action` WHERE `Title`="Úseky sítě"'); } function UpdateTo718(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `Company` ( `Id` int(11) NOT NULL, `Name` varchar(255) NOT NULL, `Subject` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `Company` ADD PRIMARY KEY (`Id`), ADD KEY `Subject` (`Subject`);'); $Manager->Execute('ALTER TABLE `Company` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;'); $Manager->Execute('ALTER TABLE `Company` ADD CONSTRAINT `Company_ibfk_1` FOREIGN KEY (`Subject`) REFERENCES `Subject` (`Id`);'); // IS menu item $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` , `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES ( NULL , "", "Firmy", "1", "/is/?t=Company&a=list", NULL , NULL , NULL , "1");'); $ActionId = $Manager->Database->insert_id; $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Finance"'); if ($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Firmy', ".$DbRow['Id'].", '".$ActionId."', '1');"); } } function UpdateTo719(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `Direction` INT NOT NULL AFTER `Cash`;'); $Manager->Execute('UPDATE `FinanceOperation` SET `Direction` = 1 WHERE `Value` >= 0 ;'); $Manager->Execute('UPDATE `FinanceOperation` SET `Direction` = -1 WHERE `Value` < 0 ;'); $Manager->Execute('UPDATE `FinanceOperation` SET `Value` = -`Value` WHERE `Value` < 0 ;'); // Set missing FinanceOperation DocumentLine according BillCode $Manager->Execute('UPDATE `FinanceOperation` SET `DocumentLine` = 1 WHERE (`BillCode` LIKE "PP%") AND (`DocumentLine` IS NULL)'); $Manager->Execute('UPDATE `FinanceOperation` SET `DocumentLine` = 2 WHERE (`BillCode` LIKE "VP%") AND (`DocumentLine` IS NULL)'); $Manager->Execute('UPDATE `FinanceOperation` SET `DocumentLine` = 3 WHERE (`BillCode` LIKE "BV%") AND (`DocumentLine` IS NULL)'); $Manager->Execute('UPDATE `FinanceOperation` SET `DocumentLine` = 4 WHERE (`BillCode` LIKE "PR%") AND (`DocumentLine` IS NULL)'); // IS menu item $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Příjmy a výdaje"'); if ($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` , `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES ( NULL , "", "Příjem do pokladny", "1", "/is/?t=FinanceTreasuryIn&a=list", NULL , NULL , NULL , "1");'); $ActionId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Příjem do pokladny', ".$DbRow['Id'].", '".$ActionId."', '1');"); $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` , `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES ( NULL , "", "Výdej z pokladny", "1", "/is/?t=FinanceTreasuryOut&a=list", NULL , NULL , NULL , "1");'); $ActionId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Výdej z pokladny', ".$DbRow['Id'].", '".$ActionId."', '1');"); $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` , `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES ( NULL , "", "Příjem na účet", "1", "/is/?t=FinanceAccountIn&a=list", NULL , NULL , NULL , "1");'); $ActionId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Příjem na účet', ".$DbRow['Id'].", '".$ActionId."', '1');"); $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` , `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES ( NULL , "", "Výdej z účtu", "1", "/is/?t=FinanceAccountOut&a=list", NULL , NULL , NULL , "1");'); $ActionId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Výdej z účtu', ".$DbRow['Id'].", '".$ActionId."', '1');"); } } function UpdateTo720(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `Direction` INT NOT NULL AFTER `TimePayment`;'); $Manager->Execute('UPDATE `FinanceInvoice` SET `Direction` = 1 WHERE `Value` >= 0 ;'); $Manager->Execute('UPDATE `FinanceInvoice` SET `Direction` = -1 WHERE `Value` < 0 ;'); $Manager->Execute('UPDATE `FinanceInvoice` SET `Value` = -`Value` WHERE `Value` < 0 ;'); // Set missing FinanceInvoice DocumentLine according BillCode $Manager->Execute('UPDATE `FinanceInvoice` SET `DocumentLine` = 5 WHERE (`BillCode` LIKE "PF%") AND (`DocumentLine` IS NULL)'); $Manager->Execute('UPDATE `FinanceInvoice` SET `DocumentLine` = 6 WHERE (`BillCode` LIKE "VF%") AND (`DocumentLine` IS NULL)'); // IS menu item $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Závazky a pohledávky"'); if ($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` , `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES ( NULL , "", "Příjaté", "1", "/is/?t=FinanceInvoiceIn&a=list", NULL , NULL , NULL , "1");'); $ActionId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Přijaté', ".$DbRow['Id'].", '".$ActionId."', '1');"); $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` , `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES ( NULL , "", "Vydané", "1", "/is/?t=FinanceInvoiceOut&a=list", NULL , NULL , NULL , "1");'); $ActionId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Vydané', ".$DbRow['Id'].", '".$ActionId."', '1');"); } } function UpdateTo722(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `Service` DROP `CustomerCount`;'); } function UpdateTo725(UpdateManager $Manager): void { // Text column of invoices is not used. Text from invoice items is taken instead. $DbResult = $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP `Text`;'); $SearchText = 'Připojení k síti'; $DbResult = $Manager->Execute('SELECT * FROM `FinanceInvoiceItem` WHERE `Description` LIKE "'.$SearchText.' za období%";'); while ($DbRow = $DbResult->fetch_assoc()) { $Text = trim(substr($DbRow['Description'], strlen($SearchText.' za období') + 1)); $Text = explode('-', $Text); $PeriodFrom = explode('.', trim($Text[0])); $PeriodFrom = $PeriodFrom[2].'-'.$PeriodFrom[1].'-'.$PeriodFrom[0]; $PeriodTo = explode('.', trim($Text[1])); $PeriodTo = $PeriodTo[2].'-'.$PeriodTo[1].'-'.$PeriodTo[0]; $Manager->Execute('UPDATE `FinanceInvoice` SET `PeriodFrom`="'.$PeriodFrom.'", `PeriodTo`="'.$PeriodTo.'" WHERE `Id`='.$DbRow['FinanceInvoice']); } $DbResult = $Manager->Execute('UPDATE `FinanceInvoiceItem` SET `Description` = "'.$SearchText.'" WHERE `Description` LIKE "'.$SearchText.' za období%";'); $SearchText = 'Připojení k Internetu'; $DbResult = $Manager->Execute('SELECT * FROM `FinanceInvoiceItem` WHERE `Description` LIKE "'.$SearchText.' za období%";'); while ($DbRow = $DbResult->fetch_assoc()) { $Text = trim(substr($DbRow['Description'], strlen($SearchText.' za období') + 1)); $Text = explode('-', $Text); $PeriodFrom = explode('.', trim($Text[0])); $PeriodFrom = $PeriodFrom[2].'-'.$PeriodFrom[1].'-'.$PeriodFrom[0]; $Text[1] = trim($Text[1]); if (strpos($Text[1], ' ') !== false) $Text[1] = substr($Text[1], 0, strpos($Text[1], ' ')); $PeriodTo = explode('.', trim($Text[1])); $PeriodTo = $PeriodTo[2].'-'.$PeriodTo[1].'-'.$PeriodTo[0]; $Manager->Execute('UPDATE `FinanceInvoice` SET `PeriodFrom`="'.$PeriodFrom.'", `PeriodTo`="'.$PeriodTo.'" WHERE `Id`='.$DbRow['FinanceInvoice']); } $DbResult = $Manager->Execute('UPDATE `FinanceInvoiceItem` SET `Description` = "'.$SearchText.'" WHERE `Description` LIKE "'.$SearchText.' za období%";'); } function UpdateTo726(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `ServiceCustomerRel` CHANGE `Action` `ChangeAction` ENUM("add","modify","remove") CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;'); $Manager->Execute('ALTER TABLE `ServiceCustomerRel` ADD `ChangeTime` DATETIME NULL AFTER `ChangeAction`;'); $Manager->Execute('ALTER TABLE `ServiceCustomerRel` DROP FOREIGN KEY `ServiceCustomerRel_ibfk_4`;'); $Manager->Execute('ALTER TABLE `ServiceCustomerRel` CHANGE `ReplaceId` `ChangeReplaceId` INT(11) NULL DEFAULT NULL;'); $Manager->Execute('ALTER TABLE `ServiceCustomerRel` ADD FOREIGN KEY (`ChangeReplaceId`) REFERENCES `ServiceCustomerRel`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); $Manager->Execute('ALTER TABLE `Service` CHANGE `Action` `ChangeAction` ENUM("add","modify","remove") CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;'); $Manager->Execute('ALTER TABLE `Service` ADD `ChangeTime` DATETIME NULL AFTER `ChangeAction`;'); $Manager->Execute('ALTER TABLE `Service` DROP FOREIGN KEY `Service_ibfk_2`;'); $Manager->Execute('ALTER TABLE `Service` CHANGE `ReplaceId` `ChangeReplaceId` INT(11) NULL DEFAULT NULL;'); $Manager->Execute('ALTER TABLE `Service` ADD FOREIGN KEY (`ChangeReplaceId`) REFERENCES `Service`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); $Manager->Execute('ALTER TABLE `FinanceCharge` CHANGE `Action` `ChangeAction` ENUM("add","modify","remove") CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;'); $Manager->Execute('ALTER TABLE `FinanceCharge` ADD `ChangeTime` DATETIME NULL AFTER `ChangeAction`;'); $Manager->Execute('ALTER TABLE `FinanceCharge` DROP FOREIGN KEY `FinanceCharge_ibfk_1`;'); $Manager->Execute('ALTER TABLE `FinanceCharge` CHANGE `ReplaceId` `ChangeReplaceId` INT(11) NULL DEFAULT NULL;'); $Manager->Execute('ALTER TABLE `FinanceCharge` ADD FOREIGN KEY (`ChangeReplaceId`) REFERENCES `FinanceCharge`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); $Manager->Execute('ALTER TABLE `MemberPayment` DROP `NetworkDevice`;'); } function UpdateTo729(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `FinanceBankAccount` ADD `AutoImport` INT NOT NULL ;'); $Manager->Execute('CREATE TABLE IF NOT EXISTS `Scheduler` ( `Id` int(11) NOT NULL, `Name` varchar(255) NOT NULL, `Enabled` int(11) NOT NULL, `Class` varchar(255) NOT NULL, `Log` mediumtext NOT NULL, `LastExecutedTime` datetime DEFAULT NULL, `ScheduledTime` datetime NOT NULL, `Period` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `Scheduler` ADD PRIMARY KEY (`Id`);'); $Manager->Execute('ALTER TABLE `Scheduler` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;'); // IS menu item $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` , `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES ( NULL , "", "Plánovač", "1", "/is/?t=Scheduler&a=list", NULL , NULL , NULL , "1");'); $ActionId = $Manager->Database->insert_id; $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Systém"'); if ($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Plánovač', ".$DbRow['Id'].", '".$ActionId."', '1');"); } $Manager->Execute('INSERT INTO `Module` (`Id`, `Name`, `Title`) VALUES (NULL, "Plánovač", "Scheduler");'); } function UpdateTo730(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `SchedulerAction` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `Class` varchar(255) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `Scheduler` CHANGE `Class` `Action` INT(11) NOT NULL;'); $Manager->Execute("ALTER TABLE `Scheduler` ADD INDEX ( `Action` ) "); $Manager->Execute('INSERT INTO `SchedulerAction` (`Id`, `Name`, `Class`) VALUES (NULL, "Import bankovních účtů", "ScheduleBankImport");'); $Manager->Execute('UPDATE `Scheduler` SET `Action` = 1 WHERE `Scheduler`.`Id` = 1;'); $Manager->Execute('ALTER TABLE `Scheduler` ADD CONSTRAINT `Schedule_ibfk_2` FOREIGN KEY (`Action`) REFERENCES `SchedulerAction` (`Id`);'); } function UpdateTo731(UpdateManager $Manager): void { // NetworkDomain $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkDomain` ( `Id` int(11) NOT NULL, `Name` varchar(255) NOT NULL, `Parent` int(11) DEFAULT NULL, `Serial` int(11) NOT NULL, `Refresh` int(11) NOT NULL, `Expire` int(11) NOT NULL, `Retry` int(11) NOT NULL, `Minimum` int(11) NOT NULL, `TTL` int(11) NOT NULL, `Description` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `NetworkDomain` ADD PRIMARY KEY (`Id`);'); $Manager->Execute('ALTER TABLE `NetworkDomain` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1;'); $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` , `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES ( NULL , "", "Síťová doména", "1", "/is/?t=NetworkDomain&a=list", NULL , NULL , NULL , "1");'); $ActionId = $Manager->Database->insert_id; $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Síť"'); if ($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Síťová doména', ".$DbRow['Id'].", '".$ActionId."', '1');"); } // Model additions $Manager->Execute('ALTER TABLE `Model` ADD `Title` VARCHAR(255) NOT NULL , '. 'ADD `Query` VARCHAR(255) NOT NULL , '. 'ADD `DefaultSortColumn` VARCHAR(255) NOT NULL , '. 'ADD `DefaultSortOrder` INT NOT NULL ;'); // ModelField $Manager->Execute('CREATE TABLE IF NOT EXISTS `ModelField` ( `Id` int(11) NOT NULL, `Name` varchar(255) NOT NULL, `Model` int(11) NOT NULL, `Query` varchar(255) NOT NULL, `Type` varchar(255) NOT NULL, `Title` varchar(255) NOT NULL, `DefaultValue` varchar(255) NOT NULL, `IsNull` int(11) NOT NULL, `Suffix` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `ModelField` ADD PRIMARY KEY (`Id`), ADD KEY `Model` (`Model`);'); $Manager->Execute('ALTER TABLE `ModelField` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;'); $Manager->Execute('ALTER TABLE `ModelField` ADD CONSTRAINT `ModelField_ibfk_1` FOREIGN KEY (`Model`) REFERENCES `Model` (`Id`);'); // Module additions $Manager->Execute('ALTER TABLE `Module` ADD `Version` VARCHAR(255) NOT NULL , '. 'ADD `Creator` VARCHAR(255) NOT NULL , '. 'ADD `License` VARCHAR(255) NOT NULL , '. 'ADD `Installed` INT NOT NULL , '. 'ADD `HomePage` VARCHAR(255) NOT NULL , '. 'ADD `Description` TEXT NOT NULL ;'); // ModuleLink $Manager->Execute('CREATE TABLE IF NOT EXISTS `ModuleLink` ( `Id` int(11) NOT NULL, `Module` int(11) NOT NULL, `LinkedModule` int(11) NOT NULL, `Type` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `ModuleLink` ADD PRIMARY KEY (`Id`), ADD KEY `Module` (`Module`), ADD KEY `LinkedModule` (`LinkedModule`);'); $Manager->Execute('ALTER TABLE `ModuleLink` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;'); } function UpdateTo735(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkFreeAccess` ( `Id` int(11) NOT NULL, `IPAddress` varchar(255) NOT NULL, `Time` datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); $Manager->Execute('ALTER TABLE `NetworkFreeAccess` ADD PRIMARY KEY (`Id`);'); $Manager->Execute('ALTER TABLE `NetworkFreeAccess` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1;'); $Manager->Execute('ALTER TABLE `NetworkFreeAccess` ADD `Configured` INT NOT NULL ;'); $DbResult = $Manager->Execute('INSERT INTO `SchedulerAction` (`Id`, `Name`, `Class`) VALUES '. '(NULL, "Konfigurace internetu zdarma", "ScheduleConfigureFreeAccess");'); $ActionId = $Manager->Database->insert_id; $Manager->Execute('INSERT INTO `Scheduler` (`Id`, `Name`, `Enabled`, `Action`, `Log`, `LastExecutedTime`, `ScheduledTime`, `Period`) VALUES (NULL, "Internet zdarma", 1, '.$ActionId.', "", NULL, "", 5);'); $Manager->Execute('ALTER TABLE `Scheduler` CHANGE `ScheduledTime` `ScheduledTime` DATETIME NULL;'); } function UpdateTo736(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkLinkType` ( `Id` int(11) NOT NULL, `Name` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $Manager->Execute('ALTER TABLE `NetworkLinkType` ADD PRIMARY KEY (`Id`);'); $Manager->Execute('ALTER TABLE `NetworkLinkType` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;'); } function UpdateTo739(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkDomain` ADD KEY (`Parent`);'); $Manager->Execute('ALTER TABLE `NetworkDomain` ADD FOREIGN KEY (`Parent`) REFERENCES `NetworkDomain`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkDomainServer` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Address` varchar(255) NOT NULL, `Domain` int(11) NOT NULL, `Sequence` int(11) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;'); $Manager->Execute('ALTER TABLE `NetworkDomainServer` ADD KEY `Domain` (`Domain`);'); $Manager->Execute('ALTER TABLE `NetworkDomainServer` ADD CONSTRAINT `NetworkDomainServer_ibfk_1` FOREIGN KEY (`Domain`) REFERENCES `NetworkDomain` (`Id`);'); } function UpdateTo740(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceInvoiceGroup` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `DocumentLine` int(11) NOT NULL, `ValueSign` int(11) NOT NULL, PRIMARY KEY (`Id`), KEY `DocumentLine` (`DocumentLine`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;'); $Manager->Execute('ALTER TABLE `FinanceInvoiceGroup` ADD CONSTRAINT `FinanceInvoiceGroup_ibfk_1` FOREIGN KEY (`DocumentLine`) REFERENCES `DocumentLine` (`Id`);'); $Manager->Execute('INSERT INTO `FinanceInvoiceGroup` (`Id`, `Name`, `DocumentLine`, `ValueSign`) VALUES (1, "Přijaté faktury", 5, -1), (2, "Vydané faktury", 6, 1);'); // Transform FinanceInvoice.DocumentLine reference to FinanceInvoiceGroup $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `Group` INT NULL AFTER `Id`;'); $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD INDEX(`Group`);'); $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD FOREIGN KEY (`Group`) REFERENCES `FinanceInvoiceGroup`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); $Manager->Execute('UPDATE `FinanceInvoice` SET `Group`=1 WHERE `DocumentLine`=5'); $Manager->Execute('UPDATE `FinanceInvoice` SET `Group`=2 WHERE `DocumentLine`=6'); $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP FOREIGN KEY `FinanceInvoice_ibfk_3`;'); $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP `DocumentLine`;'); $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceOperationGroup` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `DocumentLine` int(11) NOT NULL, `ValueSign` int(11) NOT NULL, PRIMARY KEY (`Id`), KEY `DocumentLine` (`DocumentLine`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;'); $Manager->Execute('ALTER TABLE `FinanceOperationGroup` ADD CONSTRAINT `FinanceOperationGroup_ibfk_1` FOREIGN KEY (`DocumentLine`) REFERENCES `DocumentLine` (`Id`);'); $Manager->Execute('INSERT INTO `FinanceOperationGroup` (`Id`, `Name`, `DocumentLine`, `ValueSign`) VALUES (1, "Příjem do pokladny", 1, 1), (2, "Výdej z pokladny", 2, -1), (3, "Příjem na účet", 3, 1), (4, "Výdej z účtu", 4, -1), (5, "Nezařazené (ručně vyčistit)", 1, 1);'); // Transform FinanceOperation.DocumentLine reference to FinanceOperationGroup $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `Group` INT NULL AFTER `Id`;'); $Manager->Execute('ALTER TABLE `FinanceOperation` ADD INDEX (`Group`);'); $Manager->Execute('ALTER TABLE `FinanceOperation` ADD FOREIGN KEY (`Group`) REFERENCES `FinanceOperationGroup`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=1 WHERE `DocumentLine`=1'); $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=2 WHERE `DocumentLine`=2'); $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=3 WHERE `DocumentLine`=3'); $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=4 WHERE `DocumentLine`=4'); $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=5 WHERE `DocumentLine`=10'); $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=5 WHERE `DocumentLine`=5'); $Manager->Execute('ALTER TABLE `FinanceOperation` DROP FOREIGN KEY `FinanceOperation_ibfk_6`;'); $Manager->Execute('ALTER TABLE `FinanceOperation` DROP `DocumentLine`;'); $Manager->Execute('ALTER TABLE `FinanceInvoice` CHANGE `Direction` `ValueSign` INT(11) NOT NULL;'); $Manager->Execute('ALTER TABLE `FinanceOperation` CHANGE `Direction` `ValueSign` INT(11) NOT NULL;'); } function UpdateTo741(UpdateManager $Manager): void { // Add Direction column $Manager->Execute('ALTER TABLE `FinanceOperationGroup` ADD `Direction` INT NOT NULL ;'); $Manager->Execute('UPDATE `FinanceOperationGroup` SET `Direction` = 1 WHERE ValueSign=-1'); $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `Direction` INT NOT NULL AFTER `Cash`;'); $Manager->Execute('UPDATE `FinanceOperation` SET `Direction` = 1 WHERE ValueSign=-1'); $Manager->Execute('ALTER TABLE `FinanceInvoiceGroup` ADD `Direction` INT NOT NULL ;'); $Manager->Execute('UPDATE `FinanceInvoiceGroup` SET `Direction` = 1 WHERE ValueSign=1'); $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `Direction` INT NOT NULL AFTER `TimePayment`;'); $Manager->Execute('UPDATE `FinanceInvoice` SET `Direction` = 1 WHERE ValueSign=1'); } function UpdateTo742(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `DocumentLineCode` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `DocumentLine` int(11) NULL, `Name` varchar(255) NOT NULL, PRIMARY KEY (`Id`), UNIQUE KEY `Name` (`Name`), KEY `DocumentLine` (`DocumentLine`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); $Manager->Execute('ALTER TABLE `DocumentLineCode` ADD CONSTRAINT `DocumentLineCode_ibfk_1` FOREIGN KEY (`DocumentLine`) REFERENCES `DocumentLine` (`Id`);'); // Transform finance operations $Manager->Execute('ALTER TABLE `FinanceOperation` CHANGE `BillCode` `BillCodeText` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL'); $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `BillCode` INT NULL AFTER `BillCodeText`, ADD INDEX (`BillCode`)'); $Manager->Execute('ALTER TABLE `FinanceOperation` ADD FOREIGN KEY (`BillCode`) REFERENCES `DocumentLineCode`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); $DbResult = $Manager->Execute('SELECT `FinanceOperation`.`Id`, `FinanceOperation`.`BillCodeText`, `FinanceOperationGroup`.`DocumentLine` '. 'FROM `FinanceOperation` '. 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 'WHERE `FinanceOperation`.`BillCodeText`!=""'); while ($DbRow = $DbResult->fetch_assoc()) { if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL'; $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '. 'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");'); $CodeId = $Manager->Database->insert_id; $Manager->Execute('UPDATE `FinanceOperation` SET `BillCode`='.$CodeId.' WHERE `Id`='.$DbRow['Id']); } $Manager->Execute('ALTER TABLE `FinanceOperation` DROP `BillCodeText`;'); // Transform invoices $Manager->Execute('ALTER TABLE `FinanceInvoice` CHANGE `BillCode` `BillCodeText` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL'); $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `BillCode` INT NULL AFTER `BillCodeText`, ADD INDEX (`BillCode`)'); $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD FOREIGN KEY (`BillCode`) REFERENCES `DocumentLineCode`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); $DbResult = $Manager->Execute('SELECT `FinanceInvoice`.`Id`, `FinanceInvoice`.`BillCodeText`, `FinanceInvoiceGroup`.`DocumentLine` '. 'FROM `FinanceInvoice` '. 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 'WHERE `FinanceInvoice`.`BillCodeText`!=""'); while ($DbRow = $DbResult->fetch_assoc()) { if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL'; $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '. 'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");'); $CodeId = $Manager->Database->insert_id; $Manager->Execute('UPDATE `FinanceInvoice` SET `BillCode`='.$CodeId.' WHERE `Id`='.$DbRow['Id']); } $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP `BillCodeText`;'); } function UpdateTo747(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `ValueUser` FLOAT NOT NULL AFTER `Value`;'); $Manager->Execute('UPDATE `FinanceOperation` SET `ValueUser`=`Value`'); $Manager->Execute('UPDATE `FinanceOperation` SET `Value`=`ValueUser`*`ValueSign`'); $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=1 WHERE (`ValueSign`=1) AND (`Cash`=1)'); $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=2 WHERE (`ValueSign`=-1) AND (`Cash`=1)'); $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=3 WHERE (`ValueSign`=1) AND (`Cash`=0)'); $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=4 WHERE (`ValueSign`=-1) AND (`Cash`=0)'); $Manager->Execute('ALTER TABLE `FinanceOperation` DROP `Direction`, DROP `ValueSign`;'); // SELECT FinanceInvoice.* FROM `FinanceInvoice` LEFT JOIN FinanceInvoiceGroup ON FinanceInvoiceGroup.Id=FinanceInvoice.Group WHERE FinanceInvoice.ValueSign != FinanceInvoiceGroup.ValueSign $Manager->Execute('UPDATE `FinanceInvoice` SET `Group`=1 WHERE (`ValueSign`=-1)'); $Manager->Execute('UPDATE `FinanceInvoice` SET `Group`=2 WHERE (`ValueSign`=1)'); $Manager->Execute('UPDATE `FinanceInvoice` SET `Value`=`Value`*`ValueSign`'); $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP `Direction`, DROP `ValueSign`;'); // Check rounding manual vs. calculated value from items // SELECT * FROM (SELECT `FinanceInvoice`.`Id`, ((SELECT ROUND(SUM(`Price` * `Quantity`)) FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice`=`FinanceInvoice`.`Id`) * `FinanceInvoiceGroup`.`ValueSign`) AS `Sum`, ((SELECT (SUM(`Price` * `Quantity`)) FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice`=`FinanceInvoice`.`Id`) * `FinanceInvoiceGroup`.`ValueSign`) AS `Sum2`, `FinanceInvoice`.`Value` FROM `FinanceInvoice` LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group`) AS `T` WHERE `Sum` != `Value` // Check sign of manual vs. calculated value from items // SELECT * FROM (SELECT `FinanceInvoice`.`Id`, ((SELECT ROUND(SUM(`Price` * `Quantity`)) FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice`=`FinanceInvoice`.`Id`) * `FinanceInvoiceGroup`.`ValueSign`) AS `Sum`, ((SELECT (SUM(`Price` * `Quantity`)) FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice`=`FinanceInvoice`.`Id`) * `FinanceInvoiceGroup`.`ValueSign`) AS `Sum2`, `FinanceInvoice`.`Value` FROM `FinanceInvoice` LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group`) AS `T` WHERE SIGN(`Sum`) != SIGN(`Value`) } function UpdateTo748(UpdateManager $Manager): void { $DbResult = $Manager->Database->query('SELECT * FROM (SELECT `FinanceInvoice`.`Id`, ((SELECT SUM(`Price` * `Quantity`) FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice`=`FinanceInvoice`.`Id`) * `FinanceInvoiceGroup`.`ValueSign`) AS `Sum`,`FinanceInvoice`.`Value` FROM `FinanceInvoice` LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group`) AS `T` WHERE `Sum` != `Value`'); while ($DbRow = $DbResult->fetch_assoc()) { $Manager->Database->query('UPDATE `FinanceInvoiceItem` SET `Price` = -`Price` WHERE `FinanceInvoice`='.$DbRow['Id']); } } function UpdateTo752(UpdateManager $Manager): void { $Manager->Database->query('INSERT INTO `SchedulerAction` (`Id`, `Name`, `Class`) '. 'VALUES (NULL, "Kontrola změn stavů", "ScheduleNotifyCheck");'); $Manager->Database->query(' CREATE TABLE IF NOT EXISTS `NotifyUser` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `User` int(11) NOT NULL, `Contact` int(11) NOT NULL, `Period` int(11) NOT NULL, `LastTime` datetime NOT NULL, PRIMARY KEY (`Id`), KEY `User` (`User`), KEY `Contact` (`Contact`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'); $Manager->Database->query('ALTER TABLE `NotifyUser` ADD CONSTRAINT `NotifyUser_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`Id`), ADD CONSTRAINT `NotifyUser_ibfk_2` FOREIGN KEY (`Contact`) REFERENCES `Contact` (`Id`);'); $Manager->Database->query('CREATE TABLE IF NOT EXISTS `NotifyCategory` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `SysName` varchar(255) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;'); $Manager->Database->query("INSERT INTO `NotifyCategory` (`Id`, `Name`, `SysName`) VALUES (1, 'Dostupnost zařízení (ping)', 'NetworkReachability'), (2, 'Dostupnost URL', 'URL'), (3, 'Minimální úroveň signálu', 'WirelessSignal'), (4, 'Dostupnost síťového portu', 'NetworkPort'), (5, 'Minimální odezva', 'NetworkLatency'), (6, 'Minimální propustnost', 'NetworkBandwidth');"); } function UpdateTo755(UpdateManager $Manager): void { $Manager->Execute("INSERT INTO `FinanceInvoiceGroup` (`Id`, `Name`, `DocumentLine`, `ValueSign`, `Direction`) ". "VALUES (NULL, 'Přijaté faktury - storno', '5', '1', '0'), (NULL, 'Vydané faktury - storno', '6', '-1', '1')"); $Manager->Execute("ALTER TABLE `FinanceInvoice` ADD `VisibleToUser` INT NOT NULL DEFAULT '1' AFTER `Generate`;". "ALTER TABLE `FinanceInvoice` ADD `VisibleToUser` INT NOT NULL DEFAULT '1' AFTER `Generate`;"); $Manager->Execute("CREATE TABLE IF NOT EXISTS `FinanceInvoiceStorno` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `StornoBy` int(11) NOT NULL, `StornoOf` int(11) NOT NULL, PRIMARY KEY (`Id`), KEY `StornoBy` (`StornoBy`), KEY `StornoOf` (`StornoOf`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $Manager->Execute("ALTER TABLE `FinanceInvoiceStorno` ADD CONSTRAINT `FinanceInvoiceStorno_ibfk_1` FOREIGN KEY (`StornoBy`) REFERENCES `FinanceInvoice` (`Id`), ADD CONSTRAINT `FinanceInvoiceStorno_ibfk_2` FOREIGN KEY (`StornoOf`) REFERENCES `FinanceInvoice` (`Id`); "); } function UpdateTo759(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `Scheduler` ADD `Duration` INT NOT NULL AFTER `Period`;'); } /* function UpdateTo761(UpdateManager $Manager): void { $Manager->Execute('INSERT INTO `MACAddress` (SELECT "" AS `Id`,`MAC` AS `Value` FROM `NetworkSignal` GROUP BY `MAC`)'); $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `Address` INT NOT NULL AFTER `MAC`;'); $Manager->Execute('UPDATE `NetworkSignal` SET `Address`=(SELECT `Id` FROM `MACAddress` WHERE `MACAddress`.`Value`=`NetworkSignal`.`MAC`)'); } */ function UpdateTo762(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkDevice` ADD `OnlineNotify` INT NOT NULL AFTER `API`;'); } function UpdateTo763(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkInterface` ADD `OnlineNotify` INT NOT NULL AFTER `LastOnline`;'); $Manager->Execute('ALTER TABLE `NetworkDevice` DROP `OnlineNotify`;'); } function UpdateTo765(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `SupportActivity` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Description` text NOT NULL, `Customer` int(11) NOT NULL, `User` int(11) NOT NULL, `Time` datetime NOT NULL, PRIMARY KEY (`Id`), KEY `User` (`User`), KEY `Customer` (`Customer`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;'); $Manager->Execute('ALTER TABLE `SupportActivity` ADD CONSTRAINT `SupportActivity_ibfk_1` FOREIGN KEY (`Customer`) REFERENCES `Member` (`Id`), ADD CONSTRAINT `SupportActivity_ibfk_2` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);'); // IS menu item $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` , `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES ( NULL , "", "Zákaznická podpora", "1", "/is/?t=SupportActivity&a=list", NULL , NULL , NULL , "1");'); $ActionId = $Manager->Database->insert_id; $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Zákazníci"'); if ($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Zákazická podpora', ".$DbRow['Id'].", '".$ActionId."', '1');"); } } function UpdateTo768(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkDomainAlias` ADD `Domain` INT NOT NULL AFTER `Comment`;'); $Manager->Execute('ALTER TABLE `NetworkDomainAlias` ADD KEY `Domain` (`Domain`);'); $Manager->Execute('UPDATE `NetworkDomainAlias` SET `Domain`=1'); $Manager->Execute('ALTER TABLE `NetworkDomainAlias` ADD FOREIGN KEY (`Domain`) REFERENCES `NetworkDomain`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkAddressCategory` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;'); $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkDomainItemFilter` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `Domain` int(11) NOT NULL, `AddressCategory` int(11) NOT NULL, `Suffix` varchar(255) NOT NULL, `View` int(11) NOT NULL, `AddressRange` varchar(255) NOT NULL, PRIMARY KEY (`Id`), KEY `Domain` (`Domain`), KEY `View` (`View`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;'); $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkDomainView` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Domain` int(11) NOT NULL, `AddressRange` varchar(255) NOT NULL, `Name` varchar(255) NOT NULL, `SysName` varchar(255) NOT NULL, PRIMARY KEY (`Id`), KEY `Domain` (`Domain`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;'); $Manager->Execute('ALTER TABLE `NetworkDomainItemFilter` ADD FOREIGN KEY (`Domain`) REFERENCES `NetworkDomain` (`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); $Manager->Execute('ALTER TABLE `NetworkDomainItemFilter` ADD FOREIGN KEY (`View`) REFERENCES `NetworkDomainView`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); $Manager->Execute('ALTER TABLE `NetworkDomainView` ADD FOREIGN KEY (`Domain`) REFERENCES `NetworkDomainView`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); } function UpdateTo770(UpdateManager $Manager): void { $Manager->Execute("CREATE TABLE IF NOT EXISTS `OS` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `Subject` int(11) DEFAULT NULL, `Web` varchar(255) NOT NULL, PRIMARY KEY (`Id`), KEY `Subject` (`Subject`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"); $Manager->Execute("INSERT INTO `OS` (`Id`, `Name`, `Subject`, `Web`) VALUES (3, 'Ubuntu', NULL, 'https://www.ubuntu.com/'), (4, 'Fedora', NULL, 'https://getfedora.org/'), (5, 'OpenSUSE', NULL, 'https://www.opensuse.org/'), (6, 'Arch Linux', NULL, 'https://www.archlinux.org/'), (7, 'Debian', NULL, 'https://www.debian.org/');"); $Manager->Execute("CREATE TABLE IF NOT EXISTS `OSArchitecture` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"); $Manager->Execute("INSERT INTO `OSArchitecture` (`Id`, `Name`) VALUES (1, 'i386'), (2, 'x86_64,amd64');"); $Manager->Execute("CREATE TABLE IF NOT EXISTS `OSTemplate` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `Type` int(11) NOT NULL, `Size` bigint(11) NOT NULL, `OSVersion` int(11) NOT NULL, `Public` int(11) NOT NULL, `Architecture` int(11) NOT NULL, PRIMARY KEY (`Id`), KEY `OSVersion` (`OSVersion`), KEY `Architecture` (`Architecture`), KEY `Type` (`Type`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"); $Manager->Execute("INSERT INTO `OSTemplate` (`Id`, `Name`, `Type`, `Size`, `OSVersion`, `Public`, `Architecture`) VALUES (2, 'Ubuntu 15.10 i386', 1, 200000000, 1, 1, 1);"); $Manager->Execute("CREATE TABLE IF NOT EXISTS `OSVersion` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `OS` int(11) NOT NULL, `Version` varchar(255) NOT NULL, `ReleaseDate` date NOT NULL, `CodeName` varchar(255) NOT NULL, `EndOfLife` date DEFAULT NULL, PRIMARY KEY (`Id`), KEY `OS` (`OS`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"); $Manager->Execute("INSERT INTO `OSVersion` (`Id`, `Name`, `OS`, `Version`, `ReleaseDate`, `CodeName`, `EndOfLife`) VALUES (1, 'Ubuntu 15.10', 3, '15.10', '2015-10-23', 'Wily Werewolf', NULL), (2, 'Ubuntu 14.04', 3, '14.04', '2014-04-17', 'Trusty Tahr', NULL);"); $Manager->Execute("CREATE TABLE IF NOT EXISTS `OSVirtType` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"); $Manager->Execute("INSERT INTO `OSVirtType` (`Id`, `Name`) VALUES (1, 'LXC'), (2, 'OpenVZ'), (3, 'KVM'), (4, 'Xen'), (5, 'Hardware');"); $Manager->Execute("CREATE TABLE IF NOT EXISTS `VPS` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `NetworkDevice` int(11) NOT NULL, `OSTemplate` int(11) NOT NULL, `Limits` int(11) NOT NULL, `AutoStart` int(11) NOT NULL, PRIMARY KEY (`Id`), KEY `NetworkDevice` (`NetworkDevice`), KEY `OSTemplate` (`OSTemplate`), KEY `Limit` (`Limits`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"); $Manager->Execute("CREATE TABLE IF NOT EXISTS `VPSLimit` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `Memory` bigint(11) NOT NULL, `Storage` bigint(11) NOT NULL, `NetworkDown` int(11) NOT NULL, `NetworkUp` int(11) NOT NULL, `CPUSockets` int(11) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"); $Manager->Execute("ALTER TABLE `OS` ADD CONSTRAINT `OS_ibfk_1` FOREIGN KEY (`Subject`) REFERENCES `Subject` (`Id`);"); $Manager->Execute("ALTER TABLE `OSTemplate` ADD CONSTRAINT `OSTemplate_ibfk_1` FOREIGN KEY (`OSVersion`) REFERENCES `OSVersion` (`Id`), ADD CONSTRAINT `OSTemplate_ibfk_2` FOREIGN KEY (`Architecture`) REFERENCES `OSArchitecture` (`Id`), ADD CONSTRAINT `OSTemplate_ibfk_3` FOREIGN KEY (`Type`) REFERENCES `OSVirtType` (`Id`);"); $Manager->Execute("ALTER TABLE `OSVersion` ADD CONSTRAINT `OSVersion_ibfk_1` FOREIGN KEY (`OS`) REFERENCES `OS` (`Id`);"); $Manager->Execute("ALTER TABLE `VPS` ADD CONSTRAINT `VPS_ibfk_1` FOREIGN KEY (`NetworkDevice`) REFERENCES `NetworkDevice` (`Id`), ADD CONSTRAINT `VPS_ibfk_2` FOREIGN KEY (`OSTemplate`) REFERENCES `OSTemplate` (`Id`), ADD CONSTRAINT `VPS_ibfk_3` FOREIGN KEY (`Limits`) REFERENCES `VPSLimit` (`Id`);"); } function UpdateTo785(UpdateManager $Manager): void { $Manager->Execute('DROP TABLE `NetworkInterfaceStat`'); } function UpdateTo786(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `Member` DROP FOREIGN KEY Member_ibfk_28;'); $Manager->Execute('ALTER TABLE `Member` DROP `BillingPeriodNext`;'); /* Add table change action */ $Manager->Execute('ALTER TABLE `Member` ADD `ChangeAction` ENUM( "add", "modify", "remove" ) NULL'); $Manager->Execute('ALTER TABLE `Member` ADD `ChangeTime` DATETIME NULL'); $Manager->Execute('ALTER TABLE `Member` ADD `ChangeReplaceId` INT(11) NULL DEFAULT NULL;'); $Manager->Execute('ALTER TABLE `Member` ADD FOREIGN KEY (`ChangeReplaceId`) REFERENCES `Member`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); } function UpdateTo792(UpdateManager $Manager): void { // Transform contracts $Manager->Execute('ALTER TABLE `Contract` CHANGE `BillCode` `BillCodeText` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL'); $Manager->Execute('ALTER TABLE `Contract` ADD `BillCode` INT NULL AFTER `BillCodeText`, ADD INDEX (`BillCode`)'); $Manager->Execute('ALTER TABLE `Contract` ADD FOREIGN KEY (`BillCode`) REFERENCES `DocumentLineCode`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); $DbResult = $Manager->Execute('SELECT `Contract`.`Id`, `Contract`.`BillCodeText`, `Contract`.`DocumentLine` '. 'FROM `Contract` '. 'WHERE `Contract`.`BillCodeText`!=""'); while ($DbRow = $DbResult->fetch_assoc()) { if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL'; $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '. 'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");'); $CodeId = $Manager->Database->insert_id; $Manager->Execute('UPDATE `Contract` SET `BillCode`='.$CodeId.' WHERE `Id`='.$DbRow['Id']); } $Manager->Execute('ALTER TABLE `Contract` DROP `BillCodeText`;'); } function UpdateTo800(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockItemHistory` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `StockSerialNumber` int(11) NOT NULL, `Time` datetime NOT NULL, `Text` varchar(255) NOT NULL, PRIMARY KEY (`Id`), KEY `StockSerialNumber` (`StockSerialNumber`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); $Manager->Execute('ALTER TABLE `StockItemHistory` ADD FOREIGN KEY (`StockSerialNumber`) '. 'REFERENCES `StockSerialNumber`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); $Manager->Execute('INSERT INTO `StockItemHistory` (SELECT NULL AS `Id`, `Id` AS `StockSerialNumber`, '. '"" AS `Time`, `Info` AS `Text` FROM `StockSerialNumber` WHERE `Info` != "")'); $Manager->Execute('ALTER TABLE `StockSerialNumber` DROP `Info`;'); } function UpdateTo802(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockMoveGroup` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `DocumentLine` int(11) NOT NULL, `ValueSign` int(11) NOT NULL, `Direction` int(11) NOT NULL, PRIMARY KEY (`Id`), KEY `DocumentLine` (`DocumentLine`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); $Manager->Execute('ALTER TABLE `StockMoveGroup` ADD FOREIGN KEY (`DocumentLine`) '. 'REFERENCES `DocumentLine`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); $Manager->Execute('INSERT INTO `StockMoveGroup` (`Id`, `Name`, `DocumentLine`, '. '`ValueSign`, `Direction`) VALUES (NULL, "Příjem", 8, 1, 0), (NULL, "Výdej", 7, -1, 1);'); $Manager->Execute('ALTER TABLE `StockMove` ADD `Group` INT NOT NULL AFTER `File`, ADD INDEX (`Group`);'); $Manager->Execute('ALTER TABLE `StockMove` ADD `Stock` INT NOT NULL AFTER `Time`, ADD INDEX (`Stock`);'); $Manager->Execute('UPDATE `StockMove` SET `Group`=(SELECT `Id` FROM `StockMoveGroup` WHERE `StockMoveGroup`.`DocumentLine` = `StockMove`.`DocumentLine`)'); $Manager->Execute('UPDATE `StockMove` SET `Stock`= `StockFrom` WHERE `DocumentLine` = 7'); $Manager->Execute('UPDATE `StockMove` SET `Stock`= `StockTo` WHERE `DocumentLine` = 8'); $Manager->Execute('ALTER TABLE `StockMove` ADD FOREIGN KEY (`Group`) REFERENCES `StockMoveGroup`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); $Manager->Execute('ALTER TABLE `StockMove` DROP FOREIGN KEY StockMove_ibfk_2;'); $Manager->Execute('ALTER TABLE `StockMove` DROP FOREIGN KEY StockMove_ibfk_1;'); $Manager->Execute('ALTER TABLE `StockMove` DROP FOREIGN KEY StockMove_ibfk_3;'); $Manager->Execute('ALTER TABLE `StockMove` DROP `StockFrom`, DROP `StockTo`, DROP `DocumentLine`;'); $Manager->Execute('ALTER TABLE `StockMove` ADD FOREIGN KEY (`Stock`) REFERENCES `Stock`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); // Make BillCode as reference to DocumentLineCode table $Manager->Execute('ALTER TABLE `StockMove` CHANGE `BillCode` `BillCodeText` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL'); $Manager->Execute('ALTER TABLE `StockMove` ADD `BillCode` INT NULL AFTER `BillCodeText`, ADD INDEX (`BillCode`)'); $Manager->Execute('ALTER TABLE `StockMove` ADD FOREIGN KEY (`BillCode`) REFERENCES `DocumentLineCode`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); $DbResult = $Manager->Execute('SELECT `StockMove`.`Id`, `StockMove`.`BillCodeText`, `StockMoveGroup`.`DocumentLine` '. 'FROM `StockMove` '. 'LEFT JOIN `StockMoveGroup` ON `StockMoveGroup`.`Id` = `StockMove`.`Group` '. 'WHERE `StockMove`.`BillCodeText`!=""'); while ($DbRow = $DbResult->fetch_assoc()) { if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL'; $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '. 'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");'); $CodeId = $Manager->Database->insert_id; $Manager->Execute('UPDATE `StockMove` SET `BillCode`='.$CodeId.' WHERE `Id`='.$DbRow['Id']); } $Manager->Execute('ALTER TABLE `StockMove` DROP `BillCodeText`;'); $Manager->Execute('ALTER TABLE `StockMoveItem` DROP `Text`;'); } function UpdateTo803(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockMoveItemSerialRel` ( `Id` int(11) NOT NULL, `StockMoveItem` int(11) NOT NULL, `StockSerialNumber` int(11) NOT NULL, PRIMARY KEY (`Id`), KEY `StockSerialNumber` (`StockSerialNumber`), KEY `StockMoveItem` (`StockMoveItem`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); $Manager->Execute('ALTER TABLE `StockMoveItemSerialRel` ADD FOREIGN KEY (`StockMoveItem`) '. 'REFERENCES `StockMoveItem`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); $Manager->Execute('ALTER TABLE `StockMoveItemSerialRel` ADD FOREIGN KEY (`StockSerialNumber`) '. 'REFERENCES `StockSerialNumber`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); } function UpdateTo807(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `Product` ADD `StockMinCount` INT NOT NULL AFTER `UnitOfMeasure`;'); } function UpdateTo808(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceTreasuryCheck` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Treasury` int(11) NOT NULL, `Time` datetime NOT NULL, `Value1` int(11) NOT NULL, `Value2` int(11) NOT NULL, `Value5` int(11) NOT NULL, `Value10` int(11) NOT NULL, `Value20` int(11) NOT NULL, `Value50` int(11) NOT NULL, `Value100` int(11) NOT NULL, `Value200` int(11) NOT NULL, `Value500` int(11) NOT NULL, `Value1000` int(11) NOT NULL, `Value2000` int(11) NOT NULL, `Value5000` int(11) NOT NULL, PRIMARY KEY (`Id`), KEY `Treasury` (`Treasury`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); $Manager->Execute('ALTER TABLE `FinanceTreasuryCheck` ADD CONSTRAINT `FinanceTreasuryCheck_ibfk_1` FOREIGN KEY (`Treasury`) REFERENCES `FinanceTreasury` (`Id`);'); // IS menu item $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` , `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES ( NULL , "", "Kontrola pokladen", "1", "/is/?t=FinanceTreasuryCheck&a=list", NULL , NULL , NULL , "1");'); $ActionId = $Manager->Database->insert_id; $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Pokladny"'); if ($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Kontrola pokladen', ".$DbRow['Id'].", '".$ActionId."', '1');"); } } function UpdateTo814(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkPort` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `Interface` int(11) NOT NULL, `Number` int(11) NOT NULL, `Enabled` int(11) NOT NULL, `Online` int(11) NOT NULL, `LastOnline` datetime NULL, `OnlineNotify` int(11) NOT NULL, PRIMARY KEY (`Id`), KEY `Interface` (`Interface`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); $Manager->Execute('ALTER TABLE `NetworkPort` ADD CONSTRAINT `NetworkPort_ibfk_1` FOREIGN KEY (`Interface`) REFERENCES `NetworkInterface` (`Id`);'); $Manager->Execute('ALTER TABLE `NetworkInterface` ADD `Enabled` INT NOT NULL DEFAULT "1" AFTER `OnlineNotify`;'); $Manager->Execute('ALTER TABLE `NetworkInterface` CHANGE `LastOnline` `LastOnline` DATETIME NULL;'); $Manager->Execute('UPDATE `NetworkInterface` SET `LastOnline` = NULL WHERE `LastOnline` = "0000-00-00 00:00:00"'); $Manager->Execute('ALTER TABLE `NetworkDevice` CHANGE `LastOnline` `LastOnline` DATETIME NULL;'); $Manager->Execute('UPDATE `NetworkDevice` SET `LastOnline` = NULL WHERE `LastOnline` = "0000-00-00 00:00:00"'); } function UpdateTo817(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkConfiguration` ADD `SysName` VARCHAR(255) NOT NULL FIRST;'); $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="LinuxDNS" WHERE `Id`=1'); $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="LinuxIptables" WHERE `Id`=2'); $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="LinuxTrafficShaping" WHERE `Id`=3'); $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="LinuxDHCP" WHERE `Id`=4'); $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="LinuxVPN" WHERE `Id`=5'); $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="RouterosDHCP" WHERE `Id`=7'); $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="RouterosNetwatch" WHERE `Id`=8'); $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="RouterosQueue" WHERE `Id`=9'); $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="RouterosFirewallNAT" WHERE `Id`=10'); $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="RouterosFirewallMangle" WHERE `Id`=11'); $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="RouterosFirewallFilter" WHERE `Id`=12'); $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="RouterosDNS" WHERE `Id`=13'); $Manager->Execute('ALTER TABLE `NetworkConfiguration` DROP `Execute`;'); } function UpdateTo818(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkPort` ADD `Protocol` INT NOT NULL AFTER `Enabled`;'); $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkPortUpDown` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Time` datetime NOT NULL, `Port` int(11) NOT NULL, `State` int(11) NOT NULL, `Duration` int(11) DEFAULT NULL, PRIMARY KEY (`Id`), KEY `Port` (`Port`), KEY `Time` (`Time`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;'); $Manager->Execute('ALTER TABLE `NetworkPortUpDown` ADD CONSTRAINT `NetworkPortUpDown_ibfk_1` FOREIGN KEY (`Port`) REFERENCES `NetworkPort` (`Id`);'); } function UpdateTo824(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkInterfaceLatency` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Time` datetime NOT NULL, `Interface` int(11) NOT NULL, `Value` float NOT NULL, PRIMARY KEY (`Id`), KEY `Interface` (`Interface`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); $Manager->Execute('ALTER TABLE `NetworkInterfaceLatency` ADD CONSTRAINT `NetworkInterfaceLatency_ibfk_1` FOREIGN KEY (`Interface`) REFERENCES `NetworkInterface` (`Id`);'); } function UpdateTo831(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkLinkType` '. 'ADD `MaxLinkSpeed` INT NOT NULL AFTER `Name`, '. 'ADD `MaxRealSpeed` INT NOT NULL AFTER `MaxLinkSpeed`, '. 'ADD `FullDuplex` INT NOT NULL AFTER `MaxRealSpeed`, '. 'ADD `Color` VARCHAR(6) NOT NULL AFTER `FullDuplex`'); $Manager->Execute('UPDATE `Service` SET `InternetSpeedMin`=`InternetSpeedMin`*1000;'); $Manager->Execute('UPDATE `Service` SET `InternetSpeedMax`=`InternetSpeedMax`*1000;'); } function UpdateTo838(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `News` CHANGE `Date` `Date` DATETIME NULL, CHANGE `TargetDate` `TargetDate` DATETIME NULL;'); } function UpdateTo844(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `DocumentLine` ADD `Yearly` BOOLEAN NOT NULL DEFAULT FALSE AFTER `Shortcut`;'); } function UpdateTo855(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkDeviceLog` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Time` datetime NOT NULL, `Device` int(11) NOT NULL, `Message` varchar(255) NOT NULL, `Tags` varchar(255) NOT NULL, PRIMARY KEY (`Id`), KEY `Device` (`Device`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); $Manager->Execute('ALTER TABLE `NetworkDeviceLog` ADD CONSTRAINT `NetworkDeviceLog_ibfk_1` FOREIGN KEY (`Device`) REFERENCES `NetworkDevice` (`Id`);'); } function UpdateTo862(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD `Previous` INT NULL AFTER `Duration`'); $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD INDEX ( `Previous` )'); $Manager->Execute('UPDATE `NetworkInterfaceUpDown` AS T1, `NetworkInterfaceUpDown` AS T2 SET T1.Previous = T2.Id WHERE (T1.Previous IS NULL) AND (T2.Interface=T1.Interface) AND (T1.Time = DATE_ADD(T2.Time, INTERVAL T2.Duration SECOND))'); } function UpdateTo867(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `NotifyLog` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Time` datetime NOT NULL, `Title` varchar(255) NOT NULL DEFAULT "", `Content` mediumtext NOT NULL DEFAULT "", PRIMARY KEY (`Id`), KEY `Time` (`Time`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); } function UpdateTo869(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkSpeedLimit` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) CHARACTER SET utf8 NOT NULL, `SpeedMaxOut` bigint(20) NOT NULL DEFAULT 0, `SpeedMaxIn` bigint(20) NOT NULL DEFAULT 0, `Parent` int(11) DEFAULT 0, PRIMARY KEY (`Id`), KEY `Parent` (`Parent`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;'); $Manager->Execute('ALTER TABLE `ServiceCustomerRel` ADD COLUMN `SpeedLimit` INT NULL AFTER `ChangeReplaceId`, ADD INDEX `SpeedLimit` (`SpeedLimit`);'); // IS menu item $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` , `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES ( NULL , "", "Omezení rychlosti", "1", "/is/?t=NetworkSpeedLimit&a=list", NULL , NULL , NULL , "1");'); $ActionId = $Manager->Database->insert_id; $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Síť"'); if ($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Omezení rychlosti', ".$DbRow['Id'].", '".$ActionId."', '1');"); } } function UpdateTo870(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkSubnet`ADD COLUMN `MaskIPv6` INT(11) NOT NULL AFTER `AddressRangeIPv6`;'); $Manager->Execute('UPDATE `NetworkSubnet` SET `MaskIPv6`=64 WHERE `AddressRangeIPv6` != ""'); $Manager->Execute('UPDATE `NetworkSubnet` SET `AddressRangeIPv6` = REPLACE(`AddressRangeIPv6`, "/64", "")'); } function UpdateTo878(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NewsImport` ADD `Method` VARCHAR(255) NOT NULL AFTER `Category`;'); $Manager->Execute('ALTER TABLE `NewsImport` ADD PRIMARY KEY (`Id`);'); $Manager->Execute('ALTER TABLE `NewsImport` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;'); } function UpdateTo880(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `UserOnline` CHANGE `IpAddress` `IpAddress` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT "";'); $Manager->Execute('ALTER TABLE `User` CHANGE `LastIpAddress` `LastIpAddress` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT "";'); $Manager->Execute('ALTER TABLE `Log` CHANGE `IPAddress` `IPAddress` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;'); } function UpdateTo882(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `FinanceMonthlyOverall` CHANGE `Investment` `Investment` INT(11) NOT NULL DEFAULT "0";'); } function UpdateTo885(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `FinanceOperation` CHANGE `Value` `Value` FLOAT NOT NULL DEFAULT "0";'); $Manager->Execute('ALTER TABLE `NetworkInterface` CHANGE `OnlineNotify` `OnlineNotify` INT(11) NOT NULL DEFAULT "0";'); } function UpdateTo901(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `Member` ADD `Contract` INT NULL DEFAULT NULL AFTER `ChangeReplaceId`;'); $Manager->Execute('ALTER TABLE `Member` ADD FOREIGN KEY (`Contract`) REFERENCES `Contract`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); $Manager->Execute("INSERT INTO `Module` (`Id`, `Name`, `Title`, `Version`, `Creator`, `License`, `Installed`, `HomePage`, `Description`) VALUES (NULL, 'Contract', '', '', '', '', '0', '', '');"); $Manager->Execute("INSERT INTO `Module` (`Id`, `Name`, `Title`, `Version`, `Creator`, `License`, `Installed`, `HomePage`, `Description`) VALUES (NULL, 'Document', '', '', '', '', '0', '', '');"); $Manager->Execute("INSERT INTO `PermissionOperation` (`Id`, `Module`, `Operation`, `Item`, `ItemId`) VALUES (NULL, '1', 'DisplayCustomerDocuments', '', '0');"); $Manager->Execute("INSERT INTO `PermissionGroupAssignment` (`Id`, `Group`, `AssignedGroup`, `AssignedOperation`) VALUES (NULL, '3', NULL, '52');"); $Manager->Execute('ALTER TABLE `File` ADD `Hash` VARCHAR(255) NOT NULL AFTER `Time`;'); $Manager->Execute("UPDATE `File` SET `Hash` = SHA1(CONCAT(Id,Name,Size,Time))"); $Manager->Execute("ALTER TABLE `Contract` ADD `Generate` INT NOT NULL DEFAULT '0' AFTER `File`;"); $Manager->Execute("ALTER TABLE `Contract` DROP `BillCodeText`;"); $Manager->Execute("INSERT INTO `FileDirectory` (`Id`, `Name`, `Parent`) VALUES (NULL, 'smlouvy', NULL);"); $Manager->Execute("ALTER TABLE `Log` CHANGE `Value` `Value` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;"); $Manager->Execute("INSERT INTO `PermissionOperation` (`Id`, `Module`, `Operation`, `Item`, `ItemId`) VALUES (NULL, '4', 'DownloadById', '', '0');"); $Manager->Execute("INSERT INTO `PermissionGroupAssignment` (`Id`, `Group`, `AssignedGroup`, `AssignedOperation`) VALUES (NULL, '4', NULL, '53');"); } function UpdateTo907(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE `AddressPlace` ( `Id` int(11) NOT NULL, `Town` varchar(255) NOT NULL, `Street` varchar(255) NOT NULL, `HouseNumber` int(11) NOT NULL, `HouseNumberType` int(11) NOT NULL, `Psc` int(11) NOT NULL, `RuianCode` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); $Manager->Execute('ALTER TABLE `AddressPlace` ADD PRIMARY KEY (`Id`);'); $Manager->Execute('ALTER TABLE `AddressPlace` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;'); $Manager->Execute('ALTER TABLE `Member` ADD `AddressPlace` INT NULL AFTER `Subject`;'); $Manager->Execute('ALTER TABLE `Member` ADD KEY (`AddressPlace`);'); $Manager->Execute('ALTER TABLE `Member` ADD FOREIGN KEY (`AddressPlace`) REFERENCES `AddressPlace`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); } function UpdateTo911(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `Remote` INT NOT NULL DEFAULT "0" AFTER `Device`;'); } function UpdateTo921(UpdateManager $Manager): void { $Manager->Execute('CREATE TABLE `NetworkMac` ( `Id` int(11) NOT NULL, `MAC` varchar(17) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); $Manager->Execute('ALTER TABLE `NetworkMac` ADD PRIMARY KEY (`Id`), ADD KEY `MAC` (`MAC`);'); $Manager->Execute('ALTER TABLE `NetworkMac` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;'); // Convert NetworkSignal MAC from string into reference $Manager->Execute('INSERT INTO `NetworkMac` (`MAC`) SELECT DISTINCT(`MAC`) FROM `NetworkSignal`;'); $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `MACTemp` INT NOT NULL AFTER `Remote`;'); $Manager->Execute('UPDATE `NetworkSignal` SET `MACTemp` = (SELECT `Id` FROM `NetworkMac` WHERE `NetworkMac`.`MAC` = `NetworkSignal`.`MAC`);'); $Manager->Execute('ALTER TABLE `NetworkSignal` DROP `MAC`;'); $Manager->Execute('ALTER TABLE `NetworkSignal` CHANGE `MACTemp` `MAC` INT(11) NOT NULL;'); $Manager->Execute('ALTER TABLE `NetworkSignal` ADD KEY `MAC` (`MAC`);'); $Manager->Execute('ALTER TABLE `NetworkSignal` ADD FOREIGN KEY (`MAC`) REFERENCES `NetworkMac`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); // IS menu item $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` , `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES ( NULL , "", "Fyzické adresy", "1", "/is/?t=NetworkMac&a=list", NULL , NULL , NULL , "1");'); $ActionId = $Manager->Database->insert_id; $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Síť"'); if ($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Fyzické adresy', ".$DbRow['Id'].", '".$ActionId."', '1');"); } } function UpdateTo933(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `PermissionGroup` ADD `SysName` VARCHAR(255) NULL DEFAULT "" AFTER `Description`;'); $Manager->Execute('UPDATE `PermissionGroup` SET `SysName`="admins" WHERE `Description`="Systémoví administrátoři"'); $Manager->Execute('UPDATE `PermissionGroup` SET `SysName`="network-admins" WHERE `Description`="Správci sítě"'); $Manager->Execute('UPDATE `PermissionGroup` SET `SysName`="registered-users" WHERE `Description`="Registrovaní uživatelé"'); $Manager->Execute('UPDATE `PermissionGroup` SET `SysName`="other-users" WHERE `Description`="Ostatní"'); $Manager->Execute('UPDATE `PermissionGroup` SET `SysName`="customers" WHERE `Description`="Zákazníci"'); } function UpdateTo939(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `Member` ADD `PaymentEmailTime` DATETIME NULL DEFAULT NULL AFTER `Contract`;'); $Manager->Execute('UPDATE `Member` SET `PaymentEmailTime`=DATE_SUB(`BillingPeriodLastDate`, INTERVAL 1 MONTH) WHERE BillingPeriod=2 AND BillingPeriodLastDate<>"0000-00-00"'); $Manager->Execute('UPDATE `Member` SET `PaymentEmailTime`=DATE_SUB(`BillingPeriodLastDate`, INTERVAL 3 MONTH) WHERE BillingPeriod=3 AND BillingPeriodLastDate<>"0000-00-00"'); $Manager->Execute('UPDATE `Member` SET `PaymentEmailTime`=DATE_SUB(`BillingPeriodLastDate`, INTERVAL 6 MONTH) WHERE BillingPeriod=4 AND BillingPeriodLastDate<>"0000-00-00"'); $Manager->Execute('UPDATE `Member` SET `PaymentEmailTime`=DATE_SUB(`BillingPeriodLastDate`, INTERVAL 12 MONTH) WHERE BillingPeriod=5 AND BillingPeriodLastDate<>"0000-00-00"'); $Manager->Execute('ALTER TABLE `UserOnline` ENGINE = InnoDB;'); } function UpdateTo948(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `News` CHANGE `IP` `IP` VARCHAR(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL;'); } function UpdateTo953(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `News` ADD `Intranet` INT NOT NULL DEFAULT "0" AFTER `Link`;'); } function UpdateTo957(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `Log` ADD `URL` VARCHAR(255) NOT NULL AFTER `IPAddress`;'); } function UpdateTo967(UpdateManager $Manager): void { $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Roční výkazy"'); if ($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); $Manager->Execute("INSERT INTO `Action` ( `Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` , `Enable`) VALUES (NULL , '', 'Měsíční přehled', '1', '/is/?t=FinanceMonthReport&a=list', NULL , NULL , NULL , '1' );"); $ActionId = $Manager->Database->insert_id; $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". "VALUES (NULL , 'Měsíční přehled', '".$DbRow['Id']."', '".$ActionId."', '1');"); } } function UpdateTo970(UpdateManager $Manager): void { $Manager->Execute('ALTER TABLE `Service` ADD `InternetSpeedBonus` INT NULL DEFAULT NULL AFTER `InternetSpeedMin`;'); } class Updates { function Get(): array { return array( 491 => array('Revision' => 493, 'Function' => 'UpdateTo493'), 493 => array('Revision' => 494, 'Function' => 'UpdateTo494'), 494 => array('Revision' => 495, 'Function' => 'UpdateTo495'), 495 => array('Revision' => 497, 'Function' => 'UpdateTo497'), 497 => array('Revision' => 498, 'Function' => 'UpdateTo498'), 498 => array('Revision' => 499, 'Function' => 'UpdateTo499'), 499 => array('Revision' => 500, 'Function' => 'UpdateTo500'), 500 => array('Revision' => 502, 'Function' => 'UpdateTo502'), 502 => array('Revision' => 505, 'Function' => 'UpdateTo505'), 505 => array('Revision' => 507, 'Function' => 'UpdateTo507'), 507 => array('Revision' => 515, 'Function' => 'UpdateTo515'), 515 => array('Revision' => 517, 'Function' => 'UpdateTo517'), 517 => array('Revision' => 526, 'Function' => 'UpdateTo526'), 526 => array('Revision' => 527, 'Function' => 'UpdateTo527'), 527 => array('Revision' => 535, 'Function' => 'UpdateTo535'), 535 => array('Revision' => 549, 'Function' => 'UpdateTo549'), 549 => array('Revision' => 550, 'Function' => 'UpdateTo550'), 550 => array('Revision' => 551, 'Function' => 'UpdateTo551'), 551 => array('Revision' => 565, 'Function' => 'UpdateTo565'), 565 => array('Revision' => 571, 'Function' => 'UpdateTo571'), 571 => array('Revision' => 574, 'Function' => 'UpdateTo574'), 574 => array('Revision' => 584, 'Function' => 'UpdateTo584'), 584 => array('Revision' => 591, 'Function' => 'UpdateTo591'), 591 => array('Revision' => 597, 'Function' => 'UpdateTo597'), 597 => array('Revision' => 601, 'Function' => 'UpdateTo601'), 601 => array('Revision' => 615, 'Function' => 'UpdateTo615'), 615 => array('Revision' => 619, 'Function' => 'UpdateTo619'), 619 => array('Revision' => 620, 'Function' => 'UpdateTo620'), 620 => array('Revision' => 627, 'Function' => 'UpdateTo627'), 627 => array('Revision' => 632, 'Function' => 'UpdateTo632'), 632 => array('Revision' => 633, 'Function' => 'UpdateTo633'), 633 => array('Revision' => 645, 'Function' => 'UpdateTo645'), 645 => array('Revision' => 646, 'Function' => 'UpdateTo646'), 646 => array('Revision' => 647, 'Function' => 'UpdateTo647'), 647 => array('Revision' => 657, 'Function' => 'UpdateTo657'), 657 => array('Revision' => 661, 'Function' => 'UpdateTo661'), 661 => array('Revision' => 662, 'Function' => 'UpdateTo662'), 662 => array('Revision' => 668, 'Function' => 'UpdateTo668'), 668 => array('Revision' => 671, 'Function' => 'UpdateTo671'), 671 => array('Revision' => 674, 'Function' => 'UpdateTo674'), 674 => array('Revision' => 676, 'Function' => 'UpdateTo676'), 676 => array('Revision' => 678, 'Function' => 'UpdateTo678'), 678 => array('Revision' => 679, 'Function' => 'UpdateTo679'), 679 => array('Revision' => 688, 'Function' => 'UpdateTo688'), 688 => array('Revision' => 692, 'Function' => 'UpdateTo692'), 692 => array('Revision' => 696, 'Function' => 'UpdateTo696'), 696 => array('Revision' => 697, 'Function' => 'UpdateTo697'), 697 => array('Revision' => 707, 'Function' => 'UpdateTo707'), 707 => array('Revision' => 710, 'Function' => 'UpdateTo710'), 710 => array('Revision' => 715, 'Function' => 'UpdateTo715'), 715 => array('Revision' => 718, 'Function' => 'UpdateTo718'), 718 => array('Revision' => 719, 'Function' => 'UpdateTo719'), 719 => array('Revision' => 720, 'Function' => 'UpdateTo720'), 720 => array('Revision' => 722, 'Function' => 'UpdateTo722'), 722 => array('Revision' => 725, 'Function' => 'UpdateTo725'), 725 => array('Revision' => 726, 'Function' => 'UpdateTo726'), 726 => array('Revision' => 729, 'Function' => 'UpdateTo729'), 729 => array('Revision' => 730, 'Function' => 'UpdateTo730'), 730 => array('Revision' => 731, 'Function' => 'UpdateTo731'), 731 => array('Revision' => 735, 'Function' => 'UpdateTo735'), 735 => array('Revision' => 736, 'Function' => 'UpdateTo736'), 736 => array('Revision' => 739, 'Function' => 'UpdateTo739'), 739 => array('Revision' => 740, 'Function' => 'UpdateTo740'), 740 => array('Revision' => 741, 'Function' => 'UpdateTo741'), 741 => array('Revision' => 742, 'Function' => 'UpdateTo742'), 742 => array('Revision' => 747, 'Function' => 'UpdateTo747'), 747 => array('Revision' => 748, 'Function' => 'UpdateTo748'), 748 => array('Revision' => 752, 'Function' => 'UpdateTo752'), 752 => array('Revision' => 755, 'Function' => 'UpdateTo755'), 755 => array('Revision' => 759, 'Function' => 'UpdateTo759'), 759 => array('Revision' => 762, 'Function' => 'UpdateTo762'), 762 => array('Revision' => 763, 'Function' => 'UpdateTo763'), 763 => array('Revision' => 765, 'Function' => 'UpdateTo765'), 765 => array('Revision' => 768, 'Function' => 'UpdateTo768'), 768 => array('Revision' => 770, 'Function' => 'UpdateTo770'), 770 => array('Revision' => 785, 'Function' => 'UpdateTo785'), 785 => array('Revision' => 786, 'Function' => 'UpdateTo786'), 786 => array('Revision' => 792, 'Function' => 'UpdateTo792'), 792 => array('Revision' => 800, 'Function' => 'UpdateTo800'), 800 => array('Revision' => 802, 'Function' => 'UpdateTo802'), 802 => array('Revision' => 803, 'Function' => 'UpdateTo803'), 803 => array('Revision' => 807, 'Function' => 'UpdateTo807'), 807 => array('Revision' => 808, 'Function' => 'UpdateTo808'), 808 => array('Revision' => 814, 'Function' => 'UpdateTo814'), 814 => array('Revision' => 817, 'Function' => 'UpdateTo817'), 817 => array('Revision' => 818, 'Function' => 'UpdateTo818'), 818 => array('Revision' => 824, 'Function' => 'UpdateTo824'), 824 => array('Revision' => 831, 'Function' => 'UpdateTo831'), 831 => array('Revision' => 838, 'Function' => 'UpdateTo838'), 838 => array('Revision' => 844, 'Function' => 'UpdateTo844'), 844 => array('Revision' => 855, 'Function' => 'UpdateTo855'), 855 => array('Revision' => 862, 'Function' => 'UpdateTo862'), 862 => array('Revision' => 867, 'Function' => 'UpdateTo867'), 867 => array('Revision' => 869, 'Function' => 'UpdateTo869'), 869 => array('Revision' => 870, 'Function' => 'UpdateTo870'), 870 => array('Revision' => 878, 'Function' => 'UpdateTo878'), 878 => array('Revision' => 880, 'Function' => 'UpdateTo880'), 880 => array('Revision' => 882, 'Function' => 'UpdateTo882'), 882 => array('Revision' => 885, 'Function' => 'UpdateTo885'), 885 => array('Revision' => 901, 'Function' => 'UpdateTo901'), 901 => array('Revision' => 907, 'Function' => 'UpdateTo907'), 907 => array('Revision' => 911, 'Function' => 'UpdateTo911'), 911 => array('Revision' => 921, 'Function' => 'UpdateTo921'), 921 => array('Revision' => 933, 'Function' => 'UpdateTo933'), 933 => array('Revision' => 939, 'Function' => 'UpdateTo939'), 939 => array('Revision' => 948, 'Function' => 'UpdateTo948'), 948 => array('Revision' => 953, 'Function' => 'UpdateTo953'), 953 => array('Revision' => 957, 'Function' => 'UpdateTo957'), 957 => array('Revision' => 967, 'Function' => 'UpdateTo967'), 967 => array('Revision' => 970, 'Function' => 'UpdateTo970'), ); } }