This commit is contained in:
William 2022-03-20 22:02:26 +01:00
parent 14820d90fd
commit d3657810b1
5 changed files with 23 additions and 5 deletions

View File

@ -0,0 +1,4 @@
<h1>Er du sikker?</h1>
<p>Er du sikker at du vil nullstille alle runder?</p>
<span>[&nbsp;<a class="success" href="reset.php?confirm=1">Nullstill</a>&nbsp;]</span>
<span>[&nbsp;<a class="danger" href="index.php">Avbryt</a>&nbsp;]</span>

View File

@ -1,4 +1,4 @@
<h1>Er du sikker?</h1> <h1>Er du sikker?</h1>
<p>Er du sikker at du vil slette lag <?=htmlspecialchars($team->name)?>?</p> <p>Er du sikker at du vil slette lag <?=htmlspecialchars($team->name)?>?</p>
<span>[&nbsp;<a class="success" href="delete.php?item=<?=$team->id?>">Slett</a>&nbsp;]</span> <span>[&nbsp;<a class="success" href="delete.php?confirm=1&item=<?=$team->id?>">Slett</a>&nbsp;]</span>
<span>[&nbsp;<a class="danger" href="index.php">Avbryt</a>&nbsp;]</span> <span>[&nbsp;<a class="danger" href="index.php">Avbryt</a>&nbsp;]</span>

View File

@ -1,5 +1,6 @@
<h1>Endre lagtabell</h1> <h1>Endre lagtabell</h1>
<span class="float-right">[&nbsp;<a class="success" href="update.php">Opprett lag</a>&nbsp;]</span> <span class="float-right">[&nbsp;<a class="success" href="update.php">Opprett lag</a>&nbsp;]</span>
<span class="float-right">[&nbsp;<a class="danger" href="../reset.php">Nullstill runder</a>&nbsp;]&nbsp;</span>
<br> <br>
<table> <table>
<tr> <tr>
@ -29,7 +30,7 @@
echo "<td>" . htmlspecialchars($team->rounds) . "</td>"; echo "<td>" . htmlspecialchars($team->rounds) . "</td>";
echo "<td>" . htmlspecialchars(($team->bestTime === NULL) ? "Ukjent" : $team->bestTime) . "</td>"; echo "<td>" . htmlspecialchars(($team->bestTime === NULL) ? "Ukjent" : $team->bestTime) . "</td>";
echo "<td>"; echo "<td>";
echo "<span>[&nbsp;<a class='danger' href='delete.php?item={$team->id}&confirm=1'>Slett</a>&nbsp;]&nbsp;</span>"; echo "<span>[&nbsp;<a class='danger' href='delete.php?item={$team->id}'>Slett</a>&nbsp;]&nbsp;</span>";
echo "<span>[&nbsp;<a class='info' href='update.php?item={$team->id}'>Endre</a>&nbsp;]</span>"; echo "<span>[&nbsp;<a class='info' href='update.php?item={$team->id}'>Endre</a>&nbsp;]</span>";
echo "</td>"; echo "</td>";
echo '</tr>'; echo '</tr>';

View File

@ -1,6 +1,6 @@
<?php $app = require '../../../app/inc.php'; <?php $app = require '../../../app/inc.php';
/** /**
* Remove times from timetable and update teamtable with new times * Resets team counters and removes all time records
*/ */
use App\Teamtable\Team; use App\Teamtable\Team;
@ -8,6 +8,16 @@ use App\Teamtable\TeamMapper;
use App\Timetable\Time; use App\Timetable\Time;
use App\Timetable\TimeMapper; use App\Timetable\TimeMapper;
$confirm = filter_input(INPUT_GET, 'confirm', FILTER_VALIDATE_BOOLEAN);
if (!$confirm)
{
$app->view('template/header', ['title' => 'Nullstill runder']);
$app->view('pages/race/configure/reset');
$app->view('template/footer');
die();
}
$teamMapper = new TeamMapper($app->database->conn); $teamMapper = new TeamMapper($app->database->conn);
$timeMapper = new TimeMapper($app->database->conn); $timeMapper = new TimeMapper($app->database->conn);
@ -28,3 +38,6 @@ foreach ($times as $key => $time)
{ {
$timeMapper->delete($time->id); $timeMapper->delete($time->id);
} }
$app->session->flash("Runder er nullstilt", "success");
$app->redirect("index.php");

View File

@ -23,7 +23,7 @@ if (!$team)
} }
// show confirmation page // show confirmation page
if ($confirm) if (!$confirm)
{ {
$app->view('template/header', ['title' => 'Bekreft sletting']); $app->view('template/header', ['title' => 'Bekreft sletting']);
$app->view('pages/race/configure/teams/delete', ['team' => $team]); $app->view('pages/race/configure/teams/delete', ['team' => $team]);