Title = 'Mapa sítě'; $this->ParentClass = 'PagePortal'; } //var $Load = 'initialize()'; //var $Unload = 'GUnload()'; function Show(): string { if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Map', 'Show')) return 'Nemáte oprávnění'; if (count($this->System->PathItems) > 1) { if ($this->System->PathItems[1] == 'show-position') return $this->ShowPosition(); else return PAGE_NOT_FOUND; } else return $this->ShowMain(); } function ShowPosition(): string { $DbResult = $this->Database->select('MapPosition', '*', '`Id`='.$_GET['i']); if ($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); $Pos = explode(';', $DbRow['Pos']); $MapApi = new MapOpenStreetMaps($this->System); $MapApi->Position = array('Lat' => $Pos[0], 'Lng' => $Pos[1]); $MapApi->Zoom = 18; $MapApi->Key = $this->System->Config['Map']['GoogleMapsApiKey']; $MapApi->ShowMarker = true; $Marker = new MapMarker(); $Marker->Text = $DbRow['Name']; $Marker->Position = $MapApi->Position; $MapApi->Markers[] = $Marker; $Output = $MapApi->ShowPage($this); return $Output; } else return 'Položka nenalezena'; } function ShowMain(): string { $Map = new MapOpenStreetMaps($this->System); $Map->Position = array('Lat' => $this->System->Config['Map']['DefaultLatitude'], 'Lng' => $this->System->Config['Map']['DefaultLongitude']); $Map->Zoom = $this->System->Config['Map']['DefaultZoom']; $Map->Key = $this->System->Config['Map']['GoogleMapsApiKey']; //$Map->OnClickObject = $_GET['r']; //$MapApi->ShowMarker = true; $DbResult = $this->Database->query('SELECT GROUP_CONCAT(`NetworkDevice`.`Name` SEPARATOR ",") AS `Name`, '. '`MapPosition`.`Pos` AS `Pos`, `MapPosition`.`Name` AS `NodeName` '. 'FROM `NetworkDevice` LEFT JOIN `MapPosition` ON `MapPosition`.`Id` = `NetworkDevice`.`MapPosition` '. 'WHERE (`NetworkDevice`.`Used`=1) AND (`NetworkDevice`.`MapPosition` IS NOT NULL) '. 'GROUP BY `NetworkDevice`.`MapPosition`'); while ($Device = $DbResult->fetch_assoc()) { $Pos = explode(';', $Device['Pos']); $Marker = new MapMarker(); $Marker->Position = array('Lat' => $Pos[0], 'Lng' => $Pos[1]); $Marker->Text = $Device['NodeName'].': '.$Device['Name']; $Map->Markers[] = $Marker; } $DbResult = $this->Database->query('SELECT * FROM `NetworkLink` WHERE (`Interface1` <> 0) AND (`Interface2` <> 0)'); while ($Link = $DbResult->fetch_assoc()) { $DbResult2 = $this->Database->query('SELECT `NetworkDevice`.`Used`, `MapPosition`.`Pos` FROM `NetworkDevice` '. 'JOIN `MapPosition` ON `MapPosition`.`Id` = `NetworkDevice`.`MapPosition` '. 'WHERE `NetworkDevice`.`Id` = (SELECT `NetworkInterface`.`Device` FROM `NetworkInterface` WHERE `NetworkInterface`.`Id` = '.$Link['Interface1'].')'); $DbResult3 = $this->Database->query('SELECT `NetworkDevice`.`Used`, `MapPosition`.`Pos` FROM `NetworkDevice` '. 'JOIN `MapPosition` ON `MapPosition`.`Id` = `NetworkDevice`.`MapPosition` '. 'WHERE `NetworkDevice`.`Id` = (SELECT `NetworkInterface`.`Device` FROM `NetworkInterface` WHERE `NetworkInterface`.`Id` = '.$Link['Interface2'].')'); if (($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0)) { $Device1 = $DbResult2->fetch_assoc(); $Pos1 = explode(';', $Device1['Pos']); $Device2 = $DbResult3->fetch_assoc(); $Pos2 = explode(';', $Device2['Pos']); if (($Device1['Used'] == 1) and ($Device2['Used'] == 1)) { $PolyLine = new MapPolyLine(); $PolyLine->Color = '#4F4FBF'; $PolyLine->Points[] = array('Lat' => $Pos1[0], 'Lng' => $Pos1[1]); $PolyLine->Points[] = array('Lat' => $Pos2[0], 'Lng' => $Pos2[1]); $Map->PolyLines[] = $PolyLine; } } } $Output = $Map->ShowPage($this); /* $Output = ''; $Output .= ''; $Output .= '