From 29a41f5ad8f21d0fd971e6a27c55f55cd2506867 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Fri, 10 Aug 2018 00:19:16 +0200 Subject: [PATCH] Fix admin event editor The date field was a lot of work, but it's a lot easier to use now. --- www/admin/aktiviteter/edit.php | 84 ++++++++++++++++++++------------ www/admin/aktiviteter/update.php | 31 ++++++++++-- www/css/style.css | 4 ++ 3 files changed, 85 insertions(+), 34 deletions(-) diff --git a/www/admin/aktiviteter/edit.php b/www/admin/aktiviteter/edit.php index 69435f9..4825cb9 100644 --- a/www/admin/aktiviteter/edit.php +++ b/www/admin/aktiviteter/edit.php @@ -14,6 +14,7 @@ $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!!!'; @@ -36,24 +37,31 @@ if(isset($_GET['id'])){ } $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"); +$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 = new \pvv\side\SimpleEvent( - 0, - 'Kul Hendelse', - $today, - $inOneHour, - 'PVV', - 'Norge et sted', - 'her skjer det noe altså' -); +$event; if($new == 0){ $event = $customActivity->getEventByID($eventID); } -?> +else { + $event = new \pvv\side\SimpleEvent( + 0, + '', + $today, + $inTwoHours, + '', + '', + '' + ); +} + +?> + + @@ -75,34 +83,50 @@ if($new == 0){

-
+

Tittel

- getName(). '" class="boxinput">' ?>
+
+ +
+
+

Arrangør

+
+
+
+

Sted

+
+
+

Beskrivelse

- + + +
-
-

Starttid (YYYY-MM-DD HH:MM:SS)

- getStart()->format('Y-m-d H:00:00') . '">
' ?> - -

Sluttid (YYYY-MM-DD HH:MM:SS)

- getStop()->format('Y-m-d H:00:00') . '">
' ?> - -

Arrangør

- getOrganiser(). '" class="boxinput">' ?>
- -

Sted

- getLocation(). '" class="boxinput">' ?>
+
+

Starttid


+ Måned:
+
+ Dag:
+
+ Klokkeslett:
+
+
+

Varighet


+ getStart()->diff($event->getStop()); ?> + Timer:
+
+ Minutter:
+
+
- getID() . '" />' ?> +

-
diff --git a/www/admin/aktiviteter/update.php b/www/admin/aktiviteter/update.php index 642f39d..8f5b161 100644 --- a/www/admin/aktiviteter/update.php +++ b/www/admin/aktiviteter/update.php @@ -18,7 +18,15 @@ if(!$userManager->hasGroup($uname, 'aktiviteter')){ exit(); } -if(!isset($_POST['title']) or !isset($_POST['desc']) or !isset($_POST['start']) or !isset($_POST['end']) or !isset($_POST['organiser']) or !isset($_POST['location'])){ +if((!isset($_POST['title'])) +or (!isset($_POST['desc'])) +or (!isset($_POST['organiser'])) +or (!isset($_POST['location'])) +or (!isset($_POST['start_mon'])) +or (!isset($_POST['start_day'])) +or (!isset($_POST['start_time'])) +or (!isset($_POST['lasts_hours'])) +or (!isset($_POST['lasts_minutes']))) { header('Location: ' . $_SERVER['HTTP_REFERER']); exit(); } @@ -30,13 +38,28 @@ if(isset($_POST['id'])){ $title = $_POST['title']; $desc = $_POST['desc']; -$start = $_POST['start']; -$stop = $_POST['end']; +//$start = $_POST['start']; +//$stop = $_POST['end']; $organiser = $_POST['organiser']; $location = $_POST['location']; +$date_part_start_mon = $_POST['start_mon']; +$date_part_start_day = $_POST['start_day']; +$date_part_start_time = $_POST['start_time']; +$date_part_lasts_hours = $_POST['lasts_hours']; +$date_part_lasts_minutes = $_POST['lasts_minutes']; + +$start = ($date_part_start_mon . "-" . $date_part_start_day . " " . $date_part_start_time); +if (sizeof(explode(":", $date_part_start_time))==2) { + $start .= ":00"; +} +print($start); + $start_date = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $start); -$stop_date = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $stop); +$stop_date = $start_date->add(new DateInterval('PT' . $date_part_lasts_hours . 'H' . $date_part_lasts_minutes . 'M')); +$stop = $stop_date->format('Y-m-d H:i:s'); +print($stop); + if ($start_date >= $stop_date) { echo 'Invalid dates. End date must come after the start date!'; exit(); diff --git a/www/css/style.css b/www/css/style.css index 7dcff4d..56c0f0a 100644 --- a/www/css/style.css +++ b/www/css/style.css @@ -260,6 +260,10 @@ article { margin-top: 0; } +.noborder { + border: none; +} + .btn { padding: .5em; border-radius: 4px;