source: trunk/Application/UpdateTrace.php

Last change on this file was 970, checked in by chronos, 5 months ago
  • Modified: Service internet speed min and max used as contracted speeds. Real speed will be calculated with bonus speed and further queues calculations.
  • Added: Bonus internet speed service field.
  • Modified: Few PHP 8.3 fixes.
File size: 119.7 KB
Line 
1<?php
2
3function UpdateTo493(UpdateManager $Manager): void
4{
5 $Manager->Execute("ALTER TABLE `UserOnline` CHANGE `User` `User` INT( 11 ) NULL DEFAULT NULL COMMENT 'User.Id'");
6}
7
8function UpdateTo494(UpdateManager $Manager): void
9{
10 $Manager->Execute("ALTER TABLE `FinanceOperation` DROP FOREIGN KEY `FinanceOperation_ibfk_2` ;\n".
11 "ALTER TABLE `FinanceOperation` CHANGE `Bill` `File` INT( 11 ) NULL DEFAULT NULL;\n".
12 "ALTER TABLE `FinanceOperation` ADD FOREIGN KEY ( `File` ) REFERENCES `File` (`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
13}
14
15function UpdateTo495(UpdateManager $Manager): void
16{
17 $Manager->Execute("INSERT INTO `MapPosition` (SELECT NULL AS `Id`, `Name`, `MapPositionX` AS `Latitude`, `MapPositionY` AS `Longitude` FROM `Subject`)");
18 $Manager->Execute("ALTER TABLE `Subject` ADD `MapPosition` INT NULL AFTER `PayVAT`");
19 $Manager->Execute("UPDATE `Subject` SET `MapPosition` = (SELECT `MapPosition`.`Id` FROM `MapPosition` WHERE `MapPosition`.`Name` = `Subject`.`Name` LIMIT 1)");
20 $Manager->Execute("ALTER TABLE `Subject` DROP `MapPositionX`, DROP `MapPositionY`;");
21 $Manager->Execute("ALTER TABLE `Subject` ADD INDEX ( `MapPosition` ) ");
22 $Manager->Execute("ALTER TABLE `Subject` ADD FOREIGN KEY ( `MapPosition` ) REFERENCES `MapPosition` (".
23 "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
24}
25
26function UpdateTo497(UpdateManager $Manager): void
27{
28 $Manager->Execute("ALTER TABLE `FinanceCharge` ADD `Id` INT NOT NULL AUTO_INCREMENT FIRST , ADD PRIMARY KEY ( `Id` ) ");
29 $Manager->Execute("ALTER TABLE `FinanceCharge` ADD `ReplaceId` INT NULL ,ADD INDEX ( `ReplaceId` ) ");
30 $Manager->Execute("DELETE FROM `FinanceCharge` WHERE `FinanceCharge`.`Period` = 1");
31 $Manager->Execute("ALTER TABLE `FinanceCharge` DROP `Period`");
32 $Manager->Execute("ALTER TABLE `FinanceCharge` ADD `Action` ENUM( 'add', 'modify', 'remove' ) NULL AFTER `TopTariffPrice` ");
33 $Manager->Execute("ALTER TABLE `FinanceCharge` ADD FOREIGN KEY ( `ReplaceId` ) REFERENCES `FinanceCharge` (".
34 "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
35 $Manager->Execute("ALTER TABLE `FinanceCharge` ADD INDEX ( `Action` )");
36 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
37 "VALUES (NULL , 'Parametry účtování', '2', 'FinanceCharge', '');");
38 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
39 "VALUES (NULL , 'Úseky sítě', '2', 'NetworkSegment', '');");
40 $Manager->Execute("ALTER TABLE `ServiceCustomerRel` ADD `Action` ENUM( 'add', 'modify', 'remove' ) NULL , ".
41 "ADD `ReplaceId` INT NULL");
42 $Manager->Execute("DELETE FROM `ServiceCustomerRel` WHERE `Period`=1");
43 $Manager->Execute("ALTER TABLE `ServiceCustomerRel` DROP `Period`");
44 $Manager->Execute("ALTER TABLE `ServiceCustomerRel` ADD INDEX ( `Action` )");
45 $Manager->Execute("ALTER TABLE `ServiceCustomerRel` ADD INDEX ( `ReplaceId` ) ");
46 $Manager->Execute("ALTER TABLE `ServiceCustomerRel` ADD FOREIGN KEY ( `ReplaceId` ) REFERENCES `ServiceCustomerRel` (".
47 "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
48 $Manager->Execute("ALTER TABLE `Service` ADD `Action` ENUM( 'add', 'modify', 'remove' ) NULL AFTER `CustomerCount`");
49 $Manager->Execute("ALTER TABLE `Service` ADD INDEX ( `Action` )");
50 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
51 "VALUES (NULL , 'Placení zákazníků', '2', 'MemberPayment', '');");
52}
53
54function UpdateTo498(UpdateManager $Manager): void
55{
56 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
57 "VALUES (NULL , 'Síťové služby', '1', 'NetworkConfiguration', '');");
58 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
59 "VALUES (NULL , 'Fronta e-mailů', '23', 'EmailQueue', '');");
60 $Manager->Execute("CREATE TABLE IF NOT EXISTS `FinanceVAT` (
61 `Id` int(11) NOT NULL AUTO_INCREMENT,
62 `Name` varchar(255) NOT NULL,
63 `ValidFrom` date NOT NULL,
64 `Value` int(11) NOT NULL,
65 PRIMARY KEY (`Id`)
66) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
67INSERT INTO `FinanceVAT` (`Id`, `Name`, `ValidFrom`, `Value`) VALUES
68(1, 'DPH snížená sazba', '2013-01-01', 15),
69(2, 'DPH běžná sazba', '2013-01-01', 21);");
70 $Manager->Execute("ALTER TABLE `Service` ADD `VAT` INT NOT NULL AFTER `Price`");
71 $Manager->Execute("ALTER TABLE `Service` ADD INDEX ( `VAT` ) ");
72 $Manager->Execute("UPDATE `Service` SET `VAT` = 2;");
73 $Manager->Execute("ALTER TABLE `Service` ADD FOREIGN KEY ( `VAT` ) REFERENCES `FinanceVAT` (".
74 "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
75 $Manager->Execute("ALTER TABLE `FinanceInvoice` ADD `Cash` INT NOT NULL DEFAULT '0'");
76}
77
78function UpdateTo499(UpdateManager $Manager): void
79{
80 $Manager->Execute("CREATE TABLE IF NOT EXISTS `Currency` (
81 `Id` int(11) NOT NULL AUTO_INCREMENT,
82 `Code` varchar(3) NOT NULL,
83 `Name` varchar(255) NOT NULL,
84 `Symbol` varchar(255) NOT NULL,
85 PRIMARY KEY (`Id`)
86) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
87
88INSERT INTO `Currency` (`Id`, `Code`, `Name`, `Symbol`) VALUES
89(1, 'CZK', 'Česká koruna', 'Kč'),
90(2, 'EUR', 'Euro', '€'),
91(3, 'USD', 'Americký dolar', '$'),
92(4, 'CNY', 'Čínský jüan', '¥');");
93 $Manager->Execute("CREATE TABLE IF NOT EXISTS `FinanceBankImport` (
94 `Id` int(11) NOT NULL AUTO_INCREMENT,
95 `BankAccount` int(11) NOT NULL,
96 `Time` date NOT NULL,
97 `Identification` varchar(255) NOT NULL,
98 `AccountNumber` varchar(255) NOT NULL,
99 `VariableSymbol` varchar(255) NOT NULL,
100 `ConstantSymbol` varchar(255) NOT NULL,
101 `SpecificSymbol` varchar(255) NOT NULL,
102 `Value` decimal(10,0) NOT NULL,
103 `Currency` int(11) NOT NULL,
104 `Description` varchar(255) NOT NULL,
105 `OffsetAccountName` varchar(255) NOT NULL,
106 `FinanceOperation` int(11) DEFAULT NULL,
107 PRIMARY KEY (`Id`),
108 KEY `FinanceOperation` (`FinanceOperation`),
109 KEY `Currency` (`Currency`),
110 KEY `BankAccount` (`BankAccount`)
111) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
112
113ALTER TABLE `FinanceBankImport`
114 ADD CONSTRAINT `FinanceBankImport_ibfk_3` FOREIGN KEY (`FinanceOperation`) REFERENCES `FinanceOperation` (`Id`),
115 ADD CONSTRAINT `FinanceBankImport_ibfk_1` FOREIGN KEY (`BankAccount`) REFERENCES `FinanceBankAccount` (`Id`),
116 ADD CONSTRAINT `FinanceBankImport_ibfk_2` FOREIGN KEY (`Currency`) REFERENCES `Currency` (`Id`);");
117 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`)".
118 "VALUES (NULL , 'Měny', '2', 'Currency', '');");
119 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
120 "VALUES (NULL , 'Import z účtu', '2', 'FinanceBankImport', '');");
121}
122
123function UpdateTo500(UpdateManager $Manager): void
124{
125 $Manager->Execute("CREATE TABLE IF NOT EXISTS `FinanceBank` (
126 `Id` int(11) NOT NULL AUTO_INCREMENT,
127 `Name` varchar(255) NOT NULL,
128 `Code` varchar(4) NOT NULL,
129 `BIC` varchar(255) NOT NULL,
130 `Country` int(11) NOT NULL,
131 PRIMARY KEY (`Id`),
132 KEY `Country` (`Country`)
133) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
134 $Manager->Execute("ALTER TABLE `FinanceBank`
135 ADD CONSTRAINT `FinanceBank_ibfk_1` FOREIGN KEY (`Country`) REFERENCES `Country` (`Id`);");
136 $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD `Bank` INT NOT NULL AFTER `Number` ,".
137 " ADD INDEX ( `Bank` )");
138 $Manager->Execute("INSERT INTO `FinanceBank` (`Id`, `Name`, `Code`, `BIC`, `Country`) VALUES
139 (1, 'Neznámá banka', '', '', 1);");
140 $Manager->Execute("UPDATE `FinanceBankAccount` SET `Bank` = 1 WHERE `Bank` = 0");
141 $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD FOREIGN KEY ( `Bank` ) REFERENCES `FinanceBank` (".
142 "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
143 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
144 "VALUES (NULL , 'Banky', '2', 'FinanceBank', '');");
145}
146
147function UpdateTo502(UpdateManager $Manager): void
148{
149 $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD `LoginName` VARCHAR( 255 ) NOT NULL ");
150 $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD `LoginPassword` VARCHAR( 255 ) NOT NULL");
151 $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD `Currency` INT NOT NULL AFTER `Use` ,".
152 "ADD INDEX ( `Currency` ) ");
153 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
154 "VALUES (NULL , 'Banka', '2', '', '');");
155 $Id = $Manager->Database->insert_id;
156 $Manager->Execute("UPDATE `ISMenuItem` SET `Parent` = '".$Id."' WHERE `ISMenuItem`.`Id` ='Bankovní účty'; ".
157 "UPDATE `ISMenuItem` SET `Parent` = '".$Id."' WHERE `ISMenuItem`.`Id` ='Import z účtu';".
158 "UPDATE `ISMenuItem` SET `Parent` = '".$Id."' WHERE `ISMenuItem`.`Name` ='Banky';");
159}
160
161function UpdateTo505(UpdateManager $Manager): void
162{
163 $Manager->Execute("UPDATE `ISMenuItem` SET `Name` = 'Služby', `Table` = 'Service' WHERE `ISMenuItem`.`Name` ='Tarify';");
164 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
165 "VALUES (NULL , 'Kategorie služeb', '2', 'ServiceCategory', '');");
166 $Manager->Execute("CREATE TABLE IF NOT EXISTS `NetworkShareItem` (
167 `Id` int(11) NOT NULL AUTO_INCREMENT,
168 `Name` varchar(255) NOT NULL DEFAULT '',
169 `Parent` int(11) NOT NULL DEFAULT '0',
170 `Host` int(11) NOT NULL DEFAULT '0',
171 `Size` bigint(20) NOT NULL DEFAULT '0',
172 `Ext` varchar(64) NOT NULL DEFAULT '',
173 `Date` date NOT NULL DEFAULT '0000-00-00',
174 `Type` int(11) NOT NULL DEFAULT '0',
175 PRIMARY KEY (`Id`),
176 KEY `Parent` (`Parent`),
177 KEY `Search` (`Name`,`Size`),
178 KEY `Name` (`Name`)
179) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
180 $Manager->Execute("CREATE TABLE IF NOT EXISTS `NetworkShareError` (
181 `Id` int(11) NOT NULL AUTO_INCREMENT,
182 `Host` varchar(16) NOT NULL DEFAULT '',
183 `Message` varchar(255) NOT NULL DEFAULT '',
184 PRIMARY KEY (`Id`)
185) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
186}
187
188function UpdateTo507(UpdateManager $Manager): void
189{
190 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
191 "VALUES (NULL , 'Aktuality', NULL, '', '');");
192 $Id = $Manager->Database->insert_id;
193 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
194 "VALUES (NULL , 'Aktuality', '".$Id."', 'News', '');");
195 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
196 "VALUES (NULL , 'Kategorie aktualit', '".$Id."', 'NewsCategory', '');");
197 $Manager->Execute("INSERT INTO `FileDirectory` (`Id` ,`Name` ,`Parent`".
198 ") VALUES (NULL , 'news', NULL);");
199 $Manager->Execute("ALTER TABLE `File` ADD `Time` DATETIME NOT NULL ");
200 // Convert Hire column to Service item
201 $Manager->Execute("INSERT INTO `ServiceCategory` (
202`Id` ,`Name`) VALUES (NULL , 'Pevný nájem');");
203 $ServiceCategoryHire = $Manager->Database->insert_id;
204 $DbResult = $Manager->Execute("SELECT * FROM Member WHERE Hire>0");
205 while ($Member = $DbResult->fetch_assoc())
206 {
207 $Manager->Execute("INSERT INTO `Service` (
208`Id` ,`Name` ,`Category` ,`Price` ,`VAT` ,`CustomerCount` ,`Action` ,`ReplaceId` ,
209`Public` ,`InternetSpeedMin` ,`InternetSpeedMax` ,`UploadAsymmetry` ,`Memory` ,`MemorySwap` ,`Storage` ,`CPUCount`)
210VALUES (
211NULL , 'Nájem', '".$ServiceCategoryHire."', '-".$Member['Hire']."', '2', '', NULL , NULL , '', '', '', '', '', '', '', ''
212);");
213 $ServiceHire = $Manager->Database->insert_id;
214 $Manager->Execute("INSERT INTO `ServiceCustomerRel` (`Service`, `Customer`) VALUES ".
215 "(".$ServiceHire.",".$Member['Id'].")");
216 }
217 $Manager->Execute("ALTER TABLE `Member` DROP `Hire`");
218 // Each device and subnet have to be assigned to payed service to determine service parameters
219 $Manager->Execute("ALTER TABLE `NetworkDevice` ADD `Service` INT NULL AFTER `Location` ,
220ADD INDEX ( `Service` )");
221 $Manager->Execute("ALTER TABLE `NetworkDevice` ADD FOREIGN KEY ( `Service` ) REFERENCES `ServiceCustomerRel` (
222`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
223 $Manager->Execute("UPDATE `NetworkDevice` SET `Service` = (SELECT `Id` FROM `ServiceCustomerRel` WHERE `ServiceCustomerRel`.`Customer` = `NetworkDevice`.`Member` LIMIT 1)");
224 $Manager->Execute("ALTER TABLE `NetworkSubnet` ADD `Service` INT NULL AFTER `Member` ,
225ADD INDEX ( `Service` ) ");
226 $Manager->Execute("ALTER TABLE `NetworkSubnet` ADD FOREIGN KEY ( `Service` ) REFERENCES `ServiceCustomerRel` (
227`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
228 $Manager->Execute("UPDATE `NetworkSubnet` SET `Service` = (SELECT `Id` FROM `ServiceCustomerRel` WHERE `ServiceCustomerRel`.`Customer` = `NetworkSubnet`.`Member` LIMIT 1)");
229}
230
231function UpdateTo515(UpdateManager $Manager): void
232{
233 $Manager->Execute("ALTER TABLE `PermissionUserAssignment` CHANGE `User` `User` INT( 11 ) NULL");
234}
235
236function UpdateTo517(UpdateManager $Manager): void
237{
238 $Manager->Execute("ALTER TABLE `Log` ADD `IPAddress` VARCHAR( 16 ) NOT NULL");
239}
240
241function UpdateTo526(UpdateManager $Manager): void
242{
243 $Manager->Execute("ALTER TABLE `Hyperlink` CHANGE `Name` `Title` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL");
244 $Manager->Execute("ALTER TABLE `Hyperlink` ADD `Name` VARCHAR( 255 ) NOT NULL AFTER `Id`");
245 //$Manager->Execute("ALTER TABLE `Hyperlink` ADD UNIQUE ( `Name` )");
246 $Manager->Execute("ALTER TABLE `Hyperlink` ADD `Type` INT NOT NULL AFTER `Title` , ADD INDEX ( `Type` )");
247 $Manager->Execute("RENAME TABLE `Hyperlink` TO `Action` ;");
248 $Manager->Execute("RENAME TABLE `HyperlinkGroup` TO `ActionGroup` ;");
249 $Manager->Execute("CREATE TABLE IF NOT EXISTS `ActionType` (
250 `Id` int(11) NOT NULL AUTO_INCREMENT,
251 `Name` varchar(255) NOT NULL,
252 PRIMARY KEY (`Id`)
253 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
254
255 INSERT INTO `ActionType` (`Id`, `Name`) VALUES
256 (1, 'Odkaz'),
257 (2, 'Obrázek');");
258 $Manager->Execute("UPDATE `Action` SET `Type` = 1;");
259 $Manager->Execute("ALTER TABLE `Action` ADD FOREIGN KEY ( `Type` ) REFERENCES `ActionType` (".
260 "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
261 $Manager->Execute("UPDATE `Panel` SET `Module` = 'ActionGroup' WHERE `Module` = 'HyperlinkGroup'");
262 $Manager->Execute("CREATE TABLE IF NOT EXISTS `ActionIcon` (
263 `Id` int(11) NOT NULL AUTO_INCREMENT,
264 `Name` varchar(255) NOT NULL,
265 PRIMARY KEY (`Id`)
266) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
267 $Manager->Execute("INSERT INTO `ActionIcon` (SELECT NULL AS `Id`, `IconFile` AS `Name` FROM `Action` WHERE `IconFile` != '' GROUP BY `IconFile`)");
268 $Manager->Execute("ALTER TABLE `Action` CHANGE `IconFile` `IconFile` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
269 $Manager->Execute("UPDATE `Action` SET `IconFile` = (SELECT `Id` FROM `ActionIcon` WHERE `ActionIcon`.`Name` = `Action`.`IconFile`) ");
270 $Manager->Execute("ALTER TABLE `Action` CHANGE `IconFile` `Icon` INT NULL ");
271 $Manager->Execute("UPDATE `Action` SET `Icon` = NULL WHERE `Icon` = 0");
272 $Manager->Execute("ALTER TABLE `Action` ADD INDEX ( `Icon` ) ");
273 $Manager->Execute("ALTER TABLE `Action` ADD FOREIGN KEY ( `Icon` ) REFERENCES `ActionIcon` (`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
274 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
275 "VALUES (NULL , 'Akce', '23', 'Action', '');");
276}
277
278function UpdateTo527(UpdateManager $Manager): void
279{
280 $Manager->Execute("RENAME TABLE `ISMenuItem` TO `MenuItem` ;");
281 $Manager->Execute("CREATE TABLE IF NOT EXISTS `Menu` (
282 `Id` int(11) NOT NULL AUTO_INCREMENT,
283 `Name` varchar(255) NOT NULL,
284 PRIMARY KEY (`Id`)
285) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
286 $Manager->Execute("INSERT INTO `Menu` (`Id` ,`Name`)VALUES (NULL , 'IS');");
287 $Manager->Execute("ALTER TABLE `MenuItem` ADD `Menu` INT NOT NULL , ADD INDEX ( `Menu` )");
288 $Manager->Execute("UPDATE `MenuItem` SET `Menu` = 1");
289 $Manager->Execute("ALTER TABLE `MenuItem` ADD FOREIGN KEY ( `Menu` ) REFERENCES `Menu` (".
290 "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
291 $Manager->Execute("ALTER TABLE `Action` CHANGE `Group` `Group` INT( 11 ) NULL ");
292 $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)");
293 $Manager->Execute("ALTER TABLE `MenuItem` DROP `IconName`");
294 $Manager->Execute("UPDATE `MenuItem` SET `Table` = (SELECT `Id` FROM `Action` WHERE `Action`.`URL` = CONCAT('/is/?t=', `MenuItem`.`Table`, '&a=list')) WHERE `MenuItem`.`Table` != ''");
295 $Manager->Execute("ALTER TABLE `MenuItem` CHANGE `Table` `Action` INT NULL");
296 $Manager->Execute("UPDATE `MenuItem` SET `Action` = NULL WHERE `Action` = 0");
297 $Manager->Execute("ALTER TABLE `MenuItem` ADD INDEX ( `Action` ) ");
298 $Manager->Execute("ALTER TABLE `MenuItem` ADD FOREIGN KEY ( `Action` ) REFERENCES `Action` (`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
299 $Manager->Execute("INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionModule` ,`PermissionOperation` ,`Enable`)".
300 "VALUES (NULL , '', 'Nabídky', '1', '/is/?t=Menu&a=list', NULL , NULL , '', '', '1');");
301 $ActionId = $Manager->Database->insert_id;
302 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
303 "VALUES (NULL , 'Nabídky', '23', '".$ActionId."', '1');");
304}
305
306function UpdateTo535(UpdateManager $Manager): void
307{
308 // Set all string collation to utf8 general
309 $DbResult = $Manager->Execute("SHOW TABLES");
310 while ($DbRow = $DbResult->fetch_row())
311 {
312 $Manager->Execute("ALTER TABLE `".$DbRow[0]."` CONVERT TO CHARACTER SET utf8");
313 }
314}
315
316function UpdateTo549(UpdateManager $Manager): void
317{
318 $Manager->Execute("ALTER TABLE `FinanceOperation` ADD `Generate` INT NOT NULL DEFAULT '0',
319ADD INDEX ( `Generate` ) ;");
320 $Manager->Execute("ALTER TABLE `FinanceInvoice` ADD `Generate` INT NOT NULL DEFAULT '0',
321ADD INDEX ( `Generate` ) ;");
322}
323
324function UpdateTo550(UpdateManager $Manager): void
325{
326 $Manager->Execute('ALTER TABLE `FinanceBankAccount` ADD `LastImportId` VARCHAR( 255 ) NOT NULL ;');
327 $Manager->Execute('ALTER TABLE `FinanceBankAccount` ADD `LastImportDate` DATE NULL ;');
328 $Manager->Execute('ALTER TABLE `FinanceBankImport` ADD `BankCode` VARCHAR( 255 ) NOT NULL AFTER `AccountNumber` ;');
329}
330
331function UpdateTo551(UpdateManager $Manager): void
332{
333 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `DocumentLine` INT NULL AFTER `Value` ,
334ADD INDEX ( `DocumentLine` ) ;');
335 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD FOREIGN KEY ( `DocumentLine` ) REFERENCES `DocumentLine` (
336`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;');
337 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `DocumentLine` INT NULL AFTER `Id` ,
338ADD INDEX ( `DocumentLine` ) ;');
339 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD FOREIGN KEY ( `DocumentLine` ) REFERENCES `DocumentLine` (
340`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;');
341 $Manager->Execute('DROP TABLE `FinanceBillsItemsOld`');
342 $Manager->Execute('DROP TABLE `FinanceBillsOld`');
343}
344
345function UpdateTo565(UpdateManager $Manager): void
346{
347 $Manager->Execute('CREATE TABLE IF NOT EXISTS `WikiPage` (
348 `Id` int(11) NOT NULL AUTO_INCREMENT,
349 `Name` varchar(255) NOT NULL,
350 `NormalizedName` varchar(255) NOT NULL,
351 `VisibleInMenu` int(11) NOT NULL,
352 PRIMARY KEY (`Id`),
353 UNIQUE KEY `Name` (`Name`),
354 KEY `VisibleInMenu` (`VisibleInMenu`)
355 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
356 $Manager->Execute('CREATE TABLE IF NOT EXISTS `WikiPageContent` (
357 `Id` int(11) NOT NULL AUTO_INCREMENT,
358 `Page` int(11) NOT NULL,
359 `Time` datetime NOT NULL,
360 `Content` text NOT NULL,
361 `User` int(11) NOT NULL,
362 PRIMARY KEY (`Id`),
363 KEY `User` (`User`),
364 KEY `Page` (`Page`)
365 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
366 $Manager->Execute('ALTER TABLE `WikiPageContent`
367 ADD CONSTRAINT `WikiPageContent_ibfk_2` FOREIGN KEY (`Page`) REFERENCES `WikiPage` (`Id`),
368ADD CONSTRAINT `WikiPageContent_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`ID`);');
369}
370
371function UpdateTo571(UpdateManager $Manager): void
372{
373 $Manager->Execute('ALTER TABLE `NetworkDevice` ADD `LoginName` VARCHAR( 255 ) NOT NULL ,
374ADD `LoginPassword` VARCHAR( 255 ) NOT NULL ;');
375}
376
377function UpdateTo574(UpdateManager $Manager): void
378{
379 $Manager->Execute('ALTER TABLE `MapPosition` ADD `Pos` VARCHAR( 255 ) NOT NULL ;');
380 $Manager->Execute('UPDATE `MapPosition` SET `Pos`=CONCAT(`Latitude`, ";", `Longitude`)');
381 $Manager->Execute('ALTER TABLE `MapPosition` DROP `Latitude`');
382 $Manager->Execute('ALTER TABLE `MapPosition` DROP `Longitude`');
383}
384
385function UpdateTo584(UpdateManager $Manager): void
386{
387 $Manager->Execute("CREATE TABLE IF NOT EXISTS `Module` (
388 `Id` int(11) NOT NULL AUTO_INCREMENT,
389 `Name` varchar(255) NOT NULL,
390 `Title` varchar(255) NOT NULL,
391 PRIMARY KEY (`Id`)
392 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=33 ;");
393
394 $Manager->Execute("INSERT INTO `Module` (`Id`, `Name`, `Title`) VALUES
395 (1, 'Customer', 'Zákazník'),
396 (2, 'EmailQueue', 'Fronta emailů'),
397 (3, 'Error', 'Obsluha chyb'),
398 (4, 'File', 'Správa souborů'),
399 (5, 'Finance', 'Finance'),
400 (6, 'FinanceBankAPI', 'Rozhraní pro bankovní účty'),
401 (7, 'Chat', 'Pokec'),
402 (8, 'IS', 'Informační systém'),
403 (9, 'Log', 'Záznam událostí'),
404 (10, 'Map', 'Mapa'),
405 (11, 'Meals', 'Jídelníček'),
406 (12, 'Meteostation', 'Meteostanice'),
407 (13, 'Network', 'Síť'),
408 (14, 'NetworkConfig', 'Nastavení sítě'),
409 (15, 'NetworkConfigLinux', 'Nastavení linuxových zařízení'),
410 (16, 'NetworkConfigRouterOS', 'Nastavení RouterOS zařízení'),
411 (17, 'NetworkShare', 'Síťové sdílení'),
412 (18, 'NetworkTopology', 'Síťová topologie'),
413 (19, 'News', 'Aktuality'),
414 (20, 'OpeningHours', 'Otvírací doby'),
415 (21, 'Portal', 'Portál'),
416 (22, 'Search', 'Vyhledávání'),
417 (23, 'Setup', 'Instalace systému'),
418 (24, 'SpeedTest', 'Měření rychlosti'),
419 (25, 'Stock', 'Sklad'),
420 (26, 'System', 'Systém'),
421 (27, 'Task', 'Úlohy'),
422 (28, 'TimeMeasure', 'Časové průběhy'),
423 (29, 'TV', 'Televize'),
424 (30, 'User', 'Uživatelé'),
425 (31, 'WebCam', 'Web kamery'),
426 (32, 'Wiki', 'Wiki');");
427 $Manager->Execute("UPDATE `PermissionOperation` SET `Module` = 'Meals' WHERE `PermissionOperation`.`Module` ='EatingPlace';");
428 $Manager->Execute("UPDATE `PermissionOperation` SET `Module` = 'NetworkShare' WHERE `PermissionOperation`.`Module` ='Share';");
429 $Manager->Execute("UPDATE `PermissionOperation` SET `Module` = 'OpeningHours' WHERE `PermissionOperation`.`Module` ='SubjectOpenTime';");
430 $Manager->Execute("UPDATE `PermissionOperation` SET `Module`=(SELECT `Id` FROM `Module` WHERE `Module`.`Name` = `PermissionOperation`.`Module`)");
431 $Manager->Execute("ALTER TABLE `PermissionOperation` CHANGE `Module` `Module` INT( 11 ) NOT NULL ;");
432 $Manager->Execute("ALTER TABLE `PermissionOperation` ADD FOREIGN KEY ( `Module` ) REFERENCES `Module` (
433`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
434 $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`))");
435 $Manager->Execute("ALTER TABLE `Action` CHANGE `PermissionOperation` `PermissionOperation` INT( 11 ) NULL ;");
436 $Manager->Execute("ALTER TABLE `Action` DROP `PermissionModule` ;");
437 $Manager->Execute("UPDATE `Action` SET `PermissionOperation`=NULL WHERE `PermissionOperation`=0");
438 $Manager->Execute("ALTER TABLE `Action` ADD INDEX (`PermissionOperation`);");
439 $Manager->Execute("ALTER TABLE `Action` ADD FOREIGN KEY ( `PermissionOperation` ) REFERENCES `PermissionOperation` (
440`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
441}
442
443function UpdateTo591(UpdateManager $Manager): void
444{
445 $Manager->Execute('ALTER TABLE `StockItem` ADD `Esemble` INT NULL ,
446ADD INDEX ( `Esemble` ) ;');
447 $Manager->Execute('ALTER TABLE `StockItem` ADD FOREIGN KEY ( `Esemble` ) REFERENCES `StockItem` (
448`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;');
449}
450
451function UpdateTo597(UpdateManager $Manager): void
452{
453 $Manager->Execute('CREATE TABLE IF NOT EXISTS `Model` (
454 `Id` int(11) NOT NULL AUTO_INCREMENT,
455 `Name` varchar(255) NOT NULL,
456 `Module` int(11) NOT NULL,
457 PRIMARY KEY (`Id`),
458 KEY `Module` (`Module`)
459) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
460
461 $Manager->Execute('ALTER TABLE `Model`
462 ADD CONSTRAINT `Model_ibfk_1` FOREIGN KEY (`Module`) REFERENCES `Module` (`Id`);');
463}
464
465function UpdateTo601(UpdateManager $Manager): void
466{
467 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkInterfaceWireless` (
468 `Id` int(11) NOT NULL AUTO_INCREMENT,
469 `NetworkInterface` int(11) NOT NULL,
470 `TxPower` int(11) NOT NULL,
471 `CableAttenuation` int(11) NOT NULL,
472 `AntenaGain` int(11) NOT NULL,
473 `Frequency` float NOT NULL,
474 `ChannelWidth` int(11) NOT NULL,
475 `SSID` varchar(255) NOT NULL,
476 PRIMARY KEY (`Id`),
477 KEY `NetworkInterface` (`NetworkInterface`)
478) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
479
480 $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless`
481 ADD CONSTRAINT `NetworkInterfaceWireless_ibfk_1` FOREIGN KEY (`NetworkInterface`) REFERENCES `NetworkInterface` (`Id`);');
482 $Manager->Execute("INSERT INTO `Action` (
483`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` ,
484`Enable`) VALUES (NULL , '', 'Wifi rozhraní', '1', '/is/?t=NetworkInterfaceWireless&a=list', NULL , NULL , NULL , '1'
485);");
486 $ActionId = $Manager->Database->insert_id;
487 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
488 "VALUES (NULL , 'Bezdrátové rozhraní', '1', '".$ActionId."', '1');");
489}
490
491function UpdateTo615(UpdateManager $Manager): void
492{
493 $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `AntennaPolarity` INT NOT NULL ,
494ADD `Description` VARCHAR( 255 ) NOT NULL ;');
495 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NewsImport` (
496 `Id` int(11) NOT NULL,
497 `Name` varchar(255) NOT NULL,
498 `Enabled` int(11) NOT NULL,
499 `Source` varchar(255) NOT NULL,
500 `Category` int(11) NOT NULL,
501 `BlockStart` varchar(255) NOT NULL,
502 `BlockEnd` varchar(255) NOT NULL,
503 `ItemStart` varchar(255) NOT NULL,
504 `ItemEnd` varchar(255) NOT NULL,
505 `TitleStart` varchar(255) NOT NULL,
506 `TitleEnd` varchar(255) NOT NULL,
507 `ContentStart` varchar(255) NOT NULL,
508 `ContentEnd` varchar(255) NOT NULL,
509 `LinkStart` varchar(255) NOT NULL,
510 `LinkEnd` varchar(255) NOT NULL,
511 `DateStart` varchar(255) NOT NULL,
512 `DateEnd` varchar(255) NOT NULL,
513 KEY `Category` (`Category`)
514) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
515 $Manager->Execute('ALTER TABLE `NewsImport` '.
516 'ADD CONSTRAINT `NewsImport_ibfk_1` FOREIGN KEY (`Category`) '.
517 ' REFERENCES `NewsCategory` (`Id`);');
518 $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `Antenna` INT NULL AFTER `AntennaPolarity` ,
519ADD INDEX ( `Product` ) ;');
520 $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD FOREIGN KEY ( `Antenna` ) REFERENCES `Product` (
521`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;');
522 $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `MAC` VARCHAR( 17 ) NOT NULL ;');
523}
524
525function UpdateTo619(UpdateManager $Manager): void
526{
527 $Manager->Execute('ALTER TABLE `UserOnline` ADD `StayLogged` INT NOT NULL ;');
528}
529
530function UpdateTo620(UpdateManager $Manager): void
531{
532 $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `ChannelWidthLower` INT NOT NULL ,
533ADD `ChannelWidthUpper` INT NOT NULL ;');
534 $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `Mode` INT NOT NULL ;');
535 $Manager->Execute('DROP TABLE `NetworkAP`');
536}
537
538function UpdateTo627(UpdateManager $Manager): void
539{
540 $Manager->Execute('ALTER TABLE `FinanceInvoice` CHANGE `TimeCreation` `Time` DATETIME NOT NULL DEFAULT "0000-00-00 00:00:00";');
541 $Manager->Execute('ALTER TABLE `FinanceYear` ADD `Closed` INT NOT NULL ;');
542}
543
544function UpdateTo632(UpdateManager $Manager): void
545{
546 $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceInvoiceOperationRel` (
547 `Id` int(11) NOT NULL AUTO_INCREMENT,
548 `Invoice` int(11) NOT NULL,
549 `Operation` int(11) NOT NULL,
550 PRIMARY KEY (`Id`),
551 KEY `Invoice` (`Invoice`),
552 KEY `Operation` (`Operation`)
553) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
554 $Manager->Execute('ALTER TABLE `FinanceInvoiceOperationRel`
555 ADD CONSTRAINT `FinanceInvoiceOperationRel_ibfk_2` FOREIGN KEY (`Operation`) REFERENCES `FinanceOperation` (`Id`),
556 ADD CONSTRAINT `FinanceInvoiceOperationRel_ibfk_1` FOREIGN KEY (`Invoice`) REFERENCES `FinanceInvoice` (`Id`);');
557}
558
559function UpdateTo633(UpdateManager $Manager): void
560{
561 $Manager->Execute('ALTER TABLE `UserOnline` ADD `StayLoggedHash` VARCHAR( 40 ) NOT NULL ;');
562}
563
564function UpdateTo645(UpdateManager $Manager): void
565{
566 $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceVATType` (
567 `Id` int(11) NOT NULL,
568 `Name` varchar(255) NOT NULL,
569 PRIMARY KEY (`Id`)
570) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
571 $Manager->Execute('INSERT INTO `FinanceVATType` (SELECT Id, Name FROM `FinanceVAT`)');
572 $Manager->Execute('ALTER TABLE `FinanceVAT` ADD `ValidTo` DATE NULL ,
573ADD `Type` INT NOT NULL ;');
574 $Manager->Execute('UPDATE `FinanceVAT` SET `Type`=(SELECT `Id` FROM `FinanceVATType` WHERE `FinanceVATType`.`Name`=`FinanceVAT`.`Name`)');
575 $Manager->Execute('ALTER TABLE `FinanceVAT` DROP `Name`');
576}
577
578function UpdateTo646(UpdateManager $Manager): void
579{
580 $Manager->Execute('CREATE TABLE IF NOT EXISTS `Contract` (
581 `Id` int(11) NOT NULL AUTO_INCREMENT,
582 `BillCode` varchar(255) NOT NULL,
583 `Subject` int(11) NOT NULL,
584 `DocumentLine` int(11) NOT NULL,
585 `ValidFrom` date NOT NULL,
586 `ValidTo` date DEFAULT NULL,
587 `File` int(11) DEFAULT NULL,
588 PRIMARY KEY (`Id`),
589 KEY `Subject` (`Subject`),
590 KEY `DocumentLine` (`DocumentLine`),
591 KEY `File` (`File`)
592) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
593 $Manager->Execute('ALTER TABLE `Contract`
594 ADD CONSTRAINT `Contract_ibfk_3` FOREIGN KEY (`File`) REFERENCES `File` (`Id`),
595 ADD CONSTRAINT `Contract_ibfk_1` FOREIGN KEY (`Subject`) REFERENCES `Subject` (`Id`),
596 ADD CONSTRAINT `Contract_ibfk_2` FOREIGN KEY (`DocumentLine`) REFERENCES `DocumentLine` (`Id`);
597');
598 $Manager->Execute("INSERT INTO `Action` (
599`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` ,
600`Enable`) VALUES (NULL , '', 'Smlouvy', '1', '/is/?t=Contract&a=list', NULL , NULL , NULL , '1'
601);");
602 $ActionId = $Manager->Database->insert_id;
603 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
604 "VALUES (NULL , 'Smlouvy', '2', '".$ActionId."', '1');");
605 $Manager->Execute("INSERT INTO `Action` (
606`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` ,
607`Enable`) VALUES (NULL , '', 'Sazby DPH', '1', '/is/?t=FinanceVAT&a=list', NULL , NULL , NULL , '1'
608);");
609 $ActionId = $Manager->Database->insert_id;
610 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
611 "VALUES (NULL , 'Sazby DPH', '2', '".$ActionId."', '1');");
612}
613
614function UpdateTo647(UpdateManager $Manager): void
615{
616 $Manager->Execute('ALTER TABLE `EmployeeSalary` ADD FOREIGN KEY ( `Employee` ) REFERENCES `Employee` (
617`Id`
618) ON DELETE RESTRICT ON UPDATE RESTRICT ;');
619 $Manager->Execute('ALTER TABLE `EmployeeSalary` ADD `Contract` INT NULL ,
620ADD INDEX ( `Contract` ) ;');
621 $Manager->Execute('ALTER TABLE `EmployeeSalary` ADD FOREIGN KEY ( `Contract` ) REFERENCES `Contract` (
622`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;');
623 $Manager->Execute("INSERT INTO `Action` (
624`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` ,
625`Enable`) VALUES (NULL , '', 'Zaměstnanci', '1', '/is/?t=Employee&a=list', NULL , NULL , NULL , '1'
626);");
627 $ActionId = $Manager->Database->insert_id;
628 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
629 "VALUES (NULL , 'Zaměstnanci', '2', '".$ActionId."', '1');");
630 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
631 "VALUES (NULL , 'Roční výkazy', '2', NULL, '1');");
632 $MenuId = $Manager->Database->insert_id;
633 $Manager->Execute("INSERT INTO `Action` (
634`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` ,
635`Enable`) VALUES (NULL , '', 'Roční přehled', '1', '/is/?t=FinanceYearReport&a=list', NULL , NULL , NULL , '1'
636);");
637 $ActionId = $Manager->Database->insert_id;
638 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
639 "VALUES (NULL , 'Roční přehled', '".$MenuId."', '".$ActionId."', '1');");
640 $Manager->Execute("INSERT INTO `Action` (
641`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` ,
642`Enable`) VALUES (NULL , '', 'Výkaz subjektů', '1', '/is/?t=SubjectReport&a=list', NULL , NULL , NULL , '1'
643);");
644 $ActionId = $Manager->Database->insert_id;
645 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
646 "VALUES (NULL , 'Výkaz subjektů', '".$MenuId."', '".$ActionId."', '1');");
647}
648
649function UpdateTo656(UpdateManager $Manager): void
650{
651 $Manager->Execute('CREATE TABLE IF NOT EXISTS `Measure` (
652 `Id` int(11) NOT NULL AUTO_INCREMENT,
653 `Name` varchar(255) NOT NULL,
654 `Method` int(11) NOT NULL,
655 `Continuity` int(11) NOT NULL,
656 `Period` int(11) NOT NULL,
657 `Enabled` int(11) NOT NULL,
658 `Description` text NOT NULL,
659 `DataType` varchar(255) NOT NULL,
660 `DataTable` varchar(255) NOT NULL,
661 `Group` int(11) DEFAULT NULL,
662 `Cumulative` int(11) NOT NULL DEFAULT "0",
663 PRIMARY KEY (`Id`),
664 KEY `Group` (`Group`),
665 KEY `Method` (`Method`)
666) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
667
668 $Manager->Execute('CREATE TABLE IF NOT EXISTS `MeasureData` (
669 `Id` int(11) NOT NULL AUTO_INCREMENT,
670 `Time` datetime NOT NULL,
671 `Level` int(11) NOT NULL,
672 `Measure` int(11) NOT NULL,
673 `Continuity` int(11) NOT NULL,
674 `Min` int(11) NOT NULL,
675 `Avg` int(11) NOT NULL,
676 `Max` int(11) NOT NULL,
677 PRIMARY KEY (`Id`),
678 KEY `Time` (`Time`),
679 KEY `Measure` (`Measure`)
680) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
681
682 $Manager->Execute('CREATE TABLE IF NOT EXISTS `MeasureGroup` (
683 `Id` int(11) NOT NULL AUTO_INCREMENT,
684 `Name` varchar(255) NOT NULL,
685 `Parent` int(11) DEFAULT NULL,
686 PRIMARY KEY (`Id`),
687 KEY `Parent` (`Parent`)
688) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
689
690 $Manager->Execute('CREATE TABLE IF NOT EXISTS `MeasureMethod` (
691 `Id` int(11) NOT NULL AUTO_INCREMENT,
692 `Name` varchar(255) NOT NULL,
693 `Unit` varchar(255) NOT NULL,
694 PRIMARY KEY (`Id`)
695) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
696
697 $Manager->Execute('ALTER TABLE `Measure`
698 ADD CONSTRAINT `Measure_ibfk_1` FOREIGN KEY (`Group`) REFERENCES `MeasureGroup` (`Id`),
699 ADD CONSTRAINT `Measure_ibfk_2` FOREIGN KEY (`Method`) REFERENCES `MeasureMethod` (`Id`);');
700
701 $Manager->Execute('ALTER TABLE `MeasureData`
702 ADD CONSTRAINT `MeasureData_ibfk_1` FOREIGN KEY (`Measure`) REFERENCES `Measure` (`Id`);');
703
704 $Manager->Execute('ALTER TABLE `MeasureGroup`
705 ADD CONSTRAINT `MeasureGroup_ibfk_1` FOREIGN KEY (`Parent`) REFERENCES `MeasureGroup` (`Id`);');
706}
707
708function UpdateTo657(UpdateManager $Manager): void
709{
710 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkInterfaceUpDown` (
711 `Id` int(11) NOT NULL AUTO_INCREMENT,
712 `Time` datetime NOT NULL,
713 `Interface` int(11) NOT NULL,
714 `State` int(11) NOT NULL,
715 PRIMARY KEY (`Id`),
716 KEY `Interface` (`Interface`)
717) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;');
718 $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown`
719 ADD CONSTRAINT `NetworkInterfaceUpDown_ibfk_1` FOREIGN KEY (`Interface`) REFERENCES `NetworkInterface` (`Id`);');
720 $Manager->Execute("INSERT INTO `Action` (
721`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` ,
722`Enable`) VALUES (NULL , '', 'Změny stavu rozhraní', '1', '/is/?t=NetworkInterfaceUpDown&a=list', NULL , NULL , NULL , '1'
723);");
724 $ActionId = $Manager->Database->insert_id;
725 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
726 "VALUES (NULL , 'Změny stavu rozhraní', 4, '".$ActionId."', '1');");
727}
728
729function UpdateTo661(UpdateManager $Manager): void
730{
731 $Manager->Execute('CREATE TABLE IF NOT EXISTS `Contact` (
732 `Id` int(11) NOT NULL AUTO_INCREMENT,
733 `Category` int(11) NOT NULL,
734 `Value` varchar(255) NOT NULL,
735 `Subject` int(11) DEFAULT NULL,
736 `User` int(11) DEFAULT NULL,
737 PRIMARY KEY (`Id`),
738 KEY `Category` (`Category`),
739 KEY `User` (`User`),
740 KEY `Subject` (`Subject`)
741 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
742
743 $Manager->Execute('CREATE TABLE IF NOT EXISTS `ContactCategory` (
744 `Id` int(11) NOT NULL AUTO_INCREMENT,
745 `Name` varchar(255) NOT NULL,
746 PRIMARY KEY (`Id`)
747 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
748
749 $Manager->Execute('ALTER TABLE `Contact`
750 ADD CONSTRAINT `Contact_ibfk_3` FOREIGN KEY (`User`) REFERENCES `User` (`Id`),
751 ADD CONSTRAINT `Contact_ibfk_1` FOREIGN KEY (`Category`) REFERENCES `ContactCategory` (`Id`),
752 ADD CONSTRAINT `Contact_ibfk_2` FOREIGN KEY (`Subject`) REFERENCES `Subject` (`Id`);');
753
754 $Manager->Execute("INSERT INTO `Action` (
755`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` ,
756`Enable`) VALUES (NULL , '', 'Kontakty', '1', '/is/?t=Contact&a=list', NULL , NULL , NULL , '1'
757);");
758 $ActionId = $Manager->Database->insert_id;
759 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
760 "VALUES (NULL , 'Kontakty', '12', '".$ActionId."', '1');");
761 $ContactMenuId = $Manager->Database->insert_id;
762
763 $Manager->Execute("INSERT INTO `Action` (
764`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` ,
765`Enable`) VALUES (NULL , '', 'Druhy kontakty', '1', '/is/?t=ContactCategory&a=list', NULL , NULL , NULL , '1'
766);");
767 $ActionId = $Manager->Database->insert_id;
768 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
769 "VALUES (NULL , 'Druhy kontaktů', ".$ContactMenuId.", '".$ActionId."', '1');");
770
771 $Manager->Execute("INSERT INTO `ContactCategory` (`Id` ,`Name`)
772VALUES (NULL , 'Telefón'), (NULL , 'ICQ'), (NULL , 'Jabber'), (NULL , 'Email'), (NULL , 'Skype');");
773}
774
775function UpdateTo662(UpdateManager $Manager): void
776{
777 $Manager->Execute('INSERT INTO `Contact` (SELECT NULL AS `Id`, 2 AS `Category`, `ICQ` AS `Value`, NULL AS `Subject`, `Id` AS `User` FROM `User`
778WHERE (`ICQ` != "") AND (`ICQ` != 0))');
779 $Manager->Execute('ALTER TABLE `User` DROP `ICQ`;');
780 $Manager->Execute('INSERT INTO `ActionIcon` (`Id`, `Name`) VALUES (NULL, "Contact.png");');
781 $IconId = $Manager->Database->insert_id;
782 $Manager->Execute('UPDATE `Action` SET `Icon` = '.$IconId.' WHERE `Title`="Kontakty"');
783}
784
785function UpdateTo668(UpdateManager $Manager): void
786{
787 $Manager->Execute('CREATE TABLE IF NOT EXISTS `APIToken` (
788 `Id` int(11) NOT NULL AUTO_INCREMENT,
789 `User` int(11) NOT NULL,
790 `Token` varchar(255) NOT NULL,
791 PRIMARY KEY (`Id`),
792 KEY `User` (`User`)
793) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
794
795 $Manager->Execute('ALTER TABLE `APIToken`
796 ADD CONSTRAINT `APIToken_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);');
797 $Manager->Execute('INSERT INTO `Module` (`Id` ,`Name` ,`Title`)
798VALUES (NULL , "RSS", "RSS kanály");');
799}
800
801function UpdateTo671(UpdateManager $Manager): void
802{
803 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkSignal` (
804 `Id` int(11) NOT NULL AUTO_INCREMENT,
805 `Time` datetime NOT NULL,
806 `MAC` varchar(17) NOT NULL,
807 `Interface` int(11) DEFAULT NULL,
808 `Value` int(11) NOT NULL,
809 PRIMARY KEY (`Id`),
810 KEY `Interface` (`Interface`)
811) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
812
813 $Manager->Execute('ALTER TABLE `NetworkSignal`
814 ADD CONSTRAINT `NetworkSignal_ibfk_1` FOREIGN KEY (`Interface`) REFERENCES `NetworkInterface` (`Id`);');
815 $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
816`Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
817NULL , "", "Signál rozhraní", "1", "/is/?t=NetworkSignal&a=list", NULL , NULL , NULL , "1");');
818 $ActionId = $Manager->Database->insert_id;
819 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
820 "VALUES (NULL , 'Signál rozhraní', 4, '".$ActionId."', '1');");
821
822 $Manager->Execute('ALTER TABLE `NetworkDevice` ADD `API` INT NULL ,ADD INDEX ( `API` ) ;');
823 $Manager->Execute('CREATE TABLE IF NOT EXISTS `DeviceAPIType` (
824 `Id` int(11) NOT NULL AUTO_INCREMENT,
825 `Name` varchar(255) NOT NULL,
826 PRIMARY KEY (`Id`)
827) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;');
828
829 $Manager->Execute('INSERT INTO `DeviceAPIType` (`Id`, `Name`) VALUES
830(1, "RouterOS API"),
831(2, "AirOS");');
832 $Manager->Execute('ALTER TABLE `NetworkDevice` ADD FOREIGN KEY ( `API` ) REFERENCES `DeviceAPIType` (
833`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;');
834}
835
836function UpdateTo674(UpdateManager $Manager): void
837{
838 $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `RateRx` INT NOT NULL ;');
839 $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `RateTx` INT NOT NULL ;');
840}
841
842function UpdateTo676(UpdateManager $Manager): void
843{
844 $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `Device` INT NULL ,
845ADD INDEX ( `Device` ) ;');
846 $Manager->Execute('ALTER TABLE `NetworkSignal` ADD FOREIGN KEY ( `Device` ) REFERENCES `NetworkDevice` (
847`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;');
848}
849
850function UpdateTo678(UpdateManager $Manager): void
851{
852 $Manager->Execute('ALTER TABLE `Contact` ADD `Description` VARCHAR( 255 ) NOT NULL ;');
853 $Manager->Execute('ALTER TABLE `Contact` ADD `Receive` BOOLEAN NOT NULL ;');
854
855 $Manager->Execute('CREATE TABLE IF NOT EXISTS `MenuItemFavorite` (
856 `Id` int(11) NOT NULL AUTO_INCREMENT,
857 `User` int(11) NOT NULL,
858 `MenuItem` int(11) NOT NULL,
859 PRIMARY KEY (`Id`),
860 KEY `User` (`User`),
861 KEY `MenuItem` (`MenuItem`)
862) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
863
864 $Manager->Execute('ALTER TABLE `MenuItemFavorite`
865 ADD CONSTRAINT `MenuItemFavorite_ibfk_2` FOREIGN KEY (`MenuItem`) REFERENCES `MenuItem` (`Id`),
866 ADD CONSTRAINT `MenuItemFavorite_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);');
867
868 $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
869`Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
870NULL , "", "Oblíbené položky nabídky", "1", "/is/?t=MenuItemFavorite&a=list", NULL , NULL , NULL , "1");');
871 $ActionId = $Manager->Database->insert_id;
872 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Nabídky"');
873 if ($DbResult->num_rows > 0)
874 {
875 $DbRow = $DbResult->fetch_assoc();
876 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
877 "VALUES (NULL , 'Oblíbené položky nabídky', ".$DbRow['Id'].", '".$ActionId."', '1');");
878 }
879}
880
881function UpdateTo679(UpdateManager $Manager): void
882{
883 $Manager->Execute('ALTER TABLE `NetworkDevice` ADD `Product` INT NOT NULL AFTER `Id` ,
884ADD INDEX ( `Product` ) ;');
885}
886
887function UpdateTo688(UpdateManager $Manager): void
888{
889 // Convert monthly plus payment for consumption to regular service
890 $DbResult = $Manager->Execute('SELECT `MonthlyPlus`, `Member` FROM `MemberPayment` WHERE `MonthlyPlus` > 0');
891 while ($DbRow = $DbResult->fetch_assoc())
892 {
893 $Manager->Execute("INSERT INTO `Service` (`Id` ,`Name` ,`Category` ,`Price` ,`VAT`) ".
894 "VALUES (NULL , 'Spotřeba energie', 3, -".$DbRow['MonthlyPlus'].", 2);");
895 $ServiceId = $Manager->Database->insert_id;
896 $Manager->Execute("INSERT INTO `ServiceCustomerRel` (`Id` ,`Service` ,`Customer`) ".
897 "VALUES (NULL , ".$ServiceId.', '.$DbRow['Member'].");");
898 }
899}
900
901function UpdateTo692(UpdateManager $Manager): void
902{
903 // Convert user emails to contacts
904 $DbResult = $Manager->Execute('SELECT `Id` FROM `ContactCategory` WHERE `Name` = "Telefón"');
905 $DbRow = $DbResult->fetch_assoc();
906 $ContactCategoryId = $DbRow['Id'];
907
908 $Manager->Execute('INSERT INTO `Contact` (SELECT NULL AS `Id`, '.$ContactCategoryId.' AS `Category`, '.
909 '`PhoneNumber` AS `Value`, NULL AS `Subject`, `Id` AS `User`, "" AS `Descriptions`, 1 AS `Receive` FROM `User`
910WHERE (`PhoneNumber` != "") AND (`PhoneNumber` != 0))');
911 $Manager->Execute('ALTER TABLE `User` DROP `PhoneNumber`;');
912}
913
914function UpdateTo696(UpdateManager $Manager): void
915{
916 $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD `Duration` INT NOT NULL ;');
917 $Manager->Execute('UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = IFNULL(TIMESTAMPDIFF(SECOND,
918 (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` < `TM`.`Time`)
919 AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` DESC LIMIT 1), `TM`.`Time`), 0)');
920}
921
922function UpdateTo697(UpdateManager $Manager): void
923{
924 $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` CHANGE `Duration` `Duration` INT( 11 ) NULL ;');
925 $Manager->Execute('UPDATE `NetworkInterfaceUpDown` SET `Duration` = NULL');
926 $Manager->Execute('UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = TIMESTAMPDIFF(SECOND,
927 `TM`.`Time`, (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` > `TM`.`Time`)
928 AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` ASC LIMIT 1))');
929}
930
931function UpdateTo707(UpdateManager $Manager): void
932{
933 $Manager->Execute('ALTER TABLE `NetworkDevice` CHANGE `Product` `Product` INT(11) NULL;');
934}
935
936function UpdateTo710(UpdateManager $Manager): void
937{
938 $Manager->Execute('RENAME TABLE `StockItem` TO `StockSerialNumber`;');
939 $Manager->Execute('UPDATE `Action` SET `URL`="/is/?t=StockSerialNumber&a=list",`Title`="Sériová čísla" WHERE `URL`="/is/?t=StockItem&a=list";');
940
941 // StockMove
942 $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockMove` (
943 `Id` int(11) NOT NULL,
944 `Time` datetime NOT NULL,
945 `StockFrom` int(11) DEFAULT NULL,
946 `StockTo` int(11) DEFAULT NULL,
947 `BillCode` varchar(255) NOT NULL,
948 `DocumentLine` int(11) NOT NULL,
949 `File` int(11) DEFAULT NULL
950 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
951
952 $Manager->Execute('ALTER TABLE `StockMove`
953 ADD PRIMARY KEY (`Id`), ADD KEY `DocumentLine` (`DocumentLine`), ADD KEY `StockFrom` (`StockFrom`), ADD KEY `StockTo` (`StockTo`), ADD KEY `File` (`File`);');
954
955 $Manager->Execute('ALTER TABLE `StockMove`
956 MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;');
957
958 $Manager->Execute('ALTER TABLE `StockMove`
959 ADD CONSTRAINT `StockMove_ibfk_1` FOREIGN KEY (`StockFrom`) REFERENCES `Stock` (`Id`),
960 ADD CONSTRAINT `StockMove_ibfk_2` FOREIGN KEY (`StockTo`) REFERENCES `Stock` (`Id`),
961 ADD CONSTRAINT `StockMove_ibfk_3` FOREIGN KEY (`DocumentLine`) REFERENCES `DocumentLine` (`Id`);');
962
963 // StockMoveItem
964 $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockMoveItem` (
965 `Id` int(11) NOT NULL,
966 `StockMove` int(11) NOT NULL,
967 `Product` int(11) NOT NULL,
968 `Amount` int(11) NOT NULL,
969 `Text` varchar(255) NOT NULL,
970 `UnitPrice` int(11) NOT NULL
971 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
972
973 $Manager->Execute('ALTER TABLE `StockMoveItem`
974 ADD PRIMARY KEY (`Id`), ADD KEY `Product` (`Product`), ADD KEY `StockMove` (`StockMove`);');
975
976 $Manager->Execute('ALTER TABLE `StockMoveItem`
977 MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;');
978
979 $Manager->Execute('ALTER TABLE `StockMoveItem`
980 ADD CONSTRAINT `StockMoveItem_ibfk_2` FOREIGN KEY (`Product`) REFERENCES `Product` (`Id`),
981 ADD CONSTRAINT `StockMoveItem_ibfk_1` FOREIGN KEY (`StockMove`) REFERENCES `StockMove` (`Id`);');
982
983 // IS menu item
984 $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
985`Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
986NULL , "", "Skladové pohyby", "1", "/is/?t=StockMove&a=list", NULL , NULL , NULL , "1");');
987 $ActionId = $Manager->Database->insert_id;
988 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Sklad"');
989 if ($DbResult->num_rows > 0)
990 {
991 $DbRow = $DbResult->fetch_assoc();
992 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
993 "VALUES (NULL , 'Skladové pohyby', ".$DbRow['Id'].", '".$ActionId."', '1');");
994 }
995}
996
997function UpdateTo715(UpdateManager $Manager): void
998{
999 $Manager->Execute('ALTER TABLE `StockSerialNumber` DROP FOREIGN KEY `StockSerialNumber_ibfk_6`;');
1000 $Manager->Execute('ALTER TABLE `StockSerialNumber` DROP `Segment`');
1001 $Manager->Execute('ALTER TABLE `Member` DROP `NetworkSegment`');
1002 $Manager->Execute('DROP TABLE `NetworkSegment`');
1003 $Manager->Execute('DELETE FROM `MenuItem` WHERE `Name`="Úseky sítě"');
1004 $Manager->Execute('DELETE FROM `Action` WHERE `Title`="Úseky sítě"');
1005}
1006
1007function UpdateTo718(UpdateManager $Manager): void
1008{
1009 $Manager->Execute('CREATE TABLE IF NOT EXISTS `Company` (
1010`Id` int(11) NOT NULL,
1011`Name` varchar(255) NOT NULL,
1012`Subject` int(11) NOT NULL
1013) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
1014 $Manager->Execute('ALTER TABLE `Company`
1015ADD PRIMARY KEY (`Id`), ADD KEY `Subject` (`Subject`);');
1016 $Manager->Execute('ALTER TABLE `Company`
1017MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;');
1018 $Manager->Execute('ALTER TABLE `Company`
1019ADD CONSTRAINT `Company_ibfk_1` FOREIGN KEY (`Subject`) REFERENCES `Subject` (`Id`);');
1020
1021 // IS menu item
1022 $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
1023`Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
1024NULL , "", "Firmy", "1", "/is/?t=Company&a=list", NULL , NULL , NULL , "1");');
1025 $ActionId = $Manager->Database->insert_id;
1026 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Finance"');
1027 if ($DbResult->num_rows > 0)
1028 {
1029 $DbRow = $DbResult->fetch_assoc();
1030 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
1031 "VALUES (NULL , 'Firmy', ".$DbRow['Id'].", '".$ActionId."', '1');");
1032 }
1033}
1034
1035function UpdateTo719(UpdateManager $Manager): void
1036{
1037 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `Direction` INT NOT NULL AFTER `Cash`;');
1038 $Manager->Execute('UPDATE `FinanceOperation` SET `Direction` = 1 WHERE `Value` >= 0 ;');
1039 $Manager->Execute('UPDATE `FinanceOperation` SET `Direction` = -1 WHERE `Value` < 0 ;');
1040 $Manager->Execute('UPDATE `FinanceOperation` SET `Value` = -`Value` WHERE `Value` < 0 ;');
1041 // Set missing FinanceOperation DocumentLine according BillCode
1042 $Manager->Execute('UPDATE `FinanceOperation` SET `DocumentLine` = 1 WHERE (`BillCode` LIKE "PP%") AND (`DocumentLine` IS NULL)');
1043 $Manager->Execute('UPDATE `FinanceOperation` SET `DocumentLine` = 2 WHERE (`BillCode` LIKE "VP%") AND (`DocumentLine` IS NULL)');
1044 $Manager->Execute('UPDATE `FinanceOperation` SET `DocumentLine` = 3 WHERE (`BillCode` LIKE "BV%") AND (`DocumentLine` IS NULL)');
1045 $Manager->Execute('UPDATE `FinanceOperation` SET `DocumentLine` = 4 WHERE (`BillCode` LIKE "PR%") AND (`DocumentLine` IS NULL)');
1046
1047 // IS menu item
1048 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Příjmy a výdaje"');
1049 if ($DbResult->num_rows > 0)
1050 {
1051 $DbRow = $DbResult->fetch_assoc();
1052 $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
1053 `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
1054 NULL , "", "Příjem do pokladny", "1", "/is/?t=FinanceTreasuryIn&a=list", NULL , NULL , NULL , "1");');
1055 $ActionId = $Manager->Database->insert_id;
1056 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
1057 "VALUES (NULL , 'Příjem do pokladny', ".$DbRow['Id'].", '".$ActionId."', '1');");
1058 $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
1059 `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
1060 NULL , "", "Výdej z pokladny", "1", "/is/?t=FinanceTreasuryOut&a=list", NULL , NULL , NULL , "1");');
1061 $ActionId = $Manager->Database->insert_id;
1062 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
1063 "VALUES (NULL , 'Výdej z pokladny', ".$DbRow['Id'].", '".$ActionId."', '1');");
1064 $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
1065 `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
1066 NULL , "", "Příjem na účet", "1", "/is/?t=FinanceAccountIn&a=list", NULL , NULL , NULL , "1");');
1067 $ActionId = $Manager->Database->insert_id;
1068 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
1069 "VALUES (NULL , 'Příjem na účet', ".$DbRow['Id'].", '".$ActionId."', '1');");
1070 $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
1071 `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
1072 NULL , "", "Výdej z účtu", "1", "/is/?t=FinanceAccountOut&a=list", NULL , NULL , NULL , "1");');
1073 $ActionId = $Manager->Database->insert_id;
1074 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
1075 "VALUES (NULL , 'Výdej z účtu', ".$DbRow['Id'].", '".$ActionId."', '1');");
1076 }
1077}
1078
1079function UpdateTo720(UpdateManager $Manager): void
1080{
1081 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `Direction` INT NOT NULL AFTER `TimePayment`;');
1082 $Manager->Execute('UPDATE `FinanceInvoice` SET `Direction` = 1 WHERE `Value` >= 0 ;');
1083 $Manager->Execute('UPDATE `FinanceInvoice` SET `Direction` = -1 WHERE `Value` < 0 ;');
1084 $Manager->Execute('UPDATE `FinanceInvoice` SET `Value` = -`Value` WHERE `Value` < 0 ;');
1085 // Set missing FinanceInvoice DocumentLine according BillCode
1086 $Manager->Execute('UPDATE `FinanceInvoice` SET `DocumentLine` = 5 WHERE (`BillCode` LIKE "PF%") AND (`DocumentLine` IS NULL)');
1087 $Manager->Execute('UPDATE `FinanceInvoice` SET `DocumentLine` = 6 WHERE (`BillCode` LIKE "VF%") AND (`DocumentLine` IS NULL)');
1088
1089 // IS menu item
1090 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Závazky a pohledávky"');
1091 if ($DbResult->num_rows > 0)
1092 {
1093 $DbRow = $DbResult->fetch_assoc();
1094 $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
1095 `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
1096 NULL , "", "Příjaté", "1", "/is/?t=FinanceInvoiceIn&a=list", NULL , NULL , NULL , "1");');
1097 $ActionId = $Manager->Database->insert_id;
1098 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
1099 "VALUES (NULL , 'Přijaté', ".$DbRow['Id'].", '".$ActionId."', '1');");
1100
1101 $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
1102 `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
1103 NULL , "", "Vydané", "1", "/is/?t=FinanceInvoiceOut&a=list", NULL , NULL , NULL , "1");');
1104 $ActionId = $Manager->Database->insert_id;
1105 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
1106 "VALUES (NULL , 'Vydané', ".$DbRow['Id'].", '".$ActionId."', '1');");
1107 }
1108}
1109
1110function UpdateTo722(UpdateManager $Manager): void
1111{
1112 $Manager->Execute('ALTER TABLE `Service` DROP `CustomerCount`;');
1113}
1114
1115function UpdateTo725(UpdateManager $Manager): void
1116{
1117 // Text column of invoices is not used. Text from invoice items is taken instead.
1118 $DbResult = $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP `Text`;');
1119
1120 $SearchText = 'Připojení k síti';
1121 $DbResult = $Manager->Execute('SELECT * FROM `FinanceInvoiceItem` WHERE `Description` LIKE "'.$SearchText.' za období%";');
1122 while ($DbRow = $DbResult->fetch_assoc())
1123 {
1124 $Text = trim(substr($DbRow['Description'], strlen($SearchText.' za období') + 1));
1125 $Text = explode('-', $Text);
1126 $PeriodFrom = explode('.', trim($Text[0]));
1127 $PeriodFrom = $PeriodFrom[2].'-'.$PeriodFrom[1].'-'.$PeriodFrom[0];
1128 $PeriodTo = explode('.', trim($Text[1]));
1129 $PeriodTo = $PeriodTo[2].'-'.$PeriodTo[1].'-'.$PeriodTo[0];
1130 $Manager->Execute('UPDATE `FinanceInvoice` SET `PeriodFrom`="'.$PeriodFrom.'", `PeriodTo`="'.$PeriodTo.'" WHERE `Id`='.$DbRow['FinanceInvoice']);
1131 }
1132 $DbResult = $Manager->Execute('UPDATE `FinanceInvoiceItem` SET `Description` = "'.$SearchText.'" WHERE `Description` LIKE "'.$SearchText.' za období%";');
1133
1134 $SearchText = 'Připojení k Internetu';
1135 $DbResult = $Manager->Execute('SELECT * FROM `FinanceInvoiceItem` WHERE `Description` LIKE "'.$SearchText.' za období%";');
1136 while ($DbRow = $DbResult->fetch_assoc())
1137 {
1138 $Text = trim(substr($DbRow['Description'], strlen($SearchText.' za období') + 1));
1139 $Text = explode('-', $Text);
1140 $PeriodFrom = explode('.', trim($Text[0]));
1141 $PeriodFrom = $PeriodFrom[2].'-'.$PeriodFrom[1].'-'.$PeriodFrom[0];
1142 $Text[1] = trim($Text[1]);
1143 if (strpos($Text[1], ' ') !== false) $Text[1] = substr($Text[1], 0, strpos($Text[1], ' '));
1144 $PeriodTo = explode('.', trim($Text[1]));
1145 $PeriodTo = $PeriodTo[2].'-'.$PeriodTo[1].'-'.$PeriodTo[0];
1146 $Manager->Execute('UPDATE `FinanceInvoice` SET `PeriodFrom`="'.$PeriodFrom.'", `PeriodTo`="'.$PeriodTo.'" WHERE `Id`='.$DbRow['FinanceInvoice']);
1147 }
1148 $DbResult = $Manager->Execute('UPDATE `FinanceInvoiceItem` SET `Description` = "'.$SearchText.'" WHERE `Description` LIKE "'.$SearchText.' za období%";');
1149}
1150
1151function UpdateTo726(UpdateManager $Manager): void
1152{
1153 $Manager->Execute('ALTER TABLE `ServiceCustomerRel` CHANGE `Action` `ChangeAction` ENUM("add","modify","remove") CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;');
1154 $Manager->Execute('ALTER TABLE `ServiceCustomerRel` ADD `ChangeTime` DATETIME NULL AFTER `ChangeAction`;');
1155 $Manager->Execute('ALTER TABLE `ServiceCustomerRel` DROP FOREIGN KEY `ServiceCustomerRel_ibfk_4`;');
1156 $Manager->Execute('ALTER TABLE `ServiceCustomerRel` CHANGE `ReplaceId` `ChangeReplaceId` INT(11) NULL DEFAULT NULL;');
1157 $Manager->Execute('ALTER TABLE `ServiceCustomerRel` ADD FOREIGN KEY (`ChangeReplaceId`) REFERENCES `ServiceCustomerRel`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1158
1159 $Manager->Execute('ALTER TABLE `Service` CHANGE `Action` `ChangeAction` ENUM("add","modify","remove") CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;');
1160 $Manager->Execute('ALTER TABLE `Service` ADD `ChangeTime` DATETIME NULL AFTER `ChangeAction`;');
1161 $Manager->Execute('ALTER TABLE `Service` DROP FOREIGN KEY `Service_ibfk_2`;');
1162 $Manager->Execute('ALTER TABLE `Service` CHANGE `ReplaceId` `ChangeReplaceId` INT(11) NULL DEFAULT NULL;');
1163 $Manager->Execute('ALTER TABLE `Service` ADD FOREIGN KEY (`ChangeReplaceId`) REFERENCES `Service`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1164
1165 $Manager->Execute('ALTER TABLE `FinanceCharge` CHANGE `Action` `ChangeAction` ENUM("add","modify","remove") CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;');
1166 $Manager->Execute('ALTER TABLE `FinanceCharge` ADD `ChangeTime` DATETIME NULL AFTER `ChangeAction`;');
1167 $Manager->Execute('ALTER TABLE `FinanceCharge` DROP FOREIGN KEY `FinanceCharge_ibfk_1`;');
1168 $Manager->Execute('ALTER TABLE `FinanceCharge` CHANGE `ReplaceId` `ChangeReplaceId` INT(11) NULL DEFAULT NULL;');
1169 $Manager->Execute('ALTER TABLE `FinanceCharge` ADD FOREIGN KEY (`ChangeReplaceId`) REFERENCES `FinanceCharge`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1170
1171 $Manager->Execute('ALTER TABLE `MemberPayment` DROP `NetworkDevice`;');
1172}
1173
1174function UpdateTo729(UpdateManager $Manager): void
1175{
1176 $Manager->Execute('ALTER TABLE `FinanceBankAccount` ADD `AutoImport` INT NOT NULL ;');
1177
1178 $Manager->Execute('CREATE TABLE IF NOT EXISTS `Scheduler` (
1179 `Id` int(11) NOT NULL,
1180 `Name` varchar(255) NOT NULL,
1181 `Enabled` int(11) NOT NULL,
1182 `Class` varchar(255) NOT NULL,
1183 `Log` mediumtext NOT NULL,
1184 `LastExecutedTime` datetime DEFAULT NULL,
1185 `ScheduledTime` datetime NOT NULL,
1186 `Period` int(11) NOT NULL
1187) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
1188
1189 $Manager->Execute('ALTER TABLE `Scheduler`
1190 ADD PRIMARY KEY (`Id`);');
1191
1192 $Manager->Execute('ALTER TABLE `Scheduler`
1193MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;');
1194
1195 // IS menu item
1196 $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
1197`Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
1198NULL , "", "Plánovač", "1", "/is/?t=Scheduler&a=list", NULL , NULL , NULL , "1");');
1199 $ActionId = $Manager->Database->insert_id;
1200 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Systém"');
1201 if ($DbResult->num_rows > 0)
1202 {
1203 $DbRow = $DbResult->fetch_assoc();
1204 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
1205 "VALUES (NULL , 'Plánovač', ".$DbRow['Id'].", '".$ActionId."', '1');");
1206 }
1207
1208 $Manager->Execute('INSERT INTO `Module` (`Id`, `Name`, `Title`) VALUES (NULL, "Plánovač", "Scheduler");');
1209}
1210
1211function UpdateTo730(UpdateManager $Manager): void
1212{
1213 $Manager->Execute('CREATE TABLE IF NOT EXISTS `SchedulerAction` (
1214 `Id` int(11) NOT NULL AUTO_INCREMENT,
1215 `Name` varchar(255) NOT NULL,
1216 `Class` varchar(255) NOT NULL,
1217 PRIMARY KEY (`Id`)
1218) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
1219 $Manager->Execute('ALTER TABLE `Scheduler` CHANGE `Class` `Action` INT(11) NOT NULL;');
1220 $Manager->Execute("ALTER TABLE `Scheduler` ADD INDEX ( `Action` ) ");
1221 $Manager->Execute('INSERT INTO `SchedulerAction` (`Id`, `Name`, `Class`) VALUES (NULL, "Import bankovních účtů", "ScheduleBankImport");');
1222 $Manager->Execute('UPDATE `Scheduler` SET `Action` = 1 WHERE `Scheduler`.`Id` = 1;');
1223 $Manager->Execute('ALTER TABLE `Scheduler` ADD CONSTRAINT `Schedule_ibfk_2` FOREIGN KEY (`Action`) REFERENCES `SchedulerAction` (`Id`);');
1224}
1225
1226function UpdateTo731(UpdateManager $Manager): void
1227{
1228 // NetworkDomain
1229 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkDomain` (
1230`Id` int(11) NOT NULL,
1231`Name` varchar(255) NOT NULL,
1232`Parent` int(11) DEFAULT NULL,
1233`Serial` int(11) NOT NULL,
1234`Refresh` int(11) NOT NULL,
1235`Expire` int(11) NOT NULL,
1236`Retry` int(11) NOT NULL,
1237`Minimum` int(11) NOT NULL,
1238`TTL` int(11) NOT NULL,
1239`Description` varchar(255) NOT NULL
1240) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
1241
1242 $Manager->Execute('ALTER TABLE `NetworkDomain` ADD PRIMARY KEY (`Id`);');
1243
1244 $Manager->Execute('ALTER TABLE `NetworkDomain`
1245 MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1;');
1246
1247 $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
1248`Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
1249NULL , "", "Síťová doména", "1", "/is/?t=NetworkDomain&a=list", NULL , NULL , NULL , "1");');
1250 $ActionId = $Manager->Database->insert_id;
1251 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Síť"');
1252 if ($DbResult->num_rows > 0)
1253 {
1254 $DbRow = $DbResult->fetch_assoc();
1255 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
1256 "VALUES (NULL , 'Síťová doména', ".$DbRow['Id'].", '".$ActionId."', '1');");
1257 }
1258
1259 // Model additions
1260 $Manager->Execute('ALTER TABLE `Model` ADD `Title` VARCHAR(255) NOT NULL , '.
1261 'ADD `Query` VARCHAR(255) NOT NULL , '.
1262 'ADD `DefaultSortColumn` VARCHAR(255) NOT NULL , '.
1263 'ADD `DefaultSortOrder` INT NOT NULL ;');
1264
1265 // ModelField
1266 $Manager->Execute('CREATE TABLE IF NOT EXISTS `ModelField` (
1267 `Id` int(11) NOT NULL,
1268 `Name` varchar(255) NOT NULL,
1269 `Model` int(11) NOT NULL,
1270 `Query` varchar(255) NOT NULL,
1271 `Type` varchar(255) NOT NULL,
1272 `Title` varchar(255) NOT NULL,
1273 `DefaultValue` varchar(255) NOT NULL,
1274 `IsNull` int(11) NOT NULL,
1275 `Suffix` varchar(255) NOT NULL
1276 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
1277
1278 $Manager->Execute('ALTER TABLE `ModelField`
1279 ADD PRIMARY KEY (`Id`), ADD KEY `Model` (`Model`);');
1280
1281 $Manager->Execute('ALTER TABLE `ModelField`
1282 MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;');
1283
1284 $Manager->Execute('ALTER TABLE `ModelField`
1285 ADD CONSTRAINT `ModelField_ibfk_1` FOREIGN KEY (`Model`) REFERENCES `Model` (`Id`);');
1286
1287 // Module additions
1288 $Manager->Execute('ALTER TABLE `Module` ADD `Version` VARCHAR(255) NOT NULL , '.
1289 'ADD `Creator` VARCHAR(255) NOT NULL , '.
1290 'ADD `License` VARCHAR(255) NOT NULL , '.
1291 'ADD `Installed` INT NOT NULL , '.
1292 'ADD `HomePage` VARCHAR(255) NOT NULL , '.
1293 'ADD `Description` TEXT NOT NULL ;');
1294
1295 // ModuleLink
1296 $Manager->Execute('CREATE TABLE IF NOT EXISTS `ModuleLink` (
1297`Id` int(11) NOT NULL,
1298 `Module` int(11) NOT NULL,
1299 `LinkedModule` int(11) NOT NULL,
1300 `Type` int(11) NOT NULL
1301) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
1302
1303 $Manager->Execute('ALTER TABLE `ModuleLink`
1304 ADD PRIMARY KEY (`Id`), ADD KEY `Module` (`Module`), ADD KEY `LinkedModule` (`LinkedModule`);');
1305
1306 $Manager->Execute('ALTER TABLE `ModuleLink`
1307 MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;');
1308}
1309
1310function UpdateTo735(UpdateManager $Manager): void
1311{
1312 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkFreeAccess` (
1313`Id` int(11) NOT NULL,
1314`IPAddress` varchar(255) NOT NULL,
1315`Time` datetime NOT NULL
1316) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
1317
1318 $Manager->Execute('ALTER TABLE `NetworkFreeAccess`
1319 ADD PRIMARY KEY (`Id`);');
1320
1321 $Manager->Execute('ALTER TABLE `NetworkFreeAccess`
1322 MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1;');
1323
1324 $Manager->Execute('ALTER TABLE `NetworkFreeAccess` ADD `Configured` INT NOT NULL ;');
1325 $DbResult = $Manager->Execute('INSERT INTO `SchedulerAction` (`Id`, `Name`, `Class`) VALUES '.
1326 '(NULL, "Konfigurace internetu zdarma", "ScheduleConfigureFreeAccess");');
1327 $ActionId = $Manager->Database->insert_id;
1328 $Manager->Execute('INSERT INTO `Scheduler` (`Id`, `Name`, `Enabled`, `Action`,
1329 `Log`, `LastExecutedTime`, `ScheduledTime`, `Period`) VALUES (NULL, "Internet zdarma",
1330 1, '.$ActionId.', "", NULL, "", 5);');
1331 $Manager->Execute('ALTER TABLE `Scheduler` CHANGE `ScheduledTime` `ScheduledTime` DATETIME NULL;');
1332}
1333
1334function UpdateTo736(UpdateManager $Manager): void
1335{
1336 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkLinkType` (
1337`Id` int(11) NOT NULL,
1338`Name` varchar(255) NOT NULL
1339) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
1340
1341 $Manager->Execute('ALTER TABLE `NetworkLinkType` ADD PRIMARY KEY (`Id`);');
1342
1343 $Manager->Execute('ALTER TABLE `NetworkLinkType`
1344MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;');
1345}
1346
1347function UpdateTo739(UpdateManager $Manager): void
1348{
1349 $Manager->Execute('ALTER TABLE `NetworkDomain` ADD KEY (`Parent`);');
1350 $Manager->Execute('ALTER TABLE `NetworkDomain` ADD FOREIGN KEY (`Parent`) REFERENCES `NetworkDomain`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1351
1352 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkDomainServer` (
1353 `Id` int(11) NOT NULL AUTO_INCREMENT,
1354 `Address` varchar(255) NOT NULL,
1355 `Domain` int(11) NOT NULL,
1356 `Sequence` int(11) NOT NULL,
1357 PRIMARY KEY (`Id`)
1358) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;');
1359
1360 $Manager->Execute('ALTER TABLE `NetworkDomainServer` ADD KEY `Domain` (`Domain`);');
1361
1362 $Manager->Execute('ALTER TABLE `NetworkDomainServer`
1363ADD CONSTRAINT `NetworkDomainServer_ibfk_1` FOREIGN KEY (`Domain`) REFERENCES `NetworkDomain` (`Id`);');
1364}
1365
1366function UpdateTo740(UpdateManager $Manager): void
1367{
1368 $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceInvoiceGroup` (
1369 `Id` int(11) NOT NULL AUTO_INCREMENT,
1370 `Name` varchar(255) NOT NULL,
1371 `DocumentLine` int(11) NOT NULL,
1372 `ValueSign` int(11) NOT NULL,
1373 PRIMARY KEY (`Id`),
1374 KEY `DocumentLine` (`DocumentLine`)
1375) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;');
1376 $Manager->Execute('ALTER TABLE `FinanceInvoiceGroup`
1377ADD CONSTRAINT `FinanceInvoiceGroup_ibfk_1` FOREIGN KEY (`DocumentLine`) REFERENCES `DocumentLine` (`Id`);');
1378 $Manager->Execute('INSERT INTO `FinanceInvoiceGroup` (`Id`, `Name`, `DocumentLine`, `ValueSign`) VALUES
1379(1, "Přijaté faktury", 5, -1),
1380(2, "Vydané faktury", 6, 1);');
1381
1382 // Transform FinanceInvoice.DocumentLine reference to FinanceInvoiceGroup
1383 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `Group` INT NULL AFTER `Id`;');
1384 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD INDEX(`Group`);');
1385 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD FOREIGN KEY (`Group`) REFERENCES `FinanceInvoiceGroup`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1386 $Manager->Execute('UPDATE `FinanceInvoice` SET `Group`=1 WHERE `DocumentLine`=5');
1387 $Manager->Execute('UPDATE `FinanceInvoice` SET `Group`=2 WHERE `DocumentLine`=6');
1388 $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP FOREIGN KEY `FinanceInvoice_ibfk_3`;');
1389 $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP `DocumentLine`;');
1390
1391 $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceOperationGroup` (
1392 `Id` int(11) NOT NULL AUTO_INCREMENT,
1393 `Name` varchar(255) NOT NULL,
1394 `DocumentLine` int(11) NOT NULL,
1395 `ValueSign` int(11) NOT NULL,
1396 PRIMARY KEY (`Id`),
1397 KEY `DocumentLine` (`DocumentLine`)
1398) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;');
1399 $Manager->Execute('ALTER TABLE `FinanceOperationGroup`
1400ADD CONSTRAINT `FinanceOperationGroup_ibfk_1` FOREIGN KEY (`DocumentLine`) REFERENCES `DocumentLine` (`Id`);');
1401 $Manager->Execute('INSERT INTO `FinanceOperationGroup` (`Id`, `Name`, `DocumentLine`, `ValueSign`) VALUES
1402(1, "Příjem do pokladny", 1, 1),
1403(2, "Výdej z pokladny", 2, -1),
1404(3, "Příjem na účet", 3, 1),
1405(4, "Výdej z účtu", 4, -1),
1406(5, "Nezařazené (ručně vyčistit)", 1, 1);');
1407
1408 // Transform FinanceOperation.DocumentLine reference to FinanceOperationGroup
1409 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `Group` INT NULL AFTER `Id`;');
1410 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD INDEX (`Group`);');
1411 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD FOREIGN KEY (`Group`) REFERENCES `FinanceOperationGroup`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1412 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=1 WHERE `DocumentLine`=1');
1413 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=2 WHERE `DocumentLine`=2');
1414 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=3 WHERE `DocumentLine`=3');
1415 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=4 WHERE `DocumentLine`=4');
1416 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=5 WHERE `DocumentLine`=10');
1417 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=5 WHERE `DocumentLine`=5');
1418 $Manager->Execute('ALTER TABLE `FinanceOperation` DROP FOREIGN KEY `FinanceOperation_ibfk_6`;');
1419 $Manager->Execute('ALTER TABLE `FinanceOperation` DROP `DocumentLine`;');
1420
1421 $Manager->Execute('ALTER TABLE `FinanceInvoice` CHANGE `Direction` `ValueSign` INT(11) NOT NULL;');
1422 $Manager->Execute('ALTER TABLE `FinanceOperation` CHANGE `Direction` `ValueSign` INT(11) NOT NULL;');
1423}
1424
1425function UpdateTo741(UpdateManager $Manager): void
1426{
1427 // Add Direction column
1428 $Manager->Execute('ALTER TABLE `FinanceOperationGroup` ADD `Direction` INT NOT NULL ;');
1429 $Manager->Execute('UPDATE `FinanceOperationGroup` SET `Direction` = 1 WHERE ValueSign=-1');
1430 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `Direction` INT NOT NULL AFTER `Cash`;');
1431 $Manager->Execute('UPDATE `FinanceOperation` SET `Direction` = 1 WHERE ValueSign=-1');
1432 $Manager->Execute('ALTER TABLE `FinanceInvoiceGroup` ADD `Direction` INT NOT NULL ;');
1433 $Manager->Execute('UPDATE `FinanceInvoiceGroup` SET `Direction` = 1 WHERE ValueSign=1');
1434 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `Direction` INT NOT NULL AFTER `TimePayment`;');
1435 $Manager->Execute('UPDATE `FinanceInvoice` SET `Direction` = 1 WHERE ValueSign=1');
1436}
1437
1438function UpdateTo742(UpdateManager $Manager): void
1439{
1440 $Manager->Execute('CREATE TABLE IF NOT EXISTS `DocumentLineCode` (
1441 `Id` int(11) NOT NULL AUTO_INCREMENT,
1442 `DocumentLine` int(11) NULL,
1443 `Name` varchar(255) NOT NULL,
1444 PRIMARY KEY (`Id`),
1445 UNIQUE KEY `Name` (`Name`),
1446 KEY `DocumentLine` (`DocumentLine`)
1447) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
1448 $Manager->Execute('ALTER TABLE `DocumentLineCode`
1449ADD CONSTRAINT `DocumentLineCode_ibfk_1` FOREIGN KEY (`DocumentLine`) REFERENCES `DocumentLine` (`Id`);');
1450
1451 // Transform finance operations
1452 $Manager->Execute('ALTER TABLE `FinanceOperation` CHANGE `BillCode` `BillCodeText` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL');
1453 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `BillCode` INT NULL AFTER `BillCodeText`, ADD INDEX (`BillCode`)');
1454 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD FOREIGN KEY (`BillCode`) REFERENCES `DocumentLineCode`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1455 $DbResult = $Manager->Execute('SELECT `FinanceOperation`.`Id`, `FinanceOperation`.`BillCodeText`, `FinanceOperationGroup`.`DocumentLine` '.
1456 'FROM `FinanceOperation` '.
1457 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '.
1458 'WHERE `FinanceOperation`.`BillCodeText`!=""');
1459 while ($DbRow = $DbResult->fetch_assoc())
1460 {
1461 if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL';
1462 $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '.
1463 'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");');
1464 $CodeId = $Manager->Database->insert_id;
1465 $Manager->Execute('UPDATE `FinanceOperation` SET `BillCode`='.$CodeId.' WHERE `Id`='.$DbRow['Id']);
1466 }
1467 $Manager->Execute('ALTER TABLE `FinanceOperation` DROP `BillCodeText`;');
1468
1469 // Transform invoices
1470 $Manager->Execute('ALTER TABLE `FinanceInvoice` CHANGE `BillCode` `BillCodeText` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL');
1471 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `BillCode` INT NULL AFTER `BillCodeText`, ADD INDEX (`BillCode`)');
1472 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD FOREIGN KEY (`BillCode`) REFERENCES `DocumentLineCode`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1473 $DbResult = $Manager->Execute('SELECT `FinanceInvoice`.`Id`, `FinanceInvoice`.`BillCodeText`, `FinanceInvoiceGroup`.`DocumentLine` '.
1474 'FROM `FinanceInvoice` '.
1475 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '.
1476 'WHERE `FinanceInvoice`.`BillCodeText`!=""');
1477 while ($DbRow = $DbResult->fetch_assoc())
1478 {
1479 if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL';
1480 $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '.
1481 'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");');
1482 $CodeId = $Manager->Database->insert_id;
1483 $Manager->Execute('UPDATE `FinanceInvoice` SET `BillCode`='.$CodeId.' WHERE `Id`='.$DbRow['Id']);
1484 }
1485 $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP `BillCodeText`;');
1486}
1487
1488function UpdateTo747(UpdateManager $Manager): void
1489{
1490 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `ValueUser` FLOAT NOT NULL AFTER `Value`;');
1491 $Manager->Execute('UPDATE `FinanceOperation` SET `ValueUser`=`Value`');
1492 $Manager->Execute('UPDATE `FinanceOperation` SET `Value`=`ValueUser`*`ValueSign`');
1493 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=1 WHERE (`ValueSign`=1) AND (`Cash`=1)');
1494 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=2 WHERE (`ValueSign`=-1) AND (`Cash`=1)');
1495 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=3 WHERE (`ValueSign`=1) AND (`Cash`=0)');
1496 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=4 WHERE (`ValueSign`=-1) AND (`Cash`=0)');
1497 $Manager->Execute('ALTER TABLE `FinanceOperation` DROP `Direction`, DROP `ValueSign`;');
1498
1499 // SELECT FinanceInvoice.* FROM `FinanceInvoice` LEFT JOIN FinanceInvoiceGroup ON FinanceInvoiceGroup.Id=FinanceInvoice.Group WHERE FinanceInvoice.ValueSign != FinanceInvoiceGroup.ValueSign
1500 $Manager->Execute('UPDATE `FinanceInvoice` SET `Group`=1 WHERE (`ValueSign`=-1)');
1501 $Manager->Execute('UPDATE `FinanceInvoice` SET `Group`=2 WHERE (`ValueSign`=1)');
1502 $Manager->Execute('UPDATE `FinanceInvoice` SET `Value`=`Value`*`ValueSign`');
1503 $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP `Direction`, DROP `ValueSign`;');
1504
1505 // Check rounding manual vs. calculated value from items
1506 // 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`
1507 // Check sign of manual vs. calculated value from items
1508 // 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`)
1509}
1510
1511function UpdateTo748(UpdateManager $Manager): void
1512{
1513 $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`');
1514 while ($DbRow = $DbResult->fetch_assoc())
1515 {
1516 $Manager->Database->query('UPDATE `FinanceInvoiceItem` SET `Price` = -`Price` WHERE `FinanceInvoice`='.$DbRow['Id']);
1517 }
1518}
1519
1520function UpdateTo752(UpdateManager $Manager): void
1521{
1522 $Manager->Database->query('INSERT INTO `SchedulerAction` (`Id`, `Name`, `Class`) '.
1523 'VALUES (NULL, "Kontrola změn stavů", "ScheduleNotifyCheck");');
1524
1525 $Manager->Database->query('
1526 CREATE TABLE IF NOT EXISTS `NotifyUser` (
1527 `Id` int(11) NOT NULL AUTO_INCREMENT,
1528 `User` int(11) NOT NULL,
1529 `Contact` int(11) NOT NULL,
1530 `Period` int(11) NOT NULL,
1531 `LastTime` datetime NOT NULL,
1532 PRIMARY KEY (`Id`),
1533 KEY `User` (`User`),
1534 KEY `Contact` (`Contact`)
1535 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;');
1536 $Manager->Database->query('ALTER TABLE `NotifyUser`
1537ADD CONSTRAINT `NotifyUser_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`Id`),
1538ADD CONSTRAINT `NotifyUser_ibfk_2` FOREIGN KEY (`Contact`) REFERENCES `Contact` (`Id`);');
1539
1540 $Manager->Database->query('CREATE TABLE IF NOT EXISTS `NotifyCategory` (
1541 `Id` int(11) NOT NULL AUTO_INCREMENT,
1542 `Name` varchar(255) NOT NULL,
1543 `SysName` varchar(255) NOT NULL,
1544 PRIMARY KEY (`Id`)
1545 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;');
1546
1547 $Manager->Database->query("INSERT INTO `NotifyCategory` (`Id`, `Name`, `SysName`) VALUES
1548 (1, 'Dostupnost zařízení (ping)', 'NetworkReachability'),
1549 (2, 'Dostupnost URL', 'URL'),
1550 (3, 'Minimální úroveň signálu', 'WirelessSignal'),
1551 (4, 'Dostupnost síťového portu', 'NetworkPort'),
1552 (5, 'Minimální odezva', 'NetworkLatency'),
1553 (6, 'Minimální propustnost', 'NetworkBandwidth');");
1554}
1555
1556function UpdateTo755(UpdateManager $Manager): void
1557{
1558 $Manager->Execute("INSERT INTO `FinanceInvoiceGroup` (`Id`, `Name`, `DocumentLine`, `ValueSign`, `Direction`) ".
1559 "VALUES (NULL, 'Přijaté faktury - storno', '5', '1', '0'), (NULL, 'Vydané faktury - storno', '6', '-1', '1')");
1560 $Manager->Execute("ALTER TABLE `FinanceInvoice` ADD `VisibleToUser` INT NOT NULL DEFAULT '1' AFTER `Generate`;".
1561 "ALTER TABLE `FinanceInvoice` ADD `VisibleToUser` INT NOT NULL DEFAULT '1' AFTER `Generate`;");
1562
1563 $Manager->Execute("CREATE TABLE IF NOT EXISTS `FinanceInvoiceStorno` (
1564 `Id` int(11) NOT NULL AUTO_INCREMENT,
1565 `StornoBy` int(11) NOT NULL,
1566 `StornoOf` int(11) NOT NULL,
1567 PRIMARY KEY (`Id`),
1568 KEY `StornoBy` (`StornoBy`),
1569 KEY `StornoOf` (`StornoOf`)
1570 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
1571
1572 $Manager->Execute("ALTER TABLE `FinanceInvoiceStorno`
1573 ADD CONSTRAINT `FinanceInvoiceStorno_ibfk_1` FOREIGN KEY (`StornoBy`) REFERENCES `FinanceInvoice` (`Id`),
1574 ADD CONSTRAINT `FinanceInvoiceStorno_ibfk_2` FOREIGN KEY (`StornoOf`) REFERENCES `FinanceInvoice` (`Id`);
1575 ");
1576}
1577
1578function UpdateTo759(UpdateManager $Manager): void
1579{
1580 $Manager->Execute('ALTER TABLE `Scheduler` ADD `Duration` INT NOT NULL AFTER `Period`;');
1581}
1582
1583/*
1584function UpdateTo761(UpdateManager $Manager): void
1585{
1586 $Manager->Execute('INSERT INTO `MACAddress` (SELECT "" AS `Id`,`MAC` AS `Value` FROM `NetworkSignal` GROUP BY `MAC`)');
1587 $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `Address` INT NOT NULL AFTER `MAC`;');
1588 $Manager->Execute('UPDATE `NetworkSignal` SET `Address`=(SELECT `Id` FROM `MACAddress` WHERE `MACAddress`.`Value`=`NetworkSignal`.`MAC`)');
1589}
1590*/
1591
1592function UpdateTo762(UpdateManager $Manager): void
1593{
1594 $Manager->Execute('ALTER TABLE `NetworkDevice` ADD `OnlineNotify` INT NOT NULL AFTER `API`;');
1595}
1596
1597function UpdateTo763(UpdateManager $Manager): void
1598{
1599 $Manager->Execute('ALTER TABLE `NetworkInterface` ADD `OnlineNotify` INT NOT NULL AFTER `LastOnline`;');
1600 $Manager->Execute('ALTER TABLE `NetworkDevice` DROP `OnlineNotify`;');
1601}
1602
1603function UpdateTo765(UpdateManager $Manager): void
1604{
1605 $Manager->Execute('CREATE TABLE IF NOT EXISTS `SupportActivity` (
1606 `Id` int(11) NOT NULL AUTO_INCREMENT,
1607 `Description` text NOT NULL,
1608 `Customer` int(11) NOT NULL,
1609 `User` int(11) NOT NULL,
1610 `Time` datetime NOT NULL,
1611 PRIMARY KEY (`Id`),
1612 KEY `User` (`User`),
1613 KEY `Customer` (`Customer`)
1614 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;');
1615
1616 $Manager->Execute('ALTER TABLE `SupportActivity`
1617ADD CONSTRAINT `SupportActivity_ibfk_1` FOREIGN KEY (`Customer`) REFERENCES `Member` (`Id`),
1618ADD CONSTRAINT `SupportActivity_ibfk_2` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);');
1619
1620 // IS menu item
1621 $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
1622`Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
1623NULL , "", "Zákaznická podpora", "1", "/is/?t=SupportActivity&a=list", NULL , NULL , NULL , "1");');
1624 $ActionId = $Manager->Database->insert_id;
1625 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Zákazníci"');
1626 if ($DbResult->num_rows > 0)
1627 {
1628 $DbRow = $DbResult->fetch_assoc();
1629 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
1630 "VALUES (NULL , 'Zákazická podpora', ".$DbRow['Id'].", '".$ActionId."', '1');");
1631 }
1632}
1633
1634function UpdateTo768(UpdateManager $Manager): void
1635{
1636 $Manager->Execute('ALTER TABLE `NetworkDomainAlias` ADD `Domain` INT NOT NULL AFTER `Comment`;');
1637 $Manager->Execute('ALTER TABLE `NetworkDomainAlias` ADD KEY `Domain` (`Domain`);');
1638 $Manager->Execute('UPDATE `NetworkDomainAlias` SET `Domain`=1');
1639 $Manager->Execute('ALTER TABLE `NetworkDomainAlias` ADD FOREIGN KEY (`Domain`) REFERENCES `NetworkDomain`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1640 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkAddressCategory` (
1641 `Id` int(11) NOT NULL AUTO_INCREMENT,
1642 `Name` varchar(255) NOT NULL,
1643 PRIMARY KEY (`Id`)
1644) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;');
1645 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkDomainItemFilter` (
1646 `Id` int(11) NOT NULL AUTO_INCREMENT,
1647 `Name` varchar(255) NOT NULL,
1648 `Domain` int(11) NOT NULL,
1649 `AddressCategory` int(11) NOT NULL,
1650 `Suffix` varchar(255) NOT NULL,
1651 `View` int(11) NOT NULL,
1652 `AddressRange` varchar(255) NOT NULL,
1653 PRIMARY KEY (`Id`),
1654 KEY `Domain` (`Domain`),
1655 KEY `View` (`View`)
1656) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;');
1657 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkDomainView` (
1658 `Id` int(11) NOT NULL AUTO_INCREMENT,
1659 `Domain` int(11) NOT NULL,
1660 `AddressRange` varchar(255) NOT NULL,
1661 `Name` varchar(255) NOT NULL,
1662 `SysName` varchar(255) NOT NULL,
1663 PRIMARY KEY (`Id`),
1664 KEY `Domain` (`Domain`)
1665) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;');
1666 $Manager->Execute('ALTER TABLE `NetworkDomainItemFilter`
1667 ADD FOREIGN KEY (`Domain`) REFERENCES `NetworkDomain` (`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1668 $Manager->Execute('ALTER TABLE `NetworkDomainItemFilter`
1669 ADD FOREIGN KEY (`View`) REFERENCES `NetworkDomainView`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1670 $Manager->Execute('ALTER TABLE `NetworkDomainView`
1671 ADD FOREIGN KEY (`Domain`) REFERENCES `NetworkDomainView`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1672}
1673
1674function UpdateTo770(UpdateManager $Manager): void
1675{
1676 $Manager->Execute("CREATE TABLE IF NOT EXISTS `OS` (
1677 `Id` int(11) NOT NULL AUTO_INCREMENT,
1678 `Name` varchar(255) NOT NULL,
1679 `Subject` int(11) DEFAULT NULL,
1680 `Web` varchar(255) NOT NULL,
1681 PRIMARY KEY (`Id`),
1682 KEY `Subject` (`Subject`)
1683 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
1684
1685 $Manager->Execute("INSERT INTO `OS` (`Id`, `Name`, `Subject`, `Web`) VALUES
1686 (3, 'Ubuntu', NULL, 'https://www.ubuntu.com/'),
1687 (4, 'Fedora', NULL, 'https://getfedora.org/'),
1688 (5, 'OpenSUSE', NULL, 'https://www.opensuse.org/'),
1689 (6, 'Arch Linux', NULL, 'https://www.archlinux.org/'),
1690 (7, 'Debian', NULL, 'https://www.debian.org/');");
1691
1692 $Manager->Execute("CREATE TABLE IF NOT EXISTS `OSArchitecture` (
1693 `Id` int(11) NOT NULL AUTO_INCREMENT,
1694 `Name` varchar(255) NOT NULL,
1695 PRIMARY KEY (`Id`)
1696 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
1697
1698 $Manager->Execute("INSERT INTO `OSArchitecture` (`Id`, `Name`) VALUES
1699 (1, 'i386'),
1700 (2, 'x86_64,amd64');");
1701
1702 $Manager->Execute("CREATE TABLE IF NOT EXISTS `OSTemplate` (
1703 `Id` int(11) NOT NULL AUTO_INCREMENT,
1704 `Name` varchar(255) NOT NULL,
1705 `Type` int(11) NOT NULL,
1706 `Size` bigint(11) NOT NULL,
1707 `OSVersion` int(11) NOT NULL,
1708 `Public` int(11) NOT NULL,
1709 `Architecture` int(11) NOT NULL,
1710 PRIMARY KEY (`Id`),
1711 KEY `OSVersion` (`OSVersion`),
1712 KEY `Architecture` (`Architecture`),
1713 KEY `Type` (`Type`)
1714 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
1715
1716 $Manager->Execute("INSERT INTO `OSTemplate` (`Id`, `Name`, `Type`, `Size`, `OSVersion`, `Public`, `Architecture`) VALUES
1717 (2, 'Ubuntu 15.10 i386', 1, 200000000, 1, 1, 1);");
1718
1719 $Manager->Execute("CREATE TABLE IF NOT EXISTS `OSVersion` (
1720 `Id` int(11) NOT NULL AUTO_INCREMENT,
1721 `Name` varchar(255) NOT NULL,
1722 `OS` int(11) NOT NULL,
1723 `Version` varchar(255) NOT NULL,
1724 `ReleaseDate` date NOT NULL,
1725 `CodeName` varchar(255) NOT NULL,
1726 `EndOfLife` date DEFAULT NULL,
1727 PRIMARY KEY (`Id`),
1728 KEY `OS` (`OS`)
1729 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
1730
1731 $Manager->Execute("INSERT INTO `OSVersion` (`Id`, `Name`, `OS`, `Version`, `ReleaseDate`, `CodeName`, `EndOfLife`) VALUES
1732 (1, 'Ubuntu 15.10', 3, '15.10', '2015-10-23', 'Wily Werewolf', NULL),
1733 (2, 'Ubuntu 14.04', 3, '14.04', '2014-04-17', 'Trusty Tahr', NULL);");
1734
1735 $Manager->Execute("CREATE TABLE IF NOT EXISTS `OSVirtType` (
1736 `Id` int(11) NOT NULL AUTO_INCREMENT,
1737 `Name` varchar(255) NOT NULL,
1738 PRIMARY KEY (`Id`)
1739 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
1740
1741 $Manager->Execute("INSERT INTO `OSVirtType` (`Id`, `Name`) VALUES
1742 (1, 'LXC'),
1743 (2, 'OpenVZ'),
1744 (3, 'KVM'),
1745 (4, 'Xen'),
1746 (5, 'Hardware');");
1747
1748 $Manager->Execute("CREATE TABLE IF NOT EXISTS `VPS` (
1749 `Id` int(11) NOT NULL AUTO_INCREMENT,
1750 `Name` varchar(255) NOT NULL,
1751 `NetworkDevice` int(11) NOT NULL,
1752 `OSTemplate` int(11) NOT NULL,
1753 `Limits` int(11) NOT NULL,
1754 `AutoStart` int(11) NOT NULL,
1755 PRIMARY KEY (`Id`),
1756 KEY `NetworkDevice` (`NetworkDevice`),
1757 KEY `OSTemplate` (`OSTemplate`),
1758 KEY `Limit` (`Limits`)
1759 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
1760
1761 $Manager->Execute("CREATE TABLE IF NOT EXISTS `VPSLimit` (
1762 `Id` int(11) NOT NULL AUTO_INCREMENT,
1763 `Name` varchar(255) NOT NULL,
1764 `Memory` bigint(11) NOT NULL,
1765 `Storage` bigint(11) NOT NULL,
1766 `NetworkDown` int(11) NOT NULL,
1767 `NetworkUp` int(11) NOT NULL,
1768 `CPUSockets` int(11) NOT NULL,
1769 PRIMARY KEY (`Id`)
1770 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
1771
1772 $Manager->Execute("ALTER TABLE `OS`
1773 ADD CONSTRAINT `OS_ibfk_1` FOREIGN KEY (`Subject`) REFERENCES `Subject` (`Id`);");
1774
1775 $Manager->Execute("ALTER TABLE `OSTemplate`
1776 ADD CONSTRAINT `OSTemplate_ibfk_1` FOREIGN KEY (`OSVersion`) REFERENCES `OSVersion` (`Id`),
1777 ADD CONSTRAINT `OSTemplate_ibfk_2` FOREIGN KEY (`Architecture`) REFERENCES `OSArchitecture` (`Id`),
1778 ADD CONSTRAINT `OSTemplate_ibfk_3` FOREIGN KEY (`Type`) REFERENCES `OSVirtType` (`Id`);");
1779
1780 $Manager->Execute("ALTER TABLE `OSVersion`
1781 ADD CONSTRAINT `OSVersion_ibfk_1` FOREIGN KEY (`OS`) REFERENCES `OS` (`Id`);");
1782
1783 $Manager->Execute("ALTER TABLE `VPS`
1784 ADD CONSTRAINT `VPS_ibfk_1` FOREIGN KEY (`NetworkDevice`) REFERENCES `NetworkDevice` (`Id`),
1785 ADD CONSTRAINT `VPS_ibfk_2` FOREIGN KEY (`OSTemplate`) REFERENCES `OSTemplate` (`Id`),
1786 ADD CONSTRAINT `VPS_ibfk_3` FOREIGN KEY (`Limits`) REFERENCES `VPSLimit` (`Id`);");
1787}
1788
1789function UpdateTo785(UpdateManager $Manager): void
1790{
1791 $Manager->Execute('DROP TABLE `NetworkInterfaceStat`');
1792}
1793
1794function UpdateTo786(UpdateManager $Manager): void
1795{
1796 $Manager->Execute('ALTER TABLE `Member` DROP FOREIGN KEY Member_ibfk_28;');
1797 $Manager->Execute('ALTER TABLE `Member` DROP `BillingPeriodNext`;');
1798 /* Add table change action */
1799 $Manager->Execute('ALTER TABLE `Member` ADD `ChangeAction` ENUM( "add", "modify", "remove" ) NULL');
1800 $Manager->Execute('ALTER TABLE `Member` ADD `ChangeTime` DATETIME NULL');
1801 $Manager->Execute('ALTER TABLE `Member` ADD `ChangeReplaceId` INT(11) NULL DEFAULT NULL;');
1802 $Manager->Execute('ALTER TABLE `Member` ADD FOREIGN KEY (`ChangeReplaceId`) REFERENCES `Member`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1803}
1804
1805function UpdateTo792(UpdateManager $Manager): void
1806{
1807 // Transform contracts
1808 $Manager->Execute('ALTER TABLE `Contract` CHANGE `BillCode` `BillCodeText` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL');
1809 $Manager->Execute('ALTER TABLE `Contract` ADD `BillCode` INT NULL AFTER `BillCodeText`, ADD INDEX (`BillCode`)');
1810 $Manager->Execute('ALTER TABLE `Contract` ADD FOREIGN KEY (`BillCode`) REFERENCES `DocumentLineCode`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1811 $DbResult = $Manager->Execute('SELECT `Contract`.`Id`, `Contract`.`BillCodeText`, `Contract`.`DocumentLine` '.
1812 'FROM `Contract` '.
1813 'WHERE `Contract`.`BillCodeText`!=""');
1814 while ($DbRow = $DbResult->fetch_assoc())
1815 {
1816 if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL';
1817 $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '.
1818 'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");');
1819 $CodeId = $Manager->Database->insert_id;
1820 $Manager->Execute('UPDATE `Contract` SET `BillCode`='.$CodeId.' WHERE `Id`='.$DbRow['Id']);
1821 }
1822 $Manager->Execute('ALTER TABLE `Contract` DROP `BillCodeText`;');
1823}
1824
1825function UpdateTo800(UpdateManager $Manager): void
1826{
1827 $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockItemHistory` (
1828 `Id` int(11) NOT NULL AUTO_INCREMENT,
1829 `StockSerialNumber` int(11) NOT NULL,
1830 `Time` datetime NOT NULL,
1831 `Text` varchar(255) NOT NULL,
1832 PRIMARY KEY (`Id`),
1833 KEY `StockSerialNumber` (`StockSerialNumber`)
1834 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
1835 $Manager->Execute('ALTER TABLE `StockItemHistory` ADD FOREIGN KEY (`StockSerialNumber`) '.
1836 'REFERENCES `StockSerialNumber`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1837 $Manager->Execute('INSERT INTO `StockItemHistory` (SELECT NULL AS `Id`, `Id` AS `StockSerialNumber`, '.
1838 '"" AS `Time`, `Info` AS `Text` FROM `StockSerialNumber` WHERE `Info` != "")');
1839 $Manager->Execute('ALTER TABLE `StockSerialNumber` DROP `Info`;');
1840}
1841
1842function UpdateTo802(UpdateManager $Manager): void
1843{
1844 $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockMoveGroup` (
1845 `Id` int(11) NOT NULL AUTO_INCREMENT,
1846 `Name` varchar(255) NOT NULL,
1847 `DocumentLine` int(11) NOT NULL,
1848 `ValueSign` int(11) NOT NULL,
1849 `Direction` int(11) NOT NULL,
1850 PRIMARY KEY (`Id`),
1851 KEY `DocumentLine` (`DocumentLine`)
1852) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
1853 $Manager->Execute('ALTER TABLE `StockMoveGroup` ADD FOREIGN KEY (`DocumentLine`) '.
1854 'REFERENCES `DocumentLine`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1855 $Manager->Execute('INSERT INTO `StockMoveGroup` (`Id`, `Name`, `DocumentLine`, '.
1856 '`ValueSign`, `Direction`) VALUES (NULL, "Příjem", 8, 1, 0), (NULL, "Výdej", 7, -1, 1);');
1857
1858 $Manager->Execute('ALTER TABLE `StockMove` ADD `Group` INT NOT NULL AFTER `File`, ADD INDEX (`Group`);');
1859 $Manager->Execute('ALTER TABLE `StockMove` ADD `Stock` INT NOT NULL AFTER `Time`, ADD INDEX (`Stock`);');
1860 $Manager->Execute('UPDATE `StockMove` SET `Group`=(SELECT `Id` FROM `StockMoveGroup` WHERE `StockMoveGroup`.`DocumentLine` = `StockMove`.`DocumentLine`)');
1861 $Manager->Execute('UPDATE `StockMove` SET `Stock`= `StockFrom` WHERE `DocumentLine` = 7');
1862 $Manager->Execute('UPDATE `StockMove` SET `Stock`= `StockTo` WHERE `DocumentLine` = 8');
1863 $Manager->Execute('ALTER TABLE `StockMove` ADD FOREIGN KEY (`Group`) REFERENCES `StockMoveGroup`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1864 $Manager->Execute('ALTER TABLE `StockMove` DROP FOREIGN KEY StockMove_ibfk_2;');
1865 $Manager->Execute('ALTER TABLE `StockMove` DROP FOREIGN KEY StockMove_ibfk_1;');
1866 $Manager->Execute('ALTER TABLE `StockMove` DROP FOREIGN KEY StockMove_ibfk_3;');
1867 $Manager->Execute('ALTER TABLE `StockMove` DROP `StockFrom`, DROP `StockTo`, DROP `DocumentLine`;');
1868 $Manager->Execute('ALTER TABLE `StockMove` ADD FOREIGN KEY (`Stock`) REFERENCES `Stock`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1869
1870 // Make BillCode as reference to DocumentLineCode table
1871 $Manager->Execute('ALTER TABLE `StockMove` CHANGE `BillCode` `BillCodeText` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL');
1872 $Manager->Execute('ALTER TABLE `StockMove` ADD `BillCode` INT NULL AFTER `BillCodeText`, ADD INDEX (`BillCode`)');
1873 $Manager->Execute('ALTER TABLE `StockMove` ADD FOREIGN KEY (`BillCode`) REFERENCES `DocumentLineCode`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1874
1875 $DbResult = $Manager->Execute('SELECT `StockMove`.`Id`, `StockMove`.`BillCodeText`, `StockMoveGroup`.`DocumentLine` '.
1876 'FROM `StockMove` '.
1877 'LEFT JOIN `StockMoveGroup` ON `StockMoveGroup`.`Id` = `StockMove`.`Group` '.
1878 'WHERE `StockMove`.`BillCodeText`!=""');
1879 while ($DbRow = $DbResult->fetch_assoc())
1880 {
1881 if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL';
1882 $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '.
1883 'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");');
1884 $CodeId = $Manager->Database->insert_id;
1885 $Manager->Execute('UPDATE `StockMove` SET `BillCode`='.$CodeId.' WHERE `Id`='.$DbRow['Id']);
1886 }
1887 $Manager->Execute('ALTER TABLE `StockMove` DROP `BillCodeText`;');
1888 $Manager->Execute('ALTER TABLE `StockMoveItem` DROP `Text`;');
1889}
1890
1891function UpdateTo803(UpdateManager $Manager): void
1892{
1893 $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockMoveItemSerialRel` (
1894 `Id` int(11) NOT NULL,
1895 `StockMoveItem` int(11) NOT NULL,
1896 `StockSerialNumber` int(11) NOT NULL,
1897 PRIMARY KEY (`Id`),
1898 KEY `StockSerialNumber` (`StockSerialNumber`),
1899 KEY `StockMoveItem` (`StockMoveItem`)
1900) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
1901 $Manager->Execute('ALTER TABLE `StockMoveItemSerialRel` ADD FOREIGN KEY (`StockMoveItem`) '.
1902 'REFERENCES `StockMoveItem`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1903 $Manager->Execute('ALTER TABLE `StockMoveItemSerialRel` ADD FOREIGN KEY (`StockSerialNumber`) '.
1904 'REFERENCES `StockSerialNumber`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
1905}
1906
1907function UpdateTo807(UpdateManager $Manager): void
1908{
1909 $Manager->Execute('ALTER TABLE `Product` ADD `StockMinCount` INT NOT NULL AFTER `UnitOfMeasure`;');
1910}
1911
1912function UpdateTo808(UpdateManager $Manager): void
1913{
1914 $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceTreasuryCheck` (
1915 `Id` int(11) NOT NULL AUTO_INCREMENT,
1916 `Treasury` int(11) NOT NULL,
1917 `Time` datetime NOT NULL,
1918 `Value1` int(11) NOT NULL,
1919 `Value2` int(11) NOT NULL,
1920 `Value5` int(11) NOT NULL,
1921 `Value10` int(11) NOT NULL,
1922 `Value20` int(11) NOT NULL,
1923 `Value50` int(11) NOT NULL,
1924 `Value100` int(11) NOT NULL,
1925 `Value200` int(11) NOT NULL,
1926 `Value500` int(11) NOT NULL,
1927 `Value1000` int(11) NOT NULL,
1928 `Value2000` int(11) NOT NULL,
1929 `Value5000` int(11) NOT NULL,
1930 PRIMARY KEY (`Id`),
1931 KEY `Treasury` (`Treasury`)
1932 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
1933 $Manager->Execute('ALTER TABLE `FinanceTreasuryCheck`
1934 ADD CONSTRAINT `FinanceTreasuryCheck_ibfk_1` FOREIGN KEY (`Treasury`) REFERENCES `FinanceTreasury` (`Id`);');
1935
1936 // IS menu item
1937 $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
1938`Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
1939NULL , "", "Kontrola pokladen", "1", "/is/?t=FinanceTreasuryCheck&a=list", NULL , NULL , NULL , "1");');
1940 $ActionId = $Manager->Database->insert_id;
1941 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Pokladny"');
1942 if ($DbResult->num_rows > 0)
1943 {
1944 $DbRow = $DbResult->fetch_assoc();
1945 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
1946 "VALUES (NULL , 'Kontrola pokladen', ".$DbRow['Id'].", '".$ActionId."', '1');");
1947 }
1948}
1949
1950function UpdateTo814(UpdateManager $Manager): void
1951{
1952 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkPort` (
1953 `Id` int(11) NOT NULL AUTO_INCREMENT,
1954 `Name` varchar(255) NOT NULL,
1955 `Interface` int(11) NOT NULL,
1956 `Number` int(11) NOT NULL,
1957 `Enabled` int(11) NOT NULL,
1958 `Online` int(11) NOT NULL,
1959 `LastOnline` datetime NULL,
1960 `OnlineNotify` int(11) NOT NULL,
1961 PRIMARY KEY (`Id`),
1962 KEY `Interface` (`Interface`)
1963 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
1964
1965 $Manager->Execute('ALTER TABLE `NetworkPort`
1966 ADD CONSTRAINT `NetworkPort_ibfk_1` FOREIGN KEY (`Interface`) REFERENCES `NetworkInterface` (`Id`);');
1967 $Manager->Execute('ALTER TABLE `NetworkInterface` ADD `Enabled` INT NOT NULL DEFAULT "1" AFTER `OnlineNotify`;');
1968 $Manager->Execute('ALTER TABLE `NetworkInterface` CHANGE `LastOnline` `LastOnline` DATETIME NULL;');
1969 $Manager->Execute('UPDATE `NetworkInterface` SET `LastOnline` = NULL WHERE `LastOnline` = "0000-00-00 00:00:00"');
1970 $Manager->Execute('ALTER TABLE `NetworkDevice` CHANGE `LastOnline` `LastOnline` DATETIME NULL;');
1971 $Manager->Execute('UPDATE `NetworkDevice` SET `LastOnline` = NULL WHERE `LastOnline` = "0000-00-00 00:00:00"');
1972}
1973
1974function UpdateTo817(UpdateManager $Manager): void
1975{
1976 $Manager->Execute('ALTER TABLE `NetworkConfiguration` ADD `SysName` VARCHAR(255) NOT NULL FIRST;');
1977 $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="LinuxDNS" WHERE `Id`=1');
1978 $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="LinuxIptables" WHERE `Id`=2');
1979 $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="LinuxTrafficShaping" WHERE `Id`=3');
1980 $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="LinuxDHCP" WHERE `Id`=4');
1981 $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="LinuxVPN" WHERE `Id`=5');
1982 $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="RouterosDHCP" WHERE `Id`=7');
1983 $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="RouterosNetwatch" WHERE `Id`=8');
1984 $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="RouterosQueue" WHERE `Id`=9');
1985 $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="RouterosFirewallNAT" WHERE `Id`=10');
1986 $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="RouterosFirewallMangle" WHERE `Id`=11');
1987 $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="RouterosFirewallFilter" WHERE `Id`=12');
1988 $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="RouterosDNS" WHERE `Id`=13');
1989 $Manager->Execute('ALTER TABLE `NetworkConfiguration` DROP `Execute`;');
1990}
1991
1992function UpdateTo818(UpdateManager $Manager): void
1993{
1994 $Manager->Execute('ALTER TABLE `NetworkPort` ADD `Protocol` INT NOT NULL AFTER `Enabled`;');
1995 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkPortUpDown` (
1996 `Id` int(11) NOT NULL AUTO_INCREMENT,
1997 `Time` datetime NOT NULL,
1998 `Port` int(11) NOT NULL,
1999 `State` int(11) NOT NULL,
2000 `Duration` int(11) DEFAULT NULL,
2001 PRIMARY KEY (`Id`),
2002 KEY `Port` (`Port`),
2003 KEY `Time` (`Time`)
2004 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;');
2005 $Manager->Execute('ALTER TABLE `NetworkPortUpDown`
2006 ADD CONSTRAINT `NetworkPortUpDown_ibfk_1` FOREIGN KEY (`Port`) REFERENCES `NetworkPort` (`Id`);');
2007}
2008
2009function UpdateTo824(UpdateManager $Manager): void
2010{
2011 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkInterfaceLatency` (
2012 `Id` int(11) NOT NULL AUTO_INCREMENT,
2013 `Time` datetime NOT NULL,
2014 `Interface` int(11) NOT NULL,
2015 `Value` float NOT NULL,
2016 PRIMARY KEY (`Id`),
2017 KEY `Interface` (`Interface`)
2018 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
2019 $Manager->Execute('ALTER TABLE `NetworkInterfaceLatency`
2020 ADD CONSTRAINT `NetworkInterfaceLatency_ibfk_1` FOREIGN KEY (`Interface`) REFERENCES `NetworkInterface` (`Id`);');
2021}
2022
2023function UpdateTo831(UpdateManager $Manager): void
2024{
2025 $Manager->Execute('ALTER TABLE `NetworkLinkType` '.
2026 'ADD `MaxLinkSpeed` INT NOT NULL AFTER `Name`, '.
2027 'ADD `MaxRealSpeed` INT NOT NULL AFTER `MaxLinkSpeed`, '.
2028 'ADD `FullDuplex` INT NOT NULL AFTER `MaxRealSpeed`, '.
2029 'ADD `Color` VARCHAR(6) NOT NULL AFTER `FullDuplex`');
2030
2031 $Manager->Execute('UPDATE `Service` SET `InternetSpeedMin`=`InternetSpeedMin`*1000;');
2032 $Manager->Execute('UPDATE `Service` SET `InternetSpeedMax`=`InternetSpeedMax`*1000;');
2033}
2034
2035function UpdateTo838(UpdateManager $Manager): void
2036{
2037 $Manager->Execute('ALTER TABLE `News` CHANGE `Date` `Date` DATETIME NULL, CHANGE `TargetDate` `TargetDate` DATETIME NULL;');
2038}
2039
2040function UpdateTo844(UpdateManager $Manager): void
2041{
2042 $Manager->Execute('ALTER TABLE `DocumentLine` ADD `Yearly` BOOLEAN NOT NULL DEFAULT FALSE AFTER `Shortcut`;');
2043}
2044
2045function UpdateTo855(UpdateManager $Manager): void
2046{
2047 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkDeviceLog` (
2048 `Id` int(11) NOT NULL AUTO_INCREMENT,
2049 `Time` datetime NOT NULL,
2050 `Device` int(11) NOT NULL,
2051 `Message` varchar(255) NOT NULL,
2052 `Tags` varchar(255) NOT NULL,
2053 PRIMARY KEY (`Id`),
2054 KEY `Device` (`Device`)
2055 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
2056 $Manager->Execute('ALTER TABLE `NetworkDeviceLog`
2057 ADD CONSTRAINT `NetworkDeviceLog_ibfk_1` FOREIGN KEY (`Device`) REFERENCES `NetworkDevice` (`Id`);');
2058}
2059
2060function UpdateTo862(UpdateManager $Manager): void
2061{
2062 $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD `Previous` INT NULL AFTER `Duration`');
2063 $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD INDEX ( `Previous` )');
2064 $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))');
2065}
2066
2067function UpdateTo867(UpdateManager $Manager): void
2068{
2069 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NotifyLog` (
2070 `Id` int(11) NOT NULL AUTO_INCREMENT,
2071 `Time` datetime NOT NULL,
2072 `Title` varchar(255) NOT NULL DEFAULT "",
2073 `Content` mediumtext NOT NULL DEFAULT "",
2074 PRIMARY KEY (`Id`),
2075 KEY `Time` (`Time`)
2076 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
2077}
2078
2079function UpdateTo869(UpdateManager $Manager): void
2080{
2081 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkSpeedLimit` (
2082 `Id` int(11) NOT NULL AUTO_INCREMENT,
2083 `Name` varchar(255) CHARACTER SET utf8 NOT NULL,
2084 `SpeedMaxOut` bigint(20) NOT NULL DEFAULT 0,
2085 `SpeedMaxIn` bigint(20) NOT NULL DEFAULT 0,
2086 `Parent` int(11) DEFAULT 0,
2087 PRIMARY KEY (`Id`),
2088 KEY `Parent` (`Parent`)
2089 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;');
2090 $Manager->Execute('ALTER TABLE `ServiceCustomerRel` ADD COLUMN `SpeedLimit` INT NULL AFTER `ChangeReplaceId`, ADD INDEX `SpeedLimit` (`SpeedLimit`);');
2091
2092 // IS menu item
2093 $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
2094 `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
2095 NULL , "", "Omezení rychlosti", "1", "/is/?t=NetworkSpeedLimit&a=list", NULL , NULL , NULL , "1");');
2096 $ActionId = $Manager->Database->insert_id;
2097 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Síť"');
2098 if ($DbResult->num_rows > 0)
2099 {
2100 $DbRow = $DbResult->fetch_assoc();
2101 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
2102 "VALUES (NULL , 'Omezení rychlosti', ".$DbRow['Id'].", '".$ActionId."', '1');");
2103 }
2104}
2105
2106function UpdateTo870(UpdateManager $Manager): void
2107{
2108 $Manager->Execute('ALTER TABLE `NetworkSubnet`ADD COLUMN `MaskIPv6` INT(11) NOT NULL AFTER `AddressRangeIPv6`;');
2109 $Manager->Execute('UPDATE `NetworkSubnet` SET `MaskIPv6`=64 WHERE `AddressRangeIPv6` != ""');
2110 $Manager->Execute('UPDATE `NetworkSubnet` SET `AddressRangeIPv6` = REPLACE(`AddressRangeIPv6`, "/64", "")');
2111}
2112
2113function UpdateTo878(UpdateManager $Manager): void
2114{
2115 $Manager->Execute('ALTER TABLE `NewsImport` ADD `Method` VARCHAR(255) NOT NULL AFTER `Category`;');
2116 $Manager->Execute('ALTER TABLE `NewsImport` ADD PRIMARY KEY (`Id`);');
2117 $Manager->Execute('ALTER TABLE `NewsImport` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;');
2118}
2119
2120function UpdateTo880(UpdateManager $Manager): void
2121{
2122 $Manager->Execute('ALTER TABLE `UserOnline` CHANGE `IpAddress` `IpAddress` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT "";');
2123 $Manager->Execute('ALTER TABLE `User` CHANGE `LastIpAddress` `LastIpAddress` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT "";');
2124 $Manager->Execute('ALTER TABLE `Log` CHANGE `IPAddress` `IPAddress` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;');
2125}
2126
2127function UpdateTo882(UpdateManager $Manager): void
2128{
2129 $Manager->Execute('ALTER TABLE `FinanceMonthlyOverall` CHANGE `Investment` `Investment` INT(11) NOT NULL DEFAULT "0";');
2130}
2131
2132function UpdateTo885(UpdateManager $Manager): void
2133{
2134 $Manager->Execute('ALTER TABLE `FinanceOperation` CHANGE `Value` `Value` FLOAT NOT NULL DEFAULT "0";');
2135 $Manager->Execute('ALTER TABLE `NetworkInterface` CHANGE `OnlineNotify` `OnlineNotify` INT(11) NOT NULL DEFAULT "0";');
2136}
2137
2138function UpdateTo901(UpdateManager $Manager): void
2139{
2140 $Manager->Execute('ALTER TABLE `Member` ADD `Contract` INT NULL DEFAULT NULL AFTER `ChangeReplaceId`;');
2141 $Manager->Execute('ALTER TABLE `Member` ADD FOREIGN KEY (`Contract`) REFERENCES `Contract`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
2142 $Manager->Execute("INSERT INTO `Module` (`Id`, `Name`, `Title`, `Version`, `Creator`, `License`, `Installed`, `HomePage`, `Description`) VALUES (NULL, 'Contract', '', '', '', '', '0', '', '');");
2143 $Manager->Execute("INSERT INTO `Module` (`Id`, `Name`, `Title`, `Version`, `Creator`, `License`, `Installed`, `HomePage`, `Description`) VALUES (NULL, 'Document', '', '', '', '', '0', '', '');");
2144 $Manager->Execute("INSERT INTO `PermissionOperation` (`Id`, `Module`, `Operation`, `Item`, `ItemId`) VALUES (NULL, '1', 'DisplayCustomerDocuments', '', '0');");
2145 $Manager->Execute("INSERT INTO `PermissionGroupAssignment` (`Id`, `Group`, `AssignedGroup`, `AssignedOperation`) VALUES (NULL, '3', NULL, '52');");
2146 $Manager->Execute('ALTER TABLE `File` ADD `Hash` VARCHAR(255) NOT NULL AFTER `Time`;');
2147 $Manager->Execute("UPDATE `File` SET `Hash` = SHA1(CONCAT(Id,Name,Size,Time))");
2148 $Manager->Execute("ALTER TABLE `Contract` ADD `Generate` INT NOT NULL DEFAULT '0' AFTER `File`;");
2149 $Manager->Execute("ALTER TABLE `Contract` DROP `BillCodeText`;");
2150 $Manager->Execute("INSERT INTO `FileDirectory` (`Id`, `Name`, `Parent`) VALUES (NULL, 'smlouvy', NULL);");
2151 $Manager->Execute("ALTER TABLE `Log` CHANGE `Value` `Value` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;");
2152 $Manager->Execute("INSERT INTO `PermissionOperation` (`Id`, `Module`, `Operation`, `Item`, `ItemId`) VALUES (NULL, '4', 'DownloadById', '', '0');");
2153 $Manager->Execute("INSERT INTO `PermissionGroupAssignment` (`Id`, `Group`, `AssignedGroup`, `AssignedOperation`) VALUES (NULL, '4', NULL, '53');");
2154}
2155
2156function UpdateTo907(UpdateManager $Manager): void
2157{
2158 $Manager->Execute('CREATE TABLE `AddressPlace` (
2159 `Id` int(11) NOT NULL,
2160 `Town` varchar(255) NOT NULL,
2161 `Street` varchar(255) NOT NULL,
2162 `HouseNumber` int(11) NOT NULL,
2163 `HouseNumberType` int(11) NOT NULL,
2164 `Psc` int(11) NOT NULL,
2165 `RuianCode` int(11) NOT NULL
2166) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
2167 $Manager->Execute('ALTER TABLE `AddressPlace` ADD PRIMARY KEY (`Id`);');
2168 $Manager->Execute('ALTER TABLE `AddressPlace` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;');
2169 $Manager->Execute('ALTER TABLE `Member` ADD `AddressPlace` INT NULL AFTER `Subject`;');
2170 $Manager->Execute('ALTER TABLE `Member` ADD KEY (`AddressPlace`);');
2171 $Manager->Execute('ALTER TABLE `Member` ADD FOREIGN KEY (`AddressPlace`) REFERENCES `AddressPlace`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
2172}
2173
2174function UpdateTo911(UpdateManager $Manager): void
2175{
2176 $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `Remote` INT NOT NULL DEFAULT "0" AFTER `Device`;');
2177}
2178
2179function UpdateTo921(UpdateManager $Manager): void
2180{
2181 $Manager->Execute('CREATE TABLE `NetworkMac` (
2182 `Id` int(11) NOT NULL,
2183 `MAC` varchar(17) NOT NULL
2184 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
2185 $Manager->Execute('ALTER TABLE `NetworkMac` ADD PRIMARY KEY (`Id`), ADD KEY `MAC` (`MAC`);');
2186 $Manager->Execute('ALTER TABLE `NetworkMac` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;');
2187
2188 // Convert NetworkSignal MAC from string into reference
2189 $Manager->Execute('INSERT INTO `NetworkMac` (`MAC`) SELECT DISTINCT(`MAC`) FROM `NetworkSignal`;');
2190 $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `MACTemp` INT NOT NULL AFTER `Remote`;');
2191 $Manager->Execute('UPDATE `NetworkSignal` SET `MACTemp` = (SELECT `Id` FROM `NetworkMac` WHERE `NetworkMac`.`MAC` = `NetworkSignal`.`MAC`);');
2192 $Manager->Execute('ALTER TABLE `NetworkSignal` DROP `MAC`;');
2193 $Manager->Execute('ALTER TABLE `NetworkSignal` CHANGE `MACTemp` `MAC` INT(11) NOT NULL;');
2194 $Manager->Execute('ALTER TABLE `NetworkSignal` ADD KEY `MAC` (`MAC`);');
2195 $Manager->Execute('ALTER TABLE `NetworkSignal` ADD FOREIGN KEY (`MAC`) REFERENCES `NetworkMac`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
2196
2197 // IS menu item
2198 $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
2199 `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
2200 NULL , "", "Fyzické adresy", "1", "/is/?t=NetworkMac&a=list", NULL , NULL , NULL , "1");');
2201 $ActionId = $Manager->Database->insert_id;
2202 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Síť"');
2203 if ($DbResult->num_rows > 0)
2204 {
2205 $DbRow = $DbResult->fetch_assoc();
2206 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
2207 "VALUES (NULL , 'Fyzické adresy', ".$DbRow['Id'].", '".$ActionId."', '1');");
2208 }
2209}
2210
2211function UpdateTo933(UpdateManager $Manager): void
2212{
2213 $Manager->Execute('ALTER TABLE `PermissionGroup` ADD `SysName` VARCHAR(255) NULL DEFAULT "" AFTER `Description`;');
2214 $Manager->Execute('UPDATE `PermissionGroup` SET `SysName`="admins" WHERE `Description`="Systémoví administrátoři"');
2215 $Manager->Execute('UPDATE `PermissionGroup` SET `SysName`="network-admins" WHERE `Description`="Správci sítě"');
2216 $Manager->Execute('UPDATE `PermissionGroup` SET `SysName`="registered-users" WHERE `Description`="Registrovaní uživatelé"');
2217 $Manager->Execute('UPDATE `PermissionGroup` SET `SysName`="other-users" WHERE `Description`="Ostatní"');
2218 $Manager->Execute('UPDATE `PermissionGroup` SET `SysName`="customers" WHERE `Description`="Zákazníci"');
2219}
2220
2221function UpdateTo939(UpdateManager $Manager): void
2222{
2223 $Manager->Execute('ALTER TABLE `Member` ADD `PaymentEmailTime` DATETIME NULL DEFAULT NULL AFTER `Contract`;');
2224 $Manager->Execute('UPDATE `Member` SET `PaymentEmailTime`=DATE_SUB(`BillingPeriodLastDate`, INTERVAL 1 MONTH) WHERE BillingPeriod=2 AND BillingPeriodLastDate<>"0000-00-00"');
2225 $Manager->Execute('UPDATE `Member` SET `PaymentEmailTime`=DATE_SUB(`BillingPeriodLastDate`, INTERVAL 3 MONTH) WHERE BillingPeriod=3 AND BillingPeriodLastDate<>"0000-00-00"');
2226 $Manager->Execute('UPDATE `Member` SET `PaymentEmailTime`=DATE_SUB(`BillingPeriodLastDate`, INTERVAL 6 MONTH) WHERE BillingPeriod=4 AND BillingPeriodLastDate<>"0000-00-00"');
2227 $Manager->Execute('UPDATE `Member` SET `PaymentEmailTime`=DATE_SUB(`BillingPeriodLastDate`, INTERVAL 12 MONTH) WHERE BillingPeriod=5 AND BillingPeriodLastDate<>"0000-00-00"');
2228 $Manager->Execute('ALTER TABLE `UserOnline` ENGINE = InnoDB;');
2229}
2230
2231function UpdateTo948(UpdateManager $Manager): void
2232{
2233 $Manager->Execute('ALTER TABLE `News` CHANGE `IP` `IP` VARCHAR(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL;');
2234}
2235
2236function UpdateTo953(UpdateManager $Manager): void
2237{
2238 $Manager->Execute('ALTER TABLE `News` ADD `Intranet` INT NOT NULL DEFAULT "0" AFTER `Link`;');
2239}
2240
2241function UpdateTo957(UpdateManager $Manager): void
2242{
2243 $Manager->Execute('ALTER TABLE `Log` ADD `URL` VARCHAR(255) NOT NULL AFTER `IPAddress`;');
2244}
2245
2246function UpdateTo967(UpdateManager $Manager): void
2247{
2248 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Roční výkazy"');
2249 if ($DbResult->num_rows > 0)
2250 {
2251 $DbRow = $DbResult->fetch_assoc();
2252
2253 $Manager->Execute("INSERT INTO `Action` (
2254 `Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` ,
2255 `Enable`) VALUES (NULL , '', 'Měsíční přehled', '1', '/is/?t=FinanceMonthReport&a=list', NULL , NULL , NULL , '1'
2256 );");
2257 $ActionId = $Manager->Database->insert_id;
2258 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
2259 "VALUES (NULL , 'Měsíční přehled', '".$DbRow['Id']."', '".$ActionId."', '1');");
2260 }
2261}
2262
2263function UpdateTo970(UpdateManager $Manager): void
2264{
2265 $Manager->Execute('ALTER TABLE `Service` ADD `InternetSpeedBonus` INT NULL DEFAULT NULL AFTER `InternetSpeedMin`;');
2266}
2267
2268class Updates
2269{
2270 function Get(): array
2271 {
2272 return array(
2273 491 => array('Revision' => 493, 'Function' => 'UpdateTo493'),
2274 493 => array('Revision' => 494, 'Function' => 'UpdateTo494'),
2275 494 => array('Revision' => 495, 'Function' => 'UpdateTo495'),
2276 495 => array('Revision' => 497, 'Function' => 'UpdateTo497'),
2277 497 => array('Revision' => 498, 'Function' => 'UpdateTo498'),
2278 498 => array('Revision' => 499, 'Function' => 'UpdateTo499'),
2279 499 => array('Revision' => 500, 'Function' => 'UpdateTo500'),
2280 500 => array('Revision' => 502, 'Function' => 'UpdateTo502'),
2281 502 => array('Revision' => 505, 'Function' => 'UpdateTo505'),
2282 505 => array('Revision' => 507, 'Function' => 'UpdateTo507'),
2283 507 => array('Revision' => 515, 'Function' => 'UpdateTo515'),
2284 515 => array('Revision' => 517, 'Function' => 'UpdateTo517'),
2285 517 => array('Revision' => 526, 'Function' => 'UpdateTo526'),
2286 526 => array('Revision' => 527, 'Function' => 'UpdateTo527'),
2287 527 => array('Revision' => 535, 'Function' => 'UpdateTo535'),
2288 535 => array('Revision' => 549, 'Function' => 'UpdateTo549'),
2289 549 => array('Revision' => 550, 'Function' => 'UpdateTo550'),
2290 550 => array('Revision' => 551, 'Function' => 'UpdateTo551'),
2291 551 => array('Revision' => 565, 'Function' => 'UpdateTo565'),
2292 565 => array('Revision' => 571, 'Function' => 'UpdateTo571'),
2293 571 => array('Revision' => 574, 'Function' => 'UpdateTo574'),
2294 574 => array('Revision' => 584, 'Function' => 'UpdateTo584'),
2295 584 => array('Revision' => 591, 'Function' => 'UpdateTo591'),
2296 591 => array('Revision' => 597, 'Function' => 'UpdateTo597'),
2297 597 => array('Revision' => 601, 'Function' => 'UpdateTo601'),
2298 601 => array('Revision' => 615, 'Function' => 'UpdateTo615'),
2299 615 => array('Revision' => 619, 'Function' => 'UpdateTo619'),
2300 619 => array('Revision' => 620, 'Function' => 'UpdateTo620'),
2301 620 => array('Revision' => 627, 'Function' => 'UpdateTo627'),
2302 627 => array('Revision' => 632, 'Function' => 'UpdateTo632'),
2303 632 => array('Revision' => 633, 'Function' => 'UpdateTo633'),
2304 633 => array('Revision' => 645, 'Function' => 'UpdateTo645'),
2305 645 => array('Revision' => 646, 'Function' => 'UpdateTo646'),
2306 646 => array('Revision' => 647, 'Function' => 'UpdateTo647'),
2307 647 => array('Revision' => 657, 'Function' => 'UpdateTo657'),
2308 657 => array('Revision' => 661, 'Function' => 'UpdateTo661'),
2309 661 => array('Revision' => 662, 'Function' => 'UpdateTo662'),
2310 662 => array('Revision' => 668, 'Function' => 'UpdateTo668'),
2311 668 => array('Revision' => 671, 'Function' => 'UpdateTo671'),
2312 671 => array('Revision' => 674, 'Function' => 'UpdateTo674'),
2313 674 => array('Revision' => 676, 'Function' => 'UpdateTo676'),
2314 676 => array('Revision' => 678, 'Function' => 'UpdateTo678'),
2315 678 => array('Revision' => 679, 'Function' => 'UpdateTo679'),
2316 679 => array('Revision' => 688, 'Function' => 'UpdateTo688'),
2317 688 => array('Revision' => 692, 'Function' => 'UpdateTo692'),
2318 692 => array('Revision' => 696, 'Function' => 'UpdateTo696'),
2319 696 => array('Revision' => 697, 'Function' => 'UpdateTo697'),
2320 697 => array('Revision' => 707, 'Function' => 'UpdateTo707'),
2321 707 => array('Revision' => 710, 'Function' => 'UpdateTo710'),
2322 710 => array('Revision' => 715, 'Function' => 'UpdateTo715'),
2323 715 => array('Revision' => 718, 'Function' => 'UpdateTo718'),
2324 718 => array('Revision' => 719, 'Function' => 'UpdateTo719'),
2325 719 => array('Revision' => 720, 'Function' => 'UpdateTo720'),
2326 720 => array('Revision' => 722, 'Function' => 'UpdateTo722'),
2327 722 => array('Revision' => 725, 'Function' => 'UpdateTo725'),
2328 725 => array('Revision' => 726, 'Function' => 'UpdateTo726'),
2329 726 => array('Revision' => 729, 'Function' => 'UpdateTo729'),
2330 729 => array('Revision' => 730, 'Function' => 'UpdateTo730'),
2331 730 => array('Revision' => 731, 'Function' => 'UpdateTo731'),
2332 731 => array('Revision' => 735, 'Function' => 'UpdateTo735'),
2333 735 => array('Revision' => 736, 'Function' => 'UpdateTo736'),
2334 736 => array('Revision' => 739, 'Function' => 'UpdateTo739'),
2335 739 => array('Revision' => 740, 'Function' => 'UpdateTo740'),
2336 740 => array('Revision' => 741, 'Function' => 'UpdateTo741'),
2337 741 => array('Revision' => 742, 'Function' => 'UpdateTo742'),
2338 742 => array('Revision' => 747, 'Function' => 'UpdateTo747'),
2339 747 => array('Revision' => 748, 'Function' => 'UpdateTo748'),
2340 748 => array('Revision' => 752, 'Function' => 'UpdateTo752'),
2341 752 => array('Revision' => 755, 'Function' => 'UpdateTo755'),
2342 755 => array('Revision' => 759, 'Function' => 'UpdateTo759'),
2343 759 => array('Revision' => 762, 'Function' => 'UpdateTo762'),
2344 762 => array('Revision' => 763, 'Function' => 'UpdateTo763'),
2345 763 => array('Revision' => 765, 'Function' => 'UpdateTo765'),
2346 765 => array('Revision' => 768, 'Function' => 'UpdateTo768'),
2347 768 => array('Revision' => 770, 'Function' => 'UpdateTo770'),
2348 770 => array('Revision' => 785, 'Function' => 'UpdateTo785'),
2349 785 => array('Revision' => 786, 'Function' => 'UpdateTo786'),
2350 786 => array('Revision' => 792, 'Function' => 'UpdateTo792'),
2351 792 => array('Revision' => 800, 'Function' => 'UpdateTo800'),
2352 800 => array('Revision' => 802, 'Function' => 'UpdateTo802'),
2353 802 => array('Revision' => 803, 'Function' => 'UpdateTo803'),
2354 803 => array('Revision' => 807, 'Function' => 'UpdateTo807'),
2355 807 => array('Revision' => 808, 'Function' => 'UpdateTo808'),
2356 808 => array('Revision' => 814, 'Function' => 'UpdateTo814'),
2357 814 => array('Revision' => 817, 'Function' => 'UpdateTo817'),
2358 817 => array('Revision' => 818, 'Function' => 'UpdateTo818'),
2359 818 => array('Revision' => 824, 'Function' => 'UpdateTo824'),
2360 824 => array('Revision' => 831, 'Function' => 'UpdateTo831'),
2361 831 => array('Revision' => 838, 'Function' => 'UpdateTo838'),
2362 838 => array('Revision' => 844, 'Function' => 'UpdateTo844'),
2363 844 => array('Revision' => 855, 'Function' => 'UpdateTo855'),
2364 855 => array('Revision' => 862, 'Function' => 'UpdateTo862'),
2365 862 => array('Revision' => 867, 'Function' => 'UpdateTo867'),
2366 867 => array('Revision' => 869, 'Function' => 'UpdateTo869'),
2367 869 => array('Revision' => 870, 'Function' => 'UpdateTo870'),
2368 870 => array('Revision' => 878, 'Function' => 'UpdateTo878'),
2369 878 => array('Revision' => 880, 'Function' => 'UpdateTo880'),
2370 880 => array('Revision' => 882, 'Function' => 'UpdateTo882'),
2371 882 => array('Revision' => 885, 'Function' => 'UpdateTo885'),
2372 885 => array('Revision' => 901, 'Function' => 'UpdateTo901'),
2373 901 => array('Revision' => 907, 'Function' => 'UpdateTo907'),
2374 907 => array('Revision' => 911, 'Function' => 'UpdateTo911'),
2375 911 => array('Revision' => 921, 'Function' => 'UpdateTo921'),
2376 921 => array('Revision' => 933, 'Function' => 'UpdateTo933'),
2377 933 => array('Revision' => 939, 'Function' => 'UpdateTo939'),
2378 939 => array('Revision' => 948, 'Function' => 'UpdateTo948'),
2379 948 => array('Revision' => 953, 'Function' => 'UpdateTo953'),
2380 953 => array('Revision' => 957, 'Function' => 'UpdateTo957'),
2381 957 => array('Revision' => 967, 'Function' => 'UpdateTo967'),
2382 967 => array('Revision' => 970, 'Function' => 'UpdateTo970'),
2383 );
2384 }
2385}
Note: See TracBrowser for help on using the repository browser.