<?php

class PageHosting extends Page
{
  function __construct(System $System)
  {
    parent::__construct($System);
    $this->Title = 'Hostované projekty';
    $this->ParentClass = 'PageNetwork';
  }

  function Show(): string
  {
    $Output = '<br /><table class="WideTable"><tr><th>Název projektu</th><th>Založeno</th><th>Umístění na serveru</th><th>Zodpovědná osoba</th></tr>';
    $DbResult = $this->Database->query('SELECT NetworkDevice.Name as ServerName, HostedProject.Name, HostedProject.Homepage, HostedProject.TimeCreate, User.Name AS UserName FROM HostedProject JOIN User ON User.Id = HostedProject.User JOIN NetworkDevice ON NetworkDevice.Id = HostedProject.Server ORDER BY HostedProject.Name');
    while ($DbRow = $DbResult->fetch_assoc())
    {
      $Output .= '<tr><td><a href="'.$DbRow['Homepage'].'">'.$DbRow['Name'].'</a></td><td>'.HumanDate($DbRow['TimeCreate']).'</td><td>'.$DbRow['ServerName'].'</td><td>'.$DbRow['UserName'].'</td></tr>';
    }
    $Output .= '</table>';
    return $Output;
  }
}
