This repository has been archived on 2023-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
web/public/race/configure/reset.php

43 lines
989 B
PHP
Raw Normal View History

2022-03-20 20:36:35 +00:00
<?php $app = require '../../../app/inc.php';
/**
2022-03-20 21:02:26 +00:00
* Resets team counters and removes all time records
2022-03-20 20:36:35 +00:00
*/
use App\Teamtable\Team;
use App\Teamtable\TeamMapper;
use App\Timetable\Time;
use App\Timetable\TimeMapper;
2022-03-20 21:02:26 +00:00
$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();
}
2022-04-14 20:59:42 +00:00
$team_mapper = new TeamMapper($app->database->conn);
$time_mapper = new TimeMapper($app->database->conn);
2022-03-20 20:36:35 +00:00
// reset counters for all teams
2022-04-14 20:59:42 +00:00
$teams = $team_mapper->getAll();
2022-03-20 20:36:35 +00:00
foreach ($teams as $key => $team)
{
$team->setRounds(0);
2022-04-14 20:59:42 +00:00
$team->best_time = NULL;
$team_mapper->update($team);
2022-03-20 20:36:35 +00:00
}
// delete all time records
2022-04-14 20:59:42 +00:00
$times = $time_mapper->getAll();
2022-03-20 20:36:35 +00:00
foreach ($times as $key => $time)
{
2022-04-14 20:59:42 +00:00
$time_mapper->delete($time->id);
2022-03-20 21:02:26 +00:00
}
$app->session->flash("Runder er nullstilt", "success");
$app->redirect("index.php");