Ignore:
Timestamp:
Jan 5, 2021, 10:30:31 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Further improved models initialization system.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.