| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | class Employee extends Model
|
|---|
| 4 | {
|
|---|
| 5 | static function GetModelDesc(): ModelDesc
|
|---|
| 6 | {
|
|---|
| 7 | $Desc = new ModelDesc(self::GetClassName());
|
|---|
| 8 | $Desc->AddDateTime('Time');
|
|---|
| 9 | $Desc->AddString('To');
|
|---|
| 10 | $Desc->AddString('Subject');
|
|---|
| 11 | $Desc->AddText('Content');
|
|---|
| 12 | $Desc->AddString('Headers');
|
|---|
| 13 | $Desc->AddBoolean('Archive');
|
|---|
| 14 | $Desc->AddString('From');
|
|---|
| 15 | $Desc->AddReference('AttachmentFile', File::GetClassName());
|
|---|
| 16 | return $Desc;
|
|---|
| 17 | }
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | class EmployeeSalary extends Model
|
|---|
| 21 | {
|
|---|
| 22 | static function GetModelDesc(): ModelDesc
|
|---|
| 23 | {
|
|---|
| 24 | $Desc = new ModelDesc(self::GetClassName());
|
|---|
| 25 | $Desc->AddDate('Date');
|
|---|
| 26 | $Desc->AddReference('Employee', Employee::GetClassName());
|
|---|
| 27 | $Desc->AddInteger('Amount');
|
|---|
| 28 | $Desc->AddReference('Contract', Contract::GetClassName());
|
|---|
| 29 | return $Desc;
|
|---|
| 30 | }
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | class ModuleEmployee extends Module
|
|---|
| 34 | {
|
|---|
| 35 | function __construct(System $System)
|
|---|
| 36 | {
|
|---|
| 37 | parent::__construct($System);
|
|---|
| 38 | $this->Name = 'Employee';
|
|---|
| 39 | $this->Version = '1.0';
|
|---|
| 40 | $this->Creator = 'Chronos';
|
|---|
| 41 | $this->License = 'GNU/GPLv3';
|
|---|
| 42 | $this->Description = 'Employee wages management';
|
|---|
| 43 | $this->Dependencies = array(ModuleUser::GetName(), ModuleFinance::GetName());
|
|---|
| 44 | $this->Models = array(Employee::GetClassName(), EmployeeSalary::GetClassName());
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | function DoStart(): void
|
|---|
| 48 | {
|
|---|
| 49 | $this->System->FormManager->RegisterClass('Employee', array(
|
|---|
| 50 | 'Title' => 'Zaměstnanci',
|
|---|
| 51 | 'Table' => 'Employee',
|
|---|
| 52 | 'Items' => array(
|
|---|
| 53 | 'FirstName' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
|
|---|
| 54 | 'SecondName' => array('Type' => 'String', 'Caption' => 'Příjmení', 'Default' => ''),
|
|---|
| 55 | 'Salary' => array('Type' => 'Integer', 'Caption' => 'Pevná mzda', 'Default' => '0', 'Suffix' => 'Kč'),
|
|---|
| 56 | 'ValidFrom' => array('Type' => 'Date', 'Caption' => 'Platnost od', 'Default' => ''),
|
|---|
| 57 | 'ValidTo' => array('Type' => 'Date', 'Caption' => 'Platnost do', 'Default' => '', 'Null' => true),
|
|---|
| 58 | 'SalaryList' => array('Type' => 'TEmployeeSalaryList', 'Caption' => 'Mzda', 'Default' => ''),
|
|---|
| 59 | ),
|
|---|
| 60 | ));
|
|---|
| 61 | $this->System->FormManager->RegisterClass('EmployeeSalary', array(
|
|---|
| 62 | 'Title' => 'Výplaty zaměstnanců',
|
|---|
| 63 | 'Table' => 'EmployeeSalary',
|
|---|
| 64 | 'Items' => array(
|
|---|
| 65 | 'Date' => array('Type' => 'Date', 'Caption' => 'Datum', 'Default' => ''),
|
|---|
| 66 | 'Employee' => array('Type' => 'TEmployee', 'Caption' => 'Zaměstnance', 'Default' => ''),
|
|---|
| 67 | 'Amount' => array('Type' => 'Integer', 'Caption' => 'Částka', 'Default' => '0', 'Suffix' => 'Kč'),
|
|---|
| 68 | 'Contract' => array('Type' => 'TContract', 'Caption' => 'Smlouva', 'Default' => ''),
|
|---|
| 69 | ),
|
|---|
| 70 | ));
|
|---|
| 71 | $this->System->FormManager->RegisterFormType('TEmployee', array(
|
|---|
| 72 | 'Type' => 'Reference',
|
|---|
| 73 | 'Table' => 'Employee',
|
|---|
| 74 | 'Id' => 'Id',
|
|---|
| 75 | 'Name' => 'CONCAT_WS(" ", NULLIF(`FirstName`, ""), NULLIF(`SecondName`, ""))',
|
|---|
| 76 | 'Filter' => '1',
|
|---|
| 77 | ));
|
|---|
| 78 | $this->System->FormManager->RegisterFormType('TEmployeeSalaryList', array(
|
|---|
| 79 | 'Type' => 'ManyToOne',
|
|---|
| 80 | 'Table' => 'EmployeeSalary',
|
|---|
| 81 | 'Id' => 'Id',
|
|---|
| 82 | 'Ref' => 'Employee',
|
|---|
| 83 | 'Filter' => '1',
|
|---|
| 84 | ));
|
|---|
| 85 | $this->System->FormManager->RegisterFormType('TEmployeeSalaryListContract', array(
|
|---|
| 86 | 'Type' => 'ManyToOne',
|
|---|
| 87 | 'Table' => 'EmployeeSalary',
|
|---|
| 88 | 'Id' => 'Id',
|
|---|
| 89 | 'Ref' => 'Contract',
|
|---|
| 90 | 'Filter' => '1',
|
|---|
| 91 | ));
|
|---|
| 92 | }
|
|---|
| 93 | }
|
|---|