diff --git a/app/inc.php b/app/inc.php index 9765dba..470a9ef 100644 --- a/app/inc.php +++ b/app/inc.php @@ -12,9 +12,6 @@ * Tread carefully */ -// disable type coercion -declare(strict_types=1); - // PSR-4 like autoloader spl_autoload_register( function ($className) { @@ -23,7 +20,6 @@ spl_autoload_register( } ); -// imports use App\Core\ { ErrorHandler, Config, @@ -34,22 +30,16 @@ use App\Core\ { AccessControl }; -// displays a custom page on error or exception new ErrorHandler(); -// grab configuration file $config = (new Config(__DIR__ . '/config.php'))->config; -// start database connection $database = new Database($config['database']); -// session wrapper $session = new Session(); -// handles current user session $user = new User($session, $database); - $app = new App(__DIR__, $config, $database, $session, $user); // we will use $app instead diff --git a/app/lib/App/Core/App.php b/app/lib/App/Core/App.php index 65159e7..8d30419 100644 --- a/app/lib/App/Core/App.php +++ b/app/lib/App/Core/App.php @@ -30,19 +30,22 @@ class App $this->user = $user; } - // grab model - // TODO: have a look to see if this might name conflict with anything and - // maybe also throw an exception if the model class is not found within the file + /** + * Grab model + * + * TODO: have a look to see if this might name conflict with anything and + * maybe also throw an exception if the model class is not found within the file + */ public function model(string $model, $injection = NULL): object { - // Require model file + // require model file $path = $this->dir . '/model/' . $model . '.php'; if (!file_exists($path)) { throw new Exception("Model does not exist"); } require $path; - // Instantiate model + // instantiate model if (!$injection) { $injection = $this->database; @@ -71,10 +74,10 @@ class App */ public function api(array $data, int $status_code = 200): void { - // Set headers + // set headers http_response_code($status_code); header('Content-type: application/json'); - // Convert and respond with data + // convert and respond with data echo json_encode($data); die(); } diff --git a/app/lib/App/Core/Database.php b/app/lib/App/Core/Database.php index e82b421..05abe0a 100644 --- a/app/lib/App/Core/Database.php +++ b/app/lib/App/Core/Database.php @@ -8,7 +8,7 @@ use \PDOException; /** * Encapsulates a single connection to a database. - * TODO: Refactor and add different driver implementations. + * TODO: add different driver implementations. */ class Database { @@ -33,7 +33,7 @@ class Database $dsn = "mysql:host={$args['host']};dbname={$args['database']};charset={$args['charset']}"; $options = [ PDO::ATTR_PERSISTENT => true, - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION // In PHP 8 and above, this will be the default mode. + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION // in PHP 8 and above, this will be the default mode. ]; return new PDO($dsn, $args['user'], $args['password'], $options); } diff --git a/app/lib/App/Core/Session.php b/app/lib/App/Core/Session.php index 2483587..85e34df 100644 --- a/app/lib/App/Core/Session.php +++ b/app/lib/App/Core/Session.php @@ -3,6 +3,7 @@ namespace App\Core; use \Exception; +use \InvalidArgumentException; /** * Handles anything to do with sessions @@ -63,7 +64,7 @@ class Session "warning" ]; if (!in_array($type, $types)) { - throw new Exception("Flash type: \"$type\" does not exist"); + throw new InvalidArgumentException("Flash type: \"$type\" does not exist"); } $key = 'flashed_messages'; if (!$this->has($key)) diff --git a/app/lib/App/Teamtable/Team.php b/app/lib/App/Teamtable/Team.php index 62a1f16..0f21907 100644 --- a/app/lib/App/Teamtable/Team.php +++ b/app/lib/App/Teamtable/Team.php @@ -2,97 +2,62 @@ namespace App\Teamtable; +use \InvalidArgumentException; + /** * Represents a team in the teamtable database + * TODO: Add validation for setters */ class Team { - public string $name; - public string $company; - public string $cardnumber; - public int $phone; - public int $participants; - public int $rounds; + public int $id; + public string $name = 'NN'; + public string $company = 'NN'; + public string $cardnumber = 'NN'; + public string $leader = 'NN'; + public int $phone = 0; + public int $participants = 0; + public int $rounds = 0; - public function __construct( - string $name = 'NN', - string $company = 'NN', - string $cardnumber = 'NN', - int $phone = 0, - int $participants = 0, - int $rounds = 0 - ) + public function setName(string $name): Self { - $this->name = $name; - $this->company = $company; - $this->cardnumber = $cardnumber; - $this->phone = $phone; - $this->participants = $participants; - $this->rounds = $rounds; + $this->name = $name; + return $this; } - /** - * Check if all current values are valid - */ - public function validate(): bool + public function setCompany(string $company): Self { - $validationError = FALSE; - $template = $model->template; + $this->company = $company; + return $this; + } - // LagNavn - if (!strlen($LagNavn)) { - $LagNavn = $template['LagNavn']; - } - if (strlen($LagNavn) > 32) { - $validationError = TRUE; - } + public function setCardnumber(string $cardnumber): Self + { + $this->cardnumber = $cardnumber; + return $this; + } - // Bedrift - if (!strlen($Bedrift)) { - $Bedrift = $template['Bedrift']; - } - if (strlen($Bedrift) > 32) { - $validationError = TRUE; - } + public function setLeader(string $leader): Self + { + $this->leader = $leader; + return $this; + } - // Kortnummer - if (!strlen($Kortnummer)) { - $Kortnummer = $template['Kortnummer']; - } - if (strlen($Kortnummer) > 32) { - $validationError = TRUE; - } + public function setPhone(int $phone): Self + { + $this->phone = $phone; + return $this; + } - // Lagleder - if (!strlen($Lagleder)) { - $Lagleder = $template['Lagleder']; - } - if (strlen($Lagleder) > 32) { - $validationError = TRUE; - } + public function setParticipants(int $participants): Self + { + $this->participants = $participants; + return $this; + } - // Telefon - if (!strlen($Telefon)) { - $Telefon = $template['Telefon']; - } - if (strlen((string) $Telefon) > 32) { - $validationError = TRUE; - } - - // Deltagere - if (!strlen($Deltagere)) { - $Deltagere = $template['Deltagere']; - } - if (strlen((string) $Deltagere) > 32) { - $validationError = TRUE; - } - - // Runder - if (!strlen($Runder)) { - $Runder = $template['Runder']; - } - if (strlen((string) $Runder) > 32) { - $validationError = TRUE; - } + public function setRounds(int $rounds): Self + { + $this->rounds = $rounds; + return $this; } } \ No newline at end of file diff --git a/app/lib/App/Teamtable/TeamMapper.php b/app/lib/App/Teamtable/TeamMapper.php new file mode 100644 index 0000000..19732f0 --- /dev/null +++ b/app/lib/App/Teamtable/TeamMapper.php @@ -0,0 +1,118 @@ +dbh = $dbh; + } + + private function mapRowToTeam(array $row): Team + { + $team = new Team(); + $team->id = $row['LagID']; + $team->setName($row['LagNavn']); + $team->setCompany($row['Bedrift']); + $team->setCardnumber($row['Kortnummer']); + $team->setLeader($row['Lagleder']); + $team->setPhone($row['Telefon']); + $team->setParticipants($row['Deltagere']); + $team->setRounds($row['Runder']); + return $team; + } + + /** + * Returns an array of all teams + */ + public function getAll(): array + { + $sth = $this->dbh->query('SELECT * FROM lagtabell'); + $assoc_array = $sth->fetchAll(PDO::FETCH_ASSOC); + + $teams = []; + foreach ($assoc_array as $key => $row) + { + array_push($teams, $this->mapRowToTeam($row)); + } + return $teams; + #while ($assoc_array) + #{ + # array_push($teams, $this->mapRowToTeam($assoc_array[0])); + # array_pop($assoc_array); + #} + #return $teams; + } + + public function get(int $id): ?Team + { + $sth = $this->dbh->prepare('SELECT * FROM lagtabell WHERE LagID = ?'); + $sth->execute([$id]); + $row = $sth->fetch(PDO::FETCH_ASSOC); + if ($row) + { + return $this->mapRowToTeam($row); + } + return NULL; + } + + public function create(Team $team): Team + { + $sth = $this->dbh->prepare( + 'INSERT INTO lagtabell + (LagNavn, Bedrift, Kortnummer, Lagleder, Telefon, Deltagere, Runder) + VALUES + (?, ?, ?, ?, ?, ?, ?)' + ); + $sth->execute([ + $team->name, + $team->company, + $team->cardnumber, + $team->leader, + $team->phone, + $team->participants, + $team->rounds + ]); + $lastId = $this->dbh->lastInsertId(); + return $this->get($lastId); + } + + public function update(Team $team): Team + { + $sth = $this->dbh->prepare( + 'UPDATE lagtabell SET + LagNavn = ?, Bedrift = ?, Kortnummer = ?, + Lagleder = ?, Telefon = ?, Deltagere = ?, + Runder = ? + WHERE + LagID = ?' + ); + $sth->execute([ + $team->name, + $team->company, + $team->cardnumber, + $team->leader, + $team->phone, + $team->participants, + $team->rounds, + $team->id + ]); + return $this->get($team->id); + } + + public function delete(int $id): void + { + $sth = $this->dbh->prepare('DELETE FROM lagtabell WHERE LagID = ?'); + $sth->execute([$id]); + } +} \ No newline at end of file diff --git a/app/model/Teamtable.php b/app/model/Teamtable.php index c21ceee..73dd1a5 100644 --- a/app/model/Teamtable.php +++ b/app/model/Teamtable.php @@ -2,132 +2,75 @@ use App\Core\Database as Database; use App\Teamtable\Team as Team; +use App\Teamtable\TeamMapper as TeamMapper; /** - * Do stuff with the teamtable + * Does stuffs with the teamtable */ class Teamtable { /** - * Database handler + * Database connection */ public PDO $dbh; + /** + * We use a data mapper pattern + */ + public TeamMapper $teamMapper; + public function __construct(Database $database) { $this->dbh = $database->conn; + $this->teamMapper = new TeamMapper($this->dbh); } /** * Fetch entire team table */ - public function getTable(): array + public function getAll(): array { - $sth = $this->dbh->query('SELECT * FROM lagtabell'); - return $sth->fetchAll(PDO::FETCH_ASSOC); + return $this->teamMapper->getAll(); } /** - * Delete team with supplied id + * Find team with supplied id */ - public function deleteTeamByID(int $LagID): void + public function get(int $id): ?Team { - $sth = $this->dbh->prepare('DELETE FROM lagtabell WHERE LagID = ?'); - $sth->execute([$LagID]); + return $this->teamMapper->get($id); } /** - * Returns mixed, array if exists, FALSE if not. + * Inserts team into database */ - public function getTeamByID(int $LagID) + public function create(Team $team): Team { - $sth = $this->dbh->prepare('SELECT * FROM lagtabell WHERE LagID = ?'); - $sth->execute([$LagID]); - return $sth->fetch(PDO::FETCH_ASSOC); + return $this->teamMapper->create($team); } - /** - * Why this is so long who cares??? - */ - public function updateTeamByID( - int $id, - string $LagNavn, - string $Bedrift, - string $Kortnummer, - string $Lagleder, - int $Telefon, - string $Deltagere, - int $Runder - ): void + public function delete(int $id): void { - $sth = $this->dbh->prepare( - 'UPDATE lagtabell SET LagNavn = ?, Bedrift = ?, Kortnummer = ?, Lagleder = ?, Telefon = ?, Deltagere = ?, Runder = ? WHERE LagID = ?' - ); - $sth->execute([$LagNavn, $Bedrift, $Kortnummer, $Lagleder, $Telefon, $Deltagere, $Runder, $id]); - } - - public function addEmptyTeam(): int - { - $sth = $this->dbh->prepare( - 'INSERT INTO lagtabell (LagNavn, Bedrift, Kortnummer, Lagleder, Telefon, Deltagere, Runder) VALUES (?, ?, ?, ?, ?, ?, ?)' - ); - $template = $this->template; - $sth->execute([ - $template['LagNavn'], - $template['Bedrift'], - $template['Kortnummer'], - $template['Lagleder'], - $template['Telefon'], - $template['Deltagere'], - $template['Runder'], - ]); - return $this->dbh->lastInsertId(); - } - - /** - * Check if team is empty by comparing it to the template - */ - public function isEqualEmptyTemplate(array $team): bool - { - $template = $this->template; - foreach ($template as $key => $value) { - if ((string)$team[$key] !== (string)$template[$key]) { - return FALSE; - } - } - return TRUE; + $this->teamMapper->delete($id); } /** * Returns TRUE if team exists, FALSE if not */ - public function recieveStick(string $cardnumber): bool + public function recieveBaton(string $cardnumber): bool { - $sth = $this->dbh->prepare('SELECT * FROM lagtabell WHERE Kortnummer = ?'); - $sth->execute([$cardnumber]); - - $row = $sth->fetch(PDO::FETCH_ASSOC); - if ($row) + $team = $this->getTeamByCardnumber($cardnumber); + if ($team) { // team exists, insert into time table $sth = $this->dbh->prepare('INSERT INTO tidtabell (LagID) VALUES (?)'); $sth->execute([$row['LagID']]); return TRUE; } - // team does not exist, lets create it - $sth = $this->dbh->prepare( - "INSERT INTO `lagtabell` (`LagNavn`, `Bedrift`, `Kortnummer`, `Lagleder`, `Telefon`, `Deltagere`, `Runder`) VALUES (?, ?, ?, ?, ?, ?, ?)" - ); - $template = $this->template; - $sth->execute([ - $template['LagNavn'], - $template['Bedrift'], - $cardnumber, - $template['Lagleder'], - $template['Telefon'], - $template['Deltagere'], - $template['Runder'], - ]); + // team does not exist, lets create it + $team = new Team(); + $team->cardnumber = $cardnumber; + $this->addTeam($team); return FALSE; } } \ No newline at end of file diff --git a/app/view/pages/teamtable/edit/delete.php b/app/view/pages/teamtable/edit/delete.php index 1a4208f..d870fe9 100644 --- a/app/view/pages/teamtable/edit/delete.php +++ b/app/view/pages/teamtable/edit/delete.php @@ -1,4 +1,4 @@

