Make days clickable in kalender

This commit is contained in:
Peder Bergebakken Sundt 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()) { ?>

View File

@ -12,6 +12,14 @@ figure.calendar {
grid-template-rows: auto;
}
.calendar ul a {
text-decoration: none;
color: inherit;
}
.calendar ul a div {
min-height: 4.8em;
}
.calendar ul li {
margin: 2px;
@ -28,7 +36,6 @@ figure.calendar {
font-size: 0.8em;
color: #444;
transition: 0.1s;
}
.calendar ul li.header {

View File

@ -72,19 +72,24 @@ $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
<?php } ?>
<?php for ($day=1; $day <= $days_in_month; $day++) { ?>
<?php $events = $agenda->getEventsBetween(
new DateTimeImmutable("$year-$month-$day 00:00:00"),
new DateTimeImmutable("$year-$month-$day 23:59:59")); ?>
<?php if ($day==$day_of_month) { ?>
<li class="active"><?= $day ?>.
<li class="active">
<?php } else { ?>
<li><?= $day ?>.
<li>
<?php } ?>
<?php if (sizeof($events)!=0) { ?>
<a href="../aktiviteter/?<?="year=$year&amp;month=$month&amp;day=$day"?>"><div>
<?= $day ?>.
<?php foreach($events as $event) { ?>
<section><?=$event->getName()?></section>
<?php } ?>
</div></a>
<?php } else { ?>
<?= $day ?>.
<?php } ?>
<?php } ?>
</ul>