Make days clickable in kalender

This commit is contained in:
2017-10-07 23:03:53 +02:00
parent 34e09667e5
commit aef3488c80
3 changed files with 46 additions and 17 deletions

View File

@@ -5,7 +5,6 @@ require __DIR__ . '/../../src/_autoload.php';
require __DIR__ . '/../../sql_config.php';
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
use \pvv\side\Agenda;
$agenda = new \pvv\side\Agenda([
new \pvv\side\social\NerdepitsaActivity,
@@ -13,6 +12,17 @@ $agenda = new \pvv\side\Agenda([
new \pvv\side\social\BrettspillActivity,
new \pvv\side\DBActivity($pdo),
]);
$year = (isset($_GET['year']))
? $_GET['year']
: date("Y");
$month = (isset($_GET['month']))
? $_GET['month']
: date("m");
$day = (isset($_GET['day']))
? $_GET['day']
: -1;
?><!DOCTYPE html>
<html lang="no">
<title>Aktivitetverkstedet</title>
@@ -26,9 +36,16 @@ $agenda = new \pvv\side\Agenda([
<main>
<?php $limit = 0; ?>
<?php foreach($agenda->getNextOfEach(new \DateTimeImmutable) as $event) { ?>
<?php
$events = ($day==-1)
? $agenda->getNextOfEach(new \DateTimeImmutable)
: $agenda->getEventsBetween(
new DateTimeImmutable("$year-$month-$day 00:00:00"),
new DateTimeImmutable("$year-$month-$day 23:59:59"));
$limit = 0;
foreach($events as $event) {
?>
<article>
<h2>
<?php if ($event->getImageURL()) { ?>