Er du sikker?

-

Er du sikker på at du vil slette lag ?

-Slett ] +

Er du sikker på at du vil slette lag name)?>?

+Slett ] Avbryt ] \ No newline at end of file diff --git a/app/view/pages/teamtable/edit/index.php b/app/view/pages/teamtable/edit/index.php index 6b890b1..5a0acf0 100644 --- a/app/view/pages/teamtable/edit/index.php +++ b/app/view/pages/teamtable/edit/index.php @@ -1,5 +1,5 @@

Endre lagtabell

-Opprett lag ] +Opprett lag ]
@@ -18,25 +18,19 @@ $i = 0; foreach ($teams as $team) { $i++; - // Remember to escape your values! - foreach ($team as $key => $value) - { - $team[$key] = htmlspecialchars($team[$key]); - } - echo ''; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; echo ""; echo ''; } diff --git a/app/view/pages/teamtable/edit/update.php b/app/view/pages/teamtable/edit/update.php index b590441..5f54bc4 100644 --- a/app/view/pages/teamtable/edit/update.php +++ b/app/view/pages/teamtable/edit/update.php @@ -1,45 +1,40 @@ - $value) { - $team[$key] = htmlspecialchars($value); -} -?>

Endre lagdetaljer

Her kan du oppdatere informasjonen om laget

- -
- +
- -
- + -
- -
- +
- -
- - -
- -
- + -
- -
- +
- + + + +
- + + + + +
+ + + + +
+ + + + +
+

diff --git a/app/view/pages/teamtable/index.php b/app/view/pages/teamtable/index.php index 565989f..e2f6dbb 100644 --- a/app/view/pages/teamtable/index.php +++ b/app/view/pages/teamtable/index.php @@ -13,25 +13,19 @@ $value) - { - $team[$key] = htmlspecialchars($team[$key]); - } - echo ''; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; echo ''; } ?> diff --git a/public/teamtable/edit/add.php b/public/teamtable/edit/add.php deleted file mode 100644 index 19b44b9..0000000 --- a/public/teamtable/edit/add.php +++ /dev/null @@ -1,10 +0,0 @@ -model('Teamtable'); - -$id = $model->addEmptyTeam(); - -$app->session->flash('Opprettet ny lagmal, klikk her for å endre på den', 'success', TRUE); - -$app->redirect('index.php'); \ No newline at end of file diff --git a/public/teamtable/edit/create.php b/public/teamtable/edit/create.php new file mode 100644 index 0000000..cf8e0d6 --- /dev/null +++ b/public/teamtable/edit/create.php @@ -0,0 +1,16 @@ +model('Teamtable'); + +$team = $model->create( + new Team() +); + +$app->session->flash('Opprettet ny lagmal, klikk her for å endre på den', 'success', TRUE); + +$app->redirect('index.php'); \ No newline at end of file diff --git a/public/teamtable/edit/delete.php b/public/teamtable/edit/delete.php index 5f3107c..9069c50 100644 --- a/public/teamtable/edit/delete.php +++ b/public/teamtable/edit/delete.php @@ -1,47 +1,37 @@ -model('Teamtable'); -if (!isset($_GET['item'])) +// item is NULL if not set +if ($item === NULL) { - $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->session->flash('Kunne ikke slette lag: Mangler parameter.', 'danger'); $app->redirect('index.php'); } -// Check if ID is in teamtable -$currentTeam = $model->getTeamByID($id); -if (!$currentTeam) +$team = $model->get($item); +if (!$team) { - $app->session->flash("Kunne ikke slette lag: ID $id finnes ikke", "danger"); + // team does not exist + $app->session->flash('Kunne ikke slette lag: Lag eksisterer ikke', 'danger'); $app->redirect('index.php'); } -$sameAsTemplate = $model->isEqualEmptyTemplate($currentTeam); - -// Show confirmation page -if (isset($_GET['confirmation']) && $_GET['confirmation'] == 'true' && !$sameAsTemplate) +// show confirmation page +if ($confirm) { $app->view('template/header', ['title' => 'Bekreft sletting']); - $app->view('pages/teamtable/edit/delete', ['currentTeam' => $currentTeam]); + $app->view('pages/teamtable/edit/delete', ['team' => $team]); $app->view('template/footer'); die(); } -$model->deleteTeamByID($id); - -if ($sameAsTemplate) { - $app->session->flash("Slettet lagmal", "success"); -} else { - $app->session->flash("Slettet lag: {$currentTeam['LagNavn']}", "success"); -} - +// all is good, lets delete the team +$model->delete($team->id); +$app->session->flash("Slettet lag: {$team->name}", "success"); $app->redirect('index.php'); \ No newline at end of file diff --git a/public/teamtable/edit/index.php b/public/teamtable/edit/index.php index 34d4aa5..dbe082b 100644 --- a/public/teamtable/edit/index.php +++ b/public/teamtable/edit/index.php @@ -1,9 +1,8 @@ -model('Teamtable'); -$teams = $model->getTable(); +$teams = $model->getAll(); $app->view('template/header', ['title' => 'Endre lagtabell']); $app->view('pages/teamtable/edit/index', ["teams" => $teams]); diff --git a/public/teamtable/edit/update.php b/public/teamtable/edit/update.php index c39ca15..5cc1003 100644 --- a/public/teamtable/edit/update.php +++ b/public/teamtable/edit/update.php @@ -1,151 +1,25 @@ -model('Teamtable'); -if (!isset($_GET['item'])) +// item is NULL if not set +if ($item !== NULL) { - $app->session->flash('Kunne ikke endre lag: ID ikke definert som GET parameter', 'danger'); - $app->redirect('index.php'); -} -$id = $_GET['item']; - -// Id must be a number -if (!is_numeric($id)) -{ - $app->session->flash('Kunne ikke endre lag: ID må være tall', 'danger'); - $app->redirect('index.php'); -} - -// Check if team with supplied ID exists -$currentTeam = $model->getTeamByID($id); -if (!$currentTeam) -{ - $app->session->flash("Kunne ikke endre lag: ID $id finnes ikke", "danger"); - $app->redirect('index.php'); -} - -if ($_SERVER['REQUEST_METHOD'] === 'POST') -{ - // Check that all parameters are present - if (!isset( - $_POST['LagNavn'], - $_POST['Bedrift'], - $_POST['Kortnummer'], - $_POST['Lagleder'], - $_POST['Telefon'], - $_POST['Deltagere'], - $_POST['Runder'], - ) - ) + // check that team exists + $team = $model->get($item); + if (!$team) { - $app->session->flash("Kunne ikke endre lag: Ikke alle POST parametere er til stede!", "danger"); - $app->redirect('./'); - } - - $LagNavn = $_POST['LagNavn']; - $Bedrift = $_POST['Bedrift']; - $Kortnummer = $_POST['Kortnummer']; - $Lagleder = $_POST['Lagleder']; - $Telefon = $_POST['Telefon']; - $Deltagere = $_POST['Deltagere']; - $Runder = $_POST['Runder']; - - //====Validate Input====// - - $validationError = FALSE; - $template = $model->template; - - // LagNavn - if (!strlen($LagNavn)) { - $LagNavn = $template['LagNavn']; - } - if (strlen($LagNavn) > 32) { - $validationError = TRUE; - } - - // Bedrift - if (!strlen($Bedrift)) { - $Bedrift = $template['Bedrift']; - } - if (strlen($Bedrift) > 32) { - $validationError = TRUE; - } - - // Kortnummer - if (!strlen($Kortnummer)) { - $Kortnummer = $template['Kortnummer']; - } - if (strlen($Kortnummer) > 32) { - $validationError = TRUE; - } - - // Lagleder - if (!strlen($Lagleder)) { - $Lagleder = $template['Lagleder']; - } - if (strlen($Lagleder) > 32) { - $validationError = TRUE; - } - - // Telefon - if (!strlen($Telefon)) { - $Telefon = $template['Telefon']; - } - if (strlen((string) $Telefon) > 32) { - $validationError = TRUE; - } - - // Deltagere - if (!strlen($Deltagere)) { - $Deltagere = $template['Deltagere']; - } - if (strlen((string) $Deltagere) > 32) { - $validationError = TRUE; - } - - // Runder - if (!strlen($Runder)) { - $Runder = $template['Runder']; - } - if (strlen((string) $Runder) > 32) { - $validationError = TRUE; - } - - - if (!$validationError) { - if ( - $LagNavn == $currentTeam['LagNavn'] && - $Bedrift == $currentTeam['Bedrift'] && - $Kortnummer == $currentTeam['Kortnummer'] && - $Lagleder == $currentTeam['Lagleder'] && - $Telefon == $currentTeam['Telefon'] && - $Deltagere == $currentTeam['Deltagere'] && - $Runder == $currentTeam['Runder'] - ) - { - $app->session->flash('Fant ingen endringer for lag: '.$LagNavn); - } else { - // All is good! Lets update the team details - $model->updateTeamByID( - $id, - $LagNavn, - $Bedrift, - $Kortnummer, - $Lagleder, - $Telefon, - $Deltagere, - $Runder, - ); - - $app->session->flash('Lagret endringer for lag: '.$LagNavn, 'success'); - } - $app->redirect('index.php'); - } else { - $app->session->flash('Kunne ikke endre lag: Validerings feil!', 'danger'); + // team does not exist + $app->session->flash('Kunne ikke endre lag: Lag finnes ikke', 'danger'); + $app->redirect('index.php'); } } +// lets create a team $app->view('template/header', ['title' => 'Endre lagdetaljer']); -$app->view('pages/teamtable/edit/update', ["team" => $currentTeam]); +$app->view('pages/teamtable/edit/update', ["team" => new Team]); $app->view('template/footer'); \ No newline at end of file diff --git a/public/teamtable/index.php b/public/teamtable/index.php index 3767acc..9b79f12 100644 --- a/public/teamtable/index.php +++ b/public/teamtable/index.php @@ -3,7 +3,7 @@ $app = require '../../app/inc.php'; $model = $app->model('Teamtable'); -$teams = $model->getTable(); +$teams = $model->getAll(); $app->view('template/header', ['title' => 'Lagtabell']); $app->view('pages/teamtable/index', ["teams" => $teams]); diff --git a/public/testing.php b/public/testing.php deleted file mode 100644 index 6cee1da..0000000 --- a/public/testing.php +++ /dev/null @@ -1,6 +0,0 @@ -
{$i}{$team['LagNavn']}{$team['Bedrift']}{$team['Kortnummer']}{$team['Lagleder']}{$team['Telefon']}{$team['Deltagere']}{$team['Runder']}{$team['Bestetid']}" . $i . "" . htmlspecialchars($team->name) . "" . htmlspecialchars($team->company) . "" . htmlspecialchars($team->cardnumber) . "" . htmlspecialchars($team->leader) . "" . htmlspecialchars($team->phone) . "" . htmlspecialchars($team->participants) . "" . htmlspecialchars($team->rounds) . "" . "Ukjent" . ""; - echo "Slett ]"; - echo "Endre ]"; + echo "Slett ]"; + echo "Endre ]"; echo "
Bestetid
{$i}{$team['LagNavn']}{$team['Bedrift']}{$team['Kortnummer']}{$team['Lagleder']}{$team['Telefon']}{$team['Deltagere']}{$team['Runder']}{$team['Bestetid']}" . $i . "" . htmlspecialchars($team->name) . "" . htmlspecialchars($team->company) . "" . htmlspecialchars($team->cardnumber) . "" . htmlspecialchars($team->leader) . "" . htmlspecialchars($team->phone) . "" . htmlspecialchars($team->participants) . "" . htmlspecialchars($team->rounds) . "" . "Ukjent" . "