2022-03-07 06:13:17 +00:00
|
|
|
<?php $app = require '../../../app/inc.php';
|
2022-02-09 15:59:20 +00:00
|
|
|
|
2022-03-07 06:13:17 +00:00
|
|
|
use App\Teamtable\Team;
|
2022-02-09 15:59:20 +00:00
|
|
|
|
2022-03-07 06:13:17 +00:00
|
|
|
$item = filter_input(INPUT_GET, 'item', FILTER_VALIDATE_INT);
|
|
|
|
$confirm = filter_input(INPUT_GET, 'confirm', FILTER_VALIDATE_BOOL);
|
|
|
|
|
|
|
|
$model = $app->model('Teamtable');
|
2022-02-09 15:59:20 +00:00
|
|
|
|
2022-03-07 06:13:17 +00:00
|
|
|
// item is NULL if not set
|
|
|
|
if ($item === NULL)
|
2022-02-09 15:59:20 +00:00
|
|
|
{
|
2022-03-07 06:13:17 +00:00
|
|
|
$app->session->flash('Kunne ikke slette lag: Mangler parameter.', 'danger');
|
2022-02-09 15:59:20 +00:00
|
|
|
$app->redirect('index.php');
|
|
|
|
}
|
|
|
|
|
2022-03-07 06:13:17 +00:00
|
|
|
$team = $model->get($item);
|
|
|
|
if (!$team)
|
2022-02-09 15:59:20 +00:00
|
|
|
{
|
2022-03-07 06:13:17 +00:00
|
|
|
// team does not exist
|
|
|
|
$app->session->flash('Kunne ikke slette lag: Lag eksisterer ikke', 'danger');
|
2022-02-09 15:59:20 +00:00
|
|
|
$app->redirect('index.php');
|
|
|
|
}
|
|
|
|
|
2022-03-07 06:13:17 +00:00
|
|
|
// show confirmation page
|
|
|
|
if ($confirm)
|
2022-02-14 01:52:59 +00:00
|
|
|
{
|
|
|
|
$app->view('template/header', ['title' => 'Bekreft sletting']);
|
2022-03-07 06:13:17 +00:00
|
|
|
$app->view('pages/teamtable/edit/delete', ['team' => $team]);
|
2022-02-14 01:52:59 +00:00
|
|
|
$app->view('template/footer');
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
2022-03-07 06:13:17 +00:00
|
|
|
// all is good, lets delete the team
|
|
|
|
$model->delete($team->id);
|
|
|
|
$app->session->flash("Slettet lag: {$team->name}", "success");
|
2022-02-09 15:59:20 +00:00
|
|
|
$app->redirect('index.php');
|