trackdirect2023/htdocs/public/views/latest.php

104 lines
5.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php require dirname(__DIR__) . "../../includes/bootstrap.php"; ?>
<?php
$stations = [];
$seconds = 60*60*72;
$page = $_GET['page'] ?? 1;
$rows = 50;
$offset = ($page - 1) * $rows;
$stations = StationRepository::getInstance()->getObjectList($seconds, $rows, $offset);
$count = StationRepository::getInstance()->getNumberOfStations($seconds);
$pages = ceil($count / $rows);
?>
<title>Последние принятые пакеты</title>
<div class="modal-inner-content" style="padding-bottom: 30px;">
<?php if (count($stations) > 0) : ?>
<p>
<?php echo $count; ?> станций было принято за последние 24 часа.
</p>
<?php if ($pages > 1): ?>
<div class="pagination">
<a class="tdlink" href="/views/latest.php?q=<?php echo ($_GET['q'] ?? "") ?>&seconds=<?php echo $seconds ?>&page=1"><<</a>
<?php for($i = max(1, $page - 3); $i <= min($pages, $page + 3); $i++) : ?>
<a href="/views/latest.php?q=<?php echo ($_GET['q'] ?? "") ?>&seconds=<?php echo $seconds ?>&page=<?php echo $i; ?>" <?php echo ($i == $page ? 'class="tdlink active"': 'class="tdlink"')?>><?php echo $i ?></a>
<?php endfor; ?>
<a class="tdlink" href="/views/latest.php?q=<?php echo ($_GET['q'] ?? "") ?>&seconds=<?php echo $seconds ?>&page=<?php echo $pages; ?>">>></a>
</div>
<?php endif; ?>
<div class="datagrid datagrid-search" style="max-width:1000px;">
<table>
<thead>
<tr>
<th>&nbsp;</th>
<th>Позывной</th>
<th>Последний пакет</th>
<th>Комментарий/инфо</th>
<th>На карте</th>
</tr>
</thead>
<tbody>
<?php foreach ($stations as $foundStation) : ?>
<tr>
<td>
<img src="<?php echo $foundStation->getIconFilePath(22, 22); ?>" alt="Symbol"/>
</td>
<td>
<a class="tdlink" href="/views/overview.php?id=<?php echo $foundStation->id; ?>&imperialUnits=<?php echo $_GET['imperialUnits'] ?? 0; ?>"><?php echo htmlentities($foundStation->name) ?></a>
</td>
<td class="station-latest-heard-timestamp" style="white-space: nowrap;">
<?php echo $foundStation->latestConfirmedPacketTimestamp; ?>
</td>
<td>
<?php if ($foundStation->sourceId == 5 && $foundStation->getOgnDevice() !== null) : ?>
<div style="width: 100px; display: inline-block;">Регистрация:</div><?php echo htmlspecialchars($foundStation->getOgnDevice()->registration); ?> <?php echo $foundStation->getOgnDevice()->cn ? '[' .htmlspecialchars($foundStation->getOgnDevice()->cn) . ']' : ''; ?><br/>
<div style="width: 100px; display: inline-block;">Модель самолёта:</div><?php echo htmlspecialchars($foundStation->getOgnDevice()->aircraftModel); ?>
<?php else : ?>
<?php $latestPacket = PacketRepository::getInstance()->getObjectById($foundStation->latestPacketId, $foundStation->latestPacketTimestamp); ?>
<?php echo htmlspecialchars($latestPacket->comment); ?>
<?php endif; ?>
</td>
<td>
<?php if ($foundStation->latestConfirmedPacketTimestamp > (time() - 60*60*72)) : ?>
<a href="?sid=<?php echo $foundStation->id; ?>" onclick="
if (window.parent && window.parent.trackdirect) {
$('.modal', parent.document).hide();
window.parent.trackdirect.filterOnStationId([]);
window.parent.trackdirect.filterOnStationId([<?php echo $foundStation->id; ?>]);
return false;
}">Показать</a>
<?php else : ?>
&nbsp;
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
<?php if (count($stations) == 0) : ?>
<p>
<b><i>За последние 24 часа не было принято ни одной станции.</i></b>
</p>
<?php endif; ?>
</div>
<script>
$(document).ready(function() {
var locale = window.navigator.userLanguage || window.navigator.language;
moment.locale(locale);
$('.station-latest-heard-timestamp').each(function() {
if ($(this).html().trim() != '' && !isNaN($(this).html().trim())) {
$(this).html(moment(new Date(1000 * $(this).html())).format('L LTSZ'));
}
});
});
</script>