source: trunk/Modules/Customer/Customer.php@ 869

Last change on this file since 869 was 869, checked in by chronos, 5 years ago
  • Added: New SpeedLimit table to support network speed limit groups.
File size: 10.5 KB
Line 
1<?php
2
3class ModuleCustomer extends AppModule
4{
5 function __construct($System)
6 {
7 parent::__construct($System);
8 $this->Name = 'Customer';
9 $this->Version = '1.0';
10 $this->Creator = 'Chronos';
11 $this->License = 'GNU/GPL';
12 $this->Description = 'Customer management';
13 $this->Dependencies = array('User');
14 }
15
16 function DoStart()
17 {
18 $this->System->FormManager->RegisterClass('Member', array(
19 'Title' => 'Zákazníci',
20 'Table' => 'Member',
21 'DefaultSortColumn' => 'Name',
22 'Items' => array(
23 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
24 'ResponsibleUser' => array('Type' => 'TUser', 'Caption' => 'Zodpovědný uživatel', 'Default' => ''),
25 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => ''),
26 'FamilyMemberCount' => array('Type' => 'String', 'Caption' => 'Bydlících osob', 'Default' => '0', 'Suffix' => 'osob'),
27 'MembershipDate' => array('Type' => 'Date', 'Caption' => 'Datum členství', 'Default' => ''),
28 'BillingPeriod' => array('Type' => 'TFinanceBillingPeriod', 'Caption' => 'Fakturační období aktuální', 'Default' => ''),
29 'BillingPeriodLastDate' => array('Type' => 'Date', 'Caption' => 'Datum poslední fakturace', 'Default' => ''),
30 'Blocked' => array('Type' => 'Boolean', 'Caption' => 'Blokování', 'Default' => '0'),
31 'PayDay' => array('Type' => 'Integer', 'Caption' => 'Den placení', 'Default' => '1', 'Suffix' => 'den'),
32 'Devices' => array('Type' => 'TDeviceList', 'Caption' => 'Registrovaná zařízení', 'Default' => ''),
33 'UserRel' => array('Type' => 'TUserCustomerRelListCustomer', 'Caption' => 'Přiřazení uživatelé', 'Default' => ''),
34 'ServiceRel' => array('Type' => 'TServiceCustomerRelListCustomer', 'Caption' => 'Placené služby', 'Default' => ''),
35 'SupportActivity' => array('Type' => 'TSupportActivityListCustomer', 'Caption' => 'Zákaznická podpora', 'Default' => ''),
36 'Consumption' => array('Type' => 'TCustomerStockSerialNumber', 'Caption' => 'Spotřeba zařízení', 'Default' => ''),
37 'ChangeAction' => array('Type' => 'TActionEnum', 'Caption' => 'Změna - akce', 'Default' => '', 'Null' => true),
38 'ChangeTime' => array('Type' => 'DateTime', 'Caption' => 'Změna - čas', 'Default' => '', 'Null' => true, 'NotInList' => true),
39 'ChangeReplaceId' => array('Type' => 'TMember', 'Caption' => 'Změna - položka', 'Default' => '0', 'Null' => true, 'NotInList' => true),
40 ),
41 'ItemActions' => array(
42 array('Caption' => 'Klientská sekce', 'URL' => '/finance/platby/?i=#RowId'),
43 ),
44 ));
45 $this->System->FormManager->RegisterClass('MemberPayment', array(
46 'Title' => 'Placení zákazníků',
47 'Table' => 'MemberPayment',
48 'Items' => array(
49 'Member' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => '', 'ReadOnly' => true),
50 'MonthlyTotal' => array('Type' => 'Integer', 'Caption' => 'Celkem měsíčně', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true),
51 'MonthlyInternet' => array('Type' => 'Integer', 'Caption' => 'Internet měsíčně', 'Default' => '', 'Suffix' => 'Kč', 'ReadOnly' => true),
52 'MonthlyConsumption' => array('Type' => 'Integer', 'Caption' => 'Spotřeba měsíčně', 'Default' => '', 'Suffix' => 'Kč', 'ReadOnly' => true),
53 'MonthlyPlus' => array('Type' => 'Integer', 'Caption' => 'Měsíčně plus', 'Default' => '', 'Suffix' => 'Kč', 'ReadOnly' => true),
54 'Cash' => array('Type' => 'Integer', 'Caption' => 'Kredit', 'Default' => '', 'Suffix' => 'Kč', 'ReadOnly' => true),
55 ),
56 'Actions' => array(
57 array('Caption' => 'Přepočítat', 'URL' => '/finance/sprava/?Operation=Recalculate'),
58 ),
59 ));
60 $this->System->FormManager->RegisterFormType('TMember', array(
61 'Type' => 'Reference',
62 'Table' => 'Member',
63 'Id' => 'Id',
64 'Name' => 'Name',
65 'Filter' => '1',
66 ));
67 $this->System->FormManager->RegisterClass('Service', array(
68 'Title' => 'Služby',
69 'Table' => 'Service',
70 'DefaultSortColumn' => 'Name',
71 'Items' => array(
72 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
73 'Category' => array('Type' => 'TServiceCategory', 'Caption' => 'Skupina', 'Default' => '', 'Null' => true),
74 'Price' => array('Type' => 'Integer', 'Caption' => 'Cena', 'Default' => '0', 'Suffix' => 'Kč'),
75 'VAT' => array('Type' => 'TFinanceVATType', 'Caption' => 'Sazba DPH', 'Default' => '0', 'Suffix' => ''),
76 'CustomerCount' => array('Type' => 'Integer', 'Caption' => 'Počet zákazníků', 'Default' => '', 'ReadOnly' => true,
77 'SQL' => '(SELECT COUNT(*) FROM `ServiceCustomerRel` LEFT JOIN `Member` ON `Member`.`Id`=`ServiceCustomerRel`.`Customer` WHERE (`ServiceCustomerRel`.`Service`=#Id) AND (`Member`.`Blocked`=0))'),
78 'Public' => array('Type' => 'Boolean', 'Caption' => 'Veřejné', 'Default' => ''),
79 'InternetSpeedMin' => array('Type' => 'Integer', 'Caption' => 'Min. rychlost internetu', 'Default' => '0', 'Suffix' => 'bit/s'),
80 'InternetSpeedMax' => array('Type' => 'Integer', 'Caption' => 'Max. rychlost internetu', 'Default' => '0', 'Suffix' => 'bit/s'),
81 'UploadAsymmetry' => array('Type' => 'Integer', 'Caption' => 'Asymetrie odesílání', 'Default' => '1'),
82 'Memory' => array('Type' => 'Integer', 'Caption' => 'Paměť', 'Default' => '0', 'Suffix' => 'GB'),
83 'MemorySwap' => array('Type' => 'Integer', 'Caption' => 'Odkládací oddíl', 'Default' => '0', 'Suffix' => 'GB'),
84 'Storage' => array('Type' => 'Integer', 'Caption' => 'Úložiště', 'Default' => '0', 'Suffix' => 'GB'),
85 'CPUCount' => array('Type' => 'Integer', 'Caption' => 'Počet jader', 'Default' => '0', 'Suffix' => ''),
86 'ChangeAction' => array('Type' => 'TActionEnum', 'Caption' => 'Změna - akce', 'Default' => '', 'Null' => true),
87 'ChangeTime' => array('Type' => 'DateTime', 'Caption' => 'Změna - čas', 'Default' => '', 'Null' => true),
88 'ChangeReplaceId' => array('Type' => 'TService', 'Caption' => 'Změna - položka', 'Default' => '', 'Null' => true),
89 'CustomerRel' => array('Type' => 'TServiceCustomerRelListService', 'Caption' => 'Placení zákazníky', 'Default' => ''),
90 ),
91 ));
92 $this->System->FormManager->RegisterClass('ServiceCategory', array(
93 'Title' => 'Kategorie služeb',
94 'Table' => 'ServiceCategory',
95 'Items' => array(
96 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
97 'Items' => array('Type' => 'TServiceListServiceCategory', 'Caption' => 'Služby', 'Default' => ''),
98 ),
99 ));
100 $this->System->FormManager->RegisterClass('ServiceCustomerRel', array(
101 'Title' => 'Služby zákazníka',
102 'Table' => 'ServiceCustomerRel',
103 'Items' => array(
104 'Service' => array('Type' => 'TService', 'Caption' => 'Služba', 'Default' => ''),
105 'Customer' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => ''),
106 'SpeedLimit' => array('Type' => 'TNetworkSpeedLimit', 'Caption' => 'Omezení rychlosti', 'Default' => null, 'Null' => true),
107 'Devices' => array('Type' => 'TNetworkDeviceListService', 'Caption' => 'Zařízení', 'Default' => ''),
108 'ChangeAction' => array('Type' => 'TActionEnum', 'Caption' => 'Změna - akce', 'Default' => '', 'Null' => true),
109 'ChangeTime' => array('Type' => 'DateTime', 'Caption' => 'Změna - čas', 'Default' => '', 'Null' => true, 'NotInList' => true),
110 'ChangeReplaceId' => array('Type' => 'TServiceCustomerRel', 'Caption' => 'Změna - položka', 'Default' => '', 'Null' => true, 'NotInList' => true),
111 ),
112 ));
113 $this->System->FormManager->RegisterFormType('TServiceCategory', array(
114 'Type' => 'Reference',
115 'Table' => 'ServiceCategory',
116 'Id' => 'Id',
117 'Name' => 'Name',
118 'Filter' => '1',
119 ));
120 $this->System->FormManager->RegisterFormType('TService', array(
121 'Type' => 'Reference',
122 'Table' => 'Service',
123 'Id' => 'Id',
124 'Name' => 'Name',
125 'Filter' => '1',
126 ));
127 $this->System->FormManager->RegisterFormType('TServiceCustomerRel', array(
128 'Type' => 'Reference',
129 'Table' => 'ServiceCustomerRel',
130 'Id' => 'Id',
131 'Name' => 'Id',
132 'Filter' => '1',
133 ));
134 $this->System->FormManager->RegisterFormType('TServiceCustomerRelListCustomer', array(
135 'Type' => 'ManyToOne',
136 'Table' => 'ServiceCustomerRel',
137 'Id' => 'Id',
138 'Ref' => 'Customer',
139 'Filter' => '1',
140 ));
141 $this->System->FormManager->RegisterFormType('TNetworkDeviceListService', array(
142 'Type' => 'ManyToOne',
143 'Table' => 'NetworkDevice',
144 'Id' => 'Id',
145 'Ref' => 'Service',
146 'Filter' => '1',
147 ));
148 $this->System->FormManager->RegisterFormType('TServiceCustomerRelListService', array(
149 'Type' => 'ManyToOne',
150 'Table' => 'ServiceCustomerRel',
151 'Id' => 'Id',
152 'Ref' => 'Service',
153 'Filter' => '1',
154 ));
155 $this->System->FormManager->RegisterFormType('TServiceListServiceCategory', array(
156 'Type' => 'ManyToOne',
157 'Table' => 'Service',
158 'Id' => 'Id',
159 'Ref' => 'Category',
160 'Filter' => '1',
161 ));
162 $this->System->FormManager->RegisterClass('SupportActivity', array(
163 'Title' => 'Zákaznická podpora',
164 'Table' => 'SupportActivity',
165 'DefaultSortColumn' => 'Time',
166 'Items' => array(
167 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''),
168 'Description' => array('Type' => 'Text', 'Caption' => 'Popis', 'Default' => ''),
169 'Customer' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => ''),
170 'User' => array('Type' => 'TUser', 'Caption' => 'Pracovník', 'Default' => ''),
171 ),
172 ));
173 $this->System->FormManager->RegisterFormType('TSupportActivityListCustomer', array(
174 'Type' => 'ManyToOne',
175 'Table' => 'SupportActivity',
176 'Id' => 'Id',
177 'Ref' => 'Customer',
178 'Filter' => '1',
179 ));
180
181 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Customer',
182 array('ModuleCustomer', 'ShowDashboardItem'));
183 }
184
185 function ShowDashboardItem()
186 {
187 $DbResult = $this->Database->select('Member', 'COUNT(*)', '1');
188 $DbRow = $DbResult->fetch_row();
189 $Output = 'Zákazníků: registrovaných:'.$DbRow['0'];
190
191 $DbResult = $this->Database->select('Member', 'COUNT(*)', '`Blocked`=0 AND `BillingPeriod`<>1');
192 $DbRow = $DbResult->fetch_row();
193 $Output .= ' platících:'.$DbRow['0'].'<br/>';
194
195 return($Output);
196 }
197
198}
Note: See TracBrowser for help on using the repository browser.