1 | <?php
|
---|
2 |
|
---|
3 | class PageUserList extends Page
|
---|
4 | {
|
---|
5 | function __construct(System $System)
|
---|
6 | {
|
---|
7 | parent::__construct($System);
|
---|
8 | $this->Title = 'Seznam uživatelů';
|
---|
9 | $this->Description = 'Seznam registrovaných uživatelů';
|
---|
10 | $this->ParentClass = 'PagePortal';
|
---|
11 | }
|
---|
12 |
|
---|
13 | function Show(): string
|
---|
14 | {
|
---|
15 | if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('User', 'ShowList'))
|
---|
16 | return 'Nemáte oprávnění';
|
---|
17 |
|
---|
18 | $DbResult = $this->Database->query('SELECT COUNT(*) FROM `User`');
|
---|
19 | $DbRow = $DbResult->fetch_row();
|
---|
20 | $PageList = GetPageList('Users', $DbRow[0]);
|
---|
21 |
|
---|
22 | $Output = $PageList['Output'];
|
---|
23 | $Output .= '<table class="WideTable" style="font-size: small;">';
|
---|
24 |
|
---|
25 | $TableColumns = array(
|
---|
26 | array('Name' => 'Name', 'Title' => 'Jméno'),
|
---|
27 | array('Name' => 'Email', 'Title' => 'E-mail'),
|
---|
28 | array('Name' => '', 'Title' => 'Počítače'),
|
---|
29 | );
|
---|
30 | $Order = GetOrderTableHeader('Users', $TableColumns, 'Name', 0);
|
---|
31 | $Output .= $Order['Output'];
|
---|
32 |
|
---|
33 | $Query = 'SELECT * FROM `User` '.$Order['SQL'].$PageList['SQLLimit'];
|
---|
34 |
|
---|
35 | $DbResult = $this->Database->query($Query);
|
---|
36 | while ($User = $DbResult->fetch_assoc())
|
---|
37 | {
|
---|
38 | $Devices = array();
|
---|
39 | $DbResult2 = $this->Database->query('SELECT `Id` FROM `Member` WHERE `Member`.`ResponsibleUser` = '.$User['Id']);
|
---|
40 | while ($Member = $DbResult2->fetch_assoc())
|
---|
41 | {
|
---|
42 | $DbResult3 = $this->Database->query('SELECT `Name`, `Id` FROM `NetworkDevice` '.
|
---|
43 | 'WHERE `Member` = '.$Member['Id'].' AND `Used`=1 ORDER BY `Name`');
|
---|
44 | while ($Device = $DbResult3->fetch_assoc())
|
---|
45 | {
|
---|
46 | $Devices[] = $Device['Name'];
|
---|
47 | }
|
---|
48 | }
|
---|
49 | $User['Devices'] = implode(', ', $Devices);
|
---|
50 |
|
---|
51 | $Output .= '<tr><td>'.$User['Name'].'</td>'.
|
---|
52 | '<td>'.$User['Email'].'</td>'.
|
---|
53 | '<td>'.$User['Devices'].'</td></tr>';
|
---|
54 | }
|
---|
55 | $Output .= '</table>';
|
---|
56 | $Output .= $PageList['Output'];
|
---|
57 |
|
---|
58 | return $Output;
|
---|
59 | }
|
---|
60 | }
|
---|