Beginning of the admin interface
This commit is contained in:
parent
7cd78ac3bb
commit
89c2a59fd6
|
@ -10,6 +10,29 @@ class DBActivity implements Activity {
|
|||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
public function getAllEvents() {
|
||||
$query = 'SELECT * FROM events ORDER BY id ASC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
|
||||
$events = [];
|
||||
foreach($statement->fetchAll() as $dbEvent){
|
||||
$event = new SimpleEvent(
|
||||
$dbEvent['id'],
|
||||
$dbEvent['name'],
|
||||
DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dbEvent['start']),
|
||||
DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dbEvent['stop']),
|
||||
$dbEvent['organiser'],
|
||||
$dbEvent['location'],
|
||||
$dbEvent['description']
|
||||
);
|
||||
$events[] = $event;
|
||||
}
|
||||
|
||||
return $events;
|
||||
}
|
||||
|
||||
|
||||
public function getNextEventFrom(DateTimeImmutable $date) {
|
||||
$query = 'SELECT name,start,stop,organiser,location,description FROM events WHERE start > :date ORDER BY start ASC LIMIT 1';
|
||||
return $this->retrieve($date, $query);
|
||||
|
@ -25,6 +48,7 @@ class DBActivity implements Activity {
|
|||
$stmt->execute(['date' => $date->format('Y-m-d H:i:s')]);
|
||||
if ($result = $stmt->fetch(PDO::FETCH_ASSOC)){
|
||||
$ev = new SimpleEvent(
|
||||
$result['id'],
|
||||
$result['name'],
|
||||
DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $result['start']),
|
||||
DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $result['stop']),
|
||||
|
|
|
@ -5,13 +5,19 @@ class SimpleEvent extends Event {
|
|||
|
||||
private $name, $start, $end, $org, $loc;
|
||||
|
||||
public function __construct($name,\DateTimeImmutable $start,\DateTimeImmutable $end,$org, $loc, $descr){
|
||||
public function __construct($id, $name,\DateTimeImmutable $start,\DateTimeImmutable $end,$org, $loc, $descr, $isDBEvent = false){
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->start = $start;
|
||||
$this->end = $end;
|
||||
$this->org = $org;
|
||||
$this->loc = $loc;
|
||||
$this->descr = explode("\n", $descr);
|
||||
$this->isDBEvent = $isDBEvent;
|
||||
}
|
||||
|
||||
public function getID(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getStart(){
|
||||
|
@ -46,4 +52,8 @@ class SimpleEvent extends Event {
|
|||
return $this->descr;
|
||||
}
|
||||
|
||||
public function isDBEvent() {
|
||||
return $this->isDBEvent;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$eventID = $_GET['id'];
|
||||
|
||||
$query = 'DELETE FROM events WHERE id=\'' . $eventID . '\'';
|
||||
$statement = $pdo->prepare($query);
|
||||
$statement->execute();
|
||||
|
||||
header('Location: ' . $_SERVER['HTTP_REFERER']);
|
||||
?>
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
ini_set('display_errors', '1');
|
||||
date_default_timezone_set('Europe/Oslo');
|
||||
setlocale(LC_ALL, 'no_NO');
|
||||
error_reporting(E_ALL);
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$customActivity = new \pvv\side\DBActivity($pdo);
|
||||
?>
|
||||
|
||||
<link rel="stylesheet" href="../../css/normalize.css">
|
||||
<link rel="stylesheet" href="../../css/style.css">
|
||||
<link rel="stylesheet" href="../../css/events.css">
|
||||
<link rel="stylesheet" href="../../css/admin.css">
|
||||
|
||||
<nav><ul>
|
||||
<li class="active"><a href="index.php">hjem</a></li>
|
||||
<li><a href="aktiviteter/">aktiviteter</a></li>
|
||||
<li><a href="kontakt">kontakt</a></li>
|
||||
<li><a href="pvv/">wiki</a></li>
|
||||
</nav>
|
||||
|
||||
<header class="admin">Aktivitets­administrasjon</header>
|
||||
|
||||
<main>
|
||||
|
||||
<article class="gridsplit">
|
||||
<div class="gridl">
|
||||
<h2 class="no-chin">Aktive aktiviteter</h2>
|
||||
<p class="subnote">Gjentagende aktiviteter vises ikke</p>
|
||||
|
||||
<ul class="event-list">
|
||||
<?php foreach($customActivity->getAllEvents() as $event){
|
||||
$eventID = $event->getID();
|
||||
?>
|
||||
<li>
|
||||
<div class="event admin">
|
||||
<div class="event-info">
|
||||
<h3 class="no-chin"><?= $event->getName() . " (" . $eventID . ")"; ?></h3>
|
||||
<p class="subnote"><?= $event->getStart()->format("(Y-m-d H:i:s)") . " - " . $event->getStop()->format("(Y-m-d H:i:s)"); ?></p>
|
||||
<p><?= implode($event->getDescription(), "</p>\n<p>"); ?></p>
|
||||
</div>
|
||||
|
||||
<div class="event-actions">
|
||||
<a href="/">🖊</a> <!-- emojis are for big boys -->
|
||||
<?php
|
||||
echo '<a href="./delete.php?id=' . $eventID . '" onclick="return confirm(\'Knallsikker? (ID: ' . $eventID . ')\');">🗑</a>';
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="gridr">
|
||||
<h2>Verktøy</h2>
|
||||
<a class="btn adminbtn" href="./ny">Legg inn ny aktivitet</a>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
</main>
|
|
@ -0,0 +1,23 @@
|
|||
<link rel="stylesheet" href="../css/normalize.css">
|
||||
<link rel="stylesheet" href="../css/style.css">
|
||||
<link rel="stylesheet" href="../css/events.css">
|
||||
<link rel="stylesheet" href="../css/admin.css">
|
||||
|
||||
<nav><ul>
|
||||
<li class="active"><a href="index.php">hjem</a></li>
|
||||
<li><a href="aktiviteter/">aktiviteter</a></li>
|
||||
<li><a href="kontakt">kontakt</a></li>
|
||||
<li><a href="pvv/">wiki</a></li>
|
||||
</nav>
|
||||
|
||||
<header class="admin">Stor­-gutt­-leketøy</header>
|
||||
|
||||
<main>
|
||||
|
||||
<article>
|
||||
<h2>Verktøy</h2>
|
||||
<a class="btn adminbtn" href="admin/aktiviteter/">Aktiviteter/Hendelser</a>
|
||||
<a class="btn adminbtn" href="admin/prosjekter/">Prosjekter</a>
|
||||
</article>
|
||||
|
||||
</main>
|
|
@ -0,0 +1,77 @@
|
|||
header.admin {
|
||||
margin-top: 3rem;
|
||||
height: 16rem;
|
||||
overflow: hidden;
|
||||
text-align: right;
|
||||
color: #fff;
|
||||
font-family: monospace;
|
||||
padding: 1rem;
|
||||
font-size: 4em;
|
||||
background: url('ja.png') no-repeat 1% 50% #024;
|
||||
background-size: contain;
|
||||
}
|
||||
|
||||
.event-list {
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.event {
|
||||
display: grid;
|
||||
grid-template-columns: 90% 10%;
|
||||
margin-bottom: 2em;
|
||||
padding-bottom: .5em;
|
||||
border-bottom: 1px solid gray;
|
||||
}
|
||||
|
||||
.event-info {
|
||||
grid-column: 1;
|
||||
}
|
||||
|
||||
.event-info h3 {
|
||||
padding: 0;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.event-info p {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.event-actions {
|
||||
grid-column: 2;
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.event-actions a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.no-chin {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.gridsplit {
|
||||
display: grid;
|
||||
grid-template-columns: 75% 25%;
|
||||
}
|
||||
|
||||
.gridl {
|
||||
height: 100%;
|
||||
grid-column: 1;
|
||||
}
|
||||
|
||||
.gridr {
|
||||
height: 100%;
|
||||
padding: 0 1em;
|
||||
margin-left: 1em;
|
||||
border-left: 1px solid gray;
|
||||
grid-column: 2;
|
||||
}
|
||||
|
||||
.subnote {
|
||||
margin-top: 0;
|
||||
color: gray;
|
||||
font-size: .7em;
|
||||
font-style: italic;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.3 MiB |
Reference in New Issue