Changeset 894


Ignore:
Timestamp:
Jan 5, 2021, 10:30:31 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Further improved models initialization system.
Location:
trunk
Files:
2 added
40 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/FormClasses.php

    r891 r894  
    55function RegisterFormClasses(FormManager $FormManager): void
    66{
    7   $FormManager->Classes = array(
    8   'UserCustomerRel' => array(
    9     'Title' => 'Vztahy uživatel - zákazník',
    10     'Table' => 'UserCustomerRel',
    11     'Items' => array(
    12       'User' => array('Type' => 'TUser', 'Caption' => 'Uživatel', 'Default' => ''),
    13       'Customer' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => ''),
    14     ),
    15   ),
    16   'FinanceInvoiceOperationRel' => array(
    17     'Title' => 'Zaplacení faktůr',
    18     'Table' => 'FinanceInvoiceOperationRel',
    19     'Items' => array(
    20       'Invoice' => array('Type' => 'TFinanceInvoice', 'Caption' => 'Faktura', 'Default' => ''),
    21       'Operation' => array('Type' => 'TFinanceOperation', 'Caption' => 'Platba', 'Default' => ''),
    22     ),
    23   ),
    24   'FinanceYearReport' => array(
    25     'Title' => 'Roční výkaz',
    26     'Table' => 'FinanceYearReport',
    27     'SQL' => 'SELECT Id, DateEnd, DateStart FROM FinanceYear',
    28     'DefaultSortColumn' => 'Id',
    29     'Items' => array(
    30       'Id' => array('Type' => 'TFinanceYear', 'Caption' => 'Rok', 'Default' => '',
    31         'ReadOnly' => true),
    32       'Income' => array('Type' => 'Integer', 'Caption' => 'Příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
    33         'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
    34         'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
    35         'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
    36         'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperationGroup`.`ValueSign` = 1))'),
    37       'Spending' => array('Type' => 'Integer', 'Caption' => 'Výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
    38         'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
    39         'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
    40         'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
    41         'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperationGroup`.`ValueSign` = -1))'),
    42       'OperationBalance' => array('Type' => 'Integer', 'Caption' => 'Zisk', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
    43         'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
    44         'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
    45         'AND (`FinanceOperation`.`Time` >= `DateStart`))'),
    46       'TaxIncome' => array('Type' => 'Integer', 'Caption' => 'Daňové příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
    47         'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
    48         'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
    49         'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
    50         'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1) AND (`FinanceOperationGroup`.`ValueSign` = 1))'),
    51       'TaxSpending' => array('Type' => 'Integer', 'Caption' => 'Daňové výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
    52         'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
    53         'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
    54         'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
    55         'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1) AND (`FinanceOperationGroup`.`ValueSign` = -1))'),
    56       'TaxBase' => array('Type' => 'Integer', 'Caption' => 'Základ daně', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
    57         'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
    58         'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
    59         'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1))'),
    60       'Claims' => array('Type' => 'Integer', 'Caption' => 'Pohledávky', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
    61         'SQL' => '(SELECT ROUND(SUM(`FinanceInvoice`.`Value`)) FROM `FinanceInvoice` '.
    62         'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group` '.
    63         'WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '.
    64         'AND (`FinanceInvoice`.`Time` >= `DateStart`) AND (`FinanceInvoiceGroup`.`ValueSign` = 1))'),
    65       'Liabilities' => array('Type' => 'Integer', 'Caption' => 'Závazky', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
    66         'SQL' => '(SELECT -ROUND(SUM(`FinanceInvoice`.`Value`)) FROM `FinanceInvoice` '.
    67         'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group` '.
    68         'WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '.
    69         'AND (`FinanceInvoice`.`Time` >= `DateStart`) AND (`FinanceInvoiceGroup`.`ValueSign` = -1))'),
    70       'InvoiceBalance' => array('Type' => 'Integer', 'Caption' => 'Fakturační rozdíl', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
    71         'SQL' => '(SELECT ROUND(SUM(`FinanceInvoice`.`Value`)) FROM `FinanceInvoice` WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '.
    72         'AND (`FinanceInvoice`.`Time` >= `DateStart`))'),
    73     ),
    74     //'AfterInsert' => array($this, 'AfterInsertFinanceYear'),
    75   ),
    76   'FinanceBillingPeriod' => array(
    77     'Title' => 'Platební období',
    78     'Table' => 'FinanceBillingPeriod',
    79     'DefaultSortColumn' => 'Name',
    80     'Items' => array(
    81       'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
    82       'MonthCount' => array('Type' => 'Integer', 'Caption' => 'Počet měsíců', 'Default' => '0', 'Suffix' => 'měsíců'),
    83       'Customers' => array('Type' => 'TCustomerListBillingPeriod', 'Caption' => 'Zákazníci', 'Default' => ''),
    84     ),
    85   ),
    86 );
    877
    888$FormManager->FormTypes = array
  • trunk/Modules/API/API.php

    r893 r894  
    3535  function GetModels(): array
    3636  {
    37     return array('APIToken');
     37    return array(APIToken::GetClassName());
    3838  }
    3939}
     
    4343  static function GetDesc(): ModelDesc
    4444  {
    45     $Desc = new ModelDesc('APIToken');
    46     $Desc->AddReference('User', 'User');
     45    $Desc = new ModelDesc(self::GetClassName());
     46    $Desc->AddReference('User', User::GetClassName());
    4747    $Desc->AddString('Token');
    4848    return $Desc;
  • trunk/Modules/Chat/Chat.php

    r887 r894  
    9898  }
    9999
     100  function GetModels(): array
     101  {
     102    return array(ChatHistory::GetClassName());
     103  }
     104
    100105  function DoStart(): void
    101106  {
     
    103108  }
    104109}
     110
     111class ChatHistory extends Model
     112{
     113  static function GetDesc(): ModelDesc
     114  {
     115    $Desc = new ModelDesc(self::GetClassName());
     116    $Desc->AddString('Nick');
     117    $Desc->AddText('Text');
     118    $Desc->AddDateTime('Time');
     119    $Desc->AddInteger('Color');
     120    $Desc->AddString('RoomName');
     121    $Desc->AddInteger('RoomType');
     122    $Desc->AddString('Host');
     123        return $Desc;
     124  }
     125}
  • trunk/Modules/Customer/Customer.php

    r893 r894  
    186186      'Filter' => '1',
    187187    ));
     188    $this->System->FormManager->RegisterClass('UserCustomerRel', array(
     189      'Title' => 'Vztahy uživatel - zákazník',
     190      'Table' => 'UserCustomerRel',
     191      'Items' => array(
     192        'User' => array('Type' => 'TUser', 'Caption' => 'Uživatel', 'Default' => ''),
     193        'Customer' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => ''),
     194      ),
     195    ));
    188196
    189197    ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Customer',
     
    193201  function GetModels(): array
    194202  {
    195     return array('Member', 'MemberPayment', 'SupportActivity', 'ServiceCategory', 'Service', 'ServiceCustomerRel');
    196   }
    197 
    198   function DoInstall(): void
    199   {
    200     foreach (self::GetModels() as $Model)
    201     {
    202       $this->InstallModel($Model::GetDesc());
    203     }
    204   }
    205 
    206   function Uninstall(): void
    207   {
    208     foreach (array_reverse(self::GetModels()) as $Model)
    209     {
    210       $this->UninstallModel($Model::GetDesc());
    211     }
     203    return array(Member::GetClassName(), MemberPayment::GetClassName(), SupportActivity::GetClassName(), ServiceCategory::GetClassName(),
     204      Service::GetClassName(), ServiceCustomerRel::GetClassName(), UserCustomerRel::GetClassName());
    212205  }
    213206
     
    230223  static function GetDesc(): ModelDesc
    231224  {
    232     $Desc = new ModelDesc('Member');
     225    $Desc = new ModelDesc(self::GetClassName());
    233226    $Desc->AddString('Name');
    234     $Desc->AddReference('Subject', 'Subject');
    235     $Desc->AddReference('ResponsibleUser', 'User');
     227    $Desc->AddReference('Subject', Subject::GetClassName());
     228    $Desc->AddReference('ResponsibleUser', User::GetClassName());
    236229    $Desc->AddInteger('FamilyMemberCount');
    237230    $Desc->AddDate('MembershipDate');
    238231    $Desc->AddInteger('MemberState');
    239232    $Desc->AddInteger('GPS');
    240     $Desc->AddReference('BillingPeriod', 'FinanceBillingPerios');
     233    $Desc->AddReference('BillingPeriod', FinanceBillingPeriod::GetClassName());
    241234    $Desc->AddDate('BillingPeriodLastDate');
    242235    $Desc->AddBoolean('Blocked');
     
    251244  static function GetDesc(): ModelDesc
    252245  {
    253     $Desc = new ModelDesc('MemberPayment');
    254     $Desc->AddReference('Member', 'Member');
     246    $Desc = new ModelDesc(self::GetClassName());
     247    $Desc->AddReference('Member', Member::GetClassName());
    255248    $Desc->AddFloat('MonthlyTotal');
    256249    $Desc->AddFloat('MonthlyInternet');
     
    266259  static function GetDesc(): ModelDesc
    267260  {
    268     $Desc = new ModelDesc('Service');
     261    $Desc = new ModelDesc(self::GetClassName());
    269262    $Desc->AddString('Name');
    270     $Desc->AddReference('Category', 'ServiceCategory');
     263    $Desc->AddReference('Category', ServiceCategory::GetClassName());
    271264    $Desc->AddInteger('Price');
    272265    $Desc->AddInteger('VAT');
     
    288281  static function GetDesc(): ModelDesc
    289282  {
    290     $Desc = new ModelDesc('ServiceCategory');
     283    $Desc = new ModelDesc(self::GetClassName());
    291284    $Desc->AddString('Name');
    292285    return $Desc;
     
    298291  static function GetDesc(): ModelDesc
    299292  {
    300     $Desc = new ModelDesc('SupportActivity');
     293    $Desc = new ModelDesc(self::GetClassName());
    301294    $Desc->AddDateTime('Time');
    302295    $Desc->AddString('Description');
    303     $Desc->AddReference('Customer', 'Member');
    304     $Desc->AddReference('User', 'User');
     296    $Desc->AddReference('Customer', Member::GetClassName());
     297    $Desc->AddReference('User', User::GetClassName());
    305298    return $Desc;
    306299  }
     
    311304  static function GetDesc(): ModelDesc
    312305  {
    313     $Desc = new ModelDesc('ServiceCustomerRel');
    314     $Desc->AddReference('Service', 'Service');
    315     $Desc->AddReference('Customer', 'Member');
     306    $Desc = new ModelDesc(self::GetClassName());
     307    $Desc->AddReference('Service', Service::GetClassName());
     308    $Desc->AddReference('Customer', Member::GetClassName());
    316309    $Desc->AddChangeAction();
    317310    $Desc->AddInteger('SpeedLimit');
     
    319312  }
    320313}
     314
     315class UserCustomerRel extends Model
     316{
     317  static function GetDesc(): ModelDesc
     318  {
     319    $Desc = new ModelDesc(self::GetClassName());
     320    $Desc->AddReference('User', User::GetClassName());
     321    $Desc->AddReference('Customer', Member::GetClassName());
     322    return $Desc;
     323  }
     324}
  • trunk/Modules/Document/Document.php

    r893 r894  
    8282  function GetModels(): array
    8383  {
    84     return array('FinanceYear', 'DocumentLineCode', 'DocumentLine', 'DocumentLineSequence');
     84    return array(FinanceYear::GetClassName(), DocumentLineCode::GetClassName(), DocumentLine::GetClassName(),
     85      DocumentLineSequence::GetClassName());
    8586  }
    8687}
     
    9091  static function GetDesc(): ModelDesc
    9192  {
    92     $Desc = new ModelDesc('DocumentLine');
     93    $Desc = new ModelDesc(self::GetClassName());
    9394    $Desc->AddString('Name');
    9495    $Desc->AddString('ShortCut');
     
    102103  static function GetDesc(): ModelDesc
    103104  {
    104     $Desc = new ModelDesc('DocumentLineCode');
    105     $Desc->AddReference('DocumentLine', 'DocumentLine');
     105    $Desc = new ModelDesc(self::GetClassName());
     106    $Desc->AddReference('DocumentLine', DocumentLine::GetClassName());
    106107    $Desc->AddString('Name');
    107108    return $Desc;
     
    113114  static function GetDesc(): ModelDesc
    114115  {
    115     $Desc = new ModelDesc('DocumentLineSequence');
    116     $Desc->AddReference('DocumentLine', 'DocumentLine');
    117     $Desc->AddReference('FinanceYear', 'FinanceYear');
     116    $Desc = new ModelDesc(self::GetClassName());
     117    $Desc->AddReference('DocumentLine', DocumentLine::GetClassName());
     118    $Desc->AddReference('FinanceYear', FinanceYear::GetClassName());
    118119    $Desc->AddInteger('NextNumber');
    119120    $Desc->AddString('YearPrefix');
     
    126127  static function GetDesc(): ModelDesc
    127128  {
    128     $Desc = new ModelDesc('FinanceYear');
     129    $Desc = new ModelDesc(self::GetClassName());
    129130    $Desc->AddInteger('Year');
    130131    $Desc->AddDate('DateStart');
  • trunk/Modules/EmailQueue/EmailQueue.php

    r893 r894  
    2323  static function GetDesc(): ModelDesc
    2424  {
    25     $Desc = new ModelDesc('EmailQueue');
     25    $Desc = new ModelDesc(self::GetClassName());
    2626    $Desc->AddDateTime('Time');
    2727    $Desc->AddString('To');
     
    3131    $Desc->AddBoolean('Archive');
    3232    $Desc->AddString('From');
    33     $Desc->AddReference('AttachmentFile', 'File');
     33    $Desc->AddReference('AttachmentFile', File::GetClassName());
    3434    return $Desc;
    3535  }
     
    5151  function GetModels(): array
    5252  {
    53     return array('EmailQueue');
     53    return array(EmailQueue::GetClassName());
    5454  }
    5555
  • trunk/Modules/Employee/Employee.php

    r893 r894  
    55  static function GetDesc(): ModelDesc
    66  {
    7     $Desc = new ModelDesc('Employee');
     7    $Desc = new ModelDesc(self::GetClassName());
    88    $Desc->AddDateTime('Time');
    99    $Desc->AddString('To');
     
    1313    $Desc->AddBoolean('Archive');
    1414    $Desc->AddString('From');
    15     $Desc->AddReference('AttachmentFile', 'File');
     15    $Desc->AddReference('AttachmentFile', File::GetClassName());
    1616    return $Desc;
    1717  }
     
    2222  static function GetDesc(): ModelDesc
    2323  {
    24     $Desc = new ModelDesc('EmployeeSalary');
     24    $Desc = new ModelDesc(self::GetClassName());
    2525    $Desc->AddDate('Date');
    26     $Desc->AddReference('Employee', 'Employee');
     26    $Desc->AddReference('Employee', Employee::GetClassName());
    2727    $Desc->AddInteger('Amount');
    28     $Desc->AddReference('Contract', 'Contract');
     28    $Desc->AddReference('Contract', Contract::GetClassName());
    2929    return $Desc;
    3030  }
     
    4646  function GetModels(): array
    4747  {
    48     return array('Employee', 'EmployeeSalary');
     48    return array(Employee::GetClassName(), EmployeeSalary::GetClassName());
    4949  }
    5050
  • trunk/Modules/File/File.php

    r893 r894  
    1818    $Desc->AddString('Name');
    1919    $Desc->AddInteger('Size');
    20     $Desc->AddReference('Directory', 'FileDirectory', true);
     20    $Desc->AddReference('Directory', FileDirectory::GetClassName(), true);
    2121    $Desc->AddDateTime('Time');
    2222    return $Desc;
     
    120120    $Desc = new ModelDesc('FileDirectory');
    121121    $Desc->AddString('Name');
    122     $Desc->AddReference('Parent', 'FileDirectory', true);
     122    $Desc->AddReference('Parent', FileDirectory::GetClassName(), true);
    123123    return $Desc;
    124124  }
     
    194194  function GetModels(): array
    195195  {
    196     return array('FileDirectory', 'File');
     196    return array(FileDirectory::GetClassName(), File::GetClassName());
    197197  }
    198198
  • trunk/Modules/Finance/Finance.php

    r893 r894  
    11<?php
    22
     3include_once(dirname(__FILE__).'/FinanceModels.php');
    34include_once(dirname(__FILE__).'/Bill.php');
    45include_once(dirname(__FILE__).'/Manage.php');
     
    67include_once(dirname(__FILE__).'/Import.php');
    78include_once(dirname(__FILE__).'/Trade.php');
    8 
    9 // TODO: Move constants to Finance module configuration
    10 define('TARIFF_FREE', 7);
    11 define('INVOICE_DUE_DAYS', 15);
    12 define('OPERATION_GROUP_TREASURY_IN', 1);
    13 define('OPERATION_GROUP_TREASURY_OUT', 2);
    14 define('OPERATION_GROUP_ACCOUNT_IN', 3);
    15 define('OPERATION_GROUP_ACCOUNT_OUT', 4);
    16 define('INVOICE_GROUP_IN', 1);
    17 define('INVOICE_GROUP_OUT', 2);
    18 define('VAT_TYPE_BASE', 2);
    19 define('FINANCE_DIRECTION_OUT', 1);
    20 define('FINANCE_DIRECTION_IN', 0);
    21 
    22 class Finance extends Model
    23 {
    24   public string $kWh;
    25   public string $Internet;
    26   public string $Sprava;
    27   public string $DatumOdecteni;
    28   public string $InternetUsers;
    29   public string $SpravaUsers;
    30   public string $MaxSpeed;
    31   public string $RealMaxSpeed;
    32   public string $SpeedReserve;
    33   public string $BaseSpeedElement;
    34   public string $BaseTariffPrice;
    35   public string $TopTariffPrice;
    36   public string $TotalPaid;
    37   public string $TotalInternetPaid;
    38   public string $MainSubject;
    39   public array $BillingPeriods;
    40   public string $DirectoryId;
    41   public string $Rounding;
    42 
    43   function LoadMonthParameters(int $Period = 1) // 0 - now, 1 - next month
    44   {
    45     $DbResult = $this->Database->query('SELECT * FROM `FinanceBillingPeriod`');
    46     while ($BillingPeriod = $DbResult->fetch_assoc())
    47       $this->BillingPeriods[$BillingPeriod['Id']] = $BillingPeriod;
    48 
    49     // Period parameter is not used as it have to be determined from item replacement
    50     $DbResult = $this->Database->query('SELECT * FROM `FinanceCharge` WHERE (`ChangeAction` IS NULL) LIMIT 1');
    51     $Row = $DbResult->fetch_array();
    52     $this->kWh = $Row['kWh'];
    53     $this->Internet = $Row['Internet'];
    54     $this->Sprava = $Row['AdministrationPerUser'];
    55     $this->RealMaxSpeed = $Row['InternetSpeed'];
    56     $this->SpeedReserve = $Row['InternetSpeedReserve'];
    57     $this->BaseSpeedElement = $Row['BaseSpeedElement'];
    58     $this->MaxSpeed = $this->RealMaxSpeed - $this->SpeedReserve;
    59     $this->TopTariffPrice = $Row['TopTariffPrice'];
    60     $this->BaseTariffPrice = $Row['BaseTariffPrice'];
    61 
    62     $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Member`');
    63     $Row = $DbResult->fetch_row();
    64     $this->InternetUsers = $Row[0];
    65     $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Member` WHERE (`Blocked`=0) AND (`BillingPeriod` > 1)');
    66     $Row = $DbResult->fetch_row();
    67     $this->PayingUsers = $Row[0];
    68 
    69     $this->SpravaUsers = $this->PayingUsers;
    70 
    71     $DbResult = $this->Database->query('SELECT SUM(`MemberPayment`.`MonthlyInternet`) AS `MonthlyInternet`, '.
    72         'SUM(`MemberPayment`.`MonthlyTotal`) AS `MonthlyTotal` '.
    73         'FROM `MemberPayment` JOIN `Member` ON `Member`.`Id`=`MemberPayment`.`Member` WHERE `Member`.`Blocked`=0');
    74     $Row = $DbResult->fetch_assoc();
    75     $this->TotalInternetPaid = $Row['MonthlyInternet'];
    76     $this->TotalPaid = $Row['MonthlyTotal'];
    77     $this->Rounding = $this->System->Config['Finance']['Rounding'];
    78   }
    79 
    80   function W2Kc($Spotreba): string
    81   {
    82     return round($Spotreba * 0.72 * $this->kWh);
    83   }
    84 
    85   function CreateFinanceYear(int $Year)
    86   {
    87     $StartTime = mktime(0, 0, 0, 1, 1, $Year);
    88     $EndTime = mktime(0, 0, 0, 12, 31, $Year);
    89     $this->Database->insert('FinanceYear', array('Year' => $Year,
    90             'DateStart' => TimeToMysqlDate($StartTime), 'DateEnd' => TimeToMysqlDate($EndTime), 'Closed' => 0));
    91           $YearId = $this->Database->insert_id;
    92 
    93     // Create DocumentLineSequence from previous
    94     $DbResult = $this->Database->select('DocumentLine', 'Id', '`Yearly` = 1');
    95     while ($DbRow = $DbResult->fetch_assoc())
    96     {
    97             $this->Database->insert('DocumentLineSequence', array('FinanceYear' => $YearId,
    98               'NextNumber' => 1, 'YearPrefix' => 1, 'DocumentLine' => $DbRow['Id']));
    99           }
    100   }
    101 
    102   function GetFinanceYear(int $Year): array
    103   {
    104     if ($Year == 0)
    105     {
    106       // Get latest year
    107       $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY `Year` DESC LIMIT 1');
    108     } else $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year);
    109     if ($DbResult->num_rows == 0)
    110     {
    111             if ($Year == date('Y'))
    112             {
    113                     $this->CreateFinanceYear($Year);
    114         $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year);
    115             } else throw new Exception('Rok '.$Year.' nenalezen');
    116           }
    117     $FinanceYear = $DbResult->fetch_assoc();
    118     if ($FinanceYear['Closed'] == 1)
    119       throw new Exception('Rok '.$FinanceYear['Year'].' je již uzavřen. Nelze do něj přidávat položky.');
    120     return $FinanceYear;
    121   }
    122 
    123   function GetNextDocumentLineNumber(string $Id, int $FinanceYear = 0): string
    124   {
    125           $FinanceYear = $this->GetFinanceYear($FinanceYear);
    126 
    127     $DbResult = $this->Database->query('SELECT `Shortcut`, `Id` FROM `DocumentLine` WHERE `Id`='.$Id);
    128     $DocumentLine = $DbResult->fetch_assoc();
    129 
    130     $DbResult = $this->Database->query('SELECT * FROM `DocumentLineSequence` WHERE '.
    131       '`DocumentLine`='.$Id.' AND `FinanceYear`='.$FinanceYear['Id']);
    132     $Sequence = $DbResult->fetch_assoc();
    133 
    134     if ($Sequence['YearPrefix'] == 1)
    135     {
    136       $Result = $DocumentLine['Shortcut'].$Sequence['NextNumber'].'/'.$FinanceYear['Year'];
    137     } else $Result = $DocumentLine['Shortcut'].$Sequence['NextNumber'];
    138 
    139     $this->Database->query('UPDATE `DocumentLineSequence` SET `NextNumber` = `NextNumber` + 1 '.
    140       'WHERE (`DocumentLine`='.$Id.') AND (`FinanceYear`='.$FinanceYear['Id'].')');
    141     return $Result;
    142   }
    143 
    144   function GetNextDocumentLineNumberId(string $Id, int $FinanceYear = 0): int
    145   {
    146     $Code = $this->GetNextDocumentLineNumber($Id, $FinanceYear);
    147     $this->Database->insert('DocumentLineCode', array('DocumentLine' => $Id, 'Name' => $Code));
    148     return $this->Database->insert_id;
    149   }
    150 
    151   function GetFinanceGroupById(string $Id, string $Table): ?array
    152   {
    153     $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `Id`= '.$Id);
    154     if ($DbResult->num_rows == 1) {
    155       $Group = $DbResult->fetch_assoc();
    156       return $Group;
    157     }
    158     echo('Finance group id '.$Id.' not found in table '.$Table);
    159     return null;
    160   }
    161 
    162   function RecalculateMemberPayment(): string
    163   {
    164     $Output = 'Aktualizuji finance členů...<br />';
    165     $this->Database->query('TRUNCATE TABLE `MemberPayment`');
    166     $DbResult = $this->Database->query('SELECT * FROM `Member`');
    167     while ($Member = $DbResult->fetch_assoc())
    168     {
    169       $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(`Value`), 0) FROM `FinanceOperation` '.
    170           'WHERE `Subject`='.$Member['Subject'].') - (SELECT COALESCE(SUM(`Value`), 0) FROM `FinanceInvoice` '.
    171           'WHERE `Subject`='.$Member['Subject'].')) AS `Cash`');
    172       $Cash = $DbResult2->fetch_row();
    173       $Cash = $Cash[0];
    174 
    175       $DbResult2 = $this->Database->query('SELECT SUM(`Product`.`Consumption`) * `StockSerialNumber`.`Amount` '.
    176           'FROM `StockSerialNumber` JOIN `Product` ON `Product`.`Id` = `StockSerialNumber`.`Product` '.
    177           'WHERE (`StockSerialNumber`.`Location` = '.$Member['Id'].') AND (`StockSerialNumber`.`TimeElimination` IS NULL)');
    178       $ConsumptionPlus = $DbResult2->fetch_row();
    179       $ConsumptionPlus = $ConsumptionPlus[0];
    180 
    181       $DbResult2 = $this->Database->query('SELECT SUM(`Service`.`Price`) AS `Price` '.
    182           'FROM `ServiceCustomerRel` LEFT JOIN '.
    183           '`Service` ON `Service`.`Id` = `ServiceCustomerRel`.`Service` WHERE (`ServiceCustomerRel`.`Customer`='.
    184           $Member['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL)');
    185       $DbRow = $DbResult2->fetch_assoc();
    186       $Monthly = 0;
    187       if ($DbRow['Price'] != '') $MonthlyInet = $DbRow['Price'];
    188       else $MonthlyInet = 0;
    189 
    190       $Monthly += $MonthlyInet;
    191       //$Monthly -= $this->W2Kc($ConsumptionPlus);
    192       $Monthly = round($Monthly);
    193 
    194       if ($Member['BillingPeriod'] == 1)
    195       {
    196         // Inactive payer
    197         $MonthlyInet = 0;
    198         $Monthly = 0;
    199         $ConsumptionPlus = 0;
    200         $Consumption = 0;
    201       }
    202       $Consumption = 0;
    203       $this->Database->insert('MemberPayment', array('Member' => $Member['Id'],
    204         'MonthlyInternet' => $MonthlyInet,
    205         'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->W2Kc($Consumption),
    206         'Cash' => $Cash, 'MonthlyPlus' => $this->W2Kc($ConsumptionPlus)));
    207     }
    208     ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'RecalculateMemberPayment');
    209     return $Output;
    210   }
    211 
    212   function GetVATByType(string $TypeId): string
    213   {
    214     $Time = time();
    215     $DbResult = $this->Database->select('FinanceVAT', 'Value', '(Type='.$TypeId.
    216       ') AND (ValidFrom <= "'.TimeToMysqlDate($Time).'") AND ((ValidTo >= "'.
    217       TimeToMysqlDate($Time).'") OR (ValidTo IS NULL)) LIMIT 1');
    218     $Row = $DbResult->fetch_array();
    219     return $Row[0];
    220   }
    221 }
    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 }
    4659
    46610class ModuleFinance extends AppModule
     
    48529  function GetModels(): array
    48630  {
    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     );
     31    return array(FinanceBillingPeriod::GetClassName(), FinanceVatType::GetClassName(), FinanceVat::GetClassName(),
     32      FinanceGroup::GetClassName(), FinanceOperationGroup::GetClassName(), FinanceOperation::GetClassName(),
     33      FinanceInvoiceGroup::GetClassName(), FinanceInvoice::GetClassName(), FinanceInvoiceItem::GetClassName(),
     34      Company::GetClassName(), FinanceTreasury::GetClassName(), FinanceTreasuryCheck::GetClassName(),
     35      Currency::GetClassName(), FinanceBank::GetClassName(), FinanceBankAccount::GetClassName(), FinanceCharge::GetClassName(),
     36      Contract::GetClassName(), FinanceInvoiceOperationRel::GetClassName());
    50537  }
    50638
     
    937469      'Filter' => '1',
    938470    ));
     471    $this->System->FormManager->RegisterClass('FinanceYearReport', array(
     472      'Title' => 'Roční výkaz',
     473      'Table' => 'FinanceYearReport',
     474      'SQL' => 'SELECT Id, DateEnd, DateStart FROM FinanceYear',
     475      'DefaultSortColumn' => 'Id',
     476      'Items' => array(
     477        'Id' => array('Type' => 'TFinanceYear', 'Caption' => 'Rok', 'Default' => '',
     478          'ReadOnly' => true),
     479        'Income' => array('Type' => 'Integer', 'Caption' => 'Příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
     480          'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
     481          'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
     482          'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
     483          'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperationGroup`.`ValueSign` = 1))'),
     484        'Spending' => array('Type' => 'Integer', 'Caption' => 'Výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
     485          'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
     486          'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
     487          'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
     488          'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperationGroup`.`ValueSign` = -1))'),
     489        'OperationBalance' => array('Type' => 'Integer', 'Caption' => 'Zisk', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
     490          'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
     491          'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
     492          'AND (`FinanceOperation`.`Time` >= `DateStart`))'),
     493        'TaxIncome' => array('Type' => 'Integer', 'Caption' => 'Daňové příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
     494          'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
     495          'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
     496          'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
     497          'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1) AND (`FinanceOperationGroup`.`ValueSign` = 1))'),
     498        'TaxSpending' => array('Type' => 'Integer', 'Caption' => 'Daňové výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
     499          'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
     500          'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
     501          'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
     502          'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1) AND (`FinanceOperationGroup`.`ValueSign` = -1))'),
     503        'TaxBase' => array('Type' => 'Integer', 'Caption' => 'Základ daně', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
     504          'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
     505          'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
     506          'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1))'),
     507        'Claims' => array('Type' => 'Integer', 'Caption' => 'Pohledávky', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
     508          'SQL' => '(SELECT ROUND(SUM(`FinanceInvoice`.`Value`)) FROM `FinanceInvoice` '.
     509          'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group` '.
     510          'WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '.
     511          'AND (`FinanceInvoice`.`Time` >= `DateStart`) AND (`FinanceInvoiceGroup`.`ValueSign` = 1))'),
     512        'Liabilities' => array('Type' => 'Integer', 'Caption' => 'Závazky', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
     513          'SQL' => '(SELECT -ROUND(SUM(`FinanceInvoice`.`Value`)) FROM `FinanceInvoice` '.
     514          'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group` '.
     515          'WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '.
     516          'AND (`FinanceInvoice`.`Time` >= `DateStart`) AND (`FinanceInvoiceGroup`.`ValueSign` = -1))'),
     517        'InvoiceBalance' => array('Type' => 'Integer', 'Caption' => 'Fakturační rozdíl', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
     518          'SQL' => '(SELECT ROUND(SUM(`FinanceInvoice`.`Value`)) FROM `FinanceInvoice` WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '.
     519          'AND (`FinanceInvoice`.`Time` >= `DateStart`))'),
     520      ),
     521      //'AfterInsert' => array($this, 'AfterInsertFinanceYear'),
     522    ));
     523    $this->System->FormManager->RegisterClass('FinanceInvoiceOperationRel', array(
     524      'Title' => 'Zaplacení faktůr',
     525      'Table' => 'FinanceInvoiceOperationRel',
     526      'Items' => array(
     527        'Invoice' => array('Type' => 'TFinanceInvoice', 'Caption' => 'Faktura', 'Default' => ''),
     528        'Operation' => array('Type' => 'TFinanceOperation', 'Caption' => 'Platba', 'Default' => ''),
     529      ),
     530    ));
    939531
    940532    $this->Finance->MainSubject = $Config['Finance']['MainSubjectId'];
  • trunk/Modules/FinanceBankAPI/FinanceBankAPI.php

    r893 r894  
    1010  static function GetDesc(): ModelDesc
    1111  {
    12     $Desc = new ModelDesc('FinanceBankImport');
    13     $Desc->AddReference('BankAccount', 'BankAccount');
     12    $Desc = new ModelDesc(self::GetClassName());
     13    $Desc->AddReference('BankAccount', FinanceBankAccount::GetClassName());
    1414    $Desc->AddDate('Time');
    1515    $Desc->AddString('Identification');
     
    2020    $Desc->AddString('SpecificSymbol');
    2121    $Desc->AddFloat('Value');
    22     $Desc->AddReference('Currency', 'Currency');
     22    $Desc->AddReference('Currency', Currency::GetClassName());
    2323    $Desc->AddString('OffsetAccountName');
    24     $Desc->AddReference('FinanceOperation', 'FinanceOperation');
     24    $Desc->AddReference('FinanceOperation', FinanceOperation::GetClassName());
    2525    return $Desc;
    2626  }
     
    4242  function GetModels(): array
    4343  {
    44     return array('FinanceBankImport');
     44    return array(FinanceBankImport::GetClassName());
    4545  }
    4646
  • trunk/Modules/IS/IS.php

    r893 r894  
    847847  static function GetDesc(): ModelDesc
    848848  {
    849     $Desc = new ModelDesc('Menu');
     849    $Desc = new ModelDesc(self::GetClassName());
    850850    $Desc->AddString('Name');
    851851    return $Desc;
     
    857857  static function GetDesc(): ModelDesc
    858858  {
    859     $Desc = new ModelDesc('MenuItem');
     859    $Desc = new ModelDesc(self::GetClassName());
    860860    $Desc->AddString('Name');
    861     $Desc->AddReference('Parent', 'MenuItem');
    862     $Desc->AddReference('Action', 'Action');
    863     $Desc->AddReference('Menu', 'Menu');
     861    $Desc->AddReference('Parent', MenuItem::GetClassName());
     862    $Desc->AddReference('Action', Action::GetClassName());
     863    $Desc->AddReference('Menu', Menu::GetClassName());
    864864    return $Desc;
    865865  }
     
    870870  static function GetDesc(): ModelDesc
    871871  {
    872     $Desc = new ModelDesc('MenuItemFavorite');
    873     $Desc->AddReference('User', 'User');
    874     $Desc->AddReference('MenuItem', 'MenuItem');
     872    $Desc = new ModelDesc(self::GetClassName());
     873    $Desc->AddReference('User', User::GetClassName());
     874    $Desc->AddReference('MenuItem', MenuItem::GetClassName());
    875875    return $Desc;
    876876  }
     
    897897  function GetModels(): array
    898898  {
    899     return array('Menu', 'MenuItem', 'MenuItemFavorite');
     899    return array(Menu::GetClassName(), MenuItem::GetClassName(), MenuItemFavorite::GetClassName());
    900900  }
    901901
  • trunk/Modules/Log/Log.php

    r888 r894  
    1414  }
    1515
    16   function DoInstall(): void
     16  function GetModels(): array
    1717  {
    18   }
    19 
    20   function DoUnInstall(): void
    21   {
     18    return array('Log');
    2219  }
    2320
     
    4138      'Channel' => 'log', 'Callback' => array($this, 'ShowRSS'),
    4239      'Permission' => array('Module' => 'Log', 'Operation' => 'RSS')));
    43   }
    44 
    45   function DoStop(): void
    46   {
    4740  }
    4841
     
    107100  }
    108101}
     102
     103class Log extends Model
     104{
     105  static function GetDesc(): ModelDesc
     106  {
     107    $Desc = new ModelDesc(self::GetClassName());
     108    $Desc->AddDateTime('Time');
     109    $Desc->AddReference('User', User::GetClassName());
     110    $Desc->AddString('Module');
     111    $Desc->AddString('Operation');
     112    $Desc->AddText('Value');
     113    $Desc->AddString('IPAddress');
     114    return $Desc;
     115  }
     116}
  • trunk/Modules/Map/Map.php

    r891 r894  
    314314  }
    315315
    316   function DoInstall(): void
    317   {
    318     $this->InstallModel(MapPosition::GetDesc());
    319   }
    320 
    321   function DoUninstall(): void
    322   {
    323     $this->UninstallModel(MapPosition::GetDesc());
     316  function GetModels(): array
     317  {
     318    return array(MapPosition::GetClassName());
    324319  }
    325320}
     
    329324  static function GetDesc(): ModelDesc
    330325  {
    331     $Desc = new ModelDesc('MapPosition');
     326    $Desc = new ModelDesc(self::GetClassName());
    332327    $Desc->AddString('Name');
    333328    $Desc->AddString('Pos');
  • trunk/Modules/Meals/Meals.php

    r888 r894  
    196196  }
    197197
    198   function DoInstall(): void
    199   {
    200   }
    201 
    202   function DoUnInstall(): void
    203   {
     198  function GetModels(): array
     199  {
     200    return array(Meals::GetClassName(), MealsInfo::GetClassName());
    204201  }
    205202
     
    209206  }
    210207}
     208
     209class Meals extends Model
     210{
     211  static function GetDesc(): ModelDesc
     212  {
     213    $Desc = new ModelDesc(self::GetClassName());
     214    $Desc->AddDate('Date');
     215    $Desc->AddString('Soup');
     216    $Desc->AddString('Meal');
     217    $Desc->AddInteger('Status');
     218    return $Desc;
     219  }
     220}
     221
     222class MealsInfo extends Model
     223{
     224  static function GetDesc(): ModelDesc
     225  {
     226    $Desc = new ModelDesc(self::GetClassName());
     227    $Desc->AddText('Info');
     228    $Desc->AddInteger('Price');
     229    return $Desc;
     230  }
     231}
  • trunk/Modules/Meteostation/Meteostation.php

    r888 r894  
    103103  }
    104104
    105 
    106   function DoInstall(): void
    107   {
    108   }
    109 
    110   function DoUninstall(): void
    111   {
    112   }
    113 
    114105  function DoStart(): void
    115106  {
    116107    $this->System->RegisterPage(['meteo'], 'PageMeteo');
    117108  }
    118 
    119   function DoStop(): void
    120   {
    121   }
    122109}
  • trunk/Modules/Network/Network.php

    r887 r894  
    11<?php
    22
     3include_once(dirname(__FILE__).'/NetworkModels.php');
    34include_once(dirname(__FILE__).'/HostList.php');
    45include_once(dirname(__FILE__).'/Subnet.php');
     
    117118  }
    118119
    119   function DoInstall(): void
    120   {
    121   }
    122 
    123   function DoUninstall(): void
    124   {
     120  function GetModels(): array
     121  {
     122    return array(NetworkDomainAlias::GetClassName(), NetworkDevice::GetClassName(), NetworkDeviceType::GetClassName(),
     123      NetworkDeviceLog::GetClassName(), NetworkInterface::GetClassName(), NetworkInterfaceType::GetClassName(),
     124      NetworkSubnet::GetClassName(), NetworkPort::GetClassName(), NetworkSpeedLimit::GetClassName(),
     125      NetworkInterfaceLatency::GetClassName(), NetworkLink::GetClassName(), NetworkLinkType::GetClassName(),
     126      NetworkSignal::GetClassName(), NetworkAddressCategory::GetClassName(), NetworkDeviceConfig::GetClassName(),
     127      NetworkDomain::GetClassName(), NetworkDomainServer::GetClassName(), NetworkDomainView::GetClassName(),
     128      NetworkDomainItemFilter::GetClassName(), DeviceAPIType::GetClassName(), NetworkInterfaceWireless::GetClassName(),
     129      NetworkInterfaceUpDown::GetClassName(), NetworkPortUpDown::GetClassName());
    125130  }
    126131
     
    794799    global $Config;
    795800
     801    $StartTime = time();
     802
    796803    $DbResult = $this->System->Database->select('NetworkDeviceLog', 'Time',
    797804      '1 ORDER BY Time DESC LIMIT 1');
     
    838845    $Output .= 'Síťových podsítí: '.$DbRow['0'].'<br/>';
    839846    return $Output;
    840   }
    841 
    842   function DoStop(): void
    843   {
    844847  }
    845848
  • trunk/Modules/NetworkConfig/NetworkConfig.php

    r888 r894  
    1717  }
    1818
    19   function DoInstall(): void
     19  function GetModels(): array
    2020  {
    21   }
    22 
    23   function DoUnInstall(): void
    24   {
     21    return array(NetworkConfigurationLog::GetClassName(), NetworkConfiguration::GetClassName());
    2522  }
    2623
     
    109106  }
    110107}
     108
     109class NetworkConfiguration extends Model
     110{
     111  static function GetDesc(): ModelDesc
     112  {
     113    $Desc = new ModelDesc(self::GetClassName());
     114    $Desc->AddString('Caption');
     115    $Desc->AddString('SysName');
     116    $Desc->AddBoolean('Changed');
     117    $Desc->AddDateTime('LastTime');
     118    $Desc->AddInteger('ExecutionTime');
     119    $Desc->AddBoolean('Enabled');
     120    $Desc->AddInteger('Period');
     121    return $Desc;
     122  }
     123}
     124
     125class NetworkConfigurationLog extends Model
     126{
     127  static function GetDesc(): ModelDesc
     128  {
     129    $Desc = new ModelDesc(self::GetClassName());
     130    $Desc->AddString('Caption');
     131    $Desc->AddText('Log');
     132    return $Desc;
     133  }
     134}
  • trunk/Modules/NetworkConfigAirOS/NetworkConfigAirOS.php

    r887 r894  
    1616  }
    1717
    18   function DoInstall(): void
    19   {
    20   }
    21 
    22   function DoUnInstall(): void
    23   {
    24   }
    25 
    2618  function DoStart(): void
    2719  {
  • trunk/Modules/NetworkConfigLinux/NetworkConfigLinux.php

    r887 r894  
    1818  }
    1919
    20   function DoInstall(): void
    21   {
    22   }
    23 
    24   function DoUnInstall(): void
    25   {
    26   }
    27 
    2820  function DoStart(): void
    2921  {
  • trunk/Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php

    r887 r894  
    2727    $this->Description = 'Mikrotik RouterOS configuration';
    2828    $this->Dependencies = array('NetworkConfig');
    29   }
    30 
    31   function DoInstall(): void
    32   {
    33   }
    34 
    35   function DoUnInstall(): void
    36   {
    3729  }
    3830
  • trunk/Modules/NetworkShare/NetworkShare.php

    r887 r894  
    1818  }
    1919
    20   function DoInstall(): void
     20  function GetModels(): array
    2121  {
    22   }
    23 
    24   function DoUnInstall(): void
    25   {
     22    return array(NetworkShareItem::GetClassName(), NetworkShareError::GetClassName());
    2623  }
    2724
     
    3128  }
    3229}
     30
     31class NetworkShareItem extends Model
     32{
     33  static function GetDesc(): ModelDesc
     34  {
     35    $Desc = new ModelDesc('NetworkShareItem');
     36    $Desc->AddString('Name');
     37    $Desc->AddReference('Parent', NetworkShareItem::GetClassName());
     38    $Desc->AddReference('Host', NetworkDevice::GetClassName());
     39    $Desc->AddBigInt('Size');
     40    $Desc->AddString('Ext');
     41    $Desc->AddDate('Date');
     42    $Desc->AddInteger('Type');
     43    return $Desc;
     44  }
     45}
     46
     47class NetworkShareError extends Model
     48{
     49  static function GetDesc(): ModelDesc
     50  {
     51    $Desc = new ModelDesc(self::GetClassName());
     52    $Desc->AddString('Host');
     53    $Desc->AddString('Message');
     54    return $Desc;
     55  }
     56}
  • trunk/Modules/NetworkShare/update.php

    r873 r894  
    88  $Hosts = array();
    99  $StartTime = GetMicrotime();
    10   $DbResult = $Database->query("SELECT * FROM NetworkDevice WHERE Online=1 AND (Block=0 OR Name='centrala') AND (Name!='GATE') AND User>0");
     10  $DbResult = $Database->query("SELECT * FROM `NetworkDevice` WHERE `Online`=1 AND (`Block`=0 OR `Name`='centrala') AND (`Name` != 'GATE') AND (`User` > 0)");
    1111  while ($Row = $DbResult->fetch_array())
    1212  {
     
    1616    $HostID = 100;
    1717    $StartTime2 = GetMicrotime();
    18     if ($Dnes != $Row['last_share_check'])
     18    if ($Dnes != $Row['LastShareCheck'])
    1919    {
    2020      echo("Kontroluji ".$Row['Name']."...\n");
     
    2323    else echo("Vynechavam ".$Row['Name']."...\n");
    2424    // Aktualizuj datum prochazeni
    25     $Database->update('Hosts', "name='".$Row['name']."'",array('last_share_check' => $Dnes));
     25    $Database->update('NetworkDevice', "Id='".$Row['Id']."'", array('LastShareCheck' => $Dnes));
    2626  }
    27   $Rozdil = GetMicrotime()-$StartTime+10;
     27  $Rozdil = GetMicrotime() - $StartTime + 10;
    2828
    2929  // Oprav a zoptimalizuj tabulku
  • trunk/Modules/NetworkTopology/NetworkTopology.php

    r888 r894  
    148148  }
    149149
    150   function DoInstall(): void
     150  function GetModels(): array
    151151  {
    152   }
    153 
    154   function DoUnInstall(): void
    155   {
     152    return array(NetworkTopology::GetClassName());
    156153  }
    157154
     
    161158  }
    162159}
     160
     161class NetworkTopology extends Model
     162{
     163  static function GetDesc(): ModelDesc
     164  {
     165    $Desc = new ModelDesc(self::GetClassName());
     166    $Desc->AddInteger('Host');
     167    $Desc->AddInteger('Depth');
     168    $Desc->AddInteger('Pos');
     169    $Desc->AddInteger('First');
     170    $Desc->AddInteger('Last');
     171    return $Desc;
     172  }
     173}
  • trunk/Modules/News/News.php

    r893 r894  
    3030  function GetModels(): array
    3131  {
    32     return array('NewsCategory', 'News');
    33   }
    34 
    35   function DoInstall(): void
    36   {
    37     foreach (self::GetModels() as $Model)
    38     {
    39       $this->InstallModel($Model::GetDesc());
    40     }
    41   }
    42 
    43   function DoUnInstall(): void
    44   {
    45     foreach (array_reverse(self::GetModels()) as $Model)
    46     {
    47       $this->UninstallModel($Model::GetDesc());
    48     }
     32    return array(NewsCategory::GetClassName(), News::GetClassName());
    4933  }
    5034
     
    302286  static function GetDesc(): ModelDesc
    303287  {
    304     $Desc = new ModelDesc('News');
    305     $Desc->AddReference('Category', 'NewsCategory', true);
     288    $Desc = new ModelDesc(self::GetClassName());
     289    $Desc->AddReference('Category', NewsCategory::GetClassName(), true);
    306290    $Desc->AddString('Title');
    307291    $Desc->AddText('Content');
     
    309293    $Desc->AddString('Author');
    310294    $Desc->AddString('Enclosure');
    311     $Desc->AddReference('User', 'User');
     295    $Desc->AddReference('User', User::GetClassName());
    312296    $Desc->AddString('IP');
    313297    $Desc->AddString('Link');
     
    320304  static function GetDesc(): ModelDesc
    321305  {
    322     $Desc = new ModelDesc('NewsCategory');
     306    $Desc = new ModelDesc(self::GetClassName());
    323307    $Desc->AddString('Caption');
    324308    $Desc->AddString('RSS');
  • trunk/Modules/Notify/Notify.php

    r893 r894  
    130130  function GetModels(): array
    131131  {
    132     return array('NotifyCategory', 'NotifyUser');
     132    return array(NotifyCategory::GetClassName(), NotifyUser::GetClassName());
    133133  }
    134134
     
    190190  static function GetDesc(): ModelDesc
    191191  {
    192     $Desc = new ModelDesc('NotifyCategory');
     192    $Desc = new ModelDesc(self::GetClassName());
    193193    $Desc->AddString('Name');
    194194    $Desc->AddString('SysName');
     
    201201  static function GetDesc(): ModelDesc
    202202  {
    203     $Desc = new ModelDesc('NotifyUser');
    204     $Desc->AddReference('User', 'User');
    205     $Desc->AddReference('Contact', 'Contact');
     203    $Desc = new ModelDesc(self::GetClassName());
     204    $Desc->AddReference('User', User::GetClassName());
     205    $Desc->AddReference('Contact', Contact::GetClassName());
    206206    $Desc->AddInteger('Period');
    207207    return $Desc;
  • trunk/Modules/OpeningHours/OpeningHours.php

    r887 r894  
    228228  }
    229229
     230  function GetModels(): array
     231  {
     232    return array(SubjectOpenTime::GetClassName(), SubjectOpenTimeDay::GetClassName());
     233  }
     234
    230235  function DoStart(): void
    231236  {
     
    237242    $this->System->UnregisterPage(['otviraci-doby']);
    238243  }
    239 
    240   function DoInstall(): void
    241   {
    242   }
    243 
    244   function DoUnInstall(): void
    245   {
    246   }
    247 }
     244}
     245
     246class SubjectOpenTime extends Model
     247{
     248  static function GetDesc(): ModelDesc
     249  {
     250    $Desc = new ModelDesc(self::GetClassName());
     251    $Desc->AddReference('Subject', Subject::GetClassName());
     252    $Desc->AddDateTime('UpdateTime');
     253    $Desc->AddString('Notice');
     254    $Desc->AddString('Photo', File::GetClassName());
     255    return $Desc;
     256  }
     257}
     258
     259class SubjectOpenTimeDay extends Model
     260{
     261  static function GetDesc(): ModelDesc
     262  {
     263    $Desc = new ModelDesc(self::GetClassName());
     264    $Desc->AddReference('Subject', Subject::GetClassName());
     265    $Desc->AddInteger('Day');
     266    $Desc->AddInteger('Open1');
     267    $Desc->AddInteger('Close1');
     268    $Desc->AddInteger('Open2');
     269    $Desc->AddInteger('Close2');
     270    return $Desc;
     271  }
     272}
  • trunk/Modules/Scheduler/Scheduler.php

    r893 r894  
    1212    $this->Description = 'Allow to setup and execute planned and recurring tasks';
    1313    $this->Dependencies = array();
     14  }
     15
     16  function GetModels(): array
     17  {
     18    return array(SchedulerAction::GetClassName(), Scheduler::GetClassName());
    1419  }
    1520
     
    120125  }
    121126}
     127
     128class Scheduler extends Model
     129{
     130  static function GetDesc(): ModelDesc
     131  {
     132    $Desc = new ModelDesc(self::GetClassName());
     133    $Desc->AddString('Name');
     134    $Desc->AddBoolean('Enabled');
     135    $Desc->AddDateTime('ScheduledTime');
     136    $Desc->AddReference('Action', SchedulerAction::GetClassName());
     137    $Desc->AddInteger('Period');
     138    $Desc->AddDateTime('LastExecutedTime');
     139    $Desc->AddInteger('Duration');
     140    $Desc->AddText('Log');
     141    return $Desc;
     142  }
     143}
     144
     145class SchedulerAction extends Model
     146{
     147  static function GetDesc(): ModelDesc
     148  {
     149    $Desc = new ModelDesc(self::GetClassName());
     150    $Desc->AddString('Name');
     151    $Desc->AddString('Class');
     152    return $Desc;
     153  }
     154}
  • trunk/Modules/Search/Search.php

    r887 r894  
    7070  }
    7171
    72   function DoInstall(): void
    73   {
    74   }
    75 
    76   function DoUnInstall(): void
    77   {
    78   }
    79 
    8072  function RegisterSearch(string $Title, string $TableName, array $Columns): void
    8173  {
  • trunk/Modules/Stock/Stock.php

    r893 r894  
    1616  function GetModels(): array
    1717  {
    18     return array('Product', 'StockSerialNumber', 'Stock', 'StockMoveGroup', 'StockMove', 'StockMoveItem',
    19       'StockItemHistory', 'StockMoveItemSerialRel');
     18    return array(Product::GetClassName(), StockSerialNumber::GetClassName(), Stock::GetClassName(),
     19      StockMoveGroup::GetClassName(), StockMove::GetClassName(), StockMoveItem::GetClassName(),
     20      StockItemHistory::GetClassName(), StockMoveItemSerialRel::GetClassName());
    2021  }
    2122
     
    267268  static function GetDesc(): ModelDesc
    268269  {
    269     $Desc = new ModelDesc('Product');
    270     $Desc->AddReference('Manufacturer', 'Subject');
     270    $Desc = new ModelDesc(self::GetClassName());
     271    $Desc->AddReference('Manufacturer', Subject::GetClassName());
    271272    $Desc->AddString('Code');
    272273    $Desc->AddString('Name');
     
    275276    $Desc->AddInteger('VAT');
    276277    $Desc->AddInteger('Consumption');
    277     $Desc->AddReference('Supplier', 'Subject');
    278     $Desc->AddReference('UnitOfMeasure', 'UnitOfMeasure');
     278    $Desc->AddReference('Supplier', Subject::GetClassName());
     279    $Desc->AddReference('UnitOfMeasure', UnitOfMeasure::GetClassName());
    279280    $Desc->AddInteger('StockMinCount');
    280281    return $Desc;
     
    286287  static function GetDesc(): ModelDesc
    287288  {
    288     $Desc = new ModelDesc('StockSerialNumber');
    289     $Desc->AddReference('Stock', 'Stock');
    290     $Desc->AddReference('Product', 'Product');
     289    $Desc = new ModelDesc(self::GetClassName());
     290    $Desc->AddReference('Stock', Stock::GetClassName());
     291    $Desc->AddReference('Product', Product::GetClassName());
    291292    $Desc->AddDate('TimeEnlistment');
    292293    $Desc->AddDate('TimeElimination');
     
    296297    $Desc->AddString('SerialNumber');
    297298    $Desc->AddString('RegNumber');
    298     $Desc->AddReference('Location', 'Member');
    299     $Desc->AddReference('Esemble', 'StockSerialNumber');
     299    $Desc->AddReference('Location', Member::GetClassName());
     300    $Desc->AddReference('Esemble', StockSerialNumber::GetClassName());
    300301    return $Desc;
    301302  }
     
    306307  static function GetDesc(): ModelDesc
    307308  {
    308     $Desc = new ModelDesc('Stock');
    309     $Desc->AddReference('Location', 'Member');
     309    $Desc = new ModelDesc(self::GetClassName());
     310    $Desc->AddReference('Location', Member::GetClassName());
    310311    return $Desc;
    311312  }
     
    316317  static function GetDesc(): ModelDesc
    317318  {
    318     $Desc = new ModelDesc('StockMove');
    319     $Desc->AddReference('Group', 'StockMoveGroup');
     319    $Desc = new ModelDesc(self::GetClassName());
     320    $Desc->AddReference('Group', StockMoveGroup::GetClassName());
    320321    $Desc->AddDateTime('Time');
    321     $Desc->AddReference('Stock', 'Stock');
    322     $Desc->AddReference('File', 'File');
     322    $Desc->AddReference('Stock', Stock::GetClassName());
     323    $Desc->AddReference('File', File::GetClassName());
    323324    return $Desc;
    324325  }
     
    329330  static function GetDesc(): ModelDesc
    330331  {
    331     $Desc = new ModelDesc('StockMoveItem');
    332     $Desc->AddReference('StockMove', 'StockMove');
    333     $Desc->AddReference('Product', 'Product');
     332    $Desc = new ModelDesc(self::GetClassName());
     333    $Desc->AddReference('StockMove', StockMove::GetClassName());
     334    $Desc->AddReference('Product', Product::GetClassName());
    334335    $Desc->AddInteger('UnitPrice');
    335336    $Desc->AddInteger('Amount');
     
    342343  static function GetDesc(): ModelDesc
    343344  {
    344     $Desc = new ModelDesc('StockMoveGroup');
     345    $Desc = new ModelDesc(self::GetClassName());
    345346    $Desc->AddString('Name');
    346     $Desc->AddReference('DocumentLine', 'DocumentLine');
     347    $Desc->AddReference('DocumentLine', DocumentLine::GetClassName());
    347348    $Desc->AddInteger('ValueSign');
    348349    $Desc->AddInteger('Direction');
     
    355356  static function GetDesc(): ModelDesc
    356357  {
    357     $Desc = new ModelDesc('StockItemHistory');
     358    $Desc = new ModelDesc(self::GetClassName());
    358359    $Desc->AddDateTime('Time');
    359     $Desc->AddReference('StockSerialNumber', 'StockSerialNumber');
     360    $Desc->AddReference('StockSerialNumber', StockSerialNumber::GetClassName());
    360361    $Desc->AddText('Text');
    361362    return $Desc;
     
    367368  static function GetDesc(): ModelDesc
    368369  {
    369     $Desc = new ModelDesc('StockMoveItemSerialRel');
    370     $Desc->AddReference('StockMoveItem', 'StockMoveItem');
    371     $Desc->AddReference('StockSerialNumber', 'StockSerialNumber');
    372     return $Desc;
    373   }
    374 }
     370    $Desc = new ModelDesc(self::GetClassName());
     371    $Desc->AddReference('StockMoveItem', StockMoveItem::GetClassName());
     372    $Desc->AddReference('StockSerialNumber', StockSerialNumber::GetClassName());
     373    return $Desc;
     374  }
     375}
  • trunk/Modules/Subject/Subject.php

    r893 r894  
    133133  function GetModels(): array
    134134  {
    135     return array('Country', 'Subject', 'ContactCategory', 'Contact');
     135    return array(Country::GetClassName(), Subject::GetClassName(), ContactCategory::GetClassName(),
     136      Contact::GetClassName());
    136137  }
    137138
     
    149150  static function GetDesc(): ModelDesc
    150151  {
    151     $Desc = new ModelDesc('Subject');
     152    $Desc = new ModelDesc(self::GetClassName());
    152153    $Desc->AddString('Name');
    153154    $Desc->AddString('AddressStreet');
    154155    $Desc->AddString('AddressTown');
    155156    $Desc->AddString('AddressPSC');
    156     $Desc->AddReference('AddressCountry', 'Country', true);
     157    $Desc->AddReference('AddressCountry', Country::GetClassName(), true);
    157158    $Desc->AddString('IC');
    158159    $Desc->AddString('DIC');
    159160    $Desc->AddBoolean('PayVAT');
    160     $Desc->AddReference('MapPosition', 'MapPosition', true);
     161    $Desc->AddReference('MapPosition', MapPosition::GetClassName(), true);
    161162    $Desc->AddString('WWW');
    162163    $Desc->AddString('Note');
     
    169170  static function GetDesc(): ModelDesc
    170171  {
    171     $Desc = new ModelDesc('Country');
     172    $Desc = new ModelDesc(self::GetClassName());
    172173    $Desc->AddString('Name');
    173174    return $Desc;
     
    179180  static function GetDesc(): ModelDesc
    180181  {
    181     $Desc = new ModelDesc('Contact');
    182     $Desc->AddReference('Category', 'ContactCategory', true);
     182    $Desc = new ModelDesc(self::GetClassName());
     183    $Desc->AddReference('Category', ContactCategory::GetClassName(), true);
    183184    $Desc->AddString('Value');
    184     $Desc->AddReference('Subject', 'Subject', true);
    185     $Desc->AddReference('User', 'User', true);
     185    $Desc->AddReference('Subject', Subject::GetClassName(), true);
     186    $Desc->AddReference('User', User::GetClassName(), true);
    186187    $Desc->AddString('Description');
    187188    $Desc->AddBoolean('Receive');
     
    194195  static function GetDesc(): ModelDesc
    195196  {
    196     $Desc = new ModelDesc('ContactCategory');
     197    $Desc = new ModelDesc(self::GetClassName());
    197198    $Desc->AddString('Name');
    198199    return $Desc;
  • trunk/Modules/System/System.php

    r893 r894  
    111111  }
    112112
     113  function GetModels(): array
     114  {
     115    return array(UnitOfMeasure::GetClassName(), ActionIcon::GetClassName(), ActionGroup::GetClassName(),
     116      ActionType::GetClassName(), Action::GetClassName(), Language::GetClassName(), Country::GetClassName());
     117  }
     118
    113119  function DoInstall(): void
    114120  {
     
    538544  }
    539545}
     546
     547class UnitOfMeasure extends Model
     548{
     549  static function GetDesc(): ModelDesc
     550  {
     551    $Desc = new ModelDesc(self::GetClassName());
     552    $Desc->AddString('Name');
     553    $Desc->AddString('Unit');
     554    return $Desc;
     555  }
     556}
     557
     558class Action extends Model
     559{
     560  static function GetDesc(): ModelDesc
     561  {
     562    $Desc = new ModelDesc(self::GetClassName());
     563    $Desc->AddString('Title');
     564    $Desc->AddString('URL');
     565    $Desc->AddReference('Icon', ActionIcon::GetClassName());
     566    $Desc->AddReference('Type', ActionType::GetClassName());
     567    $Desc->AddReference('Group', ActionGroup::GetClassName());
     568    $Desc->AddReference('PermissionOperation', PermissionOperation::GetClassName());
     569    $Desc->AddBoolean('Enable');
     570    return $Desc;
     571  }
     572}
     573
     574class ActionIcon extends Model
     575{
     576  static function GetDesc(): ModelDesc
     577  {
     578    $Desc = new ModelDesc(self::GetClassName());
     579    $Desc->AddString('Name');
     580    return $Desc;
     581  }
     582}
     583
     584class ActionGroup extends Model
     585{
     586  static function GetDesc(): ModelDesc
     587  {
     588    $Desc = new ModelDesc(self::GetClassName());
     589    $Desc->AddString('Name');
     590    return $Desc;
     591  }
     592}
     593
     594class ActionType extends Model
     595{
     596  static function GetDesc(): ModelDesc
     597  {
     598    $Desc = new ModelDesc(self::GetClassName());
     599    $Desc->AddString('Name');
     600    return $Desc;
     601  }
     602}
     603
     604class Language extends Model
     605{
     606  static function GetDesc(): ModelDesc
     607  {
     608    $Desc = new ModelDesc(self::GetClassName());
     609    $Desc->AddString('Name');
     610    return $Desc;
     611  }
     612}
     613
     614class Country extends Model
     615{
     616  static function GetDesc(): ModelDesc
     617  {
     618    $Desc = new ModelDesc(self::GetClassName());
     619    $Desc->AddString('Name');
     620    return $Desc;
     621  }
     622}
     623
  • trunk/Modules/TV/TV.php

    r893 r894  
    114114  function GetModels(): array
    115115  {
    116     return array('TVGroup', 'TV');
     116    return array(TVGroup::GetClassName(), TV::GetClassName());
    117117  }
    118118
     
    168168  static function GetDesc(): ModelDesc
    169169  {
    170     $Desc = new ModelDesc('TVGroup');
     170    $Desc = new ModelDesc(self::GetClassName());
    171171    $Desc->AddString('Name');
    172172    return $Desc;
     
    178178  static function GetDesc(): ModelDesc
    179179  {
    180     $Desc = new ModelDesc('TV');
     180    $Desc = new ModelDesc(self::GetClassName());
    181181    $Desc->AddString('Name');
    182182    $Desc->AddInteger('Frequency');
    183183    $Desc->AddString('Norm');
    184184    $Desc->AddString('Homepage');
    185     $Desc->AddReference('Language', 'Language');
     185    $Desc->AddReference('Language', Language::GetClassName());
    186186    $Desc->AddString('ShortName');
    187187    $Desc->AddString('Stream');
    188188    $Desc->AddString('StreamWeb');
    189189    $Desc->AddString('SourceType');
    190     $Desc->AddReference('Category', 'TVGroup');
     190    $Desc->AddReference('Category', TVGroup::GetClassName());
    191191    return $Desc;
    192192  }
  • trunk/Modules/Task/Task.php

    r893 r894  
    1616  function GetModels(): array
    1717  {
    18     return array('TaskGroup', 'Task', 'Work');
     18    return array(TaskGroup::GetClassName(), Task::GetClassName(), Work::GetClassName());
    1919  }
    2020
     
    111111  static function GetDesc(): ModelDesc
    112112  {
    113     $Desc = new ModelDesc('Task');
     113    $Desc = new ModelDesc(self::GetClassName());
    114114    $Desc->AddString('Name');
    115115    $Desc->AddDate('TimeCreate');
     
    119119    $Desc->AddBoolean('Public');
    120120    $Desc->AddInteger('Progress');
    121     $Desc->AddReference('Group', 'TaskGroup');
     121    $Desc->AddReference('Group', TaskGroup::GetClassName());
    122122    $Desc->AddString('Description');
    123123    $Desc->AddText('Conclusion');
    124     $Desc->AddReference('AssignedTo', 'User');
     124    $Desc->AddReference('AssignedTo', User::GetClassName());
    125125    return $Desc;
    126126  }
     
    131131  static function GetDesc(): ModelDesc
    132132  {
    133     $Desc = new ModelDesc('TaskGroup');
     133    $Desc = new ModelDesc(self::GetClassName());
    134134    $Desc->AddString('Name');
    135135    $Desc->AddText('Description');
    136     $Desc->AddReference('Parent', 'TaskGroup');
     136    $Desc->AddReference('Parent', TaskGroup::GetClassName());
    137137    return $Desc;
    138138  }
     
    143143  static function GetDesc(): ModelDesc
    144144  {
    145     $Desc = new ModelDesc('Work');
     145    $Desc = new ModelDesc(self::GetClassName());
    146146    $Desc->AddString('Name');
    147147    $Desc->AddText('Description');
    148148    $Desc->AddDateTime('TimeStart');
    149149    $Desc->AddFloat('Duration');
    150     $Desc->AddReference('User', 'User');
    151     $Desc->AddReference('Task', 'Task');
     150    $Desc->AddReference('User', User::GetClassName());
     151    $Desc->AddReference('Task', Task::GetClassName());
    152152    return $Desc;
    153153  }
  • trunk/Modules/TimeMeasure/Measure.php

    r893 r894  
    1414  static function GetDesc(): ModelDesc
    1515  {
    16     $Desc = new ModelDesc('Measure');
     16    $Desc = new ModelDesc(self::GetClassName());
    1717    $Desc->AddString('Name');
    1818    $Desc->AddString('Title');
  • trunk/Modules/TimeMeasure/TimeMeasure.php

    r893 r894  
    2020  function GetModels(): array
    2121  {
    22     return array('Measure');
     22    return array(Measure::GetClassName());
    2323  }
    2424
  • trunk/Modules/User/User.php

    r893 r894  
    2525  function GetModels(): array
    2626  {
    27     return array('User', 'UserOnline', 'PermissionGroup', 'PermissionOperation', 'PermissionGroupAssignment', 'PermissionUserAssignment');
     27    return array(User::GetClassName(), UserOnline::GetClassName(), PermissionGroup::GetClassName(), PermissionOperation::GetClassName(),
     28      PermissionGroupAssignment::GetClassName(), PermissionUserAssignment::GetClassName());
    2829  }
    2930
  • trunk/Modules/User/UserModel.php

    r891 r894  
    6767  static function GetDesc(): ModelDesc
    6868  {
    69     $Desc = new ModelDesc('User');
     69    $Desc = new ModelDesc(self::GetClassName());
    7070    $Column = $Desc->AddString('Login');
    7171    $Column->Unique = true;
     
    458458  static function GetDesc(): ModelDesc
    459459  {
    460     $Desc = new ModelDesc('UserOnline');
     460    $Desc = new ModelDesc(self::GetClassName());
    461461    $Desc->Memory = true;
    462     $Desc->AddReference('User', 'User', true);
     462    $Desc->AddReference('User', User::GetClassName(), true);
    463463    $Desc->AddDateTime('ActivityTime');
    464464    $Desc->AddDateTime('LoginTime');
     
    477477  static function GetDesc(): ModelDesc
    478478  {
    479     $Desc = new ModelDesc('PermissionGroup');
     479    $Desc = new ModelDesc(self::GetClassName());
    480480    $Desc->AddString('Description');
    481481    return $Desc;
     
    487487  static function GetDesc(): ModelDesc
    488488  {
    489     $Desc = new ModelDesc('PermissionGroupAssignment');
    490     $Desc->AddReference('Group', 'PermissionGroup');
    491     $Desc->AddReference('AssignedGroup', 'PermissionGroup', true);
    492     $Desc->AddReference('AssignedOperation', 'PermissionOperation', true);
     489    $Desc = new ModelDesc(self::GetClassName());
     490    $Desc->AddReference('Group', PermissionGroup::GetClassName());
     491    $Desc->AddReference('AssignedGroup', PermissionGroup::GetClassName(), true);
     492    $Desc->AddReference('AssignedOperation', PermissionOperation::GetClassName(), true);
    493493    return $Desc;
    494494  }
     
    499499  static function GetDesc(): ModelDesc
    500500  {
    501     $Desc = new ModelDesc('PermissionOperation');
    502     $Desc->AddReference('Module', 'Module');
     501    $Desc = new ModelDesc(self::GetClassName());
     502    $Desc->AddReference('Module', Module::GetClassName());
    503503    $Desc->AddString('Operation');
    504504    $Desc->AddString('Item');
     
    513513  static function GetDesc(): ModelDesc
    514514  {
    515     $Desc = new ModelDesc('PermissionUserAssignment');
    516     $Desc->AddReference('User', 'User');
    517     $Desc->AddReference('AssignedGroup', 'PermissionGroup', true);
    518     $Desc->AddReference('AssignedOperation', 'PermissionOperation', true);
     515    $Desc = new ModelDesc(self::GetClassName());
     516    $Desc->AddReference('User', User::GetClassName());
     517    $Desc->AddReference('AssignedGroup', PermissionGroup::GetClassName(), true);
     518    $Desc->AddReference('AssignedOperation', PermissionOperation::GetClassName(), true);
    519519    return $Desc;
    520520  }
  • trunk/Modules/Wiki/Wiki.php

    r893 r894  
    1717  function GetModels(): array
    1818  {
    19     return array('WikiPage', 'WikiPageContent');
     19    return array(WikiPage::GetClassName(), WikiPageContent::GetClassName());
    2020  }
    2121
     
    5858  static function GetDesc(): ModelDesc
    5959  {
    60     $Desc = new ModelDesc('WikiPageContent');
    61     $Desc->AddReference('Page', 'Page');
     60    $Desc = new ModelDesc(self::GetClassName());
     61    $Desc->AddReference('Page', WikiPage::GetClassName());
    6262    $Desc->AddDateTime('Time');
    6363    $Desc->AddText('Content');
    64     $Desc->AddReference('User', 'User');
     64    $Desc->AddReference('User', User::GetClassName());
    6565    return $Desc;
    6666  }
  • trunk/Packages/Common/AppModule.php

    r893 r894  
    223223      else if ($Column->Type == ModelColumnType::Boolean) $Query .= 'tinyint(1)';
    224224      else if ($Column->Type == ModelColumnType::Date) $Query .= 'date';
     225      else if ($Column->Type == ModelColumnType::BigInt) $Query .= 'bigint(20)';
    225226      else if ($Column->Type == ModelColumnType::Enum)
    226227      {
  • trunk/Packages/Common/Base.php

    r891 r894  
    2020    $this->System = &$System;
    2121    $this->Database = &$System->Database;
     22  }
     23
     24  static function GetClassName()
     25  {
     26    return get_called_class();
    2227  }
    2328}
     
    7681  {
    7782    $Result = new ModelColumnInteger($Name);
     83    $this->Columns[] = $Result;
     84    return $Result;
     85  }
     86
     87  function AddBigInt(string $Name): ModelColumnBigInt
     88  {
     89    $Result = new ModelColumnBigInt($Name);
    7890    $this->Columns[] = $Result;
    7991    return $Result;
     
    137149  const Date = 7;
    138150  const Enum = 8;
     151  const BigInt = 9;
    139152}
    140153
     
    230243}
    231244
     245class ModelColumnBigInt extends ModelColumn
     246{
     247  public ?int $Default;
     248
     249  function __construct(string $Name)
     250  {
     251    parent::__construct($Name, ModelColumnType::BigInt);
     252    $this->HasDefault = false;
     253    $this->Default = null;
     254  }
     255
     256  function GetDefault(): ?string
     257  {
     258    return $this->Default;
     259  }
     260}
     261
    232262class ModelColumnDateTime extends ModelColumn
    233263{
Note: See TracChangeset for help on using the changeset viewer.