This repository has been archived on 2023-12-29. You can view files and clone it, but cannot push or open issues or pull requests.
dogstats/web/pages/smart/search.html.php

165 lines
6.9 KiB
PHP
Raw Normal View History

2023-11-26 14:00:23 +01:00
<h2>Hunde:</h2>
<ul>
<?php foreach ($dogs as $dog) : ?>
<li><a href="#<?= $dog ?>"><?= $dog ?></a></li>
2023-11-26 10:30:00 +01:00
<?php endforeach; ?>
2023-11-26 14:00:23 +01:00
</ul>
<?php foreach ($dogs as $dog) :
2023-11-29 13:55:28 +01:00
$dogid=preg_replace("/[^A-Za-z0-9]/", '', $dog);
2023-11-26 14:00:23 +01:00
$results = $results_dogs[$dog];
2023-11-26 14:35:28 +01:00
$sdata = [];
2023-11-26 14:00:23 +01:00
?>
2023-11-29 13:55:28 +01:00
<h1 id="<?= $dogid; ?>"><?= $dog; ?></h1>
2023-11-26 14:00:23 +01:00
2023-11-29 13:55:28 +01:00
<button onClick="getElementById('table_<?= $dogid ?>').style.display='table'">Tabelle anzeigen</button>
<table id="table_<?= $dogid ?>" class="table" style="display:none">
2023-11-26 14:00:23 +01:00
<tr>
<th>event</th>
<th>Wann wars</th>
<th>run</th>
<th>rang</th>
<th>stnr</th>
<th>teilnehmer</th>
<th>hund</th>
<th>verein</th>
<th>f</th>
<th>vw</th>
<th>zf</th>
<th>zeit</th>
<th>gf</th>
<th>msek</th>
<th>bew</th>
<th>punkte</th>
2023-12-23 18:20:50 +01:00
<th>Action</th>
2023-11-26 14:00:23 +01:00
</tr>
<?php foreach ($results as $res) :
// graph data preparation
2023-11-29 13:53:05 +01:00
if ($res['bew'] != 'DIS' && $res['punkte'] != 'DIS') {
2023-11-26 14:00:23 +01:00
$sdata['dates'][] = date("d.m.Y", strtotime($res['date']));
$sdata['speed'][] = $res['msek'] ?: 0;
$sdata['errors'][] = $res['f'] ?: 0;
$sdata['refusals'][] = $res['vw'] ?: 0;
$sdata['time'][] = $res['zeit'] ?: 0;
$sdata['points'][] = $res['punkte'];
$sdata['ranking'][] = $res['rang'];
2023-11-29 14:22:41 +01:00
$a = array_filter($sdata['speed']);
if(count($a)>0)
$averagespeed = round(array_sum($a)/count($a),2);
2023-11-29 14:27:49 +01:00
$a = $sdata['errors'];
2023-11-29 14:22:41 +01:00
if(count($a)>0)
$averageerrors = round(array_sum($a)/count($a),2);
2023-11-29 14:27:49 +01:00
$a = $sdata['refusals'];
2023-11-29 14:22:41 +01:00
if(count($a)>0)
$averagerefusals = round(array_sum($a)/count($a),2);
$a = array_filter($sdata['ranking']);
if(count($a)>0)
$averageranking = round(array_sum($a)/count($a),2);
2023-11-26 14:00:23 +01:00
}
?>
<tr>
<td><?= $res['event'] ?></td>
2023-12-23 18:20:50 +01:00
<td><?= date("d.m.Y", strtotime($res['date'])) ?></td>
2023-11-26 14:00:23 +01:00
<td><?= $res['run'] ?></td>
<td><?= $res['rang'] ?></td>
<td><?= $res['stnr'] ?></td>
<td><?= $res['teilnehmer'] ?></td>
<td><?= $res['hund'] ?></td>
<td><?= $res['verein'] ?></td>
<td><?= $res['f'] ?></td>
<td><?= $res['vw'] ?></td>
<td><?= $res['zf'] ?></td>
<td><?= $res['zeit'] ?></td>
<td><?= $res['gf'] ?></td>
<td><?= $res['msek'] ?></td>
<td><?= $res['bew'] ?></td>
<td><?= $res['punkte'] ?></td>
2023-12-23 18:20:50 +01:00
<td>
2023-12-25 16:42:59 +01:00
<form id="tournament_import" hx-post="/tournaments/add" hx-encoding="multipart/form-data" hx-target="#main">
2023-12-23 18:20:50 +01:00
<input type="hidden" name="tournament_name" value="<?= $res['event'] ?>">
<input type="hidden" name="tournament_date" value="<?= date("d.m.Y", strtotime($res['date'])) ?>">
<input type="hidden" name="tournament_run" value="<?= $res['run'] ?>">
<input type="hidden" name="tournament_ranking" value="<?= $res['rang'] ?>">
<input type="hidden" name="tournament_number" value="<?= $res['stnr'] ?>">
<input type="hidden" name="tournament_participant" value="<?= $res['teilnehmer'] ?>">
<input type="hidden" name="tournament_dog" value="<?= $res['hund'] ?>">
<input type="hidden" name="tournament_club" value="<?= $res['verein'] ?>">
<input type="hidden" name="tournament_faults" value="<?= $res['f'] ?>">
<input type="hidden" name="tournament_refusals" value="<?= $res['vw'] ?>">
<input type="hidden" name="tournament_time" value="<?= $res['zeit'] ?>">
<input type="hidden" name="tournament_speed" value="<?= $res['msek'] ?>">
<input type="hidden" name="tournament_points" value="<?= $res['punkte'] ?>">
<button type="submit">Importieren</button>
</form>
</td>
2023-11-26 14:00:23 +01:00
</tr>
<?php endforeach; ?>
</table>
2023-11-29 14:22:41 +01:00
<h4>Statistik</h4>
2023-11-29 14:26:03 +01:00
<div class="card" style="width: 25rem;">
2023-11-29 14:22:41 +01:00
<ul class="list-group list-group-flush">
2023-11-29 14:26:03 +01:00
<li class="list-group-item"><i class="fas fa-rabbit-fast"></i> Durchschnittsgeschwinigkeit: <span class="badge bg-primary" style="float:right;"><?= $averagespeed ?> m/s</span></li>
<li class="list-group-item"><i class="fas fa-exclamation-triangle"></i> Fehler pro Lauf: <span class="badge bg-primary" style="float:right;"><?= $averageerrors ?></span></li>
<li class="list-group-item"><i class="fas fa-do-not-enter"></i> Verweigerungen pro Lauf: <span class="badge bg-primary" style="float:right;"><?= $averagerefusals ?></span></li>
<li class="list-group-item"><i class="fas fa-trophy-alt"></i> Durchschnittliche Platzierung: <span class="badge bg-primary" style="float:right;"><?= $averageranking ?></span></li>
2023-11-29 14:22:41 +01:00
</ul>
</div>
<br/>
2023-11-29 13:53:05 +01:00
<div class="row">
<?php if (count($results) > 0) : ?>
<div class="col">
<?= partial('graph.html.php', [
2023-11-29 13:55:28 +01:00
'id' => 'graph1'.$dogid,
2023-11-29 13:53:05 +01:00
'title' => 'Fehler und Verweigerungen',
'xaxis' => $sdata['dates'],
'seriesdata' => [
['name' => 'Fehler', 'type' => 'line', 'stack' => 'Total', 'data' => $sdata['errors']],
['name' => 'Verweigerungen', 'type' => 'line', 'stack' => 'Total', 'data' => $sdata['refusals']],
],
]);
?>
</div>
2023-11-26 14:00:23 +01:00
2023-11-29 13:53:05 +01:00
<div class="col">
<?= partial('graph.html.php', [
2023-11-29 13:55:28 +01:00
'id' => 'graph2'.$dogid,
2023-11-29 13:53:05 +01:00
'title' => 'Geschwindigkeit',
'xaxis' => $sdata['dates'],
'seriesdata' => [
['name' => 'Geschwindigkeit', 'type' => 'line', 'stack' => 'Total', 'data' => $sdata['speed']],
],
]);
?>
</div>
2023-11-26 14:00:23 +01:00
2023-11-29 13:53:05 +01:00
<div class="col">
<?= partial('graph.html.php', [
2023-11-29 13:55:28 +01:00
'id' => 'graph3'.$dogid,
2023-11-29 13:53:05 +01:00
'title' => 'Platzierung',
'xaxis' => $sdata['dates'],
'seriesdata' => [
['name' => 'Platzierung', 'type' => 'line', 'stack' => 'Total', 'data' => $sdata['ranking']],
],
]);
?>
</div>
</div>
2023-11-26 14:00:23 +01:00
2023-11-29 13:53:05 +01:00
<?php endif; ?>
2023-11-26 14:00:23 +01:00
<hr>
<?php endforeach; ?>