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