Commit
This commit is contained in:
parent
5c891551df
commit
10f2e69c43
@ -65,7 +65,6 @@ class User
|
||||
if ($this->authenticate($username, $password))
|
||||
{
|
||||
$this->session->set(self::SESSION_KEY, [
|
||||
'loggedIn' => TRUE,
|
||||
'username' => $username,
|
||||
'password' => $password
|
||||
]);
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
class Teamtable
|
||||
{
|
||||
public PDO $dbh;
|
||||
|
||||
public array $emptyTeamTemplate = [
|
||||
public array $template = [
|
||||
'LagNavn' => 'NN',
|
||||
'Bedrift' => 'NN',
|
||||
'Kortnummer' => 'NN',
|
||||
@ -14,6 +12,8 @@ class Teamtable
|
||||
'Runder' => 0
|
||||
];
|
||||
|
||||
public PDO $dbh;
|
||||
|
||||
public function __construct(Database $database)
|
||||
{
|
||||
$this->dbh = $database->conn;
|
||||
@ -61,7 +61,7 @@ class Teamtable
|
||||
$sth = $this->dbh->prepare(
|
||||
'INSERT INTO lagtabell (LagNavn, Bedrift, Kortnummer, Lagleder, Telefon, Deltagere, Runder) VALUES (?, ?, ?, ?, ?, ?, ?)'
|
||||
);
|
||||
$template = $this->emptyTeamTemplate;
|
||||
$template = $this->template;
|
||||
$sth->execute([
|
||||
$template['LagNavn'],
|
||||
$template['Bedrift'],
|
||||
@ -77,7 +77,7 @@ class Teamtable
|
||||
// Check if team is empty by comparing it to the template
|
||||
public function isEqualEmptyTemplate(array $team): bool
|
||||
{
|
||||
$template = $this->emptyTeamTemplate;
|
||||
$template = $this->template;
|
||||
foreach ($template as $key => $value) {
|
||||
if ((string)$team[$key] !== (string)$template[$key]) {
|
||||
return FALSE;
|
||||
@ -105,7 +105,7 @@ class Teamtable
|
||||
$sth = $this->dbh->prepare(
|
||||
"INSERT INTO `lagtabell` (`LagNavn`, `Bedrift`, `Kortnummer`, `Lagleder`, `Telefon`, `Deltagere`, `Runder`) VALUES (?, ?, ?, ?, ?, ?, ?)"
|
||||
);
|
||||
$template = $this->emptyTeamTemplate;
|
||||
$template = $this->template;
|
||||
$sth->execute([
|
||||
$template['LagNavn'],
|
||||
$template['Bedrift'],
|
||||
|
@ -15,24 +15,29 @@
|
||||
<th>Handling</th>
|
||||
</tr>
|
||||
<?php
|
||||
$iterator = 0;
|
||||
foreach ($teams as $row) {
|
||||
++$iterator;
|
||||
foreach ($row as $key => $value)
|
||||
$i = 1;
|
||||
foreach ($teams as $team) {
|
||||
$i++;
|
||||
// Remember to escape your values!
|
||||
foreach ($team as $key => $value)
|
||||
{
|
||||
$row[$key] = htmlspecialchars($row[$key]);
|
||||
$team[$key] = htmlspecialchars($team[$key]);
|
||||
}
|
||||
|
||||
echo '<tr>';
|
||||
echo "<td>{$iterator}</td>";
|
||||
echo "<td>{$row['LagNavn']}</td>";
|
||||
echo "<td>{$row['Bedrift']}</td>";
|
||||
echo "<td>{$row['Kortnummer']}</td>";
|
||||
echo "<td>{$row['Lagleder']}</td>";
|
||||
echo "<td>{$row['Telefon']}</td>";
|
||||
echo "<td>{$row['Deltagere']}</td>";
|
||||
echo "<td>{$row['Runder']}</td>";
|
||||
echo "<td>{$row['Bestetid']}</td>";
|
||||
echo "<td><span>[ <a class='danger' href='delete.php?item={$row['LagID']}&confirmation=true'>Slett</a> ]</span> <span>[ <a class='info' href='update.php?item={$row['LagID']}'>Endre</a> ]</span></td>";
|
||||
echo "<td>{$i}</td>";
|
||||
echo "<td>{$team['LagNavn']}</td>";
|
||||
echo "<td>{$team['Bedrift']}</td>";
|
||||
echo "<td>{$team['Kortnummer']}</td>";
|
||||
echo "<td>{$team['Lagleder']}</td>";
|
||||
echo "<td>{$team['Telefon']}</td>";
|
||||
echo "<td>{$team['Deltagere']}</td>";
|
||||
echo "<td>{$team['Runder']}</td>";
|
||||
echo "<td>{$team['Bestetid']}</td>";
|
||||
echo "<td>";
|
||||
echo "<span>[ <a class='danger' href='delete.php?item={$team['LagID']}&confirmation=true'>Slett</a> ]</span>";
|
||||
echo "<span>[ <a class='info' href='update.php?item={$team['LagID']}'>Endre</a> ]</span>";
|
||||
echo "</td>";
|
||||
echo '</tr>';
|
||||
}
|
||||
?>
|
||||
|
@ -13,24 +13,25 @@
|
||||
<th>Bestetid</th>
|
||||
</tr>
|
||||
<?php
|
||||
$iterator = 0;
|
||||
foreach ($teams as $row) {
|
||||
++$iterator;
|
||||
// Escape all values
|
||||
foreach ($row as $key => $value)
|
||||
$i = 1;
|
||||
foreach ($teams as $team) {
|
||||
$i++;
|
||||
// Remember to escape your values!
|
||||
foreach ($team as $key => $value)
|
||||
{
|
||||
$row[$key] = htmlspecialchars($row[$key]);
|
||||
$team[$key] = htmlspecialchars($team[$key]);
|
||||
}
|
||||
|
||||
echo '<tr>';
|
||||
echo "<td>{$iterator}</td>";
|
||||
echo "<td>{$row['LagNavn']}</td>";
|
||||
echo "<td>{$row['Bedrift']}</td>";
|
||||
echo "<td>{$row['Kortnummer']}</td>";
|
||||
echo "<td>{$row['Lagleder']}</td>";
|
||||
echo "<td>{$row['Telefon']}</td>";
|
||||
echo "<td>{$row['Deltagere']}</td>";
|
||||
echo "<td>{$row['Runder']}</td>";
|
||||
echo "<td>{$row['Bestetid']}</td>";
|
||||
echo "<td>{$i}</td>";
|
||||
echo "<td>{$team['LagNavn']}</td>";
|
||||
echo "<td>{$team['Bedrift']}</td>";
|
||||
echo "<td>{$team['Kortnummer']}</td>";
|
||||
echo "<td>{$team['Lagleder']}</td>";
|
||||
echo "<td>{$team['Telefon']}</td>";
|
||||
echo "<td>{$team['Deltagere']}</td>";
|
||||
echo "<td>{$team['Runder']}</td>";
|
||||
echo "<td>{$team['Bestetid']}</td>";
|
||||
echo '</tr>';
|
||||
}
|
||||
?>
|
||||
|
@ -3,6 +3,8 @@ $app = require '../../../app/inc.php';
|
||||
|
||||
$model = $app->model('Teamtable');
|
||||
|
||||
$teams = $model->getTable();
|
||||
|
||||
$app->view('template/header', ['title' => 'Endre lagtabell']);
|
||||
$app->view('pages/teamtable/edit/index', ["teams" => $model->getTable()]);
|
||||
$app->view('pages/teamtable/edit/index', ["teams" => $teams]);
|
||||
$app->view('template/footer');
|
@ -54,7 +54,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST')
|
||||
//====Validate Input====//
|
||||
|
||||
$validationError = FALSE;
|
||||
$template = $model->emptyTeamTemplate;
|
||||
$template = $model->template;
|
||||
|
||||
// LagNavn
|
||||
if (!strlen($LagNavn)) {
|
||||
|
@ -3,6 +3,8 @@ $app = require '../../app/inc.php';
|
||||
|
||||
$model = $app->model('Teamtable');
|
||||
|
||||
$teams = $model->getTable();
|
||||
|
||||
$app->view('template/header', ['title' => 'Lagtabell']);
|
||||
$app->view('pages/teamtable/index', ["teams" => $model->getTable()]);
|
||||
$app->view('pages/teamtable/index', ["teams" => $teams]);
|
||||
$app->view('template/footer');
|
Reference in New Issue
Block a user