52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
$app = require '../../../app/inc.php';
|
|
|
|
$model = $app->model('Teamtable');
|
|
|
|
if (!isset($_GET['item']))
|
|
{
|
|
$app->session->flash('LagID ikke definert som GET parameter', 'danger');
|
|
$app->redirect('index.php');
|
|
}
|
|
$id = $_GET['item'];
|
|
|
|
// ID must be numeric
|
|
if (!is_numeric($id))
|
|
{
|
|
$app->session->flash('LagID 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 endre lag: LagID \"$id\" finnes ikke", "danger");
|
|
$app->redirect('index.php');
|
|
}
|
|
|
|
// Change team
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST')
|
|
{
|
|
$model->updateTeam(
|
|
$id, [
|
|
$_POST['navn'],
|
|
$_POST['bedrift'],
|
|
$_POST['kortnummer'],
|
|
$_POST['leder'],
|
|
$_POST['telefon'],
|
|
$_POST['deltagere'],
|
|
$_POST['runder'],
|
|
],
|
|
);
|
|
}
|
|
|
|
// Escape all values
|
|
foreach ($currentTeam as $key => $value)
|
|
{
|
|
$currentTeam[$key] = htmlspecialchars($currentTeam[$key]);
|
|
}
|
|
|
|
$app->view('template/header', ['title' => 'Endre lagdetaljer']);
|
|
$app->view('pages/teamtable/edit/alter', ["team" => $currentTeam]);
|
|
$app->view('template/footer');
|