Add unfinished simulator

This commit is contained in:
William 2022-01-24 11:54:42 +01:00
parent f41a0a88c7
commit 7ee66f95d9
4 changed files with 48 additions and 0 deletions

11
app/model/Simulator.php Normal file
View File

@ -0,0 +1,11 @@
<?php
class Simulator
{
public Database $database;
public function __construct(Database $database)
{
$this->database = $database;
}
}

8
app/view/simulator.php Normal file
View File

@ -0,0 +1,8 @@
<h1>Simulator</h1>
<p>Skriv inn et kortnummer:</p>
<form method="post">
<input type="text" name="cardnumber">
<br>
<br>
<input type="submit" value="Send">
</form>

11
public/api/get_times.php Normal file
View File

@ -0,0 +1,11 @@
<?php
$app = require '../../app/inc.php';
$sql = 'SELECT * FROM tidtabell';
$stmt = $app->database->conn->prepare($sql);
$stmt->execute();
$app->api([
"data" => $stmt->fetchAll(PDO::FETCH_ASSOC)
]);

18
public/simulator.php Normal file
View File

@ -0,0 +1,18 @@
<?php
$app = require '../app/inc.php';
$model = $app->model('Simulator');
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
if (!isset($_POST['cardnumber']) || empty($_POST['cardnumber']))
{
$app->session->flash('Kortnummer kan ikke være tom!', 'danger');
} else {
$app->session->flash("Kortnummer: \"{$_POST['cardnumber']}\" er ikke blitt lastet opp men burde bli implementert snart!", 'success');
}
}
$app->view('template/header', ['title' => 'Simulator']);
$app->view('simulator');
$app->view('template/footer');