41 lines
1.0 KiB
PHP
41 lines
1.0 KiB
PHP
<?php
|
|
$app = require '../../../app/inc.php';
|
|
|
|
$model = $app->model('Teamtable');
|
|
|
|
if (!isset($_GET['item']))
|
|
{
|
|
$app->session->flash('Kunne ikke slette lag: ID ikke definert som GET parameter', 'danger');
|
|
$app->redirect('index.php');
|
|
}
|
|
$id = $_GET['item'];
|
|
|
|
// ID must be numeric
|
|
if (!is_numeric($id))
|
|
{
|
|
$app->session->flash('Kunne ikke slette lag: ID må være tall', 'danger');
|
|
$app->redirect('index.php');
|
|
}
|
|
|
|
// Check if ID is in teamtable
|
|
$currentTeam = $model->getTeamByID($id);
|
|
if (!$currentTeam)
|
|
{
|
|
$app->session->flash("Kunne ikke slette lag: ID $id finnes ikke", "danger");
|
|
$app->redirect('index.php');
|
|
}
|
|
|
|
// Show confirmation page
|
|
if (isset($_GET['confirmation']) && $_GET['confirmation'] == 'true')
|
|
{
|
|
$app->view('template/header', ['title' => 'Bekreft sletting']);
|
|
$app->view('pages/teamtable/edit/delete', ['currentTeam' => $currentTeam]);
|
|
$app->view('template/footer');
|
|
die();
|
|
}
|
|
|
|
$model->deleteTeamByID($id);
|
|
|
|
$app->session->flash("Slettet lag: {$currentTeam['LagNavn']}", "success");
|
|
|
|
$app->redirect('index.php'); |