Add calendar

This commit is contained in:
Peder Bergebakken Sundt 2017-10-07 21:25:51 +02:00
parent d89625558b
commit a2703988f0
2 changed files with 167 additions and 0 deletions

65
www/css/calendar.css Normal file
View File

@ -0,0 +1,65 @@
figure.calendar {
margin: 0;
padding:0;
}
.calendar ul {
list-style-type: none;
padding-left:0;
display: grid;
grid-template-columns: repeat(7, 4fr);
grid-template-rows: auto;
}
.calendar ul li {
margin: 2px;
border-style: solid;
border-color: #e0e0e0;
border-width: 1px;
border-radius: 5px;
background-color: #f3f3f3;
padding: 0.2em 0.5em;
padding-bottom: 0.5em;
min-height: 4.8em;
font-size: 0.8em;
color: #444;
transition: 0.1s;
}
.calendar ul li.header {
text-align: center;
min-height: 1em;
background-color: #fff;
border: None;
border-radius: 0;
margin: 0px;
padding: 0.2em 0;
font-size: 1em;
font-weight: 500;
color: #666;
}
.calendar ul li.outOfMonth {
opacity: 0;
}
.calendar ul li.active {
color: #222;
border-color: #456;
box-shadow: 0 0 3px #89f;
}
.calendar ul li:hover {
background-color: #fff;
}
.calendar ul li section::before {
content: "\26AB ";
color: #038;
}

102
www/kalender/index.php Normal file
View File

@ -0,0 +1,102 @@
<?php
date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
require __DIR__ . '/../../src/_autoload.php';
require __DIR__ . '/../../sql_config.php';
use \pvv\side\Agenda;
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$agenda = new \pvv\side\Agenda([
new \pvv\side\social\NerdepitsaActivity,
new \pvv\side\social\AnimekveldActivity,
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");
$days_before_the_first = (new DateTime($year."-".$month."-01"))->format("w") - 1;
if ($days_before_the_first==-1) {$days_before_the_first = 6;}
$day_of_month = ($month == date("m"))
? date("j")
: -1;
$days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
?><!DOCTYPE html>
<html lang="no">
<title>Aktivitetsverkstedet</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<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/calendar.css">
<header>Aktivitets&shy;verk&shy;stedet</header>
<main>
<article>
<h2 style="text-align:center;">Aktiviteter for <?= date('F Y', mktime(0, 0, 0, $month, 1, $year)) ?></h2>
<p><?php
$pmonth = $month-1;
$nmonth = $month+1;
$pyear=$year;
$nyear=$year;
if ($pmonth==0) {$pmonth=12; $pyear--;}
if ($nmonth==13) {$nmonth=1; $nyear++;}
?>
<a class="btn" href="../kalender?year=<?=$pyear?>&amp;month=<?=$pmonth?>">Forrige måned</a>
<a class="btn" style="float:right;" href="../kalender?year=<?=$nyear?>&amp;month=<?=$nmonth?>">Neste måned</a>
</p>
<figure class="calendar">
<ul>
<li class="header">Mandag
<li class="header">Tirsdag
<li class="header">Onsdag
<li class="header">Torsdag
<li class="header">Fredag
<li class="header">Lørdag
<li class="header">Søndag
<?php if ($days_before_the_first != 0) { ?>
<li class="outOfMonth" style="grid-column: 1/<?=$days_before_the_first+1?>;">
<?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 ?>
<?php } else { ?>
<li><?= $day ?>
<?php } ?>
<?php foreach($events as $event) { ?>
<section><?=$event->getName()?></section>
<?php } ?>
<?php } ?>
</ul>
</figure>
</article>
</main>
<nav><ul>
<li><a href="../">hjem</a></li>
<!--<li><a href="../prosjekt/">prosjekter</a></li>-->
<li class="active"><a href="../aktiviteter/">aktiviteter</a></li>
<li><a href="../kontakt">kontakt</a></li>
<li><a href="../pvv/">wiki</a></li>
</nav>