dog overview
All checks were successful
Build and push / Pulling repo on server (push) Successful in 3s
All checks were successful
Build and push / Pulling repo on server (push) Successful in 3s
This commit is contained in:
parent
af05f1d520
commit
7b79995796
@ -243,6 +243,11 @@ class Model {
|
||||
return true;
|
||||
}
|
||||
|
||||
function getTable()
|
||||
{
|
||||
return $this->dbTable;
|
||||
}
|
||||
|
||||
function exists($id)
|
||||
{
|
||||
return $GLOBALS['redis']->exists($this->dbTable.':'.$id);
|
||||
|
@ -15,6 +15,39 @@ class Dog extends Model
|
||||
'active' => ['type' => 'bool', 'default' => 1]
|
||||
);
|
||||
|
||||
function getResults($dogid=false)
|
||||
{
|
||||
if(!$dogid)
|
||||
$dogid = $this->id;
|
||||
$res = new Result();
|
||||
$keys = $GLOBALS['redis']->keys($res->getTable() . ':*');
|
||||
$results = [];
|
||||
foreach ($keys as $key) {
|
||||
$id = end(explode(':', $key));
|
||||
$res = new Result();
|
||||
$res->load($id);
|
||||
if ($res->data['dog'] == $dogid) {
|
||||
$results[] = $res->data;
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
function getRuns()
|
||||
{
|
||||
$run = new Run();
|
||||
$keys = $GLOBALS['redis']->keys($run->dbTable . ':*');
|
||||
$runs = [];
|
||||
foreach ($keys as $key) {
|
||||
$id = end(explode(':', $key));
|
||||
$run = new Run();
|
||||
$run->load($id);
|
||||
if ($run->data['dog'] == $this->id)
|
||||
$runs[] = $run->data;
|
||||
}
|
||||
return $runs;
|
||||
}
|
||||
|
||||
function isMyDog($dog = false)
|
||||
{
|
||||
if ($dog == false)
|
||||
|
@ -209,11 +209,13 @@ class Dogs extends Page {
|
||||
{
|
||||
$dogid = $this->params[0];
|
||||
$d = new Dog();
|
||||
$res = new Result();
|
||||
|
||||
if(!$d->isMyDog($dogid))
|
||||
return 'Not your dog :(';
|
||||
|
||||
$d->load($dogid);
|
||||
$this->set('results', $d->getResults());
|
||||
$this->set('dogdata', $d->data);
|
||||
$this->set('dogid', $dogid);
|
||||
$this->set('template', 'dog.html');
|
||||
|
@ -25,8 +25,47 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-8" id="sitemain">
|
||||
|
||||
<div class="col-9" id="sitemain">
|
||||
<!-- table of all runs of this dog-->
|
||||
<div class="card p-2">
|
||||
<h4>Ergebnisse</h4>
|
||||
<p class="card-text">
|
||||
<button hx-get="/dogs/addresult/<?= $dogid; ?>" hx-push-url="/dogs/addresult/<?= $dogid; ?>" hx-target="#main" class="btn btn-primary"><i class="fas fa-plus-circle"></i> Ergebnis Eintragen</button>
|
||||
</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Platz</th>
|
||||
<th>Disqualifiziert</th>
|
||||
<th>Verweigerungen</th>
|
||||
<th>Fehler</th>
|
||||
<th>Zeitfehler</th>
|
||||
<th>Zeit</th>
|
||||
<th>Gesamtfehler</th>
|
||||
<th>m/Sek</th>
|
||||
<th>Bewertung</th>
|
||||
<th>Teilnehmer</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($results as $result) : ?>
|
||||
<tr>
|
||||
<td><?= escape($result['ranking']); ?></td>
|
||||
<td><?= $result['disqualified']?'Ja':'Nein'; ?></td>
|
||||
<td><?= escape($result['refusals']); ?></td>
|
||||
<td><?= escape($result['errors']); ?></td>
|
||||
<td><?= escape($result['timefaults']); ?></td>
|
||||
<td><?= escape($result['runtime']); ?></td>
|
||||
<td><?= escape($result['penalties']); ?></td>
|
||||
<td><?= escape($result['speed']); ?></td>
|
||||
<td><?= escape($result['rating']); ?></td>
|
||||
<td><a href="/dogs/overview/<?= $result['dog'] ?>"><?= escape( (new Dog())->getField('name',$result['dog']) ); ?></a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -77,7 +77,7 @@
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Reference in New Issue
Block a user