nettsiden/www/admin/aktiviteter/edit.php

115 lines
3.2 KiB
PHP
Raw Normal View History

2017-10-12 00:38:28 +02:00
<?php
date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_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];
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;
$defaultStart = $today->format("Y-m-d H:00:00");
$inOneHour = $today->add(new DateInterval('PT1H'));
$defaultEnd = $inOneHour->format("Y-m-d H:00:00");
$event = new \pvv\side\SimpleEvent(
0,
'Kul Hendelse',
$today,
$inOneHour,
'PVV',
'Norge et sted',
'her skjer det noe altså'
);
if($new == 0){
$event = $customActivity->getEventByID($eventID);
}
?>
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(); ?>
</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
2018-02-10 16:13:18 +01:00
<form action="update.php", method="post" class="gridsplit5050">
<div class="gridl">
<p class="subtitle">Tittel</p>
<?= '<input type="text" name="title" value="' . $event->getName(). '" class="boxinput">' ?><br>
2017-10-12 00:38:28 +02:00
2018-02-10 16:13:18 +01:00
<p class="subtitle">Beskrivelse</p>
<textarea name="desc" cols="40" rows="5" class="boxinput"><?= implode($event->getDescription(), "\n"); ?></textarea>
</div>
2017-10-12 00:38:28 +02:00
2018-02-10 16:13:18 +01:00
<div class="gridr noborder">
<p class="subtitle">Starttid (YYYY-MM-DD HH:MM:SS)</p>
<?= '<input name="start" type="text" class="boxinput" value="' . $event->getStart()->format('Y-m-d H:00:00') . '"><br>' ?>
2017-10-12 00:38:28 +02:00
2018-02-10 16:13:18 +01:00
<p class="subtitle">Sluttid (YYYY-MM-DD HH:MM:SS)</p>
<?= '<input name="end" type="text" class="boxinput" value="' . $event->getStop()->format('Y-m-d H:00:00') . '"><br>' ?>
2017-10-12 00:38:28 +02:00
2018-02-10 16:13:18 +01:00
<p class="subtitle">Organisert av</p>
<?= '<input type="text" name="organiser" value="' . $event->getOrganiser(). '" class="boxinput">' ?><br>
2017-10-12 00:38:28 +02:00
2018-02-10 16:13:18 +01:00
<p class="subtitle">Hvor?</p>
<?= '<input type="text" name="location" value="' . $event->getLocation(). '" class="boxinput">' ?><br>
</div>
2017-10-12 00:38:28 +02:00
2018-02-10 16:13:18 +01: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">
2017-10-12 00:38:28 +02:00
2018-02-10 16:13:18 +01:00
<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>