diff --git a/src/pvv/side/dbactivity.php b/src/pvv/side/dbactivity.php index b4590f1..7c7d58d 100644 --- a/src/pvv/side/dbactivity.php +++ b/src/pvv/side/dbactivity.php @@ -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']), diff --git a/src/pvv/side/simpleevent.php b/src/pvv/side/simpleevent.php index d9dc4f8..c2670dc 100644 --- a/src/pvv/side/simpleevent.php +++ b/src/pvv/side/simpleevent.php @@ -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; + } + } diff --git a/www/admin/aktiviteter/delete.php b/www/admin/aktiviteter/delete.php new file mode 100644 index 0000000..ba517c2 --- /dev/null +++ b/www/admin/aktiviteter/delete.php @@ -0,0 +1,13 @@ +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']); +?> \ No newline at end of file diff --git a/www/admin/aktiviteter/index.php b/www/admin/aktiviteter/index.php new file mode 100644 index 0000000..b401d06 --- /dev/null +++ b/www/admin/aktiviteter/index.php @@ -0,0 +1,64 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +$customActivity = new \pvv\side\DBActivity($pdo); +?> + + + + + + + + +
Aktivitets­administrasjon
+ +
+ +
+
+

Aktive aktiviteter

+

Gjentagende aktiviteter vises ikke

+ +
    + getAllEvents() as $event){ + $eventID = $event->getID(); + ?> +
  • +
    +
    +

    getName() . " (" . $eventID . ")"; ?>

    +

    getStart()->format("(Y-m-d H:i:s)") . " - " . $event->getStop()->format("(Y-m-d H:i:s)"); ?>

    +

    getDescription(), "

    \n

    "); ?>

    +
    + +
    + 🖊 + 🗑'; + ?> +
    +
    +
  • + +
+
+ +
+

Verktøy

+ Legg inn ny aktivitet +
+
+ +
\ No newline at end of file diff --git a/www/admin/index.php b/www/admin/index.php new file mode 100644 index 0000000..6da25f1 --- /dev/null +++ b/www/admin/index.php @@ -0,0 +1,23 @@ + + + + + + + +
Stor­-gutt­-leketøy
+ +
+ +
+

Verktøy

+ Aktiviteter/Hendelser + Prosjekter +
+ +
\ No newline at end of file diff --git a/www/css/admin.css b/www/css/admin.css new file mode 100644 index 0000000..8ab16a8 --- /dev/null +++ b/www/css/admin.css @@ -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; +} \ No newline at end of file diff --git a/www/css/ja.png b/www/css/ja.png new file mode 100644 index 0000000..cf725be Binary files /dev/null and b/www/css/ja.png differ