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