nettsiden/www/admin/aktiviteter/edit.php

139 lines
4.0 KiB
PHP
Raw Normal View History

2017-10-12 00:38:28 +02:00
<?php
date_default_timezone_set('Europe/Oslo');
2018-02-10 18:08:53 +01:00
setlocale(LC_ALL, 'nb_NO');
require __DIR__ . '/../../../inc/navbar.php';
2017-10-12 00:38:28 +02:00
require __DIR__ . '/../../../src/_autoload.php';
require __DIR__ . '/../../../sql_config.php';
2017-10-12 00:38:28 +02:00
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userManager = new \pvv\admin\UserManager($pdo);
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
$as = new SimpleSAML_Auth_Simple('default-sp');
$as->requireAuth();
$attrs = $as->getAttributes();
$uname = $attrs['uid'][0];
$name = $attrs['cn'][0];
if(!$userManager->hasGroup($uname, 'aktiviteter')){
echo 'Her har du ikke lov\'t\'å\'værra!!!';
exit();
}
2017-10-12 00:38:28 +02:00
$customActivity = new \pvv\side\DBActivity($pdo);
$new = 0;
if(isset($_GET['new'])){
$new = $_GET['new'];
}
$eventID = 0;
if(isset($_GET['id'])){
$eventID = $_GET['id'];
}else if($new == 0){
echo "\nID not set";
exit();
}
$today = new DateTimeImmutable;
$today = $today->setTime(18, 15);
$defaultStart = $today->format("Y-m-d H:15:00");
$inTwoHours = $today->add(new DateInterval('PT1H45M'));
$defaultEnd = $inTwoHours->format("Y-m-d H:00:00");
$event;
2017-10-12 00:38:28 +02:00
if($new == 0){
$event = $customActivity->getEventByID($eventID);
}
else {
$event = new \pvv\side\SimpleEvent(
0,
'',
$today,
$inTwoHours,
'',
'',
''
);
}
2017-10-12 00:38:28 +02:00
?>
<!DOCTYPE html>
<html lang="no" locale="no">
2018-02-10 16:13:18 +01:00
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../../css/normalize.css">
<link rel="stylesheet" href="../../css/style.css">
<link rel="stylesheet" href="../../css/nav.css">
<link rel="stylesheet" href="../../css/events.css">
<link rel="stylesheet" href="../../css/admin.css">
</head>
2017-10-12 00:38:28 +02:00
2018-02-10 16:13:18 +01:00
<body>
<nav>
<?php echo navbar(3, 'admin'); ?>
<?php echo loginbar(null, $pdo); ?>
2018-02-10 16:13:18 +01:00
</nav>
2017-10-12 00:38:28 +02:00
2018-02-10 16:13:18 +01:00
<main>
<h2>Aktivietsadministrasjon</h2>
<hr class="ruler">
2017-10-12 00:38:28 +02:00
2018-02-10 16:13:18 +01:00
<h2><?= ($new == 1 ? "Ny hendelse" : "Rediger hendelse"); ?></h2>
2017-10-12 00:38:28 +02:00
<form action="update.php", method="post" class="gridsplit fullwidth_inputs">
2018-02-10 16:13:18 +01:00
<div class="gridl">
<p class="subtitle">Tittel</p>
<input type="text" name="title" value="<?= $event->getName() ?>" class="boxinput" required placeholder="En kul hendelse"><br>
<div class="gridsplit5050">
<div class="gridl">
<p class="subtitle">Arrangør</p>
<input type="text" name="organiser" value="<?= $event->getOrganiser() ?>" class="boxinput" required placeholder="<?= $name ?>"><br>
</div>
<div class="gridr noborder">
<p class="subtitle">Sted</p>
<input type="text" name="location" value="<?= $event->getLocation() ?>" class="boxinput" required placeholder="Terminalrommet"><br>
</div>
</div>
2017-10-12 00:38:28 +02:00
<p class="subtitle">Beskrivelse (<i>markdown</i>)</p>
<textarea name="desc" rows="8" class="boxinput" placeholder="Beskrivese" required><?= implode($event->getDescription(), "\n"); ?></textarea>
2018-02-10 16:13:18 +01:00
</div>
2017-10-12 00:38:28 +02:00
<div class="gridr" style="line-height: 1.3em;">
<h4>Starttid</h4><br>
<i>Måned:</i><br>
<input name="start_mon" type="month" class="boxinput" required value="<?= $event->getStart()->format('Y-m') ?>"><br>
<i>Dag:</i><br>
<input name="start_day" type="number" min="1" max="31" required class="boxinput" value="<?= $event->getStart()->format('d') ?>"><br>
<i>Klokkeslett:</i><br>
<input name="start_time" type="time" class="boxinput" required value="<?= $event->getStart()->format('H:i:s') ?>"><br>
<br>
<h4>Varighet</h4><br>
<?php $diff = $event->getStart()->diff($event->getStop()); ?>
<i>Timer:</i><br>
<input name="lasts_hours" type="number" min="0" class="boxinput" required value="<?= $diff->h ?>"><br>
<i>Minutter:</i><br>
<input name="lasts_minutes" type="number" min="0" max="59" class="boxinput" required value="<?= $diff->i ?>"><br>
2018-02-10 16:13:18 +01:00
</div>
2017-10-12 00:38:28 +02:00
<input type="hidden" name="id" value="<?= $event->getID() ?>" />
2017-10-12 00:38:28 +02:00
2018-02-10 16:13:18 +01:00
<div class="allgrids" style="margin-top: 2em;">
<hr class="ruler">
<input type="submit" class="btn" value="Lagre"></a>
</div>
</form>
2017-10-12 00:38:28 +02:00
2018-02-10 16:13:18 +01:00
2017-10-12 00:38:28 +02:00
2018-02-10 16:13:18 +01:00
<p>
</main>
</body>