1 | <?php
|
---|
2 |
|
---|
3 | include_once(dirname(__FILE__).'/../../Common/Global.php');
|
---|
4 |
|
---|
5 | class ModulePortal extends AppModule
|
---|
6 | {
|
---|
7 | function __construct($System)
|
---|
8 | {
|
---|
9 | parent::__construct($System);
|
---|
10 | $this->Name = 'Portal';
|
---|
11 | $this->Version = '1.0';
|
---|
12 | $this->Creator = 'Chronos';
|
---|
13 | $this->License = 'GNU/GPLv3';
|
---|
14 | $this->Description = 'Community portal.';
|
---|
15 | $this->Dependencies = array('News');
|
---|
16 | }
|
---|
17 |
|
---|
18 | function DoInstall()
|
---|
19 | {
|
---|
20 | }
|
---|
21 |
|
---|
22 | function DoUninstall()
|
---|
23 | {
|
---|
24 | }
|
---|
25 |
|
---|
26 | function DoStart()
|
---|
27 | {
|
---|
28 | $this->System->RegisterPage('', 'PagePortal');
|
---|
29 | $this->System->FormManager->RegisterClass('MemberOptions', array(
|
---|
30 | 'Title' => 'Nastavení zákazníka',
|
---|
31 | 'SQL' => '(SELECT Member.Id, Member.FamilyMemberCount, Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, Subject.IC, Subject.DIC FROM Member JOIN Subject ON Subject.Id = Member.Subject)',
|
---|
32 | 'Table' => 'MemberOptions',
|
---|
33 | 'Items' => array(
|
---|
34 | 'Name' => array('Type' => 'String', 'Caption' => 'Fakturační jméno', 'Default' => ''),
|
---|
35 | 'AddressStreet' => array('Type' => 'String', 'Caption' => 'Ulice', 'Default' => 'Zděchov'),
|
---|
36 | 'AddressTown' => array('Type' => 'String', 'Caption' => 'Město', 'Default' => 'Zděchov'),
|
---|
37 | 'AddressPSC' => array('Type' => 'String', 'Caption' => 'PSČ', 'Default' => '75607'),
|
---|
38 | 'AddressCountry' => array('Type' => 'TCountry', 'Caption' => 'Země', 'Default' => '1'),
|
---|
39 | 'IC' => array('Type' => 'String', 'Caption' => 'IČ', 'Default' => ''),
|
---|
40 | 'DIC' => array('Type' => 'String', 'Caption' => 'DIČ', 'Default' => ''),
|
---|
41 | 'FamilyMemberCount' => array('Type' => 'Integer', 'Caption' => 'Počet bydlících osob', 'Default' => '', 'Suffix' => 'osob'),
|
---|
42 | ),
|
---|
43 | ));
|
---|
44 | $this->System->ModuleManager->Modules['User']->UserPanel[] = array('PagePortal', 'UserPanel');
|
---|
45 | }
|
---|
46 |
|
---|
47 | function DoStop()
|
---|
48 | {
|
---|
49 | }
|
---|
50 | }
|
---|
51 |
|
---|
52 | class PagePortal extends Page
|
---|
53 | {
|
---|
54 | var $FullTitle = 'Zděchovský rozcestník';
|
---|
55 | var $ShortTitle = 'Rozcestník';
|
---|
56 |
|
---|
57 | function ShowActions($ActionGroup)
|
---|
58 | {
|
---|
59 | $Output = '';
|
---|
60 | $DbResult = $this->Database->query('SELECT `Id` FROM `Action` '.
|
---|
61 | 'WHERE (`Action`.`Group`='.$ActionGroup['Id'].') AND (`Action`.`Enable` = 1)');
|
---|
62 | while($Action = $DbResult->fetch_assoc())
|
---|
63 | {
|
---|
64 | $Output .= $this->System->ShowAction($Action['Id']).'<br/>';
|
---|
65 | }
|
---|
66 | return($this->Panel($ActionGroup['Name'], $Output));
|
---|
67 | }
|
---|
68 |
|
---|
69 | function InfoBar()
|
---|
70 | {
|
---|
71 | $Output2 = '';
|
---|
72 |
|
---|
73 | $DbResult = $this->Database->query('SELECT COUNT(*) FROM NetworkDevice LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDeviceType.ShowOnline = 1');
|
---|
74 | $DbRow = $DbResult->fetch_array();
|
---|
75 | $TotalComputers = $DbRow[0];
|
---|
76 |
|
---|
77 | $DbResult = $this->Database->query('SELECT COUNT(*) FROM NetworkDevice LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE (NetworkDeviceType.ShowOnline = 1) AND (NetworkDevice.Online = 1)');
|
---|
78 | $DbRow = $DbResult->fetch_array();
|
---|
79 | $OnlineComputers = $DbRow[0];
|
---|
80 |
|
---|
81 | $Output = '<img alt="" src="images/favicons/comp.png" width="16" height="16" /> '.$OnlineComputers.' / '.$TotalComputers.' ';
|
---|
82 |
|
---|
83 | $DbResult = $this->Database->select('Member', 'COUNT(*)', '1');
|
---|
84 | $DbRow = $DbResult->fetch_array();
|
---|
85 | $TotalUser = $DbRow[0];
|
---|
86 |
|
---|
87 | $DbResult = $this->Database->query('SELECT COUNT(DISTINCT(Member)) FROM NetworkDevice '.
|
---|
88 | 'LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type '.
|
---|
89 | 'WHERE NetworkDeviceType.ShowOnline = 1 AND NetworkDevice.Online = 1');
|
---|
90 | $DbRow = $DbResult->fetch_array();
|
---|
91 | $OnlineUser = $DbRow[0];
|
---|
92 |
|
---|
93 | $Output .= '<img alt="" src="images/favicons/house.png" width="16" height="16" /> '.$OnlineUser.' / '.$TotalUser.' ';
|
---|
94 |
|
---|
95 | $NetworkUsage = 0;
|
---|
96 | $Output .= '<img alt="" src="images/favicons/usage.png" width="16" height="16" /> '.$NetworkUsage.' % ';
|
---|
97 |
|
---|
98 | //$Output .= 'Server běží: '.$this->GetServerUptime().' ';
|
---|
99 |
|
---|
100 | if($this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))
|
---|
101 | {
|
---|
102 | $DbResult = $this->Database->select('MemberPayment', 'Cash', 'Member=(SELECT Customer FROM UserCustomerRel WHERE Id='.$this->System->User->User['Id'].')');
|
---|
103 | if($DbResult->num_rows > 0)
|
---|
104 | {
|
---|
105 | $DbRow = $DbResult->fetch_assoc();
|
---|
106 | $Output2 .= ' <img alt="" src="images/favicons/money.png" width="16" height="16" /> '.$DbRow['Cash'].' Kč';
|
---|
107 | }
|
---|
108 | }
|
---|
109 |
|
---|
110 | $Output = '<div class="Navigation"><span class="MenuItem">'.$Output.'</span><div class="MenuItem2"> '.$Output2.'</div></div>';
|
---|
111 | return($Output);
|
---|
112 | }
|
---|
113 |
|
---|
114 | function UserPanel()
|
---|
115 | {
|
---|
116 | $Output = '<a href="'.$this->System->Link('/user/?Action=UserOptions').'">Profil</a><br />';
|
---|
117 | if($this->System->User->CheckPermission('Finance', 'MemberOptions'))
|
---|
118 | $Output .= '<a href="'.$this->System->Link('/?Action=MemberOptions').'">Fakturační adresa</a><br />';
|
---|
119 | if($this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))
|
---|
120 | $Output .= '<a href="'.$this->System->Link('/finance/platby/').'">Finance</a><br />';
|
---|
121 | if($this->System->User->CheckPermission('Network', 'RegistredHostList'))
|
---|
122 | $Output .= '<a href="'.$this->System->Link('/network/user-hosts/').'">Počítače</a><br />';
|
---|
123 | if($this->System->User->CheckPermission('News', 'Insert'))
|
---|
124 | $Output .= '<a href="'.$this->System->Link('/aktuality/?action=add').'">Vložení aktuality</a><br />';
|
---|
125 | if($this->System->User->CheckPermission('EatingPlace', 'Edit'))
|
---|
126 | $Output .= '<a href="'.$this->System->Link('/jidelna/menuedit.php').'">Úprava jídelníčků</a><br />';
|
---|
127 | if($this->System->User->CheckPermission('Finance', 'Manage'))
|
---|
128 | $Output .= '<a href="'.$this->System->Link('/finance/sprava/').'">Správa financí</a><br />';
|
---|
129 | if($this->System->User->CheckPermission('IS', 'Manage'))
|
---|
130 | $Output .= '<a href="'.$this->System->Link('/is/').'">Správa dat</a><br />';
|
---|
131 | return($Output);
|
---|
132 | }
|
---|
133 |
|
---|
134 | function WebcamPanel()
|
---|
135 | {
|
---|
136 | $Output = $this->System->ModuleManager->Modules['WebCam']->ShowImage();
|
---|
137 | return($Output);
|
---|
138 | }
|
---|
139 |
|
---|
140 | function MeteoPanel()
|
---|
141 | {
|
---|
142 | $Output = '<a href="http://stat.zdechov.net/meteo/?Measure=28" title="Klikněte pro detailní informace a předpověď"><img src="http://www.zdechov.net/meteo/koliba.png" border="0" alt="Počasí - Meteostanice Zděchov" width="150" height="150" /></a>';
|
---|
143 | return($Output);
|
---|
144 | }
|
---|
145 |
|
---|
146 | function OnlineHostList()
|
---|
147 | {
|
---|
148 | $Output = '<span style="font-size: smaller;">';
|
---|
149 | $DbResult = $this->Database->query('SELECT `NetworkDevice`.`Name` FROM `NetworkDevice` '.
|
---|
150 | 'LEFT JOIN `NetworkDeviceType` ON `NetworkDeviceType`.`Id` = `NetworkDevice`.`Type` '.
|
---|
151 | 'WHERE (`NetworkDeviceType`.`ShowOnline` = 1) AND (`NetworkDevice`.`Online` = 1) ORDER BY `NetworkDevice`.`Name`');
|
---|
152 | while($Device = $DbResult->fetch_array())
|
---|
153 | {
|
---|
154 | $Output .= $Device['Name'].'<br />';
|
---|
155 | }
|
---|
156 | $Output .= '</span>';
|
---|
157 | return($Output);
|
---|
158 | }
|
---|
159 |
|
---|
160 | function ShowBadPayerList()
|
---|
161 | {
|
---|
162 | $Output .= '<div class="PanelTitle">Dlužníci:</div><span style="font-size: smaller;">';
|
---|
163 | $DbResult = $Database->select('Subject', 'Name', 'Money < 0 ORDER BY Money');
|
---|
164 | while($Row = $DbResult->fetch_array())
|
---|
165 | {
|
---|
166 | $Output .= $Row['Name'].'<br />';
|
---|
167 | }
|
---|
168 | $Output .= '</span>';
|
---|
169 | return($Output);
|
---|
170 | }
|
---|
171 |
|
---|
172 | function Panel($Title, $Content, $Menu = array())
|
---|
173 | {
|
---|
174 | if(count($Menu) > 0)
|
---|
175 | foreach($Menu as $Item)
|
---|
176 | $Title .= '<div class="Action">'.$Item.'</div>';
|
---|
177 | return('<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>');
|
---|
178 | }
|
---|
179 |
|
---|
180 | function Show()
|
---|
181 | {
|
---|
182 | $Output = '';
|
---|
183 | if(array_key_exists('Action', $_GET))
|
---|
184 | {
|
---|
185 | $Action = $_GET['Action'];
|
---|
186 | if($Action == 'CustomizeNewsSave')
|
---|
187 | {
|
---|
188 | $Output .= $this->System->ModuleManager->Modules['News']->CustomizeSave();
|
---|
189 | } else
|
---|
190 | if($Action == 'MemberOptions')
|
---|
191 | {
|
---|
192 | $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` '.
|
---|
193 | 'WHERE `User`='.$this->System->User->User['Id']);
|
---|
194 | while($CustomerUserRel = $DbResult->fetch_assoc())
|
---|
195 | {
|
---|
196 | $DbResult2 = $this->Database->query('SELECT `Member`.`Id`, '.
|
---|
197 | '`Member`.`FamilyMemberCount`, `Subject`.`Name`, `Subject`.`AddressStreet`, '.
|
---|
198 | '`Subject`.`AddressTown`, `Subject`.`AddressPSC`, `Subject`.`AddressCountry`, '.
|
---|
199 | '`Subject`.`IC`, `Subject`.`DIC` FROM `Member` JOIN `Subject` '.
|
---|
200 | 'ON `Subject`.`Id` = `Member`.`Subject` WHERE `Member`.`Id`='.$CustomerUserRel['Customer']);
|
---|
201 | $Form = new Form($this->System->FormManager);
|
---|
202 | $Form->SetClass('MemberOptions');
|
---|
203 | $DbRow = $DbResult2->fetch_array();
|
---|
204 | foreach($Form->Definition['Items'] as $Index => $Item)
|
---|
205 | {
|
---|
206 | $Form->Values[$Index] = $DbRow[$Index];
|
---|
207 | }
|
---|
208 | $Form->OnSubmit = '?Action=MemberOptionsSave&Id='.$CustomerUserRel['Customer'];
|
---|
209 | $Output .= $Form->ShowEditForm();
|
---|
210 | }
|
---|
211 | } else
|
---|
212 | if($Action == 'MemberOptionsSave')
|
---|
213 | {
|
---|
214 | $Form = new Form($this->System->FormManager);
|
---|
215 | $Form->SetClass('MemberOptions');
|
---|
216 | $Form->LoadValuesFromForm();
|
---|
217 | if($Form->Values['FamilyMemberCount'] < 0)
|
---|
218 | $Form->Values['FamilyMemberCount'] = 0;
|
---|
219 |
|
---|
220 | $DbResult = $this->Database->update('Member', 'Id='.$this->System->User->User['Member'],
|
---|
221 | array('FamilyMemberCount' => $Form->Values['FamilyMemberCount']));
|
---|
222 | $DbResult = $this->Database->query('SELECT Subject FROM Member WHERE Id='.$this->System->User->User['Member']);
|
---|
223 | $Member = $DbResult->fetch_assoc();
|
---|
224 | $DbResult = $this->Database->update('Subject', 'Id='.$Member['Subject'],
|
---|
225 | array('Name' => $Form->Values['Name'], 'AddressStreet' => $Form->Values['AddressStreet'],
|
---|
226 | 'AddressTown' => $Form->Values['AddressTown'], 'AddressCountry' => $Form->Values['AddressCountry'],
|
---|
227 | 'AddressPSC' => $Form->Values['AddressPSC'], 'IC' => $Form->Values['IC'],
|
---|
228 | 'DIC' => $Form->Values['DIC']));
|
---|
229 | $Output .= $this->SystemMessage('Nastavení', 'Nastavení zákazníka uloženo.');
|
---|
230 | $this->System->ModuleManager->Modules['Log']->NewRecord('Member+Subject', 'Nastavení zákazníka/subjektu změněno',
|
---|
231 | $Form->Values['Name']);
|
---|
232 | $DbResult = $this->Database->query('SELECT Member.Id, Member.FamilyMemberCount, '.
|
---|
233 | 'Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, '.
|
---|
234 | 'Subject.AddressCountry, Subject.IC, Subject.DIC FROM Member JOIN Subject '.
|
---|
235 | 'ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->User->User['Member']);
|
---|
236 | $DbRow = $DbResult->fetch_array();
|
---|
237 | foreach($Form->Definition['Items'] as $Index => $Item)
|
---|
238 | {
|
---|
239 | $Form->Values[$Index] = $DbRow[$Index];
|
---|
240 | }
|
---|
241 | $Form->OnSubmit = '?Action=MemberOptionsSave';
|
---|
242 | $Output .= $Form->ShowEditForm();
|
---|
243 | }
|
---|
244 | } else $Output = $this->ShowMain();
|
---|
245 | return($Output);
|
---|
246 | }
|
---|
247 |
|
---|
248 | function ShowMain()
|
---|
249 | {
|
---|
250 | $Output = '';
|
---|
251 | $DbResult = $this->Database->query('SELECT * FROM `ActionGroup`');
|
---|
252 | while($DbRow = $DbResult->fetch_assoc())
|
---|
253 | $ActionGroups[$DbRow['Id']] = $DbRow;
|
---|
254 |
|
---|
255 | // Show pannels
|
---|
256 | //if(IsInternetAddr()) echo('Internet'); else echo('LAN');
|
---|
257 | //$Output .= $this->InfoBar();
|
---|
258 | $Output .= '<table id="MainTable"><tr>';
|
---|
259 | $DbResult = $this->Database->select('PanelColumn', '*');
|
---|
260 | while($PanelColumn = $DbResult->fetch_assoc())
|
---|
261 | {
|
---|
262 | if($PanelColumn != '') $Width = ' width="'.$PanelColumn['Width'].'"';
|
---|
263 | else $Width = '';
|
---|
264 | $Output .= '<td valign="top"'.$Width.'>';
|
---|
265 | $DbResult2 = $this->Database->query('SELECT * FROM `Panel` WHERE `PanelColumn`='.$PanelColumn['Id'].' ORDER BY `Order`');
|
---|
266 | while($Panel = $DbResult2->fetch_assoc())
|
---|
267 | {
|
---|
268 | if($Panel['Module'] == 'ActionGroup') $Output .= $this->ShowActions($ActionGroups[$Panel['Parameters']]);
|
---|
269 | else if($Panel['Module'] == 'OnlineHostList') $Output .= $this->Panel('Online počítače', $this->OnlineHostList());
|
---|
270 | else if($Panel['Module'] == 'UserOptions')
|
---|
271 | {
|
---|
272 | //if($this->System->User->User['Id'] != null) $Output .= $this->Panel('Přihlášený uživatel', $this->UserPanel());
|
---|
273 | } else
|
---|
274 | if($Panel['Module'] == 'Webcam') $Output .= $this->Panel('Kamery', $this->WebcamPanel());
|
---|
275 | if($Panel['Module'] == 'Meteo') $Output .= $this->Panel('Meteostanice', $this->MeteoPanel());
|
---|
276 | else if($Panel['Module'] == 'NewsGroupList')
|
---|
277 | $Output .= $this->Panel('Aktuality', $this->System->ModuleManager->Modules['News']->Show(), array('<a href="?Action=CustomizeNews">Upravit</a>'));
|
---|
278 | }
|
---|
279 | $Output .= '</td>';
|
---|
280 | }
|
---|
281 | $Output .= '</tr></table>';
|
---|
282 | return($Output);
|
---|
283 | }
|
---|
284 | }
|
---|