43 lines
989 B
PHP
43 lines
989 B
PHP
<?php $app = require '../../../app/inc.php';
|
|
/**
|
|
* Resets team counters and removes all time records
|
|
*/
|
|
|
|
use App\Teamtable\Team;
|
|
use App\Teamtable\TeamMapper;
|
|
use App\Timetable\Time;
|
|
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();
|
|
}
|
|
|
|
$team_mapper = new TeamMapper($app->database->conn);
|
|
$time_mapper = new TimeMapper($app->database->conn);
|
|
|
|
// reset counters for all teams
|
|
$teams = $team_mapper->getAll();
|
|
|
|
foreach ($teams as $key => $team)
|
|
{
|
|
$team->setRounds(0);
|
|
$team->best_time = NULL;
|
|
$team_mapper->update($team);
|
|
}
|
|
|
|
// delete all time records
|
|
$times = $time_mapper->getAll();
|
|
|
|
foreach ($times as $key => $time)
|
|
{
|
|
$time_mapper->delete($time->id);
|
|
}
|
|
|
|
$app->session->flash("Runder er nullstilt", "success");
|
|
$app->redirect("index.php"); |