1 | <?php
|
---|
2 |
|
---|
3 | class ModuleSubject extends AppModule
|
---|
4 | {
|
---|
5 | function __construct($System)
|
---|
6 | {
|
---|
7 | parent::__construct($System);
|
---|
8 | $this->Name = 'Subject';
|
---|
9 | $this->Version = '1.0';
|
---|
10 | $this->Creator = 'Chronos';
|
---|
11 | $this->License = 'GNU/GPL';
|
---|
12 | $this->Description = 'Subject management';
|
---|
13 | $this->Dependencies = array('User');
|
---|
14 | }
|
---|
15 |
|
---|
16 | function DoStart()
|
---|
17 | {
|
---|
18 | $this->System->FormManager->RegisterClass('Subject', array(
|
---|
19 | 'Title' => 'Subjekty',
|
---|
20 | 'Table' => 'Subject',
|
---|
21 | 'DefaultSortColumn' => 'Name',
|
---|
22 | 'Items' => array(
|
---|
23 | 'Id' => array('Type' => 'Integer', 'Caption' => 'Identifikace', 'Default' => '', 'ReadOnly' => true),
|
---|
24 | 'Name' => array('Type' => 'String', 'Caption' => 'Celé jméno', 'Default' => ''),
|
---|
25 | 'AddressStreet' => array('Type' => 'String', 'Caption' => 'Ulice', 'Default' => ''),
|
---|
26 | 'AddressTown' => array('Type' => 'String', 'Caption' => 'Město', 'Default' => ''),
|
---|
27 | 'AddressPSC' => array('Type' => 'String', 'Caption' => 'PSČ', 'Default' => ''),
|
---|
28 | 'AddressCountry' => array('Type' => 'TCountry', 'Caption' => 'Země', 'Default' => ''),
|
---|
29 | 'IC' => array('Type' => 'String', 'Caption' => 'IČ', 'Default' => ''),
|
---|
30 | 'DIC' => array('Type' => 'String', 'Caption' => 'DIČ', 'Default' => ''),
|
---|
31 | 'MapPosition' => array('Type' => 'TMapPosition', 'Caption' => 'Pozice na mapě', 'Default' => '', 'Null' => true),
|
---|
32 | 'WWW' => array('Type' => 'Hyperlink', 'Caption' => 'WWW', 'Default' => ''),
|
---|
33 | 'Note' => array('Type' => 'String', 'Caption' => 'Poznámka', 'Default' => ''),
|
---|
34 | 'Customer' => array('Type' => 'TMemberListSubject', 'Caption' => 'Členové', 'Default' => ''),
|
---|
35 | 'Operations' => array('Type' => 'TFinanceOperationListSubject', 'Caption' => 'Platby', 'Default' => ''),
|
---|
36 | 'Invoices' => array('Type' => 'TFinanceInvoiceListSubject', 'Caption' => 'Faktury', 'Default' => ''),
|
---|
37 | 'Payment' => array('Type' => 'Float', 'Caption' => 'Placení', 'Default' => '',
|
---|
38 | 'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => 'IFNULL((SELECT SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`Direction`) FROM `FinanceOperation` '.
|
---|
39 | 'WHERE `FinanceOperation`.`Subject`=#Id), 0) - IFNULL((SELECT SUM(`FinanceInvoice`.`Value` * `FinanceInvoice`.`Direction`) FROM `FinanceInvoice` '.
|
---|
40 | 'WHERE `FinanceInvoice`.`Subject`=#Id), 0)'),
|
---|
41 | 'BankAccounts' => array('Type' => 'TFinanceBankAccountListSubject', 'Caption' => 'Bankovní účety', 'Default' => ''),
|
---|
42 | ),
|
---|
43 | ));
|
---|
44 | $this->System->FormManager->RegisterFormType('TFinanceBankAccountListSubject', array(
|
---|
45 | 'Type' => 'ManyToOne',
|
---|
46 | 'Table' => 'FinanceBankAccount',
|
---|
47 | 'Id' => 'Id',
|
---|
48 | 'Ref' => 'Subject',
|
---|
49 | 'Filter' => '1',
|
---|
50 | ));
|
---|
51 | $this->System->FormManager->RegisterClass('SubjectReport', array(
|
---|
52 | 'Title' => 'Přehled subjektů',
|
---|
53 | 'Table' => 'SubjectReport',
|
---|
54 | 'DefaultSortColumn' => 'Id',
|
---|
55 | 'SQL' => '(SELECT Id FROM Subject)',
|
---|
56 | 'Items' => array(
|
---|
57 | 'Id' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => '', 'ReadOnly' => true),
|
---|
58 | 'Income' => array('Type' => 'Integer', 'Caption' => 'Příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
59 | 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`Direction`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Subject` = TX.`Id`) '.
|
---|
60 | 'AND (`FinanceOperation`.`Direction` = 1))'),
|
---|
61 | 'Spending' => array('Type' => 'Integer', 'Caption' => 'Výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
62 | 'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`Direction`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Subject` = TX.`Id`) '.
|
---|
63 | 'AND (`FinanceOperation`.`Direction` = -1))'),
|
---|
64 | 'OperationBalance' => array('Type' => 'Integer', 'Caption' => 'Zisk', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
65 | 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`Direction`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Subject` = TX.`Id`) '.
|
---|
66 | ')'),
|
---|
67 | ),
|
---|
68 | ));
|
---|
69 | $this->System->FormManager->RegisterFormType('TContactCategory', array(
|
---|
70 | 'Type' => 'Reference',
|
---|
71 | 'Table' => 'ContactCategory',
|
---|
72 | 'Id' => 'Id',
|
---|
73 | 'Name' => 'Name',
|
---|
74 | 'Filter' => '1',
|
---|
75 | ));
|
---|
76 | $this->System->FormManager->RegisterFormType('TContactListCategory', array(
|
---|
77 | 'Type' => 'ManyToOne',
|
---|
78 | 'Table' => 'Contact',
|
---|
79 | 'Id' => 'Id',
|
---|
80 | 'Ref' => 'Category',
|
---|
81 | 'Filter' => '1',
|
---|
82 | ));
|
---|
83 | $this->System->FormManager->RegisterFormType('TContactListUser', array(
|
---|
84 | 'Type' => 'ManyToOne',
|
---|
85 | 'Table' => 'Contact',
|
---|
86 | 'Id' => 'Id',
|
---|
87 | 'Ref' => 'User',
|
---|
88 | 'Filter' => '1',
|
---|
89 | ));
|
---|
90 | $this->System->FormManager->RegisterClass('Contact', array(
|
---|
91 | 'Title' => 'Kontakty',
|
---|
92 | 'Table' => 'Contact',
|
---|
93 | 'Items' => array(
|
---|
94 | 'Category' => array('Type' => 'TContactCategory', 'Caption' => 'Druh', 'Default' => ''),
|
---|
95 | 'Value' => array('Type' => 'String', 'Caption' => 'Hodnota', 'Default' => ''),
|
---|
96 | 'User' => array('Type' => 'TUser', 'Caption' => 'Uživatel', 'Default' => '', 'Null' => true),
|
---|
97 | 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subject', 'Default' => '', 'Null' => true),
|
---|
98 | 'Description' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => ''),
|
---|
99 | 'Receive' => array('Type' => 'Boolean', 'Caption' => 'Přijímat zprávy', 'Default' => '0'),
|
---|
100 | ),
|
---|
101 | ));
|
---|
102 | $this->System->FormManager->RegisterClass('ContactCategory', array(
|
---|
103 | 'Title' => 'Druh kontaktu',
|
---|
104 | 'Table' => 'ContactCategory',
|
---|
105 | 'Items' => array(
|
---|
106 | 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
|
---|
107 | 'Items' => array('Type' => 'TContactListCategory', 'Caption' => 'Kontakty'),
|
---|
108 | ),
|
---|
109 | ));
|
---|
110 | $this->System->FormManager->RegisterFormType('TSubject', array(
|
---|
111 | 'Type' => 'Reference',
|
---|
112 | 'Table' => 'Subject',
|
---|
113 | 'Id' => 'Id',
|
---|
114 | 'Name' => 'Name',
|
---|
115 | 'Filter' => '1',
|
---|
116 | ));
|
---|
117 | }
|
---|
118 | }
|
---|