Changeset 890 for trunk/Modules
- Timestamp:
- Dec 29, 2020, 11:11:12 PM (4 years ago)
- Location:
- trunk/Modules
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/API/API.php
r889 r890 25 25 $this->License = 'GNU/GPL'; 26 26 $this->Description = 'Remote API for support of other clients'; 27 $this->Dependencies = array( );27 $this->Dependencies = array('User'); 28 28 } 29 29 -
trunk/Modules/Customer/Customer.php
r887 r890 11 11 $this->License = 'GNU/GPL'; 12 12 $this->Description = 'Customer management'; 13 $this->Dependencies = array('User' );13 $this->Dependencies = array('User', 'Finance'); 14 14 } 15 15 … … 191 191 } 192 192 193 function DoInstall(): void 194 { 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()); 201 } 202 203 function Uninstall(): void 204 { 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()); 211 } 212 193 213 function ShowDashboardItem(): string 194 214 { … … 203 223 return $Output; 204 224 } 205 206 } 225 } 226 227 class Member extends Model 228 { 229 static function GetDesc(): ModelDesc 230 { 231 $Desc = new ModelDesc('Member'); 232 $Desc->AddString('Name'); 233 $Desc->AddReference('Subject', 'Subject'); 234 $Desc->AddReference('ResponsibleUser', 'User'); 235 $Desc->AddInteger('FamilyMemberCount'); 236 $Desc->AddDate('MembershipDate'); 237 $Desc->AddInteger('MemberState'); 238 $Desc->AddInteger('GPS'); 239 $Desc->AddReference('BillingPeriod', 'FinanceBillingPerios'); 240 $Desc->AddDate('BillingPeriodLastDate'); 241 $Desc->AddBoolean('Blocked'); 242 $Desc->AddInteger('PayDay'); 243 $Desc->AddChangeAction(); 244 return $Desc; 245 } 246 } 247 248 class MemberPayment extends Model 249 { 250 static function GetDesc(): ModelDesc 251 { 252 $Desc = new ModelDesc('MemberPayment'); 253 $Desc->AddReference('Member', 'Member'); 254 $Desc->AddFloat('MonthlyTotal'); 255 $Desc->AddFloat('MonthlyInternet'); 256 $Desc->AddFloat('MonthlyConsumption'); 257 $Desc->AddFloat('MonthlyPlus'); 258 $Desc->AddFloat('Cash'); 259 return $Desc; 260 } 261 } 262 263 class Service extends Model 264 { 265 static function GetDesc(): ModelDesc 266 { 267 $Desc = new ModelDesc('Service'); 268 $Desc->AddString('Name'); 269 $Desc->AddReference('Category', 'ServiceCategory'); 270 $Desc->AddInteger('Price'); 271 $Desc->AddInteger('VAT'); 272 $Desc->AddChangeAction(); 273 $Desc->AddBoolean('Public'); 274 $Desc->AddInteger('InternetSpeedMax'); 275 $Desc->AddInteger('InternetSpeedMin'); 276 $Desc->AddInteger('InternetUploadAsymmetry'); 277 $Desc->AddInteger('Memory'); 278 $Desc->AddInteger('MemorySwap'); 279 $Desc->AddInteger('Storage'); 280 $Desc->AddInteger('CPUCount'); 281 return $Desc; 282 } 283 } 284 285 class ServiceCategory extends Model 286 { 287 static function GetDesc(): ModelDesc 288 { 289 $Desc = new ModelDesc('ServiceCategory'); 290 $Desc->AddString('Name'); 291 return $Desc; 292 } 293 } 294 295 class SupportActivity extends Model 296 { 297 static function GetDesc(): ModelDesc 298 { 299 $Desc = new ModelDesc('SupportActivity'); 300 $Desc->AddDateTime('Time'); 301 $Desc->AddString('Description'); 302 $Desc->AddReference('Customer', 'Member'); 303 $Desc->AddReference('User', 'User'); 304 return $Desc; 305 } 306 } 307 308 class ServiceCustomerRel extends Model 309 { 310 static function GetDesc(): ModelDesc 311 { 312 $Desc = new ModelDesc('ServiceCustomerRel'); 313 $Desc->AddReference('Service', 'Service'); 314 $Desc->AddReference('Customer', 'Member'); 315 $Desc->AddChangeAction(); 316 $Desc->AddInteger('SpeedLimit'); 317 return $Desc; 318 } 319 } -
trunk/Modules/File/File.php
r887 r890 11 11 parent::__construct($System); 12 12 $this->FilesDir = ''; 13 } 14 15 static function GetDesc(): ModelDesc 16 { 17 $Desc = new ModelDesc('File'); 18 $Desc->AddString('Name'); 19 $Desc->AddInteger('Size'); 20 $Column = $Desc->AddReference('Directory', 'FileDirectory'); 21 $Column->Nullable = true; 22 $Desc->AddDateTime('Time'); 23 return $Desc; 13 24 } 14 25 … … 104 115 } 105 116 117 class FileDirectory extends Model 118 { 119 static function GetDesc(): ModelDesc 120 { 121 $Desc = new ModelDesc('FileDirectory'); 122 $Desc->AddString('Name'); 123 $Column = $Desc->AddReference('Parent', 'FileDirectory'); 124 $Column->Nullable = true; 125 return $Desc; 126 } 127 } 128 106 129 class PageFileCheck extends Page 107 130 { … … 173 196 function DoInstall(): void 174 197 { 198 $this->InstallModel(FileDirectory::GetDesc()); 199 $this->InstallModel(File::GetDesc()); 175 200 } 176 201 177 202 function DoUninstall(): void 178 203 { 204 $this->UninstallModel(File::GetDesc()); 205 $this->UninstallModel(FileDirectory::GetDesc()); 179 206 } 180 207 -
trunk/Modules/Finance/Finance.php
r888 r890 277 277 'Treasury' => array('Type' => 'TFinanceTreasury', 'Caption' => 'Pokladna', 'Default' => '', 'Null' => true), 278 278 'Generate' => array('Type' => 'Boolean', 'Caption' => 'Generovat', 'Default' => ''), 279 'Balance' => array('Type' => 'Integer', 'Caption' => 'Zůstatek', 'Default' => '', 280 'ReadOnly' => true, 'SQL' => '(SELECT SUM(`FinanceOperation2`.`Value`) FROM `FinanceOperation` AS `FinanceOperation2` WHERE `FinanceOperation2`.`Time`<`Time`)'), 279 281 'InvoiceRel' => array('Type' => 'TFinanceInvoiceOperationRelListOperation', 'Caption' => 'Zaplacené faktury', 'Default' => ''), 280 282 'InvoiceRelCount' => array('Type' => 'Integer', 'Caption' => 'Faktur', … … 289 291 ), 290 292 )); 291 293 292 294 $this->System->FormManager->RegisterClass('FinanceTreasuryIn', $this->System->FormManager->Classes['FinanceOperation']); 293 295 $this->System->FormManager->Classes['FinanceTreasuryIn']['Title'] = 'Pokladní příjmy'; … … 543 545 ), 544 546 )); 547 $this->System->FormManager->RegisterClass('FinanceBankAccountReport', array( 548 'Title' => 'Roční výkaz operací', 549 'Table' => 'FinanceBankAccountReport', 550 'SQL' => 'SELECT Id, DateEnd, DateStart FROM FinanceYear', 551 'DefaultSortColumn' => 'Id', 552 'Items' => array( 553 'Id' => array('Type' => 'TFinanceYear', 'Caption' => 'Rok', 'Default' => '', 554 'ReadOnly' => true), 555 //'Account' => array('Type' => 'TFinanceBankAccount', 'Caption' => 'Bankovní účet', 'Default' => '', 556 // 'ReadOnly' => true), 557 'StartBalance' => array('Type' => 'Integer', 'Caption' => 'Starý zůstatek', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true, 558 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '. 559 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '. 560 'WHERE (`FinanceOperation`.`Time` <= `DateStart`) AND (`FinanceOperation`.`BankAccount` = 2))'), 561 'EndBalance' => array('Type' => 'Integer', 'Caption' => 'Nový zůstatek', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true, 562 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '. 563 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '. 564 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) AND (`FinanceOperation`.`BankAccount` = 2))'), 565 'Change' => array('Type' => 'Integer', 'Caption' => 'Změna', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true, 566 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '. 567 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '. 568 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '. 569 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`BankAccount` = 2))'), 570 ), 571 //'AfterInsert' => array($this, 'AfterInsertFinanceYear'), 572 )); 545 573 $this->System->FormManager->RegisterFormType('TFinanceBankAccount', array( 546 574 'Type' => 'Reference', -
trunk/Modules/User/User.php
r887 r890 25 25 function DoInstall(): void 26 26 { 27 $this->Database->query("CREATE TABLE IF NOT EXISTS `User` ( 28 `Id` int(11) NOT NULL AUTO_INCREMENT, 29 `Login` varchar(64) NOT NULL, 30 `Name` varchar(128) NOT NULL, 31 `Password` varchar(255) NOT NULL, 32 `Salt` varchar(255) NOT NULL, 33 `Email` varchar(128) NOT NULL DEFAULT '', 34 `LastIpAddress` varchar(16) NOT NULL DEFAULT '', 35 `LastLoginTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 36 `RegistrationTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 37 `Locked` tinyint(1) NOT NULL DEFAULT '0', 38 `InitPassword` varchar(255) NOT NULL, 39 PRIMARY KEY (`Id`), 40 UNIQUE KEY `Name` (`Login`), 41 UNIQUE KEY `Nick` (`Name`) 42 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 43 $this->Database->query("CREATE TABLE IF NOT EXISTS `UserOnline` ( 44 `Id` int(11) NOT NULL AUTO_INCREMENT, 45 `User` int(11) DEFAULT NULL COMMENT 'User.Id', 46 `ActivityTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 47 `LoginTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 48 `SessionId` varchar(255) NOT NULL DEFAULT '', 49 `IpAddress` varchar(16) NOT NULL DEFAULT '', 50 `HostName` varchar(255) NOT NULL DEFAULT '', 51 `ScriptName` varchar(255) NOT NULL, 52 `StayLogged` INT NOT NULL, 53 `StayLoggedHash` VARCHAR(40) NOT NULL, 54 PRIMARY KEY (`Id`), 55 KEY `User` (`User`) 56 ) ENGINE=MEMORY DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 57 $this->Database->query("CREATE TABLE IF NOT EXISTS `PermissionGroup` ( 58 `Id` int(11) NOT NULL AUTO_INCREMENT, 59 `Description` varchar(255) NOT NULL DEFAULT '', 60 PRIMARY KEY (`Id`) 61 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 62 63 $this->Database->query("CREATE TABLE IF NOT EXISTS `PermissionGroupAssignment` ( 64 `Id` int(11) NOT NULL AUTO_INCREMENT, 65 `Group` int(11) NOT NULL DEFAULT '0', 66 `AssignedGroup` int(11) DEFAULT NULL, 67 `AssignedOperation` int(11) DEFAULT NULL, 68 PRIMARY KEY (`Id`), 69 KEY `Group` (`Group`), 70 KEY `AssignedGroup` (`AssignedGroup`), 71 KEY `AssignedOperation` (`AssignedOperation`) 72 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 73 74 $this->Database->query("CREATE TABLE IF NOT EXISTS `PermissionOperation` ( 75 `Id` int(11) NOT NULL AUTO_INCREMENT, 76 `Module` int(11) NOT NULL, 77 `Operation` varchar(128) NOT NULL DEFAULT '', 78 `Item` varchar(64) NOT NULL DEFAULT '', 79 `ItemId` int(11) NOT NULL DEFAULT '0', 80 PRIMARY KEY (`Id`), 81 KEY `Module` (`Module`), 82 KEY `Operation` (`Operation`), 83 KEY `Item` (`Item`), 84 KEY `ItemId` (`ItemId`) 85 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 86 87 $this->Database->query("CREATE TABLE IF NOT EXISTS `PermissionUserAssignment` ( 88 `Id` int(11) NOT NULL AUTO_INCREMENT, 89 `User` int(11) DEFAULT NULL, 90 `AssignedGroup` int(11) DEFAULT NULL, 91 `AssignedOperation` int(11) DEFAULT NULL, 92 PRIMARY KEY (`Id`), 93 KEY `User` (`User`), 94 KEY `AssignedGroup` (`AssignedGroup`), 95 KEY `AssignedOperation` (`AssignedOperation`) 96 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 97 98 $this->Database->query("ALTER TABLE `PermissionGroupAssignment` 99 ADD CONSTRAINT `PermissionGroupAssignment_ibfk_1` FOREIGN KEY (`Group`) REFERENCES `PermissionGroup` (`Id`), 100 ADD CONSTRAINT `PermissionGroupAssignment_ibfk_2` FOREIGN KEY (`AssignedGroup`) REFERENCES `PermissionGroup` (`Id`), 101 ADD CONSTRAINT `PermissionGroupAssignment_ibfk_3` FOREIGN KEY (`AssignedOperation`) REFERENCES `PermissionOperation` (`Id`);"); 102 103 $this->Database->query("ALTER TABLE `PermissionOperation` 104 ADD CONSTRAINT `PermissionOperation_ibfk_1` FOREIGN KEY (`Module`) REFERENCES `Module` (`Id`);"); 105 106 $this->Database->query("ALTER TABLE `PermissionUserAssignment` 107 ADD CONSTRAINT `PermissionUserAssignment_ibfk_2` FOREIGN KEY (`AssignedGroup`) REFERENCES `PermissionGroup` (`Id`), 108 ADD CONSTRAINT `PermissionUserAssignment_ibfk_3` FOREIGN KEY (`AssignedOperation`) REFERENCES `PermissionOperation` (`Id`), 109 ADD CONSTRAINT `PermissionUserAssignment_ibfk_4` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);"); 27 $this->InstallModel(User::GetDesc()); 28 $this->InstallModel(UserOnline::GetDesc()); 29 $this->InstallModel(PermissionGroup::GetDesc()); 30 $this->InstallModel(PermissionOperation::GetDesc()); 31 $this->InstallModel(PermissionGroupAssignment::GetDesc()); 32 $this->InstallModel(PermissionUserAssignment::GetDesc()); 110 33 } 111 34 112 35 function DoUninstall(): void 113 36 { 114 $this->Database->query('DROP TABLE `PermissionUserAssignment`'); 115 $this->Database->query('DROP TABLE `PermissionGroupAssignment`'); 116 $this->Database->query('DROP TABLE `PermissionGroup`'); 117 $this->Database->query('DROP TABLE `PermissionOperation`'); 118 $this->Database->query('DROP TABLE `UserOnline`'); 119 $this->Database->query('DROP TABLE `User`'); 120 } 121 122 function DoUpgrade(): void 123 { 124 /* 125 126 if ($this->InstalledVersion == '1.0') { 127 $this->System->Database->Query('SELECT * FROM User WHERE Id=1'); 128 $this->InstalledVersion = '1.1'; 129 } 130 */ 37 $this->UninstallModel(PermissionUserAssignment::GetDesc()); 38 $this->UninstallModel(PermissionGroupAssignment::GetDesc()); 39 $this->UninstallModel(PermissionOperation::GetDesc()); 40 $this->UninstallModel(PermissionGroup::GetDesc()); 41 $this->UninstallModel(UserOnline::GetDesc()); 42 $this->UninstallModel(User::GetDesc()); 131 43 } 132 44 -
trunk/Modules/User/UserModel.php
r887 r890 65 65 } 66 66 67 static function GetDesc(): ModelDesc 68 { 69 $Desc = new ModelDesc('User'); 70 $Column = $Desc->AddString('Login'); 71 $Column->Unique = true; 72 $Column = $Desc->AddString('Name'); 73 $Column->Unique = true; 74 $Desc->AddString('Password'); 75 $Desc->AddString('Salt'); 76 $Desc->AddString('Email'); 77 $Desc->AddString('LastIpAddress'); 78 $Desc->AddString('LastLoginTime'); 79 $Desc->AddDateTime('RegistrationTime'); 80 $Desc->AddBoolean('Locked'); 81 $Desc->AddString('InitPassword'); 82 return $Desc; 83 } 84 67 85 function Check(): void 68 86 { … … 435 453 } 436 454 } 455 456 class UserOnline extends Model 457 { 458 static function GetDesc(): ModelDesc 459 { 460 $Desc = new ModelDesc('UserOnline'); 461 $Desc->Memory = true; 462 $Column = $Desc->AddReference('User', 'User'); 463 $Column->Nullable = true; 464 $Desc->AddDateTime('ActivityTime'); 465 $Desc->AddDateTime('LoginTime'); 466 $Desc->AddString('SessionId'); 467 $Desc->AddString('IpAddress'); 468 $Desc->AddString('HostName'); 469 $Desc->AddString('ScriptName'); 470 $Desc->AddBoolean('StayLogged'); 471 $Desc->AddString('StayLoggedHash'); 472 return $Desc; 473 } 474 } 475 476 class PermissionGroup extends Model 477 { 478 static function GetDesc(): ModelDesc 479 { 480 $Desc = new ModelDesc('PermissionGroup'); 481 $Desc->AddString('Description'); 482 return $Desc; 483 } 484 } 485 486 class PermissionGroupAssignment extends Model 487 { 488 static function GetDesc(): ModelDesc 489 { 490 $Desc = new ModelDesc('PermissionGroupAssignment'); 491 $Desc->AddReference('Group', 'PermissionGroup'); 492 $Column = $Desc->AddReference('AssignedGroup', 'PermissionGroup'); 493 $Column->Nullable = true; 494 $Column = $Desc->AddReference('AssignedOperation', 'PermissionOperation'); 495 $Column->Nullable = true; 496 return $Desc; 497 } 498 } 499 500 class PermissionOperation extends Model 501 { 502 static function GetDesc(): ModelDesc 503 { 504 $Desc = new ModelDesc('PermissionOperation'); 505 $Desc->AddReference('Module', 'Module'); 506 $Desc->AddString('Operation'); 507 $Desc->AddString('Item'); 508 $Desc->AddInteger('ItemId'); 509 $Desc->Indices = array('Operation', 'Item', 'ItemId'); 510 return $Desc; 511 } 512 } 513 514 class PermissionUserAssignment extends Model 515 { 516 static function GetDesc(): ModelDesc 517 { 518 $Desc = new ModelDesc('PermissionUserAssignment'); 519 $Desc->AddReference('User', 'User'); 520 $Column = $Desc->AddReference('AssignedGroup', 'PermissionGroup'); 521 $Column->Nullable = true; 522 $Column = $Desc->AddReference('AssignedOperation', 'PermissionOperation'); 523 $Column->Nullable = true; 524 return $Desc; 525 } 526 }
Note:
See TracChangeset
for help on using the changeset viewer.