Changeset 891
- Timestamp:
- Dec 30, 2020, 11:52:07 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/FormClasses.php
r887 r891 21 21 'Operation' => array('Type' => 'TFinanceOperation', 'Caption' => 'Platba', 'Default' => ''), 22 22 ), 23 ),24 'DocumentLine' => array(25 'Title' => 'Dokladové řady',26 'Table' => 'DocumentLine',27 'DefaultSortColumn' => 'Name',28 'Items' => array(29 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),30 'Shortcut' => array('Type' => 'String', 'Caption' => 'Kód', 'Default' => ''),31 'Yearly' => array('Type' => 'Boolean', 'Caption' => 'Ročně', 'Default' => 0),32 'Sequence' => array('Type' => 'TDocumentLineSequenceListLine', 'Caption' => 'Čísleníky', 'Default' => ''),33 'Codes' => array('Type' => 'TDocumentLineCodeList', 'Caption' => 'Kódy', 'Default' => ''),34 'Operations' => array('Type' => 'TFinanceOperationGroupListDocumentLine', 'Caption' => 'Skupiny finančních operací', 'Default' => ''),35 'Invoices' => array('Type' => 'TFinanceInvoiceGroupListDocumentLine', 'Caption' => 'Skupiny faktur', 'Default' => ''),36 ),37 ),38 'DocumentLineSequence' => array(39 'Title' => 'Čísleníky dokladových řad',40 'Table' => 'DocumentLineSequence',41 'DefaultSortColumn' => 'Id',42 'Items' => array(43 'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''),44 'FinanceYear' => array('Type' => 'TFinanceYear', 'Caption' => 'Účetní rok', 'Default' => ''),45 'NextNumber' => array('Type' => 'Integer', 'Caption' => 'Další číslo', 'Default' => '1'),46 'YearPrefix' => array('Type' => 'Boolean', 'Caption' => 'Rok jako přípona', 'Default' => '1'),47 ),48 ),49 'DocumentLineCode' => array(50 'Title' => 'Kód dokladových řad',51 'Table' => 'DocumentLineCode',52 'DefaultSortColumn' => 'Name',53 'Items' => array(54 'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''),55 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),56 ),57 ),58 'FinanceYear' => array(59 'Title' => 'Účetní roky',60 'Table' => 'FinanceYear',61 'DefaultSortColumn' => 'Year',62 'DefaultSortOrder' => 1,63 'Items' => array(64 'Year' => array('Type' => 'Integer', 'Caption' => 'Rok', 'Default' => ''),65 'DateStart' => array('Type' => 'Date', 'Caption' => 'První den', 'Default' => ''),66 'DateEnd' => array('Type' => 'Date', 'Caption' => 'Poslední den', 'Default' => ''),67 'Closed' => array('Type' => 'Boolean', 'Caption' => 'Uzavřen', 'Default' => 0),68 'Sequence' => array('Type' => 'TDocumentLineSequenceListYear', 'Caption' => 'Čísleníky', 'Default' => ''),69 ),70 //'AfterInsert' => array($this, 'AfterInsertFinanceYear'),71 23 ), 72 24 'FinanceYearReport' => array( … … 178 130 'Filter' => '1', 179 131 ), 180 'TDocumentLine' => array(181 'Type' => 'Reference',182 'Table' => 'DocumentLine',183 'Id' => 'Id',184 'Name' => 'Name',185 'Filter' => '1',186 ),187 'TDocumentLineCode' => array(188 'Type' => 'Reference',189 'Table' => 'DocumentLineCode',190 'Id' => 'Id',191 'Name' => 'Name',192 'Filter' => '1',193 ),194 132 'TStockSerialNumberListStock' => array( 195 133 'Type' => 'ManyToOne', -
trunk/Modules/Customer/Customer.php
r890 r891 191 191 } 192 192 193 static function GetModels(): array 194 { 195 return array( 196 'Member', 197 'MemberPayment', 198 'SupportActivity', 199 'ServiceCategory', 200 'Service', 201 'ServiceCustomerRel', 202 ); 203 } 204 193 205 function DoInstall(): void 194 206 { 195 $this->InstallModel(Member::GetDesc()); 196 $this->InstallModel(MemberPayment::GetDesc()); 197 $this->InstallModel(SupportActivity::GetDesc()); 198 $this->InstallModel(ServiceCategory::GetDesc()); 199 $this->InstallModel(Service::GetDesc()); 200 $this->InstallModel(ServiceCustomerRel::GetDesc()); 207 foreach (self::GetModels() as $Model) 208 { 209 $this->InstallModel($Model::GetDesc()); 210 } 201 211 } 202 212 203 213 function Uninstall(): void 204 214 { 205 $this->UninstallModel(ServiceCustomerRel::GetDesc()); 206 $this->UninstallModel(Service::GetDesc()); 207 $this->UninstallModel(ServiceCategory::GetDesc()); 208 $this->UninstallModel(SupportActivity::GetDesc()); 209 $this->UninstallModel(MemberPayment::GetDesc()); 210 $this->UninstallModel(Member::GetDesc()); 215 foreach (array_reverse(self::GetModels()) as $Model) 216 { 217 $this->UninstallModel($Model::GetDesc()); 218 } 211 219 } 212 220 -
trunk/Modules/File/File.php
r890 r891 18 18 $Desc->AddString('Name'); 19 19 $Desc->AddInteger('Size'); 20 $Column = $Desc->AddReference('Directory', 'FileDirectory'); 21 $Column->Nullable = true; 20 $Desc->AddReference('Directory', 'FileDirectory', true); 22 21 $Desc->AddDateTime('Time'); 23 22 return $Desc; … … 121 120 $Desc = new ModelDesc('FileDirectory'); 122 121 $Desc->AddString('Name'); 123 $Column = $Desc->AddReference('Parent', 'FileDirectory'); 124 $Column->Nullable = true; 122 $Desc->AddReference('Parent', 'FileDirectory', true); 125 123 return $Desc; 126 124 } -
trunk/Modules/Finance/Finance.php
r890 r891 221 221 } 222 222 223 class FinanceGroup extends Model 224 { 225 static function GetDesc(): ModelDesc 226 { 227 $Desc = new ModelDesc('FinanceGroup'); 228 $Desc->AddString('Description'); 229 return $Desc; 230 } 231 } 232 233 class FinanceOperation extends Model 234 { 235 static function GetDesc(): ModelDesc 236 { 237 $Desc = new ModelDesc('FinanceOperation'); 238 $Desc->AddReference('Group', 'FinanceGroup'); 239 $Desc->AddDateTime('Time'); 240 $Desc->AddReference('Subject', 'Subject'); 241 $Desc->AddBoolean('Cash'); 242 $Desc->AddFloat('Value'); 243 $Desc->AddFloat('ValueUser'); 244 $Desc->AddReference('BillCode', 'DocumentLineCode'); 245 $Desc->AddBoolean('Taxable'); 246 $Desc->AddReference('File', 'File'); 247 $Desc->AddString('Text'); 248 $Desc->AddBoolean('Network'); 249 $Desc->AddReference('BankAccount', 'FinanceBankAccount'); 250 $Desc->AddReference('Treasury', 'FinanceTreasury'); 251 $Desc->AddBoolean('Generate'); 252 return $Desc; 253 } 254 } 255 256 class FinanceOperationGroup extends Model 257 { 258 static function GetDesc(): ModelDesc 259 { 260 $Desc = new ModelDesc('FinanceOperationGroup'); 261 $Desc->AddString('Name'); 262 $Desc->AddReference('DocumentLine', 'DocumentLine'); 263 $Desc->AddInteger('ValueSign'); 264 $Desc->AddInteger('Direction'); 265 return $Desc; 266 } 267 } 268 269 class FinanceInvoice extends Model 270 { 271 static function GetDesc(): ModelDesc 272 { 273 $Desc = new ModelDesc('FinanceInvoice'); 274 $Desc->AddReference('Group', 'FinanceGroup'); 275 $Desc->AddReference('BillCode', 'DocumentLineCode'); 276 $Desc->AddReference('Subject', 'Subject'); 277 $Desc->AddDateTime('Time'); 278 $Desc->AddDateTime('TimeDue'); 279 $Desc->AddDateTime('TimePayment'); 280 $Desc->AddFloat('Value'); 281 $Desc->AddReference('File', 'File'); 282 $Desc->AddDate('PeriodFrom'); 283 $Desc->AddDate('PeriodTo'); 284 $Desc->AddBoolean('Cash'); 285 $Desc->AddBoolean('Generate'); 286 $Desc->AddBoolean('VisibleToUser'); 287 return $Desc; 288 } 289 } 290 291 class FinanceInvoiceGroup extends Model 292 { 293 static function GetDesc(): ModelDesc 294 { 295 $Desc = new ModelDesc('FinanceInvoiceGroup'); 296 $Desc->AddString('Name'); 297 $Desc->AddReference('DocumentLine', 'DocumentLine'); 298 $Desc->AddInteger('ValueSign'); 299 $Desc->AddInteger('Direction'); 300 return $Desc; 301 } 302 } 303 304 class Company extends Model 305 { 306 static function GetDesc(): ModelDesc 307 { 308 $Desc = new ModelDesc('Company'); 309 $Desc->AddString('Name'); 310 $Desc->AddReference('Subject', 'Subject'); 311 return $Desc; 312 } 313 } 314 315 class FinanceInvoiceItem extends Model 316 { 317 static function GetDesc(): ModelDesc 318 { 319 $Desc = new ModelDesc('FinanceInvoiceItem'); 320 $Desc->AddReference('FinanceInvoice', 'FinanceInvoice'); 321 $Desc->AddString('Description'); 322 $Desc->AddFloat('Price'); 323 $Desc->AddFloat('Quantity'); 324 $Desc->AddInteger('VAT'); 325 return $Desc; 326 } 327 } 328 329 class FinanceTreasury extends Model 330 { 331 static function GetDesc(): ModelDesc 332 { 333 $Desc = new ModelDesc('FinanceTreasury'); 334 $Desc->AddString('Name'); 335 $Desc->AddDate('TimeCreate'); 336 return $Desc; 337 } 338 } 339 340 class FinanceTreasuryCheck extends Model 341 { 342 static function GetDesc(): ModelDesc 343 { 344 $Desc = new ModelDesc('FinanceTreasuryCheck'); 345 $Desc->AddReference('Treasury', 'FinanceTreasury', false); 346 $Desc->AddDateTime('Time'); 347 $Desc->AddInteger('Value1'); 348 $Desc->AddInteger('Value2'); 349 $Desc->AddInteger('Value5'); 350 $Desc->AddInteger('Value10'); 351 $Desc->AddInteger('Value20'); 352 $Desc->AddInteger('Value50'); 353 $Desc->AddInteger('Value100'); 354 $Desc->AddInteger('Value200'); 355 $Desc->AddInteger('Value500'); 356 $Desc->AddInteger('Value1000'); 357 $Desc->AddInteger('Value2000'); 358 $Desc->AddInteger('Value5000'); 359 return $Desc; 360 } 361 } 362 363 class FinanceBankAccount extends Model 364 { 365 static function GetDesc(): ModelDesc 366 { 367 $Desc = new ModelDesc('FinanceBankAccount'); 368 $Desc->AddReference('Subject', 'Subject'); 369 $Desc->AddString('Comment'); 370 $Desc->AddString('Number'); 371 $Desc->AddReference('Bank', 'FinanceBank'); 372 $Desc->AddDate('TimeCreate'); 373 $Desc->AddDate('TimeEnd'); 374 $Desc->AddReference('Currency', 'Currency'); 375 $Desc->AddString('LoginName'); 376 $Desc->AddString('LoginPassword'); 377 $Desc->AddBoolean('Use'); 378 $Desc->AddDate('LastImportDate'); 379 $Desc->AddString('LastImportId'); 380 $Desc->AddBoolean('AutoImport'); 381 return $Desc; 382 } 383 } 384 385 class FinanceBank extends Model 386 { 387 static function GetDesc(): ModelDesc 388 { 389 $Desc = new ModelDesc('FinanceBank'); 390 $Desc->AddString('Name'); 391 $Desc->AddString('Code'); 392 $Desc->AddString('BIC'); 393 $Desc->AddReference('Country', 'Country'); 394 return $Desc; 395 } 396 } 397 398 class Currency extends Model 399 { 400 static function GetDesc(): ModelDesc 401 { 402 $Desc = new ModelDesc('Currency'); 403 $Desc->AddString('Code'); 404 $Desc->AddString('Name'); 405 $Desc->AddString('Symbol'); 406 return $Desc; 407 } 408 } 409 410 class FinanceCharge extends Model 411 { 412 static function GetDesc(): ModelDesc 413 { 414 $Desc = new ModelDesc('FinanceCharge'); 415 $Desc->AddInteger('Internet'); 416 $Desc->AddInteger('InternetSpeed'); 417 $Desc->AddInteger('InternetSpeedReserve'); 418 $Desc->AddInteger('AdministrationPerUser'); 419 $Desc->AddInteger('kWh'); 420 $Desc->AddInteger('BaseSpeedElement'); 421 $Desc->AddInteger('BaseTariffPrice'); 422 $Desc->AddInteger('TopTariffPrice'); 423 $Desc->AddChangeAction(); 424 return $Desc; 425 } 426 } 427 428 class FinanceVat extends Model 429 { 430 static function GetDesc(): ModelDesc 431 { 432 $Desc = new ModelDesc('FinanceVAT'); 433 $Desc->AddReference('Type', 'FinanceVatType'); 434 $Desc->AddDate('ValidFrom'); 435 $Desc->AddDate('ValidTo'); 436 $Desc->AddInteger('Value'); 437 return $Desc; 438 } 439 } 440 441 class FinanceVatType extends Model 442 { 443 static function GetDesc(): ModelDesc 444 { 445 $Desc = new ModelDesc('FinanceVATType'); 446 $Desc->AddString('Name'); 447 return $Desc; 448 } 449 } 450 451 class Contract extends Model 452 { 453 static function GetDesc(): ModelDesc 454 { 455 $Desc = new ModelDesc('Contract'); 456 $Desc->AddReference('DocumentLine', 'DocumentLine'); 457 $Desc->AddReference('BillCode', 'DocumentLineCode'); 458 $Desc->AddReference('Subject', 'Subject'); 459 $Desc->AddDate('ValidFrom'); 460 $Desc->AddDate('ValidTo'); 461 $Desc->AddReference('File', 'File'); 462 return $Desc; 463 } 464 } 465 223 466 class ModuleFinance extends AppModule 224 467 { … … 234 477 $this->License = 'GNU/GPLv3'; 235 478 $this->Description = 'Base module for finance management'; 236 $this->Dependencies = array('File', 'EmailQueue' );479 $this->Dependencies = array('File', 'EmailQueue', 'Subject', 'Document'); 237 480 238 481 $this->Bill = new Bill($this->System); … … 240 483 } 241 484 485 static function GetModels(): array 486 { 487 return array( 488 'FinanceVatType', 489 'FinanceVat', 490 'FinanceGroup', 491 'FinanceOperationGroup', 492 'FinanceOperation', 493 'FinanceInvoiceGroup', 494 'FinanceInvoice', 495 'FinanceInvoiceItem', 496 'Company', 497 'FinanceTreasury', 498 'FinanceTreasuryCheck', 499 'Currency', 500 'FinanceBank', 501 'FinanceBankAccount', 502 'FinanceCharge', 503 'Contract' 504 ); 505 } 506 242 507 function DoInstall(): void 243 508 { 509 foreach (self::GetModels() as $Model) 510 { 511 $this->InstallModel($Model::GetDesc()); 512 } 244 513 } 245 514 246 515 function DoUninstall(): void 247 516 { 517 foreach (array_reverse(self::GetModels()) as $Model) 518 { 519 $this->UninstallModel($Model::GetDesc()); 520 } 248 521 } 249 522 … … 277 550 'Treasury' => array('Type' => 'TFinanceTreasury', 'Caption' => 'Pokladna', 'Default' => '', 'Null' => true), 278 551 'Generate' => array('Type' => 'Boolean', 'Caption' => 'Generovat', 'Default' => ''), 279 'Balance' => array('Type' => 'Integer', 'Caption' => 'Zůstatek', 'Default' => '', 552 'Balance' => array('Type' => 'Integer', 'Caption' => 'Zůstatek', 'Default' => '', 280 553 'ReadOnly' => true, 'SQL' => '(SELECT SUM(`FinanceOperation2`.`Value`) FROM `FinanceOperation` AS `FinanceOperation2` WHERE `FinanceOperation2`.`Time`<`Time`)'), 281 554 'InvoiceRel' => array('Type' => 'TFinanceInvoiceOperationRelListOperation', 'Caption' => 'Zaplacené faktury', 'Default' => ''), … … 291 564 ), 292 565 )); 293 566 294 567 $this->System->FormManager->RegisterClass('FinanceTreasuryIn', $this->System->FormManager->Classes['FinanceOperation']); 295 568 $this->System->FormManager->Classes['FinanceTreasuryIn']['Title'] = 'Pokladní příjmy'; -
trunk/Modules/Map/Map.php
r887 r891 316 316 function DoInstall(): void 317 317 { 318 $this->System->Database->query("CREATE TABLE IF NOT EXISTS `MapPosition` ( 319 `Id` int(11) NOT NULL AUTO_INCREMENT, 320 `Name` varchar(255) NOT NULL, 321 `Pos` varchar(255) NOT NULL, 322 PRIMARY KEY (`Id`) 323 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"); 318 $this->InstallModel(MapPosition::GetDesc()); 324 319 } 325 320 326 321 function DoUninstall(): void 327 322 { 328 $this->Database->query('DROP TABLE `MapPosition`'); 329 } 330 } 323 $this->UninstallModel(MapPosition::GetDesc()); 324 } 325 } 326 327 class MapPosition extends Model 328 { 329 static function GetDesc(): ModelDesc 330 { 331 $Desc = new ModelDesc('MapPosition'); 332 $Desc->AddString('Name'); 333 $Desc->AddString('Pos'); 334 return $Desc; 335 } 336 } -
trunk/Modules/News/News.php
r887 r891 28 28 } 29 29 30 static function GetModels(): array 31 { 32 return array( 33 'NewsCategory', 34 'News', 35 ); 36 } 37 30 38 function DoInstall(): void 31 39 { 40 foreach (self::GetModels() as $Model) 41 { 42 $this->InstallModel($Model::GetDesc()); 43 } 32 44 } 33 45 34 46 function DoUnInstall(): void 35 47 { 48 foreach (array_reverse(self::GetModels()) as $Model) 49 { 50 $this->UninstallModel($Model::GetDesc()); 51 } 36 52 } 37 53 … … 284 300 } 285 301 } 302 303 class News extends Model 304 { 305 static function GetDesc(): ModelDesc 306 { 307 $Desc = new ModelDesc('News'); 308 $Desc->AddReference('Category', 'NewsCategory', true); 309 $Desc->AddString('Title'); 310 $Desc->AddText('Content'); 311 $Desc->AddDate('Date'); 312 $Desc->AddString('Author'); 313 $Desc->AddString('Enclosure'); 314 $Desc->AddReference('User', 'User'); 315 $Desc->AddString('IP'); 316 $Desc->AddString('Link'); 317 return $Desc; 318 } 319 } 320 321 class NewsCategory extends Model 322 { 323 static function GetDesc(): ModelDesc 324 { 325 $Desc = new ModelDesc('NewsCategory'); 326 $Desc->AddString('Caption'); 327 $Desc->AddString('RSS'); 328 $Desc->AddBoolean('Permission'); 329 $Desc->AddInteger('Sequence'); 330 $Desc->AddInteger('Group'); 331 return $Desc; 332 } 333 } -
trunk/Modules/Notify/Notify.php
r887 r891 128 128 } 129 129 130 static function GetModels(): array 131 { 132 return array( 133 'NotifyCategory', 134 'NotifyUser', 135 ); 136 } 137 130 138 function DoInstall(): void 131 139 { 132 $this->Database->query('CREATE TABLE IF NOT EXISTS `NotifyCategory` ( 133 `Id` int(11) NOT NULL AUTO_INCREMENT, 134 `Name` varchar(255) NOT NULL, 135 `SysName` varchar(255) NOT NULL, 136 PRIMARY KEY (`Id`) 137 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;'); 140 foreach (self::GetModels() as $Model) 141 { 142 $this->InstallModel($Model::GetDesc()); 143 } 138 144 139 145 $this->Database->query("INSERT INTO `NotifyCategory` (`Id`, `Name`, `SysName`) VALUES … … 144 150 (5, 'Minimální odezva', 'NetworkLatency'), 145 151 (6, 'Minimální propustnost', 'NetworkBandwidth');"); 146 147 $this->Database->query('148 CREATE TABLE IF NOT EXISTS `NotifyUser` (149 `Id` int(11) NOT NULL AUTO_INCREMENT,150 `User` int(11) NOT NULL,151 `Contact` int(11) NOT NULL,152 `Period` int(11) NOT NULL,153 PRIMARY KEY (`Id`),154 KEY `User` (`User`),155 KEY `Contact` (`Contact`)156 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;');157 $this->Database->query('ALTER TABLE `NotifyUser`158 ADD CONSTRAINT `NotifyUser_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`Id`),159 ADD CONSTRAINT `NotifyUser_ibfk_2` FOREIGN KEY (`Contact`) REFERENCES `Contact` (`Id`);');160 152 } 161 153 162 154 function DoUninstall(): void 163 155 { 164 $this->Database->query('DROP TABLE `NotifyUser`'); 165 $this->Database->query('DROP TABLE `NotifyCategory`'); 156 foreach (array_reverse(self::GetModels()) as $Model) 157 { 158 $this->UninstallModel($Model::GetDesc()); 159 } 166 160 } 167 161 … … 207 201 } 208 202 } 203 204 class NotifyCategory extends Model 205 { 206 static function GetDesc(): ModelDesc 207 { 208 $Desc = new ModelDesc('NotifyCategory'); 209 $Desc->AddString('Name'); 210 $Desc->AddString('SysName'); 211 return $Desc; 212 } 213 } 214 215 class NotifyUser extends Model 216 { 217 static function GetDesc(): ModelDesc 218 { 219 $Desc = new ModelDesc('NotifyUser'); 220 $Desc->AddReference('User', 'User'); 221 $Desc->AddReference('Contact', 'Contact'); 222 $Desc->AddInteger('Period'); 223 return $Desc; 224 } 225 } -
trunk/Modules/Subject/Subject.php
r887 r891 133 133 function DoInstall(): void 134 134 { 135 $this->Database->query("CREATE TABLE IF NOT EXISTS `Subject` ( 136 `Id` int(11) NOT NULL AUTO_INCREMENT, 137 `Name` varchar(64) NOT NULL DEFAULT '', 138 `AddressStreet` varchar(64) NOT NULL DEFAULT '', 139 `AddressTown` varchar(64) NOT NULL DEFAULT '', 140 `AddressPSC` int(11) NOT NULL DEFAULT '0', 141 `AddressCountry` int(11) NOT NULL, 142 `IC` varchar(32) NOT NULL, 143 `DIC` varchar(32) NOT NULL DEFAULT '', 144 `PayVAT` int(11) NOT NULL, 145 `MapPosition` int(11) DEFAULT NULL, 146 `WWW` varchar(255) NOT NULL, 147 `Note` varchar(255) NOT NULL, 148 PRIMARY KEY (`Id`) 149 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"); 150 $this->Database->query("CREATE TABLE IF NOT EXISTS `Contact` ( 151 `Id` int(11) NOT NULL AUTO_INCREMENT, 152 `Category` int(11) NOT NULL, 153 `Value` varchar(255) NOT NULL, 154 `Subject` int(11) DEFAULT NULL, 155 `User` int(11) DEFAULT NULL, 156 `Description` varchar(255) NOT NULL, 157 `Receive` tinyint(1) NOT NULL, 158 PRIMARY KEY (`Id`) 159 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"); 160 $this->System->Database->query("CREATE TABLE IF NOT EXISTS `ContactCategory` ( 161 `Id` int(11) NOT NULL AUTO_INCREMENT, 162 `Name` varchar(255) NOT NULL, 163 PRIMARY KEY (`Id`) 164 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"); 165 166 $this->Database->query("ALTER TABLE `Subject` 167 ADD CONSTRAINT `Subject_ibfk_1` FOREIGN KEY (`AddressCountry`) REFERENCES `Country` (`Id`), 168 ADD CONSTRAINT `Subject_ibfk_2` FOREIGN KEY (`MapPosition`) REFERENCES `MapPosition` (`Id`);"); 169 $this->Database->query("ALTER TABLE `Contact` 170 ADD CONSTRAINT `Contact_ibfk_1` FOREIGN KEY (`Category`) REFERENCES `ContactCategory` (`Id`), 171 ADD CONSTRAINT `Contact_ibfk_2` FOREIGN KEY (`Subject`) REFERENCES `Subject` (`Id`), 172 ADD CONSTRAINT `Contact_ibfk_3` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);"); 135 $this->InstallModel(Country::GetDesc()); 136 $this->InstallModel(Subject::GetDesc()); 137 $this->InstallModel(ContactCategory::GetDesc()); 138 $this->InstallModel(Contact::GetDesc()); 173 139 } 174 140 175 141 function DoUninstall(): void 176 142 { 177 $this->Database->query('DROP TABLE `Contact`'); 178 $this->Database->query('DROP TABLE `ContactCategory`'); 179 $this->Database->query('DROP TABLE `Subject`'); 143 $this->UninstallModel(Contact::GetDesc()); 144 $this->UninstallModel(ContactCategory::GetDesc()); 145 $this->UninstallModel(Subject::GetDesc()); 146 $this->UninstallModel(Country::GetDesc()); 180 147 } 181 148 … … 188 155 } 189 156 } 157 158 class Subject extends Model 159 { 160 static function GetDesc(): ModelDesc 161 { 162 $Desc = new ModelDesc('Subject'); 163 $Desc->AddString('Name'); 164 $Desc->AddString('AddressStreet'); 165 $Desc->AddString('AddressTown'); 166 $Desc->AddString('AddressPSC'); 167 $Desc->AddReference('AddressCountry', 'Country', true); 168 $Desc->AddString('IC'); 169 $Desc->AddString('DIC'); 170 $Desc->AddBoolean('PayVAT'); 171 $Desc->AddReference('MapPosition', 'MapPosition', true); 172 $Desc->AddString('WWW'); 173 $Desc->AddString('Note'); 174 return $Desc; 175 } 176 } 177 178 class Country extends Model 179 { 180 static function GetDesc(): ModelDesc 181 { 182 $Desc = new ModelDesc('Country'); 183 $Desc->AddString('Name'); 184 return $Desc; 185 } 186 } 187 188 class Contact extends Model 189 { 190 static function GetDesc(): ModelDesc 191 { 192 $Desc = new ModelDesc('Contact'); 193 $Desc->AddReference('Category', 'ContactCategory', true); 194 $Desc->AddString('Value'); 195 $Desc->AddReference('Subject', 'Subject', true); 196 $Desc->AddReference('User', 'User', true); 197 $Desc->AddString('Description'); 198 $Desc->AddBoolean('Receive'); 199 return $Desc; 200 } 201 } 202 203 class ContactCategory extends Model 204 { 205 static function GetDesc(): ModelDesc 206 { 207 $Desc = new ModelDesc('ContactCategory'); 208 $Desc->AddString('Name'); 209 return $Desc; 210 } 211 } -
trunk/Modules/User/UserModel.php
r890 r891 460 460 $Desc = new ModelDesc('UserOnline'); 461 461 $Desc->Memory = true; 462 $Column = $Desc->AddReference('User', 'User'); 463 $Column->Nullable = true; 462 $Desc->AddReference('User', 'User', true); 464 463 $Desc->AddDateTime('ActivityTime'); 465 464 $Desc->AddDateTime('LoginTime'); … … 490 489 $Desc = new ModelDesc('PermissionGroupAssignment'); 491 490 $Desc->AddReference('Group', 'PermissionGroup'); 492 $Column = $Desc->AddReference('AssignedGroup', 'PermissionGroup'); 493 $Column->Nullable = true; 494 $Column = $Desc->AddReference('AssignedOperation', 'PermissionOperation'); 495 $Column->Nullable = true; 491 $Desc->AddReference('AssignedGroup', 'PermissionGroup', true); 492 $Desc->AddReference('AssignedOperation', 'PermissionOperation', true); 496 493 return $Desc; 497 494 } … … 518 515 $Desc = new ModelDesc('PermissionUserAssignment'); 519 516 $Desc->AddReference('User', 'User'); 520 $Column = $Desc->AddReference('AssignedGroup', 'PermissionGroup'); 521 $Column->Nullable = true; 522 $Column = $Desc->AddReference('AssignedOperation', 'PermissionOperation'); 523 $Column->Nullable = true; 517 $Desc->AddReference('AssignedGroup', 'PermissionGroup', true); 518 $Desc->AddReference('AssignedOperation', 'PermissionOperation', true); 524 519 return $Desc; 525 520 } -
trunk/Packages/Common/AppModule.php
r890 r891 73 73 } 74 74 75 static function GetModels(): array 76 { 77 return array(); 78 } 79 75 80 function Install(): void 76 81 { … … 90 95 $this->Stop(); 91 96 $this->Installed = false; 92 $List = array(); 97 $List = array(); 93 98 $this->Manager->EnumSuperiorDependenciesCascade($this, $List, array(ModuleCondition::Installed)); 94 99 $this->Manager->Perform($List, array(ModuleAction::Uninstall), array(ModuleCondition::Installed)); … … 200 205 else if ($Column->Type == ModelColumnType::Boolean) $Query .= 'tinyint(1)'; 201 206 else if ($Column->Type == ModelColumnType::Date) $Query .= 'date'; 202 else if ($Column->Type == ModelColumnType::Enum) 207 else if ($Column->Type == ModelColumnType::Enum) 203 208 { 204 209 $Query .= 'enum("'.implode('", "', $Column->States).'")'; … … 238 243 "ADD CONSTRAINT `".$ModelDesc->Name."_ibfk_".$I."` FOREIGN KEY (`".$Column->Name."`) REFERENCES `".$Column->RefTable."` (`Id`);"; 239 244 } 240 echo($Query);241 245 $this->Database->query($Query); 242 246 } -
trunk/Packages/Common/Base.php
r890 r891 66 66 } 67 67 68 function AddText(string $Name): ModelColumnText 69 { 70 $Result = new ModelColumnText($Name); 71 $this->Columns[] = $Result; 72 return $Result; 73 } 74 68 75 function AddInteger(string $Name): ModelColumnInteger 69 76 { … … 94 101 } 95 102 96 function AddReference(string $Name, string $RefTable ): ModelColumnReference103 function AddReference(string $Name, string $RefTable, bool $Nullable = true): ModelColumnReference 97 104 { 98 105 $Result = new ModelColumnReference($Name, $RefTable); 99 106 $this->Columns[] = $Result; 107 $Result->Nullable = $Nullable; 100 108 return $Result; 101 109 } … … 114 122 $Column = $this->AddDateTime('ChangeTime'); 115 123 $Column->Nullable = true; 116 $this->AddInteger('ChangeReplaceId'); 124 $this->AddInteger('ChangeReplaceId'); 117 125 } 118 126 } -
trunk/Packages/Common/Setup.php
r887 r891 412 412 413 413 $this->Database->query('CREATE TABLE IF NOT EXISTS `'.$this->UpdateManager->VersionTable.'` ( 414 `Id` int(11) NOT NULL AUTO_INCREMENT,415 `Revision` int(11) NOT NULL,416 PRIMARY KEY (`Id`)417 ) ENGINE=InnoDBDEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');414 `Id` int(11) NOT NULL AUTO_INCREMENT, 415 `Revision` int(11) NOT NULL, 416 PRIMARY KEY (`Id`) 417 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); 418 418 $this->Database->query("INSERT INTO `".$this->UpdateManager->VersionTable."` (`Id`, `Revision`) VALUES 419 419 (1, ".$DatabaseRevision.");"); 420 420 $this->Database->query("CREATE TABLE IF NOT EXISTS `Module` ( 421 `Id` int(11) NOT NULL AUTO_INCREMENT, 422 `Name` varchar(255) NOT NULL, 423 `Title` varchar(255) NOT NULL, 424 PRIMARY KEY (`Id`) 425 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 421 `Id` int(11) NOT NULL AUTO_INCREMENT, 422 `Name` varchar(255) NOT NULL, 423 `Title` varchar(255) NOT NULL, 424 PRIMARY KEY (`Id`) 425 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 426 $this->Database->query("CREATE TABLE IF NOT EXISTS `ModuleModel` ( 427 `Id` int(11) NOT NULL AUTO_INCREMENT, 428 `Name` varchar(255) NOT NULL, 429 `Module` int(11) NOT NULL, 430 PRIMARY KEY (`Id`) 431 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 432 $this->Database->query('ALTER TABLE `ModuleModel` 433 ADD CONSTRAINT `ModuleModel_ibfk_1` FOREIGN KEY (`Module`) REFERENCES `Module` (`Id`);'); 434 $this->Database->query("CREATE TABLE IF NOT EXISTS `ModuleModelProperty` ( 435 `Id` int(11) NOT NULL AUTO_INCREMENT, 436 `Name` varchar(255) NOT NULL, 437 `Model` int(11) NOT NULL, 438 `Type` int(11) NOT NULL, 439 `Nullable` tinyint(1) NOT NULL, 440 PRIMARY KEY (`Id`) 441 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 442 $this->Database->query('ALTER TABLE `ModuleModelProperty` 443 ADD CONSTRAINT `ModuleModelProperty_ibfk_1` FOREIGN KEY (`Model`) REFERENCES `ModuleModel` (`Id`);'); 426 444 } 427 445 … … 429 447 { 430 448 $this->System->ModuleManager->UninstallAll(); 449 $this->Database->query('DROP TABLE `ModuleModelProperty`'); 450 $this->Database->query('DROP TABLE `ModuleModel`'); 431 451 $this->Database->query('DROP TABLE `Module`'); 432 452 $this->Database->query('DROP TABLE `'.$this->UpdateManager->VersionTable.'`');
Note:
See TracChangeset
for help on using the changeset viewer.