1 | <?php
|
---|
2 |
|
---|
3 | class ModuleCustomer extends Module
|
---|
4 | {
|
---|
5 | function __construct(System $System)
|
---|
6 | {
|
---|
7 | parent::__construct($System);
|
---|
8 | $this->Name = 'Customer';
|
---|
9 | $this->Version = '1.0';
|
---|
10 | $this->Creator = 'Chronos';
|
---|
11 | $this->License = 'GNU/GPLv3';
|
---|
12 | $this->Description = 'Customer management';
|
---|
13 | $this->Dependencies = array(ModuleUser::GetName(), ModuleFinance::GetName());
|
---|
14 | $this->Models = array(Member::GetClassName(), MemberPayment::GetClassName(), SupportActivity::GetClassName(), ServiceCategory::GetClassName(),
|
---|
15 | Service::GetClassName(), ServiceCustomerRel::GetClassName(), UserCustomerRel::GetClassName(), AddressPlace::GetClassName());
|
---|
16 | }
|
---|
17 |
|
---|
18 | function DoStart(): void
|
---|
19 | {
|
---|
20 | $this->System->FormManager->RegisterClass('Member', array(
|
---|
21 | 'Title' => 'Zákazníci',
|
---|
22 | 'Table' => 'Member',
|
---|
23 | 'DefaultSortColumn' => 'Name',
|
---|
24 | 'Items' => array(
|
---|
25 | 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
|
---|
26 | 'ResponsibleUser' => array('Type' => 'TUser', 'Caption' => 'Zodpovědný uživatel', 'Default' => ''),
|
---|
27 | 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => ''),
|
---|
28 | 'AddressPlace' => array('Type' => 'TAddressPlace', 'Caption' => 'Adresní místo', 'Default' => '', 'Null' => true),
|
---|
29 | 'FamilyMemberCount' => array('Type' => 'String', 'Caption' => 'Bydlících osob', 'Default' => '0', 'Suffix' => 'osob'),
|
---|
30 | 'MembershipDate' => array('Type' => 'Date', 'Caption' => 'Datum členství', 'Default' => ''),
|
---|
31 | 'BillingPeriod' => array('Type' => 'TFinanceBillingPeriod', 'Caption' => 'Fakturační období aktuální', 'Default' => ''),
|
---|
32 | 'BillingPeriodLastDate' => array('Type' => 'Date', 'Caption' => 'Datum poslední fakturace', 'Default' => ''),
|
---|
33 | 'Blocked' => array('Type' => 'Boolean', 'Caption' => 'Blokování', 'Default' => '0'),
|
---|
34 | 'PayDay' => array('Type' => 'Integer', 'Caption' => 'Den placení', 'Default' => '1', 'Suffix' => 'den'),
|
---|
35 | 'Devices' => array('Type' => 'TDeviceList', 'Caption' => 'Registrovaná zařízení', 'Default' => ''),
|
---|
36 | 'UserRel' => array('Type' => 'TUserCustomerRelListCustomer', 'Caption' => 'Přiřazení uživatelé', 'Default' => ''),
|
---|
37 | 'ServiceRel' => array('Type' => 'TServiceCustomerRelListCustomer', 'Caption' => 'Placené služby', 'Default' => ''),
|
---|
38 | 'SupportActivity' => array('Type' => 'TSupportActivityListCustomer', 'Caption' => 'Zákaznická podpora', 'Default' => ''),
|
---|
39 | 'Consumption' => array('Type' => 'TCustomerStockSerialNumber', 'Caption' => 'Spotřeba zařízení', 'Default' => ''),
|
---|
40 | 'Contract' => array('Type' => 'TContract', 'Caption' => 'Smlouva', 'Default' => '', 'Null' => true),
|
---|
41 | 'PaymentEmailTime' => array('Type' => 'DateTime', 'Caption' => 'Čas platebního emailu', 'Default' => 'now', 'Null' => true, 'NotInList' => true),
|
---|
42 | 'ChangeAction' => array('Type' => 'TActionEnum', 'Caption' => 'Změna - akce', 'Default' => '', 'Null' => true, 'NotInList' => true),
|
---|
43 | 'ChangeTime' => array('Type' => 'DateTime', 'Caption' => 'Změna - čas', 'Default' => '', 'Null' => true, 'NotInList' => true),
|
---|
44 | 'ChangeReplaceId' => array('Type' => 'TMember', 'Caption' => 'Změna - položka', 'Default' => '0', 'Null' => true, 'NotInList' => true),
|
---|
45 | ),
|
---|
46 | 'ItemActions' => array(
|
---|
47 | array('Caption' => 'Klientská sekce', 'URL' => '/finance/platby/?i=#RowId'),
|
---|
48 | array('Caption' => 'Email s vyúčtováním do fronty', 'URL' => '/finance/sprava/?Operation=SendPaymentEmail&i=#RowId'),
|
---|
49 | ),
|
---|
50 | ));
|
---|
51 | $this->System->FormManager->RegisterClass('MemberPayment', array(
|
---|
52 | 'Title' => 'Placení zákazníků',
|
---|
53 | 'Table' => 'MemberPayment',
|
---|
54 | 'Items' => array(
|
---|
55 | 'Member' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => '', 'ReadOnly' => true),
|
---|
56 | 'MonthlyTotal' => array('Type' => 'Integer', 'Caption' => 'Celkem měsíčně', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true),
|
---|
57 | 'MonthlyInternet' => array('Type' => 'Integer', 'Caption' => 'Internet měsíčně', 'Default' => '', 'Suffix' => 'Kč', 'ReadOnly' => true),
|
---|
58 | 'MonthlyConsumption' => array('Type' => 'Integer', 'Caption' => 'Spotřeba měsíčně', 'Default' => '', 'Suffix' => 'Kč', 'ReadOnly' => true),
|
---|
59 | 'MonthlyPlus' => array('Type' => 'Integer', 'Caption' => 'Měsíčně plus', 'Default' => '', 'Suffix' => 'Kč', 'ReadOnly' => true),
|
---|
60 | 'Cash' => array('Type' => 'Integer', 'Caption' => 'Kredit', 'Default' => '', 'Suffix' => 'Kč', 'ReadOnly' => true),
|
---|
61 | ),
|
---|
62 | 'Actions' => array(
|
---|
63 | array('Caption' => 'Přepočítat', 'URL' => '/finance/sprava/?Operation=Recalculate'),
|
---|
64 | ),
|
---|
65 | ));
|
---|
66 | $this->System->FormManager->RegisterFormType('TMember', array(
|
---|
67 | 'Type' => 'Reference',
|
---|
68 | 'Table' => 'Member',
|
---|
69 | 'Id' => 'Id',
|
---|
70 | 'Name' => 'Name',
|
---|
71 | 'Filter' => '1',
|
---|
72 | ));
|
---|
73 | $this->System->FormManager->RegisterClass('Service', array(
|
---|
74 | 'Title' => 'Služby',
|
---|
75 | 'Table' => 'Service',
|
---|
76 | 'DefaultSortColumn' => 'Name',
|
---|
77 | 'Items' => array(
|
---|
78 | 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
|
---|
79 | 'Category' => array('Type' => 'TServiceCategory', 'Caption' => 'Skupina', 'Default' => '', 'Null' => true),
|
---|
80 | 'Price' => array('Type' => 'Integer', 'Caption' => 'Cena', 'Default' => '0', 'Suffix' => 'Kč'),
|
---|
81 | 'VAT' => array('Type' => 'TFinanceVATType', 'Caption' => 'Sazba DPH', 'Default' => '0', 'Suffix' => ''),
|
---|
82 | 'CustomerCount' => array('Type' => 'Integer', 'Caption' => 'Počet zákazníků', 'Default' => '', 'ReadOnly' => true,
|
---|
83 | 'SQL' => '(SELECT COUNT(*) FROM `ServiceCustomerRel` LEFT JOIN `Member` ON `Member`.`Id`=`ServiceCustomerRel`.`Customer` WHERE (`ServiceCustomerRel`.`Service`=#Id) AND (`Member`.`Blocked`=0))'),
|
---|
84 | 'Public' => array('Type' => 'Boolean', 'Caption' => 'Veřejné', 'Default' => ''),
|
---|
85 | 'InternetSpeedMin' => array('Type' => 'Integer', 'Caption' => 'Min. rychlost internetu', 'Default' => '0', 'Suffix' => 'bit/s'),
|
---|
86 | 'InternetSpeedMax' => array('Type' => 'Integer', 'Caption' => 'Max. rychlost internetu', 'Default' => '0', 'Suffix' => 'bit/s'),
|
---|
87 | 'InternetSpeedBonus' => array('Type' => 'Integer', 'Caption' => 'Bonusová rychlost internetu', 'Default' => '0', 'Suffix' => 'bit/s'),
|
---|
88 | 'UploadAsymmetry' => array('Type' => 'Integer', 'Caption' => 'Asymetrie odesílání', 'Default' => '1'),
|
---|
89 | 'Memory' => array('Type' => 'Integer', 'Caption' => 'Paměť', 'Default' => '0', 'Suffix' => 'GB'),
|
---|
90 | 'MemorySwap' => array('Type' => 'Integer', 'Caption' => 'Odkládací oddíl', 'Default' => '0', 'Suffix' => 'GB'),
|
---|
91 | 'Storage' => array('Type' => 'Integer', 'Caption' => 'Úložiště', 'Default' => '0', 'Suffix' => 'GB'),
|
---|
92 | 'CPUCount' => array('Type' => 'Integer', 'Caption' => 'Počet jader', 'Default' => '0', 'Suffix' => ''),
|
---|
93 | 'ChangeAction' => array('Type' => 'TActionEnum', 'Caption' => 'Změna - akce', 'Default' => '', 'Null' => true, 'NotInList' => true),
|
---|
94 | 'ChangeTime' => array('Type' => 'DateTime', 'Caption' => 'Změna - čas', 'Default' => '', 'Null' => true, 'NotInList' => true),
|
---|
95 | 'ChangeReplaceId' => array('Type' => 'TService', 'Caption' => 'Změna - položka', 'Default' => '', 'Null' => true, 'NotInList' => true),
|
---|
96 | 'CustomerRel' => array('Type' => 'TServiceCustomerRelListService', 'Caption' => 'Placení zákazníky', 'Default' => ''),
|
---|
97 | 'TvRel' => array('Type' => 'TServiceTvRelListService', 'Caption' => 'TV kanály', 'Default' => ''),
|
---|
98 | ),
|
---|
99 | ));
|
---|
100 | $this->System->FormManager->RegisterClass('ServiceCategory', array(
|
---|
101 | 'Title' => 'Kategorie služeb',
|
---|
102 | 'Table' => 'ServiceCategory',
|
---|
103 | 'Items' => array(
|
---|
104 | 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
|
---|
105 | 'Items' => array('Type' => 'TServiceListServiceCategory', 'Caption' => 'Služby', 'Default' => ''),
|
---|
106 | ),
|
---|
107 | ));
|
---|
108 | $this->System->FormManager->RegisterClass('ServiceCustomerRel', array(
|
---|
109 | 'Title' => 'Služby zákazníka',
|
---|
110 | 'Table' => 'ServiceCustomerRel',
|
---|
111 | 'Items' => array(
|
---|
112 | 'Service' => array('Type' => 'TService', 'Caption' => 'Služba', 'Default' => ''),
|
---|
113 | 'ServicePrice' => array('Type' => 'Integer', 'Caption' => 'Cena', 'Default' => '', 'ReadOnly' => true, 'Suffix' => 'Kč',
|
---|
114 | 'SQL' => 'SELECT `Service`.`Price` FROM `Service` WHERE `Service`.`Id`=`TX`.`Service`'),
|
---|
115 | 'Customer' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => ''),
|
---|
116 | 'SpeedLimit' => array('Type' => 'TNetworkSpeedLimit', 'Caption' => 'Omezení rychlosti', 'Default' => null, 'Null' => true),
|
---|
117 | 'Devices' => array('Type' => 'TNetworkDeviceListService', 'Caption' => 'Zařízení', 'Default' => ''),
|
---|
118 | 'Subnets' => array('Type' => 'TNetworkSubnetListService', 'Caption' => 'Podsítě', 'Default' => ''),
|
---|
119 | 'ChangeAction' => array('Type' => 'TActionEnum', 'Caption' => 'Změna - akce', 'Default' => '', 'Null' => true, 'NotInList' => true),
|
---|
120 | 'ChangeTime' => array('Type' => 'DateTime', 'Caption' => 'Změna - čas', 'Default' => '', 'Null' => true, 'NotInList' => true),
|
---|
121 | 'ChangeReplaceId' => array('Type' => 'TServiceCustomerRel', 'Caption' => 'Změna - položka', 'Default' => '', 'Null' => true, 'NotInList' => true),
|
---|
122 | ),
|
---|
123 | ));
|
---|
124 | $this->System->FormManager->RegisterClass('AddressPlace', array(
|
---|
125 | 'Title' => 'Adresní místo',
|
---|
126 | 'Table' => 'AddressPlace',
|
---|
127 | 'DefaultSortColumn' => 'HouseNumber',
|
---|
128 | 'DefaultSortOrder' => 1,
|
---|
129 | 'Items' => array(
|
---|
130 | 'Town' => array('Type' => 'String', 'Caption' => 'Město', 'Default' => ''),
|
---|
131 | 'Street' => array('Type' => 'String', 'Caption' => 'Ulice', 'Default' => ''),
|
---|
132 | 'HouseNumber' => array('Type' => 'Integer', 'Caption' => 'Číslo domu', 'Default' => ''),
|
---|
133 | 'HouseNumberType' => array('Type' => 'THouseNumberType', 'Caption' => 'Typ čísla', 'Default' => ''),
|
---|
134 | 'Psc' => array('Type' => 'Integer', 'Caption' => 'PSČ', 'Default' => ''),
|
---|
135 | 'RuianCode' => array('Type' => 'Integer', 'Caption' => 'Kód Ruian', 'Default' => ''),
|
---|
136 | 'Customers' => array('Type' => 'TCustomerListAddressPlace', 'Caption' => 'Zákazníci', 'Default' => '', 'Null' => true, 'NotInList' => true),
|
---|
137 | ),
|
---|
138 | ));
|
---|
139 | $this->System->FormManager->RegisterFormType('TAddressPlace', array(
|
---|
140 | 'Type' => 'Reference',
|
---|
141 | 'Table' => 'AddressPlace',
|
---|
142 | 'Id' => 'Id',
|
---|
143 | 'Name' => 'CONCAT_WS(" ", NULLIF(AddressPlace.Town, ""), REPLACE(REPLACE(AddressPlace.HouseNumberType, "0", ""), 1, "e.v."), NULLIF(AddressPlace.HouseNumber, ""))',
|
---|
144 | 'Filter' => '1',
|
---|
145 | ));
|
---|
146 | $this->System->FormManager->RegisterFormType('THouseNumberType', array(
|
---|
147 | 'Type' => 'Enumeration',
|
---|
148 | 'States' => array(0 => 'Popisné', 1 => 'Evidenční'),
|
---|
149 | ));
|
---|
150 | $this->System->FormManager->RegisterFormType('TCustomerListAddressPlace', array(
|
---|
151 | 'Type' => 'ManyToOne',
|
---|
152 | 'Table' => 'Member',
|
---|
153 | 'Id' => 'Id',
|
---|
154 | 'Ref' => 'AddressPlace',
|
---|
155 | 'Filter' => '1',
|
---|
156 | ));
|
---|
157 | $this->System->FormManager->RegisterFormType('TServiceCategory', array(
|
---|
158 | 'Type' => 'Reference',
|
---|
159 | 'Table' => 'ServiceCategory',
|
---|
160 | 'Id' => 'Id',
|
---|
161 | 'Name' => 'Name',
|
---|
162 | 'Filter' => '1',
|
---|
163 | ));
|
---|
164 | $this->System->FormManager->RegisterFormType('TService', array(
|
---|
165 | 'Type' => 'Reference',
|
---|
166 | 'Table' => 'Service',
|
---|
167 | 'Id' => 'Id',
|
---|
168 | 'Name' => 'Name',
|
---|
169 | 'Filter' => '1',
|
---|
170 | ));
|
---|
171 | $this->System->FormManager->RegisterFormType('TServiceCustomerRel', array(
|
---|
172 | 'Type' => 'Reference',
|
---|
173 | 'Table' => 'ServiceCustomerRel',
|
---|
174 | 'Id' => 'Id',
|
---|
175 | 'Name' => 'Id',
|
---|
176 | 'Filter' => '1',
|
---|
177 | ));
|
---|
178 | $this->System->FormManager->RegisterFormType('TServiceCustomerRelListCustomer', array(
|
---|
179 | 'Type' => 'ManyToOne',
|
---|
180 | 'Table' => 'ServiceCustomerRel',
|
---|
181 | 'Id' => 'Id',
|
---|
182 | 'Ref' => 'Customer',
|
---|
183 | 'Filter' => '1',
|
---|
184 | ));
|
---|
185 | $this->System->FormManager->RegisterFormType('TNetworkDeviceListService', array(
|
---|
186 | 'Type' => 'ManyToOne',
|
---|
187 | 'Table' => 'NetworkDevice',
|
---|
188 | 'Id' => 'Id',
|
---|
189 | 'Ref' => 'Service',
|
---|
190 | 'Filter' => '1',
|
---|
191 | ));
|
---|
192 | $this->System->FormManager->RegisterFormType('TNetworkSubnetListService', array(
|
---|
193 | 'Type' => 'ManyToOne',
|
---|
194 | 'Table' => 'NetworkSubnet',
|
---|
195 | 'Id' => 'Id',
|
---|
196 | 'Ref' => 'Service',
|
---|
197 | 'Filter' => '1',
|
---|
198 | ));
|
---|
199 | $this->System->FormManager->RegisterFormType('TServiceCustomerRelListService', array(
|
---|
200 | 'Type' => 'ManyToOne',
|
---|
201 | 'Table' => 'ServiceCustomerRel',
|
---|
202 | 'Id' => 'Id',
|
---|
203 | 'Ref' => 'Service',
|
---|
204 | 'Filter' => '1',
|
---|
205 | ));
|
---|
206 | $this->System->FormManager->RegisterFormType('TServiceTvRelListService', array(
|
---|
207 | 'Type' => 'ManyToOne',
|
---|
208 | 'Table' => 'ServiceTvRel',
|
---|
209 | 'Id' => 'Id',
|
---|
210 | 'Ref' => 'Service',
|
---|
211 | 'Filter' => '1',
|
---|
212 | ));
|
---|
213 | $this->System->FormManager->RegisterFormType('TServiceListServiceCategory', array(
|
---|
214 | 'Type' => 'ManyToOne',
|
---|
215 | 'Table' => 'Service',
|
---|
216 | 'Id' => 'Id',
|
---|
217 | 'Ref' => 'Category',
|
---|
218 | 'Filter' => '1',
|
---|
219 | ));
|
---|
220 | $this->System->FormManager->RegisterClass('SupportActivity', array(
|
---|
221 | 'Title' => 'Zákaznická podpora',
|
---|
222 | 'Table' => 'SupportActivity',
|
---|
223 | 'DefaultSortColumn' => 'Time',
|
---|
224 | 'DefaultSortOrder' => 1,
|
---|
225 | 'Items' => array(
|
---|
226 | 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''),
|
---|
227 | 'Description' => array('Type' => 'Text', 'Caption' => 'Popis', 'Default' => ''),
|
---|
228 | 'Customer' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => ''),
|
---|
229 | 'User' => array('Type' => 'TUser', 'Caption' => 'Pracovník', 'Default' => ''),
|
---|
230 | ),
|
---|
231 | ));
|
---|
232 | $this->System->FormManager->RegisterFormType('TSupportActivityListCustomer', array(
|
---|
233 | 'Type' => 'ManyToOne',
|
---|
234 | 'Table' => 'SupportActivity',
|
---|
235 | 'Id' => 'Id',
|
---|
236 | 'Ref' => 'Customer',
|
---|
237 | 'Filter' => '1',
|
---|
238 | ));
|
---|
239 | $this->System->FormManager->RegisterClass('UserCustomerRel', array(
|
---|
240 | 'Title' => 'Vztahy uživatel - zákazník',
|
---|
241 | 'Table' => 'UserCustomerRel',
|
---|
242 | 'Items' => array(
|
---|
243 | 'User' => array('Type' => 'TUser', 'Caption' => 'Uživatel', 'Default' => ''),
|
---|
244 | 'Customer' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => ''),
|
---|
245 | ),
|
---|
246 | ));
|
---|
247 | $this->System->FormManager->RegisterFormType('TCustomerListContract', array(
|
---|
248 | 'Type' => 'ManyToOne',
|
---|
249 | 'Table' => 'Member',
|
---|
250 | 'Id' => 'Id',
|
---|
251 | 'Ref' => 'Contract',
|
---|
252 | 'Filter' => '1',
|
---|
253 | ));
|
---|
254 |
|
---|
255 | $this->System->RegisterPage(['user', 'dokumenty'], 'PageCustomerDocuments');
|
---|
256 |
|
---|
257 | ModuleIS::Cast(Core::Cast($this->System)->GetModule('IS'))->RegisterDashboardItem('Customer',
|
---|
258 | array($this, 'ShowDashboardItem'));
|
---|
259 | }
|
---|
260 |
|
---|
261 | function ShowDashboardItem(): string
|
---|
262 | {
|
---|
263 | $DbResult = $this->Database->select('Member', 'COUNT(*)', '1');
|
---|
264 | $DbRow = $DbResult->fetch_row();
|
---|
265 | $Output = 'Zákazníků: registrovaných: <a href="'.$this->System->Link('/is/?a=list&t=Member').'">'.$DbRow['0'].'</a>';
|
---|
266 |
|
---|
267 | $DbResult = $this->Database->select('Member', 'COUNT(*)', '(`Blocked`=0) AND (`BillingPeriod`<>1)');
|
---|
268 | $DbRow = $DbResult->fetch_row();
|
---|
269 | $Output .= ' aktivních: <a href="'.$this->System->Link('/is/?a=list&t=Member&filter=1&FilterBlocked=0&FilterBillingPeriod=Nikdy&FilterOpBillingPeriod=notequal').'">'.$DbRow['0'].'</a>';
|
---|
270 |
|
---|
271 | $DbResult = $this->Database->select('Member', 'COUNT(*)', '(`Blocked`=0) AND (`BillingPeriod`<>1) AND '.
|
---|
272 | '((SELECT SUM(Service.Price) FROM ServiceCustomerRel LEFT JOIN Service ON Service.Id=ServiceCustomerRel.Service WHERE ServiceCustomerRel.Customer=Member.Id) <> 0)');
|
---|
273 | $DbRow = $DbResult->fetch_row();
|
---|
274 | $Output .= ' platících: <a href="'.$this->System->Link('/is/?a=list&t=Member&filter=1&FilterBlocked=0&FilterBillingPeriod=Nikdy&FilterOpBillingPeriod=notequal').'">'.$DbRow['0'].'</a><br/>';
|
---|
275 |
|
---|
276 | return $Output;
|
---|
277 | }
|
---|
278 | }
|
---|
279 |
|
---|
280 | class PageCustomerDocuments extends Page
|
---|
281 | {
|
---|
282 | function __construct(System $System)
|
---|
283 | {
|
---|
284 | parent::__construct($System);
|
---|
285 | $this->Title = 'Dokumenty';
|
---|
286 | $this->Description = 'Dokumenty klienta';
|
---|
287 | $this->ParentClass = 'PageUser';
|
---|
288 | }
|
---|
289 |
|
---|
290 | function Show(): string
|
---|
291 | {
|
---|
292 | $Output = '<br/><div><strong>Dostupné dokumenty:</strong></div><br/>';
|
---|
293 |
|
---|
294 | $User = &ModuleUser::Cast($this->System->GetModule('User'))->User;
|
---|
295 |
|
---|
296 | // Determine which customer should be displayed
|
---|
297 | if (array_key_exists('i', $_GET))
|
---|
298 | {
|
---|
299 | if (!$User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';
|
---|
300 | $CustomerId = $_GET['i'];
|
---|
301 | } else
|
---|
302 | {
|
---|
303 | if (!$User->CheckPermission('Customer', 'DisplayCustomerDocuments')) return 'Nemáte oprávnění';
|
---|
304 | $UserId = ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'];
|
---|
305 | $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` WHERE `User`='.$UserId.' LIMIT 1');
|
---|
306 | if ($DbResult->num_rows > 0)
|
---|
307 | {
|
---|
308 | $CustomerUserRel = $DbResult->fetch_assoc();
|
---|
309 | $CustomerId = $CustomerUserRel['Customer'];
|
---|
310 | } else return $this->SystemMessage('Chyba', 'Nejste zákazníkem');
|
---|
311 | }
|
---|
312 |
|
---|
313 | // Load customer info
|
---|
314 | $DbResult = $this->Database->query('SELECT * FROM `Member` WHERE `Id`='.$CustomerId);
|
---|
315 | if ($DbResult->num_rows == 1)
|
---|
316 | {
|
---|
317 | $Customer = $DbResult->fetch_assoc();
|
---|
318 | } else return $this->SystemMessage('Položka nenalezena', 'Zákazník nenalezen');
|
---|
319 |
|
---|
320 | if ($Customer['Contract'] != '')
|
---|
321 | {
|
---|
322 | $DbResult = $this->Database->query('SELECT Contract.*, File.Hash AS FileHash, DocumentLineCode.Name AS BillCodeText FROM Contract '.
|
---|
323 | 'LEFT JOIN File ON File.Id=Contract.File '.
|
---|
324 | 'LEFT JOIN DocumentLineCode ON DocumentLineCode.Id=Contract.BillCode '.
|
---|
325 | 'WHERE (Contract.Id='.$Customer['Contract'].')');
|
---|
326 | if ($DbResult->num_rows > 0)
|
---|
327 | {
|
---|
328 | $Contract = $DbResult->fetch_assoc();
|
---|
329 | if ($Contract['File'] > 0) $Output .= 'Smlouva: <a href="'.$this->System->Link('/file?h='.$Contract['FileHash']).'">'.$Contract['BillCodeText'].'</a><br/>';
|
---|
330 | else $Output .= 'Smlouva: '.$Contract['BillCodeText'].'<br/>';
|
---|
331 | $Output .= 'Všeobecné smluvní podmínky: <a href="https://www.zdechov.net/docs/V%C5%A1eobecn%C3%A9%20smluvn%C3%AD%20podm%C3%ADnky.pdf">PDF</a><br/>';
|
---|
332 | }
|
---|
333 | }
|
---|
334 | return $Output;
|
---|
335 | }
|
---|
336 | }
|
---|
337 |
|
---|
338 | class Member extends Model
|
---|
339 | {
|
---|
340 | static function GetModelDesc(): ModelDesc
|
---|
341 | {
|
---|
342 | $Desc = new ModelDesc(self::GetClassName());
|
---|
343 | $Desc->AddString('Name');
|
---|
344 | $Desc->AddReference('Subject', Subject::GetClassName());
|
---|
345 | $Desc->AddReference('ResponsibleUser', User::GetClassName());
|
---|
346 | $Desc->AddInteger('FamilyMemberCount');
|
---|
347 | $Desc->AddDate('MembershipDate');
|
---|
348 | $Desc->AddInteger('MemberState');
|
---|
349 | $Desc->AddInteger('GPS');
|
---|
350 | $Desc->AddReference('BillingPeriod', FinanceBillingPeriod::GetClassName());
|
---|
351 | $Desc->AddDate('BillingPeriodLastDate');
|
---|
352 | $Desc->AddBoolean('Blocked');
|
---|
353 | $Desc->AddInteger('PayDay');
|
---|
354 | $Desc->AddDateTime('PaymentEmailTime');
|
---|
355 | $Desc->AddChangeAction();
|
---|
356 | return $Desc;
|
---|
357 | }
|
---|
358 | }
|
---|
359 |
|
---|
360 | class MemberPayment extends Model
|
---|
361 | {
|
---|
362 | static function GetModelDesc(): ModelDesc
|
---|
363 | {
|
---|
364 | $Desc = new ModelDesc(self::GetClassName());
|
---|
365 | $Desc->AddReference('Member', Member::GetClassName());
|
---|
366 | $Desc->AddFloat('MonthlyTotal');
|
---|
367 | $Desc->AddFloat('MonthlyInternet');
|
---|
368 | $Desc->AddFloat('MonthlyConsumption');
|
---|
369 | $Desc->AddFloat('MonthlyPlus');
|
---|
370 | $Desc->AddFloat('Cash');
|
---|
371 | return $Desc;
|
---|
372 | }
|
---|
373 | }
|
---|
374 |
|
---|
375 | class Service extends Model
|
---|
376 | {
|
---|
377 | static function GetModelDesc(): ModelDesc
|
---|
378 | {
|
---|
379 | $Desc = new ModelDesc(self::GetClassName());
|
---|
380 | $Desc->AddString('Name');
|
---|
381 | $Desc->AddReference('Category', ServiceCategory::GetClassName());
|
---|
382 | $Desc->AddInteger('Price');
|
---|
383 | $Desc->AddInteger('VAT');
|
---|
384 | $Desc->AddChangeAction();
|
---|
385 | $Desc->AddBoolean('Public');
|
---|
386 | $Desc->AddInteger('InternetSpeedMax');
|
---|
387 | $Desc->AddInteger('InternetSpeedMin');
|
---|
388 | $Desc->AddInteger('InternetSpeedBonus');
|
---|
389 | $Desc->AddInteger('InternetUploadAsymmetry');
|
---|
390 | $Desc->AddInteger('Memory');
|
---|
391 | $Desc->AddInteger('MemorySwap');
|
---|
392 | $Desc->AddInteger('Storage');
|
---|
393 | $Desc->AddInteger('CPUCount');
|
---|
394 | return $Desc;
|
---|
395 | }
|
---|
396 | }
|
---|
397 |
|
---|
398 | class ServiceCategory extends Model
|
---|
399 | {
|
---|
400 | static function GetModelDesc(): ModelDesc
|
---|
401 | {
|
---|
402 | $Desc = new ModelDesc(self::GetClassName());
|
---|
403 | $Desc->AddString('Name');
|
---|
404 | return $Desc;
|
---|
405 | }
|
---|
406 | }
|
---|
407 |
|
---|
408 | class SupportActivity extends Model
|
---|
409 | {
|
---|
410 | static function GetModelDesc(): ModelDesc
|
---|
411 | {
|
---|
412 | $Desc = new ModelDesc(self::GetClassName());
|
---|
413 | $Desc->AddDateTime('Time');
|
---|
414 | $Desc->AddString('Description');
|
---|
415 | $Desc->AddReference('Customer', Member::GetClassName());
|
---|
416 | $Desc->AddReference('User', User::GetClassName());
|
---|
417 | return $Desc;
|
---|
418 | }
|
---|
419 | }
|
---|
420 |
|
---|
421 | class ServiceCustomerRel extends Model
|
---|
422 | {
|
---|
423 | static function GetModelDesc(): ModelDesc
|
---|
424 | {
|
---|
425 | $Desc = new ModelDesc(self::GetClassName());
|
---|
426 | $Desc->AddReference('Service', Service::GetClassName());
|
---|
427 | $Desc->AddReference('Customer', Member::GetClassName());
|
---|
428 | $Desc->AddChangeAction();
|
---|
429 | $Desc->AddInteger('SpeedLimit');
|
---|
430 | return $Desc;
|
---|
431 | }
|
---|
432 | }
|
---|
433 |
|
---|
434 | class UserCustomerRel extends Model
|
---|
435 | {
|
---|
436 | static function GetModelDesc(): ModelDesc
|
---|
437 | {
|
---|
438 | $Desc = new ModelDesc(self::GetClassName());
|
---|
439 | $Desc->AddReference('User', User::GetClassName());
|
---|
440 | $Desc->AddReference('Customer', Member::GetClassName());
|
---|
441 | return $Desc;
|
---|
442 | }
|
---|
443 | }
|
---|
444 |
|
---|
445 | class AddressPlace extends Model
|
---|
446 | {
|
---|
447 | static function GetModelDesc(): ModelDesc
|
---|
448 | {
|
---|
449 | $Desc = new ModelDesc(self::GetClassName());
|
---|
450 | $Desc->AddString('Town');
|
---|
451 | $Desc->AddString('Street');
|
---|
452 | $Desc->AddString('HouseNumber');
|
---|
453 | $Desc->AddEnum('HouseNumberType', array('Popisné', 'Evidenční'));
|
---|
454 | $Desc->AddString('Psc');
|
---|
455 | $Desc->AddInteger('RuianCode');
|
---|
456 | return $Desc;
|
---|
457 | }
|
---|
458 | }
|
---|